Skip to contentSkip to conversation

add MDIO bus multiplexer driven by a regmap device

PATCH Superseded Pankaj Bansal 3 participants 6 messages Feb 4, 2019 – Feb 5, 2019

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover add MDIO bus multiplexer driven by a regmap device

Add support for an MDIO bus multiplexer controlled by a regmap device, like an FPGA.

These apis is an extension of the existing driver
drivers/net/phy/mdio-mux-mmioreg.c.

The problem with mmioreg driver is that it can operate only on memory mapped devices.
but if we have a device that controls mdio muxing and that device is controlled using i2c or spi, then it will not work.

Therefore, added apis that can be used by regmap device to control mdio mux.

Tested on a NXP LX2160AQDS board which uses the "QIXIS" FPGA attached to the i2c bus.

This is my second attempt at this.
In my previous approach i wrote a separate driver for regmap apis. But then i realized that it is not meant to control a specific device. It is meant to control some registers of parent device. Therefore, IMO this should not be a Platform driver and there should not be any "compatible" property to which this driver is associated.

The previous approach patches and discussion can be accessed here:
https://www.mail-archive.com/[email protected]/msg252744.html

Cc Varun Sethi <[email protected]>

---

Notes:

	V1:
	- https://www.spinics.net/lists/netdev/msg548027.html

Pankaj Bansal (2):
dt-bindings: net: add MDIO bus multiplexer driven by a regmap device netdev/phy: add MDIO bus multiplexer driven by a regmap

 .../bindings/net/mdio-mux-regmap.txt          | 167 +++++++++++++++++
 drivers/net/phy/Kconfig                       |  14 ++
 drivers/net/phy/Makefile                      |   1 +
 drivers/net/phy/mdio-mux-regmap.c             | 171 ++++++++++++++++++
 include/linux/mdio-mux.h                      |  34 ++++
 5 files changed, 387 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/mdio-mux-regmap.txt
 create mode 100644 drivers/net/phy/mdio-mux-regmap.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/2 dt-bindings: net: add MDIO bus multiplexer driven by a regmap device

Add support for an MDIO bus multiplexer controlled by a regmap device, like an FPGA.

Tested on a NXP LX2160AQDS board which uses the "QIXIS" FPGA attached to the i2c bus.

---

Notes:
V2:
- New file describing the device tree bindings for regmap controlled devices' mdio mux

 .../bindings/net/mdio-mux-regmap.txt         | 167 +++++++++++++++++
 1 file changed, 167 insertions(+)
