Skip to content

Commit c865aa6

Browse files
committed
phy: ti: gmii-sel: Update methods for fetching and using qsgmii main port
JIRA: https://issues.redhat.com/browse/RHEL-44742 commit 3b66ab6 Author: Siddharth Vadapalli <s-vadapalli@ti.com> Date: Wed Oct 26 13:15:31 2022 +0530 phy: ti: gmii-sel: Update methods for fetching and using qsgmii main port The number of QSGMII main ports are specific to the device. TI's J7200 for which the QSGMII main port property is fetched from the device-tree has only one QSGMII main port. However, devices like TI's J721e support up to two QSGMII main ports. Thus, the existing methods for fetching and using the QSGMII main port are not scalable. Update the existing methods for handling the QSGMII main ports and its associated requirements to make it scalable for future devices. Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> Reviewed-by: Roger Quadros <rogerq@kernel.org> Link: https://lore.kernel.org/r/20221026074532.109220-3-s-vadapalli@ti.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
1 parent fb2275e commit c865aa6

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct phy_gmii_sel_soc_data {
5050
const struct reg_field (*regfields)[PHY_GMII_SEL_LAST];
5151
bool use_of_data;
5252
u64 extra_modes;
53+
u32 num_qsgmii_main_ports;
5354
};
5455

5556
struct phy_gmii_sel_priv {
@@ -213,6 +214,8 @@ struct phy_gmii_sel_soc_data phy_gmii_sel_cpsw5g_soc_j7200 = {
213214
.use_of_data = true,
214215
.regfields = phy_gmii_sel_fields_am654,
215216
.extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII),
217+
.num_ports = 4,
218+
.num_qsgmii_main_ports = 1,
216219
};
217220

218221
static const struct of_device_id phy_gmii_sel_id_table[] = {
@@ -378,11 +381,13 @@ static int phy_gmii_sel_init_ports(struct phy_gmii_sel_priv *priv)
378381
static int phy_gmii_sel_probe(struct platform_device *pdev)
379382
{
380383
struct device *dev = &pdev->dev;
384+
const struct phy_gmii_sel_soc_data *soc_data;
381385
struct device_node *node = dev->of_node;
382386
const struct of_device_id *of_id;
383387
struct phy_gmii_sel_priv *priv;
384388
u32 main_ports = 1;
385389
int ret;
390+
u32 i;
386391

387392
of_id = of_match_node(phy_gmii_sel_id_table, pdev->dev.of_node);
388393
if (!of_id)
@@ -394,16 +399,26 @@ static int phy_gmii_sel_probe(struct platform_device *pdev)
394399

395400
priv->dev = &pdev->dev;
396401
priv->soc_data = of_id->data;
402+
soc_data = priv->soc_data;
397403
priv->num_ports = priv->soc_data->num_ports;
398-
of_property_read_u32(node, "ti,qsgmii-main-ports", &main_ports);
404+
priv->qsgmii_main_ports = 0;
405+
399406
/*
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.
407+
* Based on the compatible, try to read the appropriate number of
408+
* QSGMII main ports from the "ti,qsgmii-main-ports" property from
409+
* the device-tree node.
403410
*/
404-
if (main_ports < 1 || main_ports > 4)
405-
main_ports = 1;
406-
priv->qsgmii_main_ports = PHY_GMII_PORT(main_ports);
411+
for (i = 0; i < soc_data->num_qsgmii_main_ports; i++) {
412+
of_property_read_u32_index(node, "ti,qsgmii-main-ports", i, &main_ports);
413+
/*
414+
* Ensure that main_ports is within bounds.
415+
*/
416+
if (main_ports < 1 || main_ports > soc_data->num_ports) {
417+
dev_err(dev, "Invalid qsgmii main port provided\n");
418+
return -EINVAL;
419+
}
420+
priv->qsgmii_main_ports |= PHY_GMII_PORT(main_ports);
421+
}
407422

408423
priv->regmap = syscon_node_to_regmap(node->parent);
409424
if (IS_ERR(priv->regmap)) {

0 commit comments

Comments
 (0)