setup.c 6.0 KB

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