setup.c 12 KB

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