board-apsh4a3a.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * ALPHAPROJECT AP-SH4A-3A Support.
  3. *
  4. * Copyright (C) 2010 ALPHAPROJECT Co.,Ltd.
  5. * Copyright (C) 2008 Yoshihiro Shimoda
  6. * Copyright (C) 2009 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/io.h>
  15. #include <linux/mtd/physmap.h>
  16. #include <linux/smsc911x.h>
  17. #include <linux/irq.h>
  18. #include <linux/clk.h>
  19. #include <asm/machvec.h>
  20. #include <asm/sizes.h>
  21. #include <asm/clock.h>
  22. static struct mtd_partition nor_flash_partitions[] = {
  23. {
  24. .name = "loader",
  25. .offset = 0x00000000,
  26. .size = 512 * 1024,
  27. },
  28. {
  29. .name = "bootenv",
  30. .offset = MTDPART_OFS_APPEND,
  31. .size = 512 * 1024,
  32. },
  33. {
  34. .name = "kernel",
  35. .offset = MTDPART_OFS_APPEND,
  36. .size = 4 * 1024 * 1024,
  37. },
  38. {
  39. .name = "data",
  40. .offset = MTDPART_OFS_APPEND,
  41. .size = MTDPART_SIZ_FULL,
  42. },
  43. };
  44. static struct physmap_flash_data nor_flash_data = {
  45. .width = 4,
  46. .parts = nor_flash_partitions,
  47. .nr_parts = ARRAY_SIZE(nor_flash_partitions),
  48. };
  49. static struct resource nor_flash_resources[] = {
  50. [0] = {
  51. .start = 0x00000000,
  52. .end = 0x01000000 - 1,
  53. .flags = IORESOURCE_MEM,
  54. }
  55. };
  56. static struct platform_device nor_flash_device = {
  57. .name = "physmap-flash",
  58. .dev = {
  59. .platform_data = &nor_flash_data,
  60. },
  61. .num_resources = ARRAY_SIZE(nor_flash_resources),
  62. .resource = nor_flash_resources,
  63. };
  64. static struct resource smsc911x_resources[] = {
  65. [0] = {
  66. .name = "smsc911x-memory",
  67. .start = 0xA4000000,
  68. .end = 0xA4000000 + SZ_256 - 1,
  69. .flags = IORESOURCE_MEM,
  70. },
  71. [1] = {
  72. .name = "smsc911x-irq",
  73. .start = evt2irq(0x200),
  74. .end = evt2irq(0x200),
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. };
  78. static struct smsc911x_platform_config smsc911x_config = {
  79. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  80. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  81. .flags = SMSC911X_USE_16BIT,
  82. .phy_interface = PHY_INTERFACE_MODE_MII,
  83. };
  84. static struct platform_device smsc911x_device = {
  85. .name = "smsc911x",
  86. .id = -1,
  87. .num_resources = ARRAY_SIZE(smsc911x_resources),
  88. .resource = smsc911x_resources,
  89. .dev = {
  90. .platform_data = &smsc911x_config,
  91. },
  92. };
  93. static struct platform_device *apsh4a3a_devices[] __initdata = {
  94. &nor_flash_device,
  95. &smsc911x_device,
  96. };
  97. static int __init apsh4a3a_devices_setup(void)
  98. {
  99. return platform_add_devices(apsh4a3a_devices,
  100. ARRAY_SIZE(apsh4a3a_devices));
  101. }
  102. device_initcall(apsh4a3a_devices_setup);
  103. static int apsh4a3a_clk_init(void)
  104. {
  105. struct clk *clk;
  106. int ret;
  107. clk = clk_get(NULL, "extal");
  108. if (!clk || IS_ERR(clk))
  109. return PTR_ERR(clk);
  110. ret = clk_set_rate(clk, 33333000);
  111. clk_put(clk);
  112. return ret;
  113. }
  114. /* Initialize the board */
  115. static void __init apsh4a3a_setup(char **cmdline_p)
  116. {
  117. printk(KERN_INFO "Alpha Project AP-SH4A-3A support:\n");
  118. }
  119. static void __init apsh4a3a_init_irq(void)
  120. {
  121. plat_irq_setup_pins(IRQ_MODE_IRQ7654);
  122. }
  123. /* Return the board specific boot mode pin configuration */
  124. static int apsh4a3a_mode_pins(void)
  125. {
  126. int value = 0;
  127. /* These are the factory default settings of SW1 and SW2.
  128. * If you change these dip switches then you will need to
  129. * adjust the values below as well.
  130. */
  131. value &= ~MODE_PIN0; /* Clock Mode 16 */
  132. value &= ~MODE_PIN1;
  133. value &= ~MODE_PIN2;
  134. value &= ~MODE_PIN3;
  135. value |= MODE_PIN4;
  136. value &= ~MODE_PIN5; /* 16-bit Area0 bus width */
  137. value |= MODE_PIN6; /* Area 0 SRAM interface */
  138. value |= MODE_PIN7;
  139. value |= MODE_PIN8; /* Little Endian */
  140. value |= MODE_PIN9; /* Master Mode */
  141. value |= MODE_PIN10; /* Crystal resonator */
  142. value |= MODE_PIN11; /* Display Unit */
  143. value |= MODE_PIN12;
  144. value &= ~MODE_PIN13; /* 29-bit address mode */
  145. value |= MODE_PIN14; /* No PLL step-up */
  146. return value;
  147. }
  148. /*
  149. * The Machine Vector
  150. */
  151. static struct sh_machine_vector mv_apsh4a3a __initmv = {
  152. .mv_name = "AP-SH4A-3A",
  153. .mv_setup = apsh4a3a_setup,
  154. .mv_clk_init = apsh4a3a_clk_init,
  155. .mv_init_irq = apsh4a3a_init_irq,
  156. .mv_mode_pins = apsh4a3a_mode_pins,
  157. };