gpio: Refactor the mcux gpio driver to use dts

Get the driver name, base address, irq number, and irq priority from
dts.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
This commit is contained in:
Maureen Helm 2018-04-19 13:09:04 -05:00 committed by Kumar Gala
commit 4e8f29f319
4 changed files with 34 additions and 84 deletions

View file

@ -56,7 +56,7 @@ static int hexiwear_k64_pinmux_init(struct device *dev)
/* 3V3B_EN */
pinmux_pin_set(portb, 12, PORT_PCR_MUX(kPORT_MuxAsGpio));
struct device *gpiob = device_get_binding(CONFIG_GPIO_MCUX_PORTB_NAME);
struct device *gpiob = device_get_binding(GPIO_B_LABEL);
gpio_pin_configure(gpiob, 12, GPIO_DIR_OUT);
gpio_pin_write(gpiob, 12, 0);
@ -91,7 +91,7 @@ static int hexiwear_k64_pinmux_init(struct device *dev)
/* LDO - MAX30101 power supply */
pinmux_pin_set(porta, 29, PORT_PCR_MUX(kPORT_MuxAsGpio));
struct device *gpioa = device_get_binding(CONFIG_GPIO_MCUX_PORTA_NAME);
struct device *gpioa = device_get_binding(GPIO_A_LABEL);
gpio_pin_configure(gpioa, 29, GPIO_DIR_OUT);
gpio_pin_write(gpioa, 29, 1);
@ -100,7 +100,7 @@ static int hexiwear_k64_pinmux_init(struct device *dev)
#ifdef CONFIG_BATTERY_SENSE
pinmux_pin_set(portc, 14, PORT_PCR_MUX(kPORT_MuxAsGpio));
struct device *gpioc = device_get_binding(CONFIG_GPIO_MCUX_PORTC_NAME);
struct device *gpioc = device_get_binding(GPIO_C_LABEL);
gpio_pin_configure(gpioc, 14, GPIO_DIR_OUT);
gpio_pin_write(gpioc, 14, 0);

View file

@ -22,16 +22,6 @@ config GPIO_MCUX_PORTA
help
Enable Port A.
config GPIO_MCUX_PORTA_NAME
string "Port A driver name"
depends on GPIO_MCUX_PORTA
default "GPIO_0"
config GPIO_MCUX_PORTA_PRI
int "Port A interrupt priority"
depends on GPIO_MCUX_PORTA
default 2
config GPIO_MCUX_PORTB
bool "Port B"
depends on PINMUX_MCUX_PORTB
@ -39,16 +29,6 @@ config GPIO_MCUX_PORTB
help
Enable Port B.
config GPIO_MCUX_PORTB_NAME
string "Port B driver name"
depends on GPIO_MCUX_PORTB
default "GPIO_1"
config GPIO_MCUX_PORTB_PRI
int "Port B interrupt priority"
depends on GPIO_MCUX_PORTB
default 2
config GPIO_MCUX_PORTC
bool "Port C"
depends on PINMUX_MCUX_PORTC
@ -56,16 +36,6 @@ config GPIO_MCUX_PORTC
help
Enable Port C.
config GPIO_MCUX_PORTC_NAME
string "Port C driver name"
depends on GPIO_MCUX_PORTC
default "GPIO_2"
config GPIO_MCUX_PORTC_PRI
int "Port C interrupt priority"
depends on GPIO_MCUX_PORTC
default 2
config GPIO_MCUX_PORTD
bool "Port D"
depends on PINMUX_MCUX_PORTD
@ -73,16 +43,6 @@ config GPIO_MCUX_PORTD
help
Enable Port D.
config GPIO_MCUX_PORTD_NAME
string "Port D driver name"
depends on GPIO_MCUX_PORTD
default "GPIO_3"
config GPIO_MCUX_PORTD_PRI
int "Port D interrupt priority"
depends on GPIO_MCUX_PORTD
default 2
config GPIO_MCUX_PORTE
bool "Port E"
depends on PINMUX_MCUX_PORTE
@ -90,14 +50,4 @@ config GPIO_MCUX_PORTE
help
Enable Port E.
config GPIO_MCUX_PORTE_NAME
string "Port E driver name"
depends on GPIO_MCUX_PORTE
default "GPIO_4"
config GPIO_MCUX_PORTE_PRI
int "Port E interrupt priority"
depends on GPIO_MCUX_PORTE
default 2
endif # GPIO_MCUX

View file

