setup.c 12 KB

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