Documentation/devicetree/bindings/net/mdio-mux-regmap.txt new file +167 -0
new file mode 100644
index 000000000000..8968f317965f
@@ -0,0 +1,167 @@
+Properties for an MDIO bus multiplexer controlled by a regmap
+
+This is a special case of a MDIO bus multiplexer.  A regmap device,
+like an FPGA, is used to control which child bus is connected.  The mdio-mux
+node must be a child of the device that is controlled by a regmap.
+The driver currently only supports devices with upto 32-bit registers.
+
+Required properties in addition to the generic multiplexer properties:
+
+- reg : integer, contains the offset of the register that controls the bus
+	multiplexer. it can be 32 bit number.
+
+- mux-mask : integer, contains an 32 bit mask that specifies which
+	bits in the register control the actual bus multiplexer.  The
+	'reg' property of each child mdio-mux node must be constrained by
+	this mask.
+
+Example 1:
+
+The FPGA node defines a i2c connected FPGA with a register space of 0x30 bytes.
+For the "EMI2" MDIO bus, register 0x54 (BRDCFG4) controls the mux on that bus.
+A bitmask of 0x07 means that bits 0, 1 and 2 (bit 0 is lsb) are the bits on
+BRDCFG4 that control the actual mux.
+
+i2c@2000000 {
+	compatible = "fsl,vf610-i2c";
+	#address-cells = <1>;
+	#size-cells = <0>;
+	reg = <0x0 0x2000000 0x0 0x10000>;
+	interrupts = <0 34 0x4>; // Level high type
+	clock-names = "i2c";
+	clocks = <&clockgen 4 7>;
+	fsl-scl-gpio = <&gpio2 15 0>;
+	status = "okay";
+
+	/* The FPGA node */
+	fpga@66 {
+		compatible = "fsl,lx2160aqds-fpga", "fsl,fpga-qixis-i2c";
+		reg = <0x66>; // fpga device address on i2c bus
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mdio-mux-2@54 {
+			mdio-parent-bus = <&emdio2>; /* MDIO bus */
+			reg = <0x54>;	    /* BRDCFG4 */
+			mux-mask = <0x07>;      /* EMI2_MDIO */
+			#address-cells=<1>;
+			#size-cells = <0>;
+
+			mdio@0 {   // Slot 1
+				reg = <0x00>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				ethernet-phy@@1 {
+					reg = <1>;
+					compatible = "ethernet-phy-id0210.7441";
+				};
+
+				ethernet-phy@@0 {
+					reg = <0>;
+					compatible = "ethernet-phy-id0210.7441";
+				};
+			};
+
+			mdio@1 {   // Slot 2
+				reg = <0x01>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+			};
+
+			mdio@2 {   // Slot 3
+				reg = <0x02>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+			};
+		};
+	};
+};
+
+/* The parent MDIO bus. */
+emdio2: mdio@0x8B97000 {
+	compatible = "fsl,fman-memac-mdio";
+	reg = <0x0 0x8B97000 0x0 0x1000>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+	little-endian;
+};
+
+Example 2:
+
+The FPGA node defines a memory mapped FPGA with a register space of 0x100 bytes.
+For the "EMI1" MDIO bus, register 0x54 (BRDCFG4) controls the mux on that bus.
+A bitmask of 0xe0 means that bits 5, 6 and 7 (bit 0 is lsb) are the bits on
+BRDCFG4 that control the actual mux.
+
+ifc: ifc@1530000 {
+	compatible = "fsl,ifc", "simple-bus";
+	reg = <0x0 0x1530000 0x0 0x10000>;
+	interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
+	#address-cells = <2>;
+	#size-cells = <1>;
+	/* NOR, NAND Flashes and FPGA on board */
+	ranges = <0x0 0x0 0x0 0x60000000 0x08000000
+		  0x2 0x0 0x0 0x7e800000 0x00010000
+		  0x3 0x0 0x0 0x7fb00000 0x00000100>;
+	status = "okay";
+
+	/* The FPGA node */
+	fpga: board-control@3,0 {
+		compatible = "fsl,ls1021aqds-fpga", "fsl,fpga-qixis";
+		reg = <0x3 0x0 0x0000100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		mdio-mux-1@54 {
+			mdio-parent-bus = <&emdio1>; /* MDIO bus */
+			reg = <0x54>;	    /* BRDCFG4 */
+			mux-mask = <0xe0>;      /* EMI1_MDIO */
+			#address-cells=<1>;
+			#size-cells = <0>;
+
+			mdio@0 {   // Onboard PHYs rgmii_phy1
+				reg = <0x00>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				ethernet-phy@@1 {
+					reg = <1>;
+					compatible = "ethernet-phy-ieee802.3-c22";
+				};
+			};
+
+			mdio@20 {   // Onboard PHYs rgmii_phy2
+				reg = <0x20>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				ethernet-phy@2 {
+					reg = <0x2>;
+					compatible = "ethernet-phy-ieee802.3-c22";
+				};
+			};
+
+			mdio@40 {   // Onboard PHYs rgmii_phy3
+				reg = <0x40>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+				ethernet-phy@3 {
+					reg = <0x3>;
+					compatible = "ethernet-phy-ieee802.3-c22";
+				};
+			};
+		};
+	};
+};
+
+/* The parent MDIO bus. */
+emdio1: mdio@2d24000 {
+	compatible = "gianfar";
+	device_type = "mdio";
+	#address-cells = <1>;
+	#size-cells = <0>;
+	reg = <0x0 0x2d24000 0x0 0x4000>,
+	      <0x0 0x2d10030 0x0 0x4>;
+};
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 2/2 netdev/phy: add MDIO bus multiplexer driven by a regmap

