blob: 3a795cfb1eda702ca9f9c487e4c5bc99be37390d [file] [log] [blame]
kogiidena94c0fa52006-09-27 14:53:35 +09001/*
2 * arch/sh/boards/landisk/setup.c
3 *
Paul Mundtd7cdc9e2006-09-27 15:16:42 +09004 * Copyright (C) 2000 Kazumoto Kojima
kogiidena94c0fa52006-09-27 14:53:35 +09005 * Copyright (C) 2002 Paul Mundt
6 *
kogiidena94c0fa52006-09-27 14:53:35 +09007 * I-O DATA Device, Inc. LANDISK Support.
8 *
9 * Modified for LANDISK by
10 * Atom Create Engineering Co., Ltd. 2002.
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090011 *
kogiidena94c0fa52006-09-27 14:53:35 +090012 * modifed by kogiidena
13 * 2005.09.16
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090014 *
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.
kogiidena94c0fa52006-09-27 14:53:35 +090018 */
kogiidena94c0fa52006-09-27 14:53:35 +090019#include <linux/config.h>
20#include <linux/init.h>
kogiidena94c0fa52006-09-27 14:53:35 +090021#include <linux/pm.h>
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090022#include <linux/mm.h>
kogiidena94c0fa52006-09-27 14:53:35 +090023#include <asm/machvec.h>
24#include <asm/rtc.h>
kogiidena94c0fa52006-09-27 14:53:35 +090025#include <asm/landisk/iodata_landisk.h>
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090026#include <asm/io.h>
kogiidena94c0fa52006-09-27 14:53:35 +090027
kogiidena94c0fa52006-09-27 14:53:35 +090028void landisk_time_init(void);
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090029void init_landisk_IRQ(void);
kogiidena94c0fa52006-09-27 14:53:35 +090030
31int landisk_ledparam;
32int landisk_buzzerparam;
33int landisk_arch;
34
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090035/* cycle the led's in the clasic knightrider/sun pattern */
36static void heartbeat_landisk(void)
37{
38 static unsigned int cnt = 0, blink = 0x00, period = 25;
39 volatile u8 *p = (volatile u8 *)PA_LED;
40 char data;
41
42 if ((landisk_ledparam & 0x080) == 0)
43 return;
44
45 cnt += 1;
46
47 if (cnt < period)
48 return;
49
50 cnt = 0;
51 blink++;
52
53 data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0;
54 data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0;
55 data |= landisk_ledparam;
56
57 /* buzzer */
58 if (landisk_buzzerparam & 0x1) {
59 data |= 0x80;
60 } else {
61 data &= 0x7f;
62 }
63 *p = data;
64
65 if (((landisk_ledparam & 0x007f7f00) == 0) &&
66 (landisk_buzzerparam == 0))
67 landisk_ledparam &= (~0x0080);
68
69 landisk_buzzerparam >>= 1;
70}
kogiidena94c0fa52006-09-27 14:53:35 +090071
72/*
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090073 * The Machine Vector
kogiidena94c0fa52006-09-27 14:53:35 +090074 */
Paul Mundtd7cdc9e2006-09-27 15:16:42 +090075struct sh_machine_vector mv_landisk __initmv = {
76 .mv_nr_irqs = 72,
77 .mv_inb = landisk_inb,
78 .mv_inw = landisk_inw,
79 .mv_inl = landisk_inl,
80 .mv_outb = landisk_outb,
81 .mv_outw = landisk_outw,
82 .mv_outl = landisk_outl,
83 .mv_inb_p = landisk_inb_p,
84 .mv_inw_p = landisk_inw,
85 .mv_inl_p = landisk_inl,
86 .mv_outb_p = landisk_outb_p,
87 .mv_outw_p = landisk_outw,
88 .mv_outl_p = landisk_outl,
89 .mv_insb = landisk_insb,
90 .mv_insw = landisk_insw,
91 .mv_insl = landisk_insl,
92 .mv_outsb = landisk_outsb,
93 .mv_outsw = landisk_outsw,
94 .mv_outsl = landisk_outsl,
95 .mv_ioport_map = landisk_ioport_map,
96 .mv_init_irq = init_landisk_IRQ,
97#ifdef CONFIG_HEARTBEAT
98 .mv_heartbeat = heartbeat_landisk,
99#endif
100};
101ALIAS_MV(landisk)
kogiidena94c0fa52006-09-27 14:53:35 +0900102
103const char *get_system_type(void)
104{
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900105 return "LANDISK";
kogiidena94c0fa52006-09-27 14:53:35 +0900106}
107
108static void landisk_power_off(void)
109{
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900110 ctrl_outb(0x01, PA_SHUTDOWN);
kogiidena94c0fa52006-09-27 14:53:35 +0900111}
112
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900113static void check_usl5p(void)
kogiidena94c0fa52006-09-27 14:53:35 +0900114{
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900115 volatile u8 *p = (volatile u8 *)PA_LED;
116 u8 tmp1, tmp2;
117
118 tmp1 = *p;
119 *p = 0x40;
120 tmp2 = *p;
121 *p = tmp1;
122
123 landisk_arch = (tmp2 == 0x40);
124 if (landisk_arch == 1) {
125 /* arch == usl-5p */
126 landisk_ledparam = 0x00000380;
127 landisk_ledparam |= (tmp1 & 0x07c);
128 } else {
129 /* arch == landisk */
130 landisk_ledparam = 0x02000180;
131 landisk_ledparam |= 0x04;
132 }
kogiidena94c0fa52006-09-27 14:53:35 +0900133}
134
135void __init platform_setup(void)
136{
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900137 landisk_buzzerparam = 0;
138 check_usl5p();
kogiidena94c0fa52006-09-27 14:53:35 +0900139
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900140 printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
141 board_time_init = landisk_time_init;
142 pm_power_off = landisk_power_off;
kogiidena94c0fa52006-09-27 14:53:35 +0900143}
144
145void *area5_io_base;
146void *area6_io_base;
147
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900148static int __init landisk_cf_init(void)
kogiidena94c0fa52006-09-27 14:53:35 +0900149{
150 pgprot_t prot;
151 unsigned long paddrbase, psize;
152
153 /* open I/O area window */
154 paddrbase = virt_to_phys((void *)PA_AREA5_IO);
155 psize = PAGE_SIZE;
156 prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
157 area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
158 if (!area5_io_base) {
159 printk("allocate_cf_area : can't open CF I/O window!\n");
160 return -ENOMEM;
161 }
162
163 paddrbase = virt_to_phys((void *)PA_AREA6_IO);
164 psize = PAGE_SIZE;
165 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
166 area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
167 if (!area6_io_base) {
168 printk("allocate_cf_area : can't open HDD I/O window!\n");
169 return -ENOMEM;
170 }
171
172 printk(KERN_INFO "Allocate Area5/6 success.\n");
173
174 /* XXX : do we need attribute and common-memory area also? */
175
176 return 0;
177}
178
Paul Mundtd7cdc9e2006-09-27 15:16:42 +0900179__initcall(landisk_cf_init);