Commit graph

479 commits

Author SHA1 Message Date
Zide Chen 87b65c5ac2 interrupt_controller: program local APIC LDR register for xAPIC
If IO APIC is in logical destination mode, local APICs compare their
logical APIC ID defined in LDR (Logical Destination Register) with
the destination code sent with the interrupt to determine whether or not
to accept the incoming interrupt.

This patch programs LDR in xAPIC mode to support IO APIC logical mode.

The local APIC ID from local APIC ID register can't be used as the
'logical APIC ID' because LAPIC ID may not be consecutive numbers hence
it makes it impossible for LDR to encode 8 IDs within 8 bits.

This patch chooses 0 for BSP, and for APs, cpu_number which is the index
to x86_cpuboot[], which ultimately assigned in z_smp_init[].

Signed-off-by: Zide Chen <zide.chen@intel.com>
2020-02-19 10:25:10 -08:00
Peter Bigot fe266f9d2c gpio: restore missing legacy devicetree direction flag
GPIO_DIR_OUT is deprecated but allowed in devicetree bindings because
some in-tree bindings provided it in the past.  GPIO_DIR_IN was the
former explicit way of representing the default direction.  Put it
back so symmetry is maintained.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-13 22:50:45 +02:00
Krzysztof Chruscinski ce766305b7 drivers: clock_control: Add subsys argument to the callback
Added subsys argument to the callback, updated one driver which
used it and test cases.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-02-05 17:07:01 +01: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 37239dbcbf gpio: rename typedef for devicetree flags
gpio_dt_flags_t is shorter and consistent with DT_ prefix.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot f017209821 gpio: use reduced-size role typedef for public API pin indexes
There is a typedef used to store pin indexes in configuration
structures.  For consistency it should also be used to identify pin
indexes in function prototypes.

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 09af4ba1ab gpio: mark deprecated flag macros
Mark the outdated flag macros as deprecated so they can be fixed.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 2befa6a251 gpio: deprecate legacy gpio pin read/write functions
These have been replaced by get/set functions in both raw and
active-sensitive variants.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Tomasz Bursztyka 62b2cae2ae drivers/ieee802154: Adapt cc1200 driver to new GPIO API
Update to use new API for GPIO pin configuration and operation.  Fix
invalid arithmetic on void pointer.  Convert to support devicetree.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Tomasz Bursztyka 3587fe2fe3 drivers/ieee802154: Adapt cc2520 driver to new GPIO API
Update to use new API for GPIO pin configuration and operation.  Fix
invalid arithmetic on void pointer.  Mark all CC2520 GPIOs as required
in binding.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Tomasz Bursztyka a40e9d3762 drivers/wifi: Switch WINC1500 to new GPIO API
Use new API to configure and interact with GPIOs.  Move GPIO
initialization from sample into driver.  The existing physical/line
level control has been kept rather than converting to logical level
signals.

Also improve error messages.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 558a585805 gpio: do not deprecate internal direction mask
Existing drivers still use this; move it above the deprecated macro
region.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot d85a9e30d1 gpio: remove unused internal API
Remove macros and a state structure that are not used anywhere and
incompletely describe a GPIO pin specifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot d3281f5b6f gpio: clean up API documentation
Use more standard Doxygen styling.  Add clarification to
recommendations and expectations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Henrik Brix Andersen 82ecb89dae drivers: gpio: lmp90xxx: update to use new GPIO API
Update the TI LMP90xxx GPIO driver to the new GPIO API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-02-05 12:00:36 +01:00
Peter Bigot d68807a391 drivers: gpio_mmio32: add support for pin validation
Add the common config structure as a prefix of the driver-specific
config structure and use the mask parameter to initialize it.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 9022d33fec drivers: gpio: add support for device-specific pin validation
Extend the driver data structure with a field that identifies the pins
supported by the device.  Document the fields and who is responsible
for maintaining them.

Update all configuration functions for specific pins to return an
error if the pin is not supported.

