Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Control the Cobalt Qube/RaQ front LED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/leds.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #define LED_FRONT_LEFT	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define LED_FRONT_RIGHT	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) static void __iomem *led_port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static u8 led_value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static void qube_front_led_set(struct led_classdev *led_cdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 			       enum led_brightness brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	if (brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		led_value = ~(LED_FRONT_LEFT | LED_FRONT_RIGHT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	writeb(led_value, led_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static struct led_classdev qube_front_led = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	.name			= "qube::front",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	.brightness		= LED_FULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	.brightness_set		= qube_front_led_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	.default_trigger	= "default-on",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) static int cobalt_qube_led_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	if (!res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	led_port = devm_ioremap(&pdev->dev, res->start, resource_size(res));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (!led_port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	writeb(led_value, led_port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	return devm_led_classdev_register(&pdev->dev, &qube_front_led);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static struct platform_driver cobalt_qube_led_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	.probe	= cobalt_qube_led_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	.driver	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		.name	= "cobalt-qube-leds",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) module_platform_driver(cobalt_qube_led_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) MODULE_DESCRIPTION("Front LED support for Cobalt Server");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) MODULE_ALIAS("platform:cobalt-qube-leds");