Skip to content

Commit c7fc9eb

Browse files
yankejiandavem330
authored andcommitted
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 <[email protected]> Signed-off-by: lisheng <[email protected]> Signed-off-by: lipeng <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e9e6d79 commit c7fc9eb

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

drivers/net/ethernet/hisilicon/hns_mdio.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/etherdevice.h>
1212
#include <linux/init.h>
1313
#include <linux/kernel.h>
14+
#include <linux/mfd/syscon.h>
1415
#include <linux/module.h>
1516
#include <linux/mutex.h>
1617
#include <linux/netdevice.h>
@@ -20,6 +21,7 @@
2021
#include <linux/of_platform.h>
2122
#include <linux/phy.h>
2223
#include <linux/platform_device.h>
24+
#include <linux/regmap.h>
2325
#include <linux/spinlock_types.h>
2426

2527
#define MDIO_DRV_NAME "Hi-HNS_MDIO"
@@ -36,7 +38,7 @@
3638

3739
struct hns_mdio_device {
3840
void *vbase; /* mdio reg base address */
39-
void *sys_vbase;
41+
struct regmap *subctrl_vbase;
4042
};
4143

4244
/* mdio reg */
@@ -155,10 +157,10 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev,
155157
u32 time_cnt;
156158
u32 reg_value;
157159

158-
mdio_write_reg((void *)mdio_dev->sys_vbase, cfg_reg, set_val);
160+
regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val);
159161

160162
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, &reg_value);
162164
reg_value &= st_msk;
163165
if ((!!check_st) == (!!reg_value))
164166
break;
@@ -352,7 +354,7 @@ static int hns_mdio_reset(struct mii_bus *bus)
352354
struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv;
353355
int ret;
354356

355-
if (!mdio_dev->sys_vbase) {
357+
if (!mdio_dev->subctrl_vbase) {
356358
dev_err(&bus->dev, "mdio sys ctl reg has not maped\n");
357359
return -ENODEV;
358360
}
@@ -455,13 +457,12 @@ static int hns_mdio_probe(struct platform_device *pdev)
455457
return ret;
456458
}
457459

458-
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
459-
mdio_dev->sys_vbase = devm_ioremap_resource(&pdev->dev, res);
460-
if (IS_ERR(mdio_dev->sys_vbase)) {
461-
ret = PTR_ERR(mdio_dev->sys_vbase);
462-
return ret;
460+
mdio_dev->subctrl_vbase =
461+
syscon_node_to_regmap(of_parse_phandle(np, "subctrl_vbase", 0));
462+
if (IS_ERR(mdio_dev->subctrl_vbase)) {
463+
dev_warn(&pdev->dev, "no syscon hisilicon,peri-c-subctrl\n");
464+
mdio_dev->subctrl_vbase = NULL;
463465
}
464-
465466
new_bus->irq = devm_kcalloc(&pdev->dev, PHY_MAX_ADDR,
466467
sizeof(int), GFP_KERNEL);
467468
if (!new_bus->irq)

0 commit comments

Comments
 (0)