Skip to content

Commit ecf5321

Browse files
committed
drivers: added pinctrl driver for MSPM0
added pinctrl driver support for MSPM0 Family Signed-off-by: Jackson Farley <[email protected]>
1 parent d80387a commit ecf5321

File tree

5 files changed

+168
-0
lines changed

5 files changed

+168
-0
lines changed

drivers/pinctrl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ zephyr_library_sources_ifdef(CONFIG_PINCTRL_GECKO pinctrl_gecko.c)
3232
zephyr_library_sources_ifdef(CONFIG_PINCTRL_TI_K3 pinctrl_ti_k3.c)
3333
zephyr_library_sources_ifdef(CONFIG_PINCTRL_EMSDP pinctrl_emsdp.c)
3434
zephyr_library_sources_ifdef(CONFIG_PINCTRL_TI_CC32XX pinctrl_ti_cc32xx.c)
35+
zephyr_library_sources_ifdef(CONFIG_PINCTRL_MSPM0 pinctrl_mspm0.c)
3536
zephyr_library_sources_ifdef(CONFIG_PINCTRL_NUMAKER pinctrl_numaker.c)
3637
zephyr_library_sources_ifdef(CONFIG_PINCTRL_QUICKLOGIC_EOS_S3 pinctrl_eos_s3.c)
3738
zephyr_library_sources_ifdef(CONFIG_PINCTRL_MCI_IO_MUX pinctrl_mci_io_mux.c)

drivers/pinctrl/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ source "drivers/pinctrl/Kconfig.xmc4xxx"
5858
source "drivers/pinctrl/Kconfig.nxp_s32"
5959
source "drivers/pinctrl/Kconfig.gecko"
6060
source "drivers/pinctrl/Kconfig.ti_k3"
61+
source "drivers/pinctrl/Kconfig.mspm0"
6162
source "drivers/pinctrl/Kconfig.emsdp"
6263
source "drivers/pinctrl/Kconfig.ti_cc32xx"
6364
source "drivers/pinctrl/Kconfig.numaker"

drivers/pinctrl/Kconfig.mspm0

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
# Copyright (c) 2024 Texas Instruments
3+
4+
config PINCTRL_MSPM0
5+
bool "TI pinctrl MSPM0 driver"
6+
default y
7+
depends on DT_HAS_TI_MSPM0_PINCTRL_ENABLED
8+
help
9+
Enable support for the PINCTRL on TI MSPM0 series.

