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