RE: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Rafal Ozieblo
>-Original Message-
>From: Nicolas Ferre [mailto:nicolas.fe...@atmel.com] 
>Sent: 27 stycznia 2017 11:28
>Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support for 
>MACB/GEM
>
>Le 27/01/2017 à 11:26, Rafal Ozieblo a écrit :
>>> -Original Message-
>>> From: Harini Katakam [mailto:harinikatakamli...@gmail.com] 
>>> Sent: 27 stycznia 2017 06:43
>>> Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support 
>>> for MACB/GEM
>>>
>>> Hi Rafal,
>>>
>>> On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo <raf...@cadence.com> wrote:
>>>>> -Original Message-----
>>>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>>>> Sent: 19 stycznia 2017 16:56
>>>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>>>> MACB/GEM
>>>>>
>>>>>
>>>>> +static inline bool gem_has_ptp(struct macb *bp)
>>>>> +{
>>>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>>>> +}
>>>> Why don't you use hardware capabilities here? Would it be better to read 
>>>> it from hardware instead adding it to many configuration?
>>>
>>> If you are referring to TSU bit in DCFG5, then we will be relying on
>>> Cadence IP's information irrespective of the SoC capability
>>> and whether the PTP support was adequate.
>>> I think the capability approach gives better control and
>>> it is not really much to add.
>>>
>>> Regards,
>>> Harini
>>>
>> Yes, I'm referring to TSU bit.
>> What if SoC contains multiple Cadence GEMs, some with PTP support and others 
>> without?
>
>Simply define different DT compatibility strings and we're good.

What with GEM on PCI ? There is no DT.

>> Relevant will be checking both, hardware capabilities and SoC capabilities 
>> from "caps" field.
>> 
>
>
>-- 
>Nicolas Ferre
>


RE: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Rafal Ozieblo
>-Original Message-
>From: Nicolas Ferre [mailto:nicolas.fe...@atmel.com] 
>Sent: 27 stycznia 2017 11:28
>Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support for 
>MACB/GEM
>
>Le 27/01/2017 à 11:26, Rafal Ozieblo a écrit :
>>> -Original Message-
>>> From: Harini Katakam [mailto:harinikatakamli...@gmail.com] 
>>> Sent: 27 stycznia 2017 06:43
>>> Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support 
>>> for MACB/GEM
>>>
>>> Hi Rafal,
>>>
>>> On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo  wrote:
>>>>> -Original Message-
>>>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>>>> Sent: 19 stycznia 2017 16:56
>>>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>>>> MACB/GEM
>>>>>
>>>>>
>>>>> +static inline bool gem_has_ptp(struct macb *bp)
>>>>> +{
>>>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>>>> +}
>>>> Why don't you use hardware capabilities here? Would it be better to read 
>>>> it from hardware instead adding it to many configuration?
>>>
>>> If you are referring to TSU bit in DCFG5, then we will be relying on
>>> Cadence IP's information irrespective of the SoC capability
>>> and whether the PTP support was adequate.
>>> I think the capability approach gives better control and
>>> it is not really much to add.
>>>
>>> Regards,
>>> Harini
>>>
>> Yes, I'm referring to TSU bit.
>> What if SoC contains multiple Cadence GEMs, some with PTP support and others 
>> without?
>
>Simply define different DT compatibility strings and we're good.

What with GEM on PCI ? There is no DT.

>> Relevant will be checking both, hardware capabilities and SoC capabilities 
>> from "caps" field.
>> 
>
>
>-- 
>Nicolas Ferre
>


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Nicolas Ferre
Le 27/01/2017 à 11:26, Rafal Ozieblo a écrit :
>> -Original Message-
>> From: Harini Katakam [mailto:harinikatakamli...@gmail.com] 
>> Sent: 27 stycznia 2017 06:43
>> Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support for 
>> MACB/GEM
>>
>> Hi Rafal,
>>
>> On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo <raf...@cadence.com> wrote:
>>>> -Original Message-
>>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>>> Sent: 19 stycznia 2017 16:56
>>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>>> MACB/GEM
>>>>
>>>>
>>>> +static inline bool gem_has_ptp(struct macb *bp)
>>>> +{
>>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>>> +}
>>> Why don't you use hardware capabilities here? Would it be better to read it 
>>> from hardware instead adding it to many configuration?
>>
>> If you are referring to TSU bit in DCFG5, then we will be relying on
>> Cadence IP's information irrespective of the SoC capability
>> and whether the PTP support was adequate.
>> I think the capability approach gives better control and
>> it is not really much to add.
>>
>> Regards,
>> Harini
>>
> Yes, I'm referring to TSU bit.
> What if SoC contains multiple Cadence GEMs, some with PTP support and others 
> without?

Simply define different DT compatibility strings and we're good.

> Relevant will be checking both, hardware capabilities and SoC capabilities 
> from "caps" field.
> 


-- 
Nicolas Ferre


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Nicolas Ferre
Le 27/01/2017 à 11:26, Rafal Ozieblo a écrit :
>> -Original Message-
>> From: Harini Katakam [mailto:harinikatakamli...@gmail.com] 
>> Sent: 27 stycznia 2017 06:43
>> Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support for 
>> MACB/GEM
>>
>> Hi Rafal,
>>
>> On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo  wrote:
>>>> -Original Message-
>>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>>> Sent: 19 stycznia 2017 16:56
>>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>>> MACB/GEM
>>>>
>>>>
>>>> +static inline bool gem_has_ptp(struct macb *bp)
>>>> +{
>>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>>> +}
>>> Why don't you use hardware capabilities here? Would it be better to read it 
>>> from hardware instead adding it to many configuration?
>>
>> If you are referring to TSU bit in DCFG5, then we will be relying on
>> Cadence IP's information irrespective of the SoC capability
>> and whether the PTP support was adequate.
>> I think the capability approach gives better control and
>> it is not really much to add.
>>
>> Regards,
>> Harini
>>
> Yes, I'm referring to TSU bit.
> What if SoC contains multiple Cadence GEMs, some with PTP support and others 
> without?

