drivers/pinctrl/sophgo/pinctrl-sg2002.c

Source file repositories/reference/linux-study-clean/drivers/pinctrl/sophgo/pinctrl-sg2002.c

File Facts

System
Linux kernel
Corpus path
drivers/pinctrl/sophgo/pinctrl-sg2002.c
Extension
.c
Size
17598 bytes
Lines
552
Domain
Driver Families
Bucket
drivers/pinctrl
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

if (pstate == PIN_POWER_STATE_1V8) {
			*map = sg2002_18od33_1v8_oc_map;
			return ARRAY_SIZE(sg2002_18od33_1v8_oc_map);
		} else if (pstate == PIN_POWER_STATE_3V3) {
			*map = sg2002_18od33_3v3_oc_map;
			return ARRAY_SIZE(sg2002_18od33_3v3_oc_map);
		}
	}

	if (type == IO_TYPE_ETH) {
		*map = sg2002_eth_oc_map;
		return ARRAY_SIZE(sg2002_eth_oc_map);
	}

	return -ENOTSUPP;
}

static const u32 sg2002_1v8_schmitt_map[] = {
	0,
	970000,
	1040000
};

static const u32 sg2002_18od33_1v8_schmitt_map[] = {
	0,
	1070000
};

static const u32 sg2002_18od33_3v3_schmitt_map[] = {
	0,
	1100000
};

static int sg2002_get_schmitt_map(const struct sophgo_pin *sp, const u32 *psmap,
				  const u32 **map)
{
	const struct cv1800_pin *pin = sophgo_to_cv1800_pin(sp);
	enum cv1800_pin_io_type type = cv1800_pin_io_type(pin);
	u32 pstate = psmap[pin->power_domain];

	if (type == IO_TYPE_1V8_ONLY) {
		*map = sg2002_1v8_schmitt_map;
		return ARRAY_SIZE(sg2002_1v8_schmitt_map);
	}

	if (type == IO_TYPE_1V8_OR_3V3) {
		if (pstate == PIN_POWER_STATE_1V8) {
			*map = sg2002_18od33_1v8_schmitt_map;
			return ARRAY_SIZE(sg2002_18od33_1v8_schmitt_map);
		} else if (pstate == PIN_POWER_STATE_3V3) {
			*map = sg2002_18od33_3v3_schmitt_map;
			return ARRAY_SIZE(sg2002_18od33_3v3_schmitt_map);
		}
	}

	return -ENOTSUPP;
}

static const struct sophgo_vddio_cfg_ops sg2002_vddio_cfg_ops = {
	.get_pull_up		= sg2002_get_pull_up,
	.get_pull_down		= sg2002_get_pull_down,
	.get_oc_map		= sg2002_get_oc_map,
	.get_schmitt_map	= sg2002_get_schmitt_map,
};

static const struct pinctrl_pin_desc sg2002_pins[] = {
	PINCTRL_PIN(PIN_AUD_AINL_MIC,	"AUD_AINL_MIC"),
	PINCTRL_PIN(PIN_AUD_AOUTR,	"AUD_AOUTR"),
	PINCTRL_PIN(PIN_SD0_CLK,	"SD0_CLK"),
	PINCTRL_PIN(PIN_SD0_CMD,	"SD0_CMD"),
	PINCTRL_PIN(PIN_SD0_D0,		"SD0_D0"),
	PINCTRL_PIN(PIN_SD0_D1,		"SD0_D1"),
	PINCTRL_PIN(PIN_SD0_D2,		"SD0_D2"),
	PINCTRL_PIN(PIN_SD0_D3,		"SD0_D3"),
	PINCTRL_PIN(PIN_SD0_CD,		"SD0_CD"),
	PINCTRL_PIN(PIN_SD0_PWR_EN,	"SD0_PWR_EN"),
	PINCTRL_PIN(PIN_SPK_EN,		"SPK_EN"),
	PINCTRL_PIN(PIN_UART0_TX,	"UART0_TX"),
	PINCTRL_PIN(PIN_UART0_RX,	"UART0_RX"),
	PINCTRL_PIN(PIN_EMMC_DAT2,	"EMMC_DAT2"),
	PINCTRL_PIN(PIN_EMMC_CLK,	"EMMC_CLK"),
	PINCTRL_PIN(PIN_EMMC_DAT0,	"EMMC_DAT0"),
	PINCTRL_PIN(PIN_EMMC_DAT3,	"EMMC_DAT3"),
	PINCTRL_PIN(PIN_EMMC_CMD,	"EMMC_CMD"),
	PINCTRL_PIN(PIN_EMMC_DAT1,	"EMMC_DAT1"),
	PINCTRL_PIN(PIN_JTAG_CPU_TMS,	"JTAG_CPU_TMS"),
	PINCTRL_PIN(PIN_JTAG_CPU_TCK,	"JTAG_CPU_TCK"),
	PINCTRL_PIN(PIN_IIC0_SCL,	"IIC0_SCL"),
	PINCTRL_PIN(PIN_IIC0_SDA,	"IIC0_SDA"),
	PINCTRL_PIN(PIN_AUX0,		"AUX0"),

Annotation

Implementation Notes