mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 14:04:54 +02:00
pinctrl: rockchip: Add pinctrl support for rk3308b
The main description for rk3308b is as follows: - Old iomux multiplexing extension; - GRF_SOC_CON5 register add some bits; - Newly added GRF_SOC_CON13/15 register. Change-Id: I94bfcae5387aceae14895f1cafa0bfea51bf8b63 Signed-off-by: David Wu <david.wu@rock-chips.com> Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
This commit is contained in:
parent
046dbf0f28
commit
eb743c6a7b
|
|
@ -39,6 +39,7 @@
|
|||
#include <linux/clk.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/rockchip/cpu.h>
|
||||
#include <dt-bindings/pinctrl/rockchip.h>
|
||||
|
||||
#include "core.h"
|
||||
|
|
@ -342,6 +343,10 @@ struct rockchip_pin_ctrl {
|
|||
struct rockchip_mux_route_data *iomux_routes;
|
||||
u32 niomux_routes;
|
||||
|
||||
int (*ctrl_data_re_init)(struct rockchip_pin_ctrl *ctrl);
|
||||
|
||||
int (*soc_data_init)(struct rockchip_pinctrl *info);
|
||||
|
||||
void (*pull_calc_reg)(struct rockchip_pin_bank *bank,
|
||||
int pin_num, struct regmap **regmap,
|
||||
int *reg, u8 *bit);
|
||||
|
|
@ -723,6 +728,100 @@ static struct rockchip_mux_recalced_data rk3308_mux_recalced_data[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static struct rockchip_mux_recalced_data rk3308b_mux_recalced_data[] = {
|
||||
{
|
||||
.num = 1,
|
||||
.pin = 14,
|
||||
.reg = 0x28,
|
||||
.bit = 12,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 1,
|
||||
.pin = 15,
|
||||
.reg = 0x2c,
|
||||
.bit = 0,
|
||||
.mask = 0x3
|
||||
}, {
|
||||
.num = 1,
|
||||
.pin = 18,
|
||||
.reg = 0x30,
|
||||
.bit = 4,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 1,
|
||||
.pin = 19,
|
||||
.reg = 0x30,
|
||||
.bit = 8,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 1,
|
||||
.pin = 20,
|
||||
.reg = 0x30,
|
||||
.bit = 12,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 1,
|
||||
.pin = 21,
|
||||
.reg = 0x34,
|
||||
.bit = 0,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 1,
|
||||
.pin = 22,
|
||||
.reg = 0x34,
|
||||
.bit = 4,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 1,
|
||||
.pin = 23,
|
||||
.reg = 0x34,
|
||||
.bit = 8,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 3,
|
||||
.pin = 12,
|
||||
.reg = 0x68,
|
||||
.bit = 8,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 3,
|
||||
.pin = 13,
|
||||
.reg = 0x68,
|
||||
.bit = 12,
|
||||
.mask = 0xf
|
||||
}, {
|
||||
.num = 2,
|
||||
.pin = 2,
|
||||
.reg = 0x608,
|
||||
.bit = 0,
|
||||
.mask = 0x7
|
||||
}, {
|
||||
.num = 2,
|
||||
.pin = 3,
|
||||
.reg = 0x608,
|
||||
.bit = 4,
|
||||
.mask = 0x7
|
||||
}, {
|
||||
.num = 2,
|
||||
.pin = 16,
|
||||
.reg = 0x610,
|
||||
.bit = 8,
|
||||
.mask = 0x7
|
||||
}, {
|
||||
.num = 3,
|
||||
.pin = 10,
|
||||
.reg = 0x610,
|
||||
.bit = 0,
|
||||
.mask = 0x7
|
||||
}, {
|
||||
.num = 3,
|
||||
.pin = 11,
|
||||
.reg = 0x610,
|
||||
.bit = 4,
|
||||
.mask = 0x7
|
||||
},
|
||||
};
|
||||
|
||||
static struct rockchip_mux_recalced_data rk3328_mux_recalced_data[] = {
|
||||
{
|
||||
.num = 2,
|
||||
|
|
@ -1118,12 +1217,198 @@ static struct rockchip_mux_route_data rk3308_mux_route_data[] = {
|
|||
/* pdm-clkm-m2 */
|
||||
.bank_num = 2,
|
||||
.pin = 4,
|
||||
.func = 2,
|
||||
.func = 3,
|
||||
.route_offset = 0x600,
|
||||
.route_val = BIT(16 + 2) | BIT(2),
|
||||
},
|
||||
};
|
||||
|
||||
static struct rockchip_mux_route_data rk3308b_mux_route_data[] = {
|
||||
{
|
||||
/* rtc_clk */
|
||||
.bank_num = 0,
|
||||
.pin = 19,
|
||||
.func = 1,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 0) | BIT(0),
|
||||
}, {
|
||||
/* uart2_rxm0 */
|
||||
.bank_num = 1,
|
||||
.pin = 22,
|
||||
.func = 2,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 2) | BIT(16 + 3),
|
||||
}, {
|
||||
/* uart2_rxm1 */
|
||||
.bank_num = 4,
|
||||
.pin = 26,
|
||||
.func = 2,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 2) | BIT(16 + 3) | BIT(2),
|
||||
}, {
|
||||
/* i2c3_sdam0 */
|
||||
.bank_num = 0,
|
||||
.pin = 15,
|
||||
.func = 2,
|
||||
.route_offset = 0x608,
|
||||
.route_val = BIT(16 + 8) | BIT(16 + 9),
|
||||
}, {
|
||||
/* i2c3_sdam1 */
|
||||
.bank_num = 3,
|
||||
.pin = 12,
|
||||
.func = 2,
|
||||
.route_offset = 0x608,
|
||||
.route_val = BIT(16 + 8) | BIT(16 + 9) | BIT(8),
|
||||
}, {
|
||||
/* i2c3_sdam2 */
|
||||
.bank_num = 2,
|
||||
.pin = 0,
|
||||
.func = 3,
|
||||
.route_offset = 0x608,
|
||||
.route_val = BIT(16 + 8) | BIT(16 + 9) | BIT(9),
|
||||
}, {
|
||||
/* i2s-8ch-1-sclktxm0 */
|
||||
.bank_num = 1,
|
||||
.pin = 3,
|
||||
.func = 2,
|
||||
.route_offset = 0x308,
|
||||
.route_val = BIT(16 + 3),
|
||||
}, {
|
||||
/* i2s-8ch-1-sclkrxm0 */
|
||||
.bank_num = 1,
|
||||
.pin = 4,
|
||||
.func = 2,
|
||||
.route_offset = 0x308,
|
||||
.route_val = BIT(16 + 3),
|
||||
}, {
|
||||
/* i2s-8ch-1-sclktxm1 */
|
||||
.bank_num = 1,
|
||||
.pin = 13,
|
||||
.func = 2,
|
||||
.route_offset = 0x308,
|
||||
.route_val = BIT(16 + 3) | BIT(3),
|
||||
}, {
|
||||
/* i2s-8ch-1-sclkrxm1 */
|
||||
.bank_num = 1,
|
||||
.pin = 14,
|
||||
.func = 2,
|
||||
.route_offset = 0x308,
|
||||
.route_val = BIT(16 + 3) | BIT(3),
|
||||
}, {
|
||||
/* pdm-clkm0 */
|
||||
.bank_num = 1,
|
||||
.pin = 4,
|
||||
.func = 3,
|
||||
.route_offset = 0x308,
|
||||
.route_val = BIT(16 + 12) | BIT(16 + 13),
|
||||
}, {
|
||||
/* pdm-clkm1 */
|
||||
.bank_num = 1,
|
||||
.pin = 14,
|
||||
.func = 4,
|
||||
.route_offset = 0x308,
|
||||
.route_val = BIT(16 + 12) | BIT(16 + 13) | BIT(12),
|
||||
}, {
|
||||
/* pdm-clkm2 */
|
||||
.bank_num = 2,
|
||||
.pin = 6,
|
||||
.func = 2,
|
||||
.route_offset = 0x308,
|
||||
.route_val = BIT(16 + 12) | BIT(16 + 13) | BIT(13),
|
||||
}, {
|
||||
/* pdm-clkm-m2 */
|
||||
.bank_num = 2,
|
||||
.pin = 4,
|
||||
.func = 3,
|
||||
.route_offset = 0x600,
|
||||
.route_val = BIT(16 + 2) | BIT(2),
|
||||
}, {
|
||||
/* spi1_miso */
|
||||
.bank_num = 3,
|
||||
.pin = 10,
|
||||
.func = 3,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 9),
|
||||
}, {
|
||||
/* spi1_miso_m1 */
|
||||
.bank_num = 2,
|
||||
.pin = 4,
|
||||
.func = 2,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 9) | BIT(9),
|
||||
}, {
|
||||
/* owire_m0 */
|
||||
.bank_num = 0,
|
||||
.pin = 11,
|
||||
.func = 3,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 10) | BIT(16 + 11),
|
||||
}, {
|
||||
/* owire_m1 */
|
||||
.bank_num = 1,
|
||||
.pin = 22,
|
||||
.func = 7,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 10) | BIT(16 + 11) | BIT(10),
|
||||
}, {
|
||||
/* owire_m2 */
|
||||
.bank_num = 2,
|
||||
.pin = 2,
|
||||
.func = 5,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 10) | BIT(16 + 11) | BIT(11),
|
||||
}, {
|
||||
/* can_rxd_m0 */
|
||||
.bank_num = 0,
|
||||
.pin = 11,
|
||||
.func = 2,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 12) | BIT(16 + 13),
|
||||
}, {
|
||||
/* can_rxd_m1 */
|
||||
.bank_num = 1,
|
||||
.pin = 22,
|
||||
.func = 5,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 12) | BIT(16 + 13) | BIT(12),
|
||||
}, {
|
||||
/* can_rxd_m2 */
|
||||
.bank_num = 2,
|
||||
.pin = 2,
|
||||
.func = 4,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 12) | BIT(16 + 13) | BIT(13),
|
||||
}, {
|
||||
/* mac_rxd0_m0 */
|
||||
.bank_num = 1,
|
||||
.pin = 20,
|
||||
.func = 3,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 14),
|
||||
}, {
|
||||
/* mac_rxd0_m1 */
|
||||
.bank_num = 4,
|
||||
.pin = 2,
|
||||
.func = 2,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 14) | BIT(14),
|
||||
}, {
|
||||
/* uart3_rx */
|
||||
.bank_num = 3,
|
||||
.pin = 12,
|
||||
.func = 4,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 15),
|
||||
}, {
|
||||
/* uart3_rx_m1 */
|
||||
.bank_num = 0,
|
||||
.pin = 17,
|
||||
.func = 3,
|
||||
.route_offset = 0x314,
|
||||
.route_val = BIT(16 + 15) | BIT(15),
|
||||
},
|
||||
};
|
||||
|
||||
static struct rockchip_mux_route_data rk3328_mux_route_data[] = {
|
||||
{
|
||||
/* uart2dbg_rxm0 */
|
||||
|
|
@ -3407,6 +3692,24 @@ static int rockchip_get_bank_data(struct rockchip_pin_bank *bank,
|
|||
|
||||
static const struct of_device_id rockchip_pinctrl_dt_match[];
|
||||
|
||||
/* Ctrl data specially handle */
|
||||
static int rk3308b_ctrl_data_re_init(struct rockchip_pin_ctrl *ctrl)
|
||||
{
|
||||
/*
|
||||
* Special for rk3308b, where we need to replace the recalced
|
||||
* and routed arrays.
|
||||
*/
|
||||
if (soc_is_rk3308b()) {
|
||||
ctrl->iomux_recalced = rk3308b_mux_recalced_data;
|
||||
ctrl->niomux_recalced = ARRAY_SIZE(rk3308b_mux_recalced_data);
|
||||
ctrl->iomux_routes = rk3308b_mux_route_data;
|
||||
ctrl->niomux_routes = ARRAY_SIZE(rk3308b_mux_route_data);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* retrieve the soc specific data */
|
||||
static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(
|
||||
struct rockchip_pinctrl *d,
|
||||
|
|
@ -3439,6 +3742,12 @@ static struct rockchip_pin_ctrl *rockchip_pinctrl_get_soc_data(
|
|||
}
|
||||
}
|
||||
|
||||
/* Ctrl data re-initialize for some Socs */
|
||||
if (ctrl->ctrl_data_re_init) {
|
||||
if (ctrl->ctrl_data_re_init(ctrl))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grf_offs = ctrl->grf_mux_offset;
|
||||
pmu_offs = ctrl->pmu_mux_offset;
|
||||
drv_pmu_offs = ctrl->pmu_drv_offset;
|
||||
|
|
@ -3585,6 +3894,48 @@ static int __maybe_unused rockchip_pinctrl_resume(struct device *dev)
|
|||
static SIMPLE_DEV_PM_OPS(rockchip_pinctrl_dev_pm_ops, rockchip_pinctrl_suspend,
|
||||
rockchip_pinctrl_resume);
|
||||
|
||||
/* SoC data specially handle */
|
||||
|
||||
/* rk3308b SoC data initialize */
|
||||
#define RK3308B_GRF_SOC_CON13 0x608
|
||||
#define RK3308B_GRF_SOC_CON15 0x610
|
||||
|
||||
/* RK3308B_GRF_SOC_CON13 */
|
||||
#define RK3308B_GRF_I2C3_IOFUNC_SRC_CTRL (BIT(16 + 10) | BIT(10))
|
||||
#define RK3308B_GRF_GPIO2A3_SEL_SRC_CTRL (BIT(16 + 7) | BIT(7))
|
||||
#define RK3308B_GRF_GPIO2A2_SEL_SRC_CTRL (BIT(16 + 3) | BIT(3))
|
||||
|
||||
/* RK3308B_GRF_SOC_CON15 */
|
||||
#define RK3308B_GRF_GPIO2C0_SEL_SRC_CTRL (BIT(16 + 11) | BIT(11))
|
||||
#define RK3308B_GRF_GPIO3B3_SEL_SRC_CTRL (BIT(16 + 7) | BIT(7))
|
||||
#define RK3308B_GRF_GPIO3B2_SEL_SRC_CTRL (BIT(16 + 3) | BIT(3))
|
||||
|
||||
static int rk3308b_soc_data_init(struct rockchip_pinctrl *info)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Enable the special ctrl of selected sources.
|
||||
*/
|
||||
if (soc_is_rk3308b()) {
|
||||
ret = regmap_write(info->regmap_base, RK3308B_GRF_SOC_CON13,
|
||||
RK3308B_GRF_I2C3_IOFUNC_SRC_CTRL |
|
||||
RK3308B_GRF_GPIO2A3_SEL_SRC_CTRL |
|
||||
RK3308B_GRF_GPIO2A2_SEL_SRC_CTRL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = regmap_write(info->regmap_base, RK3308B_GRF_SOC_CON15,
|
||||
RK3308B_GRF_GPIO2C0_SEL_SRC_CTRL |
|
||||
RK3308B_GRF_GPIO3B3_SEL_SRC_CTRL |
|
||||
RK3308B_GRF_GPIO3B2_SEL_SRC_CTRL);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rockchip_pinctrl_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct rockchip_pinctrl *info;
|
||||
|
|
@ -3656,6 +4007,13 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
|
|||
return PTR_ERR(info->regmap_pmu);
|
||||
}
|
||||
|
||||
/* Special handle for some Socs */
|
||||
if (ctrl->soc_data_init) {
|
||||
ret = ctrl->soc_data_init(info);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = rockchip_gpiolib_register(pdev, info);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -3929,6 +4287,8 @@ static struct rockchip_pin_ctrl rk3308_pin_ctrl = {
|
|||
.niomux_recalced = ARRAY_SIZE(rk3308_mux_recalced_data),
|
||||
.iomux_routes = rk3308_mux_route_data,
|
||||
.niomux_routes = ARRAY_SIZE(rk3308_mux_route_data),
|
||||
.ctrl_data_re_init = rk3308b_ctrl_data_re_init,
|
||||
.soc_data_init = rk3308b_soc_data_init,
|
||||
.pull_calc_reg = rk3308_calc_pull_reg_and_bit,
|
||||
.drv_calc_reg = rk3308_calc_drv_reg_and_bit,
|
||||
.schmitt_calc_reg = rk3308_calc_schmitt_reg_and_bit,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user