board-apsh4ad0a.c 3.0 KB

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