mach-pb44.c 2.5 KB

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