Commit 04d94236 authored by Jiawen Wu's avatar Jiawen Wu Committed by Paolo Abeni

net: txgbe: Add SFP module identify

Register SFP platform device to get modules information.
Signed-off-by: default avatarJiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarPiotr Raczynski <piotr.raczynski@intel.com>
Reviewed-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent c625e725
...@@ -44,6 +44,9 @@ config TXGBE ...@@ -44,6 +44,9 @@ config TXGBE
select REGMAP select REGMAP
select I2C select I2C
select I2C_DESIGNWARE_PLATFORM select I2C_DESIGNWARE_PLATFORM
select PHYLINK
select HWMON if TXGBE=y
select SFP
select LIBWX select LIBWX
help help
This driver supports Wangxun(R) 10GbE PCI Express family of This driver supports Wangxun(R) 10GbE PCI Express family of
......
...@@ -158,6 +158,25 @@ static int txgbe_i2c_register(struct txgbe *txgbe) ...@@ -158,6 +158,25 @@ static int txgbe_i2c_register(struct txgbe *txgbe)
return 0; return 0;
} }
static int txgbe_sfp_register(struct txgbe *txgbe)
{
struct pci_dev *pdev = txgbe->wx->pdev;
struct platform_device_info info = {};
struct platform_device *sfp_dev;
info.parent = &pdev->dev;
info.fwnode = software_node_fwnode(txgbe->nodes.group[SWNODE_SFP]);
info.name = "sfp";
info.id = (pdev->bus->number << 8) | pdev->devfn;
sfp_dev = platform_device_register_full(&info);
if (IS_ERR(sfp_dev))
return PTR_ERR(sfp_dev);
txgbe->sfp_dev = sfp_dev;
return 0;
}
int txgbe_init_phy(struct txgbe *txgbe) int txgbe_init_phy(struct txgbe *txgbe)
{ {
int ret; int ret;
...@@ -180,8 +199,16 @@ int txgbe_init_phy(struct txgbe *txgbe) ...@@ -180,8 +199,16 @@ int txgbe_init_phy(struct txgbe *txgbe)
goto err_unregister_clk; goto err_unregister_clk;
} }
ret = txgbe_sfp_register(txgbe);
if (ret) {
wx_err(txgbe->wx, "failed to register sfp\n");
goto err_unregister_i2c;
}
return 0; return 0;
err_unregister_i2c:
platform_device_unregister(txgbe->i2c_dev);
err_unregister_clk: err_unregister_clk:
clkdev_drop(txgbe->clock); clkdev_drop(txgbe->clock);
clk_unregister(txgbe->clk); clk_unregister(txgbe->clk);
...@@ -193,6 +220,7 @@ int txgbe_init_phy(struct txgbe *txgbe) ...@@ -193,6 +220,7 @@ int txgbe_init_phy(struct txgbe *txgbe)
void txgbe_remove_phy(struct txgbe *txgbe) void txgbe_remove_phy(struct txgbe *txgbe)
{ {
platform_device_unregister(txgbe->sfp_dev);
platform_device_unregister(txgbe->i2c_dev); platform_device_unregister(txgbe->i2c_dev);
clkdev_drop(txgbe->clock); clkdev_drop(txgbe->clock);
clk_unregister(txgbe->clk); clk_unregister(txgbe->clk);
......
...@@ -150,6 +150,7 @@ struct txgbe_nodes { ...@@ -150,6 +150,7 @@ struct txgbe_nodes {
struct txgbe { struct txgbe {
struct wx *wx; struct wx *wx;
struct txgbe_nodes nodes; struct txgbe_nodes nodes;
struct platform_device *sfp_dev;
struct platform_device *i2c_dev; struct platform_device *i2c_dev;
struct clk_lookup *clock; struct clk_lookup *clock;
struct clk *clk; struct clk *clk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment