mach-pb44.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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/i2c-gpio.h>
  14. #include <linux/i2c/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. #define PB44_GPIO_I2C_SCL 0
  21. #define PB44_GPIO_I2C_SDA 1
  22. #define PB44_GPIO_EXP_BASE 16
  23. #define PB44_GPIO_SW_RESET (PB44_GPIO_EXP_BASE + 6)
  24. #define PB44_GPIO_SW_JUMP (PB44_GPIO_EXP_BASE + 8)
  25. #define PB44_GPIO_LED_JUMP1 (PB44_GPIO_EXP_BASE + 9)
  26. #define PB44_GPIO_LED_JUMP2 (PB44_GPIO_EXP_BASE + 10)
  27. #define PB44_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define PB44_KEYS_DEBOUNCE_INTERVAL (3 * PB44_KEYS_POLL_INTERVAL)
  29. static struct i2c_gpio_platform_data pb44_i2c_gpio_data = {
  30. .sda_pin = PB44_GPIO_I2C_SDA,
  31. .scl_pin = PB44_GPIO_I2C_SCL,
  32. };
  33. static struct platform_device pb44_i2c_gpio_device = {
  34. .name = "i2c-gpio",
  35. .id = 0,
  36. .dev = {
  37. .platform_data = &pb44_i2c_gpio_data,
  38. }
  39. };
  40. static struct pcf857x_platform_data pb44_pcf857x_data = {
  41. .gpio_base = PB44_GPIO_EXP_BASE,
  42. };
  43. static struct i2c_board_info pb44_i2c_board_info[] __initdata = {
  44. {
  45. I2C_BOARD_INFO("pcf8575", 0x20),
  46. .platform_data = &pb44_pcf857x_data,
  47. },
  48. };
  49. static struct gpio_led pb44_leds_gpio[] __initdata = {
  50. {
  51. .name = "pb44:amber:jump1",
  52. .gpio = PB44_GPIO_LED_JUMP1,
  53. .active_low = 1,
  54. }, {
  55. .name = "pb44:green:jump2",
  56. .gpio = PB44_GPIO_LED_JUMP2,
  57. .active_low = 1,
  58. },
  59. };
  60. static struct gpio_keys_button pb44_gpio_keys[] __initdata = {
  61. {
  62. .desc = "soft_reset",
  63. .type = EV_KEY,
  64. .code = KEY_RESTART,
  65. .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
  66. .gpio = PB44_GPIO_SW_RESET,
  67. .active_low = 1,
  68. } , {
  69. .desc = "jumpstart",
  70. .type = EV_KEY,
  71. .code = KEY_WPS_BUTTON,
  72. .debounce_interval = PB44_KEYS_DEBOUNCE_INTERVAL,
  73. .gpio = PB44_GPIO_SW_JUMP,
  74. .active_low = 1,
  75. }
  76. };
  77. static struct spi_board_info pb44_spi_info[] = {
  78. {
  79. .bus_num = 0,
  80. .chip_select = 0,
  81. .max_speed_hz = 25000000,
  82. .modalias = "m25p64",
  83. },
  84. };
  85. static struct ath79_spi_platform_data pb44_spi_data = {
  86. .bus_num = 0,
  87. .num_chipselect = 1,
  88. };
  89. static void __init pb44_init(void)
  90. {
  91. i2c_register_board_info(0, pb44_i2c_board_info,
  92. ARRAY_SIZE(pb44_i2c_board_info));
  93. platform_device_register(&pb44_i2c_gpio_device);
  94. ath79_register_leds_gpio(-1, ARRAY_SIZE(pb44_leds_gpio),
  95. pb44_leds_gpio);
  96. ath79_register_gpio_keys_polled(-1, PB44_KEYS_POLL_INTERVAL,
  97. ARRAY_SIZE(pb44_gpio_keys),
  98. pb44_gpio_keys);
  99. ath79_register_spi(&pb44_spi_data, pb44_spi_info,
  100. ARRAY_SIZE(pb44_spi_info));
  101. ath79_register_usb();
  102. }
  103. MIPS_MACHINE(ATH79_MACH_PB44, "PB44", "Atheros PB44 reference board",
  104. pb44_init);