2015-11-03 08:52:12 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016, Wind River Systems, 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file Driver for the Freescale K64 GPIO module.
|
|
|
|
*/
|
|
|
|
|
2016-03-09 14:54:42 -03:00
|
|
|
#include <errno.h>
|
|
|
|
|
2015-11-03 08:52:12 -05:00
|
|
|
#include <nanokernel.h>
|
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <gpio.h>
|
2016-03-25 15:27:54 -07:00
|
|
|
#include <soc.h>
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
#include <sys_io.h>
|
2016-10-09 09:56:23 -05:00
|
|
|
#include <pinmux/k64/pinmux.h>
|
2015-11-03 08:52:12 -05:00
|
|
|
|
|
|
|
#include "gpio_k64.h"
|
2016-03-23 12:01:06 +01:00
|
|
|
#include "gpio_utils.h"
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
static int gpio_k64_config(struct device *dev,
|
|
|
|
int access_op, uint32_t pin, int flags)
|
2015-11-03 08:52:12 -05:00
|
|
|
{
|
|
|
|
const struct gpio_k64_config * const cfg = dev->config->config_info;
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
uint32_t value;
|
|
|
|
uint32_t setting;
|
|
|
|
uint8_t i;
|
|
|
|
|
|
|
|
/* check for an invalid pin configuration */
|
2015-12-11 13:23:10 -05:00
|
|
|
if (((flags & GPIO_INT) && (flags & GPIO_DIR_OUT)) ||
|
2016-03-23 10:53:04 +01:00
|
|
|
((flags & GPIO_DIR_IN) && (flags & GPIO_DIR_OUT))) {
|
2016-03-09 14:54:42 -03:00
|
|
|
return -ENOTSUP;
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
}
|
2015-11-03 08:52:12 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup direction register:
|
|
|
|
* 0 - pin is input, 1 - pin is output
|
|
|
|
*/
|
|
|
|
if (access_op == GPIO_ACCESS_BY_PIN) {
|
|
|
|
if ((flags & GPIO_DIR_MASK) == GPIO_DIR_IN) {
|
2016-03-23 10:53:04 +01:00
|
|
|
sys_clear_bit((cfg->gpio_base_addr +
|
|
|
|
GPIO_K64_DIR_OFFSET), pin);
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
} else { /* GPIO_DIR_OUT */
|
2016-03-23 10:53:04 +01:00
|
|
|
sys_set_bit((cfg->gpio_base_addr +
|
|
|
|
GPIO_K64_DIR_OFFSET), pin);
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
} else { /* GPIO_ACCESS_BY_PORT */
|
|
|
|
if ((flags & GPIO_DIR_MASK) == GPIO_DIR_IN) {
|
|
|
|
value = 0x0;
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
} else { /* GPIO_DIR_OUT */
|
2015-11-03 08:52:12 -05:00
|
|
|
value = 0xFFFFFFFF;
|
|
|
|
}
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
sys_write32(value, (cfg->gpio_base_addr + GPIO_K64_DIR_OFFSET));
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
}
|
2015-11-03 08:52:12 -05:00
|
|
|
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
/*
|
|
|
|
* Set up pullup/pulldown configuration, in Port Control module:
|
|
|
|
*/
|
|
|
|
if ((flags & GPIO_PUD_MASK) == GPIO_PUD_PULL_UP) {
|
|
|
|
setting = (K64_PINMUX_PULL_ENABLE | K64_PINMUX_PULL_UP);
|
|
|
|
} else if ((flags & GPIO_PUD_MASK) == GPIO_PUD_PULL_DOWN) {
|
|
|
|
setting = (K64_PINMUX_PULL_ENABLE | K64_PINMUX_PULL_DN);
|
|
|
|
} else if ((flags & GPIO_PUD_MASK) == GPIO_PUD_NORMAL) {
|
|
|
|
setting = K64_PINMUX_PULL_DISABLE;
|
|
|
|
} else {
|
2016-03-09 14:54:42 -03:00
|
|
|
return -ENOTSUP;
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
}
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
/*
|
|
|
|
* Set up interrupt configuration, in Port Control module:
|
|
|
|
*/
|
|
|
|
if (flags & GPIO_INT) {
|
|
|
|
/* edge or level */
|
|
|
|
if (flags & GPIO_INT_EDGE) {
|
|
|
|
if (flags & GPIO_INT_ACTIVE_HIGH) {
|
|
|
|
setting |= K64_PINMUX_INT_RISING;
|
|
|
|
} else if (flags & GPIO_INT_DOUBLE_EDGE) {
|
|
|
|
setting |= K64_PINMUX_INT_BOTH_EDGE;
|
|
|
|
} else {
|
|
|
|
setting |= K64_PINMUX_INT_FALLING;
|
|
|
|
}
|
2016-03-23 10:53:04 +01:00
|
|
|
} else { /* GPIO_INT_LEVEL */
|
2015-12-11 13:23:10 -05:00
|
|
|
if (flags & GPIO_INT_ACTIVE_HIGH) {
|
|
|
|
setting |= K64_PINMUX_INT_HIGH;
|
|
|
|
} else {
|
|
|
|
setting |= K64_PINMUX_INT_LOW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write pull-up/-down and, if set, interrupt configuration settings */
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
if (access_op == GPIO_ACCESS_BY_PIN) {
|
2016-03-23 10:53:04 +01:00
|
|
|
value = sys_read32((cfg->port_base_addr +
|
|
|
|
K64_PINMUX_CTRL_OFFSET(pin)));
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
|
|
|
|
/* clear, then set configuration values */
|
|
|
|
value &= ~(K64_PINMUX_PULL_EN_MASK | K64_PINMUX_PULL_SEL_MASK);
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
if (flags & GPIO_INT) {
|
|
|
|
value &= ~K64_PINMUX_INT_MASK;
|
|
|
|
}
|
|
|
|
|
2016-05-03 00:13:32 -03:00
|
|
|
/* Pins must configured as gpio */
|
|
|
|
value |= (setting | K64_PINMUX_FUNC_GPIO);
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
sys_write32(value, (cfg->port_base_addr +
|
|
|
|
K64_PINMUX_CTRL_OFFSET(pin)));
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
} else { /* GPIO_ACCESS_BY_PORT */
|
|
|
|
for (i = 0; i < K64_PINMUX_NUM_PINS; i++) {
|
|
|
|
/* clear, then set configuration values */
|
|
|
|
value = sys_read32((cfg->port_base_addr +
|
2016-03-23 10:53:04 +01:00
|
|
|
K64_PINMUX_CTRL_OFFSET(i)));
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
value &= ~(K64_PINMUX_PULL_EN_MASK |
|
|
|
|
K64_PINMUX_PULL_SEL_MASK);
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
if (flags & GPIO_INT) {
|
|
|
|
value &= ~K64_PINMUX_INT_MASK;
|
|
|
|
}
|
|
|
|
|
2016-05-03 00:13:32 -03:00
|
|
|
/* Pins must configured as gpio */
|
|
|
|
value |= (setting | K64_PINMUX_FUNC_GPIO);
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
sys_write32(value, (cfg->port_base_addr +
|
|
|
|
K64_PINMUX_CTRL_OFFSET(i)));
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
}
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
2016-03-09 14:01:20 -03:00
|
|
|
return 0;
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
static int gpio_k64_write(struct device *dev,
|
|
|
|
int access_op, uint32_t pin, uint32_t value)
|
2015-11-03 08:52:12 -05:00
|
|
|
{
|
|
|
|
const struct gpio_k64_config * const cfg = dev->config->config_info;
|
|
|
|
|
|
|
|
if (access_op == GPIO_ACCESS_BY_PIN) {
|
|
|
|
if (value) {
|
2016-03-23 10:53:04 +01:00
|
|
|
sys_set_bit((cfg->gpio_base_addr +
|
|
|
|
GPIO_K64_DATA_OUT_OFFSET), pin);
|
2015-11-03 08:52:12 -05:00
|
|
|
} else {
|
2016-03-23 10:53:04 +01:00
|
|
|
sys_clear_bit((cfg->gpio_base_addr +
|
|
|
|
GPIO_K64_DATA_OUT_OFFSET), pin);
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
2016-03-23 10:53:04 +01:00
|
|
|
} else { /* GPIO_ACCESS_BY_PORT */
|
|
|
|
sys_write32(value, (cfg->gpio_base_addr +
|
|
|
|
GPIO_K64_DATA_OUT_OFFSET));
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
2016-03-09 14:01:20 -03:00
|
|
|
return 0;
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
static int gpio_k64_read(struct device *dev,
|
|
|
|
int access_op, uint32_t pin, uint32_t *value)
|
2015-11-03 08:52:12 -05:00
|
|
|
{
|
|
|
|
const struct gpio_k64_config * const cfg = dev->config->config_info;
|
|
|
|
|
arm: Freescale K64/FRDM-K64F Pinmux support
K64 pinmux support is created as a normal driver.
As opposed to the Galileo board, the pin configuration options are
defined by the MCU and are not board-specific. Separate
platform/board-specific configuration code uses the pinmux driver for
the default pin settings. For FRDM-K64F, only the Arduino pins (22 of a
possible 160) are set up.
Some of the I/O pins routed to the Arduino header are also configured as
JTAG/SWD signals by default and are used by the OpenSDAv2 debug
interface. Therefore, a PRESERVE_JTAG_IO_PINS config option was created
for the FRDM-K64 platform to prevent the default pin settings from
re-configuring these pins.
The K64 MCU separates pin configuration and control, implemented in the
pinmux driver, from GPIO. This results in some cross referencing
between the K64 GPIO driver and the K64 pinmux driver due to the
dependencies of one on the other.
This pinmux driver also uses the expanded pinmux function/mode parameter
size to describe pin configuration options with bit fields for the K64,
including up to 8 pin functions, plus interrupt, pullup/down, drive
strength, open-drain and slew rate.
The following GCC warnings in the K64 pinmux driver are prevented when not
compiling with 'no-optimization' (-O0):
warning: 'gpio_dev' may be used uninitialized in this function
[-Wmaybe-uninitialized]
Change-Id: Ie5031d18750143bf895883058b3cd55fd9989fd3
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-02-01 17:30:48 -05:00
|
|
|
*value = sys_read32((cfg->gpio_base_addr + GPIO_K64_DATA_IN_OFFSET));
|
2015-11-03 08:52:12 -05:00
|
|
|
|
|
|
|
if (access_op == GPIO_ACCESS_BY_PIN) {
|
2016-03-23 10:53:04 +01:00
|
|
|
*value = (*value & BIT(pin)) >> pin;
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nothing more to do for GPIO_ACCESS_BY_PORT */
|
|
|
|
|
2016-03-09 14:01:20 -03:00
|
|
|
return 0;
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-23 12:01:06 +01:00
|
|
|
static int gpio_k64_manage_callback(struct device *dev,
|
|
|
|
struct gpio_callback *callback, bool set)
|
2015-11-03 08:52:12 -05:00
|
|
|
{
|
2015-12-11 13:23:10 -05:00
|
|
|
struct gpio_k64_data *data = dev->driver_data;
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2016-03-23 12:01:06 +01:00
|
|
|
_gpio_manage_callback(&data->callbacks, callback, set);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-09 14:01:20 -03:00
|
|
|
return 0;
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
static int gpio_k64_enable_callback(struct device *dev,
|
|
|
|
int access_op, uint32_t pin)
|
2015-11-03 08:52:12 -05:00
|
|
|
{
|
2015-12-11 13:23:10 -05:00
|
|
|
struct gpio_k64_data *data = dev->driver_data;
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
if (access_op == GPIO_ACCESS_BY_PIN) {
|
2016-03-23 10:53:04 +01:00
|
|
|
data->pin_callback_enables |= BIT(pin);
|
2015-12-11 13:23:10 -05:00
|
|
|
} else {
|
2016-03-23 12:01:06 +01:00
|
|
|
data->pin_callback_enables = 0xFFFFFFFF;
|
2015-12-11 13:23:10 -05:00
|
|
|
}
|
|
|
|
|
2016-03-09 14:01:20 -03:00
|
|
|
return 0;
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-23 10:53:04 +01:00
|
|
|
static int gpio_k64_disable_callback(struct device *dev,
|
|
|
|
int access_op, uint32_t pin)
|
2015-11-03 08:52:12 -05:00
|
|
|
{
|
2015-12-11 13:23:10 -05:00
|
|
|
struct gpio_k64_data *data = dev->driver_data;
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
if (access_op == GPIO_ACCESS_BY_PIN) {
|
2016-03-23 10:53:04 +01:00
|
|
|
data->pin_callback_enables &= ~BIT(pin);
|
2015-12-11 13:23:10 -05:00
|
|
|
} else {
|
2016-03-23 12:01:06 +01:00
|
|
|
data->pin_callback_enables = 0;
|
2015-12-11 13:23:10 -05:00
|
|
|
}
|
|
|
|
|
2016-03-09 14:01:20 -03:00
|
|
|
return 0;
|
2015-11-03 08:52:12 -05:00
|
|
|
}
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Handler for port interrupts
|
|
|
|
* @param dev Pointer to device structure for driver instance
|
|
|
|
*
|
|
|
|
* @return N/A
|
|
|
|
*/
|
|
|
|
static void gpio_k64_port_isr(void *dev)
|
|
|
|
{
|
|
|
|
struct device *port = (struct device *)dev;
|
|
|
|
struct gpio_k64_data *data = port->driver_data;
|
2016-10-06 15:38:55 +01:00
|
|
|
const struct gpio_k64_config *config = port->config->config_info;
|
2015-12-11 13:23:10 -05:00
|
|
|
mem_addr_t int_status_reg_addr;
|
2016-03-23 12:01:06 +01:00
|
|
|
uint32_t enabled_int, int_status;
|
2015-12-11 13:23:10 -05:00
|
|
|
|
|
|
|
int_status_reg_addr = config->port_base_addr +
|
2016-03-23 10:53:04 +01:00
|
|
|
CONFIG_PORT_K64_INT_STATUS_OFFSET;
|
2015-12-11 13:23:10 -05:00
|
|
|
|
|
|
|
int_status = sys_read32(int_status_reg_addr);
|
2016-03-23 12:01:06 +01:00
|
|
|
enabled_int = int_status & data->pin_callback_enables;
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-23 12:01:06 +01:00
|
|
|
_gpio_fire_callbacks(&data->callbacks, port, enabled_int);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
|
|
|
/* clear the port interrupts */
|
|
|
|
sys_write32(0xFFFFFFFF, int_status_reg_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-10-24 08:21:42 +01:00
|
|
|
static const struct gpio_driver_api gpio_k64_drv_api_funcs = {
|
2015-11-03 08:52:12 -05:00
|
|
|
.config = gpio_k64_config,
|
|
|
|
.write = gpio_k64_write,
|
|
|
|
.read = gpio_k64_read,
|
2016-03-23 12:01:06 +01:00
|
|
|
.manage_callback = gpio_k64_manage_callback,
|
2015-11-03 08:52:12 -05:00
|
|
|
.enable_callback = gpio_k64_enable_callback,
|
|
|
|
.disable_callback = gpio_k64_disable_callback,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialization for Port A */
|
|
|
|
#ifdef CONFIG_GPIO_K64_A
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_A_init(struct device *dev);
|
|
|
|
|
2016-10-19 22:10:12 +01:00
|
|
|
static const struct gpio_k64_config gpio_k64_A_cfg = {
|
2016-03-25 15:27:54 -07:00
|
|
|
.gpio_base_addr = GPIO_K64_A_BASE_ADDR,
|
|
|
|
.port_base_addr = PORT_K64_A_BASE_ADDR,
|
2015-11-03 08:52:12 -05:00
|
|
|
};
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static struct gpio_k64_data gpio_data_A;
|
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
DEVICE_AND_API_INIT(gpio_k64_A, CONFIG_GPIO_K64_A_DEV_NAME, gpio_k64_A_init,
|
|
|
|
&gpio_data_A, &gpio_k64_A_cfg,
|
2016-11-08 11:06:55 -08:00
|
|
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
2016-04-14 09:28:34 -07:00
|
|
|
&gpio_k64_drv_api_funcs);
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_A_init(struct device *dev)
|
|
|
|
{
|
2016-03-25 15:27:54 -07:00
|
|
|
IRQ_CONNECT(GPIO_K64_A_IRQ, CONFIG_GPIO_K64_PORTA_PRI,
|
2016-03-23 10:53:04 +01:00
|
|
|
gpio_k64_port_isr, DEVICE_GET(gpio_k64_A), 0);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-25 15:27:54 -07:00
|
|
|
irq_enable(GPIO_K64_A_IRQ);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
return 0;
|
2015-12-11 13:23:10 -05:00
|
|
|
}
|
|
|
|
|
2015-11-03 08:52:12 -05:00
|
|
|
#endif /* CONFIG_GPIO_K64_A */
|
|
|
|
|
|
|
|
/* Initialization for Port B */
|
|
|
|
#ifdef CONFIG_GPIO_K64_B
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_B_init(struct device *dev);
|
|
|
|
|
2016-10-19 22:10:12 +01:00
|
|
|
static const struct gpio_k64_config gpio_k64_B_cfg = {
|
2016-03-25 15:27:54 -07:00
|
|
|
.gpio_base_addr = GPIO_K64_B_BASE_ADDR,
|
|
|
|
.port_base_addr = PORT_K64_B_BASE_ADDR,
|
2015-11-03 08:52:12 -05:00
|
|
|
};
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static struct gpio_k64_data gpio_data_B;
|
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
DEVICE_AND_API_INIT(gpio_k64_B, CONFIG_GPIO_K64_B_DEV_NAME, gpio_k64_B_init,
|
|
|
|
&gpio_data_B, &gpio_k64_B_cfg,
|
2016-11-08 11:06:55 -08:00
|
|
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
2016-04-14 09:28:34 -07:00
|
|
|
&gpio_k64_drv_api_funcs);
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_B_init(struct device *dev)
|
|
|
|
{
|
2016-03-25 15:27:54 -07:00
|
|
|
IRQ_CONNECT(GPIO_K64_B_IRQ, CONFIG_GPIO_K64_PORTB_PRI,
|
2016-03-23 10:53:04 +01:00
|
|
|
gpio_k64_port_isr, DEVICE_GET(gpio_k64_B), 0);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-25 15:27:54 -07:00
|
|
|
irq_enable(GPIO_K64_B_IRQ);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
return 0;
|
2015-12-11 13:23:10 -05:00
|
|
|
}
|
|
|
|
|
2015-11-03 08:52:12 -05:00
|
|
|
#endif /* CONFIG_GPIO_K64_B */
|
|
|
|
|
|
|
|
/* Initialization for Port C */
|
|
|
|
#ifdef CONFIG_GPIO_K64_C
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_C_init(struct device *dev);
|
|
|
|
|
2016-10-19 22:10:12 +01:00
|
|
|
static const struct gpio_k64_config gpio_k64_C_cfg = {
|
2016-03-25 15:27:54 -07:00
|
|
|
.gpio_base_addr = GPIO_K64_C_BASE_ADDR,
|
|
|
|
.port_base_addr = PORT_K64_C_BASE_ADDR,
|
2015-11-03 08:52:12 -05:00
|
|
|
};
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static struct gpio_k64_data gpio_data_C;
|
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
DEVICE_AND_API_INIT(gpio_k64_C, CONFIG_GPIO_K64_C_DEV_NAME, gpio_k64_C_init,
|
|
|
|
&gpio_data_C, &gpio_k64_C_cfg,
|
2016-11-08 11:06:55 -08:00
|
|
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
2016-04-14 09:28:34 -07:00
|
|
|
&gpio_k64_drv_api_funcs);
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_C_init(struct device *dev)
|
|
|
|
{
|
2016-03-25 15:27:54 -07:00
|
|
|
IRQ_CONNECT(GPIO_K64_C_IRQ, CONFIG_GPIO_K64_PORTC_PRI,
|
2016-03-23 10:53:04 +01:00
|
|
|
gpio_k64_port_isr, DEVICE_GET(gpio_k64_C), 0);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-25 15:27:54 -07:00
|
|
|
irq_enable(GPIO_K64_C_IRQ);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
return 0;
|
2015-12-11 13:23:10 -05:00
|
|
|
}
|
|
|
|
|
2015-11-03 08:52:12 -05:00
|
|
|
#endif /* CONFIG_GPIO_K64_C */
|
|
|
|
|
|
|
|
/* Initialization for Port D */
|
|
|
|
#ifdef CONFIG_GPIO_K64_D
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_D_init(struct device *dev);
|
|
|
|
|
2016-10-19 22:10:12 +01:00
|
|
|
static const struct gpio_k64_config gpio_k64_D_cfg = {
|
2016-03-25 15:27:54 -07:00
|
|
|
.gpio_base_addr = GPIO_K64_D_BASE_ADDR,
|
|
|
|
.port_base_addr = PORT_K64_D_BASE_ADDR,
|
2015-11-03 08:52:12 -05:00
|
|
|
};
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static struct gpio_k64_data gpio_data_D;
|
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
DEVICE_AND_API_INIT(gpio_k64_D, CONFIG_GPIO_K64_D_DEV_NAME, gpio_k64_D_init,
|
|
|
|
&gpio_data_D, &gpio_k64_D_cfg,
|
2016-11-08 11:06:55 -08:00
|
|
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
2016-04-14 09:28:34 -07:00
|
|
|
&gpio_k64_drv_api_funcs);
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_D_init(struct device *dev)
|
|
|
|
{
|
2016-03-25 15:27:54 -07:00
|
|
|
IRQ_CONNECT(GPIO_K64_D_IRQ, CONFIG_GPIO_K64_PORTD_PRI,
|
2016-03-23 10:53:04 +01:00
|
|
|
gpio_k64_port_isr, DEVICE_GET(gpio_k64_D), 0);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-25 15:27:54 -07:00
|
|
|
irq_enable(GPIO_K64_D_IRQ);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
return 0;
|
2015-12-11 13:23:10 -05:00
|
|
|
}
|
|
|
|
|
2015-11-03 08:52:12 -05:00
|
|
|
#endif /* CONFIG_GPIO_K64_D */
|
|
|
|
|
|
|
|
/* Initialization for Port E */
|
|
|
|
#ifdef CONFIG_GPIO_K64_E
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_E_init(struct device *dev);
|
|
|
|
|
2016-10-19 22:10:12 +01:00
|
|
|
static const struct gpio_k64_config gpio_k64_E_cfg = {
|
2016-03-25 15:27:54 -07:00
|
|
|
.gpio_base_addr = GPIO_K64_E_BASE_ADDR,
|
|
|
|
.port_base_addr = PORT_K64_E_BASE_ADDR,
|
2015-11-03 08:52:12 -05:00
|
|
|
};
|
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static struct gpio_k64_data gpio_data_E;
|
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
DEVICE_AND_API_INIT(gpio_k64_E, CONFIG_GPIO_K64_E_DEV_NAME, gpio_k64_E_init,
|
|
|
|
&gpio_data_E, &gpio_k64_E_cfg,
|
2016-11-08 11:06:55 -08:00
|
|
|
POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
|
2016-04-14 09:28:34 -07:00
|
|
|
&gpio_k64_drv_api_funcs);
|
2015-11-03 08:52:12 -05:00
|
|
|
|
2015-12-11 13:23:10 -05:00
|
|
|
static int gpio_k64_E_init(struct device *dev)
|
|
|
|
{
|
2016-03-25 15:27:54 -07:00
|
|
|
IRQ_CONNECT(GPIO_K64_E_IRQ, CONFIG_GPIO_K64_PORTE_PRI,
|
2016-03-23 10:53:04 +01:00
|
|
|
gpio_k64_port_isr, DEVICE_GET(gpio_k64_E), 0);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-03-25 15:27:54 -07:00
|
|
|
irq_enable(GPIO_K64_E_IRQ);
|
2015-12-11 13:23:10 -05:00
|
|
|
|
2016-04-14 09:28:34 -07:00
|
|
|
return 0;
|
2015-12-11 13:23:10 -05:00
|
|
|
}
|
|
|
|
|
2015-11-03 08:52:12 -05:00
|
|
|
#endif /* CONFIG_GPIO_K64_E */
|