Skip to content

Commit 6241d24

Browse files
AzharMCHPfabiobaltieri
authored andcommitted
drivers: pinctrl: microchip: update pinctrl driver for Port G1 IP
Update pinctrl driver for Microchip Port G1 Peripheral IPs Signed-off-by: Mohamed Azhar <[email protected]>
1 parent 33486ed commit 6241d24

File tree

4 files changed

+121
-9
lines changed

4 files changed

+121
-9
lines changed

drivers/pinctrl/pinctrl_mchp_port_g1.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@
2727
/* clang-format off */
2828
#define MCHP_PORT_ADDR_OR_NONE(nodelabel) \
2929
IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(nodelabel)), \
30-
(DT_REG_ADDR(DT_NODELABEL(nodelabel))))
31-
/* clang-format on */
30+
(DT_REG_ADDR(DT_NODELABEL(nodelabel)),))
3231

3332
/**
34-
* @brief Array of port addresses for the MCHP SAMD5x_E5x series.
33+
* @brief Array of port addresses for the MCHP G1 series.
3534
*
3635
* This array contains the register addresses of the ports (PORTA, PORTB, PORTC, and PORTD)
37-
* for the MCHP SAMD5x_E5x series microcontrollers. The addresses are obtained using the
36+
* for the MCHP G1 series port peripheral. The addresses are obtained using the
3837
* MCHP_PORT_ADDR_OR_NONE macro, which ensures that only existing ports are included.
39-
* This can be updated for other devices using conditional comiplation directives
38+
* This can be updated for other devices using conditional compilation directives
4039
*/
4140
static const uint32_t mchp_port_addrs[] = {
42-
MCHP_PORT_ADDR_OR_NONE(porta),
43-
MCHP_PORT_ADDR_OR_NONE(portb),
44-
MCHP_PORT_ADDR_OR_NONE(portc),
45-
MCHP_PORT_ADDR_OR_NONE(portd),
41+
MCHP_PORT_ADDR_OR_NONE(porta)
42+
MCHP_PORT_ADDR_OR_NONE(portb)
43+
MCHP_PORT_ADDR_OR_NONE(portc)
44+
MCHP_PORT_ADDR_OR_NONE(portd)
4645
};
46+
/* clang-format on */
4747

4848
/**
4949
* @brief Set pinmux registers using odd/even logic

soc/microchip/pic32c/pic32cm_jh/Kconfig.soc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ config GPIO_MCHP_PORT_U2210_3_1_0
1616
help
1717
Enable PORT GPIO peripheral IP version id="U2210" version="3.1.0".
1818

19+
config PINCTRL_MCHP_PORT_U2210_3_1_0
20+
bool
21+
default y
22+
help
23+
Enable PORT pinctrl peripheral IP version 3.1.0 (U2210).
24+
1925
endif # SOC_FAMILY_MICROCHIP_PIC32CM_JH
2026

2127
rsource "*/Kconfig.soc"

soc/microchip/pic32c/pic32cm_jh/common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
zephyr_sources(soc.c)
5+
zephyr_include_directories(.)
56

