blob: 7e1f294f0434ff0d20d7fdd08bd6d9a9aac5bdce [file] [log] [blame]
Rabin Vincent705e0982011-01-21 10:56:16 +05301/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License terms: GNU General Public License (GPL), version 2
5 */
6
7#include <linux/kernel.h>
8#include <linux/init.h>
Sundar Iyer0c243522011-01-21 10:56:17 +05309#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>
Linus Walleij4b4f7572011-02-15 15:01:35 +010015#include <asm/mach-types.h>
Rabin Vincent705e0982011-01-21 10:56:16 +053016
17#include "board-mop500.h"
18
Sundar Iyer0c243522011-01-21 10:56:17 +053019/* STMPE/SKE keypad use this key layout */
20static const unsigned int mop500_keymap[] = {
21 KEY(2, 5, KEY_END),
22 KEY(4, 1, KEY_POWER),
23 KEY(3, 5, KEY_VOLUMEDOWN),
24 KEY(1, 3, KEY_3),
25 KEY(5, 2, KEY_RIGHT),
26 KEY(5, 0, KEY_9),
27
28 KEY(0, 5, KEY_MENU),
29 KEY(7, 6, KEY_ENTER),
30 KEY(4, 5, KEY_0),
31 KEY(6, 7, KEY_2),
32 KEY(3, 4, KEY_UP),
33 KEY(3, 3, KEY_DOWN),
34
35 KEY(6, 4, KEY_SEND),
36 KEY(6, 2, KEY_BACK),
37 KEY(4, 2, KEY_VOLUMEUP),
38 KEY(5, 5, KEY_1),
39 KEY(4, 3, KEY_LEFT),
40 KEY(3, 2, KEY_7),
41};
42
43static const struct matrix_keymap_data mop500_keymap_data = {
44 .keymap = mop500_keymap,
45 .keymap_size = ARRAY_SIZE(mop500_keymap),
46};
47/*
48 * STMPE1601
49 */
50static struct stmpe_keypad_platform_data stmpe1601_keypad_data = {
51 .debounce_ms = 64,
52 .scan_count = 8,
53 .no_autorepeat = true,
54 .keymap_data = &mop500_keymap_data,
55};
56
57static struct stmpe_platform_data stmpe1601_data = {
58 .id = 1,
59 .blocks = STMPE_BLOCK_KEYPAD,
60 .irq_trigger = IRQF_TRIGGER_FALLING,
61 .irq_base = MOP500_STMPE1601_IRQ(0),
62 .keypad = &stmpe1601_keypad_data,
63 .autosleep = true,
64 .autosleep_timeout = 1024,
65};
66
67static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = {
68 {
69 I2C_BOARD_INFO("stmpe1601", 0x40),
70 .irq = NOMADIK_GPIO_TO_IRQ(218),
71 .platform_data = &stmpe1601_data,
72 .flags = I2C_CLIENT_WAKE,
73 },
74};
75
76/*
77 * BU21013 ROHM touchscreen interface on the STUIBs
78 */
79
Sundar Iyer0c243522011-01-21 10:56:17 +053080#define TOUCH_GPIO_PIN 84
81
82#define TOUCH_XMAX 384
83#define TOUCH_YMAX 704
84
85#define PRCMU_CLOCK_OCR 0x1CC
86#define TSC_EXT_CLOCK_9_6MHZ 0x840000
87
Sundar Iyer0c243522011-01-21 10:56:17 +053088static struct bu21013_platform_device tsc_plat_device = {
Lee Jones31fbcda2012-09-28 10:29:07 +010089 .touch_pin = TOUCH_GPIO_PIN,
Sundar Iyer0c243522011-01-21 10:56:17 +053090 .touch_x_max = TOUCH_XMAX,
91 .touch_y_max = TOUCH_YMAX,
92 .ext_clk = false,
93 .x_flip = false,
94 .y_flip = true,
95};
96
Sundar Iyer0c243522011-01-21 10:56:17 +053097static struct i2c_board_info __initdata u8500_i2c3_devices_stuib[] = {
98 {
99 I2C_BOARD_INFO("bu21013_tp", 0x5C),
100 .platform_data = &tsc_plat_device,
101 },
102 {
103 I2C_BOARD_INFO("bu21013_tp", 0x5D),
Lee Jones64db3642012-09-27 11:47:43 +0100104 .platform_data = &tsc_plat_device,
Sundar Iyer0c243522011-01-21 10:56:17 +0530105 },
Sundar Iyer0c243522011-01-21 10:56:17 +0530106};
107
Rabin Vincent705e0982011-01-21 10:56:16 +0530108void __init mop500_stuib_init(void)
109{
Lee Jones64db3642012-09-27 11:47:43 +0100110 if (machine_is_hrefv60())
Linus Walleij4b4f7572011-02-15 15:01:35 +0100111 tsc_plat_device.cs_pin = HREFV60_TOUCH_RST_GPIO;
Lee Jones64db3642012-09-27 11:47:43 +0100112 else
Linus Walleij4b4f7572011-02-15 15:01:35 +0100113 tsc_plat_device.cs_pin = GPIO_BU21013_CS;
Linus Walleij4b4f7572011-02-15 15:01:35 +0100114
Sundar Iyer0c243522011-01-21 10:56:17 +0530115 mop500_uib_i2c_add(0, mop500_i2c0_devices_stuib,
116 ARRAY_SIZE(mop500_i2c0_devices_stuib));
117
118 mop500_uib_i2c_add(3, u8500_i2c3_devices_stuib,
119 ARRAY_SIZE(u8500_i2c3_devices_stuib));
Rabin Vincent705e0982011-01-21 10:56:16 +0530120}