Skip to content

Commit fb2275e

Browse files
committed
phy: ti: gmii-sel: Add support for CPSW5G GMII SEL in J7200
JIRA: https://issues.redhat.com/browse/RHEL-44742 commit af96579 Author: Siddharth Vadapalli <s-vadapalli@ti.com> Date: Mon Sep 12 14:26:50 2022 +0530 phy: ti: gmii-sel: Add support for CPSW5G GMII SEL in J7200 Each of the CPSW5G ports in J7200 support additional modes like QSGMII. Add a new compatible for J7200 to support the additional modes. In TI's J7200, each of the CPSW5G ethernet interfaces can act as a QSGMII or QSGMII-SUB port. The QSGMII interface is responsible for performing auto-negotiation between the MAC and the PHY while the rest of the interfaces are designated as QSGMII-SUB interfaces, indicating that they will not be taking part in the auto-negotiation process. To indicate the interface which will serve as the main QSGMII interface, add a property "ti,qsgmii-main-ports", whose value indicates the port number of the interface which shall serve as the main QSGMII interface. The rest of the interfaces are then assigned QSGMII-SUB mode by default. The property "ti,qsgmii-main-ports" is used to configure the CTRLMMR_ENETx_CTRL register. Depending on the device, it is possible for more than one QSGMII main port to exist. Thus, the property "ti,qsgmii-main-ports" is defined as an array of values in order to reuse the property for other devices. Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> Link: https://lore.kernel.org/r/20220912085650.83263-4-s-vadapalli@ti.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
1 parent 3f2d7cf commit fb2275e

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

drivers/phy/ti/phy-gmii-sel.c

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#define AM33XX_GMII_SEL_MODE_RMII 1
2323
#define AM33XX_GMII_SEL_MODE_RGMII 2
2424

25+
/* J72xx SoC specific definitions for the CONTROL port */
26+
#define J72XX_GMII_SEL_MODE_QSGMII 4
27+
#define J72XX_GMII_SEL_MODE_QSGMII_SUB 6
28+
29+
#define PHY_GMII_PORT(n) BIT((n) - 1)
30+
2531
enum {
2632
PHY_GMII_SEL_PORT_MODE = 0,
2733
PHY_GMII_SEL_RGMII_ID_MODE,
@@ -43,6 +49,7 @@ struct phy_gmii_sel_soc_data {
4349
u32 features;
4450
const struct reg_field (*regfields)[PHY_GMII_SEL_LAST];
4551
bool use_of_data;
52+
u64 extra_modes;
4653
};
4754

4855
struct phy_gmii_sel_priv {
@@ -53,6 +60,7 @@ struct phy_gmii_sel_priv {
5360
struct phy_gmii_sel_phy_priv *if_phys;
5461
u32 num_ports;
5562
u32 reg_offset;
63+
u32 qsgmii_main_ports;
5664
};
5765

5866
static int phy_gmii_sel_mode(struct phy *phy, enum phy_mode mode, int submode)
@@ -88,10 +96,17 @@ static int phy_gmii_sel_mode(struct phy *phy, enum phy_mode mode, int submode)
8896
gmii_sel_mode = AM33XX_GMII_SEL_MODE_MII;
8997
break;
9098

99+
case PHY_INTERFACE_MODE_QSGMII:
100+
if (!(soc_data->extra_modes & BIT(PHY_INTERFACE_MODE_QSGMII)))
101+
goto unsupported;
102+
if (if_phy->priv->qsgmii_main_ports & BIT(if_phy->id - 1))
103+
gmii_sel_mode = J72XX_GMII_SEL_MODE_QSGMII;
104+
else
105+
gmii_sel_mode = J72XX_GMII_SEL_MODE_QSGMII_SUB;
106+
break;
107+
91108
default:
92-
dev_warn(dev, "port%u: unsupported mode: \"%s\"\n",
93-
if_phy->id, phy_modes(submode));
94-
return -EINVAL;
109+
goto unsupported;
95110
}
96111

97112
if_phy->phy_if_mode = submode;
@@ -123,6 +138,11 @@ static int phy_gmii_sel_mode(struct phy *phy, enum phy_mode mode, int submode)
123138
}
124139

125140
return 0;
141+
142+
unsupported:
143+
dev_warn(dev, "port%u: unsupported mode: \"%s\"\n",
144+
if_phy->id, phy_modes(submode));
145+
return -EINVAL;
126146
}
127147

128148
static const
@@ -188,6 +208,13 @@ struct phy_gmii_sel_soc_data phy_gmii_sel_soc_am654 = {
188208
.regfields = phy_gmii_sel_fields_am654,
189209
};
190210

211+
static const
212+
struct phy_gmii_sel_soc_data phy_gmii_sel_cpsw5g_soc_j7200 = {
213+
.use_of_data = true,
214+
.regfields = phy_gmii_sel_fields_am654,
215+
.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII),
216+
};
217+
191218
static const struct of_device_id phy_gmii_sel_id_table[] = {
192219
{
193220
.compatible = "ti,am3352-phy-gmii-sel",
@@ -209,6 +236,10 @@ static const struct of_device_id phy_gmii_sel_id_table[] = {
209236
.compatible = "ti,am654-phy-gmii-sel",
210237
.data = &phy_gmii_sel_soc_am654,
211238
},
239+
{
240+
.compatible = "ti,j7200-cpsw5g-phy-gmii-sel",
241+
.data = &phy_gmii_sel_cpsw5g_soc_j7200,
242+
},
212243
{}
213244
};
214245
MODULE_DEVICE_TABLE(of, phy_gmii_sel_id_table);
@@ -350,6 +381,7 @@ static int phy_gmii_sel_probe(struct platform_device *pdev)
350381
struct device_node *node = dev->of_node;
351382
const struct of_device_id *of_id;
352383
struct phy_gmii_sel_priv *priv;
384+
u32 main_ports = 1;
353385
int ret;
354386

355387
of_id = of_match_node(phy_gmii_sel_id_table, pdev->dev.of_node);
@@ -363,6 +395,15 @@ static int phy_gmii_sel_probe(struct platform_device *pdev)
363395
priv->dev = &pdev->dev;
364396
priv->soc_data = of_id->data;
365397
priv->num_ports = priv->soc_data->num_ports;
398+
of_property_read_u32(node, "ti,qsgmii-main-ports", &main_ports);
399+
/*
400+
* Ensure that main_ports is within bounds. If the property
401+
* ti,qsgmii-main-ports is not mentioned, or the value mentioned
402+
* is out of bounds, default to 1.
403+
*/
404+
if (main_ports < 1 || main_ports > 4)
405+
main_ports = 1;
406+
priv->qsgmii_main_ports = PHY_GMII_PORT(main_ports);
366407

367408
priv->regmap = syscon_node_to_regmap(node->parent);
368409
if (IS_ERR(priv->regmap)) {

0 commit comments

Comments
 (0)