[i2c] [PATCH 8/12] drivers: PMC MSP71xx TWI driver
Marc St-Jean
Marc_St-Jean at pmc-sierra.com
Fri Jun 29 22:41:41 CEST 2007
Marc St-Jean wrote:
>
>
> Jean Delvare wrote:
> > Hi Marc,
> >
> > On Thu, 28 Jun 2007 18:01:11 -0600, Marc St-Jean wrote:
> > > [PATCH 8/12] drivers: PMC MSP71xx TWI driver
> > >
> > > Patch to add TWI driver for the PMC-Sierra MSP71xx devices.
> > >
> > > Thanks,
> > > Marc
> > >
> > > Signed-off-by: Marc St-Jean <Marc_St-Jean at pmc-sierra.com>
> > > ---
> > > Changes since last post:
> > > - Changed config item to no longer depend on I2C and updated help
> text.
> > > - Converted to platform device driver and rewrote probe/remove
> > functions.
> > > - Changed xfer_command to fix up be64 handling in .
> > > - Changed master_xfer function to eliminate support for multiple
> > commands
> > > other that simple write-read. Fixed probing workaround to not perform
> > a read.
> > > - Updated IRQ flags.
> > > - Returned more meaningful error codes.
> > > - Removed unnecessary headers and definitions.
> > > - Removed get_clock_config function as not currently used.
> > > - Removed algo_data function pointers and made direct calls.
> > > - Removed extra casts and backets.
> > > - Removed redundant debugging output.
> > > - Other cleanups as requested by feedback.
> > >
> > > Kconfig | 6
> > > Makefile | 1
> > > i2c-pmcmsp.c | 674
> > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > 3 files changed, 681 insertions(+)
> >
...
> >
> > > +
> > > + if (msg->len == 0) {
> > > + if (msg->flags & I2C_M_RD) {
> > > + dev_dbg(&adap->dev,
> > > + "Read of 0 bytes unsupported\n");
> > > + return -EINVAL;
> > > + } else {
> > > + dev_dbg(&adap->dev, "Probing for slave at
> > 0x%02x\n",
> > > + msg->addr & 0xff);
> > > + probe = true;
> > > +
> > > + /* Probe is a special write of 1 byte */
> > > + cmd.write_len = 1;
> > > + cmd.write_data = probe_buf;
> > > + }
> > > + }
> >
> > This should go away. As explained in my other post, new-style i2c
> > drivers don't need probing (and if you really want probing, it no
> > longer requires zero-byte messages.)
>
> I understand but is that not dependent on a the chip drivers?
> We can't assume our customers only use new style drivers to get
> at devices on their boards.
>
> > > +
> > > + cmd.addr = msg->addr;
> > > +
> > > + if (probe || (msg->flags & I2C_M_TEN)) {
> > > + pmcmsptwi_get_twi_config(&newcfg, data);
> > > + memcpy(&oldcfg, &newcfg, sizeof(oldcfg));
> > > +
> > > + /* For probes, we don't want any retries */
> > > + if (probe)
> > > + newcfg.nak = 0;
> > > +
> > > + /* Set the special 10-bit address flag, if required */
> > > + if (msg->flags & I2C_M_TEN)
> > > + newcfg.add10 = 1;
> > > +
> > > + pmcmsptwi_set_twi_config(&newcfg, data);
> > > + }
> > > +
> > > + /* Execute the command */
> > > + ret = pmcmsptwi_xfer_cmd(&cmd, data);
> > > +
> > > + if (probe || (msg->flags & I2C_M_TEN))
> > > + pmcmsptwi_set_twi_config(&oldcfg, data);
> > > +
> > > + dev_dbg(&adap->dev, "I2C %s of %d bytes ",
> > > + (msg->flags & I2C_M_RD) ? "read" : "write", msg->len);
> > > + if (ret != MSP_TWI_XFER_OK) {
> > > + /*
> > > + * TODO: We could potentially loop and retry in the
> case
> > > + * of MSP_TWI_XFER_TIMEOUT.
> > > + */
> > > + dev_dbg(&adap->dev, "failed\n");
> > > + return -1;
> > > + }
> > > +
> > > + dev_dbg(&adap->dev, "succeeded\n");
> > > + return 0;
> > > +}
> > > +
> > > +static u32 pmcmsptwi_i2c_func(struct i2c_adapter *adapter)
> > > +{
> > > + return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR |
> I2C_FUNC_SMBUS_EMUL;
> > > +}
> >
> > You'll have to change this. I2C_FUNC_SMBUS_EMUL includes
> > I2C_FUNC_SMBUS_QUICK and it's important that you don't pretend to
> > support that when you don't.
>
> OK, changed to:
> return I2C_FUNC_I2C | | I2C_FUNC_10BIT_ADDR |
> I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA |
> I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_PROC_CALLL;
>
Hi Jean,
I guess what this function returns is dependent on the answer to the first item
above.
I just found out that removing I2C_FUNC_SMBUS_QUICK will prevent probes from
functioning, so I've added it for now.
The error returned is:
i2c /dev entries driver
pmcmsptwi: Registering MSP71xx I2C adapter
PMC MSP TWI-LED Driver
i2c_adapter i2c-0: SMBus Quick command not supported, can't probe for chips
...
Marc
More information about the i2c
mailing list