aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/input/mouse/gpio_mouse.c59
-rw-r--r--include/linux/gpio_mouse.h61
2 files changed, 52 insertions, 68 deletions
diff --git a/drivers/input/mouse/gpio_mouse.c b/drivers/input/mouse/gpio_mouse.c
index ced07391304b..dcaba1e4fffb 100644
--- a/drivers/input/mouse/gpio_mouse.c
+++ b/drivers/input/mouse/gpio_mouse.c
@@ -12,8 +12,54 @@
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/input-polldev.h> 13#include <linux/input-polldev.h>
14#include <linux/gpio.h> 14#include <linux/gpio.h>
15#include <linux/gpio_mouse.h>
16 15
16#define GPIO_MOUSE_POLARITY_ACT_HIGH 0x00
17#define GPIO_MOUSE_POLARITY_ACT_LOW 0x01
18
19#define GPIO_MOUSE_PIN_UP 0
20#define GPIO_MOUSE_PIN_DOWN 1
21#define GPIO_MOUSE_PIN_LEFT 2
22#define GPIO_MOUSE_PIN_RIGHT 3
23#define GPIO_MOUSE_PIN_BLEFT 4
24#define GPIO_MOUSE_PIN_BMIDDLE 5
25#define GPIO_MOUSE_PIN_BRIGHT 6
26#define GPIO_MOUSE_PIN_MAX 7
27
28/**
29 * struct gpio_mouse_platform_data
30 * @scan_ms: integer in ms specifying the scan periode.
31 * @polarity: Pin polarity, active high or low.
32 * @up: GPIO line for up value.
33 * @down: GPIO line for down value.
34 * @left: GPIO line for left value.
35 * @right: GPIO line for right value.
36 * @bleft: GPIO line for left button.
37 * @bmiddle: GPIO line for middle button.
38 * @bright: GPIO line for right button.
39 * @pins: GPIO line numbers used for the mouse.
40 *
41 * This struct must be added to the platform_device in the board code.
42 * It is used by the gpio_mouse driver to setup GPIO lines and to
43 * calculate mouse movement.
44 */
45struct gpio_mouse_platform_data {
46 int scan_ms;
47 int polarity;
48
49 union {
50 struct {
51 int up;
52 int down;
53 int left;
54 int right;
55
56 int bleft;
57 int bmiddle;
58 int bright;
59 };
60 int pins[GPIO_MOUSE_PIN_MAX];
61 };
62};
17 63
18/* 64/*
19 * Timer function which is run every scan_ms ms when the device is opened. 65 * Timer function which is run every scan_ms ms when the device is opened.
@@ -47,17 +93,16 @@ static void gpio_mouse_scan(struct input_polled_dev *dev)
47 93
48static int gpio_mouse_probe(struct platform_device *pdev) 94static int gpio_mouse_probe(struct platform_device *pdev)
49{ 95{
50 struct gpio_mouse_platform_data *pdata = dev_get_platdata(&pdev->dev); 96 struct device *dev = &pdev->dev;
97 struct gpio_mouse_platform_data *pdata;
51 struct input_polled_dev *input_poll; 98 struct input_polled_dev *input_poll;
52 struct input_dev *input; 99 struct input_dev *input;
53 int pin, i; 100 int pin, i;
54 int error; 101 int error;
55 102
56 if (!pdata) { 103 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
57 dev_err(&pdev->dev, "no platform data\n"); 104 if (!pdata)
58 error = -ENXIO; 105 return -ENOMEM;
59 goto out;
60 }
61 106
62 if (pdata->scan_ms < 0) { 107 if (pdata->scan_ms < 0) {
63 dev_err(&pdev->dev, "invalid scan time\n"); 108 dev_err(&pdev->dev, "invalid scan time\n");
diff --git a/include/linux/gpio_mouse.h b/include/linux/gpio_mouse.h
deleted file mode 100644
index 44ed7aa14d85..000000000000
--- a/include/linux/gpio_mouse.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * Driver for simulating a mouse on GPIO lines.
3 *
4 * Copyright (C) 2007 Atmel Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef _GPIO_MOUSE_H
12#define _GPIO_MOUSE_H
13
14#define GPIO_MOUSE_POLARITY_ACT_HIGH 0x00
15#define GPIO_MOUSE_POLARITY_ACT_LOW 0x01
16
17#define GPIO_MOUSE_PIN_UP 0
18#define GPIO_MOUSE_PIN_DOWN 1
19#define GPIO_MOUSE_PIN_LEFT 2
20#define GPIO_MOUSE_PIN_RIGHT 3
21#define GPIO_MOUSE_PIN_BLEFT 4
22#define GPIO_MOUSE_PIN_BMIDDLE 5
23#define GPIO_MOUSE_PIN_BRIGHT 6
24#define GPIO_MOUSE_PIN_MAX 7
25
26/**
27 * struct gpio_mouse_platform_data
28 * @scan_ms: integer in ms specifying the scan periode.
29 * @polarity: Pin polarity, active high or low.
30 * @up: GPIO line for up value.
31 * @down: GPIO line for down value.
32 * @left: GPIO line for left value.
33 * @right: GPIO line for right value.
34 * @bleft: GPIO line for left button.
35 * @bmiddle: GPIO line for middle button.
36 * @bright: GPIO line for right button.
37 *
38 * This struct must be added to the platform_device in the board code.
39 * It is used by the gpio_mouse driver to setup GPIO lines and to
40 * calculate mouse movement.
41 */
42struct gpio_mouse_platform_data {
43 int scan_ms;
44 int polarity;
45
46 union {
47 struct {
48 int up;
49 int down;
50 int left;
51 int right;
52
53 int bleft;
54 int bmiddle;
55 int bright;
56 };
57 int pins[GPIO_MOUSE_PIN_MAX];
58 };
59};
60
61#endif /* _GPIO_MOUSE_H */