diff options
author | Furquan Shaikh <furquan@google.com> | 2014-09-20 15:07:52 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-03-28 08:44:55 +0100 |
commit | 68a672c2c268295136e1ca186cab390494088490 (patch) | |
tree | ba8afb65f303196b2cefc1640695c0feb371393c /src/soc/nvidia/tegra132/clock.c | |
parent | cd72103021a318741cd6bb51efe585ef09f0ce2b (diff) | |
download | coreboot-68a672c2c268295136e1ca186cab390494088490.tar.xz |
tegra132: Clean up clock register writes
Clean up functions to write to clk_enb and rst_dev registers and add
clock_disable and clock_set_reset functions to provide a complete API for
updating the registers.
BUG=chrome-os-partner:31821
BRANCH=None
TEST=Compiles successfully and boots to kernel prompt on ryu. Compiles
successfully on rush
Change-Id: Ib0b7e3fc322f18be396ecf3b02b2399d4ba33e9b
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 1bb222adc22c7e26077dfb2ba6e4d41a4965d183
Original-Change-Id: Icb8081fe3d80174c920eaaecf5cbb0aa912d5b19
Original-Signed-off-by: Furquan Shaikh <furquan@google.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/219191
Original-Tested-by: Furquan Shaikh <furquan@chromium.org>
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Original-Commit-Queue: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: http://review.coreboot.org/9099
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/soc/nvidia/tegra132/clock.c')
-rw-r--r-- | src/soc/nvidia/tegra132/clock.c | 130 |
1 files changed, 82 insertions, 48 deletions
diff --git a/src/soc/nvidia/tegra132/clock.c b/src/soc/nvidia/tegra132/clock.c index 1dbec797ef..d811fd85d8 100644 --- a/src/soc/nvidia/tegra132/clock.c +++ b/src/soc/nvidia/tegra132/clock.c @@ -403,9 +403,8 @@ void clock_early_uart(void) write32(CLK_SRC_DEV_ID(UARTA, CLK_M) << CLK_SOURCE_SHIFT | CLK_UART_DIV_OVERRIDE | CLK_DIVIDER(TEGRA_CLK_M_KHZ, 1900), &clk_rst->clk_src_uarta); - setbits_le32(&clk_rst->clk_out_enb_l, CLK_L_UARTA); - udelay(2); - clrbits_le32(&clk_rst->rst_dev_l, CLK_L_UARTA); + + clock_enable_clear_reset_l(CLK_L_UARTA); } /* Enable output clock (CLK1~3) for external peripherals. */ @@ -593,36 +592,70 @@ void clock_grp_enable_clear_reset(u32 val, u32* clk_enb_set_reg, writel(val, rst_dev_clr_reg); } -void clock_enable(u32 l, u32 h, u32 u, u32 v, u32 w, u32 x) +static u32 * const clk_enb_set_arr[DEV_CONFIG_BLOCKS] = { + CLK_RST_REG(clk_enb_l_set), + CLK_RST_REG(clk_enb_h_set), + CLK_RST_REG(clk_enb_u_set), + CLK_RST_REG(clk_enb_v_set), + CLK_RST_REG(clk_enb_w_set), + CLK_RST_REG(clk_enb_x_set), +}; + +static u32 * const clk_enb_clr_arr[DEV_CONFIG_BLOCKS] = { + CLK_RST_REG(clk_enb_l_clr), + CLK_RST_REG(clk_enb_h_clr), + CLK_RST_REG(clk_enb_u_clr), + CLK_RST_REG(clk_enb_v_clr), + CLK_RST_REG(clk_enb_w_clr), + CLK_RST_REG(clk_enb_x_clr), +}; + +static u32 * const rst_dev_set_arr[DEV_CONFIG_BLOCKS] = { + CLK_RST_REG(rst_dev_l_set), + CLK_RST_REG(rst_dev_h_set), + CLK_RST_REG(rst_dev_u_set), + CLK_RST_REG(rst_dev_v_set), + CLK_RST_REG(rst_dev_w_set), + CLK_RST_REG(rst_dev_x_set), +}; + +static u32 * const rst_dev_clr_arr[DEV_CONFIG_BLOCKS] = { + CLK_RST_REG(rst_dev_l_clr), + CLK_RST_REG(rst_dev_h_clr), + CLK_RST_REG(rst_dev_u_clr), + CLK_RST_REG(rst_dev_v_clr), + CLK_RST_REG(rst_dev_w_clr), + CLK_RST_REG(rst_dev_x_clr), +}; + +static void clock_write_regs(u32 * const regs[DEV_CONFIG_BLOCKS], + u32 bits[DEV_CONFIG_BLOCKS]) +{ + int i = 0; + + for (; i < DEV_CONFIG_BLOCKS; i++) + if (bits[i]) + writel(bits[i], regs[i]); +} + +void clock_enable_regs(u32 bits[DEV_CONFIG_BLOCKS]) +{ + clock_write_regs(clk_enb_set_arr, bits); +} + +void clock_disable_regs(u32 bits[DEV_CONFIG_BLOCKS]) { - if (l) - writel(l, &clk_rst->clk_enb_l_set); - if (h) - writel(h, &clk_rst->clk_enb_h_set); - if (u) - writel(u, &clk_rst->clk_enb_u_set); - if (v) - writel(v, &clk_rst->clk_enb_v_set); - if (w) - writel(w, &clk_rst->clk_enb_w_set); - if (x) - writel(x, &clk_rst->clk_enb_x_set); + clock_write_regs(clk_enb_clr_arr, bits); } -void clock_clear_reset(u32 l, u32 h, u32 u, u32 v, u32 w, u32 x) +void clock_set_reset_regs(u32 bits[DEV_CONFIG_BLOCKS]) { - if (l) - writel(l, &clk_rst->rst_dev_l_clr); - if (h) - writel(h, &clk_rst->rst_dev_h_clr); - if (u) - writel(u, &clk_rst->rst_dev_u_clr); - if (v) - writel(v, &clk_rst->rst_dev_v_clr); - if (w) - writel(w, &clk_rst->rst_dev_w_clr); - if (x) - writel(x, &clk_rst->rst_dev_x_clr); + clock_write_regs(rst_dev_set_arr, bits); +} + +void clock_clr_reset_regs(u32 bits[DEV_CONFIG_BLOCKS]) +{ + clock_write_regs(rst_dev_clr_arr, bits); } void clock_enable_clear_reset(u32 l, u32 h, u32 u, u32 v, u32 w, u32 x) @@ -632,47 +665,48 @@ void clock_enable_clear_reset(u32 l, u32 h, u32 u, u32 v, u32 w, u32 x) /* Give clocks time to stabilize. */ udelay(IO_STABILIZATION_DELAY); - clock_clear_reset(l, h, u, v, w, x); + clock_clr_reset(l, h, u, v, w, x); +} + +static void clock_reset_dev(u32 *setaddr, u32 *clraddr, u32 bit) +{ + writel(bit, setaddr); + udelay(LOGIC_STABILIZATION_DELAY); + writel(bit, clraddr); } void clock_reset_l(u32 bit) { - writel(bit, &clk_rst->rst_dev_l_set); - udelay(1); - writel(bit, &clk_rst->rst_dev_l_clr); + clock_reset_dev(CLK_RST_REG(rst_dev_l_set), CLK_RST_REG(rst_dev_l_clr), + bit); } void clock_reset_h(u32 bit) { - writel(bit, &clk_rst->rst_dev_h_set); - udelay(1); - writel(bit, &clk_rst->rst_dev_h_clr); + clock_reset_dev(CLK_RST_REG(rst_dev_h_set), CLK_RST_REG(rst_dev_h_clr), + bit); } void clock_reset_u(u32 bit) { - writel(bit, &clk_rst->rst_dev_u_set); - udelay(1); - writel(bit, &clk_rst->rst_dev_u_clr); + clock_reset_dev(CLK_RST_REG(rst_dev_u_set), CLK_RST_REG(rst_dev_u_clr), + bit); } void clock_reset_v(u32 bit) { - writel(bit, &clk_rst->rst_dev_v_set); - udelay(1); - writel(bit, &clk_rst->rst_dev_v_clr); + clock_reset_dev(CLK_RST_REG(rst_dev_v_set), CLK_RST_REG(rst_dev_v_clr), + bit); } void clock_reset_w(u32 bit) { - writel(bit, &clk_rst->rst_dev_w_set); - udelay(1); - writel(bit, &clk_rst->rst_dev_w_clr); + clock_reset_dev(CLK_RST_REG(rst_dev_w_set), CLK_RST_REG(rst_dev_w_clr), + bit); } void clock_reset_x(u32 bit) { - writel(bit, &clk_rst->rst_dev_x_set); - udelay(1); - writel(bit, &clk_rst->rst_dev_x_clr); + clock_reset_dev(CLK_RST_REG(rst_dev_x_set), CLK_RST_REG(rst_dev_x_clr), + bit); } |