setup.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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/m32r.h>
  19. #include <asm/io.h>
  20. /*
  21. * OPSP 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[OPSPUT_NUM_CPU_IRQ];
  25. static void disable_opsput_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_opsput_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_opsput(struct irq_data *data)
  40. {
  41. disable_opsput_irq(data->irq);
  42. }
  43. static void unmask_opsput(struct irq_data *data)
  44. {
  45. enable_opsput_irq(data->irq);
  46. }
  47. static void shutdown_opsput(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 opsput_irq_type =
  54. {
  55. .name = "OPSPUT-IRQ",
  56. .irq_shutdown = shutdown_opsput,
  57. .irq_mask = mask_opsput,
  58. .irq_unmask = unmask_opsput,
  59. };
  60. /*
  61. * Interrupt Control Unit of PLD on OPSPUT (Level 2)
  62. */
  63. #define irq2pldirq(x) ((x) - OPSPUT_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[OPSPUT_NUM_PLD_IRQ];
  70. static void disable_opsput_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_opsput_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_opsput_pld(struct irq_data *data)
  89. {
  90. disable_opsput_pld_irq(data->irq);
  91. }
  92. static void unmask_opsput_pld(struct irq_data *data)
  93. {
  94. enable_opsput_pld_irq(data->irq);
  95. enable_opsput_irq(M32R_IRQ_INT1);
  96. }
  97. static void shutdown_opsput_pld(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 opsput_pld_irq_type =
  106. {
  107. .name = "OPSPUT-PLD-IRQ",
  108. .irq_shutdown = shutdown_opsput_pld,
  109. .irq_mask = mask_opsput_pld,
  110. .irq_unmask = unmask_opsput_pld,
  111. };
  112. /*
  113. * Interrupt Control Unit of PLD on OPSPUT-LAN (Level 2)
  114. */
  115. #define irq2lanpldirq(x) ((x) - OPSPUT_LAN_PLD_IRQ_BASE)
  116. #define lanpldirq2port(x) (unsigned long)((int)OPSPUT_LAN_ICUCR1 + \
  117. (((x) - 1) * sizeof(unsigned short)))
  118. static pld_icu_data_t lanpld_icu_data[OPSPUT_NUM_LAN_PLD_IRQ];
  119. static void disable_opsput_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_opsput_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_opsput_lanpld(struct irq_data *data)
  138. {
  139. disable_opsput_lanpld_irq(data->irq);
  140. }
  141. static void unmask_opsput_lanpld(struct irq_data *data)
  142. {
  143. enable_opsput_lanpld_irq(data->irq);
  144. enable_opsput_irq(M32R_IRQ_INT0);
  145. }
  146. static void shutdown_opsput_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 opsput_lanpld_irq_type =
  155. {
  156. .name = "OPSPUT-PLD-LAN-IRQ",
  157. .irq_shutdown = shutdown_opsput_lanpld,
  158. .irq_mask = mask_opsput_lanpld,
  159. .irq_unmask = unmask_opsput_lanpld,
  160. };
  161. /*
  162. * Interrupt Control Unit of PLD on OPSPUT-LCD (Level 2)
  163. */
  164. #define irq2lcdpldirq(x) ((x) - OPSPUT_LCD_PLD_IRQ_BASE)
  165. #define lcdpldirq2port(x) (unsigned long)((int)OPSPUT_LCD_ICUCR1 + \
  166. (((x) - 1) * sizeof(unsigned short)))
  167. static pld_icu_data_t lcdpld_icu_data[OPSPUT_NUM_LCD_PLD_IRQ];
  168. static void disable_opsput_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_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_IEN|PLD_ICUCR_ILEVEL6;
  184. outw(data, port);
  185. }
  186. static void mask_opsput_lcdpld(struct irq_data *data)
  187. {
  188. disable_opsput_lcdpld_irq(data->irq);
  189. }
  190. static void unmask_opsput_lcdpld(struct irq_data *data)
  191. {
  192. enable_opsput_lcdpld_irq(data->irq);
  193. enable_opsput_irq(M32R_IRQ_INT2);
  194. }
  195. static void shutdown_opsput_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 opsput_lcdpld_irq_type = {
  204. .name = "OPSPUT-PLD-LCD-IRQ",
  205. .irq_shutdown = shutdown_opsput_lcdpld,
  206. .irq_mask = mask_opsput_lcdpld,
  207. .irq_unmask = unmask_opsput_lcdpld,
  208. };
  209. void __init init_IRQ(void)
  210. {
  211. #if defined(CONFIG_SMC91X)
  212. /* INT#0: LAN controller on OPSPUT-LAN (SMC91C111)*/
  213. irq_set_chip_and_handler(OPSPUT_LAN_IRQ_LAN, &opsput_lanpld_irq_type,
  214. handle_level_irq);
  215. lanpld_icu_data[irq2lanpldirq(OPSPUT_LAN_IRQ_LAN)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* "H" edge sense */
  216. disable_opsput_lanpld_irq(OPSPUT_LAN_IRQ_LAN);
  217. #endif /* CONFIG_SMC91X */
  218. /* MFT2 : system timer */
  219. irq_set_chip_and_handler(M32R_IRQ_MFT2, &opsput_irq_type,
  220. handle_level_irq);
  221. icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN;
  222. disable_opsput_irq(M32R_IRQ_MFT2);
  223. /* SIO0 : receive */
  224. irq_set_chip_and_handler(M32R_IRQ_SIO0_R, &opsput_irq_type,
  225. handle_level_irq);
  226. icu_data[M32R_IRQ_SIO0_R].icucr = 0;
  227. disable_opsput_irq(M32R_IRQ_SIO0_R);
  228. /* SIO0 : send */
  229. irq_set_chip_and_handler(M32R_IRQ_SIO0_S, &opsput_irq_type,
  230. handle_level_irq);
  231. icu_data[M32R_IRQ_SIO0_S].icucr = 0;
  232. disable_opsput_irq(M32R_IRQ_SIO0_S);
  233. /* SIO1 : receive */
  234. irq_set_chip_and_handler(M32R_IRQ_SIO1_R, &opsput_irq_type,
  235. handle_level_irq);
  236. icu_data[M32R_IRQ_SIO1_R].icucr = 0;
  237. disable_opsput_irq(M32R_IRQ_SIO1_R);
  238. /* SIO1 : send */
  239. irq_set_chip_and_handler(M32R_IRQ_SIO1_S, &opsput_irq_type,
  240. handle_level_irq);
  241. icu_data[M32R_IRQ_SIO1_S].icucr = 0;
  242. disable_opsput_irq(M32R_IRQ_SIO1_S);
  243. /* DMA1 : */
  244. irq_set_chip_and_handler(M32R_IRQ_DMA1, &opsput_irq_type,
  245. handle_level_irq);
  246. icu_data[M32R_IRQ_DMA1].icucr = 0;
  247. disable_opsput_irq(M32R_IRQ_DMA1);
  248. #ifdef CONFIG_SERIAL_M32R_PLDSIO
  249. /* INT#1: SIO0 Receive on PLD */
  250. irq_set_chip_and_handler(PLD_IRQ_SIO0_RCV, &opsput_pld_irq_type,
  251. handle_level_irq);
  252. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_RCV)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  253. disable_opsput_pld_irq(PLD_IRQ_SIO0_RCV);
  254. /* INT#1: SIO0 Send on PLD */
  255. irq_set_chip_and_handler(PLD_IRQ_SIO0_SND, &opsput_pld_irq_type,
  256. handle_level_irq);
  257. pld_icu_data[irq2pldirq(PLD_IRQ_SIO0_SND)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD03;
  258. disable_opsput_pld_irq(PLD_IRQ_SIO0_SND);
  259. #endif /* CONFIG_SERIAL_M32R_PLDSIO */
  260. /* INT#1: CFC IREQ on PLD */
  261. irq_set_chip_and_handler(PLD_IRQ_CFIREQ, &opsput_pld_irq_type,
  262. handle_level_irq);
  263. pld_icu_data[irq2pldirq(PLD_IRQ_CFIREQ)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* 'L' level sense */
  264. disable_opsput_pld_irq(PLD_IRQ_CFIREQ);
  265. /* INT#1: CFC Insert on PLD */
  266. irq_set_chip_and_handler(PLD_IRQ_CFC_INSERT, &opsput_pld_irq_type,
  267. handle_level_irq);
  268. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_INSERT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD00; /* 'L' edge sense */
  269. disable_opsput_pld_irq(PLD_IRQ_CFC_INSERT);
  270. /* INT#1: CFC Eject on PLD */
  271. irq_set_chip_and_handler(PLD_IRQ_CFC_EJECT, &opsput_pld_irq_type,
  272. handle_level_irq);
  273. pld_icu_data[irq2pldirq(PLD_IRQ_CFC_EJECT)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD02; /* 'H' edge sense */
  274. disable_opsput_pld_irq(PLD_IRQ_CFC_EJECT);
  275. /*
  276. * INT0# is used for LAN, DIO
  277. * We enable it here.
  278. */
  279. icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  280. enable_opsput_irq(M32R_IRQ_INT0);
  281. /*
  282. * INT1# is used for UART, MMC, CF Controller in FPGA.
  283. * We enable it here.
  284. */
  285. icu_data[M32R_IRQ_INT1].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
  286. enable_opsput_irq(M32R_IRQ_INT1);
  287. #if defined(CONFIG_USB)
  288. outw(USBCR_OTGS, USBCR); /* USBCR: non-OTG */
  289. irq_set_chip_and_handler(OPSPUT_LCD_IRQ_USB_INT1,
  290. &opsput_lcdpld_irq_type, handle_level_irq);
  291. lcdpld_icu_data[irq2lcdpldirq(OPSPUT_LCD_IRQ_USB_INT1)].icucr = PLD_ICUCR_IEN|PLD_ICUCR_ISMOD01; /* "L" level sense */
  292. disable_opsput_lcdpld_irq(OPSPUT_LCD_IRQ_USB_INT1);
  293. #endif
  294. /*
  295. * INT2# is used for BAT, USB, AUDIO
  296. * We enable it here.
  297. */
  298. icu_data[M32R_IRQ_INT2].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD01;
  299. enable_opsput_irq(M32R_IRQ_INT2);
  300. #if defined(CONFIG_VIDEO_M32R_AR)
  301. /*
  302. * INT3# is used for AR
  303. */
  304. irq_set_chip_and_handler(M32R_IRQ_INT3, &opsput_irq_type,
  305. handle_level_irq);
  306. icu_data[M32R_IRQ_INT3].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10;
  307. disable_opsput_irq(M32R_IRQ_INT3);
  308. #endif /* CONFIG_VIDEO_M32R_AR */
  309. }
  310. #if defined(CONFIG_SMC91X)
  311. #define LAN_IOSTART 0x300
  312. #define LAN_IOEND 0x320
  313. static struct resource smc91x_resources[] = {
  314. [0] = {
  315. .start = (LAN_IOSTART),
  316. .end = (LAN_IOEND),
  317. .flags = IORESOURCE_MEM,
  318. },
  319. [1] = {
  320. .start = OPSPUT_LAN_IRQ_LAN,
  321. .end = OPSPUT_LAN_IRQ_LAN,
  322. .flags = IORESOURCE_IRQ,
  323. }
  324. };
  325. static struct platform_device smc91x_device = {
  326. .name = "smc91x",
  327. .id = 0,
  328. .num_resources = ARRAY_SIZE(smc91x_resources),
  329. .resource = smc91x_resources,
  330. };
  331. #endif
  332. #if defined(CONFIG_FB_S1D13XXX)
  333. #include <video/s1d13xxxfb.h>
  334. #include <asm/s1d13806.h>
  335. static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
  336. .initregs = s1d13xxxfb_initregs,
  337. .initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),
  338. .platform_init_video = NULL,
  339. #ifdef CONFIG_PM
  340. .platform_suspend_video = NULL,
  341. .platform_resume_video = NULL,
  342. #endif
  343. };
  344. static struct resource s1d13xxxfb_resources[] = {
  345. [0] = {
  346. .start = 0x10600000UL,
  347. .end = 0x1073FFFFUL,
  348. .flags = IORESOURCE_MEM,
  349. },
  350. [1] = {
  351. .start = 0x10400000UL,
  352. .end = 0x104001FFUL,
  353. .flags = IORESOURCE_MEM,
  354. }
  355. };
  356. static struct platform_device s1d13xxxfb_device = {
  357. .name = S1D_DEVICENAME,
  358. .id = 0,
  359. .dev = {
  360. .platform_data = &s1d13xxxfb_data,
  361. },
  362. .num_resources = ARRAY_SIZE(s1d13xxxfb_resources),
  363. .resource = s1d13xxxfb_resources,
  364. };
  365. #endif
  366. static int __init platform_init(void)
  367. {
  368. #if defined(CONFIG_SMC91X)
  369. platform_device_register(&smc91x_device);
  370. #endif
  371. #if defined(CONFIG_FB_S1D13XXX)
  372. platform_device_register(&s1d13xxxfb_device);
  373. #endif
  374. return 0;
  375. }
  376. arch_initcall(platform_init);