zephyr/drivers/pinmux/pinmux_mcux.c
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00

128 lines
3.1 KiB
C

/*
* Copyright (c) 2016 Freescale Semiconductor, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <errno.h>
#include <device.h>
#include <pinmux.h>
#include <fsl_common.h>
#include <fsl_clock.h>
struct pinmux_mcux_config {
clock_ip_name_t clock_ip_name;
PORT_Type *base;
};
static int pinmux_mcux_set(struct device *dev, uint32_t pin, uint32_t func)
{
const struct pinmux_mcux_config *config = dev->config->config_info;
PORT_Type *base = config->base;
base->PCR[pin] = func;
return 0;
}
static int pinmux_mcux_get(struct device *dev, uint32_t pin, uint32_t *func)
{
const struct pinmux_mcux_config *config = dev->config->config_info;
PORT_Type *base = config->base;
*func = base->PCR[pin];
return 0;
}
static int pinmux_mcux_pullup(struct device *dev, uint32_t pin, uint8_t func)
{
return -ENOTSUP;
}
static int pinmux_mcux_input(struct device *dev, uint32_t pin, uint8_t func)
{
return -ENOTSUP;
}
static int pinmux_mcux_init(struct device *dev)
{
const struct pinmux_mcux_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_set,
.get = pinmux_mcux_get,
.pullup = pinmux_mcux_pullup,
.input = pinmux_mcux_input,
};
#ifdef CONFIG_PINMUX_MCUX_PORTA
static const struct pinmux_mcux_config pinmux_mcux_porta_config = {
.base = PORTA,
.clock_ip_name = kCLOCK_PortA,
};
DEVICE_AND_API_INIT(pinmux_porta, CONFIG_PINMUX_MCUX_PORTA_NAME,
&pinmux_mcux_init,
NULL, &pinmux_mcux_porta_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_mcux_driver_api);
#endif
#ifdef CONFIG_PINMUX_MCUX_PORTB
static const struct pinmux_mcux_config pinmux_mcux_portb_config = {
.base = PORTB,
.clock_ip_name = kCLOCK_PortB,
};
DEVICE_AND_API_INIT(pinmux_portb, CONFIG_PINMUX_MCUX_PORTB_NAME,
&pinmux_mcux_init,
NULL, &pinmux_mcux_portb_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_mcux_driver_api);
#endif
#ifdef CONFIG_PINMUX_MCUX_PORTC
static const struct pinmux_mcux_config pinmux_mcux_portc_config = {
.base = PORTC,
.clock_ip_name = kCLOCK_PortC,
};
DEVICE_AND_API_INIT(pinmux_portc, CONFIG_PINMUX_MCUX_PORTC_NAME,
&pinmux_mcux_init,
NULL, &pinmux_mcux_portc_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_mcux_driver_api);
#endif
#ifdef CONFIG_PINMUX_MCUX_PORTD
static const struct pinmux_mcux_config pinmux_mcux_portd_config = {
.base = PORTD,
.clock_ip_name = kCLOCK_PortD,
};
DEVICE_AND_API_INIT(pinmux_portd, CONFIG_PINMUX_MCUX_PORTD_NAME,
&pinmux_mcux_init,
NULL, &pinmux_mcux_portd_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_mcux_driver_api);
#endif
#ifdef CONFIG_PINMUX_MCUX_PORTE
static const struct pinmux_mcux_config pinmux_mcux_porte_config = {
.base = PORTE,
.clock_ip_name = kCLOCK_PortE,
};
DEVICE_AND_API_INIT(pinmux_porte, CONFIG_PINMUX_MCUX_PORTE_NAME,
&pinmux_mcux_init,
NULL, &pinmux_mcux_porte_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_mcux_driver_api);
#endif