1 #include <linux/init.h>
2 #include <linux/types.h>
3 #include <linux/kernel.h>
6 #include <linux/console.h>
8 #include <linux/vt_kern.h>
9 #include <linux/interrupt.h>
11 #include <asm/setup.h>
12 #include <asm/bootinfo.h>
13 #include <asm/bootinfo-apollo.h>
14 #include <asm/byteorder.h>
15 #include <asm/pgtable.h>
16 #include <asm/apollohw.h>
18 #include <asm/machdep.h>
20 u_long sio01_physaddr;
21 u_long sio23_physaddr;
25 u_long cpuctrl_physaddr;
26 u_long timer_physaddr;
29 extern void dn_sched_init(irq_handler_t handler);
30 extern void dn_init_IRQ(void);
31 extern u32 dn_gettimeoffset(void);
32 extern int dn_dummy_hwclk(int, struct rtc_time *);
33 extern int dn_dummy_set_clock_mmss(unsigned long);
34 extern void dn_dummy_reset(void);
35 #ifdef CONFIG_HEARTBEAT
36 static void dn_heartbeat(int on);
38 static irqreturn_t dn_timer_int(int irq,void *);
39 static void dn_get_model(char *model);
40 static const char *apollo_models[] = {
41 [APOLLO_DN3000-APOLLO_DN3000] = "DN3000 (Otter)",
42 [APOLLO_DN3010-APOLLO_DN3000] = "DN3010 (Otter)",
43 [APOLLO_DN3500-APOLLO_DN3000] = "DN3500 (Cougar II)",
44 [APOLLO_DN4000-APOLLO_DN3000] = "DN4000 (Mink)",
45 [APOLLO_DN4500-APOLLO_DN3000] = "DN4500 (Roadrunner)"
48 int __init apollo_parse_bootinfo(const struct bi_record *record)
51 const void *data = record->data;
53 switch (be16_to_cpu(record->tag)) {
55 apollo_model = be32_to_cpup(data);
65 static void __init dn_setup_model(void)
67 pr_info("Apollo hardware found: [%s]\n",
68 apollo_models[apollo_model - APOLLO_DN3000]);
70 switch(apollo_model) {
72 panic("Unknown apollo model");
76 sio01_physaddr=SAU8_SIO01_PHYSADDR;
77 rtc_physaddr=SAU8_RTC_PHYSADDR;
78 pica_physaddr=SAU8_PICA;
79 picb_physaddr=SAU8_PICB;
80 cpuctrl_physaddr=SAU8_CPUCTRL;
81 timer_physaddr=SAU8_TIMER;
84 sio01_physaddr=SAU7_SIO01_PHYSADDR;
85 sio23_physaddr=SAU7_SIO23_PHYSADDR;
86 rtc_physaddr=SAU7_RTC_PHYSADDR;
87 pica_physaddr=SAU7_PICA;
88 picb_physaddr=SAU7_PICB;
89 cpuctrl_physaddr=SAU7_CPUCTRL;
90 timer_physaddr=SAU7_TIMER;
93 panic("Apollo model not yet supported");
96 sio01_physaddr=SAU7_SIO01_PHYSADDR;
97 sio23_physaddr=SAU7_SIO23_PHYSADDR;
98 rtc_physaddr=SAU7_RTC_PHYSADDR;
99 pica_physaddr=SAU7_PICA;
100 picb_physaddr=SAU7_PICB;
101 cpuctrl_physaddr=SAU7_CPUCTRL;
102 timer_physaddr=SAU7_TIMER;
105 panic("Undefined apollo model");
112 int dn_serial_console_wait_key(struct console *co) {
114 while(!(sio01.srb_csrb & 1))
116 return sio01.rhrb_thrb;
119 void dn_serial_console_write (struct console *co, const char *str,unsigned int count)
123 sio01.rhrb_thrb = (unsigned char)'\r';
124 while (!(sio01.srb_csrb & 0x4))
127 sio01.rhrb_thrb = (unsigned char)*str++;
128 while (!(sio01.srb_csrb & 0x4))
133 void dn_serial_print (const char *str)
137 sio01.rhrb_thrb = (unsigned char)'\r';
138 while (!(sio01.srb_csrb & 0x4))
141 sio01.rhrb_thrb = (unsigned char)*str++;
142 while (!(sio01.srb_csrb & 0x4))
147 void __init config_apollo(void)
153 mach_sched_init=dn_sched_init; /* */
154 mach_init_IRQ=dn_init_IRQ;
155 arch_gettimeoffset = dn_gettimeoffset;
156 mach_max_dma_address = 0xffffffff;
157 mach_hwclk = dn_dummy_hwclk; /* */
158 mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */
159 mach_reset = dn_dummy_reset; /* */
160 #ifdef CONFIG_HEARTBEAT
161 mach_heartbeat = dn_heartbeat;
163 mach_get_model = dn_get_model;
167 /* clear DMA translation table */
173 irqreturn_t dn_timer_int(int irq, void *dev_id)
175 irq_handler_t timer_handler = dev_id;
177 volatile unsigned char x;
179 timer_handler(irq, dev_id);
181 x = *(volatile unsigned char *)(apollo_timer + 3);
182 x = *(volatile unsigned char *)(apollo_timer + 5);
187 void dn_sched_init(irq_handler_t timer_routine)
189 /* program timer 1 */
190 *(volatile unsigned char *)(apollo_timer + 3) = 0x01;
191 *(volatile unsigned char *)(apollo_timer + 1) = 0x40;
192 *(volatile unsigned char *)(apollo_timer + 5) = 0x09;
193 *(volatile unsigned char *)(apollo_timer + 7) = 0xc4;
195 /* enable IRQ of PIC B */
196 *(volatile unsigned char *)(pica+1)&=(~8);
199 pr_info("*(0x10803) %02x\n",
200 *(volatile unsigned char *)(apollo_timer + 0x3));
201 pr_info("*(0x10803) %02x\n",
202 *(volatile unsigned char *)(apollo_timer + 0x3));
205 if (request_irq(IRQ_APOLLO, dn_timer_int, 0, "time", timer_routine))
206 pr_err("Couldn't register timer interrupt\n");
209 u32 dn_gettimeoffset(void)
214 int dn_dummy_hwclk(int op, struct rtc_time *t) {
218 t->tm_sec=rtc->second;
219 t->tm_min=rtc->minute;
220 t->tm_hour=rtc->hours;
221 t->tm_mday=rtc->day_of_month;
222 t->tm_wday=rtc->day_of_week;
223 t->tm_mon=rtc->month;
224 t->tm_year=rtc->year;
226 rtc->second=t->tm_sec;
227 rtc->minute=t->tm_min;
228 rtc->hours=t->tm_hour;
229 rtc->day_of_month=t->tm_mday;
231 rtc->day_of_week=t->tm_wday;
232 rtc->month=t->tm_mon;
233 rtc->year=t->tm_year;
240 int dn_dummy_set_clock_mmss(unsigned long nowtime)
242 pr_info("set_clock_mmss\n");
246 void dn_dummy_reset(void) {
248 dn_serial_print("The end !\n");
254 void dn_dummy_waitbut(void) {
256 dn_serial_print("waitbut\n");
260 static void dn_get_model(char *model)
262 strcpy(model, "Apollo ");
263 if (apollo_model >= APOLLO_DN3000 && apollo_model <= APOLLO_DN4500)
264 strcat(model, apollo_models[apollo_model - APOLLO_DN3000]);
267 #ifdef CONFIG_HEARTBEAT
268 static int dn_cpuctrl=0xff00;
270 static void dn_heartbeat(int on) {