mach-all0258n.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Allnet ALL0258N support
  3. *
  4. * Copyright (C) 2011 Daniel Golle <[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/mtd/mtd.h>
  11. #include <linux/mtd/partitions.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include "dev-eth.h"
  14. #include "dev-ap9x-pci.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "machtypes.h"
  19. /* found via /sys/gpio/... try and error */
  20. #define ALL0258N_GPIO_BTN_RESET 1
  21. #define ALL0258N_GPIO_LED_RSSIHIGH 13
  22. #define ALL0258N_GPIO_LED_RSSIMEDIUM 15
  23. #define ALL0258N_GPIO_LED_RSSILOW 14
  24. /* defaults taken from others machs */
  25. #define ALL0258N_KEYS_POLL_INTERVAL 20 /* msecs */
  26. #define ALL0258N_KEYS_DEBOUNCE_INTERVAL (3 * ALL0258N_KEYS_POLL_INTERVAL)
  27. /* showed up in the original firmware's bootlog */
  28. #define ALL0258N_SEC_PHYMASK BIT(3)
  29. /*
  30. * from U-Boot bootargs of original firmware:
  31. * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),320k(custom),1024k(kernel),4928k(rootfs),1536k(failsafe),64k(ART)
  32. * we use a more OpenWrt-friendly layout now:
  33. * mtdparts=ar7240-nor0:256k(u-boot),64k(u-boot-env),896k(kernel),5376k(rootfs),1536k(failsafe),64k(ART)
  34. */
  35. static struct mtd_partition all0258n_partitions[] = {
  36. {
  37. .name = "u-boot",
  38. .offset = 0,
  39. .size = 0x040000,
  40. .mask_flags = MTD_WRITEABLE,
  41. }, {
  42. .name = "u-boot-env",
  43. .offset = 0x040000,
  44. .size = 0x010000,
  45. }, {
  46. .name = "kernel",
  47. .offset = 0x050000,
  48. .size = 0x0E0000,
  49. }, {
  50. .name = "rootfs",
  51. .offset = 0x130000,
  52. .size = 0x540000,
  53. }, {
  54. .name = "failsafe",
  55. .offset = 0x670000,
  56. .size = 0x180000,
  57. }, {
  58. .name = "firmware",
  59. .offset = 0x050000,
  60. .size = 0x620000,
  61. }, {
  62. .name = "art",
  63. .offset = 0x7F0000,
  64. .size = 0x010000,
  65. .mask_flags = MTD_WRITEABLE,
  66. }
  67. };
  68. static struct flash_platform_data all0258n_flash_data = {
  69. .parts = all0258n_partitions,
  70. .nr_parts = ARRAY_SIZE(all0258n_partitions),
  71. };
  72. static struct gpio_led all0258n_leds_gpio[] __initdata = {
  73. {
  74. .name = "all0258n:green:rssihigh",
  75. .gpio = ALL0258N_GPIO_LED_RSSIHIGH,
  76. .active_low = 1,
  77. }, {
  78. .name = "all0258n:yellow:rssimedium",
  79. .gpio = ALL0258N_GPIO_LED_RSSIMEDIUM,
  80. .active_low = 1,
  81. }, {
  82. .name = "all0258n:red:rssilow",
  83. .gpio = ALL0258N_GPIO_LED_RSSILOW,
  84. .active_low = 1,
  85. }
  86. };
  87. static struct gpio_keys_button all0258n_gpio_keys[] __initdata = {
  88. {
  89. .desc = "reset",
  90. .type = EV_KEY,
  91. .code = KEY_RESTART,
  92. .debounce_interval = ALL0258N_KEYS_DEBOUNCE_INTERVAL,
  93. .gpio = ALL0258N_GPIO_BTN_RESET,
  94. .active_low = 1,
  95. }
  96. };
  97. static void __init all0258n_setup(void)
  98. {
  99. u8 *mac = (u8 *) KSEG1ADDR(0x1f7f0000);
  100. u8 *ee = (u8 *) KSEG1ADDR(0x1f7f1000);
  101. ath79_register_m25p80(&all0258n_flash_data);
  102. ath79_register_leds_gpio(-1, ARRAY_SIZE(all0258n_leds_gpio),
  103. all0258n_leds_gpio);
  104. ath79_register_gpio_keys_polled(-1, ALL0258N_KEYS_POLL_INTERVAL,
  105. ARRAY_SIZE(all0258n_gpio_keys),
  106. all0258n_gpio_keys);
  107. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  108. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  109. ath79_eth1_data.phy_mask = ALL0258N_SEC_PHYMASK;
  110. ath79_register_mdio(0, 0x0);
  111. ath79_register_eth(0);
  112. ath79_register_eth(1);
  113. ap91_pci_init(ee, mac);
  114. }
  115. MIPS_MACHINE(ATH79_MACH_ALL0258N, "ALL0258N", "Allnet ALL0258N",
  116. all0258n_setup);