pinmux: Move the Freescale FRDM K64F board to the pinmux model
Change-Id: I50cf5fcf00481a3ebac07ced3aa6f7783765934f Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
This commit is contained in:
parent
41529e20e6
commit
a12a25ad00
6 changed files with 26 additions and 69 deletions
|
@ -1,4 +1,3 @@
|
||||||
obj-y += soc_config.o
|
obj-y += soc_config.o
|
||||||
obj-y += soc.o
|
obj-y += soc.o
|
||||||
obj-y += wdog.o
|
obj-y += wdog.o
|
||||||
obj-y += pinmux.o
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <gpio.h>
|
#include <gpio.h>
|
||||||
#include <sys_io.h>
|
#include <sys_io.h>
|
||||||
|
|
||||||
#include <pinmux/pinmux_k64.h>
|
#include <pinmux/frdm_k64f/pinmux_k64.h>
|
||||||
|
|
||||||
#include "gpio_k64.h"
|
#include "gpio_k64.h"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
ccflags-y +=-I$(srctree)/drivers
|
ccflags-y +=-I$(srctree)/drivers
|
||||||
|
|
||||||
obj-$(CONFIG_PINMUX_K64) += pinmux_k64.o
|
obj-$(CONFIG_PINMUX_K64) += frdm_k64f/pinmux_k64.o frdm_k64f/pinmux_board_frdm_k64f.o
|
||||||
obj-$(CONFIG_PINMUX_STM32) += pinmux_stm32.o
|
obj-$(CONFIG_PINMUX_STM32) += pinmux_stm32.o
|
||||||
obj-$(CONFIG_BOARD_ARDUINO_101) += quark_mcu/pinmux_board_arduino_101.o
|
obj-$(CONFIG_BOARD_ARDUINO_101) += quark_mcu/pinmux_board_arduino_101.o
|
||||||
obj-$(CONFIG_BOARD_ARDUINO_DUE) += sam3x/pinmux_board_arduino_due.o
|
obj-$(CONFIG_BOARD_ARDUINO_DUE) += sam3x/pinmux_board_arduino_due.o
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* pinmux.c - pin out mapping for the Freescale FRDM K64F SoC */
|
/* pinmux_board_frdm_k64f.c - pin out mapping for the Freescale FRDM-K64F board */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2016 Intel Corporation
|
* Copyright (c) 2016 Intel Corporation
|
||||||
|
@ -16,16 +16,18 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <board.h>
|
#include <nanokernel.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <gpio.h>
|
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
|
#include <sys_io.h>
|
||||||
#include <pinmux.h>
|
#include <pinmux.h>
|
||||||
#include <pinmux/pinmux.h>
|
#include <pinmux/pinmux.h>
|
||||||
#include <pinmux/pinmux_k64.h>
|
|
||||||
#include <pwm.h>
|
|
||||||
|
|
||||||
#include "pinmux/pinmux.h"
|
#include "pinmux_k64.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I/O pin configuration
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Number of default pin settings, used for Arduino Rev 3 pinout.
|
* Number of default pin settings, used for Arduino Rev 3 pinout.
|
||||||
|
@ -82,27 +84,16 @@ struct pin_config mux_config[NUM_DFLT_PINS_SET] = {
|
||||||
{ K64_PIN_PTC10, K64_PINMUX_FUNC_ANALOG }, /* ADC1_SE6b/Analog In 5 */
|
{ K64_PIN_PTC10, K64_PINMUX_FUNC_ANALOG }, /* ADC1_SE6b/Analog In 5 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int fsl_frdm_k64f_pin_init(struct device *arg)
|
int fsl_frdm_k64f_pin_init(struct device *arg)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(arg);
|
ARG_UNUSED(arg);
|
||||||
struct device *pmux;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
pmux = device_get_binding(PINMUX_NAME);
|
|
||||||
|
|
||||||
if (!pmux) {
|
|
||||||
return -EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* configure the pins from the default mapping above */
|
/* configure the pins from the default mapping above */
|
||||||
|
for (int i = 0; i < NUM_DFLT_PINS_SET; i++) {
|
||||||
for (i = 0; i < NUM_DFLT_PINS_SET; i++) {
|
_fsl_k64_set_pin(mux_config[i].pin_num, mux_config[i].mode);
|
||||||
pinmux_pin_set(pmux, mux_config[i].pin_num, mux_config[i].mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEVICE_INIT(frdm_k64f_pmux, "", fsl_frdm_k64f_pin_init, NULL, NULL,
|
SYS_INIT(fsl_frdm_k64f_pin_init, SECONDARY, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
||||||
SECONDARY, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
|
|
@ -18,20 +18,14 @@
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <nanokernel.h>
|
#include <nanokernel.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <sys_io.h>
|
#include <sys_io.h>
|
||||||
|
|
||||||
#include <pinmux.h>
|
#include <pinmux.h>
|
||||||
#include <i2c.h>
|
|
||||||
#include <gpio.h>
|
|
||||||
#include <pwm.h>
|
|
||||||
|
|
||||||
#include <gpio/gpio_k64.h>
|
|
||||||
#include <pinmux/pinmux.h>
|
#include <pinmux/pinmux.h>
|
||||||
#include <pinmux/pinmux_k64.h>
|
|
||||||
|
#include "pinmux_k64.h"
|
||||||
|
|
||||||
/* port pin number conversion from pin ID */
|
/* port pin number conversion from pin ID */
|
||||||
#define PIN_FROM_ID(pin_id) (pin_id % K64_PINMUX_NUM_PINS)
|
#define PIN_FROM_ID(pin_id) (pin_id % K64_PINMUX_NUM_PINS)
|
||||||
|
@ -89,9 +83,11 @@ static inline int config_port_e(mem_addr_t *addr)
|
||||||
static int _fsl_k64_get_port_addr(uint8_t pin_id, mem_addr_t *port_addr_ptr)
|
static int _fsl_k64_get_port_addr(uint8_t pin_id, mem_addr_t *port_addr_ptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* determine the port base address associated with the pin identifier */
|
/* determine the port base address associated with the
|
||||||
|
* pin identifier
|
||||||
|
*/
|
||||||
|
|
||||||
if (pin_id < K64_PIN_PTB0) { /* Port A pin */
|
if (pin_id < K64_PIN_PTB0) { /* Port A pin */
|
||||||
|
|
||||||
return config_port_a(port_addr_ptr);
|
return config_port_a(port_addr_ptr);
|
||||||
|
|
||||||
|
@ -115,8 +111,7 @@ static int _fsl_k64_get_port_addr(uint8_t pin_id, mem_addr_t *port_addr_ptr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _fsl_k64_set_pin(struct device *dev, uint32_t pin_id,
|
int _fsl_k64_set_pin(uint32_t pin_id, uint32_t func)
|
||||||
uint32_t func)
|
|
||||||
{
|
{
|
||||||
mem_addr_t port_base_addr;
|
mem_addr_t port_base_addr;
|
||||||
uint8_t port_pin;
|
uint8_t port_pin;
|
||||||
|
@ -142,8 +137,7 @@ static int _fsl_k64_set_pin(struct device *dev, uint32_t pin_id,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _fsl_k64_get_pin(struct device *dev, uint32_t pin_id,
|
int _fsl_k64_get_pin(uint32_t pin_id, uint32_t *func)
|
||||||
uint32_t *func)
|
|
||||||
{
|
{
|
||||||
mem_addr_t port_base_addr;
|
mem_addr_t port_base_addr;
|
||||||
uint8_t port_pin;
|
uint8_t port_pin;
|
||||||
|
@ -167,35 +161,3 @@ static int _fsl_k64_get_pin(struct device *dev, uint32_t pin_id,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fsl_k64_dev_set(struct device *dev, uint32_t pin,
|
|
||||||
uint32_t func)
|
|
||||||
{
|
|
||||||
return _fsl_k64_set_pin(dev, pin, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int fsl_k64_dev_get(struct device *dev, uint32_t pin, uint32_t *func)
|
|
||||||
{
|
|
||||||
return _fsl_k64_get_pin(dev, pin, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct pinmux_driver_api api_funcs = {
|
|
||||||
.set = fsl_k64_dev_set,
|
|
||||||
.get = fsl_k64_dev_get
|
|
||||||
};
|
|
||||||
|
|
||||||
int pinmux_fsl_k64_initialize(struct device *port)
|
|
||||||
{
|
|
||||||
port->driver_api = &api_funcs;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct pinmux_config fsl_k64_pmux = {
|
|
||||||
.base_address = 0x00000000,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* must be initialized after GPIO */
|
|
||||||
DEVICE_INIT(pmux, PINMUX_NAME, &pinmux_fsl_k64_initialize,
|
|
||||||
NULL, &fsl_k64_pmux,
|
|
||||||
SECONDARY, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
|
|
@ -280,4 +280,9 @@
|
||||||
#define K64_PIN_PTE30 158
|
#define K64_PIN_PTE30 158
|
||||||
#define K64_PIN_PTE31 159
|
#define K64_PIN_PTE31 159
|
||||||
|
|
||||||
|
int _fsl_k64_set_pin(uint32_t pin_id, uint32_t func);
|
||||||
|
|
||||||
|
int _fsl_k64_get_pin(uint32_t pin_id, uint32_t *func);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __INCLUDE_PINMUX_K64_H */
|
#endif /* __INCLUDE_PINMUX_K64_H */
|
Loading…
Add table
Add a link
Reference in a new issue