xref: /linux/arch/x86/platform/geode/geos.c (revision 31d166642c7c601c65eccf0ff2e0afe9a0538be2)
1 // SPDX-License-Identifier: GPL-2.0-only
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
13  */
14 
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/io.h>
18 #include <linux/string.h>
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 
86 static struct platform_device *geos_devs[] __initdata = {
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 }
119 device_initcall(geos_init);
120