Skip to content

Commit 709f453

Browse files
akanisetticfriedt
authored andcommitted
drivers: gpio: Enable support for latest GINF method
Enable support for latest GINF method which requires 3 paramters for each GPIO group and enables gpio support for intel_ptl_h platform. Signed-off-by: Anisetti Avinash Krishna <[email protected]>
1 parent 69826c5 commit 709f453

File tree

13 files changed

+316
-33
lines changed

13 files changed

+316
-33
lines changed

drivers/gpio/gpio_intel.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,42 @@ struct gpio_intel_data {
120120
uint32_t pad_owner_reg;
121121
uint32_t host_owner_reg;
122122
uint32_t intr_stat_reg;
123+
uint32_t intr_en_reg;
123124
uint32_t base_num;
124125
#endif
125126
};
126127

127128
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(acpi_hid)
129+
#define GPIO_PAD_OWNERSHIP_SHIFT (0x04) /* Shift between Ownership regs */
130+
131+
#define GPIO_PAD_PINS_PER_REG (8) /*Pins for each Register */
132+
128133
#define GPIO_REG_BASE_GET(dev) DEVICE_MMIO_NAMED_GET(dev, reg_base)
129134

130135
#define REG_GPI_INT_STS_BASE_GET(data) (data)->intr_stat_reg
131136

132-
#define REG_GPI_INT_EN_BASE_GET(data) (data)->intr_stat_reg + 0x20
133-
134137
#define PIN_OFFSET_GET(dev) (0)
135138

136-
#define GPIO_PAD_OWNERSHIP_GET(data, pin, offset) (data)->pad_owner_reg + (((pin) / 8) * 0x4)
137-
138139
#define REG_PAD_HOST_SW_OWNER_GET(data) (data)->host_owner_reg
139140

140141
#define GPIO_BASE_GET(cdf) (0)
141142

142143
#define GPIO_INTERRUPT_BASE_GET(cfg) (0)
143144

144145
#define GPIO_GET_PIN_MAX(dev) ((struct gpio_intel_data *)(dev)->data)->num_pins
146+
147+
#define REG_GPI_INT_EN_BASE_GET(data) (data)->intr_en_reg
148+
149+
#if DT_ANY_INST_HAS_BOOL_STATUS_OKAY(acpi_ginf)
150+
#define GPIO_PAD_OWNERSHIP_GET(data, pin, offset)\
151+
(data)->pad_owner_reg + (pin * GPIO_PAD_OWNERSHIP_SHIFT)
152+
153+
#else
154+
#define GPIO_PAD_OWNERSHIP_GET(data, pin, offset) (data)->pad_owner_reg +\
155+
(((pin) / GPIO_PAD_PINS_PER_REG) * GPIO_PAD_OWNERSHIP_SHIFT)
156+
157+
#endif
158+
145159
#else /* Non-ACPI */
146160
#define GPIO_REG_BASE_GET(dev) GPIO_REG_BASE(DEVICE_MMIO_NAMED_GET(dev, reg_base))
147161

