Post by Bassam AlsanieIs there any code example shows how to write PHC custom clock?
See Documentation/ptp/ptp.txt in the Linux source tree.
There are plenty of examples in the kernel. From the README.org:
|------------+--------------------------+---------|
| Driver | Hardware | Version |
|------------+--------------------------+---------|
| amd-xgbe | AMD 10GbE Ethernet Soc | 3.17 |
| bfin_mac | Analog Blackfin | 3.8 |
| bnx2x | Broadcom NetXtremeII 10G | 3.18 |
| cpts | Texas Instruments am335x | 3.8 |
| e1000e | Intel 82574, 82583 | 3.9 |
| fm10k | Intel FM10000 | 3.18 |
| fec | Freescale i.mx6 | 3.8 |
| gianfar | Freescale eTSEC PowerPC | 3.0 |
| i40e | Intel XL710 Family | 3.14 |
| igb | Intel 82576, 82580 | 3.5 |
| ixgbe | Intel 82599 | 3.5 |
| mlx4 | Mellanox 40G PCI | 3.14 |
| ptp_ixp46x | Intel IXP465 | 3.0 |
| ptp_phc | Lapis EG20T PCH | 3.5 |
| sfc | Solarflare SFC9000 | 3.7 |
| stmmac | STM Synopsys IP Core | 3.10 |
| tg3 | Broadcom Tigon3 PCI | 3.8 |
| tilegx | Tilera GBE/XGBE | 3.12 |
|------------+--------------------------+---------|
Or try grep:
$ grep -r ptp_clock_register drivers/net/ethernet/
drivers/net/ethernet/mellanox/mlx4/en_clock.c: mdev->ptp_clock = ptp_clock_register(&mdev->ptp_clock_info,
drivers/net/ethernet/mellanox/mlx4/en_clock.c: mlx4_err(mdev, "ptp_clock_register failed\n");
drivers/net/ethernet/tile/tilegx.c: md->ptp_clock = ptp_clock_register(&md->caps, NULL);
drivers/net/ethernet/tile/tilegx.c: netdev_err(dev, "ptp_clock_register failed %ld\n",
drivers/net/ethernet/cavium/liquidio/lio_main.c: lio->ptp_clock = ptp_clock_register(&lio->ptp_info,
drivers/net/ethernet/ti/cpts.c: cpts->clock = ptp_clock_register(&cpts->info, dev);
drivers/net/ethernet/sfc/ptp.c: ptp->phc_clock = ptp_clock_register(&ptp->phc_clock_info,
drivers/net/ethernet/broadcom/tg3.c: tp->ptp_clock = ptp_clock_register(&tp->ptp_info,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c: bp->ptp_clock = ptp_clock_register(&bp->ptp_clock_info, &bp->pdev->dev);
drivers/net/ethernet/freescale/fec_ptp.c: fep->ptp_clock = ptp_clock_register(&fep->ptp_caps, &pdev->dev);
drivers/net/ethernet/freescale/fec_ptp.c: pr_err("ptp_clock_register failed\n");
drivers/net/ethernet/freescale/gianfar_ptp.c: etsects->clock = ptp_clock_register(&etsects->caps, &dev->dev);
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c: clock = ptp_clock_register(info, pdata->dev);
drivers/net/ethernet/amd/xgbe/xgbe-ptp.c: dev_err(pdata->dev, "ptp_clock_register failed\n");
drivers/net/ethernet/intel/igb/igb_ptp.c: adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
drivers/net/ethernet/intel/igb/igb_ptp.c: dev_err(&adapter->pdev->dev, "ptp_clock_register failed\n");
drivers/net/ethernet/intel/i40e/i40e_ptp.c: pf->ptp_clock = ptp_clock_register(&pf->ptp_caps, &pf->pdev->dev);
drivers/net/ethernet/intel/i40e/i40e_ptp.c: dev_err(&pf->pdev->dev, "%s: ptp_clock_register failed\n",
drivers/net/ethernet/intel/fm10k/fm10k_ptp.c: ptp_clock = ptp_clock_register(ptp_caps, dev);
drivers/net/ethernet/intel/fm10k/fm10k_ptp.c: dev_err(dev, "ptp_clock_register failed\n");
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c: adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c: e_dev_err("ptp_clock_register failed\n");
drivers/net/ethernet/intel/e1000e/ptp.c: adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info,
drivers/net/ethernet/intel/e1000e/ptp.c: e_err("ptp_clock_register failed\n");
drivers/net/ethernet/adi/bfin_mac.c: lp->clock = ptp_clock_register(&lp->caps, dev);
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c: priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops,
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c: pr_err("ptp_clock_register() failed on %s\n", priv->dev->name);
drivers/net/ethernet/renesas/ravb_ptp.c: priv->ptp.clock = ptp_clock_register(&priv->ptp.info, &pdev->dev);
HTH,
Richard
------------------------------------------------------------------------------