[PATCH] dts: imx8mq-librem5: Don't wake up on volume key press

2024-05-20 Thread Guido Günther
The only key that should wake up the phone is power button press. This
prevents accidental wakeup due to e.g. pressing the buttons in the
pocket or backpack and is in line what userspace uses to unblank the
device.

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
index ffb5fe61630d..1b39514d5c12 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5.dtsi
@@ -45,7 +45,6 @@ key-vol-down {
gpios = < 17 GPIO_ACTIVE_LOW>;
linux,code = ;
debounce-interval = <50>;
-   wakeup-source;
};
 
key-vol-up {
@@ -53,7 +52,6 @@ key-vol-up {
gpios = < 16 GPIO_ACTIVE_LOW>;
linux,code = ;
debounce-interval = <50>;
-   wakeup-source;
};
};
 
-- 
2.43.0




Re: [PATCH v1 1/1] Input: gpio-keys - expose wakeup keys in sysfs

2024-05-14 Thread Guido Günther
Hi,
On Mon, May 13, 2024 at 03:13:53PM -0700, Dmitry Torokhov wrote:
> Hi Guido,
> 
> On Thu, May 09, 2024 at 02:00:28PM +0200, Guido Günther wrote:
> > This helps user space to figure out which keys should be used to unidle a
> > device. E.g on phones the volume rocker should usually not unblank the
> > screen.
> 
> How exactly this is supposed to be used? We have "disabled" keys and
> switches attribute because this function can be controlled at runtime
> from userspace while wakeup control is a static device setting.

Current Linux userspace usually unblanks/unidles a device on every
keypress. That is usually not the expected result on phones where often
only the power button and e.g. some home buttons should do this.

These keys usually match the keys that are used as wakeup sources to
bring a device out of suspend. So if we export the wakeup keys to
userspace we can pick some sensible defaults (overridable via hwdb¹).

> Kernel also does not really know if the screen should be unblanked or
> not, if a button or switch is configured for wake up the kernel will go
> through wakeup process all the same and then userspace can decide if it
> should stay woken up or not.

Yes, we merely want that as a hint to figure out sensible defaults in
userspace (which might be a subset of the wakeup keys).

Cherrs,
 -- Guido

¹) See 
https://gitlab.gnome.org/World/Phosh/gmobile/-/blob/main/data/61-gmobile-wakeup.hwdb?ref_type=heads#L57-L59

> 
> Thanks.
> 
> -- 
> Dmitry
> 



[PATCH v1 1/1] Input: gpio-keys - expose wakeup keys in sysfs

2024-05-09 Thread Guido Günther
This helps user space to figure out which keys should be used to unidle a
device. E.g on phones the volume rocker should usually not unblank the
screen.

Signed-off-by: Guido Günther 
---
 drivers/input/keyboard/gpio_keys.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c 
b/drivers/input/keyboard/gpio_keys.c
index 9f3bcd41cf67..84f43d1d4375 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -198,7 +198,8 @@ static void gpio_keys_enable_button(struct gpio_button_data 
*bdata)
  */
 static ssize_t gpio_keys_attr_show_helper(struct gpio_keys_drvdata *ddata,
  char *buf, unsigned int type,
- bool only_disabled)
+ bool only_disabled,
+ bool only_wakeup)
 {
int n_events = get_n_events_by_type(type);
unsigned long *bits;
@@ -218,6 +219,9 @@ static ssize_t gpio_keys_attr_show_helper(struct 
gpio_keys_drvdata *ddata,
if (only_disabled && !bdata->disabled)
continue;
 
+   if (only_wakeup && !bdata->button->wakeup)
+   continue;
+
__set_bit(*bdata->code, bits);
}
 
@@ -297,7 +301,7 @@ static ssize_t gpio_keys_attr_store_helper(struct 
gpio_keys_drvdata *ddata,
return error;
 }
 
-#define ATTR_SHOW_FN(name, type, only_disabled)
\
+#define ATTR_SHOW_FN(name, type, only_disabled, only_wakeup)   \
 static ssize_t gpio_keys_show_##name(struct device *dev,   \
 struct device_attribute *attr, \
 char *buf) \
@@ -306,22 +310,26 @@ static ssize_t gpio_keys_show_##name(struct device *dev,  
\
struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev);   \
\
return gpio_keys_attr_show_helper(ddata, buf,   \
- type, only_disabled); \
+ type, only_disabled,  \
+ only_wakeup); \
 }
 
-ATTR_SHOW_FN(keys, EV_KEY, false);
-ATTR_SHOW_FN(switches, EV_SW, false);
-ATTR_SHOW_FN(disabled_keys, EV_KEY, true);
-ATTR_SHOW_FN(disabled_switches, EV_SW, true);
+ATTR_SHOW_FN(keys, EV_KEY, false, false);
+ATTR_SHOW_FN(switches, EV_SW, false, false);
+ATTR_SHOW_FN(disabled_keys, EV_KEY, true, false);
+ATTR_SHOW_FN(disabled_switches, EV_SW, true, false);
+ATTR_SHOW_FN(wakeup_keys, EV_KEY, false, true);
 
 /*
  * ATTRIBUTES:
  *
  * /sys/devices/platform/gpio-keys/keys [ro]
  * /sys/devices/platform/gpio-keys/switches [ro]
+ * /sys/devices/platform/gpio-keys/wakeup_keys [ro]
  */
 static DEVICE_ATTR(keys, S_IRUGO, gpio_keys_show_keys, NULL);
 static DEVICE_ATTR(switches, S_IRUGO, gpio_keys_show_switches, NULL);
+static DEVICE_ATTR(wakeup_keys, S_IRUGO, gpio_keys_show_wakeup_keys, NULL);
 
 #define ATTR_STORE_FN(name, type)  \
 static ssize_t gpio_keys_store_##name(struct device *dev,  \
@@ -361,6 +369,7 @@ static struct attribute *gpio_keys_attrs[] = {
_attr_switches.attr,
_attr_disabled_keys.attr,
_attr_disabled_switches.attr,
+   _attr_wakeup_keys.attr,
NULL,
 };
 ATTRIBUTE_GROUPS(gpio_keys);
-- 
2.43.0




Re: [PATCH v5 1/2] phy: core: Use runtime pm during configure too

2021-04-12 Thread Guido Günther
Hi,
On Mon, Apr 12, 2021 at 04:40:56PM +0800, Liu Ying wrote:
> Hi Guido,
> 
> On Fri, 2021-04-09 at 13:40 +0200, Guido Günther wrote:
> > The phy's configure phase usually needs register access so taking the
> > device out of pm_runtime suspend looks useful.
> > 
> > There's currently two in tree drivers using runtime pm and .configure
> > (qualcomm/phy-qcom-qmp.c, rockchip/phy-rockchip-inno-dsidphy.c) but both
> > don't use the phy layers 'transparent' runtime phy_pm_runtime handling
> > but manage it manually so this will for now only affect the
> > phy-fsl-imx8-mipi-dphy driver.
> 
> IIUC, the qualcomm one's runtime PM is managed by the phy core when
> users enable it using power/control in sysfs(see comment just before
> pm_runtime_forbid() in that driver).
> I'm assuming it's affected and it would be good to test it.

Ah, right. I'll reword the commit message but i don't have any means to
test it.

> I'm not pretty sure if the rockchip one is affected or not, because I'm
> assuming the power/control nodes of phy->dev and phy->parent.dev in
> sysfs are both 'auto' after the driver probes.

Testing if adding runtime pm for .configure to phy_core breaks anything
here would be great too.

I've added Dmitry and Heiko to cc: since they were active in those
drivers lately and i sure don't want to break these.

> > 
> > Signed-off-by: Guido Günther 
> > ---
> >  drivers/phy/phy-core.c | 6 ++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> > index ccb575b13777..256a964d52d3 100644
> > --- a/drivers/phy/phy-core.c
> > +++ b/drivers/phy/phy-core.c
> > @@ -470,10 +470,16 @@ int phy_configure(struct phy *phy, union 
> > phy_configure_opts *opts)
> > if (!phy->ops->configure)
> > return -EOPNOTSUPP;
> >  
> > +   ret = phy_pm_runtime_get_sync(phy);
> > +   if (ret < 0 && ret != -ENOTSUPP)
> > +   return ret;
> > +   ret = 0; /* Override possible ret == -ENOTSUPP */
> 
> This override is not needed, because 'ret' will be the return value of
> phy->ops->configure() right below.

I thought being explicit is better here but i'll drop that for the next
rev.

Thanks!
 -- Guido

> 
> Regards,
> Liu Ying
> 
> > +
> > mutex_lock(>mutex);
> > ret = phy->ops->configure(phy, opts);
> > mutex_unlock(>mutex);
> >  
> > +   phy_pm_runtime_put(phy);
> > return ret;
> >  }
> >  EXPORT_SYMBOL_GPL(phy_configure);
> 


[PATCH v5 2/2] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2021-04-09 Thread Guido Günther
This allows us to shut down the mipi power domain on the imx8. The
alternative would be to drop the dphy from the mipi power domain in the
SOCs device tree and only have the DSI host controller visible there but
since the PD is mostly about the PHY that would defeat it's purpose.

This allows to shut off the power domain when blanking the LCD panel:

pm_genpd_summary before:

domain  status  slaves
/device runtime status
--
mipion
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

after:

mipioff-0
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

Signed-off-by: Guido Günther 
---
 drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
index a95572b397ca..f89a0c458499 100644
--- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
+++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* DPHY registers */
@@ -469,20 +470,32 @@ static int mixel_dphy_probe(struct platform_device *pdev)
 
dev_set_drvdata(dev, priv);
 
+   pm_runtime_enable(dev);
+
phy = devm_phy_create(dev, np, _dphy_phy_ops);
if (IS_ERR(phy)) {
+   pm_runtime_disable(>dev);
dev_err(dev, "Failed to create phy %ld\n", PTR_ERR(phy));
return PTR_ERR(phy);
}
phy_set_drvdata(phy, priv);
 
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   pm_runtime_disable(>dev);
 
return PTR_ERR_OR_ZERO(phy_provider);
 }
 