Update all set/get functions for specific pins to assert if the pin is
not supported.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 9d41d53927 drivers: gpio: fix const qualifier on driver data pointers
Several declarations provided a const pointer to mutable data.  Change
all declarations that are not used to change the invert field to be
pointers to const data.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 2016cc64aa drivers: gpio: provide typedefs for flags and devicetree properties
The public API for GPIO flags should use unsigned values, and for
MISRA compliance the size should not be platform-dependent.  Add a
typedef for generic flags.

Also add typedefs for pin indexes and devicetree flags so these can
be safely recorded from devicetree property values without risking
loss of information if more flags are added in the future.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 52aa8edbd0 gpio: support logic-level output at initialization
Extend the physical level GPIO_OUTPUT_{HIGH,LOW} configuration with
GPIO_OUTPUT_{ACTIVE,INACTIVE} for logic level initialization.

This enables use of device-tree configuration flags in calls to
gpio_pin_configure() to set the logic level without having to
determine the corresponding physical level.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 2b150bff4f gpio: avoid disabling interrupts when supporting legacy code
gpio_pin_interrupt_configure() is invoked from within
gpio_pin_configure() to support legacy code that combines pin and
interrupt configuration.  Expressing a disabled interrupt by a zero
value for interrupt flags causes this invocation to disable interrupts
when the intent is to change only a pin configuration, such as pull
direction.

Support a distinction between explicitly disabling interrupts and
leaving the interrupt configuration unchanged.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 33cf10b5b8 gpio: unify assert checks for pin and interrupt configuration
gpio_pin_interrupt_configure() verified that the pin was within range,
while gpio_pin_configure() did not.  Make them consistent since they
take the same set of flags.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Kumar Gala 8f4da10356 drivers: mmio32: update to use new GPIO API
As the mmio32 is more of a library than a proper driver, just implement
the new port functions and have pin_interrupt_configure marked pretty
much as not supported.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Peter Bigot 30d0818179 drivers/gpio: use more clear expression for GPIO direction mask
Define the mask in terms of the individual non-zero fields to isolate
from future changes to the bit position.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 0db954a8a8 tests: gpio_basic_api: fix misplacement of debounce flag
The debounce flag is to be provided to the pin configuration, not the
pin interrupt configuration.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski 4fcb88cb51 gpio: add new asserts verifying flag configurations
The asserts verify that:
- Output needs to be enabled for 'Open Drain', 'Open Source' mode to be
  supported.
- GPIO_LINE_OPEN_DRAIN flag can be enabled only if GPIO_SINGLE_ENDED is
  enabled.
- Only one of GPIO_INT_LOW_0, GPIO_INT_HIGH_1 can be enabled for a level
  interrupt.
- GPIO_INT_DEBOUNCE is not passed to gpio_pin_interrupt_configure
  function.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
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
Peter Bigot fca26890b0 drivers/gpio: document that unsupported DEBOUNCE should be ignored
A large number of sensor drivers specify GPIO_INT_DEBOUNCE to request
a debounced signal; in practice the debounce may be performed by
external components on the board.  Historically this flag was ignored
on the many GPIO peripherals that do not support hardware debouncing.

Document that this flag is an exception to the normal rule that
unsupported features should be rejected by gpio_pin_configure.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 9e8947fe3e drivers: gpio: add named flag set for disconnected GPIO
A disconnected GPIO is one that is neither an input nor an output.
This is represented by a zero-valued all-default configuration.  Call
this configuration GPIO_DISCONNECTED so the intent is clear.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 060daac089 gpio: add error return when blocking might occur
External GPIO drivers may not be supported from interrupt context
because they involve blocking bus transactions.  Describe the return
value for this situation, and add the I/O error to operations where it
was missing.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Peter Bigot 53178c36bd gpio: put back deprecation comments
The comments identifying replacement API were inadvertently removed
along with the flag that triggers deprecation warnings.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-02-05 12:00:36 +01:00
Kumar Gala cb9c3efaad drivers: gpio_mmio32: Add gpio_driver_data to driver data
Add gpio_driver_data as the first element in the driver data as the gpio
core expects this.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Kumar Gala b535881f0c gpio: Handle logical conversion in gpio api layer
Move handling of logical flag support into gpio_pin_configure and
gpio_pin_interrupt_configure.  This way drivers don't need to know
anything about logical levels.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Kumar Gala 84b27a1525 gpio: Reorder code in drivers/gpio.h
Move z_impl_gpio_pin_interrupt_configure before gpio_pin_configure so we
can utilize z_impl_gpio_pin_interrupt_configure in gpio_pin_configure in
the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-02-05 12:00:36 +01:00
Peter Bigot 48b674b570 gpio: use named types to distinguish pin sets from pin values
Both pin sets and values encoding pin values are ultimately represented
by 32-bit unsigned integers. Provide typedefs that make the role of a
parameter explicit.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski 33193a57eb gpio: add gpio_pin_interrupt_configure function
This commit moves interrupt configuration for a single pin from
gpio_pin_configure to gpio_pin_interrupt_configure function.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski d6191b5781 gpio: add new functions to set/get pin/port values
This commit adds following functions which work with pin logical levels
(take into account GPIO_ACTIVE_LOW flag):
- gpio_port_get, gpio_port_set_masked, gpio_port_set_bits,
  gpio_port_clear_bits, gpio_port_set_clr_bits
