0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/kernel.h>
0016 #include <linux/init.h>
0017 #include <linux/io.h>
0018 #include <linux/string.h>
0019 #include <linux/leds.h>
0020 #include <linux/platform_device.h>
0021 #include <linux/input.h>
0022 #include <linux/gpio_keys.h>
0023 #include <linux/gpio/machine.h>
0024 #include <linux/dmi.h>
0025
0026 #include <asm/geode.h>
0027
0028 static struct gpio_keys_button geos_gpio_buttons[] = {
0029 {
0030 .code = KEY_RESTART,
0031 .gpio = 3,
0032 .active_low = 1,
0033 .desc = "Reset button",
0034 .type = EV_KEY,
0035 .wakeup = 0,
0036 .debounce_interval = 100,
0037 .can_disable = 0,
0038 }
0039 };
0040 static struct gpio_keys_platform_data geos_buttons_data = {
0041 .buttons = geos_gpio_buttons,
0042 .nbuttons = ARRAY_SIZE(geos_gpio_buttons),
0043 .poll_interval = 20,
0044 };
0045
0046 static struct platform_device geos_buttons_dev = {
0047 .name = "gpio-keys-polled",
0048 .id = 1,
0049 .dev = {
0050 .platform_data = &geos_buttons_data,
0051 }
0052 };
0053
0054 static struct gpio_led geos_leds[] = {
0055 {
0056 .name = "geos:1",
0057 .default_trigger = "default-on",
0058 },
0059 {
0060 .name = "geos:2",
0061 .default_trigger = "default-off",
0062 },
0063 {
0064 .name = "geos:3",
0065 .default_trigger = "default-off",
0066 },
0067 };
0068
0069 static struct gpio_led_platform_data geos_leds_data = {
0070 .num_leds = ARRAY_SIZE(geos_leds),
0071 .leds = geos_leds,
0072 };
0073
0074 static struct gpiod_lookup_table geos_leds_gpio_table = {
0075 .dev_id = "leds-gpio",
0076 .table = {
0077
0078 GPIO_LOOKUP_IDX("cs5535-gpio", 6, NULL, 0, GPIO_ACTIVE_LOW),
0079 GPIO_LOOKUP_IDX("cs5535-gpio", 25, NULL, 1, GPIO_ACTIVE_LOW),
0080 GPIO_LOOKUP_IDX("cs5535-gpio", 27, NULL, 2, GPIO_ACTIVE_LOW),
0081 { }
0082 },
0083 };
0084
0085 static struct platform_device geos_leds_dev = {
0086 .name = "leds-gpio",
0087 .id = -1,
0088 .dev.platform_data = &geos_leds_data,
0089 };
0090
0091 static struct platform_device *geos_devs[] __initdata = {
0092 &geos_buttons_dev,
0093 &geos_leds_dev,
0094 };
0095
0096 static void __init register_geos(void)
0097 {
0098
0099 gpiod_add_lookup_table(&geos_leds_gpio_table);
0100 platform_add_devices(geos_devs, ARRAY_SIZE(geos_devs));
0101 }
0102
0103 static int __init geos_init(void)
0104 {
0105 const char *vendor, *product;
0106
0107 if (!is_geode())
0108 return 0;
0109
0110 vendor = dmi_get_system_info(DMI_SYS_VENDOR);
0111 if (!vendor || strcmp(vendor, "Traverse Technologies"))
0112 return 0;
0113
0114 product = dmi_get_system_info(DMI_PRODUCT_NAME);
0115 if (!product || strcmp(product, "Geos"))
0116 return 0;
0117
0118 printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
0119 KBUILD_MODNAME, vendor, product);
0120
0121 register_geos();
0122
0123 return 0;
0124 }
0125 device_initcall(geos_init);