Re: [PATCH 0/4] Add LVTS support for mt8192

From: Nícolas F. R. A. Prado
Date: Mon Apr 24 2023 - 18:22:02 EST


On Tue, Mar 28, 2023 at 02:20:24AM +0200, Balsam CHIHI wrote:
> On Sat, Mar 25, 2023 at 5:33 AM Chen-Yu Tsai <wenst@xxxxxxxxxxxx> wrote:
> >
> > On Wed, Mar 22, 2023 at 8:48 PM Balsam CHIHI <bchihi@xxxxxxxxxxxx> wrote:
> > >
> > > Hi Chen-Yu,
> > >
> > > I suspect the bug comes from incorrect calibration data offsets for AP
> > > Domain because you confirm that MCU Domain probe runs without issues.
> > > Is it possible to test something for us to confirm this theory (i
> > > don't have an mt8192 board on hand now), when you have the time of
> > > course?
> > > We would like to test AP Domain's calibration data offsets with a
> > > working one, for example :
> > >
> > > static const struct lvts_ctrl_data mt8192_lvts_ap_data_ctrl[] = {
> > > {
> > > - .cal_offset = { 0x25, 0x28 },
> > > + .cal_offset = { 0x04, 0x04 },
> > > .lvts_sensor = {
> > > { .dt_id = MT8192_AP_VPU0 },
> > > { .dt_id = MT8192_AP_VPU1 }
> > > @@ -1336,7 +1336,7 @@ static const struct lvts_ctrl_data
[..]
> > >
> > > This example is tested and works for mt8195,
> > > (all sensors use the same calibration data offset for testing purposes).
> > >
> > > Thank you in advance for your help.
> >
> > The MCU ones are still tripping though. If I change all of them to 0x04,
> > then nothing trips. There's also a bug in the interrupt handling code
> > that needs to be dealt with.
> >
> > AFAICT the calibration data is stored differently. If you look at ChromeOS's
> > downstream v5.10 driver, you'll see mt6873_efuse_to_cal_data() for MT8192,
> > and mt8195_efuse_to_cal_data() for MT8195. The difference sums up to:
> > MT8195 has all data sequentially stored, while MT8192 has most data stored
> > in lower 24 bits of each 32-bit word, and the highest 8 bits are then used
> > to pack data for the remaining sensors.
> >
> > Regards
> > ChenYu
>
> Hi Chen-Yu Tsai,
>
> Thank you very much for helping me testing this suggestion.
>
> Indeed, calibration data is stored differently in the mt8192 compared to mt8195.
> So, the mt8192's support will be delayed for now, to allow further debugging.
>
> In the mean time, we will only continue to upstream the remaining
> mt8195's source code, so it will get full LVTS support.
> A new series will be submitted soon.

Hi Balsam,

like Chen-Yu mentioned, the calibration data is stored with 4 byte alignment for
MT8192, but the data that is split between non-contiguous bytes is for the
thermal controllers (called Resistor-Capacitor Calibration downstream) not the
sensors. The controller calibration isn't currently handled in this driver (and
downstream it also isn't used, since a current value is read from the controller
instead), so we can just ignore those.

The patch below adjusts the addresseses for the sensors and gives me reasonable
reads, so the machine no longer reboots. Can you integrate it into your series?

Thanks,
Nícolas