config.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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/rtc.h>
  18. #include <asm/machdep.h>
  19. u_long sio01_physaddr;
  20. u_long sio23_physaddr;
  21. u_long rtc_physaddr;
  22. u_long pica_physaddr;
  23. u_long picb_physaddr;
  24. u_long cpuctrl_physaddr;
  25. u_long timer_physaddr;
  26. u_long apollo_model;
  27. extern void dn_sched_init(irq_handler_t handler);
  28. extern void dn_init_IRQ(void);
  29. extern u32 dn_gettimeoffset(void);
  30. extern int dn_dummy_hwclk(int, struct rtc_time *);
  31. extern int dn_dummy_set_clock_mmss(unsigned long);
  32. extern void dn_dummy_reset(void);
  33. #ifdef CONFIG_HEARTBEAT
  34. static void dn_heartbeat(int on);
  35. #endif
  36. static irqreturn_t dn_timer_int(int irq,void *);
  37. static void dn_get_model(char *model);
  38. static const char *apollo_models[] = {
  39. [APOLLO_DN3000-APOLLO_DN3000] = "DN3000 (Otter)",
  40. [APOLLO_DN3010-APOLLO_DN3000] = "DN3010 (Otter)",
  41. [APOLLO_DN3500-APOLLO_DN3000] = "DN3500 (Cougar II)",
  42. [APOLLO_DN4000-APOLLO_DN3000] = "DN4000 (Mink)",
  43. [APOLLO_DN4500-APOLLO_DN3000] = "DN4500 (Roadrunner)"
  44. };
  45. int __init apollo_parse_bootinfo(const struct bi_record *record)
  46. {
  47. int unknown = 0;
  48. const void *data = record->data;
  49. switch (be16_to_cpu(record->tag)) {
  50. case BI_APOLLO_MODEL:
  51. apollo_model = be32_to_cpup(data);
  52. break;
  53. default:
  54. unknown=1;
  55. }
  56. return unknown;
  57. }
  58. static void __init dn_setup_model(void)
  59. {
  60. pr_info("Apollo hardware found: [%s]\n",
  61. 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 __init config_apollo(void)
  133. {
  134. int i;
  135. dn_setup_model();
  136. mach_sched_init=dn_sched_init; /* */
  137. mach_init_IRQ=dn_init_IRQ;
  138. arch_gettimeoffset = dn_gettimeoffset;
  139. mach_max_dma_address = 0xffffffff;
  140. mach_hwclk = dn_dummy_hwclk; /* */
  141. mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */
  142. mach_reset = dn_dummy_reset; /* */
  143. #ifdef CONFIG_HEARTBEAT
  144. mach_heartbeat = dn_heartbeat;
  145. #endif
  146. mach_get_model = dn_get_model;
  147. cpuctrl=0xaa00;
  148. /* clear DMA translation table */
  149. for(i=0;i<0x400;i++)
  150. addr_xlat_map[i]=0;
  151. }
  152. irqreturn_t dn_timer_int(int irq, void *dev_id)
  153. {
  154. irq_handler_t timer_handler = dev_id;
  155. volatile unsigned char x;
  156. timer_handler(irq, dev_id);
  157. x = *(volatile unsigned char *)(apollo_timer + 3);
  158. x = *(volatile unsigned char *)(apollo_timer + 5);
  159. return IRQ_HANDLED;
  160. }
  161. void dn_sched_init(irq_handler_t timer_routine)
  162. {
  163. /* program timer 1 */
  164. *(volatile unsigned char *)(apollo_timer + 3) = 0x01;
  165. *(volatile unsigned char *)(apollo_timer + 1) = 0x40;
  166. *(volatile unsigned char *)(apollo_timer + 5) = 0x09;
  167. *(volatile unsigned char *)(apollo_timer + 7) = 0xc4;
  168. /* enable IRQ of PIC B */
  169. *(volatile unsigned char *)(pica+1)&=(~8);
  170. #if 0
  171. pr_info("*(0x10803) %02x\n",
  172. *(volatile unsigned char *)(apollo_timer + 0x3));
  173. pr_info("*(0x10803) %02x\n",
  174. *(volatile unsigned char *)(apollo_timer + 0x3));
  175. #endif
  176. if (request_irq(IRQ_APOLLO, dn_timer_int, 0, "time", timer_routine))
  177. pr_err("Couldn't register timer interrupt\n");
  178. }
  179. u32 dn_gettimeoffset(void)
  180. {
  181. return 0xdeadbeef;
  182. }
  183. int dn_dummy_hwclk(int op, struct rtc_time *t) {
  184. if(!op) { /* read */
  185. t->tm_sec=rtc->second;
  186. t->tm_min=rtc->minute;
  187. t->tm_hour=rtc->hours;
  188. t->tm_mday=rtc->day_of_month;
  189. t->tm_wday=rtc->day_of_week;
  190. t->tm_mon=rtc->month;
  191. t->tm_year=rtc->year;
  192. } else {
  193. rtc->second=t->tm_sec;
  194. rtc->minute=t->tm_min;
  195. rtc->hours=t->tm_hour;
  196. rtc->day_of_month=t->tm_mday;
  197. if(t->tm_wday!=-1)
  198. rtc->day_of_week=t->tm_wday;
  199. rtc->month=t->tm_mon;
  200. rtc->year=t->tm_year;
  201. }
  202. return 0;
  203. }
  204. int dn_dummy_set_clock_mmss(unsigned long nowtime)
  205. {
  206. pr_info("set_clock_mmss\n");
  207. return 0;
  208. }
  209. void dn_dummy_reset(void) {
  210. dn_serial_print("The end !\n");
  211. for(;;);
  212. }
  213. void dn_dummy_waitbut(void) {
  214. dn_serial_print("waitbut\n");
  215. }
  216. static void dn_get_model(char *model)
  217. {
  218. strcpy(model, "Apollo ");
  219. if (apollo_model >= APOLLO_DN3000 && apollo_model <= APOLLO_DN4500)
  220. strcat(model, apollo_models[apollo_model - APOLLO_DN3000]);
  221. }
  222. #ifdef CONFIG_HEARTBEAT
  223. static int dn_cpuctrl=0xff00;
  224. static void dn_heartbeat(int on) {
  225. if(on) {
  226. dn_cpuctrl&=~0x100;
  227. cpuctrl=dn_cpuctrl;
  228. }
  229. else {
  230. dn_cpuctrl&=~0x100;
  231. dn_cpuctrl|=0x100;
  232. cpuctrl=dn_cpuctrl;
  233. }
  234. }
  235. #endif