From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfram Sang Date: Tue, 13 Sep 2011 15:12:40 +0200 Subject: [U-Boot] [PATCH 05/15] iMX28: Add I2C bus driver In-Reply-To: <201109131456.48110.marek.vasut@gmail.com> References: <1315800409-19876-1-git-send-email-marek.vasut@gmail.com> <1315800409-19876-6-git-send-email-marek.vasut@gmail.com> <20110913120530.GA5080@pengutronix.de> <201109131456.48110.marek.vasut@gmail.com> Message-ID: <20110913131240.GC5080@pengutronix.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de > > > diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c > > > new file mode 100644 > > > index 0000000..9f380a0 > > > --- /dev/null > > > +++ b/drivers/i2c/mxs_i2c.c > > > @@ -0,0 +1,240 @@ > > > +/* > > > + * Freescale i.MX28 I2C Driver > > > + * > > > + * Copyright (C) 2011 Marek Vasut > > > + * on behalf of DENX Software Engineering GmbH > > > > Do you mind adding the copyrights from the kernel driver here? It looks > > quite inspired to me, even if you didn't like some of the variable names > > and defines :) > > Bits are from the STMP3xxx driver, not much though. Could you point me to that driver? Maybe it needs fixing as well, because that pattern for example: + off = i; + for (; i < off + blen; i++) { + data >>= 8; + data |= buf[i - off] << 24; + if ((i & 3) == 2) + writel(data, &i2c_regs->hw_i2c_data); + } + + remain = 24 - ((i & 3) * 8); + if (remain) + writel(data >> remain, &i2c_regs->hw_i2c_data); is highly similar to my reimplementation of the "let's feed the buffer code" in the kernel (to name one example). Check current linus-git: for (i = 0; i < len; i++) { data >>= 8; data |= buf[i] << 24; if ((i & 3) == 2) writel(data, i2c->regs + MXS_I2C_DATA); } /* Write out the remaining bytes if any */ shifts_left = 24 - (i & 3) * 8; if (shifts_left) writel(data >> shifts_left, i2c->regs + MXS_I2C_DATA); I'd be very surprised if two programmers would come up with two routines that equal? Regards, Wolfram -- Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ | -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature Url : http://lists.denx.de/pipermail/u-boot/attachments/20110913/e7ccc63e/attachment.pgp