- gpio_pin_get, gpio_pin_set
Functions which work with pin physical levels:
- gpio_port_get_raw, gpio_port_set_masked_raw, gpio_port_set_bits_raw,
  gpio_port_clear_bits_raw, gpio_port_set_clr_bits_raw
- gpio_pin_get_raw, gpio_pin_set_raw
As well as functions:
- gpio_port_toggle_bits, gpio_pin_toggle_bits

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Piotr Mienkowski af972c2c47 api: gpio: Align GPIO dt-bindings flags with Linux DTS
This commit makes following changes to GPIO dt-bindings flags:
- Added GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH to indicate pin active state.
- Added GPIO_OPEN_DRAIN, GPIO_OPEN_SOURCE to configure single ended pin
  driving mode.
- Added GPIO_PULL_UP, GPIO_PULL_DOWN flags.
- GPIO_INPUT, GPIO_OUTPUT to configure pin as input or output.
- Added GPIO_OUTPUT_LOW, GPIO_OUTPUT_HIGH flags to initialize output
  in low or high state.
- reworked GPIO_INT_* flags to configure pin interrupts.
- following flags were deprecated: GPIO_DIR_*, GPIO_DS_DISCONNECT_*,
  GPIO_PUD_*, GPIO_INT_ACTIVE_*, GPIO_INT_DOUBLE_EDGE, GPIO_POL_*.

To be aligned with Linux DTS standard any GPIO flags that should not be
used in DTS files are moved from include/dt-bindings/gpio/gpio.h file to
include/drivers/gpio.h with an exception of several old flags which
removal would cause DTS compilation errors. Those remaining old flags
will be removed from include/dt-bindings/gpio/gpio.h at a later stage.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2020-02-05 12:00:36 +01:00
Peter A. Bigot 4420c5ed40 adc: provide API to help with conversions
Gain values are specified with enumeration values that can't be used
to reverse the effects of scaling the input signal.  Provide a
function that reverses the effect of the gain by scaling a measured
value.

Also provide a function that converts a raw measurement captured with
a reference voltage and specific gain and resolution to the
corresponding voltage in millivolts.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-02-03 16:26:51 +01:00
Maureen Helm 5a330f9b36 drivers: kscan: Extend callback arguments to 32-bits
Extends the keyboard scan callback row and column arguments from 8-bits
to 32-bits to support a touch panel driver implementation.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-02-01 08:50:16 -05:00
Carlo Caione 6f36300219 drivers: timer: Add per-core ARM architected timer
ARM cores may have a per-core architected timer, which provides per-cpu
timers, attached to a GIC to deliver its per-processor interrupts via
PPIs. This is the most common case supported by QEMU in the virt
platform.

This patch introduces support for this timer abstracting the way the
timer registers are actually accessed. This is needed because different
architectures (for example ARMv7-R vs ARMv8-A) use different registers
and even the same architecture (ARMv8-A) can actually use different
timers (ELx physical timers vs ELx virtual timers).