Simply define different DT compatibility strings and we're good.

> Relevant will be checking both, hardware capabilities and SoC capabilities 
> from "caps" field.
> 


-- 
Nicolas Ferre


RE: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Rafal Ozieblo
>-Original Message-
>From: Harini Katakam [mailto:harinikatakamli...@gmail.com] 
>Sent: 27 stycznia 2017 06:43
>Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support for 
>MACB/GEM
>
>Hi Rafal,
>
>On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo <raf...@cadence.com> wrote:
>>> -Original Message-
>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>> Sent: 19 stycznia 2017 16:56
>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>> MACB/GEM
>>>
>>>
>>> +static inline bool gem_has_ptp(struct macb *bp)
>>> +{
>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>> +}
>> Why don't you use hardware capabilities here? Would it be better to read it 
>> from hardware instead adding it to many configuration?
>
>If you are referring to TSU bit in DCFG5, then we will be relying on
>Cadence IP's information irrespective of the SoC capability
>and whether the PTP support was adequate.
>I think the capability approach gives better control and
>it is not really much to add.
>
>Regards,
>Harini
>
Yes, I'm referring to TSU bit.
What if SoC contains multiple Cadence GEMs, some with PTP support and others 
without?
Relevant will be checking both, hardware capabilities and SoC capabilities from 
"caps" field.


RE: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Rafal Ozieblo
>-Original Message-
>From: Harini Katakam [mailto:harinikatakamli...@gmail.com] 
>Sent: 27 stycznia 2017 06:43
>Subject: Re: [PATCH net-next v2] macb: Common code to enable ptp support for 
>MACB/GEM
>
>Hi Rafal,
>
>On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo  wrote:
>>> -Original Message-
>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>> Sent: 19 stycznia 2017 16:56
>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>> MACB/GEM
>>>
>>>
>>> +static inline bool gem_has_ptp(struct macb *bp)
>>> +{
>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>> +}
>> Why don't you use hardware capabilities here? Would it be better to read it 
>> from hardware instead adding it to many configuration?
>
>If you are referring to TSU bit in DCFG5, then we will be relying on
>Cadence IP's information irrespective of the SoC capability
>and whether the PTP support was adequate.
>I think the capability approach gives better control and
>it is not really much to add.
>
>Regards,
>Harini
>
Yes, I'm referring to TSU bit.
What if SoC contains multiple Cadence GEMs, some with PTP support and others 
without?
Relevant will be checking both, hardware capabilities and SoC capabilities from 
"caps" field.


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Nicolas Ferre
Le 27/01/2017 à 06:42, Harini Katakam a écrit :
> Hi Rafal,
> 
> On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo <raf...@cadence.com> wrote:
>>> -Original Message-
>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>> Sent: 19 stycznia 2017 16:56
>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>> MACB/GEM
>>>
>>>
>>> +static inline bool gem_has_ptp(struct macb *bp)
>>> +{
>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>> +}
>> Why don't you use hardware capabilities here? Would it be better to read it 
>> from hardware instead adding it to many configuration?
> 
> If you are referring to TSU bit in DCFG5, then we will be relying on
> Cadence IP's information irrespective of the SoC capability
> and whether the PTP support was adequate.
> I think the capability approach gives better control and
> it is not really much to add.

Yes, absolutely. In fact we already had this discussion and decided that
this capability scheme was giving much more control at low cost.

Regards,
-- 
Nicolas Ferre


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-27 Thread Nicolas Ferre
Le 27/01/2017 à 06:42, Harini Katakam a écrit :
> Hi Rafal,
> 
> On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo  wrote:
>>> -Original Message-
>>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>>> Sent: 19 stycznia 2017 16:56
>>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>>> MACB/GEM
>>>
>>>
>>> +static inline bool gem_has_ptp(struct macb *bp)
>>> +{
>>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>>> +}
>> Why don't you use hardware capabilities here? Would it be better to read it 
>> from hardware instead adding it to many configuration?
> 
> If you are referring to TSU bit in DCFG5, then we will be relying on
> Cadence IP's information irrespective of the SoC capability
> and whether the PTP support was adequate.
> I think the capability approach gives better control and
> it is not really much to add.

Yes, absolutely. In fact we already had this discussion and decided that
this capability scheme was giving much more control at low cost.

Regards,
-- 
Nicolas Ferre


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-26 Thread Harini Katakam
Hi Rafal,

On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo <raf...@cadence.com> wrote:
>> -Original Message-
>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>> Sent: 19 stycznia 2017 16:56
>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>> MACB/GEM
>>
>>
>> +static inline bool gem_has_ptp(struct macb *bp)
>> +{
>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>> +}
> Why don't you use hardware capabilities here? Would it be better to read it 
> from hardware instead adding it to many configuration?

If you are referring to TSU bit in DCFG5, then we will be relying on
Cadence IP's information irrespective of the SoC capability
and whether the PTP support was adequate.
I think the capability approach gives better control and
it is not really much to add.

Regards,
Harini


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-26 Thread Harini Katakam
Hi Rafal,

On Thu, Jan 26, 2017 at 8:45 PM, Rafal Ozieblo  wrote:
>> -Original Message-
>> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com]
>> Sent: 19 stycznia 2017 16:56
>> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
>> MACB/GEM
>>
>>
>> +static inline bool gem_has_ptp(struct macb *bp)
>> +{
>> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
>> +}
> Why don't you use hardware capabilities here? Would it be better to read it 
> from hardware instead adding it to many configuration?

If you are referring to TSU bit in DCFG5, then we will be relying on
Cadence IP's information irrespective of the SoC capability
and whether the PTP support was adequate.
I think the capability approach gives better control and
it is not really much to add.

Regards,
Harini


RE: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-26 Thread Rafal Ozieblo
> -Original Message-
> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com] 
> Sent: 19 stycznia 2017 16:56
> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
> MACB/GEM
> 
>  
> +static inline bool gem_has_ptp(struct macb *bp)
> +{
> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
> +}
Why don't you use hardware capabilities here? Would it be better to read it 
from hardware instead adding it to many configuration?



