drivers/pinctrl/mediatek/pinctrl-mtk-common.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/mediatek/pinctrl-mtk-common.c- Extension
.c- Size
- 29727 bytes
- Lines
- 1169
- 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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/io.hlinux/gpio/driver.hlinux/of.hlinux/of_irq.hlinux/pinctrl/consumer.hlinux/pinctrl/machine.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinconf-generic.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.hlinux/platform_device.hlinux/slab.hlinux/bitops.hlinux/regmap.hlinux/mfd/syscon.hlinux/delay.hlinux/interrupt.hlinux/pm.hdt-bindings/pinctrl/mt65xx.h../core.h../pinconf.h../pinctrl-utils.hmtk-eint.hpinctrl-mtk-common.h
Detected Declarations
function mtk_get_portfunction mtk_pmx_gpio_set_directionfunction mtk_gpio_setfunction mtk_pconf_set_ies_smtfunction mtk_pconf_spec_set_ies_smt_rangefunction mtk_pconf_set_drivingfunction mtk_pctrl_spec_pull_set_sameregfunction mtk_pconf_set_pull_selectfunction mtk_pconf_parse_conffunction mtk_pconf_group_getfunction mtk_pconf_group_setfunction mtk_pctrl_find_group_by_pinfunction mtk_pctrl_is_function_validfunction mtk_pctrl_dt_node_to_map_funcfunction mtk_pctrl_dt_subnode_to_mapfunction mtk_pctrl_dt_node_to_mapfunction for_each_child_of_node_scopedfunction mtk_pctrl_get_groups_countfunction mtk_pctrl_get_group_pinsfunction mtk_pmx_get_funcs_cntfunction mtk_pmx_get_func_groupsfunction mtk_pmx_set_modefunction mtk_find_pin_by_eint_numfunction mtk_pmx_set_muxfunction mtk_pmx_find_gpio_modefunction mtk_pmx_gpio_request_enablefunction mtk_gpio_direction_inputfunction mtk_gpio_direction_outputfunction mtk_gpio_get_directionfunction mtk_gpio_getfunction mtk_gpio_to_irqfunction mtk_gpio_set_configfunction mtk_eint_suspendfunction mtk_eint_resumefunction mtk_pctrl_build_statefunction mtk_xt_get_gpio_nfunction mtk_xt_get_gpio_statefunction mtk_xt_set_gpio_as_eintfunction mtk_eint_initfunction mtk_pctrl_initfunction mtk_pctrl_common_probe
Annotated Snippet
if (pin == devdata->spec_pupd[i].pin) {
find = true;
break;
}
}
if (!find)
return -EINVAL;
spec_pupd_pin = devdata->spec_pupd + i;
reg_set = spec_pupd_pin->offset + devdata->port_align;
reg_rst = spec_pupd_pin->offset + (devdata->port_align << 1);
if (isup)
reg_pupd = reg_rst;
else
reg_pupd = reg_set;
bit_pupd = BIT(spec_pupd_pin->pupd_bit);
regmap_write(regmap, reg_pupd, bit_pupd);
bit_r0 = BIT(spec_pupd_pin->r0_bit);
bit_r1 = BIT(spec_pupd_pin->r1_bit);
switch (r1r0) {
case MTK_PUPD_SET_R1R0_00:
regmap_write(regmap, reg_rst, bit_r0);
regmap_write(regmap, reg_rst, bit_r1);
break;
case MTK_PUPD_SET_R1R0_01:
regmap_write(regmap, reg_set, bit_r0);
regmap_write(regmap, reg_rst, bit_r1);
break;
case MTK_PUPD_SET_R1R0_10:
regmap_write(regmap, reg_rst, bit_r0);
regmap_write(regmap, reg_set, bit_r1);
break;
case MTK_PUPD_SET_R1R0_11:
regmap_write(regmap, reg_set, bit_r0);
regmap_write(regmap, reg_set, bit_r1);
break;
default:
return -EINVAL;
}
return 0;
}
static int mtk_pconf_set_pull_select(struct mtk_pinctrl *pctl,
unsigned int pin, bool enable, bool isup, unsigned int arg)
{
unsigned int bit;
unsigned int reg_pullen, reg_pullsel, r1r0;
int ret;
/* Some pins' pull setting are very different,
* they have separate pull up/down bit, R0 and R1
* resistor bit, so we need this special handle.
*/
if (pctl->devdata->spec_pull_set) {
/* For special pins, bias-disable is set by R1R0,
* the parameter should be "MTK_PUPD_SET_R1R0_00".
*/
r1r0 = enable ? arg : MTK_PUPD_SET_R1R0_00;
ret = pctl->devdata->spec_pull_set(mtk_get_regmap(pctl, pin),
pctl->devdata, pin, isup,
r1r0);
if (!ret)
return 0;
}
/* For generic pull config, default arg value should be 0 or 1. */
if (arg != 0 && arg != 1) {
dev_err(pctl->dev, "invalid pull-up argument %d on pin %d .\n",
arg, pin);
return -EINVAL;
}
if (pctl->devdata->mt8365_set_clr_mode) {
bit = pin & pctl->devdata->mode_mask;
reg_pullen = mtk_get_port(pctl, pin) +
pctl->devdata->pullen_offset;
reg_pullsel = mtk_get_port(pctl, pin) +
pctl->devdata->pullsel_offset;
ret = pctl->devdata->mt8365_set_clr_mode(mtk_get_regmap(pctl, pin),
bit, reg_pullen, reg_pullsel,
enable, isup);
if (ret)
return -EINVAL;
Annotation
- Immediate include surface: `linux/io.h`, `linux/gpio/driver.h`, `linux/of.h`, `linux/of_irq.h`, `linux/pinctrl/consumer.h`, `linux/pinctrl/machine.h`, `linux/pinctrl/pinconf.h`, `linux/pinctrl/pinconf-generic.h`.
- Detected declarations: `function mtk_get_port`, `function mtk_pmx_gpio_set_direction`, `function mtk_gpio_set`, `function mtk_pconf_set_ies_smt`, `function mtk_pconf_spec_set_ies_smt_range`, `function mtk_pconf_set_driving`, `function mtk_pctrl_spec_pull_set_samereg`, `function mtk_pconf_set_pull_select`, `function mtk_pconf_parse_conf`, `function mtk_pconf_group_get`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.