linux/drivers/leds/leds-turris-omnia.c

// SPDX-License-Identifier: GPL-2.0
/*
 * CZ.NIC's Turris Omnia LEDs driver
 *
 * 2020, 2023 by Marek Behún <[email protected]>
 */

#include <linux/i2c.h>
#include <linux/led-class-multicolor.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include "leds.h"

#define OMNIA_BOARD_LEDS
#define OMNIA_LED_NUM_CHANNELS

/* MCU controller commands at I2C address 0x2a */
#define OMNIA_MCU_I2C_ADDR

#define CMD_GET_STATUS_WORD
#define STS_FEATURES_SUPPORTED

#define CMD_GET_FEATURES
#define FEAT_LED_GAMMA_CORRECTION

/* LED controller commands at I2C address 0x2b */
#define CMD_LED_MODE
#define CMD_LED_MODE_LED(l)
#define CMD_LED_MODE_USER

#define CMD_LED_STATE
#define CMD_LED_STATE_LED(l)
#define CMD_LED_STATE_ON

#define CMD_LED_COLOR
#define CMD_LED_SET_BRIGHTNESS
#define CMD_LED_GET_BRIGHTNESS

#define CMD_SET_GAMMA_CORRECTION
#define CMD_GET_GAMMA_CORRECTION

struct omnia_led {};

#define to_omnia_led(l)

struct omnia_leds {};

static int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd, u8 val)
{}

static int omnia_cmd_read_raw(struct i2c_adapter *adapter, u8 addr, u8 cmd,
			      void *reply, size_t len)
{}

static int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd)
{}

static int omnia_led_send_color_cmd(const struct i2c_client *client,
				    struct omnia_led *led)
{}

/* Determine if the computed RGB channels are different from the cached ones */
static bool omnia_led_channels_changed(struct omnia_led *led)
{}

static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
					     enum led_brightness brightness)
{}

static struct led_hw_trigger_type omnia_hw_trigger_type;

static int omnia_hwtrig_activate(struct led_classdev *cdev)
{}

static void omnia_hwtrig_deactivate(struct led_classdev *cdev)
{}

static struct led_trigger omnia_hw_trigger =;

static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
			      struct device_node *np)
{}

/*
 * On the front panel of the Turris Omnia router there is also a button which
 * can be used to control the intensity of all the LEDs at once, so that if they
 * are too bright, user can dim them.
 * The microcontroller cycles between 8 levels of this global brightness (from
 * 100% to 0%), but this setting can have any integer value between 0 and 100.
 * It is therefore convenient to be able to change this setting from software.
 * We expose this setting via a sysfs attribute file called "brightness". This
 * file lives in the device directory of the LED controller, not an individual
 * LED, so it should not confuse users.
 */
static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
			       char *buf)
{}

static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
				const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(brightness);

static ssize_t gamma_correction_show(struct device *dev,
				     struct device_attribute *a, char *buf)
{}

static ssize_t gamma_correction_store(struct device *dev,
				      struct device_attribute *a,
				      const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(gamma_correction);

static struct attribute *omnia_led_controller_attrs[] =;
ATTRIBUTE_GROUPS();

static int omnia_mcu_get_features(const struct i2c_client *client)
{}

static int omnia_leds_probe(struct i2c_client *client)
{}

static void omnia_leds_remove(struct i2c_client *client)
{}

static const struct of_device_id of_omnia_leds_match[] =;

static const struct i2c_device_id omnia_id[] =;
MODULE_DEVICE_TABLE(i2c, omnia_id);

static struct i2c_driver omnia_leds_driver =;

module_i2c_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();