board-apsh4ad0a.c 3.2 KB

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