Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Philip A. Prindeville | 3197059 | 2012-01-14 01:45:39 -0700 | [diff] [blame] | 2 | /* |
| 3 | * System Specific setup for Traverse Technologies GEOS. |
| 4 | * At the moment this means setup of GPIO control of LEDs. |
| 5 | * |
| 6 | * Copyright (C) 2008 Constantin Baranov <const@mimas.ru> |
| 7 | * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com> |
| 8 | * and Philip Prindeville <philipp@redfish-solutions.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 |
Philip A. Prindeville | 3197059 | 2012-01-14 01:45:39 -0700 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/io.h> |
| 18 | #include <linux/string.h> |
Philip A. Prindeville | 3197059 | 2012-01-14 01:45:39 -0700 | [diff] [blame] | 19 | #include <linux/leds.h> |
| 20 | #include <linux/platform_device.h> |
| 21 | #include <linux/gpio.h> |
| 22 | #include <linux/input.h> |
| 23 | #include <linux/gpio_keys.h> |
| 24 | #include <linux/dmi.h> |
| 25 | |
| 26 | #include <asm/geode.h> |
| 27 | |
| 28 | static struct gpio_keys_button geos_gpio_buttons[] = { |
| 29 | { |
| 30 | .code = KEY_RESTART, |
| 31 | .gpio = 3, |
| 32 | .active_low = 1, |
| 33 | .desc = "Reset button", |
| 34 | .type = EV_KEY, |
| 35 | .wakeup = 0, |
| 36 | .debounce_interval = 100, |
| 37 | .can_disable = 0, |
| 38 | } |
| 39 | }; |
| 40 | static struct gpio_keys_platform_data geos_buttons_data = { |
| 41 | .buttons = geos_gpio_buttons, |
| 42 | .nbuttons = ARRAY_SIZE(geos_gpio_buttons), |
| 43 | .poll_interval = 20, |
| 44 | }; |
| 45 | |
| 46 | static struct platform_device geos_buttons_dev = { |
| 47 | .name = "gpio-keys-polled", |
| 48 | .id = 1, |
| 49 | .dev = { |
| 50 | .platform_data = &geos_buttons_data, |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | static struct gpio_led geos_leds[] = { |
| 55 | { |
| 56 | .name = "geos:1", |
| 57 | .gpio = 6, |
| 58 | .default_trigger = "default-on", |
| 59 | .active_low = 1, |
| 60 | }, |
| 61 | { |
| 62 | .name = "geos:2", |
| 63 | .gpio = 25, |
| 64 | .default_trigger = "default-off", |
| 65 | .active_low = 1, |
| 66 | }, |
| 67 | { |
| 68 | .name = "geos:3", |
| 69 | .gpio = 27, |
| 70 | .default_trigger = "default-off", |
| 71 | .active_low = 1, |
| 72 | }, |
| 73 | }; |
| 74 | |
| 75 | static struct gpio_led_platform_data geos_leds_data = { |
| 76 | .num_leds = ARRAY_SIZE(geos_leds), |
| 77 | .leds = geos_leds, |
| 78 | }; |
| 79 | |
| 80 | static struct platform_device geos_leds_dev = { |
| 81 | .name = "leds-gpio", |
| 82 | .id = -1, |
| 83 | .dev.platform_data = &geos_leds_data, |
| 84 | }; |
| 85 | |
Bartlomiej Zolnierkiewicz | a6d30e0 | 2013-09-30 15:21:15 +0200 | [diff] [blame] | 86 | static struct platform_device *geos_devs[] __initdata = { |
Philip A. Prindeville | 3197059 | 2012-01-14 01:45:39 -0700 | [diff] [blame] | 87 | &geos_buttons_dev, |
| 88 | &geos_leds_dev, |
| 89 | }; |
| 90 | |
| 91 | static void __init register_geos(void) |
| 92 | { |
| 93 | /* Setup LED control through leds-gpio driver */ |
| 94 | platform_add_devices(geos_devs, ARRAY_SIZE(geos_devs)); |
| 95 | } |
| 96 | |
| 97 | static int __init geos_init(void) |
| 98 | { |
| 99 | const char *vendor, *product; |
| 100 | |
| 101 | if (!is_geode()) |
| 102 | return 0; |
| 103 | |
| 104 | vendor = dmi_get_system_info(DMI_SYS_VENDOR); |
| 105 | if (!vendor || strcmp(vendor, "Traverse Technologies")) |
| 106 | return 0; |
| 107 | |
| 108 | product = dmi_get_system_info(DMI_PRODUCT_NAME); |
| 109 | if (!product || strcmp(product, "Geos")) |
| 110 | return 0; |
| 111 | |
| 112 | printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n", |
| 113 | KBUILD_MODNAME, vendor, product); |
| 114 | |
| 115 | register_geos(); |
| 116 | |
| 117 | return 0; |
| 118 | } |
Paul Gortmaker | eb61aee | 2016-02-14 18:09:54 -0500 | [diff] [blame] | 119 | device_initcall(geos_init); |