aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/leds
diff options
context:
space:
mode:
authorRaffaello D. Di Napoli <rafdev@dinapo.li>2018-06-25 08:50:02 -0400
committerJacek Anaszewski <jacek.anaszewski@gmail.com>2018-06-28 15:34:43 -0400
commit8cb21086cc6359c6d4f003a788050308afb211ad (patch)
tree2efa779daae33fda33c7b7f3349b30853a1f4952 /drivers/leds
parentd30c8d2031259d6dc360f8c96d362bb36665c99c (diff)
leds: Modify PC Engines apu/apu2 driver to support apu3
PC Engines apu3 is an improved version of the apu2, using the same SoC and almost everything else. This patch reuses as much as possible from the apu2 definitions, to avoid redundancy. Signed-off-by: Raffaello D. Di Napoli <rafdev@dinapo.li> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers/leds')
-rw-r--r--drivers/leds/Kconfig5
-rw-r--r--drivers/leds/leds-apu.c44
2 files changed, 46 insertions, 3 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 6e3a998f3370..44097a3e0fcc 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -57,12 +57,13 @@ config LEDS_AAT1290
57 depends on PINCTRL 57 depends on PINCTRL
58 help 58 help
59 This option enables support for the LEDs on the AAT1290. 59 This option enables support for the LEDs on the AAT1290.
60
60config LEDS_APU 61config LEDS_APU
61 tristate "Front panel LED support for PC Engines APU/APU2 boards" 62 tristate "Front panel LED support for PC Engines APU/APU2/APU3 boards"
62 depends on LEDS_CLASS 63 depends on LEDS_CLASS
63 depends on X86 && DMI 64 depends on X86 && DMI
64 help 65 help
65 This driver makes the PC Engines APU/APU2 front panel LEDs 66 This driver makes the PC Engines APU/APU2/APU3 front panel LEDs
66 accessible from userspace programs through the LED subsystem. 67 accessible from userspace programs through the LED subsystem.
67 68
68 To compile this driver as a module, choose M here: the 69 To compile this driver as a module, choose M here: the
diff --git a/drivers/leds/leds-apu.c b/drivers/leds/leds-apu.c
index 8c93d68964c7..8d42e46e2de3 100644
--- a/drivers/leds/leds-apu.c
+++ b/drivers/leds/leds-apu.c
@@ -102,6 +102,13 @@ static const struct apu_led_profile apu2_led_profile[] = {
102 { "apu2:green:3", LED_OFF, APU2_FCH_GPIO_BASE + 70 * APU2_IOSIZE }, 102 { "apu2:green:3", LED_OFF, APU2_FCH_GPIO_BASE + 70 * APU2_IOSIZE },
103}; 103};
104 104
105/* Same as apu2_led_profile, but with "3" in the LED names. */
106static const struct apu_led_profile apu3_led_profile[] = {
107 { "apu3:green:1", LED_ON, APU2_FCH_GPIO_BASE + 68 * APU2_IOSIZE },
108 { "apu3:green:2", LED_OFF, APU2_FCH_GPIO_BASE + 69 * APU2_IOSIZE },
109 { "apu3:green:3", LED_OFF, APU2_FCH_GPIO_BASE + 70 * APU2_IOSIZE },
110};
111
105static const struct dmi_system_id apu_led_dmi_table[] __initconst = { 112static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
106 { 113 {
107 .ident = "apu", 114 .ident = "apu",
@@ -134,6 +141,30 @@ static const struct dmi_system_id apu_led_dmi_table[] __initconst = {
134 DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu2") 141 DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu2")
135 } 142 }
136 }, 143 },
144 /* PC Engines APU3 with "Legacy" bios < 4.0.8 */
145 {
146 .ident = "apu3",
147 .matches = {
148 DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
149 DMI_MATCH(DMI_BOARD_NAME, "APU3")
150 }
151 },
152 /* PC Engines APU3 with "Legacy" bios >= 4.0.8 */
153 {
154 .ident = "apu3",
155 .matches = {
156 DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
157 DMI_MATCH(DMI_BOARD_NAME, "apu3")
158 }
159 },
160 /* PC Engines APU2 with "Mainline" bios */
161 {
162 .ident = "apu3",
163 .matches = {
164 DMI_MATCH(DMI_SYS_VENDOR, "PC Engines"),
165 DMI_MATCH(DMI_BOARD_NAME, "PC Engines apu3")
166 }
167 },
137 {} 168 {}
138}; 169};
139MODULE_DEVICE_TABLE(dmi, apu_led_dmi_table); 170MODULE_DEVICE_TABLE(dmi, apu_led_dmi_table);
@@ -235,6 +266,14 @@ static int __init apu_led_probe(struct platform_device *pdev)
235 apu_led->platform = APU2_LED_PLATFORM; 266 apu_led->platform = APU2_LED_PLATFORM;
236 apu_led->num_led_instances = ARRAY_SIZE(apu2_led_profile); 267 apu_led->num_led_instances = ARRAY_SIZE(apu2_led_profile);
237 apu_led->iosize = APU2_IOSIZE; 268 apu_led->iosize = APU2_IOSIZE;
269 } else if (dmi_match(DMI_BOARD_NAME, "APU3") ||
270 dmi_match(DMI_BOARD_NAME, "apu3") ||
271 dmi_match(DMI_BOARD_NAME, "PC Engines apu3")) {
272 apu_led->profile = apu3_led_profile;
273 /* Otherwise identical to APU2. */
274 apu_led->platform = APU2_LED_PLATFORM;
275 apu_led->num_led_instances = ARRAY_SIZE(apu3_led_profile);
276 apu_led->iosize = APU2_IOSIZE;
238 } 277 }
239 278
240 spin_lock_init(&apu_led->lock); 279 spin_lock_init(&apu_led->lock);
@@ -259,7 +298,10 @@ static int __init apu_led_init(void)
259 if (!(dmi_match(DMI_PRODUCT_NAME, "APU") || 298 if (!(dmi_match(DMI_PRODUCT_NAME, "APU") ||
260 dmi_match(DMI_PRODUCT_NAME, "APU2") || 299 dmi_match(DMI_PRODUCT_NAME, "APU2") ||
261 dmi_match(DMI_PRODUCT_NAME, "apu2") || 300 dmi_match(DMI_PRODUCT_NAME, "apu2") ||
262 dmi_match(DMI_PRODUCT_NAME, "PC Engines apu2"))) { 301 dmi_match(DMI_PRODUCT_NAME, "PC Engines apu2") ||
302 dmi_match(DMI_PRODUCT_NAME, "APU3") ||
303 dmi_match(DMI_PRODUCT_NAME, "apu3") ||
304 dmi_match(DMI_PRODUCT_NAME, "PC Engines apu3"))) {
263 pr_err("Unknown PC Engines board: %s\n", 305 pr_err("Unknown PC Engines board: %s\n",
264 dmi_get_system_info(DMI_PRODUCT_NAME)); 306 dmi_get_system_info(DMI_PRODUCT_NAME));
265 return -ENODEV; 307 return -ENODEV;