Commit graph

479 commits

Author SHA1 Message Date
Andrew Boie e98ac235e6 x86: declare internal API for interrupt controllers
Originally, x86 just supported APIC. Then later support
for the Mint Valley Interrupt Controller was added. This
controller is mostly similar to the APIC with some differences,
but was integrated in a somewhat hacked-up fashion.

Now we define irq_controller.h, which is a layer of abstraction
between the core arch code and the interrupt controller
implementation.

Contents of the API:

- Controllers with a fixed irq-to-vector mapping define
_IRQ_CONTROLLER_VECTOR_MAPPING(irq) to obtain a compile-time
map between the two.

- _irq_controller_program() notifies the interrupt controller
what vector will be used for a particular IRQ along with triggering
flags

- _irq_controller_isr_vector_get() reports the vector number of
the IRQ currently being serviced

- In assembly language domain, _irq_controller_eoi implements
EOI handling.

- Since triggering options can vary, some common defines for
triggering IRQ_TRIGGER_EDGE, IRQ_TRIGGER_LEVEL, IRQ_POLARITY_HIGH,
IRQ_POLARITY_LOW introduced.

Specific changes made:

- New Kconfig X86_FIXED_IRQ_MAPPING for those interrupt controllers
that have a fixed relationship between IRQ lines and IDT vectors.

- MVIC driver rewritten per the HAS instead of the tortuous methods
used to get it to behave like LOAPIC. We are no longer writing values
to reserved registers. Additional assertions added.

- Some cleanup in the loapic_timer driver to make the MVIC differences
clearer.

- Unused APIs removed, or folded into calling code when used just once.

- MVIC doesn't bother to write a -1 to the intList priority field since
it gets ignored anyway

Issue: ZEP-48
Change-Id: I071a477ea68c36e00c3d0653ce74b3583454154d
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-09-06 18:35:47 +00:00
Andrew Boie 926a368991 ipm_console: rate-limit to avoid losing messages
These console messages are for debugging and if sent too
rapidly, could be discarded. This was causing false positives on
test cases which rely on console output to determine success or
failure.

Issue: ZEP-704
Change-Id: I5a86c761311cde90f295cd2e65f2e70608f875fa
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-08-17 18:04:37 +00:00
Ramesh Thomas 8f0fdb668a timer: Adds device suspend/resume to loapic timer
This is part of a change to enable device suspend/resume and
Deep Sleep support in applications. Adds suspend/resume handling
in loapic timer.

Jira: ZEP-512
Change-Id: I9da2c8419bd9109fb71ef5a6caf736de7c7de9e1
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
2016-07-21 11:25:31 -07:00
Andrew Boie af085b8edf quark_se: make EOI operations atomic
Some issues have been noted with nested interrupts on quark SE.
In particular, the wrong vector # being sent to the IOAPIC EOI
register. Now when doing EOI, we lock interrupts so that the act
of reading the current vector being serviced, and sending EOI
to both controllers happens atomically.

Change-Id: Id9ad992740e197bb9d4638764952b04a27c4af61
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-07-13 22:41:33 +00:00
Adrian Bradianu fca8eb8608 usb: Add USB device controller header file
Add USB device controller header file containing the USB device
controller APIs. All device controller drivers should implement the
APIs described in this file.

Change-Id: I14443a5286bbc2faddbd6420ce1668acb183cd2e
Signed-off-by: Adrian Bradianu <adrian.bradianu@windriver.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
2016-06-30 00:21:39 +00:00
Szymon Janc d7e8fd0446 console: Add support for commands completion
This allows to register callback that will be called to
perform command completion.

Change-Id: Ide7a0427d9b8bb4dd8cfc0995ef2567b32e89632
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-05-26 12:02:51 +00:00
Jithu Joseph 7c29fefd7d apic : Refactor some macros into a header
Moving few macros into a header file.

Change-Id: I975e19ba518bd6184038d6c1715224be7190b3ad
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
2016-05-24 00:31:37 +00:00
Anas Nashif 4b411b34a1 stm32: rename SOC_STM32F1X -> SOC_SERIES_STM32F1X
Use SOC_SERIES_* for naming SoCs with similar features and architectures
with the goal of code reuse. The Series in the config variable should avoid
name collisions and clearly denote the relationships within an SoC family.

Change-Id: I7a98542f96b5d5dc3acc23782c4d45f98cceb599
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-04-18 21:24:58 +00:00
Benjamin Walsh 0ff5d37a4a console: add hook for debug server to handle outgoing characters
A debug server might want to redirect outgoing characters on the console
to another output if it piggybacks on the serial line normally reserved
for the console.

Change-Id: I534f5b35456306940a3926f52fe5cce2d5c94da4
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-04-16 05:29:20 +00:00
Daniel Leung cf97ca685e doc: clock_control/stm32f1: Fix @file tag
The @file tag should follow by a file (or nothing for current file),
instead of file description. Fix it by separating the description.

Change-Id: Iabe3550568cdfdda6ad71be6fab3e8b5dfbeb940
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-04-15 22:06:42 +00:00
Tomasz Bursztyka a1adbcb125 ieee802154: Replace the CC2520 driver with a new implementation
This is a complete new cc2520 driver for zephyr. Intention is to fit
better within Zephyr device driver model.

- It's (almost*) ready to be instanciated as many times as necessary
- It's fully interrupt based on SFD and FIFOP (no pin polling)
- It's nicer to other sub-systems (it sleeps, no busy-wait loop)
- It still loosely complies to old legacy radio device driver model

*: GPIO API needs to be fixed in order to accept multiple callbacks, as
well as enabling callbacks to retrieve private data.

Notes:
- Hardware filtering does not work yet as the net stack, above, needs to
  provide the relevant information for it (src/dst ieee802154 extended
  addresses, short addresses...)
- A embryo of generic functions (txpower, channel, addresses...)
  have been implemented but don't belong yet to any radio device driver
  model. Such new driver model will come afterwards (soon?)
- SPI API would need to be improved to avoid as much as possible memcpy
  as well as spi_slave_select() call.

Change-Id: I1fd6dfff28fba3984f6006d394ea12f1e763ac18
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-07 17:25:02 +00:00
Tomasz Bursztyka f7d5d2c8f5 drivers: Renaming directory "802.15.4" into "ieee802154"
ieee802154 is a more relevant name. Applying the change in
include/drivers as well.

Change-Id: I7f7188ed0421045d7667303c375eeb8af1298b97
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-04-07 17:24:55 +00:00
Maciek Borzecki 3f5af00529 clock_control/stm32f10x: introduce driver for STM32F10x RCC
The patch adds a driver for STM32F10x series RCC (Reset and Clock
Control) subsystem.

