Commit 825e6180 authored by Josua Mayer's avatar Josua Mayer

linux: lx2160a: add quirk, mmc controller has no LEDs

In Linux we can by default see 2 LEDs - mmc:0, mmc:1 - created in
/sys/class/leds/. This is unexpected for 2 reasons:

1. LX2160A has no mention of mmc led functionality for the pads
2. LX2160A reference manual describes the relevant bit in control
   register as reserved.

Enable SDHCI_QUIRK_NO_LED for LX2160A.
parent 910d43ae
From 531dfd92649bf52a97f086c0462313b6f4eea8f8 Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Thu, 20 Apr 2023 16:17:23 +0300
Subject: [PATCH 64/66] net: dpaa2: properly cleanup resources when dpmac probe
fails
dpmac probe function allocates several resources dynamically such as
IRQs and dpmac objects. If probe fails for any reason, the next probe
can no longer succeed.
Add additional labels to the return path to free all resources.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index a4aad5431e82..69b6c2ebaaa2 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -1006,18 +1006,18 @@ static int dpaa2_mac_probe(struct fsl_mc_device *mc_dev)
err = dpmac_get_attributes(mc_dev->mc_io, 0, mc_dev->mc_handle, &priv->attr);
if (err) {
dev_err(dev, "dpmac_get_attributes() = %d\n", err);
- goto free_portal;
+ goto free_dpmac;
}
err = dpaa2_mac_setup_irqs(mc_dev);
if (err) {
err = -EFAULT;
- goto free_portal;
+ goto free_dpmac;
}
err = dpaa2_mac_open(priv);
if (err)
- goto free_portal;
+ goto free_irqs;
if (is_of_node(priv->fw_node)) {
struct device_node *np;
@@ -1036,7 +1036,8 @@ static int dpaa2_mac_probe(struct fsl_mc_device *mc_dev)
dev_err(dev, "failed to get link-status led from 'link-status-led' property: %pe\n", priv->link_status_led);
fallthrough;
case -EPROBE_DEFER:
- goto free_portal;
+ dev_err(dev, "link-status-led defer\n");
+ goto free_irqs;
};
}
}
@@ -1045,7 +1046,7 @@ static int dpaa2_mac_probe(struct fsl_mc_device *mc_dev)
err = dpaa2_mac_connect(priv);
if (err) {
dev_err(dev, "Error connecting to the MAC endpoint\n");
- goto free_portal;
+ goto free_irqs;
}
}
@@ -1065,6 +1066,10 @@ static int dpaa2_mac_probe(struct fsl_mc_device *mc_dev)
}
return 0;
+free_irqs:
+ fsl_mc_free_irqs(mc_dev);
+free_dpmac:
+ dpaa2_mac_close(priv);
free_portal:
fsl_mc_portal_free(mc_dev->mc_io);
unregister_netdev:
--
2.35.3
From bd365fe9e953053b59aa08591e58887701ca833a Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Thu, 20 Apr 2023 16:13:43 +0300
Subject: [PATCH 65/66] leds: core: fix of_led_get_hack to return error on
invalid dts node
When unchecked, class_find_device_by_of_node will just return the first
registered led in the system. This can cause binding to unintentional
LEDs, such as the mmc host-controller led.
Check value of device-tree pointer and return -ENOENT when NULL.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/leds/led-class.c | 3 +++
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 1 +
drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 1 +
drivers/net/phy/sfp.c | 1 +
4 files changed, 6 insertions(+)
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 3198ebb5cfaf..e2591a491c48 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -261,6 +261,9 @@ struct led_classdev *of_led_get_hack(struct device_node *led_node)
struct device *led_dev;
struct led_classdev *led_cdev;
+ if (!led_node)
+ return ERR_PTR(-ENOENT);
+
led_dev = class_find_device_by_of_node(leds_class, led_node);
if (!led_dev)
return ERR_PTR(-EPROBE_DEFER);
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 430ab61f71dc..f20396e305ea 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -4176,6 +4176,7 @@ static int dpaa2_eth_connect_mac(struct dpaa2_eth_priv *priv)
err = PTR_ERR(mac->link_status_led);
switch (err) {
case -ENODEV:
+ case -ENOENT:
mac->link_status_led = NULL;
break;
default:
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index 69b6c2ebaaa2..531ece326d5d 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -1030,6 +1030,7 @@ static int dpaa2_mac_probe(struct fsl_mc_device *mc_dev)
err = PTR_ERR(priv->link_status_led);
switch (err) {
case -ENODEV:
+ case -ENOENT:
priv->link_status_led = NULL;
break;
default:
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 0f18e77b8b68..085d7c265e44 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2439,6 +2439,7 @@ static int sfp_probe(struct platform_device *pdev)
if (IS_ERR(sfp->link_status_led)) {
switch (PTR_ERR(sfp->link_status_led)) {
case -ENODEV:
+ case -ENOENT:
sfp->link_status_led = NULL;
break;
default:
--
2.35.3
From 0cd0483c5b5414050d5b558f77ed925b4b38aff5 Mon Sep 17 00:00:00 2001
From: Josua Mayer <josua@solid-run.com>
Date: Sun, 20 Nov 2022 17:59:15 +0200
Subject: [PATCH 66/66] arch: arm64: dts: lx2160a: mmc controller has no led
line, enable quirk
At runtime we can by default see 2 LEDs - mmc:0, mmc:1 - created in
/sys/class/leds/. This is unexpected for 2 reasons:
1. LX2160A has no mention of mmc led functionality for the pads
2. LX2160A reference manual describes the relevant bit in control
register as reserved.
Add a new soc-specific compatible string "fsl,lx2160a-esdhc" and enable
the existing SDHCI_QUIRK_NO_LED.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 4 ++--
drivers/mmc/host/sdhci-of-esdhc.c | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
index d4c73170c0a0..c83ff74ec9b6 100644
--- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
@@ -866,7 +866,7 @@ dspi2: spi@2120000 {
};
esdhc0: esdhc@2140000 {
- compatible = "fsl,esdhc";
+ compatible = "fsl,lx2160a-esdhc", "fsl,esdhc";
reg = <0x0 0x2140000 0x0 0x10000>;
interrupts = <0 28 0x4>; /* Level high type */
clocks = <&clockgen 4 1>;
@@ -879,7 +879,7 @@ esdhc0: esdhc@2140000 {
};
esdhc1: esdhc@2150000 {
- compatible = "fsl,esdhc";
+ compatible = "fsl,lx2160a-esdhc", "fsl,esdhc";
reg = <0x0 0x2150000 0x0 0x10000>;
interrupts = <0 63 0x4>; /* Level high type */
clocks = <&clockgen 4 1>;
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 83a28e5c9a93..e6d1d5c8a2a9 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -1504,6 +1504,11 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
esdhc->quirk_ignore_data_inhibit = true;
}
+ if (of_device_is_compatible(np, "fsl,lx2160a-esdhc")) {
+ /* no led line, reference manual marks register 0x28 bit 0 reserved */
+ host->quirks |= SDHCI_QUIRK_NO_LED;
+ }
+
/* call to generic mmc_of_parse to support additional capabilities */
ret = mmc_of_parse(host->mmc);
if (ret)
--
2.35.3
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment