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. 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> 16 17#include <asm/mips-boards/sead3-addr.h> 18 19static void sead3_pled_set(struct led_classdev *led_cdev, 20 enum led_brightness value) 21{ 22 writel(value, (void __iomem *)SEAD3_CPLD_P_LED); 23} 24 25static void sead3_fled_set(struct led_classdev *led_cdev, 26 enum led_brightness value) 27{ 28 writel(value, (void __iomem *)SEAD3_CPLD_F_LED); 29} 30 31static struct led_classdev sead3_pled = { 32 .name = "sead3::pled", 33 .brightness_set = sead3_pled_set, 34 .flags = LED_CORE_SUSPENDRESUME, 35}; 36 37static struct led_classdev sead3_fled = { 38 .name = "sead3::fled", 39 .brightness_set = sead3_fled_set, 40 .flags = LED_CORE_SUSPENDRESUME, 41}; 42 43static 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); 62 63 return 0; 64} 65 66static struct platform_driver sead3_led_driver = { 67 .probe = sead3_led_probe, 68 .remove = sead3_led_remove, 69 .driver = { 70 .name = "sead3-led", 71 }, 72}; 73 74module_platform_driver(sead3_led_driver); 75 76MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>"); 77MODULE_DESCRIPTION("SEAD3 LED driver"); 78MODULE_LICENSE("GPL"); 79