From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 5/9] tegra: i2c: Add I2C driver
Date: Thu, 1 Mar 2012 15:29:08 -0500 [thread overview]
Message-ID: <201203011529.11213.vapier@gentoo.org> (raw)
In-Reply-To: <1330536689-9121-6-git-send-email-sjg@chromium.org>
On Wednesday 29 February 2012 12:31:25 Simon Glass wrote:
> --- /dev/null
> +++ b/arch/arm/include/asm/arch-tegra2/tegra_i2c.h
>
> +/* Convert i2c slave address to be put on bus */
> +#define I2C_ADDR_ON_BUS(chip) (chip << 1)
i'm not sure the desc here is correct ... it's@least a little bit
misleading. addresses are 7bits, and the 8th bit is for telling the device to
read/write. since it only gets used in two places, might be better to inline
the bit shift there ? hard to say.
> --- /dev/null
> +++ b/drivers/i2c/tegra_i2c.c
>
> + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
guess you need to -2012 that now ;)
> +#include <common.h>
> +#include <asm/io.h>
> +#include <asm/arch/clk_rst.h>
> +#include <asm/arch/clock.h>
> +#include <asm/arch/funcmux.h>
> +#include <asm/arch/gpio.h>
> +#include <asm/arch/pinmux.h>
> +#include <asm/arch/tegra_i2c.h>
> +#include <fdtdec.h>
needs to include i2c.h to make sure your local defs stay inline with the
prototypes everyone else is using. also, asm/* generally should come last (so
after ftdec.h).
> +static int send_recv_packets(
> + struct i2c_bus *i2c_bus,
> + struct i2c_trans_info *trans)
> +{
> + struct i2c_control *control = i2c_bus->control;
> + u32 int_status;
> + u32 words;
> + u8 *dptr;
> + u32 local;
> + uchar last_bytes;
> + int error = 0;
> + int is_write = trans->flags & I2C_IS_WRITE;
> +
> + /* clear status from previous transaction, XFER_COMPLETE, NOACK, etc. */
> + int_status = readl(&control->int_status);
> + writel(int_status, &control->int_status);
> +
> + send_packet_headers(i2c_bus, trans, 1);
> +
> + words = DIV_ROUND_UP(trans->num_bytes, 4);
> + last_bytes = trans->num_bytes & 3;
> + dptr = trans->buf;
> +
> + while (words) {
> + if (is_write) {
> + /* deal with word alignment */
> + if ((unsigned)dptr & 3) {
> + memcpy(&local, dptr, sizeof(u32));
> + writel(local, &control->tx_fifo);
> + debug("pkt data sent (0x%x)\n", local);
> + } else {
> + writel(*(u32 *)dptr, &control->tx_fifo);
> + debug("pkt data sent (0x%x)\n", *(u32 *)dptr);
generally inlining these types of bitsized casts are discouraged ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120301/93d666c6/attachment.pgp>
next prev parent reply other threads:[~2012-03-01 20:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-29 17:31 [U-Boot] [PATCH v4 4/9] tegra: fdt: i2c: Add extra I2C bindings for U-Boot Simon Glass
2012-02-29 17:31 ` [U-Boot] [PATCH v4 5/9] tegra: i2c: Add I2C driver Simon Glass
2012-02-29 20:30 ` Stephen Warren
2012-03-07 4:46 ` Simon Glass
2012-03-01 7:50 ` Heiko Schocher
2012-03-01 20:29 ` Mike Frysinger [this message]
2012-03-07 4:48 ` Simon Glass
2012-02-29 17:31 ` [U-Boot] [PATCH v4 7/9] tegra: i2c: Select I2C ordering for Seaboard Simon Glass
2012-02-29 20:31 ` Stephen Warren
2012-02-29 20:21 ` [U-Boot] [PATCH v4 4/9] tegra: fdt: i2c: Add extra I2C bindings for U-Boot Stephen Warren
2012-02-29 20:32 ` Simon Glass
2012-02-29 20:36 ` Stephen Warren
2012-03-07 4:22 ` Simon Glass
2012-03-07 20:35 ` Stephen Warren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201203011529.11213.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox