pinmux: Introduce new ksdk pinmux driver

Kinetis SoCs contain one or more PORT modules to handle pin muxing and
pin configuration. Unlike the existing k64 pinmux driver, this driver
handles each PORT module individually and can be used for other Kinetis
SoCs.

This driver uses KSDK CMSIS register accesses to the PORT module rather
than the KSDK PORT driver (fsl_port.h), because the Zephyr pinmux
interface contains both set() and get() functions to access the pin
configuration. The KSDK PORT driver only contains a set() function
(which is a very thin static inline function to modify the PCR
register), therefore building a shim on top of it would result in a
strange mix of using the KSDK PORT driver for the set() and a direct
CMSIS register access for the get().

Jira: ZEP-1393
Change-Id: I2f7c6b08b207350697d590dcd665223f81de9f9e
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
Maureen Helm 2016-11-23 09:10:03 -06:00 committed by Anas Nashif
commit a4e823eee0
9 changed files with 316 additions and 1 deletions

View file

@ -56,6 +56,8 @@ config PINMUX_K64
help help
Enable driver for Freescale K64-based Pin multiplexer. Enable driver for Freescale K64-based Pin multiplexer.
source "drivers/pinmux/Kconfig.ksdk"
source "drivers/pinmux/Kconfig.stm32" source "drivers/pinmux/Kconfig.stm32"
source "drivers/pinmux/Kconfig.beetle" source "drivers/pinmux/Kconfig.beetle"

View file

@ -0,0 +1,57 @@
# Kconfig - Kinetis SDK pinmux
#
# Copyright (c) 2016, Freescale Semiconductor, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
menuconfig PINMUX_KSDK
bool "KSDK pinmux driver"
depends on HAS_KSDK
default n
help
Enable the KSDK pinmux driver.
if PINMUX_KSDK
config PINMUX_KSDK_PORTA
bool "Port A"
default n
help
Enable Port A.
config PINMUX_KSDK_PORTB
bool "Port B"
default n
help
Enable Port B.
config PINMUX_KSDK_PORTC
bool "Port C"
default n
help
Enable Port C.
config PINMUX_KSDK_PORTD
bool "Port D"
default n
help
Enable Port D.
config PINMUX_KSDK_PORTE
bool "Port E"
default n
help
Enable Port E.
endif # PINMUX_KSDK

View file

@ -1,9 +1,12 @@
ccflags-y +=-I$(srctree)/drivers ccflags-y +=-I$(srctree)/drivers
# Board initialization # Board initialization
obj-$(CONFIG_PINMUX_K64) += k64/pinmux.o ifdef CONFIG_PINMUX_K64
obj-y += k64/pinmux.o
obj-$(CONFIG_BOARD_FRDM_K64F) += k64/pinmux_board_frdm_k64f.o obj-$(CONFIG_BOARD_FRDM_K64F) += k64/pinmux_board_frdm_k64f.o
obj-$(CONFIG_BOARD_HEXIWEAR_K64) += k64/pinmux_board_hexiwear.o obj-$(CONFIG_BOARD_HEXIWEAR_K64) += k64/pinmux_board_hexiwear.o
endif
obj-$(CONFIG_PINMUX_KSDK) += pinmux_ksdk.o
obj-$(CONFIG_PINMUX_STM32) += stm32/pinmux_stm32.o obj-$(CONFIG_PINMUX_STM32) += stm32/pinmux_stm32.o
obj-$(CONFIG_PINMUX_BEETLE) += beetle/pinmux_board_v2m_beetle.o obj-$(CONFIG_PINMUX_BEETLE) += beetle/pinmux_board_v2m_beetle.o
obj-$(CONFIG_BOARD_NUCLEO_F103RB) += stm32/pinmux_board_nucleo_f103rb.o obj-$(CONFIG_BOARD_NUCLEO_F103RB) += stm32/pinmux_board_nucleo_f103rb.o

View file

