diff options
author | Ed Wildgoose <git@wildgooses.com> | 2011-09-20 17:00:12 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-09-21 05:19:42 -0400 |
commit | d4f3e350172a1dc769ed5e7f5bd540feb0c475d8 (patch) | |
tree | ddf2c6a7b32b9c91e003f7f60260ddf985e91b16 /arch/x86/platform | |
parent | 9d037a777695993ec7437e5f451647dea7919d4c (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/x86/platform')
-rw-r--r-- | arch/x86/platform/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/platform/geode/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/platform/geode/alix.c | 142 |
3 files changed, 144 insertions, 0 deletions
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 |
2 | obj-y += ce4100/ | 2 | obj-y += ce4100/ |
3 | obj-y += efi/ | 3 | obj-y += efi/ |
4 | obj-y += geode/ | ||
4 | obj-y += iris/ | 5 | obj-y += iris/ |
5 | obj-y += mrst/ | 6 | obj-y += mrst/ |
6 | obj-y += olpc/ | 7 | obj-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 | |||
30 | static int force = 0; | ||
31 | module_param(force, bool, 0444); | ||
32 | /* FIXME: Award bios is not automatically detected as Alix platform */ | ||
33 | MODULE_PARM_DESC(force, "Force detection as ALIX.2/ALIX.3 platform"); | ||
34 | |||
35 | static 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 | |||
56 | static struct gpio_led_platform_data alix_leds_data = { | ||
57 | .num_leds = ARRAY_SIZE(alix_leds), | ||
58 | .leds = alix_leds, | ||
59 | }; | ||
60 | |||
61 | static struct platform_device alix_leds_dev = { | ||
62 | .name = "leds-gpio", | ||
63 | .id = -1, | ||
64 | .dev.platform_data = &alix_leds_data, | ||
65 | }; | ||
66 | |||
67 | static void __init register_alix(void) | ||
68 | { | ||
69 | /* Setup LED control through leds-gpio driver */ | ||
70 | platform_device_register(&alix_leds_dev); | ||
71 | } | ||
72 | |||
73 | static 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 | |||
123 | static 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 | |||
138 | module_init(alix_init); | ||
139 | |||
140 | MODULE_AUTHOR("Ed Wildgoose <kernel@wildgooses.com>"); | ||
141 | MODULE_DESCRIPTION("PCEngines ALIX System Setup"); | ||
142 | MODULE_LICENSE("GPL"); | ||