Skip to content

Commit 7090605

Browse files
AlessandroLuokartben
authored andcommitted
drivers: pinctrl: Add pinctrl driver for Apollo510 SoCs
This commit adds pinctrl support for Apollo510 SoCs, and unified pinctrl bindings across apollo families. Signed-off-by: Hao Luo <hluo@ambiq.com>
1 parent 6575b55 commit 7090605

File tree

4 files changed

+195
-1
lines changed

4 files changed

+195
-1
lines changed

drivers/pinctrl/Kconfig.ambiq

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
config PINCTRL_AMBIQ
66
bool "Ambiq Apollo pin controller driver"
77
default y
8-
depends on DT_HAS_AMBIQ_APOLLO4_PINCTRL_ENABLED || DT_HAS_AMBIQ_APOLLO3_PINCTRL_ENABLED
8+
depends on DT_HAS_AMBIQ_APOLLO5_PINCTRL_ENABLED || DT_HAS_AMBIQ_APOLLO4_PINCTRL_ENABLED || DT_HAS_AMBIQ_APOLLO3_PINCTRL_ENABLED
99
select AMBIQ_HAL
1010
select AMBIQ_HAL_USE_GPIO
1111
help

drivers/pinctrl/pinctrl_ambiq.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ static void pinctrl_configure_pin(const pinctrl_soc_pin_t *pin)
4545
pin_config.GP.cfg_b.eDriveStrength = pin->drive_strength;
4646
#if defined(CONFIG_SOC_SERIES_APOLLO4X)
4747
pin_config.GP.cfg_b.uSlewRate = pin->slew_rate;
48+
#else
49+
switch (pin->sdif_cdwp) {
50+
case 1:
51+
am_hal_gpio_cd0_pin_config(pin->pin_num);
52+
break;
53+
case 2:
54+
am_hal_gpio_wp0_pin_config(pin->pin_num);
55+
break;
56+
case 3:
57+
am_hal_gpio_cd1_pin_config(pin->pin_num);
58+
break;
59+
case 4:
60+
am_hal_gpio_wp1_pin_config(pin->pin_num);
61+
break;
62+
default:
63+
/* not a sdif pin */
64+
break;
65+
}
4866
#endif
4967
pin_config.GP.cfg_b.uNCE = pin->nce;
5068
pin_config.GP.cfg_b.eCEpol = pin->nce_pol;
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Copyright (c) 2025 Ambiq Micro Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
The Ambiq Apollo5 pin controller is a node responsible for controlling
6+
pin function selection and pin properties, such as routing a UART0 TX
7+
to pin 60 and enabling the pullup resistor on that pin.
8+
9+
The node has the 'pinctrl' node label set in your SoC's devicetree,
10+
so you can modify it like this:
11+
12+
&pinctrl {
13+
/* your modifications go here */
14+
};
15+
16+
All device pin configurations should be placed in child nodes of the
17+
'pinctrl' node, as shown in this example:
18+
19+
/* You can put this in places like a board-pinctrl.dtsi file in
20+
* your board directory, or a devicetree overlay in your application.
21+
*/
22+
23+
/* include pre-defined combinations for the SoC variant used by the board */
24+
#include <dt-bindings/pinctrl/ambiq-apollo5-pinctrl.h>
25+
26+
&pinctrl {
27+
uart0_default: uart0_default {
28+
group1 {
29+
pinmux = <UART0TX_P60>;
30+
};
31+
group2 {
32+
pinmux = <UART0RX_P47>;
33+
input-enable;
34+
};
35+
};
36+
};
37+
38+
The 'uart0_default' child node encodes the pin configurations for a
39+
particular state of a device; in this case, the default (that is, active)
40+
state.
41+
42+
As shown, pin configurations are organized in groups within each child node.
43+
Each group can specify a list of pin function selections in the 'pinmux'
44+
property.
45+
46+
A group can also specify shared pin properties common to all the specified
47+
pins, such as the 'input-enable' property in group 2.
48+
49+
compatible: "ambiq,apollo5-pinctrl"
50+
51+
include: base.yaml
52+
53+
child-binding:
54+
description: |
55+
Definitions for a pinctrl state.
56+
child-binding:
57+
58+
include:
59+
- name: pincfg-node.yaml
60+
property-allowlist:
61+
- input-enable
62+
- drive-push-pull
63+
- drive-open-drain
64+
- bias-high-impedance
65+
- bias-pull-up
66+
- bias-pull-down
67+
68+
properties:
69+
pinmux:
70+
required: true
71+
type: array
72+
description: |
73+
An array of pins sharing the same group properties. Each
74+
element of the array is an integer constructed from the
75+
pin number and the alternative function of the pin.
76+
drive-strength:
77+
type: string
78+
enum:
79+
- "0.1"
80+
- "0.5"
81+
- "0.75"
82+
- "1.0"
83+
default: "0.1"
84+
description: |
85+
The drive strength of a pin, relative to full-driver strength.
86+
The default value is 0.1, which is the reset value.
87+
ambiq,pull-up-ohms:
88+
type: int
89+
enum:
90+
- 1500
91+
- 6000
92+
- 12000
93+
- 24000
94+
- 50000
95+
- 100000
96+
default: 1500
97+
description: |
98+
The pullup resistor value. The default value is 1500 ohms.
99+
ambiq,nce-src:
100+
type: int
101+
default: 0
102+
description: |
103+
IOM0CE0 = 0x0 - IOM 0 NCE 0 module
104+
IOM0CE1 = 0x1 - IOM 0 NCE 1 module
105+
IOM0CE2 = 0x2 - IOM 0 NCE 2 module
106+
IOM0CE3 = 0x3 - IOM 0 NCE 3 module
107+
IOM1CE0 = 0x4 - IOM 1 NCE 0 module
108+
IOM1CE1 = 0x5 - IOM 1 NCE 1 module
109+
IOM1CE2 = 0x6 - IOM 1 NCE 2 module
110+
IOM1CE3 = 0x7 - IOM 1 NCE 3 module
111+
IOM2CE0 = 0x8 - IOM 2 NCE 0 module
112+
IOM2CE1 = 0x9 - IOM 2 NCE 1 module
113+
IOM2CE2 = 0xA - IOM 2 NCE 2 module
114+
IOM2CE3 = 0xB - IOM 2 NCE 3 module
115+
IOM3CE0 = 0xC - IOM 3 NCE 0 module
116+
IOM3CE1 = 0xD - IOM 3 NCE 1 module
117+
IOM3CE2 = 0xE - IOM 3 NCE 2 module
118+
IOM3CE3 = 0xF - IOM 3 NCE 3 module
119+
IOM4CE0 = 0x10 - IOM 4 NCE 0 module
120+
IOM4CE1 = 0x11 - IOM 4 NCE 1 module
121+
IOM4CE2 = 0x12 - IOM 4 NCE 2 module
122+
IOM4CE3 = 0x13 - IOM 4 NCE 3 module
123+
IOM5CE0 = 0x14 - IOM 5 NCE 0 module
124+
IOM5CE1 = 0x15 - IOM 5 NCE 1 module
125+
IOM5CE2 = 0x16 - IOM 5 NCE 2 module
126+
IOM5CE3 = 0x17 - IOM 5 NCE 3 module
127+
IOM6CE0 = 0x18 - IOM 6 NCE 0 module
128+
IOM6CE1 = 0x19 - IOM 6 NCE 1 module
129+
IOM6CE2 = 0x1A - IOM 6 NCE 2 module
130+
IOM6CE3 = 0x1B - IOM 6 NCE 3 module
131+
IOM7CE0 = 0x1C - IOM 7 NCE 0 module
132+
IOM7CE1 = 0x1D - IOM 7 NCE 1 module
133+
IOM7CE2 = 0x1E - IOM 7 NCE 2 module
134+
IOM7CE3 = 0x1F - IOM 7 NCE 3 module
135+
DC_DPI_DE = 0x30 - DC DPI DE module
136+
DISP_CONT_CSX = 0x31 - DISP CONT CSX module
137+
DC_SPI_CS_N = 0x32 - DC SPI CS_N module
138+
DC_QSPI_CS_N = 0x33 - DC QSPI CS_N module
139+
DC_RESX = 0x34 - DC module RESX
140+
ambiq,nce-pol:
141+
type: int
142+
default: 0
143+
description: |
144+
Polarity select for NCE
145+
LOW = 0x0 - Polarity is active low
146+
HIGH = 0x1 - Polarity is active high
147+
ambiq,sdif-cdwp:
148+
type: int
149+
default: 0
150+
description: |
151+
Configure SD Card Detection and Write Protection pin
152+
0x0 - Not SDIF pin
153+
0x1 - SDIF0CD
154+
0x2 - SDIF0WP
155+
0x3 - SDIF1CD
156+
0x4 - SDIF1WP
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright (c) 2025 Ambiq Micro Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef __APOLLO5_PINCTRL_H__
8+
#define __APOLLO5_PINCTRL_H__
9+
10+
#define APOLLO5_ALT_FUNC_POS 0
11+
#define APOLLO5_ALT_FUNC_MASK 0xf
12+
13+
#define APOLLO5_PIN_NUM_POS 4
14+
#define APOLLO5_PIN_NUM_MASK 0xff
15+
16+
#define APOLLO5_PINMUX(pin_num, alt_func) \
17+
(pin_num << APOLLO5_PIN_NUM_POS | \
18+
alt_func << APOLLO5_ALT_FUNC_POS)
19+
20+
#endif /* __APOLLO5_PINCTRL_H__ */

0 commit comments

Comments
 (0)