365ee494df55bec9a1a3c54754cb680cd71dc6bf
[buildroot.git] /
1 >From 9c5fa914202d20756c56e0c4fd76035ed8f8ced8 Mon Sep 17 00:00:00 2001
2 From: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
3 Date: Mon, 6 Aug 2007 08:31:14 +0200
4 Subject: [PATCH 1/1] Add gpio_mouse board setup to atstk1000 board
5
6 This patch adds a gpio_mouse_platform_data to the atstk1000 board code and
7 registers a gpio_mouse platform_device. This will enable a GPIO mouse on header
8 J1 on GPIO of the ATSTK1000 development kit. The board code is enabled/disabled
9 in menuconfig.
10
11 By connecting J1 (GPIO) to J25 (SWITCH) you can use the following keys to
12 simulate a mouse:
13
14 SW0: right
15 SW1: down
16 SW2: up
17 SW3: left
18 SW5: right button
19 SW6: middle button
20 SW7: left button
21
22 Signed-off-by: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
23 ---
24 arch/avr32/boards/atstk1000/Kconfig | 16 ++++++++++
25 arch/avr32/boards/atstk1000/atstk1002.c | 48 +++++++++++++++++++++++++++++++
26 2 files changed, 64 insertions(+), 0 deletions(-)
27
28 diff --git a/arch/avr32/boards/atstk1000/Kconfig b/arch/avr32/boards/atstk1000/Kconfig
29 index 718578f..d99d4bd 100644
30 --- a/arch/avr32/boards/atstk1000/Kconfig
31 +++ b/arch/avr32/boards/atstk1000/Kconfig
32 @@ -52,6 +52,22 @@ config BOARD_ATSTK100X_SPI1
33 GPIO lines and accessed through the J1 jumper block. Say "y"
34 here to configure that SPI controller.
35
36 +config BOARD_ATSTK1002_GPIO_MOUSE
37 + bool "Configure gpio_mouse on GPIO J1 header"
38 + depends on !BOARD_ATSTK1002_SW4_CUSTOM
39 + help
40 + Enable gpio_mouse board configuration on GPIO 0 to 7. Connecting a
41 + 10-pin flat cable from J1 (GPIO) to J25 (SWITCH) will let a user give
42 + mouse inputs using the the switches SW0 to SW7.
43 +
44 + SW0: right
45 + SW1: down
46 + SW2: up
47 + SW3: left
48 + SW5: right button
49 + SW6: middle button
50 + SW7: left button
51 +
52 config BOARD_ATSTK1000_J2_LED
53 bool
54 default BOARD_ATSTK1000_J2_LED8 || BOARD_ATSTK1000_J2_RGB
55 diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c
56 index c958fd4..c7560e5 100644
57 --- a/arch/avr32/boards/atstk1000/atstk1002.c
58 +++ b/arch/avr32/boards/atstk1000/atstk1002.c
59 @@ -16,6 +16,7 @@
60 #include <linux/types.h>
61 #include <linux/spi/spi.h>
62 #include <linux/spi/at73c213.h>
63 +#include <linux/gpio_mouse.h>
64
65 #include <video/atmel_lcdc.h>
66
67 @@ -100,6 +101,49 @@ static struct mci_platform_data __initdata mci0_data = {
68 .cs = 4,
69 };
70
71 +#ifdef CONFIG_BOARD_ATSTK1002_GPIO_MOUSE
72 +static struct gpio_mouse_platform_data gpio_mouse0_data = {
73 + .polarity = GPIO_MOUSE_POLARITY_ACT_LOW,
74 + {
75 + {
76 + .up = GPIO_PIN_PB(2),
77 + .down = GPIO_PIN_PB(1),
78 + .left = GPIO_PIN_PB(3),
79 + .right = GPIO_PIN_PB(0),
80 + .bleft = GPIO_PIN_PB(7),
81 + .bmiddle = GPIO_PIN_PB(6),
82 + .bright = GPIO_PIN_PB(5),
83 + },
84 + },
85 + .scan_ms = 10,
86 +};
87 +
88 +static struct platform_device gpio_mouse0_device = {
89 + .name = "gpio_mouse",
90 + .id = 0,
91 + .dev = {
92 + .platform_data = &gpio_mouse0_data,
93 + },
94 +};
95 +
96 +static void __init add_device_gpio_mouse0(void)
97 +{
98 + struct platform_device *pdev = &gpio_mouse0_device;
99 + struct gpio_mouse_platform_data *data = pdev->dev.platform_data;
100 +
101 + at32_select_gpio(data->up, 0);
102 + at32_select_gpio(data->down, 0);
103 + at32_select_gpio(data->left, 0);
104 + at32_select_gpio(data->right, 0);
105 +
106 + at32_select_gpio(data->bleft, 0);
107 + at32_select_gpio(data->bmiddle, 0);
108 + at32_select_gpio(data->bright, 0);
109 +
110 + platform_device_register(pdev);
111 +}
112 +#endif
113 +
114 /*
115 * The next two functions should go away as the boot loader is
116 * supposed to initialize the macb address registers with a valid
117 @@ -269,6 +313,10 @@ static int __init atstk1002_init(void)
118 atstk1000_setup_j2_leds();
119 atstk1002_setup_extdac();
120
121 +#ifdef CONFIG_BOARD_ATSTK1002_GPIO_MOUSE
122 + add_device_gpio_mouse0();
123 +#endif
124 +
125 return 0;
126 }
127 postcore_initcall(atstk1002_init);
128 --
129 1.5.2.3
130