public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()
@ 2015-05-16 21:01 Simon Glass
  2015-05-18  6:03 ` Heiko Schocher
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2015-05-16 21:01 UTC (permalink / raw)
  To: u-boot

Add the legacy i2c_reg_read/write() functions to the compatibility layer
so that they can be used when CONFIG_DM_I2C_COMPAT is defined.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/i2c/i2c-uclass-compat.c | 21 +++++++++++++++++++++
 include/i2c.h                   |  6 ++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/i2c/i2c-uclass-compat.c b/drivers/i2c/i2c-uclass-compat.c
index 223f238..5606d1f 100644
--- a/drivers/i2c/i2c-uclass-compat.c
+++ b/drivers/i2c/i2c-uclass-compat.c
@@ -106,3 +106,24 @@ void board_i2c_init(const void *blob)
 {
 	/* Nothing to do here - the init happens through driver model */
 }
+
+uint8_t i2c_reg_read(uint8_t chip_addr, uint8_t offset)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_compat_get_device(chip_addr, 1, &dev);
+	if (ret)
+		return 0xff;
+	return dm_i2c_reg_read(dev, offset);
+}
+
+void i2c_reg_write(uint8_t chip_addr, uint8_t offset, uint8_t val)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = i2c_compat_get_device(chip_addr, 1, &dev);
+	if (!ret)
+		dm_i2c_reg_write(dev, offset, val);
+}
diff --git a/include/i2c.h b/include/i2c.h
index ddfebc4..9300d97 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -284,6 +284,12 @@ void i2c_init(int speed, int slaveaddr);
  */
 void board_i2c_init(const void *blob);
 
+/*
+ * Compatibility functions for driver model.
+ */
+uint8_t i2c_reg_read(uint8_t addr, uint8_t reg);
+void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val);
+
 #endif
 
 /*
-- 
2.2.0.rc0.207.ga3a616c

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()
  2015-05-16 21:01 [U-Boot] [PATCH] dm: i2c: Add compatibility functions for dm_i2c_reg_read/write() Simon Glass
@ 2015-05-18  6:03 ` Heiko Schocher
  2015-06-11 20:18   ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: Heiko Schocher @ 2015-05-18  6:03 UTC (permalink / raw)
  To: u-boot

Hello Simon,

Am 16.05.2015 23:01, schrieb Simon Glass:
> Add the legacy i2c_reg_read/write() functions to the compatibility layer
> so that they can be used when CONFIG_DM_I2C_COMPAT is defined.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   drivers/i2c/i2c-uclass-compat.c | 21 +++++++++++++++++++++
>   include/i2c.h                   |  6 ++++++
>   2 files changed, 27 insertions(+)

Acked-by: Heiko Schocher <hs@denx.de>

Thanks!

bye,
Heiko

>
> diff --git a/drivers/i2c/i2c-uclass-compat.c b/drivers/i2c/i2c-uclass-compat.c
> index 223f238..5606d1f 100644
> --- a/drivers/i2c/i2c-uclass-compat.c
> +++ b/drivers/i2c/i2c-uclass-compat.c
> @@ -106,3 +106,24 @@ void board_i2c_init(const void *blob)
>   {
>   	/* Nothing to do here - the init happens through driver model */
>   }
> +
> +uint8_t i2c_reg_read(uint8_t chip_addr, uint8_t offset)
> +{
> +	struct udevice *dev;
> +	int ret;
> +
> +	ret = i2c_compat_get_device(chip_addr, 1, &dev);
> +	if (ret)
> +		return 0xff;
> +	return dm_i2c_reg_read(dev, offset);
> +}
> +
> +void i2c_reg_write(uint8_t chip_addr, uint8_t offset, uint8_t val)
> +{
> +	struct udevice *dev;
> +	int ret;
> +
> +	ret = i2c_compat_get_device(chip_addr, 1, &dev);
> +	if (!ret)
> +		dm_i2c_reg_write(dev, offset, val);
> +}
> diff --git a/include/i2c.h b/include/i2c.h
> index ddfebc4..9300d97 100644
> --- a/include/i2c.h
> +++ b/include/i2c.h
> @@ -284,6 +284,12 @@ void i2c_init(int speed, int slaveaddr);
>    */
>   void board_i2c_init(const void *blob);
>
> +/*
> + * Compatibility functions for driver model.
> + */
> +uint8_t i2c_reg_read(uint8_t addr, uint8_t reg);
> +void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val);
> +
>   #endif
>
>   /*
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] dm: i2c: Add compatibility functions for dm_i2c_reg_read/write()
  2015-05-18  6:03 ` Heiko Schocher
@ 2015-06-11 20:18   ` Simon Glass
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Glass @ 2015-06-11 20:18 UTC (permalink / raw)
  To: u-boot

On 18 May 2015 at 00:03, Heiko Schocher <hs@denx.de> wrote:
>
> Hello Simon,
>
> Am 16.05.2015 23:01, schrieb Simon Glass:
>>
>> Add the legacy i2c_reg_read/write() functions to the compatibility layer
>> so that they can be used when CONFIG_DM_I2C_COMPAT is defined.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>>   drivers/i2c/i2c-uclass-compat.c | 21 +++++++++++++++++++++
>>   include/i2c.h                   |  6 ++++++
>>   2 files changed, 27 insertions(+)
>
>
> Acked-by: Heiko Schocher <hs@denx.de>
>

Applied to u-boot-dm.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-11 20:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-16 21:01 [U-Boot] [PATCH] dm: i2c: Add compatibility functions for dm_i2c_reg_read/write() Simon Glass
2015-05-18  6:03 ` Heiko Schocher
2015-06-11 20:18   ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox