wgt634u.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
  7. */
  8. #include <linux/platform_device.h>
  9. #include <linux/module.h>
  10. #include <linux/leds.h>
  11. #include <linux/mtd/physmap.h>
  12. #include <linux/ssb/ssb.h>
  13. #include <asm/mach-bcm47xx/bcm47xx.h>
  14. /* GPIO definitions for the WGT634U */
  15. #define WGT634U_GPIO_LED 3
  16. #define WGT634U_GPIO_RESET 2
  17. #define WGT634U_GPIO_TP1 7
  18. #define WGT634U_GPIO_TP2 6
  19. #define WGT634U_GPIO_TP3 5
  20. #define WGT634U_GPIO_TP4 4
  21. #define WGT634U_GPIO_TP5 1
  22. static struct gpio_led wgt634u_leds[] = {
  23. {
  24. .name = "power",
  25. .gpio = WGT634U_GPIO_LED,
  26. .active_low = 1,
  27. .default_trigger = "heartbeat",
  28. },
  29. };
  30. static struct gpio_led_platform_data wgt634u_led_data = {
  31. .num_leds = ARRAY_SIZE(wgt634u_leds),
  32. .leds = wgt634u_leds,
  33. };
  34. static struct platform_device wgt634u_gpio_leds = {
  35. .name = "leds-gpio",
  36. .id = -1,
  37. .dev = {
  38. .platform_data = &wgt634u_led_data,
  39. }
  40. };
  41. /* 8MiB flash. The struct mtd_partition matches original Netgear WGT634U
  42. firmware. */
  43. static struct mtd_partition wgt634u_partitions[] = {
  44. {
  45. .name = "cfe",
  46. .offset = 0,
  47. .size = 0x60000, /* 384k */
  48. .mask_flags = MTD_WRITEABLE /* force read-only */
  49. },
  50. {
  51. .name = "config",
  52. .offset = 0x60000,
  53. .size = 0x20000 /* 128k */
  54. },
  55. {
  56. .name = "linux",
  57. .offset = 0x80000,
  58. .size = 0x140000 /* 1280k */
  59. },
  60. {
  61. .name = "jffs",
  62. .offset = 0x1c0000,
  63. .size = 0x620000 /* 6272k */
  64. },
  65. {
  66. .name = "nvram",
  67. .offset = 0x7e0000,
  68. .size = 0x20000 /* 128k */
  69. },
  70. };
  71. static struct physmap_flash_data wgt634u_flash_data = {
  72. .parts = wgt634u_partitions,
  73. .nr_parts = ARRAY_SIZE(wgt634u_partitions)
  74. };
  75. static struct resource wgt634u_flash_resource = {
  76. .flags = IORESOURCE_MEM,
  77. };
  78. static struct platform_device wgt634u_flash = {
  79. .name = "physmap-flash",
  80. .id = 0,
  81. .dev = { .platform_data = &wgt634u_flash_data, },
  82. .resource = &wgt634u_flash_resource,
  83. .num_resources = 1,
  84. };
  85. /* Platform devices */
  86. static struct platform_device *wgt634u_devices[] __initdata = {
  87. &wgt634u_flash,
  88. &wgt634u_gpio_leds,
  89. };
  90. static int __init wgt634u_init(void)
  91. {
  92. /* There is no easy way to detect that we are running on a WGT634U
  93. * machine. Use the MAC address as an heuristic. Netgear Inc. has
  94. * been allocated ranges 00:09:5b:xx:xx:xx and 00:0f:b5:xx:xx:xx.
  95. */
  96. u8 *et0mac = ssb_bcm47xx.sprom.et0mac;
  97. if (et0mac[0] == 0x00 &&
  98. ((et0mac[1] == 0x09 && et0mac[2] == 0x5b) ||
  99. (et0mac[1] == 0x0f && et0mac[2] == 0xb5))) {
  100. struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
  101. wgt634u_flash_data.width = mcore->flash_buswidth;
  102. wgt634u_flash_resource.start = mcore->flash_window;
  103. wgt634u_flash_resource.end = mcore->flash_window
  104. + mcore->flash_window_size
  105. - 1;
  106. return platform_add_devices(wgt634u_devices,
  107. ARRAY_SIZE(wgt634u_devices));
  108. } else
  109. return -ENODEV;
  110. }
  111. module_init(wgt634u_init);