@ -75,3 +75,5 @@ config PINMUX_DEV_ARM_V2M_BEETLE
Enables the pinmux dev driver for boards based on the Enables the pinmux dev driver for boards based on the
ARM Beetle SoC MCUs. ARM Beetle SoC MCUs.
default n default n
source "drivers/pinmux/dev/Kconfig.ksdk"

View file

@ -0,0 +1,52 @@
# Kconfig - Kinetis SDK pinmux dev
#
# Copyright (c) 2016, Freescale Semiconductor, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
menuconfig PINMUX_DEV_KSDK
bool "KSDK pinmux dev driver"
depends on PINMUX_DEV && PINMUX_KSDK
default n
help
Enable the KSDK pinmux dev driver.
if PINMUX_DEV_KSDK
config PINMUX_DEV_KSDK_PORTA_NAME
string "Pinmux Dev Port A driver name"
depends on PINMUX_KSDK_PORTA
default "pinmux_dev_porta"
config PINMUX_DEV_KSDK_PORTB_NAME
string "Pinmux Dev Port B driver name"
depends on PINMUX_KSDK_PORTB
default "pinmux_dev_portb"
config PINMUX_DEV_KSDK_PORTC_NAME
string "Pinmux Dev Port C driver name"
depends on PINMUX_KSDK_PORTC
default "pinmux_dev_portc"
config PINMUX_DEV_KSDK_PORTD_NAME
string "Pinmux Dev Port D driver name"
depends on PINMUX_KSDK_PORTD
default "pinmux_dev_portd"
config PINMUX_DEV_KSDK_PORTE_NAME
string "Pinmux Dev Port E driver name"
depends on PINMUX_KSDK_PORTE
default "pinmux_dev_porte"
endif # PINMUX_DEV_KSDK

View file

@ -4,6 +4,7 @@ ccflags-$(CONFIG_PINMUX_DEV_QMSI) += -I$(CONFIG_QMSI_INSTALL_PATH)/include
obj-$(CONFIG_PINMUX_DEV_ATMEL_SAM3X) += pinmux_dev_atmel_sam3x.o obj-$(CONFIG_PINMUX_DEV_ATMEL_SAM3X) += pinmux_dev_atmel_sam3x.o
obj-$(CONFIG_PINMUX_DEV_K64) += pinmux_dev_k64.o obj-$(CONFIG_PINMUX_DEV_K64) += pinmux_dev_k64.o
obj-$(CONFIG_PINMUX_DEV_KSDK) += pinmux_dev_ksdk.o
obj-$(CONFIG_PINMUX_DEV_QMSI) += pinmux_dev_qmsi.o obj-$(CONFIG_PINMUX_DEV_QMSI) += pinmux_dev_qmsi.o
obj-$(CONFIG_PINMUX_DEV_STM32) += pinmux_dev_stm32.o obj-$(CONFIG_PINMUX_DEV_STM32) += pinmux_dev_stm32.o
obj-$(CONFIG_PINMUX_DEV_ARM_V2M_BEETLE) += pinmux_dev_arm_beetle.o obj-$(CONFIG_PINMUX_DEV_ARM_V2M_BEETLE) += pinmux_dev_arm_beetle.o

View file

