setup_m32700ut.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. /*
  2. * linux/arch/m32r/kernel/setup_m32700ut.c
  3. *
  4. * Setup routines for Renesas M32700UT Board
  5. *
  6. * Copyright (c) 2002 Hiroyuki Kondo, Hirokazu Takata,
  7. * Hitoshi Yamamoto, Takeo Takahashi
  8. *
  9. * This file is subject to the terms and conditions of the GNU General
  10. * Public License. See the file "COPYING" in the main directory of this
  11. * archive for more details.
  12. */
  13. #include <linux/config.h>
  14. #include <linux/irq.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/device.h>
  18. #include <asm/system.h>
  19. #include <asm/m32r.h>
  20. #include <asm/io.h>
  21. /*
  22. * M32700 Interrupt Control Unit (Level 1)
  23. */
  24. #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long)))
  25. #ifndef CONFIG_SMP
  26. typedef struct {
  27. unsigned long icucr; /* ICU Control Register */
  28. } icu_data_t;
  29. #endif /* CONFIG_SMP */
  30. static icu_data_t icu_data[M32700UT_NUM_CPU_IRQ];
  31. static void disable_m32700ut_irq(unsigned int irq)
  32. {
  33. unsigned long port, data;
  34. port = irq2port(irq);
  35. data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7;
  36. outl(data, port);
  37. }
  38. static void enable_m32700ut_irq(unsigned int irq)
  39. {
  40. unsigned long port, data;
  41. port = irq2port(irq);
  42. data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6;
  43. outl(data, port);
  44. }
  45. static void mask_and_ack_m32700ut(unsigned int irq)
  46. {
  47. disable_m32700ut_irq(irq);
  48. }
  49. static void end_m32700ut_irq(unsigned int irq)
  50. {
  51. enable_m32700ut_irq(irq);
  52. }
  53. static unsigned int startup_m32700ut_irq(unsigned int irq)
  54. {
  55. enable_m32700ut_irq(irq);
  56. return (0);
  57. }
  58. static void shutdown_m32700ut_irq(unsigned int irq)
  59. {
  60. unsigned long port;
  61. port = irq2port(irq);
  62. outl(M32R_ICUCR_ILEVEL7, port);
  63. }
  64. static struct hw_interrupt_type m32700ut_irq_type =
  65. {
  66. .typename = "M32700UT-IRQ",
  67. .startup = startup_m32700ut_irq,
  68. .shutdown = shutdown_m32700ut_irq,
  69. .enable = enable_m32700ut_irq,
  70. .disable = disable_m32700ut_irq,
  71. .ack = mask_and_ack_m32700ut,
  72. .end = end_m32700ut_irq
  73. };
  74. /*
  75. * Interrupt Control Unit of PLD on M32700UT (Level 2)
  76. */
  77. #define irq2pldirq(x) ((x) - M32700UT_PLD_IRQ_BASE)
  78. #define pldirq2port(x) (unsigned long)((int)PLD_ICUCR1 + \
  79. (((x) - 1) * sizeof(unsigned short)))
  80. typedef struct {
  81. unsigned short icucr; /* ICU Control Register */
  82. } pld_icu_data_t;
  83. static pld_icu_data_t pld_icu_data[M32700UT_NUM_PLD_IRQ];
  84. static void disable_m32700ut_pld_irq(unsigned int irq)
  85. {
  86. unsigned long port, data;
  87. unsigned int pldirq;
  88. pldirq = irq2pldirq(irq);
  89. // disable_m32700ut_irq(M32R_IRQ_INT1);
  90. port = pldirq2port(pldirq);
  91. data = pld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
  92. outw(data, port);
  93. }
  94. static void enable_m32700ut_pld_irq(unsigned int irq)
  95. {
  96. unsigned long port, data;
  97. unsigned int pldirq;
  98. pldirq = irq2pldirq(irq);
  99. // enable_m32700ut_irq(M32R_IRQ_INT1);
  100. port = pldirq2port(pldirq);
  101. data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  102. outw(data, port);
  103. }
  104. static void mask_and_ack_m32700ut_pld(unsigned int irq)
  105. {
  106. disable_m32700ut_pld_irq(irq);
  107. // mask_and_ack_m32700ut(M32R_IRQ_INT1);
  108. }
  109. static void end_m32700ut_pld_irq(unsigned int irq)
  110. {
  111. enable_m32700ut_pld_irq(irq);
  112. end_m32700ut_irq(M32R_IRQ_INT1);
  113. }
  114. static unsigned int startup_m32700ut_pld_irq(unsigned int irq)
  115. {
  116. enable_m32700ut_pld_irq(irq);
  117. return (0);
  118. }
  119. static void shutdown_m32700ut_pld_irq(unsigned int irq)
  120. {
  121. unsigned long port;
  122. unsigned int pldirq;
  123. pldirq = irq2pldirq(irq);
  124. // shutdown_m32700ut_irq(M32R_IRQ_INT1);
  125. port = pldirq2port(pldirq);
  126. outw(PLD_ICUCR_ILEVEL7, port);
  127. }
  128. static struct hw_interrupt_type m32700ut_pld_irq_type =
  129. {
  130. .typename = "M32700UT-PLD-IRQ",
  131. .startup = startup_m32700ut_pld_irq,
  132. .shutdown = shutdown_m32700ut_pld_irq,
  133. .enable = enable_m32700ut_pld_irq,
  134. .disable = disable_m32700ut_pld_irq,
  135. .ack = mask_and_ack_m32700ut_pld,
  136. .end = end_m32700ut_pld_irq
  137. };
  138. /*
  139. * Interrupt Control Unit of PLD on M32700UT-LAN (Level 2)
  140. */
  141. #define irq2lanpldirq(x) ((x) - M32700UT_LAN_PLD_IRQ_BASE)
  142. #define lanpldirq2port(x) (unsigned long)((int)M32700UT_LAN_ICUCR1 + \
  143. (((x) - 1) * sizeof(unsigned short)))
  144. static pld_icu_data_t lanpld_icu_data[M32700UT_NUM_LAN_PLD_IRQ];
  145. static void disable_m32700ut_lanpld_irq(unsigned int irq)
  146. {
  147. unsigned long port, data;
  148. unsigned int pldirq;
  149. pldirq = irq2lanpldirq(irq);
  150. port = lanpldirq2port(pldirq);
  151. data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
  152. outw(data, port);
  153. }
  154. static void enable_m32700ut_lanpld_irq(unsigned int irq)
  155. {
  156. unsigned long port, data;
  157. unsigned int pldirq;
  158. pldirq = irq2lanpldirq(irq);
  159. port = lanpldirq2port(pldirq);
  160. data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  161. outw(data, port);
  162. }
  163. static void mask_and_ack_m32700ut_lanpld(unsigned int irq)
  164. {
  165. disable_m32700ut_lanpld_irq(irq);
  166. }
  167. static void end_m32700ut_lanpld_irq(unsigned int irq)
  168. {
  169. enable_m32700ut_lanpld_irq(irq);
  170. end_m32700ut_irq(M32R_IRQ_INT0);
  171. }
  172. static unsigned int startup_m32700ut_lanpld_irq(unsigned int irq)
  173. {
  174. enable_m32700ut_lanpld_irq(irq);
  175. return (0);
  176. }
  177. static void shutdown_m32700ut_lanpld_irq(unsigned int irq)
  178. {
  179. unsigned long port;
  180. unsigned int pldirq;
  181. pldirq = irq2lanpldirq(irq);
  182. port = lanpldirq2port(pldirq);
  183. outw(PLD_ICUCR_ILEVEL7, port);
  184. }
  185. static struct hw_interrupt_type m32700ut_lanpld_irq_type =
  186. {
  187. .typename = "M32700UT-PLD-LAN-IRQ",
  188. .startup = startup_m32700ut_lanpld_irq,
  189. .shutdown = shutdown_m32700ut_lanpld_irq,
  190. .enable = enable_m32700ut_lanpld_irq,
  191. .disable = disable_m32700ut_lanpld_irq,
  192. .ack = mask_and_ack_m32700ut_lanpld,
  193. .end = end_m32700ut_lanpld_irq
  194. };
  195. /*
  196. * Interrupt Control Unit of PLD on M32700UT-LCD (Level 2)
  197. */
  198. #define irq2lcdpldirq(x) ((x) - M32700UT_LCD_PLD_IRQ_BASE)
  199. #define lcdpldirq2port(x) (unsigned long)((int)M32700UT_LCD_ICUCR1 + \
  200. (((x) - 1) * sizeof(unsigned short)))
  201. static pld_icu_data_t lcdpld_icu_data[M32700UT_NUM_LCD_PLD_IRQ];
  202. static void disable_m32700ut_lcdpld_irq(unsigned int irq)
  203. {
  204. unsigned long port, data;
  205. unsigned int pldirq;
  206. pldirq = irq2lcdpldirq(irq);
  207. port = lcdpldirq2port(pldirq);
  208. data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
  209. outw(data, port);
  210. }
  211. static void enable_m32700ut_lcdpld_irq(unsigned int irq)
  212. {
  213. unsigned long port, data;
  214. unsigned int pldirq;
  215. pldirq = irq2lcdpldirq(irq);
  216. port = lcdpldirq2port(pldirq);
  217. data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  218. outw(data, port);
  219. }
  220. static void mask_and_ack_m32700ut_lcdpld(unsigned int irq)
  221. {
  222. disable_m32700ut_lcdpld_irq(irq);
  223. }
  224. static void end_m32700ut_lcdpld_irq(unsigned int irq)
  225. {
  226. enable_m32700ut_lcdpld_irq(irq);
  227. end_m32700ut_irq(M32R_IRQ_INT2);
  228. }
  229. static unsigned int startup_m32700ut_lcdpld_irq(unsigned int irq)
  230. {
  231. enable_m32700ut_lcdpld_irq(irq);
  232. return (0);
  233. }
  234. static void shutdown_m32700ut_lcdpld_irq(unsigned int irq)
  235. {
  236. unsigned long port;
  237. unsigned int pldirq;
  238. pldirq = irq2lcdpldirq(irq);
  239. port = lcdpldirq2port(pldirq);
  240. outw(PLD_ICUCR_ILEVEL7, port);
  241. }
  242. static struct hw_interrupt_type m32700ut_lcdpld_irq_type =
  243. {
  244. .typename = "M32700UT-PLD-LCD-IRQ",
  245. .startup = startup_m32700ut_lcdpld_irq,
  246. .shutdown = shutdown_m32700ut_lcdpld_irq,
  247. .enable = enable_m32700ut_lcdpld_irq,
  248. .disable = disable_m32700ut_lcdpld_irq,
  249. .ack = mask_and_ack_m32700ut_lcdpld,
  250. .end = end_m32700ut_lcdpld_irq
  251. };
  252. void __init init_IRQ(void)
  253. {
  254. #if defined(CONFIG_SMC91X)
  255. /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/
  256. irq_desc[M32700UT_LAN_IRQ_LAN].status = IRQ_DISABLED;
  257. irq_desc[M32700UT_LAN_IRQ_LAN].handler = &m32700ut_lanpld_irq_type;
  258. irq_desc[M32700UT_LAN_IRQ_LAN].action = 0;
  259. irq_desc[M32700UT_LAN_IRQ_LAN].depth = 1; /* disable nested irq */
  260. lanpld_icu_data[irq2lanpldirq(M32700UT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
  261. disable_m32700ut_lanpld_irq(M32700UT_LAN_IRQ_LAN);
  262. #endif /* CONFIG_SMC91X */
  263. /* MFT2 : system timer */
  264. irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED;
  265. irq_desc[M32R_IRQ_MFT2].handler = &m32700ut_irq_type;
  266. irq_desc[M32R_IRQ_MFT2].action = 0;
  267. irq_desc[M32R_IRQ_MFT2].depth = 1;
  268. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  269. disable_m32700ut_irq(M32R_IRQ_MFT2);
  270. /* SIO0 : receive */
  271. irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED;
  272. irq_desc[M32R_IRQ_SIO0_R].handler = &m32700ut_irq_type;
  273. irq_desc[M32R_IRQ_SIO0_R].action = 0;
  274. irq_desc[M32R_IRQ_SIO0_R].depth = 1;
  275. icu_data[M32R_IRQ_SIO0_R].icucr = 0;
  276. disable_m32700ut_irq(M32R_IRQ_SIO0_R);
  277. /* SIO0 : send */
  278. irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED;
  279. irq_desc[M32R_IRQ_SIO0_S].handler = &m32700ut_irq_type;
  280. irq_desc[M32R_IRQ_SIO0_S].action = 0;
  281. irq_desc[M32R_IRQ_SIO0_S].depth = 1;
  282. icu_data[M32R_IRQ_SIO0_S].icucr = 0;
  283. disable_m32700ut_irq(M32R_IRQ_SIO0_S);
  284. /* SIO1 : receive */
  285. irq_desc[M32R_IRQ_SIO1_R].status = IRQ_DISABLED;
  286. irq_desc[M32R_IRQ_SIO1_R].handler = &m32700ut_irq_type;
  287. irq_desc[M32R_IRQ_SIO1_R].action = 0;
  288. irq_desc[M32R_IRQ_SIO1_R].depth = 1;
  289. icu_data[M32R_IRQ_SIO1_R].icucr = 0;
  290. disable_m32700ut_irq(M32R_IRQ_SIO1_R);
  291. /* SIO1 : send */
  292. irq_desc[M32R_IRQ_SIO1_S].status = IRQ_DISABLED;
  293. irq_desc[M32R_IRQ_SIO1_S].handler = &m32700ut_irq_type;
  294. irq_desc[M32R_IRQ_SIO1_S].action = 0;
  295. irq_desc[M32R_IRQ_SIO1_S].depth = 1;
  296. icu_data[M32R_IRQ_SIO1_S].icucr = 0;
  297. disable_m32700ut_irq(M32R_IRQ_SIO1_S);
  298. /* DMA1 : */
  299. irq_desc[M32R_IRQ_DMA1].status = IRQ_DISABLED;
  300. irq_desc[M32R_IRQ_DMA1].handler = &m32700ut_irq_type;
  301. irq_desc[M32R_IRQ_DMA1].action = 0;
  302. irq_desc[M32R_IRQ_DMA1].depth = 1;
  303. icu_data[M32R_IRQ_DMA1].icucr = 0;
  304. disable_m32700ut_irq(M32R_IRQ_DMA1);
  305. #ifdef CONFIG_SERIAL_M32R_PLDSIO
  306. /* INT#1: SIO0 Receive on PLD */
  307. irq_desc[PLD_IRQ_SIO0_RCV].status = IRQ_DISABLED;
  308. irq_desc[PLD_IRQ_SIO0_RCV].handler = &m32700ut_pld_irq_type;
  309. irq_desc[PLD_IRQ_SIO0_RCV].action = 0;
  310. irq_desc[PLD_IRQ_SIO0_RCV].depth = 1; /* disable nested irq */
  311. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  312. disable_m32700ut_pld_irq(PLD_IRQ_SIO0_RCV);
  313. /* INT#1: SIO0 Send on PLD */
  314. irq_desc[PLD_IRQ_SIO0_SND].status = IRQ_DISABLED;
  315. irq_desc[PLD_IRQ_SIO0_SND].handler = &m32700ut_pld_irq_type;
  316. irq_desc[PLD_IRQ_SIO0_SND].action = 0;
  317. irq_desc[PLD_IRQ_SIO0_SND].depth = 1; /* disable nested irq */
  318. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  319. disable_m32700ut_pld_irq(PLD_IRQ_SIO0_SND);
  320. #endif /* CONFIG_SERIAL_M32R_PLDSIO */
  321. /* INT#1: CFC IREQ on PLD */
  322. irq_desc[PLD_IRQ_CFIREQ].status = IRQ_DISABLED;
  323. irq_desc[PLD_IRQ_CFIREQ].handler = &m32700ut_pld_irq_type;
  324. irq_desc[PLD_IRQ_CFIREQ].action = 0;
  325. irq_desc[PLD_IRQ_CFIREQ].depth = 1; /* disable nested irq */
  326. pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */
  327. disable_m32700ut_pld_irq(PLD_IRQ_CFIREQ);
  328. /* INT#1: CFC Insert on PLD */
  329. irq_desc[PLD_IRQ_CFC_INSERT].status = IRQ_DISABLED;
  330. irq_desc[PLD_IRQ_CFC_INSERT].handler = &m32700ut_pld_irq_type;
  331. irq_desc[PLD_IRQ_CFC_INSERT].action = 0;
  332. irq_desc[PLD_IRQ_CFC_INSERT].depth = 1; /* disable nested irq */
  333. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */
  334. disable_m32700ut_pld_irq(PLD_IRQ_CFC_INSERT);
  335. /* INT#1: CFC Eject on PLD */
  336. irq_desc[PLD_IRQ_CFC_EJECT].status = IRQ_DISABLED;
  337. irq_desc[PLD_IRQ_CFC_EJECT].handler = &m32700ut_pld_irq_type;
  338. irq_desc[PLD_IRQ_CFC_EJECT].action = 0;
  339. irq_desc[PLD_IRQ_CFC_EJECT].depth = 1; /* disable nested irq */
  340. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */
  341. disable_m32700ut_pld_irq(PLD_IRQ_CFC_EJECT);
  342. /*
  343. * INT0# is used for LAN, DIO
  344. * We enable it here.
  345. */
  346. icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  347. enable_m32700ut_irq(M32R_IRQ_INT0);
  348. /*
  349. * INT1# is used for UART, MMC, CF Controller in FPGA.
  350. * We enable it here.
  351. */
  352. icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  353. enable_m32700ut_irq(M32R_IRQ_INT1);
  354. #if defined(CONFIG_USB)
  355. outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
  356. irq_desc[M32700UT_LCD_IRQ_USB_INT1].status = IRQ_DISABLED;
  357. irq_desc[M32700UT_LCD_IRQ_USB_INT1].handler = &m32700ut_lcdpld_irq_type;
  358. irq_desc[M32700UT_LCD_IRQ_USB_INT1].action = 0;
  359. irq_desc[M32700UT_LCD_IRQ_USB_INT1].depth = 1;
  360. lcdpld_icu_data[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
  361. disable_m32700ut_lcdpld_irq(M32700UT_LCD_IRQ_USB_INT1);
  362. #endif
  363. /*
  364. * INT2# is used for BAT, USB, AUDIO
  365. * We enable it here.
  366. */
  367. icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
  368. enable_m32700ut_irq(M32R_IRQ_INT2);
  369. //#if defined(CONFIG_VIDEO_M32R_AR)
  370. /*
  371. * INT3# is used for AR
  372. */
  373. irq_desc[M32R_IRQ_INT3].status = IRQ_DISABLED;
  374. irq_desc[M32R_IRQ_INT3].handler = &m32700ut_irq_type;
  375. irq_desc[M32R_IRQ_INT3].action = 0;
  376. irq_desc[M32R_IRQ_INT3].depth = 1;
  377. icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
  378. disable_m32700ut_irq(M32R_IRQ_INT3);
  379. //#endif /* CONFIG_VIDEO_M32R_AR */
  380. }
  381. #define LAN_IOSTART 0x300
  382. #define LAN_IOEND 0x320
  383. static struct resource smc91x_resources[] = {
  384. [0] = {
  385. .start = (LAN_IOSTART),
  386. .end = (LAN_IOEND),
  387. .flags = IORESOURCE_MEM,
  388. },
  389. [1] = {
  390. .start = M32700UT_LAN_IRQ_LAN,
  391. .end = M32700UT_LAN_IRQ_LAN,
  392. .flags = IORESOURCE_IRQ,
  393. }
  394. };
  395. static struct platform_device smc91x_device = {
  396. .name = "smc91x",
  397. .id = 0,
  398. .num_resources = ARRAY_SIZE(smc91x_resources),
  399. .resource = smc91x_resources,
  400. };
  401. static int __init platform_init(void)
  402. {
  403. platform_device_register(&smc91x_device);
  404. return 0;
  405. }
  406. arch_initcall(platform_init);