config.c 6.0 KB

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