]>
Commit | Line | Data |
---|---|---|
1a87d942 CB |
1 | /* |
2 | * LEDs driver for Soekris net48xx | |
3 | * | |
4 | * Copyright (C) 2006 Chris Boot <[email protected]> | |
5 | * | |
6 | * Based on leds-ams-delta.c | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | ||
13 | #include <linux/kernel.h> | |
14 | #include <linux/init.h> | |
15 | #include <linux/platform_device.h> | |
16 | #include <linux/leds.h> | |
17 | #include <linux/err.h> | |
6023ff73 | 18 | #include <linux/io.h> |
cfedc920 | 19 | #include <linux/nsc_gpio.h> |
1a87d942 | 20 | #include <linux/scx200_gpio.h> |
54f4dedb | 21 | #include <linux/module.h> |
1a87d942 | 22 | |
bca3bffe | 23 | #define DRVNAME "net48xx-led" |
1a87d942 CB |
24 | #define NET48XX_ERROR_LED_GPIO 20 |
25 | ||
26 | static struct platform_device *pdev; | |
27 | ||
28 | static void net48xx_error_led_set(struct led_classdev *led_cdev, | |
29 | enum led_brightness value) | |
30 | { | |
cfedc920 | 31 | scx200_gpio_ops.gpio_set(NET48XX_ERROR_LED_GPIO, value ? 1 : 0); |
1a87d942 CB |
32 | } |
33 | ||
34 | static struct led_classdev net48xx_error_led = { | |
6c152bee | 35 | .name = "net48xx::error", |
1a87d942 | 36 | .brightness_set = net48xx_error_led_set, |
859cb7f2 | 37 | .flags = LED_CORE_SUSPENDRESUME, |
1a87d942 CB |
38 | }; |
39 | ||
1a87d942 CB |
40 | static int net48xx_led_probe(struct platform_device *pdev) |
41 | { | |
51167623 | 42 | return devm_led_classdev_register(&pdev->dev, &net48xx_error_led); |
1a87d942 CB |
43 | } |
44 | ||
45 | static struct platform_driver net48xx_led_driver = { | |
1a87d942 | 46 | .probe = net48xx_led_probe, |
1a87d942 | 47 | .driver = { |
bca3bffe | 48 | .name = DRVNAME, |
1a87d942 CB |
49 | }, |
50 | }; | |
51 | ||
52 | static int __init net48xx_led_init(void) | |
53 | { | |
54 | int ret; | |
55 | ||
cfedc920 CB |
56 | /* small hack, but scx200_gpio doesn't set .dev if the probe fails */ |
57 | if (!scx200_gpio_ops.dev) { | |
1a87d942 CB |
58 | ret = -ENODEV; |
59 | goto out; | |
60 | } | |
61 | ||
62 | ret = platform_driver_register(&net48xx_led_driver); | |
63 | if (ret < 0) | |
64 | goto out; | |
65 | ||
bca3bffe | 66 | pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); |
1a87d942 CB |
67 | if (IS_ERR(pdev)) { |
68 | ret = PTR_ERR(pdev); | |
69 | platform_driver_unregister(&net48xx_led_driver); | |
70 | goto out; | |
71 | } | |
72 | ||
73 | out: | |
74 | return ret; | |
75 | } | |
76 | ||
77 | static void __exit net48xx_led_exit(void) | |
78 | { | |
79 | platform_device_unregister(pdev); | |
80 | platform_driver_unregister(&net48xx_led_driver); | |
81 | } | |
82 | ||
83 | module_init(net48xx_led_init); | |
84 | module_exit(net48xx_led_exit); | |
85 | ||
86 | MODULE_AUTHOR("Chris Boot <[email protected]>"); | |
87 | MODULE_DESCRIPTION("Soekris net48xx LED driver"); | |
88 | MODULE_LICENSE("GPL"); | |
89 |