Commit graph

34 commits

Author SHA1 Message Date
Piotr Mienkowski 4b194eb4fc gpio: remove deprecated API functions/macros
This commit removes API functions and macros which were deprecated in
2.2 release. GPIO drivers are updated accordingly.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-06-16 19:13:05 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Kumar Gala 22e65cb9ba gpio: mcux: Convert convert to DT_INST defines
Convert driver to use DT_INST_ defines.  As part of this conversion we
remove the Kconfig options for per GPIO controller enables and instead
get that information from device tree.  This means we now disable each
GPIO controller by default in the DTS and have each board dts enable the
GPIO controller ports it needs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-23 17:07:41 -05:00
Martí Bolívar 9f7cab0623 drivers: gpio: use new ngpios macros
Save some typing with sed:

$ git grep -E -l \
  'GPIO_PORT_PIN_MASK_FROM_NGPIOS\(DT_INST_PROP\(.*, ngpios\)\)' | \
  xargs sed -r -i \
  's/GPIO_PORT_PIN_MASK_FROM_NGPIOS\(DT_INST_PROP\(([0-9]+), ngpios\)\)/GPIO_PORT_PIN_MASK_FROM_DT_INST(\1)/'

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-06 09:14:02 -05:00
Kumar Gala 4b9fe8a24e drivers: mcux: Convert MCUX drivers to new DT_INST macros
Convert older DT_INST_ macro use in MCUX drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 03:40:09 -05:00
Peter Bigot 7c95d503b0 gpio: clean up internal API function prototypes
Use gpio_pin_t uniformly when passing pin indexes to the driver.  Use
gpio_flags_t uniformly when passing flags to the driver.  Change name
of pin configuration function in API function table to be consistent
with other API functions.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot c7d526be04 gpio: remove port access op support
The only remaining port operations have dedicated API function table
entries.  Remove the defines for access op (mode), and remove support
for access op from all implementations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 1f9beb193f gpio: remove legacy read/write API functions
The last external reference to these was removed when the pin
write/read functions were deprecated.  Remove the syscall support, API
function table entries, and implementation from all drivers.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 1947481cce gpio: deprecate gpio pin callback enable and disable API
These have been replaced by the appropriate call to
gpio_pin_interrupt_configure().  While the disable function could be
implemented using the new functionality, the enable function cannot
because the interrupt mode is not available.  Consequently we cannot
replace these with equivalent functionality using the legacy API.

Clean up the internal implementation by removing the inaccessible
port-based enable/disable feature, leaving the pin-based capability in
place.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 56f975fbb4 drivers: gpio_mcux: add support for pin validation
Add the common config structure as a prefix of the driver-specific
config structure and use the devicetree GPIO pin counts to initialize
it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski 73fcc07281 drivers: gpio_mcux: clean up interrupt code
Remove redundant interrupt code from gpio_mcux_configure, move the rest
to gpio_mcux_pin_interrupt_configure.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Peter Bigot 79c04b4ea6 drivers: gpio_mcux: fix handling of unsupported configurations
The MCUX GPIO peripheral must be configured as either input or output.
Reject attempts to configure disconnected or bidirectional.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Kumar Gala bd8141832e drivers: gpio_mcux: Update for handling local layer in core
Remove handling for GPIO_INT_LEVELS_LOGICAL in driver now that we do
that in gpio_pin_interrupt_configure and gpio_pin_configure.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Kumar Gala 7989f5cd6b drivers: gpio_mcux: Fix interrupt handling
Change when we clear interrupt status to happen before we handle the
callbacks.  As the callbacks might manipluate the GPIO state and cause
a GPIO interrupt.  If we clear interrupt status after than we might
miss an interrupt.

Also only clear interrupts for interrupts that are we have enabled and
that were reported when we read from the interrupt status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski 30a97ce28e drivers: gpio_mcux: update to use new GPIO API
Update driver code and board files to use new GPIO configuration flags
such as GPIO_ACTIVE_LOW. Also add implementation of new port_* driver
API as well as gpio_pin_interrupt_configure function.

