Commit graph

83 commits

Author SHA1 Message Date
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
Jean-Paul Etienne cfa43f5bda serial: enable 64-bytes FIFO for UART 16750 in uart_ns16550 driver
UART 16750 is basically a UART 16550 with a 64-bytes FIFO.
The 64-bytes FIFO can be enabled via register FCR.

Account for it in the uart_ns16550 driver whenever the
CONFIG_UART_NS16750 variable is set.

Change-Id: I2342b28a41d03c96410bbfbe57e4b5a4e335731d
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-05 16:05:20 +00:00
Flavio Santes 0a1c29cda4 driver: Add ARG_UNUSED to console and uart drivers
This patch adds the ARG_UNUSED macros to some function
arguments to avoid compiler warnings.

Change-Id: I628aea55d98cf8519c046ae5835e95cfa70a973f
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-21 12:54:47 +00:00
Flavio Santes b04cdcd6e6 drivers: Remove legacy nanokernel.h include
This commit replaces the nanokernel.h include by kernel.h.

Change-Id: Ib42fbf2d9f77a73c0831f569b3dbbfb342ea2e1d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-04 14:59:37 -06:00
Andrew Boie 0b474eef9c kernel: deprecate old init levels
PRIMARY, SECONDARY, NANOKERNEL, MICROKERNEL init levels are now
deprecated.

New init levels introduced: PRE_KERNEL_1, PRE_KERNEL_2, POST_KERNEL
to replace them.

Most existing code has instances of PRIMARY replaced with PRE_KERNEL_1,
SECONDARY with POST_KERNEL as SECONDARY has had a longstanding bug
where the documentation specified SECONDARY ran before the kernel started
up, but actually ran afterwards.

Change-Id: I771bc634e9caf7f17dbf214a270bc9967eed7d32
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-11-09 17:59:44 +00:00
Marcus Shawcroft 7c8b6498e3 serial/uart_ns16550: Make driver_api structure const.
Change-Id: Ie27216f1020504d8c6368d228e2e8e94da8fa51f
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-25 18:45:42 +00:00
Marcus Shawcroft bad9aa1501 uart/ns16550: Make driver config_info structure const.
Change-Id: I57c71df60dfcfee1ea6bf461777775b928a61c1b
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-20 16:49:01 +00:00
Marcus Shawcroft 7ee5ce75e9 serial/ns16550: Move RW objects from driver config to driver context.
PCI enumeration modifies pci_dev and port at driver initialization,
these objects move from config_info to driver_data in preparation for
config_info becoming const.

This driver shares a unified uart configuration structure with other
uart device drivers.  The structure uses 'union' and the preprocessor
to customize the structure to the drivers specific requirement.  There
appears to be no compelling reason why all the uart drivers should
share the same (customized) config_info structure.  In order to
re-organize the structure for this driver to get config_info const, an
ns16550 specific config structure is defined and the driver switched
over from the generic uart_config.

Change-Id: I31932d811f623a9370b69903114ae97b15d65886
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>
2016-10-15 16:44:06 +00:00
Sebastien Griffoul 300dee8a26 serial: fix ns16550 set_baud_rate()
In order to change the baudrate the DLAB bit of the LCR register has to
be set to 1 (This bit is used to enable reading and writing of the 
divisor latch register). This bit must be cleared after the baudrate
setup in order to access other registers.

The set_baud_rate function correctly sets the DLAB bit of the LCR reg but
never clears it. Therefore the ns16550 doesn't properly work any more
after updating the initial baud rate.

In order to fix this issue the LCR reg has to be temporary saved
(because it contains other important settings). After switching to a new
baud rate the LCR reg value has to be restored. 

Change-Id: Ied4db683cbf40ba3125e747552968ddf1a66e2be
Signed-off-by: Jeremie GARCIA <jeremie.garcia@intel.com>
Signed-off-by: Sebastien GRIFFOUL <sebastien.griffoul@intel.com>
2016-06-22 01:35:37 +00:00
Daniel Leung 793da30039 serial/uart_ns16550: convert to use DEVICE_AND_API_INIT()
Note that the failure case can only be reached when PCI is enabled.
Otherwise, the if-block is always false, which reduces code size
for non-PCI platforms.

Change-Id: Ib98b78a75cc2a5f124e67f32f2bf82960a963aec
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-15 22:06:10 +00:00
Daniel Leung 26b474c987 serial/ns16550: reduce number of kconfig options
Moves those kconfig options which should be declared in
SoC or board header files instead. These are the one
that are tied to SoC or board and there is no need
for them to be configurable in kconfig.

