提交 bc0b8b66 编写于 作者: D David S. Miller

Merge branch 'sh_eth-optimize-mdio'

Sergei Shtylyov says:

====================
sh_eth: optimize MDIO code

Here's a set of 3 patches against DaveM's 'net-next.git' repo which
gets rid of ~35 LoCs in the MDIO bitbang methods.
====================
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
...@@ -1013,56 +1013,34 @@ struct bb_info { ...@@ -1013,56 +1013,34 @@ struct bb_info {
void (*set_gate)(void *addr); void (*set_gate)(void *addr);
struct mdiobb_ctrl ctrl; struct mdiobb_ctrl ctrl;
void *addr; void *addr;
u32 mmd_msk;/* MMD */
u32 mdo_msk;
u32 mdi_msk;
u32 mdc_msk;
}; };
/* PHY bit set */ static void sh_mdio_ctrl(struct mdiobb_ctrl *ctrl, u32 mask, int set)
static void bb_set(void *addr, u32 msk)
{ {
iowrite32(ioread32(addr) | msk, addr); struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
} u32 pir;
/* PHY bit clear */ if (bitbang->set_gate)
static void bb_clr(void *addr, u32 msk) bitbang->set_gate(bitbang->addr);
{
iowrite32((ioread32(addr) & ~msk), addr);
}
/* PHY bit read */ pir = ioread32(bitbang->addr);
static int bb_read(void *addr, u32 msk) if (set)
{ pir |= mask;
return (ioread32(addr) & msk) != 0; else
pir &= ~mask;
iowrite32(pir, bitbang->addr);
} }
/* Data I/O pin control */ /* Data I/O pin control */
static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit) static void sh_mmd_ctrl(struct mdiobb_ctrl *ctrl, int bit)
{ {
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); sh_mdio_ctrl(ctrl, PIR_MMD, bit);
if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr);
if (bit)
bb_set(bitbang->addr, bitbang->mmd_msk);
else
bb_clr(bitbang->addr, bitbang->mmd_msk);
} }
/* Set bit data*/ /* Set bit data*/
static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit) static void sh_set_mdio(struct mdiobb_ctrl *ctrl, int bit)
{ {
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); sh_mdio_ctrl(ctrl, PIR_MDO, bit);
if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr);
if (bit)
bb_set(bitbang->addr, bitbang->mdo_msk);
else
bb_clr(bitbang->addr, bitbang->mdo_msk);
} }
/* Get bit data*/ /* Get bit data*/
...@@ -1073,21 +1051,13 @@ static int sh_get_mdio(struct mdiobb_ctrl *ctrl) ...@@ -1073,21 +1051,13 @@ static int sh_get_mdio(struct mdiobb_ctrl *ctrl)
if (bitbang->set_gate) if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr); bitbang->set_gate(bitbang->addr);
return bb_read(bitbang->addr, bitbang->mdi_msk); return (ioread32(bitbang->addr) & PIR_MDI) != 0;
} }
/* MDC pin control */ /* MDC pin control */
static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit) static void sh_mdc_ctrl(struct mdiobb_ctrl *ctrl, int bit)
{ {
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl); sh_mdio_ctrl(ctrl, PIR_MDC, bit);
if (bitbang->set_gate)
bitbang->set_gate(bitbang->addr);
if (bit)
bb_set(bitbang->addr, bitbang->mdc_msk);
else
bb_clr(bitbang->addr, bitbang->mdc_msk);
} }
/* mdio bus control struct */ /* mdio bus control struct */
...@@ -2899,10 +2869,6 @@ static int sh_mdio_init(struct sh_eth_private *mdp, ...@@ -2899,10 +2869,6 @@ static int sh_mdio_init(struct sh_eth_private *mdp,
/* bitbang init */ /* bitbang init */
bitbang->addr = mdp->addr + mdp->reg_offset[PIR]; bitbang->addr = mdp->addr + mdp->reg_offset[PIR];
bitbang->set_gate = pd->set_mdio_gate; bitbang->set_gate = pd->set_mdio_gate;
bitbang->mdi_msk = PIR_MDI;
bitbang->mdo_msk = PIR_MDO;
bitbang->mmd_msk = PIR_MMD;
bitbang->mdc_msk = PIR_MDC;
bitbang->ctrl.ops = &bb_ops; bitbang->ctrl.ops = &bb_ops;
/* MII controller setting */ /* MII controller setting */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册