From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/6] i2c: add slave mode support
Date: Tue, 29 Apr 2014 07:30:41 +0200 [thread overview]
Message-ID: <535F3901.8010800@denx.de> (raw)
In-Reply-To: <1398561270-25091-2-git-send-email-danindrey@mail.ru>
Hello Andrey,
Am 27.04.2014 03:14, schrieb Andrey Danin:
> Signed-off-by: Andrey Danin<danindrey@mail.ru>
> CC: Stephen Warren<swarren@nvidia.com>
> CC: Marc Dietrich<marvin24@gmx.de>
> CC: Julian Andres Klode<jak@jak-linux.org>
> CC: ac100 at lists.launchpad.net
> ---
> drivers/i2c/i2c_core.c | 13 +++++++++++++
> include/i2c.h | 30 +++++++++++++++++++++++++++++-
> 2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c
> index 18d6736..105aa0a 100644
> --- a/drivers/i2c/i2c_core.c
> +++ b/drivers/i2c/i2c_core.c
> @@ -395,6 +395,19 @@ void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val)
> i2c_write(addr, reg, 1,&val, 1);
> }
>
> +int i2c_slave_io(struct i2c_transaction *trans)
> +{
> + struct i2c_adapter *cur = I2C_ADAP;
> +
> + if (!cur->slave_io) {
> + printf("Error: slave IO is not supported on adap %d\n",
> + cur->hwadapnr);
> + return -1;
> + }
> +
> + return cur->slave_io(cur, trans);
> +}
> +
> void __i2c_init(int speed, int slaveaddr)
> {
> i2c_init_bus(i2c_get_bus_num(), speed, slaveaddr);
> diff --git a/include/i2c.h b/include/i2c.h
> index f93a183..165b919 100644
> --- a/include/i2c.h
> +++ b/include/i2c.h
> @@ -55,6 +55,20 @@
> #define CONFIG_SYS_SPD_BUS_NUM 0
> #endif
>
> +struct i2c_transaction {
> + char rx_buf[34];
> + int rx_pos;
> +
> + char tx_buf[34];
> + int tx_pos;
> + int tx_size;
> +
> + unsigned int start_timeout;
> + unsigned int timeout;
> +
> + int res;
> +};
> +
> struct i2c_adapter {
> void (*init)(struct i2c_adapter *adap, int speed,
> int slaveaddr);
> @@ -65,6 +79,8 @@ struct i2c_adapter {
> int (*write)(struct i2c_adapter *adap, uint8_t chip,
> uint addr, int alen, uint8_t *buffer,
> int len);
> + int (*slave_io)(struct i2c_adapter *adap,
> + struct i2c_transaction *trans);
> uint (*set_bus_speed)(struct i2c_adapter *adap,
> uint speed);
> int speed;
> @@ -81,12 +97,13 @@ struct i2c_adapter {
> .probe = _probe, \
> .read = _read, \
> .write = _write, \
> + .slave_io = 0, \
> .set_bus_speed = _set_speed, \
> .speed = _speed, \
> .slaveaddr = _slaveaddr, \
> .init_done = 0, \
> .hwadapnr = _hwadapnr, \
> - .name = #_name \
> + .name = #_name, \
> };
>
> #define U_BOOT_I2C_ADAP_COMPLETE(_name, _init, _probe, _read, _write, \
> @@ -450,4 +467,15 @@ int i2c_get_bus_num_fdt(int node);
> * @return 0 if port was reset, -1 if not found
> */
> int i2c_reset_port_fdt(const void *blob, int node);
> +
> +/**
> + * Perform I2C transaction with master device.
> + *
> + * @param trans I2C transaction object
> + * @return 0 if succeeded, -1 if not supported,
> + * 1 if not ready, 2 if operation timed out,
> + * 3 if not our packet, other - unknown error.
> + */
> +int i2c_slave_io(struct i2c_transaction *trans);
> +
> #endif /* _I2C_H_ */
Hmm, why you use positiv error codes? Can we use negativ codes here
please? And maybe define somewhere this values as defines? Or can
you use:
include/asm-generic/errno.h
Beside of that, it looks Ok to me.
bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2014-04-29 5:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH 0/3] ARM: tegra: add nvec keyboard support for paz00>
2014-04-27 1:14 ` [PATCH v2 0/6] ARM: tegra: add nvec keyboard support for paz00 Andrey Danin
2014-04-27 1:14 ` [U-Boot] " Andrey Danin
2014-04-27 1:14 ` [U-Boot] [PATCH v2 1/6] i2c: add slave mode support Andrey Danin
2014-04-28 23:06 ` [U-Boot] [Ac100] " Stephen Warren
2014-04-30 5:31 ` Andrey Danin
2014-04-29 5:30 ` Heiko Schocher [this message]
2014-04-27 1:14 ` [U-Boot] [PATCH v2 2/6] ARM: tegra: " Andrey Danin
2014-04-29 5:36 ` Heiko Schocher
2014-04-27 1:14 ` [U-Boot] [PATCH v2 3/6] ARM: tegra: i2c: add nvec driver Andrey Danin
2014-04-29 5:43 ` Heiko Schocher
2014-04-29 7:15 ` Andrey Danin
2014-04-29 8:07 ` Heiko Schocher
2014-04-27 1:14 ` [U-Boot] [PATCH v2 4/6] ARM: tegra: nvec: add keyboard support Andrey Danin
2014-04-28 23:23 ` [U-Boot] [Ac100] " Stephen Warren
[not found] ` <1398561270-25091-1-git-send-email-danindrey-JGs/UdohzUI@public.gmane.org>
2014-04-27 1:14 ` [PATCH v2 5/6] ARM: tegra: paz00: add dt bindings for nvec Andrey Danin
2014-04-27 1:14 ` [U-Boot] " Andrey Danin
[not found] ` <1398561270-25091-6-git-send-email-danindrey-JGs/UdohzUI@public.gmane.org>
2014-04-28 23:04 ` [Ac100] " Stephen Warren
2014-04-28 23:04 ` [U-Boot] " Stephen Warren
[not found] ` <535EDE6D.2050505-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-04-30 7:52 ` [U-Boot] [Ac100] [PATCH v2 5/6] ARM: tegra: paz00: add dtbindings " Marc Dietrich
2014-04-30 7:52 ` Marc Dietrich
2014-04-30 16:21 ` Stephen Warren
2014-04-30 16:21 ` Stephen Warren
[not found] ` <536122F3.4070301-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-04-30 21:03 ` [U-Boot] [Ac100] [PATCH v2 5/6] ARM: tegra: paz00: add dtbindingsfor nvec Marc Dietrich
2014-04-30 21:03 ` Marc Dietrich
2014-04-27 1:14 ` [U-Boot] [PATCH v2 6/6] ARM: tegra: paz00: enable nvec keyboard Andrey Danin
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=535F3901.8010800@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.