Re: [PATCH 0/2] add regulator driver and mfd cell for Intel Cherry Trail Whiskey Cove PMIC

From: Andrey Zhizhikin
Date: Fri Oct 25 2019 - 07:54:23 EST

On Fri, Oct 25, 2019 at 12:45 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
> Hi,
> On 25-10-2019 12:11, Andrey Zhizhikin wrote:
> > On Fri, Oct 25, 2019 at 11:38 AM Hans de Goede <hdegoede@xxxxxxxxxx> wrote:
> >>
> >> Hi,
> >>
> >> On 25-10-2019 09:53, Andy Shevchenko wrote:
> >>> On Thu, Oct 24, 2019 at 02:29:37PM +0000, Andrey Zhizhikin wrote:
> >>>> This patchset introduces additional regulator driver for Intel Cherry
> >>>> Trail Whiskey Cove PMIC. It also adds a cell in mfd driver for this
> >>>> PMIC, which is used to instantiate this regulator.
> >>>>
> >>>> Regulator support for this PMIC was present in kernel release from Intel
> >>>> targeted Aero platform, but was not entirely ported upstream and has
> >>>> been omitted in mainline kernel releases. Consecutively, absence of
> >>>> regulator caused the SD Card interface not to be provided with Vqcc
> >>>> voltage source needed to operate with UHS-I cards.
> >>>>
> >>>> Following patches are addessing this issue and making sd card interface
> >>>> to be fully operable with UHS-I cards. Regulator driver lists an ACPI id
> >>>> of the SD Card interface in consumers and exposes optional "vqmmc"
> >>>> voltage source, which mmc driver uses to switch signalling voltages
> >>>> between 1.8V and 3.3V.
> >>>>
> >>>> This set contains of 2 patches: one is implementing the regulator driver
> >>>> (based on a non upstreamed version from Intel Aero), and another patch
> >>>> registers this driver as mfd cell in exising Whiskey Cove PMIC driver.
> >>>
> >>> Thank you.
> >>> Hans, Cc'ed, has quite interested in these kind of patches.
> >>> Am I right, Hans?
> >>
> >> Yes since I do a lot of work on Bay and Cherry Trail hw enablement I'm
> >> always interested in CHT specific patches.
> >>
> >> Overall this series looks good (from a high level view I did not
> >> do a detailed review) but I wonder if we really want to export all the
> >> regulators when we just need the vsdio one?
> >
> > I thought about this point, and actually came to a personal conclusion
> > that if I do this as a new driver - then it is better to list all
> > possible regulators, creating some sort of "skeleton" which people
> > could then work on if need be. I do agree that at the present moment
> > the one regulator which is exposed is the one for vsdio, but listing
> > all possibilities should not hurt. This was my motivation to put them
> > all into the driver on the first place.
> >
> > If you believe additional regulator elements should be removed from
> > this version of the driver - I can clean them up and come up with v2
> > here.
> >
> >>
> >> Most regulators are controlled by either the P-Unit inside the CHT SoC
> >> or through ACPI OpRegion accesses. Luckily the regulator subsys does not
> >> expose a sysfs interface for users to directly poke regulators, but this will
> >> still make it somewhat easier for users to poke regulators which they should
> >> leave alone.
> >
> > Agree, this is a valid point. But honestly I would really be surprised
> > if a user would directly touch something which can burn his silicon to
> > pieces. Regulators are usually not approached by users; unless they
> > are really HW engineers and know what they are doing.
> True.
> Hmm, I do just realize that the regulator subsystem turns off regulators
> which are not in use from its pov, which would be kinda bad here.

Interesting point, this I did not know.

> It does this when the kernel is done initializing / switches to the
> initrd or directly to the rootfs. Its been a while since I've last touched
> this. Have you tried building the regulator driver (and mfd stuff and i2c
> controller, etc.) into the kernel, so that the regulators work without modules?

This is the first thing that I've tested - I've selected the new
regulator as built-in, and it is fully operable.

> I'm afraid that if you do that they will all get turned off, with expecting
> results... Although I guess the regulator subsystem may skip this step for
> regulators without any constrains, to be sure I would have to re-read the code.

I guess (although to 100% sure), that this is exactly the reason why
this regulator remains operable - it does have neither source nor
constraints, therefore it remains enabled.

> Anyways this is a serious concern which we need to resolve.
> >> Andrey, may I ask which device you are testing this on?
> >
> > Sure, I use the original Intel Aero board. It used to have an official
> > image from Aero team with a heavily patched 4.4.y kernel, but when I
> > decided to have this updated to the latest stable branch - I've faced
> > the issue of missing core functionality, which led me to this patch.
> Ah I see, the reason I was asking is because I only know of three CHT
> devices using a Whiskey Cove PMIC (instead of the AXP288, Crystal Cove or
> TI one): the GPD Win, GPD pocket and one of the Lenovo Book versions
> (the one with the CHT SoC).

I've stumbled upon those platforms, specifically when I was searching
for information about the sdmmc interface. It looks like that they all
are affected by this missing vqmmc piece, since a lot of people have
raised complaints some SD Cards are not recognized.

> Lets say I want to test this patch-set on one of the GPD devices,
> I guess I need an UHS-I capable card and then what should I see
> in sysfs for the mmc settings ?

This is rather trivial: with the absence of 1.8v on the interface,
UHS-I cards are failing during the speed switch sped in
initialization. If you would plug in the UHS-I SD Card in the slot,
then driver outputs the error message in dmesg:
mmc2: error -110 whilst initialising SD card

Error codes returned are either ETIMEDOUT or EILSEQ, depending on how
the SD Card controller handles improper voltages on interface.

With the patch applied, when UHS-I card is inserted, following message
in recorded in dmesg:
mmc2: new ultra high speed SDR104 SDHC card at address aaaa

SDR104 mode is only for UHS-capable cards (Grade I and above); that
message is for example recorded when SanDisk Extreme 32GB card is
inserted. I've also tested different other cards from Verbatim,
Swissbit and SanDisk, and they all were recognized OK.

BTW, as a side note: there is a way to disable 1.8v switching in mmc
sub-system via quirks2, this makes all UHS-I cards to operate as High
Speed (HS) cards at 3.3v IO level. This is rather a hack, but people
using the CHT-based products tend to do exactly that (or at least this
is a common solution proposed in Internet).

As for sysfs attributes: I actually didn't look into those to really
tell you which values for which parameters would definitely
distinguish UHS cards and settings from HS ones.

> Regards,
> Hans