[PATCH 08/10] ARM: mxs: add ocotp read function

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Wed Dec 29 08:47:10 EST 2010


Hello Shawn,

On Wed, Dec 29, 2010 at 08:08:23PM +0800, Shawn Guo wrote:
> On Wed, Dec 29, 2010 at 11:47:45AM +0100, Uwe Kleine-König wrote:
> > On Tue, Dec 28, 2010 at 10:55:53PM +0800, Shawn Guo wrote:
> > > +{
> > > +	void __iomem *ocotp_base = MXS_IO_ADDRESS(MXS_OCOTP_BASE_ADDR);
> > > +	int i, timeout = 0x400;
> > > +
> > > +	/* open OCOTP banks for read */
> > > +	__mxs_setl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
> > > +
> > > +	/* approximately wait 32 hclk cycles */
> > > +	udelay(1);
> > > +
> > > +	/* poll BUSY bit becoming cleared */
> > > +	while ((__raw_readl(ocotp_base) & BM_OCOTP_CTRL_BUSY) && --timeout)
> > > +		/* nothing */;
> > > +
> > > +	if (unlikely(!timeout))
> > > +		goto error;
> > > +
> > > +	for (i = 0; i < count; i++, offset += 4)
> > > +		*values++ = __raw_readl(ocotp_base + offset);
> > > +
> > > +	/* close banks for power saving */
> > > +	__mxs_clrl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
> > > +
> > > +	return 0;
> > > +
> > > +error:
> > > +	pr_err("%s: timeout in reading OCOTP\n", __func__);
> > > +	return -ETIMEDOUT;
> > > +}
> > does this need locking?
> > 
> You are suggesting mutex or spinlock?
This isn't time critical, so I'd advice to use a mutex.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the linux-arm-kernel mailing list