drivers/leds/leds-lp5562.c

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

File Facts

System
Linux kernel
Corpus path
drivers/leds/leds-lp5562.c
Extension
.c
Size
10300 bytes
Lines
425
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

switch (idx) {
		case LP55XX_ENGINE_1:
			val = LP5562_ENG1_FOR_W;
			break;
		case LP55XX_ENGINE_2:
			val = LP5562_ENG2_FOR_W;
			break;
		case LP55XX_ENGINE_3:
			val = LP5562_ENG3_FOR_W;
			break;
		default:
			return -EINVAL;
		}

	} else {
		dev_err(dev, "choose RGB or W\n");
		return -EINVAL;
	}

	guard(mutex)(&chip->lock);

	lp55xx_update_bits(chip, LP5562_REG_ENG_SEL, mask, val);

	return len;
}

static LP55XX_DEV_ATTR_WO(led_pattern, lp5562_store_pattern);
static LP55XX_DEV_ATTR_WO(engine_mux, lp5562_store_engine_mux);

static struct attribute *lp5562_attributes[] = {
	&dev_attr_led_pattern.attr,
	&dev_attr_engine_mux.attr,
	NULL,
};

static const struct attribute_group lp5562_group = {
	.attrs = lp5562_attributes,
};

/* Chip specific configurations */
static struct lp55xx_device_config lp5562_cfg = {
	.max_channel  = LP5562_MAX_LEDS,
	.reg_op_mode = {
		.addr = LP5562_REG_OP_MODE,
	},
	.reg_exec = {
		.addr = LP5562_REG_ENABLE,
	},
	.reset = {
		.addr = LP5562_REG_RESET,
		.val  = LP5562_RESET,
	},
	.enable = {
		.addr = LP5562_REG_ENABLE,
		.val  = LP5562_ENABLE_DEFAULT,
	},
	.prog_mem_base = {
		.addr = LP5562_REG_PROG_MEM_ENG1,
	},
	.post_init_device   = lp5562_post_init_device,
	.set_led_current    = lp5562_set_led_current,
	.brightness_fn      = lp5562_led_brightness,
	.multicolor_brightness_fn = lp5562_multicolor_brightness,
	.run_engine         = lp5562_run_engine,
	.firmware_cb        = lp55xx_firmware_loaded_cb,
	.dev_attr_group     = &lp5562_group,
};

static const struct i2c_device_id lp5562_id[] = {
	{ .name = "lp5562", .driver_data = (kernel_ulong_t)&lp5562_cfg },
	{ }
};
MODULE_DEVICE_TABLE(i2c, lp5562_id);

static const struct of_device_id of_lp5562_leds_match[] = {
	{ .compatible = "ti,lp5562", .data = &lp5562_cfg, },
	{},
};

MODULE_DEVICE_TABLE(of, of_lp5562_leds_match);

static struct i2c_driver lp5562_driver = {
	.driver = {
		.name	= "lp5562",
		.of_match_table = of_lp5562_leds_match,
	},
	.probe		= lp55xx_probe,
	.remove		= lp55xx_remove,
	.id_table	= lp5562_id,
};

Annotation

Implementation Notes