mach-pb44.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Atheros PB44 reference board support
  3. *
  4. * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  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/i2c.h>
  13. #include <linux/gpio/machine.h>
  14. #include <linux/platform_data/pcf857x.h>
  15. #include "machtypes.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-spi.h"
  19. #include "dev-usb.h"
  20. #include "pci.h"
  21. #define PB44_GPIO_I2C_SCL 0
  22. #define PB44_GPIO_I2C_SDA 1
  23. #define PB44_GPIO_EXP_BASE 16
  24. #define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
  25. #define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
  26. #define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
  27. #define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + 10)
  28. #define PB44_KEYS_POLL_INTERVAL 20 /* msecs */
  29. #define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
  30. static struct gpiod_lookup_table pb44_i2c_gpiod_table = {
  31. .dev_id = "i2c-gpio.0",
  32. .table = {
  33. GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SDA,
  34. NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  35. GPIO_LOOKUP_IDX("ath79-gpio", PB44_GPIO_I2C_SCL,
  36. NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
  37. },
  38. };
  39. static struct platform_device pb44_i2c_gpio_device = {
  40. .name = "i2c-gpio",
  41. .id = 0,
  42. .dev = {
  43. .platform_data = NULL,
  44. }
  45. };
  46. static struct pcf857x_platform_data pb44_pcf857x_data = {
  47. .gpio_base = PB44_GPIO_EXP_BASE,
  48. };
  49. static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
  50. {
  51. I2C_BOARD_INFO("pcf8575", 0x20),
  52. .platform_data = &pb44_pcf857x_data,
  53. },
  54. };
  55. static struct gpio_led pb44_leds_gpio[] __initdata = {
  56. {
  57. .name = "pb44:amber:jump1",
  58. .gpio = PB44_GPIO_LED_JUMP1,
  59. .active_low = 1,
  60. }, {
  61. .name = "pb44:green:jump2",
  62. .gpio = PB44_GPIO_LED_JUMP2,
  63. .active_low = 1,
  64. },
  65. };
  66. static struct gpio_keys_button pb44_gpio_keys[] __initdata = {
  67. {
  68. .desc = "soft_reset",
  69. .type = EV_KEY,
  70. .code = KEY_RESTART,
  71. .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
  72. .gpio = PB44_GPIO_SW_RESET,
  73. .active_low = 1,
  74. } , {
  75. .desc = "jumpstart",
  76. .type = EV_KEY,
  77. .code = KEY_WPS_BUTTON,
  78. .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
  79. .gpio = PB44_GPIO_SW_JUMP,
  80. .active_low = 1,
  81. }
  82. };
  83. static struct spi_board_info pb44_spi_info[] = {
  84. {
  85. .bus_num = 0,
  86. .chip_select = 0,
  87. .max_speed_hz = 25000000,
  88. .modalias = "m25p64",
  89. },
  90. };
  91. static struct ath79_spi_platform_data pb44_spi_data = {
  92. .bus_num = 0,
  93. .num_chipselect = 1,
  94. };
  95. static void __init pb44_init(void)
  96. {
  97. gpiod_add_lookup_table(&pb44_i2c_gpiod_table);
  98. i2c_register_board_info(0, pb44_i2c_board_info,
  99. ARRAY_SIZE(pb44_i2c_board_info));
  100. platform_device_register(&pb44_i2c_gpio_device);
  101. ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
  102. pb44_leds_gpio);
  103. ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
  104. ARRAY_SIZE(pb44_gpio_keys),
  105. pb44_gpio_keys);
  106. ath79_register_spi(&pb44_spi_data, pb44_spi_info,
  107. ARRAY_SIZE(pb44_spi_info));
  108. ath79_register_usb();
  109. ath79_register_pci();
  110. }
  111. MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
  112. pb44_init);