The module is primarily responsible for setting up of MCU's clock
tree. In particular the driver sets up SYSCLK, PLL (with source
configuration), AHB prescaler, and APB1/APB2 prescalers. As part of this
functionality, the subsystem can enable/disable clock signal for
particular peripherals, thus reducing the power consumption of the MCU.

The driver implements clock control driver API. However, subsystem IDs
being HW specific are exposed in driver public header that must be
included by callers. The driver registers a single device using a common
name STM32_CLOCK_CONTROL_NAME. The device is initialized at
the PRIMARY level with priority 1. This allows the initialization to
take place right after SoC initialization routine.

The driver depends on selection of SOC_STM32F1X config option and is MCU
specific.

Change-Id: I8bea5db20726a24bce7b7ffe0b95de543240429a
Origin: Original
Signed-off-by: Maciej Borzecki <maciek.borzecki@gmail.com>
2016-03-16 18:11:18 +00:00
Jeff Blais 995a9ba72a arm: K64 SPI module driver
Support for Freescale/NXP K64 SPI modules, limited to:

- Master mode
- A single active set of clock and transfer attributes (CTAR0), which
includes non-adjustable delay parameters
- Tx FIFO fill and Rx FIFO drain interrupt handling
- Standard, continuous select and continuous SCK SPI transfer formats

Also, divide-by-zero code generation in this driver is prevented.
The 'volatile' attribute is added to some of the variables in the baud
rate and delay calculation functions of the K64 SPI driver in order to
prevent bad code generation by gcc toolchains for ARM seen when an
optimization setting above -O0 is used.
Specifically, a register is loaded with the constant 0 and is used as
the divisor in a following divide instruction, resulting in a
divide-by-zero exception.
This issue has been seen with gcc versions 4.8.1 (the VxWorks toolchain)
and 5.2.0 (the Zephyr SDK toolchain).

Change-Id: Ib5b2b748aad8fdfd5e8d40544e6e1abef3713abe
Signed-off-by: Jeff Blais <jeff.blais@windriver.com>
2016-03-09 15:50:16 +00:00
Szymon Janc 1b0e961ef2 Fix uart_pipe_send documentation
This function doesn't return number of bytes sent but error code.

Change-Id: Ife5e4d3957226ce2b4283b5d229095db2ac375dc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-08 13:53:26 +00: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
Benjamin Walsh 038790a945 sys_clock/microkernel: do not announce ticks until microkernel is up
This is a prologue to reverting:

	commit 3c66686
	Author: Benjamin Walsh <benjamin.walsh@windriver.com>
	Date:   Tue Feb 9 17:34:02 2016 -0500

		sys_clock: start the microkernel ticker in the MICROKERNEL init level

to allow the devices initializing in pre-MICROKERNEL init levels to poll
the hi-res clock (sys_cycle_get_32()), which relies on the system clock
having been started.

This change allows starting the system clock in the NANOKERNEL init
level by delaying announcing the ticks until the MICROKERNEL init level.

Change-Id: I43d54bb5e2f182d4edd880da0124a0817f911943
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-11 17:10:49 -05:00
Peter Mitsis 8413e1f872 doc: Fix misuse of @file doxygen tag
Summary lines follow the @brief tag instead of the @file tag.

This prevents doxygen build warnings such as ...

    The name xxx supplied as the second argument in the \file
    statement is not an input file

Change-Id: I1014586ad21be12e14aa1d2a942e6b8a11211795
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-11 20:11:03 +00:00
Sergio Rodriguez 4dee326306 tickless idle x86: Tickless idle support on nanokernel for x86
Modifications to timer drivers and interrupt setup, to manage
the tickless idle for the x86 architecture

Change-Id: Ie02d484b7e5636de6ea382ba2eeed57e704c8498
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2016-02-11 19:10:24 +00:00
Tomasz Bursztyka 2b3e60e6df cc2520: Reworking radio on and transmission logic
FIFOP setting is a wrong assumption to know if radio is on.
Transmission runs on clock basis instead of pre-set loop counter. Thus
removing useless config option relevantly as well.
Opmitizing a bit the code as well, and making cc2520_on() public for
testing purpose.

Change-Id: I4495d1d6c19d10dcbc18f7e2fd5041720ec1f438
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:25:23 -05:00
Jukka Rissanen f1563253cf cc2520: Initial checkin for TI CC2520 802.15.4 driver
Integrating it into network stack. Centralizing all in drivers/802.15.4

Change-Id: Ia2916ff652afe5fe736f6560c2ed4a911a5f0679
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:25:23 -05:00
Peter Mitsis a0e4568760 c++: Add extern "C" { } block to header files
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ source files.

Change-Id: Ia4db0c36a5dac5d3de351184a297d2af0df64532
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:25:22 -05:00
Tomasz Bursztyka 13c2b1ac7b spi: Rename files according to rules
Renaming files as:
<domain>_<model or manufacturer>.<c/h>

Change-Id: I018f6fdb4ba8aac8bb96e848f0f3633bd032b44e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:25:21 -05:00
Andrew Boie d9cfbd5a61 interrupts: new static IRQ API
The interrupt API has been redesigned:

- irq_connect() for dynamic interrupts renamed to irq_connect_dynamic().
  It will be used in situations where the new static irq_connect()
  won't work, i.e. the value of arguments can't be computed at build time
- a new API for static interrupts replaces irq_connect(). it is used
  exactly the same way as its dynamic counterpart. The old static irq
  macros will be removed
- Separate stub assembly files are no longer needed as the stubs are now
  generated inline with irq_connect()

ReST documentation updated for the changed API. Some detail about the
IDT in ROM added, and an oblique reference to the internal-only
_irq_handler_set() API removed; we don't talk about internal APIs in
the official documentation.

Change-Id: I280519993da0e0fe671eb537a876f67de33d3cd4
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:17 -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
Dirk Brandewie 788fa782dc iamcu: Fix loapic_mkstub macro to pass isr context value correctly
Change-Id: I4f5bab262171e2d248f7c6fdab960a45a47840a9
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:25:06 -05:00
Daniel Leung 8a3273aeb6 arm/fsl_frdm_k64f: serial/uart_k20: rework UART clock gating
The code to poke the system integration module to disable clock gating
for UARTs only works for UART0-3 since all the bits are in the same
register. However, clocks for UART4 and UART5 are controlled by
another register. This means that we have been writing to the wrong
bit for enabling UART4.

This patch fixes this issue, and moves the clock gating clock into
board initialization. The incorrect code has also been removed to
prevent accidental mis-use. The dev_data struct is no longer needed
for uart_k20, so that is removed as well.

