i2c: Rename ksdk to mcux
Renames the ksdk i2c shim driver to mcux. Change-Id: I1bcae2fa30cb698af32d6abc609d77dee42c608d Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
parent
40f5de5a56
commit
b22bc6e69b
5 changed files with 47 additions and 47 deletions
|
@ -41,7 +41,7 @@ endif # GPIO
|
||||||
|
|
||||||
if I2C
|
if I2C
|
||||||
|
|
||||||
config I2C_KSDK
|
config I2C_MCUX
|
||||||
def_bool y
|
def_bool y
|
||||||
|
|
||||||
endif # I2C
|
endif # I2C
|
||||||
|
|
|
@ -65,12 +65,12 @@ config I2C_ATMEL_SAM3
|
||||||
Says y to enable additional options to enable support
|
Says y to enable additional options to enable support
|
||||||
for individual controllers.
|
for individual controllers.
|
||||||
|
|
||||||
config I2C_KSDK
|
config I2C_MCUX
|
||||||
bool "KSDK I2C driver"
|
bool "MCUX I2C driver"
|
||||||
depends on I2C && HAS_KSDK
|
depends on I2C && HAS_MCUX
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Enable the ksdk I2C driver.
|
Enable the mcux I2C driver.
|
||||||
|
|
||||||
config I2C_STM32LX
|
config I2C_STM32LX
|
||||||
bool "STM32Lx MCU I2C Driver"
|
bool "STM32Lx MCU I2C Driver"
|
||||||
|
|
|
@ -2,5 +2,5 @@ obj-$(CONFIG_I2C_DW) += i2c_dw.o
|
||||||
obj-$(CONFIG_I2C_QMSI) += i2c_qmsi.o
|
obj-$(CONFIG_I2C_QMSI) += i2c_qmsi.o
|
||||||
obj-$(CONFIG_I2C_QMSI_SS) += i2c_qmsi_ss.o
|
obj-$(CONFIG_I2C_QMSI_SS) += i2c_qmsi_ss.o
|
||||||
obj-$(CONFIG_I2C_ATMEL_SAM3) += i2c_atmel_sam3.o
|
obj-$(CONFIG_I2C_ATMEL_SAM3) += i2c_atmel_sam3.o
|
||||||
obj-$(CONFIG_I2C_KSDK) += i2c_ksdk.o
|
obj-$(CONFIG_I2C_MCUX) += i2c_mcux.o
|
||||||
obj-$(CONFIG_I2C_STM32LX) += i2c_stm32lx.o
|
obj-$(CONFIG_I2C_STM32LX) += i2c_stm32lx.o
|
||||||
|
|
|
@ -22,29 +22,29 @@
|
||||||
#include <misc/util.h>
|
#include <misc/util.h>
|
||||||
|
|
||||||
#define DEV_CFG(dev) \
|
#define DEV_CFG(dev) \
|
||||||
((const struct i2c_ksdk_config * const)(dev)->config->config_info)
|
((const struct i2c_mcux_config * const)(dev)->config->config_info)
|
||||||
#define DEV_DATA(dev) \
|
#define DEV_DATA(dev) \
|
||||||
((struct i2c_ksdk_data * const)(dev)->driver_data)
|
((struct i2c_mcux_data * const)(dev)->driver_data)
|
||||||
#define DEV_BASE(dev) \
|
#define DEV_BASE(dev) \
|
||||||
((I2C_Type *)(DEV_CFG(dev))->base)
|
((I2C_Type *)(DEV_CFG(dev))->base)
|
||||||
|
|
||||||
struct i2c_ksdk_config {
|
struct i2c_mcux_config {
|
||||||
I2C_Type *base;
|
I2C_Type *base;
|
||||||
clock_name_t clock_source;
|
clock_name_t clock_source;
|
||||||
void (*irq_config_func)(struct device *dev);
|
void (*irq_config_func)(struct device *dev);
|
||||||
union dev_config default_cfg;
|
union dev_config default_cfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct i2c_ksdk_data {
|
struct i2c_mcux_data {
|
||||||
i2c_master_handle_t handle;
|
i2c_master_handle_t handle;
|
||||||
struct k_sem device_sync_sem;
|
struct k_sem device_sync_sem;
|
||||||
status_t callback_status;
|
status_t callback_status;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int i2c_ksdk_configure(struct device *dev, uint32_t dev_config_raw)
|
static int i2c_mcux_configure(struct device *dev, uint32_t dev_config_raw)
|
||||||
{
|
{
|
||||||
I2C_Type *base = DEV_BASE(dev);
|
I2C_Type *base = DEV_BASE(dev);
|
||||||
const struct i2c_ksdk_config *config = DEV_CFG(dev);
|
const struct i2c_mcux_config *config = DEV_CFG(dev);
|
||||||
union dev_config dev_config = (union dev_config)dev_config_raw;
|
union dev_config dev_config = (union dev_config)dev_config_raw;
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
uint32_t baudrate;
|
uint32_t baudrate;
|
||||||
|
@ -78,11 +78,11 @@ static int i2c_ksdk_configure(struct device *dev, uint32_t dev_config_raw)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void i2c_ksdk_master_transfer_callback(I2C_Type *base,
|
static void i2c_mcux_master_transfer_callback(I2C_Type *base,
|
||||||
i2c_master_handle_t *handle, status_t status, void *userData)
|
i2c_master_handle_t *handle, status_t status, void *userData)
|
||||||
{
|
{
|
||||||
struct device *dev = userData;
|
struct device *dev = userData;
|
||||||
struct i2c_ksdk_data *data = DEV_DATA(dev);
|
struct i2c_mcux_data *data = DEV_DATA(dev);
|
||||||
|
|
||||||
ARG_UNUSED(handle);
|
ARG_UNUSED(handle);
|
||||||
ARG_UNUSED(base);
|
ARG_UNUSED(base);
|
||||||
|
@ -91,7 +91,7 @@ static void i2c_ksdk_master_transfer_callback(I2C_Type *base,
|
||||||
k_sem_give(&data->device_sync_sem);
|
k_sem_give(&data->device_sync_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t i2c_ksdk_convert_flags(int msg_flags)
|
static uint32_t i2c_mcux_convert_flags(int msg_flags)
|
||||||
{
|
{
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
|
|
||||||
|
@ -106,11 +106,11 @@ static uint32_t i2c_ksdk_convert_flags(int msg_flags)
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i2c_ksdk_transfer(struct device *dev, struct i2c_msg *msgs,
|
static int i2c_mcux_transfer(struct device *dev, struct i2c_msg *msgs,
|
||||||
uint8_t num_msgs, uint16_t addr)
|
uint8_t num_msgs, uint16_t addr)
|
||||||
{
|
{
|
||||||
I2C_Type *base = DEV_BASE(dev);
|
I2C_Type *base = DEV_BASE(dev);
|
||||||
struct i2c_ksdk_data *data = DEV_DATA(dev);
|
struct i2c_mcux_data *data = DEV_DATA(dev);
|
||||||
i2c_master_transfer_t transfer;
|
i2c_master_transfer_t transfer;
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ static int i2c_ksdk_transfer(struct device *dev, struct i2c_msg *msgs,
|
||||||
for (int i = 0; i < num_msgs; i++) {
|
for (int i = 0; i < num_msgs; i++) {
|
||||||
|
|
||||||
/* Initialize the transfer descriptor */
|
/* Initialize the transfer descriptor */
|
||||||
transfer.flags = i2c_ksdk_convert_flags(msgs->flags);
|
transfer.flags = i2c_mcux_convert_flags(msgs->flags);
|
||||||
transfer.slaveAddress = addr;
|
transfer.slaveAddress = addr;
|
||||||
transfer.direction = (msgs->flags & I2C_MSG_READ)
|
transfer.direction = (msgs->flags & I2C_MSG_READ)
|
||||||
? kI2C_Read : kI2C_Write;
|
? kI2C_Read : kI2C_Write;
|
||||||
|
@ -155,20 +155,20 @@ static int i2c_ksdk_transfer(struct device *dev, struct i2c_msg *msgs,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void i2c_ksdk_isr(void *arg)
|
static void i2c_mcux_isr(void *arg)
|
||||||
{
|
{
|
||||||
struct device *dev = (struct device *)arg;
|
struct device *dev = (struct device *)arg;
|
||||||
I2C_Type *base = DEV_BASE(dev);
|
I2C_Type *base = DEV_BASE(dev);
|
||||||
struct i2c_ksdk_data *data = DEV_DATA(dev);
|
struct i2c_mcux_data *data = DEV_DATA(dev);
|
||||||
|
|
||||||
I2C_MasterTransferHandleIRQ(base, &data->handle);
|
I2C_MasterTransferHandleIRQ(base, &data->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int i2c_ksdk_init(struct device *dev)
|
static int i2c_mcux_init(struct device *dev)
|
||||||
{
|
{
|
||||||
I2C_Type *base = DEV_BASE(dev);
|
I2C_Type *base = DEV_BASE(dev);
|
||||||
const struct i2c_ksdk_config *config = DEV_CFG(dev);
|
const struct i2c_mcux_config *config = DEV_CFG(dev);
|
||||||
struct i2c_ksdk_data *data = DEV_DATA(dev);
|
struct i2c_mcux_data *data = DEV_DATA(dev);
|
||||||
uint32_t clock_freq;
|
uint32_t clock_freq;
|
||||||
i2c_master_config_t master_config;
|
i2c_master_config_t master_config;
|
||||||
int error;
|
int error;
|
||||||
|
@ -179,9 +179,9 @@ static int i2c_ksdk_init(struct device *dev)
|
||||||
I2C_MasterGetDefaultConfig(&master_config);
|
I2C_MasterGetDefaultConfig(&master_config);
|
||||||
I2C_MasterInit(base, &master_config, clock_freq);
|
I2C_MasterInit(base, &master_config, clock_freq);
|
||||||
I2C_MasterTransferCreateHandle(base, &data->handle,
|
I2C_MasterTransferCreateHandle(base, &data->handle,
|
||||||
i2c_ksdk_master_transfer_callback, dev);
|
i2c_mcux_master_transfer_callback, dev);
|
||||||
|
|
||||||
error = i2c_ksdk_configure(dev, config->default_cfg.raw);
|
error = i2c_mcux_configure(dev, config->default_cfg.raw);
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -191,60 +191,60 @@ static int i2c_ksdk_init(struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct i2c_driver_api i2c_ksdk_driver_api = {
|
static const struct i2c_driver_api i2c_mcux_driver_api = {
|
||||||
.configure = i2c_ksdk_configure,
|
.configure = i2c_mcux_configure,
|
||||||
.transfer = i2c_ksdk_transfer,
|
.transfer = i2c_mcux_transfer,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_I2C_0
|
#ifdef CONFIG_I2C_0
|
||||||
static void i2c_ksdk_config_func_0(struct device *dev);
|
static void i2c_mcux_config_func_0(struct device *dev);
|
||||||
|
|
||||||
static const struct i2c_ksdk_config i2c_ksdk_config_0 = {
|
static const struct i2c_mcux_config i2c_mcux_config_0 = {
|
||||||
.base = I2C0,
|
.base = I2C0,
|
||||||
.clock_source = I2C0_CLK_SRC,
|
.clock_source = I2C0_CLK_SRC,
|
||||||
.irq_config_func = i2c_ksdk_config_func_0,
|
.irq_config_func = i2c_mcux_config_func_0,
|
||||||
.default_cfg.raw = CONFIG_I2C_0_DEFAULT_CFG,
|
.default_cfg.raw = CONFIG_I2C_0_DEFAULT_CFG,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct i2c_ksdk_data i2c_ksdk_data_0;
|
static struct i2c_mcux_data i2c_mcux_data_0;
|
||||||
|
|
||||||
DEVICE_AND_API_INIT(i2c_ksdk_0, CONFIG_I2C_0_NAME, &i2c_ksdk_init,
|
DEVICE_AND_API_INIT(i2c_mcux_0, CONFIG_I2C_0_NAME, &i2c_mcux_init,
|
||||||
&i2c_ksdk_data_0, &i2c_ksdk_config_0,
|
&i2c_mcux_data_0, &i2c_mcux_config_0,
|
||||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||||
&i2c_ksdk_driver_api);
|
&i2c_mcux_driver_api);
|
||||||
|
|
||||||
static void i2c_ksdk_config_func_0(struct device *dev)
|
static void i2c_mcux_config_func_0(struct device *dev)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
IRQ_CONNECT(IRQ_I2C0, CONFIG_I2C_0_IRQ_PRI,
|
IRQ_CONNECT(IRQ_I2C0, CONFIG_I2C_0_IRQ_PRI,
|
||||||
i2c_ksdk_isr, DEVICE_GET(i2c_ksdk_0), 0);
|
i2c_mcux_isr, DEVICE_GET(i2c_mcux_0), 0);
|
||||||
|
|
||||||
irq_enable(I2C0_IRQn);
|
irq_enable(I2C0_IRQn);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_I2C_0 */
|
#endif /* CONFIG_I2C_0 */
|
||||||
|
|
||||||
#ifdef CONFIG_I2C_1
|
#ifdef CONFIG_I2C_1
|
||||||
static void i2c_ksdk_config_func_1(struct device *dev);
|
static void i2c_mcux_config_func_1(struct device *dev);
|
||||||
|
|
||||||
static const struct i2c_ksdk_config i2c_ksdk_config_1 = {
|
static const struct i2c_mcux_config i2c_mcux_config_1 = {
|
||||||
.base = I2C1,
|
.base = I2C1,
|
||||||
.clock_source = I2C1_CLK_SRC,
|
.clock_source = I2C1_CLK_SRC,
|
||||||
.irq_config_func = i2c_ksdk_config_func_1,
|
.irq_config_func = i2c_mcux_config_func_1,
|
||||||
.default_cfg.raw = CONFIG_I2C_1_DEFAULT_CFG,
|
.default_cfg.raw = CONFIG_I2C_1_DEFAULT_CFG,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct i2c_ksdk_data i2c_ksdk_data_1;
|
static struct i2c_mcux_data i2c_mcux_data_1;
|
||||||
|
|
||||||
DEVICE_AND_API_INIT(i2c_ksdk_1, CONFIG_I2C_1_NAME, &i2c_ksdk_init,
|
DEVICE_AND_API_INIT(i2c_mcux_1, CONFIG_I2C_1_NAME, &i2c_mcux_init,
|
||||||
&i2c_ksdk_data_1, &i2c_ksdk_config_1,
|
&i2c_mcux_data_1, &i2c_mcux_config_1,
|
||||||
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||||
&i2c_ksdk_driver_api);
|
&i2c_mcux_driver_api);
|
||||||
|
|
||||||
static void i2c_ksdk_config_func_1(struct device *dev)
|
static void i2c_mcux_config_func_1(struct device *dev)
|
||||||
{
|
{
|
||||||
IRQ_CONNECT(IRQ_I2C1, CONFIG_I2C_1_IRQ_PRI,
|
IRQ_CONNECT(IRQ_I2C1, CONFIG_I2C_1_IRQ_PRI,
|
||||||
i2c_ksdk_isr, DEVICE_GET(i2c_ksdk_1), 0);
|
i2c_mcux_isr, DEVICE_GET(i2c_mcux_1), 0);
|
||||||
|
|
||||||
irq_enable(I2C1_IRQn);
|
irq_enable(I2C1_IRQn);
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
obj-$(CONFIG_ETH_MCUX) += fsl_enet.o
|
obj-$(CONFIG_ETH_MCUX) += fsl_enet.o
|
||||||
obj-$(CONFIG_I2C_KSDK) += fsl_i2c.o
|
obj-$(CONFIG_I2C_MCUX) += fsl_i2c.o
|
||||||
obj-$(CONFIG_RANDOM_KSDK) += fsl_rnga.o
|
obj-$(CONFIG_RANDOM_KSDK) += fsl_rnga.o
|
||||||
obj-$(CONFIG_SOC_FLASH_KSDK) += fsl_flash.o
|
obj-$(CONFIG_SOC_FLASH_KSDK) += fsl_flash.o
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue