setup.c 11 KB

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