In reply to Pankaj Bansal

Add support for an MDIO bus multiplexer controlled by a regmap device, like an FPGA.

Tested on a NXP LX2160AQDS board which uses the "QIXIS" FPGA attached to the i2c bus.

---

Notes:
V2:
- Added Kconfig entry for regmap based mdio mux
- restrict the comment lines to 80 chars
- use kerneldoc formatting for this function documentation.

 drivers/net/phy/Kconfig           |  14 +++
 drivers/net/phy/Makefile          |   1 +
 drivers/net/phy/mdio-mux-regmap.c | 171 ++++++++++++++++++++++++++++
 include/linux/mdio-mux.h          |  34 ++++++
 4 files changed, 220 insertions(+)
drivers/net/phy/Kconfig +14 -0
index 3d187cd50eb0..93ef2505caba 100644
@@ -87,6 +87,20 @@ config MDIO_BUS_MUX_MMIOREG
 
 	  Currently, only 8/16/32 bits registers are supported.
 
+config MDIO_BUS_MUX_REGMAP
+	tristate "regmap device controlled MDIO bus multiplexers"
+	depends on OF_MDIO && REGMAP
+	select MDIO_BUS_MUX
+	help
+	  This module provides a driver for MDIO bus multiplexers that
+	  are controlled via a regmap device, like an FPGA connected to i2c bus
+	  or spi bus or memory mapped FPGA.
+	  The multiplexer connects one of several child MDIO busses to a
+	  parent bus.  Child bus selection is under the control of one of
+	  the FPGA's registers.
+
+	  Currently, only 32 bits registers are supported.
+
 config MDIO_CAVIUM
 	tristate
 
drivers/net/phy/Makefile +1 -0
index 5805c0b7d60e..0827a700eb31 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_MDIO_BCM_IPROC)	+= mdio-bcm-iproc.o
 obj-$(CONFIG_MDIO_BCM_UNIMAC)	+= mdio-bcm-unimac.o
 obj-$(CONFIG_MDIO_BITBANG)	+= mdio-bitbang.o
 obj-$(CONFIG_MDIO_BUS_MUX)	+= mdio-mux.o
+obj-$(CONFIG_MDIO_BUS_MUX_REGMAP)	+= mdio-mux-regmap.o
 obj-$(CONFIG_MDIO_BUS_MUX_BCM_IPROC)	+= mdio-mux-bcm-iproc.o
 obj-$(CONFIG_MDIO_BUS_MUX_GPIO)	+= mdio-mux-gpio.o
 obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o
drivers/net/phy/mdio-mux-regmap.c new file +171 -0

171 lines not on this page · raw message

