diff options
author | Sundar Iyer <sundar.iyer@stericsson.com> | 2011-01-21 00:26:17 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2011-03-14 09:05:10 -0400 |
commit | 0c24352eada58dc3571647593e516b2d5b50014f (patch) | |
tree | bde43f747bc461568398884937060122354577e4 /arch/arm/mach-ux500/board-mop500-stuib.c | |
parent | 705e0984444bc7109c5686c36333b27119d8a888 (diff) |
mach-ux500: add ST-UIB platform data
The ST-UIB contains a matrix keypad interfaced with the
STMPE1601 port expander and a ROHM BU2101 touch panel.
Signed-off-by: Sundar Iyer <sundar.iyer@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'arch/arm/mach-ux500/board-mop500-stuib.c')
-rw-r--r-- | arch/arm/mach-ux500/board-mop500-stuib.c | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c index 7fa30217cc01..8b6323e229ff 100644 --- a/arch/arm/mach-ux500/board-mop500-stuib.c +++ b/arch/arm/mach-ux500/board-mop500-stuib.c | |||
@@ -6,9 +6,192 @@ | |||
6 | 6 | ||
7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
8 | #include <linux/init.h> | 8 | #include <linux/init.h> |
9 | #include <linux/mfd/stmpe.h> | ||
10 | #include <linux/input/bu21013.h> | ||
11 | #include <linux/gpio.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/i2c.h> | ||
14 | #include <linux/input/matrix_keypad.h> | ||
9 | 15 | ||
10 | #include "board-mop500.h" | 16 | #include "board-mop500.h" |
11 | 17 | ||
18 | /* STMPE/SKE keypad use this key layout */ | ||
19 | static const unsigned int mop500_keymap[] = { | ||
20 | KEY(2, 5, KEY_END), | ||
21 | KEY(4, 1, KEY_POWER), | ||
22 | KEY(3, 5, KEY_VOLUMEDOWN), | ||
23 | KEY(1, 3, KEY_3), | ||
24 | KEY(5, 2, KEY_RIGHT), | ||
25 | KEY(5, 0, KEY_9), | ||
26 | |||
27 | KEY(0, 5, KEY_MENU), | ||
28 | KEY(7, 6, KEY_ENTER), | ||
29 | KEY(4, 5, KEY_0), | ||
30 | KEY(6, 7, KEY_2), | ||
31 | KEY(3, 4, KEY_UP), | ||
32 | KEY(3, 3, KEY_DOWN), | ||
33 | |||
34 | KEY(6, 4, KEY_SEND), | ||
35 | KEY(6, 2, KEY_BACK), | ||
36 | KEY(4, 2, KEY_VOLUMEUP), | ||
37 | KEY(5, 5, KEY_1), | ||
38 | KEY(4, 3, KEY_LEFT), | ||
39 | KEY(3, 2, KEY_7), | ||
40 | }; | ||
41 | |||
42 | static const struct matrix_keymap_data mop500_keymap_data = { | ||
43 | .keymap = mop500_keymap, | ||
44 | .keymap_size = ARRAY_SIZE(mop500_keymap), | ||
45 | }; | ||
46 | /* | ||
47 | * STMPE1601 | ||
48 | */ | ||
49 | static struct stmpe_keypad_platform_data stmpe1601_keypad_data = { | ||
50 | .debounce_ms = 64, | ||
51 | .scan_count = 8, | ||
52 | .no_autorepeat = true, | ||
53 | .keymap_data = &mop500_keymap_data, | ||
54 | }; | ||
55 | |||
56 | static struct stmpe_platform_data stmpe1601_data = { | ||
57 | .id = 1, | ||
58 | .blocks = STMPE_BLOCK_KEYPAD, | ||
59 | .irq_trigger = IRQF_TRIGGER_FALLING, | ||
60 | .irq_base = MOP500_STMPE1601_IRQ(0), | ||
61 | .keypad = &stmpe1601_keypad_data, | ||
62 | .autosleep = true, | ||
63 | .autosleep_timeout = 1024, | ||
64 | }; | ||
65 | |||
66 | static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = { | ||
67 | { | ||
68 | I2C_BOARD_INFO("stmpe1601", 0x40), | ||
69 | .irq = NOMADIK_GPIO_TO_IRQ(218), | ||
70 | .platform_data = &stmpe1601_data, | ||
71 | .flags = I2C_CLIENT_WAKE, | ||
72 | }, | ||
73 | }; | ||
74 | |||
75 | /* | ||
76 | * BU21013 ROHM touchscreen interface on the STUIBs | ||
77 | */ | ||
78 | |||
79 | /* tracks number of bu21013 devices being enabled */ | ||
80 | static int bu21013_devices; | ||
81 | |||
82 | #define TOUCH_GPIO_PIN 84 | ||
83 | |||
84 | #define TOUCH_XMAX 384 | ||
85 | #define TOUCH_YMAX 704 | ||
86 | |||
87 | #define PRCMU_CLOCK_OCR 0x1CC | ||
88 | #define TSC_EXT_CLOCK_9_6MHZ 0x840000 | ||
89 | |||
90 | /** | ||
91 | * bu21013_gpio_board_init : configures the touch panel. | ||
92 | * @reset_pin: reset pin number | ||
93 | * This function can be used to configures | ||
94 | * the voltage and reset the touch panel controller. | ||
95 | */ | ||
96 | static int bu21013_gpio_board_init(int reset_pin) | ||
97 | { | ||
98 | int retval = 0; | ||
99 | |||
100 | bu21013_devices++; | ||
101 | if (bu21013_devices == 1) { | ||
102 | retval = gpio_request(reset_pin, "touchp_reset"); | ||
103 | if (retval) { | ||
104 | printk(KERN_ERR "Unable to request gpio reset_pin"); | ||
105 | return retval; | ||
106 | } | ||
107 | retval = gpio_direction_output(reset_pin, 1); | ||
108 | if (retval < 0) { | ||
109 | printk(KERN_ERR "%s: gpio direction failed\n", | ||
110 | __func__); | ||
111 | return retval; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | return retval; | ||
116 | } | ||
117 | |||
118 | /** | ||
119 | * bu21013_gpio_board_exit : deconfigures the touch panel controller | ||
120 | * @reset_pin: reset pin number | ||
121 | * This function can be used to deconfigures the chip selection | ||
122 | * for touch panel controller. | ||
123 | */ | ||
124 | static int bu21013_gpio_board_exit(int reset_pin) | ||
125 | { | ||
126 | int retval = 0; | ||
127 | |||
128 | if (bu21013_devices == 1) { | ||
129 | retval = gpio_direction_output(reset_pin, 0); | ||
130 | if (retval < 0) { | ||
131 | printk(KERN_ERR "%s: gpio direction failed\n", | ||
132 | __func__); | ||
133 | return retval; | ||
134 | } | ||
135 | gpio_set_value(reset_pin, 0); | ||
136 | } | ||
137 | bu21013_devices--; | ||
138 | |||
139 | return retval; | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * bu21013_read_pin_val : get the interrupt pin value | ||
144 | * This function can be used to get the interrupt pin value for touch panel | ||
145 | * controller. | ||
146 | */ | ||
147 | static int bu21013_read_pin_val(void) | ||
148 | { | ||
149 | return gpio_get_value(TOUCH_GPIO_PIN); | ||
150 | } | ||
151 | |||
152 | static struct bu21013_platform_device tsc_plat_device = { | ||
153 | .cs_en = bu21013_gpio_board_init, | ||
154 | .cs_dis = bu21013_gpio_board_exit, | ||
155 | .irq_read_val = bu21013_read_pin_val, | ||
156 | .irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN), | ||
157 | .cs_pin = GPIO_BU21013_CS, | ||
158 | .touch_x_max = TOUCH_XMAX, | ||
159 | .touch_y_max = TOUCH_YMAX, | ||
160 | .ext_clk = false, | ||
161 | .x_flip = false, | ||
162 | .y_flip = true, | ||
163 | }; | ||
164 | |||
165 | static struct bu21013_platform_device tsc_plat2_device = { | ||
166 | .cs_en = bu21013_gpio_board_init, | ||
167 | .cs_dis = bu21013_gpio_board_exit, | ||
168 | .irq_read_val = bu21013_read_pin_val, | ||
169 | .irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN), | ||
170 | .cs_pin = GPIO_BU21013_CS, | ||
171 | .touch_x_max = TOUCH_XMAX, | ||
172 | .touch_y_max = TOUCH_YMAX, | ||
173 | .ext_clk = false, | ||
174 | .x_flip = false, | ||
175 | .y_flip = true, | ||
176 | }; | ||
177 | |||
178 | static struct i2c_board_info __initdata u8500_i2c3_devices_stuib[] = { | ||
179 | { | ||
180 | I2C_BOARD_INFO("bu21013_tp", 0x5C), | ||
181 | .platform_data = &tsc_plat_device, | ||
182 | }, | ||
183 | { | ||
184 | I2C_BOARD_INFO("bu21013_tp", 0x5D), | ||
185 | .platform_data = &tsc_plat2_device, | ||
186 | }, | ||
187 | |||
188 | }; | ||
189 | |||
12 | void __init mop500_stuib_init(void) | 190 | void __init mop500_stuib_init(void) |
13 | { | 191 | { |
192 | mop500_uib_i2c_add(0, mop500_i2c0_devices_stuib, | ||
193 | ARRAY_SIZE(mop500_i2c0_devices_stuib)); | ||
194 | |||
195 | mop500_uib_i2c_add(3, u8500_i2c3_devices_stuib, | ||
196 | ARRAY_SIZE(u8500_i2c3_devices_stuib)); | ||
14 | } | 197 | } |