mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-25 11:57:22 +00:00
tegra: Correct PLL access in ap20.c and clock.c
Correct this warning seen by Albert: ap20.c:44:18: warning: array subscript is above array bounds There is a subtle bug here which currently causes no errors, but might in future if people use PCI or the 32KHz clock. So take the opportunity to correct the logic now. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Warren <twarren@nvidia.com>
This commit is contained in:
parent
00a55add04
commit
27c4a3318f
3 changed files with 9 additions and 6 deletions
|
@ -77,8 +77,10 @@ static int ap20_cpu_is_cortexa9(void)
|
||||||
|
|
||||||
void init_pllx(void)
|
void init_pllx(void)
|
||||||
{
|
{
|
||||||
struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
|
struct clk_rst_ctlr *clkrst =
|
||||||
struct clk_pll *pll = &clkrst->crc_pll[CLOCK_ID_XCPU];
|
(struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
|
||||||
|
struct clk_pll_simple *pll =
|
||||||
|
&clkrst->crc_pll_simple[CLOCK_ID_XCPU - CLOCK_ID_FIRST_SIMPLE];
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
|
||||||
/* If PLLX is already enabled, just return */
|
/* If PLLX is already enabled, just return */
|
||||||
|
|
|
@ -426,7 +426,7 @@ static struct clk_pll *get_pll(enum clock_id clkid)
|
||||||
struct clk_rst_ctlr *clkrst =
|
struct clk_rst_ctlr *clkrst =
|
||||||
(struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
|
(struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
|
||||||
|
|
||||||
assert(clock_id_isvalid(clkid));
|
assert(clock_id_is_pll(clkid));
|
||||||
return &clkrst->crc_pll[clkid];
|
return &clkrst->crc_pll[clkid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ int clock_ll_read_pll(enum clock_id clkid, u32 *divm, u32 *divn,
|
||||||
assert(clkid != CLOCK_ID_USB);
|
assert(clkid != CLOCK_ID_USB);
|
||||||
|
|
||||||
/* Safety check, adds to code size but is small */
|
/* Safety check, adds to code size but is small */
|
||||||
if (!clock_id_isvalid(clkid) || clkid == CLOCK_ID_USB)
|
if (!clock_id_is_pll(clkid) || clkid == CLOCK_ID_USB)
|
||||||
return -1;
|
return -1;
|
||||||
data = readl(&pll->pll_base);
|
data = readl(&pll->pll_base);
|
||||||
*divm = (data & PLL_DIVM_MASK) >> PLL_DIVM_SHIFT;
|
*divm = (data & PLL_DIVM_MASK) >> PLL_DIVM_SHIFT;
|
||||||
|
|
|
@ -186,8 +186,9 @@ enum periph_id {
|
||||||
/* Mask value for a clock (within PERIPH_REG(id)) */
|
/* Mask value for a clock (within PERIPH_REG(id)) */
|
||||||
#define PERIPH_MASK(id) (1 << ((id) & 0x1f))
|
#define PERIPH_MASK(id) (1 << ((id) & 0x1f))
|
||||||
|
|
||||||
/* return 1 if a PLL ID is in range */
|
/* return 1 if a PLL ID is in range, and not a simple PLL */
|
||||||
#define clock_id_isvalid(id) ((id) >= CLOCK_ID_FIRST && (id) < CLOCK_ID_COUNT)
|
#define clock_id_is_pll(id) ((id) >= CLOCK_ID_FIRST && \
|
||||||
|
(id) < CLOCK_ID_FIRST_SIMPLE)
|
||||||
|
|
||||||
/* PLL stabilization delay in usec */
|
/* PLL stabilization delay in usec */
|
||||||
#define CLOCK_PLL_STABLE_DELAY_US 300
|
#define CLOCK_PLL_STABLE_DELAY_US 300
|
||||||
|
|
Loading…
Add table
Reference in a new issue