9
0
Fork 0

Merge branch 'pu/am335x'

This commit is contained in:
Sascha Hauer 2015-05-28 08:27:02 +02:00
commit f13f1c269e
6 changed files with 64 additions and 17 deletions

View File

@ -916,20 +916,22 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
struct phy_device *phy; struct phy_device *phy;
phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id); phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id);
if (IS_ERR(phy)) if (IS_ERR(phy)) {
return PTR_ERR(phy); ret = PTR_ERR(phy);
goto err_out;
}
phy->dev.device_node = priv->slaves[slave_num].dev.device_node; phy->dev.device_node = priv->slaves[slave_num].dev.device_node;
ret = phy_register_device(phy); ret = phy_register_device(phy);
if (ret) if (ret)
return ret; goto err_out;
sprintf(dev->name, "cpsw-slave"); sprintf(dev->name, "cpsw-slave");
dev->id = slave->slave_num; dev->id = slave->slave_num;
dev->parent = priv->dev; dev->parent = priv->dev;
ret = register_device(dev); ret = register_device(dev);
if (ret) if (ret)
return ret; goto err_register_dev;
dev_dbg(&slave->dev, "* %s\n", __func__); dev_dbg(&slave->dev, "* %s\n", __func__);
@ -948,7 +950,20 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
edev->set_ethaddr = cpsw_set_hwaddr; edev->set_ethaddr = cpsw_set_hwaddr;
edev->parent = dev; edev->parent = dev;
return eth_register(edev); ret = eth_register(edev);
if (ret)
goto err_register_edev;
return 0;
err_register_dev:
phy_unregister_device(phy);
err_register_edev:
unregister_device(dev);
err_out:
slave->slave_num = -1;
return ret;
} }
struct cpsw_data { struct cpsw_data {
@ -1219,6 +1234,8 @@ int cpsw_probe(struct device_d *dev)
} }
} }
dev->priv = priv;
return 0; return 0;
out: out:
free(priv->slaves); free(priv->slaves);
@ -1227,6 +1244,22 @@ out:
return ret; return ret;
} }
static void cpsw_remove(struct device_d *dev)
{
struct cpsw_priv *priv = dev->priv;
int i;
for (i = 0; i < priv->num_slaves; i++) {
struct cpsw_slave *slave = &priv->slaves[i];
if (slave->slave_num < 0)
continue;
eth_unregister(&slave->edev);
}
mdiobus_unregister(&priv->miibus);
}
static __maybe_unused struct of_device_id cpsw_dt_ids[] = { static __maybe_unused struct of_device_id cpsw_dt_ids[] = {
{ {
.compatible = "ti,cpsw", .compatible = "ti,cpsw",
@ -1238,6 +1271,7 @@ static __maybe_unused struct of_device_id cpsw_dt_ids[] = {
static struct driver_d cpsw_driver = { static struct driver_d cpsw_driver = {
.name = "cpsw", .name = "cpsw",
.probe = cpsw_probe, .probe = cpsw_probe,
.remove = cpsw_remove,
.of_compatible = DRV_OF_COMPAT(cpsw_dt_ids), .of_compatible = DRV_OF_COMPAT(cpsw_dt_ids),
}; };
device_platform_driver(cpsw_driver); device_platform_driver(cpsw_driver);

View File

@ -272,6 +272,17 @@ int phy_register_device(struct phy_device *phydev)
return ret; return ret;
} }
void phy_unregister_device(struct phy_device *phydev)
{
if (!phydev->registered)
return;
phydev->bus->phy_map[phydev->addr] = NULL;
unregister_device(&phydev->dev);
phydev->registered = 0;
}
static struct phy_device *of_mdio_find_phy(struct eth_device *edev) static struct phy_device *of_mdio_find_phy(struct eth_device *edev)
{ {
struct device_d *dev; struct device_d *dev;

View File

@ -139,6 +139,7 @@ int musb_register(struct musb *musb)
host->submit_control_msg = submit_control_msg; host->submit_control_msg = submit_control_msg;
host->submit_bulk_msg = submit_bulk_msg; host->submit_bulk_msg = submit_bulk_msg;
musb->controller->priv = musb;
musb->controller->detect = musb_detect; musb->controller->detect = musb_detect;
usb_register_host(host); usb_register_host(host);

View File

@ -129,14 +129,17 @@ struct dsps_glue {
struct musb_hdrc_platform_data pdata; struct musb_hdrc_platform_data pdata;
}; };
static struct dsps_glue *to_dsps_glue(struct musb *musb)
{
return container_of(musb, struct dsps_glue, musb);
}
/** /**
* dsps_musb_enable - enable interrupts * dsps_musb_enable - enable interrupts
*/ */
static void dsps_musb_enable(struct musb *musb) static void dsps_musb_enable(struct musb *musb)
{ {
struct device_d *dev = musb->controller; struct dsps_glue *glue = to_dsps_glue(musb);
struct device_d *pdev = dev;
struct dsps_glue *glue = pdev->priv;
const struct dsps_musb_wrapper *wrp = glue->wrp; const struct dsps_musb_wrapper *wrp = glue->wrp;
void __iomem *reg_base = musb->ctrl_base; void __iomem *reg_base = musb->ctrl_base;
u32 epmask, coremask; u32 epmask, coremask;
@ -158,9 +161,7 @@ static void dsps_musb_enable(struct musb *musb)
*/ */
static void dsps_musb_disable(struct musb *musb) static void dsps_musb_disable(struct musb *musb)
{ {
struct device_d *dev = musb->controller; struct dsps_glue *glue = to_dsps_glue(musb);
struct device_d *pdev = dev;
struct dsps_glue *glue = pdev->priv;
const struct dsps_musb_wrapper *wrp = glue->wrp; const struct dsps_musb_wrapper *wrp = glue->wrp;
void __iomem *reg_base = musb->ctrl_base; void __iomem *reg_base = musb->ctrl_base;
@ -173,8 +174,7 @@ static void dsps_musb_disable(struct musb *musb)
static irqreturn_t dsps_interrupt(struct musb *musb) static irqreturn_t dsps_interrupt(struct musb *musb)
{ {
void __iomem *reg_base = musb->ctrl_base; void __iomem *reg_base = musb->ctrl_base;
struct device_d *dev = musb->controller; struct dsps_glue *glue = to_dsps_glue(musb);
struct dsps_glue *glue = dev->priv;
const struct dsps_musb_wrapper *wrp = glue->wrp; const struct dsps_musb_wrapper *wrp = glue->wrp;
unsigned long flags; unsigned long flags;
irqreturn_t ret = IRQ_NONE; irqreturn_t ret = IRQ_NONE;
@ -213,8 +213,7 @@ out:
static int dsps_musb_init(struct musb *musb) static int dsps_musb_init(struct musb *musb)
{ {
struct device_d *dev = musb->controller; struct dsps_glue *glue = to_dsps_glue(musb);
struct dsps_glue *glue = dev->priv;
const struct dsps_musb_wrapper *wrp = glue->wrp; const struct dsps_musb_wrapper *wrp = glue->wrp;
u32 rev, val, mode; u32 rev, val, mode;
@ -377,8 +376,6 @@ static int dsps_probe(struct device_d *dev)
glue->dev = dev; glue->dev = dev;
glue->wrp = wrp; glue->wrp = wrp;
dev->priv = glue;
pdata = &glue->pdata; pdata = &glue->pdata;
glue->musb.mregs = dev_request_mem_region(dev, 0); glue->musb.mregs = dev_request_mem_region(dev, 0);

View File

@ -266,6 +266,7 @@ int phy_init(void);
int phy_init_hw(struct phy_device *phydev); int phy_init_hw(struct phy_device *phydev);
int phy_register_device(struct phy_device* dev); int phy_register_device(struct phy_device* dev);
void phy_unregister_device(struct phy_device *phydev);
/** /**
* phy_read - Convenience function for reading a given PHY register * phy_read - Convenience function for reading a given PHY register

View File

@ -385,6 +385,9 @@ void eth_unregister(struct eth_device *edev)
if (edev == eth_current) if (edev == eth_current)
eth_current = NULL; eth_current = NULL;
if (edev->active)
edev->halt(edev);
if (IS_ENABLED(CONFIG_OFDEVICE)) if (IS_ENABLED(CONFIG_OFDEVICE))
free(edev->nodepath); free(edev->nodepath);