Merge tag 'mvebu' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull ARM SoC updates for Marvell mvebu/kirkwood from Olof Johansson: "This is a branch with updates for Marvell's mvebu/kirkwood platforms. They came in late-ish, and were heavily interdependent such that it didn't make sense to split them up across the cross-platform topic branches. So here they are (for the second release in a row) in a branch on their own." * tag 'mvebu' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (88 commits) arm: l2x0: add aurora related properties to OF binding arm: mvebu: add Aurora L2 Cache Controller to the DT arm: mvebu: add L2 cache support dma: mv_xor: fix error handling path dma: mv_xor: fix error checking of irq_of_parse_and_map() dma: mv_xor: use request_irq() instead of devm_request_irq() dma: mv_xor: clear the window override control registers arm: mvebu: fix address decoding armada_cfg_base() function ARM: mvebu: update defconfig with I2C and RTC support ARM: mvebu: Add SATA support for OpenBlocks AX3-4 ARM: mvebu: Add support for the RTC in OpenBlocks AX3-4 ARM: mvebu: Add support for I2C on OpenBlocks AX3-4 ARM: mvebu: Add support for I2C controllers in Armada 370/XP arm: mvebu: Add hardware I/O Coherency support arm: plat-orion: Add coherency attribute when setup mbus target arm: dma mapping: Export a dma ops function arm_dma_set_mask arm: mvebu: Add SMP support for Armada XP arm: mm: Add support for PJ4B cpu and init routines arm: mvebu: Add IPI support via doorbells arm: mvebu: Add initial support for power managmement service unit ...
This commit is contained in:
@@ -31,6 +31,30 @@ config MV643XX_ETH
|
||||
Some boards that use the Discovery chipset are the Momenco
|
||||
Ocelot C and Jaguar ATX and Pegasos II.
|
||||
|
||||
config MVMDIO
|
||||
tristate "Marvell MDIO interface support"
|
||||
---help---
|
||||
This driver supports the MDIO interface found in the network
|
||||
interface units of the Marvell EBU SoCs (Kirkwood, Orion5x,
|
||||
Dove, Armada 370 and Armada XP).
|
||||
|
||||
For now, this driver is only needed for the MVNETA driver
|
||||
(used on Armada 370 and XP), but it could be used in the
|
||||
future by the MV643XX_ETH driver.
|
||||
|
||||
config MVNETA
|
||||
tristate "Marvell Armada 370/XP network interface support"
|
||||
depends on MACH_ARMADA_370_XP
|
||||
select PHYLIB
|
||||
select MVMDIO
|
||||
---help---
|
||||
This driver supports the network interface units in the
|
||||
Marvell ARMADA XP and ARMADA 370 SoC family.
|
||||
|
||||
Note that this driver is distinct from the mv643xx_eth
|
||||
driver, which should be used for the older Marvell SoCs
|
||||
(Dove, Orion, Discovery, Kirkwood).
|
||||
|
||||
config PXA168_ETH
|
||||
tristate "Marvell pxa168 ethernet support"
|
||||
depends on CPU_PXA168
|
||||
|
@@ -3,6 +3,8 @@
|
||||
#
|
||||
|
||||
obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o
|
||||
obj-$(CONFIG_MVMDIO) += mvmdio.o
|
||||
obj-$(CONFIG_MVNETA) += mvneta.o
|
||||
obj-$(CONFIG_PXA168_ETH) += pxa168_eth.o
|
||||
obj-$(CONFIG_SKGE) += skge.o
|
||||
obj-$(CONFIG_SKY2) += sky2.o
|
||||
|
228
drivers/net/ethernet/marvell/mvmdio.c
Normal file
228
drivers/net/ethernet/marvell/mvmdio.c
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Driver for the MDIO interface of Marvell network interfaces.
|
||||
*
|
||||
* Since the MDIO interface of Marvell network interfaces is shared
|
||||
* between all network interfaces, having a single driver allows to
|
||||
* handle concurrent accesses properly (you may have four Ethernet
|
||||
* ports, but they in fact share the same SMI interface to access the
|
||||
* MDIO bus). Moreover, this MDIO interface code is similar between
|
||||
* the mv643xx_eth driver and the mvneta driver. For now, it is only
|
||||
* used by the mvneta driver, but it could later be used by the
|
||||
* mv643xx_eth driver as well.
|
||||
*
|
||||
* Copyright (C) 2012 Marvell
|
||||
*
|
||||
* Thomas Petazzoni <thomas.petazzoni@free-electrons.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/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/phy.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/of_mdio.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#define MVMDIO_SMI_DATA_SHIFT 0
|
||||
#define MVMDIO_SMI_PHY_ADDR_SHIFT 16
|
||||
#define MVMDIO_SMI_PHY_REG_SHIFT 21
|
||||
#define MVMDIO_SMI_READ_OPERATION BIT(26)
|
||||
#define MVMDIO_SMI_WRITE_OPERATION 0
|
||||
#define MVMDIO_SMI_READ_VALID BIT(27)
|
||||
#define MVMDIO_SMI_BUSY BIT(28)
|
||||
|
||||
struct orion_mdio_dev {
|
||||
struct mutex lock;
|
||||
void __iomem *smireg;
|
||||
};
|
||||
|
||||
/* Wait for the SMI unit to be ready for another operation
|
||||
*/
|
||||
static int orion_mdio_wait_ready(struct mii_bus *bus)
|
||||
{
|
||||
struct orion_mdio_dev *dev = bus->priv;
|
||||
int count;
|
||||
u32 val;
|
||||
|
||||
count = 0;
|
||||
while (1) {
|
||||
val = readl(dev->smireg);
|
||||
if (!(val & MVMDIO_SMI_BUSY))
|
||||
break;
|
||||
|
||||
if (count > 100) {
|
||||
dev_err(bus->parent, "Timeout: SMI busy for too long\n");
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
udelay(10);
|
||||
count++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int orion_mdio_read(struct mii_bus *bus, int mii_id,
|
||||
int regnum)
|
||||
{
|
||||
struct orion_mdio_dev *dev = bus->priv;
|
||||
int count;
|
||||
u32 val;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
ret = orion_mdio_wait_ready(bus);
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
|
||||
(regnum << MVMDIO_SMI_PHY_REG_SHIFT) |
|
||||
MVMDIO_SMI_READ_OPERATION),
|
||||
dev->smireg);
|
||||
|
||||
/* Wait for the value to become available */
|
||||
count = 0;
|
||||
while (1) {
|
||||
val = readl(dev->smireg);
|
||||
if (val & MVMDIO_SMI_READ_VALID)
|
||||
break;
|
||||
|
||||
if (count > 100) {
|
||||
dev_err(bus->parent, "Timeout when reading PHY\n");
|
||||
mutex_unlock(&dev->lock);
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
udelay(10);
|
||||
count++;
|
||||
}
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
return val & 0xFFFF;
|
||||
}
|
||||
|
||||
static int orion_mdio_write(struct mii_bus *bus, int mii_id,
|
||||
int regnum, u16 value)
|
||||
{
|
||||
struct orion_mdio_dev *dev = bus->priv;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
ret = orion_mdio_wait_ready(bus);
|
||||
if (ret < 0) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
writel(((mii_id << MVMDIO_SMI_PHY_ADDR_SHIFT) |
|
||||
(regnum << MVMDIO_SMI_PHY_REG_SHIFT) |
|
||||
MVMDIO_SMI_WRITE_OPERATION |
|
||||
(value << MVMDIO_SMI_DATA_SHIFT)),
|
||||
dev->smireg);
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int orion_mdio_reset(struct mii_bus *bus)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devinit orion_mdio_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
struct mii_bus *bus;
|
||||
struct orion_mdio_dev *dev;
|
||||
int i, ret;
|
||||
|
||||
bus = mdiobus_alloc_size(sizeof(struct orion_mdio_dev));
|
||||
if (!bus) {
|
||||
dev_err(&pdev->dev, "Cannot allocate MDIO bus\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
bus->name = "orion_mdio_bus";
|
||||
bus->read = orion_mdio_read;
|
||||
bus->write = orion_mdio_write;
|
||||
bus->reset = orion_mdio_reset;
|
||||
snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii",
|
||||
dev_name(&pdev->dev));
|
||||
bus->parent = &pdev->dev;
|
||||
|
||||
bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
|
||||
if (!bus->irq) {
|
||||
dev_err(&pdev->dev, "Cannot allocate PHY IRQ array\n");
|
||||
mdiobus_free(bus);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < PHY_MAX_ADDR; i++)
|
||||
bus->irq[i] = PHY_POLL;
|
||||
|
||||
dev = bus->priv;
|
||||
dev->smireg = of_iomap(pdev->dev.of_node, 0);
|
||||
if (!dev->smireg) {
|
||||
dev_err(&pdev->dev, "No SMI register address given in DT\n");
|
||||
kfree(bus->irq);
|
||||
mdiobus_free(bus);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
mutex_init(&dev->lock);
|
||||
|
||||
ret = of_mdiobus_register(bus, np);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret);
|
||||
iounmap(dev->smireg);
|
||||
kfree(bus->irq);
|
||||
mdiobus_free(bus);
|
||||
return ret;
|
||||
}
|
||||
|
||||
platform_set_drvdata(pdev, bus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __devexit orion_mdio_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct mii_bus *bus = platform_get_drvdata(pdev);
|
||||
mdiobus_unregister(bus);
|
||||
kfree(bus->irq);
|
||||
mdiobus_free(bus);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id orion_mdio_match[] = {
|
||||
{ .compatible = "marvell,orion-mdio" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, orion_mdio_match);
|
||||
|
||||
static struct platform_driver orion_mdio_driver = {
|
||||
.probe = orion_mdio_probe,
|
||||
.remove = __devexit_p(orion_mdio_remove),
|
||||
.driver = {
|
||||
.name = "orion-mdio",
|
||||
.of_match_table = orion_mdio_match,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(orion_mdio_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Marvell MDIO interface driver");
|
||||
MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
|
||||
MODULE_LICENSE("GPL");
|
2848
drivers/net/ethernet/marvell/mvneta.c
Normal file
2848
drivers/net/ethernet/marvell/mvneta.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user