board-apsh4ad0a.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * ALPHAPROJECT AP-SH4AD-0A Support.
  3. *
  4. * Copyright (C) 2010 ALPHAPROJECT Co.,Ltd.
  5. * Copyright (C) 2010 Matt Fleming
  6. * Copyright (C) 2010 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/regulator/fixed.h>
  16. #include <linux/regulator/machine.h>
  17. #include <linux/smsc911x.h>
  18. #include <linux/irq.h>
  19. #include <linux/clk.h>
  20. #include <asm/machvec.h>
  21. #include <asm/sizes.h>
  22. /* Dummy supplies, where voltage doesn't matter */
  23. static struct regulator_consumer_supply dummy_supplies[] = {
  24. REGULATOR_SUPPLY("vddvario", "smsc911x"),
  25. REGULATOR_SUPPLY("vdd33a", "smsc911x"),
  26. };
  27. static struct resource smsc911x_resources[] = {
  28. [0] = {
  29. .name = "smsc911x-memory",
  30. .start = 0xA4000000,
  31. .end = 0xA4000000 + SZ_256 - 1,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. [1] = {
  35. .name = "smsc911x-irq",
  36. .start = evt2irq(0x200),
  37. .end = evt2irq(0x200),
  38. .flags = IORESOURCE_IRQ,
  39. },
  40. };
  41. static struct smsc911x_platform_config smsc911x_config = {
  42. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  43. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  44. .flags = SMSC911X_USE_16BIT,
  45. .phy_interface = PHY_INTERFACE_MODE_MII,
  46. };
  47. static struct platform_device smsc911x_device = {
  48. .name = "smsc911x",
  49. .id = -1,
  50. .num_resources = ARRAY_SIZE(smsc911x_resources),
  51. .resource = smsc911x_resources,
  52. .dev = {
  53. .platform_data = &smsc911x_config,
  54. },
  55. };
  56. static struct platform_device *apsh4ad0a_devices[] __initdata = {
  57. &smsc911x_device,
  58. };
  59. static int __init apsh4ad0a_devices_setup(void)
  60. {
  61. regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
  62. return platform_add_devices(apsh4ad0a_devices,
  63. ARRAY_SIZE(apsh4ad0a_devices));
  64. }
  65. device_initcall(apsh4ad0a_devices_setup);
  66. static int apsh4ad0a_mode_pins(void)
  67. {
  68. int value = 0;
  69. /* These are the factory default settings of SW1 and SW2.
  70. * If you change these dip switches then you will need to
  71. * adjust the values below as well.
  72. */
  73. value |= MODE_PIN0; /* Clock Mode 3 */
  74. value |= MODE_PIN1;
  75. value &= ~MODE_PIN2;
  76. value &= ~MODE_PIN3;
  77. value &= ~MODE_PIN4; /* 16-bit Area0 bus width */
  78. value |= MODE_PIN5;
  79. value |= MODE_PIN6;
  80. value |= MODE_PIN7; /* Normal mode */
  81. value |= MODE_PIN8; /* Little Endian */
  82. value |= MODE_PIN9; /* Crystal resonator */
  83. value &= ~MODE_PIN10; /* 29-bit address mode */
  84. value &= ~MODE_PIN11; /* PCI-E Root port */
  85. value &= ~MODE_PIN12; /* 4 lane + 1 lane */
  86. value |= MODE_PIN13; /* AUD Enable */
  87. value &= ~MODE_PIN14; /* Normal Operation */
  88. return value;
  89. }
  90. static int apsh4ad0a_clk_init(void)
  91. {
  92. struct clk *clk;
  93. int ret;
  94. clk = clk_get(NULL, "extal");
  95. if (IS_ERR(clk))
  96. return PTR_ERR(clk);
  97. ret = clk_set_rate(clk, 33333000);
  98. clk_put(clk);
  99. return ret;
  100. }
  101. /* Initialize the board */
  102. static void __init apsh4ad0a_setup(char **cmdline_p)
  103. {
  104. pr_info("Alpha Project AP-SH4AD-0A support:\n");
  105. }
  106. static void __init apsh4ad0a_init_irq(void)
  107. {
  108. plat_irq_setup_pins(IRQ_MODE_IRQ3210);
  109. }
  110. /*
  111. * The Machine Vector
  112. */
  113. static struct sh_machine_vector mv_apsh4ad0a __initmv = {
  114. .mv_name = "AP-SH4AD-0A",
  115. .mv_setup = apsh4ad0a_setup,
  116. .mv_mode_pins = apsh4ad0a_mode_pins,
  117. .mv_clk_init = apsh4ad0a_clk_init,
  118. .mv_init_irq = apsh4ad0a_init_irq,
  119. };