aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorEd Wildgoose <git@wildgooses.com>2011-09-20 17:00:12 -0400
committerThomas Gleixner <tglx@linutronix.de>2011-09-21 05:19:42 -0400
commitd4f3e350172a1dc769ed5e7f5bd540feb0c475d8 (patch)
treeddf2c6a7b32b9c91e003f7f60260ddf985e91b16 /arch
parent9d037a777695993ec7437e5f451647dea7919d4c (diff)
x86: geode: New PCEngines Alix system driver
This new driver replaces the old PCEngines Alix 2/3 LED driver with a new driver that controls the LEDs through the leds-gpio driver. The old driver accessed GPIOs directly, which created a conflict and prevented also loading the cs5535-gpio driver to read other GPIOs on the Alix board. With this new driver, we hook into leds-gpio which in turn uses GPIO to control the LEDs and therefore it's possible to control both the LEDs and access onboard GPIOs Driver is moved to platform/geode as requested by Grant and any other geode initialisation modules should move here also This driver is inspired by leds-net5501.c by Alessandro Zummo. Ideally, leds-net5501.c should also be moved to platform/geode. Additionally the driver relies on parts of the patch: 7f131cf3ed ("leds: leds-alix2c - take port address from MSR) by Daniel Mack to perform detection of the Alix board. [akpm@linux-foundation.org: include module.h] Signed-off-by: Ed Wildgoose <kernel@wildgooses.com> Cc: git@wildgooses.com Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Daniel Mack <daniel@caiaq.de> Cc: Ingo Molnar <mingo@elte.hu> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Richard Purdie <rpurdie@rpsys.net> Reviewed-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/Kconfig14
-rw-r--r--arch/x86/platform/Makefile1
-rw-r--r--arch/x86/platform/geode/Makefile1
-rw-r--r--arch/x86/platform/geode/alix.c142
4 files changed, 158 insertions, 0 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6a47bb22657f..8c4e5bc35e29 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2064,6 +2064,20 @@ config OLPC_XO15_SCI
2064 - AC adapter status updates 2064 - AC adapter status updates
2065 - Battery status updates 2065 - Battery status updates
2066 2066
2067config ALIX
2068 bool "PCEngines ALIX System Support (LED setup)"
2069 select GPIOLIB
2070 ---help---
2071 This option enables system support for the PCEngines ALIX.
2072 At present this just sets up LEDs for GPIO control on
2073 ALIX2/3/6 boards. However, other system specific setup should
2074 get added here.
2075
2076 Note: You must still enable the drivers for GPIO and LED support
2077 (GPIO_CS5535 & LEDS_GPIO) to actually use the LEDs
2078
2079 Note: You have to set alix.force=1 for boards with Award BIOS.
2080
2067endif # X86_32 2081endif # X86_32
2068 2082
2069config AMD_NB 2083config AMD_NB
diff --git a/arch/x86/platform/Makefile b/arch/x86/platform/Makefile
index 021eee91c056..8d874396cb29 100644
--- a/arch/x86/platform/Makefile
+++ b/arch/x86/platform/Makefile
@@ -1,6 +1,7 @@
1# Platform specific code goes here 1# Platform specific code goes here
2obj-y += ce4100/ 2obj-y += ce4100/
3obj-y += efi/ 3obj-y += efi/
4obj-y += geode/
4obj-y += iris/ 5obj-y += iris/
5obj-y += mrst/ 6obj-y += mrst/
6obj-y += olpc/ 7obj-y += olpc/
diff --git a/arch/x86/platform/geode/Makefile b/arch/x86/platform/geode/Makefile
new file mode 100644
index 000000000000..07c9cd05021a
--- /dev/null
+++ b/arch/x86/platform/geode/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_ALIX) += alix.o
diff --git a/arch/x86/platform/geode/alix.c b/arch/x86/platform/geode/alix.c
new file mode 100644
index 000000000000..ca1973699d3d
--- /dev/null
+++ b/arch/x86/platform/geode/alix.c
@@ -0,0 +1,142 @@
1/*
2 * System Specific setup for PCEngines ALIX.
3 * At the moment this means setup of GPIO control of LEDs
4 * on Alix.2/3/6 boards.
5 *
6 *
7 * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
8 * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com>
9 *
10 * TODO: There are large similarities with leds-net5501.c
11 * by Alessandro Zummo <a.zummo@towertech.it>
12 * In the future leds-net5501.c should be migrated over to platform
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2
16 * as published by the Free Software Foundation.
17 */
18
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/io.h>
22#include <linux/string.h>
23#include <linux/module.h>
24#include <linux/leds.h>
25#include <linux/platform_device.h>
26#include <linux/gpio.h>
27
28#include <asm/geode.h>
29
30static int force = 0;
31module_param(force, bool, 0444);
32/* FIXME: Award bios is not automatically detected as Alix platform */
33MODULE_PARM_DESC(force, "Force detection as ALIX.2/ALIX.3 platform");
34
35static struct gpio_led alix_leds[] = {
36 {
37 .name = "alix:1",
38 .gpio = 6,
39 .default_trigger = "default-on",
40 .active_low = 1,
41 },
42 {
43 .name = "alix:2",
44 .gpio = 25,
45 .default_trigger = "default-off",
46 .active_low = 1,
47 },
48 {
49 .name = "alix:3",
50 .gpio = 27,
51 .default_trigger = "default-off",
52 .active_low = 1,
53 },
54};
55
56static struct gpio_led_platform_data alix_leds_data = {
57 .num_leds = ARRAY_SIZE(alix_leds),
58 .leds = alix_leds,
59};
60
61static struct platform_device alix_leds_dev = {
62 .name = "leds-gpio",
63 .id = -1,
64 .dev.platform_data = &alix_leds_data,
65};
66
67static void __init register_alix(void)
68{
69 /* Setup LED control through leds-gpio driver */
70 platform_device_register(&alix_leds_dev);
71}
72
73static int __init alix_present(unsigned long bios_phys,
74 const char *alix_sig,
75 size_t alix_sig_len)
76{
77 const size_t bios_len = 0x00010000;
78 const char *bios_virt;
79 const char *scan_end;
80 const char *p;
81 char name[64];
82
83 if (force) {
84 printk(KERN_NOTICE "%s: forced to skip BIOS test, "
85 "assume system is ALIX.2/ALIX.3\n",
86 KBUILD_MODNAME);
87 return 1;
88 }
89
90 bios_virt = phys_to_virt(bios_phys);
91 scan_end = bios_virt + bios_len - (alix_sig_len + 2);
92 for (p = bios_virt; p < scan_end; p++) {
93 const char *tail;
94 char *a;
95
96 if (memcmp(p, alix_sig, alix_sig_len) != 0)
97 continue;
98
99 memcpy(name, p, sizeof(name));
100
101 /* remove the first \0 character from string */
102 a = strchr(name, '\0');
103 if (a)
104 *a = ' ';
105
106 /* cut the string at a newline */
107 a = strchr(name, '\r');
108 if (a)
109 *a = '\0';
110
111 tail = p + alix_sig_len;
112 if ((tail[0] == '2' || tail[0] == '3')) {
113 printk(KERN_INFO
114 "%s: system is recognized as \"%s\"\n",
115 KBUILD_MODNAME, name);
116 return 1;
117 }
118 }
119
120 return 0;
121}
122
123static int __init alix_init(void)
124{
125 const char tinybios_sig[] = "PC Engines ALIX.";
126 const char coreboot_sig[] = "PC Engines\0ALIX.";
127
128 if (!is_geode())
129 return 0;
130
131 if (alix_present(0xf0000, tinybios_sig, sizeof(tinybios_sig) - 1) ||
132 alix_present(0x500, coreboot_sig, sizeof(coreboot_sig) - 1))
133 register_alix();
134
135 return 0;
136}
137
138module_init(alix_init);
139
140MODULE_AUTHOR("Ed Wildgoose <kernel@wildgooses.com>");
141MODULE_DESCRIPTION("PCEngines ALIX System Setup");
142MODULE_LICENSE("GPL");