@@ -564,13 +578,14 @@ static DEVICE_API(gpio, gpio_intel_api) = {
564578
/* We need support either DTS or ACPI base resource enumeration at time.*/
565579
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY(acpi_hid)
566580

567-
static int gpio_intel_acpi_enum(const struct device *dev, int bank_idx, char *hid, char *uid)
581+
static int gpio_intel_acpi_enum(const struct device *dev, int bank_idx, char *hid, char *uid,
582+
bool ginf)
568583
{
569584
int ret;
570585
struct gpio_acpi_res res;
571586
struct gpio_intel_data *data = dev->data;
572587

573-
ret = soc_acpi_gpio_resource_get(bank_idx, hid, uid, &res);
588+
ret = soc_acpi_gpio_resource_get(bank_idx, hid, uid, &res, ginf);
574589
if (ret) {
575590
return ret;
576591
}
@@ -580,7 +595,8 @@ static int gpio_intel_acpi_enum(const struct device *dev, int bank_idx, char *hi
580595
data->num_pins = res.num_pins;
581596
data->pad_owner_reg = res.pad_owner_reg;
582597
data->host_owner_reg = res.host_owner_reg;
583-
data->intr_stat_reg = res.intr_stat_reg;
598+
data->intr_stat_reg = res.gp_evt_stat_reg - DT_INST_PROP(0, int_stat_offset);
599+
data->intr_en_reg = res.gp_evt_stat_reg - DT_INST_PROP(0, int_en_offset);
584600
data->base_num = res.base_num;
585601
data->pad_base = res.pad_base;
586602

@@ -605,8 +621,9 @@ static int gpio_intel_acpi_enum(const struct device *dev, int bank_idx, char *hi
605621
#define GPIO_INIT_FN_DEFINE(n) \
606622
static int gpio_intel_init##n(const struct device *dev) \
607623
{ \
608-
return gpio_intel_acpi_enum(dev, DT_INST_PROP(n, group_index), \
609-
ACPI_DT_HID(DT_DRV_INST(n)), ACPI_DT_UID(DT_DRV_INST(n))); \
624+
return gpio_intel_acpi_enum(dev, DT_INST_PROP(n, group_index), \
625+
ACPI_DT_HID(DT_DRV_INST(n)), ACPI_DT_UID(DT_DRV_INST(n)), \
626+
DT_INST_PROP(n, acpi_ginf_3_param)); \
610627
}
611628

612629
#define GPIO_MMIO_ROM_INIT(n)

dts/bindings/gpio/intel,gpio.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,33 @@ properties:
2525
type: int
2626
description: Pin offset of this GPIO entry
2727

28+
int-en-offset:
29+
type: int
30+
description: |
31+
This parameter enables to add proper offset to access
32+
GPIO_INT_EN register from General Purpose Events status
33+
Register, as it is observed that the offset varies from
34+
platform to platform. GP_EVENT_STAT register is fetched
35+
from ACPI GPIO table.
36+
37+
int-stat-offset:
38+
type: int
39+
description: |
40+
This parameter enables to add proper offset to access
41+
GPIO_INT_STAT register from General Purpose Events status
42+
Register, as it is observed that the offset varies from
43+
platform to platform. GP_EVENT_STAT register is fetched
44+
from ACPI GPIO table.
45+
46+
acpi-ginf-3-param:
47+
type: boolean
48+
description: |
49+
This boolean will indicate the version of GINF method ACPI
50+
enabled for a given platform. If the value is true, GINF
51+
method which takes 3 parameters (u-id, bank-id and field-id)
52+
will be used else GINF method with 2 parameters (field-id
53+
and bank-id) will be used.
54+
2855
"#gpio-cells":
2956
const: 2
3057

dts/x86/intel/alder_lake.dtsi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,83 +57,107 @@
5757
acpi-hid = "INTC1057";
5858
acpi-uid = "2";
5959
group-index = <0x02>;
60+
int-stat-offset = <0x40>;
61+
int-en-offset = <0x20>;
6062
status = "okay";
6163
};
6264

6365
gpio_b: gpio_b {
6466
acpi-hid = "INTC1057";
6567
acpi-uid = "0";
6668
group-index = <0x0>;
69+
int-stat-offset = <0x40>;
70+
int-en-offset = <0x20>;
6771
status = "okay";
6872
};
6973

7074
gpio_c: gpio_c {
7175
acpi-hid = "INTC1057";
7276
acpi-uid = "0";
7377
group-index = <0x0B>;
78+
int-stat-offset = <0x40>;
79+
int-en-offset = <0x20>;
7480
status = "okay";
7581
};
7682

7783
gpio_d: gpio_d {
7884
acpi-hid = "INTC1057";
7985
acpi-uid = "0";
8086
group-index = <0x8>;
87+
int-stat-offset = <0x40>;
88+
int-en-offset = <0x20>;
8189
status = "okay";
8290
};
8391

8492
gpio_e: gpio_e {
8593
acpi-hid = "INTC1057";
8694
acpi-uid = "0";
8795
group-index = <0xE>;
96+
int-stat-offset = <0x40>;
97+
int-en-offset = <0x20>;
8898
status = "okay";
8999
};
90100

91101
gpio_f: gpio_f {
92102
acpi-hid = "INTC1057";
93103
acpi-uid = "0";
94104
group-index = <0xC>;
105+
int-stat-offset = <0x40>;
106+
int-en-offset = <0x20>;
95107
status = "okay";
96108
};
97109

98110
gpio_h: gpio_h {
99111
acpi-hid = "INTC1057";
100112
acpi-uid = "0";
101113
group-index = <0x7>;
114+
int-stat-offset = <0x40>;
115+
int-en-offset = <0x20>;
102116
status = "okay";
103117
};
104118

105119
gpio_i: gpio_i {
106120
acpi-hid = "INTC1057";
107121
acpi-uid = "0";
108122
group-index = <0x9>;
123+
int-stat-offset = <0x40>;
124+
int-en-offset = <0x20>;
109125
status = "okay";
110126
};
111127

112128
gpio_s: gpio_s {
113129
acpi-hid = "INTC1057";
114130
acpi-uid = "0";
115131
group-index = <0x6>;
132+
int-stat-offset = <0x40>;
133+
int-en-offset = <0x20>;
116134
status = "okay";
117135
};
118136

119137
gpio_r: gpio_r {
120138
acpi-hid = "INTC1057";
121139
acpi-uid = "0";
122140
group-index = <0x3>;
141+
int-stat-offset = <0x40>;
142+
int-en-offset = <0x20>;
123143
status = "okay";
124144
};
125145

126146
gpio_t: gpio_t {
127147
acpi-hid = "INTC1057";
128148
acpi-uid = "0";
129149
group-index = <0x1>;
150+
int-stat-offset = <0x40>;
151+
int-en-offset = <0x20>;
130152
status = "okay";
131153
};
132154

133155
gpio_v: gpio_v {
134156
acpi-hid = "INTC1057";
135157
acpi-uid = "0";
136158
group-index = <0xA>;
159+
int-stat-offset = <0x40>;
160+
int-en-offset = <0x20>;
137161
status = "okay";
138162
};
139163
};

dts/x86/intel/gpio_common.dtsi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@
145145
status = "disabled";
146146
};
147147

148+
gpio_v: gpio_v {
149+
compatible = "intel,gpio";
150+
interrupt-parent = <&intc>;
151+
interrupts = <ACPI_IRQ_DETECT ACPI_IRQ_FLAG_DETECT 3>;
152+
gpio-controller;
153+
#gpio-cells = <2>;
154+
status = "disabled";
155+
};
156+
148157
vgpio: vgpio {
149158
compatible = "intel,gpio";
150159
interrupt-parent = <&intc>;

dts/x86/intel/panther_lake_h.dtsi

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <zephyr/dt-bindings/interrupt-controller/intel-ioapic.h>
88
#include <zephyr/dt-bindings/i2c/i2c.h>
99
#include <zephyr/dt-bindings/pcie/pcie.h>
10+
#include <zephyr/dt-bindings/gpio/gpio.h>
11+
#include "gpio_common.dtsi"
1012

1113
/ {
1214
cpus {
@@ -49,6 +51,98 @@
4951
#address-cells = <1>;
5052
};
5153

54+
acpi {
55+
gpio_a: gpio_a {
56+
acpi-hid = "INTC10BC";
57+
acpi-uid = "3";
58+
group-index = <0x02>;
59+
acpi-ginf-3-param;
60+
int-stat-offset = <0x30>;
61+
int-en-offset = <0x20>;
62+
status = "disabled";
63+
};
64+
65+
gpio_b: gpio_b {
66+
acpi-hid = "INTC10BC";
67+
acpi-uid = "5";
68+
group-index = <0x00>;
69+
acpi-ginf-3-param;
70+
int-stat-offset = <0x30>;
71+
int-en-offset = <0x20>;
72+
status = "disabled";
73+
};
74+
75+
gpio_c: gpio_c {
76+
acpi-hid = "INTC10BC";
77+
acpi-uid = "0";
78+
group-index = <0x01>;
79+
acpi-ginf-3-param;
80+
int-stat-offset = <0x30>;
81+
int-en-offset = <0x20>;
82+
status = "disabled";
83+
};
84+
85+
gpio_d: gpio_d {
86+
acpi-hid = "INTC10BC";
87+
acpi-uid = "5";
88+
group-index = <0x01>;
89+
acpi-ginf-3-param;
90+
int-stat-offset = <0x30>;
91+
int-en-offset = <0x20>;
92+
status = "disabled";
93+
};
94+
95+
gpio_e: gpio_e {
96+
acpi-hid = "INTC10BC";
97+
acpi-uid = "1";
98+
group-index = <0x01>;
99+
acpi-ginf-3-param;
100+
int-stat-offset = <0x30>;
101+
int-en-offset = <0x20>;
102+
status = "disabled";
103+
};
104+
105+
gpio_f: gpio_f {
106+
acpi-hid = "INTC10BC";
107+
acpi-uid = "1";
108+
group-index = <0x00>;
109+
acpi-ginf-3-param;
110+
int-stat-offset = <0x30>;
111+
int-en-offset = <0x20>;
112+
status = "disabled";
113+
};
114+
115+
gpio_h: gpio_h {
116+
acpi-hid = "INTC10BC";
117+
acpi-uid = "3";
118+
group-index = <0x01>;
119+
acpi-ginf-3-param;
120+
int-stat-offset = <0x30>;
121+
int-en-offset = <0x20>;
122+
status = "disabled";
123+
};
124+
125+
gpio_s: gpio_s {
126+
acpi-hid = "INTC10BC";
127+
acpi-uid = "4";
128+
group-index = <0x00>;
129+
acpi-ginf-3-param;
130+
int-stat-offset = <0x30>;
131+
int-en-offset = <0x20>;
132+
status = "disabled";
133+
};
134+
135+
gpio_v: gpio_v {
136+
acpi-hid = "INTC10BC";
137+
acpi-uid = "0";
138+
group-index = <0x00>;
139+
acpi-ginf-3-param;
140+
int-stat-offset = <0x30>;
141+
int-en-offset = <0x20>;
142+
status = "disabled";
143+
};
144+
};
145+
52146
pcie0: pcie0 {
53147
#address-cells = <1>;
54148
#size-cells = <1>;
@@ -178,6 +272,7 @@
178272
pw,cs-mode = <0>;
179273
pw,cs-output = <0>;
180274
pw,fifo-depth = <64>;
275+
cs-gpios = <&gpio_e 17 GPIO_ACTIVE_LOW>;
181276
clock-frequency = <100000000>;
182277
interrupts = <PCIE_IRQ_DETECT IRQ_TYPE_LOWEST_LEVEL_LOW 3>;
183278
interrupt-parent = <&intc>;
@@ -193,6 +288,7 @@
193288
pw,cs-mode = <0>;
194289
pw,cs-output = <0>;
195290
pw,fifo-depth = <64>;
291+
cs-gpios = <&gpio_f 17 GPIO_ACTIVE_LOW>;
196292
clock-frequency = <100000000>;
197293
interrupts = <PCIE_IRQ_DETECT IRQ_TYPE_LOWEST_LEVEL_LOW 3>;
198294
interrupt-parent = <&intc>;
@@ -208,6 +304,7 @@
208304
pw,cs-mode = <0>;
209305
pw,cs-output = <0>;
210306
pw,fifo-depth = <64>;
307+
cs-gpios = <&gpio_f 18 GPIO_ACTIVE_LOW>;
211308
clock-frequency = <100000000>;
212309
interrupts = <PCIE_IRQ_DETECT IRQ_TYPE_LOWEST_LEVEL_LOW 3>;
213310
interrupt-parent = <&intc>;

soc/intel/alder_lake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
88
zephyr_cc_option(-march=goldmont)
99

1010
zephyr_library_sources(cpu.c)
11-
zephyr_library_sources(../common/soc_gpio.c)
11+
zephyr_library_sources_ifdef(CONFIG_GPIO ../common/soc_gpio.c)
1212

1313
zephyr_library_sources_ifdef(CONFIG_POWEROFF ../common/power.c)
1414

0 commit comments

Comments
 (0)