setup.c 11 KB

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