devices-rsk7203.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Renesas Technology Europe RSK+ 7203 Support.
  3. *
  4. * Copyright (C) 2008 - 2010 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/types.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/smsc911x.h>
  15. #include <linux/input.h>
  16. #include <linux/gpio.h>
  17. #include <linux/gpio_keys.h>
  18. #include <linux/leds.h>
  19. #include <asm/machvec.h>
  20. #include <asm/io.h>
  21. #include <cpu/sh7203.h>
  22. static struct smsc911x_platform_config smsc911x_config = {
  23. .phy_interface = PHY_INTERFACE_MODE_MII,
  24. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  25. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  26. .flags = SMSC911X_USE_32BIT | SMSC911X_SWAP_FIFO,
  27. };
  28. static struct resource smsc911x_resources[] = {
  29. [0] = {
  30. .start = 0x24000000,
  31. .end = 0x240000ff,
  32. .flags = IORESOURCE_MEM,
  33. },
  34. [1] = {
  35. .start = 64,
  36. .end = 64,
  37. .flags = IORESOURCE_IRQ,
  38. },
  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 gpio_led rsk7203_gpio_leds[] = {
  50. {
  51. .name = "green",
  52. .gpio = GPIO_PE10,
  53. .active_low = 1,
  54. }, {
  55. .name = "orange",
  56. .default_trigger = "nand-disk",
  57. .gpio = GPIO_PE12,
  58. .active_low = 1,
  59. }, {
  60. .name = "red:timer",
  61. .default_trigger = "timer",
  62. .gpio = GPIO_PC14,
  63. .active_low = 1,
  64. }, {
  65. .name = "red:heartbeat",
  66. .default_trigger = "heartbeat",
  67. .gpio = GPIO_PE11,
  68. .active_low = 1,
  69. },
  70. };
  71. static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
  72. .leds = rsk7203_gpio_leds,
  73. .num_leds = ARRAY_SIZE(rsk7203_gpio_leds),
  74. };
  75. static struct platform_device led_device = {
  76. .name = "leds-gpio",
  77. .id = -1,
  78. .dev = {
  79. .platform_data = &rsk7203_gpio_leds_info,
  80. },
  81. };
  82. static struct gpio_keys_button rsk7203_gpio_keys_table[] = {
  83. {
  84. .code = BTN_0,
  85. .gpio = GPIO_PB0,
  86. .active_low = 1,
  87. .desc = "SW1",
  88. }, {
  89. .code = BTN_1,
  90. .gpio = GPIO_PB1,
  91. .active_low = 1,
  92. .desc = "SW2",
  93. }, {
  94. .code = BTN_2,
  95. .gpio = GPIO_PB2,
  96. .active_low = 1,
  97. .desc = "SW3",
  98. },
  99. };
  100. static struct gpio_keys_platform_data rsk7203_gpio_keys_info = {
  101. .buttons = rsk7203_gpio_keys_table,
  102. .nbuttons = ARRAY_SIZE(rsk7203_gpio_keys_table),
  103. .poll_interval = 50, /* default to 50ms */
  104. };
  105. static struct platform_device keys_device = {
  106. .name = "gpio-keys-polled",
  107. .dev = {
  108. .platform_data = &rsk7203_gpio_keys_info,
  109. },
  110. };
  111. static struct platform_device *rsk7203_devices[] __initdata = {
  112. &smsc911x_device,
  113. &led_device,
  114. &keys_device,
  115. };
  116. static int __init rsk7203_devices_setup(void)
  117. {
  118. /* Select pins for SCIF0 */
  119. gpio_request(GPIO_FN_TXD0, NULL);
  120. gpio_request(GPIO_FN_RXD0, NULL);
  121. /* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
  122. __raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
  123. gpio_request(GPIO_FN_IRQ0_PB, NULL);
  124. return platform_add_devices(rsk7203_devices,
  125. ARRAY_SIZE(rsk7203_devices));
  126. }
  127. device_initcall(rsk7203_devices_setup);