blob: a95ac59852061b84dc9a2d550c063b0013a91b0c [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.
7 */
8#include <linux/kernel.h>
9#include <linux/module.h>
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/leds.h>
13#include <linux/err.h>
14#include <linux/io.h>
15
16#define DRVNAME "sead3-led"
17
18static struct platform_device *pdev;
19
20static void sead3_pled_set(struct led_classdev *led_cdev,
21 enum led_brightness value)
22{
23 pr_debug("sead3_pled_set\n");
24 writel(value, (void __iomem *)0xBF000210); /* FIXME */
25}
26
27static void sead3_fled_set(struct led_classdev *led_cdev,
28 enum led_brightness value)
29{
30 pr_debug("sead3_fled_set\n");
31 writel(value, (void __iomem *)0xBF000218); /* FIXME */
32}
33
34static struct led_classdev sead3_pled = {
35 .name = "sead3::pled",
36 .brightness_set = sead3_pled_set,
37};
38
39static struct led_classdev sead3_fled = {
40 .name = "sead3::fled",
41 .brightness_set = sead3_fled_set,
42};
43
44#ifdef CONFIG_PM
45static int sead3_led_suspend(struct platform_device *dev,
46 pm_message_t state)
47{
48 led_classdev_suspend(&sead3_pled);
49 led_classdev_suspend(&sead3_fled);
50 return 0;
51}
52
53static int sead3_led_resume(struct platform_device *dev)
54{
55 led_classdev_resume(&sead3_pled);
56 led_classdev_resume(&sead3_fled);
57 return 0;
58}
59#else
60#define sead3_led_suspend NULL
61#define sead3_led_resume NULL
62#endif
63
64static int sead3_led_probe(struct platform_device *pdev)
65{
66 int ret;
67
68 ret = led_classdev_register(&pdev->dev, &sead3_pled);
69 if (ret < 0)
70 return ret;
71
72 ret = led_classdev_register(&pdev->dev, &sead3_fled);
73 if (ret < 0)
74 led_classdev_unregister(&sead3_pled);
75
76 return ret;
77}
78
79static int sead3_led_remove(struct platform_device *pdev)
80{
81 led_classdev_unregister(&sead3_pled);
82 led_classdev_unregister(&sead3_fled);
83 return 0;
84}
85
86static struct platform_driver sead3_led_driver = {
87 .probe = sead3_led_probe,
88 .remove = sead3_led_remove,
89 .suspend = sead3_led_suspend,
90 .resume = sead3_led_resume,
91 .driver = {
92 .name = DRVNAME,
93 .owner = THIS_MODULE,
94 },
95};
96
97static int __init sead3_led_init(void)
98{
99 int ret;
100
101 ret = platform_driver_register(&sead3_led_driver);
102 if (ret < 0)
103 goto out;
104
105 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
106 if (IS_ERR(pdev)) {
107 ret = PTR_ERR(pdev);
108 platform_driver_unregister(&sead3_led_driver);
109 goto out;
110 }
111
112out:
113 return ret;
114}
115
116static void __exit sead3_led_exit(void)
117{
118 platform_device_unregister(pdev);
119 platform_driver_unregister(&sead3_led_driver);
120}
121
122module_init(sead3_led_init);
123module_exit(sead3_led_exit);
124
125MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
126MODULE_DESCRIPTION("SEAD3 LED driver");
127MODULE_LICENSE("GPL");
128