From: Corey Minyard <cminyard@mvista.com>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH v6] drivers: ipmi: Support raw i2c packet in IPMB
Date: Wed, 11 Dec 2019 13:23:08 -0600 [thread overview]
Message-ID: <20191211192308.GC3585@minyard.net> (raw)
In-Reply-To: <20191211185604.1266063-1-vijaykhemka@fb.com>
On Wed, Dec 11, 2019 at 10:56:04AM -0800, Vijay Khemka wrote:
> Many IPMB devices don't support smbus protocol and this driver
> only supports the smbus protocol at the moment.
Ok, I have this in. Documentation/IPMB.txt had moved, I had to adjust
for that.
-corey
>
> Added support for the i2c protocol as well. There will be a variable
> "i2c-protocol" passed by the device tree or ACPI table which determines
> whether the protocol is i2c or smbus.
>
> Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
> Reviewed-by: Asmaa Mnebhi <asmaa@mellanox.com>
> ---
> Documentation/IPMB.txt | 4 ++++
> drivers/char/ipmi/ipmb_dev_int.c | 29 +++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
>
> diff --git a/Documentation/IPMB.txt b/Documentation/IPMB.txt
> index a6ed8b68bd0f..7a023beff976 100644
> --- a/Documentation/IPMB.txt
> +++ b/Documentation/IPMB.txt
> @@ -71,9 +71,13 @@ b) Example for device tree:
> ipmb at 10 {
> compatible = "ipmb-dev";
> reg = <0x10>;
> + i2c-protocol;
> };
> };
>
> +If xmit of data to be done using raw i2c block vs smbus
> +then "i2c-protocol" needs to be defined as above.
> +
> 2) Manually from Linux:
> modprobe ipmb-dev-int
>
> diff --git a/drivers/char/ipmi/ipmb_dev_int.c b/drivers/char/ipmi/ipmb_dev_int.c
> index ae3bfba27526..68a254c0dd92 100644
> --- a/drivers/char/ipmi/ipmb_dev_int.c
> +++ b/drivers/char/ipmi/ipmb_dev_int.c
> @@ -63,6 +63,7 @@ struct ipmb_dev {
> spinlock_t lock;
> wait_queue_head_t wait_queue;
> struct mutex file_mutex;
> + bool is_i2c_protocol;
> };
>
> static inline struct ipmb_dev *to_ipmb_dev(struct file *file)
> @@ -112,6 +113,25 @@ static ssize_t ipmb_read(struct file *file, char __user *buf, size_t count,
> return ret < 0 ? ret : count;
> }
>
> +static int ipmb_i2c_write(struct i2c_client *client, u8 *msg, u8 addr)
> +{
> + struct i2c_msg i2c_msg;
> +
> + /*
> + * subtract 1 byte (rq_sa) from the length of the msg passed to
> + * raw i2c_transfer
> + */
> + i2c_msg.len = msg[IPMB_MSG_LEN_IDX] - 1;
> +
> + /* Assign message to buffer except first 2 bytes (length and address) */
> + i2c_msg.buf = msg + 2;
> +
> + i2c_msg.addr = addr;
> + i2c_msg.flags = client->flags & I2C_CLIENT_PEC;
> +
> + return i2c_transfer(client->adapter, &i2c_msg, 1);
> +}
> +
> static ssize_t ipmb_write(struct file *file, const char __user *buf,
> size_t count, loff_t *ppos)
> {
> @@ -133,6 +153,12 @@ static ssize_t ipmb_write(struct file *file, const char __user *buf,
> rq_sa = GET_7BIT_ADDR(msg[RQ_SA_8BIT_IDX]);
> netf_rq_lun = msg[NETFN_LUN_IDX];
>
> + /* Check i2c block transfer vs smbus */
> + if (ipmb_dev->is_i2c_protocol) {
> + ret = ipmb_i2c_write(ipmb_dev->client, msg, rq_sa);
> + return (ret == 1) ? count : ret;
> + }
> +
> /*
> * subtract rq_sa and netf_rq_lun from the length of the msg passed to
> * i2c_smbus_xfer
> @@ -302,6 +328,9 @@ static int ipmb_probe(struct i2c_client *client,
> if (ret)
> return ret;
>
> + ipmb_dev->is_i2c_protocol
> + = device_property_read_bool(&client->dev, "i2c-protocol");
> +
> ipmb_dev->client = client;
> i2c_set_clientdata(client, ipmb_dev);
> ret = i2c_slave_register(client, ipmb_slave_cb);
> --
> 2.17.1
>
next prev parent reply other threads:[~2019-12-11 19:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 18:56 [PATCH v6] drivers: ipmi: Support raw i2c packet in IPMB Vijay Khemka
2019-12-11 19:23 ` Corey Minyard [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-11-14 22:33 Vijay Khemka
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=20191211192308.GC3585@minyard.net \
--to=cminyard@mvista.com \
--cc=linux-aspeed@lists.ozlabs.org \
/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.