RE: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-26 Thread Rafal Ozieblo
> -Original Message-
> From: Andrei Pistirica [mailto:andrei.pistir...@microchip.com] 
> Sent: 19 stycznia 2017 16:56
> Subject: [PATCH net-next v2] macb: Common code to enable ptp support for 
> MACB/GEM
> 
>  
> +static inline bool gem_has_ptp(struct macb *bp)
> +{
> + return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP);
> +}
Why don't you use hardware capabilities here? Would it be better to read it 
from hardware instead adding it to many configuration?



Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-25 Thread Harini Katakam
On Wed, Jan 25, 2017 at 2:56 PM, Nicolas Ferre  wrote:
> Le 19/01/2017 à 17:07, Nicolas Ferre a écrit :
>> Le 19/01/2017 à 08:56, Andrei Pistirica a écrit :
>>> This patch does the following:
>>> - MACB/GEM-PTP interface
>>> - registers and bitfields for TSU
>>> - capability flags to enable PTP per platform basis
>>>
>>> Signed-off-by: Andrei Pistirica 
>>
>> Acked-by: Nicolas Ferre 

Reviewed-by: Harini Katakam 

>
> Harini or Rafal, do you plan to review this patch and add your
> "Reviewed-by" tags? It can be useful to make this support move forward.

Sure, reviewed and working with it, meant to add tag :)

Regards,
Harini


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-25 Thread Harini Katakam
On Wed, Jan 25, 2017 at 2:56 PM, Nicolas Ferre  wrote:
> Le 19/01/2017 à 17:07, Nicolas Ferre a écrit :
>> Le 19/01/2017 à 08:56, Andrei Pistirica a écrit :
>>> This patch does the following:
>>> - MACB/GEM-PTP interface
>>> - registers and bitfields for TSU
>>> - capability flags to enable PTP per platform basis
>>>
>>> Signed-off-by: Andrei Pistirica 
>>
>> Acked-by: Nicolas Ferre 

Reviewed-by: Harini Katakam 

>
> Harini or Rafal, do you plan to review this patch and add your
> "Reviewed-by" tags? It can be useful to make this support move forward.

Sure, reviewed and working with it, meant to add tag :)

Regards,
Harini


Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-25 Thread Nicolas Ferre
Le 19/01/2017 à 17:07, Nicolas Ferre a écrit :
> Le 19/01/2017 à 08:56, Andrei Pistirica a écrit :
>> This patch does the following:
>> - MACB/GEM-PTP interface
>> - registers and bitfields for TSU
>> - capability flags to enable PTP per platform basis
>>
>> Signed-off-by: Andrei Pistirica 
> 
> Acked-by: Nicolas Ferre 

Harini or Rafal, do you plan to review this patch and add your
"Reviewed-by" tags? It can be useful to make this support move forward.

Regards,

