Commit graph

94 commits

Author SHA1 Message Date
Alexandre Bourdiol c8ceca2d53 drivers: STM32 dualcore concurrent register access protection with HSEM
In case of dualcore, STM32H7, STM32W and STM32MP1,
protect concurrent register write access with HSEM.
Done for following drivers:
clock_control, counter, flash, gpio, interrupt_controller

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-07-09 11:27:56 +02:00
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 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02: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
Erwan Gouriou cdd5856167 driver/gpio: stm32: Add STM32L5 support
Add basic GPIO support. Regarding interface with EXTI,
STM32L5 is similar to STM32G0.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-05-08 00:34:34 -05:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Erwan Gouriou e26767fc06 drivers/gpio: stm32: Remove Kconfig based device declaration
Use device node declaration instead.
Clean up GPIO_STM32_PORT* Kconfig symbols.

On some boards some gpio ports where disabled using Kconfig symbols.
Disable them now via device tree nodes in boards dts files.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-04-02 06:50:05 -05:00
Erwan Gouriou c4de0d3b5b drivers: gpio: Use new DT macros for device driver init
Kconfig based device declaration is kept as is.
Clean up the fixup files.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-04-02 06:50:05 -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
Erwan Gouriou 9222a4f9a3 drivers/gpio: stm32: Align arguments types on few api functions
Somehow, types used in some api functions where not in line with
api.
Fix this.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Peter Bigot 32ff5f1d1f drivers: gpio_stm32: add support for pin validation
Add the common config structure as a prefix of the driver-specific
config structure.  This driver uses fixups to define a common name
based on the SOC series; until aliases for the new properties are
added the code assumes all pins are supported.

Since pin ordinal validation is now done directly in gpio API,
remove checks inside the driver itself.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Erwan Gouriou 78d7b2106a drivers/interrup_controller: stm32: stm32_exti_enable could be void
stm32_exti_enable was returning errors on line > 32 or line pointing
to non implemented line. Both conditions are hard-coded, hence there
is no use to detect them dynamically in the code.
Check them with assert. As a consequence, function could now be void.

Additionally, enable exti irq line only if both checks are passed.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Erwan Gouriou 29e9780ad1 drivers/interrupt_controller: stm32: Clean set api from unused arg
Argument 'port' in stm32_exti_set_callback function is not
used, remove it.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Erwan Gouriou e88cdffcd6 drivers/gpio: stm32: exti: Clear triggers when not requested
Since it is now possible to disable/re-enable interrupts and
also to reconfigure an already configured interrupt, it is
now required to clear non requested triggers.
While it is not strictly requested, triggers are also cleared
when interrupt is disabled (assuming trigger should be configured
when interrupt is enabled).

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>

fixup exti
2020-02-05 12:00:36 +01:00
Erwan Gouriou eecc384b22 drivers/gpio: stm32: various clean up
Perform few clean up in stm32 gpio driver:
*Clean up uint32_t occurrences left over.
*Move function gpio_stm32_flags_to_conf from const to static
and remove useless parameter check
*Rework error handling in functoin gpio_stm32_config
*Remove gpio_stm32_int_enabled_port function and have direct call
to gpio_stm32_get_exti_source

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Erwan Gouriou a6801f7ff4 drivers/gpio: stm32: Update to new GPIO api
Update STM32 GPIO driver to support new GPIO API.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-02-05 12:00:36 +01:00
Peter Bigot 0b0d2e640b treewide: use full path to clock_control/stm32_clock_control.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Tomasz Bursztyka 9abc0e2efd include/drivers: Move 2 specific intc headers into public location
sam0 and stm32 specific interrupt controller headers are meant to be
public, and as such should be found in
include/drivers/interrupt_controller and not in
drivers/interrupt_controllers.

Fixing documentation issues as well.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-12-18 21:49:46 +01:00
Tomasz Bursztyka c30600d4ab drivers/interrupt_controller: Adopt file naming as other drivers
Pattern being <domain>_<model>.<c/h>.
Here interrupt_controller as a domain would be far too long so
shortening it to "intc", as DTS does actually.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-12-18 21:49:46 +01:00
Marcin Niestroj dfda0cb114 gpio: stm32: support disabling and reenabling interrupts on gpio pin
Up to now interrupts could be only configured once, with no way to
disable them in runtime.

Allow interrupts to be disabled in runtime and then properly reenabled
on user request. This allows to ignore interrupts when software is not
expecting them.

The improvement over previously reverted patch [1] is that we disable
interrupts only when we configure port for which interrupt line was
previously selected. This for example prevents to disable interrupts
line 2 in case PA2 was previously configured as interrupt source, but we
are currently configuring PB2 as output.

