linux/drivers/leds/leds-lm3532.c

// SPDX-License-Identifier: GPL-2.0
// TI LM3532 LED driver
// Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/
// https://www.ti.com/lit/ds/symlink/lm3532.pdf

#include <linux/i2c.h>
#include <linux/leds.h>
#include <linux/slab.h>
#include <linux/regmap.h>
#include <linux/types.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
#include <uapi/linux/uleds.h>
#include <linux/gpio/consumer.h>

#define LM3532_NAME
#define LM3532_BL_MODE_MANUAL
#define LM3532_BL_MODE_ALS

#define LM3532_REG_OUTPUT_CFG
#define LM3532_REG_STARTSHUT_RAMP
#define LM3532_REG_RT_RAMP
#define LM3532_REG_PWM_A_CFG
#define LM3532_REG_PWM_B_CFG
#define LM3532_REG_PWM_C_CFG
#define LM3532_REG_ZONE_CFG_A
#define LM3532_REG_CTRL_A_FS_CURR
#define LM3532_REG_ZONE_CFG_B
#define LM3532_REG_CTRL_B_FS_CURR
#define LM3532_REG_ZONE_CFG_C
#define LM3532_REG_CTRL_C_FS_CURR
#define LM3532_REG_ENABLE
#define LM3532_ALS_CONFIG
#define LM3532_REG_ZN_0_HI
#define LM3532_REG_ZN_0_LO
#define LM3532_REG_ZN_1_HI
#define LM3532_REG_ZN_1_LO
#define LM3532_REG_ZN_2_HI
#define LM3532_REG_ZN_2_LO
#define LM3532_REG_ZN_3_HI
#define LM3532_REG_ZN_3_LO
#define LM3532_REG_ZONE_TRGT_A
#define LM3532_REG_ZONE_TRGT_B
#define LM3532_REG_ZONE_TRGT_C
#define LM3532_REG_MAX

/* Control Enable */
#define LM3532_CTRL_A_ENABLE
#define LM3532_CTRL_B_ENABLE
#define LM3532_CTRL_C_ENABLE

/* PWM Zone Control */
#define LM3532_PWM_ZONE_MASK
#define LM3532_PWM_ZONE_0_EN
#define LM3532_PWM_ZONE_1_EN
#define LM3532_PWM_ZONE_2_EN
#define LM3532_PWM_ZONE_3_EN
#define LM3532_PWM_ZONE_4_EN

/* Brightness Configuration */
#define LM3532_I2C_CTRL
#define LM3532_ALS_CTRL
#define LM3532_LINEAR_MAP
#define LM3532_ZONE_MASK
#define LM3532_ZONE_0
#define LM3532_ZONE_1
#define LM3532_ZONE_2
#define LM3532_ZONE_3
#define LM3532_ZONE_4

#define LM3532_ENABLE_ALS
#define LM3532_ALS_SEL_SHIFT

/* Zone Boundary Register */
#define LM3532_ALS_WINDOW_mV
#define LM3532_ALS_ZB_MAX
#define LM3532_ALS_OFFSET_mV

#define LM3532_CONTROL_A
#define LM3532_CONTROL_B
#define LM3532_CONTROL_C
#define LM3532_MAX_CONTROL_BANKS
#define LM3532_MAX_LED_STRINGS

#define LM3532_OUTPUT_CFG_MASK
#define LM3532_BRT_VAL_ADJUST
#define LM3532_RAMP_DOWN_SHIFT

#define LM3532_NUM_RAMP_VALS
#define LM3532_NUM_AVG_VALS
#define LM3532_NUM_IMP_VALS

#define LM3532_FS_CURR_MIN
#define LM3532_FS_CURR_MAX
#define LM3532_FS_CURR_STEP

/*
 * struct lm3532_als_data
 * @config: value of ALS configuration register
 * @als1_imp_sel: value of ALS1 resistor select register
 * @als2_imp_sel: value of ALS2 resistor select register
 * @als_avrg_time: ALS averaging time
 * @als_input_mode: ALS input mode for brightness control
 * @als_vmin: Minimum ALS voltage
 * @als_vmax: Maximum ALS voltage
 * @zone_lo: values of ALS lo ZB(Zone Boundary) registers
 * @zone_hi: values of ALS hi ZB(Zone Boundary) registers
 */
struct lm3532_als_data {};

/**
 * struct lm3532_led
 * @led_dev: led class device
 * @priv: Pointer the device data structure
 * @control_bank: Control bank the LED is associated to
 * @mode: Mode of the LED string
 * @ctrl_brt_pointer: Zone target register that controls the sink
 * @num_leds: Number of LED strings are supported in this array
 * @full_scale_current: The full-scale current setting for the current sink.
 * @led_strings: The LED strings supported in this array
 * @enabled: Enabled status
 */
struct lm3532_led {};

/**
 * struct lm3532_data
 * @enable_gpio: Hardware enable gpio
 * @regulator: regulator
 * @client: i2c client
 * @regmap: Devices register map
 * @dev: Pointer to the devices device struct
 * @lock: Lock for reading/writing the device
 * @als_data: Pointer to the als data struct
 * @runtime_ramp_up: Runtime ramp up setting
 * @runtime_ramp_down: Runtime ramp down setting
 * @leds: Array of LED strings
 */
struct lm3532_data {};

static const struct reg_default lm3532_reg_defs[] =;

static const struct regmap_config lm3532_regmap_config =;

static const int als_imp_table[LM3532_NUM_IMP_VALS] =;
static int lm3532_get_als_imp_index(int als_imped)
{}

static int lm3532_get_index(const int table[], int size, int value)
{}

static const int als_avrg_table[LM3532_NUM_AVG_VALS] =;
static int lm3532_get_als_avg_index(int avg_time)
{}

static const int ramp_table[LM3532_NUM_RAMP_VALS] =;
static int lm3532_get_ramp_index(int ramp_time)
{}

/* Caller must take care of locking */
static int lm3532_led_enable(struct lm3532_led *led_data)
{}

/* Caller must take care of locking */
static int lm3532_led_disable(struct lm3532_led *led_data)
{}

static int lm3532_brightness_set(struct led_classdev *led_cdev,
				 enum led_brightness brt_val)
{}

static int lm3532_init_registers(struct lm3532_led *led)
{}

static int lm3532_als_configure(struct lm3532_data *priv,
				struct lm3532_led *led)
{}

static int lm3532_parse_als(struct lm3532_data *priv)
{}

static void gpio_set_low_action(void *data)
{}

static int lm3532_parse_node(struct lm3532_data *priv)
{}

static int lm3532_probe(struct i2c_client *client)
{}

static const struct of_device_id of_lm3532_leds_match[] =;
MODULE_DEVICE_TABLE(of, of_lm3532_leds_match);

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

static struct i2c_driver lm3532_i2c_driver =;
module_i2c_driver();

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