drivers/platform/x86/intel/int3472/discrete.c

Source file repositories/reference/linux-study-clean/drivers/platform/x86/intel/int3472/discrete.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/x86/intel/int3472/discrete.c
Extension
.c
Size
15315 bytes
Lines
532
Domain
Driver Families
Bucket
drivers/platform
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 int3472_gpio_map {
	const char *hid;
	u8 type_from;
	u8 type_to;
	bool polarity_low;
	unsigned int enable_time_us;
	const char *con_id;
};

static const struct int3472_gpio_map int3472_gpio_map[] = {
	{	/* mt9m114 designs declare a powerdown pin which controls the regulators */
		.hid = "INT33F0",
		.type_from = INT3472_GPIO_TYPE_POWERDOWN,
		.type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
		.con_id = "vdd",
		.enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
	},
	{	/* ov7251 driver / DT-bindings expect "enable" as con_id for reset */
		.hid = "INT347E",
		.type_from = INT3472_GPIO_TYPE_RESET,
		.type_to = INT3472_GPIO_TYPE_RESET,
		.con_id = "enable",
	},
	{	/* ov08x40's handshake pin needs a 45 ms delay on some HP laptops */
		.hid = "OVTI08F4",
		.type_from = INT3472_GPIO_TYPE_HANDSHAKE,
		.type_to = INT3472_GPIO_TYPE_HANDSHAKE,
		.con_id = "dvdd",
		.enable_time_us = 45 * USEC_PER_MSEC,
	},
};

static void int3472_get_con_id_and_polarity(struct int3472_discrete_device *int3472, u8 *type,
					    const char **con_id, unsigned long *gpio_flags,
					    unsigned int *enable_time_us)
{
	struct acpi_device *adev = int3472->sensor;
	unsigned int i;

	for (i = 0; i < ARRAY_SIZE(int3472_gpio_map); i++) {
		/*
		 * Map the firmware-provided GPIO to whatever a driver expects
		 * (as in DT bindings). First check if the type matches with the
		 * GPIO map, then further check that the device _HID matches.
		 */
		if (*type != int3472_gpio_map[i].type_from)
			continue;

		if (!acpi_dev_hid_uid_match(adev, int3472_gpio_map[i].hid, NULL))
			continue;

		dev_dbg(int3472->dev, "mapping type 0x%02x pin to 0x%02x %s\n",
			*type, int3472_gpio_map[i].type_to, int3472_gpio_map[i].con_id);

		*type = int3472_gpio_map[i].type_to;
		*gpio_flags = int3472_gpio_map[i].polarity_low ?
			      GPIO_ACTIVE_LOW : GPIO_ACTIVE_HIGH;
		*con_id = int3472_gpio_map[i].con_id;
		*enable_time_us = int3472_gpio_map[i].enable_time_us;
		return;
	}

	*enable_time_us = GPIO_REGULATOR_ENABLE_TIME;

	switch (*type) {
	case INT3472_GPIO_TYPE_RESET:
		*con_id = "reset";
		*gpio_flags = GPIO_ACTIVE_LOW;
		break;
	case INT3472_GPIO_TYPE_POWERDOWN:
		*con_id = "powerdown";
		*gpio_flags = GPIO_ACTIVE_LOW;
		break;
	case INT3472_GPIO_TYPE_CLK_ENABLE:
		*con_id = "clk-enable";
		*gpio_flags = GPIO_ACTIVE_HIGH;
		break;
	case INT3472_GPIO_TYPE_PRIVACY_LED:
		*con_id = "privacy";
		*gpio_flags = GPIO_ACTIVE_HIGH;
		break;
	case INT3472_GPIO_TYPE_STROBE:
		*con_id = "ir_flood";
		*gpio_flags = GPIO_ACTIVE_HIGH;
		break;
	case INT3472_GPIO_TYPE_HOTPLUG_DETECT:
		*con_id = "hpd";
		*gpio_flags = GPIO_ACTIVE_HIGH;
		break;
	case INT3472_GPIO_TYPE_POWER_ENABLE:

Annotation

Implementation Notes