platform.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * MTX-1 platform devices registration
  3. *
  4. * Copyright (C) 2007-2009, Florian Fainelli <florian@openwrt.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/leds.h>
  23. #include <linux/gpio.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/input.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/mtd/physmap.h>
  28. #include <mtd/mtd-abi.h>
  29. #include <asm/mach-au1x00/au1xxx_eth.h>
  30. static struct gpio_keys_button mtx1_gpio_button[] = {
  31. {
  32. .gpio = 207,
  33. .code = BTN_0,
  34. .desc = "System button",
  35. }
  36. };
  37. static struct gpio_keys_platform_data mtx1_buttons_data = {
  38. .buttons = mtx1_gpio_button,
  39. .nbuttons = ARRAY_SIZE(mtx1_gpio_button),
  40. };
  41. static struct platform_device mtx1_button = {
  42. .name = "gpio-keys",
  43. .id = -1,
  44. .dev = {
  45. .platform_data = &mtx1_buttons_data,
  46. }
  47. };
  48. static struct resource mtx1_wdt_res[] = {
  49. [0] = {
  50. .start = 15,
  51. .end = 15,
  52. .name = "mtx1-wdt-gpio",
  53. .flags = IORESOURCE_IRQ,
  54. }
  55. };
  56. static struct platform_device mtx1_wdt = {
  57. .name = "mtx1-wdt",
  58. .id = 0,
  59. .num_resources = ARRAY_SIZE(mtx1_wdt_res),
  60. .resource = mtx1_wdt_res,
  61. };
  62. static struct gpio_led default_leds[] = {
  63. {
  64. .name = "mtx1:green",
  65. .gpio = 211,
  66. }, {
  67. .name = "mtx1:red",
  68. .gpio = 212,
  69. },
  70. };
  71. static struct gpio_led_platform_data mtx1_led_data = {
  72. .num_leds = ARRAY_SIZE(default_leds),
  73. .leds = default_leds,
  74. };
  75. static struct platform_device mtx1_gpio_leds = {
  76. .name = "leds-gpio",
  77. .id = -1,
  78. .dev = {
  79. .platform_data = &mtx1_led_data,
  80. }
  81. };
  82. static struct mtd_partition mtx1_mtd_partitions[] = {
  83. {
  84. .name = "filesystem",
  85. .size = 0x01C00000,
  86. .offset = 0,
  87. },
  88. {
  89. .name = "yamon",
  90. .size = 0x00100000,
  91. .offset = MTDPART_OFS_APPEND,
  92. .mask_flags = MTD_WRITEABLE,
  93. },
  94. {
  95. .name = "kernel",
  96. .size = 0x002c0000,
  97. .offset = MTDPART_OFS_APPEND,
  98. },
  99. {
  100. .name = "yamon env",
  101. .size = 0x00040000,
  102. .offset = MTDPART_OFS_APPEND,
  103. },
  104. };
  105. static struct physmap_flash_data mtx1_flash_data = {
  106. .width = 4,
  107. .nr_parts = 4,
  108. .parts = mtx1_mtd_partitions,
  109. };
  110. static struct resource mtx1_mtd_resource = {
  111. .start = 0x1e000000,
  112. .end = 0x1fffffff,
  113. .flags = IORESOURCE_MEM,
  114. };
  115. static struct platform_device mtx1_mtd = {
  116. .name = "physmap-flash",
  117. .dev = {
  118. .platform_data = &mtx1_flash_data,
  119. },
  120. .num_resources = 1,
  121. .resource = &mtx1_mtd_resource,
  122. };
  123. static struct __initdata platform_device * mtx1_devs[] = {
  124. &mtx1_gpio_leds,
  125. &mtx1_wdt,
  126. &mtx1_button,
  127. &mtx1_mtd,
  128. };
  129. static struct au1000_eth_platform_data mtx1_au1000_eth0_pdata = {
  130. .phy_search_highest_addr = 1,
  131. .phy1_search_mac0 = 1,
  132. };
  133. static int __init mtx1_register_devices(void)
  134. {
  135. int rc;
  136. au1xxx_override_eth_cfg(0, &mtx1_au1000_eth0_pdata);
  137. rc = gpio_request(mtx1_gpio_button[0].gpio,
  138. mtx1_gpio_button[0].desc);
  139. if (rc < 0) {
  140. printk(KERN_INFO "mtx1: failed to request %d\n",
  141. mtx1_gpio_button[0].gpio);
  142. goto out;
  143. }
  144. gpio_direction_input(mtx1_gpio_button[0].gpio);
  145. out:
  146. return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
  147. }
  148. arch_initcall(mtx1_register_devices);