Change-Id: I67845a417e43647bf0ffcbdbda34ce68fa887713
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:06 -05:00
Dirk Brandewie d8a1c8ef17 x86: iamcu: Add support for the IAMCU calling convention.
Add support for compilers conforming to the IAMCU calling convention
as documented by
https://github.com/hjl-tools/x86-psABI/wiki/iamcu-psABI-0.7.pdf


Change-Id: I6fd9d5bede0538b2049772e3850a5940c5dd911e
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:25:06 -05:00
Andrew Boie a664aae335 x86: reduce static IRQ stub size
All of these stubs at the end pop the stack and tell the LOAPIC
that we are at EOI. Put this in common code which falls through to
_IntExit(). Saves 8 bytes per static IRQ stub. There is also small
constant savings in the common code for dynamic IRQs.

Change-Id: If17e9f105928a4251a2cb3fc0d192649c1c4d84b
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:05 -05:00
Andrew Boie 88808f1247 quark_se: apic: work around EOI forwarding issue
Quark SE Lakemont core has a hardware bug where the LOAPIC does
not properly notify the IOAPIC to clear the IRR bit for level-
triggered interrupts.

This patch introduces a workaround where the vector ID of the
in-service interrupt is manually written to the IOAPIC_EOI
register, resulting in the bit being cleared.

Unfortunately, in the context where EOI happens it's very difficult
to identify which IRQ line is being serviced, so this is done
unconditionally for all interrupts vectors whether they are registered
in the IOAPIC RTE table or not.

Change-Id: I639cd258dec4f50934e17eadbb821e6a7112e636
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:25:05 -05:00
Andrew Boie a0e427f8a4 x86: remove loapic_int_vec_trigger()
This was only needed for an older implementation of software interrupts,
now superseded by the irq_offload() API (which doesn't interact with
the interrupt controller at all)

Change-Id: I8aa696d370ae1799872f6d70de69f3cb5b47456a
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:04 -05:00
Andrew Boie 3589695508 ipi: rename to ipm
To many people, IPI connotes inter-processor interrupts on SMP
systems. Rename this to IPM, or Inter-Processor Mailboxes.

Change-Id: I032815e23c69a8297c0a43992132441c240fb71e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:04 -05:00
Andrew Boie 902eb1d5f1 loapic: expose _loapic_isr_vector_get() in header
Other internal functions are shown in this header, no reason to
keep this a secret.

Change-Id: Icb7d36206148c281f1960d1ac10368d9bb3033f1
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:25:03 -05:00
Daniel Leung 77d167d004 ioapic: move common init code into driver
The initialization code and macros are the same. So extracts it
and puts it into the driver. This is another step to follow
the driver model.

Those empty C files are there because the current Kbuild
requires Makefile to be present at those directories,
(due to arch/x86/Kbuild), which requires building some object
files. So the empty source files are there to produce empty
object files to satisfy this.

Change-Id: I14056347ea14cff227d9e8960192e8673c0019b8
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:03 -05:00
Daniel Leung 921ee03094 loapic: move common init code into driver
The initialization code and macros are the same. So extracts it
and puts it into the driver. This is another step to follow
the driver model.

Change-Id: I1d379068f64855d5d4595838040ec50f97f638a0
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:03 -05:00
Daniel Leung 8778152298 i8259: move init code into driver
The initialization code and macros are the same. So extracts it
and puts it into the driver. This is another step to follow
the driver model.

Change-Id: I1af8b2888779b2b58367feaff9ee1a6d97b4873c
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:25:03 -05:00
Johan Hedberg 7ad2d474d8 drivers/console: shell: Decrease maximum line length from 1024 to 256
It's very rare to have lines exceeding 100 characters (default console
width being 80) so 1024 is quite overkill. Even 256 is probably more
than anyone will need any time soon, but if that becomes an issue this
define can be converted to a Kconfig option in the future.

Change-Id: If5fd324b17a0e8ef7b39ea7cc6624739d0241cac
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:58 -05:00
Anas Nashif 275ca60b08 Fixed file description and applied doxygen style
Removed old style file description and documnetation and apply
doxygen synatx.

Change-Id: I3ac9f06d4f574bf3c79c6f6044cec3a7e2f6e4c8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:58 -05:00
Daniel Leung ddab92c23a hpet: move content of include/drivers/hpet.h into driver
The content of include/drivers/hpet.h is really private to
the driver and does not need to be exposed in public include
directory. So move the content into driver code.

Change-Id: Ica442e43c480a6b079b8d3c4e75e67adcfd0ba6b
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:56 -05:00
Daniel Leung 91cea2c9a6 serial/nsim: refactor (again) to conform to driver model
() Rename nsim_uart.c to uart_nsim.c. This is to follow
   the driver naming convention.
() Rename functions nsim_uart_*() to uart_nsim_*(),
   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.

Change-Id: If015f39a6f6b4fcc65625e6e5f973b4469202f54
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:56 -05:00
Daniel Leung d77f6efe03 serial/k20: refactor (again) to conform to driver model
() Rename k20UartDrv.c to uart_k20.c. This is to follow the driver
   naming convention.
() Move driver/serial/k20_uart.h to drivers/serial/uart_k20_priv.h
   as this contains definitions private to the driver, and
   should not be exposed in public include directory.
() Rename functions k20_uart_*() to uart_k20_*(), following
   driver naming convention.
() Renames CONFIG_K20_UART_* to CONFIG_UART_K20_*
() 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.

Change-Id: If1be1fde083aba6ff68062db2059aef08617a286
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:56 -05:00
Peter Mitsis 92b21c7153 timer: Rename _sys_clock_cycle_get()
Renames _sys_clock_cycle_get() (provided by the timer driver)
to sys_cycle_get_32().  It is the preferred method to read the
hardware clock.

Change-Id: Ifea5213d8c04a8bf7b9114b048c5db0ccee61549
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:55 -05:00
Peter Mitsis 7afd7035a2 sys_clock: Replace microkernel _k_sys_clock_tick_count
Replaces microkernel global variable _k_sys_clock_tick_count with the
global variable _sys_clock_tick_count.  This allows both the microkernel
and the nanokernel to use the same variable to track system clock ticks
instead of using two different ones.

Change-Id: Ia4eebf022f59d130ad1882e0e550016527543a45
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:53 -05:00
Peter Mitsis 30bf5c05c8 sys_clock: fix _sys_idle_elapsed_ticks type
Fixes the type of global variable _sys_idle_elapsed_ticks such that
both its nanokernel and microkernel definitions are of the same
type--int32_t.

