11/*
2- * Copyright (c) 2022, Gerson Fernando Budke <[email protected] > 2+ * Copyright (c) 2022-2023 , Gerson Fernando Budke <[email protected] > 33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
66
77#include <zephyr/drivers/pinctrl.h>
8+ #include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
89#include <soc_gpio.h>
910
1011/** Utility macro that expands to the GPIO port address if it exists */
1314 (DT_REG_ADDR(DT_NODELABEL(nodelabel)),))
1415
1516/** Utility macro that expands to the GPIO Peripheral ID if it exists */
16- #define SAM_PORT_PERIPH_ID_OR_NONE (nodelabel ) \
17+ #define SAM_PORT_CLOCKS_OR_NONE (nodelabel ) \
1718 IF_ENABLED(DT_NODE_EXISTS(DT_NODELABEL(nodelabel)), \
18- (DT_PROP( DT_NODELABEL(nodelabel), peripheral_id ),))
19+ (SAM_DT_CLOCK_PMC_CFG(0, DT_NODELABEL(nodelabel)),))
1920
2021/** SAM port addresses */
2122static const uint32_t sam_port_addrs [] = {
@@ -33,19 +34,19 @@ static const uint32_t sam_port_addrs[] = {
3334#endif
3435};
3536
36- /** SAM port peripheral id */
37- static const uint32_t sam_port_periph_id [] = {
37+ /** SAM port clocks */
38+ static const struct atmel_sam_pmc_config sam_port_clocks [] = {
3839#ifdef ID_GPIO
39- SAM_PORT_PERIPH_ID_OR_NONE (gpioa )
40- SAM_PORT_PERIPH_ID_OR_NONE (gpiob )
41- SAM_PORT_PERIPH_ID_OR_NONE (gpioc )
40+ SAM_PORT_CLOCKS_OR_NONE (gpioa )
41+ SAM_PORT_CLOCKS_OR_NONE (gpiob )
42+ SAM_PORT_CLOCKS_OR_NONE (gpioc )
4243#else
43- SAM_PORT_PERIPH_ID_OR_NONE (pioa )
44- SAM_PORT_PERIPH_ID_OR_NONE (piob )
45- SAM_PORT_PERIPH_ID_OR_NONE (pioc )
46- SAM_PORT_PERIPH_ID_OR_NONE (piod )
47- SAM_PORT_PERIPH_ID_OR_NONE (pioe )
48- SAM_PORT_PERIPH_ID_OR_NONE (piof )
44+ SAM_PORT_CLOCKS_OR_NONE (pioa )
45+ SAM_PORT_CLOCKS_OR_NONE (piob )
46+ SAM_PORT_CLOCKS_OR_NONE (pioc )
47+ SAM_PORT_CLOCKS_OR_NONE (piod )
48+ SAM_PORT_CLOCKS_OR_NONE (pioe )
49+ SAM_PORT_CLOCKS_OR_NONE (piof )
4950#endif
5051};
5152
@@ -63,7 +64,7 @@ static void pinctrl_configure_pin(pinctrl_soc_pin_t pin)
6364#else
6465 soc_pin .regs = (Pio * ) sam_port_addrs [port_idx ];
6566#endif
66- soc_pin .periph_id = sam_port_periph_id [port_idx ];
67+ soc_pin .periph_id = sam_port_clocks [port_idx ]. peripheral_id ;
6768 soc_pin .mask = 1 << SAM_PINMUX_PIN_GET (pin );
6869 soc_pin .flags = SAM_PINCTRL_FLAGS_GET (pin ) << SOC_GPIO_FLAGS_POS ;
6970
0 commit comments