config.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. #include <linux/types.h>
  2. #include <linux/kernel.h>
  3. #include <linux/mm.h>
  4. #include <linux/tty.h>
  5. #include <linux/console.h>
  6. #include <linux/rtc.h>
  7. #include <linux/vt_kern.h>
  8. #include <linux/interrupt.h>
  9. #include <asm/setup.h>
  10. #include <asm/bootinfo.h>
  11. #include <asm/system.h>
  12. #include <asm/pgtable.h>
  13. #include <asm/apollohw.h>
  14. #include <asm/irq.h>
  15. #include <asm/rtc.h>
  16. #include <asm/machdep.h>
  17. u_long sio01_physaddr;
  18. u_long sio23_physaddr;
  19. u_long rtc_physaddr;
  20. u_long pica_physaddr;
  21. u_long picb_physaddr;
  22. u_long cpuctrl_physaddr;
  23. u_long timer_physaddr;
  24. u_long apollo_model;
  25. extern void dn_sched_init(irq_handler_t handler);
  26. extern void dn_init_IRQ(void);
  27. extern unsigned long dn_gettimeoffset(void);
  28. extern int dn_dummy_hwclk(int, struct rtc_time *);
  29. extern int dn_dummy_set_clock_mmss(unsigned long);
  30. extern void dn_dummy_reset(void);
  31. extern void dn_dummy_waitbut(void);
  32. extern struct fb_info *dn_fb_init(long *);
  33. extern void dn_dummy_debug_init(void);
  34. extern irqreturn_t dn_process_int(int irq, struct pt_regs *fp);
  35. #ifdef CONFIG_HEARTBEAT
  36. static void dn_heartbeat(int on);
  37. #endif
  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)"
  46. };
  47. int apollo_parse_bootinfo(const struct bi_record *record) {
  48. int unknown = 0;
  49. const unsigned long *data = record->data;
  50. switch(record->tag) {
  51. case BI_APOLLO_MODEL:
  52. apollo_model=*data;
  53. break;
  54. default:
  55. unknown=1;
  56. }
  57. return unknown;
  58. }
  59. void dn_setup_model(void) {
  60. printk("Apollo hardware found: ");
  61. printk("[%s]\n", apollo_models[apollo_model - APOLLO_DN3000]);
  62. switch(apollo_model) {
  63. case APOLLO_UNKNOWN:
  64. panic("Unknown apollo model");
  65. break;
  66. case APOLLO_DN3000:
  67. case APOLLO_DN3010:
  68. sio01_physaddr=SAU8_SIO01_PHYSADDR;
  69. rtc_physaddr=SAU8_RTC_PHYSADDR;
  70. pica_physaddr=SAU8_PICA;
  71. picb_physaddr=SAU8_PICB;
  72. cpuctrl_physaddr=SAU8_CPUCTRL;
  73. timer_physaddr=SAU8_TIMER;
  74. break;
  75. case APOLLO_DN4000:
  76. sio01_physaddr=SAU7_SIO01_PHYSADDR;
  77. sio23_physaddr=SAU7_SIO23_PHYSADDR;
  78. rtc_physaddr=SAU7_RTC_PHYSADDR;
  79. pica_physaddr=SAU7_PICA;
  80. picb_physaddr=SAU7_PICB;
  81. cpuctrl_physaddr=SAU7_CPUCTRL;
  82. timer_physaddr=SAU7_TIMER;
  83. break;
  84. case APOLLO_DN4500:
  85. panic("Apollo model not yet supported");
  86. break;
  87. case APOLLO_DN3500:
  88. sio01_physaddr=SAU7_SIO01_PHYSADDR;
  89. sio23_physaddr=SAU7_SIO23_PHYSADDR;
  90. rtc_physaddr=SAU7_RTC_PHYSADDR;
  91. pica_physaddr=SAU7_PICA;
  92. picb_physaddr=SAU7_PICB;
  93. cpuctrl_physaddr=SAU7_CPUCTRL;
  94. timer_physaddr=SAU7_TIMER;
  95. break;
  96. default:
  97. panic("Undefined apollo model");
  98. break;
  99. }
  100. }
  101. int dn_serial_console_wait_key(struct console *co) {
  102. while(!(sio01.srb_csrb & 1))
  103. barrier();
  104. return sio01.rhrb_thrb;
  105. }
  106. void dn_serial_console_write (struct console *co, const char *str,unsigned int count)
  107. {
  108. while(count--) {
  109. if (*str == '\n') {
  110. sio01.rhrb_thrb = (unsigned char)'\r';
  111. while (!(sio01.srb_csrb & 0x4))
  112. ;
  113. }
  114. sio01.rhrb_thrb = (unsigned char)*str++;
  115. while (!(sio01.srb_csrb & 0x4))
  116. ;
  117. }
  118. }
  119. void dn_serial_print (const char *str)
  120. {
  121. while (*str) {
  122. if (*str == '\n') {
  123. sio01.rhrb_thrb = (unsigned char)'\r';
  124. while (!(sio01.srb_csrb & 0x4))
  125. ;
  126. }
  127. sio01.rhrb_thrb = (unsigned char)*str++;
  128. while (!(sio01.srb_csrb & 0x4))
  129. ;
  130. }
  131. }
  132. void config_apollo(void) {
  133. int i;
  134. dn_setup_model();
  135. mach_sched_init=dn_sched_init; /* */
  136. mach_init_IRQ=dn_init_IRQ;
  137. mach_gettimeoffset = dn_gettimeoffset;
  138. mach_max_dma_address = 0xffffffff;
  139. mach_hwclk = dn_dummy_hwclk; /* */
  140. mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */
  141. mach_reset = dn_dummy_reset; /* */
  142. #ifdef CONFIG_HEARTBEAT
  143. mach_heartbeat = dn_heartbeat;
  144. #endif
  145. mach_get_model = dn_get_model;
  146. cpuctrl=0xaa00;
  147. /* clear DMA translation table */
  148. for(i=0;i<0x400;i++)
  149. addr_xlat_map[i]=0;
  150. }
  151. irqreturn_t dn_timer_int(int irq, void *dev_id)
  152. {
  153. irq_handler_t timer_handler = dev_id;
  154. volatile unsigned char x;
  155. timer_handler(irq, dev_id);
  156. x=*(volatile unsigned char *)(timer+3);
  157. x=*(volatile unsigned char *)(timer+5);
  158. return IRQ_HANDLED;
  159. }
  160. void dn_sched_init(irq_handler_t timer_routine)
  161. {
  162. /* program timer 1 */
  163. *(volatile unsigned char *)(timer+3)=0x01;
  164. *(volatile unsigned char *)(timer+1)=0x40;
  165. *(volatile unsigned char *)(timer+5)=0x09;
  166. *(volatile unsigned char *)(timer+7)=0xc4;
  167. /* enable IRQ of PIC B */
  168. *(volatile unsigned char *)(pica+1)&=(~8);
  169. #if 0
  170. printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3));
  171. printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3));
  172. #endif
  173. request_irq(IRQ_APOLLO, dn_timer_int, 0, "time", timer_routine);
  174. }
  175. unsigned long dn_gettimeoffset(void) {
  176. return 0xdeadbeef;
  177. }
  178. int dn_dummy_hwclk(int op, struct rtc_time *t) {
  179. if(!op) { /* read */
  180. t->tm_sec=rtc->second;
  181. t->tm_min=rtc->minute;
  182. t->tm_hour=rtc->hours;
  183. t->tm_mday=rtc->day_of_month;
  184. t->tm_wday=rtc->day_of_week;
  185. t->tm_mon=rtc->month;
  186. t->tm_year=rtc->year;
  187. } else {
  188. rtc->second=t->tm_sec;
  189. rtc->minute=t->tm_min;
  190. rtc->hours=t->tm_hour;
  191. rtc->day_of_month=t->tm_mday;
  192. if(t->tm_wday!=-1)
  193. rtc->day_of_week=t->tm_wday;
  194. rtc->month=t->tm_mon;
  195. rtc->year=t->tm_year;
  196. }
  197. return 0;
  198. }
  199. int dn_dummy_set_clock_mmss(unsigned long nowtime) {
  200. printk("set_clock_mmss\n");
  201. return 0;
  202. }
  203. void dn_dummy_reset(void) {
  204. dn_serial_print("The end !\n");
  205. for(;;);
  206. }
  207. void dn_dummy_waitbut(void) {
  208. dn_serial_print("waitbut\n");
  209. }
  210. static void dn_get_model(char *model)
  211. {
  212. strcpy(model, "Apollo ");
  213. if (apollo_model >= APOLLO_DN3000 && apollo_model <= APOLLO_DN4500)
  214. strcat(model, apollo_models[apollo_model - APOLLO_DN3000]);
  215. }
  216. #ifdef CONFIG_HEARTBEAT
  217. static int dn_cpuctrl=0xff00;
  218. static void dn_heartbeat(int on) {
  219. if(on) {
  220. dn_cpuctrl&=~0x100;
  221. cpuctrl=dn_cpuctrl;
  222. }
  223. else {
  224. dn_cpuctrl&=~0x100;
  225. dn_cpuctrl|=0x100;
  226. cpuctrl=dn_cpuctrl;
  227. }
  228. }
  229. #endif