platform.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * GPR board platform device registration
  3. *
  4. * Copyright (C) 2010 Wolfgang Grandegger <wg@denx.de>
  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/mtd/partitions.h>
  23. #include <linux/mtd/physmap.h>
  24. #include <linux/leds.h>
  25. #include <linux/gpio.h>
  26. #include <linux/i2c.h>
  27. #include <linux/i2c-gpio.h>
  28. #include <asm/mach-au1x00/au1000.h>
  29. /*
  30. * Watchdog
  31. */
  32. static struct resource gpr_wdt_resource[] = {
  33. [0] = {
  34. .start = 1,
  35. .end = 1,
  36. .name = "gpr-adm6320-wdt",
  37. .flags = IORESOURCE_IRQ,
  38. }
  39. };
  40. static struct platform_device gpr_wdt_device = {
  41. .name = "adm6320-wdt",
  42. .id = 0,
  43. .num_resources = ARRAY_SIZE(gpr_wdt_resource),
  44. .resource = gpr_wdt_resource,
  45. };
  46. /*
  47. * FLASH
  48. *
  49. * 0x00000000-0x00200000 : "kernel"
  50. * 0x00200000-0x00a00000 : "rootfs"
  51. * 0x01d00000-0x01f00000 : "config"
  52. * 0x01c00000-0x01d00000 : "yamon"
  53. * 0x01d00000-0x01d40000 : "yamon env vars"
  54. * 0x00000000-0x00a00000 : "kernel+rootfs"
  55. */
  56. static struct mtd_partition gpr_mtd_partitions[] = {
  57. {
  58. .name = "kernel",
  59. .size = 0x00200000,
  60. .offset = 0,
  61. },
  62. {
  63. .name = "rootfs",
  64. .size = 0x00800000,
  65. .offset = MTDPART_OFS_APPEND,
  66. .mask_flags = MTD_WRITEABLE,
  67. },
  68. {
  69. .name = "config",
  70. .size = 0x00200000,
  71. .offset = 0x01d00000,
  72. },
  73. {
  74. .name = "yamon",
  75. .size = 0x00100000,
  76. .offset = 0x01c00000,
  77. },
  78. {
  79. .name = "yamon env vars",
  80. .size = 0x00040000,
  81. .offset = MTDPART_OFS_APPEND,
  82. },
  83. {
  84. .name = "kernel+rootfs",
  85. .size = 0x00a00000,
  86. .offset = 0,
  87. },
  88. };
  89. static struct physmap_flash_data gpr_flash_data = {
  90. .width = 4,
  91. .nr_parts = ARRAY_SIZE(gpr_mtd_partitions),
  92. .parts = gpr_mtd_partitions,
  93. };
  94. static struct resource gpr_mtd_resource = {
  95. .start = 0x1e000000,
  96. .end = 0x1fffffff,
  97. .flags = IORESOURCE_MEM,
  98. };
  99. static struct platform_device gpr_mtd_device = {
  100. .name = "physmap-flash",
  101. .dev = {
  102. .platform_data = &gpr_flash_data,
  103. },
  104. .num_resources = 1,
  105. .resource = &gpr_mtd_resource,
  106. };
  107. /*
  108. * LEDs
  109. */
  110. static struct gpio_led gpr_gpio_leds[] = {
  111. { /* green */
  112. .name = "gpr:green",
  113. .gpio = 4,
  114. .active_low = 1,
  115. },
  116. { /* red */
  117. .name = "gpr:red",
  118. .gpio = 5,
  119. .active_low = 1,
  120. }
  121. };
  122. static struct gpio_led_platform_data gpr_led_data = {
  123. .num_leds = ARRAY_SIZE(gpr_gpio_leds),
  124. .leds = gpr_gpio_leds,
  125. };
  126. static struct platform_device gpr_led_devices = {
  127. .name = "leds-gpio",
  128. .id = -1,
  129. .dev = {
  130. .platform_data = &gpr_led_data,
  131. }
  132. };
  133. /*
  134. * I2C
  135. */
  136. static struct i2c_gpio_platform_data gpr_i2c_data = {
  137. .sda_pin = 209,
  138. .sda_is_open_drain = 1,
  139. .scl_pin = 210,
  140. .scl_is_open_drain = 1,
  141. .udelay = 2, /* ~100 kHz */
  142. .timeout = HZ,
  143. };
  144. static struct platform_device gpr_i2c_device = {
  145. .name = "i2c-gpio",
  146. .id = -1,
  147. .dev.platform_data = &gpr_i2c_data,
  148. };
  149. static struct i2c_board_info gpr_i2c_info[] __initdata = {
  150. {
  151. I2C_BOARD_INFO("lm83", 0x18),
  152. .type = "lm83"
  153. }
  154. };
  155. static struct platform_device *gpr_devices[] __initdata = {
  156. &gpr_wdt_device,
  157. &gpr_mtd_device,
  158. &gpr_i2c_device,
  159. &gpr_led_devices,
  160. };
  161. static int __init gpr_dev_init(void)
  162. {
  163. i2c_register_board_info(0, gpr_i2c_info, ARRAY_SIZE(gpr_i2c_info));
  164. return platform_add_devices(gpr_devices, ARRAY_SIZE(gpr_devices));
  165. }
  166. device_initcall(gpr_dev_init);