#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/netdevice.h>
#include <linux/of_platform.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/spinlock_types.h>
#define MDIO_DRV_NAME "Hi-HNS_MDIO"
struct hns_mdio_device {
void *vbase; /* mdio reg base address */
- void *sys_vbase;
+ struct regmap *subctrl_vbase;
};
/* mdio reg */
u32 time_cnt;
u32 reg_value;
- mdio_write_reg((void *)mdio_dev->sys_vbase, cfg_reg, set_val);
+ regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val);
for (time_cnt = MDIO_TIMEOUT; time_cnt; time_cnt--) {
- reg_value = mdio_read_reg((void *)mdio_dev->sys_vbase, st_reg);
+ regmap_read(mdio_dev->subctrl_vbase, st_reg, ®_value);
reg_value &= st_msk;
if ((!!check_st) == (!!reg_value))
break;
struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv;
int ret;
- if (!mdio_dev->sys_vbase) {
+ if (!mdio_dev->subctrl_vbase) {
dev_err(&bus->dev, "mdio sys ctl reg has not maped\n");
return -ENODEV;
}
return ret;
}
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- mdio_dev->sys_vbase = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(mdio_dev->sys_vbase)) {
- ret = PTR_ERR(mdio_dev->sys_vbase);
- return ret;
+ mdio_dev->subctrl_vbase =
+ syscon_node_to_regmap(of_parse_phandle(np, "subctrl_vbase", 0));
+ if (IS_ERR(mdio_dev->subctrl_vbase)) {
+ dev_warn(&pdev->dev, "no syscon hisilicon,peri-c-subctrl\n");
+ mdio_dev->subctrl_vbase = NULL;
}
-
new_bus->irq = devm_kcalloc(&pdev->dev, PHY_MAX_ADDR,
sizeof(int), GFP_KERNEL);
if (!new_bus->irq)