setup.c 6.2 KB

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