Change-Id: I243d634f1a4a11dc8dc3530d95f93371015492b7
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-30 13:38:34 +00:00
Andre Guedes b3cb3a1f68 drivers: Replace DEV_INVALID_CONF by -EINVAL
This patch replaces all occurences of the macro DEV_INVALID_CONF by
-EINVAL at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/ when applicable.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: Idae0d5af8dd780416977c9261a5fb6188c3aab64
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Andre Guedes 245e140da6 drivers: Replace DEV_INVALID_OP by -ENOTSUP
This patch replaces all occurences of the macro DEV_INVALID_OP by
-ENOTSUP at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/ when applicable.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: I46aec3c65963018c479b01602e4a3eec8650eaff
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Andre Guedes 024cfe754e drivers: Replace DEV_OK by 0
This patch replaces all occurences of the macro DEV_OK by the actual
value 0 at the driver level. So this patch touch the files under
drivers/, include/ and samples/drivers/.

This patch is part of the effort to transition from DEV_* codes to
errno.h codes.

Change-Id: I69980ecb9755f2fb026de5668ae9c21a4ae62d1e
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
2016-03-16 19:30:04 -04:00
Daniel Leung e643cede3a uart: add ISR callback mechanism for UART drivers
The peripherals utilizing UART were required to register their own
ISR rountines. This means that all those peripherals drivers need
to know which IRQ line is attached to a UART controller, and all
the other config values required to register a ISR. This causes
scalibility issue as every board and peripherals have to define
those values.

Another reason for this patch is to support virtual serial ports.
Virtual serial ports do not have physical interrupt lines to
attach, and thus would not work.

This patch adds a simple callback mechanism, which calls a function
when UART interrupts are triggered. The low level plumbing still needs
to be done by the peripheral drivers, as these drivers may need to
access low level capability of UART to function correctly. This simply
moves the interrupt setup into the UART drivers themselves. By doing
this, the peripheral drivers do not need to know all the config values
to properly setup the interrupts and attaching the ISR. One drawback
is that this adds to the interrupt latency.

Note that this patch breaks backward compatibility in terms of
setting up interrupt for UART controller. How to use UART is still
the same.

This also addresses the following issues:

() UART driver for Atmel SAM3 currently does not support interrupts.
   So remove the code from vector table. This will be updated when
   there is interrupt support for the driver.
() Corrected some config options for Stellaris UART driver.

This was tested with samples/shell on Arduino 101, and on QEMU
(Cortex-M3 and x86).

Origin: original code
Change-Id: Ib4593d8ccd711f4e97d388c7293205d213be1aec
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-05 13:37:57 +00:00
Daniel Leung f8bf86c95f uart: serial_ns16550: exclude driver data variables under #ifdef
Not all of the variables defined in the driver data structure are
required. So put some #ifdef around them.

Change-Id: I08a0c02d9e5c6885d9b4d6237446bdb9b98f3bfa
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-03-05 13:37:48 +00:00
Dan Kalowsky 4743684e4f struct packing
Looking at all structs as to where we can pack them a little better, and
calling out the padding/stride at the end for future expansion.

Change-Id: I4a651092e950dd3d915af9fa0ee0d7d59803e58f
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-10 16:21:26 +00:00
Benjamin Walsh d340d4cb3f device: use DEVICE_INIT everwhere
This is the last step before obsoleting DEVICE_DEFINE() and
DEVICE_INIT_CONFIG_DEFINE().

Change-Id: Ica4257662969048083ab9839872b4b437b8b351b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh 0303d8cab9 device: rename SYS_DEFINE_DEVICE()
Rename it to DEVICE_DEFINE() so that it fits in the 'device' namespace.

Change-Id: I3af3a39cf9154359b31d22729d0db9f710cd202b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh bfc27206b2 device: rename DECLARE_DEVICE_INIT_CONFIG()
Rename it to DEVICE_INIT_CONFIG_DEFINE(), because (a) it was not fitting
in any namespace and (b) it is not used to declare, but rather define a
object.

