* [PATCH v3 0/3] net: phy: bcm63xx: add support for BCM63268 GPHY
@ 2025-02-28 0:27 Kyle Hendry
2025-02-28 0:27 ` [PATCH v3 1/3] " Kyle Hendry
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Kyle Hendry @ 2025-02-28 0:27 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Heiner Kallweit, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Philipp Zabel
Cc: noltari, jonas.gorski, Kyle Hendry, netdev, devicetree,
linux-kernel
Some BCM63268 bootloaders do not enable the internal PHYs by default.
This patch series adds a phy driver to set the registers required
for the gigabit PHY to work.
v3 changes:
- Remove syscon for the GPHY control register
- Change driver to access the GPIO controller syscon
- Move syscon phandle from mdio bus to phy node
- Remove unecessary devm_phy_package_join()
- Made functions static to fix build warning
- Fix formatting and whitespace issues
- Add schema for PHY driver
- Deassert PHY reset signal
v2: https://lore.kernel.org/netdev/d819144d-ce2f-4ea5-8bfb-83e341672da6@gmail.com/
- Remove changes to b53 dsa code and rework fix as a PHY driver
- Use a regmap for accessing GPHY control register
- Add documentaion for device tree changes
v1: https://lore.kernel.org/netdev/20250206043055.177004-1-kylehendrydev@gmail.com/
Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
Kyle Hendry (3):
net: phy: bcm63xx: add support for BCM63268 GPHY
net: phy: enable bcm63xx on bmips
dt-bindings: net: phy: add BCM63268 GPHY
.../bindings/net/brcm,bcm63268-gphy.yaml | 51 +++++++++
drivers/net/phy/Kconfig | 4 +-
drivers/net/phy/bcm63xx.c | 101 ++++++++++++++++++
3 files changed, 154 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.yaml
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] net: phy: bcm63xx: add support for BCM63268 GPHY
2025-02-28 0:27 [PATCH v3 0/3] net: phy: bcm63xx: add support for BCM63268 GPHY Kyle Hendry
@ 2025-02-28 0:27 ` Kyle Hendry
2025-02-28 9:34 ` Kory Maincent
2025-02-28 0:27 ` [PATCH v3 2/3] net: phy: enable bcm63xx on bmips Kyle Hendry
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Kyle Hendry @ 2025-02-28 0:27 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Heiner Kallweit, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Philipp Zabel
Cc: noltari, jonas.gorski, Kyle Hendry, netdev, devicetree,
linux-kernel
Add support for the internal gigabit PHY on the BCM63268 SoC.
Some of the PHY functionality is configured out of band through
memory mapped registers. The GPHY control register contains bits
which need to be written to enable/disable low power mode. The
register is part of the SoC's GPIO controller, so accessing it
is done through a phandle to that syscon.
Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
---
drivers/net/phy/bcm63xx.c | 101 ++++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c
index b46a736a3130..9467bbf573e5 100644
--- a/drivers/net/phy/bcm63xx.c
+++ b/drivers/net/phy/bcm63xx.c
@@ -3,8 +3,11 @@
* Driver for Broadcom 63xx SOCs integrated PHYs
*/
#include "bcm-phy-lib.h"
+#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/phy.h>
+#include <linux/regmap.h>
+#include <linux/reset.h>
#define MII_BCM63XX_IR 0x1a /* interrupt register */
#define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */
@@ -13,10 +16,20 @@
#define MII_BCM63XX_IR_LINK 0x0200 /* link changed */
#define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */
+#define PHY_ID_BCM63268_GPHY 0x03625f50
+
+#define GPHY_CTRL_OFFSET 0x54
+#define GPHY_CTRL_IDDQ_BIAS BIT(0)
+#define GPHY_CTRL_LOW_PWR BIT(3)
+
MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
MODULE_LICENSE("GPL");
+struct bcm_gphy_priv {
+ struct regmap *gpio_ctrl;
+};
+
static int bcm63xx_config_intr(struct phy_device *phydev)
{
int reg, err;
@@ -69,6 +82,84 @@ static int bcm63xx_config_init(struct phy_device *phydev)
return phy_write(phydev, MII_BCM63XX_IR, reg);
}
+static int bcm63268_gphy_set(struct phy_device *phydev, bool enable)
+{
+ struct bcm_gphy_priv *priv = phydev->priv;
+ u32 pwr_bits;
+ int ret;
+
+ pwr_bits = GPHY_CTRL_IDDQ_BIAS | GPHY_CTRL_LOW_PWR;
+
+ if (enable)
+ ret = regmap_update_bits(priv->gpio_ctrl, GPHY_CTRL_OFFSET, pwr_bits, 0);
+ else
+ ret = regmap_update_bits(priv->gpio_ctrl, GPHY_CTRL_OFFSET, pwr_bits, pwr_bits);
+
+ return ret;
+}
+
+static int bcm63268_gphy_resume(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = bcm63268_gphy_set(phydev, true);
+ if (ret)
+ return ret;
+
+ ret = genphy_resume(phydev);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int bcm63268_gphy_suspend(struct phy_device *phydev)
+{
+ int ret;
+
+ ret = genphy_suspend(phydev);
+ if (ret)
+ return ret;
+
+ ret = bcm63268_gphy_set(phydev, false);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static int bcm63268_gphy_probe(struct phy_device *phydev)
+{
+ struct mdio_device *mdio = &phydev->mdio;
+ struct device *dev = &mdio->dev;
+ struct reset_control *reset;
+ struct bcm_gphy_priv *priv;
+ struct regmap *regmap;
+ int ret;
+
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ phydev->priv = priv;
+
+ regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "brcm,gpio-ctrl");
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
+
+ priv->gpio_ctrl = regmap;
+
+ reset = devm_reset_control_get_optional_exclusive(dev, NULL);
+ if (IS_ERR(reset))
+ return PTR_ERR(reset);
+
+ ret = reset_control_reset(reset);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
static struct phy_driver bcm63xx_driver[] = {
{
.phy_id = 0x00406000,
@@ -89,6 +180,15 @@ static struct phy_driver bcm63xx_driver[] = {
.config_init = bcm63xx_config_init,
.config_intr = bcm63xx_config_intr,
.handle_interrupt = bcm_phy_handle_interrupt,
+}, {
+ .phy_id = PHY_ID_BCM63268_GPHY,
+ .phy_id_mask = 0xfffffff0,
+ .name = "Broadcom BCM63268 GPHY",
+ /* PHY_BASIC_FEATURES */
+ .flags = PHY_IS_INTERNAL,
+ .probe = bcm63268_gphy_probe,
+ .resume = bcm63268_gphy_resume,
+ .suspend = bcm63268_gphy_suspend,
} };
module_phy_driver(bcm63xx_driver);
@@ -96,6 +196,7 @@ module_phy_driver(bcm63xx_driver);
static const struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {
{ 0x00406000, 0xfffffc00 },
{ 0x002bdc00, 0xfffffc00 },
+ { PHY_ID_MATCH_EXACT(PHY_ID_BCM63268_GPHY) },
{ }
};
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] net: phy: enable bcm63xx on bmips
2025-02-28 0:27 [PATCH v3 0/3] net: phy: bcm63xx: add support for BCM63268 GPHY Kyle Hendry
2025-02-28 0:27 ` [PATCH v3 1/3] " Kyle Hendry
@ 2025-02-28 0:27 ` Kyle Hendry
2025-02-28 0:27 ` [PATCH v3 3/3] dt-bindings: net: phy: add BCM63268 GPHY Kyle Hendry
2025-02-28 9:25 ` [PATCH v3 0/3] net: phy: bcm63xx: add support for " Kory Maincent
3 siblings, 0 replies; 7+ messages in thread
From: Kyle Hendry @ 2025-02-28 0:27 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Heiner Kallweit, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Philipp Zabel
Cc: noltari, jonas.gorski, Kyle Hendry, netdev, devicetree,
linux-kernel
Allow the bcm63xx PHY driver to be built on bmips machines
Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
drivers/net/phy/Kconfig | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 41c15a2c2037..0f2956ba472d 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -156,10 +156,10 @@ config BCM54140_PHY
config BCM63XX_PHY
tristate "Broadcom 63xx SOCs internal PHY"
- depends on BCM63XX || COMPILE_TEST
+ depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST
select BCM_NET_PHYLIB
help
- Currently supports the 6348 and 6358 PHYs.
+ Currently supports the 6348, 6358 and 63268 PHYs.
config BCM7XXX_PHY
tristate "Broadcom 7xxx SOCs internal PHYs"
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] dt-bindings: net: phy: add BCM63268 GPHY
2025-02-28 0:27 [PATCH v3 0/3] net: phy: bcm63xx: add support for BCM63268 GPHY Kyle Hendry
2025-02-28 0:27 ` [PATCH v3 1/3] " Kyle Hendry
2025-02-28 0:27 ` [PATCH v3 2/3] net: phy: enable bcm63xx on bmips Kyle Hendry
@ 2025-02-28 0:27 ` Kyle Hendry
2025-02-28 1:25 ` Rob Herring (Arm)
2025-02-28 9:25 ` [PATCH v3 0/3] net: phy: bcm63xx: add support for " Kory Maincent
3 siblings, 1 reply; 7+ messages in thread
From: Kyle Hendry @ 2025-02-28 0:27 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Heiner Kallweit, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Philipp Zabel
Cc: noltari, jonas.gorski, Kyle Hendry, netdev, devicetree,
linux-kernel
Add YAML bindings for BCM63268 internal GPHY
Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
---
.../bindings/net/brcm,bcm63268-gphy.yaml | 51 +++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.yaml
diff --git a/Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.yaml b/Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.yaml
new file mode 100644
index 000000000000..415f5c03c1a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.yaml
@@ -0,0 +1,51 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/brcm,bcm63268-gphy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom BCM63268 GPHY
+
+description: Broadcom's internal gigabit ethernet PHY on BCM63268 SoC
+
+maintainers:
+ - TBD
+
+allOf:
+ - $ref: ethernet-phy.yaml#
+
+properties:
+ compatible:
+ const: ethernet-phy-id0362.5f50
+
+ reg:
+ maxItems: 1
+
+ brcm,gpio-ctrl:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ Phandle to the SoC GPIO controller which contains
+ PHY control registers
+
+required:
+ - reg
+ - brcm,gpio-ctrl
+ - resets
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ mdio {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ethernet-phy@4 {
+ compatible = "ethernet-phy-id0362.5f50";
+ reg = <4>;
+
+ resets = <&periph_rst BCM63268_RST_GPHY>;
+
+ brcm,gpio-ctrl = <&gpio_cntl>;
+ };
+ };
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 3/3] dt-bindings: net: phy: add BCM63268 GPHY
2025-02-28 0:27 ` [PATCH v3 3/3] dt-bindings: net: phy: add BCM63268 GPHY Kyle Hendry
@ 2025-02-28 1:25 ` Rob Herring (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring (Arm) @ 2025-02-28 1:25 UTC (permalink / raw)
To: Kyle Hendry
Cc: Jakub Kicinski, Broadcom internal kernel review list,
jonas.gorski, Krzysztof Kozlowski, netdev, Philipp Zabel,
Conor Dooley, Heiner Kallweit, linux-kernel, noltari,
David S. Miller, Russell King, Florian Fainelli, devicetree,
Paolo Abeni, Eric Dumazet, Andrew Lunn
On Thu, 27 Feb 2025 16:27:17 -0800, Kyle Hendry wrote:
> Add YAML bindings for BCM63268 internal GPHY
>
> Signed-off-by: Kyle Hendry <kylehendrydev@gmail.com>
> ---
> .../bindings/net/brcm,bcm63268-gphy.yaml | 51 +++++++++++++++++++
> 1 file changed, 51 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.yaml
>
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.yaml: maintainers:0: 'TBD' does not match '@'
from schema $id: http://devicetree.org/meta-schemas/base.yaml#
Error: Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.example.dts:26.39-40 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.dtbs:131: Documentation/devicetree/bindings/net/brcm,bcm63268-gphy.example.dtb] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/builds/robherring/dt-review-ci/linux/Makefile:1511: dt_binding_check] Error 2
make: *** [Makefile:251: __sub-make] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20250228002722.5619-4-kylehendrydev@gmail.com
The base for the series is generally the latest rc1. A different dependency
should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note
that DT_SCHEMA_FILES can be set to your schema file to speed up checking
your schema. However, it must be unset to test all examples with your schema.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 0/3] net: phy: bcm63xx: add support for BCM63268 GPHY
2025-02-28 0:27 [PATCH v3 0/3] net: phy: bcm63xx: add support for BCM63268 GPHY Kyle Hendry
` (2 preceding siblings ...)
2025-02-28 0:27 ` [PATCH v3 3/3] dt-bindings: net: phy: add BCM63268 GPHY Kyle Hendry
@ 2025-02-28 9:25 ` Kory Maincent
3 siblings, 0 replies; 7+ messages in thread
From: Kory Maincent @ 2025-02-28 9:25 UTC (permalink / raw)
To: Kyle Hendry
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Heiner Kallweit, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Philipp Zabel, noltari,
jonas.gorski, netdev, devicetree, linux-kernel
On Thu, 27 Feb 2025 16:27:14 -0800
Kyle Hendry <kylehendrydev@gmail.com> wrote:
> Some BCM63268 bootloaders do not enable the internal PHYs by default.
> This patch series adds a phy driver to set the registers required
> for the gigabit PHY to work.
These are no fixes, you should add net-next prefix in your series.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 1/3] net: phy: bcm63xx: add support for BCM63268 GPHY
2025-02-28 0:27 ` [PATCH v3 1/3] " Kyle Hendry
@ 2025-02-28 9:34 ` Kory Maincent
0 siblings, 0 replies; 7+ messages in thread
From: Kory Maincent @ 2025-02-28 9:34 UTC (permalink / raw)
To: Kyle Hendry
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Heiner Kallweit, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Philipp Zabel, noltari,
jonas.gorski, netdev, devicetree, linux-kernel
On Thu, 27 Feb 2025 16:27:15 -0800
Kyle Hendry <kylehendrydev@gmail.com> wrote:
> Add support for the internal gigabit PHY on the BCM63268 SoC.
> Some of the PHY functionality is configured out of band through
> memory mapped registers. The GPHY control register contains bits
> which need to be written to enable/disable low power mode. The
> register is part of the SoC's GPIO controller, so accessing it
> is done through a phandle to that syscon.
...
> +static int bcm63268_gphy_resume(struct phy_device *phydev)
> +{
> + int ret;
> +
> + ret = bcm63268_gphy_set(phydev, true);
> + if (ret)
> + return ret;
> +
> + ret = genphy_resume(phydev);
> + if (ret)
> + return ret;
> +
> + return 0;
No need for the last check. You can simply do this:
return genphy_resume(phydev);
> +}
> +
> +static int bcm63268_gphy_suspend(struct phy_device *phydev)
> +{
> + int ret;
> +
> + ret = genphy_suspend(phydev);
> + if (ret)
> + return ret;
> +
> + ret = bcm63268_gphy_set(phydev, false);
> + if (ret)
> + return ret;
> +
> + return 0;
Same here.
> +}
> +
> +static int bcm63268_gphy_probe(struct phy_device *phydev)
> +{
> + struct mdio_device *mdio = &phydev->mdio;
> + struct device *dev = &mdio->dev;
> + struct reset_control *reset;
> + struct bcm_gphy_priv *priv;
> + struct regmap *regmap;
> + int ret;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + phydev->priv = priv;
> +
> + regmap = syscon_regmap_lookup_by_phandle(dev->of_node,
> "brcm,gpio-ctrl");
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + priv->gpio_ctrl = regmap;
> +
> + reset = devm_reset_control_get_optional_exclusive(dev, NULL);
> + if (IS_ERR(reset))
> + return PTR_ERR(reset);
> +
> + ret = reset_control_reset(reset);
> + if (ret)
> + return ret;
> +
> + return 0;
Same here.
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-02-28 9:34 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 0:27 [PATCH v3 0/3] net: phy: bcm63xx: add support for BCM63268 GPHY Kyle Hendry
2025-02-28 0:27 ` [PATCH v3 1/3] " Kyle Hendry
2025-02-28 9:34 ` Kory Maincent
2025-02-28 0:27 ` [PATCH v3 2/3] net: phy: enable bcm63xx on bmips Kyle Hendry
2025-02-28 0:27 ` [PATCH v3 3/3] dt-bindings: net: phy: add BCM63268 GPHY Kyle Hendry
2025-02-28 1:25 ` Rob Herring (Arm)
2025-02-28 9:25 ` [PATCH v3 0/3] net: phy: bcm63xx: add support for " Kory Maincent
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).