One of the repercussions of this is that code related to the routine
_nano_sys_clock_tick_announce() does not need the application of
typecasting.

Change-Id: I3d7374cd1a32aea7e4651726febde74ebe4ac8ac
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:53 -05:00
Peter Mitsis 42bb6227dc doc: Change "None" return value to "N/A"
Improves documentation consistency by using "N/A" instead of "None"
when the routine does not return a value.

Change-Id: I429a159b3037742cbc431db0cb4828ab9d6d35c3
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:53 -05:00
Szymon Janc c0baad2262 Rename simple UART driver to pipe UART
Original name was too generic and confusing. This patch renames
driver to pipe UART and moves it to console drivers folder. Kconfig
destription is also improved.

Change-Id: I716fdbf7d636bbdc03b0fce27a59fd866f473246
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:52 -05:00
Anas Nashif 00c4d32d42 x86: add Quark D2000 Interrupt Controller (MVIC)
This module is based on the standard Local APIC and IO APIC source modules.

This modules combines these modules into one source module that exports the
same APIs defined by the Local APIC and IO APIC header modules. These
routine have been adapted for the Quark D2000 Interrupt Controller which has
a cutdown implementation of the Local APIC & IO APIC register sets.

Change-Id: Ic80aa78918483663d76054ebadefa08d8a3f188a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:48 -05:00
Tomasz Bursztyka 714dd9786b clock: add Quark SE clock control
Quark SE provides various clock controllers through its SCSS block.
Peripheral, external, sensor, and others.

This current drivers provides only the clock gating capability, for
peripheral, external and sensor. But it could support divider and more
other features once defined in the generic API.

Note: such clock has _nothing_ to do with a Real Time Clock (RTC).
An RTC provide clock timing like a watch would do. Here the clock
controller is about circuit clocking.

Change-Id: I1a365ae730dfc6be7686271f7fbb693e64a6ff6f
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:48 -05:00
Andrei Emeltchenko 71a19117d6 Bluetooth: Rename __unused to compile with newlib
__unused is define in sys/cdefs.h when building against newlib.

Change-Id: I0fad81dc91e1eb91368b5b3370e3fbb0fb7ba4a9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:24:44 -05:00
Peter Mitsis 0497dabd36 k20uart: Fix uart fifo enabling logic
Change-Id: I9d48f0fb57e975ec336cf8a970c2678b695199a6
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:44 -05:00
Benjamin Walsh ac1148e1de timer: rename SYSTEM_TIMER_DISABLE/timer_disable
Rename them to SYSTEM_CLOCK_DISABLE and sys_clock_disable to put
the symbols in the proper namespace and to align with the rest of
the timer APIs.

Change-Id: I341cdb1bd6cc01e5662d8526c293d4e0acd6ec24
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:43 -05:00
Andrew Boie 5e1ae08765 loapic: get rid of function call overhead for _loapic_eoi()
We generally call this in interrupt code, and since it's just a register
write, get rid of all the function call overhead.

Change-Id: I251fa3cee0841fcdd8eecc7941d4d3782d112e66
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:24:42 -05:00
Andrew Boie b43758d22a x86: remove dynamically generated IRQ and exception code
We are interested in supporting some XIP x86 platforms which are
unable to fetch CPU instructions from system RAM. This requires
refactoring our dynamic IRQ/exc code which currently synthesizes
assembly language instructions to create IRQ stubs on-the-fly.

Instead, a new approach is taken. Given that the configuration at
build time specifies the number of required stubs, use this
to generate a build time a set of tiny stub functions which simply
push a 'stub id' and then call common dynamic interrupt code.
The handler function and handler argument is saved in a table keyed by
this stub id.

CONFIG_EOI_HANDLER_SUPPORTED removed, the code hasn't been conditionally
compiled for some time and in all cases we call _loapic_eoi() when
finished with an interrupt.

Some other out-of-date verbiage in comments related to supporting
non-APIC removed.

Previously, when dynamic exceptions were created a pointer would
be passed in by the caller reserving ram for the stub code. Since
this is no longer feasible, two new Kconfig options have been added.
CONFIG_NUM_DYNAMIC_EXC_STUBS and CONFIG_NUM_DYNAMIC_EXC_NO_ERR_STUBS
control how many stubs are created for exceptions that push
an error code, and no error code, respectively.

SW Interrupts are no longer triggered by "int <vector>" hard-coded
assembly instructions. Instead this is done by sending a self-directed
inter-processor interrupt from the LOAPIC, using a new API
loapic_int_vect_trigger(). In this way we get rid of dynamically
generated code in irq_test_common.h.

All interrupts call _loapic_eoi() when finished, since this is now
the right thing to do for all IRQs, including SW interrupts.

_irq_handler_set() for x86 no longer requires the old function pointer
to be supplied.

Change-Id: I78993d3d00dd153c9051c518b417cce8d3acee9e
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:24:41 -05:00
Allan Stephens d765602ec0 kernel: Minor tweak to generation of microkernel TICK_EVENT
The tick event is now generated by calling the standard API for
signalling an event from an ISR. (This allows the tick event
to be generated properly even if the internal implementation of
the event sub-system changes.)

Change-Id: Ia2be3874358acb0ea2b2d2bbefbe4603fe11da8a
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:24:41 -05:00
Dan Kalowsky 7ed1abfdda checkpatch: warning - new_typedefs
Removing many of the typedefs that are only used once to lessen the
checkpatch warning about creating new typedefs.  A handful have been
behind as they would require a more invasive change to the code.  It
has yet to be determined if this is a worthwhile endavour.


Change-Id: Ibeb29e0a1d37e8121218fccf0d986cbebd226e85
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:41 -05:00
Michael LeMay 2684f4472f pci: Add pci_enable_bus_master
This patch adds the pci_enable_bus_master function that enables bus
master access for a PCI device.

Change-Id: I317daac1a613ccfc5a3894332c1a7dbbff05991f
Signed-off-by: Michael LeMay <michael.lemay@intel.com>
2016-02-05 20:24:38 -05:00
jkruger 9f49db54fa ioapic.h: prevent potential compiler warning
Includes device.h to prevent potential compiler warnings due to use of
'struct device *' in _ioapic_init() declaration.

Change-Id: Iabd97c09385044a3742658f66a79be969b62852a
Work-by: Johan Kruger <johan.kruger@windriver.com>
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:24:37 -05:00
Andrew Boie 090385b666 x86: remove boi handler support, eoi argument
This was only needed for the older 8259A style PICs which are no
longer supported.

Since we now just support APIC, we always just call loapic_eoi which
no longer requires an argument and informs the IOAPIC that the interrupt
is complete if necessary.