>> ---
>> Patch history:
>>
>> Version 1:
>> This is just the common code for MACB/GEM-PTP support.
>> Code is based on the comments related to the following patch series:
>> - [RFC PATCH net-next v1-to-4 1/2] macb: Add 1588 support in Cadence GEM
>> - [RFC PATCH net-next v1-to-4 2/2] macb: Enable 1588 support in SAMA5Dx 
>> platforms
>>
>> Version 2:
>> - Cosmetic changes and PTP capability flag changed doe to overlapping with 
>> JUMBO.
>>
>> Note: Patch on net-next: January 19.
>>
>>  drivers/net/ethernet/cadence/macb.c | 32 +++-
>>  drivers/net/ethernet/cadence/macb.h | 74 
>> +
>>  2 files changed, 104 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/cadence/macb.c 
>> b/drivers/net/ethernet/cadence/macb.c
>> index c0fb80a..ff1e648 100644
>> --- a/drivers/net/ethernet/cadence/macb.c
>> +++ b/drivers/net/ethernet/cadence/macb.c
>> @@ -2085,6 +2085,9 @@ static int macb_open(struct net_device *dev)
>>  
>>  netif_tx_start_all_queues(dev);
>>  
>> +if (bp->ptp_info)
>> +bp->ptp_info->ptp_init(dev);
>> +
>>  return 0;
>>  }
>>  
>> @@ -2106,6 +2109,9 @@ static int macb_close(struct net_device *dev)
>>  
>>  macb_free_consistent(bp);
>>  
>> +if (bp->ptp_info)
>> +bp->ptp_info->ptp_remove(dev);
>> +
>>  return 0;
>>  }
>>  
>> @@ -2379,6 +2385,17 @@ static int macb_set_ringparam(struct net_device 
>> *netdev,
>>  return 0;
>>  }
>>  
>> +static int macb_get_ts_info(struct net_device *netdev,
>> +struct ethtool_ts_info *info)
>> +{
>> +struct macb *bp = netdev_priv(netdev);
>> +
>> +if (bp->ptp_info)
>> +return bp->ptp_info->get_ts_info(netdev, info);
>> +
>> +return ethtool_op_get_ts_info(netdev, info);
>> +}
>> +
>>  static const struct ethtool_ops macb_ethtool_ops = {
>>  .get_regs_len   = macb_get_regs_len,
>>  .get_regs   = macb_get_regs,
>> @@ -2396,7 +2413,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>>  .get_regs_len   = macb_get_regs_len,
>>  .get_regs   = macb_get_regs,
>>  .get_link   = ethtool_op_get_link,
>> -.get_ts_info= ethtool_op_get_ts_info,
>> +.get_ts_info= macb_get_ts_info,
>>  .get_ethtool_stats  = gem_get_ethtool_stats,
>>  .get_strings= gem_get_ethtool_strings,
>>  .get_sset_count = gem_get_sset_count,
>> @@ -2409,6 +2426,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>>  static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
>>  {
>>  struct phy_device *phydev = dev->phydev;
>> +struct macb *bp = netdev_priv(dev);
>>  
>>  if (!netif_running(dev))
>>  return -EINVAL;
>> @@ -2416,7 +2434,17 @@ static int macb_ioctl(struct net_device *dev, struct 
>> ifreq *rq, int cmd)
>>  if (!phydev)
>>  return -ENODEV;
>>  
>> -return phy_mii_ioctl(phydev, rq, cmd);
>> +if (!bp->ptp_info)
>> +return phy_mii_ioctl(phydev, rq, cmd);
>> +
>> +switch (cmd) {
>> +case SIOCSHWTSTAMP:
>> +return bp->ptp_info->set_hwtst(dev, rq, cmd);
>> +case SIOCGHWTSTAMP:
>> +return bp->ptp_info->get_hwtst(dev, rq);
>> +default:
>> +return phy_mii_ioctl(phydev, rq, cmd);
>> +}
>>  }
>>  
>>  static int macb_set_features(struct net_device *netdev,
>> diff --git a/drivers/net/ethernet/cadence/macb.h 
>> b/drivers/net/ethernet/cadence/macb.h
>> index d67adad..94ddedd 100644
>> --- a/drivers/net/ethernet/cadence/macb.h
>> +++ b/drivers/net/ethernet/cadence/macb.h
>> @@ -131,6 +131,20 @@
>>  #define GEM_RXIPCCNT0x01a8 /* IP header Checksum Error 
>> Counter */
>>  #define GEM_RXTCPCCNT   0x01ac /* TCP Checksum Error Counter */
>>  #define GEM_RXUDPCCNT   0x01b0 /* UDP Checksum Error Counter */
>> +#define GEM_TISUBN  0x01bc /* 1588 Timer Increment Sub-ns */
>> +#define GEM_TSH 0x01c0 /* 1588 Timer Seconds High */
>> +#define GEM_TSL 0x01d0 /* 1588 Timer Seconds Low */
>> +#define GEM_TN  0x01d4 /* 1588 Timer Nanoseconds */
>> +#define GEM_TA  0x01d8 /* 1588 Timer Adjust */
>> +#define GEM_TI  0x01dc /* 1588 Timer Increment */
>> +#define GEM_EFTSL   0x01e0 /* PTP Event Frame Tx Seconds Low */
>> 

Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-25 Thread Nicolas Ferre
Le 19/01/2017 à 17:07, Nicolas Ferre a écrit :
> Le 19/01/2017 à 08:56, Andrei Pistirica a écrit :
>> This patch does the following:
>> - MACB/GEM-PTP interface
>> - registers and bitfields for TSU
>> - capability flags to enable PTP per platform basis
>>
>> Signed-off-by: Andrei Pistirica 
> 
> Acked-by: Nicolas Ferre 

Harini or Rafal, do you plan to review this patch and add your
"Reviewed-by" tags? It can be useful to make this support move forward.

Regards,

>> ---
>> Patch history:
>>
>> Version 1:
>> This is just the common code for MACB/GEM-PTP support.
>> Code is based on the comments related to the following patch series:
>> - [RFC PATCH net-next v1-to-4 1/2] macb: Add 1588 support in Cadence GEM
>> - [RFC PATCH net-next v1-to-4 2/2] macb: Enable 1588 support in SAMA5Dx 
>> platforms
>>
>> Version 2:
>> - Cosmetic changes and PTP capability flag changed doe to overlapping with 
>> JUMBO.
>>
>> Note: Patch on net-next: January 19.
>>
>>  drivers/net/ethernet/cadence/macb.c | 32 +++-
>>  drivers/net/ethernet/cadence/macb.h | 74 
>> +
>>  2 files changed, 104 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/cadence/macb.c 
>> b/drivers/net/ethernet/cadence/macb.c
>> index c0fb80a..ff1e648 100644
>> --- a/drivers/net/ethernet/cadence/macb.c
>> +++ b/drivers/net/ethernet/cadence/macb.c
>> @@ -2085,6 +2085,9 @@ static int macb_open(struct net_device *dev)
>>  
>>  netif_tx_start_all_queues(dev);
>>  
>> +if (bp->ptp_info)
>> +bp->ptp_info->ptp_init(dev);
>> +
>>  return 0;
>>  }
>>  
>> @@ -2106,6 +2109,9 @@ static int macb_close(struct net_device *dev)
>>  
>>  macb_free_consistent(bp);
>>  
>> +if (bp->ptp_info)
>> +bp->ptp_info->ptp_remove(dev);
>> +
>>  return 0;
>>  }
>>  
>> @@ -2379,6 +2385,17 @@ static int macb_set_ringparam(struct net_device 
>> *netdev,
>>  return 0;
>>  }
>>  
>> +static int macb_get_ts_info(struct net_device *netdev,
>> +struct ethtool_ts_info *info)
>> +{
>> +struct macb *bp = netdev_priv(netdev);
>> +
>> +if (bp->ptp_info)
>> +return bp->ptp_info->get_ts_info(netdev, info);
>> +
>> +return ethtool_op_get_ts_info(netdev, info);
>> +}
>> +
>>  static const struct ethtool_ops macb_ethtool_ops = {
>>  .get_regs_len   = macb_get_regs_len,
>>  .get_regs   = macb_get_regs,
>> @@ -2396,7 +2413,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>>  .get_regs_len   = macb_get_regs_len,
>>  .get_regs   = macb_get_regs,
>>  .get_link   = ethtool_op_get_link,
>> -.get_ts_info= ethtool_op_get_ts_info,
>> +.get_ts_info= macb_get_ts_info,
>>  .get_ethtool_stats  = gem_get_ethtool_stats,
>>  .get_strings= gem_get_ethtool_strings,
>>  .get_sset_count = gem_get_sset_count,
>> @@ -2409,6 +2426,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>>  static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
>>  {
>>  struct phy_device *phydev = dev->phydev;
>> +struct macb *bp = netdev_priv(dev);
>>  
>>  if (!netif_running(dev))
>>  return -EINVAL;
>> @@ -2416,7 +2434,17 @@ static int macb_ioctl(struct net_device *dev, struct 
>> ifreq *rq, int cmd)
>>  if (!phydev)
>>  return -ENODEV;
>>  
>> -return phy_mii_ioctl(phydev, rq, cmd);
>> +if (!bp->ptp_info)
>> +return phy_mii_ioctl(phydev, rq, cmd);
>> +
>> +switch (cmd) {
>> +case SIOCSHWTSTAMP:
>> +return bp->ptp_info->set_hwtst(dev, rq, cmd);
>> +case SIOCGHWTSTAMP:
>> +return bp->ptp_info->get_hwtst(dev, rq);
>> +default:
>> +return phy_mii_ioctl(phydev, rq, cmd);
>> +}
>>  }
>>  
>>  static int macb_set_features(struct net_device *netdev,
>> diff --git a/drivers/net/ethernet/cadence/macb.h 
>> b/drivers/net/ethernet/cadence/macb.h
>> index d67adad..94ddedd 100644
>> --- a/drivers/net/ethernet/cadence/macb.h
>> +++ b/drivers/net/ethernet/cadence/macb.h
>> @@ -131,6 +131,20 @@
>>  #define GEM_RXIPCCNT0x01a8 /* IP header Checksum Error 
>> Counter */
>>  #define GEM_RXTCPCCNT   0x01ac /* TCP Checksum Error Counter */
>>  #define GEM_RXUDPCCNT   0x01b0 /* UDP Checksum Error Counter */
>> +#define GEM_TISUBN  0x01bc /* 1588 Timer Increment Sub-ns */
>> +#define GEM_TSH 0x01c0 /* 1588 Timer Seconds High */
>> +#define GEM_TSL 0x01d0 /* 1588 Timer Seconds Low */
>> +#define GEM_TN  0x01d4 /* 1588 Timer Nanoseconds */
>> +#define GEM_TA  0x01d8 /* 1588 Timer Adjust */
>> +#define GEM_TI  0x01dc /* 1588 Timer Increment */
>> +#define GEM_EFTSL   0x01e0 /* PTP Event Frame Tx Seconds Low */
>> +#define GEM_EFTN0x01e4 /* PTP Event Frame Tx 

Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-19 Thread Nicolas Ferre
Le 19/01/2017 à 08:56, Andrei Pistirica a écrit :
> This patch does the following:
> - MACB/GEM-PTP interface
> - registers and bitfields for TSU
> - capability flags to enable PTP per platform basis
> 
> Signed-off-by: Andrei Pistirica 

Acked-by: Nicolas Ferre 

Thanks, regards,

> ---
> Patch history:
> 
> Version 1:
> This is just the common code for MACB/GEM-PTP support.
> Code is based on the comments related to the following patch series:
> - [RFC PATCH net-next v1-to-4 1/2] macb: Add 1588 support in Cadence GEM
> - [RFC PATCH net-next v1-to-4 2/2] macb: Enable 1588 support in SAMA5Dx 
> platforms
> 
> Version 2:
> - Cosmetic changes and PTP capability flag changed doe to overlapping with 
> JUMBO.
> 
> Note: Patch on net-next: January 19.
> 
>  drivers/net/ethernet/cadence/macb.c | 32 +++-
>  drivers/net/ethernet/cadence/macb.h | 74 
> +
>  2 files changed, 104 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.c 
> b/drivers/net/ethernet/cadence/macb.c
> index c0fb80a..ff1e648 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -2085,6 +2085,9 @@ static int macb_open(struct net_device *dev)
>  
>   netif_tx_start_all_queues(dev);
>  
> + if (bp->ptp_info)
> + bp->ptp_info->ptp_init(dev);
> +
>   return 0;
>  }
>  
> @@ -2106,6 +2109,9 @@ static int macb_close(struct net_device *dev)
>  
>   macb_free_consistent(bp);
>  
> + if (bp->ptp_info)
> + bp->ptp_info->ptp_remove(dev);
> +
>   return 0;
>  }
>  
> @@ -2379,6 +2385,17 @@ static int macb_set_ringparam(struct net_device 
> *netdev,
>   return 0;
>  }
>  
> +static int macb_get_ts_info(struct net_device *netdev,
> + struct ethtool_ts_info *info)
> +{
> + struct macb *bp = netdev_priv(netdev);
> +
> + if (bp->ptp_info)
> + return bp->ptp_info->get_ts_info(netdev, info);
> +
> + return ethtool_op_get_ts_info(netdev, info);
> +}
> +
>  static const struct ethtool_ops macb_ethtool_ops = {
>   .get_regs_len   = macb_get_regs_len,
>   .get_regs   = macb_get_regs,
> @@ -2396,7 +2413,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>   .get_regs_len   = macb_get_regs_len,
>   .get_regs   = macb_get_regs,
>   .get_link   = ethtool_op_get_link,
> - .get_ts_info= ethtool_op_get_ts_info,
> + .get_ts_info= macb_get_ts_info,
>   .get_ethtool_stats  = gem_get_ethtool_stats,
>   .get_strings= gem_get_ethtool_strings,
>   .get_sset_count = gem_get_sset_count,
> @@ -2409,6 +2426,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>  static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
>  {
>   struct phy_device *phydev = dev->phydev;
> + struct macb *bp = netdev_priv(dev);
>  
>   if (!netif_running(dev))
>   return -EINVAL;
> @@ -2416,7 +2434,17 @@ static int macb_ioctl(struct net_device *dev, struct 
> ifreq *rq, int cmd)
>   if (!phydev)
>   return -ENODEV;
>  
> - return phy_mii_ioctl(phydev, rq, cmd);
> + if (!bp->ptp_info)
> + return phy_mii_ioctl(phydev, rq, cmd);
> +
> + switch (cmd) {
> + case SIOCSHWTSTAMP:
> + return bp->ptp_info->set_hwtst(dev, rq, cmd);
> + case SIOCGHWTSTAMP:
> + return bp->ptp_info->get_hwtst(dev, rq);
> + default:
> + return phy_mii_ioctl(phydev, rq, cmd);
> + }
>  }
>  
>  static int macb_set_features(struct net_device *netdev,
> diff --git a/drivers/net/ethernet/cadence/macb.h 
> b/drivers/net/ethernet/cadence/macb.h
> index d67adad..94ddedd 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -131,6 +131,20 @@
>  #define GEM_RXIPCCNT 0x01a8 /* IP header Checksum Error Counter */
>  #define GEM_RXTCPCCNT0x01ac /* TCP Checksum Error Counter */
>  #define GEM_RXUDPCCNT0x01b0 /* UDP Checksum Error Counter */
> +#define GEM_TISUBN   0x01bc /* 1588 Timer Increment Sub-ns */
> +#define GEM_TSH  0x01c0 /* 1588 Timer Seconds High */
> +#define GEM_TSL  0x01d0 /* 1588 Timer Seconds Low */
> +#define GEM_TN   0x01d4 /* 1588 Timer Nanoseconds */
> +#define GEM_TA   0x01d8 /* 1588 Timer Adjust */
> +#define GEM_TI   0x01dc /* 1588 Timer Increment */
> +#define GEM_EFTSL0x01e0 /* PTP Event Frame Tx Seconds Low */
> +#define GEM_EFTN 0x01e4 /* PTP Event Frame Tx Nanoseconds */
> +#define GEM_EFRSL0x01e8 /* PTP Event Frame Rx Seconds Low */
> +#define GEM_EFRN 0x01ec /* PTP Event Frame Rx Nanoseconds */
> +#define GEM_PEFTSL   0x01f0 

Re: [PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-19 Thread Nicolas Ferre
Le 19/01/2017 à 08:56, Andrei Pistirica a écrit :
> This patch does the following:
> - MACB/GEM-PTP interface
> - registers and bitfields for TSU
> - capability flags to enable PTP per platform basis
> 
> Signed-off-by: Andrei Pistirica 

Acked-by: Nicolas Ferre 

Thanks, regards,

> ---
> Patch history:
> 
> Version 1:
> This is just the common code for MACB/GEM-PTP support.
> Code is based on the comments related to the following patch series:
> - [RFC PATCH net-next v1-to-4 1/2] macb: Add 1588 support in Cadence GEM
> - [RFC PATCH net-next v1-to-4 2/2] macb: Enable 1588 support in SAMA5Dx 
> platforms
> 
> Version 2:
> - Cosmetic changes and PTP capability flag changed doe to overlapping with 
> JUMBO.
> 
> Note: Patch on net-next: January 19.
> 
>  drivers/net/ethernet/cadence/macb.c | 32 +++-
>  drivers/net/ethernet/cadence/macb.h | 74 
> +
>  2 files changed, 104 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb.c 
> b/drivers/net/ethernet/cadence/macb.c
> index c0fb80a..ff1e648 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -2085,6 +2085,9 @@ static int macb_open(struct net_device *dev)
>  
>   netif_tx_start_all_queues(dev);
>  
> + if (bp->ptp_info)
> + bp->ptp_info->ptp_init(dev);
> +
>   return 0;
>  }
>  
> @@ -2106,6 +2109,9 @@ static int macb_close(struct net_device *dev)
>  
>   macb_free_consistent(bp);
>  
> + if (bp->ptp_info)
> + bp->ptp_info->ptp_remove(dev);
> +
>   return 0;
>  }
>  
> @@ -2379,6 +2385,17 @@ static int macb_set_ringparam(struct net_device 
> *netdev,
>   return 0;
>  }
>  
> +static int macb_get_ts_info(struct net_device *netdev,
> + struct ethtool_ts_info *info)
> +{
> + struct macb *bp = netdev_priv(netdev);
> +
> + if (bp->ptp_info)
> + return bp->ptp_info->get_ts_info(netdev, info);
> +
> + return ethtool_op_get_ts_info(netdev, info);
> +}
> +
>  static const struct ethtool_ops macb_ethtool_ops = {
>   .get_regs_len   = macb_get_regs_len,
>   .get_regs   = macb_get_regs,
> @@ -2396,7 +2413,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>   .get_regs_len   = macb_get_regs_len,
>   .get_regs   = macb_get_regs,
>   .get_link   = ethtool_op_get_link,
> - .get_ts_info= ethtool_op_get_ts_info,
> + .get_ts_info= macb_get_ts_info,
>   .get_ethtool_stats  = gem_get_ethtool_stats,
>   .get_strings= gem_get_ethtool_strings,
>   .get_sset_count = gem_get_sset_count,
> @@ -2409,6 +2426,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
>  static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
>  {
>   struct phy_device *phydev = dev->phydev;
> + struct macb *bp = netdev_priv(dev);
>  
>   if (!netif_running(dev))
>   return -EINVAL;
> @@ -2416,7 +2434,17 @@ static int macb_ioctl(struct net_device *dev, struct 
> ifreq *rq, int cmd)
>   if (!phydev)
>   return -ENODEV;
>  
> - return phy_mii_ioctl(phydev, rq, cmd);
> + if (!bp->ptp_info)
> + return phy_mii_ioctl(phydev, rq, cmd);
> +
> + switch (cmd) {
> + case SIOCSHWTSTAMP:
> + return bp->ptp_info->set_hwtst(dev, rq, cmd);
> + case SIOCGHWTSTAMP:
> + return bp->ptp_info->get_hwtst(dev, rq);
> + default:
> + return phy_mii_ioctl(phydev, rq, cmd);
> + }
>  }
>  
>  static int macb_set_features(struct net_device *netdev,
> diff --git a/drivers/net/ethernet/cadence/macb.h 
> b/drivers/net/ethernet/cadence/macb.h
> index d67adad..94ddedd 100644
> --- a/drivers/net/ethernet/cadence/macb.h
> +++ b/drivers/net/ethernet/cadence/macb.h
> @@ -131,6 +131,20 @@
>  #define GEM_RXIPCCNT 0x01a8 /* IP header Checksum Error Counter */
>  #define GEM_RXTCPCCNT0x01ac /* TCP Checksum Error Counter */
>  #define GEM_RXUDPCCNT0x01b0 /* UDP Checksum Error Counter */
> +#define GEM_TISUBN   0x01bc /* 1588 Timer Increment Sub-ns */
> +#define GEM_TSH  0x01c0 /* 1588 Timer Seconds High */
> +#define GEM_TSL  0x01d0 /* 1588 Timer Seconds Low */
> +#define GEM_TN   0x01d4 /* 1588 Timer Nanoseconds */
> +#define GEM_TA   0x01d8 /* 1588 Timer Adjust */
> +#define GEM_TI   0x01dc /* 1588 Timer Increment */
> +#define GEM_EFTSL0x01e0 /* PTP Event Frame Tx Seconds Low */
> +#define GEM_EFTN 0x01e4 /* PTP Event Frame Tx Nanoseconds */
> +#define GEM_EFRSL0x01e8 /* PTP Event Frame Rx Seconds Low */
> +#define GEM_EFRN 0x01ec /* PTP Event Frame Rx Nanoseconds */
> +#define GEM_PEFTSL   0x01f0 /* PTP Peer Event Frame Tx Secs Low */
> +#define 

[PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-19 Thread Andrei Pistirica
This patch does the following:
- MACB/GEM-PTP interface
- registers and bitfields for TSU
- capability flags to enable PTP per platform basis

Signed-off-by: Andrei Pistirica 
---
Patch history:

Version 1:
This is just the common code for MACB/GEM-PTP support.
Code is based on the comments related to the following patch series:
- [RFC PATCH net-next v1-to-4 1/2] macb: Add 1588 support in Cadence GEM
- [RFC PATCH net-next v1-to-4 2/2] macb: Enable 1588 support in SAMA5Dx 
platforms

Version 2:
- Cosmetic changes and PTP capability flag changed doe to overlapping with 
JUMBO.

Note: Patch on net-next: January 19.

 drivers/net/ethernet/cadence/macb.c | 32 +++-
 drivers/net/ethernet/cadence/macb.h | 74 +
 2 files changed, 104 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index c0fb80a..ff1e648 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -2085,6 +2085,9 @@ static int macb_open(struct net_device *dev)
 
netif_tx_start_all_queues(dev);
 
+   if (bp->ptp_info)
+   bp->ptp_info->ptp_init(dev);
+
return 0;
 }
 
@@ -2106,6 +2109,9 @@ static int macb_close(struct net_device *dev)
 
macb_free_consistent(bp);
 
+   if (bp->ptp_info)
+   bp->ptp_info->ptp_remove(dev);
+
return 0;
 }
 
@@ -2379,6 +2385,17 @@ static int macb_set_ringparam(struct net_device *netdev,
return 0;
 }
 
+static int macb_get_ts_info(struct net_device *netdev,
+   struct ethtool_ts_info *info)
+{
+   struct macb *bp = netdev_priv(netdev);
+
+   if (bp->ptp_info)
+   return bp->ptp_info->get_ts_info(netdev, info);
+
+   return ethtool_op_get_ts_info(netdev, info);
+}
+
 static const struct ethtool_ops macb_ethtool_ops = {
.get_regs_len   = macb_get_regs_len,
.get_regs   = macb_get_regs,
@@ -2396,7 +2413,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
.get_regs_len   = macb_get_regs_len,
.get_regs   = macb_get_regs,
.get_link   = ethtool_op_get_link,
-   .get_ts_info= ethtool_op_get_ts_info,
+   .get_ts_info= macb_get_ts_info,
.get_ethtool_stats  = gem_get_ethtool_stats,
.get_strings= gem_get_ethtool_strings,
.get_sset_count = gem_get_sset_count,
@@ -2409,6 +2426,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
 static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
struct phy_device *phydev = dev->phydev;
+   struct macb *bp = netdev_priv(dev);
 
if (!netif_running(dev))
return -EINVAL;
@@ -2416,7 +2434,17 @@ static int macb_ioctl(struct net_device *dev, struct 
ifreq *rq, int cmd)
if (!phydev)
return -ENODEV;
 
-   return phy_mii_ioctl(phydev, rq, cmd);
+   if (!bp->ptp_info)
+   return phy_mii_ioctl(phydev, rq, cmd);
+
+   switch (cmd) {
+   case SIOCSHWTSTAMP:
+   return bp->ptp_info->set_hwtst(dev, rq, cmd);
+   case SIOCGHWTSTAMP:
+   return bp->ptp_info->get_hwtst(dev, rq);
+   default:
+   return phy_mii_ioctl(phydev, rq, cmd);
+   }
 }
 
 static int macb_set_features(struct net_device *netdev,
diff --git a/drivers/net/ethernet/cadence/macb.h 
b/drivers/net/ethernet/cadence/macb.h
index d67adad..94ddedd 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -131,6 +131,20 @@
 #define GEM_RXIPCCNT   0x01a8 /* IP header Checksum Error Counter */
 #define GEM_RXTCPCCNT  0x01ac /* TCP Checksum Error Counter */
 #define GEM_RXUDPCCNT  0x01b0 /* UDP Checksum Error Counter */
+#define GEM_TISUBN 0x01bc /* 1588 Timer Increment Sub-ns */
+#define GEM_TSH0x01c0 /* 1588 Timer Seconds High */
+#define GEM_TSL0x01d0 /* 1588 Timer Seconds Low */
+#define GEM_TN 0x01d4 /* 1588 Timer Nanoseconds */
+#define GEM_TA 0x01d8 /* 1588 Timer Adjust */
+#define GEM_TI 0x01dc /* 1588 Timer Increment */
+#define GEM_EFTSL  0x01e0 /* PTP Event Frame Tx Seconds Low */
+#define GEM_EFTN   0x01e4 /* PTP Event Frame Tx Nanoseconds */
+#define GEM_EFRSL  0x01e8 /* PTP Event Frame Rx Seconds Low */
+#define GEM_EFRN   0x01ec /* PTP Event Frame Rx Nanoseconds */
+#define GEM_PEFTSL 0x01f0 /* PTP Peer Event Frame Tx Secs Low */
+#define GEM_PEFTN  0x01f4 /* PTP Peer Event Frame Tx Ns */
+#define GEM_PEFRSL 0x01f8 /* PTP Peer Event Frame Rx Sec Low */
+#define GEM_PEFRN  0x01fc /* PTP Peer Event Frame Rx Ns */
 #define GEM_DCFG1  0x0280 /* 

[PATCH net-next v2] macb: Common code to enable ptp support for MACB/GEM

2017-01-19 Thread Andrei Pistirica
This patch does the following:
- MACB/GEM-PTP interface
- registers and bitfields for TSU
- capability flags to enable PTP per platform basis

Signed-off-by: Andrei Pistirica 
---
Patch history:

Version 1:
This is just the common code for MACB/GEM-PTP support.
Code is based on the comments related to the following patch series:
- [RFC PATCH net-next v1-to-4 1/2] macb: Add 1588 support in Cadence GEM
- [RFC PATCH net-next v1-to-4 2/2] macb: Enable 1588 support in SAMA5Dx 
platforms

Version 2:
- Cosmetic changes and PTP capability flag changed doe to overlapping with 
JUMBO.

Note: Patch on net-next: January 19.

 drivers/net/ethernet/cadence/macb.c | 32 +++-
 drivers/net/ethernet/cadence/macb.h | 74 +
 2 files changed, 104 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb.c 
b/drivers/net/ethernet/cadence/macb.c
index c0fb80a..ff1e648 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -2085,6 +2085,9 @@ static int macb_open(struct net_device *dev)
 
netif_tx_start_all_queues(dev);
 
+   if (bp->ptp_info)
+   bp->ptp_info->ptp_init(dev);
+
return 0;
 }
 
@@ -2106,6 +2109,9 @@ static int macb_close(struct net_device *dev)
 
macb_free_consistent(bp);
 
+   if (bp->ptp_info)
+   bp->ptp_info->ptp_remove(dev);
+
return 0;
 }
 
@@ -2379,6 +2385,17 @@ static int macb_set_ringparam(struct net_device *netdev,
return 0;
 }
 
+static int macb_get_ts_info(struct net_device *netdev,
+   struct ethtool_ts_info *info)
+{
+   struct macb *bp = netdev_priv(netdev);
+
+   if (bp->ptp_info)
+   return bp->ptp_info->get_ts_info(netdev, info);
+
+   return ethtool_op_get_ts_info(netdev, info);
+}
+
 static const struct ethtool_ops macb_ethtool_ops = {
.get_regs_len   = macb_get_regs_len,
.get_regs   = macb_get_regs,
@@ -2396,7 +2413,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
.get_regs_len   = macb_get_regs_len,
.get_regs   = macb_get_regs,
.get_link   = ethtool_op_get_link,
-   .get_ts_info= ethtool_op_get_ts_info,
+   .get_ts_info= macb_get_ts_info,
.get_ethtool_stats  = gem_get_ethtool_stats,
.get_strings= gem_get_ethtool_strings,
.get_sset_count = gem_get_sset_count,
@@ -2409,6 +2426,7 @@ static const struct ethtool_ops gem_ethtool_ops = {
 static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
struct phy_device *phydev = dev->phydev;
+   struct macb *bp = netdev_priv(dev);
 
if (!netif_running(dev))
return -EINVAL;
@@ -2416,7 +2434,17 @@ static int macb_ioctl(struct net_device *dev, struct 
ifreq *rq, int cmd)
if (!phydev)
return -ENODEV;
 
-   return phy_mii_ioctl(phydev, rq, cmd);
+   if (!bp->ptp_info)
+   return phy_mii_ioctl(phydev, rq, cmd);
+
+   switch (cmd) {
+   case SIOCSHWTSTAMP:
+   return bp->ptp_info->set_hwtst(dev, rq, cmd);
+   case SIOCGHWTSTAMP:
+   return bp->ptp_info->get_hwtst(dev, rq);
+   default:
+   return phy_mii_ioctl(phydev, rq, cmd);
+   }
 }
 
 static int macb_set_features(struct net_device *netdev,
diff --git a/drivers/net/ethernet/cadence/macb.h 
b/drivers/net/ethernet/cadence/macb.h
index d67adad..94ddedd 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -131,6 +131,20 @@
 #define GEM_RXIPCCNT   0x01a8 /* IP header Checksum Error Counter */
 #define GEM_RXTCPCCNT  0x01ac /* TCP Checksum Error Counter */
 #define GEM_RXUDPCCNT  0x01b0 /* UDP Checksum Error Counter */
+#define GEM_TISUBN 0x01bc /* 1588 Timer Increment Sub-ns */
+#define GEM_TSH0x01c0 /* 1588 Timer Seconds High */
+#define GEM_TSL0x01d0 /* 1588 Timer Seconds Low */
+#define GEM_TN 0x01d4 /* 1588 Timer Nanoseconds */
+#define GEM_TA 0x01d8 /* 1588 Timer Adjust */
+#define GEM_TI 0x01dc /* 1588 Timer Increment */
+#define GEM_EFTSL  0x01e0 /* PTP Event Frame Tx Seconds Low */
+#define GEM_EFTN   0x01e4 /* PTP Event Frame Tx Nanoseconds */
+#define GEM_EFRSL  0x01e8 /* PTP Event Frame Rx Seconds Low */
+#define GEM_EFRN   0x01ec /* PTP Event Frame Rx Nanoseconds */
+#define GEM_PEFTSL 0x01f0 /* PTP Peer Event Frame Tx Secs Low */
+#define GEM_PEFTN  0x01f4 /* PTP Peer Event Frame Tx Ns */
+#define GEM_PEFRSL 0x01f8 /* PTP Peer Event Frame Rx Sec Low */
+#define GEM_PEFRN  0x01fc /* PTP Peer Event Frame Rx Ns */
 #define GEM_DCFG1  0x0280 /* Design Config 1 */
 #define GEM_DCFG2