From 41d1ca8c3b1ae42dc15ac74bca5326e73bab0405 Mon Sep 17 00:00:00 2001 From: Ionela Voinescu Date: Mon, 26 Jan 2015 17:15:59 +0000 Subject: pistachio: fix clocks setup code Some of the asserts were not done properly: the value has to be shifted before is matched with the mask. Added condition to exit while loop for USB clock setup. BUG=chrome-os-partner:31438 TEST=tested on Pistachio bring up board; after this patch is applied none of the asserts fail and the code is executed properly. BRANCH=none Change-Id: Ib3aae9f7751a9f077bc95b6e0f9d63e3e16d8e4b Signed-off-by: Stefan Reinauer Original-Commit-Id: 96999a4322ba98e87bc6746ad05b30cc56704e2e Original-Change-Id: I8d2d468d618ca1ffcb1421409122482444e6d420 Original-Signed-off-by: Ionela Voinescu Original-Reviewed-on: https://chromium-review.googlesource.com/243214 Original-Reviewed-by: David Hendricks Reviewed-on: http://review.coreboot.org/9667 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- src/soc/imgtec/pistachio/clocks.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/soc') diff --git a/src/soc/imgtec/pistachio/clocks.c b/src/soc/imgtec/pistachio/clocks.c index ec77d6511d..1b7722fe74 100644 --- a/src/soc/imgtec/pistachio/clocks.c +++ b/src/soc/imgtec/pistachio/clocks.c @@ -179,8 +179,10 @@ static int pll_setup(struct pll_parameters *param, u8 divider1, u8 divider2) struct stopwatch sw; /* Check input parameters */ - assert(!(divider1 & ~(param->postdiv1_mask))); - assert(!(divider2 & ~(param->postdiv2_mask))); + assert(!((divider1 << param->postdiv1_shift) & + ~(param->postdiv1_mask))); + assert(!((divider2 << param->postdiv2_shift) & + ~(param->postdiv2_mask))); /* Temporary bypass PLL (select XTAL as clock input) */ reg = read32(PISTACHIO_CLOCK_SWITCH); @@ -198,7 +200,8 @@ static int pll_setup(struct pll_parameters *param, u8 divider1, u8 divider2) write32(param->power_down_ctrl_addr, reg); if (param->feedback_addr) { - assert(!(param->feedback & ~(param->feedback_mask))); + assert(!((param->feedback << param->feedback_shift) & + ~(param->feedback_mask))); reg = read32(param->feedback_addr); reg &= ~(param->feedback_mask); reg |= (param->feedback << param->feedback_shift) & @@ -207,7 +210,8 @@ static int pll_setup(struct pll_parameters *param, u8 divider1, u8 divider2) } if (param->refdiv_addr) { - assert(!(param->refdivider & ~(param->refdiv_mask))); + assert(!((param->refdivider << param->refdiv_shift) & + ~(param->refdiv_mask))); reg = read32(param->refdiv_addr); reg &= ~(param->refdiv_mask); reg |= (param->refdivider << param->refdiv_shift) & @@ -307,8 +311,10 @@ int usb_clk_setup(u8 divider, u8 refclksel, u8 fsel) /* Check input parameters */ assert(!(divider & ~(USBPHYCLKOUT_MASK))); - assert(!(refclksel & ~(USBPHYSTRAPCTRL_REFCLKSEL_MASK))); - assert(!(fsel & ~(USBPHYCONTROL1_FSEL_MASK))); + assert(!((refclksel << USBPHYSTRAPCTRL_REFCLKSEL_SHIFT) & + ~(USBPHYSTRAPCTRL_REFCLKSEL_MASK))); + assert(!((fsel << USBPHYCONTROL1_FSEL_SHIFT) & + ~(USBPHYCONTROL1_FSEL_MASK))); /* Set USB divider */ reg = read32(USBPHYCLKOUT_CTRL_ADDR); @@ -338,6 +344,10 @@ int usb_clk_setup(u8 divider, u8 refclksel, u8 fsel) return USB_VBUS_FAULT; if (stopwatch_expired(&sw)) return USB_TIMEOUT; + /* Check if USB is set up properly */ + if ((reg & USBPHYSTATUS_RX_PHY_CLK_MASK) && + (reg & USBPHYSTATUS_RX_UTMI_CLK_MASK)) + break; } return CLOCKS_OK; -- cgit v1.2.3