|
11 | 11 | #include <linux/etherdevice.h> |
12 | 12 | #include <linux/init.h> |
13 | 13 | #include <linux/kernel.h> |
| 14 | +#include <linux/mfd/syscon.h> |
14 | 15 | #include <linux/module.h> |
15 | 16 | #include <linux/mutex.h> |
16 | 17 | #include <linux/netdevice.h> |
|
20 | 21 | #include <linux/of_platform.h> |
21 | 22 | #include <linux/phy.h> |
22 | 23 | #include <linux/platform_device.h> |
| 24 | +#include <linux/regmap.h> |
23 | 25 | #include <linux/spinlock_types.h> |
24 | 26 |
|
25 | 27 | #define MDIO_DRV_NAME "Hi-HNS_MDIO" |
|
36 | 38 |
|
37 | 39 | struct hns_mdio_device { |
38 | 40 | void *vbase; /* mdio reg base address */ |
39 | | - void *sys_vbase; |
| 41 | + struct regmap *subctrl_vbase; |
40 | 42 | }; |
41 | 43 |
|
42 | 44 | /* mdio reg */ |
@@ -155,10 +157,10 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev, |
155 | 157 | u32 time_cnt; |
156 | 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 | 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 | 164 | reg_value &= st_msk; |
163 | 165 | if ((!!check_st) == (!!reg_value)) |
164 | 166 | break; |
@@ -352,7 +354,7 @@ static int hns_mdio_reset(struct mii_bus *bus) |
352 | 354 | struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv; |
353 | 355 | int ret; |
354 | 356 |
|
355 | | - if (!mdio_dev->sys_vbase) { |
| 357 | + if (!mdio_dev->subctrl_vbase) { |
356 | 358 | dev_err(&bus->dev, "mdio sys ctl reg has not maped\n"); |
357 | 359 | return -ENODEV; |
358 | 360 | } |
@@ -455,13 +457,12 @@ static int hns_mdio_probe(struct platform_device *pdev) |
455 | 457 | return ret; |
456 | 458 | } |
457 | 459 |
|
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; |
463 | 465 | } |
464 | | - |
465 | 466 | new_bus->irq = devm_kcalloc(&pdev->dev, PHY_MAX_ADDR, |
466 | 467 | sizeof(int), GFP_KERNEL); |
467 | 468 | if (!new_bus->irq) |
|
0 commit comments