From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 02/19] dm: i2c: Make API accessible even without CONFIG_DM
Date: Fri, 06 Feb 2015 08:15:14 +0100 [thread overview]
Message-ID: <54D46A02.6030604@denx.de> (raw)
In-Reply-To: <1423197710-1568-3-git-send-email-sjg@chromium.org>
Hello Simon,
Am 06.02.2015 05:41, schrieb Simon Glass:
> Make the driver model I2C API available always, even if driver model
> is not enabled. This allows for a 'soft' switch-over, where drivers can
> use the new structures in code which is compiled but not yet used. This
> makes migration easier in some cases.
>
> Fix up the existing drivers which define their own 'struct i2c_msg'.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Add a patch to squash use of 'struct i2c_msg' in drivers
>
> drivers/i2c/adi_i2c.c | 6 +++---
> drivers/i2c/kona_i2c.c | 16 ++++++++--------
> drivers/i2c/mv_i2c.c | 10 +++++-----
> include/i2c.h | 5 +----
> 4 files changed, 17 insertions(+), 20 deletions(-)
Acked-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/drivers/i2c/adi_i2c.c b/drivers/i2c/adi_i2c.c
> index 20495b1..c58f14a 100644
> --- a/drivers/i2c/adi_i2c.c
> +++ b/drivers/i2c/adi_i2c.c
> @@ -63,7 +63,7 @@ struct twi_regs {
> #endif
>
> /* All transfers are described by this data structure */
> -struct i2c_msg {
> +struct adi_i2c_msg {
> u8 flags;
> #define I2C_M_COMBO 0x4
> #define I2C_M_STOP 0x2
> @@ -81,7 +81,7 @@ struct i2c_msg {
> * wait_for_completion - manage the actual i2c transfer
> * @msg: the i2c msg
> */
> -static int wait_for_completion(struct twi_regs *twi, struct i2c_msg *msg)
> +static int wait_for_completion(struct twi_regs *twi, struct adi_i2c_msg *msg)
> {
> u16 int_stat, ctl;
> ulong timebase = get_timer(0);
> @@ -151,7 +151,7 @@ static int i2c_transfer(struct i2c_adapter *adap, uint8_t chip, uint addr,
> (addr >> 8),
> (addr >> 16),
> };
> - struct i2c_msg msg = {
> + struct adi_i2c_msg msg = {
> .flags = flags | (len >= 0xff ? I2C_M_STOP : 0),
> .buf = buffer,
> .len = len,
> diff --git a/drivers/i2c/kona_i2c.c b/drivers/i2c/kona_i2c.c
> index 5eab338..9af496b 100644
> --- a/drivers/i2c/kona_i2c.c
> +++ b/drivers/i2c/kona_i2c.c
> @@ -156,7 +156,7 @@ static struct bcm_kona_i2c_dev g_i2c_devs[CONFIG_SYS_MAX_I2C_BUS] = {
> #define I2C_M_RD 0x0001 /* read data */
> #define I2C_M_NOSTART 0x4000 /* no restart between msgs */
>
> -struct i2c_msg {
> +struct kona_i2c_msg {
> uint16_t addr;
> uint16_t flags;
> uint16_t len;
> @@ -297,7 +297,7 @@ static int bcm_kona_i2c_read_fifo_single(struct bcm_kona_i2c_dev *dev,
>
> /* Read any amount of data using the RX FIFO from the i2c bus */
> static int bcm_kona_i2c_read_fifo(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg *msg)
> + struct kona_i2c_msg *msg)
> {
> unsigned int bytes_to_read = MAX_RX_FIFO_SIZE;
> unsigned int last_byte_nak = 0;
> @@ -392,7 +392,7 @@ static int bcm_kona_i2c_write_fifo_single(struct bcm_kona_i2c_dev *dev,
>
> /* Write any amount of data using TX FIFO to the i2c bus */
> static int bcm_kona_i2c_write_fifo(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg *msg)
> + struct kona_i2c_msg *msg)
> {
> unsigned int bytes_to_write = MAX_TX_FIFO_SIZE;
> unsigned int bytes_written = 0;
> @@ -418,7 +418,7 @@ static int bcm_kona_i2c_write_fifo(struct bcm_kona_i2c_dev *dev,
>
> /* Send i2c address */
> static int bcm_kona_i2c_do_addr(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg *msg)
> + struct kona_i2c_msg *msg)
> {
> unsigned char addr;
>
> @@ -480,9 +480,9 @@ static void bcm_kona_i2c_config_timing(struct bcm_kona_i2c_dev *dev)
>
> /* Master transfer function */
> static int bcm_kona_i2c_xfer(struct bcm_kona_i2c_dev *dev,
> - struct i2c_msg msgs[], int num)
> + struct kona_i2c_msg msgs[], int num)
> {
> - struct i2c_msg *pmsg;
> + struct kona_i2c_msg *pmsg;
> int rc = 0;
> int i;
>
> @@ -635,7 +635,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
> int alen, uchar *buffer, int len)
> {
> /* msg[0] writes the addr, msg[1] reads the data */
> - struct i2c_msg msg[2];
> + struct kona_i2c_msg msg[2];
> unsigned char msgbuf0[64];
> struct bcm_kona_i2c_dev *dev = kona_get_dev(adap);
>
> @@ -663,7 +663,7 @@ static int kona_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
> static int kona_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
> int alen, uchar *buffer, int len)
> {
> - struct i2c_msg msg[1];
> + struct kona_i2c_msg msg[1];
> unsigned char msgbuf0[64];
> unsigned int i;
> struct bcm_kona_i2c_dev *dev = kona_get_dev(adap);
> diff --git a/drivers/i2c/mv_i2c.c b/drivers/i2c/mv_i2c.c
> index dac3463..e65cce0 100644
> --- a/drivers/i2c/mv_i2c.c
> +++ b/drivers/i2c/mv_i2c.c
> @@ -31,7 +31,7 @@
> #endif
>
> /* All transfers are described by this data structure */
> -struct i2c_msg {
> +struct mv_i2c_msg {
> u8 condition;
> u8 acknack;
> u8 direction;
> @@ -157,7 +157,7 @@ static int i2c_isr_set_cleared(unsigned long set_mask,
> * -5: illegal parameters
> * -6: bus is busy and couldn't be aquired
> */
> -int i2c_transfer(struct i2c_msg *msg)
> +int i2c_transfer(struct mv_i2c_msg *msg)
> {
> int ret;
>
> @@ -286,7 +286,7 @@ void i2c_init(int speed, int slaveaddr)
> */
> int i2c_probe(uchar chip)
> {
> - struct i2c_msg msg;
> + struct mv_i2c_msg msg;
>
> i2c_reset();
>
> @@ -322,7 +322,7 @@ int i2c_probe(uchar chip)
> */
> int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
> {
> - struct i2c_msg msg;
> + struct mv_i2c_msg msg;
> u8 addr_bytes[3]; /* lowest...highest byte of data address */
>
> PRINTD(("i2c_read(chip=0x%02x, addr=0x%02x, alen=0x%02x, "
> @@ -410,7 +410,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
> */
> int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
> {
> - struct i2c_msg msg;
> + struct mv_i2c_msg msg;
> u8 addr_bytes[3]; /* lowest...highest byte of data address */
>
> PRINTD(("i2c_write(chip=0x%02x, addr=0x%02x, alen=0x%02x, "
> diff --git a/include/i2c.h b/include/i2c.h
> index 1635e9a..31b0389 100644
> --- a/include/i2c.h
> +++ b/include/i2c.h
> @@ -25,14 +25,13 @@
> * enough as to be incompatible for compilation purposes.
> */
>
> -#ifdef CONFIG_DM_I2C
> -
> enum dm_i2c_chip_flags {
> DM_I2C_CHIP_10BIT = 1 << 0, /* Use 10-bit addressing */
> DM_I2C_CHIP_RD_ADDRESS = 1 << 1, /* Send address for each read byte */
> DM_I2C_CHIP_WR_ADDRESS = 1 << 2, /* Send address for each write byte */
> };
>
> +struct udevice;
> /**
> * struct dm_i2c_chip - information about an i2c chip
> *
> @@ -439,8 +438,6 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
> int i2c_chip_ofdata_to_platdata(const void *blob, int node,
> struct dm_i2c_chip *chip);
>
> -#endif
> -
> #ifndef CONFIG_DM_I2C
>
> /*
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2015-02-06 7:15 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-06 4:41 [U-Boot] [PATCH v2 0/19] dm: Convert boards to Kconfig for driver model Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 01/19] dm: i2c: Add a dm_ prefix to driver model bus speed functions Simon Glass
2015-02-06 7:12 ` Heiko Schocher
2015-02-11 19:44 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 02/19] dm: i2c: Make API accessible even without CONFIG_DM Simon Glass
2015-02-06 7:15 ` Heiko Schocher [this message]
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 03/19] dm: Add Kconfig for driver/demo Simon Glass
2015-02-09 3:51 ` Masahiro Yamada
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 04/19] dm: Expand and complete Kconfig in drivers/ Simon Glass
2015-02-09 3:46 ` Masahiro Yamada
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 05/19] dm: Add Kconfig options for driver model SPL support Simon Glass
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 06/19] dm: test: Add a Kconfig file Simon Glass
2015-02-09 3:51 ` Masahiro Yamada
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 07/19] dm: Add CMD_DM and CMD_DEMO to Kconfig Simon Glass
2015-02-09 4:10 ` Masahiro Yamada
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 08/19] dm: Move Raspberry Pi driver model CONFIGs " Simon Glass
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 09/19] dm: exynos: Move " Simon Glass
2015-02-11 19:45 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 10/19] dm: x86: " Simon Glass
2015-02-11 19:46 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 11/19] dm: tegra: " Simon Glass
2015-02-11 19:46 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 12/19] dm: at91: snapper: " Simon Glass
2015-02-09 3:43 ` Masahiro Yamada
2015-02-10 5:04 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 13/19] dm: omap3: " Simon Glass
2015-02-09 5:35 ` Masahiro Yamada
2015-02-10 5:04 ` Simon Glass
2015-02-11 19:46 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 14/19] dm: sandbox: " Simon Glass
2015-02-11 19:46 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 15/19] dm: sunxi: " Simon Glass
2015-02-07 4:22 ` Ian Campbell
2015-02-07 15:12 ` Simon Glass
2015-02-11 19:46 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 16/19] dm: mx6: " Simon Glass
2015-02-11 19:47 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 17/19] dm: Kconfig: Move CONFIG_SYS_MALLOC_F_LEN " Simon Glass
2015-02-18 13:44 ` Alexey Brodkin
2015-02-19 14:06 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 18/19] dm: socfpga: Move driver model CONFIGs " Simon Glass
2015-02-06 23:36 ` Dinh Nguyen
2015-02-07 0:11 ` Simon Glass
2015-02-09 7:29 ` Stefan Roese
2015-02-09 16:45 ` Dinh Nguyen
2015-02-09 17:04 ` Marek Vasut
2015-02-11 19:47 ` Simon Glass
2015-02-06 4:41 ` [U-Boot] [PATCH v2 19/19] dm: Drop unused driver model config_defaults Simon Glass
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=54D46A02.6030604@denx.de \
--to=hs@denx.de \
--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