platform.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * MTX-1 platform devices registration
  3. *
  4. * Copyright (C) 2007, 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. static struct gpio_keys_button mtx1_gpio_button[] = {
  30. {
  31. .gpio = 207,
  32. .code = BTN_0,
  33. .desc = "System button",
  34. }
  35. };
  36. static struct gpio_keys_platform_data mtx1_buttons_data = {
  37. .buttons = mtx1_gpio_button,
  38. .nbuttons = ARRAY_SIZE(mtx1_gpio_button),
  39. };
  40. static struct platform_device mtx1_button = {
  41. .name = "gpio-keys",
  42. .id = -1,
  43. .dev = {
  44. .platform_data = &mtx1_buttons_data,
  45. }
  46. };
  47. static struct resource mtx1_wdt_res[] = {
  48. [0] = {
  49. .start = 15,
  50. .end = 15,
  51. .name = "mtx1-wdt-gpio",
  52. .flags = IORESOURCE_IRQ,
  53. }
  54. };
  55. static struct platform_device mtx1_wdt = {
  56. .name = "mtx1-wdt",
  57. .id = 0,
  58. .num_resources = ARRAY_SIZE(mtx1_wdt_res),
  59. .resource = mtx1_wdt_res,
  60. };
  61. static struct gpio_led default_leds[] = {
  62. {
  63. .name = "mtx1:green",
  64. .gpio = 211,
  65. }, {
  66. .name = "mtx1:red",
  67. .gpio = 212,
  68. },
  69. };
  70. static struct gpio_led_platform_data mtx1_led_data = {
  71. .num_leds = ARRAY_SIZE(default_leds),
  72. .leds = default_leds,
  73. };
  74. static struct platform_device mtx1_gpio_leds = {
  75. .name = "leds-gpio",
  76. .id = -1,
  77. .dev = {
  78. .platform_data = &mtx1_led_data,
  79. }
  80. };
  81. static struct mtd_partition mtx1_mtd_partitions[] = {
  82. {
  83. .name = "filesystem",
  84. .size = 0x01C00000,
  85. .offset = 0,
  86. },
  87. {
  88. .name = "yamon",
  89. .size = 0x00100000,
  90. .offset = MTDPART_OFS_APPEND,
  91. .mask_flags = MTD_WRITEABLE,
  92. },
  93. {
  94. .name = "kernel",
  95. .size = 0x002c0000,
  96. .offset = MTDPART_OFS_APPEND,
  97. },
  98. {
  99. .name = "yamon env",
  100. .size = 0x00040000,
  101. .offset = MTDPART_OFS_APPEND,
  102. },
  103. };
  104. static struct physmap_flash_data mtx1_flash_data = {
  105. .width = 4,
  106. .nr_parts = 4,
  107. .parts = mtx1_mtd_partitions,
  108. };
  109. static struct resource mtx1_mtd_resource = {
  110. .start = 0x1e000000,
  111. .end = 0x1fffffff,
  112. .flags = IORESOURCE_MEM,
  113. };
  114. static struct platform_device mtx1_mtd = {
  115. .name = "physmap-flash",
  116. .dev = {
  117. .platform_data = &mtx1_flash_data,
  118. },
  119. .num_resources = 1,
  120. .resource = &mtx1_mtd_resource,
  121. };
  122. static struct __initdata platform_device * mtx1_devs[] = {
  123. &mtx1_gpio_leds,
  124. &mtx1_wdt,
  125. &mtx1_button,
  126. &mtx1_mtd,
  127. };
  128. static int __init mtx1_register_devices(void)
  129. {
  130. gpio_direction_input(207);
  131. return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
  132. }
  133. arch_initcall(mtx1_register_devices);