Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 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. |
| 5 | * |
| 6 | * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. |
Ralf Baechle | fbacc8d | 2015-03-27 23:50:58 +0100 | [diff] [blame] | 7 | * Copyright (C) 2015 Imagination Technologies, Inc. |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 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> |
| 16 | |
Ralf Baechle | fbacc8d | 2015-03-27 23:50:58 +0100 | [diff] [blame] | 17 | #include <asm/mips-boards/sead3-addr.h> |
| 18 | |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 19 | static void sead3_pled_set(struct led_classdev *led_cdev, |
| 20 | enum led_brightness value) |
| 21 | { |
Ralf Baechle | fbacc8d | 2015-03-27 23:50:58 +0100 | [diff] [blame] | 22 | writel(value, (void __iomem *)SEAD3_CPLD_P_LED); |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | static void sead3_fled_set(struct led_classdev *led_cdev, |
| 26 | enum led_brightness value) |
| 27 | { |
Ralf Baechle | fbacc8d | 2015-03-27 23:50:58 +0100 | [diff] [blame] | 28 | writel(value, (void __iomem *)SEAD3_CPLD_F_LED); |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | static struct led_classdev sead3_pled = { |
| 32 | .name = "sead3::pled", |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 33 | .brightness_set = sead3_pled_set, |
Lars-Peter Clausen | f4d1f2b | 2013-03-25 11:54:17 -0500 | [diff] [blame] | 34 | .flags = LED_CORE_SUSPENDRESUME, |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | static struct led_classdev sead3_fled = { |
| 38 | .name = "sead3::fled", |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 39 | .brightness_set = sead3_fled_set, |
Lars-Peter Clausen | f4d1f2b | 2013-03-25 11:54:17 -0500 | [diff] [blame] | 40 | .flags = LED_CORE_SUSPENDRESUME, |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 43 | static 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 | |
| 58 | static int sead3_led_remove(struct platform_device *pdev) |
| 59 | { |
| 60 | led_classdev_unregister(&sead3_pled); |
| 61 | led_classdev_unregister(&sead3_fled); |
Ralf Baechle | 22a1687 | 2015-08-03 17:04:01 +0200 | [diff] [blame^] | 62 | |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static struct platform_driver sead3_led_driver = { |
| 67 | .probe = sead3_led_probe, |
| 68 | .remove = sead3_led_remove, |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 69 | .driver = { |
Ralf Baechle | 2c0916d | 2015-03-27 21:57:36 +0100 | [diff] [blame] | 70 | .name = "sead3-led", |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 71 | }, |
| 72 | }; |
| 73 | |
Ralf Baechle | 4558e09 | 2015-03-27 21:47:01 +0100 | [diff] [blame] | 74 | module_platform_driver(sead3_led_driver); |
Steven J. Hill | 3070033 | 2012-05-30 21:02:49 +0000 | [diff] [blame] | 75 | |
| 76 | MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>"); |
| 77 | MODULE_DESCRIPTION("SEAD3 LED driver"); |
| 78 | MODULE_LICENSE("GPL"); |