Change-Id: I15c9b7b4f03b872656220af32220b62e043bfa6b
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:24:35 -05:00
Dan Kalowsky 890cc2f1ef checkpatch: warning - line_spacing
Change-Id: I2276676142deea21cf8079449ce153f2fb887a8e
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky e8563c2f97 checkpatch: error - trailing_whitespace
Change-Id: I819d13f0d7a23e3a61dcda6a3ced18810b192158
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky da67b29569 checkpatch: warning - block_comment_style
Change-Id: I6da43e41f9c6efee577b70513ec368ae3cce0144
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Tomasz Bursztyka 17e06fb457 uart: Move generic API to root directory of include
Only driver specific public headers should be found in include/drivers.
All generic API are found in include/ directory.

Change-Id: Ic50931987bb9460fd4a3843abc6f5de107faf045
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:32 -05:00
Dirk Brandewie ad5af93f25 x86: Add context value to loapic_mkstub and ioapic_mkstub macros
Add a context value to the ioapic and loapic mkstub macros to allow
the developer to specify a context value that will be passed on the
stack to the interrupt service routines.

All the invocations for the loapic_mkstub and ioapic_mkstub macros
have been changed to pass in 0 so there is no functional difference
ATM.  This change removes the need for drivers to have trampoline ISR
routines to pass a context vaule to their generic ISR routine.

This is the first step in getting rid of the hack where the driver
needs to look into the __initconfig_* linker objects.

Change-Id: I2c5eaa20d8cb5a42ef445762c426854be32c8452
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky 39063598db checkpatch: error - spacing
Change-Id: Ie6e1c43581dd4b0734625b3a4e59a4ca79619e99
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky 978851fb6a checkpatch: code_indent failures
Corrects the checkpatch code_indent failures

Change-Id: I2ff93b8907d3eddbaa543ccbd12aecef8af7f698
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Tomasz Bursztyka 6090d779d7 spi: intel: Move back private structures to the right locations
Since the driver is the only one needing those, no need to expose them
anywhere.

Change-Id: Iac4eaa65a9dbdaa8e72c70ea0de35cd2b3d836d1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:27 -05:00
Tomasz Bursztyka 15058e21ef spi: intel: Fixing how speed is set
This was failing, the documentationg provides numbers only telling at
one places these are hexadecimal values. So switching to hexadecimal.
Then DDS rate retrieving macro was bogus, so fixing it.
And adding debug output about the DDS rate and the clock ratio.

Change-Id: I9cc414796fbd7f7123f1f406c6bce7ffacf641e8
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:27 -05:00
Daniel Leung 7551562a14 uart: make poll_in and poll_out mandatory
Polling in/out are basic UART functions that are supposed to
work on every UART controllers. Therefore, both poll_in and
poll_out are now mandatory. The API no longer checks if
they are defined before calling. This is to avoid the if
statements so to speed up things a bit.

Change-Id: I3bd1e7a2dfa5405699ebaec3eb34cfc0434b0073
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:24:27 -05:00
Dmitriy Korovkin 13b3e2a127 Add PCI legacy bridge device driver
PCI legacy bridge is a device connected to PCI bus and
allowing to program the routes from interrupt pins to IRQ
numbers.

Change-Id: I129719d71f958bbf5ad8c5c9949dcea93d94b89d
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:24:23 -05:00
Tomasz Bursztyka 4cace6d2d7 spi: Add the CS pin control over GPIO for intel spi port 0
This is specific to Galileo board where its SPI port 0 needs to setup
the CS pin through a GPIO pin.

Change-Id: I9df6f7144a96bcd10f61fc7d057f89caa0e599d1
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:24:22 -05:00
Dirk Brandewie 25c9d021a5 x86: move IOAPIC driver to device model/init system
Change the IOAPIC driver to be initialized directly from the init
system. The function signature of _ioapic_init() function is updated
accordingly.

Change-Id: I2f824ac745926966eebb23f60445a41e1df9eb8f
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:18 -05:00
Dirk Brandewie be1b1a4e35 x86: move LOAPIC driver to device model/init system
Change the LOAPIC driver to be initialized directly from the init
system. The function signature of _loapic_init() function is updated
accordingly.

Change-Id: I5ed26d53524c8526d413a05ac9a7a58dd4264c5a
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:17 -05:00
Dirk Brandewie 1bcb7a339a x86: Move PIC driver to device model/init system
Change the PIC driver to be initialized by the init system. To be
initialized by the init system the function signature of the
_i8259_init() function needs to be changed to the standard *_init()
function signature specified by the device model.

Change-Id: I63bf1cd0ce78920fa20da94f5966e5aab4bf41b2
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:24:17 -05:00
Andrew Boie 2a1e4266e8 IPI console driver with test case
This introduces a generic driver set for console messages routed over
inter-processor interrupt (IPI) channels. These drivers bind to a
low-level IPI driver instance for the actual transport of messages.

ipi_console_sender installs printk and/or stdout hooks to forward
messages over IPI. There is currently no buffering on the sending side.

ipi_console_receiver installs an IPI callback which stashes incoming
characters into a ring buffer, which is monitored by a nanokernel
fiber. The fiber buffers the characters on a per-line basis and sends
them to either printk or stdout. Multiple instances of this driver
may be created in case you need to receive console data from multiple
CPUs.

Change-Id: Icebc110794fbe040f975101cd2ae6e78fb38645a
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2016-02-05 20:24:17 -05:00
heeleyth df0fd2c8cc ioapic: do not check for CONFIG_IOAPIC from ioapic.h
Match loapic.h and allow 'ioapic like' drivers to export same ioapic
interface.

Change-Id: Ia2e5380cf9c3fc72e27beb198013e7416daa6aca
Signed-off-by: heeleyth <thomas.heeley@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:17 -05:00
Dirk Brandewie dbd25aeb3b x86: Change SHUTOFF_PIC to PIC_DISABLE
Make config variable name match the function.  The PIC is never turned
on in the zephyr code so there is nothing to shut off.

Change-Id: I1627e5a35cc37ef7959f36758c1e1aec03e22782
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:15:41 -05:00
Adrian Pochiu 70603a5144 Add option to enable HW flow control for UART
Change-Id: I151b3c6516b9b5a38ab0da2948c951eb69d57498
Signed-off-by: Adrian Pochiu <adrianx.pochiu@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:15:35 -05:00
Tomasz Bursztyka 1e39d6274b uart: Properly integrate driver config within PCI context
- Makes the code simpler in driver side
- Configuration is done on platform's config.c file and not the driver
- Handles CONFIG_PCI_ENUMERATION setting

