mach-dir-300-revb.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * D-Link DIR-300 rev B board support
  3. *
  4. * Copyright (C) 2009-2010 Gabor Juhos <[email protected]>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mtd/mtd.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/mtd/physmap.h>
  15. #include <asm/mach-ralink/machine.h>
  16. #include <asm/mach-ralink/dev-gpio-buttons.h>
  17. #include <asm/mach-ralink/dev-gpio-leds.h>
  18. #include <asm/mach-ralink/rt305x.h>
  19. #include <asm/mach-ralink/rt305x_regs.h>
  20. #include "devices.h"
  21. #define DIR_300B_GPIO_LED_STATUS_AMBER 8
  22. #define DIR_300B_GPIO_LED_STATUS_GREEN 9
  23. #define DIR_300B_GPIO_LED_WPS 13
  24. #define DIR_300B_GPIO_BUTTON_WPS 0 /* active low */
  25. #define DIR_300B_GPIO_BUTTON_RESET 10 /* active low */
  26. #define DIR_300B_BUTTONS_POLL_INTERVAL 20
  27. #ifdef CONFIG_MTD_PARTITIONS
  28. static struct mtd_partition dir_300b_partitions[] = {
  29. {
  30. .name = "u-boot",
  31. .offset = 0,
  32. .size = 0x030000,
  33. .mask_flags = MTD_WRITEABLE,
  34. }, {
  35. .name = "devdata",
  36. .offset = 0x030000,
  37. .size = 0x010000,
  38. .mask_flags = MTD_WRITEABLE,
  39. }, {
  40. .name = "devconf",
  41. .offset = 0x040000,
  42. .size = 0x010000,
  43. .mask_flags = MTD_WRITEABLE,
  44. }, {
  45. .name = "kernel",
  46. .offset = 0x050000,
  47. .size = 0x090000,
  48. }, {
  49. .name = "rootfs",
  50. .offset = 0x140000,
  51. .size = 0x2B0000,
  52. }, {
  53. .name = "openwrt",
  54. .offset = 0x050000,
  55. .size = 0x3a0000,
  56. }
  57. };
  58. #endif /* CONFIG_MTD_PARTITIONS */
  59. static struct physmap_flash_data dir_300b_flash_data = {
  60. #ifdef CONFIG_MTD_PARTITIONS
  61. .nr_parts = ARRAY_SIZE(dir_300b_partitions),
  62. .parts = dir_300b_partitions,
  63. #endif
  64. };
  65. static struct gpio_led dir_300b_leds_gpio[] __initdata = {
  66. {
  67. .name = "dir-300b:amber:status",
  68. .gpio = DIR_300B_GPIO_LED_STATUS_AMBER,
  69. .active_low = 1,
  70. }, {
  71. .name = "dir-300b:green:status",
  72. .gpio = DIR_300B_GPIO_LED_STATUS_GREEN,
  73. .active_low = 1,
  74. }, {
  75. .name = "dir-300b:blue:wps",
  76. .gpio = DIR_300B_GPIO_LED_WPS,
  77. .active_low = 1,
  78. }
  79. };
  80. static struct gpio_button dir_300b_gpio_buttons[] __initdata = {
  81. {
  82. .desc = "reset",
  83. .type = EV_KEY,
  84. .code = BTN_0,
  85. .threshold = 3,
  86. .gpio = DIR_300B_GPIO_BUTTON_RESET,
  87. .active_low = 1,
  88. }, {
  89. .desc = "wps",
  90. .type = EV_KEY,
  91. .code = BTN_1,
  92. .threshold = 3,
  93. .gpio = DIR_300B_GPIO_BUTTON_WPS,
  94. .active_low = 1,
  95. }
  96. };
  97. static void __init dir_300b_init(void)
  98. {
  99. rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
  100. rt305x_register_flash(0, &dir_300b_flash_data);
  101. rt305x_register_ethernet();
  102. ramips_register_gpio_leds(-1, ARRAY_SIZE(dir_300b_leds_gpio),
  103. dir_300b_leds_gpio);
  104. ramips_register_gpio_buttons(-1, DIR_300B_BUTTONS_POLL_INTERVAL,
  105. ARRAY_SIZE(dir_300b_gpio_buttons),
  106. dir_300b_gpio_buttons);
  107. rt305x_register_wifi();
  108. }
  109. MIPS_MACHINE(RAMIPS_MACH_DIR_300_REVB, "DIR-300-revB", "D-Link DIR-300 revB",
  110. dir_300b_init);