setup.c 12 KB

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