Skip to content

Commit f11db0c

Browse files
Deepika-aerlyncdharunkrithikk
authored andcommitted
zephyr: infineon: add pincntrl support for cy8cproto_041tp
Added pinctrl driver implementation and device tree bindings for Infineon CAT2 SoCs, used by the CY8CPROTO-041TP evaluation kit. Changes include: - New pinctrl driver: drivers/pinctrl/pinctrl_ifx_cat2.c - Associated Kconfig entries (drivers/pinctrl/Kconfig.ifx_cat2) - Updated CMakeLists and Kconfig for driver integration - Added DTS binding: dts/bindings/pinctrl/infineon,cat2-pinctrl.yaml This enables proper peripheral pin configuration support for Infineon CAT2-based boards. Signed-off-by: Deepika aerlync <[email protected]> Signed-off-by: Sayooj K Karun <[email protected]>
1 parent 2faa552 commit f11db0c

File tree

20 files changed

+771
-26
lines changed

20 files changed

+771
-26
lines changed

drivers/pinctrl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ zephyr_library_sources_ifdef(CONFIG_PINCTRL_CC13XX_CC26XX pinctrl_cc13xx_cc26xx.
3232
zephyr_library_sources_ifdef(CONFIG_PINCTRL_CC23X0 pinctrl_cc23x0.c)
3333
zephyr_library_sources_ifdef(CONFIG_PINCTRL_ESP32 pinctrl_esp32.c)
3434
zephyr_library_sources_ifdef(CONFIG_PINCTRL_RV32M1 pinctrl_rv32m1.c)
35-
zephyr_library_sources_ifdef(CONFIG_PINCTRL_INFINEON_CAT1 pinctrl_ifx_cat1.c)
35+
zephyr_library_sources_ifdef(CONFIG_PINCTRL_INFINEON_CATX pinctrl_ifx_catx.c)
3636
zephyr_library_sources_ifdef(CONFIG_PINCTRL_XLNX_ZYNQ pinctrl_xlnx_zynq.c)
3737
zephyr_library_sources_ifdef(CONFIG_PINCTRL_XLNX_ZYNQMP pinctrl_xlnx_zynqmp.c)
3838
zephyr_library_sources_ifdef(CONFIG_PINCTRL_XMC4XXX pinctrl_xmc4xxx.c)

drivers/pinctrl/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ source "drivers/pinctrl/Kconfig.cc13xx_cc26xx"
6565
source "drivers/pinctrl/Kconfig.cc23x0"
6666
source "drivers/pinctrl/Kconfig.esp32"
6767
source "drivers/pinctrl/Kconfig.rv32m1"
68-
source "drivers/pinctrl/Kconfig.ifx_cat1"
68+
source "drivers/pinctrl/Kconfig.ifx_catx"
6969
source "drivers/pinctrl/Kconfig.xlnx"
7070
source "drivers/pinctrl/Kconfig.xmc4xxx"
7171
source "drivers/pinctrl/Kconfig.nxp_siul2"

drivers/pinctrl/Kconfig.ifx_catx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#Infineon CAT1 Pin controller configuration options
2+
3+
# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company) or
4+
# an affiliate of Cypress Semiconductor Corporation
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
config PINCTRL_INFINEON_CATX
8+
bool "Pin controller driver for Infineon CATx MCUs"
9+
default y
10+
depends on DT_HAS_INFINEON_CATX_PINCTRL_ENABLED
11+
help
12+
Enable Pin controller driver for Infineon CATx MCUs

drivers/pinctrl/pinctrl_ifx_catx.c

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company) or
3+
* an affiliate of Cypress Semiconductor Corporation
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
/**
9+
* @brief Pin control driver for Infineon CATx MCU family.
10+
*/
11+
12+
#include <zephyr/drivers/pinctrl.h>
13+
#include <cy_gpio.h>
14+
15+
#define GPIO_PORT_OR_NULL(node_id) \
16+
COND_CODE_1(DT_NODE_EXISTS(node_id), ((GPIO_PRT_Type *)DT_REG_ADDR(node_id)), (NULL))
17+
18+
/* @brief Array containing pointers to each GPIO port.
19+
*
20+
* Entries will be NULL if the GPIO port is not enabled.
21+
*/
22+
static GPIO_PRT_Type *const gpio_ports[] = {
23+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt0)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt1)),
24+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt2)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt3)),
25+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt4)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt5)),
26+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt6)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt7)),
27+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt8)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt9)),
28+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt10)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt11)),
29+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt12)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt13)),
30+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt14)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt15)),
31+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt16)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt17)),
32+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt18)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt19)),
33+
GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt20)), GPIO_PORT_OR_NULL(DT_NODELABEL(gpio_prt21))};
34+
35+
/* @brief This function returns gpio drive mode, according to.
36+
* bias and drive mode params defined in pinctrl node.
37+
*
38+
* @param flags - bias and drive mode flags from pinctrl node.
39+
*/
40+
static uint32_t soc_gpio_get_drv_mode(uint32_t flags)
41+
{
42+
uint32_t drv_mode = CY_GPIO_DM_ANALOG;
43+
uint32_t _flags;
44+
45+
_flags = ((flags & SOC_GPIO_FLAGS_MASK) >> SOC_GPIO_FLAGS_POS);
46+
47+
if (_flags & SOC_GPIO_OPENDRAIN) {
48+
/* drive_open_drain */
49+
drv_mode = (_flags & SOC_GPIO_INPUTENABLE) ? CY_GPIO_DM_OD_DRIVESLOW
50+
: CY_GPIO_DM_OD_DRIVESLOW_IN_OFF;
51+
52+
} else if (_flags & SOC_GPIO_OPENSOURCE) {
53+
/* drive_open_source */
54+
drv_mode = (_flags & SOC_GPIO_INPUTENABLE) ? CY_GPIO_DM_OD_DRIVESHIGH
55+
: CY_GPIO_DM_OD_DRIVESHIGH_IN_OFF;
56+
57+
} else if (_flags & SOC_GPIO_PUSHPULL) {
58+
/* drive_push_pull */
59+
drv_mode = (_flags & SOC_GPIO_INPUTENABLE) ? CY_GPIO_DM_STRONG
60+
: CY_GPIO_DM_STRONG_IN_OFF;
61+
62+
} else if ((_flags & SOC_GPIO_PULLUP) && (_flags & SOC_GPIO_PULLDOWN)) {
63+
/* bias_pull_up and bias_pull_down */
64+
drv_mode = (_flags & SOC_GPIO_INPUTENABLE) ? CY_GPIO_DM_PULLUP_DOWN
65+
: CY_GPIO_DM_PULLUP_DOWN_IN_OFF;
66+
67+
} else if (_flags & SOC_GPIO_PULLUP) {
68+
/* bias_pull_up */
69+
drv_mode = (_flags & SOC_GPIO_INPUTENABLE) ? CY_GPIO_DM_PULLUP
70+
: CY_GPIO_DM_PULLUP_IN_OFF;
71+
72+
} else if (_flags & SOC_GPIO_PULLDOWN) {
73+
/* bias_pull_down */
74+
drv_mode = (_flags & SOC_GPIO_INPUTENABLE) ? CY_GPIO_DM_PULLDOWN
75+
: CY_GPIO_DM_PULLDOWN_IN_OFF;
76+
} else if ((_flags & SOC_GPIO_HIGHZ) | (_flags & SOC_GPIO_INPUTENABLE)) {
77+
/* bias_pull_down */
78+
drv_mode = CY_GPIO_DM_HIGHZ;
79+
} else {
80+
/* nothing do here */
81+
}
82+
83+
return drv_mode;
84+
}
85+
86+
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
87+
{
88+
ARG_UNUSED(reg);
89+
90+
for (uint8_t i = 0U; i < pin_cnt; i++) {
91+
uint32_t drv_mode = soc_gpio_get_drv_mode(pins[i].pincfg);
92+
uint32_t hsiom = CAT1_PINMUX_GET_HSIOM_FUNC(pins[i].pinmux);
93+
uint32_t port_num = CAT1_PINMUX_GET_PORT_NUM(pins[i].pinmux);
94+
uint32_t pin_num = CAT1_PINMUX_GET_PIN_NUM(pins[i].pinmux);
95+
96+
/* Initialize pin */
97+
#if defined(COMPONENT_SECURE_DEVICE) || defined(CY_PDL_TZ_ENABLED)
98+
Cy_GPIO_Pin_SecFastInit(gpio_ports[port_num], pin_num, drv_mode, 1, hsiom);
99+
#else
100+
Cy_GPIO_Pin_FastInit(gpio_ports[port_num], pin_num, drv_mode, 1, hsiom);
101+
#endif /* defined(CY_PDL_TZ_ENABLED) */
102+
103+
/* Force output to enable pulls */
104+
switch (drv_mode) {
105+
case CY_GPIO_DM_PULLUP:
106+
Cy_GPIO_Write(gpio_ports[port_num], pin_num, 1);
107+
break;
108+
case CY_GPIO_DM_PULLDOWN:
109+
Cy_GPIO_Write(gpio_ports[port_num], pin_num, 0);
110+
break;
111+
default:
112+
/* do nothing */
113+
break;
114+
}
115+
}
116+
117+
return 0;
118+
}

