Commit Graph

543 Commits

Author SHA1 Message Date
Tomasz Bursztyka ef560e0a53 drivers: Manual const-ification of device driver instance
These are all the case that coccinelle cannot find as they are inside
macro declarations.

Fixed via:

git grep -rlz -E "\(struct device \*" |
	xargs -0 sed -i 's/(struct device/(const struct device/g'

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 7967aa6af0 drivers: gpio: Use DEVICE_AND_API_INIT for mmio32 driver
Let's set the api at built time, or this will create a bug once device
instance pointers become constant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Simon Glass 49f2167974 emul: i2c: Add support for I2C emulators
Add an emulation controller which routes I2C traffic to attached
emulators depending on the I2C address selected. This allows drivers
for I2C peripherals to be tested on systems that don't have that
peripheral attached, with the emulator handling the I2C traffic.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-09-01 14:30:46 -04:00
Krzysztof Chruscinski 701e9befe4 drivers: clock_control: nrf: Move USB part to the USB driver
Removed all nrf_power/USB related stuff from clock control
driver to USB driver.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-08-31 12:40:47 +02:00
Ryan Erickson eca8842b67 drivers: modem: add Sierra Wireless HL7800 Modem Driver
The driver utilizes the CONFIG_NET_OFFLOAD setting to avoid the
normal handling of IP packets, and instead uses a socket-like
UART interface to handle incoming and outgoing data via AT commands.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2020-08-31 10:46:33 +02:00
Simon Guinot b37ea90335 drivers: led: add driver for TI LP503x controllers
This patch adds support for the Texas Instruments LP5030 and LP5036
I2C LED controllers. They are respectively providing up to 30 and 36
channels (i.e. 10 or 12 RGB LEDs).

In addition to the channel/color registers this LED controller provides
a per-LED brigthness register. This driver implements both LED-based and
channel-based API methods:

- led_on
- led_off
- led_get_info
- led_set_brightness
- led_set_color
- led_set_channel
- led_write_channels

Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
2020-08-28 15:04:35 +02:00
Simon Guinot f59abf5916 drivers: led: introduce channel-dedicated syscalls
Some LED controllers are connected to a large number of LEDs (i.e.
array/strip of LEDs). A user may need to set several LEDs at the same
time. The LED oriented syscalls are not adapted to this task. Indeed a
call per LED is needed to configure a group of LEDs. To that end, this
patch adds the led_set_channel and led_write_channels syscalls to the
LED API. They offer direct access to the raw channels. They respectively
allow to set a single channel and to write several contiguous channels
(and therefore to configure a group of LEDs).

Moreover the addition of the led_write_channels syscall also aims at
closing the gap with the LED strip API.

Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
Signed-off-by: Maxime Bittan <maxime.bittan@seagate.com>
2020-08-28 15:04:35 +02:00
Simon Guinot 4f5583bf33 drivers: led: make more API callbacks optional
For the LED controller without any hardware blinking capability this
doesn't really make sense to make the blink callback mandatory. It is
better to let it undefined. This way this will allow the LED API to
fall back to a common software blink implementation.

In addition some controllers with RGB LEDs don't have the capability
to configure the LED brightness but only the channel/color levels.
Their drivers may only implement the set_color callback.

That's why this patch makes the blink and set_brightness LED API
callbacks optional.

Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
2020-08-28 15:04:35 +02:00
Simon Guinot 2e26262451 drivers: led: introduce led_set_color syscall
The led_set_color syscall adds support for multicolor (i.e.
multi-channel) LEDs to the LED API. It allows a user to set all the
colors/channels of a LED at once by passing a color array. Note that
this array must provide an entry per color/channel and must also be
ordered following the color mapping of the LED. This color mapping can
be either retrieved from the "color-mapping" DT property or from the LED
driver itself (by using the led_get_info syscall).

Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
2020-08-28 15:04:35 +02:00
Simon Guinot 713809f0ce drivers: led: introduce led_get_info syscall
When supported by the driver the led_get_info syscall allows a user
to retrieve the following information about each LED available:

- The LED label.
- The number of colors/channels.
- And for a multicolor LED a pointer to a channel-color mapping.

Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
Signed-off-by: Maxime Bittan <maxime.bittan@seagate.com>
2020-08-28 15:04:35 +02:00
Simon Guinot 745d5ac7e1 led: move API functions to LED objects
Actually the LED API functions are handling channel objects. The "led"
parameter passed to the functions is defined as a channel number. This
patch redefines it as a LED number instead.

