drivers: CC1XX/CC26XX based boards: transition to pinctrl driver
This commit has the necessary changes to update the consumers of pinmux driver(SPI, I2C, UART) and update the board specific files to use the pinctrl interface. Signed-off-by: Vaishnav Achath <vaishnav@beagleboard.org>
This commit is contained in:
parent
e2ed8cf130
commit
ace77c71e9
16 changed files with 255 additions and 127 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <kernel.h>
|
||||
#include <drivers/i2c.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
#include <pm/device.h>
|
||||
#include <pm/policy.h>
|
||||
|
||||
|
@ -16,7 +17,6 @@
|
|||
LOG_MODULE_REGISTER(i2c_cc13xx_cc26xx);
|
||||
|
||||
#include <driverlib/i2c.h>
|
||||
#include <driverlib/ioc.h>
|
||||
#include <driverlib/prcm.h>
|
||||
|
||||
#include <ti/drivers/Power.h>
|
||||
|
@ -36,8 +36,7 @@ struct i2c_cc13xx_cc26xx_data {
|
|||
|
||||
struct i2c_cc13xx_cc26xx_config {
|
||||
uint32_t base;
|
||||
uint32_t scl_pin;
|
||||
uint32_t sda_pin;
|
||||
const struct pinctrl_dev_config *pcfg;
|
||||
};
|
||||
|
||||
static int i2c_cc13xx_cc26xx_transmit(const struct device *dev,
|
||||
|
@ -330,7 +329,10 @@ static int i2c_cc13xx_cc26xx_pm_action(const struct device *dev,
|
|||
switch (action) {
|
||||
case PM_DEVICE_ACTION_RESUME:
|
||||
Power_setDependency(PowerCC26XX_PERIPH_I2C0);
|
||||
IOCPinTypeI2c(config->base, config->sda_pin, config->scl_pin);
|
||||
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = i2c_cc13xx_cc26xx_configure(dev, data->dev_config);
|
||||
if (ret == 0) {
|
||||
I2CMasterIntEnable(config->base);
|
||||
|
@ -340,10 +342,10 @@ static int i2c_cc13xx_cc26xx_pm_action(const struct device *dev,
|
|||
I2CMasterIntDisable(config->base);
|
||||
I2CMasterDisable(config->base);
|
||||
/* Reset pin type to default GPIO configuration */
|
||||
IOCPortConfigureSet(config->scl_pin,
|
||||
IOC_PORT_GPIO, IOC_STD_OUTPUT);
|
||||
IOCPortConfigureSet(config->sda_pin,
|
||||
IOC_PORT_GPIO, IOC_STD_OUTPUT);
|
||||
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
Power_releaseDependency(PowerCC26XX_PERIPH_I2C0);
|
||||
break;
|
||||
default:
|
||||
|
@ -398,8 +400,11 @@ static int i2c_cc13xx_cc26xx_init(const struct device *dev)
|
|||
i2c_cc13xx_cc26xx_isr, DEVICE_DT_INST_GET(0), 0);
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
|
||||
/* Configure IOC module to route SDA and SCL signals */
|
||||
IOCPinTypeI2c(config->base, config->sda_pin, config->scl_pin);
|
||||
err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||
if (err < 0) {
|
||||
LOG_ERR("Failed to configure pinctrl state");
|
||||
return err;
|
||||
}
|
||||
|
||||
cfg = i2c_map_dt_bitrate(DT_INST_PROP(0, clock_frequency));
|
||||
err = i2c_cc13xx_cc26xx_configure(dev, cfg | I2C_MODE_MASTER);
|
||||
|
@ -418,10 +423,11 @@ static const struct i2c_driver_api i2c_cc13xx_cc26xx_driver_api = {
|
|||
.transfer = i2c_cc13xx_cc26xx_transfer
|
||||
};
|
||||
|
||||
PINCTRL_DT_INST_DEFINE(0);
|
||||
|
||||
static const struct i2c_cc13xx_cc26xx_config i2c_cc13xx_cc26xx_config = {
|
||||
.base = DT_INST_REG_ADDR(0),
|
||||
.sda_pin = DT_INST_PROP(0, sda_pin),
|
||||
.scl_pin = DT_INST_PROP(0, scl_pin)
|
||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
||||
};
|
||||
|
||||
static struct i2c_cc13xx_cc26xx_data i2c_cc13xx_cc26xx_data = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue