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