Note that this patch doesn't change anything for the drivers handling
mono-color (or single channel) LEDs. For the drivers handling multicolor
(or multi-channel) LEDs, such as the lp5562, then the API is broken.

Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
2020-08-28 15:04:35 +02:00
Peter Bigot 7a8a4c9b3e drivers: spi: document expectation on spi config parameter
Most if not all drivers use an internal function
spi_context_configured() to bypass reconfiguring the SPI peripheral
when nothing has changed.  That function determines change based on
comparing the struct spi_config pointer that was last used.  This does
not work if a user changes fields within the pointed-to structure.

Document that pointer comparison may be used to detect changes.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-08-26 12:25:06 +02:00
Flavio Ceolin 0aaae4a039 guideline: Make explicit fallthrough cases
-Wimplicit-fallthrough=2 requires a fallthrough comment or a compiler
to tells gcc that this happens intentionally.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-08-24 20:28:47 -04:00
Peter Bigot 4f8f286a2a drivers: i2c: document speed levels
Many developers will be unfamiliar with UM10204 so document the rates
that are associated with the standard, fast, etc. speed names.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-08-24 16:23:43 -05:00
Peter A. Bigot dae5bfdfd4 cdc_acm: fix C++ issues with header and document dependency
The header was missing the language linkage wrapper that allows the
driver-specific function to be located from C++.

Also it helps the poor user to be informed that the function is only
available when a special Kconfig option is set.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:42:02 -04:00
Peter A. Bigot 6a1a246825 drivers: flash: add API to read JEDEC ID from compatible drivers
Some flash drivers are capable of issuing a JESD216 READ_SFDP command
to read serial flash discoverable parameters.  Allow applications and
utilities access to API that reads the JEDEC ID from those devices.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:38:14 -04:00
Peter A. Bigot 4eb8d9dd9e drivers: flash: add API to access SFDP region of serial flash devices
Some flash drivers are capable of issuing a JESD216 READ_SFDP command
to read serial flash discoverable parameters.  Allow applications and
utilities access to that capability where it's supported.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2020-08-17 13:38:14 -04:00
Peter Bigot cabbd916cf drivers: move eeprom_slave driver to tests directory
This device isn't an actual hardware driver: it's a virtual EEPROM
that stores data in an instance-specific RAM buffer, with the data
exposed on an I2C bus as a I2C follower (slave) device that can be
controlled by another device acting as a leader (master) on that same
bus.

As such it's a reasonable example of how to write an I2C follower
driver, but it's not clear that it has a real use in applications.  A
Zephyr application that needs to emulate an EEPROM in a real-world
system would be unlikely to provide its data from a RAM buffer.

The sole in-tree reference is in the i2c_slave_api test, so move the
driver implementation into that test.

The Kconfig and hierarchy are being left in place until it is more
clear how this functionality should be selectable within Zephyr.  The
I2C_SLAVE symbol has been converted from menuconfig to config to
eliminate a Kconfig style diagnostic.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-08-13 11:49:12 +02:00
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka af6140cc0d device: Apply config_info rename everywhere
Via coccinelle:

@r_device_config@
struct device *D;
@@

D->
-	config_info
+	config

And 2 grep/sed rules for macros:

git grep -rlz 'dev)->config_info' |
	xargs -0 sed -i 's/dev)->config_info/dev)->config/g'

git grep -rlz 'dev->config_info' |
	xargs -0 sed -i 's/dev->config_info/dev->config/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka a8cd162d2c device: Rename config_info attribute to config
There use to be a config attribute of type device_config, on which
config_info could be found. config_info was thus named that way to
differentiate easily from config attribute in struct device.

Now that there is no such device_config structure, config_info in
structure device now, can be renamed to config.

Semantically, it makes for sense. We have an attribute pointing to the
configuration of the device driver instance. Configuration information
is correct but has a redundant meaning.

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Rubin Gerritsen 38295e0b73 bluetooth: controller: Add BT_QUIRK_NO_AUTO_DLE for BT_LL_SW_SPLIT
It does not auto-initiate the DLE procedure if the default data length
parameters are not equal to the initial parameters.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-08-10 12:14:49 +02:00
Rubin Gerritsen 5b034e103f bluetooth: hci_driver: Add BT_QUIRK_NO_AUTO_DLE
Some controllers do not follow the recommendation of auto-initiating
a data length update if the host writes default data length parameters.

If the controller follows this recommendation, calling
LE Write Suggested Default Data Length command is sufficient
to ensure that the LL will auto-initiate the DLE procedure. Performing
a second procedure is unecessary.

In Core v5.2, Vol 4, Part E, Section 7.8.35:
The HCI_LE_Write_Suggested_Default_Data_Length command allows the
Host to specify its suggested values for the Controller's maximum
transmission number of payload octets and maximum packet
transmission time for packets containing LL Data PDUs to be used
for new connections. The Controller may use smaller or larger values
for connInitialMaxTxOctets and connInitialMaxTxTime based on local
information.

In short, this command sets connInitialMaxTxOctets
and connInitialMaxTxTime.

In Core v5.2, Vol 6, Part B, Section 4.5.10:

For a new connection: connMaxTxOctets shall be set to
connInitialMaxTxOctets and connMaxRxOctets shall be chosen by the
Controller. If either value is not 27 then the Controller should
initiate the Data Length Update Procedure at the earliest practical
opportunity.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-08-10 12:14:49 +02:00
Andrzej Puzdrowski 4d4455b174 include/drivers/flash: document on the unrestricted source buffers
Document unrestricted source buffer location while writing to
the flash.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-08-05 15:27:46 -04:00
Andrzej Puzdrowski 1d8cf859db include/drivers/flash: document on the unrestricted alignment of reads
Unaligned read-out capability become fact among all drivers.
Let's cut this in stone as API requirement.

fixes #16439

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-08-05 15:27:46 -04:00
Simon Glass 6b50f643da drivers: i2c: Add a dump routine
Add a function to dump out a set of I2C messages. It uses debug logging
so it only useful for debugging.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-04 17:50:39 +02:00
Krzysztof Chruscinski 2891256b67 drivers: serial: Add error code to uart_rx_buf_rsp
API did not cover a case when uart_rx_buf_rsp is called when receiver
is already disabled. It may happen if uart_rx_buf_rsp is called too
late and active transfer is already finished. In that case -EACCES is
returned.

Some implementations already returned that error in that case.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-08-03 13:49:57 +02:00
Tomasz Bursztyka 0d4477604a ipm: Callback's user data has to be called user_data
s/context/user_data

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:51:51 +02:00
Tomasz Bursztyka e4479f907f api: ipm: Pass the ipm device as first parameter to callback
Let's normalize the callback like it is done in other APIs.
This will avoid the need to do not so nice code (storing the ipm device
pointer as global, or else) and more importantly will help to move all
device instance to constant.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:51:51 +02:00
Tomasz Bursztyka 8144de1513 dma: Callback's user data has to be called user_data
s/callback_arg/user_data

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka 800e6c3a28 dma: Generalize dma callback signature by adding a dedicated typedef
Until now, each and every driver had to redeclare the type to store such
pointer, now they will be using this typedef.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka 020dab824c api: dma: Pass the dma device pointer as parameter to callback
Normalize callback like other APIs.
This clarifies the callback usage. It will also help to switch all
device instance to constants.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:48:00 +02:00
Tomasz Bursztyka b258f2d3a3 uart: Removing uart_irq_callback_t type
This type of callback does not exist anymore and can be safely removed.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00
Tomasz Bursztyka e4e6b8e193 uart: Normalize irq callback signature
All other API provide the device pointer to the callback it's going to
call. So fixing this in UART.

This will avoid passing the actual device pointer as a user data (thus
enabling user data for something else).

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00
Tomasz Bursztyka 4644d4a40c uart: Normalize user callback signature
All other API provide the device pointer to the callback it's going to
call. So fixing this in UART.

This will avoid passing the actual device pointer as a user data (thus
enabling user data for something else).

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00
Tomasz Bursztyka a010241cb3 uart: Normalizing device parameter name
s/port/dev

dev is being used everywhere else so let's rename port to dev.
And the parameter documentation should be the same for all.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00
Maxime Bittan ed4511ea8c drivers: clock_control: lpc11u6x: Add support for clock controller
This commit adds basic support for the clock controller used in
lpc11u6x MCUs.

