setup.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /*
  2. * Renesas System Solutions Asia Pte. Ltd - Migo-R
  3. *
  4. * Copyright (C) 2008 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/input.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <linux/mtd/nand.h>
  16. #include <linux/i2c.h>
  17. #include <linux/smc91x.h>
  18. #include <asm/machvec.h>
  19. #include <asm/io.h>
  20. #include <asm/sh_keysc.h>
  21. #include <asm/migor.h>
  22. /* Address IRQ Size Bus Description
  23. * 0x00000000 64MB 16 NOR Flash (SP29PL256N)
  24. * 0x0c000000 64MB 64 SDRAM (2xK4M563233G)
  25. * 0x10000000 IRQ0 16 Ethernet (SMC91C111)
  26. * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596)
  27. * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
  28. */
  29. static struct smc91x_platdata smc91x_info = {
  30. .flags = SMC91X_USE_16BIT,
  31. .irq_flags = IRQF_TRIGGER_HIGH,
  32. };
  33. static struct resource smc91x_eth_resources[] = {
  34. [0] = {
  35. .name = "SMC91C111" ,
  36. .start = 0x10000300,
  37. .end = 0x1000030f,
  38. .flags = IORESOURCE_MEM,
  39. },
  40. [1] = {
  41. .start = 32, /* IRQ0 */
  42. .flags = IORESOURCE_IRQ,
  43. },
  44. };
  45. static struct platform_device smc91x_eth_device = {
  46. .name = "smc91x",
  47. .num_resources = ARRAY_SIZE(smc91x_eth_resources),
  48. .resource = smc91x_eth_resources,
  49. .dev = {
  50. .platform_data = &smc91x_info,
  51. },
  52. };
  53. static struct sh_keysc_info sh_keysc_info = {
  54. .mode = SH_KEYSC_MODE_2, /* KEYOUT0->4, KEYIN1->5 */
  55. .scan_timing = 3,
  56. .delay = 5,
  57. .keycodes = {
  58. 0, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_ENTER,
  59. 0, KEY_F, KEY_C, KEY_D, KEY_H, KEY_1,
  60. 0, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6,
  61. 0, KEY_7, KEY_8, KEY_9, KEY_S, KEY_0,
  62. 0, KEY_P, KEY_STOP, KEY_REWIND, KEY_PLAY, KEY_FASTFORWARD,
  63. },
  64. };
  65. static struct resource sh_keysc_resources[] = {
  66. [0] = {
  67. .start = 0x044b0000,
  68. .end = 0x044b000f,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. [1] = {
  72. .start = 79,
  73. .flags = IORESOURCE_IRQ,
  74. },
  75. };
  76. static struct platform_device sh_keysc_device = {
  77. .name = "sh_keysc",
  78. .num_resources = ARRAY_SIZE(sh_keysc_resources),
  79. .resource = sh_keysc_resources,
  80. .dev = {
  81. .platform_data = &sh_keysc_info,
  82. },
  83. };
  84. static struct mtd_partition migor_nor_flash_partitions[] =
  85. {
  86. {
  87. .name = "uboot",
  88. .offset = 0,
  89. .size = (1 * 1024 * 1024),
  90. .mask_flags = MTD_WRITEABLE, /* Read-only */
  91. },
  92. {
  93. .name = "rootfs",
  94. .offset = MTDPART_OFS_APPEND,
  95. .size = (15 * 1024 * 1024),
  96. },
  97. {
  98. .name = "other",
  99. .offset = MTDPART_OFS_APPEND,
  100. .size = MTDPART_SIZ_FULL,
  101. },
  102. };
  103. static struct physmap_flash_data migor_nor_flash_data = {
  104. .width = 2,
  105. .parts = migor_nor_flash_partitions,
  106. .nr_parts = ARRAY_SIZE(migor_nor_flash_partitions),
  107. };
  108. static struct resource migor_nor_flash_resources[] = {
  109. [0] = {
  110. .name = "NOR Flash",
  111. .start = 0x00000000,
  112. .end = 0x03ffffff,
  113. .flags = IORESOURCE_MEM,
  114. }
  115. };
  116. static struct platform_device migor_nor_flash_device = {
  117. .name = "physmap-flash",
  118. .resource = migor_nor_flash_resources,
  119. .num_resources = ARRAY_SIZE(migor_nor_flash_resources),
  120. .dev = {
  121. .platform_data = &migor_nor_flash_data,
  122. },
  123. };
  124. static struct mtd_partition migor_nand_flash_partitions[] = {
  125. {
  126. .name = "nanddata1",
  127. .offset = 0x0,
  128. .size = 512 * 1024 * 1024,
  129. },
  130. {
  131. .name = "nanddata2",
  132. .offset = MTDPART_OFS_APPEND,
  133. .size = 512 * 1024 * 1024,
  134. },
  135. };
  136. static void migor_nand_flash_cmd_ctl(struct mtd_info *mtd, int cmd,
  137. unsigned int ctrl)
  138. {
  139. struct nand_chip *chip = mtd->priv;
  140. if (cmd == NAND_CMD_NONE)
  141. return;
  142. if (ctrl & NAND_CLE)
  143. writeb(cmd, chip->IO_ADDR_W + 0x00400000);
  144. else if (ctrl & NAND_ALE)
  145. writeb(cmd, chip->IO_ADDR_W + 0x00800000);
  146. else
  147. writeb(cmd, chip->IO_ADDR_W);
  148. }
  149. static int migor_nand_flash_ready(struct mtd_info *mtd)
  150. {
  151. return ctrl_inb(PORT_PADR) & 0x02; /* PTA1 */
  152. }
  153. struct platform_nand_data migor_nand_flash_data = {
  154. .chip = {
  155. .nr_chips = 1,
  156. .partitions = migor_nand_flash_partitions,
  157. .nr_partitions = ARRAY_SIZE(migor_nand_flash_partitions),
  158. .chip_delay = 20,
  159. .part_probe_types = (const char *[]) { "cmdlinepart", NULL },
  160. },
  161. .ctrl = {
  162. .dev_ready = migor_nand_flash_ready,
  163. .cmd_ctrl = migor_nand_flash_cmd_ctl,
  164. },
  165. };
  166. static struct resource migor_nand_flash_resources[] = {
  167. [0] = {
  168. .name = "NAND Flash",
  169. .start = 0x18000000,
  170. .end = 0x18ffffff,
  171. .flags = IORESOURCE_MEM,
  172. },
  173. };
  174. static struct platform_device migor_nand_flash_device = {
  175. .name = "gen_nand",
  176. .resource = migor_nand_flash_resources,
  177. .num_resources = ARRAY_SIZE(migor_nand_flash_resources),
  178. .dev = {
  179. .platform_data = &migor_nand_flash_data,
  180. }
  181. };
  182. static struct platform_device *migor_devices[] __initdata = {
  183. &smc91x_eth_device,
  184. &sh_keysc_device,
  185. &migor_nor_flash_device,
  186. &migor_nand_flash_device,
  187. };
  188. static struct i2c_board_info __initdata migor_i2c_devices[] = {
  189. {
  190. I2C_BOARD_INFO("rs5c372b", 0x32),
  191. },
  192. {
  193. I2C_BOARD_INFO("migor_ts", 0x51),
  194. .irq = 38, /* IRQ6 */
  195. },
  196. };
  197. static int __init migor_devices_setup(void)
  198. {
  199. i2c_register_board_info(0, migor_i2c_devices,
  200. ARRAY_SIZE(migor_i2c_devices));
  201. return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
  202. }
  203. __initcall(migor_devices_setup);
  204. static void __init migor_setup(char **cmdline_p)
  205. {
  206. /* SMC91C111 - Enable IRQ0 */
  207. ctrl_outw(ctrl_inw(PORT_PJCR) & ~0x0003, PORT_PJCR);
  208. /* KEYSC */
  209. ctrl_outw(ctrl_inw(PORT_PYCR) & ~0x0fff, PORT_PYCR);
  210. ctrl_outw(ctrl_inw(PORT_PZCR) & ~0x0ff0, PORT_PZCR);
  211. ctrl_outw(ctrl_inw(PORT_PSELA) & ~0x4100, PORT_PSELA);
  212. ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
  213. ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
  214. ctrl_outl(ctrl_inl(MSTPCR2) & ~0x00004000, MSTPCR2);
  215. /* NAND Flash */
  216. ctrl_outw(ctrl_inw(PORT_PXCR) & 0x0fff, PORT_PXCR);
  217. ctrl_outl((ctrl_inl(BSC_CS6ABCR) & ~0x00000600) | 0x00000200,
  218. BSC_CS6ABCR);
  219. /* I2C */
  220. ctrl_outl(ctrl_inl(MSTPCR1) & ~0x00000200, MSTPCR1);
  221. /* Touch Panel - Enable IRQ6 */
  222. ctrl_outw(ctrl_inw(PORT_PZCR) & ~0xc, PORT_PZCR);
  223. ctrl_outw((ctrl_inw(PORT_PSELA) | 0x8000), PORT_PSELA);
  224. ctrl_outw((ctrl_inw(PORT_HIZCRC) & ~0x4000), PORT_HIZCRC);
  225. }
  226. static struct sh_machine_vector mv_migor __initmv = {
  227. .mv_name = "Migo-R",
  228. .mv_setup = migor_setup,
  229. };