Change-Id: I1da5822f06b85a9fb024b5b184afd0ccc01012ec
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:25 -05:00
Benjamin Walsh 2ec2f8bb62 uart: remove incorrect comment w.r.t. type of device pointer
Change-Id: Ic0523d7413dbc14dd8e44cf9c4c0b70d65d759d0
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:25:23 -05:00
Fabien Chereau e2e78baf68 ns16550: implement the irq_tx_empty function
Change-Id: I5b043354aefe8d54c2f8e06e06204e3de8e715b5
Signed-off-by: Fabien Chereau <fabien.chereau@intel.com>
2016-02-05 20:25:23 -05:00
Fabien Chereau b7d9842875 ns16550: implement the err_check function
Change-Id: If38bb1082f11a3be5b5d94a7122db233e6a822df
Signed-off-by: Fabien Chereau <fabien.chereau@intel.com>
2016-02-05 20:25:23 -05:00
Fabien Chereau 43ad5532df ns16550: Interruption Identification Register definitions clean up
Change-Id: I7346cec74061bce774c8fee80186d09aaf690f76
Signed-off-by: Fabien Chereau <fabien.chereau@intel.com>
2016-02-05 20:25:23 -05:00
Andrew Boie 2295e2abf7 uart: remove uart_irq_get()
This API is not being used for anything, the interrupts for UART
drivers are all being configured statically. Saves code space as
gc-sections can't tell that these APIs are unused.

Some instances where IRQ/priority information was being saved in
data structures and never used fixed.

Change-Id: If56b4fdc251b80be9094ffcbac6f61e265ac2ffd
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:16 -05:00
Daniel Leung 760f8798f3 uart/ns16550: implements new API of line control
This implements the newly introduced APIs to manipulate line controls
for UART.

This also implements the driver command API as setting baud rate
may require setting the DLF.

Change-Id: I80634aa3fbd4a3223c46edb61417123e36f439dd
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:14 -05:00
Daniel Leung b85d3ef826 uart: move baud rate and options into driver data
This moves the baud rate and options fields out of the UART driver
config struct and into the driver data struct. This will allow
changing baud rate and options at runtime in the future.

Change-Id: I62ddea2f95e634f2d60eeb9537f960799fc9301f
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:14 -05:00
Daniel Leung b9c70ce76a uart/ns16550: support divisor latch fraction (DLF)
The UART on Quark SE and D2000 supports fractional clock divider.
It is used to limit frequency error for supported baud rates.

Change-Id: I1f39a95db09f4a5a4116edc700a10e4b9ecfa2bd
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:14 -05:00
Javier B Perez Hernandez 02812f4635 drivers: pci: struct pci_dev_info rename class
Rename class in pci_dev_info struct to allow to use C++ compilers.
Updated drivers to use new struct.

Change-Id: I17b94cb7bc094bccd615c8389a28589bfa90cab8
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
2016-02-05 20:25:12 -05:00
Ido Yariv e4ddf68561 serial/ns16550: scan pci on the second port
Only the first port is currently enumerated on the PCI bus. As a result,
the second port configuration will be set based on the default options,
that may be invalid on some platforms.

Fix this by enumerating the second port as well.

Change-Id: I63733a1f13f7cb35cae1dba3b6192dcd61c9f644
Signed-off-by: Ido Yariv <idox.yariv@intel.com>
Signed-off-by: Ido Yariv <ido@wizery.com>
2016-02-05 20:25:12 -05:00
Daniel Leung ba6f2d9617 uart: remove uart_devs[]
Since all the necessary bits utilizing UART by index have moved to
use device name instead, the uart_devs[] can finally be removed.

Change-Id: Idbae6b46c0af9eef6c22c59e121e9d6a6b52426a
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:56 -05:00
Daniel Leung 7dbf56bb0e serial/ns16550: consolidate initialization code
Since the initialization is now done within driver, there is
no need to expose the port_init() function externally anymore.
After the consumers of port_init() have been updated. It is time
to perform the final step.

Change-Id: I4e0d0a6802ddda4a6671c6d246233eaa5074d4ff
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:56 -05:00
Daniel Leung 728d91d598 serial/ns16550: refactor (again) to conform to driver model
() Renames ns16550.c to uart_ns16550.c. This is to follow
   the driver naming convention.
() Renames functions ns16550_uart_*() to uart_ns16550_*(),
   following driver naming convention.
() UART ports initialization is moved into the driver itself.
   All the init code in platform config files is removed.
() Adds (many) Kconfig options. These don't have to be defined
   in each platform's board.h anymore.
() Renames CONFIG_NS16550_* to CONFIG_UART_NS16550_*
() Disable NS16550 for ARC as no port is defined anyway.

Change-Id: I76bbe25b9bc75eb62df81e533f84f4f63a5257b7
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:56 -05:00
Renamed from drivers/serial/ns16550.c (Browse further)