linux/drivers/leds/leds-aw200xx.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Awinic AW20036/AW20054/AW20072/AW20108 LED driver
 *
 * Copyright (c) 2023, SberDevices. All Rights Reserved.
 *
 * Author: Martin Kurbanov <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/container_of.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/leds.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regmap.h>
#include <linux/time.h>
#include <linux/units.h>

#define AW200XX_DIM_MAX
#define AW200XX_FADE_MAX
#define AW200XX_IMAX_DEFAULT_uA
#define AW200XX_IMAX_MAX_uA
#define AW200XX_IMAX_MIN_uA

/* Page 0 */
#define AW200XX_REG_PAGE0_BASE

/* Select page register */
#define AW200XX_REG_PAGE
#define AW200XX_PAGE_MASK
#define AW200XX_PAGE_SHIFT
#define AW200XX_NUM_PAGES
#define AW200XX_PAGE_SIZE
#define AW200XX_REG(page, reg)
#define AW200XX_REG_MAX
#define AW200XX_PAGE0
#define AW200XX_PAGE1
#define AW200XX_PAGE2
#define AW200XX_PAGE3
#define AW200XX_PAGE4
#define AW200XX_PAGE5

/* Chip ID register */
#define AW200XX_REG_IDR
#define AW200XX_IDR_CHIPID

/* Sleep mode register */
#define AW200XX_REG_SLPCR
#define AW200XX_SLPCR_ACTIVE

/* Reset register */
#define AW200XX_REG_RSTR
#define AW200XX_RSTR_RESET

/* Global current configuration register */
#define AW200XX_REG_GCCR
#define AW200XX_GCCR_IMAX_MASK
#define AW200XX_GCCR_IMAX(x)
#define AW200XX_GCCR_ALLON

/* Fast clear display control register */
#define AW200XX_REG_FCD
#define AW200XX_FCD_CLEAR

/* Display size configuration */
#define AW200XX_REG_DSIZE
#define AW200XX_DSIZE_COLUMNS_MAX

#define AW200XX_LED2REG(x, columns)

/* DIM current configuration register on page 1 */
#define AW200XX_REG_DIM_PAGE1(x, columns)

/*
 * DIM current configuration register (page 4).
 * The even address for current DIM configuration.
 * The odd address for current FADE configuration
 */
#define AW200XX_REG_DIM(x, columns)
#define AW200XX_REG_DIM2FADE(x)
#define AW200XX_REG_FADE2DIM(fade)

/*
 * Duty ratio of display scan (see p.15 of datasheet for formula):
 *   duty = (592us / 600.5us) * (1 / (display_rows + 1))
 *
 * Multiply to 1000 (MILLI) to improve the accuracy of calculations.
 */
#define AW200XX_DUTY_RATIO(rows)

struct aw200xx_chipdef {};

struct aw200xx_led {};

struct aw200xx {};

static ssize_t dim_show(struct device *dev, struct device_attribute *devattr,
			char *buf)
{}

static ssize_t dim_store(struct device *dev, struct device_attribute *devattr,
			 const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(dim);

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

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

static u32 aw200xx_imax_from_global(const struct aw200xx *const chip,
				    u32 global_imax_uA)
{}

static u32 aw200xx_imax_to_global(const struct aw200xx *const chip,
				  u32 led_imax_uA)
{}

#define AW200XX_IMAX_MULTIPLIER1
#define AW200XX_IMAX_MULTIPLIER2
#define AW200XX_IMAX_BASE_VAL1
#define AW200XX_IMAX_BASE_VAL2

/*
 * The AW200XX has a 4-bit register (GCCR) to configure the global current,
 * which ranges from 3.3mA to 160mA. The following table indicates the values
 * of the global current, divided into two parts:
 *
 * +-----------+-----------------+-----------+-----------------+
 * | reg value | global max (mA) | reg value | global max (mA) |
 * +-----------+-----------------+-----------+-----------------+
 * | 0         | 10              | 8         | 3.3             |
 * | 1         | 20              | 9         | 6.7             |
 * | 2         | 30              | 10        | 10              |
 * | 3         | 40              | 11        | 13.3            |
 * | 4         | 60              | 12        | 20              |
 * | 5         | 80              | 13        | 26.7            |
 * | 6         | 120             | 14        | 40              |
 * | 7         | 160             | 15        | 53.3            |
 * +-----------+-----------------+-----------+-----------------+
 *
 * The left part  with a multiplier of 10, and the right part  with a multiplier
 * of 3.3.
 * So we have two formulas to calculate the global current:
 *   for the left part of the table:
 *     imax = coefficient * 10
 *
 *   for the right part of the table:
 *     imax = coefficient * 3.3
 *
 * The coefficient table consists of the following values:
 *   1, 2, 3, 4, 6, 8, 12, 16.
 */
static int aw200xx_set_imax(const struct aw200xx *const chip,
			    u32 led_imax_uA)
{}

static int aw200xx_chip_reset(const struct aw200xx *const chip)
{}

static int aw200xx_chip_init(const struct aw200xx *const chip)
{}

static int aw200xx_chip_check(const struct aw200xx *const chip)
{}

static void aw200xx_enable(const struct aw200xx *const chip)
{}

static void aw200xx_disable(const struct aw200xx *const chip)
{}

static int aw200xx_probe_get_display_rows(struct device *dev,
					  struct aw200xx *chip)
{}

static int aw200xx_probe_fw(struct device *dev, struct aw200xx *chip)
{}

static const struct regmap_range_cfg aw200xx_ranges[] =;

static const struct regmap_range aw200xx_writeonly_ranges[] =;

static const struct regmap_access_table aw200xx_readable_table =;

static const struct regmap_range aw200xx_readonly_ranges[] =;

static const struct regmap_access_table aw200xx_writeable_table =;

static const struct regmap_config aw200xx_regmap_config =;

static void aw200xx_chip_reset_action(void *data)
{}

static void aw200xx_disable_action(void *data)
{}

static int aw200xx_probe(struct i2c_client *client)
{}

static const struct aw200xx_chipdef aw20036_cdef =;

static const struct aw200xx_chipdef aw20054_cdef =;

static const struct aw200xx_chipdef aw20072_cdef =;

static const struct aw200xx_chipdef aw20108_cdef =;

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

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

static struct i2c_driver aw200xx_driver =;
module_i2c_driver();

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