@ -0,0 +1,122 @@
/*
* Copyright (c) 2016 Freescale Semiconductor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <errno.h>
#include <device.h>
#include <pinmux.h>
#include <pinmux/pinmux_ksdk.h>
struct pinmux_dev_ksdk_config {
PORT_Type *base;
};
static int pinmux_dev_ksdk_set(struct device *dev, uint32_t pin, uint32_t func)
{
const struct pinmux_dev_ksdk_config *config = dev->config->config_info;
return pinmux_ksdk_set(config->base, pin, func);
}
static int pinmux_dev_ksdk_get(struct device *dev, uint32_t pin, uint32_t *func)
{
const struct pinmux_dev_ksdk_config *config = dev->config->config_info;
return pinmux_ksdk_get(config->base, pin, func);
}
static int pinmux_dev_ksdk_pullup(struct device *dev, uint32_t pin,
uint8_t func)
{
return -ENOTSUP;
}
static int pinmux_dev_ksdk_input(struct device *dev, uint32_t pin,
uint8_t func)
{
return -ENOTSUP;
}
static const struct pinmux_driver_api pinmux_dev_ksdk_driver_api = {
.set = pinmux_dev_ksdk_set,
.get = pinmux_dev_ksdk_get,
.pullup = pinmux_dev_ksdk_pullup,
.input = pinmux_dev_ksdk_input,
};
static int pinmux_dev_ksdk_init(struct device *dev)
{
return 0;
}
#ifdef CONFIG_PINMUX_KSDK_PORTA
static const struct pinmux_dev_ksdk_config pinmux_dev_ksdk_porta_config = {
.base = PORTA,
};
DEVICE_AND_API_INIT(pinmux_dev_porta, CONFIG_PINMUX_DEV_KSDK_PORTA_NAME,
&pinmux_dev_ksdk_init,
NULL, &pinmux_dev_ksdk_porta_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_dev_ksdk_driver_api);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTB
static const struct pinmux_dev_ksdk_config pinmux_dev_ksdk_portb_config = {
.base = PORTB,
};
DEVICE_AND_API_INIT(pinmux_dev_portb, CONFIG_PINMUX_DEV_KSDK_PORTB_NAME,
&pinmux_dev_ksdk_init,
NULL, &pinmux_dev_ksdk_portb_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_dev_ksdk_driver_api);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTC
static const struct pinmux_dev_ksdk_config pinmux_dev_ksdk_portc_config = {
.base = PORTC,
};
DEVICE_AND_API_INIT(pinmux_dev_portc, CONFIG_PINMUX_DEV_KSDK_PORTC_NAME,
&pinmux_dev_ksdk_init,
NULL, &pinmux_dev_ksdk_portc_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_dev_ksdk_driver_api);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTD
static const struct pinmux_dev_ksdk_config pinmux_dev_ksdk_portd_config = {
.base = PORTD,
};
DEVICE_AND_API_INIT(pinmux_dev_portd, CONFIG_PINMUX_DEV_KSDK_PORTD_NAME,
&pinmux_dev_ksdk_init,
NULL, &pinmux_dev_ksdk_portd_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_dev_ksdk_driver_api);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTE
static const struct pinmux_dev_ksdk_config pinmux_dev_ksdk_porte_config = {
.base = PORTE,
};
DEVICE_AND_API_INIT(pinmux_dev_porte, CONFIG_PINMUX_DEV_KSDK_PORTE_NAME,
&pinmux_dev_ksdk_init,
NULL, &pinmux_dev_ksdk_porte_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
&pinmux_dev_ksdk_driver_api);
#endif

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2016 Freescale Semiconductor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <pinmux/pinmux_ksdk.h>
#include <fsl_common.h>
#include <fsl_clock.h>
int pinmux_ksdk_init(void)
{
#ifdef CONFIG_PINMUX_KSDK_PORTA
CLOCK_EnableClock(kCLOCK_PortA);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTB
CLOCK_EnableClock(kCLOCK_PortB);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTC
CLOCK_EnableClock(kCLOCK_PortC);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTD
CLOCK_EnableClock(kCLOCK_PortD);
#endif
#ifdef CONFIG_PINMUX_KSDK_PORTE
CLOCK_EnableClock(kCLOCK_PortE);
#endif
return 0;
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2016 Freescale Semiconductor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __INCLUDE_PINMUX_KSDK_H
#define __INCLUDE_PINMUX_KSDK_H
#include <device.h>
#include <fsl_port.h>
int pinmux_ksdk_init(void);
static inline int pinmux_ksdk_set(PORT_Type *base, uint32_t pin, uint32_t func)
{
base->PCR[pin] = func;
return 0;
}
static inline int pinmux_ksdk_get(PORT_Type *base, uint32_t pin, uint32_t *func)
{
*func = base->PCR[pin];
return 0;
}
#endif /* __INCLUDE_PINMUX_KSDK_H */