Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: phy-ocelot-serdes: add ability to be used in a non-syscon configuration

The phy-ocelot-serdes module has exclusively been used in a syscon setup,
from an internal CPU. The addition of external control of ocelot switches
via an existing MFD implementation means that syscon is no longer the only
interface that phy-ocelot-serdes will see.

In the MFD configuration, an IORESOURCE_REG resource will exist for the
device. Utilize this resource to be able to function in both syscon and
non-syscon configurations.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Colin Foster and committed by
David S. Miller
672faa7b d4671cb9

+9
+9
drivers/phy/mscc/phy-ocelot-serdes.c
··· 494 494 { 495 495 struct phy_provider *provider; 496 496 struct serdes_ctrl *ctrl; 497 + struct resource *res; 497 498 unsigned int i; 498 499 int ret; 499 500 ··· 504 503 505 504 ctrl->dev = &pdev->dev; 506 505 ctrl->regs = syscon_node_to_regmap(pdev->dev.parent->of_node); 506 + if (IS_ERR(ctrl->regs)) { 507 + /* Fall back to using IORESOURCE_REG, if possible */ 508 + res = platform_get_resource(pdev, IORESOURCE_REG, 0); 509 + if (res) 510 + ctrl->regs = dev_get_regmap(ctrl->dev->parent, 511 + res->name); 512 + } 513 + 507 514 if (IS_ERR(ctrl->regs)) 508 515 return PTR_ERR(ctrl->regs); 509 516