@@ -1403,6 +1403,7 @@ static int ravb_get_ts_info(struct net_device *ndev,
14031403 struct ethtool_ts_info * info )
14041404{
14051405 struct ravb_private * priv = netdev_priv (ndev );
1406+ const struct ravb_hw_info * hw_info = priv -> info ;
14061407
14071408 info -> so_timestamping =
14081409 SOF_TIMESTAMPING_TX_SOFTWARE |
@@ -1416,7 +1417,8 @@ static int ravb_get_ts_info(struct net_device *ndev,
14161417 (1 << HWTSTAMP_FILTER_NONE ) |
14171418 (1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT ) |
14181419 (1 << HWTSTAMP_FILTER_ALL );
1419- info -> phc_index = ptp_clock_index (priv -> ptp .clock );
1420+ if (hw_info -> gptp || hw_info -> ccc_gac )
1421+ info -> phc_index = ptp_clock_index (priv -> ptp .clock );
14201422
14211423 return 0 ;
14221424}
@@ -1640,6 +1642,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)
16401642static netdev_tx_t ravb_start_xmit (struct sk_buff * skb , struct net_device * ndev )
16411643{
16421644 struct ravb_private * priv = netdev_priv (ndev );
1645+ const struct ravb_hw_info * info = priv -> info ;
16431646 unsigned int num_tx_desc = priv -> num_tx_desc ;
16441647 u16 q = skb_get_queue_mapping (skb );
16451648 struct ravb_tstamp_skb * ts_skb ;
@@ -1716,28 +1719,30 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
17161719 desc -> dptr = cpu_to_le32 (dma_addr );
17171720
17181721 /* TX timestamp required */
1719- if (q == RAVB_NC ) {
1720- ts_skb = kmalloc (sizeof (* ts_skb ), GFP_ATOMIC );
1721- if (!ts_skb ) {
1722- if (num_tx_desc > 1 ) {
1723- desc -- ;
1724- dma_unmap_single (ndev -> dev .parent , dma_addr ,
1725- len , DMA_TO_DEVICE );
1722+ if (info -> gptp || info -> ccc_gac ) {
1723+ if (q == RAVB_NC ) {
1724+ ts_skb = kmalloc (sizeof (* ts_skb ), GFP_ATOMIC );
1725+ if (!ts_skb ) {
1726+ if (num_tx_desc > 1 ) {
1727+ desc -- ;
1728+ dma_unmap_single (ndev -> dev .parent , dma_addr ,
1729+ len , DMA_TO_DEVICE );
1730+ }
1731+ goto unmap ;
17261732 }
1727- goto unmap ;
1733+ ts_skb -> skb = skb_get (skb );
1734+ ts_skb -> tag = priv -> ts_skb_tag ++ ;
1735+ priv -> ts_skb_tag &= 0x3ff ;
1736+ list_add_tail (& ts_skb -> list , & priv -> ts_skb_list );
1737+
1738+ /* TAG and timestamp required flag */
1739+ skb_shinfo (skb )-> tx_flags |= SKBTX_IN_PROGRESS ;
1740+ desc -> tagh_tsr = (ts_skb -> tag >> 4 ) | TX_TSR ;
1741+ desc -> ds_tagl |= cpu_to_le16 (ts_skb -> tag << 12 );
17281742 }
1729- ts_skb -> skb = skb_get (skb );
1730- ts_skb -> tag = priv -> ts_skb_tag ++ ;
1731- priv -> ts_skb_tag &= 0x3ff ;
1732- list_add_tail (& ts_skb -> list , & priv -> ts_skb_list );
17331743
1734- /* TAG and timestamp required flag */
1735- skb_shinfo (skb )-> tx_flags |= SKBTX_IN_PROGRESS ;
1736- desc -> tagh_tsr = (ts_skb -> tag >> 4 ) | TX_TSR ;
1737- desc -> ds_tagl |= cpu_to_le16 (ts_skb -> tag << 12 );
1744+ skb_tx_timestamp (skb );
17381745 }
1739-
1740- skb_tx_timestamp (skb );
17411746 /* Descriptor type must be set after all the above writes */
17421747 dma_wmb ();
17431748 if (num_tx_desc > 1 ) {
@@ -1858,10 +1863,12 @@ static int ravb_close(struct net_device *ndev)
18581863 "device will be stopped after h/w processes are done.\n" );
18591864
18601865 /* Clear the timestamp list */
1861- list_for_each_entry_safe (ts_skb , ts_skb2 , & priv -> ts_skb_list , list ) {
1862- list_del (& ts_skb -> list );
1863- kfree_skb (ts_skb -> skb );
1864- kfree (ts_skb );
1866+ if (info -> gptp || info -> ccc_gac ) {
1867+ list_for_each_entry_safe (ts_skb , ts_skb2 , & priv -> ts_skb_list , list ) {
1868+ list_del (& ts_skb -> list );
1869+ kfree_skb (ts_skb -> skb );
1870+ kfree (ts_skb );
1871+ }
18651872 }
18661873
18671874 /* PHY disconnect */
@@ -2207,9 +2214,11 @@ static void ravb_set_config_mode(struct net_device *ndev)
22072214 ravb_modify (ndev , CCC , CCC_OPC , CCC_OPC_CONFIG );
22082215 /* Set CSEL value */
22092216 ravb_modify (ndev , CCC , CCC_CSEL , CCC_CSEL_HPB );
2210- } else {
2217+ } else if ( info -> ccc_gac ) {
22112218 ravb_modify (ndev , CCC , CCC_OPC , CCC_OPC_CONFIG |
22122219 CCC_GAC | CCC_CSEL_HPB );
2220+ } else {
2221+ ravb_modify (ndev , CCC , CCC_OPC , CCC_OPC_CONFIG );
22132222 }
22142223}
22152224
@@ -2395,13 +2404,15 @@ static int ravb_probe(struct platform_device *pdev)
23952404 /* Set AVB config mode */
23962405 ravb_set_config_mode (ndev );
23972406
2398- /* Set GTI value */
2399- error = ravb_set_gti (ndev );
2400- if (error )
2401- goto out_disable_refclk ;
2407+ if (info -> gptp || info -> ccc_gac ) {
2408+ /* Set GTI value */
2409+ error = ravb_set_gti (ndev );
2410+ if (error )
2411+ goto out_disable_refclk ;
24022412
2403- /* Request GTI loading */
2404- ravb_modify (ndev , GCCR , GCCR_LTI , GCCR_LTI );
2413+ /* Request GTI loading */
2414+ ravb_modify (ndev , GCCR , GCCR_LTI , GCCR_LTI );
2415+ }
24052416
24062417 if (info -> internal_delay ) {
24072418 ravb_parse_delay_mode (np , ndev );
@@ -2602,13 +2613,15 @@ static int __maybe_unused ravb_resume(struct device *dev)
26022613 /* Set AVB config mode */
26032614 ravb_set_config_mode (ndev );
26042615
2605- /* Set GTI value */
2606- ret = ravb_set_gti (ndev );
2607- if (ret )
2608- return ret ;
2616+ if (info -> gptp || info -> ccc_gac ) {
2617+ /* Set GTI value */
2618+ ret = ravb_set_gti (ndev );
2619+ if (ret )
2620+ return ret ;
26092621
2610- /* Request GTI loading */
2611- ravb_modify (ndev , GCCR , GCCR_LTI , GCCR_LTI );
2622+ /* Request GTI loading */
2623+ ravb_modify (ndev , GCCR , GCCR_LTI , GCCR_LTI );
2624+ }
26122625
26132626 if (info -> internal_delay )
26142627 ravb_set_delay_mode (ndev );
0 commit comments