include/linux/mdio-mux.h +34 -0
index a5d58f221939..fb715d56999b 100644
@@ -29,4 +29,38 @@ int mdio_mux_init(struct device *dev,
 
 void mdio_mux_uninit(void *mux_handle);
 
+#ifdef CONFIG_MDIO_BUS_MUX_REGMAP
+/**
+ * mdio_mux_regmap_init - control MDIO bus muxing using regmap constructs.
+ * @dev: device with which regmap construct is associated.
+ * @mux_node: mdio bus mux node that contains parent mdio bus phandle.
+ *	      This node also contains sub nodes, where each subnode denotes
+ *	      a child mdio bus. All the child mdio buses are muxed, i.e. at a
+ *	      time only one of the child mdio buses can be used.
+ * @data: to store the address of data allocated by this function
+ */
+int mdio_mux_regmap_init(struct device *dev,
+			 struct device_node *mux_node,
+			 void **data);
+
+/**
+ * mdio_mux_regmap_uninit - relinquish the control of MDIO bus muxing using
+ *			    regmap constructs.
+ * @data: address of data allocated by mdio_mux_regmap_init
+ */
+int mdio_mux_regmap_uninit(void *data);
+#else /* CONFIG_MDIO_BUS_MUX_REGMAP */
+static inline int mdio_mux_regmap_init(struct device *dev,
+				       struct device_node *mux_node,
+				       void **data)
+{
+	return -ENODEV;
+}
+
+static inline int mdio_mux_regmap_uninit(void *data)
+{
+	return 0;
+}
+#endif /* CONFIG_MDIO_BUS_MUX_REGMAP */
+
 #endif /* __LINUX_MDIO_MUX_H */
Signature · 1 line
2.17.1
maintainer
#3 lore raw

Re: [PATCH v2 2/2] netdev/phy: add MDIO bus multiplexer driven by a regmap

Quoted 2 lines · Pankaj Bansal

Add support for an MDIO bus multiplexer controlled by a regmap device, like an FPGA.

Hi Pankaj

Thanks for adding the binding documentation.

drivers/net/phy/Makefile obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o · line 32

Quoted 12 lines
drivers/net/phy/Makefile +1 -0
index 5805c0b7d60e..0827a700eb31 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_MDIO_BCM_IPROC)	+= mdio-bcm-iproc.o
 obj-$(CONFIG_MDIO_BCM_UNIMAC)	+= mdio-bcm-unimac.o
 obj-$(CONFIG_MDIO_BITBANG)	+= mdio-bitbang.o
 obj-$(CONFIG_MDIO_BUS_MUX)	+= mdio-mux.o
+obj-$(CONFIG_MDIO_BUS_MUX_REGMAP)	+= mdio-mux-regmap.o
 obj-$(CONFIG_MDIO_BUS_MUX_BCM_IPROC)	+= mdio-mux-bcm-iproc.o
 obj-$(CONFIG_MDIO_BUS_MUX_GPIO)	+= mdio-mux-gpio.o
 obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o

We try to keep the Makefile sorting in alphabetical order.

drivers/net/phy/Makefile

Quoted 13 lines
drivers/net/phy/Makefile +13 -0
+/**
+ * mdio_mux_regmap_uninit - relinquish the control of MDIO bus muxing using
+ *			    regmap constructs.
+ * @data: address of data allocated by mdio_mux_regmap_init
+ */
+int mdio_mux_regmap_uninit(void *data)
+{
+	struct mdio_mux_regmap_state *s = data;
+
+	mdio_mux_uninit(s->mux_handle);
+
+	return 0;
+}

Please make this a void function, since there is nothing to return.

Andrew

#4 lore raw

Re: [PATCH v2 2/2] netdev/phy: add MDIO bus multiplexer driven by a regmap

In reply to Pankaj Bansal
Thank you for the patch! Yet something to improve:

Hi Pankaj,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Pankaj-Bansal/add-MDIO-bus-multiplexer-driven-by-a-regmap-device/20190204-213429
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.2.0 make.cross ARCH=sh

All errors (new ones prefixed by >>):

