mach-pb44.c 2.9 KB

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