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/module.h>
24 #include <linux/leds.h>
25 #include <linux/platform_device.h>
26 #include <linux/gpio.h>
28 #include <asm/geode.h>
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");
35 static struct gpio_led alix_leds[] = {
39 .default_trigger = "default-on",
45 .default_trigger = "default-off",
51 .default_trigger = "default-off",
56 static struct gpio_led_platform_data alix_leds_data = {
57 .num_leds = ARRAY_SIZE(alix_leds),
61 static struct platform_device alix_leds_dev = {
64 .dev.platform_data = &alix_leds_data,
67 static void __init register_alix(void)
69 /* Setup LED control through leds-gpio driver */
70 platform_device_register(&alix_leds_dev);
73 static int __init alix_present(unsigned long bios_phys,
77 const size_t bios_len = 0x00010000;
78 const char *bios_virt;
84 printk(KERN_NOTICE "%s: forced to skip BIOS test, "
85 "assume system is ALIX.2/ALIX.3\n",
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++) {
96 if (memcmp(p, alix_sig, alix_sig_len) != 0)
99 memcpy(name, p, sizeof(name));
101 /* remove the first \0 character from string */
102 a = strchr(name, '\0');
106 /* cut the string at a newline */
107 a = strchr(name, '\r');
111 tail = p + alix_sig_len;
112 if ((tail[0] == '2' || tail[0] == '3')) {
114 "%s: system is recognized as \"%s\"\n",
115 KBUILD_MODNAME, name);
123 static int __init alix_init(void)
125 const char tinybios_sig[] = "PC Engines ALIX.";
126 const char coreboot_sig[] = "PC Engines\0ALIX.";
131 if (alix_present(0xf0000, tinybios_sig, sizeof(tinybios_sig) - 1) ||
132 alix_present(0x500, coreboot_sig, sizeof(coreboot_sig) - 1))
138 module_init(alix_init);
140 MODULE_AUTHOR("Ed Wildgoose <kernel@wildgooses.com>");
141 MODULE_DESCRIPTION("PCEngines ALIX System Setup");
142 MODULE_LICENSE("GPL");