2 * LEDs driver for Soekris net48xx
4 * Copyright (C) 2006 Chris Boot <bootc@bootc.net>
6 * Based on leds-ams-delta.c
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.
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>
19 #include <linux/nsc_gpio.h>
20 #include <linux/scx200_gpio.h>
22 #define DRVNAME "net48xx-led"
23 #define NET48XX_ERROR_LED_GPIO 20
25 static struct platform_device *pdev;
27 static void net48xx_error_led_set(struct led_classdev *led_cdev,
28 enum led_brightness value)
30 scx200_gpio_ops.gpio_set(NET48XX_ERROR_LED_GPIO, value ? 1 : 0);
33 static struct led_classdev net48xx_error_led = {
34 .name = "net48xx:error",
35 .brightness_set = net48xx_error_led_set,
39 static int net48xx_led_suspend(struct platform_device *dev,
42 led_classdev_suspend(&net48xx_error_led);
46 static int net48xx_led_resume(struct platform_device *dev)
48 led_classdev_resume(&net48xx_error_led);
52 #define net48xx_led_suspend NULL
53 #define net48xx_led_resume NULL
56 static int net48xx_led_probe(struct platform_device *pdev)
58 return led_classdev_register(&pdev->dev, &net48xx_error_led);
61 static int net48xx_led_remove(struct platform_device *pdev)
63 led_classdev_unregister(&net48xx_error_led);
67 static struct platform_driver net48xx_led_driver = {
68 .probe = net48xx_led_probe,
69 .remove = net48xx_led_remove,
70 .suspend = net48xx_led_suspend,
71 .resume = net48xx_led_resume,
78 static int __init net48xx_led_init(void)
82 /* small hack, but scx200_gpio doesn't set .dev if the probe fails */
83 if (!scx200_gpio_ops.dev) {
88 ret = platform_driver_register(&net48xx_led_driver);
92 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
95 platform_driver_unregister(&net48xx_led_driver);
103 static void __exit net48xx_led_exit(void)
105 platform_device_unregister(pdev);
106 platform_driver_unregister(&net48xx_led_driver);
109 module_init(net48xx_led_init);
110 module_exit(net48xx_led_exit);
112 MODULE_AUTHOR("Chris Boot <bootc@bootc.net>");
113 MODULE_DESCRIPTION("Soekris net48xx LED driver");
114 MODULE_LICENSE("GPL");