kogiidena | 94c0fa5 | 2006-09-27 14:53:35 +0900 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/boards/landisk/setup.c |
| 3 | * |
| 4 | * Copyright (C) 2002 Paul Mundt |
| 5 | * |
| 6 | * May be copied or modified under the terms of the GNU General Public |
| 7 | * License. See linux/COPYING for more information. |
| 8 | * |
| 9 | * Setup code for an unknown machine (internal peripherials only) |
| 10 | */ |
| 11 | /* |
| 12 | * linux/arch/sh/kernel/setup_landisk.c |
| 13 | * |
| 14 | * Copyright (C) 2000 Kazumoto Kojima |
| 15 | * |
| 16 | * I-O DATA Device, Inc. LANDISK Support. |
| 17 | * |
| 18 | * Modified for LANDISK by |
| 19 | * Atom Create Engineering Co., Ltd. 2002. |
| 20 | */ |
| 21 | /* |
| 22 | * modifed by kogiidena |
| 23 | * 2005.09.16 |
| 24 | */ |
| 25 | |
| 26 | #include <linux/config.h> |
| 27 | #include <linux/init.h> |
| 28 | #include <linux/irq.h> |
| 29 | #include <linux/pm.h> |
| 30 | |
| 31 | #include <linux/hdreg.h> |
| 32 | #include <linux/ide.h> |
| 33 | #include <linux/pci.h> |
| 34 | |
| 35 | #include <asm/machvec.h> |
| 36 | #include <asm/rtc.h> |
| 37 | #include <asm/machvec_init.h> |
| 38 | #include <asm/io.h> |
| 39 | #include <asm/landisk/iodata_landisk.h> |
| 40 | #include <asm/landisk/io.h> |
| 41 | |
| 42 | #include <linux/mm.h> |
| 43 | #include <linux/vmalloc.h> |
| 44 | |
| 45 | extern void (*board_time_init) (void); |
| 46 | void landisk_time_init(void); |
| 47 | extern void init_landisk_IRQ(void); |
| 48 | |
| 49 | int landisk_ledparam; |
| 50 | int landisk_buzzerparam; |
| 51 | int landisk_arch; |
| 52 | |
| 53 | /* defined in mm/ioremap.c */ |
| 54 | extern void *p3_ioremap(unsigned long phys_addr, unsigned long size, |
| 55 | unsigned long flags); |
| 56 | |
| 57 | /* |
| 58 | * Initialize the board |
| 59 | */ |
| 60 | |
| 61 | const char *get_system_type(void) |
| 62 | { |
| 63 | return "LANDISK"; |
| 64 | } |
| 65 | |
| 66 | static void landisk_power_off(void) |
| 67 | { |
| 68 | ctrl_outb(0x01, PA_SHUTDOWN); |
| 69 | } |
| 70 | |
| 71 | void check_usl5p(void) |
| 72 | { |
| 73 | volatile unsigned char *p = (volatile unsigned char *)PA_LED; |
| 74 | unsigned char tmp1, tmp2; |
| 75 | tmp1 = *p; |
| 76 | *p = 0x40; |
| 77 | tmp2 = *p; |
| 78 | *p = tmp1; |
| 79 | landisk_arch = (tmp2 == 0x40) ? 1 : 0; |
| 80 | if (landisk_arch == 1) { /* arch == usl-5p */ |
| 81 | landisk_ledparam = 0x00000380; |
| 82 | landisk_ledparam |= (tmp1 & 0x07c); |
| 83 | } else { /* arch == landisk */ |
| 84 | landisk_ledparam = 0x02000180; |
| 85 | landisk_ledparam |= 0x04; |
| 86 | } |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | void __init platform_setup(void) |
| 91 | { |
| 92 | |
| 93 | landisk_buzzerparam = 0; |
| 94 | check_usl5p(); |
| 95 | |
| 96 | printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n"); |
| 97 | board_time_init = landisk_time_init; |
| 98 | pm_power_off = landisk_power_off; |
| 99 | |
| 100 | } |
| 101 | |
| 102 | void *area5_io_base; |
| 103 | void *area6_io_base; |
| 104 | |
| 105 | int __init cf_init(void) |
| 106 | { |
| 107 | pgprot_t prot; |
| 108 | unsigned long paddrbase, psize; |
| 109 | |
| 110 | /* open I/O area window */ |
| 111 | paddrbase = virt_to_phys((void *)PA_AREA5_IO); |
| 112 | psize = PAGE_SIZE; |
| 113 | prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16); |
| 114 | area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot); |
| 115 | if (!area5_io_base) { |
| 116 | printk("allocate_cf_area : can't open CF I/O window!\n"); |
| 117 | return -ENOMEM; |
| 118 | } |
| 119 | |
| 120 | paddrbase = virt_to_phys((void *)PA_AREA6_IO); |
| 121 | psize = PAGE_SIZE; |
| 122 | prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16); |
| 123 | area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot); |
| 124 | if (!area6_io_base) { |
| 125 | printk("allocate_cf_area : can't open HDD I/O window!\n"); |
| 126 | return -ENOMEM; |
| 127 | } |
| 128 | |
| 129 | printk(KERN_INFO "Allocate Area5/6 success.\n"); |
| 130 | |
| 131 | /* XXX : do we need attribute and common-memory area also? */ |
| 132 | |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | __initcall(cf_init); |
| 137 | |
| 138 | #include <linux/sched.h> |
| 139 | |
| 140 | /* Cycle the LED's in the clasic knightrider/Sun pattern */ |
| 141 | |
| 142 | void heartbeat_landisk(void) |
| 143 | { |
| 144 | static unsigned int cnt = 0, blink = 0x00, period = 25; |
| 145 | volatile unsigned char *p = (volatile unsigned char *)PA_LED; |
| 146 | char data; |
| 147 | |
| 148 | if ((landisk_ledparam & 0x080) == 0) { |
| 149 | return; |
| 150 | } |
| 151 | cnt += 1; |
| 152 | if (cnt < period) { |
| 153 | return; |
| 154 | } |
| 155 | cnt = 0; |
| 156 | blink++; |
| 157 | |
| 158 | data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0; |
| 159 | data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0; |
| 160 | data |= landisk_ledparam; |
| 161 | |
| 162 | /* buzzer */ |
| 163 | if (landisk_buzzerparam & 0x1) { |
| 164 | data |= 0x80; |
| 165 | } else { |
| 166 | data &= 0x7f; |
| 167 | } |
| 168 | *p = data; |
| 169 | |
| 170 | if (((landisk_ledparam & 0x007f7f00) == 0) |
| 171 | && (landisk_buzzerparam == 0)) { |
| 172 | landisk_ledparam &= (~0x0080); |
| 173 | } |
| 174 | landisk_buzzerparam >>= 1; |
| 175 | } |
| 176 | |
| 177 | /* |
| 178 | * The Machine Vector |
| 179 | */ |
| 180 | |
| 181 | struct sh_machine_vector mv_landisk __initmv = { |
| 182 | .mv_nr_irqs = 72, |
| 183 | .mv_inb = landisk_inb, |
| 184 | .mv_inw = landisk_inw, |
| 185 | .mv_inl = landisk_inl, |
| 186 | .mv_outb = landisk_outb, |
| 187 | .mv_outw = landisk_outw, |
| 188 | .mv_outl = landisk_outl, |
| 189 | .mv_inb_p = landisk_inb_p, |
| 190 | .mv_inw_p = landisk_inw, |
| 191 | .mv_inl_p = landisk_inl, |
| 192 | .mv_outb_p = landisk_outb_p, |
| 193 | .mv_outw_p = landisk_outw, |
| 194 | .mv_outl_p = landisk_outl, |
| 195 | .mv_insb = landisk_insb, |
| 196 | .mv_insw = landisk_insw, |
| 197 | .mv_insl = landisk_insl, |
| 198 | .mv_outsb = landisk_outsb, |
| 199 | .mv_outsw = landisk_outsw, |
| 200 | .mv_outsl = landisk_outsl, |
| 201 | .mv_readb = landisk_readb, |
| 202 | .mv_readw = landisk_readw, |
| 203 | .mv_readl = landisk_readl, |
| 204 | .mv_writeb = landisk_writeb, |
| 205 | .mv_writew = landisk_writew, |
| 206 | .mv_writel = landisk_writel, |
| 207 | .mv_ioremap = landisk_ioremap, |
| 208 | .mv_iounmap = landisk_iounmap, |
| 209 | .mv_isa_port2addr = landisk_isa_port2addr, |
| 210 | .mv_init_irq = init_landisk_IRQ, |
| 211 | |
| 212 | #ifdef CONFIG_HEARTBEAT |
| 213 | .mv_heartbeat = heartbeat_landisk, |
| 214 | #endif |
| 215 | |
| 216 | }; |
| 217 | |
| 218 | ALIAS_MV(landisk) |