linux/drivers/leds/leds-pca955x.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2007-2008 Extreme Engineering Solutions, Inc.
 *
 * Author: Nate Case <[email protected]>
 *
 * LED driver for various PCA955x I2C LED drivers
 *
 * Supported devices:
 *
 *	Device		Description		7-bit slave address
 *	------		-----------		-------------------
 *	PCA9550		2-bit driver		0x60 .. 0x61
 *	PCA9551		8-bit driver		0x60 .. 0x67
 *	PCA9552		16-bit driver		0x60 .. 0x67
 *	PCA9553/01	4-bit driver		0x62
 *	PCA9553/02	4-bit driver		0x63
 *
 * Philips PCA955x LED driver chips follow a register map as shown below:
 *
 *	Control Register		Description
 *	----------------		-----------
 *	0x0				Input register 0
 *					..
 *	NUM_INPUT_REGS - 1		Last Input register X
 *
 *	NUM_INPUT_REGS			Frequency prescaler 0
 *	NUM_INPUT_REGS + 1		PWM register 0
 *	NUM_INPUT_REGS + 2		Frequency prescaler 1
 *	NUM_INPUT_REGS + 3		PWM register 1
 *
 *	NUM_INPUT_REGS + 4		LED selector 0
 *	NUM_INPUT_REGS + 4
 *	    + NUM_LED_REGS - 1		Last LED selector
 *
 *  where NUM_INPUT_REGS and NUM_LED_REGS vary depending on how many
 *  bits the chip supports.
 */

#include <linux/bitops.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/driver.h>
#include <linux/i2c.h>
#include <linux/leds.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/slab.h>
#include <linux/string.h>

#include <dt-bindings/leds/leds-pca955x.h>

/* LED select registers determine the source that drives LED outputs */
#define PCA955X_LS_LED_ON
#define PCA955X_LS_LED_OFF
#define PCA955X_LS_BLINK0
#define PCA955X_LS_BLINK1

#define PCA955X_GPIO_INPUT
#define PCA955X_GPIO_HIGH
#define PCA955X_GPIO_LOW

enum pca955x_type {};

struct pca955x_chipdef {};

static const struct pca955x_chipdef pca955x_chipdefs[] =;

struct pca955x {};

struct pca955x_led {};

struct pca955x_platform_data {};

/* 8 bits per input register */
static inline int pca95xx_num_input_regs(int bits)
{}

/*
 * Return an LED selector register value based on an existing one, with
 * the appropriate 2-bit state value set for the given LED number (0-3).
 */
static inline u8 pca955x_ledsel(u8 oldval, int led_num, int state)
{}

/*
 * Write to frequency prescaler register, used to program the
 * period of the PWM output.  period = (PSCx + 1) / 38
 */
static int pca955x_write_psc(struct i2c_client *client, int n, u8 val)
{}

/*
 * Write to PWM register, which determines the duty cycle of the
 * output.  LED is OFF when the count is less than the value of this
 * register, and ON when it is greater.  If PWMx == 0, LED is always OFF.
 *
 * Duty cycle is (256 - PWMx) / 256
 */
static int pca955x_write_pwm(struct i2c_client *client, int n, u8 val)
{}

/*
 * Write to LED selector register, which determines the source that
 * drives the LED output.
 */
static int pca955x_write_ls(struct i2c_client *client, int n, u8 val)
{}

/*
 * Read the LED selector register, which determines the source that
 * drives the LED output.
 */
static int pca955x_read_ls(struct i2c_client *client, int n, u8 *val)
{}

static int pca955x_read_pwm(struct i2c_client *client, int n, u8 *val)
{}

static enum led_brightness pca955x_led_get(struct led_classdev *led_cdev)
{}

static int pca955x_led_set(struct led_classdev *led_cdev,
			    enum led_brightness value)
{}

#ifdef CONFIG_LEDS_PCA955X_GPIO
/*
 * Read the INPUT register, which contains the state of LEDs.
 */
static int pca955x_read_input(struct i2c_client *client, int n, u8 *val)
{}

static int pca955x_gpio_request_pin(struct gpio_chip *gc, unsigned int offset)
{}

static void pca955x_gpio_free_pin(struct gpio_chip *gc, unsigned int offset)
{}

static int pca955x_set_value(struct gpio_chip *gc, unsigned int offset,
			     int val)
{}

static void pca955x_gpio_set_value(struct gpio_chip *gc, unsigned int offset,
				   int val)
{}

static int pca955x_gpio_get_value(struct gpio_chip *gc, unsigned int offset)
{}

static int pca955x_gpio_direction_input(struct gpio_chip *gc,
					unsigned int offset)
{}

static int pca955x_gpio_direction_output(struct gpio_chip *gc,
					 unsigned int offset, int val)
{}
#endif /* CONFIG_LEDS_PCA955X_GPIO */

static struct pca955x_platform_data *
pca955x_get_pdata(struct i2c_client *client, const struct pca955x_chipdef *chip)
{}

static int pca955x_probe(struct i2c_client *client)
{}

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

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

static struct i2c_driver pca955x_driver =;

module_i2c_driver();

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