+static int mixel_dphy_remove(struct platform_device *pdev)
+{
+   pm_runtime_disable(>dev);
+   return 0;
+}
+
 static struct platform_driver mixel_dphy_driver = {
.probe  = mixel_dphy_probe,
+   .remove = mixel_dphy_remove,
.driver = {
.name = "mixel-mipi-dphy",
.of_match_table = mixel_dphy_of_match,
-- 
2.30.1



[PATCH v5 0/2] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2021-04-09 Thread Guido Günther
This allows us to shut down the mipi power domain on the imx8. The alternative
would be to drop the dphy from the mipi power domain in the SOCs device tree
and only have the DSI host controller visible there but since the PD is mostly
about the PHY that would defeat it's purpose.

This allows to shut off the power domain when blanking the LCD panel:

pm_genpd_summary before:

domain  status  slaves
/device runtime status
--
mipion
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

after:

mipioff-0
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

Changes from v1:
 - Tweak commit message slightly

Changes from v2:
  - As per review comment by Lucas Stach

https://lore.kernel.org/linux-arm-kernel/ee22b072e0abe07559a3e6a63ccf6ece064a46cb.ca...@pengutronix.de/
Check for pm_runtime_get_sync failure

Changes from v3:
  - As per review comment by Liu Ying

https://lore.kernel.org/linux-arm-kernel/424af315b677934fe6a91cee5a0a7aee058245a9.ca...@nxp.com/

https://lore.kernel.org/linux-arm-kernel/a98f7531b9d0293d3c89174446f742d4199cb27c.ca...@nxp.com/
- Use phy layers runtime pm
- simplify mixel_dphy_remove

Chanes from v4:
  - As per review comment by Liu Ying

https://lore.kernel.org/linux-arm-kernel/daef1299e43f0372a95c149b979441f8083f4b15.ca...@nxp.com/
- Disable after probe errors
- core: increment device usage count on .configure as well

Guido Günther (2):
  phy: core: Use runtime pm during configure too
  phy: fsl-imx8-mipi-dphy: Hook into runtime pm

 drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 13 +
 drivers/phy/phy-core.c |  6 ++
 2 files changed, 19 insertions(+)

-- 
2.30.1



[PATCH v5 1/2] phy: core: Use runtime pm during configure too

2021-04-09 Thread Guido Günther
The phy's configure phase usually needs register access so taking the
device out of pm_runtime suspend looks useful.

There's currently two in tree drivers using runtime pm and .configure
(qualcomm/phy-qcom-qmp.c, rockchip/phy-rockchip-inno-dsidphy.c) but both
don't use the phy layers 'transparent' runtime phy_pm_runtime handling
but manage it manually so this will for now only affect the
phy-fsl-imx8-mipi-dphy driver.

Signed-off-by: Guido Günther 
---
 drivers/phy/phy-core.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index ccb575b13777..256a964d52d3 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -470,10 +470,16 @@ int phy_configure(struct phy *phy, union 
phy_configure_opts *opts)
if (!phy->ops->configure)
return -EOPNOTSUPP;
 
+   ret = phy_pm_runtime_get_sync(phy);
+   if (ret < 0 && ret != -ENOTSUPP)
+   return ret;
+   ret = 0; /* Override possible ret == -ENOTSUPP */
+
mutex_lock(>mutex);
ret = phy->ops->configure(phy, opts);
mutex_unlock(>mutex);
 
+   phy_pm_runtime_put(phy);
return ret;
 }
 EXPORT_SYMBOL_GPL(phy_configure);
-- 
2.30.1



Re: [PATCH v2 1/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2021-02-22 Thread Guido Günther
Hi Liu,
On Sat, Feb 20, 2021 at 01:37:29PM +0800, Liu Ying wrote:
> Hi Guido,
> 
> On Wed, 2020-12-16 at 12:27 +0100, Guido Günther wrote:
> > This allows us to shut down the mipi power domain on the imx8. The
> > alternative would be to drop the dphy from the mipi power domain in the
> > SOCs device tree and only have the DSI host controller visible there but
> > since the PD is mostly about the PHY that would defeat it's purpose.
> > 
> > This allows to shut off the power domain hen blanking the LCD panel:
> > 
> > pm_genpd_summary before:
> > 
> > domain  status  slaves
> > /device runtime status
> > --
> > mipion
> > /devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
> > /devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended
> > 
> > after:
> > 
> > mipioff-0
> > /devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
> > /devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended
> > 
> > Signed-off-by: Guido Günther 
> > ---
> >  .../phy/freescale/phy-fsl-imx8-mipi-dphy.c| 22 ++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
> > b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > index a95572b397ca..34e2d801e520 100644
> > --- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > +++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > @@ -14,6 +14,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  
> >  /* DPHY registers */
> > @@ -93,6 +94,7 @@ struct mixel_dphy_cfg {
> >  };
> >  
> >  struct mixel_dphy_priv {
> > +   struct device *dev;
> > struct mixel_dphy_cfg cfg;
> > struct regmap *regmap;
> > struct clk *phy_ref_clk;
> > @@ -382,6 +384,7 @@ static int mixel_dphy_power_on(struct phy *phy)
> > ret = clk_prepare_enable(priv->phy_ref_clk);
> > if (ret < 0)
> > return ret;
> > +   pm_runtime_get_sync(priv->dev);
> >  
> > phy_write(phy, PWR_ON, DPHY_PD_PLL);
> > ret = regmap_read_poll_timeout(priv->regmap, DPHY_LOCK, locked,
> > @@ -395,6 +398,7 @@ static int mixel_dphy_power_on(struct phy *phy)
> >  
> > return 0;
> >  clock_disable:
> > +   pm_runtime_put(priv->dev);
> > clk_disable_unprepare(priv->phy_ref_clk);
> > return ret;
> >  }
> > @@ -406,6 +410,7 @@ static int mixel_dphy_power_off(struct phy *phy)
> > phy_write(phy, PWR_OFF, DPHY_PD_PLL);
> > phy_write(phy, PWR_OFF, DPHY_PD_DPHY);
> >  
> > +   pm_runtime_put(priv->dev);
> > clk_disable_unprepare(priv->phy_ref_clk);
> >  
> > return 0;
> > @@ -467,6 +472,7 @@ static int mixel_dphy_probe(struct platform_device 
> > *pdev)
> > dev_dbg(dev, "phy_ref clock rate: %lu\n",
> > clk_get_rate(priv->phy_ref_clk));
> >  
> > +   priv->dev = dev;
> > dev_set_drvdata(dev, priv);
> >  
> > phy = devm_phy_create(dev, np, _dphy_phy_ops);
> > @@ -477,12 +483,26 @@ static int mixel_dphy_probe(struct platform_device 
> > *pdev)
> > phy_set_drvdata(phy, priv);
> >  
> > phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> > +   if (IS_ERR(phy_provider))
> > +   return PTR_ERR(phy_provider);
> >  
> > -   return PTR_ERR_OR_ZERO(phy_provider);
> > +   pm_runtime_enable(dev);
> 
> If this enablement is done prior to devm_phy_create(), then the
> phy-core will manage runtime PM for this device.  This way, this driver
> doesn't have to manage it by itself.

That makes things simpler indeed. Fixed in v4 together with your other
comment.
Thanks!
 -- Guido

> 
> Regards,
> Liu Ying
> 
> > +
> > +   return 0;
> > +}
> > +
> > +static int mixel_dphy_remove(struct platform_device *pdev)
> > +{
> > +   struct mixel_dphy_priv *priv = platform_get_drvdata(pdev);
> > +
> > +   pm_runtime_disable(priv->dev);
> > +
> > +   return 0;
> >  }
> >  
> >  static struct platform_driver mixel_dphy_driver = {
> > .probe  = mixel_dphy_probe,
> > +   .remove = mixel_dphy_remove,
> > .driver = {
> > .name = "mixel-mipi-dphy",
> > .of_match_table = mixel_dphy_of_match,
> 


[PATCH v4 0/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2021-02-22 Thread Guido Günther
This allows us to shut down the mipi power domain on the imx8. The alternative
would be to drop the dphy from the mipi power domain in the SOCs device tree
and only have the DSI host controller visible there but since the PD is mostly
about the PHY that would defeat it's purpose.

This allows to shut off the power domain hen blanking the LCD panel:

pm_genpd_summary before:

domain  status  slaves
/device runtime status
--
mipion
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

after:

mipioff-0
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

Changes from v1:
 - Tweak commit message slightly

Changes from v2:
  - As per review comment by Lucas Stach

https://lore.kernel.org/linux-arm-kernel/ee22b072e0abe07559a3e6a63ccf6ece064a46cb.ca...@pengutronix.de/
Check for pm_runtime_get_sync failure

Changes from v3:
  - As per review comment by Liu Ying

https://lore.kernel.org/linux-arm-kernel/424af315b677934fe6a91cee5a0a7aee058245a9.ca...@nxp.com/

https://lore.kernel.org/linux-arm-kernel/a98f7531b9d0293d3c89174446f742d4199cb27c.ca...@nxp.com/
- Use phy layers runtime pm
- simplify mixel_dphy_remove



Guido Günther (1):
  phy: fsl-imx8-mipi-dphy: Hook into runtime pm

 drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 10 ++
 1 file changed, 10 insertions(+)

-- 
2.30.0



[PATCH v4 1/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2021-02-22 Thread Guido Günther
This allows us to shut down the mipi power domain on the imx8. The
alternative would be to drop the dphy from the mipi power domain in the
SOCs device tree and only have the DSI host controller visible there but
since the PD is mostly about the PHY that would defeat it's purpose.

This allows to shut off the power domain hen blanking the LCD panel:

pm_genpd_summary before:

domain  status  slaves
/device runtime status
--
mipion
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

after:

mipioff-0
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

Signed-off-by: Guido Günther 
---
 drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
index a95572b397ca..5de175695834 100644
--- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
+++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* DPHY registers */
@@ -469,6 +470,8 @@ static int mixel_dphy_probe(struct platform_device *pdev)
 
dev_set_drvdata(dev, priv);
 
+   pm_runtime_enable(dev);
+
phy = devm_phy_create(dev, np, _dphy_phy_ops);
if (IS_ERR(phy)) {
dev_err(dev, "Failed to create phy %ld\n", PTR_ERR(phy));
@@ -481,8 +484,15 @@ static int mixel_dphy_probe(struct platform_device *pdev)
return PTR_ERR_OR_ZERO(phy_provider);
 }
 
+static int mixel_dphy_remove(struct platform_device *pdev)
+{
+   pm_runtime_disable(>dev);
+   return 0;
+}
+
 static struct platform_driver mixel_dphy_driver = {
.probe  = mixel_dphy_probe,
+   .remove = mixel_dphy_remove,
.driver = {
.name = "mixel-mipi-dphy",
.of_match_table = mixel_dphy_of_match,
-- 
2.30.0



[PATCH v1 1/6] arm64: dts: librem5-devkit: Use a less generic codec name

2021-02-21 Thread Guido Günther
The codec is currently named after the chip but it should be named like
the device itself since otherwise it's impossible to distinguish it from
other devices using the same codec (e.g. in alsa's UCM).

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index dd217a0760e9..0c0b12c90363 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -165,7 +165,7 @@ wwan_codec: sound-wwan-codec {
 
sound {
compatible = "simple-audio-card";
-   simple-audio-card,name = "sgtl5000";
+   simple-audio-card,name = "Librem 5 Devkit";
simple-audio-card,format = "i2s";
simple-audio-card,widgets =
"Microphone", "Microphone Jack",
-- 
2.30.0



[PATCH v1 6/6] arm64: dts: librem5-devkit: Move headphone detection to sound card

2021-02-21 Thread Guido Günther
This allows for automatic output source switching in userspace. Enable
the pullup on the GPIO to actually make it trigger and mark it as
active-high since detection is reversed otherwise.

Signed-off-by: Guido Günther 
---
 .../dts/freescale/imx8mq-librem5-devkit.dts   | 21 ++-
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index f818af592046..e3bfef98090a 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -50,13 +50,6 @@ btn2 {
linux,code = ;
};
 
-   hp-det {
-   label = "HP_DET";
-   gpios = < 20 GPIO_ACTIVE_LOW>;
-   wakeup-source;
-   linux,code = ;
-   };
-
wwan-wake {
label = "WWAN_WAKE";
gpios = < 8 GPIO_ACTIVE_LOW>;
@@ -173,22 +166,25 @@ mic_mux: mic-mux {
 
sound {
compatible = "simple-audio-card";
+   pinctrl-names = "default";
+   pinctrl-0 = <_hpdet>;
simple-audio-card,aux-devs = <_amp>, <_mux>;
simple-audio-card,name = "Librem 5 Devkit";
simple-audio-card,format = "i2s";
simple-audio-card,widgets =
"Microphone", "Builtin Microphone",
"Microphone", "Headset Microphone",
-   "Headphone", "Headphone Jack",
+   "Headphone", "Headphones",
"Speaker", "Builtin Speaker";
simple-audio-card,routing =
"MIC_IN", "Mic Mux OUT",
"Mic Mux IN1", "Headset Microphone",
"Mic Mux IN2", "Builtin Microphone",
"Mic Mux OUT", "Mic Bias",
-   "Headphone Jack", "HP_OUT",
+   "Headphones", "HP_OUT",
"Builtin Speaker", "Speaker Amp OUTR",
"Speaker Amp INR", "LINE_OUT";
+   simple-audio-card,hp-det-gpio = < 20 GPIO_ACTIVE_HIGH>;
 
simple-audio-card,cpu {
sound-dai = <>;
@@ -630,7 +626,6 @@ pinctrl_gpio_keys: gpiokeygrp {
fsl,pins = <
MX8MQ_IOMUXC_SAI2_RXFS_GPIO4_IO21   0x16
MX8MQ_IOMUXC_SAI2_RXC_GPIO4_IO220x16
-   MX8MQ_IOMUXC_SAI5_RXC_GPIO3_IO200x180  /* 
HP_DET */
MX8MQ_IOMUXC_NAND_DATA02_GPIO3_IO8  0x80   /* 
nWoWWAN */
>;
};
@@ -641,6 +636,12 @@ MX8MQ_IOMUXC_SPDIF_RX_GPIO5_IO40xc6   /* 
nHAPTIC */
>;
};
 
+   pinctrl_hpdet: hpdetgrp {
+   fsl,pins = <
+   MX8MQ_IOMUXC_SAI5_RXC_GPIO3_IO200xC0   /* 
HP_DET */
+   >;
+   };
+
pinctrl_i2c1: i2c1grp {
fsl,pins = <
MX8MQ_IOMUXC_I2C1_SCL_I2C1_SCL  0x401f
-- 
2.30.0



[PATCH v1 5/6] arm64: dts: librem5-devkit: Add mux for built-in vs headset mic

2021-02-21 Thread Guido Günther
Add mux so we can select either headset or built-in microphone input.

Signed-off-by: Guido Günther 
---
 .../dts/freescale/imx8mq-librem5-devkit.dts   | 25 ---
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index aac05bbaa001..f818af592046 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -163,18 +163,29 @@ wwan_codec: sound-wwan-codec {
#sound-dai-cells = <0>;
};
 
+   mic_mux: mic-mux {
+   compatible = "simple-audio-mux";
+   pinctrl-names = "default";
+   pinctrl-0 = <_micsel>;
+   mux-gpios = < 5 GPIO_ACTIVE_LOW>;
+   sound-name-prefix = "Mic Mux";
+   };
+
sound {
compatible = "simple-audio-card";
-   simple-audio-card,aux-devs = <_amp>;
+   simple-audio-card,aux-devs = <_amp>, <_mux>;
simple-audio-card,name = "Librem 5 Devkit";
simple-audio-card,format = "i2s";
simple-audio-card,widgets =
-   "Microphone", "Microphone Jack",
+   "Microphone", "Builtin Microphone",
+   "Microphone", "Headset Microphone",
"Headphone", "Headphone Jack",
"Speaker", "Builtin Speaker";
simple-audio-card,routing =
-   "MIC_IN", "Microphone Jack",
-   "Microphone Jack", "Mic Bias",
+   "MIC_IN", "Mic Mux OUT",
+   "Mic Mux IN1", "Headset Microphone",
+   "Mic Mux IN2", "Builtin Microphone",
+   "Mic Mux OUT", "Mic Bias",
"Headphone Jack", "HP_OUT",
"Builtin Speaker", "Speaker Amp OUTR",
"Speaker Amp INR", "LINE_OUT";
@@ -650,6 +661,12 @@ MX8MQ_IOMUXC_SAI5_RXFS_GPIO3_IO19  0x8  /* IMU_INT */
>;
};
 
+   pinctrl_micsel: micselgrp {
+   fsl,pins = <
+   MX8MQ_IOMUXC_SPDIF_EXT_CLK_GPIO5_IO50xc6  /* 
MIC_SEL */
+   >;
+   };
+
pinctrl_spkamp: spkamp {
fsl,pins = <
MX8MQ_IOMUXC_SPDIF_TX_GPIO5_IO3 0x81  /* MUTE */
-- 
2.30.0



[PATCH v1 3/6] arm64: dts: librem5-devkit: "Drop Line In Jack"

2021-02-21 Thread Guido Günther
The SGTL500s LINEINL and LINEINR are N/C.

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index d01bed5eb9e0..aac05bbaa001 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -171,12 +171,10 @@ sound {
simple-audio-card,widgets =
"Microphone", "Microphone Jack",
"Headphone", "Headphone Jack",
-   "Speaker", "Builtin Speaker",
-   "Line", "Line In Jack";
+   "Speaker", "Builtin Speaker";
simple-audio-card,routing =
"MIC_IN", "Microphone Jack",
"Microphone Jack", "Mic Bias",
-   "LINE_IN", "Line In Jack",
"Headphone Jack", "HP_OUT",
"Builtin Speaker", "Speaker Amp OUTR",
"Speaker Amp INR", "LINE_OUT";
-- 
2.30.0



[PATCH v1 4/6] arm64: defconfig: Enable asoc simple mux

2021-02-21 Thread Guido Günther
This is needed to model the mic input mux on the Librem 5 devkit.

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index e830d1be6f27..762fb6a132df 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -790,6 +790,7 @@ CONFIG_SND_SOC_GTM601=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
 CONFIG_SND_SOC_RT5659=m
 CONFIG_SND_SOC_SIMPLE_AMPLIFIER=m
+CONFIG_SND_SOC_SIMPLE_MUX=m
 CONFIG_SND_SOC_TAS571X=m
 CONFIG_SND_SOC_WCD934X=m
 CONFIG_SND_SOC_WM8904=m
-- 
2.30.0



[PATCH v1 2/6] arm64: dts: librem5-devkit: Add speaker amplifier

2021-02-21 Thread Guido Günther
Wire up the amplifier that drives the builtin speaker.

Signed-off-by: Guido Günther 
---
 .../dts/freescale/imx8mq-librem5-devkit.dts   | 21 +--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index 0c0b12c90363..d01bed5eb9e0 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -165,19 +165,21 @@ wwan_codec: sound-wwan-codec {
 
sound {
compatible = "simple-audio-card";
+   simple-audio-card,aux-devs = <_amp>;
simple-audio-card,name = "Librem 5 Devkit";
simple-audio-card,format = "i2s";
simple-audio-card,widgets =
"Microphone", "Microphone Jack",
"Headphone", "Headphone Jack",
-   "Speaker", "Speaker Ext",
+   "Speaker", "Builtin Speaker",
"Line", "Line In Jack";
simple-audio-card,routing =
"MIC_IN", "Microphone Jack",
"Microphone Jack", "Mic Bias",
"LINE_IN", "Line In Jack",
"Headphone Jack", "HP_OUT",
-   "Speaker Ext", "LINE_OUT";
+   "Builtin Speaker", "Speaker Amp OUTR",
+   "Speaker Amp INR", "LINE_OUT";
 
simple-audio-card,cpu {
sound-dai = <>;
@@ -207,6 +209,15 @@ telephony_link_master: simple-audio-card,codec {
};
};
 
+   speaker_amp: speaker-amp {
+   compatible = "simple-audio-amplifier";
+   pinctrl-names = "default";
+   pinctrl-0 = <_spkamp>;
+   VCC-supply = <_3v3_p>;
+   sound-name-prefix = "Speaker Amp";
+   enable-gpios = < 3 GPIO_ACTIVE_HIGH>;
+   };
+
vibrator {
compatible = "gpio-vibrator";
pinctrl-names = "default";
@@ -641,6 +652,12 @@ MX8MQ_IOMUXC_SAI5_RXFS_GPIO3_IO19  0x8  /* IMU_INT */
>;
};
 
+   pinctrl_spkamp: spkamp {
+   fsl,pins = <
+   MX8MQ_IOMUXC_SPDIF_TX_GPIO5_IO3 0x81  /* MUTE */
+   >;
+   };
+
pinctrl_pmic: pmicgrp {
fsl,pins = <
MX8MQ_IOMUXC_GPIO1_IO03_GPIO1_IO3   0x80  /* PMIC 
intr */
-- 
2.30.0



[PATCH v1 0/6] arm64: dts: librem5-devkit: Improve audio support

2021-02-21 Thread Guido Günther
So far only headphone output worked. Thesse patches add support for the
built in speaker and mic, allow a headset microphone to work and wire up jack
detection so audio output can switch to headphones automatically.  They also
adjust the card name to match the board not the codec, similar what's done for
the Librem 5.

Patches are against next-20210210 but also apply against Shawn's imx-dt64-5.12

Guido Günther (6):
  arm64: dts: librem5-devkit: Use a less generic codec name
  arm64: dts: librem5-devkit: Add speaker amplifier
  arm64: dts: librem5-devkit: "Drop Line In Jack"
  arm64: defconfig: Enable asoc simple mux
  arm64: dts: librem5-devkit: Add mux for built-in vs headset mic
  arm64: dts: librem5-devkit: Move headphone detection to sound card

 .../dts/freescale/imx8mq-librem5-devkit.dts   | 69 ++-
 arch/arm64/configs/defconfig  |  1 +
 2 files changed, 52 insertions(+), 18 deletions(-)

-- 
2.30.0



Re: [PATCH v3 0/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2021-02-19 Thread Guido Günther
Hi,
On Wed, Dec 16, 2020 at 07:22:32PM +0100, Guido Günther wrote:
> This allows us to shut down the mipi power domain on the imx8. The alternative
> would be to drop the dphy from the mipi power domain in the SOCs device tree
> and only have the DSI host controller visible there but since the PD is mostly
> about the PHY that would defeat it's purpose.

Is there anything I can do to move that forward. I assume this needs to
go via the phy/ subsystem not drm?
Cheers,
 -- Guido

> 
> This is basically a resend from February 2020 which went without feedback.
> 
> This allows to shut off the power domain hen blanking the LCD panel:
> 
> pm_genpd_summary before:
> 
> domain  status  slaves
> /device runtime status
> --
> mipion
> /devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
> /devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended
> 
> after:
> 
> mipioff-0
> /devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
> /devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended
> 
> Changes from v1:
>  - Tweak commit message slightly
> 
> Changes from v2:
>   - As pre review comment by Lucas Stach
> 
> https://lore.kernel.org/linux-arm-kernel/ee22b072e0abe07559a3e6a63ccf6ece064a46cb.ca...@pengutronix.de/
> Check for pm_runtime_get_sync failure
> 
> Guido Günther (1):
>   phy: fsl-imx8-mipi-dphy: Hook into runtime pm
> 
>  .../phy/freescale/phy-fsl-imx8-mipi-dphy.c| 25 ++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> -- 
> 2.29.2
> 
> 
> ___
> linux-arm-kernel mailing list
> linux-arm-ker...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


[PATCH v3 4/4] usb: typec: tps6598x: Add trace event for data status

2021-02-15 Thread Guido Günther
This is useful to debug DP negotiation and pin assignment even
when the firmware does all the work.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 12 ++-
 drivers/usb/typec/tps6598x.h   | 38 +
 drivers/usb/typec/tps6598x_trace.h | 54 ++
 3 files changed, 103 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 3e6ad3ba7fc8..a4ec8e56c2b9 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -36,6 +36,7 @@
 #define TPS_REG_CTRL_CONF  0x29
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
+#define TPS_REG_DATA_STATUS0x5f
 
 /* TPS_REG_SYSTEM_CONF bits */
 #define TPS_SYSCONF_PORTINFO(c)((c) & 7)
@@ -408,7 +409,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
struct tps6598x *tps = data;
u64 event1;
u64 event2;
-   u32 status;
+   u32 status, data_status;
u16 pwr_status;
int ret;
 
@@ -438,6 +439,15 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
trace_tps6598x_power_status(pwr_status);
}
 
+   if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) {
+   ret = tps6598x_read32(tps, TPS_REG_DATA_STATUS, _status);
+   if (ret < 0) {
+   dev_err(tps->dev, "failed to read data status: %d\n", 
ret);
+   goto err_clear_ints;
+   }
+   trace_tps6598x_data_status(data_status);
+   }
+
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
if (status & TPS_STATUS_PLUG_PRESENT) {
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index 9a34c020f3e5..003a577be216 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -148,4 +148,42 @@
 #define TPS_POWER_STATUS_BC12_STATUS_CDP 2
 #define TPS_POWER_STATUS_BC12_STATUS_DCP 3
 
+/* TPS_REG_DATA_STATUS bits */
+#define TPS_DATA_STATUS_DATA_CONNECTION BIT(0)
+#define TPS_DATA_STATUS_UPSIDE_DOWN BIT(1)
+#define TPS_DATA_STATUS_ACTIVE_CABLEBIT(2)
+#define TPS_DATA_STATUS_USB2_CONNECTION BIT(4)
+#define TPS_DATA_STATUS_USB3_CONNECTION BIT(5)
+#define TPS_DATA_STATUS_USB3_GEN2   BIT(6)
+#define TPS_DATA_STATUS_USB_DATA_ROLE   BIT(7)
+#define TPS_DATA_STATUS_DP_CONNECTION   BIT(8)
+#define TPS_DATA_STATUS_DP_SINK BIT(9)
+#define TPS_DATA_STATUS_TBT_CONNECTION  BIT(16)
+#define TPS_DATA_STATUS_TBT_TYPEBIT(17)
+#define TPS_DATA_STATUS_OPTICAL_CABLE   BIT(18)
+#define TPS_DATA_STATUS_ACTIVE_LINK_TRAINBIT(20)
+#define TPS_DATA_STATUS_FORCE_LSX   BIT(23)
+#define TPS_DATA_STATUS_POWER_MISMATCH  BIT(24)
+
+#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK GENMASK(11, 10)
+#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) \
+   TPS_FIELD_GET(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK, (x))
+#define TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK   GENMASK(27, 25)
+#define TPS_DATA_STATUS_TBT_CABLE_SPEED \
+   TPS_FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK, (x))
+#define TPS_DATA_STATUS_TBT_CABLE_GEN_MASK GENMASK(29, 28)
+#define TPS_DATA_STATUS_TBT_CABLE_GEN \
+   TPS_FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_GEN_MASK, (x))
+
+/* Map data status to DP spec assignments */
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT(x) \
+   ((TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) << 1) | \
+   TPS_FIELD_GET(TPS_DATA_STATUS_USB3_CONNECTION, (x)))
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_E0
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_FBIT(0)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_CBIT(1)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_D(BIT(1) | BIT(0))
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_ABIT(2)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B(BIT(2) | BIT(1))
+
 #endif /* __TPS6598X_H__ */
diff --git a/drivers/usb/typec/tps6598x_trace.h 
b/drivers/usb/typec/tps6598x_trace.h
index 78a5a6ca337b..38bfb2f04e46 100644
--- a/drivers/usb/typec/tps6598x_trace.h
+++ b/drivers/usb/typec/tps6598x_trace.h
@@ -152,6 +152,41 @@
{ TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \
{ TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" })
 
+#define TPS_DATA_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ 
(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK | \
+ 
TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK | \
+ 
TPS_DATA_STATUS_TBT_CABLE_GEN_MASK))
+
+#define show_data_status_flags(data_status) \
+   __print_flags(data_status & TPS_DATA_STATUS_FLAGS_MASK, "|", \
+   { TPS_DATA_STATUS_DATA_CONNECTION,  

[PATCH v3 3/4] usb: typec: tps6598x: Add trace event for power status register

2021-02-15 Thread Guido Günther
Together with the PD status register this is vital for debugging power
negotiations at runtime.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 19 +--
 drivers/usb/typec/tps6598x.h   | 19 +++
 drivers/usb/typec/tps6598x_trace.h | 38 ++
 3 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 559aa175f948..3e6ad3ba7fc8 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -50,11 +50,6 @@ enum {
TPS_PORTINFO_SOURCE,
 };
 
-/* TPS_REG_POWER_STATUS bits */
-#define TPS_POWER_STATUS_CONNECTIONBIT(0)
-#define TPS_POWER_STATUS_SOURCESINKBIT(1)
-#define TPS_POWER_STATUS_PWROPMODE(p)  (((p) & GENMASK(3, 2)) >> 2)
-
 /* TPS_REG_RX_IDENTITY_SOP */
 struct tps6598x_rx_identity_reg {
u8 status;
@@ -414,6 +409,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
u64 event1;
u64 event2;
u32 status;
+   u16 pwr_status;
int ret;
 
mutex_lock(>lock);
@@ -433,6 +429,15 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
}
trace_tps6598x_status(status);
 
+   if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) {
+   ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, _status);
+   if (ret < 0) {
+   dev_err(tps->dev, "failed to read power status: %d\n", 
ret);
+   goto err_clear_ints;
+   }
+   trace_tps6598x_power_status(pwr_status);
+   }
+
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
if (status & TPS_STATUS_PLUG_PRESENT) {
@@ -497,8 +502,8 @@ static int tps6598x_psy_get_online(struct tps6598x *tps,
if (ret < 0)
return ret;
 
-   if ((pwr_status & TPS_POWER_STATUS_CONNECTION) &&
-   (pwr_status & TPS_POWER_STATUS_SOURCESINK)) {
+   if (TPS_POWER_STATUS_CONNECTION(pwr_status) &&
+   TPS_POWER_STATUS_SOURCESINK(pwr_status)) {
val->intval = 1;
} else {
val->intval = 0;
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index 621fb336c15d..9a34c020f3e5 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -129,4 +129,23 @@
 #define TPS_REG_INT_HARD_RESET BIT(1)
 #define TPS_REG_INT_PD_SOFT_RESET  BIT(0)
 
+/* TPS_REG_POWER_STATUS bits */
+#define TPS_POWER_STATUS_CONNECTION(x)  TPS_FIELD_GET(BIT(0), (x))
+#define TPS_POWER_STATUS_SOURCESINK(x) TPS_FIELD_GET(BIT(1), (x))
+#define TPS_POWER_STATUS_BC12_DET(x)   TPS_FIELD_GET(BIT(2), (x))
+
+#define TPS_POWER_STATUS_TYPEC_CURRENT_MASK GENMASK(3, 2)
+#define TPS_POWER_STATUS_PWROPMODE(p)  
TPS_FIELD_GET(TPS_POWER_STATUS_TYPEC_CURRENT_MASK, (p))
+#define TPS_POWER_STATUS_BC12_STATUS_MASK   GENMASK(6, 5)
+#define TPS_POWER_STATUS_BC12_STATUS(p)
TPS_FIELD_GET(TPS_POWER_STATUS_BC12_STATUS_MASK, (p))
+
+#define TPS_POWER_STATUS_TYPEC_CURRENT_USB 0
+#define TPS_POWER_STATUS_TYPEC_CURRENT_1A5 1
+#define TPS_POWER_STATUS_TYPEC_CURRENT_3A0 2
+#define TPS_POWER_STATUS_TYPEC_CURRENT_PD  3
+
+#define TPS_POWER_STATUS_BC12_STATUS_SDP 0
+#define TPS_POWER_STATUS_BC12_STATUS_CDP 2
+#define TPS_POWER_STATUS_BC12_STATUS_DCP 3
+
 #endif /* __TPS6598X_H__ */
diff --git a/drivers/usb/typec/tps6598x_trace.h 
b/drivers/usb/typec/tps6598x_trace.h
index e0677b9c5c53..78a5a6ca337b 100644
--- a/drivers/usb/typec/tps6598x_trace.h
+++ b/drivers/usb/typec/tps6598x_trace.h
@@ -134,6 +134,24 @@
  { TPS_STATUS_HIGH_VOLAGE_WARNING, "HIGH_VOLAGE_WARNING" 
}, \
  { TPS_STATUS_HIGH_LOW_VOLTAGE_WARNING, 
"HIGH_LOW_VOLTAGE_WARNING" })
 
+#define show_power_status_source_sink(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_SOURCESINK(power_status), \
+   { 1, "sink" }, \
+   { 0, "source" })
+
+#define show_power_status_typec_status(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_PWROPMODE(power_status), \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_PD,  "pd" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_3A0, "3.0A" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_1A5, "1.5A" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_USB, "usb" })
+
+#define show_power_status_bc12_status(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_BC12_STATUS(power_status), \
+   { TPS_POWER_STATUS_BC12_STATUS_DCP, "dcp" }, \
+   { TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \
+   { TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" })
+
 TRACE_EVENT(tps6598x_

[PATCH v3 1/4] usb: typec: tps6598x: Add trace event for IRQ events

2021-02-15 Thread Guido Günther
Allow to get irq event information via the tracing framework.  This
allows to inspect USB-C negotiation at runtime.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/Makefile |  3 +
 drivers/usb/typec/tps6598x.c   |  9 ++-
 drivers/usb/typec/tps6598x.h   | 64 
 drivers/usb/typec/tps6598x_trace.h | 97 ++
 4 files changed, 170 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/typec/tps6598x.h
 create mode 100644 drivers/usb/typec/tps6598x_trace.h

diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index d03b48c4b864..27aa12129190 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
+# define_trace.h needs to know how to find our header
+CFLAGS_tps6598x.o  := -I$(src)
+
 obj-$(CONFIG_TYPEC)+= typec.o
 typec-y:= class.o mux.o bus.o
 obj-$(CONFIG_TYPEC)+= altmodes/
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 6e6ef6317523..bc34b35e909f 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -6,6 +6,8 @@
  * Author: Heikki Krogerus 
  */
 
+#include "tps6598x.h"
+
 #include 
 #include 
 #include 
@@ -15,6 +17,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include "tps6598x_trace.h"
+
 /* Register offsets */
 #define TPS_REG_VID0x00
 #define TPS_REG_MODE   0x03
@@ -32,9 +37,6 @@
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
 
-/* TPS_REG_INT_* bits */
-#define TPS_REG_INT_PLUG_EVENT BIT(3)
-
 /* TPS_REG_STATUS bits */
 #define TPS_STATUS_PLUG_PRESENTBIT(0)
 #define TPS_STATUS_ORIENTATION BIT(4)
@@ -428,6 +430,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "%s: failed to read events\n", __func__);
goto err_unlock;
}
+   trace_tps6598x_irq(event1, event2);
 
ret = tps6598x_read32(tps, TPS_REG_STATUS, );
if (ret) {
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
new file mode 100644
index ..b83b8a6a1504
--- /dev/null
+++ b/drivers/usb/typec/tps6598x.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Driver for TI TPS6598x USB Power Delivery controller family
+ *
+ * Copyright (C) 2017, Intel Corporation
+ * Author: Heikki Krogerus 
+ */
+
+#include 
+#include 
+
+#ifndef __TPS6598X_H__
+#define __TPS6598X_H__
+
+
+/* TPS_REG_INT_* bits */
+#define TPS_REG_INT_USER_VID_ALT_MODE_OTHER_VDMBIT_ULL(27+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ATTN_VDM BIT_ULL(26+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_EXIT BIT_ULL(25+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ENTERED  BIT_ULL(24+32)
+#define TPS_REG_INT_EXIT_MODES_COMPLETEBIT_ULL(20+32)
+#define TPS_REG_INT_DISCOVER_MODES_COMPLETEBIT_ULL(19+32)
+#define TPS_REG_INT_VDM_MSG_SENT   BIT_ULL(18+32)
+#define TPS_REG_INT_VDM_ENTERED_MODE   BIT_ULL(17+32)
+#define TPS_REG_INT_ERROR_UNABLE_TO_SOURCE BIT_ULL(14+32)
+#define TPS_REG_INT_SRC_TRANSITION BIT_ULL(10+32)
+#define TPS_REG_INT_ERROR_DISCHARGE_FAILED BIT_ULL(9+32)
+#define TPS_REG_INT_ERROR_MESSAGE_DATA BIT_ULL(7+32)
+#define TPS_REG_INT_ERROR_PROTOCOL_ERROR   BIT_ULL(6+32)
+#define TPS_REG_INT_ERROR_MISSING_GET_CAP_MESSAGE  BIT_ULL(4+32)
+#define TPS_REG_INT_ERROR_POWER_EVENT_OCCURRED BIT_ULL(3+32)
+#define TPS_REG_INT_ERROR_CAN_PROVIDE_PWR_LATERBIT_ULL(2+32)
+#define TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWR   BIT_ULL(1+32)
+#define TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE  BIT_ULL(0+32)
+#define TPS_REG_INT_CMD2_COMPLETE  BIT(31)
+#define TPS_REG_INT_CMD1_COMPLETE  BIT(30)
+#define TPS_REG_INT_ADC_HIGH_THRESHOLD BIT(29)
+#define TPS_REG_INT_ADC_LOW_THRESHOLD  BIT(28)
+#define TPS_REG_INT_PD_STATUS_UPDATE   BIT(27)
+#define TPS_REG_INT_STATUS_UPDATE  BIT(26)
+#define TPS_REG_INT_DATA_STATUS_UPDATE BIT(25)
+#define TPS_REG_INT_POWER_STATUS_UPDATEBIT(24)
+#define TPS_REG_INT_PP_SWITCH_CHANGED  BIT(23)
+#define TPS_REG_INT_HIGH_VOLTAGE_WARNING   BIT(22)
+#define TPS_REG_INT_USB_HOST_PRESENT_NO_LONGER BIT(21)
+#define TPS_REG_INT_USB_HOST_PRESENT   BIT(20)
+#define TPS_REG_INT_GOTO_MIN_RECEIVED  BIT(19)
+#define TPS_REG_INT_PR_SWAP_REQUESTED  BIT(17)
+#define TPS_REG_INT_SINK_CAP_MESSAGE_READY BIT(15)
+#define TPS_REG_INT_SOURCE_CAP_MESSAGE

[PATCH v3 2/4] usb: typec: tps6598x: Add trace event for status register

2021-02-15 Thread Guido Günther
This allows to trace status information which helps to debug problems
with role switching, etc.

We don't use the generic FIELD_GET() to reduce the macro size since we
otherwise trip up sparse.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 26 -
 drivers/usb/typec/tps6598x.h   | 68 +
 drivers/usb/typec/tps6598x_trace.h | 94 ++
 3 files changed, 173 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index bc34b35e909f..559aa175f948 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -37,13 +37,6 @@
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
 
-/* TPS_REG_STATUS bits */
-#define TPS_STATUS_PLUG_PRESENTBIT(0)
-#define TPS_STATUS_ORIENTATION BIT(4)
-#define TPS_STATUS_PORTROLE(s) (!!((s) & BIT(5)))
-#define TPS_STATUS_DATAROLE(s) (!!((s) & BIT(6)))
-#define TPS_STATUS_VCONN(s)(!!((s) & BIT(7)))
-
 /* TPS_REG_SYSTEM_CONF bits */
 #define TPS_SYSCONF_PORTINFO(c)((c) & 7)
 
@@ -258,9 +251,9 @@ static int tps6598x_connect(struct tps6598x *tps, u32 
status)
}
 
typec_set_pwr_opmode(tps->port, mode);
-   typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
-   typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
-   tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), true);
+   typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
+   typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
+   tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), true);
 
tps->partner = typec_register_partner(tps->port, );
if (IS_ERR(tps->partner))
@@ -280,9 +273,10 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 
status)
typec_unregister_partner(tps->partner);
tps->partner = NULL;
typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
-   typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
-   typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
-   tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), false);
+   typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
+   typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
+   tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), 
false);
+
power_supply_changed(tps->psy);
 }
 
@@ -366,7 +360,7 @@ static int tps6598x_dr_set(struct typec_port *port, enum 
typec_data_role role)
if (ret)
goto out_unlock;
 
-   if (role != TPS_STATUS_DATAROLE(status)) {
+   if (role != TPS_STATUS_TO_TYPEC_DATAROLE(status)) {
ret = -EPROTO;
goto out_unlock;
}
@@ -396,7 +390,7 @@ static int tps6598x_pr_set(struct typec_port *port, enum 
typec_role role)
if (ret)
goto out_unlock;
 
-   if (role != TPS_STATUS_PORTROLE(status)) {
+   if (role != TPS_STATUS_TO_TYPEC_PORTROLE(status)) {
ret = -EPROTO;
goto out_unlock;
}
@@ -437,6 +431,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "%s: failed to read status\n", __func__);
goto err_clear_ints;
}
+   trace_tps6598x_status(status);
 
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
@@ -612,6 +607,7 @@ static int tps6598x_probe(struct i2c_client *client)
ret = tps6598x_read32(tps, TPS_REG_STATUS, );
if (ret < 0)
return ret;
+   trace_tps6598x_status(status);
 
ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, );
if (ret < 0)
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index b83b8a6a1504..621fb336c15d 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -12,6 +12,74 @@
 #ifndef __TPS6598X_H__
 #define __TPS6598X_H__
 
+#define TPS_FIELD_GET(_mask, _reg) ((typeof(_mask))(((_reg) & (_mask)) >> 
__bf_shf(_mask)))
+
+/* TPS_REG_STATUS bits */
+#define TPS_STATUS_PLUG_PRESENTBIT(0)
+#define TPS_STATUS_PLUG_UPSIDE_DOWNBIT(4)
+#define TPS_STATUS_PORTROLEBIT(5)
+#define TPS_STATUS_TO_TYPEC_PORTROLE(s) (!!((s) & TPS_STATUS_PORTROLE))
+#define TPS_STATUS_DATAROLEBIT(6)
+#define TPS_STATUS_TO_TYPEC_DATAROLE(s)(!!((s) & TPS_STATUS_DATAROLE))
+#define TPS_STATUS_VCONN   BIT(7)
+#define TPS_STATUS_TO_TYPEC_VCONN(s)   (!!((s) & TPS_STATUS_VCONN))
+#define TPS_STATUS_OVERCURRENT BIT(16)
+#define TPS_STATUS_GOTO_MIN_ACTIVE BIT(26)
+#define TPS_STATUS_BISTBIT(27)
+#

[PATCH v3 0/4] usb: typec: tps6598x: Add IRQ flag and register tracing

2021-02-15 Thread Guido Günther


This series adds tracing events for the chips IRQ and registers that are useful
to figure out the current data and power status. This came about since
diagnosing why a certain usb-c hub or dp-alt-mode adapter fails is hard with
the information in /sys/class/typec alone since this does not have a timeline
of events (and we don't want every typec user having to also buy a PD
analyzer). With this series debugging these kinds of things starts to become
fun:

   # echo 1 > /sys/kernel/debug/tracing/events/tps6598x/enable
   # cat /sys/kernel/debug/tracing/trace_pipe
   irq/79-0-003f-526 [003]    512.717871: tps6598x_irq: 
event1=PLUG_EVENT|DATA_STATUS_UPDATE|STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.722408: tps6598x_status: conn: 
conn-Ra, pp_5v0: off, pp_hv: off, pp_ext: off, pp_cable: off, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE
   irq/79-0-003f-526 [003]    512.727127: tps6598x_data_status: 
DATA_CONNECTION|USB2_CONNECTION|USB3_CONNECTION
   irq/79-0-003f-526 [003]    512.769571: tps6598x_irq: 
event1=PP_SWITCH_CHANGED|STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.773380: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    512.872450: tps6598x_irq: 
event1=POWER_STATUS_UPDATE|PD_STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.876311: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    512.880237: tps6598x_power_status: conn: 
1, pwr-role: source, typec: usb, bc: sdp
   irq/79-0-003f-526 [003]    513.072682: tps6598x_irq: 
event1=STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    513.076390: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe5V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.090676: tps6598x_irq: 
event1=ERROR_CANNOT_PROVIDE_PWR, event2=
   irq/79-0-003f-526 [003]    513.094368: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe5V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.109606: tps6598x_irq: 
event1=NEW_CONTRACT_AS_PROVIDER|POWER_STATUS_UPDATE|STATUS_UPDATE|SRC_TRANSITION,
 event2=
   irq/79-0-003f-526 [003]    513.113777: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.117475: tps6598x_power_status: conn: 
1, pwr-role: source, typec: pd, bc: sdp
   irq/79-0-003f-526 [003]    513.137469: tps6598x_irq: 
event1=VDM_RECEIVED, event2=
   irq/79-0-003f-526 [003]    513.141570: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.281926: tps6598x_irq: 
event1=VDM_RECEIVED, event2=
   irq/79-0-003f-526 [003]    513.285638: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.300515: tps6598x_irq: 
event1=VDM_RECEIVED|DATA_STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    513.304226: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.308302: tps6598x_data_status: 
DATA_CONNECTION|USB2_CONNECTION|USB3_CONNECTION|DP_CONNECTION, DP pinout D

It should not impose any problems for firmwares that don't have IRQs for the
registers enabled. The trace will then just be missing those events.

Patch is against next-20210210.

changes from v1:
- Fix issues on 32bit arches and missing include spotted by kbuild
  (build testes on mips)
  https://lore.kernel.org/linux-usb/202102120644.ixu75gmj-...@intel.com/
  https://lore.kernel.org/linux-usb/202102120159.lyh8aghq-...@intel.com/

changes from v2:
- Reduce macro expansion size by using a custom FIELD_GET. This
  avoids a sparse warning.
  https://lore.kernel.org/linux-usb/20210213031237.GP219708@shao2-debian/

Guido Günther (4):
  usb: typec: tps6598x: Add trace event for IRQ events
  usb: typec: tps6598x: Add trace event for status register
  usb: ty

Re: [PATCH v2 2/4] usb: typec: tps6598x: Add trace event for status register

2021-02-15 Thread Guido Günther
Hi,
On Sun, Feb 14, 2021 at 09:41:27PM +0100, Luc Van Oostenryck wrote:
> On Sun, Feb 14, 2021 at 11:00:48AM -0800, Linus Torvalds wrote:
> > On Sun, Feb 14, 2021 at 10:42 AM Ramsay Jones
> >  wrote:
> > >
> > > >
> > > > I looked around but didn't find any hints how to fix this. Any pointers
> > > > I missed (added the sparse list to cc:)?
> > >
> > > This is a limitation of sparse; when using the 'stringize' pre-processor
> > > operator #, the maximum size of the resulting string is about 8k (if I
> > > remember correctly).
> > 
> > Well, yes and no.
> > 
> > The C89 standard actually says that a string literal can be at most
> > 509 characters to be portable. C99 increased it to 4095 characters.
> > 
> > Sparse makes the limit higher, and the limit could easily be expanded
> > way past 8kB - but the point is that large string literals are
> > actually not guaranteed to be valid C.
> > 
> > So honestly, it really sounds like that TRACE_EVENT() thing is doing
> > something it shouldn't be doing.
> 
> In itself, it's OKish but it does a lot of macro expansions and most
> arguments are macros of macros of ... but the problem seems to be
> limited to TP_printk().
> 
> In the current case, the offender is the string 'print_fmt_tps6598x_status'
> which is just under 26K long especially because it expand
> TPS6598X_STATUS_FLAGS_MASK but also because the arguments use FIELD_GET()
> and thus __BF_FIELD_CHECK().

That was a great hint! Using a custom FIELD_GET() that drops the
__BF_FIELD_CHECK() makes things fit.
Cheers,
 -- Guido

> > 
> > I don't think there's any fundamental limit why sparse does 8kB as a
> > limit (just a few random buffers). Making sparse accept larger ones
> > should be as simple as just increasing MAX_STRING, but I really don't
> > think the kernel should encourage that kind of excessive string sizes.
> 
> Like you noted, there are just a few cases in the kernel and IIRC
> there is or was one case in it too.
> I would tend to increase MAX_STRING to something like 32 or 64K,
> in order to keep it reasonable but let sparse to continue its processing,
> but add a warning when the string/token is bigger than the current 8K.
> 
> -- Luc
> 


Re: [PATCH v2 2/4] usb: typec: tps6598x: Add trace event for status register

2021-02-14 Thread Guido Günther
Hi ,
On Sat, Feb 13, 2021 at 11:12:37AM +0800, kernel test robot wrote:
> Hi "Guido,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on usb/usb-testing]
> [also build test WARNING on v5.11-rc7 next-20210211]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:
> https://github.com/0day-ci/linux/commits/Guido-G-nther/usb-typec-tps6598x-Add-IRQ-flag-and-register-tracing/20210212-200855
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 
> usb-testing
> config: openrisc-randconfig-s032-20210209 (attached as .config)
> compiler: or1k-linux-gcc (GCC) 9.3.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # apt-get install sparse
> # sparse version: v0.6.3-215-g0fb77bb6-dirty
> # 
> https://github.com/0day-ci/linux/commit/ba45e1d5e1fd25b6aed8724106e6c7d5adef7a20
> git remote add linux-review https://github.com/0day-ci/linux
> git fetch --no-tags linux-review 
> Guido-G-nther/usb-typec-tps6598x-Add-IRQ-flag-and-register-tracing/20210212-200855
> git checkout ba45e1d5e1fd25b6aed8724106e6c7d5adef7a20
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
> CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=openrisc 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> 
> "sparse warnings: (new ones prefixed by >>)"
>drivers/usb/typec/tps6598x.c: note: in included file (through 
> include/trace/trace_events.h, include/trace/define_trace.h, 
> drivers/usb/typec/tps6598x_trace.h):
> >> drivers/usb/typec/./tps6598x_trace.h:157:1: sparse: sparse: too long token 
> >> expansion
> 

I looked around but didn't find any hints how to fix this. Any pointers
I missed (added the sparse list to cc:)?

Cheers,
 -- Guido

> vim +157 drivers/usb/typec/./tps6598x_trace.h
> 
> c90c0282e4ce33 Guido Günther 2021-02-12  156  
> ba45e1d5e1fd25 Guido Günther 2021-02-12 @157  TRACE_EVENT(tps6598x_status,
> ba45e1d5e1fd25 Guido Günther 2021-02-12  158      TP_PROTO(u32 
> status),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  159  TP_ARGS(status),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  160  
> ba45e1d5e1fd25 Guido Günther 2021-02-12  161  TP_STRUCT__entry(
> ba45e1d5e1fd25 Guido Günther 2021-02-12  162       
> __field(u32, status)
> ba45e1d5e1fd25 Guido Günther 2021-02-12  163   ),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  164  
> ba45e1d5e1fd25 Guido Günther 2021-02-12  165  TP_fast_assign(
> ba45e1d5e1fd25 Guido Günther 2021-02-12  166 
> __entry->status = status;
> ba45e1d5e1fd25 Guido Günther 2021-02-12  167         ),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  168  
> ba45e1d5e1fd25 Guido Günther 2021-02-12  169  TP_printk("conn: 
> %s, pp_5v0: %s, pp_hv: %s, pp_ext: %s, pp_cable: %s, "
> ba45e1d5e1fd25 Guido Günther 2021-02-12  170"pwr-src: 
> %s, vbus: %s, usb-host: %s, legacy: %s, flags: %s",
> ba45e1d5e1fd25 Guido Günther 2021-02-12  171
> show_status_conn_state(__entry->status),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  172    
> show_status_pp_switch_state(TPS_STATUS_PP_5V0_SWITCH(__entry->status)),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  173
> show_status_pp_switch_state(TPS_STATUS_PP_HV_SWITCH(__entry->status)),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  174
> show_status_pp_switch_state(TPS_STATUS_PP_EXT_SWITCH(__entry->status)),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  175
> show_status_pp_switch_state(TPS_STATUS_PP_CABLE_SWITCH(__entry->status)),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  176    
> show_status_power_sources(__entry->status),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  177        
> show_status_vbus_status(__entry->status),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  178    
> show_status_usb_host_present(__entry->status),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  179
> show_status_legacy(__entry->status),
> ba45e1d5e1fd25 Guido Günther 2021-02-12  180   

[PATCH v2 4/4] usb: typec: tps6598x: Add trace event for data status

2021-02-12 Thread Guido Günther
This is useful to debug DP negotiation and pin assignment even
when the firmware does all the work.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 12 ++-
 drivers/usb/typec/tps6598x.h   | 36 
 drivers/usb/typec/tps6598x_trace.h | 54 ++
 3 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 3e6ad3ba7fc8..a4ec8e56c2b9 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -36,6 +36,7 @@
 #define TPS_REG_CTRL_CONF  0x29
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
+#define TPS_REG_DATA_STATUS0x5f
 
 /* TPS_REG_SYSTEM_CONF bits */
 #define TPS_SYSCONF_PORTINFO(c)((c) & 7)
@@ -408,7 +409,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
struct tps6598x *tps = data;
u64 event1;
u64 event2;
-   u32 status;
+   u32 status, data_status;
u16 pwr_status;
int ret;
 
@@ -438,6 +439,15 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
trace_tps6598x_power_status(pwr_status);
}
 
+   if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) {
+   ret = tps6598x_read32(tps, TPS_REG_DATA_STATUS, _status);
+   if (ret < 0) {
+   dev_err(tps->dev, "failed to read data status: %d\n", 
ret);
+   goto err_clear_ints;
+   }
+   trace_tps6598x_data_status(data_status);
+   }
+
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
if (status & TPS_STATUS_PLUG_PRESENT) {
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index 3f6503377678..1afc22ab4dbb 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -146,4 +146,40 @@
 #define TPS_POWER_STATUS_BC12_STATUS_CDP 2
 #define TPS_POWER_STATUS_BC12_STATUS_DCP 3
 
+/* TPS_REG_DATA_STATUS bits */
+#define TPS_DATA_STATUS_DATA_CONNECTION BIT(0)
+#define TPS_DATA_STATUS_UPSIDE_DOWN BIT(1)
+#define TPS_DATA_STATUS_ACTIVE_CABLEBIT(2)
+#define TPS_DATA_STATUS_USB2_CONNECTION BIT(4)
+#define TPS_DATA_STATUS_USB3_CONNECTION BIT(5)
+#define TPS_DATA_STATUS_USB3_GEN2   BIT(6)
+#define TPS_DATA_STATUS_USB_DATA_ROLE   BIT(7)
+#define TPS_DATA_STATUS_DP_CONNECTION   BIT(8)
+#define TPS_DATA_STATUS_DP_SINK BIT(9)
+#define TPS_DATA_STATUS_TBT_CONNECTION  BIT(16)
+#define TPS_DATA_STATUS_TBT_TYPEBIT(17)
+#define TPS_DATA_STATUS_OPTICAL_CABLE   BIT(18)
+#define TPS_DATA_STATUS_ACTIVE_LINK_TRAINBIT(20)
+#define TPS_DATA_STATUS_FORCE_LSX   BIT(23)
+#define TPS_DATA_STATUS_POWER_MISMATCH  BIT(24)
+
+#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK GENMASK(11, 10)
+#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) \
+   FIELD_GET(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK, (x))
+#define TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK   GENMASK(27, 25)
+#define TPS_DATA_STATUS_TBT_CABLE_SPEED   
FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK, (x))
+#define TPS_DATA_STATUS_TBT_CABLE_GEN_MASK GENMASK(29, 28)
+#define TPS_DATA_STATUS_TBT_CABLE_GEN 
FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_GEN_MASK, (x))
+
+/* Map data status to DP spec assignments */
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT(x) \
+   ((TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) << 1) | \
+   FIELD_GET(TPS_DATA_STATUS_USB3_CONNECTION, (x)))
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_E0
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_FBIT(0)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_CBIT(1)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_D(BIT(1) | BIT(0))
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_ABIT(2)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B(BIT(2) | BIT(1))
+
 #endif /* __TPS6598X_H__ */
diff --git a/drivers/usb/typec/tps6598x_trace.h 
b/drivers/usb/typec/tps6598x_trace.h
index 78a5a6ca337b..38bfb2f04e46 100644
--- a/drivers/usb/typec/tps6598x_trace.h
+++ b/drivers/usb/typec/tps6598x_trace.h
@@ -152,6 +152,41 @@
{ TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \
{ TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" })
 
+#define TPS_DATA_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ 
(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK | \
+ 
TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK | \
+ 
TPS_DATA_STATUS_TBT_CABLE_GEN_MASK))
+
+#define show_data_status_flags(data_status) \
+   __print_flags(data_status & TPS_DATA_STATUS_FLAGS_MASK, "|", \
+   { TPS_DATA_STATUS_DATA_CONNECTION,  

[PATCH v2 2/4] usb: typec: tps6598x: Add trace event for status register

2021-02-12 Thread Guido Günther
This allows to trace status information which helps to debug problems
with role switching, etc.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 26 -
 drivers/usb/typec/tps6598x.h   | 66 +
 drivers/usb/typec/tps6598x_trace.h | 94 ++
 3 files changed, 171 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index bc34b35e909f..559aa175f948 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -37,13 +37,6 @@
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
 
-/* TPS_REG_STATUS bits */
-#define TPS_STATUS_PLUG_PRESENTBIT(0)
-#define TPS_STATUS_ORIENTATION BIT(4)
-#define TPS_STATUS_PORTROLE(s) (!!((s) & BIT(5)))
-#define TPS_STATUS_DATAROLE(s) (!!((s) & BIT(6)))
-#define TPS_STATUS_VCONN(s)(!!((s) & BIT(7)))
-
 /* TPS_REG_SYSTEM_CONF bits */
 #define TPS_SYSCONF_PORTINFO(c)((c) & 7)
 
@@ -258,9 +251,9 @@ static int tps6598x_connect(struct tps6598x *tps, u32 
status)
}
 
typec_set_pwr_opmode(tps->port, mode);
-   typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
-   typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
-   tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), true);
+   typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
+   typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
+   tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), true);
 
tps->partner = typec_register_partner(tps->port, );
if (IS_ERR(tps->partner))
@@ -280,9 +273,10 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 
status)
typec_unregister_partner(tps->partner);
tps->partner = NULL;
typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
-   typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
-   typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
-   tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), false);
+   typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
+   typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
+   tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), 
false);
+
power_supply_changed(tps->psy);
 }
 