Change-Id: I9b8376cebd7e0b62279251da132a2c4ee7b2e148
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:32 -05:00
Tomasz Bursztyka e4479cd0cf spi: Handle the support for PCI_ENUMERATION
Without it, it won't go through a pci scan, and will just trust the
pre-set information for the bus/dev/function to enable the memory
mapped registers.

Change-Id: Ica9156be541619dce9684dd45f70e05b69782a7c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:32 -05:00
Tomasz Bursztyka ff3f81b44c pci: Make use of pci_show without #ifdef
This will make code that use it not too crowded with #ifdef #endif

Change-Id: Iec0fa662445b1cefdc7c64d9483e1ae483106a90
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:32 -05:00
Tomasz Bursztyka 018bcfe8d4 pci: Add an option for enumerating PCI devices
This option will be used to disable PCI enumeration (not PCI bus) to
gain in code size and execution as long as driver will be properly
configured statically. Thus setting this option as set by default.

Change-Id: I7da5d154c8ee89e44fc2bad8e85a5a20f498927e
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:32 -05:00
Tomasz Bursztyka d96943b04c spi: Add support for Intel's SPI controller
Such controllers are found in Quark's X1000 series, and thus are found
on Galileo boards v1 and v2.

Change-Id: Ib71486c9f27de1b6c48ce3cb3dd138d69833c2ea
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:15:28 -05:00
Tomasz Bursztyka 7b34e0dcfa pci: Add helper functions to enable mem mapped registers
This will be useful to enable memory mapped registers for PCI based
drivers that requires it. Removing redundant setting as well.

Change-Id: I52e47d01263a2de31c0c9f52ff65cc7e2734cf08
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:28 -05:00
Tomasz Bursztyka ff39559146 pci: Add support for filtering by function
This will be useful for PCI based drivers to integrate fully within
the device driver model, where they will have to provide the function
they are found.

Change-Id: I7d64a4c6727cee52cbcb743c859cda43ac1a853b
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:15:28 -05:00
Benjamin Walsh 87eeaa3249 sys_clock: rename timer_read to _sys_clock_cycle_get
Follow coding conventions.

Change-Id: I3ca5d1cf4eaacfc09d5e8c44c49be447549537c8
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:15:27 -05:00
Daniel Leung 94718c7392 uart: change inline functions to static inline
When compiling with optimization level 0 (-O0), the linker complains
about missing references to uart functions. This is due to compiler
treating this functions as extern, since -O0 disables function inlining,
as described in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49653

So change the declaration to static inline.

Change-Id: I59607cffbd1cae141a9eeaca699549ebf8203061
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:26 -05:00
Daniel Leung 8729b3c802 k20: sim: clean up camel case and doxygen for file description
This converts away from camel case according to the coding style.
Also, the file description has been made into doxygen style.

Change-Id: Ib4dd85a4a96e4e87279c92fa243d3f860ebe63f2
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:26 -05:00
Daniel Leung bd2e264d26 serial: k20: cosmetic changes to comments
Converts the file description to doxygen format, and updates
the information inside. Also removes empty lines, updates
the comments for function, and adds missing comments.

Change-Id: I7610e8667cd85feb0c4c853b44880f7e29b6c05a
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:26 -05:00
Daniel Leung e424f1bee1 serial: k20: clean up camel case and function declarations
Clean up variables and function arguments to conform to coding
style. Also align the function argument list.

Note that this only changes the parts related to UART.

Change-Id: I84a6ba88963784f6ddc77d5bda653a7d2de6a72b
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:26 -05:00
Daniel Leung e564035521 serial: rename struct field int_pri to irq_pri
This is just a cosmetic change to unify anything interrupt related
under 'irq'.

Change-Id: Ib8804d194e11eb49526fda952d9efc0f2ffac2df
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Daniel Leung 40147440f5 serial: utilize dev->driver_api for new driver model
This is the final step to convert serial to the new driver model.
The dev->driver_api is now being used by individual drivers.

