drivers/pinctrl/pinctrl-rockchip.c
Source file repositories/reference/linux-study-clean/drivers/pinctrl/pinctrl-rockchip.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pinctrl/pinctrl-rockchip.c- Extension
.c- Size
- 153318 bytes
- Lines
- 5333
- Domain
- Driver Families
- Bucket
- drivers/pinctrl
- 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/init.hlinux/module.hlinux/platform_device.hlinux/io.hlinux/bitops.hlinux/gpio/driver.hlinux/of.hlinux/of_platform.hlinux/pinctrl/machine.hlinux/pinctrl/pinconf.hlinux/pinctrl/pinctrl.hlinux/pinctrl/pinmux.hlinux/pinctrl/pinconf-generic.hlinux/irqchip/chained_irq.hlinux/clk.hlinux/regmap.hlinux/mfd/syscon.hlinux/string_helpers.hdt-bindings/pinctrl/rockchip.hcore.hpinconf.hpinctrl-rockchip.h
Detected Declarations
function rockchip_get_groups_countfunction rockchip_get_group_pinsfunction rockchip_dt_node_to_mapfunction rockchip_dt_free_mapfunction rockchip_get_recalced_muxfunction rockchip_get_mux_routefunction rockchip_get_muxfunction rockchip_verify_muxfunction rockchip_set_muxfunction px30_calc_pull_reg_and_bitfunction px30_calc_drv_reg_and_bitfunction px30_calc_schmitt_reg_and_bitfunction rv1103b_calc_drv_reg_and_bitfunction rv1103b_calc_pull_reg_and_bitfunction rv1103b_calc_schmitt_reg_and_bitfunction rv1108_calc_pull_reg_and_bitfunction rv1108_calc_drv_reg_and_bitfunction rv1108_calc_schmitt_reg_and_bitfunction rv1126_calc_pull_reg_and_bitfunction rv1126_calc_drv_reg_and_bitfunction rv1126_calc_schmitt_reg_and_bitfunction rk3308_calc_schmitt_reg_and_bitfunction rk2928_calc_pull_reg_and_bitfunction rk3128_calc_pull_reg_and_bitfunction rk3188_calc_pull_reg_and_bitfunction rk3288_calc_pull_reg_and_bitfunction rk3288_calc_drv_reg_and_bitfunction rk3228_calc_pull_reg_and_bitfunction rk3228_calc_drv_reg_and_bitfunction rk3308_calc_pull_reg_and_bitfunction rk3308_calc_drv_reg_and_bitfunction rk3368_calc_pull_reg_and_bitfunction rk3368_calc_drv_reg_and_bitfunction rk3399_calc_pull_reg_and_bitfunction rk3399_calc_drv_reg_and_bitfunction rk3506_calc_drv_reg_and_bitfunction rk3506_calc_pull_reg_and_bitfunction rk3506_calc_schmitt_reg_and_bitfunction rk3528_calc_drv_reg_and_bitfunction rk3528_calc_pull_reg_and_bitfunction rk3528_calc_schmitt_reg_and_bitfunction rk3562_calc_drv_reg_and_bitfunction rk3562_calc_pull_reg_and_bitfunction rk3562_calc_schmitt_reg_and_bitfunction rk3568_calc_pull_reg_and_bitfunction rk3568_calc_drv_reg_and_bitfunction rk3576_calc_drv_reg_and_bitfunction rk3576_calc_pull_reg_and_bit
Annotated Snippet
if (bank->bank_num == 0) {
if ((pin >= RK_PB4) && (pin <= RK_PD7)) {
u32 reg0 = 0;
reg0 = reg + 0x4000 - 0xC; /* PMU2_IOC_BASE */
ret = regmap_read(regmap, reg0, &val);
if (ret)
return ret;
if (!(val & BIT(8)))
return ((val >> bit) & mask);
reg = reg + 0x8000; /* BUS_IOC_BASE */
regmap = info->regmap_base;
}
} else if (bank->bank_num > 0) {
reg += 0x8000; /* BUS_IOC_BASE */
}
}
ret = regmap_read(regmap, reg, &val);
if (ret)
return ret;
return ((val >> bit) & mask);
}
static int rockchip_verify_mux(struct rockchip_pin_bank *bank,
int pin, int mux)
{
struct rockchip_pinctrl *info = bank->drvdata;
struct device *dev = info->dev;
int iomux_num = (pin / 8);
if (iomux_num > 3)
return -EINVAL;
if (bank->iomux[iomux_num].type & IOMUX_UNROUTED) {
dev_err(dev, "pin %d is unrouted\n", pin);
return -EINVAL;
}
if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY) {
if (mux != RK_FUNC_GPIO) {
dev_err(dev, "pin %d only supports a gpio mux\n", pin);
return -ENOTSUPP;
}
}
return 0;
}
/*
* Set a new mux function for a pin.
*
* The register is divided into the upper and lower 16 bit. When changing
* a value, the previous register value is not read and changed. Instead
* it seems the changed bits are marked in the upper 16 bit, while the
* changed value gets set in the same offset in the lower 16 bit.
* All pin settings seem to be 2 bit wide in both the upper and lower
* parts.
* @bank: pin bank to change
* @pin: pin to change
* @mux: new mux function to set
*/
static int rockchip_set_mux(struct rockchip_pin_bank *bank, int pin, int mux)
{
struct rockchip_pinctrl *info = bank->drvdata;
struct rockchip_pin_ctrl *ctrl = info->ctrl;
struct device *dev = info->dev;
int iomux_num = (pin / 8);
struct regmap *regmap;
int reg, ret, mask, mux_type;
u8 bit;
u32 data, rmask, route_location, route_reg, route_val;
ret = rockchip_verify_mux(bank, pin, mux);
if (ret < 0)
return ret;
if (bank->iomux[iomux_num].type & IOMUX_GPIO_ONLY)
return 0;
dev_dbg(dev, "setting mux of GPIO%d-%d to %d\n", bank->bank_num, pin, mux);
if (bank->iomux[iomux_num].type & IOMUX_SOURCE_PMU)
regmap = info->regmap_pmu;
else if (bank->iomux[iomux_num].type & IOMUX_L_SOURCE_PMU)
regmap = (pin % 8 < 4) ? info->regmap_pmu : info->regmap_base;
else
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/platform_device.h`, `linux/io.h`, `linux/bitops.h`, `linux/gpio/driver.h`, `linux/of.h`, `linux/of_platform.h`.
- Detected declarations: `function rockchip_get_groups_count`, `function rockchip_get_group_pins`, `function rockchip_dt_node_to_map`, `function rockchip_dt_free_map`, `function rockchip_get_recalced_mux`, `function rockchip_get_mux_route`, `function rockchip_get_mux`, `function rockchip_verify_mux`, `function rockchip_set_mux`, `function px30_calc_pull_reg_and_bit`.
- Atlas domain: Driver Families / drivers/pinctrl.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.