Release 4.11 drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c
/*
* Combined Ethernet driver for Motorola MPC8xx and MPC82xx.
*
* Copyright (c) 2003 Intracom S.A.
* by Pantelis Antoniou <panto@intracom.gr>
*
* 2005 (c) MontaVista Software, Inc.
* Vitaly Bordug <vbordug@ru.mvista.com>
*
* This file is licensed under the terms of the GNU General Public License
* version 2. This program is licensed "as is" without any warranty of any
* kind, whether express or implied.
*/
#include <linux/module.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/mii.h>
#include <linux/platform_device.h>
#include <linux/mdio-bitbang.h>
#include <linux/of_address.h>
#include <linux/of_mdio.h>
#include <linux/of_platform.h>
#include "fs_enet.h"
struct bb_info {
struct mdiobb_ctrl ctrl;
__be32 __iomem *dir;
__be32 __iomem *dat;
u32 mdio_msk;
u32 mdc_msk;
};
/* FIXME: If any other users of GPIO crop up, then these will have to
* have some sort of global synchronization to avoid races with other
* pins on the same port. The ideal solution would probably be to
* bind the ports to a GPIO driver, and have this be a client of it.
*/
static inline void bb_set(u32 __iomem *p, u32 m)
{
out_be32(p, in_be32(p) | m);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitaly Bordug | 18 | 66.67% | 1 | 33.33% |
Scott Wood | 5 | 18.52% | 1 | 33.33% |
Pantelis Antoniou | 4 | 14.81% | 1 | 33.33% |
Total | 27 | 100.00% | 3 | 100.00% |
static inline void bb_clr(u32 __iomem *p, u32 m)
{
out_be32(p, in_be32(p) & ~m);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitaly Bordug | 21 | 75.00% | 1 | 33.33% |
Scott Wood | 5 | 17.86% | 1 | 33.33% |
Pantelis Antoniou | 2 | 7.14% | 1 | 33.33% |
Total | 28 | 100.00% | 3 | 100.00% |
static inline int bb_read(u32 __iomem *p, u32 m)
{
return (in_be32(p) & m) != 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Vitaly Bordug | 17 | 62.96% | 1 | 33.33% |
Pantelis Antoniou | 6 | 22.22% | 1 | 33.33% |
Scott Wood | 4 | 14.81% | 1 | 33.33% |
Total | 27 | 100.00% | 3 | 100.00% |
static inline void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
{
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
if (dir)
bb_set(bitbang->dir, bitbang->mdio_msk);
else
bb_clr(bitbang->dir, bitbang->mdio_msk);
/* Read back to flush the write. */
in_be32(bitbang->dir);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pantelis Antoniou | 31 | 47.69% | 1 | 25.00% |
Scott Wood | 25 | 38.46% | 2 | 50.00% |
Vitaly Bordug | 9 | 13.85% | 1 | 25.00% |
Total | 65 | 100.00% | 4 | 100.00% |
static inline int mdio_read(struct mdiobb_ctrl *ctrl)
{
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
return bb_read(bitbang->dat, bitbang->mdio_msk);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Wood | 21 | 53.85% | 2 | 50.00% |
Pantelis Antoniou | 16 | 41.03% | 1 | 25.00% |
Vitaly Bordug | 2 | 5.13% | 1 | 25.00% |
Total | 39 | 100.00% | 4 | 100.00% |
static inline void mdio(struct mdiobb_ctrl *ctrl, int what)
{
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
if (what)
bb_set(bitbang->dat, bitbang->mdio_msk);
else
bb_clr(bitbang->dat, bitbang->mdio_msk);
/* Read back to flush the write. */
in_be32(bitbang->dat);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Wood | 36 | 55.38% | 1 | 33.33% |
Pantelis Antoniou | 21 | 32.31% | 1 | 33.33% |
Vitaly Bordug | 8 | 12.31% | 1 | 33.33% |
Total | 65 | 100.00% | 3 | 100.00% |
static inline void mdc(struct mdiobb_ctrl *ctrl, int what)
{
struct bb_info *bitbang = container_of(ctrl, struct bb_info, ctrl);
if (what)
bb_set(bitbang->dat, bitbang->mdc_msk);
else
bb_clr(bitbang->dat, bitbang->mdc_msk);
/* Read back to flush the write. */
in_be32(bitbang->dat);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Wood | 47 | 72.31% | 1 | 33.33% |
Pantelis Antoniou | 14 | 21.54% | 1 | 33.33% |
Vitaly Bordug | 4 | 6.15% | 1 | 33.33% |
Total | 65 | 100.00% | 3 | 100.00% |
static struct mdiobb_ops bb_ops = {
.owner = THIS_MODULE,
.set_mdc = mdc,
.set_mdio_dir = mdio_dir,
.set_mdio_data = mdio,
.get_mdio_data = mdio_read,
};
static int fs_mii_bitbang_init(struct mii_bus *bus, struct device_node *np)
{
struct resource res;
const u32 *data;
int mdio_pin, mdc_pin, len;
struct bb_info *bitbang = bus->priv;
int ret = of_address_to_resource(np, 0, &res);
if (ret)
return ret;
if (resource_size(&res) <= 13)
return -ENODEV;
/* This should really encode the pin number as well, but all
* we get is an int, and the odds of multiple bitbang mdio buses
* is low enough that it's not worth going too crazy.
*/
snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
data = of_get_property(np, "fsl,mdio-pin", &len);
if (!data || len != 4)
return -ENODEV;
mdio_pin = *data;
data = of_get_property(np, "fsl,mdc-pin", &len);
if (!data || len != 4)
return -ENODEV;
mdc_pin = *data;
bitbang->dir = ioremap(res.start, resource_size(&res));
if (!bitbang->dir)
return -ENOMEM;
bitbang->dat = bitbang->dir + 4;
bitbang->mdio_msk = 1 << (31 - mdio_pin);
bitbang->mdc_msk = 1 << (31 - mdc_pin);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Wood | 145 | 67.13% | 1 | 20.00% |
Vitaly Bordug | 37 | 17.13% | 1 | 20.00% |
Pantelis Antoniou | 17 | 7.87% | 1 | 20.00% |
Joe Perches | 9 | 4.17% | 1 | 20.00% |
Andy Fleming | 8 | 3.70% | 1 | 20.00% |
Total | 216 | 100.00% | 5 | 100.00% |
static int fs_enet_mdio_probe(struct platform_device *ofdev)
{
struct mii_bus *new_bus;
struct bb_info *bitbang;
int ret = -ENOMEM;
bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL);
if (!bitbang)
goto out;
bitbang->ctrl.ops = &bb_ops;
new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
if (!new_bus)
goto out_free_priv;
new_bus->name = "CPM2 Bitbanged MII",
ret = fs_mii_bitbang_init(new_bus, ofdev->dev.of_node);
if (ret)
goto out_free_bus;
new_bus->phy_mask = ~0;
new_bus->parent = &ofdev->dev;
platform_set_drvdata(ofdev, new_bus);
ret = of_mdiobus_register(new_bus, ofdev->dev.of_node);
if (ret)
goto out_unmap_regs;
return 0;
out_unmap_regs:
iounmap(bitbang->dir);
out_free_bus:
free_mdio_bitbang(new_bus);
out_free_priv:
kfree(bitbang);
out:
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Wood | 158 | 90.29% | 2 | 22.22% |
Anatolij Gustschin | 6 | 3.43% | 1 | 11.11% |
Grant C. Likely | 5 | 2.86% | 2 | 22.22% |
Lennert Buytenhek | 4 | 2.29% | 2 | 22.22% |
Jingoo Han | 1 | 0.57% | 1 | 11.11% |
Andrew Lunn | 1 | 0.57% | 1 | 11.11% |
Total | 175 | 100.00% | 9 | 100.00% |
static int fs_enet_mdio_remove(struct platform_device *ofdev)
{
struct mii_bus *bus = platform_get_drvdata(ofdev);
struct bb_info *bitbang = bus->priv;
mdiobus_unregister(bus);
free_mdio_bitbang(bus);
iounmap(bitbang->dir);
kfree(bitbang);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Wood | 48 | 87.27% | 1 | 25.00% |
Lennert Buytenhek | 5 | 9.09% | 1 | 25.00% |
Jingoo Han | 1 | 1.82% | 1 | 25.00% |
Grant C. Likely | 1 | 1.82% | 1 | 25.00% |
Total | 55 | 100.00% | 4 | 100.00% |
static const struct of_device_id fs_enet_mdio_bb_match[] = {
{
.compatible = "fsl,cpm2-mdio-bitbang",
},
{},
};
MODULE_DEVICE_TABLE(of, fs_enet_mdio_bb_match);
static struct platform_driver fs_enet_bb_mdio_driver = {
.driver = {
.name = "fsl-bb-mdio",
.of_match_table = fs_enet_mdio_bb_match,
},
.probe = fs_enet_mdio_probe,
.remove = fs_enet_mdio_remove,
};
module_platform_driver(fs_enet_bb_mdio_driver);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Scott Wood | 592 | 64.21% | 2 | 10.00% |
Pantelis Antoniou | 146 | 15.84% | 1 | 5.00% |
Vitaly Bordug | 120 | 13.02% | 2 | 10.00% |
Grant C. Likely | 16 | 1.74% | 4 | 20.00% |
Lennert Buytenhek | 9 | 0.98% | 2 | 10.00% |
Joe Perches | 9 | 0.98% | 1 | 5.00% |
Andy Fleming | 8 | 0.87% | 1 | 5.00% |
Anton Vorontsov | 7 | 0.76% | 1 | 5.00% |
Anatolij Gustschin | 6 | 0.65% | 1 | 5.00% |
Rob Herring | 3 | 0.33% | 1 | 5.00% |
Axel Lin | 2 | 0.22% | 1 | 5.00% |
Jingoo Han | 2 | 0.22% | 1 | 5.00% |
Andrew Lunn | 1 | 0.11% | 1 | 5.00% |
Fabian Frederick | 1 | 0.11% | 1 | 5.00% |
Total | 922 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.