1 // SPDX-License-Identifier: GPL-2.0-only
3 * LEDs driver for Soekris net48xx
5 * Copyright (C) 2006 Chris Boot <bootc@bootc.net>
7 * Based on leds-ams-delta.c
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/leds.h>
14 #include <linux/err.h>
16 #include <linux/nsc_gpio.h>
17 #include <linux/scx200_gpio.h>
18 #include <linux/module.h>
20 #define DRVNAME "net48xx-led"
21 #define NET48XX_ERROR_LED_GPIO 20
23 static struct platform_device
*pdev
;
25 static void net48xx_error_led_set(struct led_classdev
*led_cdev
,
26 enum led_brightness value
)
28 scx200_gpio_ops
.gpio_set(NET48XX_ERROR_LED_GPIO
, value
? 1 : 0);
31 static struct led_classdev net48xx_error_led
= {
32 .name
= "net48xx::error",
33 .brightness_set
= net48xx_error_led_set
,
34 .flags
= LED_CORE_SUSPENDRESUME
,
37 static int net48xx_led_probe(struct platform_device
*pdev
)
39 return devm_led_classdev_register(&pdev
->dev
, &net48xx_error_led
);
42 static struct platform_driver net48xx_led_driver
= {
43 .probe
= net48xx_led_probe
,
49 static int __init
net48xx_led_init(void)
53 /* small hack, but scx200_gpio doesn't set .dev if the probe fails */
54 if (!scx200_gpio_ops
.dev
) {
59 ret
= platform_driver_register(&net48xx_led_driver
);
63 pdev
= platform_device_register_simple(DRVNAME
, -1, NULL
, 0);
66 platform_driver_unregister(&net48xx_led_driver
);
74 static void __exit
net48xx_led_exit(void)
76 platform_device_unregister(pdev
);
77 platform_driver_unregister(&net48xx_led_driver
);
80 module_init(net48xx_led_init
);
81 module_exit(net48xx_led_exit
);
83 MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
84 MODULE_DESCRIPTION("Soekris net48xx LED driver");
85 MODULE_LICENSE("GPL");