| 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 | --- a/arch/x86/Kconfig |
| 28 | +++ b/arch/x86/Kconfig |
| 29 | @@ -2133,6 +2133,13 @@ config ALIX |
| 30 | |
| 31 | Note: You have to set alix.force=1 for boards with Award BIOS. |
| 32 | |
| 33 | +config GEOS |
| 34 | + bool "Traverse Technologies GEOS System Support (LEDS, GPIO, etc)" |
| 35 | + select GPIOLIB |
| 36 | + depends on DMI |
| 37 | + ---help--- |
| 38 | + This option enables system support for the Traverse Technologies GEOS. |
| 39 | + |
| 40 | endif # X86_32 |
| 41 | |
| 42 | config AMD_NB |
| 43 | --- a/arch/x86/platform/geode/Makefile |
| 44 | +++ b/arch/x86/platform/geode/Makefile |
| 45 | @@ -1 +1,2 @@ |
| 46 | obj-$(CONFIG_ALIX) += alix.o |
| 47 | +obj-$(CONFIG_GEOS) += geos.o |
| 48 | --- /dev/null |
| 49 | +++ b/arch/x86/platform/geode/geos.c |
| 50 | @@ -0,0 +1,128 @@ |
| 51 | +/* |
| 52 | + * System Specific setup for Traverse Technologies GEOS. |
| 53 | + * At the moment this means setup of GPIO control of LEDs. |
| 54 | + * |
| 55 | + * Copyright (C) 2008 Constantin Baranov <const@mimas.ru> |
| 56 | + * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com> |
| 57 | + * and Philip Prindeville <philipp@redfish-solutions.com> |
| 58 | + * |
| 59 | + * TODO: There are large similarities with leds-net5501.c |
| 60 | + * by Alessandro Zummo <a.zummo@towertech.it> |
| 61 | + * In the future leds-net5501.c should be migrated over to platform |
| 62 | + * |
| 63 | + * This program is free software; you can redistribute it and/or modify |
| 64 | + * it under the terms of the GNU General Public License version 2 |
| 65 | + * as published by the Free Software Foundation. |
| 66 | + */ |
| 67 | + |
| 68 | +#include <linux/kernel.h> |
| 69 | +#include <linux/init.h> |
| 70 | +#include <linux/io.h> |
| 71 | +#include <linux/string.h> |
| 72 | +#include <linux/module.h> |
| 73 | +#include <linux/leds.h> |
| 74 | +#include <linux/platform_device.h> |
| 75 | +#include <linux/gpio.h> |
| 76 | +#include <linux/input.h> |
| 77 | +#include <linux/gpio_keys.h> |
| 78 | +#include <linux/dmi.h> |
| 79 | + |
| 80 | +#include <asm/geode.h> |
| 81 | + |
| 82 | +static struct gpio_keys_button geos_gpio_buttons[] = { |
| 83 | + { |
| 84 | + .code = KEY_RESTART, |
| 85 | + .gpio = 3, |
| 86 | + .active_low = 1, |
| 87 | + .desc = "Reset button", |
| 88 | + .type = EV_KEY, |
| 89 | + .wakeup = 0, |
| 90 | + .debounce_interval = 100, |
| 91 | + .can_disable = 0, |
| 92 | + } |
| 93 | +}; |
| 94 | +static struct gpio_keys_platform_data geos_buttons_data = { |
| 95 | + .buttons = geos_gpio_buttons, |
| 96 | + .nbuttons = ARRAY_SIZE(geos_gpio_buttons), |
| 97 | + .poll_interval = 20, |
| 98 | +}; |
| 99 | + |
| 100 | +static struct platform_device geos_buttons_dev = { |
| 101 | + .name = "gpio-keys-polled", |
| 102 | + .id = 1, |
| 103 | + .dev = { |
| 104 | + .platform_data = &geos_buttons_data, |
| 105 | + } |
| 106 | +}; |
| 107 | + |
| 108 | +static struct gpio_led geos_leds[] = { |
| 109 | + { |
| 110 | + .name = "geos:1", |
| 111 | + .gpio = 6, |
| 112 | + .default_trigger = "default-on", |
| 113 | + .active_low = 1, |
| 114 | + }, |
| 115 | + { |
| 116 | + .name = "geos:2", |
| 117 | + .gpio = 25, |
| 118 | + .default_trigger = "default-off", |
| 119 | + .active_low = 1, |
| 120 | + }, |
| 121 | + { |
| 122 | + .name = "geos:3", |
| 123 | + .gpio = 27, |
| 124 | + .default_trigger = "default-off", |
| 125 | + .active_low = 1, |
| 126 | + }, |
| 127 | +}; |
| 128 | + |
| 129 | +static struct gpio_led_platform_data geos_leds_data = { |
| 130 | + .num_leds = ARRAY_SIZE(geos_leds), |
| 131 | + .leds = geos_leds, |
| 132 | +}; |
| 133 | + |
| 134 | +static struct platform_device geos_leds_dev = { |
| 135 | + .name = "leds-gpio", |
| 136 | + .id = -1, |
| 137 | + .dev.platform_data = &geos_leds_data, |
| 138 | +}; |
| 139 | + |
| 140 | +static struct __initdata platform_device *geos_devs[] = { |
| 141 | + &geos_buttons_dev, |
| 142 | + &geos_leds_dev, |
| 143 | +}; |
| 144 | + |
| 145 | +static void __init register_geos(void) |
| 146 | +{ |
| 147 | + /* Setup LED control through leds-gpio driver */ |
| 148 | + platform_add_devices(geos_devs, ARRAY_SIZE(geos_devs)); |
| 149 | +} |
| 150 | + |
| 151 | +static int __init geos_init(void) |
| 152 | +{ |
| 153 | + const char *vendor, *product; |
| 154 | + |
| 155 | + if (!is_geode()) |
| 156 | + return 0; |
| 157 | + |
| 158 | + vendor = dmi_get_system_info(DMI_SYS_VENDOR); |
| 159 | + if (!vendor || strcmp(vendor, "Traverse Technologies")) |
| 160 | + return 0; |
| 161 | + |
| 162 | + product = dmi_get_system_info(DMI_PRODUCT_NAME); |
| 163 | + if (!product || strcmp(product, "Geos")) |
| 164 | + return 0; |
| 165 | + |
| 166 | + printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n", |
| 167 | + KBUILD_MODNAME, vendor, product); |
| 168 | + |
| 169 | + register_geos(); |
| 170 | + |
| 171 | + return 0; |
| 172 | +} |
| 173 | + |
| 174 | +module_init(geos_init); |
| 175 | + |
| 176 | +MODULE_AUTHOR("Philip Prindeville <philipp@redfish-solutions.com>"); |
| 177 | +MODULE_DESCRIPTION("Traverse Technologies Geos System Setup"); |
| 178 | +MODULE_LICENSE("GPL"); |
| 179 | |