diff mbox series

[v2] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property

Message ID 20240903-mvebu-utmi-phy-v2-1-7f49c131fad0@solid-run.com
State Superseded
Headers show
Series [v2] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property | expand

Commit Message

Josua Mayer Sept. 3, 2024, 8:41 a.m. UTC
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>
---
Changes in v2:
- fixed compile error introduced with v6.11-rc1:
  parameters of of_property_for_each_u32 were changed from 5 to 3.
  (Reported-by: Vinod Koul <vkoul@kernel.org>)
- rebased on v6.11-rc1
- Link to v1: https://lore.kernel.org/r/20240704-mvebu-utmi-phy-v1-1-9d3c8eea46e5@solid-run.com
---
 drivers/phy/marvell/phy-mvebu-cp110-utmi.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)


---
base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b
change-id: 20240704-mvebu-utmi-phy-84aa3bf3957d

Best regards,

Comments

kernel test robot Sept. 3, 2024, 5:50 p.m. UTC | #1
Hi Josua,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 8400291e289ee6b2bf9779ff1c83a291501f017b]

url:    https://github.com/intel-lab-lkp/linux/commits/Josua-Mayer/phy-mvebu-cp110-utmi-support-swapping-d-d-lanes-by-dts-property/20240903-164826
base:   8400291e289ee6b2bf9779ff1c83a291501f017b
patch link:    https://lore.kernel.org/r/20240903-mvebu-utmi-phy-v2-1-7f49c131fad0%40solid-run.com
patch subject: [PATCH v2] phy: mvebu-cp110-utmi: support swapping d+/d- lanes by dts property
config: arc-randconfig-r071-20240903 (https://download.01.org/0day-ci/archive/20240904/202409040139.hNh9K4iF-lkp@intel.com/config)
compiler: arceb-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240904/202409040139.hNh9K4iF-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409040139.hNh9K4iF-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/phy/marvell/phy-mvebu-cp110-utmi.c:110: warning: Function parameter or struct member 'swap_dx' not described in 'mvebu_cp110_utmi_port'


vim +110 drivers/phy/marvell/phy-mvebu-cp110-utmi.c

2fc989f74b8dac Konstantin Porotchkin 2021-03-07   97  
2fc989f74b8dac Konstantin Porotchkin 2021-03-07   98  /**
2fc989f74b8dac Konstantin Porotchkin 2021-03-07   99   * struct mvebu_cp110_utmi_port - PHY port data
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  100   *
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  101   * @priv: PHY driver data
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  102   * @id: PHY port ID
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  103   * @dr_mode: PHY connection: USB_DR_MODE_HOST or USB_DR_MODE_PERIPHERAL
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  104   */
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  105  struct mvebu_cp110_utmi_port {
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  106  	struct mvebu_cp110_utmi *priv;
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  107  	u32 id;
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  108  	enum usb_dr_mode dr_mode;
7208af25e8a67e Josua Mayer           2024-09-03  109  	bool swap_dx;
2fc989f74b8dac Konstantin Porotchkin 2021-03-07 @110  };
2fc989f74b8dac Konstantin Porotchkin 2021-03-07  111
diff mbox series

Patch

diff --git a/drivers/phy/marvell/phy-mvebu-cp110-utmi.c b/drivers/phy/marvell/phy-mvebu-cp110-utmi.c
index 4922a5f3327d..12d619d9cf97 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)
@@ -286,6 +296,7 @@  static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
 	struct phy_provider *provider;
 	struct device_node *child;
 	u32 usb_devices = 0;
+	u32 swap_dx = 0;
 
 	utmi = devm_kzalloc(dev, sizeof(*utmi), GFP_KERNEL);
 	if (!utmi)
@@ -345,6 +356,10 @@  static int mvebu_cp110_utmi_phy_probe(struct platform_device *pdev)
 			}
 		}
 
+		of_property_for_each_u32(dev->of_node, "swap-dx-lanes", swap_dx)
+			if (swap_dx == port_id)
+				port->swap_dx = 1;
+
 		/* Retrieve PHY capabilities */
 		utmi->ops = &mvebu_cp110_utmi_phy_ops;