Linux 4.1.18
[linux/fpc-iii.git] / arch / mips / mti-sead3 / leds-sead3.c
blobc938ceeb8848a1b7ef3b2186ddde2fa5ecc1641e
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
7 * Copyright (C) 2015 Imagination Technologies, Inc.
8 */
9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/leds.h>
14 #include <linux/err.h>
15 #include <linux/io.h>
17 #include <asm/mips-boards/sead3-addr.h>
19 static void sead3_pled_set(struct led_classdev *led_cdev,
20 enum led_brightness value)
22 writel(value, (void __iomem *)SEAD3_CPLD_P_LED);
25 static void sead3_fled_set(struct led_classdev *led_cdev,
26 enum led_brightness value)
28 writel(value, (void __iomem *)SEAD3_CPLD_F_LED);
31 static struct led_classdev sead3_pled = {
32 .name = "sead3::pled",
33 .brightness_set = sead3_pled_set,
34 .flags = LED_CORE_SUSPENDRESUME,
37 static struct led_classdev sead3_fled = {
38 .name = "sead3::fled",
39 .brightness_set = sead3_fled_set,
40 .flags = LED_CORE_SUSPENDRESUME,
43 static int sead3_led_probe(struct platform_device *pdev)
45 int ret;
47 ret = led_classdev_register(&pdev->dev, &sead3_pled);
48 if (ret < 0)
49 return ret;
51 ret = led_classdev_register(&pdev->dev, &sead3_fled);
52 if (ret < 0)
53 led_classdev_unregister(&sead3_pled);
55 return ret;
58 static int sead3_led_remove(struct platform_device *pdev)
60 led_classdev_unregister(&sead3_pled);
61 led_classdev_unregister(&sead3_fled);
62 return 0;
65 static struct platform_driver sead3_led_driver = {
66 .probe = sead3_led_probe,
67 .remove = sead3_led_remove,
68 .driver = {
69 .name = "sead3-led",
73 module_platform_driver(sead3_led_driver);
75 MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
76 MODULE_DESCRIPTION("SEAD3 LED driver");
77 MODULE_LICENSE("GPL");