1 #include <linux/config.h>
2 #include <linux/types.h>
3 #include <linux/kernel.h>
7 #include <linux/console.h>
10 #include <asm/bootinfo.h>
11 #include <asm/system.h>
12 #include <asm/pgtable.h>
13 #include <asm/apollohw.h>
15 #include <asm/machdep.h>
17 u_long sio01_physaddr;
18 u_long sio23_physaddr;
22 u_long cpuctrl_physaddr;
23 u_long timer_physaddr;
26 extern void dn_sched_init(void (*handler)(int,void *,struct pt_regs *));
27 extern int dn_keyb_init(void);
28 extern int dn_dummy_kbdrate(struct kbd_repeat *);
29 extern void dn_init_IRQ(void);
30 extern int dn_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id);
31 extern void dn_free_irq(unsigned int irq, void *dev_id);
32 extern void dn_enable_irq(unsigned int);
33 extern void dn_disable_irq(unsigned int);
34 extern int dn_get_irq_list(char *);
35 extern unsigned long dn_gettimeoffset(void);
36 extern void dn_gettod(int *, int *, int *, int *, int *, int *);
37 extern int dn_dummy_hwclk(int, struct hwclk_time *);
38 extern int dn_dummy_set_clock_mmss(unsigned long);
39 extern void dn_mksound(unsigned int count, unsigned int ticks);
40 extern void dn_dummy_reset(void);
41 extern void dn_dummy_waitbut(void);
42 extern struct fb_info *dn_fb_init(long *);
43 extern void dn_dummy_debug_init(void);
44 extern void (*kd_mksound)(unsigned int, unsigned int);
45 extern void dn_dummy_video_setup(char *,int *);
46 extern void dn_process_int(int irq, struct pt_regs *fp);
47 #ifdef CONFIG_HEARTBEAT
48 static void dn_heartbeat(int on);
50 static void dn_timer_int(int irq,void *, struct pt_regs *);
51 static void (*sched_timer_handler)(int, void *, struct pt_regs *)=NULL;
52 static void dn_get_model(char *model);
53 static int dn_cpuctrl=0xff00;
54 static const char *apollo_models[] = {
59 "DN4500 (Roadrunner)" };
61 int apollo_parse_bootinfo(const struct bi_record *record) {
64 const unsigned long *data = record->data;
78 void dn_setup_model(void) {
81 printk("Apollo hardware found: ");
82 printk("[%s]\n", apollo_models[apollo_model - APOLLO_DN3000]);
84 switch(apollo_model) {
86 panic("Unknown apollo model");
90 sio01_physaddr=SAU8_SIO01_PHYSADDR;
91 rtc_physaddr=SAU8_RTC_PHYSADDR;
92 pica_physaddr=SAU8_PICA;
93 picb_physaddr=SAU8_PICB;
94 cpuctrl_physaddr=SAU8_CPUCTRL;
95 timer_physaddr=SAU8_TIMER;
98 sio01_physaddr=SAU7_SIO01_PHYSADDR;
99 sio23_physaddr=SAU7_SIO23_PHYSADDR;
100 rtc_physaddr=SAU7_RTC_PHYSADDR;
101 pica_physaddr=SAU7_PICA;
102 picb_physaddr=SAU7_PICB;
103 cpuctrl_physaddr=SAU7_CPUCTRL;
104 timer_physaddr=SAU7_TIMER;
107 panic("Apollo model not yet supported");
110 sio01_physaddr=SAU7_SIO01_PHYSADDR;
111 sio23_physaddr=SAU7_SIO23_PHYSADDR;
112 rtc_physaddr=SAU7_RTC_PHYSADDR;
113 pica_physaddr=SAU7_PICA;
114 picb_physaddr=SAU7_PICB;
115 cpuctrl_physaddr=SAU7_CPUCTRL;
116 timer_physaddr=SAU7_TIMER;
119 panic("Undefined apollo model");
126 int dn_serial_console_wait_key(struct console *co) {
128 while(!(sio01.srb_csrb & 1))
130 return sio01.rhrb_thrb;
133 void dn_serial_console_write (struct console *co, const char *str,unsigned int count)
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 dn_serial_print (const char *str)
151 sio01.rhrb_thrb = (unsigned char)'\r';
152 while (!(sio01.srb_csrb & 0x4))
155 sio01.rhrb_thrb = (unsigned char)*str++;
156 while (!(sio01.srb_csrb & 0x4))
161 void config_apollo(void) {
167 mach_sched_init=dn_sched_init; /* */
168 mach_keyb_init=dn_keyb_init;
169 mach_kbdrate=dn_dummy_kbdrate;
170 mach_init_IRQ=dn_init_IRQ;
171 mach_default_handler=NULL;
172 mach_request_irq = dn_request_irq;
173 mach_free_irq = dn_free_irq;
174 enable_irq = dn_enable_irq;
175 disable_irq = dn_disable_irq;
176 mach_get_irq_list = dn_get_irq_list;
177 mach_gettimeoffset = dn_gettimeoffset;
178 mach_gettod = dn_gettod; /* */
179 mach_max_dma_address = 0xffffffff;
180 mach_hwclk = dn_dummy_hwclk; /* */
181 mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */
182 mach_process_int = dn_process_int;
183 #ifdef CONFIG_BLK_DEV_FD
184 mach_floppy_init = dn_dummy_floppy_init;
185 mach_floppy_setup = dn_dummy_floppy_setup;
187 mach_reset = dn_dummy_reset; /* */
188 #ifdef CONFIG_DUMMY_CONSOLE
189 conswitchp = &dummy_con;
191 kd_mksound = dn_mksound;
192 #ifdef CONFIG_HEARTBEAT
193 mach_heartbeat = dn_heartbeat;
195 mach_get_model = dn_get_model;
199 /* clear DMA translation table */
205 void dn_timer_int(int irq, void *dev_id, struct pt_regs *fp) {
207 volatile unsigned char x;
209 sched_timer_handler(irq,dev_id,fp);
211 x=*(volatile unsigned char *)(timer+3);
212 x=*(volatile unsigned char *)(timer+5);
216 void dn_sched_init(void (*timer_routine)(int, void *, struct pt_regs *)) {
218 /* program timer 1 */
219 *(volatile unsigned char *)(timer+3)=0x01;
220 *(volatile unsigned char *)(timer+1)=0x40;
221 *(volatile unsigned char *)(timer+5)=0x09;
222 *(volatile unsigned char *)(timer+7)=0xc4;
224 /* enable IRQ of PIC B */
225 *(volatile unsigned char *)(pica+1)&=(~8);
228 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3));
229 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3));
232 sched_timer_handler=timer_routine;
233 request_irq(0,dn_timer_int,0,NULL,NULL);
237 unsigned long dn_gettimeoffset(void) {
243 void dn_gettod(int *yearp, int *monp, int *dayp,
244 int *hourp, int *minp, int *secp) {
248 *dayp=rtc->day_of_month;
253 printk("gettod: %d %d %d %d %d %d\n",*yearp,*monp,*dayp,*hourp,*minp,*secp);
257 int dn_dummy_hwclk(int op, struct hwclk_time *t) {
264 t->day=rtc->day_of_month;
265 t->wday=rtc->day_of_week;
272 rtc->day_of_month=t->day;
274 rtc->day_of_week=t->wday;
283 int dn_dummy_set_clock_mmss(unsigned long nowtime) {
285 printk("set_clock_mmss\n");
291 void dn_dummy_reset(void) {
293 dn_serial_print("The end !\n");
299 void dn_dummy_waitbut(void) {
301 dn_serial_print("waitbut\n");
305 static void dn_get_model(char *model)
307 strcpy(model, "Apollo ");
308 if (apollo_model >= APOLLO_DN3000 && apollo_model <= APOLLO_DN4500)
309 strcat(model, apollo_models[apollo_model - APOLLO_DN3000]);
312 #ifdef CONFIG_HEARTBEAT
313 static void dn_heartbeat(int on) {