setup.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. // disable_m32700ut_irq(M32R_IRQ_INT1);
  76. port = pldirq2port(pldirq);
  77. data = pld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
  78. outw(data, port);
  79. }
  80. static void enable_m32700ut_pld_irq(unsigned int irq)
  81. {
  82. unsigned long port, data;
  83. unsigned int pldirq;
  84. pldirq = irq2pldirq(irq);
  85. // enable_m32700ut_irq(M32R_IRQ_INT1);
  86. port = pldirq2port(pldirq);
  87. data = pld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  88. outw(data, port);
  89. }
  90. static void mask_and_ack_m32700ut_pld(unsigned int irq)
  91. {
  92. disable_m32700ut_pld_irq(irq);
  93. // mask_and_ack_m32700ut(M32R_IRQ_INT1);
  94. }
  95. static void end_m32700ut_pld_irq(unsigned int irq)
  96. {
  97. enable_m32700ut_pld_irq(irq);
  98. enable_m32700ut_irq(M32R_IRQ_INT1);
  99. }
  100. static unsigned int startup_m32700ut_pld_irq(unsigned int irq)
  101. {
  102. enable_m32700ut_pld_irq(irq);
  103. return (0);
  104. }
  105. static void shutdown_m32700ut_pld_irq(unsigned int irq)
  106. {
  107. unsigned long port;
  108. unsigned int pldirq;
  109. pldirq = irq2pldirq(irq);
  110. // shutdown_m32700ut_irq(M32R_IRQ_INT1);
  111. port = pldirq2port(pldirq);
  112. outw(PLD_ICUCR_ILEVEL7, port);
  113. }
  114. static struct irq_chip m32700ut_pld_irq_type =
  115. {
  116. .name = "M32700UT-PLD-IRQ",
  117. .startup = startup_m32700ut_pld_irq,
  118. .shutdown = shutdown_m32700ut_pld_irq,
  119. .enable = enable_m32700ut_pld_irq,
  120. .disable = disable_m32700ut_pld_irq,
  121. .ack = mask_and_ack_m32700ut_pld,
  122. .end = end_m32700ut_pld_irq
  123. };
  124. /*
  125. * Interrupt Control Unit of PLD on M32700UT-LAN (Level 2)
  126. */
  127. #define irq2lanpldirq(x) ((x) - M32700UT_LAN_PLD_IRQ_BASE)
  128. #define lanpldirq2port(x) (unsigned long)((int)M32700UT_LAN_ICUCR1 + \
  129. (((x) - 1) * sizeof(unsigned short)))
  130. static pld_icu_data_t lanpld_icu_data[M32700UT_NUM_LAN_PLD_IRQ];
  131. static void disable_m32700ut_lanpld_irq(unsigned int irq)
  132. {
  133. unsigned long port, data;
  134. unsigned int pldirq;
  135. pldirq = irq2lanpldirq(irq);
  136. port = lanpldirq2port(pldirq);
  137. data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
  138. outw(data, port);
  139. }
  140. static void enable_m32700ut_lanpld_irq(unsigned int irq)
  141. {
  142. unsigned long port, data;
  143. unsigned int pldirq;
  144. pldirq = irq2lanpldirq(irq);
  145. port = lanpldirq2port(pldirq);
  146. data = lanpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  147. outw(data, port);
  148. }
  149. static void mask_and_ack_m32700ut_lanpld(unsigned int irq)
  150. {
  151. disable_m32700ut_lanpld_irq(irq);
  152. }
  153. static void end_m32700ut_lanpld_irq(unsigned int irq)
  154. {
  155. enable_m32700ut_lanpld_irq(irq);
  156. enable_m32700ut_irq(M32R_IRQ_INT0);
  157. }
  158. static unsigned int startup_m32700ut_lanpld_irq(unsigned int irq)
  159. {
  160. enable_m32700ut_lanpld_irq(irq);
  161. return (0);
  162. }
  163. static void shutdown_m32700ut_lanpld_irq(unsigned int irq)
  164. {
  165. unsigned long port;
  166. unsigned int pldirq;
  167. pldirq = irq2lanpldirq(irq);
  168. port = lanpldirq2port(pldirq);
  169. outw(PLD_ICUCR_ILEVEL7, port);
  170. }
  171. static struct irq_chip m32700ut_lanpld_irq_type =
  172. {
  173. .name = "M32700UT-PLD-LAN-IRQ",
  174. .startup = startup_m32700ut_lanpld_irq,
  175. .shutdown = shutdown_m32700ut_lanpld_irq,
  176. .enable = enable_m32700ut_lanpld_irq,
  177. .disable = disable_m32700ut_lanpld_irq,
  178. .ack = mask_and_ack_m32700ut_lanpld,
  179. .end = end_m32700ut_lanpld_irq
  180. };
  181. /*
  182. * Interrupt Control Unit of PLD on M32700UT-LCD (Level 2)
  183. */
  184. #define irq2lcdpldirq(x) ((x) - M32700UT_LCD_PLD_IRQ_BASE)
  185. #define lcdpldirq2port(x) (unsigned long)((int)M32700UT_LCD_ICUCR1 + \
  186. (((x) - 1) * sizeof(unsigned short)))
  187. static pld_icu_data_t lcdpld_icu_data[M32700UT_NUM_LCD_PLD_IRQ];
  188. static void disable_m32700ut_lcdpld_irq(unsigned int irq)
  189. {
  190. unsigned long port, data;
  191. unsigned int pldirq;
  192. pldirq = irq2lcdpldirq(irq);
  193. port = lcdpldirq2port(pldirq);
  194. data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_ILEVEL7;
  195. outw(data, port);
  196. }
  197. static void enable_m32700ut_lcdpld_irq(unsigned int irq)
  198. {
  199. unsigned long port, data;
  200. unsigned int pldirq;
  201. pldirq = irq2lcdpldirq(irq);
  202. port = lcdpldirq2port(pldirq);
  203. data = lcdpld_icu_data[pldirq].icucr|PLD_ICUCR_IEN|PLD_ICUCR_ILEVEL6;
  204. outw(data, port);
  205. }
  206. static void mask_and_ack_m32700ut_lcdpld(unsigned int irq)
  207. {
  208. disable_m32700ut_lcdpld_irq(irq);
  209. }
  210. static void end_m32700ut_lcdpld_irq(unsigned int irq)
  211. {
  212. enable_m32700ut_lcdpld_irq(irq);
  213. enable_m32700ut_irq(M32R_IRQ_INT2);
  214. }
  215. static unsigned int startup_m32700ut_lcdpld_irq(unsigned int irq)
  216. {
  217. enable_m32700ut_lcdpld_irq(irq);
  218. return (0);
  219. }
  220. static void shutdown_m32700ut_lcdpld_irq(unsigned int irq)
  221. {
  222. unsigned long port;
  223. unsigned int pldirq;
  224. pldirq = irq2lcdpldirq(irq);
  225. port = lcdpldirq2port(pldirq);
  226. outw(PLD_ICUCR_ILEVEL7, port);
  227. }
  228. static struct irq_chip m32700ut_lcdpld_irq_type =
  229. {
  230. .name = "M32700UT-PLD-LCD-IRQ",
  231. .startup = startup_m32700ut_lcdpld_irq,
  232. .shutdown = shutdown_m32700ut_lcdpld_irq,
  233. .enable = enable_m32700ut_lcdpld_irq,
  234. .disable = disable_m32700ut_lcdpld_irq,
  235. .ack = mask_and_ack_m32700ut_lcdpld,
  236. .end = end_m32700ut_lcdpld_irq
  237. };
  238. void __init init_IRQ(void)
  239. {
  240. #if defined(CONFIG_SMC91X)
  241. /* INT#0: LAN controller on M32700UT-LAN (SMC91C111)*/
  242. set_irq_chip(M32700UT_LAN_IRQ_LAN, &m32700ut_lanpld_irq_type);
  243. lanpld_icu_data[irq2lanpldirq(M32700UT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
  244. disable_m32700ut_lanpld_irq(M32700UT_LAN_IRQ_LAN);
  245. #endif /* CONFIG_SMC91X */
  246. /* MFT2 : system timer */
  247. set_irq_chip_and_handler(M32R_IRQ_MFT2, &m32700ut_irq_type,
  248. handle_level_irq);
  249. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  250. disable_m32700ut_irq(M32R_IRQ_MFT2);
  251. /* SIO0 : receive */
  252. set_irq_chip_and_handler(M32R_IRQ_SIO0_R, &m32700ut_irq_type,
  253. handle_level_irq);
  254. icu_data[M32R_IRQ_SIO0_R].icucr = 0;
  255. disable_m32700ut_irq(M32R_IRQ_SIO0_R);
  256. /* SIO0 : send */
  257. set_irq_chip_and_handler(M32R_IRQ_SIO0_S, &m32700ut_irq_type,
  258. handle_level_irq);
  259. icu_data[M32R_IRQ_SIO0_S].icucr = 0;
  260. disable_m32700ut_irq(M32R_IRQ_SIO0_S);
  261. /* SIO1 : receive */
  262. set_irq_chip_and_handler(M32R_IRQ_SIO1_R, &m32700ut_irq_type,
  263. handle_level_irq);
  264. icu_data[M32R_IRQ_SIO1_R].icucr = 0;
  265. disable_m32700ut_irq(M32R_IRQ_SIO1_R);
  266. /* SIO1 : send */
  267. set_irq_chip_and_handler(M32R_IRQ_SIO1_S, &m32700ut_irq_type,
  268. handle_level_irq);
  269. icu_data[M32R_IRQ_SIO1_S].icucr = 0;
  270. disable_m32700ut_irq(M32R_IRQ_SIO1_S);
  271. /* DMA1 : */
  272. set_irq_chip_and_handler(M32R_IRQ_DMA1, &m32700ut_irq_type,
  273. handle_level_irq);
  274. icu_data[M32R_IRQ_DMA1].icucr = 0;
  275. disable_m32700ut_irq(M32R_IRQ_DMA1);
  276. #ifdef CONFIG_SERIAL_M32R_PLDSIO
  277. /* INT#1: SIO0 Receive on PLD */
  278. set_irq_chip(PLD_IRQ_SIO0_RCV, &m32700ut_pld_irq_type);
  279. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  280. disable_m32700ut_pld_irq(PLD_IRQ_SIO0_RCV);
  281. /* INT#1: SIO0 Send on PLD */
  282. set_irq_chip(PLD_IRQ_SIO0_SND, &m32700ut_pld_irq_type);
  283. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  284. disable_m32700ut_pld_irq(PLD_IRQ_SIO0_SND);
  285. #endif /* CONFIG_SERIAL_M32R_PLDSIO */
  286. /* INT#1: CFC IREQ on PLD */
  287. set_irq_chip(PLD_IRQ_CFIREQ, &m32700ut_pld_irq_type);
  288. pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */
  289. disable_m32700ut_pld_irq(PLD_IRQ_CFIREQ);
  290. /* INT#1: CFC Insert on PLD */
  291. set_irq_chip(PLD_IRQ_CFC_INSERT, &m32700ut_pld_irq_type);
  292. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */
  293. disable_m32700ut_pld_irq(PLD_IRQ_CFC_INSERT);
  294. /* INT#1: CFC Eject on PLD */
  295. set_irq_chip(PLD_IRQ_CFC_EJECT, &m32700ut_pld_irq_type);
  296. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */
  297. disable_m32700ut_pld_irq(PLD_IRQ_CFC_EJECT);
  298. /*
  299. * INT0# is used for LAN, DIO
  300. * We enable it here.
  301. */
  302. icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  303. enable_m32700ut_irq(M32R_IRQ_INT0);
  304. /*
  305. * INT1# is used for UART, MMC, CF Controller in FPGA.
  306. * We enable it here.
  307. */
  308. icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  309. enable_m32700ut_irq(M32R_IRQ_INT1);
  310. #if defined(CONFIG_USB)
  311. outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
  312. set_irq_chip(M32700UT_LCD_IRQ_USB_INT1, &m32700ut_lcdpld_irq_type);
  313. lcdpld_icu_data[irq2lcdpldirq(M32700UT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
  314. disable_m32700ut_lcdpld_irq(M32700UT_LCD_IRQ_USB_INT1);
  315. #endif
  316. /*
  317. * INT2# is used for BAT, USB, AUDIO
  318. * We enable it here.
  319. */
  320. icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
  321. enable_m32700ut_irq(M32R_IRQ_INT2);
  322. #if defined(CONFIG_VIDEO_M32R_AR)
  323. /*
  324. * INT3# is used for AR
  325. */
  326. set_irq_chip_and_handler(M32R_IRQ_INT3, &m32700ut_irq_type,
  327. handle_level_irq);
  328. icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
  329. disable_m32700ut_irq(M32R_IRQ_INT3);
  330. #endif /* CONFIG_VIDEO_M32R_AR */
  331. }
  332. #if defined(CONFIG_SMC91X)
  333. #define LAN_IOSTART 0x300
  334. #define LAN_IOEND 0x320
  335. static struct resource smc91x_resources[] = {
  336. [0] = {
  337. .start = (LAN_IOSTART),
  338. .end = (LAN_IOEND),
  339. .flags = IORESOURCE_MEM,
  340. },
  341. [1] = {
  342. .start = M32700UT_LAN_IRQ_LAN,
  343. .end = M32700UT_LAN_IRQ_LAN,
  344. .flags = IORESOURCE_IRQ,
  345. }
  346. };
  347. static struct platform_device smc91x_device = {
  348. .name = "smc91x",
  349. .id = 0,
  350. .num_resources = ARRAY_SIZE(smc91x_resources),
  351. .resource = smc91x_resources,
  352. };
  353. #endif
  354. #if defined(CONFIG_FB_S1D13XXX)
  355. #include <video/s1d13xxxfb.h>
  356. #include <asm/s1d13806.h>
  357. static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
  358. .initregs = s1d13xxxfb_initregs,
  359. .initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),
  360. .platform_init_video = NULL,
  361. #ifdef CONFIG_PM
  362. .platform_suspend_video = NULL,
  363. .platform_resume_video = NULL,
  364. #endif
  365. };
  366. static struct resource s1d13xxxfb_resources[] = {
  367. [0] = {
  368. .start = 0x10600000UL,
  369. .end = 0x1073FFFFUL,
  370. .flags = IORESOURCE_MEM,
  371. },
  372. [1] = {
  373. .start = 0x10400000UL,
  374. .end = 0x104001FFUL,
  375. .flags = IORESOURCE_MEM,
  376. }
  377. };
  378. static struct platform_device s1d13xxxfb_device = {
  379. .name = S1D_DEVICENAME,
  380. .id = 0,
  381. .dev = {
  382. .platform_data = &s1d13xxxfb_data,
  383. },
  384. .num_resources = ARRAY_SIZE(s1d13xxxfb_resources),
  385. .resource = s1d13xxxfb_resources,
  386. };
  387. #endif
  388. static int __init platform_init(void)
  389. {
  390. #if defined(CONFIG_SMC91X)
  391. platform_device_register(&smc91x_device);
  392. #endif
  393. #if defined(CONFIG_FB_S1D13XXX)
  394. platform_device_register(&s1d13xxxfb_device);
  395. #endif
  396. return 0;
  397. }
  398. arch_initcall(platform_init);