The prcm apb0 controls multiple modules. Allow specifying which modules to enable clocks and de-assert resets so the function can be reused.
Signed-off-by: Chen-Yu Tsai <w...@csie.org> --- arch/arm/cpu/armv7/sunxi/p2wi.c | 2 +- arch/arm/cpu/armv7/sunxi/prcm.c | 14 ++++++-------- arch/arm/include/asm/arch-sunxi/prcm.h | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/arch/arm/cpu/armv7/sunxi/p2wi.c b/arch/arm/cpu/armv7/sunxi/p2wi.c index 343fa0b..469c7e0 100644 --- a/arch/arm/cpu/armv7/sunxi/p2wi.c +++ b/arch/arm/cpu/armv7/sunxi/p2wi.c @@ -29,7 +29,7 @@ void p2wi_init(void) struct sunxi_p2wi_reg *p2wi = (struct sunxi_p2wi_reg *)SUNXI_P2WI_BASE; /* Enable p2wi and PIO clk, and de-assert their resets */ - prcm_init_apb0(); + prcm_apb0_enable(PRCM_APB0_GATE_PIO | PRCM_APB0_GATE_P2WI); sunxi_gpio_set_cfgpin(SUNXI_GPL(0), SUNXI_GPL0_R_P2WI_SCK); sunxi_gpio_set_cfgpin(SUNXI_GPL(1), SUNXI_GPL1_R_P2WI_SDA); diff --git a/arch/arm/cpu/armv7/sunxi/prcm.c b/arch/arm/cpu/armv7/sunxi/prcm.c index 8f9bea9..783d4b6 100644 --- a/arch/arm/cpu/armv7/sunxi/prcm.c +++ b/arch/arm/cpu/armv7/sunxi/prcm.c @@ -21,17 +21,15 @@ #include <asm/arch/prcm.h> #include <asm/arch/sys_proto.h> -void prcm_init_apb0(void) +/* APB0 clock gate and reset bit offsets are the same. */ +void prcm_apb0_enable(u32 flags) { struct sunxi_prcm_reg *prcm = (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE; - u32 reg_val; - reg_val = readl(&prcm->apb0_gate); - reg_val |= PRCM_APB0_GATE_P2WI | PRCM_APB0_GATE_PIO; - writel(reg_val, &prcm->apb0_gate); + /* open the clock for module */ + setbits_le32(&prcm->apb0_gate, flags); - reg_val = readl(&prcm->apb0_reset); - reg_val |= PRCM_APB0_RESET_P2WI | PRCM_APB0_RESET_PIO; - writel(reg_val, &prcm->apb0_reset); + /* deassert reset for module */ + setbits_le32(&prcm->apb0_reset, flags); } diff --git a/arch/arm/include/asm/arch-sunxi/prcm.h b/arch/arm/include/asm/arch-sunxi/prcm.h index 85af1f8..df833d7 100644 --- a/arch/arm/include/asm/arch-sunxi/prcm.h +++ b/arch/arm/include/asm/arch-sunxi/prcm.h @@ -233,6 +233,6 @@ struct sunxi_prcm_reg { u32 dram_tst; /* 0x190 */ }; -void prcm_init_apb0(void); +void prcm_apb0_enable(u32 flags); #endif /* __ASSEMBLY__ */ #endif /* _PRCM_H */ -- 2.0.0.rc0 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.