config.c 6.1 KB

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