drivers/leds/leds-mt6323.c

Source file repositories/reference/linux-study-clean/drivers/leds/leds-mt6323.c

File Facts

System
Linux kernel
Corpus path
drivers/leds/leds-mt6323.c
Extension
.c
Size
18752 bytes
Lines
728
Domain
Driver Families
Bucket
drivers/leds
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct mt6323_led {
	int			id;
	struct mt6323_leds	*parent;
	struct led_classdev	cdev;
	enum led_brightness	current_brightness;
};

/**
 * struct mt6323_regs - register spec for the LED device
 * @top_ckpdn:		Offset to ISINK_CKPDN[0..x] registers
 * @num_top_ckpdn:	Number of ISINK_CKPDN registers
 * @top_ckcon:		Offset to ISINK_CKCON[0..x] registers
 * @num_top_ckcon:	Number of ISINK_CKCON registers
 * @isink_con:		Offset to ISINKx_CON[0..x] registers
 * @num_isink_con:	Number of ISINKx_CON registers
 * @isink_max_regs:	Number of ISINK[0..x] registers
 * @isink_en_ctrl:	Offset to ISINK_EN_CTRL register
 * @iwled_en_ctrl:	Offset to IWLED_EN_CTRL register
 */
struct mt6323_regs {
	const u16 *top_ckpdn;
	u8 num_top_ckpdn;
	const u16 *top_ckcon;
	u8 num_top_ckcon;
	const u16 *isink_con;
	u8 num_isink_con;
	u8 isink_max_regs;
	u16 isink_en_ctrl;
	u16 iwled_en_ctrl;
};

/**
 * struct mt6323_hwspec - hardware specific parameters
 * @max_period:		Maximum period for all LEDs
 * @max_leds:		Maximum number of supported LEDs
 * @max_wleds:		Maximum number of WLEDs
 * @max_brightness:	Maximum brightness for all LEDs
 * @unit_duty:		Steps of duty per period
 */
struct mt6323_hwspec {
	u16 max_period;
	u8 max_leds;
	u8 max_wleds;
	u16 max_brightness;
	u16 unit_duty;
};

/**
 * struct mt6323_data - device specific data
 * @regs:		Register spec for this device
 * @spec:		Hardware specific parameters
 */
struct mt6323_data {
	const struct mt6323_regs *regs;
	const struct mt6323_hwspec *spec;
};

/**
 * struct mt6323_leds -	state container for holding LED controller
 *			of the driver
 * @dev:		the device pointer
 * @hw:			the underlying hardware providing shared
 *			bus for the register operations
 * @pdata:		device specific data
 * @lock:		the lock among process context
 * @led:		the array that contains the state of individual
 *			LED device
 */
struct mt6323_leds {
	struct device		*dev;
	struct mt6397_chip	*hw;
	const struct mt6323_data *pdata;
	/* protect among process context */
	struct mutex		lock;
	struct mt6323_led	*led[MAX_SUPPORTED_LEDS];
};

static int mt6323_led_hw_brightness(struct led_classdev *cdev,
				    enum led_brightness brightness)
{
	struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev);
	struct mt6323_leds *leds = led->parent;
	const struct mt6323_regs *regs = leds->pdata->regs;
	struct regmap *regmap = leds->hw->regmap;
	u32 con2_mask = 0, con2_val = 0;
	int ret;

	/*
	 * Setup current output for the corresponding
	 * brightness level.

Annotation

Implementation Notes