17
17
/* TGPIO Register offsets */
18
18
#define ART_L 0x00 /* ART lower 32 bit reg */
19
19
#define ART_H 0x04 /* ART higher 32 bit reg */
20
+ #define ART_CTRL 0x08 /* ART Control 32 bit reg */
21
+ #define ART_TIMEOUT 100 /* ART control update timeout */
20
22
#define CTL 0x10 /* TGPIO control reg */
21
23
#define COMPV31_0 0x20 /* Comparator lower 32 bit reg */
22
24
#define COMPV63_32 0x24 /* Comparator higher 32 bit reg */
32
34
#define UINT32_MASK 0xFFFFFFFF /* 32 bit Mask */
33
35
#define UINT32_SIZE 32
34
36
35
- /* Control Register */
37
+ /*
38
+ * ART Control Register.
39
+ * This register is existing on latest platforms.
40
+ * Used to control reads to ART.
41
+ */
42
+ #define ART_CTRL_CAPT BIT(0) /* ART control capture */
43
+
44
+ /* TGPIO Control Register */
36
45
#define CTL_EN BIT(0) /* Control enable */
37
46
#define CTL_DIR BIT(1) /* Control disable */
38
47
#define CTL_EP GENMASK(3, 2) /* Recerved polarity */
@@ -53,6 +62,7 @@ struct tgpio_config {
53
62
DEVICE_MMIO_NAMED_ROM (reg_base );
54
63
uint32_t max_pins ;
55
64
uint32_t art_clock_freq ;
65
+ bool artv_ctrl ;
56
66
};
57
67
58
68
struct tgpio_runtime {
@@ -67,6 +77,18 @@ static mm_reg_t regs(const struct device *dev)
67
77
static int tgpio_intel_get_time (const struct device * dev ,
68
78
uint64_t * current_time )
69
79
{
80
+ if (DEV_CFG (dev )-> artv_ctrl ) {
81
+ uint8_t i = 0 ;
82
+
83
+ sys_write32 (sys_read32 (regs (dev ) + ART_CTRL ) | ART_CTRL_CAPT ,
84
+ regs (dev ) + ART_CTRL );
85
+ while (sys_read32 (regs (dev ) + ART_CTRL ) & ART_CTRL_CAPT ) {
86
+ i ++ ;
87
+ if (i == ART_TIMEOUT ) {
88
+ return - ETIMEDOUT ;
89
+ }
90
+ }
91
+ }
70
92
* current_time = sys_read32 (regs (dev ) + ART_L );
71
93
* current_time += ((uint64_t )sys_read32 (regs (dev ) + ART_H ) << UINT32_SIZE );
72
94
@@ -216,6 +238,7 @@ static int tgpio_init(const struct device *dev)
216
238
DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)), \
217
239
.max_pins = DT_INST_PROP(n, max_pins), \
218
240
.art_clock_freq = DT_INST_PROP(n, timer_clock), \
241
+ .artv_ctrl = DT_INST_PROP(n, artv_ctrl), \
219
242
}; \
220
243
\
221
244
static struct tgpio_runtime tgpio_##n##_runtime; \
0 commit comments