@ -237,9 +237,9 @@ static const struct gpio_driver_api gpio_mcux_driver_api = {
static int gpio_mcux_porta_init(struct device *dev);
static const struct gpio_mcux_config gpio_mcux_porta_config = {
.gpio_base = GPIOA,
.gpio_base = (GPIO_Type *) GPIO_A_BASE_ADDRESS,
.port_base = PORTA,
#ifdef IRQ_GPIO_PORTA
#ifdef GPIO_A_IRQ
.flags = GPIO_INT,
#else
.flags = 0,
@ -248,7 +248,7 @@ static const struct gpio_mcux_config gpio_mcux_porta_config = {
static struct gpio_mcux_data gpio_mcux_porta_data;
DEVICE_AND_API_INIT(gpio_mcux_porta, CONFIG_GPIO_MCUX_PORTA_NAME,
DEVICE_AND_API_INIT(gpio_mcux_porta, GPIO_A_LABEL,
gpio_mcux_porta_init,
&gpio_mcux_porta_data, &gpio_mcux_porta_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
@ -256,11 +256,11 @@ DEVICE_AND_API_INIT(gpio_mcux_porta, CONFIG_GPIO_MCUX_PORTA_NAME,
static int gpio_mcux_porta_init(struct device *dev)
{
#ifdef IRQ_GPIO_PORTA
IRQ_CONNECT(IRQ_GPIO_PORTA, CONFIG_GPIO_MCUX_PORTA_PRI,
#ifdef GPIO_A_IRQ
IRQ_CONNECT(GPIO_A_IRQ, GPIO_A_IRQ_PRIORITY,
gpio_mcux_port_isr, DEVICE_GET(gpio_mcux_porta), 0);
irq_enable(IRQ_GPIO_PORTA);
irq_enable(GPIO_A_IRQ);
return 0;
#else
@ -273,9 +273,9 @@ static int gpio_mcux_porta_init(struct device *dev)
static int gpio_mcux_portb_init(struct device *dev);
static const struct gpio_mcux_config gpio_mcux_portb_config = {
.gpio_base = GPIOB,
.gpio_base = (GPIO_Type *) GPIO_B_BASE_ADDRESS,
.port_base = PORTB,
#ifdef IRQ_GPIO_PORTB
#ifdef GPIO_B_IRQ
.flags = GPIO_INT,
#else
.flags = 0,
@ -284,7 +284,7 @@ static const struct gpio_mcux_config gpio_mcux_portb_config = {
static struct gpio_mcux_data gpio_mcux_portb_data;
DEVICE_AND_API_INIT(gpio_mcux_portb, CONFIG_GPIO_MCUX_PORTB_NAME,
DEVICE_AND_API_INIT(gpio_mcux_portb, GPIO_B_LABEL,
gpio_mcux_portb_init,
&gpio_mcux_portb_data, &gpio_mcux_portb_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
@ -292,11 +292,11 @@ DEVICE_AND_API_INIT(gpio_mcux_portb, CONFIG_GPIO_MCUX_PORTB_NAME,
static int gpio_mcux_portb_init(struct device *dev)
{
#ifdef IRQ_GPIO_PORTB
IRQ_CONNECT(IRQ_GPIO_PORTB, CONFIG_GPIO_MCUX_PORTB_PRI,
#ifdef GPIO_B_IRQ
IRQ_CONNECT(GPIO_B_IRQ, GPIO_B_IRQ_PRIORITY,
gpio_mcux_port_isr, DEVICE_GET(gpio_mcux_portb), 0);
irq_enable(IRQ_GPIO_PORTB);
irq_enable(GPIO_B_IRQ);
return 0;
#else
@ -309,9 +309,9 @@ static int gpio_mcux_portb_init(struct device *dev)
static int gpio_mcux_portc_init(struct device *dev);
static const struct gpio_mcux_config gpio_mcux_portc_config = {
.gpio_base = GPIOC,
.gpio_base = (GPIO_Type *) GPIO_C_BASE_ADDRESS,
.port_base = PORTC,
#ifdef IRQ_GPIO_PORTC
#ifdef GPIO_C_IRQ
.flags = GPIO_INT,
#else
.flags = 0,
@ -320,7 +320,7 @@ static const struct gpio_mcux_config gpio_mcux_portc_config = {
static struct gpio_mcux_data gpio_mcux_portc_data;
DEVICE_AND_API_INIT(gpio_mcux_portc, CONFIG_GPIO_MCUX_PORTC_NAME,
DEVICE_AND_API_INIT(gpio_mcux_portc, GPIO_C_LABEL,
gpio_mcux_portc_init,
&gpio_mcux_portc_data, &gpio_mcux_portc_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
@ -328,11 +328,11 @@ DEVICE_AND_API_INIT(gpio_mcux_portc, CONFIG_GPIO_MCUX_PORTC_NAME,
static int gpio_mcux_portc_init(struct device *dev)
{
#ifdef IRQ_GPIO_PORTC
IRQ_CONNECT(IRQ_GPIO_PORTC, CONFIG_GPIO_MCUX_PORTC_PRI,
#ifdef GPIO_C_IRQ
IRQ_CONNECT(GPIO_C_IRQ, GPIO_C_IRQ_PRIORITY,
gpio_mcux_port_isr, DEVICE_GET(gpio_mcux_portc), 0);
irq_enable(IRQ_GPIO_PORTC);
irq_enable(GPIO_C_IRQ);
return 0;
#else
@ -345,9 +345,9 @@ static int gpio_mcux_portc_init(struct device *dev)
static int gpio_mcux_portd_init(struct device *dev);
static const struct gpio_mcux_config gpio_mcux_portd_config = {
.gpio_base = GPIOD,
.gpio_base = (GPIO_Type *) GPIO_D_BASE_ADDRESS,
.port_base = PORTD,
#ifdef IRQ_GPIO_PORTD
#ifdef GPIO_D_IRQ
.flags = GPIO_INT,
#else
.flags = 0,
@ -356,7 +356,7 @@ static const struct gpio_mcux_config gpio_mcux_portd_config = {
static struct gpio_mcux_data gpio_mcux_portd_data;
DEVICE_AND_API_INIT(gpio_mcux_portd, CONFIG_GPIO_MCUX_PORTD_NAME,
DEVICE_AND_API_INIT(gpio_mcux_portd, GPIO_D_LABEL,
gpio_mcux_portd_init,
&gpio_mcux_portd_data, &gpio_mcux_portd_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
@ -364,11 +364,11 @@ DEVICE_AND_API_INIT(gpio_mcux_portd, CONFIG_GPIO_MCUX_PORTD_NAME,
static int gpio_mcux_portd_init(struct device *dev)
{
#ifdef IRQ_GPIO_PORTD
IRQ_CONNECT(IRQ_GPIO_PORTD, CONFIG_GPIO_MCUX_PORTD_PRI,
#ifdef GPIO_D_IRQ
IRQ_CONNECT(GPIO_D_IRQ, GPIO_D_IRQ_PRIORITY,
gpio_mcux_port_isr, DEVICE_GET(gpio_mcux_portd), 0);
irq_enable(IRQ_GPIO_PORTD);
irq_enable(GPIO_D_IRQ);
return 0;
#else
@ -381,9 +381,9 @@ static int gpio_mcux_portd_init(struct device *dev)
static int gpio_mcux_porte_init(struct device *dev);
static const struct gpio_mcux_config gpio_mcux_porte_config = {
.gpio_base = GPIOE,
.gpio_base = (GPIO_Type *) GPIO_E_BASE_ADDRESS,
.port_base = PORTE,
#ifdef IRQ_GPIO_PORTE
#ifdef GPIO_E_IRQ
.flags = GPIO_INT,
#else
.flags = 0,
@ -392,7 +392,7 @@ static const struct gpio_mcux_config gpio_mcux_porte_config = {
static struct gpio_mcux_data gpio_mcux_porte_data;
DEVICE_AND_API_INIT(gpio_mcux_porte, CONFIG_GPIO_MCUX_PORTE_NAME,
DEVICE_AND_API_INIT(gpio_mcux_porte, GPIO_E_LABEL,
gpio_mcux_porte_init,
&gpio_mcux_porte_data, &gpio_mcux_porte_config,
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
@ -400,11 +400,11 @@ DEVICE_AND_API_INIT(gpio_mcux_porte, CONFIG_GPIO_MCUX_PORTE_NAME,
static int gpio_mcux_porte_init(struct device *dev)
{
#ifdef IRQ_GPIO_PORTE
IRQ_CONNECT(IRQ_GPIO_PORTE, CONFIG_GPIO_MCUX_PORTE_PRI,
#ifdef GPIO_E_IRQ
IRQ_CONNECT(GPIO_E_IRQ, GPIO_E_IRQ_PRIORITY,
gpio_mcux_port_isr, DEVICE_GET(gpio_mcux_porte), 0);
irq_enable(IRQ_GPIO_PORTE);
irq_enable(GPIO_E_IRQ);
return 0;
#else

View file

@ -16,7 +16,7 @@
#include <ieee802154/cc2520.h>
#include <gpio.h>
#define CC2520_GPIO_DEV_NAME CONFIG_GPIO_MCUX_PORTC_NAME
#define CC2520_GPIO_DEV_NAME GPIO_C_LABEL
#define CC2520_GPIO_VREG_EN 12 /* PTC12 */
#define CC2520_GPIO_RESET 3 /* PTC3 */