cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

leds-cobalt-qube.c (1654B)


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