@@ -366,7 +360,7 @@ static int tps6598x_dr_set(struct typec_port *port, enum 
typec_data_role role)
if (ret)
goto out_unlock;
 
-   if (role != TPS_STATUS_DATAROLE(status)) {
+   if (role != TPS_STATUS_TO_TYPEC_DATAROLE(status)) {
ret = -EPROTO;
goto out_unlock;
}
@@ -396,7 +390,7 @@ static int tps6598x_pr_set(struct typec_port *port, enum 
typec_role role)
if (ret)
goto out_unlock;
 
-   if (role != TPS_STATUS_PORTROLE(status)) {
+   if (role != TPS_STATUS_TO_TYPEC_PORTROLE(status)) {
ret = -EPROTO;
goto out_unlock;
}
@@ -437,6 +431,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "%s: failed to read status\n", __func__);
goto err_clear_ints;
}
+   trace_tps6598x_status(status);
 
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
@@ -612,6 +607,7 @@ static int tps6598x_probe(struct i2c_client *client)
ret = tps6598x_read32(tps, TPS_REG_STATUS, );
if (ret < 0)
return ret;
+   trace_tps6598x_status(status);
 
ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, );
if (ret < 0)
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index b83b8a6a1504..866fd1deb471 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -12,6 +12,72 @@
 #ifndef __TPS6598X_H__
 #define __TPS6598X_H__
 
+/* TPS_REG_STATUS bits */
+#define TPS_STATUS_PLUG_PRESENTBIT(0)
+#define TPS_STATUS_PLUG_UPSIDE_DOWNBIT(4)
+#define TPS_STATUS_PORTROLEBIT(5)
+#define TPS_STATUS_TO_TYPEC_PORTROLE(s) (!!((s) & TPS_STATUS_PORTROLE))
+#define TPS_STATUS_DATAROLEBIT(6)
+#define TPS_STATUS_TO_TYPEC_DATAROLE(s)(!!((s) & TPS_STATUS_DATAROLE))
+#define TPS_STATUS_VCONN   BIT(7)
+#define TPS_STATUS_TO_TYPEC_VCONN(s)   (!!((s) & TPS_STATUS_VCONN))
+#define TPS_STATUS_OVERCURRENT BIT(16)
+#define TPS_STATUS_GOTO_MIN_ACTIVE BIT(26)
+#define TPS_STATUS_BISTBIT(27)
+#define TPS_STATUS_HIGH_VOLAGE_WARNING BIT(28)
+#define TPS_STATUS_HIGH_LOW_VOLTAGE_WARNING BIT(29)
+
+#define TPS_STATUS_CONN_STATE_MASK GENMASK(3, 1)
+#define TPS_STATUS_CONN_STATE(x)   
F

[PATCH v2 1/4] usb: typec: tps6598x: Add trace event for IRQ events

2021-02-12 Thread Guido Günther
Allow to get irq event information via the tracing framework.  This
allows to inspect USB-C negotiation at runtime.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/Makefile |  3 +
 drivers/usb/typec/tps6598x.c   |  9 ++-
 drivers/usb/typec/tps6598x.h   | 64 
 drivers/usb/typec/tps6598x_trace.h | 97 ++
 4 files changed, 170 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/typec/tps6598x.h
 create mode 100644 drivers/usb/typec/tps6598x_trace.h

diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index d03b48c4b864..27aa12129190 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
+# define_trace.h needs to know how to find our header
+CFLAGS_tps6598x.o  := -I$(src)
+
 obj-$(CONFIG_TYPEC)+= typec.o
 typec-y:= class.o mux.o bus.o
 obj-$(CONFIG_TYPEC)+= altmodes/
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 6e6ef6317523..bc34b35e909f 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -6,6 +6,8 @@
  * Author: Heikki Krogerus 
  */
 
+#include "tps6598x.h"
+
 #include 
 #include 
 #include 
@@ -15,6 +17,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include "tps6598x_trace.h"
+
 /* Register offsets */
 #define TPS_REG_VID0x00
 #define TPS_REG_MODE   0x03
@@ -32,9 +37,6 @@
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
 
-/* TPS_REG_INT_* bits */
-#define TPS_REG_INT_PLUG_EVENT BIT(3)
-
 /* TPS_REG_STATUS bits */
 #define TPS_STATUS_PLUG_PRESENTBIT(0)
 #define TPS_STATUS_ORIENTATION BIT(4)
@@ -428,6 +430,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "%s: failed to read events\n", __func__);
goto err_unlock;
}
+   trace_tps6598x_irq(event1, event2);
 
ret = tps6598x_read32(tps, TPS_REG_STATUS, );
if (ret) {
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
new file mode 100644
index ..b83b8a6a1504
--- /dev/null
+++ b/drivers/usb/typec/tps6598x.h
@@ -0,0 +1,64 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Driver for TI TPS6598x USB Power Delivery controller family
+ *
+ * Copyright (C) 2017, Intel Corporation
+ * Author: Heikki Krogerus 
+ */
+
+#include 
+#include 
+
+#ifndef __TPS6598X_H__
+#define __TPS6598X_H__
+
+
+/* TPS_REG_INT_* bits */
+#define TPS_REG_INT_USER_VID_ALT_MODE_OTHER_VDMBIT_ULL(27+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ATTN_VDM BIT_ULL(26+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_EXIT BIT_ULL(25+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ENTERED  BIT_ULL(24+32)
+#define TPS_REG_INT_EXIT_MODES_COMPLETEBIT_ULL(20+32)
+#define TPS_REG_INT_DISCOVER_MODES_COMPLETEBIT_ULL(19+32)
+#define TPS_REG_INT_VDM_MSG_SENT   BIT_ULL(18+32)
+#define TPS_REG_INT_VDM_ENTERED_MODE   BIT_ULL(17+32)
+#define TPS_REG_INT_ERROR_UNABLE_TO_SOURCE BIT_ULL(14+32)
+#define TPS_REG_INT_SRC_TRANSITION BIT_ULL(10+32)
+#define TPS_REG_INT_ERROR_DISCHARGE_FAILED BIT_ULL(9+32)
+#define TPS_REG_INT_ERROR_MESSAGE_DATA BIT_ULL(7+32)
+#define TPS_REG_INT_ERROR_PROTOCOL_ERROR   BIT_ULL(6+32)
+#define TPS_REG_INT_ERROR_MISSING_GET_CAP_MESSAGE  BIT_ULL(4+32)
+#define TPS_REG_INT_ERROR_POWER_EVENT_OCCURRED BIT_ULL(3+32)
+#define TPS_REG_INT_ERROR_CAN_PROVIDE_PWR_LATERBIT_ULL(2+32)
+#define TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWR   BIT_ULL(1+32)
+#define TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE  BIT_ULL(0+32)
+#define TPS_REG_INT_CMD2_COMPLETE  BIT(31)
+#define TPS_REG_INT_CMD1_COMPLETE  BIT(30)
+#define TPS_REG_INT_ADC_HIGH_THRESHOLD BIT(29)
+#define TPS_REG_INT_ADC_LOW_THRESHOLD  BIT(28)
+#define TPS_REG_INT_PD_STATUS_UPDATE   BIT(27)
+#define TPS_REG_INT_STATUS_UPDATE  BIT(26)
+#define TPS_REG_INT_DATA_STATUS_UPDATE BIT(25)
+#define TPS_REG_INT_POWER_STATUS_UPDATEBIT(24)
+#define TPS_REG_INT_PP_SWITCH_CHANGED  BIT(23)
+#define TPS_REG_INT_HIGH_VOLTAGE_WARNING   BIT(22)
+#define TPS_REG_INT_USB_HOST_PRESENT_NO_LONGER BIT(21)
+#define TPS_REG_INT_USB_HOST_PRESENT   BIT(20)
+#define TPS_REG_INT_GOTO_MIN_RECEIVED  BIT(19)
+#define TPS_REG_INT_PR_SWAP_REQUESTED  BIT(17)
+#define TPS_REG_INT_SINK_CAP_MESSAGE_READY BIT(15)
+#define TPS_REG_INT_SOURCE_CAP_MESSAGE

[PATCH v2 0/4] usb: typec: tps6598x: Add IRQ flag and register tracing

2021-02-12 Thread Guido Günther
This series adds tracing events for the chips IRQ and registers that are useful
to figure out the current data and power status. This came about since
diagnosing why a certain usb-c hub or dp-alt-mode adapter fails is hard with
the information in /sys/class/typec alone since this does not have a timeline
of events (and we don't want every typec user having to also buy a PD
analyzer). With this series debugging these kinds of things starts to become
fun:

   # echo 1 > /sys/kernel/debug/tracing/events/tps6598x/enable
   # cat /sys/kernel/debug/tracing/trace_pipe
   irq/79-0-003f-526 [003]    512.717871: tps6598x_irq: 
event1=PLUG_EVENT|DATA_STATUS_UPDATE|STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.722408: tps6598x_status: conn: 
conn-Ra, pp_5v0: off, pp_hv: off, pp_ext: off, pp_cable: off, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE
   irq/79-0-003f-526 [003]    512.727127: tps6598x_data_status: 
DATA_CONNECTION|USB2_CONNECTION|USB3_CONNECTION
   irq/79-0-003f-526 [003]    512.769571: tps6598x_irq: 
event1=PP_SWITCH_CHANGED|STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.773380: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    512.872450: tps6598x_irq: 
event1=POWER_STATUS_UPDATE|PD_STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.876311: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    512.880237: tps6598x_power_status: conn: 
1, pwr-role: source, typec: usb, bc: sdp
   irq/79-0-003f-526 [003]    513.072682: tps6598x_irq: 
event1=STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    513.076390: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe5V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.090676: tps6598x_irq: 
event1=ERROR_CANNOT_PROVIDE_PWR, event2=
   irq/79-0-003f-526 [003]    513.094368: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe5V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.109606: tps6598x_irq: 
event1=NEW_CONTRACT_AS_PROVIDER|POWER_STATUS_UPDATE|STATUS_UPDATE|SRC_TRANSITION,
 event2=
   irq/79-0-003f-526 [003]    513.113777: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.117475: tps6598x_power_status: conn: 
1, pwr-role: source, typec: pd, bc: sdp
   irq/79-0-003f-526 [003]    513.137469: tps6598x_irq: 
event1=VDM_RECEIVED, event2=
   irq/79-0-003f-526 [003]    513.141570: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.281926: tps6598x_irq: 
event1=VDM_RECEIVED, event2=
   irq/79-0-003f-526 [003]    513.285638: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.300515: tps6598x_irq: 
event1=VDM_RECEIVED|DATA_STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    513.304226: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.308302: tps6598x_data_status: 
DATA_CONNECTION|USB2_CONNECTION|USB3_CONNECTION|DP_CONNECTION, DP pinout D

It should not impose any problems for firmwares that don't have IRQs for the
registers enabled. The trace will then just be missing those events.

Patch is against next-20210210.

changes from v1:
- Fix issues on 32bit arches and missing include spotted by kbuild
  (build testes on mips)



Guido Günther (4):
  usb: typec: tps6598x: Add trace event for IRQ events
  usb: typec: tps6598x: Add trace event for status register
  usb: typec: tps6598x: Add trace event for power status register
  usb: typec: tps6598x: Add trace event for data status

 drivers/usb/typec/Makefile |   3 +
 drivers/usb/typec/tps6598x.c   |  66 ---
 drivers/usb/typec/tps6598x.h   | 185 +++
 drivers/usb/typec/tps6598x_trace.h | 

[PATCH v2 3/4] usb: typec: tps6598x: Add trace event for power status register

2021-02-12 Thread Guido Günther
Together with the PD status register this is vital for debugging power
negotiations at runtime.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 19 +--
 drivers/usb/typec/tps6598x.h   | 19 +++
 drivers/usb/typec/tps6598x_trace.h | 38 ++
 3 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 559aa175f948..3e6ad3ba7fc8 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -50,11 +50,6 @@ enum {
TPS_PORTINFO_SOURCE,
 };
 
-/* TPS_REG_POWER_STATUS bits */
-#define TPS_POWER_STATUS_CONNECTIONBIT(0)
-#define TPS_POWER_STATUS_SOURCESINKBIT(1)
-#define TPS_POWER_STATUS_PWROPMODE(p)  (((p) & GENMASK(3, 2)) >> 2)
-
 /* TPS_REG_RX_IDENTITY_SOP */
 struct tps6598x_rx_identity_reg {
u8 status;
@@ -414,6 +409,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
u64 event1;
u64 event2;
u32 status;
+   u16 pwr_status;
int ret;
 
mutex_lock(>lock);
@@ -433,6 +429,15 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
}
trace_tps6598x_status(status);
 
+   if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) {
+   ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, _status);
+   if (ret < 0) {
+   dev_err(tps->dev, "failed to read power status: %d\n", 
ret);
+   goto err_clear_ints;
+   }
+   trace_tps6598x_power_status(pwr_status);
+   }
+
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
if (status & TPS_STATUS_PLUG_PRESENT) {
@@ -497,8 +502,8 @@ static int tps6598x_psy_get_online(struct tps6598x *tps,
if (ret < 0)
return ret;
 
-   if ((pwr_status & TPS_POWER_STATUS_CONNECTION) &&
-   (pwr_status & TPS_POWER_STATUS_SOURCESINK)) {
+   if (TPS_POWER_STATUS_CONNECTION(pwr_status) &&
+   TPS_POWER_STATUS_SOURCESINK(pwr_status)) {
val->intval = 1;
} else {
val->intval = 0;
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index 866fd1deb471..3f6503377678 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -127,4 +127,23 @@
 #define TPS_REG_INT_HARD_RESET BIT(1)
 #define TPS_REG_INT_PD_SOFT_RESET  BIT(0)
 
+/* TPS_REG_POWER_STATUS bits */
+#define TPS_POWER_STATUS_CONNECTION(x)  FIELD_GET(BIT(0), (x))
+#define TPS_POWER_STATUS_SOURCESINK(x) FIELD_GET(BIT(1), (x))
+#define TPS_POWER_STATUS_BC12_DET(x)   FIELD_GET(BIT(2), (x))
+
+#define TPS_POWER_STATUS_TYPEC_CURRENT_MASK GENMASK(3, 2)
+#define TPS_POWER_STATUS_PWROPMODE(p)  
FIELD_GET(TPS_POWER_STATUS_TYPEC_CURRENT_MASK, (p))
+#define TPS_POWER_STATUS_BC12_STATUS_MASK   GENMASK(6, 5)
+#define TPS_POWER_STATUS_BC12_STATUS(p)
FIELD_GET(TPS_POWER_STATUS_BC12_STATUS_MASK, (p))
+
+#define TPS_POWER_STATUS_TYPEC_CURRENT_USB 0
+#define TPS_POWER_STATUS_TYPEC_CURRENT_1A5 1
+#define TPS_POWER_STATUS_TYPEC_CURRENT_3A0 2
+#define TPS_POWER_STATUS_TYPEC_CURRENT_PD  3
+
+#define TPS_POWER_STATUS_BC12_STATUS_SDP 0
+#define TPS_POWER_STATUS_BC12_STATUS_CDP 2
+#define TPS_POWER_STATUS_BC12_STATUS_DCP 3
+
 #endif /* __TPS6598X_H__ */
diff --git a/drivers/usb/typec/tps6598x_trace.h 
b/drivers/usb/typec/tps6598x_trace.h
index e0677b9c5c53..78a5a6ca337b 100644
--- a/drivers/usb/typec/tps6598x_trace.h
+++ b/drivers/usb/typec/tps6598x_trace.h
@@ -134,6 +134,24 @@
  { TPS_STATUS_HIGH_VOLAGE_WARNING, "HIGH_VOLAGE_WARNING" 
}, \
  { TPS_STATUS_HIGH_LOW_VOLTAGE_WARNING, 
"HIGH_LOW_VOLTAGE_WARNING" })
 
+#define show_power_status_source_sink(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_SOURCESINK(power_status), \
+   { 1, "sink" }, \
+   { 0, "source" })
+
+#define show_power_status_typec_status(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_PWROPMODE(power_status), \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_PD,  "pd" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_3A0, "3.0A" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_1A5, "1.5A" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_USB, "usb" })
+
+#define show_power_status_bc12_status(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_BC12_STATUS(power_status), \
+   { TPS_POWER_STATUS_BC12_STATUS_DCP, "dcp" }, \
+   { TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \
+   { TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" })
+
 TRACE_EVENT(tps6598x_irq,
TP_PROTO(

[PATCH v1 3/4] usb: typec: tps6598x: Add trace event for power status register

2021-02-11 Thread Guido Günther
Together with the PD status register this is vital for debugging power
negotiations at runtime.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 19 +--
 drivers/usb/typec/tps6598x.h   | 19 +++
 drivers/usb/typec/tps6598x_trace.h | 38 ++
 3 files changed, 69 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 559aa175f948..3e6ad3ba7fc8 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -50,11 +50,6 @@ enum {
TPS_PORTINFO_SOURCE,
 };
 
-/* TPS_REG_POWER_STATUS bits */
-#define TPS_POWER_STATUS_CONNECTIONBIT(0)
-#define TPS_POWER_STATUS_SOURCESINKBIT(1)
-#define TPS_POWER_STATUS_PWROPMODE(p)  (((p) & GENMASK(3, 2)) >> 2)
-
 /* TPS_REG_RX_IDENTITY_SOP */
 struct tps6598x_rx_identity_reg {
u8 status;
@@ -414,6 +409,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
u64 event1;
u64 event2;
u32 status;
+   u16 pwr_status;
int ret;
 
mutex_lock(>lock);
@@ -433,6 +429,15 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
}
trace_tps6598x_status(status);
 
+   if ((event1 | event2) & TPS_REG_INT_POWER_STATUS_UPDATE) {
+   ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, _status);
+   if (ret < 0) {
+   dev_err(tps->dev, "failed to read power status: %d\n", 
ret);
+   goto err_clear_ints;
+   }
+   trace_tps6598x_power_status(pwr_status);
+   }
+
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
if (status & TPS_STATUS_PLUG_PRESENT) {
@@ -497,8 +502,8 @@ static int tps6598x_psy_get_online(struct tps6598x *tps,
if (ret < 0)
return ret;
 
-   if ((pwr_status & TPS_POWER_STATUS_CONNECTION) &&
-   (pwr_status & TPS_POWER_STATUS_SOURCESINK)) {
+   if (TPS_POWER_STATUS_CONNECTION(pwr_status) &&
+   TPS_POWER_STATUS_SOURCESINK(pwr_status)) {
val->intval = 1;
} else {
val->intval = 0;
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index ceea4de51021..a2b76ee26f53 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -124,4 +124,23 @@
 #define TPS_REG_INT_HARD_RESET BIT(1)
 #define TPS_REG_INT_PD_SOFT_RESET  BIT(0)
 
+/* TPS_REG_POWER_STATUS bits */
+#define TPS_POWER_STATUS_CONNECTION(x)  FIELD_GET(BIT(0), (x))
+#define TPS_POWER_STATUS_SOURCESINK(x) FIELD_GET(BIT(1), (x))
+#define TPS_POWER_STATUS_BC12_DET(x)   FIELD_GET(BIT(2), (x))
+
+#define TPS_POWER_STATUS_TYPEC_CURRENT_MASK GENMASK(3, 2)
+#define TPS_POWER_STATUS_PWROPMODE(p)  
FIELD_GET(TPS_POWER_STATUS_TYPEC_CURRENT_MASK, (p))
+#define TPS_POWER_STATUS_BC12_STATUS_MASK   GENMASK(6, 5)
+#define TPS_POWER_STATUS_BC12_STATUS(p)
FIELD_GET(TPS_POWER_STATUS_BC12_STATUS_MASK, (p))
+
+#define TPS_POWER_STATUS_TYPEC_CURRENT_USB 0
+#define TPS_POWER_STATUS_TYPEC_CURRENT_1A5 1
+#define TPS_POWER_STATUS_TYPEC_CURRENT_3A0 2
+#define TPS_POWER_STATUS_TYPEC_CURRENT_PD  3
+
+#define TPS_POWER_STATUS_BC12_STATUS_SDP 0
+#define TPS_POWER_STATUS_BC12_STATUS_CDP 2
+#define TPS_POWER_STATUS_BC12_STATUS_DCP 3
+
 #endif /* __TPS6598X_H__ */
diff --git a/drivers/usb/typec/tps6598x_trace.h 
b/drivers/usb/typec/tps6598x_trace.h
index 5aa0aa4d5209..c15327bb7bf1 100644
--- a/drivers/usb/typec/tps6598x_trace.h
+++ b/drivers/usb/typec/tps6598x_trace.h
@@ -134,6 +134,24 @@
  { TPS_STATUS_HIGH_VOLAGE_WARNING, "HIGH_VOLAGE_WARNING" 
}, \
  { TPS_STATUS_HIGH_LOW_VOLTAGE_WARNING, 
"HIGH_LOW_VOLTAGE_WARNING" })
 
+#define show_power_status_source_sink(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_SOURCESINK(power_status), \
+   { 1, "sink" }, \
+   { 0, "source" })
+
+#define show_power_status_typec_status(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_PWROPMODE(power_status), \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_PD,  "pd" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_3A0, "3.0A" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_1A5, "1.5A" }, \
+   { TPS_POWER_STATUS_TYPEC_CURRENT_USB, "usb" })
+
+#define show_power_status_bc12_status(power_status) \
+   __print_symbolic(TPS_POWER_STATUS_BC12_STATUS(power_status), \
+   { TPS_POWER_STATUS_BC12_STATUS_DCP, "dcp" }, \
+   { TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \
+   { TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" })
+
 TRACE_EVENT(tps6598x_irq,
TP_PROTO(

[PATCH v1 4/4] usb: typec: tps6598x: Add trace event for data status

2021-02-11 Thread Guido Günther
This is useful to debug DP negotiation and pin assignment even
when the firmware does all the work.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 12 ++-
 drivers/usb/typec/tps6598x.h   | 36 
 drivers/usb/typec/tps6598x_trace.h | 54 ++
 3 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 3e6ad3ba7fc8..a4ec8e56c2b9 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -36,6 +36,7 @@
 #define TPS_REG_CTRL_CONF  0x29
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
+#define TPS_REG_DATA_STATUS0x5f
 
 /* TPS_REG_SYSTEM_CONF bits */
 #define TPS_SYSCONF_PORTINFO(c)((c) & 7)
@@ -408,7 +409,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
struct tps6598x *tps = data;
u64 event1;
u64 event2;
-   u32 status;
+   u32 status, data_status;
u16 pwr_status;
int ret;
 
@@ -438,6 +439,15 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
trace_tps6598x_power_status(pwr_status);
}
 
+   if ((event1 | event2) & TPS_REG_INT_DATA_STATUS_UPDATE) {
+   ret = tps6598x_read32(tps, TPS_REG_DATA_STATUS, _status);
+   if (ret < 0) {
+   dev_err(tps->dev, "failed to read data status: %d\n", 
ret);
+   goto err_clear_ints;
+   }
+   trace_tps6598x_data_status(data_status);
+   }
+
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
if (status & TPS_STATUS_PLUG_PRESENT) {
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index a2b76ee26f53..3794d75ffada 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -143,4 +143,40 @@
 #define TPS_POWER_STATUS_BC12_STATUS_CDP 2
 #define TPS_POWER_STATUS_BC12_STATUS_DCP 3
 
+/* TPS_REG_DATA_STATUS bits */
+#define TPS_DATA_STATUS_DATA_CONNECTION BIT(0)
+#define TPS_DATA_STATUS_UPSIDE_DOWN BIT(1)
+#define TPS_DATA_STATUS_ACTIVE_CABLEBIT(2)
+#define TPS_DATA_STATUS_USB2_CONNECTION BIT(4)
+#define TPS_DATA_STATUS_USB3_CONNECTION BIT(5)
+#define TPS_DATA_STATUS_USB3_GEN2   BIT(6)
+#define TPS_DATA_STATUS_USB_DATA_ROLE   BIT(7)
+#define TPS_DATA_STATUS_DP_CONNECTION   BIT(8)
+#define TPS_DATA_STATUS_DP_SINK BIT(9)
+#define TPS_DATA_STATUS_TBT_CONNECTION  BIT(16)
+#define TPS_DATA_STATUS_TBT_TYPEBIT(17)
+#define TPS_DATA_STATUS_OPTICAL_CABLE   BIT(18)
+#define TPS_DATA_STATUS_ACTIVE_LINK_TRAINBIT(20)
+#define TPS_DATA_STATUS_FORCE_LSX   BIT(23)
+#define TPS_DATA_STATUS_POWER_MISMATCH  BIT(24)
+
+#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK GENMASK(11, 10)
+#define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) \
+   FIELD_GET(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK, (x))
+#define TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK   GENMASK(27, 25)
+#define TPS_DATA_STATUS_TBT_CABLE_SPEED   
FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK, (x))
+#define TPS_DATA_STATUS_TBT_CABLE_GEN_MASK GENMASK(29, 28)
+#define TPS_DATA_STATUS_TBT_CABLE_GEN 
FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_GEN_MASK, (x))
+
+/* Map data status to DP spec assignments */
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT(x) \
+   ((TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) << 1) | \
+   FIELD_GET(TPS_DATA_STATUS_USB3_CONNECTION, (x)))
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_E0
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_FBIT(0)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_CBIT(1)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_D(BIT(1) | BIT(0))
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_ABIT(2)
+#define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B(BIT(2) | BIT(1))
+
 #endif /* __TPS6598X_H__ */
diff --git a/drivers/usb/typec/tps6598x_trace.h 
b/drivers/usb/typec/tps6598x_trace.h
index c15327bb7bf1..0ec264bb2042 100644
--- a/drivers/usb/typec/tps6598x_trace.h
+++ b/drivers/usb/typec/tps6598x_trace.h
@@ -152,6 +152,41 @@
{ TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \
{ TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" })
 
+#define TPS_DATA_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ 
(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK | \
+ 
TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK | \
+ 
TPS_DATA_STATUS_TBT_CABLE_GEN_MASK))
+
+#define show_data_status_flags(data_status) \
+   __print_flags(data_status & TPS_DATA_STATUS_FLAGS_MASK, "|", \
+   { TPS_DATA_STATUS_DATA_CONNECTION,  

[PATCH v1 2/4] usb: typec: tps6598x: Add trace event for status register

2021-02-11 Thread Guido Günther
This allows to trace status information which helps to debug problems
with role switching, etc.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/tps6598x.c   | 26 -
 drivers/usb/typec/tps6598x.h   | 66 +
 drivers/usb/typec/tps6598x_trace.h | 94 ++
 3 files changed, 171 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index bc34b35e909f..559aa175f948 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -37,13 +37,6 @@
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
 
-/* TPS_REG_STATUS bits */
-#define TPS_STATUS_PLUG_PRESENTBIT(0)
-#define TPS_STATUS_ORIENTATION BIT(4)
-#define TPS_STATUS_PORTROLE(s) (!!((s) & BIT(5)))
-#define TPS_STATUS_DATAROLE(s) (!!((s) & BIT(6)))
-#define TPS_STATUS_VCONN(s)(!!((s) & BIT(7)))
-
 /* TPS_REG_SYSTEM_CONF bits */
 #define TPS_SYSCONF_PORTINFO(c)((c) & 7)
 
@@ -258,9 +251,9 @@ static int tps6598x_connect(struct tps6598x *tps, u32 
status)
}
 
typec_set_pwr_opmode(tps->port, mode);
-   typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
-   typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
-   tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), true);
+   typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
+   typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
+   tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), true);
 
tps->partner = typec_register_partner(tps->port, );
if (IS_ERR(tps->partner))
@@ -280,9 +273,10 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 
status)
typec_unregister_partner(tps->partner);
tps->partner = NULL;
typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
-   typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
-   typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
-   tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), false);
+   typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
+   typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
+   tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), 
false);
+
power_supply_changed(tps->psy);
 }
 
