board-urquell.c 5.0 KB

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