Tested on frdm_k64f board.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Anas Nashif 6aa9c3a68f cleanup: include/: move gpio.h to drivers/gpio.h
move gpio.h to drivers/gpio.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Kumar Gala dba65ce47c drivers: Update DT IRQ alias defines
The defines should have had a _0 on them, now that we generate the
proper defines, fixup the cases that used that old scheme.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-06-21 07:53:05 -05:00
Patrik Flykt 97b3bd11a7 drivers: Rename reserved function names
Rename reserved function names in drivers/ subdirectory. Update
function macros concatenatenating function names with '##'. As
there is a conflict between the existing gpio_sch_manage_callback()
and _gpio_sch_manage_callback() names, leave the latter unmodified.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-04-03 17:31:00 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Maureen Helm e5ee8035c7 drivers: gpio: Fix mcux driver to init successfully with no irq
Some mcux gpio instances do not have dedicated interrupt vectors and
therefore conditionalize out the IRQ_CONNECT() and irq_enable() calls
during driver initialization. The driver initialization incorrectly
returned an error in this case, when really it just has nothing to do.
The driver can still be used without interrupts, and the gpio configure
function returns an error if an application tries otherwise.

Commit a68120de6d introduced a check on
the init return value to prevent applications from using drivers that
fail to initialize. This in turn caused zephyr/samples/basic/threads to
assert on the frdm_kl25z board. Fix this by modifying the mcux gpio
driver to return success when there is no interrupt to connect.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-02-23 08:30:21 -06:00
Kumar Gala 93a9e0b3fe gpio: mcux: Convert to use DT_ prefixed defines
The gpio mcux driver has been using non DT_ prefixed defines for DT
generated defines.  Switch to use DT_ prefixed ones as we want to
deprecated the non DT_ prefixed defines.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-08 16:03:17 -06:00
Maureen Helm 3c44137447 drivers: gpio: Validate pin number before indexing array in mcux drivers
Validates the gpio pin number before using it to index into a
memory-mapped register array. Otherwise, a user could send a high pin
number and cause an out-of-bounds access.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-01-31 03:13:15 -06:00
Tomasz Bursztyka ea5d01b41c drivers/gpio: Act relevantly if GPIO_INT is an unsupported flag
Using right error code, and no need to populate callback related API
functions.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-25 11:24:29 -05:00
Tomasz Bursztyka 064f5f0cef drivers/gpio: Manage callback addition/removal properly
It needs to verify if the callback was not already installed, and if so:
if is was in controller's list.
It should return an error in case the node is not found though it was
requested to be removed.
If already inserted, it will be silently removed but added again, to
avoid circular list as stated in the bug.

Fixes #11394

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-01-25 11:24:29 -05:00
Patrik Flykt 8ff96b5a57 drivers: Add 'U' to unsigned variable assignments
Add 'U' to a value when assigning it to an unsigned variable.
MISRA-C rule 7.2

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-12-04 22:51:56 -05:00
Maureen Helm 4e8f29f319 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>
2018-04-20 08:54:11 -05:00
Kumar Gala ccad5bf3e3 drivers: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I08f51e2bfd475f6245771c1bd2df7ffc744c48c4
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-21 10:06:48 -05:00
Gustavo Denardin 4951340829 arm: GPIO driver modifications for MKL25Z soc support
The MKL25Z soc do not support irqs in PORTB, PORTC and PORTE.
This is a patch to not enable irq if such ports are enabled.

Change-Id: I7b0b308504fcea47714fee8f2913baf336c4aa7d
Signed-off-by: Gustavo Denardin <gustavo.denardin@gmail.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-14 05:56:53 -05:00
Marcus Shawcroft c35b90890a gpio: Error GPIO_INT with GPIO_DIR_OUT consistently.
Several gpio drivers consider GPIO_INT with GPIO_DIR_OUT to be illegal
and return an errno code.  Use the same errno code across all drivers.

Change-Id: I1594df0cfdf96194685c83c34dff36261896f2de
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2017-02-08 13:31:08 +00:00
Maureen Helm 82eaa7cd5b gpio: serial: Fix NXP copyright
The NXP copyright should not have 'Semiconductors, Inc' in it.

Change-Id: I6e290146d49bf22d1d40b7fa764bb53b6b122303
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-01-23 15:15:53 -06:00
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
Maureen Helm d71f246855 gpio: Introduce new mcux gpio driver
Adds a new mcux gpio driver that can be used for k64 and other Kinetis
SoCs. This driver uses mcux CMSIS register accesses to the GPIO and PORT
modules. Some of the logic from the k64 gpio driver was reused and
refactored (mainly flag parsing and callback handling).

Jira: ZEP-1394
Change-Id: If5e9390861c181ec555dce6569b14debb729526a
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2017-01-12 09:46:27 -06:00