@@ -366,7 +360,7 @@ static int tps6598x_dr_set(struct typec_port *port, enum 
typec_data_role role)
if (ret)
goto out_unlock;
 
-   if (role != TPS_STATUS_DATAROLE(status)) {
+   if (role != TPS_STATUS_TO_TYPEC_DATAROLE(status)) {
ret = -EPROTO;
goto out_unlock;
}
@@ -396,7 +390,7 @@ static int tps6598x_pr_set(struct typec_port *port, enum 
typec_role role)
if (ret)
goto out_unlock;
 
-   if (role != TPS_STATUS_PORTROLE(status)) {
+   if (role != TPS_STATUS_TO_TYPEC_PORTROLE(status)) {
ret = -EPROTO;
goto out_unlock;
}
@@ -437,6 +431,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "%s: failed to read status\n", __func__);
goto err_clear_ints;
}
+   trace_tps6598x_status(status);
 
/* Handle plug insert or removal */
if ((event1 | event2) & TPS_REG_INT_PLUG_EVENT) {
@@ -612,6 +607,7 @@ static int tps6598x_probe(struct i2c_client *client)
ret = tps6598x_read32(tps, TPS_REG_STATUS, );
if (ret < 0)
return ret;
+   trace_tps6598x_status(status);
 
ret = tps6598x_read32(tps, TPS_REG_SYSTEM_CONF, );
if (ret < 0)
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
index 3040cfdd2b8f..ceea4de51021 100644
--- a/drivers/usb/typec/tps6598x.h
+++ b/drivers/usb/typec/tps6598x.h
@@ -9,6 +9,72 @@
 #ifndef __TPS6598X_H__
 #define __TPS6598X_H__
 
+/* TPS_REG_STATUS bits */
+#define TPS_STATUS_PLUG_PRESENTBIT(0)
+#define TPS_STATUS_PLUG_UPSIDE_DOWNBIT(4)
+#define TPS_STATUS_PORTROLEBIT(5)
+#define TPS_STATUS_TO_TYPEC_PORTROLE(s) (!!((s) & TPS_STATUS_PORTROLE))
+#define TPS_STATUS_DATAROLEBIT(6)
+#define TPS_STATUS_TO_TYPEC_DATAROLE(s)(!!((s) & TPS_STATUS_DATAROLE))
+#define TPS_STATUS_VCONN   BIT(7)
+#define TPS_STATUS_TO_TYPEC_VCONN(s)   (!!((s) & TPS_STATUS_VCONN))
+#define TPS_STATUS_OVERCURRENT BIT(16)
+#define TPS_STATUS_GOTO_MIN_ACTIVE BIT(26)
+#define TPS_STATUS_BISTBIT(27)
+#define TPS_STATUS_HIGH_VOLAGE_WARNING BIT(28)
+#define TPS_STATUS_HIGH_LOW_VOLTAGE_WARNING BIT(29)
+
+#define TPS_STATUS_CONN_STATE_MASK GENMASK(3, 1)
+#define TPS_STATUS_CONN_STATE(x)   
F

[PATCH v1 1/4] usb: typec: tps6598x: Add trace event for IRQ events

2021-02-11 Thread Guido Günther
Allow to get irq event information via the tracing framework.  This
allows to inspect USB-C negotiation at runtime.

Signed-off-by: Guido Günther 
---
 drivers/usb/typec/Makefile |  3 +
 drivers/usb/typec/tps6598x.c   |  9 ++-
 drivers/usb/typec/tps6598x.h   | 61 +++
 drivers/usb/typec/tps6598x_trace.h | 97 ++
 4 files changed, 167 insertions(+), 3 deletions(-)
 create mode 100644 drivers/usb/typec/tps6598x.h
 create mode 100644 drivers/usb/typec/tps6598x_trace.h

diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile
index d03b48c4b864..27aa12129190 100644
--- a/drivers/usb/typec/Makefile
+++ b/drivers/usb/typec/Makefile
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
+# define_trace.h needs to know how to find our header
+CFLAGS_tps6598x.o  := -I$(src)
+
 obj-$(CONFIG_TYPEC)+= typec.o
 typec-y:= class.o mux.o bus.o
 obj-$(CONFIG_TYPEC)+= altmodes/
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 6e6ef6317523..bc34b35e909f 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -6,6 +6,8 @@
  * Author: Heikki Krogerus 
  */
 
+#include "tps6598x.h"
+
 #include 
 #include 
 #include 
@@ -15,6 +17,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include "tps6598x_trace.h"
+
 /* Register offsets */
 #define TPS_REG_VID0x00
 #define TPS_REG_MODE   0x03
@@ -32,9 +37,6 @@
 #define TPS_REG_POWER_STATUS   0x3f
 #define TPS_REG_RX_IDENTITY_SOP0x48
 
-/* TPS_REG_INT_* bits */
-#define TPS_REG_INT_PLUG_EVENT BIT(3)
-
 /* TPS_REG_STATUS bits */
 #define TPS_STATUS_PLUG_PRESENTBIT(0)
 #define TPS_STATUS_ORIENTATION BIT(4)
@@ -428,6 +430,7 @@ static irqreturn_t tps6598x_interrupt(int irq, void *data)
dev_err(tps->dev, "%s: failed to read events\n", __func__);
goto err_unlock;
}
+   trace_tps6598x_irq(event1, event2);
 
