summaryrefslogtreecommitdiffstats
path: root/target/linux/mcs814x/files-3.3/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/mcs814x/files-3.3/drivers')
-rw-r--r--target/linux/mcs814x/files-3.3/drivers/char/hw_random/mcs814x-rng.c9
-rw-r--r--target/linux/mcs814x/files-3.3/drivers/net/ethernet/mcs8140/nuport_mac.c40
2 files changed, 30 insertions, 19 deletions
diff --git a/target/linux/mcs814x/files-3.3/drivers/char/hw_random/mcs814x-rng.c b/target/linux/mcs814x/files-3.3/drivers/char/hw_random/mcs814x-rng.c
index b1e95810d..5e3d8f247 100644
--- a/target/linux/mcs814x/files-3.3/drivers/char/hw_random/mcs814x-rng.c
+++ b/target/linux/mcs814x/files-3.3/drivers/char/hw_random/mcs814x-rng.c
@@ -61,14 +61,7 @@ static int mcs814x_rng_probe(struct platform_device *pdev)
rng->name = pdev->name;
rng->data_read = mcs814x_rng_data_read;
- if (!devm_request_mem_region(&pdev->dev,
- res->start, resource_size(res),
- pdev->name)) {
- ret = -EBUSY;
- goto out_rng;
- }
-
- priv->regs = devm_ioremap(&pdev->dev, res->start, resource_size(res));
+ priv->regs = devm_request_and_ioremap(&pdev->dev, res);
if (!priv->regs) {
ret = -ENOMEM;
goto out_rng;
diff --git a/target/linux/mcs814x/files-3.3/drivers/net/ethernet/mcs8140/nuport_mac.c b/target/linux/mcs814x/files-3.3/drivers/net/ethernet/mcs8140/nuport_mac.c
index d874e71a1..f11f425a0 100644
--- a/target/linux/mcs814x/files-3.3/drivers/net/ethernet/mcs8140/nuport_mac.c
+++ b/target/linux/mcs814x/files-3.3/drivers/net/ethernet/mcs8140/nuport_mac.c
@@ -19,6 +19,8 @@
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/of.h>
+#include <linux/of_mdio.h>
+#include <linux/of_net.h>
#include <linux/irq.h>
#include <linux/err.h>
#include <linux/phy.h>
@@ -117,7 +119,7 @@ static inline u32 nuport_mac_readl(void __iomem *reg)
static inline u8 nuport_mac_readb(void __iomem *reg)
{
- return __raw_readb(reg);
+ return readb_relaxed(reg);
}
static inline void nuport_mac_writel(u32 value, void __iomem *reg)
@@ -168,6 +170,8 @@ struct nuport_mac_priv {
struct platform_device *pdev;
struct mii_bus *mii_bus;
struct phy_device *phydev;
+ struct device_node *phy_node;
+ phy_interface_t phy_interface;
int old_link;
int old_duplex;
u32 msg_level;
@@ -396,7 +400,7 @@ static void nuport_mac_adjust_link(struct net_device *dev)
priv->old_link = phydev->link;
}
- if (phydev->link & (priv->old_duplex != phydev->duplex)) {
+ if (phydev->link && (priv->old_duplex != phydev->duplex)) {
reg = nuport_mac_readl(CTRL_REG);
if (phydev->duplex == DUPLEX_FULL)
reg |= DUPLEX_FULL;
@@ -564,7 +568,6 @@ static int nuport_mac_rx(struct net_device *dev, int limit)
/* Get packet status */
status = get_unaligned((u32 *) (skb->data + len));
- skb->dev = dev;
dma_unmap_single(&priv->pdev->dev, priv->rx_addr, skb->len,
DMA_FROM_DEVICE);
@@ -615,6 +618,9 @@ static int nuport_mac_rx(struct net_device *dev, int limit)
exit:
skb = netdev_alloc_skb(dev, RX_ALLOC_SIZE);
+ if (!skb)
+ goto out;
+
skb_reserve(skb, RX_SKB_HEADROOM);
priv->rx_skb[priv->cur_rx] = skb;
priv->irq_rxskb[priv->cur_rx] = 1;
@@ -624,7 +630,7 @@ exit:
priv->cur_rx = 0;
count++;
}
-
+out:
return count;
}
@@ -896,9 +902,9 @@ static int nuport_mac_mii_probe(struct net_device *dev)
goto out;
}
- phydev = phy_connect(dev, dev_name(&phydev->dev),
+ phydev = of_phy_connect(dev, priv->phy_node,
nuport_mac_adjust_link, 0,
- PHY_INTERFACE_MODE_MII);
+ priv->phy_interface);
if (IS_ERR(phydev)) {
netdev_err(dev, "could not attach PHY\n");
ret = PTR_ERR(phydev);
@@ -1038,16 +1044,14 @@ static int __init nuport_mac_probe(struct platform_device *pdev)
else
priv->buffer_shifting_len = 2;
- priv->mac_base = devm_ioremap(&pdev->dev,
- regs->start, resource_size(regs));
+ priv->mac_base = devm_request_and_ioremap(&pdev->dev, regs);
if (!priv->mac_base) {
dev_err(&pdev->dev, "failed to remap regs\n");
ret = -ENOMEM;
goto out_platform;
}
- priv->dma_base = devm_ioremap(&pdev->dev,
- dma->start, resource_size(dma));
+ priv->dma_base = devm_request_and_ioremap(&pdev->dev, dma);
if (!priv->dma_base) {
dev_err(&pdev->dev, "failed to remap dma-regs\n");
ret = -ENOMEM;
@@ -1080,6 +1084,20 @@ static int __init nuport_mac_probe(struct platform_device *pdev)
netif_napi_add(dev, &priv->napi, nuport_mac_poll, 64);
+ priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy", 0);
+ if (!priv->phy_node) {
+ dev_err(&pdev->dev, "no associated PHY\n");
+ ret = -ENODEV;
+ goto out;
+ }
+
+ priv->phy_interface = of_get_phy_mode(pdev->dev.of_node);
+ if (priv->phy_interface < 0) {
+ dev_err(&pdev->dev, "invalid PHY mode\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
priv->mii_bus = mdiobus_alloc();
if (!priv->mii_bus) {
dev_err(&pdev->dev, "mii bus allocation failed\n");
@@ -1104,7 +1122,7 @@ static int __init nuport_mac_probe(struct platform_device *pdev)
for (i = 0; i < PHY_MAX_ADDR; i++)
priv->mii_bus->irq[i] = PHY_IGNORE_INTERRUPT;
- ret = mdiobus_register(priv->mii_bus);
+ ret = of_mdiobus_register(priv->mii_bus, pdev->dev.of_node);
if (ret) {
dev_err(&pdev->dev, "failed to register mii_bus\n");
goto out_mdio_irq;