So we introduce the common driver here but the actual SoC / architecture
/ board must provide the three helpers (arm_arch_timer_set_compare(),
arm_arch_timer_toggle(), arm_arch_timer_count()) using an header file
imported through the arch/cpu.h header file.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2020-02-01 08:08:43 -05:00
Mieszko Mierunski dc3c906d12 drivers: uart: Switch timeout values to s32_t in UART async API
Use signed values for timeout in UART asynchronous API, to be consistent
with timeout type in timer and workqueue values.

Signed-off-by: Mieszko Mierunski <mieszko.mierunski@nordicsemi.no>
2020-01-29 19:37:31 +01:00
Kwon Tae-young 346e5c3a45 include: drivers: lora: Added support for RSSI and SNR in the recv API
Change the API to support RSSI, SNR of data received through lora_recv.

Signed-off-by: Kwon Tae-young <tykwon@m2i.co.kr>
2020-01-28 17:28:26 -05:00
Henrik Brix Andersen c894a6db4d drivers: counter: add counter_get_value(), deprecate counter_read()
Introduce a new counter API function for reading the current counter
value (counter_get_value()) and deprecate the former counter_read() in
favor of this.

Update all drivers and calling code to match the new counter API.

The previous counter driver API function for reading the current value
of the counter (counter_read()) did not support indicating whether the
read suceeded. This is fine for counters internal to the SoC where the
read always succeeds but insufficient for external counters (e.g. I2C
or SPI slaves).

Fixes #21846.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-01-28 12:52:46 -05:00
Henrik Brix Andersen 0f60477667 drivers: counter: add missing syscalls
Add missing syscalls and fix already present syscalls for the counter
API.

Fixes #14650.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-01-21 11:36:55 -05:00
Jan Van Winkel 9814e743fd driver: display: Added BGR565 pixel format
Added BGR565 pixel format ti display format enumeration.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2020-01-20 09:21:04 -06:00
Jan Van Winkel ecaa7102d2 driver: display: Clarified byte order of pixel formats
Clarified that the byte order of multi byte pixel formats is in big
endian order.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2020-01-20 09:21:04 -06:00
Andrew Boie a51b125aba drivers: serial: add async API system calls
These were unintentionally omitted. We don't expose callback
registration or callback response APIs for security reasons.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-01-17 16:15:02 -05:00
Peter A. Bigot ac5acb9530 drivers: sensor: ccs811: provide API to fetch configuration and versions
The application may want to know the configured mode without inspecting
Kconfig macros; this is important for proper management of BASELINE
which is mode-dependent.

It also may need to know the version of the hardware and firmware, as
the behavior of application firmware 2.0 is significantly better than
version 1.1.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot 2dd990ad55 drivers: sensor: ccs811: enable drive mode 4
This mode is documented as producing a raw result every 250 ms that the
application must convert to eCO2 and eTVOC readings.  In practice
application firmware 2.0 appears to convert the readings as with all
other rates.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot cb84836745 drivers: sensor: ccs811: provide access to sensor results
Expose the entire content of the ALG_RESULT_DATA block to the
application, primarily so the status and error flags can be seen.  With
those available the application has the ability to detect that a stale
result has been provided so sensor_fetch_sample() can return -EAGAIN in
this case instead of -EIO, and it doesn't need to block which is
annoying.

This should also make the sensor usable on older Nordic Thingy:52
devices with outdated CCS811 application firmware that doesn't properly
implement the DATA_READY bit.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot c90a738d8c drivers: sensor: ccs811: support update of environmental conditions
Accurate estimate of gas presence requires temperature and humidity
data.  Add API to update these values.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Peter A. Bigot af0c69fb9f drivers: sensor: ccs811: add interface for BASELINE management
Proper use of the CCS811 requires maintenance of the BASELINE
register value measured in clean air at various points in the sensor
life cycle.  The sensor driver abstraction has no facility to support
this, so add an application header with functions to fetch and update
the register value.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-01-14 15:44:09 -06:00
Henrik Brix Andersen bc2113bd46 drivers: adc: add LMP90xxx ADC driver with GPIO
Add driver for the Texas Instruments LMP90xxx series of multi-channel,
low-power 16-/24-bit sensor analog frontends (AFEs).

The functionality is split into two drivers; an ADC driver and a GPIO
driver.

