| 1 | /* |
| 2 | * Qualcomm QCT QTimer |
| 3 | * |
| 4 | * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef HW_TIMER_QCT_QTIMER_H |
| 9 | #define HW_TIMER_QCT_QTIMER_H |
| 10 | |
| 11 | #include "qom/object.h" |
| 12 | |
| 13 | #define TYPE_QCT_QTIMER "qct-qtimer" |
| 14 | |
| 15 | /* QTimer interface for external access from hexagon_globalreg */ |
| 16 | #define TYPE_QCT_QTIMER_INTERFACE "qct-qtimer-if" |
| 17 | |
| 18 | typedef struct QctQtimerInterface QctQtimerInterface; |
| 19 | |
| 20 | typedef struct QctQtimerInterfaceClass { |
| 21 | InterfaceClass parent_class; |
| 22 | |
| 23 | /* Read the live physical counter, backing HEX_SREG_TIMERLO/TIMERHI */ |
| 24 | uint32_t (*get_timer_lo)(const QctQtimerInterface *qtimer); |
| 25 | uint32_t (*get_timer_hi)(const QctQtimerInterface *qtimer); |
| 26 | } QctQtimerInterfaceClass; |
| 27 | |
| 28 | DECLARE_OBJ_CHECKERS(QctQtimerInterface, QctQtimerInterfaceClass, |
| 29 | QCT_QTIMER_INTERFACE, TYPE_QCT_QTIMER_INTERFACE); |
| 30 | |
| 31 | static inline uint32_t qct_qtimer_get_timer_lo(const QctQtimerInterface *qtimer) |
| 32 | { |
| 33 | QctQtimerInterfaceClass *k = QCT_QTIMER_INTERFACE_GET_CLASS(qtimer); |
| 34 | return k->get_timer_lo(qtimer); |
| 35 | } |
| 36 | |
| 37 | static inline uint32_t qct_qtimer_get_timer_hi(const QctQtimerInterface *qtimer) |
| 38 | { |
| 39 | QctQtimerInterfaceClass *k = QCT_QTIMER_INTERFACE_GET_CLASS(qtimer); |
| 40 | return k->get_timer_hi(qtimer); |
| 41 | } |
| 42 | |
| 43 | #endif /* HW_TIMER_QCT_QTIMER_H */ |