Skip to content

Commit 22d4df8

Browse files
KAZUMIZUdavem330
authored andcommitted
ravb: Add support for r8a7795 SoC
This patch supports the r8a7795 SoC by: - Using two interrupts + One for E-MAC + One for everything else + Both can be handled by the existing common interrupt handler, which affords a simpler update to support the new SoC. In future some consideration may be given to implementing multiple interrupt handlers - Limiting the phy speed to 100Mbit/s for the new SoC; at this time it is not clear how this restriction may be lifted but I hope it will be possible as more information comes to light Signed-off-by: Kazuya Mizuguchi <[email protected]> [horms: reworked] Signed-off-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 619f3bd commit 22d4df8

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

drivers/net/ethernet/renesas/ravb.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,11 @@ struct ravb_ptp {
766766
struct ravb_ptp_perout perout[N_PER_OUT];
767767
};
768768

769+
enum ravb_chip_id {
770+
RCAR_GEN2,
771+
RCAR_GEN3,
772+
};
773+
769774
struct ravb_private {
770775
struct net_device *ndev;
771776
struct platform_device *pdev;
@@ -806,6 +811,8 @@ struct ravb_private {
806811
int msg_enable;
807812
int speed;
808813
int duplex;
814+
int emac_irq;
815+
enum ravb_chip_id chip_id;
809816

810817
unsigned no_avb_link:1;
811818
unsigned avb_link_active_low:1;

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,22 @@ static int ravb_phy_init(struct net_device *ndev)
889889
return -ENOENT;
890890
}
891891

892+
/* This driver only support 10/100Mbit speeds on Gen3
893+
* at this time.
894+
*/
895+
if (priv->chip_id == RCAR_GEN3) {
896+
int err;
897+
898+
err = phy_set_max_speed(phydev, SPEED_100);
899+
if (err) {
900+
netdev_err(ndev, "failed to limit PHY to 100Mbit/s\n");
901+
phy_disconnect(phydev);
902+
return err;
903+
}
904+
905+
netdev_info(ndev, "limited PHY to 100Mbit/s\n");
906+
}
907+
892908
netdev_info(ndev, "attached PHY %d (IRQ %d) to driver %s\n",
893909
phydev->addr, phydev->irq, phydev->drv->name);
894910

@@ -1197,6 +1213,15 @@ static int ravb_open(struct net_device *ndev)
11971213
goto out_napi_off;
11981214
}
11991215

1216+
if (priv->chip_id == RCAR_GEN3) {
1217+
error = request_irq(priv->emac_irq, ravb_interrupt,
1218+
IRQF_SHARED, ndev->name, ndev);
1219+
if (error) {
1220+
netdev_err(ndev, "cannot request IRQ\n");
1221+
goto out_free_irq;
1222+
}
1223+
}
1224+
12001225
/* Device init */
12011226
error = ravb_dmac_init(ndev);
12021227
if (error)
@@ -1220,6 +1245,7 @@ static int ravb_open(struct net_device *ndev)
12201245
ravb_ptp_stop(ndev);
12211246
out_free_irq:
12221247
free_irq(ndev->irq, ndev);
1248+
free_irq(priv->emac_irq, ndev);
12231249
out_napi_off:
12241250
napi_disable(&priv->napi[RAVB_NC]);
12251251
napi_disable(&priv->napi[RAVB_BE]);
@@ -1625,10 +1651,20 @@ static int ravb_mdio_release(struct ravb_private *priv)
16251651
return 0;
16261652
}
16271653

1654+
static const struct of_device_id ravb_match_table[] = {
1655+
{ .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 },
1656+
{ .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 },
1657+
{ .compatible = "renesas,etheravb-r8a7795", .data = (void *)RCAR_GEN3 },
1658+
{ }
1659+
};
1660+
MODULE_DEVICE_TABLE(of, ravb_match_table);
1661+
16281662
static int ravb_probe(struct platform_device *pdev)
16291663
{
16301664
struct device_node *np = pdev->dev.of_node;
1665+
const struct of_device_id *match;
16311666
struct ravb_private *priv;
1667+
enum ravb_chip_id chip_id;
16321668
struct net_device *ndev;
16331669
int error, irq, q;
16341670
struct resource *res;
@@ -1657,7 +1693,14 @@ static int ravb_probe(struct platform_device *pdev)
16571693
/* The Ether-specific entries in the device structure. */
16581694
ndev->base_addr = res->start;
16591695
ndev->dma = -1;
1660-
irq = platform_get_irq(pdev, 0);
1696+
1697+
match = of_match_device(of_match_ptr(ravb_match_table), &pdev->dev);
1698+
chip_id = (enum ravb_chip_id)match->data;
1699+
1700+
if (chip_id == RCAR_GEN3)
1701+
irq = platform_get_irq_byname(pdev, "ch22");
1702+
else
1703+
irq = platform_get_irq(pdev, 0);
16611704
if (irq < 0) {
16621705
error = irq;
16631706
goto out_release;
@@ -1688,6 +1731,17 @@ static int ravb_probe(struct platform_device *pdev)
16881731
priv->avb_link_active_low =
16891732
of_property_read_bool(np, "renesas,ether-link-active-low");
16901733

1734+
if (chip_id == RCAR_GEN3) {
1735+
irq = platform_get_irq_byname(pdev, "ch24");
1736+
if (irq < 0) {
1737+
error = irq;
1738+
goto out_release;
1739+
}
1740+
priv->emac_irq = irq;
1741+
}
1742+
1743+
priv->chip_id = chip_id;
1744+
16911745
/* Set function */
16921746
ndev->netdev_ops = &ravb_netdev_ops;
16931747
ndev->ethtool_ops = &ravb_ethtool_ops;
@@ -1818,13 +1872,6 @@ static const struct dev_pm_ops ravb_dev_pm_ops = {
18181872
#define RAVB_PM_OPS NULL
18191873
#endif
18201874

1821-
static const struct of_device_id ravb_match_table[] = {
1822-
{ .compatible = "renesas,etheravb-r8a7790" },
1823-
{ .compatible = "renesas,etheravb-r8a7794" },
1824-
{ }
1825-
};
1826-
MODULE_DEVICE_TABLE(of, ravb_match_table);
1827-
18281875
static struct platform_driver ravb_driver = {
18291876
.probe = ravb_probe,
18301877
.remove = ravb_remove,

0 commit comments

Comments
 (0)