* [PATCH] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property
@ 2024-07-04 14:57 Josua Mayer
2024-08-04 17:48 ` Vinod Koul
2024-10-07 15:48 ` Vinod Koul
0 siblings, 2 replies; 4+ messages in thread
From: Josua Mayer @ 2024-07-04 14:57 UTC (permalink / raw)
To: Vinod Koul, Kishon Vijay Abraham I; +Cc: linux-phy, linux-kernel, Josua Mayer
CP11x UTMI PHY supports swapping D+/D- signals via digital control
register 1.
Add support for the "swap-dx-lanes" device-tree property, which lists
the port-ids that should swap D+ and D-.
The property is evaluated in probe and applied before power-on
during mvebu_cp110_utmi_port_setup.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/phy/marvell/phy-mvebu-cp110-utmi.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
index 4922a5f3327d..5e403f842e9a 100644
--- a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
+++ b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
@@ -62,6 +62,8 @@
#define SQ_AMP_CAL_MASK GENMASK(2, 0)
#define SQ_AMP_CAL_VAL 1
#define SQ_AMP_CAL_EN BIT(3)
+#define UTMI_DIG_CTRL1_REG 0x20
+#define SWAP_DPDM BIT(15)
#define UTMI_CTRL_STATUS0_REG 0x24
#define SUSPENDM BIT(22)
#define TEST_SEL BIT(25)
@@ -104,6 +106,7 @@ struct mvebu_cp110_utmi_port {
struct mvebu_cp110_utmi *priv;
u32 id;
enum usb_dr_mode dr_mode;
+ bool swap_dx;
};
static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port)
@@ -159,6 +162,13 @@ static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port)
reg &= ~(VDAT_MASK | VSRC_MASK);
reg |= (VDAT_VAL << VDAT_OFFSET) | (VSRC_VAL << VSRC_OFFSET);
writel(reg, PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG);
+
+ /* Swap D+/D- */
+ reg = readl(PORT_REGS(port) + UTMI_DIG_CTRL1_REG);
+ reg &= ~(SWAP_DPDM);
+ if (port->swap_dx)
+ reg |= SWAP_DPDM;
+ writel(reg, PORT_REGS(port) + UTMI_DIG_CTRL1_REG);
}
static int mvebu_cp110_utmi_phy_power_off(struct phy *phy)
@@ -285,7 +295,10 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
struct mvebu_cp110_utmi *utmi;
struct phy_provider *provider;
struct device_node *child;
+ struct property *prop;
+ const __be32 *p;
u32 usb_devices = 0;
+ u32 swap_dx = 0;
utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL);
if (!utmi)
@@ -345,6 +358,10 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
}
}
+ of_property_for_each_u32(dev->of_node, "swap-dx-lanes", prop, p, swap_dx)
+ if (swap_dx == port_id)
+ port->swap_dx = 1;
+
/* Retrieve PHY capabilities */
utmi->ops = &mvebu_cp110_utmi_phy_ops;
---
base-commit: 4de480264948cbf2b08a72c39ee122a9f9761e03
change-id: 20240704-mvebu-utmi-phy-84aa3bf3957d
Sincerely,
--
Josua Mayer <josua@solid-run.com>
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property
2024-07-04 14:57 [PATCH] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property Josua Mayer
@ 2024-08-04 17:48 ` Vinod Koul
2024-09-03 8:04 ` Josua Mayer
2024-10-07 15:48 ` Vinod Koul
1 sibling, 1 reply; 4+ messages in thread
From: Vinod Koul @ 2024-08-04 17:48 UTC (permalink / raw)
To: Josua Mayer; +Cc: Kishon Vijay Abraham I, linux-phy, linux-kernel
On 04-07-24, 16:57, Josua Mayer wrote:
> CP11x UTMI PHY supports swapping D+/D- signals via digital control
> register 1.
>
> Add support for the "swap-dx-lanes" device-tree property, which lists
> the port-ids that should swap D+ and D-.
> The property is evaluated in probe and applied before power-on
> during mvebu_cp110_utmi_port_setup.
It fails my build tests
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:
In function ‘mvebu_cp110_utmi_phy_probe’:
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:89:
error: macro "of_property_for_each_u32" passed 5 arguments, but takes
just 3
361 | of_property_for_each_u32(dev->of_node,
"swap-dx-lanes", prop, p, swap_dx)
|
^
In file included from
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:15:
include/linux/of.h:1432: note:
macro "of_property_for_each_u32" defined here
1432 | #define of_property_for_each_u32(np, propname, u)
\
|
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:17:
error: ‘of_property_for_each_u32’ undeclared (first use in this
function); did you mean ‘of_property_read_u32’?
361 | of_property_for_each_u32(dev->of_node,
"swap-dx-lanes", prop, p, swap_dx)
| ^~~~~~~~~~~~~~~~~~~~~~~~
| of_property_read_u32
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:17:
note: each undeclared identifier is reported only once for each function
it appears in
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:41:
error: expected ‘;’ before ‘if’
361 | of_property_for_each_u32(dev->of_node,
"swap-dx-lanes", prop, p, swap_dx)
| ^
| ;
362 | if (swap_dx == port_id)
| ~~
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:301:13:
error: unused variable ‘swap_dx’ [-Werror=unused-variable]
301 | u32 swap_dx = 0;
| ^~~~~~~
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:299:23:
error: unused variable ‘p’ [-Werror=unused-variable]
299 | const __be32 *p;
| ^
drivers/phy/marvell/phy-mvebu-cp110-utmi.c:298:26:
error: unused variable ‘prop’ [-Werror=unused-variable]
298 | struct property *prop;
| ^~~~
cc1: all warnings being treated as errors
>
> Signed-off-by: Josua Mayer <josua@solid-run.com>
> ---
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
> index 4922a5f3327d..5e403f842e9a 100644
> --- a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
> +++ b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
> @@ -62,6 +62,8 @@
> #define SQ_AMP_CAL_MASK GENMASK(2, 0)
> #define SQ_AMP_CAL_VAL 1
> #define SQ_AMP_CAL_EN BIT(3)
> +#define UTMI_DIG_CTRL1_REG 0x20
> +#define SWAP_DPDM BIT(15)
> #define UTMI_CTRL_STATUS0_REG 0x24
> #define SUSPENDM BIT(22)
> #define TEST_SEL BIT(25)
> @@ -104,6 +106,7 @@ struct mvebu_cp110_utmi_port {
> struct mvebu_cp110_utmi *priv;
> u32 id;
> enum usb_dr_mode dr_mode;
> + bool swap_dx;
> };
>
> static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port)
> @@ -159,6 +162,13 @@ static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port)
> reg &= ~(VDAT_MASK | VSRC_MASK);
> reg |= (VDAT_VAL << VDAT_OFFSET) | (VSRC_VAL << VSRC_OFFSET);
> writel(reg, PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG);
> +
> + /* Swap D+/D- */
> + reg = readl(PORT_REGS(port) + UTMI_DIG_CTRL1_REG);
> + reg &= ~(SWAP_DPDM);
> + if (port->swap_dx)
> + reg |= SWAP_DPDM;
> + writel(reg, PORT_REGS(port) + UTMI_DIG_CTRL1_REG);
> }
>
> static int mvebu_cp110_utmi_phy_power_off(struct phy *phy)
> @@ -285,7 +295,10 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
> struct mvebu_cp110_utmi *utmi;
> struct phy_provider *provider;
> struct device_node *child;
> + struct property *prop;
> + const __be32 *p;
> u32 usb_devices = 0;
> + u32 swap_dx = 0;
>
> utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL);
> if (!utmi)
> @@ -345,6 +358,10 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
> }
> }
>
> + of_property_for_each_u32(dev->of_node, "swap-dx-lanes", prop, p, swap_dx)
> + if (swap_dx == port_id)
> + port->swap_dx = 1;
> +
> /* Retrieve PHY capabilities */
> utmi->ops = &mvebu_cp110_utmi_phy_ops;
>
>
> ---
> base-commit: 4de480264948cbf2b08a72c39ee122a9f9761e03
> change-id: 20240704-mvebu-utmi-phy-84aa3bf3957d
>
> Sincerely,
> --
> Josua Mayer <josua@solid-run.com>
--
~Vinod
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property
2024-08-04 17:48 ` Vinod Koul
@ 2024-09-03 8:04 ` Josua Mayer
0 siblings, 0 replies; 4+ messages in thread
From: Josua Mayer @ 2024-09-03 8:04 UTC (permalink / raw)
To: Vinod Koul
Cc: Kishon Vijay Abraham I, linux-phy@lists.infradead.org,
linux-kernel@vger.kernel.org
Hi Vinod,
Thank you for looking at my patch!
Am 04.08.24 um 20:48 schrieb Vinod Koul:
> On 04-07-24, 16:57, Josua Mayer wrote:
>> CP11x UTMI PHY supports swapping D+/D- signals via digital control
>> register 1.
>>
>> Add support for the "swap-dx-lanes" device-tree property, which lists
>> the port-ids that should swap D+ and D-.
>> The property is evaluated in probe and applied before power-on
>> during mvebu_cp110_utmi_port_setup.
> It fails my build tests
I will rebase on v6.11-rc1, compile-test and then submit a new version.
>
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:
> In function ‘mvebu_cp110_utmi_phy_probe’:
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:89:
> error: macro "of_property_for_each_u32" passed 5 arguments, but takes
> just 3
> 361 | of_property_for_each_u32(dev->of_node,
> "swap-dx-lanes", prop, p, swap_dx)
> |
> ^
> In file included from
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:15:
> include/linux/of.h:1432: note:
> macro "of_property_for_each_u32" defined here
> 1432 | #define of_property_for_each_u32(np, propname, u)
> \
> |
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:17:
> error: ‘of_property_for_each_u32’ undeclared (first use in this
> function); did you mean ‘of_property_read_u32’?
> 361 | of_property_for_each_u32(dev->of_node,
> "swap-dx-lanes", prop, p, swap_dx)
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> | of_property_read_u32
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:17:
> note: each undeclared identifier is reported only once for each function
> it appears in
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:361:41:
> error: expected ‘;’ before ‘if’
> 361 | of_property_for_each_u32(dev->of_node,
> "swap-dx-lanes", prop, p, swap_dx)
> | ^
> | ;
> 362 | if (swap_dx == port_id)
> | ~~
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:301:13:
> error: unused variable ‘swap_dx’ [-Werror=unused-variable]
> 301 | u32 swap_dx = 0;
> | ^~~~~~~
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:299:23:
> error: unused variable ‘p’ [-Werror=unused-variable]
> 299 | const __be32 *p;
> | ^
> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:298:26:
> error: unused variable ‘prop’ [-Werror=unused-variable]
> 298 | struct property *prop;
> | ^~~~
> cc1: all warnings being treated as errors
>
>
>> Signed-off-by: Josua Mayer <josua@solid-run.com>
>> ---
>> drivers/phy/marvell/phy-mvebu-cp110-utmi.c | 17 +++++++++++++++++
>> 1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
>> index 4922a5f3327d..5e403f842e9a 100644
>> --- a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
>> +++ b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
>> @@ -62,6 +62,8 @@
>> #define SQ_AMP_CAL_MASK GENMASK(2, 0)
>> #define SQ_AMP_CAL_VAL 1
>> #define SQ_AMP_CAL_EN BIT(3)
>> +#define UTMI_DIG_CTRL1_REG 0x20
>> +#define SWAP_DPDM BIT(15)
>> #define UTMI_CTRL_STATUS0_REG 0x24
>> #define SUSPENDM BIT(22)
>> #define TEST_SEL BIT(25)
>> @@ -104,6 +106,7 @@ struct mvebu_cp110_utmi_port {
>> struct mvebu_cp110_utmi *priv;
>> u32 id;
>> enum usb_dr_mode dr_mode;
>> + bool swap_dx;
>> };
>>
>> static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port)
>> @@ -159,6 +162,13 @@ static void mvebu_cp110_utmi_port_setup(struct mvebu_cp110_utmi_port *port)
>> reg &= ~(VDAT_MASK | VSRC_MASK);
>> reg |= (VDAT_VAL << VDAT_OFFSET) | (VSRC_VAL << VSRC_OFFSET);
>> writel(reg, PORT_REGS(port) + UTMI_CHGDTC_CTRL_REG);
>> +
>> + /* Swap D+/D- */
>> + reg = readl(PORT_REGS(port) + UTMI_DIG_CTRL1_REG);
>> + reg &= ~(SWAP_DPDM);
>> + if (port->swap_dx)
>> + reg |= SWAP_DPDM;
>> + writel(reg, PORT_REGS(port) + UTMI_DIG_CTRL1_REG);
>> }
>>
>> static int mvebu_cp110_utmi_phy_power_off(struct phy *phy)
>> @@ -285,7 +295,10 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
>> struct mvebu_cp110_utmi *utmi;
>> struct phy_provider *provider;
>> struct device_node *child;
>> + struct property *prop;
>> + const __be32 *p;
>> u32 usb_devices = 0;
>> + u32 swap_dx = 0;
>>
>> utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL);
>> if (!utmi)
>> @@ -345,6 +358,10 @@ static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
>> }
>> }
>>
>> + of_property_for_each_u32(dev->of_node, "swap-dx-lanes", prop, p, swap_dx)
>> + if (swap_dx == port_id)
>> + port->swap_dx = 1;
>> +
>> /* Retrieve PHY capabilities */
>> utmi->ops = &mvebu_cp110_utmi_phy_ops;
>>
>>
>> ---
>> base-commit: 4de480264948cbf2b08a72c39ee122a9f9761e03
>> change-id: 20240704-mvebu-utmi-phy-84aa3bf3957d
>>
>> Sincerely,
>> --
>> Josua Mayer <josua@solid-run.com>
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property
2024-07-04 14:57 [PATCH] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property Josua Mayer
2024-08-04 17:48 ` Vinod Koul
@ 2024-10-07 15:48 ` Vinod Koul
1 sibling, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2024-10-07 15:48 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Josua Mayer; +Cc: linux-phy, linux-kernel
On Thu, 04 Jul 2024 16:57:43 +0200, Josua Mayer wrote:
> CP11x UTMI PHY supports swapping D+/D- signals via digital control
> register 1.
>
> Add support for the "swap-dx-lanes" device-tree property, which lists
> the port-ids that should swap D+ and D-.
> The property is evaluated in probe and applied before power-on
> during mvebu_cp110_utmi_port_setup.
>
> [...]
Applied, thanks!
[1/1] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property
commit: d6c496f05e98c6d25ac73f23fd0075913620de56
Best regards,
--
~Vinod
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-07 15:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04 14:57 [PATCH] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property Josua Mayer
2024-08-04 17:48 ` Vinod Koul
2024-09-03 8:04 ` Josua Mayer
2024-10-07 15:48 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).