board-urquell.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * Renesas Technology Corp. SH7786 Urquell Support.
  3. *
  4. * Copyright (C) 2008 Kuninori Morimoto <morimoto.kuninori@renesas.com>
  5. * Copyright (C) 2009, 2010 Paul Mundt
  6. *
  7. * Based on board-sh7785lcr.c
  8. * Copyright (C) 2008 Yoshihiro Shimoda
  9. *
  10. * This file is subject to the terms and conditions of the GNU General Public
  11. * License. See the file "COPYING" in the main directory of this archive
  12. * for more details.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/fb.h>
  17. #include <linux/smc91x.h>
  18. #include <linux/mtd/physmap.h>
  19. #include <linux/delay.h>
  20. #include <linux/gpio.h>
  21. #include <linux/irq.h>
  22. #include <linux/clk.h>
  23. #include <linux/sh_intc.h>
  24. #include <mach/urquell.h>
  25. #include <cpu/sh7786.h>
  26. #include <asm/heartbeat.h>
  27. #include <asm/sizes.h>
  28. #include <asm/smp-ops.h>
  29. /*
  30. * bit 1234 5678
  31. *----------------------------
  32. * SW1 0101 0010 -> Pck 33MHz version
  33. * (1101 0010) Pck 66MHz version
  34. * SW2 0x1x xxxx -> little endian
  35. * 29bit mode
  36. * SW47 0001 1000 -> CS0 : on-board flash
  37. * CS1 : SRAM, registers, LAN, PCMCIA
  38. * 38400 bps for SCIF1
  39. *
  40. * Address
  41. * 0x00000000 - 0x04000000 (CS0) Nor Flash
  42. * 0x04000000 - 0x04200000 (CS1) SRAM
  43. * 0x05000000 - 0x05800000 (CS1) on board register
  44. * 0x05800000 - 0x06000000 (CS1) LAN91C111
  45. * 0x06000000 - 0x06400000 (CS1) PCMCIA
  46. * 0x08000000 - 0x10000000 (CS2-CS3) DDR3
  47. * 0x10000000 - 0x14000000 (CS4) PCIe
  48. * 0x14000000 - 0x14800000 (CS5) Core0 LRAM/URAM
  49. * 0x14800000 - 0x15000000 (CS5) Core1 LRAM/URAM
  50. * 0x18000000 - 0x1C000000 (CS6) ATA/NAND-Flash
  51. * 0x1C000000 - (CS7) SH7786 Control register
  52. */
  53. /* HeartBeat */
  54. static struct resource heartbeat_resource = {
  55. .start = BOARDREG(SLEDR),
  56. .end = BOARDREG(SLEDR),
  57. .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT,
  58. };
  59. static struct platform_device heartbeat_device = {
  60. .name = "heartbeat",
  61. .id = -1,
  62. .num_resources = 1,
  63. .resource = &heartbeat_resource,
  64. };
  65. /* LAN91C111 */
  66. static struct smc91x_platdata smc91x_info = {
  67. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  68. };
  69. static struct resource smc91x_eth_resources[] = {
  70. [0] = {
  71. .name = "SMC91C111" ,
  72. .start = 0x05800300,
  73. .end = 0x0580030f,
  74. .flags = IORESOURCE_MEM,
  75. },
  76. [1] = {
  77. .start = evt2irq(0x360),
  78. .flags = IORESOURCE_IRQ,
  79. },
  80. };
  81. static struct platform_device smc91x_eth_device = {
  82. .name = "smc91x",
  83. .num_resources = ARRAY_SIZE(smc91x_eth_resources),
  84. .resource = smc91x_eth_resources,
  85. .dev = {
  86. .platform_data = &smc91x_info,
  87. },
  88. };
  89. /* Nor Flash */
  90. static struct mtd_partition nor_flash_partitions[] = {
  91. {
  92. .name = "loader",
  93. .offset = 0x00000000,
  94. .size = SZ_512K,
  95. .mask_flags = MTD_WRITEABLE, /* Read-only */
  96. },
  97. {
  98. .name = "bootenv",
  99. .offset = MTDPART_OFS_APPEND,
  100. .size = SZ_512K,
  101. .mask_flags = MTD_WRITEABLE, /* Read-only */
  102. },
  103. {
  104. .name = "kernel",
  105. .offset = MTDPART_OFS_APPEND,
  106. .size = SZ_4M,
  107. },
  108. {
  109. .name = "data",
  110. .offset = MTDPART_OFS_APPEND,
  111. .size = MTDPART_SIZ_FULL,
  112. },
  113. };
  114. static struct physmap_flash_data nor_flash_data = {
  115. .width = 2,
  116. .parts = nor_flash_partitions,
  117. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  118. };
  119. static struct resource nor_flash_resources[] = {
  120. [0] = {
  121. .start = NOR_FLASH_ADDR,
  122. .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1,
  123. .flags = IORESOURCE_MEM,
  124. }
  125. };
  126. static struct platform_device nor_flash_device = {
  127. .name = "physmap-flash",
  128. .dev = {
  129. .platform_data = &nor_flash_data,
  130. },
  131. .num_resources = ARRAY_SIZE(nor_flash_resources),
  132. .resource = nor_flash_resources,
  133. };
  134. static struct platform_device *urquell_devices[] __initdata = {
  135. &heartbeat_device,
  136. &smc91x_eth_device,
  137. &nor_flash_device,
  138. };
  139. static int __init urquell_devices_setup(void)
  140. {
  141. /* USB */
  142. gpio_request(GPIO_FN_USB_OVC0, NULL);
  143. gpio_request(GPIO_FN_USB_PENC0, NULL);
  144. /* enable LAN */
  145. __raw_writew(__raw_readw(UBOARDREG(IRL2MSKR)) & ~0x00000001,
  146. UBOARDREG(IRL2MSKR));
  147. return platform_add_devices(urquell_devices,
  148. ARRAY_SIZE(urquell_devices));
  149. }
  150. device_initcall(urquell_devices_setup);
  151. static void urquell_power_off(void)
  152. {
  153. __raw_writew(0xa5a5, UBOARDREG(SRSTR));
  154. }
  155. static void __init urquell_init_irq(void)
  156. {
  157. plat_irq_setup_pins(IRQ_MODE_IRL3210_MASK);
  158. }
  159. static int urquell_mode_pins(void)
  160. {
  161. return __raw_readw(UBOARDREG(MDSWMR));
  162. }
  163. static int urquell_clk_init(void)
  164. {
  165. struct clk *clk;
  166. int ret;
  167. /*
  168. * Only handle the EXTAL case, anyone interfacing a crystal
  169. * resonator will need to provide their own input clock.
  170. */
  171. if (test_mode_pin(MODE_PIN9))
  172. return -EINVAL;
  173. clk = clk_get(NULL, "extal");
  174. if (IS_ERR(clk))
  175. return PTR_ERR(clk);
  176. ret = clk_set_rate(clk, 33333333);
  177. clk_put(clk);
  178. return ret;
  179. }
  180. /* Initialize the board */
  181. static void __init urquell_setup(char **cmdline_p)
  182. {
  183. printk(KERN_INFO "Renesas Technology Corp. Urquell support.\n");
  184. pm_power_off = urquell_power_off;
  185. register_smp_ops(&shx3_smp_ops);
  186. }
  187. /*
  188. * The Machine Vector
  189. */
  190. static struct sh_machine_vector mv_urquell __initmv = {
  191. .mv_name = "Urquell",
  192. .mv_setup = urquell_setup,
  193. .mv_init_irq = urquell_init_irq,
  194. .mv_mode_pins = urquell_mode_pins,
  195. .mv_clk_init = urquell_clk_init,
  196. };