Tested with LMP90080 and LMP90100.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-09 17:27:52 +01:00
Henrik Brix Andersen 9d71384e50 drivers: adc: support for adc channel gain factor of 128
Support specifying a gain factor of 128 when configuring ADC channels.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-09 17:27:52 +01:00
Henrik Brix Andersen db611e6781 drivers: pwm: add support for inverted PWM signals
Add support for requesting an inverted PWM pulse (active-low) when
setting up the period and pulse width of a PWM pin. This is useful
when driving external, active-low circuitry (e.g. an LED) with a PWM
signal.

All in-tree PWM drivers is updated to match the new API signature, but
no driver support for inverted PWM signals is added yet.

All in-tree PWM consumers are updated to pass a flags value of 0
(0 meaning default, which is normal PWM polarity).

Fixes #21384.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-07 18:13:18 +01:00
Manivannan Sadhasivam 92b2994335 include: Add initial LoRa API
Add initial LoRa API for P2P mode.

Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
2019-12-21 12:20:24 +01:00
Stephanos Ioannidis 2b441732ff interrupt_controller: gic: Support multiple GIC versions
The current GIC driver implementation only supports the GIC-400, which
implements the GICv2 interface.

This commit refactors the GIC driver to support multiple GIC versions
and adds GICv1 interface support (GICv1 and GICv2 interfaces are very
similar).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
2019-12-19 11:05:27 -05: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
Andrew Boie 13b8b41676 drivers: watchdog: add system calls
wdt_install_timeout() was skipped as it installs an ISR-context
callback handler function. The rest are simple wrappers.

Added myself as the maintainer of the syscall handlers. WDT
subsystem appears to not currently have an owner.

Fixes: #21432

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-12-18 09:28:52 -05:00
Krzysztof Chruscinski 00156ad80a drivers: clock_control: nrf: Switch to single clock device
Low frequency and high frequency clocks had separate devices
while they are actually handled by single peripheral with single
interrupt. The split was done probably because opaque subsys
argument in the API was used for other purposes and there was
no way to pass the information which clock should be controlled.
Implementation changes some time ago and subsys parameter was
no longer used. It now can be used to indicate which clock should
be controlled.

Change become necessary when nrf5340 is taken into account where
there are more clocks and current approach would lead to create
multiple devices - mess.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-12-17 14:38:19 +01:00
Peter A. Bigot 8328159b09 include: respect line limit in api pointer initialization
The automated process used to remove implicit casts resulted in code
that exceeded the documented line length limits.  Break the assignment
into two lines where this happened.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-12-16 21:14:08 -05:00
Andrzej Puzdrowski aa0d41f7ec drivers/flash: protection API clarification
On some targets hardware (or middelware) doesn't allow
implement functionality flash protection API -
so fare it have to be emulated by software on such a target.

This patch changes documentation of this API, so on such a targets
API might implements no-operation.

fixes #15729

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-12-15 10:35:09 -05:00
Peter A. Bigot 2e358f11d0 include/drivers: remove implicit casts from api pointer initialization
C++ disallows implicit cast of void pointers to a non-void pointer
type.  Presence of implicit casts prevents use of these headers in C++
applications.

Process: Run the following coccinelle script:

@@
identifier V;
identifier TAG =~ "driver_api";
type T;
expression E;
@@
 T* V =
+(T *)
 E->TAG;

in this command line from $ZEPHYR_BASE:

spatch --sp-file expcast.cocci \
   --include-headers --dir include/ --very-quiet \
 | sed -e '/^\+/s@\*) @*)@' \
 | (cd include/ ; patch -p1)

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-12-15 10:18:17 -05:00
Brooks Prumo 32e3756d66 include: Fixes #1205, C++ usage of sensor.h
I ran into issue #1205 earlier today and realized the fix was to simply
provide the proper casts.  The issue is that C++ is less permissive than
C here, erroring when trying to implicitly convert from `void *` to
`struct gpio_driver_api *`.  The same cast is done in
include/drivers/gpio.h, which is why I did that here as well.

This fix was validated by compiling my C++ application successfully and
also successfully running my app on my board, interacting with sensors.