67
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright (c) 2025 Microchip Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/devicetree.h>
8+
#include <zephyr/types.h>
9+
#include <dt-bindings/pic32c/pic32cm_jh/common/mchp_pinctrl_pinmux_pic32c.h>
10+
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
15+
/** @cond INTERNAL_HIDDEN */
16+
17+
/**
18+
* @brief Structure representing the pin control settings for a SOC pin.
19+
*
20+
* This structure is used to define the pinmux and pin configuration settings
21+
* for a specific pin on the SOC. It includes information about the port, pin,
22+
* function, bias, drive, and other configuration options.
23+
*/
24+
typedef struct pinctrl_soc_pin {
25+
/** Pinmux settings (port, pin and function). */
26+
uint16_t pinmux;
27+
/** Pin configuration (bias, drive etc). */
28+
uint16_t pinflag;
29+
} pinctrl_soc_pin_t;
30+
31+
/**
32+
* @brief Utility macro to initialize pinmux field.
33+
*
34+
* @param node_id Node identifier.
35+
* @param prop Property name.
36+
* @param idx Property entry index.
37+
*/
38+
#define Z_PINCTRL_MCHP_PINMUX_INIT(node_id, prop, idx) DT_PROP_BY_IDX(node_id, prop, idx)
39+
40+
/**
41+
* @brief Utility macro to initialize each pin flag.
42+
*
43+
* @param node_id Node identifier.
44+
* @param prop Property name.
45+
* @param idx Property entry index.
46+
*/
47+
#define Z_PINCTRL_MCHP_PINFLAG_INIT(node_id, prop, idx) \
48+
((DT_PROP(node_id, bias_pull_up) << MCHP_PINCTRL_PULLUP_POS) | \
49+
(DT_PROP(node_id, bias_pull_down) << MCHP_PINCTRL_PULLDOWN_POS) | \
50+
(DT_PROP(node_id, input_enable) << MCHP_PINCTRL_INPUTENABLE_POS) | \
51+
(DT_PROP(node_id, output_enable) << MCHP_PINCTRL_OUTPUTENABLE_POS) | \
52+
(DT_ENUM_IDX(node_id, drive_strength) << MCHP_PINCTRL_DRIVESTRENGTH_POS)),
53+
54+
/**
55+
* @brief Utility macro to initialize each pin.
56+
*
57+
* @param node_id Node identifier.
58+
* @param prop Property name.
59+
* @param idx Property entry index.
60+
*/
61+
#define Z_PINCTRL_STATE_PIN_INIT(node_id, prop, idx) \
62+
{.pinmux = Z_PINCTRL_MCHP_PINMUX_INIT(node_id, prop, idx), \
63+
.pinflag = Z_PINCTRL_MCHP_PINFLAG_INIT(node_id, prop, idx)},
64+
65+
/**
66+
* @brief Utility macro to initialize state pins contained in a given property.
67+
*
68+
* @param node_id Node identifier.
69+
* @param prop Property name describing state pins.
70+
*/
71+
#define Z_PINCTRL_STATE_PINS_INIT(node_id, prop) \
72+
{DT_FOREACH_CHILD_VARGS(DT_PHANDLE(node_id, prop), DT_FOREACH_PROP_ELEM, pinmux, \
73+
Z_PINCTRL_STATE_PIN_INIT)}
74+
75+
/** @endcond */
76+
77+
/**
78+
* @brief Pin flags/attributes
79+
* @anchor MCHP_PINFLAGS
80+
*
81+
* @{
82+
*/
83+
84+
#define MCHP_PINCTRL_FLAGS_DEFAULT (0U)
85+
#define MCHP_PINCTRL_FLAGS_POS (0U)
86+
#define MCHP_PINCTRL_FLAGS_MASK (0x3F << MCHP_PINCTRL_FLAGS_POS)
87+
#define MCHP_PINCTRL_FLAG_MASK (1U)
88+
#define MCHP_PINCTRL_PULLUP_POS (MCHP_PINCTRL_FLAGS_POS)
89+
#define MCHP_PINCTRL_PULLUP (1U << MCHP_PINCTRL_PULLUP_POS)
90+
#define MCHP_PINCTRL_PULLDOWN_POS (MCHP_PINCTRL_PULLUP_POS + 1U)
91+
#define MCHP_PINCTRL_PULLDOWN (1U << MCHP_PINCTRL_PULLDOWN_POS)
92+
#define MCHP_PINCTRL_OPENDRAIN_POS (MCHP_PINCTRL_PULLDOWN_POS + 1U)
93+
#define MCHP_PINCTRL_OPENDRAIN (1U << MCHP_PINCTRL_OPENDRAIN_POS)
94+
#define MCHP_PINCTRL_INPUTENABLE_POS (MCHP_PINCTRL_OPENDRAIN_POS + 1U)
95+
#define MCHP_PINCTRL_INPUTENABLE (1U << MCHP_PINCTRL_INPUTENABLE_POS)
96+
#define MCHP_PINCTRL_OUTPUTENABLE_POS (MCHP_PINCTRL_INPUTENABLE_POS + 1U)
97+
#define MCHP_PINCTRL_OUTPUTENABLE (1U << MCHP_PINCTRL_OUTPUTENABLE_POS)
98+
#define MCHP_PINCTRL_DRIVESTRENGTH_POS (MCHP_PINCTRL_OUTPUTENABLE_POS + 1U)
99+
#define MCHP_PINCTRL_DRIVESTRENGTH (1U << MCHP_PINCTRL_DRIVESTRENGTH_POS)
100+
101+
/** @} */
102+
103+
#ifdef __cplusplus
104+
}
105+
#endif

0 commit comments

Comments
 (0)