From 62351dc39962207fea3f8f867f2c59b88ef239eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Mon, 27 May 2019 10:25:11 +0200 Subject: [PATCH] ayufan: rock64: add board_init_sdmmc_pwr_en to configure iomux in SPL mode --- arch/arm/mach-rockchip/rk3328-board-spl.c | 23 +++++++++++++++++++++++ arch/arm/mach-rockchip/rk3328/rk3328.c | 10 ++++++++++ drivers/pinctrl/rockchip/pinctrl_rk3328.c | 8 ++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-rockchip/rk3328-board-spl.c b/arch/arm/mach-rockchip/rk3328-board-spl.c index 88cda94b1e2..0c865c4ba10 100644 --- a/arch/arm/mach-rockchip/rk3328-board-spl.c +++ b/arch/arm/mach-rockchip/rk3328-board-spl.c @@ -18,12 +18,34 @@ #include #include +#define GRF_BASE 0xFF100000 + DECLARE_GLOBAL_DATA_PTR; void board_debug_uart_init(void) { } +void board_init_sdmmc_pwr_en(void) +{ + struct rk3328_grf_regs * const grf = (void *)GRF_BASE; + + printf("board_init_sdmmc_pwr_en\n"); + + rk_clrsetreg(&grf->com_iomux, + IOMUX_SEL_SDMMC_MASK, + IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT); + + rk_clrsetreg(&grf->gpio0d_iomux, + GPIO0D6_SEL_MASK, + GPIO0D6_GPIO << GPIO0D6_SEL_SHIFT); + + rk_clrsetreg(&grf->gpio1a_iomux, + GPIO1A0_SEL_MASK, + GPIO1A0_CARD_DATA_CLK_CMD_DETN + << GPIO1A0_SEL_SHIFT); +} + void board_init_f(ulong dummy) { struct udevice *dev; @@ -36,6 +58,7 @@ void board_init_f(ulong dummy) } preloader_console_init(); + board_init_sdmmc_pwr_en(); ret = uclass_get_device(UCLASS_RAM, 0, &dev); if (ret) { diff --git a/arch/arm/mach-rockchip/rk3328/rk3328.c b/arch/arm/mach-rockchip/rk3328/rk3328.c index f1db5bfc78e..9f8c8394246 100644 --- a/arch/arm/mach-rockchip/rk3328/rk3328.c +++ b/arch/arm/mach-rockchip/rk3328/rk3328.c @@ -102,6 +102,16 @@ int board_init(void) IOMUX_SEL_UART2_M1 << IOMUX_SEL_UART2_SHIFT | IOMUX_SEL_SDMMC_M1 << IOMUX_SEL_SDMMC_SHIFT); + // TODO: hack me + rk_clrsetreg(&grf->gpio0d_iomux, + GPIO0D6_SEL_MASK, + GPIO0D6_GPIO << GPIO0D6_SEL_SHIFT); + + rk_clrsetreg(&grf->gpio1a_iomux, + GPIO1A0_SEL_MASK, + GPIO1A0_CARD_DATA_CLK_CMD_DETN + << GPIO1A0_SEL_SHIFT); + ret = regulators_enable_boot_on(false); if (ret) debug("%s: Cannot enable boot on regulator\n", __func__); diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3328.c b/drivers/pinctrl/rockchip/pinctrl_rk3328.c index c928134deca..a70b38e6875 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3328.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3328.c @@ -181,14 +181,18 @@ static void pinctrl_rk3328_sdmmc_config(struct rk3328_grf_regs *grf, break; case PERIPH_ID_SDCARD: /* SDMMC_PWREN use GPIO and init as regulator-fiexed */ - if (com_iomux & IOMUX_SEL_SDMMC_MASK) + if (com_iomux & IOMUX_SEL_SDMMC_MASK) { + printf("GPIO0D6_GPIO\n"); rk_clrsetreg(&grf->gpio0d_iomux, GPIO0D6_SEL_MASK, GPIO0D6_GPIO << GPIO0D6_SEL_SHIFT); - else + } + else { rk_clrsetreg(&grf->gpio2a_iomux, GPIO2A7_SEL_MASK, GPIO2A7_GPIO << GPIO2A7_SEL_SHIFT); + printf("GPIO2A7_GPIO\n"); + } rk_clrsetreg(&grf->gpio1a_iomux, GPIO1A0_SEL_MASK, GPIO1A0_CARD_DATA_CLK_CMD_DETN