ret = tps6598x_read32(tps, TPS_REG_STATUS, );
if (ret) {
diff --git a/drivers/usb/typec/tps6598x.h b/drivers/usb/typec/tps6598x.h
new file mode 100644
index ..3040cfdd2b8f
--- /dev/null
+++ b/drivers/usb/typec/tps6598x.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Driver for TI TPS6598x USB Power Delivery controller family
+ *
+ * Copyright (C) 2017, Intel Corporation
+ * Author: Heikki Krogerus 
+ */
+
+#ifndef __TPS6598X_H__
+#define __TPS6598X_H__
+
+
+/* TPS_REG_INT_* bits */
+#define TPS_REG_INT_USER_VID_ALT_MODE_OTHER_VDMBIT(27+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ATTN_VDM BIT(26+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_EXIT BIT(25+32)
+#define TPS_REG_INT_USER_VID_ALT_MODE_ENTERED  BIT(24+32)
+#define TPS_REG_INT_EXIT_MODES_COMPLETEBIT(20+32)
+#define TPS_REG_INT_DISCOVER_MODES_COMPLETEBIT(19+32)
+#define TPS_REG_INT_VDM_MSG_SENT   BIT(18+32)
+#define TPS_REG_INT_VDM_ENTERED_MODE   BIT(17+32)
+#define TPS_REG_INT_ERROR_UNABLE_TO_SOURCE BIT(14+32)
+#define TPS_REG_INT_SRC_TRANSITION BIT(10+32)
+#define TPS_REG_INT_ERROR_DISCHARGE_FAILED BIT(9+32)
+#define TPS_REG_INT_ERROR_MESSAGE_DATA BIT(7+32)
+#define TPS_REG_INT_ERROR_PROTOCOL_ERROR   BIT(6+32)
+#define TPS_REG_INT_ERROR_MISSING_GET_CAP_MESSAGE  BIT(4+32)
+#define TPS_REG_INT_ERROR_POWER_EVENT_OCCURRED BIT(3+32)
+#define TPS_REG_INT_ERROR_CAN_PROVIDE_PWR_LATERBIT(2+32)
+#define TPS_REG_INT_ERROR_CANNOT_PROVIDE_PWR   BIT(1+32)
+#define TPS_REG_INT_ERROR_DEVICE_INCOMPATIBLE  BIT(0+32)
+#define TPS_REG_INT_CMD2_COMPLETE  BIT(31)
+#define TPS_REG_INT_CMD1_COMPLETE  BIT(30)
+#define TPS_REG_INT_ADC_HIGH_THRESHOLD BIT(29)
+#define TPS_REG_INT_ADC_LOW_THRESHOLD  BIT(28)
+#define TPS_REG_INT_PD_STATUS_UPDATE   BIT(27)
+#define TPS_REG_INT_STATUS_UPDATE  BIT(26)
+#define TPS_REG_INT_DATA_STATUS_UPDATE BIT(25)
+#define TPS_REG_INT_POWER_STATUS_UPDATEBIT(24)
+#define TPS_REG_INT_PP_SWITCH_CHANGED  BIT(23)
+#define TPS_REG_INT_HIGH_VOLTAGE_WARNING   BIT(22)
+#define TPS_REG_INT_USB_HOST_PRESENT_NO_LONGER BIT(21)
+#define TPS_REG_INT_USB_HOST_PRESENT   BIT(20)
+#define TPS_REG_INT_GOTO_MIN_RECEIVED  BIT(19)
+#define TPS_REG_INT_PR_SWAP_REQUESTED  BIT(17)
+#define TPS_REG_INT_SINK_CAP_MESSAGE_READY BIT(15)
+#define TPS_REG_INT_SOURCE_CAP_MESSAGE_READY   BIT(14)
+#define TPS_REG_INT_NEW_CONTRACT_AS_PROVIDER   BIT(13)
+#define TPS_REG_INT_NEW_CONT

[PATCH v1 0/4] usb: typec: tps6598x: Add IRQ flag and register tracing

2021-02-11 Thread Guido Günther


This series adds tracing events for the chips IRQ and registers that are useful
to figure out the current data and power status. This came about since
diagnosing why a certain usb-c hub or dp-alt-mode adapter fails is hard with
the information in /sys/class/typec alone since this does not have a timeline
of events (and we don't want every typec user having to also buy a PD
analyzer). With this series debugging these kinds of things starts to become
fun:

   # echo 1 > /sys/kernel/debug/tracing/events/tps6598x/enable
   # cat /sys/kernel/debug/tracing/trace_pipe
   irq/79-0-003f-526 [003]    512.717871: tps6598x_irq: 
event1=PLUG_EVENT|DATA_STATUS_UPDATE|STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.722408: tps6598x_status: conn: 
conn-Ra, pp_5v0: off, pp_hv: off, pp_ext: off, pp_cable: off, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE
   irq/79-0-003f-526 [003]    512.727127: tps6598x_data_status: 
DATA_CONNECTION|USB2_CONNECTION|USB3_CONNECTION
   irq/79-0-003f-526 [003]    512.769571: tps6598x_irq: 
event1=PP_SWITCH_CHANGED|STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.773380: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    512.872450: tps6598x_irq: 
event1=POWER_STATUS_UPDATE|PD_STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    512.876311: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe0V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    512.880237: tps6598x_power_status: conn: 
1, pwr-role: source, typec: usb, bc: sdp
   irq/79-0-003f-526 [003]    513.072682: tps6598x_irq: 
event1=STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    513.076390: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe5V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.090676: tps6598x_irq: 
event1=ERROR_CANNOT_PROVIDE_PWR, event2=
   irq/79-0-003f-526 [003]    513.094368: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: vSafe5V, usb-host: no, legacy: no, flags: 
PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.109606: tps6598x_irq: 
event1=NEW_CONTRACT_AS_PROVIDER|POWER_STATUS_UPDATE|STATUS_UPDATE|SRC_TRANSITION,
 event2=
   irq/79-0-003f-526 [003]    513.113777: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.117475: tps6598x_power_status: conn: 
1, pwr-role: source, typec: pd, bc: sdp
   irq/79-0-003f-526 [003]    513.137469: tps6598x_irq: 
event1=VDM_RECEIVED, event2=
   irq/79-0-003f-526 [003]    513.141570: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.281926: tps6598x_irq: 
event1=VDM_RECEIVED, event2=
   irq/79-0-003f-526 [003]    513.285638: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.300515: tps6598x_irq: 
event1=VDM_RECEIVED|DATA_STATUS_UPDATE, event2=
   irq/79-0-003f-526 [003]    513.304226: tps6598x_status: conn: 
conn-Ra, pp_5v0: out, pp_hv: off, pp_ext: off, pp_cable: in, pwr-src: vin-3p3, 
vbus: pd, usb-host: no, legacy: no, flags: PLUG_PRESENT|PORTROLE|DATAROLE|VCONN
   irq/79-0-003f-526 [003]    513.308302: tps6598x_data_status: 
DATA_CONNECTION|USB2_CONNECTION|USB3_CONNECTION|DP_CONNECTION, DP pinout D

It should not impose any problems for firmwares that don't have IRQs for the
registers enabled. The trace will then just be missing those events.

Patch is against next-20210210.



Guido Günther (4):
  usb: typec: tps6598x: Add trace event for IRQ events
  usb: typec: tps6598x: Add trace event for status register
  usb: typec: tps6598x: Add trace event for power status register
  usb: typec: tps6598x: Add trace event for data status

 drivers/usb/typec/Makefile |   3 +
 drivers/usb/typec/tps6598x.c   |  66 ---
 drivers/usb/typec/tps6598x.h   | 182 +++
 drivers/usb/typec/tps6598x_trace.h | 283 +
 4 files changed, 508 insertions(+), 26 deletions(-)
 create mode 100644 drivers/usb/typec/tps6598

[PATCH] spi: imx: Don't print error on -EPROBEDEFER

2021-01-18 Thread Guido Günther
This avoids

[0.962538] spi_imx 3082.spi: bitbang start failed with -517

durig driver probe.

Fixes: 8197f489f4c4 ("spi: imx: Fix failure path leak on GPIO request error 
correctly")
Signed-off-by: Guido Günther 
---
 drivers/spi/spi-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 73ca821763d6..5dc4ea4b4450 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -1685,7 +1685,7 @@ static int spi_imx_probe(struct platform_device *pdev)
master->dev.of_node = pdev->dev.of_node;
ret = spi_bitbang_start(_imx->bitbang);
if (ret) {
-   dev_err(>dev, "bitbang start failed with %d\n", ret);
+   dev_err_probe(>dev, ret, "bitbang start failed\n");
goto out_bitbang_start;
}
 
-- 
2.29.2



Re: [PATCH v3 1/4] arm64: defconfig: Enable Librem 5 devkit components

2021-01-11 Thread Guido Günther
Hi,
On Mon, Jan 11, 2021 at 08:23:09AM +0800, Shawn Guo wrote:
> On Fri, Jan 08, 2021 at 01:57:07PM +0100, Guido Günther wrote:
> > The Librem 5 devkit is based on NXP's i.MX8MQ. Schematics are at
> > https://source.puri.sm/Librem5/dvk-mx8m-bsb.
> > 
> > This enables drivers for the following hardware components that aren't
> > yet enabled in defconfig:
> > 
> > - Goodix GT5688 touchscreen
> > - iMX8MQ's PWM for the LCD backlight
> > - TI BQ25896 charge controller
> > - NXP SGTL5000 audio codec
> > - Microcrystal RV-4162-C7 RTC
> > - magnetometer: CONFIG_IIO_ST_MAGN_3AXIS
> > - the SIMCom SIM7100E/A modem
> > - NXP PTN5110HQZ usb-c controller
> > 
> > Signed-off-by: Guido Günther 
> > Reviewed-by: Krzysztof Kozlowski 
> 
> Applied, thanks.

Thanks for applying this series!
 -- Guido


Re: [PATCH] arm64: dts: imx8mq: Add clock parents for mipi dphy

2021-01-10 Thread Guido Günther
Hi,
On Sun, Jan 10, 2021 at 08:46:29PM +0800, Shawn Guo wrote:
> On Fri, Dec 18, 2020 at 06:50:05PM +0100, Guido Günther wrote:
> > This makes sure the clock tree setup for the dphy is not dependent on
> > other components.
> > 
> > Without this change bringing up the display can fail like
> > 
> >   kernel: phy phy-30a00300.dphy.2: Invalid CM/CN/CO values: 165/217/1
> >   kernel: phy phy-30a00300.dphy.2: for hs_clk/ref_clk=451656000/59398 ~ 
> > 165/217
> > 
> > if LCDIF doesn't set up that part of the clock tree first. This was
> > noticed when testing the Librem 5 devkit with defconfig. It doesn't
> > happen when modules are built in.
> > 
> > Signed-off-by: Guido Günther 
> > ---
> >  arch/arm64/boot/dts/freescale/imx8mq.dtsi | 11 ---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
> > b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
> > index a841a023e8e0..ca0847e8f13c 100644
> > --- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
> > +++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
> > @@ -1016,9 +1016,14 @@ dphy: dphy@30a00300 {
> > reg = <0x30a00300 0x100>;
> > clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
> > clock-names = "phy_ref";
> > -   assigned-clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
> > -   assigned-clock-parents = < 
> > IMX8MQ_VIDEO_PLL1_OUT>;
> > -   assigned-clock-rates = <2400>;
> > +   assigned-clocks = < 
> > IMX8MQ_VIDEO_PLL1_REF_SEL>,
> > + < 
> > IMX8MQ_VIDEO_PLL1_BYPASS>,
> > + < IMX8MQ_CLK_DSI_PHY_REF>,
> > + < IMX8MQ_VIDEO_PLL1>;
> 
> You do not seem to set parent or rate on IMX8MQ_VIDEO_PLL1.  Why do you
> have it here?

Good point. I've added a clock rate for IMX8MQ_VIDEO_PLL1 since
then the clock tree reproduces exactly with and with the DSI host
controller disabled in DT (otherwise we end up with a rate of 22MHz
instead of 24Mhz).

Cheers,
 -- Guido

> 
> Shawn
> 
> > +   assigned-clock-parents = < IMX8MQ_CLK_25M>,
> > + < IMX8MQ_VIDEO_PLL1>,
> > + < IMX8MQ_VIDEO_PLL1_OUT>;
> > +   assigned-clock-rates = <0>, <0>, <2400>;
> > #phy-cells = <0>;
> > power-domains = <_mipi>;
> > status = "disabled";
> > -- 
> > 2.29.2
> > 
> 


[PATCH v2] arm64: dts: imx8mq: Add clock parents for mipi dphy

2021-01-10 Thread Guido Günther
This makes sure the clock tree setup for the dphy is not dependent on
other components.

Without this change bringing up the display can fail like

  kernel: phy phy-30a00300.dphy.2: Invalid CM/CN/CO values: 165/217/1
  kernel: phy phy-30a00300.dphy.2: for hs_clk/ref_clk=451656000/59398 ~ 
165/217

if LCDIF doesn't set up that part of the clock tree first. This was
noticed when testing the Librem 5 devkit with defconfig. It doesn't
happen when modules are built in.

Signed-off-by: Guido Günther 

---
Changes from v1:
- as per review comment from Shawn Guo
  https://lore.kernel.org/linux-arm-kernel/20210110124629.GO28365@dragon/
  Set clock rate for IMX8MQ_VIDEO_PLL1 too. Otherwise we end up with
  a close but not exact clock rate.

 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index a841a023e8e0..50ae17f65a51 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -1016,9 +1016,14 @@ dphy: dphy@30a00300 {
reg = <0x30a00300 0x100>;
clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
clock-names = "phy_ref";
-   assigned-clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
-   assigned-clock-parents = < 
IMX8MQ_VIDEO_PLL1_OUT>;
-   assigned-clock-rates = <2400>;
+   assigned-clocks = < 
IMX8MQ_VIDEO_PLL1_REF_SEL>,
+ < 
IMX8MQ_VIDEO_PLL1_BYPASS>,
+ < IMX8MQ_CLK_DSI_PHY_REF>,
+ < IMX8MQ_VIDEO_PLL1>;
+   assigned-clock-parents = < IMX8MQ_CLK_25M>,
+ < IMX8MQ_VIDEO_PLL1>,
+ < IMX8MQ_VIDEO_PLL1_OUT>;
+   assigned-clock-rates = <0>, <0>, <2400>, 
<59400>;
#phy-cells = <0>;
power-domains = <_mipi>;
status = "disabled";
-- 
2.29.2



Re: [PATCH v2 0/4] Config and device tree updates for the Librem 5 devkit

2021-01-10 Thread Guido Günther
Hi Shawn,
On Sun, Jan 10, 2021 at 08:26:18PM +0800, Shawn Guo wrote:
> On Thu, Dec 17, 2020 at 04:13:11PM +0100, Guido Günther wrote:
> > This enables more components to get a working display, panel, audio and
> > sensors. It also updates some device tree bits to make mainline boot.
> > 
> > I've skipped wifi (which needs some more driver work) and devfreq (since 
> > Martin
> > is working on that).
> > 
> > The config changes don't depend on the DT parts so could be applied
> > independently. The series was tested against next-20201214 and i made sure 
> > the
> > defconfig changes also apply on top of shawnguo/imx/defconfig.
> 
> Sorry.  It doesn't apply any more.

v3 of this patch


https://lore.kernel.org/linux-arm-kernel/5636a3d6e3217475e2a479248250d5c0e0a50e26.1610110514.git@sigxcpu.org/)

applies for me on top of


https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git/log/?h=imx/defconfig

(which is at 773fcbcdf9d66b4aec964238b613e93804cba24c) - am i looking at
the wrong tree?

Cheers and sorry for any inconvenience,
 -- Guido


> 
> Shawn
> 


[PATCH v3 1/4] arm64: defconfig: Enable Librem 5 devkit components

2021-01-08 Thread Guido Günther
The Librem 5 devkit is based on NXP's i.MX8MQ. Schematics are at
https://source.puri.sm/Librem5/dvk-mx8m-bsb.

This enables drivers for the following hardware components that aren't
yet enabled in defconfig:

- Goodix GT5688 touchscreen
- iMX8MQ's PWM for the LCD backlight
- TI BQ25896 charge controller
- NXP SGTL5000 audio codec
- Microcrystal RV-4162-C7 RTC
- magnetometer: CONFIG_IIO_ST_MAGN_3AXIS
- the SIMCom SIM7100E/A modem
- NXP PTN5110HQZ usb-c controller

Signed-off-by: Guido Günther 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/configs/defconfig | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 4bb16b93e5d9..078d3d86289f 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -417,6 +417,7 @@ CONFIG_KEYBOARD_IMX_SC_KEY=m
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_TOUCHSCREEN_ATMEL_MXT=m
+CONFIG_TOUCHSCREEN_GOODIX=m
 CONFIG_TOUCHSCREEN_EDT_FT5X06=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
@@ -566,6 +567,7 @@ CONFIG_BATTERY_SBS=m
 CONFIG_BATTERY_BQ27XXX=y
 CONFIG_SENSORS_ARM_SCMI=y
 CONFIG_BATTERY_MAX17042=m
+CONFIG_CHARGER_BQ25890=m
 CONFIG_CHARGER_BQ25980=m
 CONFIG_SENSORS_ARM_SCPI=y
 CONFIG_SENSORS_LM90=m
@@ -747,6 +749,7 @@ CONFIG_SND_SOC_FSL_ASRC=m
 CONFIG_SND_SOC_FSL_MICFIL=m
 CONFIG_SND_SOC_FSL_EASRC=m
 CONFIG_SND_IMX_SOC=m
+CONFIG_SND_SOC_IMX_SGTL5000=m
 CONFIG_SND_SOC_IMX_SPDIF=m
 CONFIG_SND_SOC_IMX_AUDMIX=m
 CONFIG_SND_SOC_FSL_ASOC_CARD=m
@@ -773,6 +776,7 @@ CONFIG_SND_SOC_TEGRA210_ADMAIF=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
+CONFIG_SND_SOC_GTM601=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
 CONFIG_SND_SOC_SIMPLE_AMPLIFIER=m
 CONFIG_SND_SOC_TAS571X=m
@@ -810,6 +814,7 @@ CONFIG_USB_ISP1760=y
 CONFIG_USB_SERIAL=m
 CONFIG_USB_SERIAL_CP210X=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_OPTION=m
 CONFIG_USB_HSIC_USB3503=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_GADGET=y
@@ -829,6 +834,7 @@ CONFIG_USB_CONFIGFS_MASS_STORAGE=y
 CONFIG_USB_CONFIGFS_F_FS=y
 CONFIG_TYPEC=m
 CONFIG_TYPEC_TCPM=m
+CONFIG_TYPEC_TCPCI=m
 CONFIG_TYPEC_FUSB302=m
 CONFIG_TYPEC_HD3SS3220=m
 CONFIG_TYPEC_TPS6598X=m
@@ -879,6 +885,7 @@ CONFIG_RTC_DRV_HYM8563=m
 CONFIG_RTC_DRV_MAX77686=y
 CONFIG_RTC_DRV_RK808=m
 CONFIG_RTC_DRV_PCF85363=m
+CONFIG_RTC_DRV_M41T80=m
 CONFIG_RTC_DRV_RX8581=m
 CONFIG_RTC_DRV_RV8803=m
 CONFIG_RTC_DRV_S5M=y
@@ -1043,11 +1050,13 @@ CONFIG_IIO_ST_LSM6DSX=m
 CONFIG_IIO_CROS_EC_LIGHT_PROX=m
 CONFIG_SENSORS_ISL29018=m
 CONFIG_VCNL4000=m
+CONFIG_IIO_ST_MAGN_3AXIS=m
 CONFIG_IIO_CROS_EC_BARO=m
 CONFIG_MPL3115=m
 CONFIG_PWM=y
 CONFIG_PWM_BCM2835=m
 CONFIG_PWM_CROS_EC=m
+CONFIG_PWM_IMX27=m
 CONFIG_PWM_MESON=m
 CONFIG_PWM_RCAR=m
 CONFIG_PWM_ROCKCHIP=y
-- 
2.29.2



[PATCH v3 2/4] arm64: dts: imx8mq-librem5-devkit: Tweak pmic regulators

2021-01-08 Thread Guido Günther
BUCK3 needs a regulator-enable-ramp-delay since otherwise the board
freezes on etnaviv probe. With this pgc_gpu suspends and resumes as
expected. This must have been always broken since gpcv2 support was
enabled.

We also enable all the regulators needed for Deep Sleep Mode (DSM) as
always-on:

- VDD_SOC supplied by BUCK1
- VDDA_1P8 supplied by BUCK7
- VDDA_0P9 supplied by LDO4
- VDDA_DRAM supplied by LDO3
- NVCC_DRAM supplied by BUCK8
- VDD_DRAM supplied by BUCK5

Finally LDO5 and LDO6 provide VDD_PHY_1V8 and VDD_PHY_0V9 used by the
SOCs MIPI, HDMI and USB IP cores. While we would in theory be able to
turn these off (and I've tested that or LDO6 and mipi with USB disabled)
it is of little practical use atm since USB doesn't runtime suspend so
let's revisit this at a later point.

Signed-off-by: Guido Günther 
Reviewed-by: Krzysztof Kozlowski 
---
 .../boot/dts/freescale/imx8mq-librem5-devkit.dts  | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index af139b283daf..f35d6897fbf7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -298,6 +298,7 @@ buck1_reg: BUCK1 {
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
regulator-boot-on;
+   regulator-always-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <90>;
rohm,dvs-idle-voltage = <85>;
@@ -319,6 +320,7 @@ buck3_reg: BUCK3 {
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
regulator-boot-on;
+   regulator-enable-ramp-delay = <200>;
rohm,dvs-run-voltage = <90>;
};
 
@@ -334,6 +336,7 @@ buck5_reg: BUCK5 {
regulator-min-microvolt = <70>;
regulator-max-microvolt = <135>;
regulator-boot-on;
+   regulator-always-on;
};
 
buck6_reg: BUCK6 {
@@ -341,6 +344,7 @@ buck6_reg: BUCK6 {
regulator-min-microvolt = <300>;
regulator-max-microvolt = <330>;
regulator-boot-on;
+   regulator-always-on;
};
 
buck7_reg: BUCK7 {
@@ -348,6 +352,7 @@ buck7_reg: BUCK7 {
regulator-min-microvolt = <1605000>;
regulator-max-microvolt = <1995000>;
regulator-boot-on;
+   regulator-always-on;
};
 
buck8_reg: BUCK8 {
@@ -355,6 +360,7 @@ buck8_reg: BUCK8 {
regulator-min-microvolt = <80>;
regulator-max-microvolt = <140>;
regulator-boot-on;
+   regulator-always-on;
};
 
ldo1_reg: LDO1 {
@@ -380,6 +386,7 @@ ldo3_reg: LDO3 {
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
regulator-boot-on;
+   regulator-always-on;
};
 
ldo4_reg: LDO4 {
@@ -387,12 +394,14 @@ ldo4_reg: LDO4 {
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
regulator-boot-on;
+   regulator-always-on;
};
 
ldo5_reg: LDO5 {
regulator-name = "ldo5";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
+   regulator-always-on;
};
 
ldo6_reg: LDO6 {
@@ -400,6 +409,7 @@ ldo6_reg: LDO6 {
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
regulator-boot-on;
+   regulator-always-on;
  

[PATCH v3 4/4] arm64: dts: imx8mq-librem5-devkit: Drop custom clock settings

2021-01-08 Thread Guido Günther
Otherwise the boot hangs early on and the resulting clock tree without
this already closely matches the selected rates (722534400 and
786432000).

  audio_pll2  000   722534397  0 0  
5
 audio_pll2_bypass000   722534397  0 0  
5
audio_pll2_out000   722534397  0 0  
5
  audio_pll1  110   786431998  0 0  
5
 audio_pll1_bypass110   786431998  0 0  
5
audio_pll1_out110   786431998  0 0  
5
   sai2   11024576000  0 0  
5
  sai2_root_clk   11024576000  0
 0  5
   sai6   00024576000  0 0  
5
  sai6_root_clk   00024576000  0
 0  5

Signed-off-by: Guido Günther 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index 05a43ee6d051..dd217a0760e9 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -244,11 +244,6 @@ _3 {
cpu-supply = <_reg>;
 };
 
- {
-   assigned-clocks = < IMX8MQ_AUDIO_PLL1>, < IMX8MQ_AUDIO_PLL2>;
-   assigned-clock-rates = <786432000>, <722534400>;
-};
-
  {
status = "okay";
 };
-- 
2.29.2



[PATCH v3 3/4] arm64: dts: imx8mq-librem5-devkit: Disable snvs_rtc

2021-01-08 Thread Guido Günther
The board has it's own RTC chip which is backed by the (optional)
battery and hence preserves data/time on poweroff when that is inserted.

Signed-off-by: Guido Günther 
Reviewed-by: Krzysztof Kozlowski 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index f35d6897fbf7..05a43ee6d051 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -897,6 +897,10 @@ _pwrkey {
status = "okay";
 };
 
+_rtc {
+   status = "disabled";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_sai2>;
-- 
2.29.2



[PATCH v3 0/4] Config and device tree updates for the Librem 5 development kit

2021-01-08 Thread Guido Günther
This enables more components to get a working display, panel, audio and
sensors. It also updates some device tree bits to make mainline boot.

I've skipped wifi (which needs some more driver work) and devfreq (since Martin
is working on that).

The config changes don't depend on the DT parts so could be applied
independently. The series was tested against next-20200108 and i made sure the
defconfig changes also apply on top of Shawn's /imx/defconfig and the DT
changes to Shawn's imx/dt64.

changes from v2:
- Add Reviewed-by from Krzysztof Kozlowski, thanks!
- Add NXP PTN5110HQZ to defconfig

changes from v1:
- as per review comments by Krzysztof Kozlowski 
  https://lore.kernel.org/linux-arm-kernel/20201215091729.GC29321@kozik-lap/
  - describe hardware parts not config options
  - rework commit messages to give more details
- don't keep buck3 always on but rather make sure the board
  doesn't hang when resuming the gpu power domain.
  There's a generic fix pending for that helps all boards
  
https://lore.kernel.org/lkml/beba25e85db20649aa040fc0ae549895c9265f6f.ca...@fi.rohmeurope.com/

Guido Günther (4):
  arm64: defconfig: Enable Librem 5 devkit components
  arm64: dts: imx8mq-librem5-devkit: Tweak pmic regulators
  arm64: dts: imx8mq-librem5-devkit: Disable snvs_rtc
  arm64: dts: imx8mq-librem5-devkit: Drop custom clock settings

 .../dts/freescale/imx8mq-librem5-devkit.dts   | 20 ++-
 arch/arm64/configs/defconfig  |  9 +
 2 files changed, 24 insertions(+), 5 deletions(-)

-- 
2.29.2



Re: [PATCH v2] regulators: bd718x7: Add enable times

2020-12-21 Thread Guido Günther
Hi,
On Mon, Dec 21, 2020 at 06:08:15AM +, Vaittinen, Matti wrote:
> 
> On Fri, 2020-12-18 at 19:38 +0100, Guido Günther wrote:
> > Use the typical startup times from the data sheet so boards get a
> > reasonable default. Not setting any enable time can lead to board
> > hangs
> > when e.g. clocks are enabled too soon afterwards.
> > 
> > This fixes gpu power domain resume on the Librem 5.
> > 
> > Signed-off-by: Guido Günther 
> > 
> > ---
> > v2
> > - As per review comment by Matti Vaittinen
> >   
> > https://lore.kernel.org/lkml/beba25e85db20649aa040fc0ae549895c9265f6f.ca...@fi.rohmeurope.com/
> >   Use defines instead of plain values
> > - As per review comment by Mark Brown
> >   https://lore.kernel.org/lkml/20201216130637.gc4...@sirena.org.uk/
> >   Drop cover letter
> > ---
> >  drivers/regulator/bd718x7-regulator.c | 27 
> >  include/linux/mfd/rohm-bd718x7.h  | 30 
> 
> Thanks again Guido.
> I might have preferred having the defines in bd718x7-regulator.c as
> they are not likely to be used outside this file. That would have

In fact that's where I had them first, then noticing other regulator
related defines in the mfd header. I can shift those around need be.
Cheers,
 -- Guido

> strictly limited the change to regulator subsystem. Having them in the
> header is still fine with me if it works for Mark & others. (I don't
> think these defines need much of changes in the future).
> 
> Reviewed-by: Matti Vaittinen 
> 
> 
> Best Regards
>  Matti Vaittinen
> 


[PATCH v2] regulators: bd718x7: Add enable times

2020-12-18 Thread Guido Günther
Use the typical startup times from the data sheet so boards get a
reasonable default. Not setting any enable time can lead to board hangs
when e.g. clocks are enabled too soon afterwards.

This fixes gpu power domain resume on the Librem 5.

Signed-off-by: Guido Günther 

---
v2
- As per review comment by Matti Vaittinen
  
https://lore.kernel.org/lkml/beba25e85db20649aa040fc0ae549895c9265f6f.ca...@fi.rohmeurope.com/
  Use defines instead of plain values
- As per review comment by Mark Brown
  https://lore.kernel.org/lkml/20201216130637.gc4...@sirena.org.uk/
  Drop cover letter
---
 drivers/regulator/bd718x7-regulator.c | 27 
 include/linux/mfd/rohm-bd718x7.h  | 30 +++
 2 files changed, 57 insertions(+)

diff --git a/drivers/regulator/bd718x7-regulator.c 
b/drivers/regulator/bd718x7-regulator.c
index e6d5d98c3cea..f7597832d2c5 100644
--- a/drivers/regulator/bd718x7-regulator.c
+++ b/drivers/regulator/bd718x7-regulator.c
@@ -613,6 +613,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK1_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = BD71847_BUCK1_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -646,6 +647,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK2_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = BD71847_BUCK2_STARTUP_TIME,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -680,6 +682,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.linear_range_selectors = bd71847_buck3_volt_range_sel,
.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = BD71847_BUCK3_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -706,6 +709,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
.linear_range_selectors = bd71847_buck4_volt_range_sel,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = BD71847_BUCK4_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -727,6 +731,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = BD71847_BUCK5_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -750,6 +755,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = BD71847_BUCK6_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -775,6 +781,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
.enable_reg = BD718XX_REG_LDO1_VOLT,
.enable_mask = BD718XX_LDO_EN,
+   .enable_time = BD71847_LDO1_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -796,6 +803,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.n_voltages = ARRAY_SIZE(ldo_2_volts),
.enable_reg = BD718XX_REG_LDO2_VOLT,
.enable_mask = BD718XX_LDO_EN,
+   .enable_time = BD71847_LDO2_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -818,6 +826,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = BD718XX_LDO3_MASK,
.enable_reg = BD718XX_REG_LDO3_VOLT,
.enable_mask = BD718XX_LDO_EN,
+   .enable_time = BD71847_LDO3_STARTUP_TIME,
.owner = THIS_MODULE,
},
.init = {
@@ -840,6 +849,7 @@ static struct bd718xx_regulator_data bd71847_regulators

[PATCH] arm64: dts: imx8mq: Add clock parents for mipi dphy

2020-12-18 Thread Guido Günther
This makes sure the clock tree setup for the dphy is not dependent on
other components.

Without this change bringing up the display can fail like

  kernel: phy phy-30a00300.dphy.2: Invalid CM/CN/CO values: 165/217/1
  kernel: phy phy-30a00300.dphy.2: for hs_clk/ref_clk=451656000/59398 ~ 
165/217

if LCDIF doesn't set up that part of the clock tree first. This was
noticed when testing the Librem 5 devkit with defconfig. It doesn't
happen when modules are built in.

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
index a841a023e8e0..ca0847e8f13c 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
@@ -1016,9 +1016,14 @@ dphy: dphy@30a00300 {
reg = <0x30a00300 0x100>;
clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
clock-names = "phy_ref";
-   assigned-clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
-   assigned-clock-parents = < 
IMX8MQ_VIDEO_PLL1_OUT>;
-   assigned-clock-rates = <2400>;
+   assigned-clocks = < 
IMX8MQ_VIDEO_PLL1_REF_SEL>,
+ < 
IMX8MQ_VIDEO_PLL1_BYPASS>,
+ < IMX8MQ_CLK_DSI_PHY_REF>,
+ < IMX8MQ_VIDEO_PLL1>;
+   assigned-clock-parents = < IMX8MQ_CLK_25M>,
+ < IMX8MQ_VIDEO_PLL1>,
+ < IMX8MQ_VIDEO_PLL1_OUT>;
+   assigned-clock-rates = <0>, <0>, <2400>;
#phy-cells = <0>;
power-domains = <_mipi>;
status = "disabled";
-- 
2.29.2



[PATCH v1 3/3] arm64: defconfig: Enable more DM/MD targets as modules

2020-12-18 Thread Guido Günther
Most notably DM_CRYPT for disk encryption but things like snapshot, etc.
are useful on embedded as well and the others make sense on arm64
servers.

CONFIG_BLK_DEV_MD gets dropped because other config options like
CONFIG_MD_RAID0 depend on it.

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 6f5f03237db6..060bebe0d35d 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -296,10 +296,27 @@ CONFIG_SATA_RCAR=y
 CONFIG_PATA_PLATFORM=y
 CONFIG_PATA_OF_PLATFORM=y
 CONFIG_MD=y
-CONFIG_BLK_DEV_MD=m
 CONFIG_BLK_DEV_DM=m
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_THIN_PROVISIONING=m
+CONFIG_DM_WRITECACHE=m
 CONFIG_DM_MIRROR=m
+CONFIG_DM_LOG_USERSPACE=m
+CONFIG_DM_RAID=m
 CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+CONFIG_DM_MULTIPATH_QL=m
+CONFIG_DM_MULTIPATH_ST=m
+CONFIG_DM_MULTIPATH_HST=m
+CONFIG_DM_MULTIPATH_IOA=m
+CONFIG_DM_DELAY=m
+CONFIG_DM_DUST=m
+CONFIG_DM_UEVENT=y
+CONFIG_DM_FLAKEY=m
+CONFIG_DM_VERITY=m
+CONFIG_DM_LOG_WRITES=m
+CONFIG_DM_INTEGRITY=m
 CONFIG_NETDEVICES=y
 CONFIG_MACVLAN=m
 CONFIG_MACVTAP=m
-- 
2.29.2



[PATCH v1 2/3] arm64: defconfig: Enable more filesystems

2020-12-18 Thread Guido Günther
xfs, f2fs and iso are common enough to have them everywhere.

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index e42ba0c8f302..6f5f03237db6 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1092,8 +1092,10 @@ CONFIG_INTERCONNECT_QCOM_SM8250=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT3_FS=y
 CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
 CONFIG_BTRFS_FS=m
 CONFIG_BTRFS_FS_POSIX_ACL=y
+CONFIG_F2FS_FS=m
 CONFIG_FANOTIFY=y
 CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
 CONFIG_QUOTA=y
@@ -1101,6 +1103,9 @@ CONFIG_AUTOFS4_FS=y
 CONFIG_FUSE_FS=m
 CONFIG_CUSE=m
 CONFIG_OVERLAY_FS=m
+CONFIG_ISO9660_FS=m
+CONFIG_JOLIET=y
+CONFIG_UDF_FS=m
 CONFIG_VFAT_FS=y
 CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=y
-- 
2.29.2



[PATCH v1 0/3] arm64: defconfig: Enable some (hopefully) useful options

2020-12-18 Thread Guido Günther
The aim of this series is make the arm64 'make defconfig' kernel more useful
for debugging and daily usage. I'm aware that expectations there diff widely so
I went for things I found in other defconigs as well.

It enables ftrace, more filesystems and more dm/md modules.

Since it's not board specific I have no idea which tree I would target so I
picked next-20201218.

Guido Günther (3):
  arm64: defconfig: Enable function tracer
  arm64: defconfig: Enable more filesystems
  arm64: defconfig: Enable more DM/MD targets as modules

 arch/arm64/configs/defconfig | 26 --
 1 file changed, 24 insertions(+), 2 deletions(-)

-- 
2.29.2



[PATCH v1 1/3] arm64: defconfig: Enable function tracer

2020-12-18 Thread Guido Günther
This allows for way easier runtime inspection and debugging.

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index e7aef72206e3..e42ba0c8f302 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1135,5 +1135,5 @@ CONFIG_DEBUG_FS=y
 CONFIG_DEBUG_KERNEL=y
 # CONFIG_SCHED_DEBUG is not set
 # CONFIG_DEBUG_PREEMPT is not set
-# CONFIG_FTRACE is not set
+CONFIG_FUNCTION_TRACER=y
 CONFIG_MEMTEST=y
-- 
2.29.2



[PATCH v2 2/4] arm64: dts: imx8mq-librem5-devkit: Tweak pmic regulators

2020-12-17 Thread Guido Günther
BUCK3 needs a regulator-enable-ramp-delay since otherwise the board
freezes on etnaviv probe. With this pgc_gpu suspends and resumes as
expected. This must have been always broken since gpcv2 support was
enabled.

We also enable all the regulators needed for Deep Sleep Mode (DSM) as
always-on:

- VDD_SOC supplied by BUCK1
- VDDA_1P8 supplied by BUCK7
- VDDA_0P9 supplied by LDO4
- VDDA_DRAM supplied by LDO3
- NVCC_DRAM supplied by BUCK8
- VDD_DRAM supplied by BUCK5

Finally LDO5 and LDO6 provide VDD_PHY_1V8 and VDD_PHY_0V9 used by the
SOCs MIPI, HDMI and USB IP cores. While we would in theory be able to
turn these off (and I've tested that or LDO6 and mipi with USB disabled)
it is of little practical use atm since USB doesn't runtime suspend so
let's revisit this at a later point.

Signed-off-by: Guido Günther 
---
 .../boot/dts/freescale/imx8mq-librem5-devkit.dts  | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index af139b283daf..f35d6897fbf7 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -298,6 +298,7 @@ buck1_reg: BUCK1 {
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
regulator-boot-on;
+   regulator-always-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <90>;
rohm,dvs-idle-voltage = <85>;
@@ -319,6 +320,7 @@ buck3_reg: BUCK3 {
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
regulator-boot-on;
+   regulator-enable-ramp-delay = <200>;
rohm,dvs-run-voltage = <90>;
};
 
@@ -334,6 +336,7 @@ buck5_reg: BUCK5 {
regulator-min-microvolt = <70>;
regulator-max-microvolt = <135>;
regulator-boot-on;
+   regulator-always-on;
};
 
buck6_reg: BUCK6 {
@@ -341,6 +344,7 @@ buck6_reg: BUCK6 {
regulator-min-microvolt = <300>;
regulator-max-microvolt = <330>;
regulator-boot-on;
+   regulator-always-on;
};
 
buck7_reg: BUCK7 {
@@ -348,6 +352,7 @@ buck7_reg: BUCK7 {
regulator-min-microvolt = <1605000>;
regulator-max-microvolt = <1995000>;
regulator-boot-on;
+   regulator-always-on;
};
 
buck8_reg: BUCK8 {
@@ -355,6 +360,7 @@ buck8_reg: BUCK8 {
regulator-min-microvolt = <80>;
regulator-max-microvolt = <140>;
regulator-boot-on;
+   regulator-always-on;
};
 
ldo1_reg: LDO1 {
@@ -380,6 +386,7 @@ ldo3_reg: LDO3 {
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
regulator-boot-on;
+   regulator-always-on;
};
 
ldo4_reg: LDO4 {
@@ -387,12 +394,14 @@ ldo4_reg: LDO4 {
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
regulator-boot-on;
+   regulator-always-on;
};
 
ldo5_reg: LDO5 {
regulator-name = "ldo5";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
+   regulator-always-on;
};
 
ldo6_reg: LDO6 {
@@ -400,6 +409,7 @@ ldo6_reg: LDO6 {
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
regulator-boot-on;
+   regulator-always-on;
 

[PATCH v2 1/4] arm64: defconfig: Enable Librem 5 devkit components

2020-12-17 Thread Guido Günther
The Librem 5 devkit is based on NXP's i.MX8MQ. Schematics are at
https://source.puri.sm/Librem5/dvk-mx8m-bsb.

This enables drivers for the following hardware components that aren't
yet enabled in defconfig:

- Goodix GT5688 touchscreen
- iMX8MQ's PWM for the LCD backlight
- TI BQ25896 charge controller
- NXP SGTL5000 audio codec
- Microcrystal RV-4162-C7 RTC
- magnetometer: CONFIG_IIO_ST_MAGN_3AXIS
- the SIMCom SIM7100E/A modem

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 5fc7f86d62f9..9bdca86bc320 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -417,6 +417,7 @@ CONFIG_KEYBOARD_IMX_SC_KEY=m
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_TOUCHSCREEN_ATMEL_MXT=m
+CONFIG_TOUCHSCREEN_GOODIX=m
 CONFIG_TOUCHSCREEN_EDT_FT5X06=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
@@ -566,6 +567,7 @@ CONFIG_BATTERY_SBS=m
 CONFIG_BATTERY_BQ27XXX=y
 CONFIG_SENSORS_ARM_SCMI=y
 CONFIG_BATTERY_MAX17042=m
+CONFIG_CHARGER_BQ25890=m
 CONFIG_CHARGER_BQ25980=m
 CONFIG_SENSORS_ARM_SCPI=y
 CONFIG_SENSORS_LM90=m
@@ -747,6 +749,7 @@ CONFIG_SND_SOC_FSL_ASRC=m
 CONFIG_SND_SOC_FSL_MICFIL=m
 CONFIG_SND_SOC_FSL_EASRC=m
 CONFIG_SND_IMX_SOC=m
+CONFIG_SND_SOC_IMX_SGTL5000=m
 CONFIG_SND_SOC_IMX_SPDIF=m
 CONFIG_SND_SOC_IMX_AUDMIX=m
 CONFIG_SND_MESON_AXG_SOUND_CARD=m
@@ -772,6 +775,7 @@ CONFIG_SND_SOC_TEGRA210_ADMAIF=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
+CONFIG_SND_SOC_GTM601=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
 CONFIG_SND_SOC_SIMPLE_AMPLIFIER=m
 CONFIG_SND_SOC_TAS571X=m
@@ -807,6 +811,7 @@ CONFIG_USB_ISP1760=y
 CONFIG_USB_SERIAL=m
 CONFIG_USB_SERIAL_CP210X=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_OPTION=m
 CONFIG_USB_HSIC_USB3503=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_GADGET=y
@@ -876,6 +881,7 @@ CONFIG_RTC_DRV_HYM8563=m
 CONFIG_RTC_DRV_MAX77686=y
 CONFIG_RTC_DRV_RK808=m
 CONFIG_RTC_DRV_PCF85363=m
+CONFIG_RTC_DRV_M41T80=m
 CONFIG_RTC_DRV_RX8581=m
 CONFIG_RTC_DRV_RV8803=m
 CONFIG_RTC_DRV_S5M=y
@@ -1040,11 +1046,13 @@ CONFIG_IIO_ST_LSM6DSX=m
 CONFIG_IIO_CROS_EC_LIGHT_PROX=m
 CONFIG_SENSORS_ISL29018=m
 CONFIG_VCNL4000=m
+CONFIG_IIO_ST_MAGN_3AXIS=m
 CONFIG_IIO_CROS_EC_BARO=m
 CONFIG_MPL3115=m
 CONFIG_PWM=y
 CONFIG_PWM_BCM2835=m
 CONFIG_PWM_CROS_EC=m
+CONFIG_PWM_IMX27=m
 CONFIG_PWM_MESON=m
 CONFIG_PWM_RCAR=m
 CONFIG_PWM_ROCKCHIP=y
-- 
2.29.2



[PATCH v2 4/4] arm64: dts: imx8mq-librem5-devkit: Drop custom clock settings

2020-12-17 Thread Guido Günther
Otherwise the boot hangs early on and the resulting clock tree without
this already closely matches the selected rates (722534400 and
786432000).

  audio_pll2  000   722534397  0 0  
5
 audio_pll2_bypass000   722534397  0 0  
5
audio_pll2_out000   722534397  0 0  
5
  audio_pll1  110   786431998  0 0  
5
 audio_pll1_bypass110   786431998  0 0  
5
audio_pll1_out110   786431998  0 0  
5
   sai2   11024576000  0 0  
5
  sai2_root_clk   11024576000  0
 0  5
   sai6   00024576000  0 0  
5
  sai6_root_clk   00024576000  0
 0  5

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index 05a43ee6d051..dd217a0760e9 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -244,11 +244,6 @@ _3 {
cpu-supply = <_reg>;
 };
 
- {
-   assigned-clocks = < IMX8MQ_AUDIO_PLL1>, < IMX8MQ_AUDIO_PLL2>;
-   assigned-clock-rates = <786432000>, <722534400>;
-};
-
  {
status = "okay";
 };
-- 
2.29.2



[PATCH v2 3/4] arm64: dts: imx8mq-librem5-devkit: Disable snvs_rtc

2020-12-17 Thread Guido Günther
The board has it's own RTC chip which is backed by the (optional)
battery and hence preserves data/time on poweroff when that is inserted.

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index f35d6897fbf7..05a43ee6d051 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -897,6 +897,10 @@ _pwrkey {
status = "okay";
 };
 
+_rtc {
+   status = "disabled";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_sai2>;
-- 
2.29.2



[PATCH v2 0/4] Config and device tree updates for the Librem 5 devkit

2020-12-17 Thread Guido Günther
This enables more components to get a working display, panel, audio and
sensors. It also updates some device tree bits to make mainline boot.

I've skipped wifi (which needs some more driver work) and devfreq (since Martin
is working on that).

The config changes don't depend on the DT parts so could be applied
independently. The series was tested against next-20201214 and i made sure the
defconfig changes also apply on top of shawnguo/imx/defconfig.

changes from v1:
- as per review comments by Krzysztof Kozlowski 
  https://lore.kernel.org/linux-arm-kernel/20201215091729.GC29321@kozik-lap/
  - describe hardware parts not config options
  - rework commit messages to give more details
- don't keep buck3 always on but rather make sure the board
  doesn't hang when resuming the gpu power domain.
  There's a generic fix pending for that helps all boards
  
https://lore.kernel.org/lkml/beba25e85db20649aa040fc0ae549895c9265f6f.ca...@fi.rohmeurope.com/

To: Rob Herring ,Shawn Guo ,Sascha 
Hauer ,Pengutronix Kernel Team 
,Fabio Estevam ,NXP Linux Team 
,Catalin Marinas ,Will Deacon 
,Martin Kepplinger ,Angus Ainslie 
,Krzysztof Kozlowski ,Bjorn Andersson 
,Li Yang ,Geert Uytterhoeven 
,Vinod Koul ,Anson Huang 
,Michael Walle 
,devicet...@vger.kernel.org,linux-arm-ker...@lists.infradead.org,linux-kernel@vger.kernel.org,phone-de...@vger.kernel.org

Guido Günther (4):
  arm64: defconfig: Enable Librem 5 devkit components
  arm64: dts: imx8mq-librem5-devkit: Tweak pmic regulators
  arm64: dts: imx8mq-librem5-devkit: Disable snvs_rtc
  arm64: dts: imx8mq-librem5-devkit: Drop custom clock settings

 .../dts/freescale/imx8mq-librem5-devkit.dts   | 20 ++-
 arch/arm64/configs/defconfig  |  8 
 2 files changed, 23 insertions(+), 5 deletions(-)

-- 
2.29.2



Re: [PATCH v2 1/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2020-12-16 Thread Guido Günther
Hi Lucas,
On Wed, Dec 16, 2020 at 01:05:36PM +0100, Lucas Stach wrote:
> Hi Guido,
> 
> this time hopefully with less broken quoting. My mailer is driving me
> mad right now...
> 
> Am Mittwoch, dem 16.12.2020 um 12:27 +0100 schrieb Guido Günther:
> > This allows us to shut down the mipi power domain on the imx8. The
> > alternative would be to drop the dphy from the mipi power domain in the
> > SOCs device tree and only have the DSI host controller visible there but
> > since the PD is mostly about the PHY that would defeat it's purpose.
> 
> Adding RPM support is exactly the right course of action.

Thanks for confirming!

> 
> > This allows to shut off the power domain hen blanking the LCD panel:
> > 
> > pm_genpd_summary before:
> > 
> > domain  status  slaves
> > /device runtime status
> > --
> > mipion
> > /devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
> > /devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended
> > 
> > after:
> > 
> > mipioff-0
> > /devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
> > /devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended
> > 
> > Signed-off-by: Guido Günther 
> > ---
> >  .../phy/freescale/phy-fsl-imx8-mipi-dphy.c| 22 ++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
> > b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > index a95572b397ca..34e2d801e520 100644
> > --- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > +++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > @@ -14,6 +14,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  
> >  /* DPHY registers */
> > @@ -93,6 +94,7 @@ struct mixel_dphy_cfg {
> >  };
> >  
> >  struct mixel_dphy_priv {
> > +   struct device *dev;
> >     struct mixel_dphy_cfg cfg;
> >     struct regmap *regmap;
> >     struct clk *phy_ref_clk;
> > @@ -382,6 +384,7 @@ static int mixel_dphy_power_on(struct phy *phy)
> >     ret = clk_prepare_enable(priv->phy_ref_clk);
> >     if (ret < 0)
> >     return ret;
> > +   pm_runtime_get_sync(priv->dev);
> >  
> 
> This call can fail and will leave you with an elevated rpm refcount.
> Better use the new pm_runtime_resume_and_get to avoid this issue?

pm_runtime_resume_and_get is a nice API addition indeed.

I added the error handling but opted to stay with `pm_runtime_get_sync`
in this case since the error path already has a pm_runtime_put() hence
avoiding another goto target.

> 
> Nitpick: I would add a blank line before the call.

Done.

Thanks for having a look!
 -- Guido

> 
> Regards,
> Lucas
> 


[PATCH v3 0/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2020-12-16 Thread Guido Günther
This allows us to shut down the mipi power domain on the imx8. The alternative
would be to drop the dphy from the mipi power domain in the SOCs device tree
and only have the DSI host controller visible there but since the PD is mostly
about the PHY that would defeat it's purpose.

This is basically a resend from February 2020 which went without feedback.

This allows to shut off the power domain hen blanking the LCD panel:

pm_genpd_summary before:

domain  status  slaves
/device runtime status
--
mipion
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

after:

mipioff-0
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

Changes from v1:
 - Tweak commit message slightly

Changes from v2:
  - As pre review comment by Lucas Stach

https://lore.kernel.org/linux-arm-kernel/ee22b072e0abe07559a3e6a63ccf6ece064a46cb.ca...@pengutronix.de/
Check for pm_runtime_get_sync failure

Guido Günther (1):
  phy: fsl-imx8-mipi-dphy: Hook into runtime pm

 .../phy/freescale/phy-fsl-imx8-mipi-dphy.c| 25 ++-
 1 file changed, 24 insertions(+), 1 deletion(-)

-- 
2.29.2



Re: [PATCH 1/1] regulators: bd718x7: Add enable times

2020-12-16 Thread Guido Günther
Hi Matti,
On Wed, Dec 16, 2020 at 12:29:20PM +, Vaittinen, Matti wrote:
> Hello Guido,
> 
> Thanks for looking at this!
> 
> On Wed, 2020-12-16 at 12:05 +0100, Guido Günther wrote:
> > Use the typical startup times from the data sheet so boards get a
> > reasonable default. Not setting any enable time can lead to board
> > hangs
> > when e.g. clocks are enabled too soon afterwards.
> > 
> > This fixes gpu power domain resume on the Librem 5.
> > 
> > Signed-off-by: Guido Günther 
> > ---
> >  drivers/regulator/bd718x7-regulator.c | 27
> > +++
> >  1 file changed, 27 insertions(+)
> > 
> > diff --git a/drivers/regulator/bd718x7-regulator.c
> > b/drivers/regulator/bd718x7-regulator.c
> > index e6d5d98c3cea..d6d34aa4ee2e 100644
> > --- a/drivers/regulator/bd718x7-regulator.c
> > +++ b/drivers/regulator/bd718x7-regulator.c
> > @@ -613,6 +613,7 @@ static struct bd718xx_regulator_data
> > bd71847_regulators[] = {
> > .vsel_mask = DVS_BUCK_RUN_MASK,
> > .enable_reg = BD718XX_REG_BUCK1_CTRL,
> > .enable_mask = BD718XX_BUCK_EN,
> > +   .enable_time = 144,
> 
> Where are these values obtained from? I have a feeling they might be
> board / load specific. If this is the case - can the "regulator-enable-
> ramp-delay" from device-tree be used instead to avoid hard-coding board
> specific values in the driver? Although, sane defaults would probably
> not be a bad idea - if I read code correctly then the constrains from
> DT can be used to override these values.

They're the 'typical values' from the data sheet and it's basically all
about setting a default for "regulator-enable-ramp-delay" to avoid
having every board do the same. If that's not the right thing todo let
me know and i add these to each of our boards (which is where i
basically started from but then figured that this would be busywork
and every board would hit that problem).

> I'd prefer well named defines over raw numeric values though.

So s.th. like

BD71837_BUCK1_STARTUP_TIME 144

(using the terminology from the datasheet)? If that works I'll send a
v2.

Cheers,
 --Guido

> 
> Best Regards
> Matti Vaittinen
> 
> 


[PATCH v2 1/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2020-12-16 Thread Guido Günther
This allows us to shut down the mipi power domain on the imx8. The
alternative would be to drop the dphy from the mipi power domain in the
SOCs device tree and only have the DSI host controller visible there but
since the PD is mostly about the PHY that would defeat it's purpose.

This allows to shut off the power domain hen blanking the LCD panel:

pm_genpd_summary before:

domain  status  slaves
/device runtime status
--
mipion
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

after:

mipioff-0
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

Signed-off-by: Guido Günther 
---
 .../phy/freescale/phy-fsl-imx8-mipi-dphy.c| 22 ++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
index a95572b397ca..34e2d801e520 100644
--- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
+++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 /* DPHY registers */
@@ -93,6 +94,7 @@ struct mixel_dphy_cfg {
 };
 
 struct mixel_dphy_priv {
+   struct device *dev;
struct mixel_dphy_cfg cfg;
struct regmap *regmap;
struct clk *phy_ref_clk;
@@ -382,6 +384,7 @@ static int mixel_dphy_power_on(struct phy *phy)
ret = clk_prepare_enable(priv->phy_ref_clk);
if (ret < 0)
return ret;
+   pm_runtime_get_sync(priv->dev);
 
phy_write(phy, PWR_ON, DPHY_PD_PLL);
ret = regmap_read_poll_timeout(priv->regmap, DPHY_LOCK, locked,
@@ -395,6 +398,7 @@ static int mixel_dphy_power_on(struct phy *phy)
 
return 0;
 clock_disable:
+   pm_runtime_put(priv->dev);
clk_disable_unprepare(priv->phy_ref_clk);
return ret;
 }
@@ -406,6 +410,7 @@ static int mixel_dphy_power_off(struct phy *phy)
phy_write(phy, PWR_OFF, DPHY_PD_PLL);
phy_write(phy, PWR_OFF, DPHY_PD_DPHY);
 
+   pm_runtime_put(priv->dev);
clk_disable_unprepare(priv->phy_ref_clk);
 
return 0;
@@ -467,6 +472,7 @@ static int mixel_dphy_probe(struct platform_device *pdev)
dev_dbg(dev, "phy_ref clock rate: %lu\n",
clk_get_rate(priv->phy_ref_clk));
 
+   priv->dev = dev;
dev_set_drvdata(dev, priv);
 
phy = devm_phy_create(dev, np, _dphy_phy_ops);
@@ -477,12 +483,26 @@ static int mixel_dphy_probe(struct platform_device *pdev)
phy_set_drvdata(phy, priv);
 
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
+   if (IS_ERR(phy_provider))
+   return PTR_ERR(phy_provider);
 
-   return PTR_ERR_OR_ZERO(phy_provider);
+   pm_runtime_enable(dev);
+
+   return 0;
+}
+
+static int mixel_dphy_remove(struct platform_device *pdev)
+{
+   struct mixel_dphy_priv *priv = platform_get_drvdata(pdev);
+
+   pm_runtime_disable(priv->dev);
+
+   return 0;
 }
 
 static struct platform_driver mixel_dphy_driver = {
.probe  = mixel_dphy_probe,
+   .remove = mixel_dphy_remove,
.driver = {
.name = "mixel-mipi-dphy",
.of_match_table = mixel_dphy_of_match,
-- 
2.29.2



[PATCH v2 0/1] phy: fsl-imx8-mipi-dphy: Hook into runtime pm

2020-12-16 Thread Guido Günther
This allows us to shut down the mipi power domain on the imx8. The alternative
would be to drop the dphy from the mipi power domain in the SOCs device tree
and only have the DSI host controller visible there but since the PD is mostly
about the PHY that would defeat it's purpose.

This is basically a resend from February 2020 which went without feedback.

This allows to shut off the power domain hen blanking the LCD panel:

pm_genpd_summary before:

domain  status  slaves
/device runtime status
--
mipion
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  unsupported
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

after:

mipioff-0
/devices/platform/soc@0/soc@0:bus@3080/30a00300.dphy  suspended
/devices/platform/soc@0/soc@0:bus@3080/30a0.mipi_dsi  suspended

Changes from v1:
 - Tweak commit message slightly

Guido Günther (1):
  phy: fsl-imx8-mipi-dphy: Hook into runtime pm

 .../phy/freescale/phy-fsl-imx8-mipi-dphy.c| 22 ++-
 1 file changed, 21 insertions(+), 1 deletion(-)

-- 
2.29.2



[PATCH 1/1] regulators: bd718x7: Add enable times

2020-12-16 Thread Guido Günther
Use the typical startup times from the data sheet so boards get a
reasonable default. Not setting any enable time can lead to board hangs
when e.g. clocks are enabled too soon afterwards.

This fixes gpu power domain resume on the Librem 5.

Signed-off-by: Guido Günther 
---
 drivers/regulator/bd718x7-regulator.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/regulator/bd718x7-regulator.c 
b/drivers/regulator/bd718x7-regulator.c
index e6d5d98c3cea..d6d34aa4ee2e 100644
--- a/drivers/regulator/bd718x7-regulator.c
+++ b/drivers/regulator/bd718x7-regulator.c
@@ -613,6 +613,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK1_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = 144,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -646,6 +647,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = DVS_BUCK_RUN_MASK,
.enable_reg = BD718XX_REG_BUCK2_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = 162,
.owner = THIS_MODULE,
.of_parse_cb = buck_set_hw_dvs_levels,
},
@@ -680,6 +682,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.linear_range_selectors = bd71847_buck3_volt_range_sel,
.enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = 162,
.owner = THIS_MODULE,
},
.init = {
@@ -706,6 +709,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
.linear_range_selectors = bd71847_buck4_volt_range_sel,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = 240,
.owner = THIS_MODULE,
},
.init = {
@@ -727,6 +731,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = 220,
.owner = THIS_MODULE,
},
.init = {
@@ -750,6 +755,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
.enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
.enable_mask = BD718XX_BUCK_EN,
+   .enable_time = 200,
.owner = THIS_MODULE,
},
.init = {
@@ -775,6 +781,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.linear_range_selectors = bd718xx_ldo1_volt_range_sel,
.enable_reg = BD718XX_REG_LDO1_VOLT,
.enable_mask = BD718XX_LDO_EN,
+   .enable_time = 440,
.owner = THIS_MODULE,
},
.init = {
@@ -796,6 +803,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.n_voltages = ARRAY_SIZE(ldo_2_volts),
.enable_reg = BD718XX_REG_LDO2_VOLT,
.enable_mask = BD718XX_LDO_EN,
+   .enable_time = 370,
.owner = THIS_MODULE,
},
.init = {
@@ -818,6 +826,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = BD718XX_LDO3_MASK,
.enable_reg = BD718XX_REG_LDO3_VOLT,
.enable_mask = BD718XX_LDO_EN,
+   .enable_time = 310,
.owner = THIS_MODULE,
},
.init = {
@@ -840,6 +849,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.vsel_mask = BD718XX_LDO4_MASK,
.enable_reg = BD718XX_REG_LDO4_VOLT,
.enable_mask = BD718XX_LDO_EN,
+   .enable_time = 400,
.owner = THIS_MODULE,
},
.init = {
@@ -865,6 +875,7 @@ static struct bd718xx_regulator_data bd71847_regulators[] = 
{
.linear_range_selectors = bd71847_ldo5_volt_range_sel,
.enable_reg = BD718XX_REG_LDO5_VOLT,
.enable_mask = BD718XX_LDO_EN

[PATCH 0/1] regulators: bd718x7: Add enable times

2020-12-16 Thread Guido Günther
Use the typical startup times from the data sheet so boards get a
reasonable default. Not setting any enable time can lead to board hangs
when e.g. clocks are enabled too soon afterwards.

This fixes gpu power domain resume on the Librem 5.

Guido Günther (1):
  regulators: bd718x7: Add enable times

 drivers/regulator/bd718x7-regulator.c | 27 +++
 1 file changed, 27 insertions(+)

-- 
2.29.2



Re: [PATCH 1/4] drm/bridge: nwl-dsi: Set PHY mode in nwl_dsi_enable()

2020-12-15 Thread Guido Günther
Hi,
On Tue, Dec 08, 2020 at 10:04:57AM +0100, Guido Günther wrote:
> Hi,
> On Fri, Dec 04, 2020 at 03:33:41PM +0800, Liu Ying wrote:
> > The Northwest Logic MIPI DSI host controller embedded in i.MX8qxp
> > works with a Mixel MIPI DPHY + LVDS PHY combo to support either
> > a MIPI DSI display or a LVDS display.  So, this patch calls
> > phy_set_mode() from nwl_dsi_enable() to set PHY mode to MIPI DPHY
> > explicitly.

Should i pull this patch in via drm-misc-next or is the whole series
supposed to go via the phy tree?
Cheers,
 -- Guido


> > 
> > Cc: Guido Günther 
> > Cc: Robert Chiras 
> > Cc: Martin Kepplinger 
> > Cc: Andrzej Hajda 
> > Cc: Neil Armstrong 
> > Cc: Laurent Pinchart 
> > Cc: Jonas Karlman 
> > Cc: Jernej Skrabec 
> > Cc: David Airlie 
> > Cc: Daniel Vetter 
> > Cc: NXP Linux Team 
> > Signed-off-by: Liu Ying 
> > ---
> >  drivers/gpu/drm/bridge/nwl-dsi.c | 6 ++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c 
> > b/drivers/gpu/drm/bridge/nwl-dsi.c
> > index 66b6740..be6bfc5 100644
> > --- a/drivers/gpu/drm/bridge/nwl-dsi.c
> > +++ b/drivers/gpu/drm/bridge/nwl-dsi.c
> > @@ -678,6 +678,12 @@ static int nwl_dsi_enable(struct nwl_dsi *dsi)
> > return ret;
> > }
> >  
> > +   ret = phy_set_mode(dsi->phy, PHY_MODE_MIPI_DPHY);
> > +   if (ret < 0) {
> > +   DRM_DEV_ERROR(dev, "Failed to set DSI phy mode: %d\n", ret);
> > +   goto uninit_phy;
> > +   }
> > +
> > ret = phy_configure(dsi->phy, phy_cfg);
> > if (ret < 0) {
> > DRM_DEV_ERROR(dev, "Failed to configure DSI phy: %d\n", ret);
> 
> Reviewed-by: Guido Günther  
>  -- Guido
> 
> > -- 
> > 2.7.4
> > 
> 
> 


[PATCH v1 1/1] drm: mxsfb: Silence -EPROBE_DEFER while waiting for bridge

2020-12-15 Thread Guido Günther
It can take multiple iterations until all components for an attached DSI
bridge are up leading to several:

[3.796425] mxsfb 3032.lcd-controller: Cannot connect bridge: -517
[3.816952] mxsfb 3032.lcd-controller: [drm:mxsfb_probe [mxsfb]] *ERROR* 
failed to attach bridge: -517

Silence this by checking for -EPROBE_DEFER and using dev_err_probe() so
we set a deferred reason in case a dependency fails to probe (which
quickly happens on small config/DT changes due to the rather long probe
chain which can include bridges, phys, panels, backights, leds, etc.).

This also removes the only DRM_DEV_ERROR() usage, the rest of the driver
uses dev_err().

Signed-off-by: Guido Günther 
Fixes: c42001e357f7 ("drm: mxsfb: Use drm_panel_bridge")
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 6faf17b6408d..6da93551e2e5 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -134,11 +134,8 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private 
*mxsfb)
return -ENODEV;
 
ret = drm_bridge_attach(>encoder, bridge, NULL, 0);
-   if (ret) {
-   DRM_DEV_ERROR(drm->dev,
- "failed to attach bridge: %d\n", ret);
-   return ret;
-   }
+   if (ret)
+   return dev_err_probe(drm->dev, ret, "Failed to attach 
bridge\n");
 
mxsfb->bridge = bridge;
 
@@ -212,7 +209,8 @@ static int mxsfb_load(struct drm_device *drm,
 
ret = mxsfb_attach_bridge(mxsfb);
if (ret) {
-   dev_err(drm->dev, "Cannot connect bridge: %d\n", ret);
+   if (ret != -EPROBE_DEFER)
+   dev_err(drm->dev, "Cannot connect bridge: %d\n", ret);
goto err_vblank;
}
 
-- 
2.29.2



[PATCH v1 0/1] drm: mxsfb: Silence -EPROBE_DEFER while waiting for bridge

2020-12-15 Thread Guido Günther
It can take multiple iterations until all components for an attached DSI
bridge are up leading to several:

[3.796425] mxsfb 3032.lcd-controller: Cannot connect bridge: -517
[3.816952] mxsfb 3032.lcd-controller: [drm:mxsfb_probe [mxsfb]] *ERROR* 
failed to attach bridge: -517

Silence this by checking for -EPROBE_DEFER and using dev_err_probe() so
we set a deferred reason in case a dependency fails to probe (which
quickly happens on small config/DT changes due to the rather long probe
chain which can include bridges, phys, panels, backights, leds, etc.).

This also removes the only DRM_DEV_ERROR() usage, the rest of the driver
uses dev_err().

Guido Günther (1):
  drm: mxsfb: Silence -EPROBE_DEFER while waiting for bridge

 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

-- 
2.29.2



[PATCH 4/4] arm64: dts: imx8mq-librem5-devkit: Drop custom clock settings

2020-12-13 Thread Guido Günther
Otherwise the boot hangs early on.

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 5 -
 1 file changed, 5 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index 5fdea6b74ed5..b913a2aee328 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -244,11 +244,6 @@ _3 {
cpu-supply = <_reg>;
 };
 
- {
-   assigned-clocks = < IMX8MQ_AUDIO_PLL1>, < IMX8MQ_AUDIO_PLL2>;
-   assigned-clock-rates = <786432000>, <722534400>;
-};
-
  {
status = "okay";
 };
-- 
2.29.2



[PATCH 3/4] arm64: dts: imx8mq-librem5-devkit: Mark more regulators as always-on

2020-12-13 Thread Guido Günther
They power vital parts of the board and low power consumption is not
really an issue here. It also brings things more in line with what
Purism is using downstream.

Signed-off-by: Guido Günther 
---
 .../dts/freescale/imx8mq-librem5-devkit.dts   | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index 12f5d75a5e44..5fdea6b74ed5 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -297,7 +297,7 @@ buck1_reg: BUCK1 {
regulator-name = "buck1";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
-   regulator-boot-on;
+   regulator-always-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <90>;
rohm,dvs-idle-voltage = <85>;
@@ -308,7 +308,7 @@ buck2_reg: BUCK2 {
regulator-name = "buck2";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
-   regulator-boot-on;
+   regulator-always-on;
regulator-ramp-delay = <1250>;
rohm,dvs-run-voltage = <100>;
rohm,dvs-idle-voltage = <90>;
@@ -318,7 +318,7 @@ buck3_reg: BUCK3 {
regulator-name = "buck3";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <130>;
-   regulator-boot-on;
+   regulator-always-on;
rohm,dvs-run-voltage = <90>;
};
 
@@ -333,7 +333,7 @@ buck5_reg: BUCK5 {
regulator-name = "buck5";
regulator-min-microvolt = <70>;
regulator-max-microvolt = <135>;
-   regulator-boot-on;
+   regulator-always-on;
};
 
buck6_reg: BUCK6 {
@@ -354,7 +354,7 @@ buck8_reg: BUCK8 {
regulator-name = "buck8";
regulator-min-microvolt = <80>;
regulator-max-microvolt = <140>;
-   regulator-boot-on;
+   regulator-always-on;
};
 
ldo1_reg: LDO1 {
@@ -379,34 +379,35 @@ ldo3_reg: LDO3 {
regulator-name = "ldo3";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
-   regulator-boot-on;
+   regulator-always-on;
};
 
ldo4_reg: LDO4 {
regulator-name = "ldo4";
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
-   regulator-boot-on;
+   regulator-always-on;
};
 
ldo5_reg: LDO5 {
regulator-name = "ldo5";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
+   regulator-always-on;
};
 
ldo6_reg: LDO6 {
regulator-name = "ldo6";
regulator-min-microvolt = <90>;
regulator-max-microvolt = <180>;
-   regulator-boot-on;
+   regulator-always-on;
};
 
ldo7_reg: LDO7 {
regulator-name = "ldo7";
regulator-min-microvolt = <180>;
regulator-max-microvolt = <330>;
-   regulator-boot-on;
+   regulator-always-on;
};
};
};
-- 
2.29.2



[PATCH 2/4] arm64: dts: imx8mq-librem5-devkit: Disable snvs_rtc

2020-12-13 Thread Guido Günther
The board has it's own rtc chip.

Signed-off-by: Guido Günther 
---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts 
b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
index af139b283daf..12f5d75a5e44 100644
--- a/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
+++ b/arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts
@@ -886,6 +886,10 @@ _pwrkey {
status = "okay";
 };
 
+_rtc {
+   status = "disabled";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_sai2>;
-- 
2.29.2



[PATCH 1/4] arm64: defconfig: Enable Librem5 Devkit components

2020-12-13 Thread Guido Günther
This enables

- touchscreen: CONFIG_TOUCHSCREEN_GOODIX
- charge controller: CONFIG_CHARGER_BQ25890
- audio codec: CONFIG_SND_SOC_IMX_SGTL5000
- rtc: CONFIG_RTC_DRV_M41T80
- magnetometer: CONFIG_IIO_ST_MAGN_3AXIS
- pwm: CONFIG_PWM_IMX27
- modem codec: CONFIG_SND_SOC_GTM601
- modem serial: CONFIG_USB_SERIAL_OPTION

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index c8ca76751a34..dd70bf09659d 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -386,6 +386,7 @@ CONFIG_KEYBOARD_IMX_SC_KEY=m
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_TOUCHSCREEN_ATMEL_MXT=m
+CONFIG_TOUCHSCREEN_GOODIX=m
 CONFIG_TOUCHSCREEN_EDT_FT5X06=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
@@ -534,6 +535,7 @@ CONFIG_BATTERY_SBS=m
 CONFIG_BATTERY_BQ27XXX=y
 CONFIG_SENSORS_ARM_SCMI=y
 CONFIG_BATTERY_MAX17042=m
+CONFIG_CHARGER_BQ25890=m
 CONFIG_CHARGER_BQ25980=m
 CONFIG_SENSORS_ARM_SCPI=y
 CONFIG_SENSORS_LM90=m
@@ -715,6 +717,7 @@ CONFIG_SND_SOC_FSL_ASRC=m
 CONFIG_SND_SOC_FSL_MICFIL=m
 CONFIG_SND_SOC_FSL_EASRC=m
 CONFIG_SND_IMX_SOC=m
+CONFIG_SND_SOC_IMX_SGTL5000=m
 CONFIG_SND_SOC_IMX_SPDIF=m
 CONFIG_SND_SOC_IMX_AUDMIX=m
 CONFIG_SND_MESON_AXG_SOUND_CARD=m
@@ -740,6 +743,7 @@ CONFIG_SND_SOC_TEGRA210_ADMAIF=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
+CONFIG_SND_SOC_GTM601=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
 CONFIG_SND_SOC_SIMPLE_AMPLIFIER=m
 CONFIG_SND_SOC_TAS571X=m
@@ -775,6 +779,7 @@ CONFIG_USB_ISP1760=y
 CONFIG_USB_SERIAL=m
 CONFIG_USB_SERIAL_CP210X=m
 CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_OPTION=m
 CONFIG_USB_HSIC_USB3503=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_GADGET=y
@@ -844,6 +849,7 @@ CONFIG_RTC_DRV_HYM8563=m
 CONFIG_RTC_DRV_MAX77686=y
 CONFIG_RTC_DRV_RK808=m
 CONFIG_RTC_DRV_PCF85363=m
+CONFIG_RTC_DRV_M41T80=m
 CONFIG_RTC_DRV_RX8581=m
 CONFIG_RTC_DRV_RV8803=m
 CONFIG_RTC_DRV_S5M=y
@@ -1008,11 +1014,13 @@ CONFIG_IIO_ST_LSM6DSX=m
 CONFIG_IIO_CROS_EC_LIGHT_PROX=m
 CONFIG_SENSORS_ISL29018=m
 CONFIG_VCNL4000=m
+CONFIG_IIO_ST_MAGN_3AXIS=m
 CONFIG_IIO_CROS_EC_BARO=m
 CONFIG_MPL3115=m
 CONFIG_PWM=y
 CONFIG_PWM_BCM2835=m
 CONFIG_PWM_CROS_EC=m
+CONFIG_PWM_IMX27=m
 CONFIG_PWM_MESON=m
 CONFIG_PWM_RCAR=m
 CONFIG_PWM_ROCKCHIP=y
-- 
2.29.2



[PATCH 0/4] Config and device tree updates for the Librem5 Devkit

2020-12-13 Thread Guido Günther


This enables more components to get a working display, panel, audio and
sensors. It also updates some device tree bits to make mainline boot.

I've skipped wifi (which needs some more driver work) and devfreq (since Martin
is working on that).

The config changes don't depend on the DT parts so could be applied
independently.  The series was tested against next-20201209 and i made sure the
defconfig changes also apply on top of shawnguo/imx/defconfig.

Guido Günther (4):
  arm64: defconfig: Enable Librem5 Devkit components
  arm64: dts: imx8mq-librem5-devkit: Disable snvs_rtc
  arm64: dts: imx8mq-librem5-devkit: Mark more regulators as always-on
  arm64: dts: imx8mq-librem5-devkit: Drop custom clock settings

 .../dts/freescale/imx8mq-librem5-devkit.dts   | 28 +--
 arch/arm64/configs/defconfig  |  8 ++
 2 files changed, 22 insertions(+), 14 deletions(-)

-- 
2.29.2



Re: [PATCH v3 3/5] dt-bindings: phy: Convert mixel,mipi-dsi-phy to json-schema

2020-12-13 Thread Guido Günther
Hi,
On Fri, Dec 11, 2020 at 09:46:20AM +0800, Liu Ying wrote:
> This patch converts the mixel,mipi-dsi-phy binding to
> DT schema format using json-schema.
> 
> Comparing to the plain text version, the new binding adds
> the 'assigned-clocks', 'assigned-clock-parents' and
> 'assigned-clock-rates' properites, otherwise 'make dtbs_check'
> would complain that there are mis-matches.  Also, the new
> binding requires the 'power-domains' property since all potential
> SoCs that embed this PHY would provide a power domain for it.
> The example of the new binding takes reference to the latest
> dphy node in imx8mq.dtsi.
> 
> Cc: Guido Günther 
> Cc: Kishon Vijay Abraham I 
> Cc: Vinod Koul 
> Cc: Rob Herring 
> Cc: NXP Linux Team 
> Signed-off-by: Liu Ying 
> ---
> v2->v3:
> * Improve the 'clock-names' property by dropping 'items:'.
> 
> v1->v2:
> * Newly introduced in v2.  (Guido)
> 
>  .../devicetree/bindings/phy/mixel,mipi-dsi-phy.txt | 29 -
>  .../bindings/phy/mixel,mipi-dsi-phy.yaml   | 72 
> ++
>  2 files changed, 72 insertions(+), 29 deletions(-)
>  delete mode 100644 
> Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
>  create mode 100644 
> Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml
> 
> diff --git a/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt 
> b/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
> deleted file mode 100644
> index 9b23407..
> --- a/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -Mixel DSI PHY for i.MX8
> -
> -The Mixel MIPI-DSI PHY IP block is e.g. found on i.MX8 platforms (along the
> -MIPI-DSI IP from Northwest Logic). It represents the physical layer for the
> -electrical signals for DSI.
> -
> -Required properties:
> -- compatible: Must be:
> -  - "fsl,imx8mq-mipi-dphy"
> -- clocks: Must contain an entry for each entry in clock-names.
> -- clock-names: Must contain the following entries:
> -  - "phy_ref": phandle and specifier referring to the DPHY ref clock
> -- reg: the register range of the PHY controller
> -- #phy-cells: number of cells in PHY, as defined in
> -  Documentation/devicetree/bindings/phy/phy-bindings.txt
> -  this must be <0>
> -
> -Optional properties:
> -- power-domains: phandle to power domain
> -
> -Example:
> - dphy: dphy@30a0030 {
> - compatible = "fsl,imx8mq-mipi-dphy";
> - clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
> - clock-names = "phy_ref";
> - reg = <0x30a00300 0x100>;
> - power-domains = <_mipi0>;
> - #phy-cells = <0>;
> -};
> diff --git a/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml 
> b/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml
> new file mode 100644
> index ..c34f2e6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml
> @@ -0,0 +1,72 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/phy/mixel,mipi-dsi-phy.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Mixel DSI PHY for i.MX8
> +
> +maintainers:
> +  - Guido Günther 
> +
> +description: |
> +  The Mixel MIPI-DSI PHY IP block is e.g. found on i.MX8 platforms (along the
> +  MIPI-DSI IP from Northwest Logic). It represents the physical layer for the
> +  electrical signals for DSI.
> +
> +properties:
> +  compatible:
> +enum:
> +  - fsl,imx8mq-mipi-dphy
> +
> +  reg:
> +maxItems: 1
> +
> +  clocks:
> +maxItems: 1
> +
> +  clock-names:
> +const: phy_ref
> +
> +  assigned-clocks:
> +maxItems: 1
> +
> +  assigned-clock-parents:
> +maxItems: 1
> +
> +  assigned-clock-rates:
> +maxItems: 1
> +
> +  "#phy-cells":
> +const: 0
> +
> +  power-domains:
> +maxItems: 1
> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +  - clock-names
> +  - assigned-clocks
> +  - assigned-clock-parents
> +  - assigned-clock-rates
> +  - "#phy-cells"
> +  - power-domains
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +#include 
> +dphy: dphy@30a0030 {
> +compatible = "fsl,imx8mq-mipi-dphy";
> +reg = <0x30a00300 0x100>;
> +clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
> +clock-names = "phy_ref";
> +assigned-clocks = < IMX8MQ_CLK_DSI_PHY_REF>;
> +assigned-clock-parents = < IMX8MQ_VIDEO_PLL1_OUT>;
> +assigned-clock-rates = <2400>;
> +#phy-cells = <0>;
> +power-domains = <_mipi>;
> +};


Reviewed-by: Guido Günther 

Thanks for the conversion!
 -- Guido



> -- 
> 2.7.4
> 


Re: [PATCH v3 4/5] dt-bindings: phy: mixel: mipi-dsi-phy: Add Mixel combo PHY support for i.MX8qxp

2020-12-13 Thread Guido Günther
Hi,
On Fri, Dec 11, 2020 at 09:46:21AM +0800, Liu Ying wrote:
> Add support for Mixel MIPI DPHY + LVDS PHY combo IP
> as found on Freescale i.MX8qxp SoC.
> 
> Cc: Guido Günther 
> Cc: Kishon Vijay Abraham I 
> Cc: Vinod Koul 
> Cc: Rob Herring 
> Cc: NXP Linux Team 
> Signed-off-by: Liu Ying 
> ---
> v2->v3:
> * No change.
> 
> v1->v2:
> * Add the binding for i.MX8qxp Mixel combo PHY based on the converted binding.
>   (Guido)
> 
>  .../bindings/phy/mixel,mipi-dsi-phy.yaml   | 41 
> --
>  1 file changed, 38 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml 
> b/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml
> index c34f2e6..786cfd7 100644
> --- a/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml
> +++ b/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.yaml
> @@ -14,10 +14,14 @@ description: |
>MIPI-DSI IP from Northwest Logic). It represents the physical layer for the
>electrical signals for DSI.
>  
> +  The Mixel PHY IP block found on i.MX8qxp is a combo PHY that can work
> +  in either MIPI-DSI PHY mode or LVDS PHY mode.
> +
>  properties:
>compatible:
>  enum:
>- fsl,imx8mq-mipi-dphy
> +  - fsl,imx8qxp-mipi-dphy
>  
>reg:
>  maxItems: 1
> @@ -40,6 +44,11 @@ properties:
>"#phy-cells":
>  const: 0
>  
> +  fsl,syscon:
> +$ref: /schemas/types.yaml#/definitions/phandle
> +description: |
> +  A phandle which points to Control and Status Registers(CSR) module.
> +
>power-domains:
>  maxItems: 1
>  
> @@ -48,12 +57,38 @@ required:
>- reg
>- clocks
>- clock-names
> -  - assigned-clocks
> -  - assigned-clock-parents
> -  - assigned-clock-rates
>- "#phy-cells"
>- power-domains
>  
> +allOf:
> +  - if:
> +  properties:
> +compatible:
> +  contains:
> +const: fsl,imx8mq-mipi-dphy
> +then:
> +  properties:
> +fsl,syscon: false
> +
> +  required:
> +- assigned-clocks
> +- assigned-clock-parents
> +- assigned-clock-rates
> +
> +  - if:
> +  properties:
> +compatible:
> +  contains:
> +const: fsl,imx8qxp-mipi-dphy
> +then:
> +  properties:
> +assigned-clocks: false
> +assigned-clock-parents: false
> +assigned-clock-rates: false
> +
> +  required:
> +- fsl,syscon
> +
>  additionalProperties: false
>  
>  examples:

Reviewed-by: Guido Günther 
Cheers,
 -- Guido

> -- 
> 2.7.4
> 


Re: [PATCH v3 5/5] phy: freescale: phy-fsl-imx8-mipi-dphy: Add i.MX8qxp LVDS PHY mode support

2020-12-13 Thread Guido Günther
Hi,
On Fri, Dec 11, 2020 at 09:46:22AM +0800, Liu Ying wrote:
> i.MX8qxp SoC embeds a Mixel MIPI DPHY + LVDS PHY combo which supports
> either a MIPI DSI display or a LVDS display.  The PHY mode is controlled
> by SCU firmware and the driver would call a SCU firmware function to
> configure the PHY mode.  The single LVDS PHY has 4 data lanes to support
> a LVDS display.  Also, with a master LVDS PHY and a slave LVDS PHY, they
> may work together to support a LVDS display with 8 data lanes(usually, dual
> LVDS link display).  Note that this patch supports the LVDS PHY mode only
> for the i.MX8qxp Mixel combo PHY, i.e., the MIPI DPHY mode is yet to be
> supported, so for now error would be returned from ->set_mode() if MIPI
> DPHY mode is passed over to it for the combo PHY.
> 
> Cc: Guido Günther 
> Cc: Robert Chiras 
> Cc: Kishon Vijay Abraham I 
> Cc: Vinod Koul 
> Cc: Shawn Guo 
> Cc: Sascha Hauer 
> Cc: Pengutronix Kernel Team 
> Cc: Fabio Estevam 
> Cc: NXP Linux Team 
> Signed-off-by: Liu Ying 
> ---
> Guido, I also print invalid PHY mode from mixel_dphy_configure().
> 
> v2->v3:
> * Improve readability of mixel_dphy_set_mode(). (Guido)
> 
> v1->v2:
> * Print invalid PHY mode in dmesg. (Guido)
> 
>  drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 269 
> -
>  1 file changed, 258 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
> b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> index a95572b..af1ecda 100644
> --- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> +++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> @@ -4,17 +4,31 @@
>   * Copyright 2019 Purism SPC
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
> +
> +/* Control and Status Registers(CSR) */
> +#define PHY_CTRL 0x00
> +#define  CCM_MASKGENMASK(7, 5)
> +#define  CCM(n)  FIELD_PREP(CCM_MASK, (n))
> +#define  CA_MASK GENMASK(4, 2)
> +#define  CA(n)   FIELD_PREP(CA_MASK, (n))
> +#define  RFB BIT(1)
> +#define  LVDS_EN BIT(0)
>  
>  /* DPHY registers */
>  #define DPHY_PD_DPHY 0x00
> @@ -55,8 +69,15 @@
>  #define PWR_ON   0
>  #define PWR_OFF  1
>  
> +#define MIN_VCO_FREQ 64000
> +#define MAX_VCO_FREQ 15
> +
> +#define MIN_LVDS_REFCLK_FREQ 2400
> +#define MAX_LVDS_REFCLK_FREQ 15000
> +
>  enum mixel_dphy_devtype {
>   MIXEL_IMX8MQ,
> + MIXEL_IMX8QXP,
>  };
>  
>  struct mixel_dphy_devdata {
> @@ -65,6 +86,7 @@ struct mixel_dphy_devdata {
>   u8 reg_rxlprp;
>   u8 reg_rxcdrp;
>   u8 reg_rxhs_settle;
> + bool is_combo;  /* MIPI DPHY and LVDS PHY combo */
>  };
>  
>  static const struct mixel_dphy_devdata mixel_dphy_devdata[] = {
> @@ -74,6 +96,10 @@ static const struct mixel_dphy_devdata 
> mixel_dphy_devdata[] = {
>   .reg_rxlprp = 0x40,
>   .reg_rxcdrp = 0x44,
>   .reg_rxhs_settle = 0x48,
> + .is_combo = false,
> + },
> + [MIXEL_IMX8QXP] = {
> + .is_combo = true,
>   },
>  };
>  
> @@ -95,8 +121,12 @@ struct mixel_dphy_cfg {
>  struct mixel_dphy_priv {
>   struct mixel_dphy_cfg cfg;
>   struct regmap *regmap;
> + struct regmap *lvds_regmap;
>   struct clk *phy_ref_clk;
>   const struct mixel_dphy_devdata *devdata;
> + struct imx_sc_ipc *ipc_handle;
> + bool is_slave;
> + int id;
>  };
>  
>  static const struct regmap_config mixel_dphy_regmap_config = {
> @@ -317,7 +347,8 @@ static int mixel_dphy_set_pll_params(struct phy *phy)
>   return 0;
>  }
>  
> -static int mixel_dphy_configure(struct phy *phy, union phy_configure_opts 
> *opts)
> +static int
> +mixel_dphy_configure_mipi_dphy(struct phy *phy, union phy_configure_opts 
> *opts)
>  {
>   struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
>   struct mixel_dphy_cfg cfg = { 0 };
> @@ -345,15 +376,121 @@ static int mixel_dphy_configure(struct phy *phy, union 
> phy_configure_opts *opts)
>   return 0;
>  }
>  
> +static int
> +mixel_dphy_configure_lvds_phy(struct phy *phy, union phy_configure_opts 
> *opts)
> +{
> + struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
> + struct phy_configure_opts_lvds *lvds_opts = >lvds;
> + unsigned long data

Re: [PATCH 4/4] phy: freescale: phy-fsl-imx8-mipi-dphy: Add i.MX8qxp LVDS PHY mode support

2020-12-09 Thread Guido Günther
Hi,
On Tue, Dec 08, 2020 at 06:03:05PM +0800, Liu Ying wrote:
> On Tue, 2020-12-08 at 10:24 +0100, Guido Günther wrote:
> > Hi Liu,
> > some minor comments inline:
> > 
> > On Fri, Dec 04, 2020 at 03:33:44PM +0800, Liu Ying wrote:
> > > i.MX8qxp SoC embeds a Mixel MIPI DPHY + LVDS PHY combo which supports
> > > either a MIPI DSI display or a LVDS display.  The PHY mode is controlled
> > > by SCU firmware and the driver would call a SCU firmware function to
> > > configure the PHY mode.  The single LVDS PHY has 4 data lanes to support
> > > a LVDS display.  Also, with a master LVDS PHY and a slave LVDS PHY, they
> > > may work together to support a LVDS display with 8 data lanes(usually, 
> > > dual
> > > LVDS link display).  Note that this patch supports the LVDS PHY mode only
> > > for the i.MX8qxp Mixel combo PHY, i.e., the MIPI DPHY mode is yet to be
> > > supported, so for now error would be returned from ->set_mode() if MIPI
> > > DPHY mode is passed over to it for the combo PHY.
> > > 
> > > Cc: Guido Günther 
> > > Cc: Robert Chiras 
> > > Cc: Kishon Vijay Abraham I 
> > > Cc: Vinod Koul 
> > > Cc: Shawn Guo 
> > > Cc: Sascha Hauer 
> > > Cc: Pengutronix Kernel Team 
> > > Cc: Fabio Estevam 
> > > Cc: NXP Linux Team 
> > > Signed-off-by: Liu Ying 
> > > ---
> > >  drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 266 
> > > -
> > >  1 file changed, 255 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
> > > b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > > index a95572b..37084a9 100644
> > > --- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > > +++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> > > @@ -4,17 +4,31 @@
> > >   * Copyright 2019 Purism SPC
> > >   */
> > >  
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > > +#include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > > +
> > > +/* Control and Status Registers(CSR) */
> > > +#define PHY_CTRL 0x00
> > > +#define  CCM_MASKGENMASK(7, 5)
> > > +#define  CCM(n)  FIELD_PREP(CCM_MASK, (n))
> > > +#define  CA_MASK GENMASK(4, 2)
> > > +#define  CA(n)   FIELD_PREP(CA_MASK, (n))
> > > +#define  RFB BIT(1)
> > > +#define  LVDS_EN BIT(0)
> > >  
> > >  /* DPHY registers */
> > >  #define DPHY_PD_DPHY 0x00
> > > @@ -55,8 +69,15 @@
> > >  #define PWR_ON   0
> > >  #define PWR_OFF  1
> > >  
> > > +#define MIN_VCO_FREQ 64000
> > > +#define MAX_VCO_FREQ 15
> > > +
> > > +#define MIN_LVDS_REFCLK_FREQ 2400
> > > +#define MAX_LVDS_REFCLK_FREQ 15000
> > > +
> > >  enum mixel_dphy_devtype {
> > >   MIXEL_IMX8MQ,
> > > + MIXEL_IMX8QXP,
> > >  };
> > >  
> > >  struct mixel_dphy_devdata {
> > > @@ -65,6 +86,7 @@ struct mixel_dphy_devdata {
> > >   u8 reg_rxlprp;
> > >   u8 reg_rxcdrp;
> > >   u8 reg_rxhs_settle;
> > > + bool is_combo;  /* MIPI DPHY and LVDS PHY combo */
> > >  };
> > >  
> > >  static const struct mixel_dphy_devdata mixel_dphy_devdata[] = {
> > > @@ -74,6 +96,10 @@ static const struct mixel_dphy_devdata 
> > > mixel_dphy_devdata[] = {
> > >   .reg_rxlprp = 0x40,
> > >   .reg_rxcdrp = 0x44,
> > >   .reg_rxhs_settle = 0x48,
> > > + .is_combo = false,
> > > + },
> > > + [MIXEL_IMX8QXP] = {
> > > + .is_combo = true,
> > >   },
> > >  };
> > >  
> > > @@ -95,8 +121,12 @@ struct mixel_dphy_cfg {
> > >  struct mixel_dphy_priv {
> > >   struct mixel_dphy_cfg cfg;
> > >   struct regmap *regmap;
> > > + struct regmap *lvds_regmap;
> > >   struct clk *phy_ref_clk;
> > >   const struct mixel_dphy_devdata *devdata;
> > > + struct imx_sc_ipc *ipc_handle;
> > > + bool is_slave;
> > &g

Re: [PATCH v2 6/6] dt-binding: display: mantix: Add compatible for panel from YS

2020-12-08 Thread Guido Günther
Hi,
On Mon, Dec 07, 2020 at 03:32:06PM -0600, Rob Herring wrote:
> On Wed, 18 Nov 2020 09:29:53 +0100, Guido Günther wrote:
> > This panel from Shenzhen Yashi Changhua Intelligent Technology Co
> > uses the same driver IC but a different LCD.
> > 
> > Signed-off-by: Guido Günther 
> > Reviewed-by: Linus Walleij 
> > ---
> >  .../devicetree/bindings/display/panel/mantix,mlaf057we51-x.yaml  | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> 
> Acked-by: Rob Herring 
> 

Thanks! I've appplied the series to drm-misc-next now.
Cheers,
 -- Guido


Re: [PATCH 4/4] phy: freescale: phy-fsl-imx8-mipi-dphy: Add i.MX8qxp LVDS PHY mode support

2020-12-08 Thread Guido Günther
Hi Liu,
some minor comments inline:

On Fri, Dec 04, 2020 at 03:33:44PM +0800, Liu Ying wrote:
> i.MX8qxp SoC embeds a Mixel MIPI DPHY + LVDS PHY combo which supports
> either a MIPI DSI display or a LVDS display.  The PHY mode is controlled
> by SCU firmware and the driver would call a SCU firmware function to
> configure the PHY mode.  The single LVDS PHY has 4 data lanes to support
> a LVDS display.  Also, with a master LVDS PHY and a slave LVDS PHY, they
> may work together to support a LVDS display with 8 data lanes(usually, dual
> LVDS link display).  Note that this patch supports the LVDS PHY mode only
> for the i.MX8qxp Mixel combo PHY, i.e., the MIPI DPHY mode is yet to be
> supported, so for now error would be returned from ->set_mode() if MIPI
> DPHY mode is passed over to it for the combo PHY.
> 
> Cc: Guido Günther 
> Cc: Robert Chiras 
> Cc: Kishon Vijay Abraham I 
> Cc: Vinod Koul 
> Cc: Shawn Guo 
> Cc: Sascha Hauer 
> Cc: Pengutronix Kernel Team 
> Cc: Fabio Estevam 
> Cc: NXP Linux Team 
> Signed-off-by: Liu Ying 
> ---
>  drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 266 
> -
>  1 file changed, 255 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c 
> b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> index a95572b..37084a9 100644
> --- a/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> +++ b/drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
> @@ -4,17 +4,31 @@
>   * Copyright 2019 Purism SPC
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
> +
> +/* Control and Status Registers(CSR) */
> +#define PHY_CTRL 0x00
> +#define  CCM_MASKGENMASK(7, 5)
> +#define  CCM(n)  FIELD_PREP(CCM_MASK, (n))
> +#define  CA_MASK GENMASK(4, 2)
> +#define  CA(n)   FIELD_PREP(CA_MASK, (n))
> +#define  RFB BIT(1)
> +#define  LVDS_EN BIT(0)
>  
>  /* DPHY registers */
>  #define DPHY_PD_DPHY 0x00
> @@ -55,8 +69,15 @@
>  #define PWR_ON   0
>  #define PWR_OFF  1
>  
> +#define MIN_VCO_FREQ 64000
> +#define MAX_VCO_FREQ 15
> +
> +#define MIN_LVDS_REFCLK_FREQ 2400
> +#define MAX_LVDS_REFCLK_FREQ 15000
> +
>  enum mixel_dphy_devtype {
>   MIXEL_IMX8MQ,
> + MIXEL_IMX8QXP,
>  };
>  
>  struct mixel_dphy_devdata {
> @@ -65,6 +86,7 @@ struct mixel_dphy_devdata {
>   u8 reg_rxlprp;
>   u8 reg_rxcdrp;
>   u8 reg_rxhs_settle;
> + bool is_combo;  /* MIPI DPHY and LVDS PHY combo */
>  };
>  
>  static const struct mixel_dphy_devdata mixel_dphy_devdata[] = {
> @@ -74,6 +96,10 @@ static const struct mixel_dphy_devdata 
> mixel_dphy_devdata[] = {
>   .reg_rxlprp = 0x40,
>   .reg_rxcdrp = 0x44,
>   .reg_rxhs_settle = 0x48,
> + .is_combo = false,
> + },
> + [MIXEL_IMX8QXP] = {
> + .is_combo = true,
>   },
>  };
>  
> @@ -95,8 +121,12 @@ struct mixel_dphy_cfg {
>  struct mixel_dphy_priv {
>   struct mixel_dphy_cfg cfg;
>   struct regmap *regmap;
> + struct regmap *lvds_regmap;
>   struct clk *phy_ref_clk;
>   const struct mixel_dphy_devdata *devdata;
> + struct imx_sc_ipc *ipc_handle;
> + bool is_slave;
> + int id;
>  };
>  
>  static const struct regmap_config mixel_dphy_regmap_config = {
> @@ -317,7 +347,8 @@ static int mixel_dphy_set_pll_params(struct phy *phy)
>   return 0;
>  }
>  
> -static int mixel_dphy_configure(struct phy *phy, union phy_configure_opts 
> *opts)
> +static int
> +mixel_dphy_configure_mipi_dphy(struct phy *phy, union phy_configure_opts 
> *opts)
>  {
>   struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
>   struct mixel_dphy_cfg cfg = { 0 };
> @@ -345,15 +376,118 @@ static int mixel_dphy_configure(struct phy *phy, union 
> phy_configure_opts *opts)
>   return 0;
>  }
>  
> +static int
> +mixel_dphy_configure_lvds_phy(struct phy *phy, union phy_configure_opts 
> *opts)
> +{
> + struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
> + struct phy_configure_opts_lvds *lvds_opts = >lvds;
> + unsigned long data_rate;
> + unsigned long fvco;
> + u32 rsc;
> + u32 co;
> + int ret;
> +
> + priv->is_slave = lvds_opts->is_slave;
> +
> + /* LVDS interface pins */
> 

Re: [PATCH 3/4] dt-bindings: phy: mixel: mipi-dsi-phy: Add Mixel combo PHY support for i.MX8qxp

2020-12-08 Thread Guido Günther
Hi Liu,
Since we now gain optional properties validation would become even more
useful. Could you look into converting to YAML before adding more
values?
Cheers,
 -- Guido

On Fri, Dec 04, 2020 at 03:33:43PM +0800, Liu Ying wrote:
> Add support for Mixel MIPI DPHY + LVDS PHY combo IP
> as found on Freescale i.MX8qxp SoC.
> 
> Cc: Guido Günther 
> Cc: Kishon Vijay Abraham I 
> Cc: Vinod Koul 
> Cc: Rob Herring 
> Cc: NXP Linux Team 
> Signed-off-by: Liu Ying 
> ---
>  Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt 
> b/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
> index 9b23407..0afce99 100644
> --- a/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
> +++ b/Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
> @@ -4,9 +4,13 @@ The Mixel MIPI-DSI PHY IP block is e.g. found on i.MX8 
> platforms (along the
>  MIPI-DSI IP from Northwest Logic). It represents the physical layer for the
>  electrical signals for DSI.
>  
> +The Mixel PHY IP block found on i.MX8qxp is a combo PHY that can work
> +in either MIPI-DSI PHY mode or LVDS PHY mode.
> +
>  Required properties:
> -- compatible: Must be:
> +- compatible: Should be one of:
>- "fsl,imx8mq-mipi-dphy"
> +  - "fsl,imx8qxp-mipi-dphy"
>  - clocks: Must contain an entry for each entry in clock-names.
>  - clock-names: Must contain the following entries:
>- "phy_ref": phandle and specifier referring to the DPHY ref clock
> @@ -14,6 +18,8 @@ Required properties:
>  - #phy-cells: number of cells in PHY, as defined in
>Documentation/devicetree/bindings/phy/phy-bindings.txt
>this must be <0>
> +- fsl,syscon: Phandle to a system controller, as required by the PHY
> +  in i.MX8qxp SoC.
>  
>  Optional properties:
>  - power-domains: phandle to power domain
> -- 
> 2.7.4
> 


Re: [PATCH 1/4] drm/bridge: nwl-dsi: Set PHY mode in nwl_dsi_enable()

2020-12-08 Thread Guido Günther
Hi,
On Fri, Dec 04, 2020 at 03:33:41PM +0800, Liu Ying wrote:
> The Northwest Logic MIPI DSI host controller embedded in i.MX8qxp
> works with a Mixel MIPI DPHY + LVDS PHY combo to support either
> a MIPI DSI display or a LVDS display.  So, this patch calls
> phy_set_mode() from nwl_dsi_enable() to set PHY mode to MIPI DPHY
> explicitly.
> 
> Cc: Guido Günther 
> Cc: Robert Chiras 
> Cc: Martin Kepplinger 
> Cc: Andrzej Hajda 
> Cc: Neil Armstrong 
> Cc: Laurent Pinchart 
> Cc: Jonas Karlman 
> Cc: Jernej Skrabec 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: NXP Linux Team 
> Signed-off-by: Liu Ying 
> ---
>  drivers/gpu/drm/bridge/nwl-dsi.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c 
> b/drivers/gpu/drm/bridge/nwl-dsi.c
> index 66b6740..be6bfc5 100644
> --- a/drivers/gpu/drm/bridge/nwl-dsi.c
> +++ b/drivers/gpu/drm/bridge/nwl-dsi.c
> @@ -678,6 +678,12 @@ static int nwl_dsi_enable(struct nwl_dsi *dsi)
>   return ret;
>   }
>  
> + ret = phy_set_mode(dsi->phy, PHY_MODE_MIPI_DPHY);
> + if (ret < 0) {
> + DRM_DEV_ERROR(dev, "Failed to set DSI phy mode: %d\n", ret);
> + goto uninit_phy;
> + }
> +
>   ret = phy_configure(dsi->phy, phy_cfg);
>   if (ret < 0) {
>   DRM_DEV_ERROR(dev, "Failed to configure DSI phy: %d\n", ret);

Reviewed-by: Guido Günther  
 -- Guido

> -- 
> 2.7.4
> 




Re: [PATCH 0/4] phy: phy-fsl-imx8-mipi-dphy: Add i.MX8qxp LVDS PHY mode support

2020-12-08 Thread Guido Günther
Hi Liu,
On Fri, Dec 04, 2020 at 03:33:40PM +0800, Liu Ying wrote:
> Hi,
> 
> This series adds i.MX8qxp LVDS PHY mode support for the Mixel PHY in the
> Freescale i.MX8qxp SoC.

This looks good to me from the NWL and actual phy driver part. I'll
comment in the individual patches but leave comments on the extension
of the generic phy struct to someone knowledgeable with that part.

What display controllers do you intend to drive that with?
Cheers,
 -- Guido

> 
> The Mixel PHY is MIPI DPHY + LVDS PHY combo, which can works in either
> MIPI DPHY mode or LVDS PHY mode.  The PHY mode is controlled by i.MX8qxp
> SCU firmware.  The PHY driver would call a SCU function to configure the
> mode.
> 
> The PHY driver is already supporting the Mixel MIPI DPHY in i.MX8mq SoC,
> where it appears to be a single MIPI DPHY.
> 
> 
> Patch 1/4 sets PHY mode in the Northwest Logic MIPI DSI host controller
> bridge driver, since i.MX8qxp SoC embeds this controller IP to support
> MIPI DSI displays together with the Mixel PHY.
> 
> Patch 2/4 allows LVDS PHYs to be configured through the generic PHY functions
> and through a custom structure added to the generic PHY configuration union.
> 
> Patch 3/4 adds dt binding support for the Mixel combo PHY in i.MX8qxp SoC.
> 
> Patch 4/4 adds the i.MX8qxp LVDS PHY mode support in the Mixel PHY driver.
> 
> 
> Welcome comments, thanks.
> 
> 
> Liu Ying (4):
>   drm/bridge: nwl-dsi: Set PHY mode in nwl_dsi_enable()
>   phy: Add LVDS configuration options
>   dt-bindings: phy: mixel: mipi-dsi-phy: Add Mixel combo PHY support for
> i.MX8qxp
>   phy: freescale: phy-fsl-imx8-mipi-dphy: Add i.MX8qxp LVDS PHY mode
> support
> 
>  .../devicetree/bindings/phy/mixel,mipi-dsi-phy.txt |   8 +-
>  drivers/gpu/drm/bridge/nwl-dsi.c   |   6 +
>  drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c | 266 
> -
>  include/linux/phy/phy-lvds.h   |  48 
>  include/linux/phy/phy.h|   4 +
>  5 files changed, 320 insertions(+), 12 deletions(-)
>  create mode 100644 include/linux/phy/phy-lvds.h
> 
> -- 
> 2.7.4
> 


[PATCH v5 2/2] usb: typec: tps6598x: Export some power supply properties

2020-12-05 Thread Guido Günther
This allows downstream supplies and userspace to detect
whether external power is supplied.

Signed-off-by: Guido Günther 
Reviewed-by: Heikki Krogerus 
Reviewed-by: Andy Shevchenko 
---
 drivers/usb/typec/Kconfig|   1 +
 drivers/usb/typec/tps6598x.c | 103 +++
 2 files changed, 104 insertions(+)

diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 772b07e9f188..365f905a8e49 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -64,6 +64,7 @@ config TYPEC_HD3SS3220
 config TYPEC_TPS6598X
tristate "TI TPS6598x USB Power Delivery controller driver"
depends on I2C
+   select POWER_SUPPLY
select REGMAP_I2C
select USB_ROLE_SWITCH
help
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 3db33bb622c3..6e6ef6317523 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -55,6 +56,7 @@ enum {
 };
 
 /* TPS_REG_POWER_STATUS bits */
+#define TPS_POWER_STATUS_CONNECTIONBIT(0)
 #define TPS_POWER_STATUS_SOURCESINKBIT(1)
 #define TPS_POWER_STATUS_PWROPMODE(p)  (((p) & GENMASK(3, 2)) >> 2)
 
@@ -96,8 +98,25 @@ struct tps6598x {
struct typec_partner *partner;
struct usb_pd_identity partner_identity;
struct usb_role_switch *role_sw;
+   struct typec_capability typec_cap;
+
+   struct power_supply *psy;
+   struct power_supply_desc psy_desc;
+   enum power_supply_usb_type usb_type;
+};
+
+static enum power_supply_property tps6598x_psy_props[] = {
+   POWER_SUPPLY_PROP_USB_TYPE,
+   POWER_SUPPLY_PROP_ONLINE,
 };
 
+static enum power_supply_usb_type tps6598x_psy_usb_types[] = {
+   POWER_SUPPLY_USB_TYPE_C,
+   POWER_SUPPLY_USB_TYPE_PD,
+};
+
+static const char *tps6598x_psy_name_prefix = "tps6598x-source-psy-";
+
 /*
  * Max data bytes for Data1, Data2, and other registers. See ch 1.3.2:
  * https://www.ti.com/lit/ug/slvuan1a/slvuan1a.pdf
@@ -248,6 +267,8 @@ static int tps6598x_connect(struct tps6598x *tps, u32 
status)
if (desc.identity)
typec_partner_set_identity(tps->partner);
 
+   power_supply_changed(tps->psy);
+
return 0;
 }
 
@@ -260,6 +281,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 
status)
typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), false);
+   power_supply_changed(tps->psy);
 }
 
 static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd,
@@ -467,6 +489,83 @@ static const struct regmap_config tps6598x_regmap_config = 
{
.max_register = 0x7F,
 };
 
+static int tps6598x_psy_get_online(struct tps6598x *tps,
+  union power_supply_propval *val)
+{
+   int ret;
+   u16 pwr_status;
+
+   ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, _status);
+   if (ret < 0)
+   return ret;
+
+   if ((pwr_status & TPS_POWER_STATUS_CONNECTION) &&
+   (pwr_status & TPS_POWER_STATUS_SOURCESINK)) {
+   val->intval = 1;
+   } else {
+   val->intval = 0;
+   }
+   return 0;
+}
+
+static int tps6598x_psy_get_prop(struct power_supply *psy,
+enum power_supply_property psp,
+union power_supply_propval *val)
+{
+   struct tps6598x *tps = power_supply_get_drvdata(psy);
+   u16 pwr_status;
+   int ret = 0;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_USB_TYPE:
+   ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, _status);
+   if (ret < 0)
+   return ret;
+   if (TPS_POWER_STATUS_PWROPMODE(pwr_status) == TYPEC_PWR_MODE_PD)
+   val->intval = POWER_SUPPLY_USB_TYPE_PD;
+   else
+   val->intval = POWER_SUPPLY_USB_TYPE_C;
+   break;
+   case POWER_SUPPLY_PROP_ONLINE:
+   ret = tps6598x_psy_get_online(tps, val);
+   break;
+   default:
+   ret = -EINVAL;
+   break;
+   }
+
+   return ret;
+}
+
+static int devm_tps6598_psy_register(struct tps6598x *tps)
+{
+   struct power_supply_config psy_cfg = {};
+   const char *port_dev_name = dev_name(tps->dev);
+   char *psy_name;
+
+   psy_cfg.drv_data = tps;
+   psy_cfg.fwnode = dev_fwnode(tps->dev);
+
+   psy_name = devm_kasprintf(tps->dev, GFP_KERNEL, "%s%s", 
tps6598x_psy_name_prefix,
+ port_dev_name);
+   if (!psy_name)
+   return -ENOMEM;
+
+   tps->psy_desc.name = psy_name;
+   tps->psy_

[PATCH v5 1/2] usb: typec: tps6598x: Select USB_ROLE_SWITCH and REGMAP_I2C

2020-12-05 Thread Guido Günther
This is more in line with what tcpm does and will be needed
to avoid recursive dependency like

 > drivers/power/supply/Kconfig:2:error: recursive dependency detected!
   drivers/power/supply/Kconfig:2: symbol POWER_SUPPLY is selected by 
TYPEC_TPS6598X
   drivers/usb/typec/Kconfig:64: symbol TYPEC_TPS6598X depends on REGMAP_I2C
   drivers/base/regmap/Kconfig:19: symbol REGMAP_I2C is selected by 
CHARGER_ADP5061
   drivers/power/supply/Kconfig:93: symbol CHARGER_ADP5061 depends on 
POWER_SUPPLY
   For a resolution refer to Documentation/kbuild/kconfig-language.rst
   subsection "Kconfig recursive dependency limitations"

when selecting POWER_SUPPLY.

Signed-off-by: Guido Günther 
Reviewed-by: Heikki Krogerus 
Reviewed-by: Andy Shevchenko 
---
 drivers/usb/typec/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 6c5908a37ee8..772b07e9f188 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -64,8 +64,8 @@ config TYPEC_HD3SS3220
 config TYPEC_TPS6598X
tristate "TI TPS6598x USB Power Delivery controller driver"
depends on I2C
-   depends on REGMAP_I2C
-   depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
+   select REGMAP_I2C
+   select USB_ROLE_SWITCH
help
  Say Y or M here if your system has TI TPS65982 or TPS65983 USB Power
  Delivery controller.
-- 
2.29.2



[PATCH v5 0/2] usb: typec: tps6598x: Export some power supply properties

2020-12-05 Thread Guido Günther
This allows downstream supplies and userspace to detect whether external power
is supplied.

The Librem 5 has the tp65982 in front of bq25980 charge controller.  Since that
is capable of sinking and sourcing power the online property helps to decide
what to do. It also makes upower happy.

There will be follow up patches providing more properties but these need some
more time to cook and i wanted to check if this is the right way to go?

changes from v4
  - As per review comments from Andy Shevchenko

https://lore.kernel.org/linux-usb/CAHp75Vfws_WMDxxpCpB1zSgbWucYx7-qeev6=mke+znxssp...@mail.gmail.com/T/#mb90b0f7dc49c4929590fa7fa0df53631b47a9285
- Use devm_kasprintf()
  - Add reviewed by from Andy Shevchenko, thanks!

https://lore.kernel.org/linux-usb/CAHp75Vfws_WMDxxpCpB1zSgbWucYx7-qeev6=mke+znxssp...@mail.gmail.com/

changes from v3
  - As per review comments from Andy Shevchenko

https://lore.kernel.org/linux-usb/CAHp75VeLZtm85Y=3qmkpgb332wn05-zr-_mrrwxvnqlhazr...@mail.gmail.com/
- Use positive conditionals
  - Add reviewed by from Heikki Krogerus

https://lore.kernel.org/linux-usb/20201130102720.ga2911...@kuha.fi.intel.com/T/#u

https://lore.kernel.org/linux-usb/20201130102942.gb2911...@kuha.fi.intel.com/T/#u
  - Fix typc vs typec typo in commit message

changes from v2
  - As per kernel test robot
https://lore.kernel.org/linux-usb/202011271005.zjvawx74-...@intel.com/
- Flip USB_ROLE_SWITCH and REGMAP_I2C from 'depends on' to 'select'
  This matches tcpm and avoids a config symbol recursion which went
  unnoticed on my arm64 build but trips up x86_64.

changes from v1
  - As per review comments from Heikki Krogerus

https://lore.kernel.org/linux-usb/20201126123552.gp1008...@kuha.fi.intel.com/
- select POWER_SUPPLY
- use POWER_SUPPLY_USB_TYPE_PD when a PD contract got negotiated

Guido Günther (2):
  usb: typec: tps6598x: Select USB_ROLE_SWITCH and REGMAP_I2C
  usb: typec: tps6598x: Export some power supply properties

 drivers/usb/typec/Kconfig|   5 +-
 drivers/usb/typec/tps6598x.c | 103 +++
 2 files changed, 106 insertions(+), 2 deletions(-)

-- 
2.29.2



Re: [PATCH v2 0/6] drm/panel: mantix and st7703 fixes and additions

2020-12-04 Thread Guido Günther
Hi Linus,
On Thu, Nov 19, 2020 at 09:35:17AM +0100, Linus Walleij wrote:
> On Wed, Nov 18, 2020 at 9:29 AM Guido Günther  wrote:
> 
> > This adds new panel type to the mantix driver as found on the Librem 5 and
> > fixes a glitch in the init sequence (affecting both panels). The fix is at 
> > the
> > start of the series to make backporting simpler.
> > It also adds a patch to make st7703 use dev_err_probe().
> >
> > changes from v1
> > - as per review comments by Linus Walleij
> >   - fix alphabetical ordering in 
> > Documentation/devicetree/bindings/vendor-prefixes.yaml
> > 
> > https://lore.kernel.org/dri-devel/CACRpkdao_TMcpRsdK=7k5fnkjse0bqwk58iwu0xsxddndcf...@mail.gmail.com/
> >   - add reviewed by to all except 5/6, thanks
> 
> The whole v2 looks fine to me, I'd give the devicetree
> maintainers some slack to review the DT patches then I can
> apply the whole series unless you have commit access yourself,
> just tell me.

Thanks. Is 2 weeks enough slack? Checking what's the rule of thumb here.
Cheers,
 -- Guido

> 
> For all v2 patches:
> Reviewed-by: Linus Walleij 
> 
> If you have time, please review my s6e63m0 series.
> https://lore.kernel.org/dri-devel/20201117175621.870085-1-linus.wall...@linaro.org/
> https://lore.kernel.org/dri-devel/20201117175621.870085-2-linus.wall...@linaro.org/
> https://lore.kernel.org/dri-devel/20201117175621.870085-3-linus.wall...@linaro.org/
> 
> Yours,
> Linus Walleij
> 


Re: [PATCH v4 2/2] usb: typec: tps6598x: Export some power supply properties

2020-12-01 Thread Guido Günther
Hi Andy,
On Tue, Dec 01, 2020 at 03:52:40PM +0200, Andy Shevchenko wrote:
> On Tue, Dec 1, 2020 at 2:59 PM Guido Günther  wrote:
> > This allows downstream supplies and userspace to detect
> > whether external power is supplied.
> 
> ...
> 
> > +static int devm_tps6598_psy_register(struct tps6598x *tps)
> > +{
> > +   struct power_supply_config psy_cfg = {};
> > +   const char *port_dev_name = dev_name(tps->dev);
> 
> > +   size_t psy_name_len = strlen(tps6598x_psy_name_prefix) +
> > +strlen(port_dev_name) + 1;
> 
> I'm so sorry by not noticing this one...
> 
> > +   char *psy_name;
> > +
> > +   psy_cfg.drv_data = tps;
> > +   psy_cfg.fwnode = dev_fwnode(tps->dev);
> > +   psy_name = devm_kzalloc(tps->dev, psy_name_len, GFP_KERNEL);
> > +   if (!psy_name)
> > +   return -ENOMEM;
> > +
> > +   snprintf(psy_name, psy_name_len, "%s%s", tps6598x_psy_name_prefix,
> > +port_dev_name);
> 
> ...followed by this.
> 
> Please, use devm_kasprintf() instead.

Will do. I'll let the series sit for a couple of days before sending a
v5.
Cheers,
 -- Guido

> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 


Re: [PATCH v2 4/7] dt-bindings: mxsfb: Add interconnect bindings for LCDIF path

2020-12-01 Thread Guido Günther
Hi Martin,
On Tue, Dec 01, 2020 at 01:39:29PM +0100, Martin Kepplinger wrote:
> Add optional interconnect properties for the dram path requests.
> 
> Signed-off-by: Martin Kepplinger 
> ---
>  Documentation/devicetree/bindings/display/mxsfb.txt | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/display/mxsfb.txt 
> b/Documentation/devicetree/bindings/display/mxsfb.txt
> index c985871c46b3..d494a2674290 100644
> --- a/Documentation/devicetree/bindings/display/mxsfb.txt
> +++ b/Documentation/devicetree/bindings/display/mxsfb.txt
> @@ -15,6 +15,12 @@ Required properties:
>  - "pix" for the LCDIF block clock
>  - (MX6SX-only) "axi", "disp_axi" for the bus interface clock
>  
> +Optional properties:
> +- interconnects : interconnect path specifier for LCDIF according to
> + Documentation/devicetree/bindings/interconnect/interconnect.txt.
> +- interconnect-names: the name describing the interconnect path.
> + Should be "dram" for i.MX8MQ.
> +

There's a yaml conversion by Laurentiu for mxsfb in flight:


https://lore.kernel.org/dri-devel/20201007012438.27970-2-laurent.pinch...@ideasonboard.com/

Cheers,
 -- Guido

>  Required sub-nodes:
>- port: The connection to an encoder chip.
>  
> -- 
> 2.20.1
> 


Re: [PATCH v3 2/2] usb: typec: tps6598x: Export some power supply properties

2020-12-01 Thread Guido Günther
Hi,
On Mon, Nov 30, 2020 at 08:35:26PM +0200, Andy Shevchenko wrote:
> On Fri, Nov 27, 2020 at 2:57 PM Guido Günther  wrote:
> >
> > This allows downstream supplies and userspace to detect
> > whether external power is supplied.
> 
> > +   if (!(pwr_status & TPS_POWER_STATUS_CONNECTION) ||
> > +   !(pwr_status & TPS_POWER_STATUS_SOURCESINK)) {
> > +   val->intval = 0;
> > +   } else {
> > +   val->intval = 1;
> > +   }
> 
> Can we please use positive conditionals (which usually are easier to
> read)?

Make sense. Fixed in v4.
 -- Guido

> 
>if ((pwr_status & TPS_POWER_STATUS_CONNECTION) &&
>(pwr_status & TPS_POWER_STATUS_SOURCESINK)) {
>val->intval = 1;
>} else {
>val->intval = 0;
>}
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 


[PATCH v4 2/2] usb: typec: tps6598x: Export some power supply properties

2020-12-01 Thread Guido Günther
This allows downstream supplies and userspace to detect
whether external power is supplied.

Signed-off-by: Guido Günther 
Reviewed-by: Heikki Krogerus 
---
 drivers/usb/typec/Kconfig|   1 +
 drivers/usb/typec/tps6598x.c | 105 +++
 2 files changed, 106 insertions(+)

diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 772b07e9f188..365f905a8e49 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -64,6 +64,7 @@ config TYPEC_HD3SS3220
 config TYPEC_TPS6598X
tristate "TI TPS6598x USB Power Delivery controller driver"
depends on I2C
+   select POWER_SUPPLY
select REGMAP_I2C
select USB_ROLE_SWITCH
help
diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c
index 3db33bb622c3..d7fc2813b4ee 100644
--- a/drivers/usb/typec/tps6598x.c
+++ b/drivers/usb/typec/tps6598x.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -55,6 +56,7 @@ enum {
 };
 
 /* TPS_REG_POWER_STATUS bits */
+#define TPS_POWER_STATUS_CONNECTIONBIT(0)
 #define TPS_POWER_STATUS_SOURCESINKBIT(1)
 #define TPS_POWER_STATUS_PWROPMODE(p)  (((p) & GENMASK(3, 2)) >> 2)
 
@@ -96,8 +98,25 @@ struct tps6598x {
struct typec_partner *partner;
struct usb_pd_identity partner_identity;
struct usb_role_switch *role_sw;
+   struct typec_capability typec_cap;
+
+   struct power_supply *psy;
+   struct power_supply_desc psy_desc;
+   enum power_supply_usb_type usb_type;
+};
+
+static enum power_supply_property tps6598x_psy_props[] = {
+   POWER_SUPPLY_PROP_USB_TYPE,
+   POWER_SUPPLY_PROP_ONLINE,
 };
 
+static enum power_supply_usb_type tps6598x_psy_usb_types[] = {
+   POWER_SUPPLY_USB_TYPE_C,
+   POWER_SUPPLY_USB_TYPE_PD,
+};
+
+static const char *tps6598x_psy_name_prefix = "tps6598x-source-psy-";
+
 /*
  * Max data bytes for Data1, Data2, and other registers. See ch 1.3.2:
  * https://www.ti.com/lit/ug/slvuan1a/slvuan1a.pdf
@@ -248,6 +267,8 @@ static int tps6598x_connect(struct tps6598x *tps, u32 
status)
if (desc.identity)
typec_partner_set_identity(tps->partner);
 
+   power_supply_changed(tps->psy);
+
return 0;
 }
 
@@ -260,6 +281,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 
status)
typec_set_pwr_role(tps->port, TPS_STATUS_PORTROLE(status));
typec_set_vconn_role(tps->port, TPS_STATUS_VCONN(status));
tps6598x_set_data_role(tps, TPS_STATUS_DATAROLE(status), false);
+   power_supply_changed(tps->psy);
 }
 
 static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd,
@@ -467,6 +489,85 @@ static const struct regmap_config tps6598x_regmap_config = 
{
.max_register = 0x7F,
 };
 
+static int tps6598x_psy_get_online(struct tps6598x *tps,
+  union power_supply_propval *val)
+{
+   int ret;
+   u16 pwr_status;
+
+   ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, _status);
+   if (ret < 0)
+   return ret;
+
+   if ((pwr_status & TPS_POWER_STATUS_CONNECTION) &&
+   (pwr_status & TPS_POWER_STATUS_SOURCESINK)) {
+   val->intval = 1;
+   } else {
+   val->intval = 0;
+   }
+   return 0;
+}
+
+static int tps6598x_psy_get_prop(struct power_supply *psy,
+enum power_supply_property psp,
+union power_supply_propval *val)
+{
+   struct tps6598x *tps = power_supply_get_drvdata(psy);
+   u16 pwr_status;
+   int ret = 0;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_USB_TYPE:
+   ret = tps6598x_read16(tps, TPS_REG_POWER_STATUS, _status);
+   if (ret < 0)
+   return ret;
+   if (TPS_POWER_STATUS_PWROPMODE(pwr_status) == TYPEC_PWR_MODE_PD)
+   val->intval = POWER_SUPPLY_USB_TYPE_PD;
+   else
+   val->intval = POWER_SUPPLY_USB_TYPE_C;
+   break;
+   case POWER_SUPPLY_PROP_ONLINE:
+   ret = tps6598x_psy_get_online(tps, val);
+   break;
+   default:
+   ret = -EINVAL;
+   break;
+   }
+
+   return ret;
+}
+
+static int devm_tps6598_psy_register(struct tps6598x *tps)
+{
+   struct power_supply_config psy_cfg = {};
+   const char *port_dev_name = dev_name(tps->dev);
+   size_t psy_name_len = strlen(tps6598x_psy_name_prefix) +
+strlen(port_dev_name) + 1;
+   char *psy_name;
+
+   psy_cfg.drv_data = tps;
+   psy_cfg.fwnode = dev_fwnode(tps->dev);
+   psy_name = devm_kzalloc(tps->dev, psy_name_len, GFP_KERNEL);
+   if (!psy_name)
+   return -ENOMEM;
+
+   snprintf(psy_name, psy_name_len, "%s%s"

[PATCH v4 0/2] usb: typec: tps6598x: Export some power supply properties

2020-12-01 Thread Guido Günther


This allows downstream supplies and userspace to detect whether external power
is supplied.

The Librem 5 has the tp65982 in front of bq25980 charge controller.  Since that
is capable of sinking and sourcing power the online property helps to decide
what to do. It also makes upower happy.

There will be follow up patches providing more properties but these need some
more time to cook and i wanted to check if this is the right way to go?

changes from v3
  - As per review comments from Andy Shevchenko

https://lore.kernel.org/linux-usb/CAHp75VeLZtm85Y=3qmkpgb332wn05-zr-_mrrwxvnqlhazr...@mail.gmail.com/
- Use positive conditionals
  - Add reviewed by from Heikki Krogerus

https://lore.kernel.org/linux-usb/20201130102720.ga2911...@kuha.fi.intel.com/T/#u

https://lore.kernel.org/linux-usb/20201130102942.gb2911...@kuha.fi.intel.com/T/#u
  - Fix typc vs typec typo in commit message

changes from v2
  - As per kernel test robot
https://lore.kernel.org/linux-usb/202011271005.zjvawx74-...@intel.com/
- Flip USB_ROLE_SWITCH and REGMAP_I2C from 'depends on' to 'select'
  This matches tcpm and avoids a config symbol recursion which went
  unnoticed on my arm64 build but trips up x86_64.

changes from v1
  - As per review comments from Heikki Krogerus

https://lore.kernel.org/linux-usb/20201126123552.gp1008...@kuha.fi.intel.com/
- select POWER_SUPPLY
- use POWER_SUPPLY_USB_TYPE_PD when a PD contract got negotiated

To: Heikki Krogerus ,Greg Kroah-Hartman 
,linux-...@vger.kernel.org,linux-kernel@vger.kernel.org,Andy
 Shevchenko 

Guido Günther (2):
  usb: typec: tps6598x: Select USB_ROLE_SWITCH and REGMAP_I2C
  usb: typec: tps6598x: Export some power supply properties

 drivers/usb/typec/Kconfig|   5 +-
 drivers/usb/typec/tps6598x.c | 105 +++
 2 files changed, 108 insertions(+), 2 deletions(-)

-- 
2.29.2



[PATCH v4 1/2] usb: typec: tps6598x: Select USB_ROLE_SWITCH and REGMAP_I2C

2020-12-01 Thread Guido Günther
This is more in line with what tcpm does and will be needed
to avoid recursive dependency like

 > drivers/power/supply/Kconfig:2:error: recursive dependency detected!
   drivers/power/supply/Kconfig:2: symbol POWER_SUPPLY is selected by 
TYPEC_TPS6598X
   drivers/usb/typec/Kconfig:64: symbol TYPEC_TPS6598X depends on REGMAP_I2C
   drivers/base/regmap/Kconfig:19: symbol REGMAP_I2C is selected by 
CHARGER_ADP5061
   drivers/power/supply/Kconfig:93: symbol CHARGER_ADP5061 depends on 
POWER_SUPPLY
   For a resolution refer to Documentation/kbuild/kconfig-language.rst
   subsection "Kconfig recursive dependency limitations"

when selecting POWER_SUPPLY.

Signed-off-by: Guido Günther 
Reviewed-by: Heikki Krogerus 
---
 drivers/usb/typec/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig
index 6c5908a37ee8..772b07e9f188 100644
--- a/drivers/usb/typec/Kconfig
+++ b/drivers/usb/typec/Kconfig
@@ -64,8 +64,8 @@ config TYPEC_HD3SS3220
 config TYPEC_TPS6598X
tristate "TI TPS6598x USB Power Delivery controller driver"
depends on I2C
-   depends on REGMAP_I2C
-   depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH
+   select REGMAP_I2C
+   select USB_ROLE_SWITCH
help
  Say Y or M here if your system has TI TPS65982 or TPS65983 USB Power
  Delivery controller.
-- 
2.29.2



[PATCH v1 0/1] drm/imx/dcss: Add interconnect support

2020-12-01 Thread Guido Günther
This allows us to raise DRAM bandiwth to a high enough value for a
stable picture on i.mx8mq. We pick a bandwidth that should be sufficient
for 4k@60Hz.

This was tested on a Librem 5 with the (not yet) mainline mhdp DP controller.
Without that initial boot works fine but e.g. fb unblank results in a cyan
screen.

Modelled like mdp5_kms.

Guido Günther (1):
  drm/imx/dcss: Add interconnect support

 drivers/gpu/drm/imx/dcss/dcss-dev.c | 47 +++--
 drivers/gpu/drm/imx/dcss/dcss-dev.h |  3 ++
 2 files changed, 48 insertions(+), 2 deletions(-)

-- 
2.29.2



[PATCH v1 1/1] drm/imx/dcss: Add interconnect support

2020-12-01 Thread Guido Günther
This allows us to raise DRAM bandiwth to a high enough value for a
stable picture on i.mx8mq. We pick a bandwidth that should be sufficient
for 4k@60Hz.

Modelled like mdp5_kms.

Signed-off-by: Guido Günther 
---
 drivers/gpu/drm/imx/dcss/dcss-dev.c | 47 +++--
 drivers/gpu/drm/imx/dcss/dcss-dev.h |  3 ++
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.c 
b/drivers/gpu/drm/imx/dcss/dcss-dev.c
index c849533ca83e..e336f03448d6 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-dev.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-dev.c
@@ -15,6 +15,9 @@
 #include "dcss-dev.h"
 #include "dcss-kms.h"
 
+/* sufficient for 4K at 60 Hz */
+#define DCSS_BW_MAX GBps_to_icc(2)
+
 static void dcss_clocks_enable(struct dcss_dev *dcss)
 {
clk_prepare_enable(dcss->axi_clk);
@@ -162,6 +165,31 @@ static void dcss_clks_release(struct dcss_dev *dcss)
devm_clk_put(dcss->dev, dcss->apb_clk);
 }
 
+static int dcss_init_icc(struct dcss_dev *dcss)
+{
+   int ret;
+   struct icc_path *icc_path;
+
+   /* Optional interconnect request */
+   icc_path = of_icc_get(dcss->dev, NULL);
+   if (IS_ERR(icc_path)) {
+   ret = PTR_ERR(icc_path);
+   if (ret == -EPROBE_DEFER)
+   return ret;
+   /* no interconnect support is not necessarily a fatal
+* condition, the platform may simply not have an
+* interconnect driver yet.  But warn about it in case
+* bootloader didn't setup bus clocks high enough for
+* scanout.
+*/
+   dev_warn(dcss->dev, "No interconnect support may cause display 
underflows!\n");
+   return 0;
+   }
+   dcss->icc_path = icc_path;
+   dcss->icc_peak_bw = DCSS_BW_MAX;
+   return 0;
+}
+
 struct dcss_dev *dcss_dev_create(struct device *dev, bool hdmi_output)
 {
struct platform_device *pdev = to_platform_device(dev);
@@ -190,10 +218,14 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bool 
hdmi_output)
dcss->devtype = devtype;
dcss->hdmi_output = hdmi_output;
 
+   ret = dcss_init_icc(dcss);
+   if (ret < 0)
+   goto err;
+
ret = dcss_clks_init(dcss);
if (ret) {
dev_err(dev, "clocks initialization failed\n");
-   goto err;
+   goto icc_err;
}
 
dcss->of_port = of_graph_get_port_by_id(dev->of_node, 0);
@@ -223,7 +255,8 @@ struct dcss_dev *dcss_dev_create(struct device *dev, bool 
hdmi_output)
 
 clks_err:
dcss_clks_release(dcss);
-
+icc_err:
+   icc_put(dcss->icc_path);
 err:
kfree(dcss);
 
@@ -243,6 +276,8 @@ void dcss_dev_destroy(struct dcss_dev *dcss)
 
dcss_clks_release(dcss);
 
+   icc_put(dcss->icc_path);
+
kfree(dcss);
 }
 
@@ -267,6 +302,8 @@ int dcss_dev_suspend(struct device *dev)
 
dcss_clocks_disable(dcss);
 
+   icc_set_bw(dcss->icc_path, 0, 0);
+
return 0;
 }
 
@@ -281,6 +318,8 @@ int dcss_dev_resume(struct device *dev)
return 0;
}
 
+   icc_set_bw(dcss->icc_path, 0, dcss->icc_peak_bw);
+
dcss_clocks_enable(dcss);
 
dcss_blkctl_cfg(dcss->blkctl);
@@ -307,6 +346,8 @@ int dcss_dev_runtime_suspend(struct device *dev)
 
dcss_clocks_disable(dcss);
 
+   icc_set_bw(dcss->icc_path, 0, 0);
+
return 0;
 }
 
@@ -314,6 +355,8 @@ int dcss_dev_runtime_resume(struct device *dev)
 {
struct dcss_dev *dcss = dcss_drv_dev_to_dcss(dev);
 
+   icc_set_bw(dcss->icc_path, 0, dcss->icc_peak_bw);
+
dcss_clocks_enable(dcss);
 
dcss_blkctl_cfg(dcss->blkctl);
diff --git a/drivers/gpu/drm/imx/dcss/dcss-dev.h 
b/drivers/gpu/drm/imx/dcss/dcss-dev.h
index c642ae17837f..1b35a6f0d0d4 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-dev.h
+++ b/drivers/gpu/drm/imx/dcss/dcss-dev.h
@@ -8,6 +8,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #define SET0x04
@@ -85,6 +86,8 @@ struct dcss_dev {
struct clk *pll_phy_ref_clk;
 
bool hdmi_output;
+   struct icc_path *icc_path;
+   u32 icc_peak_bw;
 
void (*disable_callback)(void *data);
struct completion disable_completion;
-- 
2.29.2



Re: [PATCH v2 0/1] arm64: defconfig: Enable Librem 5 hardware

2020-11-29 Thread Guido Günther
Hi Pavel,
On Sat, Nov 28, 2020 at 09:58:48PM +0100, Pavel Machek wrote:
> Hi!
> 
> > > > This series enables components found on Purism's Librem 5
> > > > that are available in mainline.
> > > > 
> > > > - changes from v1
> > > >   - As per review comments from Krzysztof Kozlowski
> > > > 
> > > > https://lore.kernel.org/linux-arm-kernel/cajkoxpdewistg+cmes_wes5oz2f1qeexsus6ihenuls9sax...@mail.gmail.com/
> > > > - Squash config changes into a single commit
> > > >   - Add touch controller
> > > > 
> > > > Patches are on top of Shawn's imx/defconfig
> > > 
> > > Thanks for bringing support for your hardware to the mainline.
> > > 
> > > Can I ask phone-de...@vger.kernel.org to be cc-ed for phone-related
> > > changes?
> > 
> > Good point. Done with v3.
> > 
> > > How complete is the support?
> > 
> > The components enabled should work in 5.11 (there's some LCD/DSI patches
> > in flight (that's why i did not send the corresponding DT addition yet)
> > and we need to submit a DT for Evergreen (imx8mq-librem5r4).
> > 
> > https://git.sigxcpu.org/cgit/talks/2020-debconf-mobile/plain/talk.pdf
> > 
> > is a bit outdated but has some numbers starting on page 24.
> 
> Thanks for pointer :-).
> 
> > > In particular, what interface do you use to configure audio routing
> > > for the modem?
> > 
> > https://salsa.debian.org/DebianOnMobile-team/callaudiod manages
> > > that.
> 
> Does kernel provide mixer interface for callaudiod to do its job?

callaudiod handles selecting e.g. earpiece vs. speaker by selecting the
right pulseaudio ports (it's invoked by calls (the phone call handling
application via DBus) and only relies on the codec being an alsa
device and hence handled by pulseaudio/alsa-ucm.

Wys (https://source.puri.sm/Librem5/wys) manages the routing between the
modem and codec by listening to ModemManager's state and connecting audio
source and sink (again solely via pulsaudio so again just relying on
modem and codec being alsa devices). Since the modem is not part of the
SoC on the Librem 5 it's a completely separate device.

Cheers,
 -- Guido


> 
> Best regards,
> 
>   Pavel
> -- 
> http://www.livejournal.com/~pavelmachek




Re: [PATCH v2 1/1] arm64: defconfig: Enable more Librem 5 hardware

2020-11-28 Thread Guido Günther
Hi,
On Fri, Nov 27, 2020 at 05:45:03PM +0100, Geert Uytterhoeven wrote:
> Hi Guido,
> 
> Thanks for your patch!
> 
> On Fri, Nov 27, 2020 at 5:42 PM Guido Günther  wrote:
> > This enables
> >
> > - CONFIG_BATTERY_MAX17042: battery chip
> > - CONFIG_CHARGER_BQ25980: charge controller
> > - CONFIG_DRM_PANEL_MANTIX_MLAF057WE5: LCD panel
> > - CONFIG_IMX_DCSS: 2nd dislay controller
> 
> display
> 
> > - CONFIG_LEDS_LM3692X: LCD backlight
> > - CONFIG_REGULATOR_TPS65132: regulator for the LCD panel
> > - CONFIG_TOUCHSCREEN_EDT_FT5X06: touch controller
> > - CONFIG_TYPEC_TPS6598X: USB PD controller
> > - CONFIG_VCNL4000: ambient light and proximiry sensor
> 
> proximity

Both fixed in v2 - odd that checkpatch didn't scream.
Thanks!
 -- Guido

> 
> >
> > as modules.
> >
> > Signed-off-by: Guido Günther 
> 
> Gr{oetje,eeting}s,
> 
> Geert
> 
> -- 
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
> ge...@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like 
> that.
> -- Linus Torvalds
> 


[PATCH v2 1/1] arm64: defconfig: Enable more Librem 5 hardware

2020-11-28 Thread Guido Günther
This enables

- CONFIG_BATTERY_MAX17042: battery chip
- CONFIG_CHARGER_BQ25980: charge controller
- CONFIG_DRM_PANEL_MANTIX_MLAF057WE5: LCD panel
- CONFIG_GNSS/CONFIG_GNSS_MTK_SERIAL: GNSS receiver
- CONFIG_IIO_ST_LSM6DSX: IMU
- CONFIG_IMX_DCSS: 2nd display controller
- CONFIG_LEDS_LM3692X: LCD backlight
- CONFIG_REGULATOR_TPS65132: regulator for the LCD panel
- CONFIG_TOUCHSCREEN_EDT_FT5X06: touch controller
- CONFIG_TYPEC_TPS6598X: USB PD controller
- CONFIG_VCNL4000: ambient light and proximity sensor

as modules.

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 270d326d5f28..34b837b866c2 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -240,6 +240,8 @@ CONFIG_HISILICON_LPC=y
 CONFIG_SIMPLE_PM_BUS=y
 CONFIG_FSL_MC_BUS=y
 CONFIG_TEGRA_ACONNECT=m
+CONFIG_GNSS=m
+CONFIG_GNSS_MTK_SERIAL=m
 CONFIG_MTD=y
 CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
@@ -381,6 +383,7 @@ CONFIG_KEYBOARD_IMX_SC_KEY=m
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_TOUCHSCREEN_ATMEL_MXT=m
+CONFIG_TOUCHSCREEN_EDT_FT5X06=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
 CONFIG_INPUT_PM8XXX_VIBRATOR=m
@@ -521,6 +524,8 @@ CONFIG_POWER_RESET_SYSCON=y
 CONFIG_SYSCON_REBOOT_MODE=y
 CONFIG_BATTERY_SBS=m
 CONFIG_BATTERY_BQ27XXX=y
+CONFIG_BATTERY_MAX17042=m
+CONFIG_CHARGER_BQ25980=m
 CONFIG_SENSORS_ARM_SCPI=y
 CONFIG_SENSORS_LM90=m
 CONFIG_SENSORS_PWM_FAN=m
@@ -595,6 +600,7 @@ CONFIG_REGULATOR_QCOM_SMD_RPM=y
 CONFIG_REGULATOR_QCOM_SPMI=y
 CONFIG_REGULATOR_RK808=y
 CONFIG_REGULATOR_S2MPS11=y
+CONFIG_REGULATOR_TPS65132=m
 CONFIG_REGULATOR_VCTRL=m
 CONFIG_RC_CORE=m
 CONFIG_RC_DECODERS=y
@@ -655,6 +661,7 @@ CONFIG_DRM_MSM=m
 CONFIG_DRM_TEGRA=m
 CONFIG_DRM_PANEL_LVDS=m
 CONFIG_DRM_PANEL_SIMPLE=m
+CONFIG_DRM_PANEL_MANTIX_MLAF057WE51=m
 CONFIG_DRM_PANEL_RAYDIUM_RM67191=m
 CONFIG_DRM_PANEL_SITRONIX_ST7703=m
 CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA=m
@@ -669,6 +676,7 @@ CONFIG_DRM_I2C_ADV7511=m
 CONFIG_DRM_I2C_ADV7511_AUDIO=y
 CONFIG_DRM_DW_HDMI_AHB_AUDIO=m
 CONFIG_DRM_DW_HDMI_CEC=m
+CONFIG_DRM_IMX_DCSS=m
 CONFIG_DRM_VC4=m
 CONFIG_DRM_ETNAVIV=m
 CONFIG_DRM_HISI_HIBMC=m
@@ -777,6 +785,7 @@ CONFIG_TYPEC=m
 CONFIG_TYPEC_TCPM=m
 CONFIG_TYPEC_FUSB302=m
 CONFIG_TYPEC_HD3SS3220=m
+CONFIG_TYPEC_TPS6598X=m
 CONFIG_MMC=y
 CONFIG_MMC_BLOCK_MINORS=32
 CONFIG_MMC_ARMMMCI=y
@@ -806,6 +815,7 @@ CONFIG_MMC_SDHCI_AM654=y
 CONFIG_MMC_OWL=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_LM3692X=m
 CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_PWM=y
 CONFIG_LEDS_SYSCON=y
@@ -978,8 +988,10 @@ CONFIG_QCOM_SPMI_ADC5=m
 CONFIG_ROCKCHIP_SARADC=m
 CONFIG_IIO_CROS_EC_SENSORS_CORE=m
 CONFIG_IIO_CROS_EC_SENSORS=m
+CONFIG_IIO_ST_LSM6DSX=m
 CONFIG_IIO_CROS_EC_LIGHT_PROX=m
 CONFIG_SENSORS_ISL29018=m
+CONFIG_VCNL4000=m
 CONFIG_IIO_CROS_EC_BARO=m
 CONFIG_MPL3115=m
 CONFIG_PWM=y
-- 
2.29.2



Re: [PATCH v2 0/1] arm64: defconfig: Enable Librem 5 hardware

2020-11-28 Thread Guido Günther
Hi Pavel,
On Fri, Nov 27, 2020 at 09:09:08PM +0100, Pavel Machek wrote:
> Hi!
> 
> > This series enables components found on Purism's Librem 5
> > that are available in mainline.
> > 
> > - changes from v1
> >   - As per review comments from Krzysztof Kozlowski
> > 
> > https://lore.kernel.org/linux-arm-kernel/cajkoxpdewistg+cmes_wes5oz2f1qeexsus6ihenuls9sax...@mail.gmail.com/
> > - Squash config changes into a single commit
> >   - Add touch controller
> > 
> > Patches are on top of Shawn's imx/defconfig
> 
> Thanks for bringing support for your hardware to the mainline.
> 
> Can I ask phone-de...@vger.kernel.org to be cc-ed for phone-related
> changes?

Good point. Done with v3.

> How complete is the support?

The components enabled should work in 5.11 (there's some LCD/DSI patches
in flight (that's why i did not send the corresponding DT addition yet)
and we need to submit a DT for Evergreen (imx8mq-librem5r4).

https://git.sigxcpu.org/cgit/talks/2020-debconf-mobile/plain/talk.pdf

is a bit outdated but has some numbers starting on page 24.

> In particular, what interface do you use to configure audio routing
> for the modem?

https://salsa.debian.org/DebianOnMobile-team/callaudiod manages that.

Cheers,
 -- Guido

> 
> Best regards,
>   Pavel
> -- 
> http://www.livejournal.com/~pavelmachek




[PATCH v2 0/1] arm64: defconfig: Enable Librem 5 hardware

2020-11-28 Thread Guido Günther


This series enables components found on Purism's Librem 5
that are available in mainline.

- changes from v2
  - As per review comments from Geert Uytterhoeven

https://lore.kernel.org/lkml/camuhmduk3gbhwr94bcjrbknvdpqsjrmn0itrs65ay5kquca...@mail.gmail.com/
- Fix commit messages typos
  - Add GNSS receiver and IMU

- changes from v1
  - As per review comments from Krzysztof Kozlowski

https://lore.kernel.org/linux-arm-kernel/cajkoxpdewistg+cmes_wes5oz2f1qeexsus6ihenuls9sax...@mail.gmail.com/
- Squash config changes into a single commit
  - Add touch controller

Patches are on top of Shawn's imx/defconfig

Guido Günther (1):
  arm64: defconfig: Enable more Librem 5 hardware

 arch/arm64/configs/defconfig | 12 
 1 file changed, 12 insertions(+)

-- 
2.29.2



[PATCH v2 1/1] arm64: defconfig: Enable more Librem 5 hardware

2020-11-27 Thread Guido Günther
This enables

- CONFIG_BATTERY_MAX17042: battery chip
- CONFIG_CHARGER_BQ25980: charge controller
- CONFIG_DRM_PANEL_MANTIX_MLAF057WE5: LCD panel
- CONFIG_IMX_DCSS: 2nd dislay controller
- CONFIG_LEDS_LM3692X: LCD backlight
- CONFIG_REGULATOR_TPS65132: regulator for the LCD panel
- CONFIG_TOUCHSCREEN_EDT_FT5X06: touch controller
- CONFIG_TYPEC_TPS6598X: USB PD controller
- CONFIG_VCNL4000: ambient light and proximiry sensor

as modules.

Signed-off-by: Guido Günther 
---
 arch/arm64/configs/defconfig | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 270d326d5f28..9c0a9e014f28 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -381,6 +381,7 @@ CONFIG_KEYBOARD_IMX_SC_KEY=m
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_TOUCHSCREEN_ATMEL_MXT=m
+CONFIG_TOUCHSCREEN_EDT_FT5X06=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
 CONFIG_INPUT_PM8XXX_VIBRATOR=m
@@ -521,6 +522,8 @@ CONFIG_POWER_RESET_SYSCON=y
 CONFIG_SYSCON_REBOOT_MODE=y
 CONFIG_BATTERY_SBS=m
 CONFIG_BATTERY_BQ27XXX=y
+CONFIG_BATTERY_MAX17042=m
+CONFIG_CHARGER_BQ25980=m
 CONFIG_SENSORS_ARM_SCPI=y
 CONFIG_SENSORS_LM90=m
 CONFIG_SENSORS_PWM_FAN=m
@@ -595,6 +598,7 @@ CONFIG_REGULATOR_QCOM_SMD_RPM=y
 CONFIG_REGULATOR_QCOM_SPMI=y
 CONFIG_REGULATOR_RK808=y
 CONFIG_REGULATOR_S2MPS11=y
+CONFIG_REGULATOR_TPS65132=m
 CONFIG_REGULATOR_VCTRL=m
 CONFIG_RC_CORE=m
 CONFIG_RC_DECODERS=y
@@ -655,6 +659,7 @@ CONFIG_DRM_MSM=m
 CONFIG_DRM_TEGRA=m
 CONFIG_DRM_PANEL_LVDS=m
 CONFIG_DRM_PANEL_SIMPLE=m
+CONFIG_DRM_PANEL_MANTIX_MLAF057WE51=m
 CONFIG_DRM_PANEL_RAYDIUM_RM67191=m
 CONFIG_DRM_PANEL_SITRONIX_ST7703=m
 CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA=m
@@ -669,6 +674,7 @@ CONFIG_DRM_I2C_ADV7511=m
 CONFIG_DRM_I2C_ADV7511_AUDIO=y
 CONFIG_DRM_DW_HDMI_AHB_AUDIO=m
 CONFIG_DRM_DW_HDMI_CEC=m
+CONFIG_DRM_IMX_DCSS=m
 CONFIG_DRM_VC4=m
 CONFIG_DRM_ETNAVIV=m
 CONFIG_DRM_HISI_HIBMC=m
@@ -777,6 +783,7 @@ CONFIG_TYPEC=m
 CONFIG_TYPEC_TCPM=m
 CONFIG_TYPEC_FUSB302=m
 CONFIG_TYPEC_HD3SS3220=m
+CONFIG_TYPEC_TPS6598X=m
 CONFIG_MMC=y
 CONFIG_MMC_BLOCK_MINORS=32
 CONFIG_MMC_ARMMMCI=y
@@ -806,6 +813,7 @@ CONFIG_MMC_SDHCI_AM654=y
 CONFIG_MMC_OWL=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_LM3692X=m
 CONFIG_LEDS_GPIO=y
 CONFIG_LEDS_PWM=y
 CONFIG_LEDS_SYSCON=y
@@ -980,6 +988,7 @@ CONFIG_IIO_CROS_EC_SENSORS_CORE=m
 CONFIG_IIO_CROS_EC_SENSORS=m
 CONFIG_IIO_CROS_EC_LIGHT_PROX=m
 CONFIG_SENSORS_ISL29018=m
+CONFIG_VCNL4000=m
 CONFIG_IIO_CROS_EC_BARO=m
 CONFIG_MPL3115=m
 CONFIG_PWM=y
-- 
2.29.2



Re: [PATCH v1 6/8] arm64: defconfig: Enable CONFIG_VCNL4000

2020-11-27 Thread Guido Günther
Hi Krzysztof,
On Fri, Nov 27, 2020 at 05:13:58PM +0100, Krzysztof Kozlowski wrote:
> On Fri, 27 Nov 2020 at 15:23, Guido Günther  wrote:
> >
> > This is the Librem 5's proximity sensor.
> 
> Just squash all of them. Enabling option by option is too much.

Done for v2.
Cheers,
 -- Guido

> 
> Best regards,
> Krzysztof
> 


  1   2   3   4   >