drivers/pinctrl/pinctrl_mspm0.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2024 Texas Instruments
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/init.h>
8+
#include <zephyr/drivers/pinctrl.h>
9+
#include <ti/driverlib/dl_gpio.h>
10+
11+
#define DT_DRV_COMPAT ti_mspm0_pinctrl
12+
13+
#define MSPM0_PINCM(pinmux) (pinmux >> 0x10)
14+
#define MSPM0_PIN_FUNCTION(pinmux) (pinmux & 0x3F)
15+
16+
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintptr_t reg)
17+
{
18+
ARG_UNUSED(reg);
19+
20+
uint8_t pin_function;
21+
uint32_t pin_cm;
22+
uint32_t iomux;
23+
24+
for (int i = 0; i < pin_cnt; i++) {
25+
pin_cm = MSPM0_PINCM(pins[i].pinmux);
26+
pin_function = MSPM0_PIN_FUNCTION(pins[i].pinmux);
27+
iomux = pins[i].iomux;
28+
if (pin_function == 0x00) {
29+
DL_GPIO_initPeripheralAnalogFunction(pin_cm);
30+
} else {
31+
DL_GPIO_initPeripheralFunction(pin_cm, (iomux | pin_function));
32+
}
33+
}
34+
35+
return 0;
36+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Copyright (c) 2024 Texas Instruments
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
TI MSPM0 pinctrl node.
6+
7+
Device pin configuration should be placed in the child nodes of this node.
8+
Populate the 'pinmux' field with a pair consisting of a pin number and its IO
9+
functions.
10+
11+
The node has the 'pinctrl' node label set in your SoC's devicetree,
12+
so you can modify it like this:
13+
14+
&pinctrl {
15+
/* your modifications go here */
16+
};
17+
18+
All device pin configurations should be placed in child nodes of the
19+
'pinctrl' node, as in the i2c0 example shown at the end.
20+
21+
Here is a list of
22+
supported standard pin properties:
23+
24+
- bias-disable: Disable pull-up/down.
25+
- bias-pull-down: Enable pull-down resistor.
26+
- bias-pull-up: Enable pull-up resistor.
27+
- drive-open-drain: Output driver is open-drain.
28+
- drive-open-drain: Output driver is open-source.
29+
- drive-strength: Maximum current that can be sourced from the pin.
30+
- input-enable: enable input.
31+
- ti,invert: enable logical inversion of a digital input or output
32+
- ti,hysteresis: enable hysteresis control on open-drain pins
33+
34+
An example for MSPM0 family, include the chip level pinctrl
35+
DTSI file in the board level DTS:
36+
37+
#include <dt-bindings/pinctrl/mspm0-pinctrl.h>
38+
39+
We want to configure the I2C pins to open drain, with pullup enabled
40+
and input enabled.
41+
42+
To change a pin's pinctrl default properties add a reference to the
43+
pin in the board's DTS file or in the project overlay and set the
44+
properties.
45+
46+
&i2c1 {
47+
pinctrl-0 = <&i2c1_scl_pb2_pull_up &i2c1_sda_pb3_pull_up>;
48+
pinctrl-names = "default";
49+
}
50+
51+
The i2c1_scl_pb2_pull_up corresponds to the following pin configuration in
52+
the board dts file:
53+
54+
&pinctrl {
55+
i2c1_scl_pb2_pull_up: i2c1_scl_pb2_pull_up {
56+
pinmux = <MSP_PINMUX(15,MSPM0_PIN_FUNCTION_4)>;
57+
input-enable;
58+
bias-pull-up;
59+
drive-open-drain;
60+
};
61+
};
62+
63+
Pin pb2 refers to the device pin name that one would see printed on the
64+
launchpad, and the number 15 in the pinmux define refers to the PINCMx.
65+
66+
These are obtained from the device-specific datasheet.
67+
68+
compatible: "ti,mspm0-pinctrl"
69+
70+
include: base.yaml
71+
72+
properties:
73+
reg:
74+
required: true
75+
76+
child-binding:
77+
description: |
78+
This binding gives a base representation of the MSPM0
79+
pins configuration.
80+
81+
include:
82+
- name: pincfg-node.yaml
83+
property-allowlist:
84+
- bias-disable
85+
- bias-pull-down
86+
- bias-pull-up
87+
- bias-high-impedance
88+
- drive-open-drain
89+
- drive-open-source
90+
- drive-strength
91+
- input-enable
92+
93+
properties:
94+
pinmux:
95+
required: true
96+
type: int
97+
description: |
98+
MSPM0 pin's configuration (IO pin, IO function).
99+
100+
drive-strength:
101+
enum:
102+
- 6
103+
- 20
104+
default: 6
105+
description: |
106+
The drive strength controls the maximum output drive strength sunk or
107+
sourced by an I/O pin.
108+
6: max 6 mA (SoC default)
109+
20: max 20 mA on high-drive capable IOs only (HDIO).
110+
111+
ti,invert:
112+
type: boolean
113+
description: |
114+
Enables inversion of the input or output using the internal
115+
inversion capability of the GPIO
116+
117+
ti,hysteresis:
118+
type: boolean
119+
description: |
120+
Enables the hysteresis control for access to CMOS logic
121+
(on open-drain capable pins)

0 commit comments

Comments
 (0)