From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/20] dm: i2c: Add functions to read and write a register
Date: Tue, 21 Apr 2015 07:05:46 +0200 [thread overview]
Message-ID: <5535DAAA.3090300@denx.de> (raw)
In-Reply-To: <1429555051-22335-4-git-send-email-sjg@chromium.org>
Hello Simon,
Am 20.04.2015 20:37, schrieb Simon Glass:
> Add driver model versions of the legacy functions to read and write a
> single byte register. These are a useful shortcut in many cases.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> drivers/i2c/i2c-uclass.c | 19 +++++++++++++++++++
> include/i2c.h | 21 +++++++++++++++++++++
> 2 files changed, 40 insertions(+)
Acked-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
> index f2e95c0..b8eb2d6 100644
> --- a/drivers/i2c/i2c-uclass.c
> +++ b/drivers/i2c/i2c-uclass.c
> @@ -186,6 +186,25 @@ int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
> }
> }
>
> +int dm_i2c_reg_read(struct udevice *dev, uint offset)
> +{
> + uint8_t val;
> + int ret;
> +
> + ret = dm_i2c_read(dev, offset, &val, 1);
> + if (ret < 0)
> + return ret;
> +
> + return val;
> +}
> +
> +int dm_i2c_reg_write(struct udevice *dev, uint offset, uint value)
> +{
> + uint8_t val = value;
> +
> + return dm_i2c_write(dev, offset, &val, 1);
> +}
> +
> /**
> * i2c_probe_chip() - probe for a chip on a bus
> *
> diff --git a/include/i2c.h b/include/i2c.h
> index 6fd73fa..d794057 100644
> --- a/include/i2c.h
> +++ b/include/i2c.h
> @@ -124,6 +124,27 @@ int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
> struct udevice **devp);
>
> /**
> + * dm_i2c_reg_read() - Read a value from an I2C register
> + *
> + * This reads a single value from the given address in an I2C chip
> + *
> + * @addr: Address to read from
> + * @return value read, or -ve on error
> + */
> +int dm_i2c_reg_read(struct udevice *dev, uint offset);
> +
> +/**
> + * dm_i2c_reg_write() - Write a value to an I2C register
> + *
> + * This writes a single value to the given address in an I2C chip
> + *
> + * @addr: Address to write to
> + * @val: Value to write (normally a byte)
> + * @return 0 on success, -ve on error
> + */
> +int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val);
> +
> +/**
> * dm_i2c_set_bus_speed() - set the speed of a bus
> *
> * @bus: Bus to adjust
>
--
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-04-21 5:05 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-20 18:37 [U-Boot] [PATCH 00/20] dm: rtc: Add driver model support for real-time clocks Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 01/20] dm: spi: Correct the comment on spi_get_ops() Simon Glass
2015-04-22 11:39 ` Jagan Teki
2015-05-04 14:17 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 02/20] dm: i2c: sandbox: Add debugging to the speed limit Simon Glass
2015-04-21 5:04 ` Heiko Schocher
2015-04-23 15:12 ` Simon Glass
2015-04-24 5:14 ` Heiko Schocher
2015-05-04 14:19 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 03/20] dm: i2c: Add functions to read and write a register Simon Glass
2015-04-21 5:05 ` Heiko Schocher [this message]
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 04/20] dm: i2c: Add an explicit test mode to the sandbox I2C driver Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 05/20] fdt: Correct warning in fdt_setup_simplefb_node() Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 06/20] dm: rtc: Rename gregorian day function Simon Glass
2015-04-21 5:13 ` Heiko Schocher
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 07/20] dm: rtc: Rename to_tm() to rtc_to_tm() and add error code Simon Glass
2015-04-21 5:16 ` Heiko Schocher
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 08/20] dm: rtc: Rename mktime() and reduce the number of parameters Simon Glass
2015-04-21 5:17 ` Heiko Schocher
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 09/20] dm: Remove unnecessary types in bcd.h Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 10/20] dm: rtc: Split structure definition into its own file Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 11/20] dm: sandbox: Add os_localtime() to obtain the system time Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 12/20] dm: rtc: Add a uclass for real-time clocks Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 13/20] dm: rtc: sandbox: Add an emulated I2C RTC device Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 14/20] dm: rtc: sandbox: Add a driver for the sandbox I2C RTC Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 15/20] dm: rtc: Convert 'date' command to support driver model Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 16/20] dm: net: rtc: Support using driver model for rtc in sntp Simon Glass
2015-04-20 18:43 ` Joe Hershberger
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 17/20] dm: sandbox: dts: Add a real-time clock attached to I2C Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 18/20] dm: rtc: sandbox: Enable real-time clock support Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 19/20] dm: test: dts: Sort the aliases in the test device tree file Simon Glass
2015-04-21 15:32 ` Joe Hershberger
2015-05-04 14:20 ` Simon Glass
2015-04-20 18:37 ` [U-Boot] [PATCH 20/20] dm: rtc: Add tests for real-time clocks Simon Glass
2015-05-04 14:20 ` Simon Glass
2015-04-29 2:43 ` [U-Boot] [PATCH 00/20] dm: rtc: Add driver model support " Simon Glass
2015-04-29 7:09 ` Albert ARIBAUD
2015-05-03 17:21 ` 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=5535DAAA.3090300@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.