Commit graph

23 commits

Author SHA1 Message Date
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 0a7d4e2135 devicetree: Change DT_FOREACH_IMPL_ to not insert semicolon
Remove semicolon between instance invocations of DT_FOREACH_IMPL_ and
thus DT_INST_FOREACH.  This provides more flexibility to the user.  This
requires we fixup in tree users to add semicolon where needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-07 20:03:56 -05:00
Kumar Gala dbeb3ba32e drivers: spi: spi_sam: rework device tree support
Reworked spi_sam driver to utilize new DT_INST macros as part of
this rework we also now get pin ctrl/mux configuration information
from the device tree instead of via Kconfig and defines in soc_pinmap.h

We remove defines from dts_fixup.h and soc_pinmap.h and associated
Kconfig symbols that are no longer needed due to getting all that
information from devicetree.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-25 09:29:54 -05:00
Anas Nashif bd70f6f1ed cleanup: include/: move spi.h to drivers/spi.h
move spi.h to drivers/spi.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 f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05: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
Benjamin Valentin c9907b438a drivers: spi: sam/sam0: Don't access uninitialized data
Set data->ctx.config before calling a function that operates on it.

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-03-26 07:28:52 -05:00
Benjamin Valentin 388e9a6223 drivers: spi: sam/sam0: Don't claim support for async transfers
Asyc transceive is currently not implemented for this driver,
so don't claim support.

spi_context_lock() is already being called in spi_sam_transceive()
so calling it in the wrapper function will cause a deadlock.

This reverts eae05d928e

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
2019-03-26 07:28:52 -05:00
Carlos Stuart 75f77db432 include: misc: util.h: Rename min/max to MIN/MAX
There are issues using lowercase min and max macros when compiling a C++
application with a third-party toolchain such as GNU ARM Embedded when
using some STL headers i.e. <chrono>.

This is because there are actual C++ functions called min and max
defined in some of the STL headers and these macros interfere with them.
By changing the macros to UPPERCASE, which is consistent with almost all
other pre-processor macros this naming conflict is avoided.

All files that use these macros have been updated.

Signed-off-by: Carlos Stuart <carlosstuart1970@gmail.com>
2019-02-14 22:16:03 -05:00
Anas Nashif 937e45de74 drivers: spi_sam: initialize tx and rx
initialize both tx and rx in the spi_sam0 driver. Make the spi_sam
driver look the same by splitting the declaration into 2 lines.

Discovered with gcc 8.2

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-01-14 14:07:52 -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
Ashokkumar B 2652a81d98 drivers: spi: fix typo bug in spi_sam.c
* Change all occurance of sam0 to sam
     * Chande CONFIG_SPI to DT_SPI

Signed-off-by: Ashokkumar B <ashokkumar@zilogic.com>
2018-11-28 13:44:07 -06:00
Henrik Brix Andersen 4c533d053e drivers: spi: sam: avoid unsigned comparision with less than zero
Avoid comparison of size_t with less than zero.

This fixes #11136.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2018-11-27 12:05:17 -08:00
Tomasz Bursztyka eae05d928e drivers/spi: Adding async mode to SAM and SAM0 drivers
This mode was missing for some reason.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-17 00:25:36 +01:00
Tomasz Bursztyka 27195895b1 drivers/spi: Do not reconfigure at every transaction
If the configuration is already installed, there will no need to
reconfigure the controller all over again.

This was missing for mcux_dspi, mcux_lspi, sam and sam0.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-11-17 00:25:36 +01:00
Kumar Gala 71c3dd11c5 spi: sam: Specify pinmux for chipselect via Kconfig
Move to using Kconfig (like other Atmel SAM drivers do) to specify the
pinmux setting for SAMe70 SoCs.  Updated the sam_e70_xplained board to
set the default in Kconfig.defconfig instead of via board.h

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-11-15 07:29:44 -06:00
Andrzej Głąbek 20202902f2 dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig
These changes were obtained by running a script  created by
Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
specification:

1. Read the contents of all dts_fixup.h files in Zephyr
2. Check the left-hand side of the #define macros (i.e. the X in
   #define X Y)
3. Check if that name is also the name of a Kconfig option
   3.a If it is, then do nothing
   3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
       has neither of these two prefixes
4. Replace the use of the changed #define in the code itself
   (.c, .h, .ld)

Additionally, some tweaks had to be added to this script to catch some
of the macros used in the code in a parameterized form, e.g.:
- CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
- CONFIG_UART_##idx##_TX_PIN
- I2C_SBCON_##_num##_BASE_ADDR
and to prevent adding DT_ prefix to the following symbols:
- FLASH_START
- FLASH_SIZE
- SRAM_START
- SRAM_SIZE
- _ROM_ADDR
- _ROM_SIZE
- _RAM_ADDR
- _RAM_SIZE
which are surprisingly also defined in some dts_fixup.h files.

Finally, some manual corrections had to be done as well:
- name##_IRQ -> DT_##name##_IRQ in uart_stm32.c

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2018-11-13 10:44:42 -06:00
qianfan Zhao ae363e54ec drivers: spi_sam: Config chip select pin when driver init
Configure spi chip select based on pinmap defines, add support
for hardware chip select control support.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-10-16 14:01:29 -05:00
qianfan Zhao 29d9004a01 drivers: spi_sam: fix spi peripheral chip select config
Should convent slave->config to SPI_MR.PCS

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-10-16 14:01:29 -05:00
qianfan Zhao 1eec4bbf30 drivers: spi_sam: fix compiler waring
Fix: warning: assignment discards ‘const’ qualifier from
pointer target type

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-10-16 14:01:29 -05:00
qianfan Zhao 6e4963b978 drivers: add spi support for atmel sam series soc
This driver is based on spi_sam0

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-10-10 11:29:49 -05:00