setup.c 5.5 KB

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