Signed-off-by: Brooks Prumo <brooks@prumo.org>
2019-12-12 11:06:34 -06:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Andrei Emeltchenko 07bee26f8f ipm: Correct IPM API error codes
Indicates that error codes are negative.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-12-10 10:26:38 -05:00
Kumar Gala 24ae1b1aa7 include: Fix use of <misc/FOO.h> -> <sys/FOO.h>
Fix #include <misc/FOO.h> as misc/FOO.h has been deprecated and
should be #include <sys/FOO.h>.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-12-10 08:39:37 -05:00
Martí Bolívar 2de12df6b9 drivers: clock_control: clock_control_on should be blocking
Document this behavior. This partially addresses #20708, but we'll
have to deal with driver bugs case by case now that the desired
behavior is clear.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2019-12-09 12:50:36 -05:00
David B. Kinder 416a174ac2 doc: fix misspellings in docs
Fix misspellings in docs (and Kconfig and headers processed into docs)
missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-12-04 14:12:53 -06:00
Francisco Munoz 11f01dd682 API: eSPI: Add two more APIs for eSPI
eSPI is an aggregator device which is used by other blocks
to communicate with the master. This new APIs allows LPC
peripherals to communicate with eSPI master.

Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
2019-11-20 15:02:08 -05:00
Krzysztof Chruscinski 16ba258052 drivers: clock_control: Clarify allowed calling context of API calls
Clarified that clock_control_off and clock_control_async_on can be
called from any context since they are non-blocking.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-11-20 18:04:40 +01:00
Krzysztof Chruscinski c53166a8c5 drivers: clock_control: Remove false description of clock_control_async_on
Description of clock_control_async_on contained information about
delayed start which is not supported by this function call.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-11-20 18:04:40 +01:00
Emil Obalski 6c82c80a3c drivers: Add support for nRF52833 in several drivers
By adding new SoC to Zephyr drivers has to be updated.
Commit affects:
 - USB driver
	- support for nRF52833 added.
	- support for USB_DEVICE_REMOTE_WAKEUP in hid-mouse added.
 - SPI
 - IEEE 802.15.4
 - CLOCK CONTROL

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-11-13 10:33:38 -06:00
Henrik Brix Andersen a2a7b776cb drivers: eeprom: add API for EEPROM devices
Add API for accessing Electrically Erasable Programmable Read-Only
Memory (EEPROM) devices.

EEPROMs have an erase block size of 1 byte, a long lifetime, and allows
overwriting data on byte-by-byte access.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-11-07 16:32:15 -05:00
Peter A. Bigot a58d8ebaa6 driver: uart: make deprecation effective
Several macros were documented as deprecated but lacked the
infrastructure to produce deprecation warnings.  Add the deprecation
marker, and fix the in-tree references to the deprecated spellings.

Note that one non-deprecated macro should have been deprecated, and
is, referring to a newly added line control bit.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-11-07 12:44:15 -06:00
Jacob Siverskog eb4679d0c4 uart: Improve line control documentation
Minor improvements to UART line control documentation.

Signed-off-by: Jacob Siverskog <jacob@teenage.engineering>
2019-11-07 15:54:40 +01:00
Alexander Wachter d558fd055a drivers: CAN: Limit the DLC to 8
This commit limits the data length code to eight.
DLC > 8 returns a newly introduced CAN_TX_EINVAL error code.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-11-06 21:00:45 +01:00
David B. Kinder 73896c0bf0 doc: fix misspelling in API doxygen comments
Fix misspellings in API doxygen comments missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-10-29 06:00:14 +01:00
Loic Poulain 32169886ca drivers: Add video API
This generic video API can be used to capture/output video frames.

Once a video buffer is enqueued to a video device endpoint, device owns
the buffer and can process to capture (camera), output (disk, display),
convert (hw encoder)... User can then call dequeue to retrieve
the processed buffer (video driver ensure cache coherency).

Once dequeued, video buffer is owned by user (e.g. for frame
processing, display buffer update, write to media, etc...).

