blob: eb97a3271bb37a265d885f68df82f31e13b15c8c [file] [log] [blame]
Steven J. Hill30700332012-05-30 21:02:49 +00001/*
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.
5 *
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
Ralf Baechlefbacc8d2015-03-27 23:50:58 +01007 * Copyright (C) 2015 Imagination Technologies, Inc.
Steven J. Hill30700332012-05-30 21:02:49 +00008 */
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>
16
Ralf Baechlefbacc8d2015-03-27 23:50:58 +010017#include <asm/mips-boards/sead3-addr.h>
18
Steven J. Hill30700332012-05-30 21:02:49 +000019static void sead3_pled_set(struct led_classdev *led_cdev,
20 enum led_brightness value)
21{
Ralf Baechlefbacc8d2015-03-27 23:50:58 +010022 writel(value, (void __iomem *)SEAD3_CPLD_P_LED);
Steven J. Hill30700332012-05-30 21:02:49 +000023}
24
25static void sead3_fled_set(struct led_classdev *led_cdev,
26 enum led_brightness value)
27{
Ralf Baechlefbacc8d2015-03-27 23:50:58 +010028 writel(value, (void __iomem *)SEAD3_CPLD_F_LED);
Steven J. Hill30700332012-05-30 21:02:49 +000029}
30
31static struct led_classdev sead3_pled = {
32 .name = "sead3::pled",
Ralf Baechle70342282013-01-22 12:59:30 +010033 .brightness_set = sead3_pled_set,
Lars-Peter Clausenf4d1f2b2013-03-25 11:54:17 -050034 .flags = LED_CORE_SUSPENDRESUME,
Steven J. Hill30700332012-05-30 21:02:49 +000035};
36
37static struct led_classdev sead3_fled = {
38 .name = "sead3::fled",
Ralf Baechle70342282013-01-22 12:59:30 +010039 .brightness_set = sead3_fled_set,
Lars-Peter Clausenf4d1f2b2013-03-25 11:54:17 -050040 .flags = LED_CORE_SUSPENDRESUME,
Steven J. Hill30700332012-05-30 21:02:49 +000041};
42
Steven J. Hill30700332012-05-30 21:02:49 +000043static int sead3_led_probe(struct platform_device *pdev)
44{
45 int ret;
46
47 ret = led_classdev_register(&pdev->dev, &sead3_pled);
48 if (ret < 0)
49 return ret;
50
51 ret = led_classdev_register(&pdev->dev, &sead3_fled);
52 if (ret < 0)
53 led_classdev_unregister(&sead3_pled);
54
55 return ret;
56}
57
58static int sead3_led_remove(struct platform_device *pdev)
59{
60 led_classdev_unregister(&sead3_pled);
61 led_classdev_unregister(&sead3_fled);
Ralf Baechle22a16872015-08-03 17:04:01 +020062
Steven J. Hill30700332012-05-30 21:02:49 +000063 return 0;
64}
65
66static struct platform_driver sead3_led_driver = {
67 .probe = sead3_led_probe,
68 .remove = sead3_led_remove,
Steven J. Hill30700332012-05-30 21:02:49 +000069 .driver = {
Ralf Baechle2c0916d2015-03-27 21:57:36 +010070 .name = "sead3-led",
Steven J. Hill30700332012-05-30 21:02:49 +000071 },
72};
73
Ralf Baechle4558e092015-03-27 21:47:01 +010074module_platform_driver(sead3_led_driver);
Steven J. Hill30700332012-05-30 21:02:49 +000075
76MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
77MODULE_DESCRIPTION("SEAD3 LED driver");
78MODULE_LICENSE("GPL");