setup.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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. #ifdef CONFIG_USB
  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. #endif
  211. void __init init_IRQ(void)
  212. {
  213. #if defined(CONFIG_SMC91X)
  214. /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/
  215. irq_set_chip_and_handler(M32700UT_LAN_IRQ_LAN,
  216. &m32700ut_lanpld_irq_type, handle_level_irq);
  217. lanpld_icu_data[irq2lanpldirq(M32700UT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
  218. disable_m32700ut_lanpld_irq(M32700UT_LAN_IRQ_LAN);
  219. #endif /* CONFIG_SMC91X */
  220. /* MFT2 : system timer */
  221. irq_set_chip_and_handler(M32R_IRQ_MFT2, &m32700ut_irq_type,
  222. handle_level_irq);
  223. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  224. disable_m32700ut_irq(M32R_IRQ_MFT2);
  225. /* SIO0 : receive */
  226. irq_set_chip_and_handler(M32R_IRQ_SIO0_R, &m32700ut_irq_type,
  227. handle_level_irq);
  228. icu_data[M32R_IRQ_SIO0_R].icucr = 0;
  229. disable_m32700ut_irq(M32R_IRQ_SIO0_R);
  230. /* SIO0 : send */
  231. irq_set_chip_and_handler(M32R_IRQ_SIO0_S, &m32700ut_irq_type,
  232. handle_level_irq);
  233. icu_data[M32R_IRQ_SIO0_S].icucr = 0;
  234. disable_m32700ut_irq(M32R_IRQ_SIO0_S);
  235. /* SIO1 : receive */
  236. irq_set_chip_and_handler(M32R_IRQ_SIO1_R, &m32700ut_irq_type,
  237. handle_level_irq);
  238. icu_data[M32R_IRQ_SIO1_R].icucr = 0;
  239. disable_m32700ut_irq(M32R_IRQ_SIO1_R);
  240. /* SIO1 : send */
  241. irq_set_chip_and_handler(M32R_IRQ_SIO1_S, &m32700ut_irq_type,
  242. handle_level_irq);
  243. icu_data[M32R_IRQ_SIO1_S].icucr = 0;
  244. disable_m32700ut_irq(M32R_IRQ_SIO1_S);
  245. /* DMA1 : */
  246. irq_set_chip_and_handler(M32R_IRQ_DMA1, &m32700ut_irq_type,
  247. handle_level_irq);
  248. icu_data[M32R_IRQ_DMA1].icucr = 0;
  249. disable_m32700ut_irq(M32R_IRQ_DMA1);
  250. #ifdef CONFIG_SERIAL_M32R_PLDSIO
  251. /* INT#1: SIO0 Receive on PLD */
  252. irq_set_chip_and_handler(PLD_IRQ_SIO0_RCV, &m32700ut_pld_irq_type,
  253. handle_level_irq);
  254. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  255. disable_m32700ut_pld_irq(PLD_IRQ_SIO0_RCV);
  256. /* INT#1: SIO0 Send on PLD */
  257. irq_set_chip_and_handler(PLD_IRQ_SIO0_SND, &m32700ut_pld_irq_type,
  258. handle_level_irq);
  259. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  260. disable_m32700ut_pld_irq(PLD_IRQ_SIO0_SND);
  261. #endif /* CONFIG_SERIAL_M32R_PLDSIO */
  262. /* INT#1: CFC IREQ on PLD */
  263. irq_set_chip_and_handler(PLD_IRQ_CFIREQ, &m32700ut_pld_irq_type,
  264. handle_level_irq);
  265. pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */
  266. disable_m32700ut_pld_irq(PLD_IRQ_CFIREQ);
  267. /* INT#1: CFC Insert on PLD */
  268. irq_set_chip_and_handler(PLD_IRQ_CFC_INSERT, &m32700ut_pld_irq_type,
  269. handle_level_irq);
  270. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */
  271. disable_m32700ut_pld_irq(PLD_IRQ_CFC_INSERT);
  272. /* INT#1: CFC Eject on PLD */
  273. irq_set_chip_and_handler(PLD_IRQ_CFC_EJECT, &m32700ut_pld_irq_type,
  274. handle_level_irq);
  275. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */
  276. disable_m32700ut_pld_irq(PLD_IRQ_CFC_EJECT);
  277. /*
  278. * INT0# is used for LAN, DIO
  279. * We enable it here.
  280. */
  281. icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  282. enable_m32700ut_irq(M32R_IRQ_INT0);
  283. /*
  284. * INT1# is used for UART, MMC, CF Controller in FPGA.
  285. * We enable it here.
  286. */
  287. icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  288. enable_m32700ut_irq(M32R_IRQ_INT1);
  289. #if defined(CONFIG_USB)
  290. outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
  291. irq_set_chip_and_handler(M32700UT_LCD_IRQ_USB_INT1,
  292. &m32700ut_lcdpld_irq_type, handle_level_irq);
  293. lcdpld_icu_data[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
  294. disable_m32700ut_lcdpld_irq(M32700UT_LCD_IRQ_USB_INT1);
  295. #endif
  296. /*
  297. * INT2# is used for BAT, USB, AUDIO
  298. * We enable it here.
  299. */
  300. icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
  301. enable_m32700ut_irq(M32R_IRQ_INT2);
  302. #if defined(CONFIG_VIDEO_M32R_AR)
  303. /*
  304. * INT3# is used for AR
  305. */
  306. irq_set_chip_and_handler(M32R_IRQ_INT3, &m32700ut_irq_type,
  307. handle_level_irq);
  308. icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
  309. disable_m32700ut_irq(M32R_IRQ_INT3);
  310. #endif /* CONFIG_VIDEO_M32R_AR */
  311. }
  312. #if defined(CONFIG_SMC91X)
  313. #define LAN_IOSTART 0x300
  314. #define LAN_IOEND 0x320
  315. static struct resource smc91x_resources[] = {
  316. [0] = {
  317. .start = (LAN_IOSTART),
  318. .end = (LAN_IOEND),
  319. .flags = IORESOURCE_MEM,
  320. },
  321. [1] = {
  322. .start = M32700UT_LAN_IRQ_LAN,
  323. .end = M32700UT_LAN_IRQ_LAN,
  324. .flags = IORESOURCE_IRQ,
  325. }
  326. };
  327. static struct platform_device smc91x_device = {
  328. .name = "smc91x",
  329. .id = 0,
  330. .num_resources = ARRAY_SIZE(smc91x_resources),
  331. .resource = smc91x_resources,
  332. };
  333. #endif
  334. #if defined(CONFIG_FB_S1D13XXX)
  335. #include <video/s1d13xxxfb.h>
  336. #include <asm/s1d13806.h>
  337. static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
  338. .initregs = s1d13xxxfb_initregs,
  339. .initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),
  340. .platform_init_video = NULL,
  341. #ifdef CONFIG_PM
  342. .platform_suspend_video = NULL,
  343. .platform_resume_video = NULL,
  344. #endif
  345. };
  346. static struct resource s1d13xxxfb_resources[] = {
  347. [0] = {
  348. .start = 0x10600000UL,
  349. .end = 0x1073FFFFUL,
  350. .flags = IORESOURCE_MEM,
  351. },
  352. [1] = {
  353. .start = 0x10400000UL,
  354. .end = 0x104001FFUL,
  355. .flags = IORESOURCE_MEM,
  356. }
  357. };
  358. static struct platform_device s1d13xxxfb_device = {
  359. .name = S1D_DEVICENAME,
  360. .id = 0,
  361. .dev = {
  362. .platform_data = &s1d13xxxfb_data,
  363. },
  364. .num_resources = ARRAY_SIZE(s1d13xxxfb_resources),
  365. .resource = s1d13xxxfb_resources,
  366. };
  367. #endif
  368. static int __init platform_init(void)
  369. {
  370. #if defined(CONFIG_SMC91X)
  371. platform_device_register(&smc91x_device);
  372. #endif
  373. #if defined(CONFIG_FB_S1D13XXX)
  374. platform_device_register(&s1d13xxxfb_device);
  375. #endif
  376. return 0;
  377. }
  378. arch_initcall(platform_init);