For each video-buffer, user needs allocate the associated frame buffer
via video_buffer_alloc. Buffer format is defined by video device
endpoint configuration. Video device can be controlled (e.g. contrast,
brightness, flip...) via controls.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
2019-10-25 15:13:53 -05:00
Alexander Wachter 30ebf52a27 include: drivers: can: Fix zframe to frame conversion
can_copy_zframe_to_frame did not distinguish between the standard and
extended frames. As a result, uninitialized bits were copied to the
destination frame. This commit changes the function to use the correct
bitfields.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-10-24 21:51:40 +03:00
Alexander Wachter c0da8a7901 drivers: can: Extend CAN API for bus-state management.
This commit extends the CAN API with the following functions:
- can_get_state
- can_recover
- can_register_state_change_isr

This functions can be used to get the error-counters and the state
of the CAN controller. The recover function can be used to recover
from bus-off state when automatic recovery is disabled.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-10-24 12:28:01 +03:00
Francisco Munoz e13a1230b7 API: kscan: Add API for Keyboard scan matrix
-kscan_config
    -kscan_enable_callback
    -kscan_disable_callback

Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
2019-10-16 13:29:21 -07:00
Charles E. Youse f6d9fb10b1 drivers/interrupt_controller/loapic.h: add IPI support
Add a simple inline function and some definitions to faciliate
inter-processor interrupts for SMP initialization/synchronization.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-10-07 19:46:55 -04:00
Charles E. Youse a981f51fe6 arch/x86: drivers/loapic_intr.c: move local APIC initialization
In the general case, the local APIC can't be treated as a normal device
with a single boot-time initialization - on SMP systems, each CPU must
initialize its own. Hence the initialization proper is separated from
the device-driver initialization, and said initialization is called
from the early startup-assembly code when appropriate.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
2019-10-07 19:46:55 -04:00
Morten Priess d9251a83a0 drivers: bluetooth: Added EVT_DATA_BUF_OVERFLOW to bt_hci_evt_is_prio
As it is possible that hci_acl_handle generates an overflow hci event,
the high priority thread must be able to processed it.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2019-10-07 12:43:46 +03:00
Alexander Wachter 1c7892df3f include: drivers: CAN: changed return parameter description
Changed return parameter description from
"@retval filter id on success"  to
"@retval filter_id on success".
This change suppresses the doxy warnings.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
2019-10-04 13:05:44 -04:00
Krzysztof Chruscinski 6700f2f194 drivers: clock_control: nrf: reimplementation including API updates
Reimplementation of clock control driver for nrf platform. It includes
latest API changes: asynchronous starting and getting clock status.

Additionally, it implements calibration algorithm which optionally
skips calibration based on no temperature change. Internal temperature
sensor is used for that.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-10-04 17:15:39 +02:00
Anas Nashif 9d70a87f20 drivers: espi: move header to include/drivers
Driver APIs need to go into include/drivers/.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-10-01 16:18:36 -04:00
Andrei Emeltchenko a6eb2ae299 adc: Trivial style cleanup
Cleanup adc header and API test.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-09-30 12:20:39 -05:00
Yannis Damigos efec7f73b7 dts: esp32: Add GPIO support in DT
Add GPIO support in DT

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
2019-09-25 17:39:42 +02:00
Andrei Emeltchenko 549fbae43b drivers: watchdog: Trivial style cleanup
Cleanup coding style.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-09-24 11:40:53 -07:00
Andrzej Głąbek 57c6cfc9cd nordic: Use hal/ in all inclusions of nrfx HAL header files
Header files of nrfx HALs are not supposed to be included directly
but only with their names prepended with the hal/ directory (so that
an inclusion of an nrfx HAL header clearly differs from an inclusion
of an nrfx driver header).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-09-24 16:20:16 +02:00
Kumar Gala 140a8d0c8a console: Remove deprecated function console_register_line_input
console_register_line_input has been deprecated for at least 2 releases
so we can now remove it.  Remove native_stdin_register_input that is
associated with console_register_line_input.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-09-18 19:14:25 -05:00
Piotr Mienkowski bfa89782a8 gpio: Clean up API documentation
Fix minor issues in doxygen comments. Do not use typedefs for internal
driver API calls. The functions are declared directly in
`struct gpio_driver_api`. No functional changes.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-09-18 13:28:58 +08:00