mach-pb44.c 2.9 KB

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