[1] 0951ce2d34 ("gpio: stm32: support disabling and reenabling
  interrupts on pin")

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-11-13 12:05:48 -06:00
Marcin Niestroj 7edcbedc70 gpio: stm32: split helper functions from gpio_stm32_enable_int()
This patch doesn't change functionality, but is only related to improved
readability and reusability.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-11-13 12:05:48 -06:00
Marcin Niestroj 09a57a5e81 gpio: stm32: statify gpio_stm32_enable_int()
This allows compiler to inline function body and reduce overall code
size.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-11-13 12:05:48 -06:00
Erwan Gouriou dd0d567e8b drivers/gpio: stm32: Rework configure function exit for dual core
With dual core handling introduction, we now need to take care to
always release lock before exiting function.
Rework gpio_stm32_config to take this into account.
Additionally, since ENOSYS usage is resevred to system calls
handling, replace with EIO.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-11-13 12:05:48 -06:00
Richard Osterloh f7bad922f0 drivers: gpio: Add STM32G4X gpio support
Add GPIO driver support for STM32G4X SoC series.

Signed-off-by: Richard Osterloh <richard.osterloh@gmail.com>
2019-10-04 18:44:24 -07:00
Erwan Gouriou c9dcf37e6c Revert "gpio: stm32: support disabling and reenabling interrupts on pin"
This reverts commit 0951ce2d34.

This change introduces regression on GPIO interrupts handling
when several GPIOs are configured.

Fixes #19177

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-09-16 05:44:15 -05:00
Marcin Niestroj 0951ce2d34 gpio: stm32: support disabling and reenabling interrupts on pin
Up to now interrupts could be only configured once, with no way to
disable them in runtime.

Allow interrupts to be disabled in runtime and then properly reenabled
on user request. This allows to ignore interrupts when software is not
expecting them.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-09-12 08:41:44 -05:00
Marcin Niestroj c62b57fbd4 gpio: stm32: fix build for stm32l0x with no GPIOH
Some smaller stm32l0x MCUs, such as stm32l011x, do not have GPIOH
port. Fix build for those by checking LL_SYSCFG_EXTI_PORTH macro.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2019-08-26 09:48:54 -05:00
Findlay Feng 4b18a079d9 drivers: gpio: add stm32f1x SWJ configuration
Add the serial wire JTAG configuration of the stm32f1x family.
Before gpio is initialized, you can choose to turn off the debug pin to
make the used pins available.

Signed-off-by: Findlay Feng <i@fengch.me>
2019-08-05 13:22:34 +02:00
Erwan Gouriou b44f0eacd5 drivers/gpio: stm32h7: Don't use HSEM_CR_COREID_CURRENT as process id
HSEM_CR_COREID_CURRENT was used as process number parameter in
LL_HSEM_ReleaseLock function. While this is working, this
define should not be used in this context.
Also, process number parameter is actually proposed in case of HSEM
use in inter-process context but is not required for inter-core
resource lock. Replace HSEM_CR_COREID_CURRENT with 0.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-07-26 11:25:05 -04:00
Francois Ramu 9b2025c891 drivers: pinmux: Add STM32G0X pinmux support
Add pinmux support for STM32G0X SoC series.

Signed-off-by: Philippe Retornaz <philippe@shapescale.com>
Signed-off-by: Francois Ramu <francois.ramu@st.com>

# Conflicts:
#	drivers/pinmux/stm32/pinmux_stm32.h
2019-07-05 10:35:55 -05:00
Erwan Gouriou 0914f1031d drivers/gpio: stm32: Add semaphore on gpio_configure
Protect gpio_configure function in dual core context.
This operation is not needed for other fuctions of the api:
* init
* read
* write

Protecting gpio_configure also protects access to
interrupt_controller IP.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-07-04 08:50:04 -04:00
Erwan Gouriou d185ec4cff drivers/gpio: Add support on STM32H7 series
Add GPIO support on STM32H7.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-07-04 08:50:04 -04:00
Anas Nashif a2fd7d70ec cleanup: include/: move misc/util.h to sys/util.h
move misc/util.h to sys/util.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
Anas Nashif a8167ab17d cleanup: include/: move pinmux.h to drivers/pinmux.h
move pinmux.h to drivers/pinmux.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
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
Maciej Zagrabski 6a6264e497 drivers: stm32: Fix disabling EXTI subsystem
The compiler and linker was generating errors after
disabling `CONFIG_EXTI_STM32` due to inconsistency
in `interrupt_controller/CMakeLists.txt`
and not considering this option in gpio implementation.

Signed-off-by: Maciej Zagrabski <maciej.zagrabski@grinn-global.com>
2019-06-04 09:22:13 -04:00
Yaël Boutreux b4b7020b03 gpio: Add stm32mp157c_dk2 board support
Add support for stm32mp1x GPIO with Zephyr GPIO driver

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-04-26 02:56:20 -07:00
Yaël Boutreux 524c625579 drivers: gpio: stm32: Indentation and cleanup
Cleaning up indentation of stm32 drivers

Signed-off-by: Yaël Boutreux <yael.boutreux@st.com>
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
2019-04-26 02:56:20 -07:00
Manivannan Sadhasivam 1eb6177e9b drivers: gpio: Add STM32L1X GPIO support
Add GPIO driver support for STM32L1X SoC series.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2019-04-22 08:54:18 -05:00
Song Qiang 3751275fb0 drivers: gpio: stm32: add ASCR configuration for L47x+
For STM32L47x/48x series devices, register ASCR should be configured to
connect analog switch of gpio lines to the ADC.

Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
2019-04-17 16:25:28 -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
Erwan Gouriou 5622efad98 drivers/gpio: stm32: Return errors on not supported config
Following configuration options are not supported by STM32
gpio driver:
-GPIO_INT_LEVEL
-GPIO_POL_INV
Return an error when one of these is requested.

Fixes #12766

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-02-12 09:44:02 -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
Erwan Gouriou 14dcd13069 drivers/interrupt_controller: stm32: Complete driver factorization
Complete code factorization in stm32 exti drivers.
Add return value in case line is not implemented.
Except returned error code, refactor has been done iso-feature
compared to previous code. Hence error is reported only when
support was not available on previous series.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-01-24 09:38:38 -06:00
Erwan Gouriou 94bf757d68 drivers/gpio: stm32: Fix gpio_stm32_configure
Behavior of function gpio_stm32_configure has been modified
during driver factorization. Various gpio settings (speed, mode, ..)
are applied conditionally while they used to be applied in sequence,
unconditionally before this change. As a consequence some
combinations of configurations are no more applied (like speed for
alternate mode). This of course has impact in some use cases.
Rework functions in order to apply settings unconditionally. Take
advantage of the change to reduce code size.

This change impacts all SoCs except F1 series.

Fixes #12544

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2019-01-23 04:03:30 -06:00