diff options
author | yankejian <yankejian@huawei.com> | 2015-10-21 05:57:44 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-10-22 10:19:36 -0400 |
commit | c7fc9eb79a89049214f9870a6cf978050aaea43a (patch) | |
tree | 66f36e813452adcbf10375b9578fa9f8b34f3b16 | |
parent | e9e6d79c521b91e7103fea37411680e31927487b (diff) |
net: hisilicon: deals with the sub ctrl by syscon
the global Soc configuration is treated by syscon, and sub ctrl bus is
Soc bus. it has to be treated by syscon.
Signed-off-by: yankejian <yankejian@huawei.com>
Signed-off-by: lisheng <lisheng011@huawei.com>
Signed-off-by: lipeng <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/hisilicon/hns_mdio.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c b/drivers/net/ethernet/hisilicon/hns_mdio.c index e4ec52ae61ff..37491c85bc42 100644 --- a/drivers/net/ethernet/hisilicon/hns_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns_mdio.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/etherdevice.h> | 11 | #include <linux/etherdevice.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <linux/mfd/syscon.h> | ||
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
16 | #include <linux/netdevice.h> | 17 | #include <linux/netdevice.h> |
@@ -20,6 +21,7 @@ | |||
20 | #include <linux/of_platform.h> | 21 | #include <linux/of_platform.h> |
21 | #include <linux/phy.h> | 22 | #include <linux/phy.h> |
22 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/regmap.h> | ||
23 | #include <linux/spinlock_types.h> | 25 | #include <linux/spinlock_types.h> |
24 | 26 | ||
25 | #define MDIO_DRV_NAME "Hi-HNS_MDIO" | 27 | #define MDIO_DRV_NAME "Hi-HNS_MDIO" |
@@ -36,7 +38,7 @@ | |||
36 | 38 | ||
37 | struct hns_mdio_device { | 39 | struct hns_mdio_device { |
38 | void *vbase; /* mdio reg base address */ | 40 | void *vbase; /* mdio reg base address */ |
39 | void *sys_vbase; | 41 | struct regmap *subctrl_vbase; |
40 | }; | 42 | }; |
41 | 43 | ||
42 | /* mdio reg */ | 44 | /* mdio reg */ |
@@ -155,10 +157,10 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev, | |||
155 | u32 time_cnt; | 157 | u32 time_cnt; |
156 | u32 reg_value; | 158 | u32 reg_value; |
157 | 159 | ||
158 | mdio_write_reg((void *)mdio_dev->sys_vbase, cfg_reg, set_val); | 160 | regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val); |
159 | 161 | ||
160 | for (time_cnt = MDIO_TIMEOUT; time_cnt; time_cnt--) { | 162 | for (time_cnt = MDIO_TIMEOUT; time_cnt; time_cnt--) { |
161 | reg_value = mdio_read_reg((void *)mdio_dev->sys_vbase, st_reg); | 163 | regmap_read(mdio_dev->subctrl_vbase, st_reg, ®_value); |
162 | reg_value &= st_msk; | 164 | reg_value &= st_msk; |
163 | if ((!!check_st) == (!!reg_value)) | 165 | if ((!!check_st) == (!!reg_value)) |
164 | break; | 166 | break; |
@@ -352,7 +354,7 @@ static int hns_mdio_reset(struct mii_bus *bus) | |||
352 | struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv; | 354 | struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv; |
353 | int ret; | 355 | int ret; |
354 | 356 | ||
355 | if (!mdio_dev->sys_vbase) { | 357 | if (!mdio_dev->subctrl_vbase) { |
356 | dev_err(&bus->dev, "mdio sys ctl reg has not maped\n"); | 358 | dev_err(&bus->dev, "mdio sys ctl reg has not maped\n"); |
357 | return -ENODEV; | 359 | return -ENODEV; |
358 | } | 360 | } |
@@ -455,13 +457,12 @@ static int hns_mdio_probe(struct platform_device *pdev) | |||
455 | return ret; | 457 | return ret; |
456 | } | 458 | } |
457 | 459 | ||
458 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 460 | mdio_dev->subctrl_vbase = |
459 | mdio_dev->sys_vbase = devm_ioremap_resource(&pdev->dev, res); | 461 | syscon_node_to_regmap(of_parse_phandle(np, "subctrl_vbase", 0)); |
460 | if (IS_ERR(mdio_dev->sys_vbase)) { | 462 | if (IS_ERR(mdio_dev->subctrl_vbase)) { |
461 | ret = PTR_ERR(mdio_dev->sys_vbase); | 463 | dev_warn(&pdev->dev, "no syscon hisilicon,peri-c-subctrl\n"); |
462 | return ret; | 464 | mdio_dev->subctrl_vbase = NULL; |
463 | } | 465 | } |
464 | |||
465 | new_bus->irq = devm_kcalloc(&pdev->dev, PHY_MAX_ADDR, | 466 | new_bus->irq = devm_kcalloc(&pdev->dev, PHY_MAX_ADDR, |
466 | sizeof(int), GFP_KERNEL); | 467 | sizeof(int), GFP_KERNEL); |
467 | if (!new_bus->irq) | 468 | if (!new_bus->irq) |