As a side effect, it is now possible to build multiple serial
drivers in the final image (though it won't make much sense).

Change-Id: I5d864e6503a5431b29006c311320155adf81cf5b
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Daniel Leung ad2d29689e console: uart_console: decouple uart console init from UART init
With this, the UART console has its own initialization which is not
dependent on UART init routines.

This will allow the app to utilize all UARTs for other purposes,
instead of always reserving one for console. Future patch
will enable this choice.

Note that the console init is effectively demoted to pure_init
from pure_early_init. The UART console depends on UART being
initialized, but there is no deferred init at this point.
So this initializes the console a bit later than UARTs,
simply to make sure the UART is initialized before using it.
Once there is a mechanism for some type of deferred initialization,
the UART console init can be promoted back to pure_early.

Change-Id: Iba95197b13384cb1a46e34c78638348b7a0bec8c
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Daniel Leung 2fd29e2667 serial: converting to new driver initialization model
This restructures the device structs and now utilizes the new
driver initialization model. This is another step towards
converting the serial driver to the new driver model.

Note that the serial driver does not initialize the hardware
unless it is being used by another driver. The configuration
of the serial port needs to be done by the driver utilizing
the port (e.g. baud rate, interrupt priority, etc.).
Therefore, some serial ports are declared but not exactly
configured.

Also note that the UART console is being initialized at
the same time as the serial port. This will be removed
in future patch, so the UART console driver will do
its own initialization.

Change-Id: Idd89954b2d0649a557ba8c869ee96512fec898e4
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Daniel Leung 1ad2a56ee3 serial: rework functions to use struct device...
... instead of an array index to a global array. This is
an intermediate step to make the drivers conform to
the new driver model.

This only changes from using a direct array index to using
device structs. The UARTs are still staticlly defined.
Later patches will make the drivers utilize the driver
initialization procedure specified by the driver model.

Change-Id: I18041bbb4b0efdf8ae87088fd000b391d0827e9b
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2016-02-05 20:15:25 -05:00
Peter Mitsis c963861d47 Remove PIC code, but not PIC disabling code
Removes the non-PIC disabling PIC code as the PIC is not a supported interrupt
controller.  The PIC disabling code remains as it is needed to prevent the
generation of spurious interrupts from the PIC (see CONFIG_SHUTOFF_PIC).

Change-Id: Ic59aa17ab96f34685a5d7b5f24cab391de47edca
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:15:20 -05:00
Peter Mitsis 578d417e87 Use HPET timer Kconfig options
Removes the HPET timer macros from board.h and uses the HPET timer Kconfig
options in their stead.

Change-Id: Ia0b3cd87716277ac25f12deb31d5c5934f355050
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:15:19 -05:00
Peter Mitsis 7cbad4e7dd Remove references to BSP from include/ directory
Removes references to obsolete BSP terminology.  Where appropriate, replaces it
with platform terminology.

Change-Id: If38c859338c7cf0de58430336e1046b28f9e9944
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:43 -05:00
Peter Mitsis 6e95fe0356 Update _sys_clock_driver_init() interface
Prepares the _sys_clock_driver_init() routine to interface with the new driver
model.  To this end, it must accept a pointer to a device structure and return
an integer.

Change-Id: I3c600ce1efb49c0864aae7b09663ca40d6289372
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:37 -05:00
Peter Mitsis 1bafa75ef1 Rename timer_driver() to _sys_clock_driver_init()
The revised name conforms to Zephyr OS naming conventions.

Change-Id: I5bcdaf1df7da9d8ce5787a08b29ead91dd8f24ce
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:33 -05:00
Peter Mitsis 136bef3c5d timer_driver() no longer takes a parameter
Removing the parameter to timer_driver() as it is not used.

Change-Id: I09275287eeb541be0dd315056b4f2bc6cbc2573c
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:33 -05:00
Anas Nashif f367f071b6 doxygen: add @brief and capitalize
Remove function name from comment and add @brief instead.
Also capitilize first letter.

Change-Id: Ib708b49bf02e5bc89b0066637a55874e659637e0
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:33 -05:00
Anas Nashif 1362e3c162 doxygen: RETURNS: -> @return
Previous comment style used RETRURNS:, use @return to comply
with javadoc style.

Change-Id: Ib1dffd92da1d97d60063ec5309b08049828f6661
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:32 -05:00
Anas Nashif ea0d0b220c doxygen: change comment style to match javadoc
The change replaces multiple asterisks to ** at
the beginning of comments and adds a space before
the asterisks at the beginning of lines.

Change-Id: I7656bde3bf4d9a31e38941e43b580520432dabc1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:32 -05:00
Anas Nashif 20764a2e8d doxygen: javadoc style
Change all occurances of /*! to /** to match javadoc
style.

Change-Id: I3a759d34e0e928216f61252682266e64c5b875f8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:32 -05:00
Oleg Zhurakivskyy e5cdfc8ecc uart: Get rid of camelCase style
Change-Id: I3b0f0c3ead18416105a356794b6c79444f7e29cf
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2016-02-05 20:14:27 -05:00
Oleg Zhurakivskyy 58dbcfd589 Expose uartGenericInfoInit()
This is helpful when working with UART through dynamic
interrupt stubs.

Change-Id: I91d64f575aa755fcfd894d678a1c078219447f16
Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
2016-02-05 20:14:27 -05:00
Dmitriy Korovkin 8d065343c2 Use static interrupt registration in device drivers
Make device drivers use static interrupt registration procedure.

DYNAMIC_INT_STUBS configuration parameter was used only by device
drivers to switch between static and dynamic interrupt registration
procedures. Now it is obsolete and is removed.

uart_int_connect() function is removed. If UART device driver still
needs to register interrupt dynamically, it should use
irq_connect(uart_irq_get()).

Change-Id: I80c695f337456e9b0c1b0fd56716e35794f7bdb7
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:14:25 -05:00
Dmitriy Korovkin 6dd108a263 IRQ_CONNECT_STATIC implementation for x86 platform
In order to simplify x86 interrupt stub creation, each interrupt
controller implements an interrupt stub definition macro.

Add IRQ_CONNECT_STATIC() for static interrupt registration, and
construct the interrupt stubs name from device and interrupt
handler names.

Add IRQ_CONFIG() macro for the interrupt controller configuration.
On x86 platform it programs APIC to associate an IRQ number with
the interupt vector.

Add HPET_TIMER0_INT_PRI parameter to Quark platform header to
make it build correctly.

Change-Id: I24ad25e1aa807ffa63733a27ad882877fcad72af
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:14:25 -05:00
Benjamin Walsh 617f9c5b4c nanokernel: allow nano time tracking to be used in microkernels
The nanokernel time tracking code (ticker) can now exist in microkernel
systems. This allows the ticker that drives nano timers and timeouts to
advance the tick count for these in a microkernel, thus allow their
presence there. Previously, nano timers could not be used in a
microkernel.

Change-Id: I17f2b659691a081b0f9bf3961ed030533aa02a15
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:14:22 -05:00
Benjamin Walsh 6b8589612f sys_clock: rename nanokernel's _do_sys_clock_tick_announce
Rename nanokernel's _do_sys_clock_tick_announce() to
_nano_sys_clock_tick_announce() so that it can be called from the
microkernel tick handling code without name ambiguity.

Change-Id: I2ec9dd92ceda51f00be1dd95bc3239d6b2e82943
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:14:21 -05:00
Dirk Brandewie 526e132eb1 x86/bsp: move PIC (i8259) driver to drivers/interrupt_controller
Change-Id: I383424667f291ad4985781a7e6566c01c76ba5e0
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:14:20 -05:00
Szymon Janc 6d27b0a33c Add simple UART driver
This driver is a very simple UART driver that can be used to implement
a protocol in application. It has no protocol logic and just allow
application to receive and send data over UART in platform independent
manner.

API is designed to minimize number of required memory copies.
Application is able to provide new buffer every time it decides to
consume received data. It is also able to just alter offset and
reuse current buffer eg if data was corrupted or otherwise invalid.

Change-Id: I8d3827fe2e242196e986d0419bc5487357481558
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:16 -05:00
Allan Stephens bb9ab0322e Eliminate unnecessary references to cpu.h and cputype.h
Gets rid of places where there is no need to include these files
at all, or places where these files are being indirectly included
due to the inclusion of nanokernel.h.

Change-Id: I7b58148af454b977830c00a6b519a78d0595603b
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
2016-02-05 20:14:14 -05:00
Peter Mitsis db8a41c90d Replace use of __attribute__((packed)) with __packed
The __attribute__ keyword is toolchain specific.

Change-Id: Ia3c0ff54d778785679c864704f8db6a3ba898948
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:14:13 -05:00
Dmitriy Korovkin ec8a461bfb Introduce public APIs for random number generation
Convert the existing non-public random number generation APIs
into public APIs (i.e. sys_rand32_init and sys_rand32_get).

Change-Id: Id93e81e351a66d02c08cf3f5d2dd54a3b4b213c5
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:14:12 -05:00
Dmitriy Korovkin a91736ab9a Convert PCI_DEBUG parameter to a configuration parameter
Change-Id: Ie0272b52bbba56e3381cf33fded873aaa0709af6
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:14:11 -05:00
Dmitriy Korovkin 627155afeb PCI scan by BAR number
Added BAR (Base Address Registers) as a parameter for PCI scan.
Some devices (as UART in Quark) use two set of BARs for different
purposes. A driver may require only one of them.

BARs are numbered from 0 to PCI_MAX_BARS.
PCI_BAR_ANY means ignore the BAR number. Constants are defined
in drivers/pci.h

If device class is not specified as a scanning parameter, and
set to 0, ignore it.

Change-Id: I6b7116c5c6cf9c470ab22bec9eb74842f15b5d99
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:14:11 -05:00
Tomasz Bursztyka 0b4413d607 uart: Removing driver specific informations from the generic API
IRQ and registers are hardware and driver specific information and as
such should no be exposed through the generic API.

Change-Id: I33e6d7ec7bd9fb82a4e343d99b7a5c17886d1470
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:14:01 -05:00
Tomasz Bursztyka 0a7c8ea578 uart: Follow the same parameter naming everywhere
Just a tiny change s/which/port.

Change-Id: I69be83f9805d71f5ec0ad68b146816d2a4fe221a
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:14:01 -05:00
Tomasz Bursztyka d3a4177d92 pci: Provide a simpler yet powerful PCI enumeration API
This fixes many issues around PCI enumeration from old API:
- a static internal table was fed with scanning results, thus eating
  memory, and worse: due to the limit of its size, scanning for new
  classes was impossible unless growing statically the size of this
  table --> more memory eaten! Not to mention PCI enumeration is done
  once at boot time for driver initialization and that's all, so this
  table is hanging around for nothing afterwards.
- one needs first to scan a class, then maybe he will be able to find
  his device via pci_dev_find. Where all could be done at once.
- pci_dev_find was not trustworthy due again to the internal table. Now
  if the device is not found, one will know it really went through all
  the possbilities.
- still let the possibility for hard-coded BARs value on driver side
  (thus no PCI scan required). However this is greatly advised not to do
  so as BARs might change over a firmware/BIOS update.

Comparison:

old pci_dev_scan: could only filter out via class mask.
new pci_dev_scan: can filter out via a class, a vendor and device ID
(it could easily do the same for Function and BAR index as these are
usually fixed and informed through datasheet)

old pci_dev_scan: was limited in its findings by the size of the
internal result table.
new pci_dev_scan: can proceed through all the buses and devices every
time (there are optimizations to avoid useless work of course)

old results did not tell about the function or BAR index.
new one tells, and the structure has not bloated.

old internal code: was storing a big table of results
new internal code: is only storing a small lookup structure and an
array of Bus:Dev pairs for each PCI class for optimizations purpose.
(though, if needed, we could disable this through some #ifdef)

Usage:

- Have a local struct dev_info
- Fill it with what you want to look for, currently: only class and
  vendor_id/device_id. Function and BAR index could be added if needed.
- Call pci_bus_scan_init(): this will reset the internal lookup
  structure.
- Call pci_dev_scan(<a pointer to your dev_info>): at first call, the
  internal lookup structure will pick up the informations from dev_info
  and will try to find out what has been requested. It will return 1 on
  success, or 0. On 1, your dev_info structure will be updated with the
  found informations. If more devices can be found against the same
  lookup informations, just call again pci_dev_scan(<a pointer to your
  dev_info>) as long as it returns 1. When 0 is hit, it will mean you
  found all.

Change-Id: Ibc2a16c4485ee3fed7ef4946af0ece032ae406e4
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2016-02-05 20:14:01 -05:00
Dirk Brandewie 1a159cb3f5 loapic: Expose APIC LVT mask definition
When the local APIC timer driver is configured into the system it needs to
ability to enable/disable the local APIC timer. The definition of the
LVT mask bit was moved into the APIC interrupt driver as part of the
driver reroganization effort. Move the definition to the public header
file.

Change-Id: I8e7f8eab9f39aa17b96079836c182bde6f7b4fd1
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:00 -05:00
Yonattan Louise dbada63eee Fix coding style issues.
Some checkpatch issues were solved by scripts leaving other problems
such as alignment and indentation issues.  In order to comply with the
defined coding style the following fixes were made:

- Fixed the function declaration moving the parameters' comments above
  the function in accordance to the doxygen format.
- Fixed functions' opening and closing brackets. These brackets should
  not be indented.
- Fixed the 'if', 'for' and 'while' statements adding the brackets
  around the sentence.
- Fixed comments' alignment.
- Fixed indentation.

The work was done manually and submitted as one commit. I didn't
separate these changes in different commits because they were fixed all
at once. Basically, all errors were fixed in every file at once.

Change-Id: Icc94a10bfd2cff82007ce60df23b2ccd4c30268d
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:13:59 -05:00
Benjamin Walsh 153503d766 timer: micro/nano abstraction for announcing tick
The gain is two-fold:

- Removes the need of preprocessor conditionals in the timer drivers'
  ISRs.
- Allows removing the duplication of the 'tick announce' code across
  all timer drivers.

Change-Id: I6078a0b00a833c1d1ca76474987c3214a0c05f7b
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:13:59 -05:00
Andrei Emeltchenko 879541a918 console: Refactor serial console interface
Make serial console interface more robust. Enables interrupts only
when registering input, all memory is managed inside application.
Interface to application is changed to have two fifo queues. One
queue is a free line slots and another queue is keeping entered
lines. This way memory for lines is managed inside application which
provides free lines queue. It is also simpler to manage entered
lines by sleeping on fifo_get on app layer.

Change-Id: I4776c03eddd1e7d880df3b902bd48f5f2c901cad
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Tomasz Bursztyka 40b1080150 pci: Put the public API header in the right location
Instead of drivers/pci/, the public API headers will be found in
include/drivers/pci.

Change-Id: I577036660383e6bd9c015d6bbbcbc14bf8fb67ec
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:13:48 -05:00
Tomasz Bursztyka ae09a48a7e console: Put the public API header in the right location
Only moving the header from drivers/console/uart_console.h to
include/drivers/console/uart_console.h so source file did not need to be
changed, only the defs.objs files to look into include/drivers/console.

Change-Id: I585e16b50d9ffecf01ca9225e80f0e101f62ee4c
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:13:48 -05:00
Dmitriy Korovkin 7a3ee5e95e Rename driver header files according to naming standard
Change-Id: Ib384fd93c3d35abab1754b37d6464ff7dfe4a893
Signed-off-by: Dmitriy Korovkin <dmitriy.korovkin@windriver.com>
2016-02-05 20:13:40 -05:00
Inaky Perez-Gonzalez 8ddf82cf70 First commit
Signed-off-by:  <inaky.perez-gonzalez@intel.com>
2015-04-10 16:44:37 -07:00