From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 6 Aug 2015 01:19:06 +0200 Subject: [U-Boot] [PATCH v5 5/5] usb: lpc32xx: add host USB driver In-Reply-To: <55C2874B.5060408@mleia.com> References: <1438799517-24273-4-git-send-email-slemieux.tyco@gmail.com> <55C2874B.5060408@mleia.com> Message-ID: <201508060119.06277.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wednesday, August 05, 2015 at 11:59:39 PM, Vladimir Zapolskiy wrote: > Hi Sylvain, Hi! [...] > > +static struct otg_regs *otg = (struct otg_regs *)USB_BASE; > > +static struct clk_pm_regs *clk_pwr = (struct clk_pm_regs *)CLK_PM_BASE; > > + > > +static int wait_for_bit(void *reg, const u32 mask, bool set) > > Note, "set" is always 1 in the driver code. Ideally, I'd like to see a generic implementation of this wait_for_bit(), but I don't want to load this unto Slemieux. > > +{ > > + u32 val; > > + unsigned long start = get_timer(0); > > + > > + while (1) { > > + val = readl(reg); > > + if (!set) > > + val = ~val; > > + > > + if ((val & mask) == mask) > > + return 0; > > + > > + if (get_timer(start) > 1000) > > Please add a macro replacing 1000, or use CONFIG_SYS_HZ. Or add a parameter, so this looks something like: if (get_timer(start) > CONFIG_HZ * timeout) > > + break; > > + > > + udelay(1); > > + } > > + > > + debug("%s: Timeout (reg=%p mask=%08x wait_set=%i)\n", > > + __func__, reg, mask, set); > > + > > + return -ETIMEDOUT; > > +} > > + > > +static int isp1301_set_value(int reg, u8 value) > > +{ > > + return i2c_write(ISP1301_I2C_ADDR, reg, 1, &value, 1); > > +} [...]