aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2011-03-07 16:59:55 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-14 17:10:16 -0400
commitb3017e6a03d261778ad9450b5510460c4d462203 (patch)
tree6aef0e3284c8d567dab59e4f3432ae2b5a8c3303
parent8fcd496151b4354569283056076339239b86fabe (diff)
net: sh_eth: add set_mdio_gate in bb_info
The SH7757's ETHER and GETHER use common MDIO pin. The MDIO pin is selected by specific register. So this patch adds new interface in bb_info, and when the sh_eth driver use the mdio, the register can be changed by the function. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sh/include/asm/sh_eth.h1
-rw-r--r--drivers/net/sh_eth.c21
2 files changed, 20 insertions, 2 deletions
diff --git a/arch/sh/include/asm/sh_eth.h b/arch/sh/include/asm/sh_eth.h
index e86c880b7e4c..0f325da0f923 100644
--- a/arch/sh/include/asm/sh_eth.h
+++ b/arch/sh/include/asm/sh_eth.h
@@ -15,6 +15,7 @@ struct sh_eth_plat_data {
15 int edmac_endian; 15 int edmac_endian;
16 int register_type; 16 int register_type;
17 phy_interface_t phy_interface; 17 phy_interface_t phy_interface;
18 void (*set_mdio_gate)(unsigned long addr);
18 19
19 unsigned char mac_addr[6]; 20 unsigned char mac_addr[6];
20 unsigned no_ether_link:1; 21 unsigned no_ether_link:1;
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index dcf9f87d021f..e9e7a530552c 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -512,6 +512,7 @@ static unsigned long sh_eth_get_edtrr_trns(struct sh_eth_private *mdp)
512} 512}
513 513
514struct bb_info { 514struct bb_info {
515 void (*set_gate)(unsigned long addr);
515 struct mdiobb_ctrl ctrl; 516 struct mdiobb_ctrl ctrl;
516 u32 addr; 517 u32 addr;
517 u32 mmd_msk;/* MMD */ 518 u32 mmd_msk;/* MMD */
@@ -542,6 +543,10 @@ static int bb_read(u32 addr, u32 msk)
542static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit) 543static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit)
543{ 544{
544 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); 545 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
546
547 if (bitbang->set_gate)
548 bitbang->set_gate(bitbang->addr);
549
545 if (bit) 550 if (bit)
546 bb_set(bitbang->addr, bitbang->mmd_msk); 551 bb_set(bitbang->addr, bitbang->mmd_msk);
547 else 552 else
@@ -553,6 +558,9 @@ static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit)
553{ 558{
554 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); 559 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
555 560
561 if (bitbang->set_gate)
562 bitbang->set_gate(bitbang->addr);
563
556 if (bit) 564 if (bit)
557 bb_set(bitbang->addr, bitbang->mdo_msk); 565 bb_set(bitbang->addr, bitbang->mdo_msk);
558 else 566 else
@@ -563,6 +571,10 @@ static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit)
563static int sh_get_mdio(struct mdiobb_ctrl *ctrl) 571static int sh_get_mdio(struct mdiobb_ctrl *ctrl)
564{ 572{
565 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); 573 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
574
575 if (bitbang->set_gate)
576 bitbang->set_gate(bitbang->addr);
577
566 return bb_read(bitbang->addr, bitbang->mdi_msk); 578 return bb_read(bitbang->addr, bitbang->mdi_msk);
567} 579}
568 580
@@ -571,6 +583,9 @@ static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit)
571{ 583{
572 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); 584 struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
573 585
586 if (bitbang->set_gate)
587 bitbang->set_gate(bitbang->addr);
588
574 if (bit) 589 if (bit)
575 bb_set(bitbang->addr, bitbang->mdc_msk); 590 bb_set(bitbang->addr, bitbang->mdc_msk);
576 else 591 else
@@ -1646,7 +1661,8 @@ static int sh_mdio_release(struct net_device *ndev)
1646} 1661}
1647 1662
1648/* MDIO bus init function */ 1663/* MDIO bus init function */
1649static int sh_mdio_init(struct net_device *ndev, int id) 1664static int sh_mdio_init(struct net_device *ndev, int id,
1665 struct sh_eth_plat_data *pd)
1650{ 1666{
1651 int ret, i; 1667 int ret, i;
1652 struct bb_info *bitbang; 1668 struct bb_info *bitbang;
@@ -1661,6 +1677,7 @@ static int sh_mdio_init(struct net_device *ndev, int id)
1661 1677
1662 /* bitbang init */ 1678 /* bitbang init */
1663 bitbang->addr = ndev->base_addr + mdp->reg_offset[PIR]; 1679 bitbang->addr = ndev->base_addr + mdp->reg_offset[PIR];
1680 bitbang->set_gate = pd->set_mdio_gate;
1664 bitbang->mdi_msk = 0x08; 1681 bitbang->mdi_msk = 0x08;
1665 bitbang->mdo_msk = 0x04; 1682 bitbang->mdo_msk = 0x04;
1666 bitbang->mmd_msk = 0x02;/* MMD */ 1683 bitbang->mmd_msk = 0x02;/* MMD */
@@ -1854,7 +1871,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
1854 goto out_release; 1871 goto out_release;
1855 1872
1856 /* mdio bus init */ 1873 /* mdio bus init */
1857 ret = sh_mdio_init(ndev, pdev->id); 1874 ret = sh_mdio_init(ndev, pdev->id, pd);
1858 if (ret) 1875 if (ret)
1859 goto out_unregister; 1876 goto out_unregister;
1860 1877