[PATCH 1/1] geos: backport driver from linux-next to 3.2 and 3.3
[openwrt/svn-archive/archive.git] / target / linux / x86 / patches-3.2 / 002-geos_platform.patch
1 From 31bc84d45320dad2392384381ad4d818ab21087a Mon Sep 17 00:00:00 2001
2 From: "Philip A. Prindeville" <philipp@redfish-solutions.com>
3 Date: Wed, 18 Jan 2012 11:15:33 -0700
4 Subject: [PATCH 1/1] geos: Platform driver for Geos and Geos2 single-board
5 computers.
6
7 Trivial platform driver for Traverse Technologies Geos and Geos2
8 single-board computers. Uses SMBIOS to identify platform.
9 Based on progressive revisions of the leds-net5501 driver that
10 was rewritten by Ed Wildgoose as a platform driver.
11
12 Supports GPIO-based LEDs (3) and 1 polled button which is
13 typically used for a soft reset.
14
15 Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
16 Reviewed-by: Ed Wildgoose <ed@wildgooses.com>
17 Acked-by: Andres Salomon <dilinger@queued.net>
18 Cc: Richard Purdie <rpurdie@rpsys.net>
19 Cc: Andrew Morton <akpm@linux-foundation.org>
20 ---
21 arch/x86/Kconfig | 7 ++
22 arch/x86/platform/geode/Makefile | 1 +
23 arch/x86/platform/geode/geos.c | 128 ++++++++++++++++++++++++++++++++++++++
24 3 files changed, 136 insertions(+), 0 deletions(-)
25 create mode 100644 arch/x86/platform/geode/geos.c
26
27 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
28 index 07c3f15..4ee921b 100644
29 --- a/arch/x86/Kconfig
30 +++ b/arch/x86/Kconfig
31 @@ -2168,6 +2168,13 @@ config ALIX
32
33 Note: You have to set alix.force=1 for boards with Award BIOS.
34
35 +config GEOS
36 + bool "Traverse Technologies GEOS System Support (LEDS, GPIO, etc)"
37 + select GPIOLIB
38 + depends on DMI
39 + ---help---
40 + This option enables system support for the Traverse Technologies GEOS.
41 +
42 endif # X86_32
43
44 config AMD_NB
45 diff --git a/arch/x86/platform/geode/Makefile b/arch/x86/platform/geode/Makefile
46 index 07c9cd0..d8ba564 100644
47 --- a/arch/x86/platform/geode/Makefile
48 +++ b/arch/x86/platform/geode/Makefile
49 @@ -1 +1,2 @@
50 obj-$(CONFIG_ALIX) += alix.o
51 +obj-$(CONFIG_GEOS) += geos.o
52 diff --git a/arch/x86/platform/geode/geos.c b/arch/x86/platform/geode/geos.c
53 new file mode 100644
54 index 0000000..c2e6d53
55 --- /dev/null
56 +++ b/arch/x86/platform/geode/geos.c
57 @@ -0,0 +1,128 @@
58 +/*
59 + * System Specific setup for Traverse Technologies GEOS.
60 + * At the moment this means setup of GPIO control of LEDs.
61 + *
62 + * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
63 + * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com>
64 + * and Philip Prindeville <philipp@redfish-solutions.com>
65 + *
66 + * TODO: There are large similarities with leds-net5501.c
67 + * by Alessandro Zummo <a.zummo@towertech.it>
68 + * In the future leds-net5501.c should be migrated over to platform
69 + *
70 + * This program is free software; you can redistribute it and/or modify
71 + * it under the terms of the GNU General Public License version 2
72 + * as published by the Free Software Foundation.
73 + */
74 +
75 +#include <linux/kernel.h>
76 +#include <linux/init.h>
77 +#include <linux/io.h>
78 +#include <linux/string.h>
79 +#include <linux/module.h>
80 +#include <linux/leds.h>
81 +#include <linux/platform_device.h>
82 +#include <linux/gpio.h>
83 +#include <linux/input.h>
84 +#include <linux/gpio_keys.h>
85 +#include <linux/dmi.h>
86 +
87 +#include <asm/geode.h>
88 +
89 +static struct gpio_keys_button geos_gpio_buttons[] = {
90 + {
91 + .code = KEY_RESTART,
92 + .gpio = 3,
93 + .active_low = 1,
94 + .desc = "Reset button",
95 + .type = EV_KEY,
96 + .wakeup = 0,
97 + .debounce_interval = 100,
98 + .can_disable = 0,
99 + }
100 +};
101 +static struct gpio_keys_platform_data geos_buttons_data = {
102 + .buttons = geos_gpio_buttons,
103 + .nbuttons = ARRAY_SIZE(geos_gpio_buttons),
104 + .poll_interval = 20,
105 +};
106 +
107 +static struct platform_device geos_buttons_dev = {
108 + .name = "gpio-keys-polled",
109 + .id = 1,
110 + .dev = {
111 + .platform_data = &geos_buttons_data,
112 + }
113 +};
114 +
115 +static struct gpio_led geos_leds[] = {
116 + {
117 + .name = "geos:1",
118 + .gpio = 6,
119 + .default_trigger = "default-on",
120 + .active_low = 1,
121 + },
122 + {
123 + .name = "geos:2",
124 + .gpio = 25,
125 + .default_trigger = "default-off",
126 + .active_low = 1,
127 + },
128 + {
129 + .name = "geos:3",
130 + .gpio = 27,
131 + .default_trigger = "default-off",
132 + .active_low = 1,
133 + },
134 +};
135 +
136 +static struct gpio_led_platform_data geos_leds_data = {
137 + .num_leds = ARRAY_SIZE(geos_leds),
138 + .leds = geos_leds,
139 +};
140 +
141 +static struct platform_device geos_leds_dev = {
142 + .name = "leds-gpio",
143 + .id = -1,
144 + .dev.platform_data = &geos_leds_data,
145 +};
146 +
147 +static struct __initdata platform_device *geos_devs[] = {
148 + &geos_buttons_dev,
149 + &geos_leds_dev,
150 +};
151 +
152 +static void __init register_geos(void)
153 +{
154 + /* Setup LED control through leds-gpio driver */
155 + platform_add_devices(geos_devs, ARRAY_SIZE(geos_devs));
156 +}
157 +
158 +static int __init geos_init(void)
159 +{
160 + const char *vendor, *product;
161 +
162 + if (!is_geode())
163 + return 0;
164 +
165 + vendor = dmi_get_system_info(DMI_SYS_VENDOR);
166 + if (!vendor || strcmp(vendor, "Traverse Technologies"))
167 + return 0;
168 +
169 + product = dmi_get_system_info(DMI_PRODUCT_NAME);
170 + if (!product || strcmp(product, "Geos"))
171 + return 0;
172 +
173 + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
174 + KBUILD_MODNAME, vendor, product);
175 +
176 + register_geos();
177 +
178 + return 0;
179 +}
180 +
181 +module_init(geos_init);
182 +
183 +MODULE_AUTHOR("Philip Prindeville <philipp@redfish-solutions.com>");
184 +MODULE_DESCRIPTION("Traverse Technologies Geos System Setup");
185 +MODULE_LICENSE("GPL");
186 --
187 1.7.7.4
188