• Grygorii Strashko's avatar
    net: ethernet: ti: cpts: separate hw counter read from timecounter · e66dccce
    Grygorii Strashko authored
    Now CPTS HW time reading code is implemented in timecounter->cyclecounter
    .read() callback and performs following operations:
    timecounter_read() ->cc.read() -> cpts_systim_read()
     - request current CPTS HW time CPTS_TS_PUSH.TS_PUSH = 1
     - poll CPTS FIFO for CPTS_EV_PUSH event with current HW timestamp
    
    This approach need to be changed for the future switch to PTP PHC
    .gettimex64() callback, which require to separate requesting current CPTS
    HW time and processing CPTS FIFO. And for the follow up patch, which
    improves .adjfreq() implementation.
    
    This patch moves code accessing CPTS HW out of timecounter code as
    following:
    - convert HW timestamp of every CPTS event to PTP time (us) and store it as
    part struct cpts_event;
    - add CPTS context field to store current CPTS HW time (counter) value and
    update it on CPTS_EV_PUSH reception;
    - move code accessing CPTS HW out of timecounter code and use current CPTS
    HW time (counter) from CPTS context instead;
    - ensure timecounter->cycle_last is updated on CPTS_EV_PUSH reception.
    
    After this change CPTS timecounter will only perform timekeeper role
    without actually accessing CPTS HW.
    Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
    Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    e66dccce
cpts.c 16.1 KB