mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-08-14 18:45:51 +00:00
We have been combining imported mcux drivers into a flattened directory structure to maximize driver reuse, but the introduction of additional nxp soc families (lpc and imx) to zephyr has introduced driver naming conflicts. This caused us to rename and modify imported files, such as fsl_gpio.c/h, to make them unique across all three nxp soc families. This makes updating the the mcux drivers complicated, especially for the lpc family. Reoganize the mcux drivers into soc family subfolders, so we can just copy all the drivers from an mcux distribution (which is done on an soc-basis) into the appropriate soc family folder. Undo all of the naming changes that occurred when lpc and imx drivers were originally imported. Undo the accidental squashing of the kinetis watchdog and dcdc drivers that occurred when the imx drivers were introduced. The drawback to this approach is that we have duplicate files when the same hw ip modules exist in multiple soc families, however there are only few cases where this occurs, such as fsl_lpuart and fsl_trng. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
100 lines
2.4 KiB
C
100 lines
2.4 KiB
C
/*
|
|
* Copyright (c) 2017, NXP
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <errno.h>
|
|
#include <device.h>
|
|
#include <pinmux.h>
|
|
#include <fsl_common.h>
|
|
#include <fsl_clock.h>
|
|
#include <fsl_iocon.h>
|
|
#include <fsl_device_registers.h>
|
|
|
|
#define PORT0_IDX 0u
|
|
#define PORT1_IDX 1u
|
|
|
|
struct pinmux_mcux_lpc_config {
|
|
clock_ip_name_t clock_ip_name;
|
|
IOCON_Type *base;
|
|
u32_t port_no;
|
|
};
|
|
|
|
static int pinmux_mcux_lpc_set(struct device *dev, u32_t pin, u32_t func)
|
|
{
|
|
const struct pinmux_mcux_lpc_config *config = dev->config->config_info;
|
|
IOCON_Type *base = config->base;
|
|
u32_t port = config->port_no;
|
|
|
|
base->PIO[port][pin] = func;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int pinmux_mcux_lpc_get(struct device *dev, u32_t pin, u32_t *func)
|
|
{
|
|
const struct pinmux_mcux_lpc_config *config = dev->config->config_info;
|
|
IOCON_Type *base = config->base;
|
|
u32_t port = config->port_no;
|
|
|
|
*func = base->PIO[port][pin];
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int pinmux_mcux_lpc_pullup(struct device *dev, u32_t pin, u8_t func)
|
|
{
|
|
return -ENOTSUP;
|
|
}
|
|
|
|
static int pinmux_mcux_lpc_input(struct device *dev, u32_t pin, u8_t func)
|
|
{
|
|
return -ENOTSUP;
|
|
}
|
|
|
|
static int pinmux_mcux_lpc_init(struct device *dev)
|
|
{
|
|
const struct pinmux_mcux_lpc_config *config = dev->config->config_info;
|
|
|
|
CLOCK_EnableClock(config->clock_ip_name);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct pinmux_driver_api pinmux_mcux_driver_api = {
|
|
.set = pinmux_mcux_lpc_set,
|
|
.get = pinmux_mcux_lpc_get,
|
|
.pullup = pinmux_mcux_lpc_pullup,
|
|
.input = pinmux_mcux_lpc_input,
|
|
};
|
|
|
|
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT0
|
|
static const struct pinmux_mcux_lpc_config pinmux_mcux_lpc_port0_config = {
|
|
.base = IOCON,
|
|
.clock_ip_name = kCLOCK_Iocon,
|
|
.port_no = PORT0_IDX,
|
|
};
|
|
|
|
DEVICE_AND_API_INIT(pinmux_port0, CONFIG_PINMUX_MCUX_LPC_PORT0_NAME,
|
|
&pinmux_mcux_lpc_init,
|
|
NULL, &pinmux_mcux_lpc_port0_config,
|
|
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
|
&pinmux_mcux_driver_api);
|
|
#endif /* CONFIG_PINMUX_MCUX_LPC_PORT0 */
|
|
|
|
#ifdef CONFIG_PINMUX_MCUX_LPC_PORT1
|
|
static const struct pinmux_mcux_lpc_config pinmux_mcux_lpc_port1_config = {
|
|
.base = IOCON,
|
|
.clock_ip_name = kCLOCK_Iocon,
|
|
.port_no = PORT1_IDX,
|
|
};
|
|
|
|
DEVICE_AND_API_INIT(pinmux_port1, CONFIG_PINMUX_MCUX_LPC_PORT1_NAME,
|
|
&pinmux_mcux_lpc_init,
|
|
NULL, &pinmux_mcux_lpc_port1_config,
|
|
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
|
&pinmux_mcux_driver_api);
|
|
#endif /* CONFIG_PINMUX_MCUX_LPC_PORT1 */
|