[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200421214917.GA28170@raspberrypi>
Date: Tue, 21 Apr 2020 16:49:17 -0500
From: Grant Peltier <grantpeltier93@...il.com>
To: Guenter Roeck <linux@...ck-us.net>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
adam.vaughn.xh@...esas.com, grant.peltier.jg@...esas.com
Subject: Re: [PATCH 1/2] hwmon: (pmbus/isl68137) add debugfs config and black
box endpoints
On Tue, Apr 21, 2020 at 11:58:51AM -0700, Guenter Roeck wrote:
> Normally this is emulated for such controllers. I don't recall seeing
> such a need before. The code below duplicates similar code in
> i2c_smbus_xfer_emulated(), which is much more sophisticated.
> Are you sure this is needed ? Can you point me to an affected
> controller ?
>
> > +static s32 raa_smbus_read40(const struct i2c_client *client, u8 command,
> > + unsigned char *data)
> > +{
> > + int status;
> > + unsigned char msgbuf[1];
> > + struct i2c_msg msg[2] = {
> > + {
> > + .addr = client->addr,
> > + .flags = client->flags,
> > + .len = 1,
> > + .buf = msgbuf,
> > + },
> > + {
> > + .addr = client->addr,
> > + .flags = client->flags | I2C_M_RD,
> > + .len = 5,
> > + .buf = data,
> > + },
> > + };
> > +
> > + msgbuf[0] = command;
> > + status = i2c_transfer(client->adapter, msg, 2);
> > + if (status != 2)
> > + return status;
>
> i2c_transfer() can return 1 if only one of the two messages was sent.
>
> > + return 0;
> > +}
I have been using BCM2835 for most of my testing. I originally tried using
i2c_smbus_read_block_data() but that was returning errors. However, from your
email, I went back and tried i2c_smbus_read_i2c_block_data() and that appears
to be working so I will switch to that instead.
> > +
> > +/**
> > + * Helper function required since linux SMBus implementation does not currently
> > + * (v5.6) support the SMBus 3.0 "Read 32" protocol
> > + */
> > +static s32 raa_dmpvr2_smbus_read32(const struct i2c_client *client, u8 command,
> > + unsigned char *data)
> > +{
> > + int status;
> > + unsigned char msgbuf[1];
> > + struct i2c_msg msg[2] = {
> > + {
> > + .addr = client->addr,
> > + .flags = client->flags,
> > + .len = 1,
> > + .buf = msgbuf,
> > + },
> > + {
> > + .addr = client->addr,
> > + .flags = client->flags | I2C_M_RD,
> > + .len = 4,
> > + .buf = data,
> > + },
> > + };
> > +
> > + msgbuf[0] = command;
> > + status = i2c_transfer(client->adapter, msg, 2);
> > + if (status != 2)
> > + return status;
> > + return 0;
> > +}
>
> Maybe it would be worthwhile to consider implementing it ?
>
I could add these functions to i2c-core-smbus instead if that is desired.
However, I am unsure if it would be proper to only partially update the SMBus
implementation to match the 3.0 spec. Is there perhaps a better forum to
discuss adding all of the 3.0 changes?
Powered by blists - more mailing lists