Signed-off-by: Maxime Bittan <maxime.bittan@seagate.com>
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
2020-07-29 20:12:24 +02:00
Raveendra Padasalagi 306980816a dma: Support 64bit source/dest address
Add 64bit source_address/dest_address fields support.
This is needed in situation where DMA controller is capable
of handling more than 32bit source and destination addresses.

Signed-off-by: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
2020-07-24 11:54:31 +02:00
Simon Glass 49a3e49936 include: drivers: sensor: Add more channels for batteries
Add some more channels useful for batteries with fuel gauges.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-23 12:12:09 -04:00
Peter Bigot a1babb7f1f drivers: eeprom_slave: add const qualifier to read-only data
The EEPROM device doesn't mutate the source data it's given, so update
the API signature to reflect this fact.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-07-22 21:41:12 +02:00
Michael Hope 62a236e546 usb: cdc_acm: add a DTE rate changed callback
This is called when the USB host changes the virtual baud rate.

This is used by Arduino style boards to signal that the board should
reset into the bootloader.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-07-22 13:24:37 +02:00
Tomasz Bursztyka 922325992d spi: Make all API functions available
Removing ifdef around conditional API to follow zephyr coding style.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-20 17:32:42 -04:00
Krzysztof Chruscinski 6f01c0bc79 drivers: clock_control: nrf: Add onoff service support
Updated nrf clock control driver to use onoff service for managing
multiple users.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-07-20 16:22:21 +02:00
Krzysztof Chruscinski 88be2ea2d2 drivers: uart: Make all API function available
Conditional API was removed by preprocessor which violates zephyr
coding style. Removed ifdefs around conditional API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-07-17 13:00:52 -05:00
Andrew Boie ee3c50ba6d x86: apic: use device MMIO APIs
A hack was required for the loapic code due to the address
range not being in DTS. A bug was filed.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2020-07-17 11:38:18 +02:00
Johann Fischer b95558dd9f drivers: usb: unify endpoint helper macros
Unify endpoint index and direction helper macros
across all usb device drivers.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-07-10 11:45:46 +02:00
Peter Bigot a0f025995d drivers: watchdog: update API to reflect additional return code
Allow feed operations that would stall due to internal peripheral
delays to complete immediately with -EAGAIN indicating that the feed
did not occur as expected.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-07-09 06:44:59 -04:00
Andy Ross 43d84147d9 drivers/pcie: Fix BAR address size limitation
The PCI API was originally limited to 32 bit addresses.  Even though
it had code to skip over the high word in 64 bit BAR entries, it
refused to use it and returned a 32 bit value.  Some devices in the
wild have default mappings from the firmware for devices above 4G.

Also remove the "iobar" API.  It's dead code, we don't call it and we
don't test it.  IO space BAR entries are a legacy feature from way,
way back in PCI history (I genuinely have never heard of a real device
that uses them!).  And there's no difference in format between one of
these and a 32 bit "memory" BAR anyway, someone who actually had this
requirement could just use the existing API without worry.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-07-08 12:34:09 +02:00
Joakim Andersson 4be66bd33d Bluetooth: Fix host RX thread deadlock
Fix host RX thread being deadlocked. The deadlock occurs because the
RX thread is stuck waiting in conn_tx_alloc with K_FOREVER but if the
connection is disconnected only the RX thread can unblock it in the
handling of the disconnect event.

This commit fixes this deadlock by splitting the processing of the
disconnected event into two parts.
The part needed to unblock the RX is to release resources held by
unack'ed TX packets and mark the connection state as not connected
anymore.
The RX thread waiting for free_tx fifo and the TX thread waiting for
the bt_dev.le.pkts semaphore will both check the connected state after
having acquired them and will abort if disconnected.
The rest of the processing will be handled at normal RX thread
priority like normal.

Move the bt_recv_prio handling to the Bluetooth host when the host
has defined its own RX thread (CONFIG_BT_RECV_IS_RX_THREAD=n).
If the HCI driver has the RX thread (CONFIG_BT_RECV_IS_RX_THREAD=y),
then the responsibility to call bt_recv and bt_recv_prio correctly
falls to the HCI driver.
The helper function bt_hci_evt_is_prio() is replaced with
bt_hci_evt_get_flags() so that the HCI driver can do this correctly.
This decision to replace was made so that existing HCI drivers
maintained out-of-tree will fail at compile time with the new system.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>

Bluetooth: host: Move bt_recv_prio to host when RX thread is defined

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-07-06 11:15:39 +02:00