Commit f5d7837f authored by Kazuya Mizuguchi's avatar Kazuya Mizuguchi Committed by David S. Miller

ravb: ptp: Add CONFIG mode support

This patch makes PTP support active in CONFIG mode on R-Car Gen3.
Signed-off-by: default avatarKazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Signed-off-by: default avatarYoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 03b01cf5
......@@ -206,6 +206,7 @@ enum CCC_BIT {
CCC_OPC_RESET = 0x00000000,
CCC_OPC_CONFIG = 0x00000001,
CCC_OPC_OPERATION = 0x00000002,
CCC_GAC = 0x00000080,
CCC_DTSR = 0x00000100,
CCC_CSEL = 0x00030000,
CCC_CSEL_HPB = 0x00010000,
......
......@@ -1231,6 +1231,7 @@ static int ravb_open(struct net_device *ndev)
ravb_emac_init(ndev);
/* Initialise PTP Clock driver */
if (priv->chip_id == RCAR_GEN2)
ravb_ptp_init(ndev, priv->pdev);
netif_tx_start_all_queues(ndev);
......@@ -1244,6 +1245,7 @@ static int ravb_open(struct net_device *ndev)
out_ptp_stop:
/* Stop PTP Clock driver */
if (priv->chip_id == RCAR_GEN2)
ravb_ptp_stop(ndev);
out_free_irq:
free_irq(ndev->irq, ndev);
......@@ -1476,6 +1478,7 @@ static int ravb_close(struct net_device *ndev)
ravb_write(ndev, 0, TIC);
/* Stop PTP Clock driver */
if (priv->chip_id == RCAR_GEN2)
ravb_ptp_stop(ndev);
/* Set the config mode to stop the AVB-DMAC's processes */
......@@ -1781,8 +1784,16 @@ static int ravb_probe(struct platform_device *pdev)
ndev->ethtool_ops = &ravb_ethtool_ops;
/* Set AVB config mode */
ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_OPC) | CCC_OPC_CONFIG,
CCC);
if (chip_id == RCAR_GEN2) {
ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_OPC) |
CCC_OPC_CONFIG, CCC);
/* Set CSEL value */
ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_CSEL) |
CCC_CSEL_HPB, CCC);
} else {
ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_OPC) |
CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB, CCC);
}
/* Set CSEL value */
ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_CSEL) | CCC_CSEL_HPB,
......@@ -1814,6 +1825,10 @@ static int ravb_probe(struct platform_device *pdev)
/* Initialise HW timestamp list */
INIT_LIST_HEAD(&priv->ts_skb_list);
/* Initialise PTP Clock driver */
if (chip_id != RCAR_GEN2)
ravb_ptp_init(ndev, pdev);
/* Debug message level */
priv->msg_enable = RAVB_DEF_MSG_ENABLE;
......@@ -1855,6 +1870,10 @@ static int ravb_probe(struct platform_device *pdev)
out_dma_free:
dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
priv->desc_bat_dma);
/* Stop PTP Clock driver */
if (chip_id != RCAR_GEN2)
ravb_ptp_stop(ndev);
out_release:
if (ndev)
free_netdev(ndev);
......@@ -1869,6 +1888,10 @@ static int ravb_remove(struct platform_device *pdev)
struct net_device *ndev = platform_get_drvdata(pdev);
struct ravb_private *priv = netdev_priv(ndev);
/* Stop PTP Clock driver */
if (priv->chip_id != RCAR_GEN2)
ravb_ptp_stop(ndev);
dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
priv->desc_bat_dma);
/* Set reset mode */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment