]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - arch/sh/boards/landisk/setup.c
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-serial
[mirror_ubuntu-hirsute-kernel.git] / arch / sh / boards / landisk / setup.c
CommitLineData
94c0fa52 1/*
2 * arch/sh/boards/landisk/setup.c
3 *
d7cdc9e8 4 * Copyright (C) 2000 Kazumoto Kojima
94c0fa52 5 * Copyright (C) 2002 Paul Mundt
6 *
94c0fa52 7 * I-O DATA Device, Inc. LANDISK Support.
8 *
9 * Modified for LANDISK by
10 * Atom Create Engineering Co., Ltd. 2002.
d7cdc9e8 11 *
94c0fa52 12 * modifed by kogiidena
13 * 2005.09.16
d7cdc9e8
PM
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
94c0fa52 18 */
94c0fa52 19#include <linux/init.h>
94c0fa52 20#include <linux/pm.h>
d7cdc9e8 21#include <linux/mm.h>
94c0fa52 22#include <asm/machvec.h>
23#include <asm/rtc.h>
94c0fa52 24#include <asm/landisk/iodata_landisk.h>
d7cdc9e8 25#include <asm/io.h>
94c0fa52 26
94c0fa52 27void landisk_time_init(void);
d7cdc9e8 28void init_landisk_IRQ(void);
94c0fa52 29
30int landisk_ledparam;
31int landisk_buzzerparam;
32int landisk_arch;
33
d7cdc9e8
PM
34/* cycle the led's in the clasic knightrider/sun pattern */
35static void heartbeat_landisk(void)
94c0fa52 36{
37 static unsigned int cnt = 0, blink = 0x00, period = 25;
d7cdc9e8 38 volatile u8 *p = (volatile u8 *)PA_LED;
94c0fa52 39 char data;
40
d7cdc9e8 41 if ((landisk_ledparam & 0x080) == 0)
94c0fa52 42 return;
d7cdc9e8 43
94c0fa52 44 cnt += 1;
d7cdc9e8
PM
45
46 if (cnt < period)
94c0fa52 47 return;
d7cdc9e8 48
94c0fa52 49 cnt = 0;
50 blink++;
51
52 data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0;
53 data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0;
54 data |= landisk_ledparam;
55
56 /* buzzer */
57 if (landisk_buzzerparam & 0x1) {
58 data |= 0x80;
59 } else {
60 data &= 0x7f;
61 }
62 *p = data;
63
d7cdc9e8
PM
64 if (((landisk_ledparam & 0x007f7f00) == 0) &&
65 (landisk_buzzerparam == 0))
94c0fa52 66 landisk_ledparam &= (~0x0080);
d7cdc9e8 67
94c0fa52 68 landisk_buzzerparam >>= 1;
69}
70
d7cdc9e8
PM
71static void landisk_power_off(void)
72{
73 ctrl_outb(0x01, PA_SHUTDOWN);
74}
75
76static void check_usl5p(void)
77{
78 volatile u8 *p = (volatile u8 *)PA_LED;
79 u8 tmp1, tmp2;
80
81 tmp1 = *p;
82 *p = 0x40;
83 tmp2 = *p;
84 *p = tmp1;
85
86 landisk_arch = (tmp2 == 0x40);
87 if (landisk_arch == 1) {
88 /* arch == usl-5p */
89 landisk_ledparam = 0x00000380;
90 landisk_ledparam |= (tmp1 & 0x07c);
91 } else {
92 /* arch == landisk */
93 landisk_ledparam = 0x02000180;
94 landisk_ledparam |= 0x04;
95 }
96}
97
d7cdc9e8
PM
98void *area5_io_base;
99void *area6_io_base;
100
101static int __init landisk_cf_init(void)
102{
103 pgprot_t prot;
104 unsigned long paddrbase, psize;
105
106 /* open I/O area window */
107 paddrbase = virt_to_phys((void *)PA_AREA5_IO);
108 psize = PAGE_SIZE;
109 prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
110 area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
111 if (!area5_io_base) {
112 printk("allocate_cf_area : can't open CF I/O window!\n");
113 return -ENOMEM;
114 }
115
116 paddrbase = virt_to_phys((void *)PA_AREA6_IO);
117 psize = PAGE_SIZE;
118 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
119 area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
120 if (!area6_io_base) {
121 printk("allocate_cf_area : can't open HDD I/O window!\n");
122 return -ENOMEM;
123 }
124
125 printk(KERN_INFO "Allocate Area5/6 success.\n");
126
127 /* XXX : do we need attribute and common-memory area also? */
128
129 return 0;
130}
131
2c7834a6
PM
132static void __init landisk_setup(char **cmdline_p)
133{
134 device_initcall(landisk_cf_init);
135
136 landisk_buzzerparam = 0;
137 check_usl5p();
138
139 printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
140
141 board_time_init = landisk_time_init;
142 pm_power_off = landisk_power_off;
143}
144
145/*
146 * The Machine Vector
147 */
148struct sh_machine_vector mv_landisk __initmv = {
149 .mv_name = "LANDISK",
150 .mv_setup = landisk_setup,
151 .mv_nr_irqs = 72,
152 .mv_inb = landisk_inb,
153 .mv_inw = landisk_inw,
154 .mv_inl = landisk_inl,
155 .mv_outb = landisk_outb,
156 .mv_outw = landisk_outw,
157 .mv_outl = landisk_outl,
158 .mv_inb_p = landisk_inb_p,
159 .mv_inw_p = landisk_inw,
160 .mv_inl_p = landisk_inl,
161 .mv_outb_p = landisk_outb_p,
162 .mv_outw_p = landisk_outw,
163 .mv_outl_p = landisk_outl,
164 .mv_insb = landisk_insb,
165 .mv_insw = landisk_insw,
166 .mv_insl = landisk_insl,
167 .mv_outsb = landisk_outsb,
168 .mv_outsw = landisk_outsw,
169 .mv_outsl = landisk_outsl,
170 .mv_ioport_map = landisk_ioport_map,
171 .mv_init_irq = init_landisk_IRQ,
172#ifdef CONFIG_HEARTBEAT
173 .mv_heartbeat = heartbeat_landisk,
174#endif
175};
176ALIAS_MV(landisk)