>> drivers/net/phy/mdio-mux-regmap.c:72:5: error: redefinition of 'mdio_mux_regmap_init'
    int mdio_mux_regmap_init(struct device *dev,
        ^~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/phy/mdio-mux-regmap.c:18:
   include/linux/mdio-mux.h:53:19: note: previous definition of 'mdio_mux_regmap_init' was here
    static inline int mdio_mux_regmap_init(struct device *dev,
                      ^~~~~~~~~~~~~~~~~~~~
>> drivers/net/phy/mdio-mux-regmap.c:158:5: error: redefinition of 'mdio_mux_regmap_uninit'

int mdio_mux_regmap_uninit(void *data)
^~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/phy/mdio-mux-regmap.c:18:
include/linux/mdio-mux.h:60:19: note: previous definition of 'mdio_mux_regmap_uninit' was here
static inline int mdio_mux_regmap_uninit(void *data)
^~~~~~~~~~~~~~~~~~~~~~

vim +/mdio_mux_regmap_init +72 drivers/net/phy/mdio-mux-regmap.c

62
63 /**
64 * mdio_mux_regmap_init - control MDIO bus muxing using regmap constructs.
65 * @dev: device with which regmap construct is associated.
66 * @mux_node: mdio bus mux node that contains parent mdio bus phandle.
67 * This node also contains sub nodes, where each subnode denotes
68 * a child mdio bus. All the child mdio buses are muxed, i.e. at a
69 * time only one of the child mdio buses can be used.
70 * @data: to store the address of data allocated by this function
71 */

  > 72	int mdio_mux_regmap_init(struct device *dev,
    73				 struct device_node *mux_node,
    74				 void **data)
    75	{
    76		struct device_node *child;
    77		struct mdio_mux_regmap_state *s;
    78		int ret;
    79		u32 val;
    80	
    81		dev_dbg(dev, "probing node %pOF\n", mux_node);
    82	
    83		s = devm_kzalloc(dev, sizeof(*s), GFP_KERNEL);
    84		if (!s)
    85			return -ENOMEM;
    86	
    87		s->regmap = dev_get_regmap(dev, NULL);
    88		if (IS_ERR(s->regmap)) {
    89			dev_err(dev, "Failed to get parent regmap\n");
    90			return PTR_ERR(s->regmap);
    91		}
    92	
    93		ret = of_property_read_u32(mux_node, "reg", &s->mux_reg);
    94		if (ret) {
    95			dev_err(dev, "missing or invalid reg property\n");
    96			return -ENODEV;
    97		}
    98	
    99		/* Test Register read write */
   100		ret = regmap_read(s->regmap, s->mux_reg, &val);
   101		if (ret) {
   102			dev_err(dev, "error while reading reg\n");
   103			return ret;
   104		}
   105	
   106		ret = regmap_write(s->regmap, s->mux_reg, val);
   107		if (ret) {
   108			dev_err(dev, "error while writing reg\n");
   109			return ret;
   110		}
   111	
   112		ret = of_property_read_u32(mux_node, "mux-mask", &s->mask);
   113		if (ret) {
   114			dev_err(dev, "missing or invalid mux-mask property\n");
   115			return -ENODEV;
   116		}
   117	
   118		/* Verify that the 'reg' property of each child MDIO bus does not
   119		 * set any bits outside of the 'mask'.
   120		 */
   121		for_each_available_child_of_node(mux_node, child) {
   122			ret = of_property_read_u32(child, "reg", &val);
   123			if (ret) {
   124				dev_err(dev, "%pOF is missing a 'reg' property\n",
   125					child);
   126				of_node_put(child);
   127				return -ENODEV;
   128			}
   129			if (val & ~s->mask) {
   130				dev_err(dev,
   131					"%pOF has a 'reg' value with unmasked bits\n",
   132					child);
   133				of_node_put(child);
   134				return -ENODEV;
   135			}
   136		}
   137	
   138		ret = mdio_mux_init(dev, mux_node, mdio_mux_regmap_switch_fn,
   139				    &s->mux_handle, s, NULL);
   140		if (ret) {
   141			if (ret != -EPROBE_DEFER)
   142				dev_err(dev, "failed to register mdio-mux bus %pOF\n",
   143					mux_node);
   144			return ret;
   145		}
   146	
   147		*data = s;
   148	
   149		return 0;
   150	}
   151	EXPORT_SYMBOL_GPL(mdio_mux_regmap_init);
   152	
   153	/**
   154	 * mdio_mux_regmap_uninit - relinquish the control of MDIO bus muxing using
   155	 *			    regmap constructs.
   156	 * @data: address of data allocated by mdio_mux_regmap_init
   157	 */
 > 158	int mdio_mux_regmap_uninit(void *data)

159 {
160 struct mdio_mux_regmap_state *s = data;
161
162 mdio_mux_uninit(s->mux_handle);
163
164 return 0;
165 }
166 EXPORT_SYMBOL_GPL(mdio_mux_regmap_uninit);
167

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#5 lore raw

RE: [PATCH v2 2/2] netdev/phy: add MDIO bus multiplexer driven by a regmap

Hi Andrew,

I am getting this compilation error when the mdio-mux-regmap.ko is built as standalone module. This error doesn't come when the mdio-mux-regmap is built as part of linux kernel.

I don't understand the reason for it. Inline definitions of functions are only defined if CONFIG_MDIO_BUS_MUX_REGMAP Is NOT defined.

BUT it is defined as " CONFIG_MDIO_BUS_MUX_REGMAP = m"

Can you please help me to solve this?

Regards,
Pankaj Bansal

Quoted 190 lines

-----Original Message-----
From: kbuild test robot [mailto:[email protected]]
Sent: Monday, 4 February, 2019 08:22 PM
To: Pankaj Bansal <[email protected]>
Cc: [email protected]; Andrew Lunn <[email protected]>; Florian Fainelli <[email protected]>; [email protected]; Pankaj Bansal <[email protected]>
Subject: Re: [PATCH v2 2/2] netdev/phy: add MDIO bus multiplexer driven by a regmap

Hi Pankaj,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net/master]
[also build test ERROR on v5.0-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.
com%2F0day-ci%2Flinux%2Fcommits%2FPankaj-Bansal%2Fadd-MDIO-bus- multiplexer-driven-by-a-regmap-device%2F20190204- 213429&amp;data=02%7C01%7Cpankaj.bansal%40nxp.com%7Caabb2bdecd8a4 2c19f8108d68ab053d6%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 C636848890628820621&amp;sdata=WLP4yuLXqfoNLfrPSIWhNkfg24YdR6Ny8jb cUgvcrDQ%3D&amp;reserved=0
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0 reproduce:
wget
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fraw.git
hubusercontent.com%2Fintel%2Flkp- tests%2Fmaster%2Fsbin%2Fmake.cross&amp;data=02%7C01%7Cpankaj.bansal %40nxp.com%7Caabb2bdecd8a42c19f8108d68ab053d6%7C686ea1d3bc2b4c6f a92cd99c5c301635%7C0%7C0%7C636848890628820621&amp;sdata=pGqb5xq RsWH6fXd8NWLUKX86qQ0ZO8OOy8nj9rckqV8%3D&amp;reserved=0 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree GCC_VERSION=8.2.0 make.cross ARCH=sh

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

drivers/net/phy/mdio-mux-regmap.c:72:5: error: redefinition of

'mdio_mux_regmap_init'
int mdio_mux_regmap_init(struct device *dev,
^~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/phy/mdio-mux-regmap.c:18:
include/linux/mdio-mux.h:53:19: note: previous definition of
'mdio_mux_regmap_init' was here
static inline int mdio_mux_regmap_init(struct device *dev,
^~~~~~~~~~~~~~~~~~~~

Quoted 1 line
Quoted 1 line

drivers/net/phy/mdio-mux-regmap.c:158:5: error: redefinition of

'mdio_mux_regmap_uninit'
int mdio_mux_regmap_uninit(void *data)
^~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/net/phy/mdio-mux-regmap.c:18:
include/linux/mdio-mux.h:60:19: note: previous definition of
'mdio_mux_regmap_uninit' was here
static inline int mdio_mux_regmap_uninit(void *data)
^~~~~~~~~~~~~~~~~~~~~~

vim +/mdio_mux_regmap_init +72 drivers/net/phy/mdio-mux-regmap.c

    62
    63	/**
    64	 * mdio_mux_regmap_init - control MDIO bus muxing using regmap

constructs.
65 * @dev: device with which regmap construct is associated.
66 * @mux_node: mdio bus mux node that contains parent mdio bus
phandle.
67 * This node also contains sub nodes, where each subnode
denotes
68 * a child mdio bus. All the child mdio buses are muxed, i.e. at a
69 * time only one of the child mdio buses can be used.
70 * @data: to store the address of data allocated by this function
71 */

Quoted 1 line

72 int mdio_mux_regmap_init(struct device *dev,

    73				 struct device_node *mux_node,
    74				 void **data)
    75	{
    76		struct device_node *child;
    77		struct mdio_mux_regmap_state *s;
    78		int ret;
    79		u32 val;
    80
    81		dev_dbg(dev, "probing node %pOF\n", mux_node);
    82
    83		s = devm_kzalloc(dev, sizeof(*s), GFP_KERNEL);
    84		if (!s)
    85			return -ENOMEM;
    86
    87		s->regmap = dev_get_regmap(dev, NULL);
    88		if (IS_ERR(s->regmap)) {
    89			dev_err(dev, "Failed to get parent regmap\n");
    90			return PTR_ERR(s->regmap);
    91		}
    92
    93		ret = of_property_read_u32(mux_node, "reg", &s->mux_reg);
    94		if (ret) {
    95			dev_err(dev, "missing or invalid reg property\n");
    96			return -ENODEV;
    97		}
    98
    99		/* Test Register read write */
   100		ret = regmap_read(s->regmap, s->mux_reg, &val);
   101		if (ret) {
   102			dev_err(dev, "error while reading reg\n");
   103			return ret;
   104		}
   105
   106		ret = regmap_write(s->regmap, s->mux_reg, val);
   107		if (ret) {
   108			dev_err(dev, "error while writing reg\n");
   109			return ret;
   110		}
   111
   112		ret = of_property_read_u32(mux_node, "mux-mask", &s-
Quoted 1 line

mask);

   113		if (ret) {
   114			dev_err(dev, "missing or invalid mux-mask property\n");
   115			return -ENODEV;
   116		}
   117
   118		/* Verify that the 'reg' property of each child MDIO bus does
not
   119		 * set any bits outside of the 'mask'.
   120		 */
   121		for_each_available_child_of_node(mux_node, child) {
   122			ret = of_property_read_u32(child, "reg", &val);
   123			if (ret) {
   124				dev_err(dev, "%pOF is missing a 'reg'
property\n",
   125					child);
   126				of_node_put(child);
   127				return -ENODEV;
   128			}
   129			if (val & ~s->mask) {
   130				dev_err(dev,
   131					"%pOF has a 'reg' value with unmasked
bits\n",
   132					child);
   133				of_node_put(child);
   134				return -ENODEV;
   135			}
   136		}
   137
   138		ret = mdio_mux_init(dev, mux_node,
mdio_mux_regmap_switch_fn,
   139				    &s->mux_handle, s, NULL);
   140		if (ret) {
   141			if (ret != -EPROBE_DEFER)
   142				dev_err(dev, "failed to register mdio-mux
bus %pOF\n",
   143					mux_node);
   144			return ret;
   145		}
   146
   147		*data = s;
   148
   149		return 0;
   150	}
   151	EXPORT_SYMBOL_GPL(mdio_mux_regmap_init);
   152
   153	/**
   154	 * mdio_mux_regmap_uninit - relinquish the control of MDIO bus

muxing using
155 * regmap constructs.
156 * @data: address of data allocated by mdio_mux_regmap_init
157 */

Quoted 1 line

158 int mdio_mux_regmap_uninit(void *data)

   159	{
   160		struct mdio_mux_regmap_state *s = data;
   161
   162		mdio_mux_uninit(s->mux_handle);
   163
   164		return 0;
   165	}
   166	EXPORT_SYMBOL_GPL(mdio_mux_regmap_uninit);
   167

---
0-DAY kernel test infrastructure Open Source Technology Center
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.01
.org%2Fpipermail%2Fkbuild- all&amp;data=02%7C01%7Cpankaj.bansal%40nxp.com%7Caabb2bdecd8a42c19 f8108d68ab053d6%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C636 848890628820621&amp;sdata=P7RrlnHYStMpoDpwIDMmlRiDTCemyEE3bxuUrq
d0uxY%3D&amp;reserved=0 Intel Corporation