Re: [PATCH v2 2/2] iio: adc: add Nuvoton NCT720x ADC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 10 Dec 2024 13:47:25 +0800
Yu-Hsian Yang <j2anfernee@xxxxxxxxx> wrote:

> Dear Jonathan Cameron,
> 
> Sorry the above mail is not finished and just sent it.
> I would explain why we can't use bulk read sequential bytes in our chips.
Ah! I replied to previous. Let me see what you added.


> > > > +
> > > > +     guard(mutex)(&chip->access_lock);
> > > > +     err  = regmap_read(chip->regmap, REG_CHANNEL_ENABLE_1, &value);
> > > > +     if (err < 0)
> > > > +             return err;
> > > > +     data[0] = (u8)value;
> > > > +
> > > > +     err  = regmap_read(chip->regmap, REG_CHANNEL_ENABLE_2, &value);
> > > > +     if (err < 0)
> > > > +             return err;  
> > >
> > > Here I think you can use a bulk read as the registers are next to each other.
> > >  
> >  
> Generally, registers with 8 bits support Byte format, and registers
> with more than 8 bits support Word format.
> If transmission a Word command to a register that supports Byte
> format, the second byte will get 0xFF.
> Here, if we use regmap_bulk_read(), we would get first byte correct
> and second byte is wrong 0xff.
> 
> I use i2ctransfer command to demo it.
> root@evb-npcm845:~# i2ctransfer -f -y 5 w1@0x1d 0x13 r1
> 0xff
> root@evb-npcm845:~# i2ctransfer -f -y 5 w1@0x1d 0x14 r1
> 0x0f
> 
> root@evb-npcm845:~# i2ctransfer -f -y 5 w1@0x1d 0x13 r2
> 0xff 0xff
> And if we read four bytes, you can see the first and third byte as we wanted.
> root@evb-npcm845:~# i2ctransfer -f -y 5 w1@0x1d 0x13 r4
> 0xff 0xff 0x0f 0xff
> 
> so we can't use bulk read directly since it would get a second byte 0xff.
> The safe method is to  use read byte twice.
That command does not do the same thing as regmap_bulk_read() will here.
It will issue a series of byte reads.

Jonathan






[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux