setup.c 12 KB

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