11 #include <linux/kernel.h>
13 #include <linux/module.h>
18 #include <linux/input.h>
23 #include <linux/slab.h>
31 #define HEADER_LENGTH(byte) ((byte) & 0x07)
32 #define HEADER_CONTROL(byte) (((byte) >> 3) & 0x03)
33 #define HEADER_ADDRESS(byte) ((byte) >> 5)
47 static const u32 sscr0 = 0
54 static const u32 sscr1 = 0
63 static const u32 sssr = 0
76 #define NAVPOINT_X_MIN 1278
77 #define NAVPOINT_X_MAX 5340
78 #define NAVPOINT_Y_MIN 1572
79 #define NAVPOINT_Y_MAX 4396
80 #define NAVPOINT_PRESSURE_MIN 0
81 #define NAVPOINT_PRESSURE_MAX 255
89 switch (navpoint->
data[0]) {
95 finger = (navpoint->
data[1] & 0x01);
96 gesture = (navpoint->
data[1] & 0x02);
97 x = ((navpoint->
data[2] & 0x1f) << 8) | navpoint->
data[3];
98 y = ((navpoint->
data[4] & 0x1f) << 8) | navpoint->
data[5];
99 z = navpoint->
data[6];
106 input_sync(navpoint->
input);
110 if ((navpoint->
data[1] & 0xf0) == 0x10)
115 "spurious packet: data=0x%02x,0x%02x,...\n",
116 navpoint->
data[0], navpoint->
data[1]);
128 status = pxa_ssp_read_reg(ssp,
SSSR);
131 "unexpected interrupt: status=0x%08x\n", status);
132 pxa_ssp_write_reg(ssp,
SSSR, (status & sssr));
139 data = pxa_ssp_read_reg(ssp,
SSDR);
140 navpoint->
data[navpoint->
index + 0] = (data >> 8);
142 navpoint->
index += 2;
144 navpoint_packet(navpoint);
147 status = pxa_ssp_read_reg(ssp,
SSSR);
154 static void navpoint_up(
struct navpoint *navpoint)
159 clk_prepare_enable(ssp->
clk);
161 pxa_ssp_write_reg(ssp,
SSCR1, sscr1);
162 pxa_ssp_write_reg(ssp,
SSSR, sssr);
163 pxa_ssp_write_reg(ssp,
SSTO, 0);
164 pxa_ssp_write_reg(ssp,
SSCR0, sscr0);
167 for (timeout = 100; timeout != 0; --timeout) {
175 "timeout waiting for SSSR[CSS] to clear\n");
177 if (gpio_is_valid(navpoint->
gpio))
181 static void navpoint_down(
struct navpoint *navpoint)
185 if (gpio_is_valid(navpoint->
gpio))
188 pxa_ssp_write_reg(ssp,
SSCR0, 0);
190 clk_disable_unprepare(ssp->
clk);
193 static int navpoint_open(
struct input_dev *
input)
195 struct navpoint *navpoint = input_get_drvdata(input);
197 navpoint_up(navpoint);
202 static void navpoint_close(
struct input_dev *
input)
204 struct navpoint *navpoint = input_get_drvdata(input);
206 navpoint_down(navpoint);
212 dev_get_platdata(&pdev->
dev);
214 struct input_dev *
input;
215 struct navpoint *navpoint;
223 if (gpio_is_valid(pdata->
gpio)) {
238 pxa_ssp_write_reg(ssp,
SSCR0, 0);
242 navpoint = kzalloc(
sizeof(*navpoint),
GFP_KERNEL);
243 input = input_allocate_device();
244 if (!navpoint || !input) {
251 navpoint->
dev = &pdev->
dev;
254 input->name = pdev->
name;
255 input->dev.parent = &pdev->
dev;
263 input_set_abs_params(input,
ABS_X,
265 input_set_abs_params(input,
ABS_Y,
271 input->open = navpoint_open;
272 input->close = navpoint_close;
274 input_set_drvdata(input, navpoint);
280 error = input_register_device(input);
284 platform_set_drvdata(pdev, navpoint);
292 input_free_device(input);
296 if (gpio_is_valid(pdata->
gpio))
305 dev_get_platdata(&pdev->
dev);
306 struct navpoint *navpoint = platform_get_drvdata(pdev);
311 input_unregister_device(navpoint->
input);
316 if (gpio_is_valid(pdata->
gpio))
322 #ifdef CONFIG_PM_SLEEP
323 static int navpoint_suspend(
struct device *
dev)
326 struct navpoint *navpoint = platform_get_drvdata(pdev);
327 struct input_dev *input = navpoint->
input;
331 navpoint_down(navpoint);
337 static int navpoint_resume(
struct device *dev)
340 struct navpoint *navpoint = platform_get_drvdata(pdev);
341 struct input_dev *input = navpoint->
input;
345 navpoint_up(navpoint);
355 .probe = navpoint_probe,
360 .pm = &navpoint_pm_ops,