14 #include <linux/input.h>
16 #include <linux/module.h>
20 #include <linux/slab.h>
22 #include <mach/hardware.h>
27 #define TBCNTR (0x0010)
28 #define TBSBC (0x0014)
30 #define TBCR_TBRST (1 << 1)
31 #define TBCR_TBSB (1 << 10)
33 #define TBCR_Y_FLT(n) (((n) & 0xf) << 6)
34 #define TBCR_X_FLT(n) (((n) & 0xf) << 2)
36 #define TBCNTR_YM(n) (((n) >> 24) & 0xff)
37 #define TBCNTR_YP(n) (((n) >> 16) & 0xff)
38 #define TBCNTR_XM(n) (((n) >> 8) & 0xff)
39 #define TBCNTR_XP(n) ((n) & 0xff)
41 #define TBSBC_TBSBC (0x1)
68 input_report_rel(input,
REL_X, x);
69 input_report_rel(input,
REL_Y, y);
93 pr_err(
"%s: timed out writing TBCR(%x)!\n", __func__, v);
118 pr_debug(
"%s: final TBCR=%x!\n", __func__,
122 static int pxa930_trkball_open(
struct input_dev *
dev)
126 pxa930_trkball_config(trkball);
131 static void pxa930_trkball_disable(
struct pxa930_trkball *trkball)
139 static void pxa930_trkball_close(
struct input_dev *
dev)
143 pxa930_trkball_disable(trkball);
149 struct input_dev *
input;
155 dev_err(&pdev->
dev,
"failed to get trkball irq\n");
161 dev_err(&pdev->
dev,
"failed to get register memory\n");
169 trkball->
pdata = pdev->
dev.platform_data;
170 if (!trkball->
pdata) {
171 dev_err(&pdev->
dev,
"no platform data defined\n");
178 dev_err(&pdev->
dev,
"failed to ioremap registers\n");
184 pxa930_trkball_disable(trkball);
186 error =
request_irq(irq, pxa930_trkball_interrupt, 0,
187 pdev->
name, trkball);
189 dev_err(&pdev->
dev,
"failed to request irq: %d\n", error);
193 platform_set_drvdata(pdev, trkball);
195 input = input_allocate_device();
197 dev_err(&pdev->
dev,
"failed to allocate input device\n");
199 goto failed_free_irq;
202 input->name = pdev->
name;
204 input->open = pxa930_trkball_open;
205 input->close = pxa930_trkball_close;
206 input->dev.parent = &pdev->
dev;
207 input_set_drvdata(input, trkball);
214 error = input_register_device(input);
216 dev_err(&pdev->
dev,
"unable to register input device\n");
217 goto failed_free_input;
223 input_free_device(input);
238 input_unregister_device(trkball->
input);
248 .name =
"pxa930-trkball",
250 .probe = pxa930_trkball_probe,