devices-rsk7203.c 3.0 KB

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