1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2019 Rockchip Electronics Co., Ltd
8 #include <dm/pinctrl.h>
12 #include "pinctrl-rockchip.h"
14 static struct rockchip_mux_recalced_data rk3128_mux_recalced_data[] = {
48 static struct rockchip_mux_route_data rk3128_mux_route_data[] = {
54 .route_offset = 0x144,
55 .route_val = BIT(16 + 3) | BIT(16 + 4),
61 .route_offset = 0x144,
62 .route_val = BIT(16 + 3) | BIT(16 + 4) | BIT(3),
68 .route_offset = 0x144,
69 .route_val = BIT(16 + 3) | BIT(16 + 4) | BIT(4),
75 .route_offset = 0x144,
76 .route_val = BIT(16 + 5),
82 .route_offset = 0x144,
83 .route_val = BIT(16 + 5) | BIT(5),
89 .route_offset = 0x144,
90 .route_val = BIT(16 + 6),
96 .route_offset = 0x144,
97 .route_val = BIT(16 + 6) | BIT(6),
101 #define RK3128_PULL_OFFSET 0x118
102 #define RK3128_PULL_PINS_PER_REG 16
103 #define RK3128_PULL_BANK_STRIDE 8
105 static void rk3128_calc_pull_reg_and_bit(struct rockchip_pin_bank *bank,
106 int pin_num, struct regmap **regmap,
109 struct rockchip_pinctrl_priv *priv = bank->priv;
111 *regmap = priv->regmap_base;
112 *reg = RK3128_PULL_OFFSET;
113 *reg += bank->bank_num * RK3128_PULL_BANK_STRIDE;
114 *reg += ((pin_num / RK3128_PULL_PINS_PER_REG) * 4);
116 *bit = pin_num % RK3128_PULL_PINS_PER_REG;
119 static struct rockchip_pin_bank rk3128_pin_banks[] = {
120 PIN_BANK(0, 32, "gpio0"),
121 PIN_BANK(1, 32, "gpio1"),
122 PIN_BANK(2, 32, "gpio2"),
123 PIN_BANK(3, 32, "gpio3"),
126 static struct rockchip_pin_ctrl rk3128_pin_ctrl = {
127 .pin_banks = rk3128_pin_banks,
128 .nr_banks = ARRAY_SIZE(rk3128_pin_banks),
129 .label = "RK3128-GPIO",
131 .grf_mux_offset = 0xa8,
132 .iomux_recalced = rk3128_mux_recalced_data,
133 .niomux_recalced = ARRAY_SIZE(rk3128_mux_recalced_data),
134 .iomux_routes = rk3128_mux_route_data,
135 .niomux_routes = ARRAY_SIZE(rk3128_mux_route_data),
136 .pull_calc_reg = rk3128_calc_pull_reg_and_bit,
139 static const struct udevice_id rk3128_pinctrl_ids[] = {
140 { .compatible = "rockchip,rk3128-pinctrl",
141 .data = (ulong)&rk3128_pin_ctrl },
145 U_BOOT_DRIVER(pinctrl_rk3128) = {
146 .name = "pinctrl_rk3128",
147 .id = UCLASS_PINCTRL,
148 .of_match = rk3128_pinctrl_ids,
149 .priv_auto_alloc_size = sizeof(struct rockchip_pinctrl_priv),
150 .ops = &rockchip_pinctrl_ops,
151 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
152 .bind = dm_scan_fdt_dev,
154 .probe = rockchip_pinctrl_probe,