Skip to content

Commit 767dc4d

Browse files
akanisetticfriedt
authored andcommitted
drivers: misc: timeaware_gpio: Enable support for ARTV_CTRL
Enabled support for ARTV_CTRL for ART value read operation. Signed-off-by: Anisetti Avinash Krishna <[email protected]>
1 parent 16963d3 commit 767dc4d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

drivers/misc/timeaware_gpio/timeaware_gpio_intel.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
/* TGPIO Register offsets */
1818
#define ART_L 0x00 /* ART lower 32 bit reg */
1919
#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 */
2022
#define CTL 0x10 /* TGPIO control reg */
2123
#define COMPV31_0 0x20 /* Comparator lower 32 bit reg */
2224
#define COMPV63_32 0x24 /* Comparator higher 32 bit reg */
@@ -32,7 +34,14 @@
3234
#define UINT32_MASK 0xFFFFFFFF /* 32 bit Mask */
3335
#define UINT32_SIZE 32
3436

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 */
3645
#define CTL_EN BIT(0) /* Control enable */
3746
#define CTL_DIR BIT(1) /* Control disable */
3847
#define CTL_EP GENMASK(3, 2) /* Recerved polarity */
@@ -53,6 +62,7 @@ struct tgpio_config {
5362
DEVICE_MMIO_NAMED_ROM(reg_base);
5463
uint32_t max_pins;
5564
uint32_t art_clock_freq;
65+
bool artv_ctrl;
5666
};
5767

5868
struct tgpio_runtime {
@@ -67,6 +77,18 @@ static mm_reg_t regs(const struct device *dev)
6777
static int tgpio_intel_get_time(const struct device *dev,
6878
uint64_t *current_time)
6979
{
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+
}
7092
*current_time = sys_read32(regs(dev) + ART_L);
7193
*current_time += ((uint64_t)sys_read32(regs(dev) + ART_H) << UINT32_SIZE);
7294

@@ -216,6 +238,7 @@ static int tgpio_init(const struct device *dev)
216238
DEVICE_MMIO_NAMED_ROM_INIT(reg_base, DT_DRV_INST(n)), \
217239
.max_pins = DT_INST_PROP(n, max_pins), \
218240
.art_clock_freq = DT_INST_PROP(n, timer_clock), \
241+
.artv_ctrl = DT_INST_PROP(n, artv_ctrl), \
219242
}; \
220243
\
221244
static struct tgpio_runtime tgpio_##n##_runtime; \

dts/bindings/misc/intel,timeaware-gpio.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ properties:
2020
type: int
2121
required: true
2222
description: Total number of available pins
23+
24+
artv-ctrl:
25+
type: boolean
26+
description: |
27+
Some platforms have ARTV_CTRL which is required for
28+
reading the ART timestamp. This property is used to
29+
indicate if the support of ARTV_CTRL is available
30+
or not.

dts/x86/intel/panther_lake_h.dtsi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,15 @@
313313
status = "disabled";
314314
};
315315

316+
tgpio: tgpio@fe001200 {
317+
compatible = "intel,timeaware-gpio";
318+
reg = <0xfe001200 0x100>;
319+
timer-clock = <19200000>;
320+
max-pins = <2>;
321+
artv-ctrl;
322+
status = "disabled";
323+
};
324+
316325
hpet: hpet@fed00000 {
317326
compatible = "intel,hpet";
318327
reg = <0xfed00000 0x400>;

0 commit comments

Comments
 (0)