dts/arm/infineon/cat1a/legacy/psoc6.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
soc {
6969
pinctrl@40310000 {
70-
compatible = "infineon,cat1-pinctrl";
70+
compatible = "infineon,catx-pinctrl";
7171
#address-cells = <1>;
7272
#size-cells = <1>;
7373
ranges = <0x40310000 0x40310000 0x2024>;

dts/arm/infineon/cat1a/psoc6_01/psoc6_01.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
soc {
5555
pinctrl: pinctrl@40310000 {
56-
compatible = "infineon,cat1-pinctrl";
56+
compatible = "infineon,catx-pinctrl";
5757
reg = <0x40310000 0x20000>;
5858
#address-cells = <1>;
5959
#size-cells = <0>;

dts/arm/infineon/cat1a/psoc6_02/psoc6_02.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
soc {
5555
pinctrl: pinctrl@40300000 {
56-
compatible = "infineon,cat1-pinctrl";
56+
compatible = "infineon,catx-pinctrl";
5757
reg = <0x40300000 0x20000>;
5858
#address-cells = <1>;
5959
#size-cells = <0>;

dts/arm/infineon/cat1a/psoc6_03/psoc6_03.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
soc {
5555
pinctrl: pinctrl@40300000 {
56-
compatible = "infineon,cat1-pinctrl";
56+
compatible = "infineon,catx-pinctrl";
5757
reg = <0x40300000 0x20000>;
5858
#address-cells = <1>;
5959
#size-cells = <0>;

dts/arm/infineon/cat1a/psoc6_04/psoc6_04.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
soc {
5555
pinctrl: pinctrl@40300000 {
56-
compatible = "infineon,cat1-pinctrl";
56+
compatible = "infineon,catx-pinctrl";
5757
reg = <0x40300000 0x20000>;
5858
#address-cells = <1>;
5959
#size-cells = <0>;

dts/arm/infineon/cat1b/cyw20829/cyw20829.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393

9494
soc {
9595
pinctrl: pinctrl@40400000 {
96-
compatible = "infineon,cat1-pinctrl";
96+
compatible = "infineon,catx-pinctrl";
9797
reg = <0x40400000 0x20000>;
9898
};
9999

0 commit comments

Comments
 (0)