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.
7 * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
8 * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com>
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
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.
19 #include <linux/kernel.h>
20 #include <linux/init.h>
22 #include <linux/string.h>
23 #include <linux/leds.h>
24 #include <linux/platform_device.h>
25 #include <linux/gpio.h>
27 #include <asm/geode.h>
30 module_param(force, bool, 0444);
31 /* FIXME: Award bios is not automatically detected as Alix platform */
32 MODULE_PARM_DESC(force, "Force detection as ALIX.2/ALIX.3 platform");
34 static struct gpio_led alix_leds[] = {
38 .default_trigger = "default-on",
44 .default_trigger = "default-off",
50 .default_trigger = "default-off",
55 static struct gpio_led_platform_data alix_leds_data = {
56 .num_leds = ARRAY_SIZE(alix_leds),
60 static struct platform_device alix_leds_dev = {
63 .dev.platform_data = &alix_leds_data,
66 static void __init register_alix(void)
68 /* Setup LED control through leds-gpio driver */
69 platform_device_register(&alix_leds_dev);
72 static int __init alix_present(unsigned long bios_phys,
76 const size_t bios_len = 0x00010000;
77 const char *bios_virt;
83 printk(KERN_NOTICE "%s: forced to skip BIOS test, "
84 "assume system is ALIX.2/ALIX.3\n",
89 bios_virt = phys_to_virt(bios_phys);
90 scan_end = bios_virt + bios_len - (alix_sig_len + 2);
91 for (p = bios_virt; p < scan_end; p++) {
95 if (memcmp(p, alix_sig, alix_sig_len) != 0)
98 memcpy(name, p, sizeof(name));
100 /* remove the first \0 character from string */
101 a = strchr(name, '\0');
105 /* cut the string at a newline */
106 a = strchr(name, '\r');
110 tail = p + alix_sig_len;
111 if ((tail[0] == '2' || tail[0] == '3')) {
113 "%s: system is recognized as \"%s\"\n",
114 KBUILD_MODNAME, name);
122 static int __init alix_init(void)
124 const char tinybios_sig[] = "PC Engines ALIX.";
125 const char coreboot_sig[] = "PC Engines\0ALIX.";
130 if (alix_present(0xf0000, tinybios_sig, sizeof(tinybios_sig) - 1) ||
131 alix_present(0x500, coreboot_sig, sizeof(coreboot_sig) - 1))
137 module_init(alix_init);
139 MODULE_AUTHOR("Ed Wildgoose <kernel@wildgooses.com>");
140 MODULE_DESCRIPTION("PCEngines ALIX System Setup");
141 MODULE_LICENSE("GPL");