Skip to content

Commit

Permalink
pinctrl: Add wake-up sources generation
Browse files Browse the repository at this point in the history
The SAM SoC requires that SUPC be configured to enable specific pins
to be used as wake-up sources. This add a new section denominated as
wakeup. In that section the pinmux will be used to store the correct
wkupX input to be used by the pinctrl driver to configure the gpio
and supc accordingly.

This update all pinconfigs, the pinctrl definitions, update the
documentation  and expand the current test to cover the changes.

Signed-off-by: Gerson Fernando Budke <[email protected]>
  • Loading branch information
nandojve committed Oct 21, 2023
1 parent 942d664 commit 3c19322
Show file tree
Hide file tree
Showing 36 changed files with 545 additions and 454 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
steps:
- uses: actions/checkout@v1
- name: Set up Python
Expand Down
118 changes: 68 additions & 50 deletions include/dt-bindings/pinctrl/atmel_sam_pinctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
* @{
*/

#define SAM_PINMUX_PORT_a 0U
#define SAM_PINMUX_PORT_b 1U
#define SAM_PINMUX_PORT_c 2U
#define SAM_PINMUX_PORT_d 3U
#define SAM_PINMUX_PORT_e 4U
#define SAM_PINMUX_PORT_f 5U
#define SAM_PINMUX_PORT_g 6U
#define SAM_PINMUX_PORT_h 7U
#define SAM_PINMUX_PORT_i 8U
#define SAM_PINMUX_PORT_j 9U
#define SAM_PINMUX_PORT_k 10U
#define SAM_PINMUX_PORT_l 11U
#define SAM_PINMUX_PORT_m 12U
#define SAM_PINMUX_PORT_n 13U
#define SAM_PINMUX_PORT_o 14U
#define SAM_PINMUX_PORT_p 15U
#define SAM_PINMUX_PORT_a 0U
#define SAM_PINMUX_PORT_b 1U
#define SAM_PINMUX_PORT_c 2U
#define SAM_PINMUX_PORT_d 3U
#define SAM_PINMUX_PORT_e 4U
#define SAM_PINMUX_PORT_f 5U
#define SAM_PINMUX_PORT_g 6U
#define SAM_PINMUX_PORT_h 7U
#define SAM_PINMUX_PORT_i 8U
#define SAM_PINMUX_PORT_j 9U
#define SAM_PINMUX_PORT_k 10U
#define SAM_PINMUX_PORT_l 11U
#define SAM_PINMUX_PORT_m 12U
#define SAM_PINMUX_PORT_n 13U
#define SAM_PINMUX_PORT_o 14U
#define SAM_PINMUX_PORT_p 15U

/** @} */

Expand All @@ -36,29 +36,45 @@
*/

/** GPIO */
#define SAM_PINMUX_PERIPH_gpio 0U
#define SAM_PINMUX_PERIPH_gpio 0U
/** Peripherals */
#define SAM_PINMUX_PERIPH_a 0U
#define SAM_PINMUX_PERIPH_b 1U
#define SAM_PINMUX_PERIPH_c 2U
#define SAM_PINMUX_PERIPH_d 3U
#define SAM_PINMUX_PERIPH_e 4U
#define SAM_PINMUX_PERIPH_f 5U
#define SAM_PINMUX_PERIPH_g 6U
#define SAM_PINMUX_PERIPH_h 7U
#define SAM_PINMUX_PERIPH_i 8U
#define SAM_PINMUX_PERIPH_j 9U
#define SAM_PINMUX_PERIPH_k 10U
#define SAM_PINMUX_PERIPH_l 11U
#define SAM_PINMUX_PERIPH_m 12U
#define SAM_PINMUX_PERIPH_n 13U
#define SAM_PINMUX_PERIPH_a 0U
#define SAM_PINMUX_PERIPH_b 1U
#define SAM_PINMUX_PERIPH_c 2U
#define SAM_PINMUX_PERIPH_d 3U
#define SAM_PINMUX_PERIPH_e 4U
#define SAM_PINMUX_PERIPH_f 5U
#define SAM_PINMUX_PERIPH_g 6U
#define SAM_PINMUX_PERIPH_h 7U
#define SAM_PINMUX_PERIPH_i 8U
#define SAM_PINMUX_PERIPH_j 9U
#define SAM_PINMUX_PERIPH_k 10U
#define SAM_PINMUX_PERIPH_l 11U
#define SAM_PINMUX_PERIPH_m 12U
#define SAM_PINMUX_PERIPH_n 13U
/** Extra */
#define SAM_PINMUX_PERIPH_x 0U
#define SAM_PINMUX_PERIPH_x 0U
/** System */
#define SAM_PINMUX_PERIPH_s 0U
#define SAM_PINMUX_PERIPH_s 0U
/** LPM */
#define SAM_PINMUX_PERIPH_lpm 0U

#define SAM_PINMUX_PERIPH_lpm 0U
/** Wake-up pin sources */
#define SAM_PINMUX_PERIPH_wkpu0 0U
#define SAM_PINMUX_PERIPH_wkpu1 1U
#define SAM_PINMUX_PERIPH_wkpu2 2U
#define SAM_PINMUX_PERIPH_wkpu3 3U
#define SAM_PINMUX_PERIPH_wkpu4 4U
#define SAM_PINMUX_PERIPH_wkpu5 5U
#define SAM_PINMUX_PERIPH_wkpu6 6U
#define SAM_PINMUX_PERIPH_wkpu7 7U
#define SAM_PINMUX_PERIPH_wkpu8 8U
#define SAM_PINMUX_PERIPH_wkpu9 9U
#define SAM_PINMUX_PERIPH_wkpu10 10U
#define SAM_PINMUX_PERIPH_wkpu11 11U
#define SAM_PINMUX_PERIPH_wkpu12 12U
#define SAM_PINMUX_PERIPH_wkpu13 13U
#define SAM_PINMUX_PERIPH_wkpu14 14U
#define SAM_PINMUX_PERIPH_wkpu15 15U
/** @} */

/**
Expand All @@ -67,15 +83,17 @@
*/

/** Selects pin to be used as GPIO */
#define SAM_PINMUX_FUNC_gpio 0U
#define SAM_PINMUX_FUNC_gpio 0U
/** Selects pin to be used as by some peripheral */
#define SAM_PINMUX_FUNC_periph 1U
#define SAM_PINMUX_FUNC_periph 1U
/** Selects pin to be used as extra function */
#define SAM_PINMUX_FUNC_extra 2U
#define SAM_PINMUX_FUNC_extra 2U
/** Selects pin to be used as system function */
#define SAM_PINMUX_FUNC_system 3U
#define SAM_PINMUX_FUNC_system 3U
/** Selects and configure pin to be used in Low Power Mode */
#define SAM_PINMUX_FUNC_lpm 4U
#define SAM_PINMUX_FUNC_lpm 4U
/** Selects and configure wake-up pin sources Low Power Mode */
#define SAM_PINMUX_FUNC_wakeup 5U

/** @} */

Expand All @@ -85,26 +103,26 @@
*/

/** Pinmux bit field position. */
#define SAM_PINCTRL_PINMUX_POS (16U)
#define SAM_PINCTRL_PINMUX_POS (16U)
/** Pinmux bit field mask. */
#define SAM_PINCTRL_PINMUX_MASK (0xFFFF)
#define SAM_PINCTRL_PINMUX_MASK (0xFFFF)

/** Port field mask. */
#define SAM_PINMUX_PORT_MSK (0xFU)
#define SAM_PINMUX_PORT_MSK (0xFU)
/** Port field position. */
#define SAM_PINMUX_PORT_POS (0U)
#define SAM_PINMUX_PORT_POS (0U)
/** Pin field mask. */
#define SAM_PINMUX_PIN_MSK (0x1FU)
#define SAM_PINMUX_PIN_MSK (0x1FU)
/** Pin field position. */
#define SAM_PINMUX_PIN_POS (SAM_PINMUX_PORT_POS + 4U)
#define SAM_PINMUX_PIN_POS (SAM_PINMUX_PORT_POS + 4U)
/** Function field mask. */
#define SAM_PINMUX_FUNC_MSK (0x7U)
#define SAM_PINMUX_FUNC_MSK (0x7U)
/** Function field position. */
#define SAM_PINMUX_FUNC_POS (SAM_PINMUX_PIN_POS + 5U)
#define SAM_PINMUX_FUNC_POS (SAM_PINMUX_PIN_POS + 5U)
/** Peripheral field mask. */
#define SAM_PINMUX_PERIPH_MSK (0xFU)
#define SAM_PINMUX_PERIPH_MSK (0xFU)
/** Peripheral field position. */
#define SAM_PINMUX_PERIPH_POS (SAM_PINMUX_FUNC_POS + 3U)
#define SAM_PINMUX_PERIPH_POS (SAM_PINMUX_FUNC_POS + 3U)

/** @} */

Expand Down
32 changes: 16 additions & 16 deletions include/dt-bindings/pinctrl/sam3AXc-pinctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/* pa1x_supc_wkup0 */
#define PA1X_SUPC_WKUP0 \
SAM_PINMUX(a, 1, x, extra)
SAM_PINMUX(a, 1, wkup0, wakeup)

/* pa2_gpio */
#define PA2_GPIO \
Expand Down Expand Up @@ -64,7 +64,7 @@

/* pa3x_supc_wkup1 */
#define PA3X_SUPC_WKUP1 \
SAM_PINMUX(a, 3, x, extra)
SAM_PINMUX(a, 3, wkup1, wakeup)

/* pa4_gpio */
#define PA4_GPIO \
Expand Down Expand Up @@ -92,7 +92,7 @@

/* pa5x_supc_wkup2 */
#define PA5X_SUPC_WKUP2 \
SAM_PINMUX(a, 5, x, extra)
SAM_PINMUX(a, 5, wkup2, wakeup)

/* pa6_gpio */
#define PA6_GPIO \
Expand All @@ -116,7 +116,7 @@

/* pa7x_supc_wkup3 */
#define PA7X_SUPC_WKUP3 \
SAM_PINMUX(a, 7, x, extra)
SAM_PINMUX(a, 7, wkup3, wakeup)

/* pa8_gpio */
#define PA8_GPIO \
Expand All @@ -132,7 +132,7 @@

/* pa8x_supc_wkup4 */
#define PA8X_SUPC_WKUP4 \
SAM_PINMUX(a, 8, x, extra)
SAM_PINMUX(a, 8, wkup4, wakeup)

/* pa9_gpio */
#define PA9_GPIO \
Expand Down Expand Up @@ -160,7 +160,7 @@

/* pa10x_supc_wkup5 */
#define PA10X_SUPC_WKUP5 \
SAM_PINMUX(a, 10, x, extra)
SAM_PINMUX(a, 10, wkup5, wakeup)

/* pa11_gpio */
#define PA11_GPIO \
Expand All @@ -176,7 +176,7 @@

/* pa11x_supc_wkup6 */
#define PA11X_SUPC_WKUP6 \
SAM_PINMUX(a, 11, x, extra)
SAM_PINMUX(a, 11, wkup6, wakeup)

/* pa12_gpio */
#define PA12_GPIO \
Expand All @@ -192,7 +192,7 @@

/* pa12x_supc_wkup7 */
#define PA12X_SUPC_WKUP7 \
SAM_PINMUX(a, 12, x, extra)
SAM_PINMUX(a, 12, wkup7, wakeup)

/* pa13_gpio */
#define PA13_GPIO \
Expand Down Expand Up @@ -232,7 +232,7 @@

/* pa15x_supc_wkup8 */
#define PA15X_SUPC_WKUP8 \
SAM_PINMUX(a, 15, x, extra)
SAM_PINMUX(a, 15, wkup8, wakeup)

/* pa16_gpio */
#define PA16_GPIO \
Expand Down Expand Up @@ -272,7 +272,7 @@

/* pa18x_supc_wkup9 */
#define PA18X_SUPC_WKUP9 \
SAM_PINMUX(a, 18, x, extra)
SAM_PINMUX(a, 18, wkup9, wakeup)

/* pa19_gpio */
#define PA19_GPIO \
Expand Down Expand Up @@ -384,7 +384,7 @@

/* pa27x_supc_wkup10 */
#define PA27X_SUPC_WKUP10 \
SAM_PINMUX(a, 27, x, extra)
SAM_PINMUX(a, 27, wkup10, wakeup)

/* pa28_gpio */
#define PA28_GPIO \
Expand All @@ -400,7 +400,7 @@

/* pa28x_supc_wkup11 */
#define PA28X_SUPC_WKUP11 \
SAM_PINMUX(a, 28, x, extra)
SAM_PINMUX(a, 28, wkup11, wakeup)

/* pa29_gpio */
#define PA29_GPIO \
Expand Down Expand Up @@ -568,7 +568,7 @@

/* pb15x_supc_wkup10 */
#define PB15X_SUPC_WKUP10 \
SAM_PINMUX(b, 15, x, extra)
SAM_PINMUX(b, 15, wkup10, wakeup)

/* pb16_gpio */
#define PB16_GPIO \
Expand Down Expand Up @@ -668,7 +668,7 @@

/* pb21x_supc_wkup13 */
#define PB21X_SUPC_WKUP13 \
SAM_PINMUX(b, 21, x, extra)
SAM_PINMUX(b, 21, wkup13, wakeup)

/* pb22_gpio */
#define PB22_GPIO \
Expand Down Expand Up @@ -696,7 +696,7 @@

/* pb23x_supc_wkup14 */
#define PB23X_SUPC_WKUP14 \
SAM_PINMUX(b, 23, x, extra)
SAM_PINMUX(b, 23, wkup14, wakeup)

/* pb24_gpio */
#define PB24_GPIO \
Expand Down Expand Up @@ -732,7 +732,7 @@

/* pb26x_supc_wkup15 */
#define PB26X_SUPC_WKUP15 \
SAM_PINMUX(b, 26, x, extra)
SAM_PINMUX(b, 26, wkup15, wakeup)

/* pb27_gpio */
#define PB27_GPIO \
Expand Down
Loading

0 comments on commit 3c19322

Please sign in to comment.