linux/drivers/platform/chrome/wilco_ec/keyboard_leds.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Keyboard backlight LED driver for the Wilco Embedded Controller
 *
 * Copyright 2019 Google LLC
 *
 * Since the EC will never change the backlight level of its own accord,
 * we don't need to implement a brightness_get() method.
 */

#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/leds.h>
#include <linux/platform_data/wilco-ec.h>
#include <linux/slab.h>

#define WILCO_EC_COMMAND_KBBL
#define WILCO_KBBL_MODE_FLAG_PWM
#define WILCO_KBBL_DEFAULT_BRIGHTNESS

struct wilco_keyboard_leds {};

enum wilco_kbbl_subcommand {};

/**
 * struct wilco_keyboard_leds_msg - Message to/from EC for keyboard LED control.
 * @command: Always WILCO_EC_COMMAND_KBBL.
 * @status: Set by EC to 0 on success, 0xFF on failure.
 * @subcmd: One of enum wilco_kbbl_subcommand.
 * @reserved3: Should be 0.
 * @mode: Bit flags for used mode, we want to use WILCO_KBBL_MODE_FLAG_PWM.
 * @reserved5to8: Should be 0.
 * @percent: Brightness in 0-100. Only meaningful in PWM mode.
 * @reserved10to15: Should be 0.
 */
struct wilco_keyboard_leds_msg {} __packed;

/* Send a request, get a response, and check that the response is good. */
static int send_kbbl_msg(struct wilco_ec_device *ec,
			 struct wilco_keyboard_leds_msg *request,
			 struct wilco_keyboard_leds_msg *response)
{}

static int set_kbbl(struct wilco_ec_device *ec, enum led_brightness brightness)
{}

static int kbbl_exist(struct wilco_ec_device *ec, bool *exists)
{}

/**
 * kbbl_init() - Initialize the state of the keyboard backlight.
 * @ec: EC device to talk to.
 *
 * Gets the current brightness, ensuring that the BIOS already initialized the
 * backlight to PWM mode. If not in PWM mode, then the current brightness is
 * meaningless, so set the brightness to WILCO_KBBL_DEFAULT_BRIGHTNESS.
 *
 * Return: Final brightness of the keyboard, or negative error code on failure.
 */
static int kbbl_init(struct wilco_ec_device *ec)
{}

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

int wilco_keyboard_leds_init(struct wilco_ec_device *ec)
{}