drivers: pinctrl: pinctrl_gecko: Add support for using pinctrl api
This update integrates I2C support with the pinctrl_configure_pins api within the pinctrl_gecko driver. Signed-off-by: Arunmani Alagarsamy <arunmani.a@capgemini.com>
This commit is contained in:
parent
919baf84d6
commit
04931a54ee
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Silicon Labs
|
||||
* Copyright (c) 2024 Capgemini
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
@ -18,6 +19,10 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintp
|
|||
int usart_num = USART_NUM(base);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2C_GECKO
|
||||
I2C_TypeDef *i2c_base = (I2C_TypeDef *)reg;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UART_GECKO
|
||||
struct soc_gpio_pin rxpin = {0, 0, 0, 0};
|
||||
struct soc_gpio_pin txpin = {0, 0, 0, 0};
|
||||
|
@ -277,6 +282,54 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt, uintp
|
|||
#endif /* CONFIG_SOC_FAMILY_SILABS_S1 */
|
||||
#endif /* CONFIG_SPI_GECKO */
|
||||
|
||||
#ifdef CONFIG_I2C_GECKO
|
||||
case GECKO_FUN_I2C_SDA:
|
||||
pin_config.mode = gpioModeWiredAnd;
|
||||
pin_config.out = 1;
|
||||
GPIO_PinModeSet(pin_config.port, pin_config.pin, pin_config.mode,
|
||||
pin_config.out);
|
||||
|
||||
break;
|
||||
|
||||
case GECKO_FUN_I2C_SCL:
|
||||
pin_config.mode = gpioModeWiredAnd;
|
||||
pin_config.out = 1;
|
||||
GPIO_PinModeSet(pin_config.port, pin_config.pin, pin_config.mode,
|
||||
pin_config.out);
|
||||
break;
|
||||
|
||||
case GECKO_FUN_I2C_SDA_LOC:
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
i2c_base->ROUTEPEN |= I2C_ROUTEPEN_SDAPEN;
|
||||
i2c_base->ROUTELOC0 &= ~_I2C_ROUTELOC0_SDALOC_MASK;
|
||||
i2c_base->ROUTELOC0 |= (loc << _I2C_ROUTELOC0_SDALOC_SHIFT);
|
||||
#elif defined(GPIO_I2C_ROUTEEN_SCLPEN) && defined(GPIO_I2C_ROUTEEN_SDAPEN)
|
||||
GPIO->I2CROUTE[I2C_NUM(i2c_base)].ROUTEEN |= GPIO_I2C_ROUTEEN_SDAPEN;
|
||||
GPIO->I2CROUTE[I2C_NUM(i2c_base)].SDAROUTE =
|
||||
(pin_config.pin << _GPIO_I2C_SDAROUTE_PIN_SHIFT) |
|
||||
(pin_config.port << _GPIO_I2C_SDAROUTE_PORT_SHIFT);
|
||||
#else
|
||||
i2c_base->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | (loc << 8);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case GECKO_FUN_I2C_SCL_LOC:
|
||||
#ifdef CONFIG_SOC_GECKO_HAS_INDIVIDUAL_PIN_LOCATION
|
||||
i2c_base->ROUTEPEN |= I2C_ROUTEPEN_SCLPEN;
|
||||
i2c_base->ROUTELOC0 &= ~_I2C_ROUTEPEN_SCLPEN_MASK;
|
||||
i2c_base->ROUTELOC0 |= (loc << _I2C_ROUTELOC0_SCLLOC_SHIFT);
|
||||
#elif defined(GPIO_I2C_ROUTEEN_SCLPEN) && defined(GPIO_I2C_ROUTEEN_SDAPEN)
|
||||
GPIO->I2CROUTE[I2C_NUM(i2c_base)].ROUTEEN |= GPIO_I2C_ROUTEEN_SCLPEN;
|
||||
GPIO->I2CROUTE[I2C_NUM(i2c_base)].SCLROUTE =
|
||||
(pin_config.pin << _GPIO_I2C_SCLROUTE_PIN_SHIFT) |
|
||||
(pin_config.port << _GPIO_I2C_SCLROUTE_PORT_SHIFT);
|
||||
#else
|
||||
i2c_base->ROUTE = I2C_ROUTE_SDAPEN | I2C_ROUTE_SCLPEN | (loc << 8);
|
||||
#endif
|
||||
break;
|
||||
|
||||
#endif /* CONFIG_I2C_GECKO */
|
||||
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,11 @@
|
|||
#define GECKO_FUN_SPI_CS_LOC 20U
|
||||
#define GECKO_FUN_SPI_SCK_LOC 21U
|
||||
|
||||
#define GECKO_FUN_I2C_SDA 22U
|
||||
#define GECKO_FUN_I2C_SCL 23U
|
||||
#define GECKO_FUN_I2C_SDA_LOC 24U
|
||||
#define GECKO_FUN_I2C_SCL_LOC 25U
|
||||
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -66,6 +66,11 @@
|
|||
#define GECKO_FUN_SPI_CSN 7U
|
||||
#define GECKO_FUN_SPI_SCK 8U
|
||||
|
||||
#define GECKO_FUN_I2C_SDA 9U
|
||||
#define GECKO_FUN_I2C_SCL 10U
|
||||
#define GECKO_FUN_I2C_SDA_LOC 11U
|
||||
#define GECKO_FUN_I2C_SCL_LOC 12U
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue