diff --git a/ChangeLog b/ChangeLog
index a8f56d1e8e29d6f474086d1e463552dbb50622f4..4c5c42b1341bee25e531ceefb51f22f464d04270 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -1676,7 +1676,7 @@
* configs/*/ld.script: Removed 'sh_link not set for section .ARM.edix' for
a few of the builds. In you have this warning, it can be removed with the
following change to the ld.script file:
-
+
+ __exidx_start = ABSOLUTE(.);
.ARM.exidx : {
- __exidx_start = ABSOLUTE(.);
@@ -4374,7 +4374,7 @@
significant amounts of time (2013-03-18).
* arch/arm/src/armv7-h/ram_vectors.h, up_ramvec_*.c, arch/arm/src/*/*_irq.c,
and Make.defs: Add support for modifiable interrupt vectors in RAM
- (2013-03-18).
+ (2013-03-18).
* arch/arm/src/armv7-m/up_exception.S, sam3u/sam3u_vectors.S, and
lpc17xx/lpc17_vectors.S: In exception handling with CONFIG_NUTTX_KERNEL,
need to explicity set and clear the privilege bit in the CONTROL
@@ -12393,7 +12393,7 @@
(2016-07-23).
* Freedom-K64F: Add PWM support. From Jordan MacIntyre (2016-07-25).
-7.18 2016-xx-xx Gregory Nutt
+7.18 2016-10-08 Gregory Nutt
* drivers/serial/pty.c, serial.c, usbdev/cdcacm.c, include/nuttx/fs/ioctl.h:
Fix FIONWRITE and add FIONSPACE. All implementations of FIONWRITE
@@ -12672,3 +12672,689 @@
Vyhovanec (2016-09-02).
* MTD: SPI-based driver for Macronix MX25L3233F or MX25L6433F. From
Aleksandr Vyhovanec (2016-09-02).
+ * sched/: The TCB nchildren field should not be incremented when
+ pthreads are created (2016-09-06).
+ * sched/: Move fields related to parent/child task relationship out of
+ TCB into group structure (2016-09-06).
+ * STM32L4: Add support for USART3-USART5. For STM32L4 parts, the higher
+ number USART ports supported varies. Add the HAVE_USARTx definitions
+ to the configuration to allow enabling the higher numbered USART ports.
+ From Jim Wylder (2016-09-15).
+ * configs/stm32l476-mdk: Support basic booting and nsh on Motorola MDK.
+ The Motorola MDK is based off of an earlier version of NuttX. This
+ only provides a basic NSH shell. From Jim Wylder (2016-09-15).
+ * STM32 USB: Set USB address to avoid a failed assertion. From Pierre-noel
+ Bouteville (2016-09-15).
+ * STM32 L4 and L7 USB: Pierre's assertion-avoidance change should also be
+ applied to STM32 F7 and L4 (2016-09-15).
+ * sched/: mq_send() was not setting the errno value on certain failures
+ to allocate a message (2016-09-15).
+ * include/nuttx/modem: Move all modem-related IOCTL commands to a common
+ file to assure that they will be unique (2016-09-16).
+ * STM32 F4 Discovery: Add support for XEN1210 3D-board. From Alan
+ Carvalho de Assis (2016-09-17).
+ * drivers/sensors: Adds support for the Sensixs XEN1210 3D-board. This
+ sensor is used on NANOSATC-BR2 a Brazillian CUBESAT project. From
+ Alan Carvalho de Assis (2016-09-16).
+ * include/analog/dac.h: Make DAC structure packed. From Marc Rechté
+ (2016-09-20).
+ * All SAM Ethernet Drivers: Add support so that the drivers can be built
+ with CONFIG_NET_MULTIBUFFER=y (2016-09-20).
+ * Tiva Ethernet: Needs support for CONFIG_NET_MULTIBUFFER=y (2016-09-20).
+ * drivers/net: NET_TUN=y => NET_MULTIBUFFER=y. From Vladimir
+ Komendantskiy (2016-09-20).
+ * SAM3/4: Fix GPIO pull-up/down code. Enabling the pull-down resistor
+ while the pull-up resistor is still enabled is not possible. In this
+ case, the write of PIO_PPDER for the relevant I/O line is discarded.
+ Likewise, enabling the pull-up resistor while the pull-down resistor
+ is still enabled is not possible. In this case, the write of PIO_PUER
+ for the relevant I/O line is discarded. From Wolfgang Reißnegger
+ (2016-09-20).
+ * SAM GPIO: Apply Wolfgang's change for SAM3/4 to SAMA5 and SAMV7
+ (2016-09-20).
+ * Tiva QEI: Add QEI lower-half driver impl. for Tiva series chip. From
+ Young (2016-09-21).
+ * STM32, L4, and F7: Remove GPIO_ETH_RMII_TX_CLK. TX_CLK is not present
+ in RMII. Mateusz Szafoni (2016-09-22).
+ * sched/: Define 'group' even if HAVE_GROUPID is not set. From Mateusz
+ Szafoni (2016-09-22).
+ * sched/: vector table should have dimension NR_IRQS, not NR_IRQS+1.
+ From Sagitta Li (2016-09-22).
+ * fs/mount: Corrects a bad assertion noted by Pierre-noel Bouteville.
+ Also fixes a reference counting problem in an error condition: When
+ the mountpoint inode is found but is not an appropriate mountpoint,
+ the reference count on the inode was not being decremented (2016-09-22).
+ * libnx/nxglib: Fix handling of near-horizontal lines of width 1 in
+ nxgl_splitline(). Missing handling for degenerate condition caused
+ width 1 lines such as (0, 0) - (100, 10) to have gaps in the drawing.
+ From Petteri Aimonen (2016-09-22).
+ * drivers/net/slip.c: Fix calculations using MSEC_PER_TICK. If
+ USEC_PER_TICK is less than 1000, then MSEC_PER_TICK will be zero. It
+ will be inaccurate in any case (2016-09-25).
+ * Tiva QEI: Add a new ioctl command (set MAXPOS) for tiva QEI. From
+ Young (2016-09-26).
+ * LPC43xx Serial: There are some small problems in LPC43xx RS485 mode
+ configuration. In particular: (1) UART0,2,3 do not have DTR pins
+ (different from UART1), so, Kconfig needs to be adjusted. (2)
+ lpc43_uart.c in RS485 mode only configures DIR pin, but doesn't enable
+ pin output for UART0,2,3. (3) should be option to reverse DIR control
+ pin output polarity. (4) lpc43xx/chip/lpc43_uart.h doesn't have USART3
+ definitions. NOTE: I didn't modified and didn't tested USART1, as it
+ has different hardware. From Vytautas Lukenskas. From Vytautas
+ Lukenskas (2016-09-30).
+ * STM32 Ethernet: Correct typo in conditional logic. From Neil Hancock
+ (2016-10-01).
+ * sched/pthread and task: When a pthread is started, there is a small
+ bit of logic that will run on the thread of execution of the new
+ pthread. In the case where the new pthread has a lower priority than
+ the parent thread, then this could cause both the parent thread and
+ the new pthread to be blocked at the priority of the lower priority
+ pthread (assuming that CONFIG_PRIORITY_INHERITANCE is not selected).
+ This change temporarily boosts the priority of the new pthread to at
+ least the priority of the new pthread to at least the priority of the
+ parent thread. When that bit of logic has executed on the thread of
+ execution of the new pthread, it will then drop to the correct
+ priority (if necessary) before calling into the new pthread's entry
+ point (2016-10-01).
+ * configs/stm32f103-minimum: Add stm32_bringup support and userled
+ example to STM32F103 Minimum board. From Alan Carvalho de Assis
+ (2016-10-02).
+ * STM32 L4: Add support for quadrature encoders on STM32L4. Sebastien
+ Lorquet (2016-10-02).
+ * configs: Add support for qencoders on various nucleo boards. From
+ Sebastien Lorquet (2016-10-03).
+ * STM32 L4 USB Device: Fixed L4 USB Driver by avoiding SETUPDONE and
+ EPOUT_SETUP. From David Sidrane (2016-10-04).
+ * configs/olimex-stm32-e407: Add some networking configurations. From
+ Mateusz Szafoni (2016-10-06).
+ * STM32 SPI: stm32_modifycr2 should be available on all platforms if DMA
+ is enabled. (2016-10-06).
+ * STM32 DMA2D: fix an error in up_dma2dcreatelayer where an invalid
+ pointer was returned when a certain underlying function failed. From
+ Jens Gräf (2016-10-07).
+ * include/nuttx/fs/nxffs.h: Needs forward reference to struct mtd_dev_s
+ and needs to include stdbool.h (2016-10-09).
+ * STM32F103 Minimum: Note in Kconfig that the board supports buttons.
+ From Alan Carvalho de Assis (2016-10-11).
+ * STM32F103 Minimum: Add button support. From Alan Carvalho de Assis
+ (2016-10-11).
+ * arch/arm/kinetis and configs/freedom-k64f: Add UID Unique ID. From
+ Neil Hancock (2016-10-13).
+ * arch/arm/src/stm32l4: (1) too many parentheses when calculating max
+ chan count and (2) channel 4 does not have a complementary output. From
+ Sebastien Lorquet (2016-10-14).
+ * arch/arm/src/stm32l4: Support Complementary PWM outputs on STM32L4.
+ From Sebastien Lorquet (2016-10-14).
+ * Support PWM testing on board nucleo-l476. From Sebastien Lorquet
+ (2016-10-14).
+ * arch/arm/src/stm32: Support oversampling by 8 for the STM32 F4.
+ From David Sidrane (2016-10-15).
+ * libc/stdio: Fixes sscanf %sn where strlen(data) < n. From David
+ Sidrane (2016-10-15).
+ * arch/risc-v: Add support for the RISC-V architecture and
+ configs/nr5m100-nexys4 board. I will be making the FPGA code for
+ this available soon (within a week I would say). The board support on
+ this is pretty thin, but it seems like maybe a good idea to get the base
+ RISC-V stuff in since there are people interested in it. From Ken
+ Pettit (2016-10-16).
+ * C library: Add a dummy setlocale() function to avoid drawing the
+ function from newlib (2016-10-17).
+ * libc/wchar: Add wcslen, wmemchr, wmemcmp, wmemcpy and wmemset to NuttX.
+ From Alan Carvalho de Assis (2016-10-17).
+ * syscalls: Add setlocale to libc.csv (2016-10-17).
+ * libc/locale: Add clocale header file (2016-10-18).
+ * libc/wchar: Add functions btowc, mbrtowc, mbtowc, wcscmp, wcscoll,
+ wmemmove. From Alan Carvalho de Assis (2016-10-18).
+ * usbhost/enumerate: fix possible buffer overwrite. From Janne Rosberg
+ (2016-10-18).
+ * configs/Board.mk: Add extra clean operations (2016-10-18).
+ * usbhost/composite: fix compile; missing semicolons. From Jann
+ Rosberg (2016-10-18).
+ * libc/stdio: Include wchar.h in lib_libvsprintf.c to fix compilation
+ error. From Alan Carvalho de Assis (2016-10-18).
+ * arch/arm/src/kinetis: Added missing headers. From David Sidrane
+ (2016-10-18).
+ * arch/arm/src/kinetis: Kinetis broke out SPI to kinetis/kinetis_spi.h.
+ From David Sidrane (2016-10-18).
+ * arch/arm/src/kinetis: Broke out DMA to use the modern Nuttx chip
+ inclusion - still STUBS. From David Sidrane (2016-10-18).
+ * arch/arm/src/kinetis: Kinetis Support ARMV7 Common Vector and FPU.
+ From David Sidrane (2016-10-18).
+ * arch/arm/src/kinetis: Kinetis Allow CONFIG_ARMV7M_CMNVECTOR,
+ CONFIG_STACK_COLORATION, CONFIG_ARCH_FPU. From David Sidrane
+ (2016-10-18).
+ * arch/arm/src/kinetis: Kinetis i2c driver offset swapped for value
+ in kinetis_i2c_putreg. From David Sidrane (2016-10-18).
+ * Add functions wcrtomb, wcslcpy, wcsxfrm, wctob, wctomb, wctype,
+ localeconv, strcoll, strxfrm. From Alan Carvalho de Assis
+ (2016-10-18).
+ * libc/wctype: Add wctype.h; Move lib_wctype.c to libc/wctype.
+ From Alan Carvalho de Assis (2016-10-18).
+ * include/: Modify locale.h to add localeconv() and lconv structure.
+ From Alan Carvalho de Assis (2016-10-18).
+ * include/sys/time.h: timersub macro modified per recommendations of
+ phreakuencies (2016-10-18).
+ * include/: Add isblank() macro to ctype.h. From Alan Carvalho de
+ Assis (2016-10-19).
+ * libc/wctype: Add iswctype, towlower, towupper and wcsftime functions.
+ From Alan Carvalho de Assis (2016-10-19).
+ * syslog: Fixes required for file syslog output. From Max Kriegleder
+ (2016-10-19).
+ * arch/arm/src/stm32: add TIM8 to STM32F103V pinmap. From Maciej Wójcik
+ (2016-10-19).
+ * libc/locale: Allows c++ code to compile with or without
+ CONFIG_LIBC_LOCALE and will generate a link error if CONFIG_LIBC_LOCALE
+ is not defined and setlocale is referneced. With CONFIG_LIBC_LOCALE
+ defined setlocale will act as if MB string is not supported and return
+ "C" for POSIX. C and "". From David Sidrane (2016-10-19).
+ * Add vectors for interrupt levels 2-6 (2016-10-20).
+ * strtof: Add strtof() as simply a copy of strtod with types and
+ limits changed (2016-10-20).
+ * arch/arm/src/stm32v7: Register the watchdog device at the configured
+ device path CONFIG_WATCHDOG_DEVPATH vs. hard-coded /dev/wdt. From Frank
+ Benkert (2016-10-21).
+ * configs/*/defdonf The buttons example was changed to archbuttons. As
+ a result all of the button configurations are broken and need some
+ renaming in the defconfig files. Noted by Frank Berkert (2016-10-21).
+ * configs/stm32f103-minimum: Add support to PWM on STM32F103-Minimum
+ board. From Alan Carvalho de Assis (2016-10-21).
+ * include/ctype.h and cxx/cctype: Implement ctype.h functions as inline
+ if possible. cctype can then properly select namespace (2016-10-22).
+ * libc/unisted: Add strtold() (2016-10-22).
+ * sscanf: Use strtof() instead of strtod() if a short floating point
+ value was requested. The should help performance with MCUs with 32-bit
+ FPU support with some additional code size (2016-10-22).
+ * Remove support for software prioritization of interrupts (2016-10-23).
+ * drivers/net/tun.c: Fix bug in TUN interface driver. From Max
+ Nekludov (2016-10-24).
+ * arch/arm/src/stm32: A new implementation of the STM32 F4 I2C bottom
+ half. The commin I2C as this did not handled correctly in the current
+ implementation (see also https://github.com/PX4/NuttX/issues/54). The
+ changes almost exclusively affect the ISR. From Max Kriegleder
+ (2016-10-24).
+ * arch/arm/src/stm32l4: Fix I2C devices RCC registers. From Sebastien
+ Lorquet (2016-10-25).
+ * arch/arm/src/stm32l4: Enable and renames for 32l4 UARTs 4 and 5.
+ From Sebastien Lorquet (2016-10-25).
+ * configs/stm32f103-minimum: Fix Timers 2 to 7 clock frequencies.
+ From Alan Carvalho de Assis (2016-10-25).
+ * arch/arm/src/stm32: Initial implemention of the STM32 F37xx SDADC
+ module. There are also changes to ADC, DAC modules. SDADC has only been
+ tested in DMA mode and does not support external TIMER triggers. This
+ is a work in progress. From Marc Rechté (2016-10-25).
+ * Add logic to attach peripheral interrupt sources to CPU interrupts
+ (2016-10-25).
+ * CHxN channels are always outputs. From Sebastien Lorquet
+ (2016-10-26).
+ * sched/semaphore: Within the OS, when a thread obtains a semaphore
+ count it must call sem_addholder() if CONFIG_PRIORITY_INHERITANCE is
+ enabled. If a count is available, then sem_wait() calls
+ sem_addholder(), otherwise it waited for the semaphore and called
+ sem_addholder() when it eventually received the count.
+
+ This caused a problem when the thread calling sem_wait() was very
+ low priority. When it received the count, there may be higher
+ priority threads "hogging" the CPU that prevent the lower priority
+ task from running and, as a result, the sem_addholder() may be
+ elayed indefinitely.
+
+ The fix was to have sem_post() call sem_addholder() just before
+ restarting the thread waiting for the semaphore count.
+
+ This problem was noted by Benix Vincent who also suggested the
+ solution (2016-10-26).
+ * configs/stm32f103-minimum: Add RGB LED support on STM32F103 Minimum
+ board. From Alan Carvalho de Assis (2016-10-26).
+ * arch/arm/src/stm32f7: stm32_i2c.c Dejavu. Fixes a bug previously
+ found in the F4. From David Sidrane (2016-10-26).
+ * arch/arm/src/stm32f7: stm32f76xx77xx_pinmap.h Missed one. From
+ David Sidrane (2016-10-26).
+ * LPC32xx serial: Fix a typo in ioctl TIOCSRS485 ioctl. From Vytautas
+ Lukenskas (2016-10-27).
+ * sched/clock: Correct clock initialization. The correct range for
+ the month is 0-11 but is entered as 1-12 in the .config file
+ (2016-10-27).
+ * arch/*/include: Add architecture-specific inttypes.h. From Paul
+ A. Patience (2016-10-27).
+ * sched/Kconfig: Add ranges to START_YEAR, MONTH, and DAY (2016-10-28).
+ * configs/nucleo-f303re: Add STM32 F303RE hello configuration; remove
+ duplicate setting from board.h. From Marc Rechté (2016-10-18).
+ * arch/arm/src/lpc32xx: Restore RS485 mode on serial port open (if
+ RS485 is enabled via menuconfig). From Vytautas Lukenskas (2016-10-28).
+ * arch/arm/src/stm32f7: otgdev fixed typo. From David Sidrane
+ (2016-10-28).
+ * arch/xtensa: Basic architectural support for Xtensa processors and
+ the Expressif. ESP32 added. Totally untested on initial release
+ (2016-10-31).
+ * configs/esp32-core: Basic support for Expressif ESP32 Core v2 board
+ added. The initial release includes an NSH and an SMP test
+ configuration. Totally untested on initial relesae (2016-10-31).
+ * configs/bambino-200e: Add basic support to Micromint Bambino 200E
+ board. This includes contributions from Jim Wolfman. From Alan
+ Carvalho de Assis (2016-11-01).
+ * drivers/mtd/at24xx.c: Added EEPROM timeout. Fromo Aleksandr
+ Vyhovanec (2016-11-02).
+ * arch/misoc: Adds basic support for the Misoc procoessors and the
+ LM32 in particular. From Ramtin Amin (2016-11-01).
+ * configs/misoc. Board support for testing Misoc LM32 with Qemu.
+ From Ramtin Amin (2016-11-01).
+ * arch/arm/src/stm32: I think, that Size is (highest address+1 - Base
+ address). Base address has been removed and if address+count >= size
+ we are outside of the Flash. From David Sidrane (2016-11-01).
+ * sched/semaphore, sched/phread/, libc/semaphore, libc/pthread: Add
+ pthread_mutexattr_get/set_protocol and non-standard sem_get/set_protocol.
+ These may use to enable or disable priority inheritance on a single
+ semaphore (2016-11-02).
+ * arch/arm/src/stm32: Fix ADC compilation error when DMA isn't enabled.
+ From Paul A. Patience (2016-11-02).
+ * drivers/ and drivers/spi: Fix Kconfig warning. This commit moves the
+ ARCH_HAVE_SPI options outside the check for SPI. Those options don't
+ depend on SPI, and Kconfig files in arch/ enable them even if SPI isn't
+ enabled.
+
+ Sourcing the driver's Kconfig in drivers/Kconfig only if support for
+ the driver is enabled prevents us from defining these ARCH_HAVE options
+ in the driver's Kconfig. We should probably remove the other checks in
+ drivers/Kconfig and check if the drivers are enabled only in their
+ Kconfig. From Paul A. Patience (2016-11-02).
+ * Move protoypes for the non-standard include/semaphore.h file to the
+ non-standard include/nuttx/semaphore.h with the other non-standard
+ semaphore interfaces (2016-11-02).
+ * include/semaphores.h: Provide macros for sem_setprotocol() and
+ sem_getprotocol() if priority inheritance is not enabled. More
+ SEM_PRIO_* definitions to include/nuttx/semaphore.h (2016-11-02).
+ * drivers/serial.c: Make sure that priority inheritance is not
+ enabled for the signaling semaphores used in the serial driver
+ (2016-11-03).
+ * arch/arm/src/stm32f7: Fix to SPI-Master driver. Without this the
+ chip select decoding feature will not work properly. From Michael
+ Spahlinger (2016-11-03).
+ * drivers/, net/, fs/, sched, arch/, graphics/, libnx,: Disable
+ priority inheritance on all semaphores used for signaling (2016-11-03).
+ * sched/semaphore: Handle a case of missing proxy for sem_setprotocol.
+ Reorder so that (1) this error is avoided, and (2) >No proxy is needed
+ if priority inheritance is not enabled (2016-11-03).
+ * config/*/defconfgs: More fallout from name change of
+ apps/examples/buttons to archbuttons (2016-11-03).
+ * configs/nucleo_f303re: Various fixes to get the adc configuration
+ building again after PR. Refresh all configurations (2016-11-03).
+ * arch/misoc/src/common: Add interrupting Misoc serial driver. From
+ Ramtin Amin (2016-11-04)
+ * Fix a number of header files with mismatched 'extern C {' and '}'
+ (2016-11-05).
+ * Provide do-nothing stubs for mutex attribute interfaces if features
+ ot enabled. pthread_cond includes a signaling semaphore and should
+ call sem_setprotocol (2016-11-05).
+ * arch/arm/src/armv7-r: Fix compilation error. This commit fixes
+ compilation errors on MPU support for ARMv7-R. From Heesub Shin
+ (2016-11-06).
+ * arch/arm/src/armv7-r: fix invalid drbar handling. In ARMv7-R,
+ [31:5] bits of DRBAR is physical base address and other bits are
+ reserved and SBZ. Thus, there is no point in passing other than the
+ base address. From Heesub Shin (2016-11-06).
+ * arch/arm/src/armv7-r: Remove the redundant update on SCTLR.
+ mpu_control() is invoking cp15_wrsctlr() around SCTLR update
+ redundantly. From Heesub Shin (2016-11-06).
+ * arch/arm/src/armv7-r: add new Kconfig entries for d/i-cache.
+ Unlike in ARMv7-A/M, Kconfig entries for data and instruction caches
+ are currently missing in ARMv7-R. This commit adds those missing
+ Kconfig entries. Actual implmenetation for those functions will be
+ added in the subsequent patches. From Heesub Shin (2016-11-06).
+ * arch/arm/src/armv7-r: add cache handling functions. This commit
+ adds functions for enabling and disabling d/i-caches which were
+ missing for ARMv7-R. From Heesub Shin (2016-11-06).
+ * arch/arm/src/armv7-r: fix typo in mpu support. s/ARMV7M/ARMV7R/g.
+ From Heesub Shin (2016-11-06).
+ * arch/arm/src/armv7-r: fix CPSR corruption after exception handling.
+ A sporadic hang with consequent crash was observed when booting. It
+ seemed to be caused by the corrupted or wrong CPSR restored on return
+ from exception. NuttX restores the context using code like this:
+
+ msr spsr, r1
+
+ GCC translates this to:
+
+ msr spsr_fc, r1
+
+ As a result, not all SPSR fields are updated on exception return.
+ This should be:
+
+ msr spsr_fsxc, r1
+
+ On some evaluation boards, spsr_svc may have totally invalid value at
+ power-on-reset. As it is not initialized at boot, the code above may
+ result in the corruption of cpsr and thus unexpected behavior.
+
+ From Heesub Shin (2016-11-06).
+ * arch/arm/src/armv7-r: fix to restore the Thumb flag in CPSR. Thumb
+ flag in CPSR is not restored back when the context switch occurs while
+ executing thumb instruction. From Heesub Shin (2016-11-06).
+ * sched/wqueue: When queuing new LP work, don't signal any threads
+ if they are all busy. From Heesub Shin (2016-11-06).
+ * sched/wqueue: Signal sent from work_signal() may interrupt the low
+ priority worker thread that is already running. For example, the worker
+ thread that is waiting for a semaphore could be woken up by the signal
+ and break any synchronization assumption as a result. It also does not
+ make any sense to send signal if it is already running and busy. This
+ commit fixes it. From Heesub Shin (2016-11-06).
+ * arch/arm/src/stm32f7: STM32F7 SD/MMC driver depends on
+ CONFIG_SDIO_DMA which is only defined in stm32/Kconfig. Changed to
+ CONFIG_STM32F7_SDMMC_DMA and defined in stm32f7/Kconfig (2016-11-07).
+ * arch/arm/src/stm32: Add PWM driver support for STMF37xx. The
+ changes have been tested successfuly for TIM4 and TIM17 (different
+ IPs). From Marc Rechté (2016-11-07).
+ * sched/semaphore: sem_trywait() no longer modifies the errno value
+ UNLESS an error occurs. This allows these functions to be used
+ internally without clobbering the errno value. From Freddie Chopin
+ (2016-11-09).
+ * arch/arm/src/stm32l4: Change the way to configure quadrature encoder
+ prescalers. From Sebastien Lorquet (2016-11-09).
+ * libc/unisted: Patch brings strtol() and related functions more
+ conformant with POSIX. Corner cases like strtol(-2147483648, NULL, 10)
+ now pass clang -fsanitize=integer without warnings. From Juha Niskanen
+ (2016-11-10).
+ * drivers/sensors and configs/stm32f103-minimum: Add Vishay VEML6070
+ driver and support for STM32F103-Minimum board. From From Alan
+ Carvalho de Assis(2016-11-13).
+ * Misoc LM32: Corrects a bug that never occured in qemu on simulation or
+ real fpga. The error was that the r1 register was being modified out of
+ context switching and not restoring it. From Ramtin Amin (2016-11-14)
+ * arch/arm/src/samv71: A problem occurred with the SAMV7 USBDEVHS driver
+ if the USB cable is unplugged while a large amount of data is send over
+ an IN endpoint using DMA. If the USB cable is plugged in again after a
+ few seconds it is not possible to send data over this IN endpoint again,
+ all other endpoints work as expected.
+
+ The problem occurs because if the USB cable is unplugged while an DMA
+ transfer is in flight the transfer is canceled but the register
+ SAM_USBHS_DEVDMACTRL is left in an undefined state. The problem was
+ fixed the problem by resetting the register SAM_USBHS_DEVDMACTRL to a
+ known state. Additionally all pending interrupts are cleared.
+
+ From Stefan Kolb (2016-11-14).
+ * configs/esp32-core: ESP32 Core v2: Add configuration to supporting
+ linking NuttX for execution out of IRAM (2016-11-14).
+ * libc/unistd: sleep() was returning remaining nanoseconds (kind of),
+ instead the remaining seconds. From Eunbong Song (2016-11-15).
+ * sched/irq: Fixes for the SMP case: (1) Change order for SMP case in
+ enter_critical_section: (1) Disable local interrupts BEFORE taking
+ spinlock and (2) If SMP is enabled, if any interrupt handler calls
+ enter_critical_section(), it should take the spinlock. (2016-11-15).
+ * arch/xtensa: Add EXPERIMENTAL hooks to support lazy Xtensa co-
+ processor state restore in the future (2016-11-16).
+ * Add some experimental changes to enter/leave_critical_section to
+ deal with the case where interrupts are disabled only on the local
+ CPU (2016-11-16).
+ * sched/irq: Add logic to handled nested calls to
+ enter_critical_section() from interrupts handlers (with SMP)
+ (2016-11-16).
+ * drivers/timer: Remove the timer driver TIOC_SETHANDLER IOCTL call.
+ This calls directly from the timer driver into application code. That
+ is non-standard, non-portable, and cannot be supported (2016-11-17).
+ *drivers/timer: Add timer driver hooks to support signal notification
+ of timer expiration. Commented out because invasive interface changes
+ would also be required to complete the implementation (2016-11-17).
+ * arch/arm/src/armv7-m: Fix double allocation of MPU region in mmu.h
+ (2016-11-17).
+ * timer driver: Use signal to notify of timer expiration. Add generic
+ argument so that there can be additional usage. From Sebastien Lorquet
+ (2016-11-17).
+ * All timer lower half drivers. Port Sebastien's changes to all all
+ other implementations of the timer lower half. Very many just and
+ untested. Expect some problems. (2016-11-17).
+ * sched/irq: irq_csection() has a bad assumption in the SMP case. It
+ assumed that the state of certain variables. That was true on entry
+ into the interrupt handler, but might change to the execution of logic
+ within the interrupt handler (2016-11-18).
+ * config/ nucleo-l476rg: Add support for timers to nucleo l476. From
+ Sebastien Lorquet (2016-11-18).
+ * drivers/net: Add option to use low-priority work queue to all drivers
+ in drivers/net. Not yet added to all architecture-specific network
+ drivers (2016-11-18).
+ * sched/wdog: Most interrupt handling logic interacts with tasks via
+ standard mechanism such as sem_post, sigqueue, mq_send, etc. These all
+ call enter_critical_section and are assumed to be safe in the SMP case.
+
+ But certain logic interacts with tasks in different ways. The only one
+ that comes to mind are wdogs. There is a tasking interface that to
+ manipulate wdogs, and a different interface in the timer interrupt
+ handling logic to manage wdog expirations.
+
+ In the normal case, this is fine. Since the tasking level code calls
+ enter_critical_section, interrupts are disabled an no conflicts can
+ occur. But that may not be the case in the SMP case. Most
+ architectures do not permit disabling interrupts on other CPUs so
+ enter_critical_section must work differently: Locks are required to
+ protect code.
+
+ So this change adds locking (via enter_critical section) to wdog
+ expiration logic for the the case if the SMP configuration
+ (2016-11-18).
+ * SAM3/4: Add delay between setting and clearing the endpoint RESET bit
+ in sam_ep_resume(). We need to add a delay between setting and
+ clearing the endpoint reset bit in SAM_UDP_RSTEP. Without the delay the
+ USB controller will (may?) not reset the endpoint. If the endpoint is
+ not being reset, the Data Toggle (DTGLE) bit will not to be cleared
+ which will cause the next transaction to fail if DTGLE is 1. If that
+ happens the host will time-out and reset the bus. Adding this delay
+ may also fix the USBMSC_STALL_RACEWAR in usbmsc_scsi.c, however this
+ has not been verified yet. From Wolfgang Reißnegger (2016-11-18).
+ * SAM3/4: Remove unused 'halted' flag in UDP driver. From Wolfgang
+ Reißnegger (2016-11-18).
+ * SAM3/4: Remove 'stalled' flag in UDP driver. The flag is not necessary.
+ The state of the endpoint can be determined using 'epstate' instead.
+ From Wolfgang Reißnegger (2016-11-18).
+ * USBMSC: Fix length of mode6 sense reply packet. From Wolfgang
+ Reißnegger (2016-11-18).
+ * configs/dk-tm4c129x: Typo fix. From Wolfgang Reißnegger (2016-11-18).
+ * Typo fix in sam_udp.c. From Wolfgang Reißnegger (2016-11-18).
+ * STM32: STM32F303xB and STM32F303xC chips have 4 ADCs. From Paul A.
+ Patience (2016-11-19).
+ * vfork(): Fix a race condition in the SMP case. Existing logic
+ depended on the fact that the child would not run until waitpid was
+ called because the child had the same priority as the parent. BUT
+ in the SMP case that is not true... the child may run immediately on
+ a different CPU (2016-11-19).
+ * arch/: Add option to use low-priority work queue to all Ethernet
+ drivers in arch that support CONFIG_NET_NOINTS (2016-11-19).
+ * sched/clock: Correct calculation for the case of Tickless mode with
+ a 32-bit timer. In that case, the calculation was returning
+ millisecond accuracy. That is not good when the timer accuracy is < 1
+ msec. From Rajan Gill (2016-11-19).
+ * sched/task: task_restart() test not supported on SMP systems. This is
+ not fully implemented (2016-11-19).
+ * This commit adds a new internal interfaces and fixes a problem with
+ three APIs in the SMP configuration. The new internal interface is
+ sched_cpu_pause(tcb). This function will pause a CPU if the task
+ associated with 'tcb' is running on that CPU. This allows a different
+ CPU to modify that OS data stuctures associated with the CPU. When the
+ other CPU is resumed, those modifications can safely take place. The
+ three fixes are to handle cases in the SMP configuration where one CPU
+ does need to make modifications to TCB and data structures on a task
+ that could be running running on another CPU. Those three cases are
+ task_delete(), task_restart(), and execution of signal handles. In
+ all three cases the solutions is basically the same: (1) Call
+ sched_cpu_pause(tcb) to pause the CPU on which the task is running,
+ (2) perform the necessary operations, then (3) call up_cpu_resume() to
+ restart the paused CPU (2016-11-20).
+ * task_restart: Make sure new task starts with pre-emption disabled and
+ not in a critical section (2016-11-21).
+ * Fix a typo in a spinlock macro (2016-11-21).
+ * Spinlocks: Added capability to provide architecture-specific memory
+ barriers. This was for i.MX6 but does not help with the SMP problems.
+ It is still a good feature (2016-11-21).
+ * Remove a assertion condition that appears to rarely cause false-alarm
+ assertions. Teported by Petteri Aimonen (2016-11-21).
+ * The examples/qencoder app was trying to init the encoder by a direct
+ call into the board, cheating in a local header to declare the normally
+ unavailable function prototype. From Sebastien Lorquet (2016-11-22).
+ * configs: All QE encoder files. Last change made timer hard-coded to 3.
+ Make configurable (2016-11-22).
+ * configs: Remove all traces of the no-longer existent ARCHBUTTONS
+ example. Remove all button configurations that depended on the
+ obsoleted ARCHBUTTON example (2016-11-22).
+ * nucleo-l476rg: Add better selection of timer (2016-11-22).
+ * implementation of dumpgpio for stm32l4, was required for pwm debug.
+ From Sebastien Lorquet (2016-11-22).
+ * SMP: Add logic to avoid a deadlock condition when CPU1 is hung waiting
+ for g_cpu_irqlock and CPU0 is waitin for g_cpu_paused (2016-11-22).
+ * Misoc: Add timer driver. From Ramtin Amin (2016-11-22).
+ * Misoc: Add commits and warnings about missing caculation of the timer
+ reload value (2016-11-22).
+ * SAM3/4: Name of method is now setcallback, not sethandler (2016-11-22).
+ * sam4s-xplained-pro/nsh: Configuration uses old, improper timer interface.
+ CONFIG_TIMER disabled in configuration. (2016-11-22).
+ * sam4s-xplained-pro: Remove obsolete timer initialization logic
+ (2016-11-22).
+ * Misoc LM32: Make system timer configurable via CONFIG_USEC_PER_TICK.
+ From Ramtin Amin (2016-11-23).
+ * LPC43xx: Add timer driver; configs/bambino-200e: Add support for timer
+ driver. From Alan Carvalho de Assis (2016-11-23).
+ * SMP: Fix backward condition in test (2016-11-23).
+ * ARMv7-A SMP: Add a little logic to signal handling (2016-11-24).
+ * Misoc LM32: Add signal handling logic. From Ramtin Amin (2016-11-24).
+ * SMP: Add spin_trylock(). Use this in conditions where other CPUs need
+ to stopped but we cannot call enter_critical_section (2016-11-24).
+ * Fix for F1 RTC Clock, tested on F103. From Maciej Wójcik (2016-11-25).
+ * SMP: Fix yet another potential deadlock (2016-11-25).
+ * Enable CONFIG_RTC in the hymini-stm32v/nsh2 (kitchensink) config.
+ From Maciej Wójcik (2016-11-26).
+ * This adds support for keeping i.MX6 inter-processor communication data
+ in a non-cached address region (2016-11-26).
+ * i.MX6: Disable non-cached region support. Add SCU register definitions
+ (2016-11-26).
+ * i.MX6: Add some controls to enable SMP cache coherency in SMP mode
+ (2016-11-26).
+ * ARMv7-A: Fix some SCU SMP logic (2016-11-26).
+ * ARMv7-A/i.MX6: Modify handling of the SMP cache coherency
+ configuration so that it is identical to the steps from the TRM.
+ Makes no differenct, however (2016-11-27).
+ * The Smoothie project needs to compile C++ inside config/boardname/src/
+ to use with High Priority Interruption, then I modified the board
+ configs Makefile to support it. It works fine for the first time
+ compilation, but if we execute "touch config/boardname/src/Pin.cxx"
+ and execute "make" it will not detect that Pin.cxx was modified. I
+ think there is some other place I should modify, but I didn't find
+ it. From Alan Carvalho de Assis (2016-11-27).
+ * ARMv7-A/i.MX6 SMP: Move SMP coherernt cache setup to earlier in
+ initialization of CPUn, n>0 (2016-11-27).
+ * ARMv7 GIC: SGIs are non-maskable but go through the same path as other,
+ maskable interrupts. Added logic to serialize SGI processing when
+ necessary (2016-11-27).
+ * sched_note: Extend OS instrumentation to include some SMP events
+ (2016-11-27).
+ * sched_note: Add spinlock instrumentation; In SMP configurations,
+ select to log only notes from certain CPUs (2016-11-28).
+ * Misoc LM3: Add Misoc Ethernet driver. Integrate network support into
+ configs/misoc/hello. Remove configs/misoc/include/generated directory.
+ I suppose the the intent now is that this is a symbolic link? DANGER!
+ This means that you cannot compile this code with first generating
+ these files a providing a symbolic link to this location! From Ramtin
+ Amin (2016-11-28).
+ * Add tools/showsize.sh (2016-11-28).
+ * configs/misoc: Add a sample directory containing generated sources.
+ This is really only useful for performing test builds. You really
+ must generate the Misoc architecture for a real-life build. From
+ Ramtin Amin (2016-11-28).
+ * sched_note: Permit spinlock and critical section notes in in-memory
+ buffer iff sched_not_get() interfaces is disabled (2016-11-28).
+ * STM32 DAC: Fix shift value whenever there are is a DAC2 and, hence,
+ up to three interfaces. From Marc Rechté (2016-11-29).
+ * Back out a debug change that was included in commit (2016-11-29).
+ * i.MX6: Don't output the alphabet if CONFIG_DEBUG_FEATURES is not set
+ (2016-11-29).
+ * Misoc LM32: Add logic to flush/invalidate caches. From Ramtin Amin
+ (2016-11-29).
+ * drivers/net/: Adapt all Ethernet drivers to work as though
+ CONFIG_NET_MULTIBUFFER were set. Remove all references to
+ CONFIG_NET_MULTIBUFFER (2016-11-29).
+ * stm32_otghshost: if STM32F446 increase number of channels to 16. From
+ Janne Rosberg (2016-11-30).
+ * usbhost_composite: fix end offset in usbhost_copyinterface(). From
+ Janne Rosberg (2016-11-30).
+ * usbhost_cdcacm: add CDC_SUBCLASS_ACM and CDC_PROTO_ATM to supported
+ class and proto. From Janne Rosberg (2016-11-30).
+ * LPC43 SD/MMC: Correct some git definitions on SMMC control register
+ in lpc43_sdmmc.h. From Alan Carvalho de Assis (2016-11-30).
+ * STM32L4: Correct USART1/2 definitions. Use default mbed UART4
+ settings. From Sebastien Lorquet (2016-12-01).
+ * boardctl: Add new boardctl() command ,BOARDIOC_NX_START, to start the
+ NX server as a kernel thread (2016-12-01).
+ * GPDMA driver for the LPC43xx. The GPDMA block is basically the same
+ as the LPC17xx. Only the clock configuration is different and LPC43xx
+ has four different DMA request sources, where LPC17xx has only two.
+ From Alan Carvalho de Assis (2016-12-01).
+ * Remove RGMP and RGMP drivers (2016-12-02).
+ * i.MX6: Add an untested SPI driver taken directly from the i.MX1 port
+ (2016-12-02).
+ * Eliminate CONFIG_NO_NOINTS. There is no longer any support for
+ interrupt level processing of the network stack. Lots of files changed
+ -> lots of testing needed (2016-12-03).
+ * Fix DEBUGASSERT() in group_signal.c. From Masayuki Ishikawa
+ (2016-12-04).
+ * Add support for the SAM5CMP-DB board. From Masayuki Ishikawa
+ (2016-12-04).
+ * SAM3/4: Add SMP support for the dual-core SAM4CM. From Masayuki
+ Ishikawa (2016-12-04).
+ * C Library: Allow option to enable IP address conversions even when the
+ IP address family is not supported (2016-12-04).
+ * SSD1306: Fix errors in SPI mode configuration. From Gong Darcy
+ (2016-12-04).
+ * SAMA5 does not build when executing from SDRAM before board
+ frequencies are not constant. Rather, the bootloader configures the
+ clocking and we must derive the clocking from the MCK left by the
+ bootloader. This means lots more computations. This is untested on
+ initial commit because I don't have a good PWM test setup right now
+ (2016-12-04).
+ * Olimex-LPC1766-STK: Enable procfs in NSH configuration. Automount
+ /proc on startup (2016-12-05).
+ * SAM4CMP-DB: Add hooks to auto-mount the procfs file system on startup
+ in board bring-up logic (2016-12-05).
+ * Remove all references to BOARDIOC_PWMSETUP and board_pwm_setup()
+ (2016-12-05).
+ * Remove all references to BOARDIOC_ADCSETUP and board_adc_setup()
+ (2016-12-05).
+ * Added Timers 2-5 and control of SAI and I2S PLLs. From David Sidrane
+ (2016-12-05).
+ * Added support for stmf469 SAI and I2S PLL configuration and STM446
+ fixes. From David Sidrane (2016-12-05).
+ * Expanded otgfs support to stm32F469 and stm32f446. Added missing bits
+ definitions, Used stm32F469 and stm32f446 bit definitions, Removed
+ unsed header file. From David Sidrane (2016-12-05).
+ * Remove BOARDIOC_CAN_INITIALIZE. CAN initialization is now done in the
+ board initialization logic just like every other device driver
+ (2016-12-06).
+ * STM32F7: Allow the config to override the clock edge setting. From
+ David Sidrane (2016-12-06).
+ * For Cortex-A9, should also set ACTLR.FW in SMP mode to enble TLB and
+ cache broadcasts. Does not fix SMP cache problem (2016-12-07).
+ * sched notes: Add additional note to see if/when CPU is started in SMP
+ mode (2016-12-07).
+ * EFM32: Fix a compilation error. From Pierre-noel Bouteville
+ (2016-12-07).
+ * pthreads: Add pthread_cleanup_push() and pthread_cleanup_pop()
+ (2016-12-08).
+ * BUGFIX:STM32F427 was rebooting. Over reached family. From David
+ Sidrane (2016-12-08).
+ * Add pthread_setcanceltype() and pthread_testcancel() (2016-12-09).
+ * Added STM32F469 RAM size and deliberated STM32F446 size. From David
+ Sidrane (2016-12-09).
+ * Typo in stm32f76xx77xx_pinmap.h edited online with Bitbucket. From
+ David Sidrane (2016-12-09).
+ * stm32_allocateheap.c edited online with Bitbucket. From David Sidrane
+ (2016-12-09).
+ * LPC43xx SD card: Correct pin configuration options needed for SD card
+ pins. From Alan Carvalho de Assis (2016-12-09).
+ * pthread_mutex_destroy(): Fix an error in destroying a mutex which can
+ occur after a pthread has been canceled while holding the mutex
+ (2016-12-09).
+ * Add support for cancellation points (2016-12-09).
+ * Forgot to add some files in the last commit (2016-12-10).
+ * Correct some default font IDs. From Pierre-Noel Bouteville
+ (2016-12-10).
+ * task_delete() now obeys all cancellation point semantics (2016-12-10).
+ * Add task_setcancelstate(), task_setcanceltype(), and task_testcancel().
+ These are non-standard interfaces analogous to the correponding pthread_
+ interfaces that provide cancellation controls for tasks (2016-12-10).
+
+7.19 2016-xx-xx Gregory Nutt
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 700876be653012c2f291f2c823b1509f1f0891e2..ca35c859ed65b87b42ca9662651cedc3abcc2e09 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -8,7 +8,7 @@
NuttX RTOS
- Last Updated: July 25, 2016
+ Last Updated: October 8, 2016
|
@@ -146,13 +146,11 @@
to support a rich, multi-threaded development environment for deeply embedded
processors.
- NON-GOALS: (1) It is not a goal to provide the level of OS features like those provided by Linux.
+ NON-GOALS: It is not a goal to provide the level of OS features like those provided by Linux.
In order to work with smaller MCUs, small footprint must be more important than an extensive feature set.
But standard compliance is more important than small footprint.
Surely a smaller RTOS could be produced by ignoring standards.
Think of NuttX is a tiny Linux work-alike with a much reduced feature set.
- (2) There is no MMU-based support for processes.
- At present, NuttX assumes a flat address space.
@@ -1341,11 +1339,11 @@
Released Versions
In addition to the ever-changing GIT repository, there are frozen released versions of NuttX available.
- The current release is NuttX 7.17.
- NuttX 7.17 is the 117th release of NuttX.
- It was released on June 1, 2016, and is available for download from the
+ The current release is NuttX 7.18.
+ NuttX 7.18 is the 118th release of NuttX.
+ It was released on October 8, 2016, and is available for download from the
Bitbucket.org website.
- Note that the release consists of two tarballs: nuttx-7.17.tar.gz
and apps-7.17.tar.gz
.
+ Note that the release consists of two tarballs: nuttx-7.18.tar.gz
and apps-7.18.tar.gz
.
Both may be needed (see the top-level nuttx/README.txt
file for build information).
@@ -1354,7 +1352,7 @@
- nuttx.
- Release notes for NuttX 7.17 are available here.
+ Release notes for NuttX 7.18 are available here.
Release notes for all released versions on NuttX are available in the Bitbucket GIT.
The ChangeLog for all releases of NuttX is available in the ChangeLog file that can viewed in the Bitbucket GIT.
The ChangeLog for the current release is at the bottom of that file.
@@ -1362,7 +1360,7 @@
apps.
- Release notes for NuttX 7.17 are available here.
+ Release notes for NuttX 7.18 are available here.
Release notes for all released versions on NuttX are available in the Bitbucket GIT
The ChangeLog for the all releases of apps/
is available in the ChangeLog file that can viewed in the Bitbucket GIT.
The ChangeLog for the current release is at the bottom of that file.
@@ -1410,7 +1408,7 @@
- Linux/Cygwin user mode simulation (1)
- ARM
-
-
|
-
-
- TI Calypso.
- This port supports the TI "Calypso" MCU used in various cell phones (and, in particular,
- by the Osmocom-bb project).
- Like the c5471, NuttX operates on the ARM7 of this dual core processor.
- Board support is available for the Motorola C139, C155 and W220 phones and for the Pirelli DP-L10 phone.
-
-
-
- STATUS:
- This port was contributed by Denis Carilki and includes the work of Denis Carikli, Alan Carvalho de Assis, and Stefan Richter.
- Calypso support first appeared in NuttX-6.17 with LCD drivers.
- Support for the Calypso keyboard was added in NuttX-6.24 by Denis Carilki.
- Refer to the NuttX board README files for the Compal E88, Compal E99 and Pirelli DP-L10 phones for further information.
-
-
- |
-
-
-
|
-
|
-
|
@@ -2928,6 +2900,7 @@ nsh>
The other port is for a generic minimual STM32F103CBT6 "blue" board contributed by Alan Carvalho de Assis.
+ Alan added support for numerous sensors, tone generators, user LEDs, and LCD support in NuttX 7.18.
@@ -3101,7 +3074,7 @@ nsh>
|
STMicro STM32F107x (STM32 F1 "Connectivity Line" family).
- Chip support for the STM32 F1 "Connectivity Line" family has been present in NuttX for some time and users have reported that they have successful brought up NuttX on there proprietary boards using this logic.
+ Chip support for the STM32 F1 "Connectivity Line" family has been present in NuttX for some time and users have reported that they have successful brought up NuttX on theor proprietary boards using this logic.
-
@@ -3155,7 +3128,17 @@ nsh>
STATUS:
Networking and touchscreen support are well test.
But, at present, neither USB nor LCD functionality have been verified.
- Refer to the SViewtool STM32F103/F107 README file for further information.
+ Refer to the Viewtool STM32F103/F107 README file for further information.
+
+
+ -
+
+ Kamami STM32 Butterfly 2
+ Support for the Kamami STM32 Butterfly 2 was contributed by Michał Łyszczek in NuttX-7/18. That port features the STMicro STM32F107VC MCU.
+
+
+ STATUS:
+ A configuration for the NuttShell (NSH), NSH with networking, and NSH with USB host are available and verified.
|
@@ -3805,6 +3788,7 @@ nsh>
Olimex STM32 E407.
Support for the Olimex STM32 E407 development board was contributed by Mateusz Szafoni and appeared in NuttX-7.17.
+ Networking configurations were added in NuttX-7.18.
See the NuttX board README file for further information about the NuttX port.
@@ -3906,7 +3890,7 @@ nsh>
STMicro STM32 L476.
- Two boards are supported in this family:
+ Three boards are supported in this family:
Status:
@@ -3944,6 +3936,22 @@ nsh>
- CAN contributed by Sebastien Lorquet.
- I2C made functional by Dave (ziggurat29).
+
+ NuttX-7.17.
+ Additional drivers/features were contributed:
+
+
+ - Support for tickless mode.
+ - CAN driver enhancements.
+
+
+ NuttX-7.18.
+ Additional drivers were contributed:
+
+
+ - Oneshot timer driver.
+ - Quadrature encode contributed by Sebastien Lorquet.
+
|
@@ -4156,6 +4164,7 @@ nsh>
Support for the EK-TM4C1294XL was contributed by Frank Sautter and was released in NuttX 7.9.
This basic board support included a configuration for the NuttShell NSH) and a configuration for testing IPv6.
+ See drivers for the TI Tiva TM4C129X.
@@ -4191,6 +4200,9 @@ nsh>
Both are networked enabled: One configured to support IPv4 and one configured to supported IPv6.
Instructions are included in the board README file for configuring both IPv4 and IPv6 simultaneously..
+
+ Tiva PWM and Quadrature Encoder drivers were contributed to NuttX in 7.18 by Young.
+
Refer to the DK-TM4C129X board README file for more detailed information about this port.
@@ -4882,34 +4894,6 @@ Mem: 29232 5920 23312 23312
-
-
|
-
|
-
-
-
|
-
-
- RGMP.
- RGMP stands for RTOS and GPOS on Multi-Processor.
- RGMP is a project for running GPOS and RTOS simultaneously on multi-processor platforms
- You can port your favorite RTOS to RGMP together with an unmodified Linux to form a hybrid operating system.
- This makes your application able to use both RTOS and GPOS features.
-
-
- See the RGMP Wiki for further information about RGMP.
-
-
-
- STATUS:
- This initial port of NuttX to RGMP was provided in NuttX-6.3.
- This initial RGP port provides only minimal driver support and does not use the native NuttX interrupt system.
- This is a great, stable starting point for anyone interest in working with NuttX under RGMP!
- Refer to the NuttX README file for further information.
-
-
- |
-
|
diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html
index 8ecbf7abc7f1708c44a339850d500be216c4a450..f1007f49926cbb047c9535d5eba895ec3e17055a 100644
--- a/Documentation/NuttxPortingGuide.html
+++ b/Documentation/NuttxPortingGuide.html
@@ -1008,10 +1008,6 @@ drivers/
| |-- Kconfig
| |-- Make.defs
| `-- (Common sensor driver source files)
-|-- sercomm/
-| |-- Kconfig
-| |-- Make.defs
-| `-- (Files for the Calypso SERCOMM driver)
|-- serial/
| |-- Kconfig
| |-- Make.defs
@@ -1170,8 +1166,6 @@ include/
| | `-- (Power management header files)
| |-sensors/
| | `-- (Sensor device driver header files)
-| |-sercomm/
-| | `-- (SERCOMM driver header files)
| |-serial/
| | `-- (Serial driver header files)
| |-spi/
diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html
index 3766eba646fda9464e641f870b44ecacf44972e0..5f1b35ca94605e132238f17d98af62eb238ddf81 100644
--- a/Documentation/NuttxUserGuide.html
+++ b/Documentation/NuttxUserGuide.html
@@ -13,7 +13,7 @@
NuttX Operating SystemUser's Manual
by
Gregory Nutt
- Last Updated: July 24, 2015
+ Last Updated: December 11, 2016
|
@@ -204,48 +204,57 @@ paragraphs.
2.1.4 task_delete
2.1.5 task_restart
+
+ Non-standard extensions to VxWorks-like interfaces to support POSIX Cancellation Points.
+
+
Standard interfaces
Standard vfork
and exec[v|l]
interfaces:
Standard posix_spawn
interfaces:
Non-standard task control interfaces inspired by posix_spawn
:
@@ -469,8 +478,21 @@ int task_delete(pid_t pid);
Description:
- This function causes a specified task to cease to exist -- its stack and TCB will be deallocated.
- This function is the companion to task_create().
+ This function causes a specified task to cease to exist.
+ Its stack and TCB will be deallocated.
+ This function is the companion to task_create()
.
+ This is the version of the function exposed to the user;
+ it is simply a wrapper around the internal, task_terminate()
function.
+
+
+ The logic in this function only deletes non-running tasks.
+ If the pid
parameter refers to to the currently runing task, then processing is redirected to exit()
.
+ This can only happen if a task calls task_delete()
in order to delete itself.
+
+
+ This function obeys the semantics of pthread cancellation:
+ task deletion is deferred if cancellation is disabled or if deferred cancellation is supported (with Cancellation Points enabled).
+
Input Parameters:
@@ -485,7 +507,8 @@ int task_delete(pid_t pid);
-
OK
, or ERROR
if the task cannot be deleted.
- This function can fail if the provided pid does not correspond to a task (errno
is not set).
+ The errno
is set to indicate the nature of the failure.
+ This function can fail, for example, if the provided pid does not correspond to a currently executing task.
@@ -583,7 +606,128 @@ VxWorks provides the following similar interface:
-
+
+
+Function Prototype:
+
+
+ #include <sched.h>
+ int task_setcancelstate(int state, int *oldstate);
+
+
+Description:
+The task_setcancelstate()
function atomically
+sets both the calling task's cancelability state to the indicated
+state and returns the previous cancelability state at the location
+referenced by oldstate.
+Legal values for state are TASK_CANCEL_ENABLE and TASK_CANCEL_DISABLE.
+
+
+Any pending thread cancellation may occur at the time that the
+cancellation state is set to TASK_CANCEL_ENABLE.
+
+
+The cancelability state and type of any newly created tasks are TASK_CANCEL_ENABLE and TASK_CANCEL_DEFERRED respectively.
+
+Input Parameters:
+
+
+
+state
+New cancellation state. One of PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.
+oldstate
.
+Location to return the previous cancellation state.
+
+
+
+Returned Value:
+
+
+Zero (OK
) on success; ERROR
is returned on any failure with the errno
value set appropriately:
+
+
+
+ESRCH
.
+No thread could be found corresponding to that specified by the given thread ID.
+
+
+Assumptions/Limitations:
+
+POSIX Compatibility: This is a non-standard interface. It extends the functionality of pthread_setcancelstate()
to tasks and supports use of task_delete()
.
+
+
+
+
+Function Prototype:
+
+
+ #include <sched.h>
+ int task_setcanceltype(int type, FAR int *oldtype);
+
+
+Description:
+The task_setcanceltype()
function atomically both sets the calling task's cancelability type to the indicated type and returns the previous cancelability type at the location referenced by oldtype
.
+Legal values for type are TASK_CANCEL_DEFERRED
and TASK_CANCEL_ASYNCHRONOUS
.
+
+
+The cancelability state and type of any newly created tasks are TASK_CANCEL_ENABLE
and TASK_CANCEL_DEFERRED
respectively.
+
+
+Input Parameters:
+
+
+
+type
+New cancellation state. One of PTHREAD_CANCEL_DEFERRED
or PTHREAD_CANCEL_ASYNCHRONOUS
.
+oldtype
.
+Location to return the previous cancellation type.
+
+
+
+Returned Value:
+
+
+Zero (OK
) on success; ERROR
is returned on any failure with the errno
value set appropriately:
+
+
+
+ESRCH
.
+No thread could be found corresponding to that specified by the given thread ID.
+
+
+
+POSIX Compatibility: This is a non-standard interface. It extends the functionality of pthread_setcanceltype()
to tasks and supports use of task_delete()
.
+
+
+
+
+Function Prototype:
+
+
+
+ #include <sched.h>
+ void task_testcancel(void);
+
+
+
+Description:
+
+
+The task_testcancel()
function creates a Cancellation Point in the calling task.
+The task_testcancel()
function has no effect if cancelability is disabled.
+
+
+Input Parameters: None
+
+
+Returned Value: None
+
+
+POSIX Compatibility: This is a non-standard interface. It extends the functionality of pthread_testcancel()
to tasks and supports use of task_delete()
.
+
+
+
+
Function Prototype:
@@ -629,7 +773,7 @@ And the UNIX interface:
The code
parameter is ignored.
-
+
Function Prototype:
@@ -657,7 +801,7 @@ level.
Compatible with the POSIX interface of the same name.
-
+
Function Prototype:
@@ -691,7 +835,7 @@ pid_t vfork(void);
Compatible with the Unix interface of the same name.
-
+
Function Prototype:
@@ -777,7 +921,7 @@ int execv(FAR const char *path, FAR char *const argv[]);
There are, however, several compatibility issues as detailed in the description above.
-
+
Function Prototype:
@@ -821,7 +965,7 @@ int execl(FAR const char *path, ...);
There are, however, several compatibility issues as detailed in the description of execv().
-
+
Function Prototype:
@@ -964,7 +1108,7 @@ int posix_spawnp(FAR pid_t *pid, FAR const char *file,
For the caller of posix_spawn()
, the provided argv[0] will correspond to argv[1]
received by the new task.
-
+
Function Prototype:
@@ -990,7 +1134,7 @@ int posix_spawn_file_actions_init(FAR posix_spawn_file_actions_t *file_actions);
On success, this function returns 0; on failure it will return an error number from <errno.h>
.
-
+
Function Prototype:
@@ -1017,7 +1161,7 @@ int posix_spawn_file_actions_destroy(FAR posix_spawn_file_actions_t *file_action
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1048,7 +1192,7 @@ int posix_spawn_file_actions_addclose(FAR posix_spawn_file_actions_t *file_actio
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1085,7 +1229,7 @@ int posix_spawn_file_actions_adddup2(FAR posix_spawn_file_actions_t *file_action
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1130,7 +1274,7 @@ int posix_spawn_file_actions_addopen(FAR posix_spawn_file_actions_t *file_action
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1166,7 +1310,7 @@ int posix_spawnattr_init(FAR posix_spawnattr_t *attr);
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1196,7 +1340,7 @@ int posix_spawnattr_getflags(FAR const posix_spawnattr_t *attr, FAR short *flags
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1226,7 +1370,7 @@ int posix_spawnattr_getschedparam(FAR const posix_spawnattr_t *attr, FAR struct
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1256,7 +1400,7 @@ int posix_spawnattr_getschedpolicy(FAR const posix_spawnattr_t *attr, FAR int *p
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1288,7 +1432,7 @@ int posix_spawnattr_getsigmask(FAR const posix_spawnattr_t *attr, FAR sigset_t *
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1318,7 +1462,7 @@ int posix_spawnattr_setflags(FAR posix_spawnattr_t *attr, short flags);
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1348,7 +1492,7 @@ int posix_spawnattr_setschedparam(FAR posix_spawnattr_t *attr, FAR const struct
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1378,7 +1522,7 @@ int posix_spawnattr_setschedpolicy(FAR posix_spawnattr_t *attr, int policy);
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1410,7 +1554,7 @@ int posix_spawnattr_setsigmask(FAR posix_spawnattr_t *attr, FAR const sigset_t *
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1524,7 +1668,7 @@ int task_spawn(FAR pid_t *pid, FAR const char *name, main_t entry,
This is a non-standard interface inspired by posix_spawn()
.
-
+
Function Prototype:
@@ -1554,7 +1698,7 @@ int task_spawnattr_getstacksize(FAR const posix_spawnattr_t *attr, FAR size_t *s
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -1584,7 +1728,7 @@ int task_spawnattr_setstacksize(FAR posix_spawnattr_t *attr, size_t stacksize);
On success, this function returns 0; on failure it will return an error number from <errno.h>
-
+
Function Prototype:
@@ -3380,6 +3524,29 @@ interface of the same name.
inheritance logic.
+
+ Locking versus Signaling Semaphores.
+ Semaphores (and mutexes) may be used for many different purposes.
+ One typical use of for mutual exclusion and locking of resources:
+ In this usage, the thread that needs exclusive access to a resources takes the semaphore to get access to the resource.
+ The same thread subsequently releases the seamphore count when it no longer needs exclusive access.
+ Priority inheritance is intended just for this usage case.
+
+
+ In a different usage case, a semaphore may to be used to signal an event:
+ One thread A waits on a semaphore for an event to occur.
+ When the event occurs, another thread B will post the semaphore waking the waiting thread A.
+ This is a completely different usage model; notice that in the mutual exclusion case, the same thread takes and posts the semaphore. In the signaling case, one thread takes the seamphore and a different thread posts the samphore. Priority inheritance should never be used in this signaling case.
+ Subtle, strange behaviors may result.
+
+
+ When priority inheritance is enabled with CONFIG_PRIORITY_INHERITANCE
, the default protocol for the semaphore will be to use priority inheritance.
+ For signaling semaphores, priority inheritance must be explicitly disabled by calling sem_setprotocol
with SEM_PRIO_NONE
.
+ For the case of pthread mutexes, pthread_mutexattr_setprotocol
with PTHREAD_PRIO_NONE
.
+
+
+ This is discussed in much more detail on this Wiki page.
+
POSIX semaphore interfaces:
@@ -3394,6 +3561,8 @@ interface of the same name.
2.5.8 sem_trywait
2.5.9 sem_post
2.5.10 sem_getvalue
+ 2.5.11 sem_getprotocol
+ 2.5.12 sem_setprotocol
@@ -3868,6 +4037,75 @@ number of tasks waiting for the semaphore.
interface of the same name.
+
+
+Function Prototype:
+
+
+ #include <nuttx/semaphore.h>
+ int sem_getprotocol(FAR const pthread_mutexattr_t *attr, FAR int *protocol);
+
+
+Description: Return the value of the semaphore protocol attribute.
+
+
+Input Parameters:
+
+
+
+ attr
. A pointer to the semaphore to be queried
+ protocol
. The user provided location in which to store the protocol value. May be one of SEM_PRIO_NONE
, or SEM_PRIO_INHERIT
, SEM_PRIO_PROTECT
.
+
+
+
+Returned Value:
+
+
+If successful, the sem_getprotocol()
function will return zero (OK
).
+Otherwise, an -1 (ERROR
) will be returned and the errno
value will be set to indicate the nature of the error.
+
+
+Assumptions/Limitations:
+
+
+POSIX Compatibility: Non-standard NuttX interface. Should not be used in portable code. Analogous to pthread_muxtexattr_getprotocol()
.
+
+
+
+
+Function Prototype:
+
+
+ #include <nuttx/semaphore.h>
+ int sem_setprotocol(FAR pthread_mutexattr_t *attr, int protocol);
+
+
+Description: Set semaphore protocol attribute. See the paragraph Locking versus Signaling Semaphores for some important information about the use of this interface.
+
+
+
+Input Parameters:
+
+
+
+ attr
. A pointer to the semaphore to be modified
+ protocol
. The new protocol to use. One of SEM_PRIO_NONE
, or SEM_PRIO_INHERIT
, SEM_PRIO_PROTECT
. SEM_PRIO_INHERIT
is supported only if CONFIG_PRIORITY_INHERITANCE
is defined; SEM_PRIO_PROTECT
is not currently supported in any configuration.
+
+
+
+Returned Value:
+
+
+If successful, the sem_getprotocol()
function will return zero (OK
).
+Otherwise, an -1 (ERROR
) will be returned and the errno
value will be set to indicate the nature of the error.
+
+
+Assumptions/Limitations:
+
+
+POSIX Compatibility: Non-standard NuttX interface. Should not be used in portable code. Analogous to pthread_muxtexattr_setprotocol()
.
+
+
@@ -4587,9 +4825,9 @@ interface of the same name.
See the NuttX Threading Wiki page and the Tasks vs. Threads FAQ for additional information on tasks and threads in NuttX.
- Signalling Multi-threaded Task Groups.
+ Signaling Multi-threaded Task Groups.
The behavior of signals in the multi-thread task group is complex.
- NuttX emulates a process model with task groups and follows the POSIX rules for signalling behavior.
+ NuttX emulates a process model with task groups and follows the POSIX rules for signaling behavior.
Normally when you signal the task group you would signal using the task ID of the main task that created the group (in practice, a different task should not know the IDs of the internal threads created within the task group); that ID is remembered by the task group (even if the main task thread exits).
@@ -5424,12 +5662,15 @@ be sent.
2.8.13 pthread_exit
2.8.14 pthread_cancel
2.8.15 pthread_setcancelstate
- 2.8.16 pthread_testcancelstate
- 2.8.17 pthread_join
- 2.8.18 pthread_yield
- 2.8.19 pthread_self
- 2.8.20 pthread_getschedparam
- 2.8.21 pthread_setschedparam
+ 2.8.16 pthread_setcanceltype
+ 2.8.17 pthread_testcancel
+ 2.8.18 pthread_cleanup_pop
+ 2.8.19 pthread_cleanup_push
+ 2.8.20 pthread_join
+ 2.8.21 pthread_yield
+ 2.8.22 pthread_self
+ 2.8.23 pthread_getschedparam
+ 2.8.24 pthread_setschedparam
Thread Specific Data.
@@ -5439,64 +5680,66 @@ be sent.
(2) The main task thread does not had thread-specific data.
pthread Mutexes.
Condition Variables.
Barriers.
Initialization.
Signals.
@@ -5515,8 +5758,6 @@ be sent.
pthread_attr_setscope . get and set the contentionscope attribute.
pthread_attr_setstack . get and set stack attributes.
pthread_attr_setstackaddr . get and set the stackaddr attribute.
- pthread_cleanup_pop . establish cancellation handlers.
- pthread_cleanup_push . establish cancellation handlers.
pthread_condattr_getclock . set the clock selection condition variable attribute.
pthread_condattr_getpshared . get the process-shared condition variable attribute.
pthread_condattr_setclock . set the clock selection condition variable attribute.
@@ -5527,9 +5768,7 @@ be sent.
pthread_mutex_setprioceiling . get and set the priority ceiling of a mutex.
pthread_mutex_timedlock . lock a mutex.
pthread_mutexattr_getprioceiling . get and set the prioceiling attribute of the mutex attributes object.
- pthread_mutexattr_getprotocol . get and set the protocol attribute of the mutex attributes object.
pthread_mutexattr_setprioceiling . get and set the prioceiling attribute of the mutex attributes object.
- pthread_mutexattr_setprotocol . get and set the protocol attribute of the mutex attributes object.
pthread_rwlock_destroy . destroy and initialize a read-write lock object.
pthread_rwlock_init . destroy and initialize a read-write lock object.
pthread_rwlock_rdlock . lock a read-write lock object for reading.
@@ -5543,14 +5782,12 @@ be sent.
pthread_rwlockattr_getpshared . get and set the process-shared attribute of the read-write lock attributes object.
pthread_rwlockattr_init . destroy and initialize the read-write lock attributes object.
pthread_rwlockattr_setpshared . get and set the process-shared attribute of the read-write lock attributes object.
- pthread_setcanceltype . set cancelability state.
pthread_setconcurrency . get and set the level of concurrency.
pthread_spin_destroy . destroy or initialize a spin lock object.
pthread_spin_init . destroy or initialize a spin lock object.
pthread_spin_lock . lock a spin lock object.
pthread_spin_trylock . lock a spin lock object.
pthread_spin_unlock . unlock a spin lock object.
- pthread_testcancel . set cancelability state.
@@ -5985,19 +6222,15 @@ interface of the same name.
Description:
- The pthread_cancel() function will request that thread
-be canceled. The target thread's cancelability state determines
-when the cancellation takes effect. When the
-cancellation is acted on, thread will be terminated.
+The pthread_cancel() function will request that thread be canceled.
+The target thread's cancelability state, enabled, or disabled, determines when the cancellation takes effect: When the cancellation is acted on, thread will be terminated.
+When cancelability is disabled, all cancellations are held pending in the target thread until the thread re-enables cancelability.
-When cancelability is disabled, all cancels are held pending
-in the target thread until the thread changes the cancelability.
-When cancelability is deferred, all cancels are held pending in
-the target thread until the thread changes the cancelability or
-calls pthread_testcancel().
+The target thread's cancelability state determines how the cancellation is acted on:
+Either asychronrously or deferred.
+Asynchronous cancellations we be acted upon immediately (when enabled), interrupting the thread with its processing in an abritray state.
-Cancelability is asynchronous; all cancels are acted upon
-immediately (when enable), interrupting the thread with its processing.
+When cancelability is deferred, all cancellations are held pending in the target thread until the thread changes the cancelability type or a Cancellation Point function such as pthread_testcancel() is entered.
Input Parameters:
@@ -6018,16 +6251,10 @@ No thread could be found corresponding to that specified by the given thread ID.
Assumptions/Limitations:
-POSIX Compatibility: Comparable to the POSIX
-interface of the same name. Except:
+POSIX Compatibility: Comparable to the POSIX interface of the same name. Except:
-- The thread-specific data destructor functions will be called for thread.
-However, these destructors are not currently supported.
-- Cancellation types are not supported. The thread will be canceled
-at the time that pthread_cancel() is called or, if cancellation is disabled, at
-the time when cancellation is re-enabled.
-- pthread_testcancel() is not supported.
-- Thread cancellation at cancellation points is not supported.
+- The thread-specific data destructor functions will be not called for thread
+These destructors are not currently supported.
@@ -6040,23 +6267,29 @@ the time when cancellation is re-enabled.
Description:
- The pthread_setcancelstate() function atomically
+
+
+The pthread_setcancelstate() function atomically
sets both the calling thread's cancelability state to the indicated
state and returns the previous cancelability state at the location
referenced by oldstate.
-Legal values for state are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DISABLE.<.li>
-
- Any pending thread cancellation may occur at the time that the
-cancellation state is set to PTHREAD_CANCEL_ENABLE.
-
+Legal values for state are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DISABLE.
+
+
+Any pending thread cancellation may occur at the time that the
+cancellation state is set to PTHREAD_CANCEL_ENABLE.
+
+
Input Parameters:
+
state
-New cancellation state. One of PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.<.li>
+New cancellation state. One of PTHREAD_CANCEL_ENABLE or PTHREAD_CANCEL_DISABLE.
oldstate .
Location to return the previous cancellation state.
+
Returned Value:
@@ -6072,38 +6305,149 @@ No thread could be found corresponding to that specified by the given thread ID.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
#include <pthread.h>
- int pthread_setcancelstate(void);
+ int pthread_setcanceltype(int type, FAR int *oldtype);
Description:
- NOT SUPPORTED
+The pthread_setcanceltype() function atomically both sets the calling thread's cancelability type to the indicated type and returns the previous cancelability type at the location referenced by oldtype .
+Legal values for type are PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS .
+
+
+The cancelability state and type of any newly created threads are PTHREAD_CANCEL_ENABLE and PTHREAD_CANCEL_DEFERRED respectively .
+
+
Input Parameters:
+
- To be provided .
+type
+New cancellation state. One of PTHREAD_CANCEL_DEFERRED or PTHREAD_CANCEL_ASYNCHRONOUS .
+oldtype .
+Location to return the previous cancellation type.
+
Returned Value:
If successful, the pthread_setcancelstate() function will return
zero (OK ). Otherwise, an error number will be
+returned to indicate the error.
+
+
+POSIX Compatibility: Comparable to the POSIX interface of the same name.
+
+
+
+
+Function Prototype:
+
+
+
+ #include <pthread.h>
+ void pthread_testcancel(void);
+
+
+
+Description:
+
+
+The pthread_testcancel() function creates a Cancellation Point in the calling thread.
+The pthread_testcancel() function has no effect if cancelability is disabled.
+
+
+Input Parameters: None
+
+
+Returned Value: None
+
+
+POSIX Compatibility: Comparable to the POSIX interface of the same name.
+
+
+
+
+Function Prototype:
+
+
+ #include <pthread.h>
+ void pthread_cleanup_pop(int execute);
+
+
+Description:
+
+
+The pthread_cleanup_pop() function will remove the routine at the top of the calling thread's cancellation cleanup stack and optionally invoke it (if execute is non-zero).
+
+
+Input Parameters:
+
+
+
+ execute . Execute the popped cleanup function immediately.
+
+
+
+Returned Value:
+
+
+If successful, the pthread_setcancelstate() function will return
+zero (OK ). Otherwise, an error number will be
returned to indicate the error:
+
+
+POSIX Compatibility: Comparable to the POSIX interface of the same name.
+
+
+
+
+Function Prototype:
+
+
+ #include <pthread.h>
+ void pthread_cleanup_push(CODE void (*routine)(FAR void *), FAR void *arg);
+
+
+Description:
+
+
+The pthread_cleanup_push() function will push the specified cancellation cleanup handler routine onto the calling thread's cancellation cleanup stack.
+
+
+The cancellation cleanup handler will be popped from the cancellation cleanup stack and invoked with the argument arg when:
+
+
- To be provided .
+- The thread exits (that is, calls
pthread_exit() ).
+- The thread acts upon a cancellation request.
+- The thread calls
pthread_cleanup_pop() with a non-zero execute argument.
-Assumptions/Limitations:
+
-POSIX Compatibility: Comparable to the POSIX
-interface of the same name.
+Input Parameters:
+
+
+ routine . The cleanup routine to be pushed on the the cleanup stack.
+ arg . An argument that will accompany the callback.
+
+
+Returned Value:
+
+If successful, the pthread_setcancelstate() function will return
+zero (OK ). Otherwise, an error number will be
+returned to indicate the error.
+
+
+POSIX Compatibility: Comparable to the POSIX interface of the same name.
+
-
+
Function Prototype:
@@ -6136,7 +6480,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6169,7 +6513,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6201,7 +6545,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6291,7 +6635,7 @@ interface of the same name.
Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -6383,7 +6727,7 @@ interface of the same name.
Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -6438,7 +6782,7 @@ interface of the same name.
The present implementation ignores the destructor argument.
-
+
Function Prototype:
@@ -6488,7 +6832,7 @@ interface of the same name.
destructor function.
-
+
Function Prototype:
@@ -6529,7 +6873,7 @@ interface of the same name.
destructor function.
-
+
Function Prototype:
@@ -6561,7 +6905,7 @@ this function does nothing in the present implementation.
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6592,7 +6936,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6623,7 +6967,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6655,7 +6999,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6687,7 +7031,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6722,7 +7066,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -6776,7 +7120,77 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
+
+Function Prototype:
+
+
+ #include <pthread.h>
+ int pthread_mutexattr_getprotocol(FAR const pthread_mutexattr_t *attr,
+ FAR int *protocol);
+
+
+Description: Return the value of the mutex protocol attribute..
+
+
+Input Parameters:
+
+
+
+ attr . A pointer to the mutex attributes to be queried
+ protocol . The user provided location in which to store the protocol value. May be one of PTHREAD_PRIO_NONE , or PTHREAD_PRIO_INHERIT , PTHREAD_PRIO_PROTECT .
+
+
+
+Returned Value:
+
+
+If successful, the pthread_mutexattr_getprotocol() function will return zero (OK ).
+Otherwise, an error number will be returned to indicate the error.
+
+
+Assumptions/Limitations:
+
+
+POSIX Compatibility: Comparable to the POSIX interface of the same name.
+
+
+
+
+Function Prototype:
+
+
+ #include <pthread.h>
+ int pthread_mutexattr_setprotocol(FAR pthread_mutexattr_t *attr,
+ int protocol);
+
+
+Description: Set mutex protocol attribute. See the paragraph Locking versus Signaling Semaphores for some important information about the use of this interface.
+
+
+Input Parameters:
+
+
+
+ attr . A pointer to the mutex attributes to be modified
+ protocol . The new protocol to use. One of PTHREAD_PRIO_NONE , or PTHREAD_PRIO_INHERIT , PTHREAD_PRIO_PROTECT . PTHREAD_PRIO_INHERIT is supported only if CONFIG_PRIORITY_INHERITANCE is defined; PTHREAD_PRIO_PROTECT is not currently supported in any configuration.
+
+
+
+Returned Value:
+
+
+If successful, the pthread_mutexattr_setprotocol() function will return zero (OK ).
+Otherwise, an error number will be returned to indicate the error.
+
+
+Assumptions/Limitations:
+
+
+POSIX Compatibility: Comparable to the POSIX interface of the same name.
+
+
+
Function Prototype:
@@ -6805,10 +7219,9 @@ returned to indicate the error:
Assumptions/Limitations:
-POSIX Compatibility: Comparable to the POSIX
-interface of the same name.
+POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -6839,7 +7252,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6905,7 +7318,7 @@ Otherwise, an error number will be returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6945,7 +7358,7 @@ Otherwise, an error number will be returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -6991,7 +7404,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7022,7 +7435,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7053,7 +7466,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7084,7 +7497,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7115,7 +7528,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7146,7 +7559,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7177,7 +7590,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7208,7 +7621,7 @@ returned to indicate the error:
POSIX Compatibility: Comparable to the POSIX
interface of the same name.
-
+
Function Prototype:
@@ -7245,7 +7658,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7278,7 +7691,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7310,7 +7723,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7348,7 +7761,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7380,7 +7793,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7450,7 +7863,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7494,7 +7907,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7554,7 +7967,7 @@ interface of the same name.
-
+
Function Prototype:
@@ -7598,7 +8011,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -7660,7 +8073,7 @@ interface of the same name.
POSIX Compatibility: Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -9975,6 +10388,7 @@ notify a task when a message is available on a queue.
lio_listio
listen
localtime_r
+ Locking versus Signaling Semaphores
lseek
Named Message Queue Interfaces
mkdir
@@ -9992,9 +10406,9 @@ notify a task when a message is available on a queue.
mq_timedsend
mq_unlink
mmap
+ Network Interfaces
|
- Network Interfaces
on_exit
open
opendir
@@ -10060,9 +10474,11 @@ notify a task when a message is available on a queue.
pthread_key_delete
pthread_kill
pthread_mutexattr_destroy
+ pthread_mutexattr_getprotocol
pthread_mutexattr_getpshared
pthread_mutexattr_gettype
pthread_mutexattr_init
+ pthread_mutexattr_setprotocol
pthread_mutexattr_setpshared
pthread_mutexattr_settype
pthread_mutex_destroy
@@ -10074,10 +10490,11 @@ notify a task when a message is available on a queue.
pthread_once
pthread_self
pthread_setcancelstate
+ pthread_setcanceltype
pthread_setschedparam
pthread_setspecific
pthread_sigmask
- pthread_testcancelstate
+ pthread_testcancel
pthread_yield
puts
RAM disk driver
@@ -10107,10 +10524,12 @@ notify a task when a message is available on a queue.
Counting Semaphore Interfaces
sem_close
sem_destroy
+ sem_getprotocol
sem_getvalue
sem_init
sem_open
sem_post
+ sem_setprotocol
sem_trywait
sem_unlink
sem_wait
@@ -10147,10 +10566,13 @@ notify a task when a message is available on a queue.
task_init
task_restart
Task Scheduling Interfaces
+ task_setcancelstate
+ task_spawn
task_spawnattr_getstacksize
task_spawnattr_setstacksize
Task Switching Interfaces
+ task_testcancel
telldir
timer_create
timer_delete
diff --git a/Documentation/README.html b/Documentation/README.html
index bdc92c660c8c0ec2a9488f98af28c17309ee55cb..b7d8330c10e2cf5d98291a8a26068c633c287f05 100644
--- a/Documentation/README.html
+++ b/Documentation/README.html
@@ -8,7 +8,7 @@
|
NuttX README Files
- Last Updated: July 3, 2016
+ Last Updated: December 4, 2016
|
@@ -62,18 +62,14 @@ nuttx/
| | `- README.txt
| |- avr32dev1/
| | `- README.txt
+ | |- bambino-200e/
+ | | `- README.txt
| |- c5471evm/
| | `- README.txt
| |- cc3200-launchpad/
| | `- README.txt
| |- cloudctrl/
| | `- README.txt
- | |- compal_e86/
- | | `- README.txt
- | |- compal_e88/
- | | `- README.txt
- | |- compal_e99/
- | | `- README.txt
| |- demo9s12ne64/
| | `- README.txt
| |- dk-tm4c129x/
@@ -148,6 +144,8 @@ nuttx/
| | `- README.txt
| |- mirtoo/
| | `- README.txt
+ | |- misoc/
+ | | `- README.txt
| |- moteino-mega/
| | `- README.txt
| |- mx1ads/
@@ -195,12 +193,8 @@ nuttx/
| | `- README.txt
| |- pic32mz-starterkit/
| | `- README.txt
- | |- pirelli_dpl10/
- | | `- README.txt
| |- qemu-i486/
| | `- README.txt
- | |- rgmp/
- | | `- README.txt
| |- sabre-6quad/
| | `- README.txt
| |- sama5d2-xult/
@@ -219,6 +213,8 @@ nuttx/
| | `- README.txt
| |- sam3u-ek/
| | `- README.txt
+ | |- sam4cmp-db
+ | | `- README.txt
| |- sam4e-ek/
| | `- README.txt
| |- sam4l-xplained/
@@ -324,8 +320,6 @@ nuttx/
| | `- README.txt
| |- sensors/
| | `- README.txt
- | |- sercomm/
- | | `- README.txt
| |- syslog/
| | `- README.txt
| `- README.txt
@@ -380,7 +374,8 @@ apps/
|- gpsutils/
| `- "minmea/README.txt
|- graphics/
- | `- "tiff/README.txt
+ | |- "tiff/README.txt
+ | `- "traveler/tools/tcledit/README.txt
|- interpreters/
| |- bas/README.txt
| |- ficl/README.txt
diff --git a/README.txt b/README.txt
index 599200988d25ce7b174f29ee4544597fccca1502..4ea0c5143753098d9b3e62f0797d26f80631dae1 100644
--- a/README.txt
+++ b/README.txt
@@ -987,7 +987,7 @@ Native Windows Build
The windows native build logic initiated if CONFIG_WINDOWS_NATIVE=y is
defined in the NuttX configuration file:
-
+
This build:
- Uses all Windows style paths
@@ -1279,18 +1279,14 @@ nuttx/
| | `- README.txt
| |- avr32dev1/
| | `- README.txt
+ | |- bambino-200e/
+ | | `- README.txt
| |- c5471evm/
| | `- README.txt
| |- cc3200-launchpad/
| | `- README.txt
| |- cloudctrl
| | `- README.txt
- | |- compal_e86
- | | `- README.txt
- | |- compal_e88
- | | `- README.txt
- | |- compal_e99
- | | `- README.txt
| |- demo0s12ne64/
| | `- README.txt
| |- dk-tm4c129x/
@@ -1364,6 +1360,8 @@ nuttx/
| | `- README.txt
| |- mirtoo/
| | `- README.txt
+ | |- misoc/
+ | | `- README.txt
| |- moteino-mega/
| | `- README.txt
| |- mx1ads/
@@ -1411,12 +1409,8 @@ nuttx/
| | `- README.txt
| |- pic32mz-starterkit/
| | `- README.txt
- | |- pirelli_dpl10/
- | | `- README.txt
| |- qemu-i486/
| | `- README.txt
- | |- rgmp/
- | | `- README.txt
| |- sabre-6quad/
| | `- README.txt
| |- sama5d2-xult/
@@ -1435,6 +1429,8 @@ nuttx/
| | `- README.txt
| |- sam3u-ek/
| | `- README.txt
+ | |- sam4cmp-db
+ | | `- README.txt
| |- sam4e-ek/
| | `- README.txt
| |- sam4l-xplained/
@@ -1540,8 +1536,6 @@ nuttx/
| | `- README.txt
| |- sensors/
| | `- README.txt
- | |- sercomm/
- | | `- README.txt
| |- syslog/
| | `- README.txt
| `- README.txt
@@ -1593,7 +1587,8 @@ apps/
|- gpsutils/
| `- minmea/README.txt
|- graphics/
- | `- tiff/README.txt
+ | |- tiff/README.txt
+ | `- traveler/tools/tcledit/README.txt
|- interpreters/
| |- bas
| | `- README.txt
diff --git a/ReleaseNotes b/ReleaseNotes
index 66e1c712c1e652d5be08c0d5a46a525ef27ccb0a..18b20f8b148d7ebddd1575a584f04ee7b0cc22ef 100644
--- a/ReleaseNotes
+++ b/ReleaseNotes
@@ -11775,3 +11775,522 @@ detailed bugfix information):
command line argument, or a compiled-in default value from config.
However, the default was ignored, leading to confusing error
messages. From ziggurat29.
+
+NuttX-7.18 Release Notes
+------------------------
+
+The 118th release of NuttX, Version 7.18, was made on October 8, 2016,
+and is available for download from the Bitbucket.org website. Note
+that release consists of two tarballs: nuttx-7.18.tar.gz and
+apps-7.18.tar.gz. These are available from:
+
+ https://bitbucket.org/nuttx/nuttx/downloads
+ https://bitbucket.org/nuttx/apps/downloads
+
+Both may be needed (see the top-level nuttx/README.txt file for build
+information).
+
+Additional new features and extended functionality:
+
+ * Core OS:
+
+ - Add standard adjtime() interface and basic timekeeping support.
+ Normally used with an NTP client to keep system time in
+ synchronization. From Max Neklyudov.
+ - Use the oneshot timer with optional entropy to measure CPU load if
+ so configured.
+
+ * File System and Block and MTD Drivers:
+
+ - Add Fujistu MB85RS256B ramtron support. From Beat Kng.
+ - SPI-based MTD driver for Macronix MX25L3233F or MX25L6433F. From
+ Aleksandr Vyhovanec.
+
+ * Graphics/Display Drivers:
+
+ - SH1106 0.96 OLED module support (SSD1306 compatible) + I2C fixes.
+ From v01d (phreakuencies).
+
+ * Sensor Drivers:
+
+ - Add KXJT9 Accelerometer driver from the Motorola Moto Z MDK.
+ - Add MFRC522 RFID ISO14443 and Mifare transceiver driver. From Alan
+ Carvalho de Assis.
+ - Add driver for the LIS3MDL 3 axis magnetometer. From Alexander
+ Entinger.
+ - Add driver for the MLX90393 3 axis magnetometer. From Alexander
+ Entinger.
+ - Add driver for the LIS3DSH 3 axis accelerometer. From Alexander
+ Entinger.
+ - Add driver for the Bosch BMG160 3 axis gyroscope. From Alexander
+ Entinger.
+ - Add support for the Sensixs XEN1210 3D-board. This sensor is used
+ on NANOSATC-BR2 a Brazillian CUBESAT project. From Alan Carvalho
+ de Assis.
+ - Add a new ioctl command (set MAXPOS) for Tiva QEI. From Young.
+
+ * Other Common Device Drivers:
+
+ - I/O Expander: Remove hard-coded PCA9555 fields from ioexpander.h
+ definitons. Add support for an attach() method that may be used
+ when any subset of pin interrupts occur.
+ - I/O Expander Interface: Encode and extend I/O expander options to
+ include interrupt configuration.
+ - PCA9555 Driver: Replace the signalling logic with a simple callback
+ using the new definitons of ioexpander.h. This repartitioning of
+ functionality is necessary because (1) the I/O expander driver is
+ the lower-lower part of any driver that uses GPIOs (include the GPIO
+ driver itself) and should not be interacting directly with the much
+ higher level application layer. And (2) in order to be compatible
+ with the GPIO driver (and any arbitrary upper half driver), the
+ PCA9555 should not directly signal, but should call back into the
+ upper half. The upper half driver that interacts directly with the
+ application is the appropriate place to be generating signal.
+ - Add a skeleton I/O Expander driver (based on the PCA9555 driver).
+ - Add PCF8574 I/O Expander driver.
+ - GPIO driver: Add IOCTLs to get the pin type and to unregister a
+ signal handler.
+ - Add a GPIO lower-half driver that can be used to register a GPIO
+ character driver for accessing pins on an I/O expander.
+ - Add an SPI helper function that encapsulates and manages a sequence
+ of SPI transfers.
+ - Add an SPI character driver that will permit access to the SPI bus
+ for testing purposes.
+ - Add oneshot timer lower half interface definition.
+ - Add an upper-half, oneshot timer character driver.
+ - Add Audio Tone Generator for NuttX. From Alan Carvalho de Assis.
+ - Add USB host support for composite devices. This feature is not
+ well tested.
+ - drivers/ioexpander: Add an (untested) TCA64XX I/O Expander driver
+ leveraged from Project Ara.
+
+ * Simulation Platform:
+
+ - Add a simulated I/O Expander driver.
+ - Add simulator-based test support for apps/examples/gpio.
+ - Add a configuration useful for testing Mini Basic.
+ - Add a simulated oneshot lowerhalf driver.
+
+ * Atmel SAM3/4 Drivers:
+
+ - SAM4CM: Add option to support oneshot timer without free-running
+ timer. Add oneshot lower half driver.
+
+ * Atmel SAMA5 Drivers:
+
+ - SAMA5D: Add option to support oneshot timer without free-running
+ timer. Add oneshot lower half driver.
+
+ * Atmel SAMV7 Drivers:
+
+ - SAMV71/SAME70: Add option to support oneshot timer without
+ free-running timer. Add oneshot lower half driver.
+ - Add support for SAMV7 DACC module. From Piotr Mienkowski.
+
+ * NXP Freescale Kinetis Drivers:
+
+ - Add support for I2C and RTC. From v01d (phreakuencies).
+
+ * NXP Freescale Kinetis Boards:
+
+ - Add teensy 3.x I2C support. From v01d (phreakuencies).
+
+ * STMicro STM32:
+
+ - Add IAR-style STM32F1xx vectors. Tested on STM32F103RB and
+ STM32F107RC. From Aleksandr Vyhovanec.
+
+ * STMicro STM32 Drivers:
+
+ - Add timekeeping support for the STM32 tickless mode. From Max
+ Neklyudov.
+ - Add a oneshot, lower-half driver for STM32.
+ - STM32 L4: Add oneshot lower half driver for STM32 L4.
+ - STM32 L4: Add support for quadrature encoders on STM32L4. Sebastien
+ Lorquet.
+
+ * STMicro STM32 Boards:
+
+ - stm32f103-minimum: Add board support to MFRC522 driver. From Alan
+ Carvalho de Assis.
+ - Add oneshot board initialization to stm32f103-minimum. From Alan
+ Carvalho de Assis.
+ - stm32f103-minimum: Add board configuration to initialize Audio Tone
+ Generator. From Alan Carvalho de Assis.
+ - stm32bufferfly2: Add support for the Kamami stm32butterfly2
+ development board with optional ETH phy. From Michal Lyszczek.
+ - stm32f103-minimum: Add board config support to SPI LCD module
+ JLX12864G-086. From Alan Carvalho de Assis.
+ - stm32l476-mdk: Support basic booting and nsh on Motorola MDK. The
+ Motorola MDK is based off of an earlier version of NuttX.
+ This only provides a basic NSH shell. From Jim Wylder.
+ - STM32 F4 Discovery: Add support for XEN1210 3D-board. From Alan
+ Carvalho de Assis.
+ - stm32f103-minimum: Add stm32_bringup support and userled example to
+ STM32F103 Minimum board. From Alan Carvalho de Assis.
+ - Add support for qencoders on various nucleo boards. From Sebastien
+ Lorquet.
+ - olimex-stm32-e407: Add some networking configurations. From Mateusz
+ Szafoni.
+
+ * TI Tiva Drivers:
+
+ - Add tiva PWM lower-half driver implementation. From Young.
+ - Tiva QEI: Add QEI lower-half driver for Tiva series chip. From
+ Young.
+
+ * C Library/Header Files:
+
+ - Separate XorShift128 PRNG from /dev/urandom and make it generally
+ available.
+ - Add POSIX type sig_atomic_t. From Sebastien Lorquet.
+ - Add the difftime() function. The function depends on the toolchain-
+ dependent CONFIG_HAVE_DOUBLE so is not available on tiny platforms.
+ From Sebastien Lorquet.
+ - Add support for remove(). From Sebastien Lorquet.
+ - Add system() to stdlib.h. Actual implementation is in
+ apps/system/system.
+
+ * Build/Configuration System:
+
+ - Rename arch/sh to arch/renesas.
+ - Remove contactless drivers from drivers/wireless to drivers
+ contactless. From Sebastien Lorquet.
+ - Move all modem-related IOCTL commands to a common file to assure
+ that they will be unique.
+
+ * Tools:
+
+ - Add sethost.sh. This is a script that you can use to quickly
+ change the host platform from Linux to Windows/Cygwin. Might save
+ you a lot of headaches.
+
+ * Applications: apps/nshlib:
+
+ - Add logic to support an NSH-specific system command.
+ - Add printf command to NSH, e.g., controlling /dev/userleds from
+ command line: nsh> printf \x01 > /dev/userleds. From Alan Carvalho
+ de Assis.
+
+ * Platforms: apps/system:
+
+ - Port tee command from NetBSD.
+ - Add a generic system command. Current implentation cannot use
+ /bin/sh and spawns the custom NSH system command directly.
+
+ * Platforms: apps/platform:
+
+ - Add C++ support for STM32L476-MDK.
+
+ * Platforms: apps/interpreters:
+
+ - Add a port of Mini Basic, version 1.0, written by Malcom McLean and
+ released under the Creative Commons Attribution license.
+
+ * Applications: apps/examples:
+
+ - Add a simple test of the GPIO driver.
+ - Add RFID_READUID sample application. From Alan Carvalho de Assis.
+ - Add Oneshot timer example.
+ - Add a simple test of the system command.
+
+Works-In-Progress:
+
+ * IEEE802.14.5/6LowPAN. Hooks and framework for this effort were
+ introduced in NuttX-7.15. Work has continued on this effort on
+ forks from the main repositories, albeit with many interruptions.
+ The completion of this wireless feature will postponed until at
+ least NuttX-7.19.
+
+Bugfixes. Only the most critical bugfixes are listed here (see the
+ChangeLog for the complete list of bugfixes and for additional, more
+detailed bugfix information):
+
+ * Core OS:
+
+ - Explicitly initialize the group tg_exitsem with sem_init(). The
+ existing logic worked because the correct initialization value is
+ all zero, but it is better to initialize the semaphore explicitly.
+ - The TCB nchildren field should not be incremented when pthreads are
+ created.
+ - Move fields related to parent/child task relationship out of TCB
+ into group structure where they belong. Child is a group, not a
+ thread.
+ - mq_send() was not setting the errno value on certain failures to
+ allocate a message.
+ - Define 'group' even if HAVE_GROUPID is not set. From Mateusz
+ Szafoni.
+ - Vector table should have dimension NR_IRQS, not NR_IRQS+1. From
+ Sagitta Li.
+ - pthreads: When a pthread is started, there is a small bit
+ of logic that will run on the thread of execution of the new
+ pthread. In the case where the new pthread has a lower
+ priority than the parent thread, then this could cause both the
+ parent thread and the new pthread to be blocked at the priority of
+ the lower priority pthread (assuming that CONFIG_PRIORITY_INHERITANCE
+ is not selected). This change temporarily boosts the priority of the
+ new pthread to at least the priority of the new pthread to at least
+ the priority of the parent thread. When that bit of logic has
+ executed on the thread of execution of the new pthread, it will then
+ drop to the correct priority (if necessary) before calling into the
+ new pthread's entry point.
+
+ * File System/Block Drivers/MTD Drivers:
+
+ - FAT performance improvement. In large files, seeking to a
+ position from the beginning of the file can be very time consuming.
+ ftell does lssek(fd, 0, SET_CURR). In that case, that is wasted
+ time since we are going to seek to the same position. This fix
+ short-circuits fat_seek() in all cases where we attempt to seek to
+ current position. Suggested by Nate Weibley.
+ - MTD: Fixed cloned typos in several FLASH drivers. From Aleksandr
+ Vyhovanec.
+ - mount: Corrects a bad assertion noted by Pierre-noel Bouteville.
+ Also fixes a reference counting problem in an error condition:
+ When the mountpoint inode is found but is not an appropriate
+ mountpoint, the reference count on the inode was not being
+ decremented.
+
+ * Common Drivers:
+
+ - Various serial drivers: Fix FIONWRITE and add FIONSPACE. All
+ implementations of FIONWRITE were wrong. FIONWRITE should return
+ the number of bytes waiting in the outgoing send queue, not the free
+ space. Rather, FIONSPACE should return the free space in the send
+ queue.
+ - Add missing prototype for btn_lower_initialize().
+ - Make DAC sample structure packed. From Marc Recht.
+
+ * Networking:
+
+ - TCP: tcp_ipvX_bind() not actually using the port selected with
+ port==0. Also removes duplicate call to pkt_input(). Issues noted
+ by Pascal Speck.
+ - drivers/net: NET_TUN=y => NET_MULTIBUFFER=y. From Vladimir
+ Komendantskiy.
+ - slip driver: Fix calculations using MSEC_PER_TICK. If
+ USEC_PER_TICK is less than 1000, then MSEC_PER_TICK will be
+ zero. It will be inaccurate in any case.
+
+ * Atmel SAM3/4 Drivers:
+
+ - SAM3/4 GPIO: Enable peripheral clock for GPIO port when GPIO is
+ configured as input. The value of a GPIO input is only sampled when
+ the peripheral clock for the port controller the GPIO resides in is
+ enabled. Therefore we need to enable the clock even when polling a
+ GPIO. From Wolfgang Reissnegger.
+ - All SAM Ethernet Drivers: Add support so that the drivers can be
+ built with CONFIG_NET_MULTIBUFFER=y.
+ - SAM3/4: Fix GPIO pull-up/down code. Enabling the pull-down resistor
+ while the pull-up resistor is still enabled is not possible. In this
+ case, the write of PIO_PPDER for the relevant I/O line is discarded.
+ Likewise, enabling the pull-up resistor while the pull-down resistor
+ is still enabled is not possible. In this case, the write of
+ PIO_PUER for the relevant I/O line is discarded. From Wolfgang
+ Reinegger.
+
+ * Atmel SAMV7 Drivers:
+
+ - All SAM Ethernet Drivers: Add support so that the drivers can be
+ built with CONFIG_NET_MULTIBUFFER=y.
+ - SAM GPIO: Apply Wolfgang's change for SAM3/4 to SAMA5 and SAMV7.
+
+ * Atmel SAMA5:
+
+ - Add missing oneshot max_delay method.
+ - All SAM Ethernet Drivers: Add support so that the drivers can be
+ built with CONFIG_NET_MULTIBUFFER=y.
+ - SAM GPIO: Apply Wolfgang's change for SAM3/4 to SAMA5 and SAMV7.
+
+ * NXP Freescale LPC43xx Drivers:
+
+ - LPC43xx serial: Fix typos in LPC43 serial driver. Found by Vytautas
+ Lukenskas.
+ - LPC43xx Serial: There are some small problems in LPC43xx RS485 mode
+ configuration. In particular: (1) UART0,2,3 do not have DTR pins
+ (different from UART1), so, Kconfig needs to be adjusted. (2)
+ lpc43_uart.c in RS485 mode only configures DIR pin, but doesn't
+ enable pin output for UART0,2,3. (3) should be option to reverse DIR
+ control pin output polarity. (4) lpc43xx/chip/lpc43_uart.h doesn't
+ have USART3 definitions. NOTE: I didn't modified and didn't tested
+ USART1, as it has different hardware. From Vytautas Lukenskas.
+ From Vytautas Lukenskas.
+
+ * SiLabs EFM32 Drivers:
+
+ - EFM32 SPI drivers adopted incompatible conventions (See STM32 for
+ details of the issue).
+
+ * STMicro STM32 Drivers:
+
+ - STM32, STM32 L4, and EFM32 SPI drivers adopted incompatible
+ conventions somewhere along the line. They set the number of bits
+ to negative when calling SPI_SETBITS which had the magical side-
+ effect of setting LSB first order of bit transmission. This is not
+ only a hokey way to pass control information but is supported by no
+ other SPI drivers. This change three things: (1) It adds
+ HWFEAT_LSBFIRST as a new H/W feature. (2) It changes the
+ implementations of SPI_SETBITS in the STM32 and EFM32 drivers so
+ that negated bit numbers are simply errors and it adds the
+ SPI_HWFEATURES method that can set the LSB bit order, and
+ (3) It changes all calls with negative number of bits from all
+ drivers: The number of bits is now always positive and
+ SPI_HWFEATURES is called with HWFEAT_LSBFIRST to set the bit order.
+ - Add missing SPI2 and SPI3 support for STM32F3F3. Add STM32F37XX DMA
+ channel configuration. For STM32F37XX, SYSCFG_EXTICR_PORTE defined
+ twice. From Alan Carvalho de Assis.
+ - STM32: Make stm32_pwr_enablebkp thread safe. From Max Neklyudov.
+ - Fix bad pllmul values for STM32F1XX connectivity line. STM32F1XX
+ connectivity line supports only x4, x5, x6, x7, x8, x9 and x6.5
+ values. From Michal Lyszczek.
+ - STM32F3 SPI: Fix the number of bit setting for the F3. That and
+ data packing work differently on the STM32F3 than for other STM32
+ parts.
+ - STM32 and STM32 L4: Enabling SPI DMA loses other bits in CR2.
+ - STM32F3 SPI: Cannot write always 16-bit value to DR register
+ because of how the F3 implements data packing.
+ - STM32F411 and STM32F446 map i2c2_sda_4 to different alternate
+ function numbers. From Konstantin Berezenko.
+ - STM32 DMA Fix: Change stm32 adc dma callback to send channel
+ number instead of index. From Konstantin Berezenko.
+ - STM32 OTGFS device: Fix for lost first word from FIFO
+
+ 1) Do not overwrite Reserved Bits in GINTSTS (per ref manual)*
+ 2) Acknowledge all pending int on entry to ISR that are Only rc_w1*
+ 3) Do not disable RXFVL*
+ 4) Loop until RXFVL is cleared*
+ 5) Only clear the NAK on the endpoint on the OTGFS_GRXSTSD_PKTSTS_SETUPDONE to not loose the first WORD of FIFO all the data (Bug Fix)
+
+ Changed marked *are just driver clean up and ensure ints are not lost. The bug fix is #5
+
+ Test case open putty and observer the Set/Get LineCoding. Without this fix #5 the Get will not match the Set, and in fact the data might be skewed by 4 bytes, that are lost from the FIFO if the OTGFS_DOEPCTL0_CNAK bit is set in the OTGFS_GRXSTSD_PKTSTS_SETUPRECVD as opposed to the OTGFS_GRXSTSD_PKTSTS_SETUPDONE
+
+ Set Line Coding DATA1: 4B | 00 c2 01 00 00 00 08 | c8 1B
+ Get Line Coding DATA1: 4B | .. .. .. .. 00 00 08 c8 .. 00 00 07 | 7a 72
+
+ From David Sidrane.
+ - STM32 L4 OTGFS device: Apply stm32 fix to stm32l4. From Sebastien
+ Lorquet.
+ - STM32 F7: Remove duplicate call to pkt_input from Ethernet driver.
+ Issues noted by Pascal Speck.
+ - STM32 L4: Add support for USART3-USART5. For STM32L4 parts, the
+ higher number USART ports supported varies. Add the HAVE_USARTx
+ definitions to the configuration to allow enabling the higher
+ numbered USART ports. From Jim Wylder.
+ - STM32 USB: Set USB address to avoid a failed assertion. From
+ Pierre-noel Bouteville.
+ - STM32 L4 and L7 USB: Pierre's assertion-avoidance change should
+ also be applied to STM32 F7 and L4.
+ - STM32, L4, and F7: Remove GPIO_ETH_RMII_TX_CLK. TX_CLK is not
+ present in RMII. Mateusz Szafoni.
+ - STM32 Ethernet: Correct typo in conditional logic. From Neil
+ Hancock.
+ - STM32 L4 USB Device: Fixed L4 USB Driver by avoiding SETUPDONE and
+ EPOUT_SETUP. From David Sidrane.
+ - STM32 SPI: stm32_modifycr2 should be available on all platforms if
+ DMA is enabled.
+ - STM32 DMA2D: fix an error in up_dma2dcreatelayer where an invalid
+ pointer was returned when a certain underlying function failed.
+ From Jens Grf.
+
+ * TI Tiva Drivers:
+
+ - Fix two bugs of tiva pwm lower-half driver implementation. From
+ Young.
+ - Tiva Ethernet: Needs support for CONFIG_NET_MULTIBUFFER=y.
+
+ * C Library/Header Files:
+
+ - lib_dumpbuffer() now prints a large on-stack buffer first to avoid
+ problems when the syslog output is prefixed with time. From
+ Pierre-noel Bouteville.
+ - libc/math: This fixes the following libc/math issues: (1) asin[f l]()
+ use Newtons method to converge on a solution. But Newtons method
+ converges very slowly (> 500,000 iterations) for values of x close to
+ 1.0; and, in the case of asinl(), sometimes fails to converge (loops
+ forever). The attached patch uses an trig identity for values of
+ x > sqrt(2). The resultant functions converge in no more than 5
+ iterations, 6 for asinl(). (2) The NuttX erf[f l]() functions are
+ based on Chebyshev fitting to a good guess. The problem theres a
+ bug in the implementation that causes the functions to blow up with
+ x near -3.0. This patch fixes that problem. It should be noted that
+ this method returns the error function erf(x) with fractional error
+ less than 1.2E-07 and thats fine for the float version erff(), but
+ the same method is used for double and long double version which
+ will yield only slightly better precision. This patch doesn't
+ address the issue of lower precision for erf() and erfl(). (3) a
+ faster version of copysignf() for floats is included. From David S.
+ Alessio.
+ - strtod() was not returning endptr on error conditions.
+ - libc/math: floor(), floorf(), and floorl(): Fix logic error. Was
+ not correctly handling negative integral value.
+ - isatty() should be prototyped in unstid.h, not termios.h. From
+ Sebastien Lorquet.
+ - nxglib: Fix handling of near-horizontal lines of width 1 in
+ nxgl_splitline(). Missing handling for degenerate condition caused
+ width 1 lines such as (0, 0) - (100, 10) to have gaps in the
+ drawing. From Petteri Aimonen.
+
+ * Build/Configuration System:
+
+ - Top-Level Makefiles: Fix a chicken-and-egg problem. In the menuconfig
+ target, the context dependency was executed before kconfig-mconf. That
+ was necessary because the link at apps/platform/board needed to be set
+ up before creating the apps/Kconfig file. Otherwise, the platform
+ Kconfig files would not be included. But this introduces the chicken-
+ and-egg problem in some configurations. In particular: (1) An NX
+ graphics configuration is used that requires auto-generation of
+ source files using cpp, (2) the configuration is set for Linux, but
+ (3) we are running under Cygwin with (4) a Windows native toolchain.
+ In this case, POSIX-style symbolic links are set up but the Windows
+ native toolchain cannot follow them. The reason we are running
+ 'make menuconfig' is to change from Linux to Cygwin, but the target
+ fails. During the context phase, NX runs CPP to generate source files
+ but that fails because the Windows native toolchain cannot follow
+ the links. Checkmate. This was fixed by changing all of the make
+ menuconfig (and related) targets. They no longer depend on context
+ being run. Instead, they depend only on the dirlinks target. The
+ dirlinks target only sets up the directory links but does not try
+ to run all of the context setup; the compiler is never invoked; no
+ code is autogenerated and things work.
+ - CXXFLAGS: add -fcheck-new whenever -fno-exceptions is used. From
+ Beat Kng.
+
+ * Tools
+
+ - tools/refresh.sh: Recent complexities added to apps/ means that
+ configuration needs the correct Make.defs file in place in order to
+ configure properly.
+ - tools/kconfig2html.c: Update to handle absolute paths when sourcing
+ Kconfig files.
+ - tools/mkfsdata.pl was still generating the old-style apps/include
+ inclusion paths.
+
+ * Application Build/Configuration System:
+
+ - Add DIRLINK and DIRUNLINK tool definitions to apps/Make.defs.
+
+ * apps/nshlib:
+
+ - Fix FIFO_SIZE vs PIPE_SIZE.
+ - Fix hex representation of IP address in Kconfig. Noted by Michal
+ Lyszczek.
+ - nsh_syscmds.c: missing semicolon. From Mateusz Szafoni.
+ - In system command, don't try to flush output streams if stdio
+ buffered I/O is not supported.
+
+ * apps/canutils:
+
+ - libuavcan: Under certain circumstances, DELIM is not be defined in
+ Makefile.
+ - Add definition for APPNAME in apps/canutils/canlib. From Sebastien
+ Lorquet.
+
+ * apps/gpsutils:
+
+ - Fix an error minmea. From Aleksandr Vyhovanec.
+
+ * apps/examples:
+
+ - apps/examples/oneshot: If the requested delay is > max_delay, then
+ break the delay up into several pieces.
diff --git a/TODO b/TODO
index 5372b0aec5044cb7c37a920b531f1bdfdc5ad877..38557d81242ba670997708eb6a25acc7b00d7092 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-NuttX TODO List (Last updated July 20, 2016)
+NuttX TODO List (Last updated December 11, 2016)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This file summarizes known NuttX bugs, limitations, inconsistencies with
@@ -9,20 +9,22 @@ issues related to each board port.
nuttx/:
- (13) Task/Scheduler (sched/)
+ (12) Task/Scheduler (sched/)
+ (1) SMP
(1) Memory Management (mm/)
+ (1) Power Management (drivers/pm)
(3) Signals (sched/signal, arch/)
(2) pthreads (sched/pthread)
(0) Message Queues (sched/mqueue)
- (9) Kernel/Protected Build
+ (8) Kernel/Protected Build
(3) C++ Support
(6) Binary loaders (binfmt/)
- (11) Network (net/, drivers/net)
+ (12) Network (net/, drivers/net)
(4) USB (drivers/usbdev, drivers/usbhost)
(0) Other drivers (drivers/)
- (11) Libraries (libc/, libm/)
+ (12) Libraries (libc/, libm/)
(11) File system/Generic drivers (fs/, drivers/)
- (8) Graphics subsystem (graphics/)
+ (9) Graphics Subsystem (graphics/)
(2) Build system / Toolchains
(3) Linux/Cywgin simulation (arch/sim)
(4) ARM (arch/arm/)
@@ -99,16 +101,37 @@ o Task/Scheduler (sched/)
Status: Open
Priority: Medium Low for now
- Title: ISSUES WITH atexit() AND on_exit()
+ Title: ISSUES WITH atexit(), on_exit(), AND pthread_cleanup_pop()
Description: These functions execute with the following bad properties:
1. They run with interrupts disabled,
2. They run in supervisor mode (if applicable), and
3. They do not obey any setup of PIC or address
environments. Do they need to?
+ 4. In the case of task_delete() and pthread_cancel(), these
+ callbacks will run on the thread of execution and address
+ context of the caller of task. That is very bad!
The fix for all of these issues it to have the callbacks
- run on the caller's thread (as with signal handlers).
+ run on the caller's thread as is currently done with
+ signal handlers. Signals are delivered differently in
+ PROTECTED and KERNEL modes: The deliver is involes a
+ signal handling trampoline function in the user address
+ space and two signal handlers: One to call the signal
+ handler trampoline in user mode (SYS_signal_handler) and
+ on in with the signal handler trampoline to return to
+ supervisor mode (SYS_signal_handler_return)
+
+ The primary difference is in the location of the signal
+ handling trampoline:
+
+ - In PROTECTED mode, there is on a single user space blob
+ with a header at the beginning of the block (at a well-
+ known location. There is a pointer to the signal handler
+ trampoline function in that header.
+ - In the KERNEL mode, a special process signal handler
+ trampoline is used at a well-known location in every
+ process address space (ARCH_DATA_RESERVE->ar_sigtramp).
Status: Open
Priority: Medium Low. This is an important change to some less
important interfaces. For the average user, these
@@ -142,20 +165,6 @@ o Task/Scheduler (sched/)
incompatibilities could show up in porting some code).
Priority: Low
- Title: REMOVE TASK_DELETE
- Description: Need to remove or fix task delete. This interface is non-
- standard and not safe. Arbitrary deleting tasks can cause
- serious problems such as memory leaks. Better to remove it
- than to retain it as a latent bug.
-
- Currently used within the OS and also part of the
- implementation of pthread_cancel() and task_restart() (which
- should also go for the same reasons). It is used in
- NxWM::CNxConsole to terminate console tasks and also in
- apps/netutils/thttpd to kill CGI tasks that timeout.
- Status: Open
- Priority: Low and not easily removable.
-
Title: RELEASE SEMAPHORES HELD BY CANCELED THREADS:
Description: Commit: fecb9040d0e54baf14b729e556a832febfe8229e: "In
case a thread is doing a blocking operation (e.g. read())
@@ -215,6 +224,74 @@ o Task/Scheduler (sched/)
Status: Open
Priority: Medium-ish
+ Title: ISSUES WITH PRIORITY INHERITANCE WHEN SEMAPHORE/MUTX IS USED AS IPC
+ Description: Semaphores have multiple uses. The typical usage is where
+ the semaphore is used as lock on one or more resources. In
+ this typical case, priority inheritance works perfectly: The
+ holder of a semaphore count must be remembered so that its
+ priority can be boosted if a higher priority task requires a
+ count from the semaphore. It remains the holder until the
+ same task calls sem_post() to release the count on the
+ semaphore.
+
+ But a different usage model for semaphores is for signalling
+ events. In this case, the semaphore count is initialized to
+ zero and the receiving task calls sem_wait() to wait for the
+ next event of interest. When an event of interest is
+ detected by another task (or even an interrupt handler),
+ sem_post() is called which increments the count to 1 and
+ wakes up the receiving task.
+
+ For example, in the following TASK A waits for events and
+ TASK B (or perhaps an interrupt handler) signals task A of
+ the occurence of the events by posting the semaphore:
+
+ ---------------------- ---------------
+ TASK A TASK B
+ ---------------------- ---------------
+ sem_init(sem, 0, 0);
+ sem_wait(sem);
+ sem_post(sem);
+ Awakens as holder
+ ---------------------- ---------------
+
+ These two usage models are really very different and priority
+ inheritance simply does not apply when the semaphore is used for
+ signalling rather than locking. In this signalling case
+ priority inheritance can interfere with the operation of the
+ semaphore. The problem is that when TASK A is awakened it is
+ a holder of the semaphore. Normally, a task is removed from
+ the holder list when it finally releases the semaphore via
+ sem_post().
+
+ However, TASK A never calls sem_post(sem) so it becomes
+ *permanently* a holder of the semaphore and may have its
+ priority boosted at any time when any other task tries to
+ acquire the semaphore.
+
+ The fix is to call sem_setprotocol(SEM_PRIO_NONE) immediately
+ after the sem_init() call so that there will be no priority
+ inheritance operations on this semaphore used for signalling.
+
+ NOTE also that in NuttX, pthread mutexes are build on top of
+ binary semaphores. As a result, the above recommendation also
+ applies when pthread mutexes are used for inter-thread
+ signaling. That is, a mutex that is used for signaling should
+ be initialize like this (simplified, no error checking here):
+
+ pthread_mutexattr_t attr;
+ pthread_mutex_t mutex;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_PRIO_NONE);
+ pthread_mutex_init(&mutex, &attr);
+
+ Status: Closed. If you have priority inheritance enabled and you use
+ semaphores for signalling events, then you *must* call
+ sem_setprotocol(SEM_PRIO_NONE) immediately after initializing
+ the semaphore.
+ Priority: High.
+
Title: SCALABILITY
Description: Task control information is retained in simple lists. This
is completely appropriate for small embedded systems where
@@ -235,6 +312,37 @@ o Task/Scheduler (sched/)
Priority: Low. Things are just the way that we want them for the way
that NuttX is used today.
+o SMP
+ ^^^
+
+ Title: SMP AND DATA CACHES
+ Description: When spinlocks, semaphores, etc. are used in an SMP system with
+ a data cache, then there may be problems with cache coherency
+ in some CPU architectures: When one CPU modifies the shared
+ object, the changes may not be visible to another CPU if it
+ does not share the data cache. That would cause failure in
+ the IPC logic.
+
+ Flushing the D-cache on writes and invalidating before a read is
+ not really an option. That would essentially effect every memory
+ access and there may be side-effects due to cache line sizes
+ and alignment.
+
+ For the same reason a separate, non-cacheable memory region is
+ not an option. Essentially all data would have to go in the
+ non-cached region and you would have no benefit from the data
+ cache.
+
+ On ARM Cortex-A, each CPU has a separate data cache. However,
+ the MPCore's Snoop Controller Unit supports coherency among
+ the different caches. The SCU is enabled by the SCU control
+ register and each CPU participates in the SMP coherency by
+ setting the ACTLR_SMP bit in the auxiliary control register
+ (ACTLR).
+
+ Status: Closed
+ Priority: High on platforms that may have the issue.
+
o Memory Management (mm/)
^^^^^^^^^^^^^^^^^^^^^^^
@@ -323,6 +431,34 @@ o Memory Management (mm/)
Priority: Medium/Low, a good feature to prevent memory leaks but would
have negative impact on memory usage and code size.
+o Power Management (drivers/pm)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ Title: PM CALLBACKS AREN'T BASED ON DOMAIN
+ Description: Recently support for different power domains was added. Prior
+ to this, only a single domain (the "IDLE" domain was supported).
+ Having multiple power domains extends the basic concept to
+ support power management for different functionality. For
+ example, a UI may be managed separately from, say, some network
+ functionality.
+
+ One thing that was missed when the PM domains was added was
+ support for domain-specific driver callbacks: Currently, all
+ callbacks will be invoked for all PM domain events making it
+ impossible to distinguish the domain in the driver.
+
+ Possibilities:
+ - Add a domain value to the PM registration function. In this
+ case, callbacks would be retained separately for each domain
+ and those callbacks would be invoked only for domain-specific
+ events.
+ - Add a domain value to the PM callback functions. In this case,
+ each driver would receive events from all domains and could
+ respond different (or ignore) events from other domains.
+ Status: Open
+ Priority: Currently low because I know of no use of the multiple PM
+ domains. But, obviously, this would become important if the
+ features were used.
o Signals (sched/signal, arch/)
^^^^^^^^^^^^^^^^^^^^^^^
@@ -362,29 +498,25 @@ o Signals (sched/signal, arch/)
o pthreads (sched/pthreads)
^^^^^^^^^^^^^^^^^
- Title: CANCELLATION POINTS
- Description: pthread_cancel(): Should implement cancellation points and
- pthread_testcancel()
- Status: Open. No changes are planned.
- Priority: Low, probably not that useful
-
Title: PTHREAD_PRIO_PROTECT
- Description: Extended pthread_mutexattr_setprotocol() support PTHREAD_PRIO_PROTECT:
+ Description: Extend pthread_mutexattr_setprotocol() support PTHREAD_PRIO_PROTECT:
+
"When a thread owns one or more mutexes initialized with the
PTHREAD_PRIO_PROTECT protocol, it shall execute at the higher of its
priority or the highest of the priority ceilings of all the mutexes
owned by this thread and initialized with this attribute, regardless of
whether other threads are blocked on any of these mutexes or not.
- "While a thread is holding a mutex which has been initialized with
+ "While a thread is holding a mutex which has been initialized with
the PTHREAD_PRIO_INHERIT or PTHREAD_PRIO_PROTECT protocol attributes,
it shall not be subject to being moved to the tail of the scheduling queue
at its priority in the event that its original priority is changed,
such as by a call to sched_setparam(). Likewise, when a thread unlocks
a mutex that has been initialized with the PTHREAD_PRIO_INHERIT or
PTHREAD_PRIO_PROTECT protocol attributes, it shall not be subject to
- being moved to the tail of the scheduling queue at its priority in the
+ being moved to the tail of the scheduling queue at its priority in the
event that its original priority is changed."
+
Status: Open. No changes planned.
Priority: Low -- about zero, probably not that useful. Priority inheritance is
already supported and is a much better solution. And it turns out
@@ -392,39 +524,77 @@ o pthreads (sched/pthreads)
Excerpted from my post in a Linked-In discussion:
"I started to implement this HLS/"PCP" semaphore in an RTOS that I
- work with (http://www.nuttx.org) and I discovered after doing the
- analysis and basic code framework that a complete solution for the
- case of a counting semaphore is still quite complex -- essentially
- as complex as is priority inheritance.
+ work with (http://www.nuttx.org) and I discovered after doing the
+ analysis and basic code framework that a complete solution for the
+ case of a counting semaphore is still quite complex -- essentially
+ as complex as is priority inheritance.
"For example, suppose that a thread takes 3 different HLS semaphores
- A, B, and C. Suppose that they are prioritized in that order with
- A the lowest and C the highest. Suppose the thread takes 5 counts
- from A, 3 counts from B, and 2 counts from C. What priority should
- it run at? It would have to run at the priority of the highest
- priority semaphore C. This means that the RTOS must maintain
- internal information of the priority of every semaphore held by
- the thread.
+ A, B, and C. Suppose that they are prioritized in that order with
+ A the lowest and C the highest. Suppose the thread takes 5 counts
+ from A, 3 counts from B, and 2 counts from C. What priority should
+ it run at? It would have to run at the priority of the highest
+ priority semaphore C. This means that the RTOS must maintain
+ internal information of the priority of every semaphore held by
+ the thread.
"Now suppose it releases one count on semaphore B. How does the
- RTOS know that it still holds 2 counts on B? With some complex
- internal data structure. The RTOS would have to maintain internal
- information about how many counts from each semaphore are held
- by each thread.
+ RTOS know that it still holds 2 counts on B? With some complex
+ internal data structure. The RTOS would have to maintain internal
+ information about how many counts from each semaphore are held
+ by each thread.
"How does the RTOS know that it should not decrement the priority
- from the priority of C? Again, only with internal complexity. It
- would have to know the priority of every semaphore held by
- every thread.
+ from the priority of C? Again, only with internal complexity. It
+ would have to know the priority of every semaphore held by
+ every thread.
"Providing the HLS capability on a simple pthread mutex would not
- be such quite such a complex job if you allow only one mutex per
- thread. However, the more general case seems almost as complex
- as priority inheritance. I decided that the implementation does
- not have value to me. I only wanted it for its reduced
- complexity; in all other ways I believe that it is the inferior
- solution. So I discarded a few hours of programming. Not a
- big loss from the experience I gained."
+ be such quite such a complex job if you allow only one mutex per
+ thread. However, the more general case seems almost as complex
+ as priority inheritance. I decided that the implementation does
+ not have value to me. I only wanted it for its reduced
+ complexity; in all other ways I believe that it is the inferior
+ solution. So I discarded a few hours of programming. Not a
+ big loss from the experience I gained."
+
+ Title: ISSUES WITH CANCELLATION POINTS
+ Description: According to POIX cancellation points must occur when a thread is executing
+ the following functions. There are some execptions as noted:
+
+ accept() mq_timedsend() NA putpmsg() sigtimedwait()
+ 04 aio_suspend() NA msgrcv() pwrite() NA sigwait()
+ NA clock_nanosleep() NA msgsnd() read() sigwaitinfo()
+ close() NA msync() NA readv() 01 sleep()
+ connect() nanosleep() recv() 02 system()
+ -- creat() open() recvfrom() NA tcdrain()
+ fcntl() pause() NA recvmsg() 01 usleep()
+ NA fdatasync() poll() select() -- wait()
+ fsync() pread() sem_timedwait() waitid()
+ NA getmsg() NA pselect() sem_wait() waitpid()
+ NA getpmsg() pthread_cond_timedwait() send() write()
+ NA lockf() pthread_cond_wait() NA sendmsg() NA writev()
+ mq_receive() pthread_join() sendto()
+ mq_send() pthread_testcancel() 03 sigpause()
+ mq_timedreceive() NA putmsg() sigsuspend()
+
+ NA Not supported
+ -- Doesn't need instrumentation. Handled by lower level calls.
+ nn See note nn
+
+ NOTE 01: sleep() and usleep() are user-space functions in the C library and cannot
+ serve as cancellation points. They are, however, simple wrappers around nanosleep
+ which is a true cancellation point.
+ NOTE 02: system() is actually implemented in apps/ as part of NSH. It cannot be
+ a cancellation point either.
+ NOTE 03: sigpause() is a user-space function in the C library and cannot serve as
+ cancellation points. It is, however, a simple wrapper around sigsuspend()
+ which is a true cancellation point.
+ NOTE 04: aio_suspend() is a user-space function in the C library and cannot serve as
+ cancellation points. It does call around sigtimedwait() which is a true cancellation
+ point.
+ Status: Not really open. This is just the way it is.
+ Priority: Nothing additional is planned.
o Message Queues (sched/mqueue)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -584,14 +754,6 @@ o Kernel/Protected Build
improvement. However, there is no strong motivation now do
do that partitioning work.
- Title: TIMER INTERRUPT CALLBACK
- Description: The timer upper half driver at drivers/timers/timer.c performs
- interrupt level callbacks into applications. This, of course,
- will never work in anything but a non-secure, flat build.
- Status: Open
- Priority: Medium. The driver is only usable with all of its features
- in a FLAT build.
-
Title: USER MODE TASKS CAN MODIFY PRIVILEGED TASKS
Description: Certain interfaces, such as sched_setparam(),
sched_setscheduler(), etc. can be used by user mode tasks to
@@ -920,41 +1082,18 @@ o Network (net/, drivers/net)
Priority: Medium. Important on slow applications that will not accept
connections promptly.
- Title: INTERRUPT LEVEL PROCESSING IN ETHERNET DRIVERS
- Description: Too many Ethernet drivers do interrupt-level processing with
- the network stack. The network stack supports either interrupt
- level processing or normal task level processing (depending on
- CONFIG_NET_NOINTS). This is really a very bad use of CPU
- resources; All of the network stack processing should be
- modified to use a work queue (and, all use of CONFIG_NET_NOINTS=n
- should be eliminated). This applies to many Ethernet drivers:
-
- ARCHITECTURE CONFIG_NET_NOINTS? ADDRESS FILTER SUPPORT?
- C5471 NO NO
- STM32 YES YES
- STM32F7 YES YES
- TIVA ----------------------- ------
- LM3S NO NO
- TM4C YES YES
- eZ80 NO NO
- Kinetis YES YES (not tested)
- LPC17xx YES YES (not tested)
- LPC43xx YES YES (not tested)
- DMxxx NIC NO NO
- PIC32 NO NO
- RGMP ??? ???
- SAM3/4 YES YES
- SAMA5D ----------------------- ------
- EMACA NO YES (not tested)
- EMACB YES YES
- GMAC NO YES (not tested)
- SAMV7 YES YES
- SIM N/A (No interrupts) NO
-
- The general outline of how this might be done is included in
- drivers/net/skeleton.c
- Status: Open
- Priority: Pretty high if you want a well behaved system.
+ Title: IPv6 REQUIRES ADDRESS FILTER SUPPORT
+ Description: IPv6 requires that the Ethernet driver support NuttX address
+ filter interfaces. Several Ethernet drivers do support there,
+ however. Others support the address filtering interfaces but
+ have never been verifed:
+
+ C5471, LM3X, ez80, DM0x90 NIC, PIC: Do not support address
+ filteringing.
+ Kinetis, LPC17xx, LPC43xx: Untested address filter support
+
+ Status: Open
+ Priority: Pretty high if you want a to use IPv6 on these platforms.
Title: UDP MULTICAST RECEPTION
Description: The logic in udp_input() expects either a single receive socket or
@@ -1032,6 +1171,15 @@ o Network (net/, drivers/net)
Status: Open
Priority: Low
+ Title: REMOVE CONFIG_NET_MULTIBUFFER
+ Description: The CONFIG_NET_MULTIBUFFER controls some details in the layout
+ of the network device structure. This is really a unnecessary
+ complexity and should be removed. The cost for those network
+ drivers that currently do not support CONFIG_NET_MULTIBUFFER
+ is the size of one pointer.
+ Status: Open
+ Priority: Low
+
o USB (drivers/usbdev, drivers/usbhost)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1208,8 +1356,8 @@ o USB (drivers/usbdev, drivers/usbhost)
Status: Open
Priority: Medium-Low unless you really need host CDC/ACM support.
-o Libraries (libc/)
- ^^^^^^^^^^^^^^^^^
+o Libraries (libc/, libm/)
+ ^^^^^^^^^^^^^^^^^^^^^^^^
Title: SIGNED time_t
Description: The NuttX time_t is type uint32_t. I think this is consistent
@@ -1342,10 +1490,28 @@ o Libraries (libc/)
2016-07-30: Numerous fixes and performance improvements from
David Alessio.
-Status: Open
-Priority: Low for casual users but clearly high if you need care about
+ Status: Open
+ Priority: Low for casual users but clearly high if you need care about
these incorrect corner case behaviors in the math libraries.
+ Title: Repartition libc functionality.
+ Description: There are many things implemented within the kernel (for example
+ under sched/pthread) that probably should be migrated in the
+ C library where it belongs.
+
+ I would really like to see a little flavor of a micro-kernel
+ at the OS interface: I would like to see more primitive OS
+ system calls with more higher level logic in the C library.
+
+ One awkard thing is the incompatibility of KERNEL vs FLAT
+ builds: In the kernel build, it would be nice to move many
+ of the thread-specific data items out of the TCB and into
+ the process address environment where they belong. It is
+ difficult to make this compatible with the FLAT build,
+ however.
+ Status: Open
+ Priority: Low
+
o File system / Generic drivers (fs/, drivers/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1501,7 +1667,7 @@ o File system / Generic drivers (fs/, drivers/)
ignored by readder() logic. This the file does not
appear in the 'ls'.
-o Graphics subsystem (graphics/)
+o Graphics Subsystem (graphics/)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
See also the NxWidgets TODO list file for related issues.
@@ -1621,6 +1787,21 @@ o Build system
Priority: Low, since I am not aware of anyone using the Windows Native build.
But, of course, very high if you want to use it.
+ Title: REMOVE SINGLE USER MODE
+ Description: The graphics sub-system can operate in either a single-user mode or
+ in a multi-user mode. In the multiple-user mode, a kernel thread
+ is used to support a graphics server. Multiple applications may then
+ communicate with the server using a message queue. This users only
+ standard POSIX interfaces and works in all build modes (FLAT,
+ PROTECTED, and KERNEL builds).
+
+ The single-user mode, on the hand, uses inappropriate calls directly
+ into the OS. This violates the POSIX interface and must, eventually,
+ be eliminated. These inappropriate calls can only be supported in
+ the FLAT build mode.
+ Status: Open
+ Priority: Medium-High
+
o Other drivers (drivers/)
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1913,3 +2094,4 @@ o Other Applications & Tests (apps/examples/)
the artifact is larger.
Status: Open
Priority: Medium.
+
diff --git a/arch/Kconfig b/arch/Kconfig
index 319419bb2d13e9f2781ceed045b25099104e9fbb..7685a2182d6c113ef074514d42f8d64976320022 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -39,11 +39,12 @@ config ARCH_MIPS
---help---
MIPS architectures (PIC32)
-config ARCH_RGMP
- bool "RGMP"
+config ARCH_MISOC
+ bool "MISOC"
+ select ARCH_HAVE_INTERRUPTSTACK
+ select ARCH_HAVE_CUSTOMOPT
---help---
- RTOS and GPOS on Multi-Processor (RGMP) architecture. See
- http://rgmp.sourceforge.net/wiki/index.php/Main_Page.
+ MISOC
config ARCH_RENESAS
bool "Renesas"
@@ -52,6 +53,13 @@ config ARCH_RENESAS
---help---
Renesas architectures (SH and M16C).
+config ARCH_RISCV
+ bool "RISC-V"
+ select ARCH_HAVE_INTERRUPTSTACK
+ select ARCH_HAVE_CUSTOMOPT
+ ---help---
+ RISC-V 32 and 64-bit RV32 / RV64 architectures.
+
config ARCH_SIM
bool "Simulation"
select ARCH_HAVE_MULTICPU
@@ -67,6 +75,12 @@ config ARCH_X86
---help---
Intel x86 architectures.
+config ARCH_XTENSA
+ bool "Xtensa"
+ select ARCH_HAVE_CUSTOMOPT
+ ---help---
+ Cadence® Tensilica® Xtensa® actictures.
+
config ARCH_Z16
bool "ZNEO"
select ARCH_HAVE_HEAP2
@@ -87,10 +101,12 @@ config ARCH
default "avr" if ARCH_AVR
default "hc" if ARCH_HC
default "mips" if ARCH_MIPS
- default "rgmp" if ARCH_RGMP
+ default "misoc" if ARCH_MISOC
default "renesas" if ARCH_RENESAS
+ default "risc-v" if ARCH_RISCV
default "sim" if ARCH_SIM
default "x86" if ARCH_X86
+ default "xtensa" if ARCH_XTENSA
default "z16" if ARCH_Z16
default "z80" if ARCH_Z80
@@ -98,10 +114,12 @@ source arch/arm/Kconfig
source arch/avr/Kconfig
source arch/hc/Kconfig
source arch/mips/Kconfig
-source arch/rgmp/Kconfig
+source arch/misoc/Kconfig
source arch/renesas/Kconfig
+source arch/risc-v/Kconfig
source arch/sim/Kconfig
source arch/x86/Kconfig
+source arch/xtensa/Kconfig
source arch/z16/Kconfig
source arch/z80/Kconfig
@@ -540,6 +558,7 @@ config ARCH_USBDUMP
config ENDIAN_BIG
bool "Big Endian Architecture"
default n
+ depends on !ARCH_RISCV
---help---
Select if architecture operates using big-endian byte ordering.
diff --git a/arch/README.txt b/arch/README.txt
index bd49fb31a7c2a6b430fdb73cb1f79fd730105b2c..a0f604e4affe695ed956fb33191c3e1bb5e94b6a 100644
--- a/arch/README.txt
+++ b/arch/README.txt
@@ -158,7 +158,6 @@ arch/arm - ARM-based micro-controllers
MCU support
arch/arm/include/a1x and arch/arm/src/a1x
arch/arm/include/c5471 and arch/arm/src/c5471
- arch/arm/include/calypso and arch/arm/src/calypso
arch/arm/include/dm320 and arch/arm/src/dm320
arch/arm/include/efm32 and arch/arm/src/efm32
arch/arm/include/imx1 and arch/arm/src/imx1
@@ -222,16 +221,14 @@ arch/renesas - Support for Renesas and legacy Hitachi microcontrollers.
arch/renesas/include/m16c and arch/renesas/src/m16c
arch/renesas/include/sh1 and arch/renesas/src/sh1
-arch/rgmp
+arch/risc-v
+ This directory is dedicated to ports to the RISC-V family.
- RGMP stands for RTOS and GPOS on Multi-Processor. RGMP is a project
- for running GPOS and RTOS simultaneously on multi-processor platforms.
- You can port your favorite RTOS to RGMP together with an unmodified
- Linux to form a hybrid operating system. This makes your application
- able to use both RTOS and GPOS features.
+ Architecture Support
+ arch/risc-v/include/rv32im
- See http://rgmp.sourceforge.net/wiki/index.php/Main_Page for further
- information about RGMP.
+ MCU support
+ arch/risc-v/include/nr5m100
arch/x86 - Intel x86 architectures
This directory holds related, 32- and 64-bit architectures from Intel.
@@ -244,6 +241,21 @@ arch/x86 - Intel x86 architectures
arch/x86/include/i486 and arch/x86/src/i486
arch/x86/include/qemu and arch/x86/src/qemu
+arch/xtensa
+
+ Implementations based on the Cadence® Tensilica® Xtensa® processors,
+ such as the Xtensa LX6 dataplane processing units (DPUs). At
+ present, this includes the following subdirectories:
+
+ Common XTENSA support:
+ arch/xtensa/include and arch/xtensa/src/common
+
+ LX6 DPU support:
+ arch/xtensa/include/lx6 and arch/xtensa/xtensa/lx6
+
+ Expressif ESP32 implemenation of the LX6 DPU:
+ arch/xtensa/include/esp32 and arch/xtensa/xtensa/esp32
+
arch/z16 - ZiLOG 16-bit processors
This directory holds related, 16-bit architectures from ZiLOG. At
present, this includes the following subdirectories:
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 63af8acafc96f30946a27c8371244ff4b442e1fc..d56e0a861e1c2c31db4a9b4c67effda01a868fb6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -31,16 +31,6 @@ config ARCH_CHIP_C5471
---help---
TI TMS320 C5471, A180, or DA180 (ARM7TDMI)
-config ARCH_CHIP_CALYPSO
- bool "Calypso"
- select ARCH_ARM7TDMI
- select ARCH_HAVE_HEAP2
- select ARCH_HAVE_LOWVECTORS
- select OTHER_UART_SERIALDRIVER
- select ARCH_HAVE_POWEROFF
- ---help---
- TI Calypso-based cell phones (ARM7TDMI)
-
config ARCH_CHIP_DM320
bool "TMS320 DM320"
select ARCH_ARM926EJS
@@ -85,6 +75,7 @@ config ARCH_CHIP_KINETIS
select ARM_HAVE_MPU_UNIFIED
select ARCH_HAVE_FPU
select ARCH_HAVE_RAMFUNCS
+ select ARCH_HAVE_CMNVECTOR
---help---
Freescale Kinetis Architectures (ARM Cortex-M4)
@@ -408,7 +399,6 @@ config ARCH_CHIP
string
default "a1x" if ARCH_CHIP_A1X
default "c5471" if ARCH_CHIP_C5471
- default "calypso" if ARCH_CHIP_CALYPSO
default "dm320" if ARCH_CHIP_DM320
default "efm32" if ARCH_CHIP_EFM32
default "imx1" if ARCH_CHIP_IMX1
@@ -624,9 +614,6 @@ endif
if ARCH_CHIP_C5471
source arch/arm/src/c5471/Kconfig
endif
-if ARCH_CHIP_CALYPSO
-source arch/arm/src/calypso/Kconfig
-endif
if ARCH_CHIP_DM320
source arch/arm/src/dm320/Kconfig
endif
diff --git a/arch/rgmp/src/arm/sigentry.S b/arch/arm/include/arm/spinlock.h
similarity index 80%
rename from arch/rgmp/src/arm/sigentry.S
rename to arch/arm/include/arm/spinlock.h
index 1e413450bf6573c61f7215f23eb366fe0c38fa06..ee3db052cf0002db9f13b0b8a547196ec97e2aad 100644
--- a/arch/rgmp/src/arm/sigentry.S
+++ b/arch/arm/include/arm/spinlock.h
@@ -1,12 +1,8 @@
/****************************************************************************
- * arch/rgmp/src/arm/sigentry.S
+ * arch/arm/include/armv7-a/spinlock.h
*
- * Copyright (C) 2011 Yu Qiang. All rights reserved.
- * Author: Yu Qiang
- *
- * This file is a part of NuttX:
- *
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,13 +33,7 @@
*
****************************************************************************/
- .globl up_sigentry
-up_sigentry:
- sub sp, sp, #68 @ 68 is the size of Trapframe
- mov r0, sp
- bl up_sigdeliver
- add sp, sp, #4 @ skip current_task
- pop {r0-r12, lr}
- rfefd sp!
+#ifndef __ARCH_ARM_INCLUDE_ARM_SPINLOCK_H
+#define __ARCH_ARM_INCLUDE_ARM_SPINLOCK_H
-
\ No newline at end of file
+#endif /* __ARCH_ARM_INCLUDE_ARM_SPINLOCK_H */
diff --git a/arch/rgmp/include/arm/arch/subarch/arch.h b/arch/arm/include/armv6-m/spinlock.h
similarity index 78%
rename from arch/rgmp/include/arm/arch/subarch/arch.h
rename to arch/arm/include/armv6-m/spinlock.h
index e5f3fff10f93ad6892b0c744442d0956407c60cd..c1d154b37001652e6624c535d113ed7519cce219 100644
--- a/arch/rgmp/include/arm/arch/subarch/arch.h
+++ b/arch/arm/include/armv6-m/spinlock.h
@@ -1,12 +1,8 @@
/****************************************************************************
- * arch/rgmp/include/arm/arch/subarch/arch.h
+ * arch/arm/include/armv7-a/spinlock.h
*
- * Copyright (C) 2011 Yu Qiang. All rights reserved.
- * Author: Yu Qiang
- *
- * This file is a part of NuttX:
- *
- * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -37,22 +33,7 @@
*
****************************************************************************/
-#ifndef __RGMP_ARCH_SUBARCH_ARCH_H
-#define __RGMP_ARCH_SUBARCH_ARCH_H
-
-#ifndef __ASSEMBLY__
-
-
-static inline void up_mdelay(uint32_t msec)
-{
-
-}
-
-static inline void up_udelay(uint32_t usec)
-{
-
-}
-
-#endif /* !__ASSEMBLY__ */
+#ifndef __ARCH_ARM_INCLUDE_ARMV6_M_SPINLOCK_H
+#define __ARCH_ARM_INCLUDE_ARMV6_M_SPINLOCK_H
-#endif
+#endif /* __ARCH_ARM_INCLUDE_ARMV6_M_SPINLOCK_H */
diff --git a/arch/arm/include/armv7-a/spinlock.h b/arch/arm/include/armv7-a/spinlock.h
new file mode 100644
index 0000000000000000000000000000000000000000..764a96ecef3104a8f27e6dde4c816cd7afb0864f
--- /dev/null
+++ b/arch/arm/include/armv7-a/spinlock.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * arch/arm/include/armv7-a/spinlock.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_INCLUDE_ARMV7_A_SPINLOCK_H
+#define __ARCH_ARM_INCLUDE_ARMV7_A_SPINLOCK_H
+
+#endif /* __ARCH_ARM_INCLUDE_ARMV7_A_SPINLOCK_H */
diff --git a/arch/arm/include/armv7-m/spinlock.h b/arch/arm/include/armv7-m/spinlock.h
new file mode 100644
index 0000000000000000000000000000000000000000..79a06b4173f94731d24c8379f0999dc9e07c1183
--- /dev/null
+++ b/arch/arm/include/armv7-m/spinlock.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * arch/arm/include/armv7-a/spinlock.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_INCLUDE_ARMV7_M_SPINLOCK_H
+#define __ARCH_ARM_INCLUDE_ARMV7_M_SPINLOCK_H
+
+#endif /* __ARCH_ARM_INCLUDE_ARMV7_M_SPINLOCK_H */
diff --git a/arch/arm/include/armv7-r/spinlock.h b/arch/arm/include/armv7-r/spinlock.h
new file mode 100644
index 0000000000000000000000000000000000000000..ab7900fa7337d90291c62b4cbfd716559e2a474c
--- /dev/null
+++ b/arch/arm/include/armv7-r/spinlock.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * arch/arm/include/armv7-r/spinlock.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_INCLUDE_ARMV7_R_SPINLOCK_H
+#define __ARCH_ARM_INCLUDE_ARMV7_R_SPINLOCK_H
+
+#endif /* __ARCH_ARM_INCLUDE_ARMV7_R_SPINLOCK_H */
diff --git a/arch/arm/include/calypso/clock.h b/arch/arm/include/calypso/clock.h
deleted file mode 100644
index a10a607a5d232d960e1f2861ef101fcab6cd42ef..0000000000000000000000000000000000000000
--- a/arch/arm/include/calypso/clock.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef __ARCH_ARM_INCLUDE_CALYPSO_CLOCK_H
-#define __ARCH_ARM_INCLUDE_CALYPSO_CLOCK_H
-
-#include
-
-#define CALYPSO_PLL26_52_MHZ ((2 << 8) | 0)
-#define CALYPSO_PLL26_86_7_MHZ ((10 << 8) | 2)
-#define CALYPSO_PLL26_87_MHZ ((3 << 8) | 0)
-#define CALYPSO_PLL13_104_MHZ ((8 << 8) | 0)
-
-enum mclk_div {
- _ARM_MCLK_DIV_1 = 0,
- ARM_MCLK_DIV_1 = 1,
- ARM_MCLK_DIV_2 = 2,
- ARM_MCLK_DIV_3 = 3,
- ARM_MCLK_DIV_4 = 4,
- ARM_MCLK_DIV_5 = 5,
- ARM_MCLK_DIV_6 = 6,
- ARM_MCLK_DIV_7 = 7,
- ARM_MCLK_DIV_1_5 = 0x80 | 1,
- ARM_MCLK_DIV_2_5 = 0x80 | 2,
-};
-
-void calypso_clock_set(uint8_t vtcxo_div2, uint16_t inp, enum mclk_div mclk_div);
-void calypso_pll_set(uint16_t inp);
-void calypso_clk_dump(void);
-
-/* CNTL_RST */
-enum calypso_rst {
- RESET_DSP = (1 << 1),
- RESET_EXT = (1 << 2),
- RESET_WDOG = (1 << 3),
-};
-
-void calypso_reset_set(enum calypso_rst calypso_rst, int active);
-int calypso_reset_get(enum calypso_rst);
-
-enum calypso_bank {
- CALYPSO_nCS0 = 0,
- CALYPSO_nCS1 = 2,
- CALYPSO_nCS2 = 4,
- CALYPSO_nCS3 = 6,
- CALYPSO_nCS7 = 8,
- CALYPSO_CS4 = 0xa,
- CALYPSO_nCS6 = 0xc,
-};
-
-enum calypso_mem_width {
- CALYPSO_MEM_8bit = 0,
- CALYPSO_MEM_16bit = 1,
- CALYPSO_MEM_32bit = 2,
-};
-
-void calypso_mem_cfg(enum calypso_bank bank, uint8_t ws,
- enum calypso_mem_width width, int we);
-
-/* Enable or disable the internal bootrom mapped to 0x0000'0000 */
-void calypso_bootrom(int enable);
-
-/* Enable or disable the debug unit */
-void calypso_debugunit(int enable);
-
-/* configure the RHEA bus bridge[s] */
-void calypso_rhea_cfg(uint8_t fac0, uint8_t fac1, uint8_t timeout,
- uint8_t ws_h, uint8_t ws_l, uint8_t w_en0, uint8_t w_en1);
-
-#endif /* __ARCH_ARM_INCLUDE_CALYPSO_CLOCK_H */
diff --git a/arch/arm/include/calypso/debug.h b/arch/arm/include/calypso/debug.h
deleted file mode 100644
index 9596946775756250a5b5dd9dabef3230503dc9d7..0000000000000000000000000000000000000000
--- a/arch/arm/include/calypso/debug.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __ARCH_ARM_INCLUDE_CALYPSO_DEBUG_H
-#define __ARCH_ARM_INCLUDE_CALYPSO_DEBUG_H
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
-/*
- * Check at compile time that something is of a particular type.
- * Always evaluates to 1 so you may use it easily in comparisons.
- */
-#define typecheck(type,x) \
-({ type __dummy; \
- typeof(x) __dummy2; \
- (void)(&__dummy == &__dummy2); \
- 1; \
-})
-
-#ifdef DEBUG
-#define dputchar(x) putchar(x)
-#define dputs(x) puts(x)
-#define dphex(x,y) phex(x,y)
-#define printd(x, ...) printf(x, ##__VA_ARGS__)
-#else
-#define dputchar(x)
-#define dputs(x)
-#define dphex(x,y)
-#define printd(x, args ...)
-#endif
-
-#endif /* __ARCH_ARM_INCLUDE_CALYPSO_DEBUG_H */
diff --git a/arch/arm/include/calypso/defines.h b/arch/arm/include/calypso/defines.h
deleted file mode 100644
index 4f29560c8332f41b0eba7db613b64b037921b597..0000000000000000000000000000000000000000
--- a/arch/arm/include/calypso/defines.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __ARCH_ARM_INCLUDE_CALYPSO_DEFINES_H
-#define __ARCH_ARM_INCLUDE_CALYPSO_DEFINES_H
-
-#define __attribute_const__ __attribute__((__const__))
-
-/* type properties */
-#define __packed __attribute__((packed))
-#define __aligned(alignment) __attribute__((aligned(alignment)))
-#define __unused __attribute__((unused))
-
-/* linkage */
-#define __section(name) __attribute__((section(name)))
-
-/* force placement in zero-waitstate memory */
-#define __ramtext __section(".ramtext")
-
-#endif /* !__ARCH_ARM_INCLUDE_CALYPSO_DEFINES_H */
diff --git a/arch/arm/include/calypso/irq.h b/arch/arm/include/calypso/irq.h
deleted file mode 100644
index 0dda3f312feec579d446f491cd1b04f479fa1398..0000000000000000000000000000000000000000
--- a/arch/arm/include/calypso/irq.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
- * arch/arm/include/calypso/irq.h
- * Driver for Calypso IRQ controller
- *
- * (C) 2010 by Harald Welte
- * (C) 2011 by Stefan Richter
- *
- * This source code is derivated from Osmocom-BB project and was
- * relicensed as BSD with permission from original authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#ifndef __INCLUDE_NUTTX_IRQ_H
-#error "This file should never be included directly! Use "
-#endif
-
-#ifndef __ARCH_ARM_INCLUDE_CALYPSO_IRQ_H
-#define __ARCH_ARM_INCLUDE_CALYPSO_IRQ_H
-
-#ifndef __ASSEMBLY__
-
-enum irq_nr {
- IRQ_WATCHDOG = 0,
- IRQ_TIMER1 = 1,
- IRQ_TIMER2 = 2,
- IRQ_TSP_RX = 3,
- IRQ_TPU_FRAME = 4,
- IRQ_TPU_PAGE = 5,
- IRQ_SIMCARD = 6,
- IRQ_UART_MODEM = 7,
- IRQ_KEYPAD_GPIO = 8,
- IRQ_RTC_TIMER = 9,
- IRQ_RTC_ALARM_I2C = 10,
- IRQ_ULPD_GAUGING = 11,
- IRQ_EXTERNAL = 12,
- IRQ_SPI = 13,
- IRQ_DMA = 14,
- IRQ_API = 15,
- IRQ_SIM_DETECT = 16,
- IRQ_EXTERNAL_FIQ = 17,
- IRQ_UART_IRDA = 18,
- IRQ_ULPD_GSM_TIMER = 19,
- IRQ_GEA = 20,
- _NR_IRQS
-};
-
-#endif /* __ASSEMBLY__ */
-
-/* Don't use _NR_IRQS!!! Won't work in preprocessor... */
-#define NR_IRQS 21
-
-#define IRQ_SYSTIMER IRQ_TIMER2
-
-#endif /* __ARCH_ARM_INCLUDE_CALYPSO_IRQ_H */
diff --git a/arch/arm/include/calypso/memory.h b/arch/arm/include/calypso/memory.h
deleted file mode 100644
index a4ce1e890ee2c57b98cdfe61e0814600cc6cc4ee..0000000000000000000000000000000000000000
--- a/arch/arm/include/calypso/memory.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __ARCH_ARM_INCLUDE_CALYPSO_MEMORY_H
-#define __ARCH_ARM_INCLUDE_CALYPSO_MEMORY_H
-
-#define __arch_getb(a) (*(volatile unsigned char *)(a))
-#define __arch_getw(a) (*(volatile unsigned short *)(a))
-#define __arch_getl(a) (*(volatile unsigned int *)(a))
-
-#define __arch_putb(v,a) (*(volatile unsigned char *)(a) = (v))
-#define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
-#define __arch_putl(v,a) (*(volatile unsigned int *)(a) = (v))
-
-#define __raw_writeb(v,a) __arch_putb(v,a)
-#define __raw_writew(v,a) __arch_putw(v,a)
-#define __raw_writel(v,a) __arch_putl(v,a)
-
-#define __raw_readb(a) __arch_getb(a)
-#define __raw_readw(a) __arch_getw(a)
-#define __raw_readl(a) __arch_getl(a)
-
-#define writeb(v,a) __arch_putb(v,a)
-#define writew(v,a) __arch_putw(v,a)
-#define writel(v,a) __arch_putl(v,a)
-
-#define readb(a) __arch_getb(a)
-#define readw(a) __arch_getw(a)
-#define readl(a) __arch_getl(a)
-
-#endif /* __ARCH_ARM_INCLUDE_CALYPSO_MEMORY_H */
diff --git a/arch/arm/include/calypso/timer.h b/arch/arm/include/calypso/timer.h
deleted file mode 100644
index 93a1bd1492508a27af51a76edb776b175badd86b..0000000000000000000000000000000000000000
--- a/arch/arm/include/calypso/timer.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __ARCH_ARM_INCLUDE_CALYPSO_TIMER_H
-#define __ARCH_ARM_INCLUDE_CALYPSO_TIMER_H
-
-/* Enable or Disable a timer */
-void hwtimer_enable(int num, int on);
-
-/* Configure pre-scaler and if timer is auto-reload */
-void hwtimer_config(int num, uint8_t pre_scale, int auto_reload);
-
-/* Load a timer with the given value */
-void hwtimer_load(int num, uint16_t val);
-
-/* Read the current timer value */
-uint16_t hwtimer_read(int num);
-
-/* Enable or disable the watchdog */
-void wdog_enable(int on);
-
-/* Reset cpu using watchdog */
-void wdog_reset(void);
-
-/* power up the timers */
-void hwtimer_init(void);
-
-#endif /* __ARCH_ARM_INCLUDE_CALYPSO_TIMER_H */
diff --git a/arch/arm/include/calypso/uwire.h b/arch/arm/include/calypso/uwire.h
deleted file mode 100644
index 0ca6c376ca7c326618db38f025f4a84d531bbfa0..0000000000000000000000000000000000000000
--- a/arch/arm/include/calypso/uwire.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __ARCH_ARM_INCLUDE_CALYPSO_UWIRE_H
-#define __ARCH_ARM_INCLUDE_CALYPSO_UWIRE_H
-void uwire_init(void);
-int uwire_xfer(int cs, int bitlen, const void *dout, void *din);
-#endif
-
diff --git a/arch/arm/include/inttypes.h b/arch/arm/include/inttypes.h
new file mode 100644
index 0000000000000000000000000000000000000000..280d4a5ecaf93f67556b3aca5f7924a98edc8262
--- /dev/null
+++ b/arch/arm/include/inttypes.h
@@ -0,0 +1,245 @@
+/****************************************************************************
+ * arch/arm/include/inttypes.h
+ *
+ * Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved.
+ * Author: Paul Alexander Patience
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_INCLUDE_INTTYPES_H
+#define __ARCH_ARM_INCLUDE_INTTYPES_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "d"
+#define PRId64 "lld"
+
+#define PRIdLEAST8 "d"
+#define PRIdLEAST16 "d"
+#define PRIdLEAST32 "d"
+#define PRIdLEAST64 "lld"
+
+#define PRIdFAST8 "d"
+#define PRIdFAST16 "d"
+#define PRIdFAST32 "d"
+#define PRIdFAST64 "lld"
+
+#define PRIdMAX "lld"
+#define PRIdPTR "d"
+
+#define PRIi8 "i"
+#define PRIi16 "i"
+#define PRIi32 "i"
+#define PRIi64 "lli"
+
+#define PRIiLEAST8 "i"
+#define PRIiLEAST16 "i"
+#define PRIiLEAST32 "i"
+#define PRIiLEAST64 "lli"
+
+#define PRIiFAST8 "i"
+#define PRIiFAST16 "i"
+#define PRIiFAST32 "i"
+#define PRIiFAST64 "lli"
+
+#define PRIiMAX "lli"
+#define PRIiPTR "i"
+
+#define PRIo8 "o"
+#define PRIo16 "o"
+#define PRIo32 "o"
+#define PRIo64 "llo"
+
+#define PRIoLEAST8 "o"
+#define PRIoLEAST16 "o"
+#define PRIoLEAST32 "o"
+#define PRIoLEAST64 "llo"
+
+#define PRIoFAST8 "o"
+#define PRIoFAST16 "o"
+#define PRIoFAST32 "o"
+#define PRIoFAST64 "llo"
+
+#define PRIoMAX "llo"
+#define PRIoPTR "o"
+
+#define PRIu8 "u"
+#define PRIu16 "u"
+#define PRIu32 "u"
+#define PRIu64 "llu"
+
+#define PRIuLEAST8 "u"
+#define PRIuLEAST16 "u"
+#define PRIuLEAST32 "u"
+#define PRIuLEAST64 "llu"
+
+#define PRIuFAST8 "u"
+#define PRIuFAST16 "u"
+#define PRIuFAST32 "u"
+#define PRIuFAST64 "llu"
+
+#define PRIuMAX "llu"
+#define PRIuPTR "u"
+
+#define PRIx8 "x"
+#define PRIx16 "x"
+#define PRIx32 "x"
+#define PRIx64 "llx"
+
+#define PRIxLEAST8 "x"
+#define PRIxLEAST16 "x"
+#define PRIxLEAST32 "x"
+#define PRIxLEAST64 "llx"
+
+#define PRIxFAST8 "x"
+#define PRIxFAST16 "x"
+#define PRIxFAST32 "x"
+#define PRIxFAST64 "llx"
+
+#define PRIxMAX "llx"
+#define PRIxPTR "x"
+
+#define PRIX8 "X"
+#define PRIX16 "X"
+#define PRIX32 "X"
+#define PRIX64 "llX"
+
+#define PRIXLEAST8 "X"
+#define PRIXLEAST16 "X"
+#define PRIXLEAST32 "X"
+#define PRIXLEAST64 "llX"
+
+#define PRIXFAST8 "X"
+#define PRIXFAST16 "X"
+#define PRIXFAST32 "X"
+#define PRIXFAST64 "llX"
+
+#define PRIXMAX "llX"
+#define PRIXPTR "X"
+
+#define SCNd8 "hhd"
+#define SCNd16 "hd"
+#define SCNd32 "d"
+#define SCNd64 "lld"
+
+#define SCNdLEAST8 "hhd"
+#define SCNdLEAST16 "hd"
+#define SCNdLEAST32 "d"
+#define SCNdLEAST64 "lld"
+
+#define SCNdFAST8 "hhd"
+#define SCNdFAST16 "hd"
+#define SCNdFAST32 "d"
+#define SCNdFAST64 "lld"
+
+#define SCNdMAX "lld"
+#define SCNdPTR "d"
+
+#define SCNi8 "hhi"
+#define SCNi16 "hi"
+#define SCNi32 "i"
+#define SCNi64 "lli"
+
+#define SCNiLEAST8 "hhi"
+#define SCNiLEAST16 "hi"
+#define SCNiLEAST32 "i"
+#define SCNiLEAST64 "lli"
+
+#define SCNiFAST8 "hhi"
+#define SCNiFAST16 "hi"
+#define SCNiFAST32 "i"
+#define SCNiFAST64 "lli"
+
+#define SCNiMAX "lli"
+#define SCNiPTR "i"
+
+#define SCNo8 "hho"
+#define SCNo16 "ho"
+#define SCNo32 "o"
+#define SCNo64 "llo"
+
+#define SCNoLEAST8 "hho"
+#define SCNoLEAST16 "ho"
+#define SCNoLEAST32 "o"
+#define SCNoLEAST64 "llo"
+
+#define SCNoFAST8 "hho"
+#define SCNoFAST16 "ho"
+#define SCNoFAST32 "o"
+#define SCNoFAST64 "llo"
+
+#define SCNoMAX "llo"
+#define SCNoPTR "o"
+
+#define SCNu8 "hhu"
+#define SCNu16 "hu"
+#define SCNu32 "u"
+#define SCNu64 "llu"
+
+#define SCNuLEAST8 "hhu"
+#define SCNuLEAST16 "hu"
+#define SCNuLEAST32 "u"
+#define SCNuLEAST64 "llu"
+
+#define SCNuFAST8 "hhu"
+#define SCNuFAST16 "hu"
+#define SCNuFAST32 "u"
+#define SCNuFAST64 "llu"
+
+#define SCNuMAX "llu"
+#define SCNuPTR "u"
+
+#define SCNx8 "hhx"
+#define SCNx16 "hx"
+#define SCNx32 "x"
+#define SCNx64 "llx"
+
+#define SCNxLEAST8 "hhx"
+#define SCNxLEAST16 "hx"
+#define SCNxLEAST32 "x"
+#define SCNxLEAST64 "llx"
+
+#define SCNxFAST8 "hhx"
+#define SCNxFAST16 "hx"
+#define SCNxFAST32 "x"
+#define SCNxFAST64 "llx"
+
+#define SCNxMAX "llx"
+#define SCNxPTR "x"
+
+#endif /* __ARCH_ARM_INCLUDE_INTTYPES_H */
diff --git a/arch/arm/include/kinetis/irq.h b/arch/arm/include/kinetis/irq.h
index 1e45a5b4c63be0f1c6ee3cd1a5009fb165f02885..6eb5f00a7ce5329430ab475a43c6dde2ecc817f6 100644
--- a/arch/arm/include/kinetis/irq.h
+++ b/arch/arm/include/kinetis/irq.h
@@ -1,8 +1,9 @@
-/************************************************************************************
+/****************************************************************************
* arch/arm/include/kinetis/irq.h
*
- * Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -31,10 +32,10 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************************************/
+ ****************************************************************************/
-/* This file should never be included directed but, rather, only indirectly through
- * nuttx/irq.h
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
*/
#ifndef __ARCH_ARM_INCLUDE_KINETIS_IRQ_H
@@ -50,8 +51,8 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
-/* IRQ numbers **********************************************************************/
-/* The IRQ numbers corresponds directly to vector numbers and hence map directly to
+
+/* IRQ numbers. The IRQ number corresponds vector number and hence map directly to
* bits in the NVIC. This does, however, waste several words of memory in the IRQ
* to handle mapping tables.
*/
@@ -73,410 +74,20 @@
#define KINETIS_IRQ_PENDSV (14) /* Vector 14: Pendable system service request */
#define KINETIS_IRQ_SYSTICK (15) /* Vector 15: System tick */
-/* External interrupts (vectors >= 16) */
-
-#define KINETIS_IRQ_EXTINT (16)
+/* External interrupts (vectors >= 16). These definitions are chip-specific */
-/* K20 Family ***********************************************************************
- *
- * The interrupt vectors for the following parts is defined in Freescale document
- * K20P64M72SF1RM
- */
+#define KINETIS_IRQ_FIRST (16) /* Vector number of the first external interrupt */
#if defined(CONFIG_ARCH_FAMILY_K20)
-# define KINETIS_IRQ_DMACH0 (16) /* Vector 16: DMA channel 0 transfer complete */
-# define KINETIS_IRQ_DMACH1 (17) /* Vector 17: DMA channel 1 transfer complete */
-# define KINETIS_IRQ_DMACH2 (18) /* Vector 18: DMA channel 2 transfer complete */
-# define KINETIS_IRQ_DMACH3 (19) /* Vector 19: DMA channel 3 transfer complete */
-# define KINETIS_IRQ_DMACH4 (20) /* Vector 20: DMA channel 4 transfer complete */
-# define KINETIS_IRQ_DMACH5 (21) /* Vector 21: DMA channel 5 transfer complete */
-# define KINETIS_IRQ_DMACH6 (22) /* Vector 22: DMA channel 6 transfer complete */
-# define KINETIS_IRQ_DMACH7 (23) /* Vector 23: DMA channel 7 transfer complete */
-# define KINETIS_IRQ_DMACH8 (24) /* Vector 24: DMA channel 8 transfer complete */
-# define KINETIS_IRQ_DMACH9 (25) /* Vector 25: DMA channel 9 transfer complete */
-# define KINETIS_IRQ_DMACH10 (26) /* Vector 26: DMA channel 10 transfer complete */
-# define KINETIS_IRQ_DMACH11 (27) /* Vector 27: DMA channel 11 transfer complete */
-# define KINETIS_IRQ_DMACH12 (28) /* Vector 28: DMA channel 12 transfer complete */
-# define KINETIS_IRQ_DMACH13 (29) /* Vector 29: DMA channel 13 transfer complete */
-# define KINETIS_IRQ_DMACH14 (30) /* Vector 30: DMA channel 14 transfer complete */
-# define KINETIS_IRQ_DMACH15 (31) /* Vector 31: DMA channel 15 transfer complete */
-# define KINETIS_IRQ_DMAERR (32) /* Vector 32: DMA error interrupt channels 0-15 */
-# define KINETIS_IRQ_FLASHCC (34) /* Vector 34: Flash memory command complete */
-# define KINETIS_IRQ_FLASHRC (35) /* Vector 35: Flash memory read collision */
-# define KINETIS_IRQ_SMCLVD (36) /* Vector 36: Mode Controller low-voltage
- * detect, low-voltage warning */
-# define KINETIS_IRQ_LLWU (37) /* Vector 37: LLWU Normal Low Leakage Wakeup */
-# define KINETIS_IRQ_WDOG (38) /* Vector 38: Watchdog */
-# define KINETIS_IRQ_I2C0 (40) /* Vector 40: I2C0 */
-# define KINETIS_IRQ_I2C1 (41) /* Vector 41: I2C1 */
-# define KINETIS_IRQ_SPI0 (42) /* Vector 42: SPI0 all sources */
-# define KINETIS_IRQ_SPI1 (43) /* Vector 43: SPI1 all sources */
-# define KINETIS_IRQ_CAN0MB (45) /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
-# define KINETIS_IRQ_CAN0BO (46) /* Vector 46: CAN0 Bus Off */
-# define KINETIS_IRQ_CAN0ERR (47) /* Vector 47: CAN0 Error */
-# define KINETIS_IRQ_CAN0TW (48) /* Vector 48: CAN0 Transmit Warning */
-# define KINETIS_IRQ_CAN0RW (49) /* Vector 49: CAN0 Receive Warning */
-# define KINETIS_IRQ_CAN0WU (50) /* Vector 50: CAN0 Wake UP */
-//TODO UART0_LON
-# define KINETIS_IRQ_UART0S (61) /* Vector 61: UART0 status */
-# define KINETIS_IRQ_UART0E (62) /* Vector 62: UART0 error */
-# define KINETIS_IRQ_UART1S (63) /* Vector 63: UART1 status */
-# define KINETIS_IRQ_UART1E (64) /* Vector 64: UART1 error */
-# define KINETIS_IRQ_UART2S (65) /* Vector 65: UART2 status */
-# define KINETIS_IRQ_UART2E (66) /* Vector 66: UART2 error */
-# define KINETIS_IRQ_ADC0 (73) /* Vector 73: ADC0 */
-# define KINETIS_IRQ_ADC1 (74) /* Vector 74: ADC1 */
-# define KINETIS_IRQ_CMP0 (75) /* Vector 75: CMP0 */
-# define KINETIS_IRQ_CMP1 (76) /* Vector 76: CMP1 */
-# define KINETIS_IRQ_CMP2 (77) /* Vector 77: CMP2 */
-# define KINETIS_IRQ_FTM0 (78) /* Vector 78: FTM0 all sources */
-# define KINETIS_IRQ_FTM1 (79) /* Vector 79: FTM1 all sources */
-# define KINETIS_IRQ_FTM2 (80) /* Vector 80: FTM2 all sources */
-# define KINETIS_IRQ_CMT (81) /* Vector 81: CMT */
-# define KINETIS_IRQ_RTC (82) /* Vector 82: RTC alarm interrupt */
-//TODO RTC_SECOND
-# define KINETIS_IRQ_PITCH0 (84) /* Vector 84: PIT channel 0 */
-# define KINETIS_IRQ_PITCH1 (85) /* Vector 85: PIT channel 1 */
-# define KINETIS_IRQ_PITCH2 (86) /* Vector 86: PIT channel 2 */
-# define KINETIS_IRQ_PITCH3 (87) /* Vector 87: PIT channel 3 */
-# define KINETIS_IRQ_PDB (88) /* Vector 88: PDB */
-# define KINETIS_IRQ_USBOTG (89) /* Vector 88: USB OTG */
-# define KINETIS_IRQ_USBCD (90) /* Vector 90: USB charger detect */
-# define KINETIS_IRQ_DAC0 (97) /* Vector 97: DAC0 */
-# define KINETIS_IRQ_TSI (99) /* Vector 97: TSI all sources */
-# define KINETIS_IRQ_MCG (100) /* Vector 100: MCG */
-# define KINETIS_IRQ_LPT (101) /* Vector 101: Low power timer */
-# define KINETIS_IRQ_PORTA (103) /* Vector 103: Pin detect port A */
-# define KINETIS_IRQ_PORTB (104) /* Vector 104: Pin detect port B */
-# define KINETIS_IRQ_PORTC (105) /* Vector 105: Pin detect port C */
-# define KINETIS_IRQ_PORTD (106) /* Vector 106: Pin detect port D */
-# define KINETIS_IRQ_PORTE (107) /* Vector 107: Pin detect port E */
-# define KINETIS_IRQ_SWI (110) /* Vector 110: Software interrupt */
-
-# define NR_VECTORS (111) /* 111 vectors */
-# define NR_IRQS (111) /* 94 interrupts but 111 IRQ numbers */
-
-/* K40 Family ***********************************************************************
- *
- * The interrupt vectors for the following parts is defined in Freescale document
- * K40P144M100SF2RM
- */
-
+# include
#elif defined(CONFIG_ARCH_FAMILY_K40)
-
-# define KINETIS_IRQ_DMACH0 (16) /* Vector 16: DMA channel 0 transfer complete */
-# define KINETIS_IRQ_DMACH1 (17) /* Vector 17: DMA channel 1 transfer complete */
-# define KINETIS_IRQ_DMACH2 (18) /* Vector 18: DMA channel 2 transfer complete */
-# define KINETIS_IRQ_DMACH3 (19) /* Vector 19: DMA channel 3 transfer complete */
-# define KINETIS_IRQ_DMACH4 (20) /* Vector 20: DMA channel 4 transfer complete */
-# define KINETIS_IRQ_DMACH5 (21) /* Vector 21: DMA channel 5 transfer complete */
-# define KINETIS_IRQ_DMACH6 (22) /* Vector 22: DMA channel 6 transfer complete */
-# define KINETIS_IRQ_DMACH7 (23) /* Vector 23: DMA channel 7 transfer complete */
-# define KINETIS_IRQ_DMACH8 (24) /* Vector 24: DMA channel 8 transfer complete */
-# define KINETIS_IRQ_DMACH9 (25) /* Vector 25: DMA channel 9 transfer complete */
-# define KINETIS_IRQ_DMACH10 (26) /* Vector 26: DMA channel 10 transfer complete */
-# define KINETIS_IRQ_DMACH11 (27) /* Vector 27: DMA channel 11 transfer complete */
-# define KINETIS_IRQ_DMACH12 (28) /* Vector 28: DMA channel 12 transfer complete */
-# define KINETIS_IRQ_DMACH13 (29) /* Vector 29: DMA channel 13 transfer complete */
-# define KINETIS_IRQ_DMACH14 (30) /* Vector 30: DMA channel 14 transfer complete */
-# define KINETIS_IRQ_DMACH15 (31) /* Vector 31: DMA channel 15 transfer complete */
-# define KINETIS_IRQ_DMAERR (32) /* Vector 32: DMA error interrupt channels 0-15 */
-# define KINETIS_IRQ_MCM (33) /* Vector 33: MCM Normal interrupt */
-# define KINETIS_IRQ_FLASHCC (34) /* Vector 34: Flash memory command complete */
-# define KINETIS_IRQ_FLASHRC (35) /* Vector 35: Flash memory read collision */
-# define KINETIS_IRQ_SMCLVD (36) /* Vector 36: Mode Controller low-voltage
- * detect, low-voltage warning */
-# define KINETIS_IRQ_LLWU (37) /* Vector 37: LLWU Normal Low Leakage Wakeup */
-# define KINETIS_IRQ_WDOG (38) /* Vector 38: Watchdog */
- /* Vector 39: Reserved */
-# define KINETIS_IRQ_I2C0 (40) /* Vector 40: I2C0 */
-# define KINETIS_IRQ_I2C1 (41) /* Vector 41: I2C1 */
-# define KINETIS_IRQ_SPI0 (42) /* Vector 42: SPI0 all sources */
-# define KINETIS_IRQ_SPI1 (43) /* Vector 43: SPI1 all sources */
-# define KINETIS_IRQ_SPI2 (44) /* Vector 44: SPI2 all sources */
-# define KINETIS_IRQ_CAN0MB (45) /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
-# define KINETIS_IRQ_CAN0BO (46) /* Vector 46: CAN0 Bus Off */
-# define KINETIS_IRQ_CAN0ERR (47) /* Vector 47: CAN0 Error */
-# define KINETIS_IRQ_CAN0TW (48) /* Vector 48: CAN0 Transmit Warning */
-# define KINETIS_IRQ_CAN0RW (49) /* Vector 49: CAN0 Receive Warning */
-# define KINETIS_IRQ_CAN0WU (50) /* Vector 50: CAN0 Wake UP */
- /* Vectors 51-52: Reserved */
-# define KINETIS_IRQ_CAN1MB (53) /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
-# define KINETIS_IRQ_CAN1BO (54) /* Vector 54: CAN1 Bus Off */
-# define KINETIS_IRQ_CAN1ERR (55) /* Vector 55: CAN1 Error */
-# define KINETIS_IRQ_CAN1TW (56) /* Vector 56: CAN1 Transmit Warning */
-# define KINETIS_IRQ_CAN1RW (57) /* Vector 57: CAN1 Receive Warning */
-# define KINETIS_IRQ_CAN1WU (58) /* Vector 58: CAN1 Wake UP */
- /* Vectors 59-60: Reserved */
-# define KINETIS_IRQ_UART0S (61) /* Vector 61: UART0 status */
-# define KINETIS_IRQ_UART0E (62) /* Vector 62: UART0 error */
-# define KINETIS_IRQ_UART1S (63) /* Vector 63: UART1 status */
-# define KINETIS_IRQ_UART1E (64) /* Vector 64: UART1 error */
-# define KINETIS_IRQ_UART2S (65) /* Vector 65: UART2 status */
-# define KINETIS_IRQ_UART2E (66) /* Vector 66: UART2 error */
-# define KINETIS_IRQ_UART3S (67) /* Vector 67: UART3 status */
-# define KINETIS_IRQ_UART3E (68) /* Vector 68: UART3 error */
-# define KINETIS_IRQ_UART4S (69) /* Vector 69: UART4 status */
-# define KINETIS_IRQ_UART4E (70) /* Vector 70: UART4 error */
-# define KINETIS_IRQ_UART5S (71) /* Vector 71: UART5 status */
-# define KINETIS_IRQ_UART5E (72) /* Vector 72: UART5 error */
-# define KINETIS_IRQ_ADC0 (73) /* Vector 73: ADC0 */
-# define KINETIS_IRQ_ADC1 (74) /* Vector 74: ADC1 */
-# define KINETIS_IRQ_CMP0 (75) /* Vector 75: CMP0 */
-# define KINETIS_IRQ_CMP1 (76) /* Vector 76: CMP1 */
-# define KINETIS_IRQ_CMP2 (77) /* Vector 77: CMP2 */
-# define KINETIS_IRQ_FTM0 (78) /* Vector 78: FTM0 all sources */
-# define KINETIS_IRQ_FTM1 (79) /* Vector 79: FTM1 all sources */
-# define KINETIS_IRQ_FTM2 (80) /* Vector 80: FTM2 all sources */
-# define KINETIS_IRQ_CMT (81) /* Vector 81: CMT */
-# define KINETIS_IRQ_RTC (82) /* Vector 82: RTC alarm interrupt */
- /* Vector 83: Reserved */
-# define KINETIS_IRQ_PITCH0 (84) /* Vector 84: PIT channel 0 */
-# define KINETIS_IRQ_PITCH1 (85) /* Vector 85: PIT channel 1 */
-# define KINETIS_IRQ_PITCH2 (86) /* Vector 86: PIT channel 2 */
-# define KINETIS_IRQ_PITCH3 (87) /* Vector 87: PIT channel 3 */
-# define KINETIS_IRQ_PDB (88) /* Vector 88: PDB */
-# define KINETIS_IRQ_USBOTG (89) /* Vector 88: USB OTG */
-# define KINETIS_IRQ_USBCD (90) /* Vector 90: USB charger detect */
- /* Vectors 91-94: Reserved */
-# define KINETIS_IRQ_I2S0 (95) /* Vector 95: I2S0 */
-# define KINETIS_IRQ_SDHC (96) /* Vector 96: SDHC */
-# define KINETIS_IRQ_DAC0 (97) /* Vector 97: DAC0 */
-# define KINETIS_IRQ_DAC1 (98) /* Vector 98: DAC1 */
-# define KINETIS_IRQ_TSI (99) /* Vector 97: TSI all sources */
-# define KINETIS_IRQ_MCG (100) /* Vector 100: MCG */
-# define KINETIS_IRQ_LPT (101) /* Vector 101: Low power timer */
-# define KINETIS_IRQ_SLCD (102) /* Vector 102: Segment LCD all sources */
-# define KINETIS_IRQ_PORTA (103) /* Vector 103: Pin detect port A */
-# define KINETIS_IRQ_PORTB (104) /* Vector 104: Pin detect port B */
-# define KINETIS_IRQ_PORTC (105) /* Vector 105: Pin detect port C */
-# define KINETIS_IRQ_PORTD (106) /* Vector 106: Pin detect port D */
-# define KINETIS_IRQ_PORTE (107) /* Vector 107: Pin detect port E */
- /* Vectors 108-109: Reserved */
-# define KINETIS_IRQ_SWI (110) /* Vector 110: Software interrupt */
-
-/* Note that the total number of IRQ numbers supported is equal to the number of
- * valid interrupt vectors. This is wasteful in that certain tables are sized by
- * this value. There are only 94 valid interrupts so, potentially the numver of
- * IRQs to could be reduced to 94. However, equating IRQ numbers with vector numbers
- * also simplifies operations on NVIC registers and (at least in my state of mind
- * now) seems to justify the waste.
- */
-
-# define NR_VECTORS (111) /* 111 vectors */
-# define NR_IRQS (111) /* 94 interrupts but 111 IRQ numbers */
-
-/* K60 Family ***********************************************************************
- *
- * The memory map for the following parts is defined in Freescale document
- * K60P144M100SF2RM
- */
-
+# include
#elif defined(CONFIG_ARCH_FAMILY_K60)
-
-# define KINETIS_IRQ_DMACH0 (16) /* Vector 16: DMA channel 0 transfer complete */
-# define KINETIS_IRQ_DMACH1 (17) /* Vector 17: DMA channel 1 transfer complete */
-# define KINETIS_IRQ_DMACH2 (18) /* Vector 18: DMA channel 2 transfer complete */
-# define KINETIS_IRQ_DMACH3 (19) /* Vector 19: DMA channel 3 transfer complete */
-# define KINETIS_IRQ_DMACH4 (20) /* Vector 20: DMA channel 4 transfer complete */
-# define KINETIS_IRQ_DMACH5 (21) /* Vector 21: DMA channel 5 transfer complete */
-# define KINETIS_IRQ_DMACH6 (22) /* Vector 22: DMA channel 6 transfer complete */
-# define KINETIS_IRQ_DMACH7 (23) /* Vector 23: DMA channel 7 transfer complete */
-# define KINETIS_IRQ_DMACH8 (24) /* Vector 24: DMA channel 8 transfer complete */
-# define KINETIS_IRQ_DMACH9 (25) /* Vector 25: DMA channel 9 transfer complete */
-# define KINETIS_IRQ_DMACH10 (26) /* Vector 26: DMA channel 10 transfer complete */
-# define KINETIS_IRQ_DMACH11 (27) /* Vector 27: DMA channel 11 transfer complete */
-# define KINETIS_IRQ_DMACH12 (28) /* Vector 28: DMA channel 12 transfer complete */
-# define KINETIS_IRQ_DMACH13 (29) /* Vector 29: DMA channel 13 transfer complete */
-# define KINETIS_IRQ_DMACH14 (30) /* Vector 30: DMA channel 14 transfer complete */
-# define KINETIS_IRQ_DMACH15 (31) /* Vector 31: DMA channel 15 transfer complete */
-# define KINETIS_IRQ_DMAERR (32) /* Vector 32: DMA error interrupt channels 0-15 */
-# define KINETIS_IRQ_MCM (33) /* Vector 33: MCM Normal interrupt */
-# define KINETIS_IRQ_FLASHCC (34) /* Vector 34: Flash memory command complete */
-# define KINETIS_IRQ_FLASHRC (35) /* Vector 35: Flash memory read collision */
-# define KINETIS_IRQ_SMCLVD (36) /* Vector 36: Mode Controller low-voltage
- * detect, low-voltage warning */
-# define KINETIS_IRQ_LLWU (37) /* Vector 37: LLWU Normal Low Leakage Wakeup */
-# define KINETIS_IRQ_WDOG (38) /* Vector 38: Watchdog */
-# define KINETIS_IRQ_RNGB (39) /* Vector 39: Random number generator */
-# define KINETIS_IRQ_I2C0 (40) /* Vector 40: I2C0 */
-# define KINETIS_IRQ_I2C1 (41) /* Vector 41: I2C1 */
-# define KINETIS_IRQ_SPI0 (42) /* Vector 42: SPI0 all sources */
-# define KINETIS_IRQ_SPI1 (43) /* Vector 43: SPI1 all sources */
-# define KINETIS_IRQ_SPI2 (44) /* Vector 44: SPI2 all sources */
-# define KINETIS_IRQ_CAN0MB (45) /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
-# define KINETIS_IRQ_CAN0BO (46) /* Vector 46: CAN0 Bus Off */
-# define KINETIS_IRQ_CAN0ERR (47) /* Vector 47: CAN0 Error */
-# define KINETIS_IRQ_CAN0TW (48) /* Vector 48: CAN0 Transmit Warning */
-# define KINETIS_IRQ_CAN0RW (49) /* Vector 49: CAN0 Receive Warning */
-# define KINETIS_IRQ_CAN0WU (50) /* Vector 50: CAN0 Wake UP */
- /* Vectors 51-52: Reserved */
-# define KINETIS_IRQ_CAN1MB (53) /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
-# define KINETIS_IRQ_CAN1BO (54) /* Vector 54: CAN1 Bus Off */
-# define KINETIS_IRQ_CAN1ERR (55) /* Vector 55: CAN1 Error */
-# define KINETIS_IRQ_CAN1TW (56) /* Vector 56: CAN1 Transmit Warning */
-# define KINETIS_IRQ_CAN1RW (57) /* Vector 57: CAN1 Receive Warning */
-# define KINETIS_IRQ_CAN1WU (58) /* Vector 58: CAN1 Wake UP */
- /* Vectors 59-60: Reserved */
-# define KINETIS_IRQ_UART0S (61) /* Vector 61: UART0 status */
-# define KINETIS_IRQ_UART0E (62) /* Vector 62: UART0 error */
-# define KINETIS_IRQ_UART1S (63) /* Vector 63: UART1 status */
-# define KINETIS_IRQ_UART1E (64) /* Vector 64: UART1 error */
-# define KINETIS_IRQ_UART2S (65) /* Vector 65: UART2 status */
-# define KINETIS_IRQ_UART2E (66) /* Vector 66: UART2 error */
-# define KINETIS_IRQ_UART3S (67) /* Vector 67: UART3 status */
-# define KINETIS_IRQ_UART3E (68) /* Vector 68: UART3 error */
-# define KINETIS_IRQ_UART4S (69) /* Vector 69: UART4 status */
-# define KINETIS_IRQ_UART4E (70) /* Vector 70: UART4 error */
-# define KINETIS_IRQ_UART5S (71) /* Vector 71: UART5 status */
-# define KINETIS_IRQ_UART5E (72) /* Vector 72: UART5 error */
-# define KINETIS_IRQ_ADC0 (73) /* Vector 73: ADC0 */
-# define KINETIS_IRQ_ADC1 (74) /* Vector 74: ADC1 */
-# define KINETIS_IRQ_CMP0 (75) /* Vector 75: CMP0 */
-# define KINETIS_IRQ_CMP1 (76) /* Vector 76: CMP1 */
-# define KINETIS_IRQ_CMP2 (77) /* Vector 77: CMP2 */
-# define KINETIS_IRQ_FTM0 (78) /* Vector 78: FTM0 all sources */
-# define KINETIS_IRQ_FTM1 (79) /* Vector 79: FTM1 all sources */
-# define KINETIS_IRQ_FTM2 (80) /* Vector 80: FTM2 all sources */
-# define KINETIS_IRQ_CMT (81) /* Vector 81: CMT */
-# define KINETIS_IRQ_RTC (82) /* Vector 82: RTC alarm interrupt */
- /* Vector 83: Reserved */
-# define KINETIS_IRQ_PITCH0 (84) /* Vector 84: PIT channel 0 */
-# define KINETIS_IRQ_PITCH1 (85) /* Vector 85: PIT channel 1 */
-# define KINETIS_IRQ_PITCH2 (86) /* Vector 86: PIT channel 2 */
-# define KINETIS_IRQ_PITCH3 (87) /* Vector 87: PIT channel 3 */
-# define KINETIS_IRQ_PDB (88) /* Vector 88: PDB */
-# define KINETIS_IRQ_USBOTG (89) /* Vector 88: USB OTG */
-# define KINETIS_IRQ_USBCD (90) /* Vector 90: USB charger detect */
-# define KINETIS_IRQ_EMACTMR (91) /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
-# define KINETIS_IRQ_EMACTX (92) /* Vector 92: Ethernet MAC transmit interrupt */
-# define KINETIS_IRQ_EMACRX (93) /* Vector 93: Ethernet MAC receive interrupt */
-# define KINETIS_IRQ_EMACMISC (94) /* Vector 94: Ethernet MAC error and misc interrupt */
-# define KINETIS_IRQ_I2S0 (95) /* Vector 95: I2S0 */
-# define KINETIS_IRQ_SDHC (96) /* Vector 96: SDHC */
-# define KINETIS_IRQ_DAC0 (97) /* Vector 97: DAC0 */
-# define KINETIS_IRQ_DAC1 (98) /* Vector 98: DAC1 */
-# define KINETIS_IRQ_TSI (99) /* Vector 97: TSI all sources */
-# define KINETIS_IRQ_MCG (100) /* Vector 100: MCG */
-# define KINETIS_IRQ_LPT (101) /* Vector 101: Low power timer */
- /* Vector 102: Reserved */
-# define KINETIS_IRQ_PORTA (103) /* Vector 103: Pin detect port A */
-# define KINETIS_IRQ_PORTB (104) /* Vector 104: Pin detect port B */
-# define KINETIS_IRQ_PORTC (105) /* Vector 105: Pin detect port C */
-# define KINETIS_IRQ_PORTD (106) /* Vector 106: Pin detect port D */
-# define KINETIS_IRQ_PORTE (107) /* Vector 107: Pin detect port E */
- /* Vectors 108-119: Reserved */
-
-/* Note that the total number of IRQ numbers supported is equal to the number of
- * valid interrupt vectors. This is wasteful in that certain tables are sized by
- * this value. There are only 97 valid interrupts so, potentially the number of
- * IRQs to could be reduced to 97. However, equating IRQ numbers with vector numbers
- * also simplifies operations on NVIC registers and (at least in my state of mind
- * now) seems to justify the waste.
- */
-
-# define NR_VECTORS (120) /* 120 vectors */
-# define NR_IRQS (108) /* 120 interrupts but 108 IRQ numbers */
-
-/* K64 Family ***********************************************************************
- *
- * The memory map for the following parts is defined in NXP document
- * K64P144M120SF5RM.pdf
- */
-
+# include
#elif defined(CONFIG_ARCH_FAMILY_K64)
-
-# define KINETIS_IRQ_DMACH0 (16) /* Vector 16: DMA channel 0 transfer complete */
-# define KINETIS_IRQ_DMACH1 (17) /* Vector 17: DMA channel 1 transfer complete */
-# define KINETIS_IRQ_DMACH2 (18) /* Vector 18: DMA channel 2 transfer complete */
-# define KINETIS_IRQ_DMACH3 (19) /* Vector 19: DMA channel 3 transfer complete */
-# define KINETIS_IRQ_DMACH4 (20) /* Vector 20: DMA channel 4 transfer complete */
-# define KINETIS_IRQ_DMACH5 (21) /* Vector 21: DMA channel 5 transfer complete */
-# define KINETIS_IRQ_DMACH6 (22) /* Vector 22: DMA channel 6 transfer complete */
-# define KINETIS_IRQ_DMACH7 (23) /* Vector 23: DMA channel 7 transfer complete */
-# define KINETIS_IRQ_DMACH8 (24) /* Vector 24: DMA channel 8 transfer complete */
-# define KINETIS_IRQ_DMACH9 (25) /* Vector 25: DMA channel 9 transfer complete */
-# define KINETIS_IRQ_DMACH10 (26) /* Vector 26: DMA channel 10 transfer complete */
-# define KINETIS_IRQ_DMACH11 (27) /* Vector 27: DMA channel 11 transfer complete */
-# define KINETIS_IRQ_DMACH12 (28) /* Vector 28: DMA channel 12 transfer complete */
-# define KINETIS_IRQ_DMACH13 (29) /* Vector 29: DMA channel 13 transfer complete */
-# define KINETIS_IRQ_DMACH14 (30) /* Vector 30: DMA channel 14 transfer complete */
-# define KINETIS_IRQ_DMACH15 (31) /* Vector 31: DMA channel 15 transfer complete */
-# define KINETIS_IRQ_DMAERR (32) /* Vector 32: DMA error interrupt channels 0-15 */
-# define KINETIS_IRQ_MCM (33) /* Vector 33: MCM Normal interrupt */
-# define KINETIS_IRQ_FLASHCC (34) /* Vector 34: Flash memory command complete */
-# define KINETIS_IRQ_FLASHRC (35) /* Vector 35: Flash memory read collision */
-# define KINETIS_IRQ_SMCLVD (36) /* Vector 36: Mode Controller low-voltage
- * detect, low-voltage warning */
-# define KINETIS_IRQ_LLWU (37) /* Vector 37: LLWU Normal Low Leakage Wakeup */
-# define KINETIS_IRQ_WDOG (38) /* Vector 38: Watchdog */
-# define KINETIS_IRQ_RNGB (39) /* Vector 39: Random number generator */
-# define KINETIS_IRQ_I2C0 (40) /* Vector 40: I2C0 */
-# define KINETIS_IRQ_I2C1 (41) /* Vector 41: I2C1 */
-# define KINETIS_IRQ_SPI0 (42) /* Vector 42: SPI0 all sources */
-# define KINETIS_IRQ_SPI1 (43) /* Vector 43: SPI1 all sources */
-# define KINETIS_IRQ_I2S0 (44) /* Vector 44: Transmit */
-# define KINETIS_IRQ_I2S1 (45) /* Vector 45: Transmit */
- /* Vector 46: Reserved */
-# define KINETIS_IRQ_UART0S (47) /* Vector 47: UART0 status */
-# define KINETIS_IRQ_UART0E (48) /* Vector 48: UART0 error */
-# define KINETIS_IRQ_UART1S (49) /* Vector 49: UART1 status */
-# define KINETIS_IRQ_UART1E (50) /* Vector 50: UART1 error */
-# define KINETIS_IRQ_UART2S (51) /* Vector 51: UART2 status */
-# define KINETIS_IRQ_UART2E (52) /* Vector 52: UART2 error */
-# define KINETIS_IRQ_UART3S (53) /* Vector 53: UART3 status */
-# define KINETIS_IRQ_UART3E (54) /* Vector 54: UART3 error */
-# define KINETIS_IRQ_ADC0 (55) /* Vector 55: ADC0 */
-# define KINETIS_IRQ_CMP0 (56) /* Vector 56: CMP0 */
-# define KINETIS_IRQ_CMP1 (57) /* Vector 57: CMP1 */
-# define KINETIS_IRQ_FTM0 (58) /* Vector 58: FTM0 all sources */
-# define KINETIS_IRQ_FTM1 (59) /* Vector 59: FTM1 all sources */
-# define KINETIS_IRQ_FTM2 (60) /* Vector 60: FTM2 all sources */
-# define KINETIS_IRQ_CMT (61) /* Vector 61: CMT */
-# define KINETIS_IRQ_RTC0 (62) /* Vector 62: RTC alarm interrupt */
-# define KINETIS_IRQ_RTC1 (63) /* Vector 63: RTC seconds interrupt */
-# define KINETIS_IRQ_PITCH0 (64) /* Vector 64: PIT channel 0 */
-# define KINETIS_IRQ_PITCH1 (65) /* Vector 65: PIT channel 1 */
-# define KINETIS_IRQ_PITCH2 (66) /* Vector 66: PIT channel 2 */
-# define KINETIS_IRQ_PITCH3 (67) /* Vector 67: PIT channel 3 */
-# define KINETIS_IRQ_PDB (68) /* Vector 68: PDB */
-# define KINETIS_IRQ_USBOTG (69) /* Vector 68: USB OTG */
-# define KINETIS_IRQ_USBCD (70) /* Vector 70: USB charger detect */
- /* Vector 71: Reserved */
-# define KINETIS_IRQ_DAC0 (72) /* Vector 72: DAC0 */
-# define KINETIS_IRQ_MCG (73) /* Vector 73: MCG */
-# define KINETIS_IRQ_LPT (74) /* Vector 74: Low power timer */
-# define KINETIS_IRQ_PORTA (75) /* Vector 75: Pin detect port A */
-# define KINETIS_IRQ_PORTB (76) /* Vector 76: Pin detect port B */
-# define KINETIS_IRQ_PORTC (77) /* Vector 77: Pin detect port C */
-# define KINETIS_IRQ_PORTD (78) /* Vector 78: Pin detect port D */
-# define KINETIS_IRQ_PORTE (79) /* Vector 79: Pin detect port E */
-# define KINETIS_IRQ_SOFTWARE (80) /* Vector 80: Software interrupt */
-# define KINETIS_IRQ_SPI2 (81) /* Vector 81: SPI2 all sources */
-# define KINETIS_IRQ_UART4S (82) /* Vector 82: UART4 status */
-# define KINETIS_IRQ_UART4E (83) /* Vector 83: UART4 error */
-# define KINETIS_IRQ_UART5S (84) /* Vector 84: UART5 status */
-# define KINETIS_IRQ_UART5E (85) /* Vector 85: UART5 error */
-# define KINETIS_IRQ_CMP2 (86) /* Vector 86: CMP2 */
-# define KINETIS_IRQ_FTM3 (87) /* Vector 87: FTM3 all sources */
-# define KINETIS_IRQ_DAC1 (88) /* Vector 88: DAC1 */
-# define KINETIS_IRQ_ADC1 (89) /* Vector 89: ADC1 */
-# define KINETIS_IRQ_I2C2 (90) /* Vector 90: I2C2 */
-# define KINETIS_IRQ_CAN0MB (91) /* Vector 91: CAN0 OR'ed Message buffer (0-15) */
-# define KINETIS_IRQ_CAN0BO (92) /* Vector 92: CAN0 Bus Off */
-# define KINETIS_IRQ_CAN0ERR (93) /* Vector 93: CAN0 Error */
-# define KINETIS_IRQ_CAN0TW (94) /* Vector 94: CAN0 Transmit Warning */
-# define KINETIS_IRQ_CAN0RW (95) /* Vector 95: CAN0 Receive Warning */
-# define KINETIS_IRQ_CAN0WU (96) /* Vector 96: CAN0 Wake UP */
-# define KINETIS_IRQ_SDHC (97) /* Vector 97: SDHC */
-# define KINETIS_IRQ_EMACTMR (98) /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
-# define KINETIS_IRQ_EMACTX (99) /* Vector 92: Ethernet MAC transmit interrupt */
-# define KINETIS_IRQ_EMACRX (100) /* Vector 93: Ethernet MAC receive interrupt */
-# define KINETIS_IRQ_EMACMISC (101) /* Vector 94: Ethernet MAC error and misc interrupt */
-
-# define NR_VECTORS (102) /* 102 vectors */
-# define NR_IRQS (102) /* 85 interrupts but 102 IRQ numbers */
-
+# include
+#elif defined(CONFIG_ARCH_FAMILY_K66)
+# include
#else
/* The interrupt vectors for other parts are defined in other documents and may or
* may not be the same as above (the family members are all very similar) This
@@ -484,7 +95,7 @@
* if the vectors are the same.
*/
-# error "No IRQ numbers for this Kinetis part"
+# error "No IRQ numbers for this Kinetis K part"
#endif
/************************************************************************************
diff --git a/arch/arm/include/kinetis/kinetis_k20irq.h b/arch/arm/include/kinetis/kinetis_k20irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..a5bb3068a655f27e97e048d2a6cfd15a2ca576a1
--- /dev/null
+++ b/arch/arm/include/kinetis/kinetis_k20irq.h
@@ -0,0 +1,200 @@
+/*****************************************************************************
+ * arch/arm/include/kinetis/kinetis_k20irq.h
+ *
+ * Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
+ */
+
+#ifndef __ARCH_ARM_INCLUDE_KINETIS_KINETIS_K20IRQ_H
+#define __ARCH_ARM_INCLUDE_KINETIS_KINETIS_K20IRQ_H
+
+/*****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+/*****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* IRQ numbers. The IRQ number corresponds vector number and hence map
+ * directly to bits in the NVIC. This does, however, waste several words of
+ * memory in the IRQ to handle mapping tables.
+ *
+ * Processor Exceptions (vectors 0-15). These common definitions can be found
+ * in the file nuttx/arch/arm/include/kinets/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ *
+ * K20 Family ****************************************************************
+ *
+ * The interrupt vectors for the following parts is defined in Freescale
+ * document K20P64M72SF1RM
+ */
+
+#define KINETIS_IRQ_DMACH0 (KINETIS_IRQ_FIRST+0) /* 0: DMA channel 0 transfer complete */
+#define KINETIS_IRQ_DMACH1 (KINETIS_IRQ_FIRST+1) /* 1: DMA channel 1 transfer complete */
+#define KINETIS_IRQ_DMACH2 (KINETIS_IRQ_FIRST+2) /* 2: DMA channel 2 transfer complete */
+#define KINETIS_IRQ_DMACH3 (KINETIS_IRQ_FIRST+3) /* 3: DMA channel 3 transfer complete */
+#define KINETIS_IRQ_DMACH4 (KINETIS_IRQ_FIRST+4) /* 4: DMA channel 4 transfer complete */
+#define KINETIS_IRQ_DMACH5 (KINETIS_IRQ_FIRST+5) /* 5: DMA channel 5 transfer complete */
+#define KINETIS_IRQ_DMACH6 (KINETIS_IRQ_FIRST+6) /* 6: DMA channel 6 transfer complete */
+#define KINETIS_IRQ_DMACH7 (KINETIS_IRQ_FIRST+7) /* 7: DMA channel 7 transfer complete */
+#define KINETIS_IRQ_DMACH8 (KINETIS_IRQ_FIRST+8) /* 8: DMA channel 8 transfer complete */
+#define KINETIS_IRQ_DMACH9 (KINETIS_IRQ_FIRST+9) /* 9: DMA channel 9 transfer complete */
+#define KINETIS_IRQ_DMACH10 (KINETIS_IRQ_FIRST+10) /* 10: DMA channel 10 transfer complete */
+#define KINETIS_IRQ_DMACH11 (KINETIS_IRQ_FIRST+11) /* 11: DMA channel 11 transfer complete */
+#define KINETIS_IRQ_DMACH12 (KINETIS_IRQ_FIRST+12) /* 12: DMA channel 12 transfer complete */
+#define KINETIS_IRQ_DMACH13 (KINETIS_IRQ_FIRST+13) /* 13: DMA channel 13 transfer complete */
+#define KINETIS_IRQ_DMACH14 (KINETIS_IRQ_FIRST+14) /* 14: DMA channel 14 transfer complete */
+#define KINETIS_IRQ_DMACH15 (KINETIS_IRQ_FIRST+15) /* 15: DMA channel 15 transfer complete */
+#define KINETIS_IRQ_DMAERR (KINETIS_IRQ_FIRST+16) /* 16: DMA error interrupt channels 0-15 */
+#define KINETIS_IRQ_RESVD17 (KINETIS_IRQ_FIRST+17) /* 17: Reserved */
+#define KINETIS_IRQ_FLASHCC (KINETIS_IRQ_FIRST+18) /* 18: Flash memory command complete */
+#define KINETIS_IRQ_FLASHRC (KINETIS_IRQ_FIRST+19) /* 19: Flash memory read collision */
+#define KINETIS_IRQ_SMCLVD (KINETIS_IRQ_FIRST+20) /* 20: Mode Controller low-voltage
+ * detect, low-voltage warning */
+#define KINETIS_IRQ_LLWU (KINETIS_IRQ_FIRST+21) /* 21: LLWU Normal Low Leakage Wakeup */
+#define KINETIS_IRQ_WDOG (KINETIS_IRQ_FIRST+22) /* 22: Watchdog */
+#define KINETIS_IRQ_RESVD23 (KINETIS_IRQ_FIRST+23) /* 23: Reserved */
+#define KINETIS_IRQ_I2C0 (KINETIS_IRQ_FIRST+24) /* 24: I2C0 */
+#define KINETIS_IRQ_I2C1 (KINETIS_IRQ_FIRST+25) /* 25: I2C1 */
+#define KINETIS_IRQ_SPI0 (KINETIS_IRQ_FIRST+26) /* 26: SPI0 all sources */
+#define KINETIS_IRQ_SPI1 (KINETIS_IRQ_FIRST+27) /* 27: SPI1 all sources */
+#define KINETIS_IRQ_RESVD28 (KINETIS_IRQ_FIRST+28) /* 28: Reserved */
+#define KINETIS_IRQ_CAN0MB (KINETIS_IRQ_FIRST+29) /* 29: CAN0 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN0BO (KINETIS_IRQ_FIRST+30) /* 30: CAN0 Bus Off */
+#define KINETIS_IRQ_CAN0ERR (KINETIS_IRQ_FIRST+31) /* 31: CAN0 Error */
+#define KINETIS_IRQ_CAN0TW (KINETIS_IRQ_FIRST+32) /* 32: CAN0 Transmit Warning */
+#define KINETIS_IRQ_CAN0RW (KINETIS_IRQ_FIRST+33) /* 33: CAN0 Receive Warning */
+#define KINETIS_IRQ_CAN0WU (KINETIS_IRQ_FIRST+34) /* 34: CAN0 Wake UP */
+#define KINETIS_IRQ_I2S0TX (KINETIS_IRQ_FIRST+35) /* 35: I2S0 Transmit */
+#define KINETIS_IRQ_I2S0TX (KINETIS_IRQ_FIRST+36) /* 36: I2S0 Receive */
+#define KINETIS_IRQ_RESVD37 (KINETIS_IRQ_FIRST+37) /* 37: Reserved */
+#define KINETIS_IRQ_RESVD38 (KINETIS_IRQ_FIRST+38) /* 38: Reserved */
+#define KINETIS_IRQ_RESVD39 (KINETIS_IRQ_FIRST+39) /* 39: Reserved */
+#define KINETIS_IRQ_RESVD40 (KINETIS_IRQ_FIRST+40) /* 40: Reserved */
+#define KINETIS_IRQ_RESVD41 (KINETIS_IRQ_FIRST+41) /* 41: Reserved */
+#define KINETIS_IRQ_RESVD42 (KINETIS_IRQ_FIRST+42) /* 42: Reserved */
+#define KINETIS_IRQ_RESVD43 (KINETIS_IRQ_FIRST+43) /* 43: Reserved */
+#define KINETIS_IRQ_UART0L (KINETIS_IRQ_FIRST+44) /* 44: UART0 LON */
+#define KINETIS_IRQ_UART0S (KINETIS_IRQ_FIRST+45) /* 45: UART0 status */
+#define KINETIS_IRQ_UART0E (KINETIS_IRQ_FIRST+46) /* 46: UART0 error */
+#define KINETIS_IRQ_UART1S (KINETIS_IRQ_FIRST+47) /* 47: UART1 status */
+#define KINETIS_IRQ_UART1E (KINETIS_IRQ_FIRST+48) /* 48: UART1 error */
+#define KINETIS_IRQ_UART2S (KINETIS_IRQ_FIRST+49) /* 49: UART2 status */
+#define KINETIS_IRQ_UART2E (KINETIS_IRQ_FIRST+50) /* 50: UART2 error */
+#define KINETIS_IRQ_RESVD51 (KINETIS_IRQ_FIRST+51) /* 51: Reserved */
+#define KINETIS_IRQ_RESVD52 (KINETIS_IRQ_FIRST+52) /* 52: Reserved */
+#define KINETIS_IRQ_RESVD53 (KINETIS_IRQ_FIRST+53) /* 53: Reserved */
+#define KINETIS_IRQ_RESVD54 (KINETIS_IRQ_FIRST+54) /* 54: Reserved */
+#define KINETIS_IRQ_RESVD55 (KINETIS_IRQ_FIRST+55) /* 55: Reserved */
+#define KINETIS_IRQ_RESVD56 (KINETIS_IRQ_FIRST+56) /* 56: Reserved */
+#define KINETIS_IRQ_ADC0 (KINETIS_IRQ_FIRST+57) /* 57: ADC0 */
+#define KINETIS_IRQ_ADC1 (KINETIS_IRQ_FIRST+58) /* 58: ADC1 */
+#define KINETIS_IRQ_CMP0 (KINETIS_IRQ_FIRST+59) /* 59: CMP0 */
+#define KINETIS_IRQ_CMP1 (KINETIS_IRQ_FIRST+60) /* 60: CMP1 */
+#define KINETIS_IRQ_CMP2 (KINETIS_IRQ_FIRST+61) /* 61: CMP2 */
+#define KINETIS_IRQ_FTM0 (KINETIS_IRQ_FIRST+62) /* 62: FTM0 all sources */
+#define KINETIS_IRQ_FTM1 (KINETIS_IRQ_FIRST+63) /* 63: FTM1 all sources */
+#define KINETIS_IRQ_FTM2 (KINETIS_IRQ_FIRST+64) /* 64: FTM2 all sources */
+#define KINETIS_IRQ_CMT (KINETIS_IRQ_FIRST+65) /* 65: CMT */
+#define KINETIS_IRQ_RTC (KINETIS_IRQ_FIRST+66) /* 66: RTC alarm interrupt */
+#define KINETIS_IRQ_RTCS (KINETIS_IRQ_FIRST+67) /* 67: RTC Seconds interrupt */
+#define KINETIS_IRQ_PITCH0 (KINETIS_IRQ_FIRST+68) /* 68: PIT channel 0 */
+#define KINETIS_IRQ_PITCH1 (KINETIS_IRQ_FIRST+69) /* 69: PIT channel 1 */
+#define KINETIS_IRQ_PITCH2 (KINETIS_IRQ_FIRST+70) /* 70: PIT channel 2 */
+#define KINETIS_IRQ_PITCH3 (KINETIS_IRQ_FIRST+71) /* 71: PIT channel 3 */
+#define KINETIS_IRQ_PDB (KINETIS_IRQ_FIRST+72) /* 72: PDB */
+#define KINETIS_IRQ_USBOTG (KINETIS_IRQ_FIRST+73) /* 73: USB OTG */
+#define KINETIS_IRQ_USBCD (KINETIS_IRQ_FIRST+74) /* 74: USB charger detect */
+#define KINETIS_IRQ_RESVD75 (KINETIS_IRQ_FIRST+75) /* 75: Reserved */
+#define KINETIS_IRQ_RESVD76 (KINETIS_IRQ_FIRST+76) /* 76: Reserved */
+#define KINETIS_IRQ_RESVD77 (KINETIS_IRQ_FIRST+77) /* 77: Reserved */
+#define KINETIS_IRQ_RESVD78 (KINETIS_IRQ_FIRST+78) /* 78: Reserved */
+#define KINETIS_IRQ_RESVD79 (KINETIS_IRQ_FIRST+79) /* 79: Reserved */
+#define KINETIS_IRQ_RESVD80 (KINETIS_IRQ_FIRST+80) /* 80: Reserved */
+#define KINETIS_IRQ_DAC0 (KINETIS_IRQ_FIRST+81) /* 81: DAC0 */
+#define KINETIS_IRQ_RESVD82 (KINETIS_IRQ_FIRST+82) /* 82: Reserved */
+#define KINETIS_IRQ_TSI (KINETIS_IRQ_FIRST+83) /* 83: TSI all sources */
+#define KINETIS_IRQ_MCG (KINETIS_IRQ_FIRST+84) /* 84: MCG */
+#define KINETIS_IRQ_LPT (KINETIS_IRQ_FIRST+85) /* 85: Low power timer */
+#define KINETIS_IRQ_RESVD86 (KINETIS_IRQ_FIRST+86) /* 86: Reserved */
+#define KINETIS_IRQ_PORTA (KINETIS_IRQ_FIRST+87) /* 87: Pin detect port A */
+#define KINETIS_IRQ_PORTB (KINETIS_IRQ_FIRST+88) /* 88: Pin detect port B */
+#define KINETIS_IRQ_PORTC (KINETIS_IRQ_FIRST+89) /* 89: Pin detect port C */
+#define KINETIS_IRQ_PORTD (KINETIS_IRQ_FIRST+90) /* 90: Pin detect port D */
+#define KINETIS_IRQ_PORTE (KINETIS_IRQ_FIRST+91) /* 91: Pin detect port E */
+#define KINETIS_IRQ_RESVD92 (KINETIS_IRQ_FIRST+92) /* 92: Reserved */
+#define KINETIS_IRQ_RESVD93 (KINETIS_IRQ_FIRST+93) /* 93: Reserved */
+#define KINETIS_IRQ_SWI (KINETIS_IRQ_FIRST+94) /* 94: Software interrupt */
+
+#define NR_INTERRUPTS 95 /* 95 Non core IRQs*/
+#define NR_VECTORS (KINETIS_IRQ_FIRST+NR_INTERRUPTS) /* 111 vectors */
+
+/* EXTI interrupts (Do not use IRQ numbers) */
+
+#define NR_IRQS NR_VECTORS
+
+/*****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/*****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_KINETIS_KINETIS_K20IRQ_H */
diff --git a/arch/arm/include/kinetis/kinetis_k40irq.h b/arch/arm/include/kinetis/kinetis_k40irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..4156b321f94ea3a229f3a467626bc000b4b72c00
--- /dev/null
+++ b/arch/arm/include/kinetis/kinetis_k40irq.h
@@ -0,0 +1,200 @@
+/*****************************************************************************
+ * arch/arm/include/kinetis/kinetis_k40irq.h
+ *
+ * Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
+ */
+
+#ifndef __ARCH_ARM_INCLUDE_KINETIS_KINETIS_40KIRQ_H
+#define __ARCH_ARM_INCLUDE_KINETIS_KINETIS_40KIRQ_H
+
+/*****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+/*****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* IRQ numbers. The IRQ number corresponds vector number and hence map
+ * directly to bits in the NVIC. This does, however, waste several words of
+ * memory in the IRQ to handle mapping tables.
+ *
+ * Processor Exceptions (vectors 0-15). These common definitions can be found
+ * in the file nuttx/arch/arm/include/kinets/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ *
+ * K40 Family ****************************************************************
+ *
+ * The interrupt vectors for the following parts is defined in Freescale
+ * document K40P144M100SF2RM
+ */
+
+#define KINETIS_IRQ_DMACH0 (KINETIS_IRQ_FIRST+0) /* 0: DMA channel 0 transfer complete */
+#define KINETIS_IRQ_DMACH1 (KINETIS_IRQ_FIRST+1) /* 1: DMA channel 1 transfer complete */
+#define KINETIS_IRQ_DMACH2 (KINETIS_IRQ_FIRST+2) /* 2: DMA channel 2 transfer complete */
+#define KINETIS_IRQ_DMACH3 (KINETIS_IRQ_FIRST+3) /* 3: DMA channel 3 transfer complete */
+#define KINETIS_IRQ_DMACH4 (KINETIS_IRQ_FIRST+4) /* 4: DMA channel 4 transfer complete */
+#define KINETIS_IRQ_DMACH5 (KINETIS_IRQ_FIRST+5) /* 5: DMA channel 5 transfer complete */
+#define KINETIS_IRQ_DMACH6 (KINETIS_IRQ_FIRST+6) /* 6: DMA channel 6 transfer complete */
+#define KINETIS_IRQ_DMACH7 (KINETIS_IRQ_FIRST+7) /* 7: DMA channel 7 transfer complete */
+#define KINETIS_IRQ_DMACH8 (KINETIS_IRQ_FIRST+8) /* 8: DMA channel 8 transfer complete */
+#define KINETIS_IRQ_DMACH9 (KINETIS_IRQ_FIRST+9) /* 9: DMA channel 9 transfer complete */
+#define KINETIS_IRQ_DMACH10 (KINETIS_IRQ_FIRST+10) /* 10: DMA channel 10 transfer complete */
+#define KINETIS_IRQ_DMACH11 (KINETIS_IRQ_FIRST+11) /* 11: DMA channel 11 transfer complete */
+#define KINETIS_IRQ_DMACH12 (KINETIS_IRQ_FIRST+12) /* 12: DMA channel 12 transfer complete */
+#define KINETIS_IRQ_DMACH13 (KINETIS_IRQ_FIRST+13) /* 13: DMA channel 13 transfer complete */
+#define KINETIS_IRQ_DMACH14 (KINETIS_IRQ_FIRST+14) /* 14: DMA channel 14 transfer complete */
+#define KINETIS_IRQ_DMACH15 (KINETIS_IRQ_FIRST+15) /* 15: DMA channel 15 transfer complete */
+#define KINETIS_IRQ_DMAERR (KINETIS_IRQ_FIRST+16) /* 16: DMA error interrupt channels 0-15 */
+#define KINETIS_IRQ_MCM (KINETIS_IRQ_FIRST+17) /* 17: MCM Normal interrupt */
+#define KINETIS_IRQ_FLASHCC (KINETIS_IRQ_FIRST+18) /* 18: Flash memory command complete */
+#define KINETIS_IRQ_FLASHRC (KINETIS_IRQ_FIRST+19) /* 19: Flash memory read collision */
+#define KINETIS_IRQ_SMCLVD (KINETIS_IRQ_FIRST+20) /* 20: Mode Controller low-voltage
+ * detect, low-voltage warning */
+#define KINETIS_IRQ_LLWU (KINETIS_IRQ_FIRST+21) /* 21: LLWU Normal Low Leakage Wakeup */
+#define KINETIS_IRQ_WDOG (KINETIS_IRQ_FIRST+22) /* 22: Watchdog */
+#define KINETIS_IRQ_RESVD23 (KINETIS_IRQ_FIRST+23) /* 23: Reserved */
+#define KINETIS_IRQ_I2C0 (KINETIS_IRQ_FIRST+24) /* 24: I2C0 */
+#define KINETIS_IRQ_I2C1 (KINETIS_IRQ_FIRST+25) /* 25: I2C1 */
+#define KINETIS_IRQ_SPI0 (KINETIS_IRQ_FIRST+26) /* 26: SPI0 all sources */
+#define KINETIS_IRQ_SPI1 (KINETIS_IRQ_FIRST+27) /* 27: SPI1 all sources */
+#define KINETIS_IRQ_SPI2 (KINETIS_IRQ_FIRST+28) /* 28: SPI2 all sources */
+#define KINETIS_IRQ_CAN0MB (KINETIS_IRQ_FIRST+29) /* 29: CAN0 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN0BO (KINETIS_IRQ_FIRST+30) /* 30: CAN0 Bus Off */
+#define KINETIS_IRQ_CAN0ERR (KINETIS_IRQ_FIRST+31) /* 31: CAN0 Error */
+#define KINETIS_IRQ_CAN0TW (KINETIS_IRQ_FIRST+32) /* 32: CAN0 Transmit Warning */
+#define KINETIS_IRQ_CAN0RW (KINETIS_IRQ_FIRST+33) /* 33: CAN0 Receive Warning */
+#define KINETIS_IRQ_CAN0WU (KINETIS_IRQ_FIRST+34) /* 34: CAN0 Wake UP */
+#define KINETIS_IRQ_RESVD35 (KINETIS_IRQ_FIRST+35) /* 35: Reserved */
+#define KINETIS_IRQ_RESVD36 (KINETIS_IRQ_FIRST+36) /* 36: Reserved */
+#define KINETIS_IRQ_CAN1MB (KINETIS_IRQ_FIRST+37) /* 37: CAN1 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN1BO (KINETIS_IRQ_FIRST+38) /* 38: CAN1 Bus Off */
+#define KINETIS_IRQ_CAN1ERR (KINETIS_IRQ_FIRST+39) /* 39: CAN1 Error */
+#define KINETIS_IRQ_CAN1TW (KINETIS_IRQ_FIRST+40) /* 40: CAN1 Transmit Warning */
+#define KINETIS_IRQ_CAN1RW (KINETIS_IRQ_FIRST+41) /* 41: CAN1 Receive Warning */
+#define KINETIS_IRQ_CAN1WU (KINETIS_IRQ_FIRST+42) /* 42: CAN1 Wake UP */
+#define KINETIS_IRQ_RESVD43 (KINETIS_IRQ_FIRST+43) /* 43: Reserved */
+#define KINETIS_IRQ_RESVD44 (KINETIS_IRQ_FIRST+44) /* 44: Reserved */
+#define KINETIS_IRQ_UART0S (KINETIS_IRQ_FIRST+45) /* 45: UART0 status */
+#define KINETIS_IRQ_UART0E (KINETIS_IRQ_FIRST+46) /* 46: UART0 error */
+#define KINETIS_IRQ_UART1S (KINETIS_IRQ_FIRST+47) /* 47: UART1 status */
+#define KINETIS_IRQ_UART1E (KINETIS_IRQ_FIRST+48) /* 48: UART1 error */
+#define KINETIS_IRQ_UART2S (KINETIS_IRQ_FIRST+49) /* 49: UART2 status */
+#define KINETIS_IRQ_UART2E (KINETIS_IRQ_FIRST+50) /* 50: UART2 error */
+#define KINETIS_IRQ_UART3S (KINETIS_IRQ_FIRST+51) /* 51: UART3 status */
+#define KINETIS_IRQ_UART3E (KINETIS_IRQ_FIRST+52) /* 52: UART3 error */
+#define KINETIS_IRQ_UART4S (KINETIS_IRQ_FIRST+53) /* 53: UART4 status */
+#define KINETIS_IRQ_UART4E (KINETIS_IRQ_FIRST+54) /* 54: UART4 error */
+#define KINETIS_IRQ_UART5S (KINETIS_IRQ_FIRST+55) /* 55: UART5 status */
+#define KINETIS_IRQ_UART5E (KINETIS_IRQ_FIRST+56) /* 56: UART5 error */
+#define KINETIS_IRQ_ADC0 (KINETIS_IRQ_FIRST+57) /* 57: ADC0 */
+#define KINETIS_IRQ_ADC1 (KINETIS_IRQ_FIRST+58) /* 58: ADC1 */
+#define KINETIS_IRQ_CMP0 (KINETIS_IRQ_FIRST+59) /* 59: CMP0 */
+#define KINETIS_IRQ_CMP1 (KINETIS_IRQ_FIRST+60) /* 60: CMP1 */
+#define KINETIS_IRQ_CMP2 (KINETIS_IRQ_FIRST+61) /* 61: CMP2 */
+#define KINETIS_IRQ_FTM0 (KINETIS_IRQ_FIRST+62) /* 62: FTM0 all sources */
+#define KINETIS_IRQ_FTM1 (KINETIS_IRQ_FIRST+63) /* 63: FTM1 all sources */
+#define KINETIS_IRQ_FTM2 (KINETIS_IRQ_FIRST+64) /* 64: FTM2 all sources */
+#define KINETIS_IRQ_CMT (KINETIS_IRQ_FIRST+65) /* 65: CMT */
+#define KINETIS_IRQ_RTC (KINETIS_IRQ_FIRST+66) /* 66: RTC alarm interrupt */
+#define KINETIS_IRQ_RESVD67 (KINETIS_IRQ_FIRST+67) /* 67: Reserved */
+#define KINETIS_IRQ_PITCH0 (KINETIS_IRQ_FIRST+68) /* 68: PIT channel 0 */
+#define KINETIS_IRQ_PITCH1 (KINETIS_IRQ_FIRST+69) /* 69: PIT channel 1 */
+#define KINETIS_IRQ_PITCH2 (KINETIS_IRQ_FIRST+70) /* 70: PIT channel 2 */
+#define KINETIS_IRQ_PITCH3 (KINETIS_IRQ_FIRST+71) /* 71: PIT channel 3 */
+#define KINETIS_IRQ_PDB (KINETIS_IRQ_FIRST+72) /* 72: PDB */
+#define KINETIS_IRQ_USBOTG (KINETIS_IRQ_FIRST+73) /* 73: USB OTG */
+#define KINETIS_IRQ_USBCD (KINETIS_IRQ_FIRST+74) /* 74: USB charger detect */
+#define KINETIS_IRQ_RESVD75 (KINETIS_IRQ_FIRST+75) /* 75: Reserved */
+#define KINETIS_IRQ_RESVD76 (KINETIS_IRQ_FIRST+76) /* 76: Reserved */
+#define KINETIS_IRQ_RESVD77 (KINETIS_IRQ_FIRST+77) /* 77: Reserved */
+#define KINETIS_IRQ_RESVD78 (KINETIS_IRQ_FIRST+78) /* 78: Reserved */
+#define KINETIS_IRQ_I2S0 (KINETIS_IRQ_FIRST+79) /* 79: I2S0 */
+#define KINETIS_IRQ_SDHC (KINETIS_IRQ_FIRST+80) /* 80: SDHC */
+#define KINETIS_IRQ_DAC0 (KINETIS_IRQ_FIRST+81) /* 81: DAC0 */
+#define KINETIS_IRQ_DAC1 (KINETIS_IRQ_FIRST+82) /* 82: DAC1 */
+#define KINETIS_IRQ_TSI (KINETIS_IRQ_FIRST+83) /* 83: TSI all sources */
+#define KINETIS_IRQ_MCG (KINETIS_IRQ_FIRST+84) /* 84: MCG */
+#define KINETIS_IRQ_LPT (KINETIS_IRQ_FIRST+85) /* 85: Low power timer */
+#define KINETIS_IRQ_SLCD (KINETIS_IRQ_FIRST+86) /* 86: Segment LCD all sources */
+#define KINETIS_IRQ_PORTA (KINETIS_IRQ_FIRST+87) /* 87: Pin detect port A */
+#define KINETIS_IRQ_PORTB (KINETIS_IRQ_FIRST+88) /* 88: Pin detect port B */
+#define KINETIS_IRQ_PORTC (KINETIS_IRQ_FIRST+89) /* 89: Pin detect port C */
+#define KINETIS_IRQ_PORTD (KINETIS_IRQ_FIRST+90) /* 90: Pin detect port D */
+#define KINETIS_IRQ_PORTE (KINETIS_IRQ_FIRST+91) /* 91: Pin detect port E */
+#define KINETIS_IRQ_RESVD92 (KINETIS_IRQ_FIRST+92) /* 92: Reserved */
+#define KINETIS_IRQ_RESVD93 (KINETIS_IRQ_FIRST+93) /* 93: Reserved */
+#define KINETIS_IRQ_SWI (KINETIS_IRQ_FIRST+94) /* 94: Software interrupt */
+
+#define NR_INTERRUPTS 95 /* 95 Non core IRQs*/
+#define NR_VECTORS (KINETIS_IRQ_FIRST+NR_INTERRUPTS) /* 111 vectors */
+
+/* EXTI interrupts (Do not use IRQ numbers) */
+
+#define NR_IRQS NR_VECTORS
+
+/*****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/*****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_KINETIS_KINETIS_40KIRQ_H */
diff --git a/arch/arm/include/kinetis/kinetis_k60irq.h b/arch/arm/include/kinetis/kinetis_k60irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..b2e3a79b83c656f0a106ec14f9dc4f54b06891d9
--- /dev/null
+++ b/arch/arm/include/kinetis/kinetis_k60irq.h
@@ -0,0 +1,200 @@
+/*****************************************************************************
+ * arch/arm/include/kinetis/kinetis_k60irq.h
+ *
+ * Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
+ */
+
+#ifndef __ARCH_ARM_INCLUDE_KINETIS_KINETIS_60KIRQ_H
+#define __ARCH_ARM_INCLUDE_KINETIS_KINETIS_60KIRQ_H
+
+/*****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+/*****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* IRQ numbers. The IRQ number corresponds vector number and hence map
+ * directly to bits in the NVIC. This does, however, waste several words of
+ * memory in the IRQ to handle mapping tables.
+ *
+ * Processor Exceptions (vectors 0-15). These common definitions can be found
+ * in the file nuttx/arch/arm/include/kinets/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ *
+ * K60 Family ****************************************************************
+ *
+ * The interrupt vectors for the following parts is defined in Freescale
+ * document K60P144M100SF2RM
+ */
+
+#define KINETIS_IRQ_DMACH0 (KINETIS_IRQ_FIRST+0) /* 0: DMA channel 0 transfer complete */
+#define KINETIS_IRQ_DMACH1 (KINETIS_IRQ_FIRST+1) /* 1: DMA channel 1 transfer complete */
+#define KINETIS_IRQ_DMACH2 (KINETIS_IRQ_FIRST+2) /* 2: DMA channel 2 transfer complete */
+#define KINETIS_IRQ_DMACH3 (KINETIS_IRQ_FIRST+3) /* 3: DMA channel 3 transfer complete */
+#define KINETIS_IRQ_DMACH4 (KINETIS_IRQ_FIRST+4) /* 4: DMA channel 4 transfer complete */
+#define KINETIS_IRQ_DMACH5 (KINETIS_IRQ_FIRST+5) /* 5: DMA channel 5 transfer complete */
+#define KINETIS_IRQ_DMACH6 (KINETIS_IRQ_FIRST+6) /* 6: DMA channel 6 transfer complete */
+#define KINETIS_IRQ_DMACH7 (KINETIS_IRQ_FIRST+7) /* 7: DMA channel 7 transfer complete */
+#define KINETIS_IRQ_DMACH8 (KINETIS_IRQ_FIRST+8) /* 8: DMA channel 8 transfer complete */
+#define KINETIS_IRQ_DMACH9 (KINETIS_IRQ_FIRST+9) /* 9: DMA channel 9 transfer complete */
+#define KINETIS_IRQ_DMACH10 (KINETIS_IRQ_FIRST+10) /* 10: DMA channel 10 transfer complete */
+#define KINETIS_IRQ_DMACH11 (KINETIS_IRQ_FIRST+11) /* 11: DMA channel 11 transfer complete */
+#define KINETIS_IRQ_DMACH12 (KINETIS_IRQ_FIRST+12) /* 12: DMA channel 12 transfer complete */
+#define KINETIS_IRQ_DMACH13 (KINETIS_IRQ_FIRST+13) /* 13: DMA channel 13 transfer complete */
+#define KINETIS_IRQ_DMACH14 (KINETIS_IRQ_FIRST+14) /* 14: DMA channel 14 transfer complete */
+#define KINETIS_IRQ_DMACH15 (KINETIS_IRQ_FIRST+15) /* 15: DMA channel 15 transfer complete */
+#define KINETIS_IRQ_DMAERR (KINETIS_IRQ_FIRST+16) /* 16: DMA error interrupt channels 0-15 */
+#define KINETIS_IRQ_MCM (KINETIS_IRQ_FIRST+17) /* 17: MCM Normal interrupt */
+#define KINETIS_IRQ_FLASHCC (KINETIS_IRQ_FIRST+18) /* 18: Flash memory command complete */
+#define KINETIS_IRQ_FLASHRC (KINETIS_IRQ_FIRST+19) /* 19: Flash memory read collision */
+#define KINETIS_IRQ_SMCLVD (KINETIS_IRQ_FIRST+20) /* 20: Mode Controller low-voltage
+ * detect, low-voltage warning */
+#define KINETIS_IRQ_LLWU (KINETIS_IRQ_FIRST+21) /* 21: LLWU Normal Low Leakage Wakeup */
+#define KINETIS_IRQ_WDOG (KINETIS_IRQ_FIRST+22) /* 22: Watchdog */
+#define KINETIS_IRQ_RNGB (KINETIS_IRQ_FIRST+23) /* 23: Random number generator */
+#define KINETIS_IRQ_I2C0 (KINETIS_IRQ_FIRST+24) /* 24: I2C0 */
+#define KINETIS_IRQ_I2C1 (KINETIS_IRQ_FIRST+25) /* 25: I2C1 */
+#define KINETIS_IRQ_SPI0 (KINETIS_IRQ_FIRST+26) /* 26: SPI0 all sources */
+#define KINETIS_IRQ_SPI1 (KINETIS_IRQ_FIRST+27) /* 27: SPI1 all sources */
+#define KINETIS_IRQ_SPI2 (KINETIS_IRQ_FIRST+28) /* 28: SPI2 all sources */
+#define KINETIS_IRQ_CAN0MB (KINETIS_IRQ_FIRST+29) /* 29: CAN0 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN0BO (KINETIS_IRQ_FIRST+30) /* 30: CAN0 Bus Off */
+#define KINETIS_IRQ_CAN0ERR (KINETIS_IRQ_FIRST+31) /* 31: CAN0 Error */
+#define KINETIS_IRQ_CAN0TW (KINETIS_IRQ_FIRST+32) /* 32: CAN0 Transmit Warning */
+#define KINETIS_IRQ_CAN0RW (KINETIS_IRQ_FIRST+33) /* 33: CAN0 Receive Warning */
+#define KINETIS_IRQ_CAN0WU (KINETIS_IRQ_FIRST+34) /* 34: CAN0 Wake UP */
+#define KINETIS_IRQ_RESVD35 (KINETIS_IRQ_FIRST+35) /* 35: Reserved */
+#define KINETIS_IRQ_RESVD36 (KINETIS_IRQ_FIRST+36) /* 36: Reserved */
+#define KINETIS_IRQ_CAN1MB (KINETIS_IRQ_FIRST+37) /* 37: CAN1 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN1BO (KINETIS_IRQ_FIRST+38) /* 38: CAN1 Bus Off */
+#define KINETIS_IRQ_CAN1ERR (KINETIS_IRQ_FIRST+39) /* 39: CAN1 Error */
+#define KINETIS_IRQ_CAN1TW (KINETIS_IRQ_FIRST+40) /* 40: CAN1 Transmit Warning */
+#define KINETIS_IRQ_CAN1RW (KINETIS_IRQ_FIRST+41) /* 41: CAN1 Receive Warning */
+#define KINETIS_IRQ_CAN1WU (KINETIS_IRQ_FIRST+42) /* 42: CAN1 Wake UP */
+#define KINETIS_IRQ_RESVD43 (KINETIS_IRQ_FIRST+43) /* 43: Reserved */
+#define KINETIS_IRQ_RESVD44 (KINETIS_IRQ_FIRST+44) /* 44: Reserved */
+#define KINETIS_IRQ_UART0S (KINETIS_IRQ_FIRST+45) /* 45: UART0 status */
+#define KINETIS_IRQ_UART0E (KINETIS_IRQ_FIRST+46) /* 46: UART0 error */
+#define KINETIS_IRQ_UART1S (KINETIS_IRQ_FIRST+47) /* 47: UART1 status */
+#define KINETIS_IRQ_UART1E (KINETIS_IRQ_FIRST+48) /* 48: UART1 error */
+#define KINETIS_IRQ_UART2S (KINETIS_IRQ_FIRST+49) /* 49: UART2 status */
+#define KINETIS_IRQ_UART2E (KINETIS_IRQ_FIRST+50) /* 50: UART2 error */
+#define KINETIS_IRQ_UART3S (KINETIS_IRQ_FIRST+51) /* 51: UART3 status */
+#define KINETIS_IRQ_UART3E (KINETIS_IRQ_FIRST+52) /* 52: UART3 error */
+#define KINETIS_IRQ_UART4S (KINETIS_IRQ_FIRST+53) /* 53: UART4 status */
+#define KINETIS_IRQ_UART4E (KINETIS_IRQ_FIRST+54) /* 54: UART4 error */
+#define KINETIS_IRQ_UART5S (KINETIS_IRQ_FIRST+55) /* 55: UART5 status */
+#define KINETIS_IRQ_UART5E (KINETIS_IRQ_FIRST+56) /* 56: UART5 error */
+#define KINETIS_IRQ_ADC0 (KINETIS_IRQ_FIRST+57) /* 57: ADC0 */
+#define KINETIS_IRQ_ADC1 (KINETIS_IRQ_FIRST+58) /* 58: ADC1 */
+#define KINETIS_IRQ_CMP0 (KINETIS_IRQ_FIRST+59) /* 59: CMP0 */
+#define KINETIS_IRQ_CMP1 (KINETIS_IRQ_FIRST+60) /* 60: CMP1 */
+#define KINETIS_IRQ_CMP2 (KINETIS_IRQ_FIRST+61) /* 61: CMP2 */
+#define KINETIS_IRQ_FTM0 (KINETIS_IRQ_FIRST+62) /* 62: FTM0 all sources */
+#define KINETIS_IRQ_FTM1 (KINETIS_IRQ_FIRST+63) /* 63: FTM1 all sources */
+#define KINETIS_IRQ_FTM2 (KINETIS_IRQ_FIRST+64) /* 64: FTM2 all sources */
+#define KINETIS_IRQ_CMT (KINETIS_IRQ_FIRST+65) /* 65: CMT */
+#define KINETIS_IRQ_RTC (KINETIS_IRQ_FIRST+66) /* 66: RTC alarm interrupt */
+#define KINETIS_IRQ_RESVD67 (KINETIS_IRQ_FIRST+67) /* 67: Reserved */
+#define KINETIS_IRQ_PITCH0 (KINETIS_IRQ_FIRST+68) /* 68: PIT channel 0 */
+#define KINETIS_IRQ_PITCH1 (KINETIS_IRQ_FIRST+69) /* 69: PIT channel 1 */
+#define KINETIS_IRQ_PITCH2 (KINETIS_IRQ_FIRST+70) /* 70: PIT channel 2 */
+#define KINETIS_IRQ_PITCH3 (KINETIS_IRQ_FIRST+71) /* 71: PIT channel 3 */
+#define KINETIS_IRQ_PDB (KINETIS_IRQ_FIRST+72) /* 72: PDB */
+#define KINETIS_IRQ_USBOTG (KINETIS_IRQ_FIRST+73) /* 73: USB OTG */
+#define KINETIS_IRQ_USBCD (KINETIS_IRQ_FIRST+74) /* 74: USB charger detect */
+#define KINETIS_IRQ_EMACTMR (KINETIS_IRQ_FIRST+75) /* 75: Ethernet MAC IEEE 1588 timer interrupt */
+#define KINETIS_IRQ_EMACTX (KINETIS_IRQ_FIRST+76) /* 76: Ethernet MAC transmit interrupt */
+#define KINETIS_IRQ_EMACRX (KINETIS_IRQ_FIRST+77) /* 77: Ethernet MAC receive interrupt */
+#define KINETIS_IRQ_EMACMISC (KINETIS_IRQ_FIRST+78) /* 78: Ethernet MAC error and misc interrupt */
+#define KINETIS_IRQ_I2S0 (KINETIS_IRQ_FIRST+79) /* 79: I2S0 */
+#define KINETIS_IRQ_SDHC (KINETIS_IRQ_FIRST+80) /* 80: SDHC */
+#define KINETIS_IRQ_DAC0 (KINETIS_IRQ_FIRST+81) /* 81: DAC0 */
+#define KINETIS_IRQ_DAC1 (KINETIS_IRQ_FIRST+82) /* 82: DAC1 */
+#define KINETIS_IRQ_TSI (KINETIS_IRQ_FIRST+83) /* 83: TSI all sources */
+#define KINETIS_IRQ_MCG (KINETIS_IRQ_FIRST+84) /* 84: MCG */
+#define KINETIS_IRQ_LPT (KINETIS_IRQ_FIRST+85) /* 85: Low power timer */
+#define KINETIS_IRQ_RESVD86 (KINETIS_IRQ_FIRST+86) /* 86: Reserved */
+#define KINETIS_IRQ_PORTA (KINETIS_IRQ_FIRST+87) /* 87: Pin detect port A */
+#define KINETIS_IRQ_PORTB (KINETIS_IRQ_FIRST+88) /* 88: Pin detect port B */
+#define KINETIS_IRQ_PORTC (KINETIS_IRQ_FIRST+89) /* 89: Pin detect port C */
+#define KINETIS_IRQ_PORTD (KINETIS_IRQ_FIRST+90) /* 90: Pin detect port D */
+#define KINETIS_IRQ_PORTE (KINETIS_IRQ_FIRST+91) /* 91: Pin detect port E */
+#define KINETIS_IRQ_RESVD92 (KINETIS_IRQ_FIRST+92) /* 92: Reserved */
+#define KINETIS_IRQ_RESVD93 (KINETIS_IRQ_FIRST+93) /* 93: Reserved */
+#define KINETIS_IRQ_SWI (KINETIS_IRQ_FIRST+94) /* 94: Software interrupt */
+
+#define NR_INTERRUPTS 95 /* 95 Non core IRQs*/
+#define NR_VECTORS (KINETIS_IRQ_FIRST+NR_INTERRUPTS) /* 111 vectors */
+
+/* EXTI interrupts (Do not use IRQ numbers) */
+
+#define NR_IRQS NR_VECTORS
+
+/*****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/*****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_KINETIS_KINETIS_60KIRQ_H */
diff --git a/arch/arm/include/kinetis/kinetis_k64irq.h b/arch/arm/include/kinetis/kinetis_k64irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..c97c4b25122b98494383b851541c1ddc969519f3
--- /dev/null
+++ b/arch/arm/include/kinetis/kinetis_k64irq.h
@@ -0,0 +1,190 @@
+/*****************************************************************************
+ * arch/arm/include/kinetis/kinetis_k64irq.h
+ *
+ * Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
+ */
+
+#ifndef __ARCH_ARM_INCLUDE_KINETIS_KINETIS_64KIRQ_H
+#define __ARCH_ARM_INCLUDE_KINETIS_KINETIS_64KIRQ_H
+
+/*****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+/*****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* IRQ numbers. The IRQ number corresponds vector number and hence map
+ * directly to bits in the NVIC. This does, however, waste several words of
+ * memory in the IRQ to handle mapping tables.
+ *
+ * Processor Exceptions (vectors 0-15). These common definitions can be found
+ * in the file nuttx/arch/arm/include/kinets/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ *
+ * K60 Family ****************************************************************
+ *
+ * The interrupt vectors for the following parts is defined in Freescale
+ * document K64P144M120SF5RM.pdf
+ */
+#define KINETIS_IRQ_DMACH0 (KINETIS_IRQ_FIRST+0) /* 0: DMA channel 0 transfer complete */
+#define KINETIS_IRQ_DMACH1 (KINETIS_IRQ_FIRST+1) /* 1: DMA channel 1 transfer complete */
+#define KINETIS_IRQ_DMACH2 (KINETIS_IRQ_FIRST+2) /* 2: DMA channel 2 transfer complete */
+#define KINETIS_IRQ_DMACH3 (KINETIS_IRQ_FIRST+3) /* 3: DMA channel 3 transfer complete */
+#define KINETIS_IRQ_DMACH4 (KINETIS_IRQ_FIRST+4) /* 4: DMA channel 4 transfer complete */
+#define KINETIS_IRQ_DMACH5 (KINETIS_IRQ_FIRST+5) /* 5: DMA channel 5 transfer complete */
+#define KINETIS_IRQ_DMACH6 (KINETIS_IRQ_FIRST+6) /* 6: DMA channel 6 transfer complete */
+#define KINETIS_IRQ_DMACH7 (KINETIS_IRQ_FIRST+7) /* 7: DMA channel 7 transfer complete */
+#define KINETIS_IRQ_DMACH8 (KINETIS_IRQ_FIRST+8) /* 8: DMA channel 8 transfer complete */
+#define KINETIS_IRQ_DMACH9 (KINETIS_IRQ_FIRST+9) /* 9: DMA channel 9 transfer complete */
+#define KINETIS_IRQ_DMACH10 (KINETIS_IRQ_FIRST+10) /* 10: DMA channel 10 transfer complete */
+#define KINETIS_IRQ_DMACH11 (KINETIS_IRQ_FIRST+11) /* 11: DMA channel 11 transfer complete */
+#define KINETIS_IRQ_DMACH12 (KINETIS_IRQ_FIRST+12) /* 12: DMA channel 12 transfer complete */
+#define KINETIS_IRQ_DMACH13 (KINETIS_IRQ_FIRST+13) /* 13: DMA channel 13 transfer complete */
+#define KINETIS_IRQ_DMACH14 (KINETIS_IRQ_FIRST+14) /* 14: DMA channel 14 transfer complete */
+#define KINETIS_IRQ_DMACH15 (KINETIS_IRQ_FIRST+15) /* 15: DMA channel 15 transfer complete */
+#define KINETIS_IRQ_DMAERR (KINETIS_IRQ_FIRST+16) /* 16: DMA error interrupt channels 0-15 */
+#define KINETIS_IRQ_MCM (KINETIS_IRQ_FIRST+17) /* 17: MCM Normal interrupt */
+#define KINETIS_IRQ_FLASHCC (KINETIS_IRQ_FIRST+18) /* 18: Flash memory command complete */
+#define KINETIS_IRQ_FLASHRC (KINETIS_IRQ_FIRST+19) /* 19: Flash memory read collision */
+#define KINETIS_IRQ_SMCLVD (KINETIS_IRQ_FIRST+20) /* 20: Mode Controller low-voltage
+ * detect, low-voltage warning */
+#define KINETIS_IRQ_LLWU (KINETIS_IRQ_FIRST+21) /* 21: LLWU Normal Low Leakage Wakeup */
+#define KINETIS_IRQ_WDOG (KINETIS_IRQ_FIRST+22) /* 22: Watchdog or EWM */
+#define KINETIS_IRQ_RNGB (KINETIS_IRQ_FIRST+23) /* 23: Random number generator */
+#define KINETIS_IRQ_I2C0 (KINETIS_IRQ_FIRST+24) /* 24: I2C0 */
+#define KINETIS_IRQ_I2C1 (KINETIS_IRQ_FIRST+25) /* 25: I2C1 */
+#define KINETIS_IRQ_SPI0 (KINETIS_IRQ_FIRST+26) /* 26: SPI0 all sources */
+#define KINETIS_IRQ_SPI1 (KINETIS_IRQ_FIRST+27) /* 27: SPI1 all sources */
+#define KINETIS_IRQ_I2S0 (KINETIS_IRQ_FIRST+28) /* 28: 12S0 Transmit */
+#define KINETIS_IRQ_I2S1 (KINETIS_IRQ_FIRST+29) /* 29: 12S0 Receive */
+#define KINETIS_IRQ_RESVD30 (KINETIS_IRQ_FIRST+30) /* 30: Reserved */
+#define KINETIS_IRQ_UART0S (KINETIS_IRQ_FIRST+31) /* 31: UART0 status */
+#define KINETIS_IRQ_UART0E (KINETIS_IRQ_FIRST+32) /* 32: UART0 error */
+#define KINETIS_IRQ_UART1S (KINETIS_IRQ_FIRST+33) /* 33: UART1 status */
+#define KINETIS_IRQ_UART1E (KINETIS_IRQ_FIRST+34) /* 34: UART1 error */
+#define KINETIS_IRQ_UART2S (KINETIS_IRQ_FIRST+35) /* 35: UART2 status */
+#define KINETIS_IRQ_UART2E (KINETIS_IRQ_FIRST+36) /* 36: UART2 error */
+#define KINETIS_IRQ_UART3S (KINETIS_IRQ_FIRST+37) /* 37: UART3 status */
+#define KINETIS_IRQ_UART3E (KINETIS_IRQ_FIRST+38) /* 38: UART3 error */
+#define KINETIS_IRQ_ADC0 (KINETIS_IRQ_FIRST+39) /* 39: ADC0 */
+#define KINETIS_IRQ_CMP0 (KINETIS_IRQ_FIRST+40) /* 40: CMP0 */
+#define KINETIS_IRQ_CMP1 (KINETIS_IRQ_FIRST+41) /* 41: CMP1 */
+#define KINETIS_IRQ_FTM0 (KINETIS_IRQ_FIRST+42) /* 42: FTM0 all sources */
+#define KINETIS_IRQ_FTM1 (KINETIS_IRQ_FIRST+43) /* 43: FTM1 all sources */
+#define KINETIS_IRQ_FTM2 (KINETIS_IRQ_FIRST+44) /* 44: FTM2 all sources */
+#define KINETIS_IRQ_CMT (KINETIS_IRQ_FIRST+45) /* 45: CMT */
+#define KINETIS_IRQ_RTC (KINETIS_IRQ_FIRST+46) /* 46: RTC alarm interrupt */
+#define KINETIS_IRQ_RTCS (KINETIS_IRQ_FIRST+47) /* 47: RTC seconds interrupt */
+#define KINETIS_IRQ_PITCH0 (KINETIS_IRQ_FIRST+48) /* 48: PIT channel 0 */
+#define KINETIS_IRQ_PITCH1 (KINETIS_IRQ_FIRST+49) /* 49: PIT channel 1 */
+#define KINETIS_IRQ_PITCH2 (KINETIS_IRQ_FIRST+50) /* 50: PIT channel 2 */
+#define KINETIS_IRQ_PITCH3 (KINETIS_IRQ_FIRST+51) /* 51: PIT channel 3 */
+#define KINETIS_IRQ_PDB (KINETIS_IRQ_FIRST+52) /* 52: PDB */
+#define KINETIS_IRQ_USBOTG (KINETIS_IRQ_FIRST+53) /* 53: USB OTG */
+#define KINETIS_IRQ_USBCD (KINETIS_IRQ_FIRST+54) /* 54: USB charger detect */
+#define KINETIS_IRQ_RESVD55 (KINETIS_IRQ_FIRST+55) /* 55: Reserved */
+#define KINETIS_IRQ_DAC0 (KINETIS_IRQ_FIRST+56) /* 56: DAC0 */
+#define KINETIS_IRQ_MCG (KINETIS_IRQ_FIRST+57) /* 57: MCG */
+#define KINETIS_IRQ_LPT (KINETIS_IRQ_FIRST+58) /* 58: Low power timer */
+#define KINETIS_IRQ_PORTA (KINETIS_IRQ_FIRST+59) /* 59: Pin detect port A */
+#define KINETIS_IRQ_PORTB (KINETIS_IRQ_FIRST+60) /* 60: Pin detect port B */
+#define KINETIS_IRQ_PORTC (KINETIS_IRQ_FIRST+61) /* 61: Pin detect port C */
+#define KINETIS_IRQ_PORTD (KINETIS_IRQ_FIRST+62) /* 62: Pin detect port D */
+#define KINETIS_IRQ_PORTE (KINETIS_IRQ_FIRST+63) /* 63: Pin detect port E */
+#define KINETIS_IRQ_SWI (KINETIS_IRQ_FIRST+64) /* 64: Software interrupt */
+#define KINETIS_IRQ_SPI2 (KINETIS_IRQ_FIRST+65) /* 65: SPI2 all sources */
+#define KINETIS_IRQ_UART4S (KINETIS_IRQ_FIRST+66) /* 66: UART4 status */
+#define KINETIS_IRQ_UART4E (KINETIS_IRQ_FIRST+67) /* 67: UART4 error */
+#define KINETIS_IRQ_UART5S (KINETIS_IRQ_FIRST+68) /* 68: UART5 status */
+#define KINETIS_IRQ_UART5E (KINETIS_IRQ_FIRST+69) /* 69: UART5 error */
+#define KINETIS_IRQ_CMP2 (KINETIS_IRQ_FIRST+70) /* 70: CMP2 */
+#define KINETIS_IRQ_FTM3 (KINETIS_IRQ_FIRST+71) /* 71: FTM3 all sources */
+#define KINETIS_IRQ_DAC1 (KINETIS_IRQ_FIRST+72) /* 72: DAC1 */
+#define KINETIS_IRQ_ADC1 (KINETIS_IRQ_FIRST+73) /* 73: ADC1 */
+#define KINETIS_IRQ_I2C2 (KINETIS_IRQ_FIRST+74) /* 74: I2C2 */
+#define KINETIS_IRQ_CAN0MB (KINETIS_IRQ_FIRST+75) /* 75: CAN0 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN0BO (KINETIS_IRQ_FIRST+76) /* 76: CAN0 Bus Off */
+#define KINETIS_IRQ_CAN0ERR (KINETIS_IRQ_FIRST+77) /* 77: CAN0 Error */
+#define KINETIS_IRQ_CAN0TW (KINETIS_IRQ_FIRST+78) /* 78: CAN0 Transmit Warning */
+#define KINETIS_IRQ_CAN0RW (KINETIS_IRQ_FIRST+79) /* 79: CAN0 Receive Warning */
+#define KINETIS_IRQ_CAN0WU (KINETIS_IRQ_FIRST+80) /* 80: CAN0 Wake UP */
+#define KINETIS_IRQ_SDHC (KINETIS_IRQ_FIRST+81) /* 81: SDHC */
+#define KINETIS_IRQ_EMACTMR (KINETIS_IRQ_FIRST+82) /* 82: Ethernet MAC IEEE 1588 timer interrupt */
+#define KINETIS_IRQ_EMACTX (KINETIS_IRQ_FIRST+83) /* 83: Ethernet MAC transmit interrupt */
+#define KINETIS_IRQ_EMACRX (KINETIS_IRQ_FIRST+84) /* 84: Ethernet MAC receive interrupt */
+#define KINETIS_IRQ_EMACMISC (KINETIS_IRQ_FIRST+85) /* 85: Ethernet MAC error and misc interrupt */
+
+#define NR_INTERRUPTS 86 /* 86 Non core IRQs*/
+#define NR_VECTORS (KINETIS_IRQ_FIRST+NR_INTERRUPTS) /* 102 vectors */
+
+/* EXTI interrupts (Do not use IRQ numbers) */
+
+#define NR_IRQS NR_VECTORS
+
+/*****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/*****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_KINETIS_KINETIS_64KIRQ_H */
diff --git a/arch/arm/include/kinetis/kinetis_k66irq.h b/arch/arm/include/kinetis/kinetis_k66irq.h
new file mode 100644
index 0000000000000000000000000000000000000000..bbf0903f5a627587e5880f4fefa57bd056d9bcad
--- /dev/null
+++ b/arch/arm/include/kinetis/kinetis_k66irq.h
@@ -0,0 +1,206 @@
+/*****************************************************************************
+ * arch/arm/include/kinetis/kinetis_k66irq.h
+ *
+ * Copyright (C) 2011, 2015-2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/* This file should never be included directed but, rather, only indirectly
+ * through nuttx/irq.h
+ */
+
+#ifndef __ARCH_ARM_INCLUDE_KINETIS_KINETIS_66KIRQ_H
+#define __ARCH_ARM_INCLUDE_KINETIS_KINETIS_66KIRQ_H
+
+/*****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+/*****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* IRQ numbers. The IRQ number corresponds vector number and hence map
+ * directly to bits in the NVIC. This does, however, waste several words of
+ * memory in the IRQ to handle mapping tables.
+ *
+ * Processor Exceptions (vectors 0-15). These common definitions can be found
+ * in the file nuttx/arch/arm/include/kinets/irq.h which includes this file
+ *
+ * External interrupts (vectors >= 16)
+ *
+ * K66 Family ****************************************************************
+ *
+ * The interrupt vectors for the following parts is defined in Freescale
+ * document K66P144M180SF5RMV2
+ */
+
+#define KINETIS_IRQ_DMACH0 (KINETIS_IRQ_FIRST+0) /* 0: DMA channel 0, 16 transfer complete */
+#define KINETIS_IRQ_DMACH1 (KINETIS_IRQ_FIRST+1) /* 1: DMA channel 1, 17 transfer complete */
+#define KINETIS_IRQ_DMACH2 (KINETIS_IRQ_FIRST+2) /* 2: DMA channel 2, 18 transfer complete */
+#define KINETIS_IRQ_DMACH3 (KINETIS_IRQ_FIRST+3) /* 3: DMA channel 3, 19 transfer complete */
+#define KINETIS_IRQ_DMACH4 (KINETIS_IRQ_FIRST+4) /* 4: DMA channel 4, 20 transfer complete */
+#define KINETIS_IRQ_DMACH5 (KINETIS_IRQ_FIRST+5) /* 5: DMA channel 5, 21 transfer complete */
+#define KINETIS_IRQ_DMACH6 (KINETIS_IRQ_FIRST+6) /* 6: DMA channel 6, 11 transfer complete */
+#define KINETIS_IRQ_DMACH7 (KINETIS_IRQ_FIRST+7) /* 7: DMA channel 7, 23 transfer complete */
+#define KINETIS_IRQ_DMACH8 (KINETIS_IRQ_FIRST+8) /* 8: DMA channel 8, 24 transfer complete */
+#define KINETIS_IRQ_DMACH9 (KINETIS_IRQ_FIRST+9) /* 9: DMA channel 9, 25 transfer complete */
+#define KINETIS_IRQ_DMACH10 (KINETIS_IRQ_FIRST+10) /* 10: DMA channel 10, 26 transfer complete */
+#define KINETIS_IRQ_DMACH11 (KINETIS_IRQ_FIRST+11) /* 11: DMA channel 11, 27 transfer complete */
+#define KINETIS_IRQ_DMACH12 (KINETIS_IRQ_FIRST+12) /* 12: DMA channel 12, 28 transfer complete */
+#define KINETIS_IRQ_DMACH13 (KINETIS_IRQ_FIRST+13) /* 13: DMA channel 13, 29 transfer complete */
+#define KINETIS_IRQ_DMACH14 (KINETIS_IRQ_FIRST+14) /* 14: DMA channel 14, 30 transfer complete */
+#define KINETIS_IRQ_DMACH15 (KINETIS_IRQ_FIRST+15) /* 15: DMA channel 15, 31 transfer complete */
+#define KINETIS_IRQ_DMAERR (KINETIS_IRQ_FIRST+16) /* 16: DMA error interrupt channels 0-31 */
+#define KINETIS_IRQ_MCM (KINETIS_IRQ_FIRST+17) /* 17: MCM Normal interrupt */
+#define KINETIS_IRQ_FLASHCC (KINETIS_IRQ_FIRST+18) /* 18: Flash memory command complete */
+#define KINETIS_IRQ_FLASHRC (KINETIS_IRQ_FIRST+19) /* 19: Flash memory read collision */
+#define KINETIS_IRQ_SMCLVD (KINETIS_IRQ_FIRST+20) /* 20: Mode Controller low-voltage
+ * detect, low-voltage warning */
+#define KINETIS_IRQ_LLWU (KINETIS_IRQ_FIRST+21) /* 21: LLWU Normal Low Leakage Wakeup */
+#define KINETIS_IRQ_WDOG (KINETIS_IRQ_FIRST+22) /* 22: Watchdog or EWM */
+#define KINETIS_IRQ_RNGB (KINETIS_IRQ_FIRST+23) /* 23: Random number generator */
+#define KINETIS_IRQ_I2C0 (KINETIS_IRQ_FIRST+24) /* 24: I2C0 */
+#define KINETIS_IRQ_I2C1 (KINETIS_IRQ_FIRST+25) /* 25: I2C1 */
+#define KINETIS_IRQ_SPI0 (KINETIS_IRQ_FIRST+26) /* 26: SPI0 all sources */
+#define KINETIS_IRQ_SPI1 (KINETIS_IRQ_FIRST+27) /* 27: SPI1 all sources */
+#define KINETIS_IRQ_I2S0 (KINETIS_IRQ_FIRST+28) /* 28: 12S0 Transmit */
+#define KINETIS_IRQ_I2S1 (KINETIS_IRQ_FIRST+29) /* 29: 12S0 Receive */
+#define KINETIS_IRQ_RESVD30 (KINETIS_IRQ_FIRST+30) /* 30: Reserved */
+#define KINETIS_IRQ_UART0S (KINETIS_IRQ_FIRST+31) /* 31: UART0 status */
+#define KINETIS_IRQ_UART0E (KINETIS_IRQ_FIRST+32) /* 32: UART0 error */
+#define KINETIS_IRQ_UART1S (KINETIS_IRQ_FIRST+33) /* 33: UART1 status */
+#define KINETIS_IRQ_UART1E (KINETIS_IRQ_FIRST+34) /* 34: UART1 error */
+#define KINETIS_IRQ_UART2S (KINETIS_IRQ_FIRST+35) /* 35: UART2 status */
+#define KINETIS_IRQ_UART2E (KINETIS_IRQ_FIRST+36) /* 36: UART2 error */
+#define KINETIS_IRQ_UART3S (KINETIS_IRQ_FIRST+37) /* 37: UART3 status */
+#define KINETIS_IRQ_UART3E (KINETIS_IRQ_FIRST+38) /* 38: UART3 error */
+#define KINETIS_IRQ_ADC0 (KINETIS_IRQ_FIRST+39) /* 39: ADC0 */
+#define KINETIS_IRQ_CMP0 (KINETIS_IRQ_FIRST+40) /* 40: CMP0 */
+#define KINETIS_IRQ_CMP1 (KINETIS_IRQ_FIRST+41) /* 41: CMP1 */
+#define KINETIS_IRQ_FTM0 (KINETIS_IRQ_FIRST+42) /* 42: FTM0 all sources */
+#define KINETIS_IRQ_FTM1 (KINETIS_IRQ_FIRST+43) /* 43: FTM1 all sources */
+#define KINETIS_IRQ_FTM2 (KINETIS_IRQ_FIRST+44) /* 44: FTM2 all sources */
+#define KINETIS_IRQ_CMT (KINETIS_IRQ_FIRST+45) /* 45: CMT */
+#define KINETIS_IRQ_RTC (KINETIS_IRQ_FIRST+46) /* 46: RTC alarm interrupt */
+#define KINETIS_IRQ_RTCS (KINETIS_IRQ_FIRST+47) /* 47: RTC seconds interrupt */
+#define KINETIS_IRQ_PITCH0 (KINETIS_IRQ_FIRST+48) /* 48: PIT channel 0 */
+#define KINETIS_IRQ_PITCH1 (KINETIS_IRQ_FIRST+49) /* 49: PIT channel 1 */
+#define KINETIS_IRQ_PITCH2 (KINETIS_IRQ_FIRST+50) /* 50: PIT channel 2 */
+#define KINETIS_IRQ_PITCH3 (KINETIS_IRQ_FIRST+51) /* 51: PIT channel 3 */
+#define KINETIS_IRQ_PDB (KINETIS_IRQ_FIRST+52) /* 52: PDB */
+#define KINETIS_IRQ_USBOTG (KINETIS_IRQ_FIRST+53) /* 53: USB OTG */
+#define KINETIS_IRQ_USBCD (KINETIS_IRQ_FIRST+54) /* 54: USB charger detect */
+#define KINETIS_IRQ_RESVD55 (KINETIS_IRQ_FIRST+55) /* 55: Reserved */
+#define KINETIS_IRQ_DAC0 (KINETIS_IRQ_FIRST+56) /* 56: DAC0 */
+#define KINETIS_IRQ_MCG (KINETIS_IRQ_FIRST+57) /* 57: MCG */
+#define KINETIS_IRQ_LPT (KINETIS_IRQ_FIRST+58) /* 58: Low power timer */
+#define KINETIS_IRQ_PORTA (KINETIS_IRQ_FIRST+59) /* 59: Pin detect port A */
+#define KINETIS_IRQ_PORTB (KINETIS_IRQ_FIRST+60) /* 60: Pin detect port B */
+#define KINETIS_IRQ_PORTC (KINETIS_IRQ_FIRST+61) /* 61: Pin detect port C */
+#define KINETIS_IRQ_PORTD (KINETIS_IRQ_FIRST+62) /* 62: Pin detect port D */
+#define KINETIS_IRQ_PORTE (KINETIS_IRQ_FIRST+63) /* 63: Pin detect port E */
+#define KINETIS_IRQ_SWI (KINETIS_IRQ_FIRST+64) /* 64: Software interrupt */
+#define KINETIS_IRQ_SPI2 (KINETIS_IRQ_FIRST+65) /* 65: SPI2 all sources */
+#define KINETIS_IRQ_UART4S (KINETIS_IRQ_FIRST+66) /* 66: UART4 status */
+#define KINETIS_IRQ_UART4E (KINETIS_IRQ_FIRST+67) /* 67: UART4 error */
+#define KINETIS_IRQ_RESVD68 (KINETIS_IRQ_FIRST+68) /* 68: Reserved */
+#define KINETIS_IRQ_RESVD69 (KINETIS_IRQ_FIRST+69) /* 69: Reserved */
+#define KINETIS_IRQ_CMP2 (KINETIS_IRQ_FIRST+70) /* 70: CMP2 */
+#define KINETIS_IRQ_FTM3 (KINETIS_IRQ_FIRST+71) /* 71: FTM3 all sources */
+#define KINETIS_IRQ_DAC1 (KINETIS_IRQ_FIRST+72) /* 72: DAC1 */
+#define KINETIS_IRQ_ADC1 (KINETIS_IRQ_FIRST+73) /* 73: ADC1 */
+#define KINETIS_IRQ_I2C2 (KINETIS_IRQ_FIRST+74) /* 74: I2C2 */
+#define KINETIS_IRQ_CAN0MB (KINETIS_IRQ_FIRST+75) /* 75: CAN0 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN0BO (KINETIS_IRQ_FIRST+76) /* 76: CAN0 Bus Off */
+#define KINETIS_IRQ_CAN0ERR (KINETIS_IRQ_FIRST+77) /* 77: CAN0 Error */
+#define KINETIS_IRQ_CAN0TW (KINETIS_IRQ_FIRST+78) /* 78: CAN0 Transmit Warning */
+#define KINETIS_IRQ_CAN0RW (KINETIS_IRQ_FIRST+79) /* 79: CAN0 Receive Warning */
+#define KINETIS_IRQ_CAN0WU (KINETIS_IRQ_FIRST+80) /* 80: CAN0 Wake UP */
+#define KINETIS_IRQ_SDHC (KINETIS_IRQ_FIRST+81) /* 81: SDHC */
+#define KINETIS_IRQ_EMACTMR (KINETIS_IRQ_FIRST+82) /* 82: Ethernet MAC IEEE 1588 timer interrupt */
+#define KINETIS_IRQ_EMACTX (KINETIS_IRQ_FIRST+83) /* 83: Ethernet MAC transmit interrupt */
+#define KINETIS_IRQ_EMACRX (KINETIS_IRQ_FIRST+84) /* 84: Ethernet MAC receive interrupt */
+#define KINETIS_IRQ_EMACMISC (KINETIS_IRQ_FIRST+85) /* 85: Ethernet MAC error and misc interrupt */
+#define KINETIS_IRQ_LPUART0 (KINETIS_IRQ_FIRST+86) /* 86: LPUART0 Status and error */
+#define KINETIS_IRQ_TSI0 (KINETIS_IRQ_FIRST+87) /* 87: TSI0 */
+#define KINETIS_IRQ_TPM1 (KINETIS_IRQ_FIRST+88) /* 88: TPM1 */
+#define KINETIS_IRQ_TPM2 (KINETIS_IRQ_FIRST+89) /* 89: TPM2 */
+#define KINETIS_IRQ_USBHSDCD (KINETIS_IRQ_FIRST+90) /* 90: shared by USBHS DCD & USBHS Phy modules */
+#define KINETIS_IRQ_I2C3 (KINETIS_IRQ_FIRST+91) /* 91: I2C3 */
+#define KINETIS_IRQ_CMP3 (KINETIS_IRQ_FIRST+92) /* 92: CMP3 */
+#define KINETIS_IRQ_USBHSOTG (KINETIS_IRQ_FIRST+93) /* 93: USBHS OTG*/
+#define KINETIS_IRQ_CAN1MB (KINETIS_IRQ_FIRST+94) /* 94: CAN1 OR'ed Message buffer (0-15) */
+#define KINETIS_IRQ_CAN1BO (KINETIS_IRQ_FIRST+95) /* 95: CAN1 Bus Off */
+#define KINETIS_IRQ_CAN1ERR (KINETIS_IRQ_FIRST+96) /* 96: CAN1 Error */
+#define KINETIS_IRQ_CAN1TW (KINETIS_IRQ_FIRST+97) /* 97: CAN1 Transmit Warning */
+#define KINETIS_IRQ_CAN1RW (KINETIS_IRQ_FIRST+98) /* 98: CAN1 Receive Warning */
+#define KINETIS_IRQ_CAN1WU (KINETIS_IRQ_FIRST+99) /* 99: CAN1 Wake UP */
+
+
+#define NR_INTERRUPTS 100 /* 100 Non core IRQs*/
+#define NR_VECTORS (KINETIS_IRQ_FIRST+NR_INTERRUPTS) /* 116 vectors */
+
+/* EXTI interrupts (Do not use IRQ numbers) */
+
+#define NR_IRQS NR_VECTORS
+
+/*****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/*****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+#ifdef __cplusplus
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/*****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#undef EXTERN
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif /* __ARCH_ARM_INCLUDE_KINETIS_KINETIS_66KIRQ_H */
diff --git a/arch/arm/include/spinlock.h b/arch/arm/include/spinlock.h
index fbd0e424382e7aff2c0607abe48b3b71cd4e5ec0..16079cc81a333f6fed72d3e7b80662859eb0390f 100644
--- a/arch/arm/include/spinlock.h
+++ b/arch/arm/include/spinlock.h
@@ -44,13 +44,59 @@
# include
#endif /* __ASSEMBLY__ */
+/* Include ARM architecture-specific IRQ definitions (including register
+ * save structure and up_irq_save()/up_irq_restore() functions)
+ */
+
+#if defined(CONFIG_ARCH_CORTEXA5) || defined(CONFIG_ARCH_CORTEXA8) || \
+ defined(CONFIG_ARCH_CORTEXA9)
+# include
+#elif defined(CONFIG_ARCH_CORTEXR4) || defined(CONFIG_ARCH_CORTEXR4F) || \
+ defined(CONFIG_ARCH_CORTEXR5) || defined(CONFIG_ARCH_CORTEXR5F) || \
+ defined(CONFIG_ARCH_CORTEXR7) || defined(CONFIG_ARCH_CORTEXR7F)
+# include
+#elif defined(CONFIG_ARCH_CORTEXM3) || defined(CONFIG_ARCH_CORTEXM4) || \
+ defined(CONFIG_ARCH_CORTEXM7)
+# include
+#elif defined(CONFIG_ARCH_CORTEXM0)
+# include
+#else
+# include
+#endif
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/* Spinlock states */
+
#define SP_UNLOCKED 0 /* The Un-locked state */
#define SP_LOCKED 1 /* The Locked state */
+/* Memory barriers for use with NuttX spinlock logic
+ *
+ * Data Memory Barrier (DMB) acts as a memory barrier. It ensures that all
+ * explicit memory accesses that appear in program order before the DMB
+ * instruction are observed before any explicit memory accesses that appear
+ * in program order after the DMB instruction. It does not affect the
+ * ordering of any other instructions executing on the processor
+ *
+ * dmb st - Data memory barrier. Wait for stores to complete.
+ *
+ * Data Synchronization Barrier (DSB) acts as a special kind of memory
+ * barrier. No instruction in program order after this instruction executes
+ * until this instruction completes. This instruction completes when: (1) All
+ * explicit memory accesses before this instruction complete, and (2) all
+ * Cache, Branch predictor and TLB maintenance operations before this
+ * instruction complete.
+ *
+ * dsb sy - Data syncrhonization barrier. Assures that the CPU waits until
+ * all memory accesses are complete
+ */
+
+#define SP_DSB(n) __asm__ __volatile__ ("dsb sy" : : : "memory")
+#define SP_DMB(n) __asm__ __volatile__ ("dmb st" : : : "memory")
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -82,7 +128,7 @@ typedef uint8_t spinlock_t;
* Name: up_testset
*
* Description:
- * Perform and atomic test and set operation on the provided spinlock.
+ * Perform an atomic test and set operation on the provided spinlock.
*
* This function must be provided via the architecture-specific logoic.
*
diff --git a/arch/arm/include/stm32/chip.h b/arch/arm/include/stm32/chip.h
index e476bff892e5eaa37ba673c01d64096eb2359b22..8f06701b518dfdb12230fe2021f970090f0bc5bb 100644
--- a/arch/arm/include/stm32/chip.h
+++ b/arch/arm/include/stm32/chip.h
@@ -1101,7 +1101,6 @@
* c = C (48pins) R (68 pins) V (100 pins)
* c = K (32 pins), C (48 pins), R (68 pins), V (100 pins)
* f = 6 (32KB FLASH), 8 (64KB FLASH), B (128KB FLASH), C (256KB FLASH)
- * f = 8 (64KB FLASH), B (128KB FLASH), C (256KB FLASH)
* xxx = Package, temperature range, options (ignored here)
*/
@@ -1534,7 +1533,8 @@
# define STM32_NLCD 0 /* (0) No LCD */
# define STM32_NUSBOTG 0 /* USB FS device, but no USB OTG FS/HS */
# define STM32_NGPIO 87 /* GPIOA-F */
-# define STM32_NADC 1 /* (3) 12-bit ADC1 */
+# define STM32_NADC 1 /* (1) 12-bit ADC1 */
+# define STM32_NSDADC 3 /* (3) 16-bit SDADC1-3 */
# define STM32_NDAC 2 /* (2) 12-bit DAC1-2 */
# define STM32_NCAPSENSE 0 /* (0) No capacitive sensing channels */
# define STM32_NCRC 1 /* (1) CRC calculation unit */
diff --git a/arch/arm/include/stm32l4/chip.h b/arch/arm/include/stm32l4/chip.h
index 12d718764060f81070e5897e5b8cd95a2e426531..9d0712b27682037e9224e5f89104edf1259841c9 100644
--- a/arch/arm/include/stm32l4/chip.h
+++ b/arch/arm/include/stm32l4/chip.h
@@ -77,7 +77,7 @@
# define STM32L4_NBTIM 2 /* Two basic timers, TIM6-7 */
# define STM32L4_NLPTIM 2 /* Two low-power timers, LPTIM1-2 */
# define STM32L4_NRNG 1 /* Random number generator (RNG) */
-# define STM32L4_NUART 4 /* UART 4-5 */
+# define STM32L4_NUART 2 /* UART 4-5 */
# define STM32L4_NUSART 3 /* USART 1-3 */
# define STM32L4_NLPUART 1 /* LPUART 1 */
# define STM32L4_NSPI 3 /* SPI1-3 */
diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c
index 3c798d33a0d832f98753fb80496b695c51969b03..72952e0cfaa096d8902ff03440d4ece14c70bd07 100644
--- a/arch/arm/src/armv7-a/arm_assert.c
+++ b/arch/arm/src/armv7-a/arm_assert.c
@@ -53,6 +53,7 @@
#include "up_arch.h"
#include "sched/sched.h"
+#include "irq/irq.h"
#include "up_internal.h"
/****************************************************************************
@@ -345,10 +346,21 @@ static void _up_assert(int errorcode)
if (CURRENT_REGS || this_task()->pid == 0)
{
+ /* Disable interrupts on this CPU */
+
(void)up_irq_save();
+
for (; ; )
{
+#ifdef CONFIG_SMP
+ /* Try (again) to stop activity on other CPUs */
+
+ (void)spin_trylock(&g_cpu_irqlock);
+#endif
+
#ifdef CONFIG_ARCH_LEDS
+ /* FLASH LEDs a 2Hz */
+
board_autoled_on(LED_PANIC);
up_mdelay(250);
board_autoled_off(LED_PANIC);
diff --git a/arch/arm/src/armv7-a/arm_cpuhead.S b/arch/arm/src/armv7-a/arm_cpuhead.S
index 487fee0a46bc805660b030c47d20c34976627b10..02735e36d50c39df1d5ff8a558fcf138d66df0fa 100644
--- a/arch/arm/src/armv7-a/arm_cpuhead.S
+++ b/arch/arm/src/armv7-a/arm_cpuhead.S
@@ -308,7 +308,11 @@ __cpu3_start:
orr r0, r0, #(SCTLR_RR)
#endif
-#ifndef CPU_DCACHE_DISABLE
+ /* In SMP configurations, the data cache will not be enabled until later
+ * after SMP cache coherency has been setup.
+ */
+
+#if 0 /* !defined(CPU_DCACHE_DISABLE) && !defined(CONFIG_SMP) */
/* Dcache enable
*
* SCTLR_C Bit 2: DCache enable
diff --git a/arch/arm/src/armv7-a/arm_cpupause.c b/arch/arm/src/armv7-a/arm_cpupause.c
index 585d574b06c5f6f97c42bac4a46b28b90e9b3277..ef324448e2235b774816c2973309f64676c7846d 100644
--- a/arch/arm/src/armv7-a/arm_cpupause.c
+++ b/arch/arm/src/armv7-a/arm_cpupause.c
@@ -44,6 +44,7 @@
#include
#include
#include
+#include
#include "up_internal.h"
#include "gic.h"
@@ -55,18 +56,58 @@
* Private Data
****************************************************************************/
-static spinlock_t g_cpu_wait[CONFIG_SMP_NCPUS];
-static spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS];
+/* These spinlocks are used in the SMP configuration in order to implement
+ * up_cpu_pause(). The protocol for CPUn to pause CPUm is as follows
+ *
+ * 1. The up_cpu_pause() implementation on CPUn locks both g_cpu_wait[m]
+ * and g_cpu_paused[m]. CPUn then waits spinning on g_cpu_paused[m].
+ * 2. CPUm receives the interrupt it (1) unlocks g_cpu_paused[m] and
+ * (2) locks g_cpu_wait[m]. The first unblocks CPUn and the second
+ * blocks CPUm in the interrupt handler.
+ *
+ * When CPUm resumes, CPUn unlocks g_cpu_wait[m] and the interrupt handler
+ * on CPUm continues. CPUm must, of course, also then unlock g_cpu_wait[m]
+ * so that it will be ready for the next pause operation.
+ */
+
+static volatile spinlock_t g_cpu_wait[CONFIG_SMP_NCPUS] SP_SECTION;
+static volatile spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS] SP_SECTION;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Name: arm_pause_handler
+ * Name: up_cpu_pausereq
*
* Description:
- * This is the handler for SGI2. It performs the following operations:
+ * Return true if a pause request is pending for this CPU.
+ *
+ * Input Parameters:
+ * cpu - The index of the CPU to be queried
+ *
+ * Returned Value:
+ * true = a pause request is pending.
+ * false = no pasue request is pending.
+ *
+ ****************************************************************************/
+
+bool up_cpu_pausereq(int cpu)
+{
+ return spin_islocked(&g_cpu_paused[cpu]);
+}
+
+/****************************************************************************
+ * Name: up_cpu_paused
+ *
+ * Description:
+ * Handle a pause request from another CPU. Normally, this logic is
+ * executed from interrupt handling logic within the architecture-specific
+ * However, it is sometimes necessary necessary to perform the pending
+ * pause operation in other contexts where the interrupt cannot be taken
+ * in order to avoid deadlocks.
+ *
+ * This function performs the following operations:
*
* 1. It saves the current task state at the head of the current assigned
* task list.
@@ -75,49 +116,107 @@ static spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS];
* head of the ready to run list.
*
* Input Parameters:
- * Standard interrupt handling
+ * cpu - The index of the CPU to be paused
*
* Returned Value:
- * Zero on success; a negated errno value on failure.
+ * On success, OK is returned. Otherwise, a negated errno value indicating
+ * the nature of the failure is returned.
*
****************************************************************************/
-int arm_pause_handler(int irq, FAR void *context)
+int up_cpu_paused(int cpu)
{
FAR struct tcb_s *tcb = this_task();
- int cpu = up_cpu_index();
/* Update scheduler parameters */
sched_suspend_scheduler(tcb);
- /* Save the current context at CURRENT_REGS into the TCB at the head of the
- * assigned task list for this CPU.
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+ /* Notify that we are paused */
+
+ sched_note_cpu_paused(tcb);
+#endif
+
+ /* Save the current context at CURRENT_REGS into the TCB at the head
+ * of the assigned task list for this CPU.
*/
up_savestate(tcb->xcp.regs);
- /* Wait for the spinlock to be released */
+ /* Release the g_cpu_puased spinlock to synchronize with the
+ * requesting CPU.
+ */
spin_unlock(&g_cpu_paused[cpu]);
+
+ /* Wait for the spinlock to be released. The requesting CPU will release
+ * the spinlcok when the CPU is resumed.
+ */
+
spin_lock(&g_cpu_wait[cpu]);
- /* Restore the exception context of the tcb at the (new) head of the
- * assigned task list.
+ /* This CPU has been resumed. Restore the exception context of the TCB at
+ * the (new) head of the assigned task list.
*/
tcb = this_task();
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+ /* Notify that we have resumed */
+
+ sched_note_cpu_resumed(tcb);
+#endif
+
/* Reset scheduler parameters */
sched_resume_scheduler(tcb);
- /* Then switch contexts. Any necessary address environment changes will
- * be made when the interrupt returns.
+ /* Then switch contexts. Any necessary address environment changes
+ * will be made when the interrupt returns.
*/
up_restorestate(tcb->xcp.regs);
spin_unlock(&g_cpu_wait[cpu]);
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: arm_pause_handler
+ *
+ * Description:
+ * This is the handler for SGI2. It performs the following operations:
+ *
+ * 1. It saves the current task state at the head of the current assigned
+ * task list.
+ * 2. It waits on a spinlock, then
+ * 3. Returns from interrupt, restoring the state of the new task at the
+ * head of the ready to run list.
+ *
+ * Input Parameters:
+ * Standard interrupt handling
+ *
+ * Returned Value:
+ * Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+int arm_pause_handler(int irq, FAR void *context)
+{
+ int cpu = this_cpu();
+
+ /* Check for false alarms. Such false could occur as a consequence of
+ * some deadlock breaking logic that might have already serviced the SG2
+ * interrupt by calling up_cpu_paused(). If the pause event has already
+ * been processed then g_cpu_paused[cpu] will not be locked.
+ */
+
+ if (spin_islocked(&g_cpu_paused[cpu]))
+ {
+ return up_cpu_paused(cpu);
+ }
+
return OK;
}
@@ -134,7 +233,7 @@ int arm_pause_handler(int irq, FAR void *context)
* CPU.
*
* Input Parameters:
- * cpu - The index of the CPU to be stopped/
+ * cpu - The index of the CPU to be stopped
*
* Returned Value:
* Zero on success; a negated errno value on failure.
@@ -145,6 +244,12 @@ int up_cpu_pause(int cpu)
{
int ret;
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+ /* Notify of the pause event */
+
+ sched_note_cpu_pause(this_task(), cpu);
+#endif
+
DEBUGASSERT(cpu >= 0 && cpu < CONFIG_SMP_NCPUS && cpu != this_cpu());
/* Take the both spinlocks. The g_cpu_wait spinlock will prevent the SGI2
@@ -208,6 +313,12 @@ int up_cpu_pause(int cpu)
int up_cpu_resume(int cpu)
{
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+ /* Notify of the resume event */
+
+ sched_note_cpu_resume(this_task(), cpu);
+#endif
+
DEBUGASSERT(cpu >= 0 && cpu < CONFIG_SMP_NCPUS && cpu != this_cpu());
/* Release the spinlock. Releasing the spinlock will cause the SGI2
diff --git a/arch/arm/src/armv7-a/arm_cpustart.c b/arch/arm/src/armv7-a/arm_cpustart.c
index 88906a717ded5441a01f73310458fff480089ffc..d63c035db68f1d5c7af0e0d0ad07d7dc1a59c55e 100644
--- a/arch/arm/src/armv7-a/arm_cpustart.c
+++ b/arch/arm/src/armv7-a/arm_cpustart.c
@@ -43,10 +43,11 @@
#include
#include
+#include
#include "up_internal.h"
-#include "gic.h"
#include "cp15_cacheops.h"
+#include "gic.h"
#include "sched/sched.h"
#ifdef CONFIG_SMP
@@ -104,13 +105,18 @@ static inline void arm_registerdump(FAR struct tcb_s *tcb)
int arm_start_handler(int irq, FAR void *context)
{
- FAR struct tcb_s *tcb;
+ FAR struct tcb_s *tcb = this_task();
+
+ sinfo("CPU%d Started\n", this_cpu());
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+ /* Notify that this CPU has started */
- sinfo("CPU%d Started\n", up_cpu_index());
+ sched_note_cpu_started(tcb);
+#endif
/* Reset scheduler parameters */
- tcb = this_task();
sched_resume_scheduler(tcb);
/* Dump registers so that we can see what is going to happen on return */
@@ -159,6 +165,12 @@ int up_cpu_start(int cpu)
DEBUGASSERT(cpu >= 0 && cpu < CONFIG_SMP_NCPUS && cpu != this_cpu());
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+ /* Notify of the start event */
+
+ sched_note_cpu_start(this_task(), cpu);
+#endif
+
/* Make the content of CPU0 L1 cache has been written to coherent L2 */
cp15_clean_dcache(CONFIG_RAM_START, CONFIG_RAM_END - 1);
diff --git a/arch/arm/src/armv7-a/arm_doirq.c b/arch/arm/src/armv7-a/arm_doirq.c
index b3d98151c0bcb262f2b0e10901a684e78fb80544..fa3e104582383162b874619a58dfd86b165aed78 100644
--- a/arch/arm/src/armv7-a/arm_doirq.c
+++ b/arch/arm/src/armv7-a/arm_doirq.c
@@ -40,10 +40,10 @@
#include
#include
-#include
-#include
#include
+#include
+#include
#include
#include
@@ -51,21 +51,40 @@
#include "up_internal.h"
#include "group/group.h"
+#include "gic.h"
/****************************************************************************
- * Public Functions
+ * Private Data
****************************************************************************/
-uint32_t *arm_doirq(int irq, uint32_t *regs)
-{
- board_autoled_on(LED_INIRQ);
-#ifdef CONFIG_SUPPRESS_INTERRUPTS
- PANIC();
+/* A bit set of pending, non-maskable SGI interrupts, on bit set for each
+ * supported CPU.
+ */
+
+#ifdef CONFIG_ARMV7A_HAVE_GICv2
+#ifdef CONFIG_SMP
+static uint16_t g_sgi_pending[CONFIG_SMP_NCPUS];
#else
- /* Nested interrupts are not supported */
+static uint16_t g_sgi_pending[1];
+#endif
+#endif
- DEBUGASSERT(CURRENT_REGS == NULL);
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: _arm_doirq
+ *
+ * Description:
+ * Receives the one decoded interrupt and dispatches control to the
+ * attached interrupt handler.
+ *
+ ****************************************************************************/
+#ifndef CONFIG_SUPPRESS_INTERRUPTS
+static inline uint32_t *_arm_doirq(int irq, uint32_t *regs)
+{
/* Current regs non-zero indicates that we are processing an interrupt;
* CURRENT_REGS is also used to manage interrupt level context switches.
*/
@@ -110,8 +129,131 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
regs = (uint32_t *)CURRENT_REGS;
CURRENT_REGS = NULL;
+
+ return regs;
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_doirq
+ *
+ * Description:
+ * Receives the decoded GIC interrupt information and dispatches control
+ * to the attached interrupt handler. There are two versions:
+ *
+ * 1) For the simple case where all interrupts are maskable. In that
+ * simple case, arm_doirq() is simply a wrapper for the inlined
+ * _arm_do_irq() that does the real work.
+ *
+ * 2) With the GICv2, there are 16 non-maskable software generated
+ * interrupts (SGIs) that also come through arm_doirq(). In that case,
+ * we must avoid nesting interrupt handling and serial the processing.
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_ARMV7A_HAVE_GICv2
+uint32_t *arm_doirq(int irq, uint32_t *regs)
+{
+ board_autoled_on(LED_INIRQ);
+#ifdef CONFIG_SUPPRESS_INTERRUPTS
+ PANIC();
+#else
+ /* Nested interrupts are not supported */
+
+ DEBUGASSERT(CURRENT_REGS == NULL);
+
+ /* Dispatch the interrupt to its attached handler */
+
+ regs = _arm_doirq(irq, regs);
+#endif
+
+ board_autoled_off(LED_INIRQ);
+ return regs;
+}
+#endif
+
+#ifdef CONFIG_ARMV7A_HAVE_GICv2
+uint32_t *arm_doirq(int irq, uint32_t *regs)
+{
+#ifndef CONFIG_SUPPRESS_INTERRUPTS
+ uint32_t bit;
+ int cpu;
+ int i;
+#endif
+
+ board_autoled_on(LED_INIRQ);
+#ifdef CONFIG_SUPPRESS_INTERRUPTS
+ PANIC();
+
+#else
+ /* Get the CPU processing the interrupt */
+
+#ifdef CONFIG_SMP
+ cpu = up_cpu_index();
+#else
+ cpu = 0;
+#endif
+
+ /* Non-zero CURRENT_REGS indicates that we are already processing an
+ * interrupt. This could be a normal event for the case of the GICv2;
+ * Software generated interrupts are non-maskable.
+ *
+ * REVISIT: There is no support for nested SGIs! That will cause an
+ * assertion below. There is also no protection for concurrent access
+ * to g_sgi_pending for that case.
+ */
+
+ if (CURRENT_REGS != NULL)
+ {
+ int ndx = irq - GIC_IRQ_SGI0;
+ bit = (1 << (ndx));
+
+ /* Only an SGI should cause this event. We also cannot support
+ * multiple pending SGI interrupts.
+ */
+
+ ASSERT((unsigned int)irq <= GIC_IRQ_SGI15 &&
+ (g_sgi_pending[cpu] & bit) == 0);
+
+ /* Mare the SGI as pending and return immediately */
+
+ sinfo("SGI%d pending\n", ndx);
+ g_sgi_pending[cpu] |= bit;
+ return regs;
+ }
+
+ /* Dispatch the interrupt to its attached handler */
+
+ regs = _arm_doirq(irq, regs);
+
+ /* Then loop dispatching any pending SGI interrupts that occcurred during
+ * processing of the interrupts.
+ */
+
+ for (i = 0; i < 16 && g_sgi_pending[cpu] != 0; i++)
+ {
+ /* Check if this SGI is pending */
+
+ bit = (1 << i);
+ if ((g_sgi_pending[cpu] & bit) != 0)
+ {
+ /* Clear the pending bit */
+
+ g_sgi_pending[cpu] &= ~bit;
+
+ /* And dispatch the SGI */
+
+ sinfo("Dispatching pending SGI%d\n", i + GIC_IRQ_SGI0);
+ regs = _arm_doirq(i + GIC_IRQ_SGI0, regs);
+ }
+ }
#endif
board_autoled_off(LED_INIRQ);
return regs;
}
+#endif
diff --git a/arch/arm/src/armv7-a/arm_gicv2.c b/arch/arm/src/armv7-a/arm_gicv2.c
index e99eb540fdef6e55cd24f9c9cd30aeae5f380630..dce0b621ed98f1096d1e55d3df108739daf3aa19 100644
--- a/arch/arm/src/armv7-a/arm_gicv2.c
+++ b/arch/arm/src/armv7-a/arm_gicv2.c
@@ -122,7 +122,7 @@ void arm_gic0_initialize(void)
}
#ifdef CONFIG_SMP
- /* Attach SGI interrupt handlers */
+ /* Attach SGI interrupt handlers. This attaches the handler for all CPUs. */
DEBUGVERIFY(irq_attach(GIC_IRQ_SGI1, arm_start_handler));
DEBUGVERIFY(irq_attach(GIC_IRQ_SGI2, arm_pause_handler));
@@ -574,5 +574,4 @@ int arm_gic_irq_trigger(int irq, bool edge)
return -EINVAL;
}
-
#endif /* CONFIG_ARMV7A_HAVE_GICv2 */
diff --git a/arch/arm/src/armv7-a/arm_head.S b/arch/arm/src/armv7-a/arm_head.S
index c98ab30719d5774314346cea3c4ab0ece6007022..27c2a5b4dcfb628db63ee069385070ef01a39735 100644
--- a/arch/arm/src/armv7-a/arm_head.S
+++ b/arch/arm/src/armv7-a/arm_head.S
@@ -450,7 +450,11 @@ __start:
orr r0, r0, #(SCTLR_RR)
#endif
-#ifndef CPU_DCACHE_DISABLE
+ /* In SMP configurations, the data cache will not be enabled until later
+ * after SMP cache coherency has been setup.
+ */
+
+#if !defined(CPU_DCACHE_DISABLE) && !defined(CONFIG_SMP)
/* Dcache enable
*
* SCTLR_C Bit 2: DCache enable
@@ -638,7 +642,7 @@ __start:
#endif
/* Perform early C-level, platform-specific initialization. Logic
- * within arm_boot() must configure SDRAM and call arm_ram_initailize.
+ * within arm_boot() must configure SDRAM and call arm_data_initialize().
*/
bl arm_boot
diff --git a/arch/arm/src/armv7-a/arm_pghead.S b/arch/arm/src/armv7-a/arm_pghead.S
index 1a546c813d4007ea2105fb0ae544df94dc469956..1dda0acdd929ba56db8fa450e68d781300c084df 100644
--- a/arch/arm/src/armv7-a/arm_pghead.S
+++ b/arch/arm/src/armv7-a/arm_pghead.S
@@ -434,7 +434,11 @@ __start:
orr r0, r0, #(SCTLR_RR)
#endif
-#ifndef CPU_DCACHE_DISABLE
+ /* In SMP configurations, the data cache will not be enabled until later
+ * after SMP cache coherency has been setup.
+ */
+
+#if !defined(CPU_DCACHE_DISABLE) && !defined(CONFIG_SMP)
/* Dcache enable
*
* SCTLR_C Bit 2: DCache enable
@@ -670,7 +674,7 @@ __start:
#endif
/* Perform early C-level, platform-specific initialization. Logic
- * within arm_boot() must configure SDRAM and call arm_ram_initailize.
+ * within arm_boot() must configure SDRAM and call arm_data_initialize().
*/
bl arm_boot
diff --git a/arch/arm/src/armv7-a/arm_schedulesigaction.c b/arch/arm/src/armv7-a/arm_schedulesigaction.c
index 89df348ba039c8942f4c76ac3692b48be245482f..c448a9a8a4dc6448b30004fd4bc8ee1a8d2bd627 100644
--- a/arch/arm/src/armv7-a/arm_schedulesigaction.c
+++ b/arch/arm/src/armv7-a/arm_schedulesigaction.c
@@ -153,6 +153,18 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS[REG_PC] = (uint32_t)up_sigdeliver;
CURRENT_REGS[REG_CPSR] = (PSR_MODE_SVC | PSR_I_BIT | PSR_F_BIT);
+#ifdef CONFIG_SMP
+ /* In an SMP configuration, the interrupt disable logic also
+ * involves spinlocks that are configured per the TCB irqcount
+ * field. This is logically equivalent to enter_critical_section().
+ * The matching call to leave_critical_section() will be
+ * performed in up_sigdeliver().
+ */
+
+ DEBUGASSERT(tcb->irqcount < INT16_MAX);
+ tcb->irqcount++;
+#endif
+
/* And make sure that the saved context in the TCB is the same
* as the interrupt return context.
*/
@@ -183,6 +195,19 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs[REG_PC] = (uint32_t)up_sigdeliver;
tcb->xcp.regs[REG_CPSR] = (PSR_MODE_SVC | PSR_I_BIT | PSR_F_BIT);
+
+#ifdef CONFIG_SMP
+ /* In an SMP configuration, the interrupt disable logic also
+ * involves spinlocks that are configured per the TCB irqcount
+ * field. This is logically equivalent to enter_critical_section();
+ * The matching leave_critical_section will be performed in
+ * The matching call to leave_critical_section() will be performed
+ * in up_sigdeliver().
+ */
+
+ DEBUGASSERT(tcb->irqcount < INT16_MAX);
+ tcb->irqcount++;
+#endif
}
}
diff --git a/arch/arm/src/armv7-a/arm_scu.c b/arch/arm/src/armv7-a/arm_scu.c
new file mode 100644
index 0000000000000000000000000000000000000000..eedf179e73161438d738872ce2af869d634cd3b5
--- /dev/null
+++ b/arch/arm/src/armv7-a/arm_scu.c
@@ -0,0 +1,227 @@
+/****************************************************************************
+ * arch/arm/src/armv7-a/arm_scu.c
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+
+#include "up_arch.h"
+#include "cp15_cacheops.h"
+#include "sctlr.h"
+#include "cache.h"
+#include "scu.h"
+
+#ifdef CONFIG_SMP
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_get_sctlr
+ *
+ * Description:
+ * Get the contents of the SCTLR register
+ *
+ ****************************************************************************/
+
+static inline uint32_t arm_get_sctlr(void)
+{
+ uint32_t sctlr;
+
+ __asm__ __volatile__
+ (
+ "\tmrc p15, 0, %0, c1, c0, 0\n" /* Read SCTLR */
+ : "=r"(sctlr)
+ :
+ :
+ );
+
+ return sctlr;
+}
+
+/****************************************************************************
+ * Name: arm_set_sctlr
+ *
+ * Description:
+ * Set the contents of the SCTLR register
+ *
+ ****************************************************************************/
+
+static inline void arm_set_sctlr(uint32_t sctlr)
+{
+ __asm__ __volatile__
+ (
+ "\tmcr p15, 0, %0, c1, c0, 0\n" /* Write SCTLR */
+ :
+ : "r"(sctlr)
+ :
+ );
+}
+
+/****************************************************************************
+ * Name: arm_get_actlr
+ *
+ * Description:
+ * Get the contents of the ACTLR register
+ *
+ ****************************************************************************/
+
+static inline uint32_t arm_get_actlr(void)
+{
+ uint32_t actlr;
+
+ __asm__ __volatile__
+ (
+ "\tmrc p15, 0, %0, c1, c0, 1\n" /* Read ACTLR */
+ : "=r"(actlr)
+ :
+ :
+ );
+
+ return actlr;
+}
+
+/****************************************************************************
+ * Name: arm_set_actlr
+ *
+ * Description:
+ * Set the contents of the ACTLR register
+ *
+ ****************************************************************************/
+
+static inline void arm_set_actlr(uint32_t actlr)
+{
+ __asm__ __volatile__
+ (
+ "\tmcr p15, 0, %0, c1, c0, 1\n" /* Write ACTLR */
+ :
+ : "r"(actlr)
+ :
+ );
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_enable_smp
+ *
+ * Description:
+ * Enable the SCU and make certain that current CPU is participating in
+ * the SMP cache coherency.
+ *
+ * Assumption:
+ * Called early in the CPU start-up. No special critical sections are
+ * needed if only CPU-private registers are modified.
+ *
+ ****************************************************************************/
+
+void arm_enable_smp(int cpu)
+{
+ uint32_t regval;
+
+ /* Handle actions unique to CPU0 which comes up first */
+
+ if (cpu == 0)
+ {
+ /* Invalidate the SCU duplicate tags for all processors */
+
+ putreg32((SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU0_SHIFT) |
+ (SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU1_SHIFT) |
+ (SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU2_SHIFT) |
+ (SCU_INVALIDATE_ALL_WAYS << SCU_INVALIDATE_CPU3_SHIFT),
+ SCU_INVALIDATE);
+
+ /* Invalidate CPUn L1 data cache so that is will we be reloaded from
+ * coherent L2.
+ */
+
+ cp15_invalidate_dcache_all();
+ ARM_DSB();
+
+ /* Invalidate the L2C-310 -- Missing logic. */
+
+ /* Enable the SCU */
+
+ regval = getreg32(SCU_CTRL);
+ regval |= SCU_CTRL_ENABLE;
+ putreg32(regval, SCU_CTRL);
+ }
+
+ /* Actions for other CPUs */
+
+ else
+ {
+ /* Invalidate CPUn L1 data cache so that is will we be reloaded from
+ * coherent L2.
+ */
+
+ cp15_invalidate_dcache_all();
+ ARM_DSB();
+
+ /* Wait for the SCU to be enabled by the primary processor -- should
+ * not be necessary.
+ */
+ }
+
+ /* Enable the data cache, set the SMP mode with ACTLR.SMP=1.
+ *
+ * SMP - Sgnals if the Cortex-A9 processor is taking part in coherency
+ * or not.
+ *
+ * Cortex-A9 also needs ACTLR.FW=1
+ *
+ * FW - Cache and TLB maintenance broadcast.
+ */
+
+ regval = arm_get_actlr();
+ regval |= ACTLR_SMP;
+#ifdef CONFIG_ARCH_CORTEXA9
+ regval |= ACTLR_FW;
+#endif
+ arm_set_actlr(regval);
+
+ regval = arm_get_sctlr();
+ regval |= SCTLR_C;
+ arm_set_sctlr(regval);
+}
+
+#endif
diff --git a/arch/arm/src/armv7-a/arm_sigdeliver.c b/arch/arm/src/armv7-a/arm_sigdeliver.c
index be720a464c3550d648b6c4ec52f9de108bc54ba8..5d89583282032ac543a151682ff517f94b31b212 100644
--- a/arch/arm/src/armv7-a/arm_sigdeliver.c
+++ b/arch/arm/src/armv7-a/arm_sigdeliver.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/armv7-a/arm_sigdeliver.c
*
- * Copyright (C) 2013, 2015 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2013, 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without
@@ -103,18 +103,27 @@ void up_sigdeliver(void)
/* Then restore the task interrupt state */
- up_irq_restore(regs[REG_CPSR]);
+ leave_critical_section(regs[REG_CPSR]);
- /* Deliver the signals */
+ /* Deliver the signal */
sigdeliver(rtcb);
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
* errno that is needed by the user logic (it is probably EINTR).
+ *
+ * REVISIT: In SMP mode up_irq_save() probably only disables interrupts
+ * on the local CPU. We do not want to call enter_critical_section()
+ * here, however, because we don't want this state to stick after the
+ * call to up_fullcontextrestore().
+ *
+ * I would prefer that all interrupts are disabled when
+ * up_fullcontextrestore() is called, but that may not be necessary.
*/
sinfo("Resuming\n");
+
(void)up_irq_save();
rtcb->pterrno = saved_errno;
diff --git a/arch/arm/src/armv7-a/arm_testset.S b/arch/arm/src/armv7-a/arm_testset.S
index 6d6cdcd4acb78859f48730a62024408df1df53de..e89cbb3adc554a1cab2e3208a1bf4954379abbcb 100644
--- a/arch/arm/src/armv7-a/arm_testset.S
+++ b/arch/arm/src/armv7-a/arm_testset.S
@@ -70,7 +70,7 @@
* Name: up_testset
*
* Description:
- * Perform and atomic test and set operation on the provided spinlock.
+ * Perform an atomic test and set operation on the provided spinlock.
*
* This function must be provided via the architecture-specific logoic.
*
diff --git a/arch/arm/src/armv7-a/arm_vectors.S b/arch/arm/src/armv7-a/arm_vectors.S
index 33d1f8fc550dc6e49d4e7623e2a66892de87837d..8a76e000b563ec9c1c9e6a19322ce8e0af7ec0ff 100644
--- a/arch/arm/src/armv7-a/arm_vectors.S
+++ b/arch/arm/src/armv7-a/arm_vectors.S
@@ -64,6 +64,10 @@ g_fiqtmp:
.word 0 /* Saved lr */
.word 0 /* Saved spsr */
#endif
+#if CONFIG_ARCH_INTERRUPTSTACK > 3 && defined(CONFIG_ARMV7A_HAVE_GICv2)
+g_nestlevel:
+ .word 0 /* Interrupt nesting level */
+#endif
/************************************************************************************
* Private Functions
@@ -172,13 +176,53 @@ arm_vectorirq:
mov r0, sp /* Get r0=xcp */
#if CONFIG_ARCH_INTERRUPTSTACK > 3
+#ifdef CONFIG_ARMV7A_HAVE_GICv2
+ /* We will switch to the interrupt stack, UNLESS we are processing a
+ * nested interrupt in which case we are already using the interrupt
+ * stack. SGI interrupts may be nested because they are non-maskable.
+ */
+
+ ldr r5, .Lirqnestlevel /* r1=Points to interrupt nesting level */
+ ldr r1, [r5] /* Get r1= nesting level */
+ add r1, r1, #1 /* Increment nesting level */
+ str r1, [r5] /* Save r1= nesting level */
+
+ cmp r1, #1 /* r1>1 if nested */
+ bgt .Lintnested /* Use current SP if nested */
+#endif
+
+ /* Call arm_decodeirq() on the interrupt stack */
+
ldr sp, .Lirqstackbase /* SP = interrupt stack base */
str r0, [sp] /* Save the user stack pointer */
mov r4, sp /* Save the SP in a preserved register */
bic sp, sp, #7 /* Force 8-byte alignment */
bl arm_decodeirq /* Call the handler */
ldr sp, [r4] /* Restore the user stack pointer */
+
+#ifdef CONFIG_ARMV7A_HAVE_GICv2
+ b .Lintreturn
+
+ /* Call arm_decodeirq() on whatever stack is in place */
+
+.Lintnested:
+ mov r4, sp /* Save the SP in a preserved register */
+ bic sp, sp, #7 /* Force 8-byte alignment */
+ bl arm_decodeirq /* Call the handler */
+ mov sp, r4 /* Restore the possibly unaligned stack pointer */
+
+ /* Decrement the nesting level (r5 should be preserved) */
+
+.Lintreturn:
+ ldr r1, [r5] /* Get r1= nesting level */
+ cmp r1, #0 /* A sanity check*/
+ subgt r1, r1, #1 /* Decrement nesting level */
+ strgt r1, [r5] /* Save r1= nesting level */
+#endif
+
#else
+ /* Call arm_decodeirq() on the user stack */
+
mov r4, sp /* Save the SP in a preserved register */
bic sp, sp, #7 /* Force 8-byte alignment */
bl arm_decodeirq /* Call the handler */
@@ -227,6 +271,10 @@ arm_vectorirq:
#if CONFIG_ARCH_INTERRUPTSTACK > 3
.Lirqstackbase:
.word g_intstackbase
+#ifdef CONFIG_ARMV7A_HAVE_GICv2
+.Lirqnestlevel:
+ .word g_nestlevel
+#endif
#endif
.size arm_vectorirq, . - arm_vectorirq
.align 5
@@ -937,7 +985,7 @@ arm_vectorfiq:
.word g_fiqtmp
#if CONFIG_ARCH_INTERRUPTSTACK > 3
.Lfiqstackbase:
- .word g_intstackbase
+ .word g_fiqstackbase
#endif
#else
@@ -965,5 +1013,21 @@ g_intstackbase:
.size g_intstackbase, 4
.size g_intstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3)
+ .globl g_fiqstackalloc
+ .type g_fiqstackalloc, object
+ .globl g_fiqstackbase
+ .type g_fiqstackbase, object
+
+/************************************************************************************
+ * Name: g_fiqstackalloc/g_fiqstackbase
+ ************************************************************************************/
+
+g_fiqstackalloc:
+ .skip ((CONFIG_ARCH_INTERRUPTSTACK & ~3) - 4)
+g_fiqstackbase:
+ .skip 4
+ .size g_fiqstackbase, 4
+ .size g_fiqstackalloc, (CONFIG_ARCH_INTERRUPTSTACK & ~3)
+
#endif /* CONFIG_ARCH_INTERRUPTSTACK > 3 */
.end
diff --git a/arch/arm/src/armv7-a/cache.h b/arch/arm/src/armv7-a/cache.h
index dda36271e2d865a5e2533e9201feea5952fc9845..c9af0611f7b31d4a16fac7ca43b299f68f08c283 100644
--- a/arch/arm/src/armv7-a/cache.h
+++ b/arch/arm/src/armv7-a/cache.h
@@ -50,6 +50,16 @@
* Pre-processor Definitions
************************************************************************************/
+/* Intrinsics are used in these inline functions */
+
+#define arm_isb(n) __asm__ __volatile__ ("isb " #n : : : "memory")
+#define arm_dsb(n) __asm__ __volatile__ ("dsb " #n : : : "memory")
+#define arm_dmb(n) __asm__ __volatile__ ("dmb " #n : : : "memory")
+
+#define ARM_DSB() arm_dsb(15)
+#define ARM_ISB() arm_isb(15)
+#define ARM_DMB() arm_dmb(15)
+
/************************************************************************************
* Inline Functions
************************************************************************************/
diff --git a/arch/arm/src/armv7-a/mmu.h b/arch/arm/src/armv7-a/mmu.h
index 9ce8280b73232ba793c8a0d11ed0e958f41aeb77..c6338d33378b30395f574085ac6aac80ed98a4f6 100644
--- a/arch/arm/src/armv7-a/mmu.h
+++ b/arch/arm/src/armv7-a/mmu.h
@@ -513,7 +513,6 @@
* NMRR registers. For the simple case where TEX[2:0] = 0b000, the control
* is as follows:
*
- *
* MEMORY INNER OUTER OUTER SHAREABLE
* C B TYPE CACHEABILITY CACHEABILITY ATTRIBUTE
* - - ---------- ------------- ------------ -----------------
@@ -602,7 +601,6 @@
#define MMU_L2_PGTABFLAGS (PTE_TYPE_SMALL | PTE_WRITE_THROUGH | PTE_AP_RW1)
#define MMU_L1_VECTORFLAGS (PMD_TYPE_PTE | PMD_PTE_PXN | PMD_PTE_DOM(0))
-
#define MMU_L2_VECTRWFLAGS (PTE_TYPE_SMALL | PTE_WRITE_THROUGH | PTE_AP_RW1)
#define MMU_L2_VECTROFLAGS (PTE_TYPE_SMALL | PTE_WRITE_THROUGH | PTE_AP_R1)
#define MMU_L2_VECTORFLAGS MMU_L2_VECTRWFLAGS
@@ -1424,6 +1422,28 @@ void mmu_l1_restore(uintptr_t vaddr, uint32_t l1entry);
# define mmu_l1_clrentry(v) mmu_l1_restore(v,0)
#endif
+/****************************************************************************
+ * Name: mmu_l2_setentry
+ *
+ * Description:
+ * Set one small (4096B) entry in a level2 translation table.
+ *
+ * Input Parameters:
+ * l2vaddr - the virtual address of the beginning of the L2 translation
+ * table.
+ * paddr - The physical address to be mapped. Must be aligned to a 4KB
+ * address boundary
+ * vaddr - The virtual address to be mapped. Must be aligned to a 4KB
+ * address boundary
+ * mmuflags - The MMU flags to use in the mapping.
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_ARCH_ROMPGTABLE
+void mmu_l2_setentry(uint32_t l2vaddr, uint32_t paddr, uint32_t vaddr,
+ uint32_t mmuflags);
+#endif
+
/************************************************************************************
* Name: mmu_l1_map_region
*
diff --git a/arch/arm/src/armv7-a/scu.h b/arch/arm/src/armv7-a/scu.h
new file mode 100644
index 0000000000000000000000000000000000000000..a84fb0cc4f84bdaa007b4ee61edd1bd295cf947f
--- /dev/null
+++ b/arch/arm/src/armv7-a/scu.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+ * arch/arm/src/armv7-a/scu.h
+ * Generic Interrupt Controller Definitions
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Reference:
+ * Cortex™-A9 MPCore, Revision: r4p1, Technical Reference Manual, ARM DDI
+ * 0407I (ID091612).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_ARMV7_A_SCU_H
+#define __ARCH_ARM_SRC_ARMV7_A_SCU_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "mpcore.h" /* For MPCORE_SCU_VBASE */
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Register offsets *********************************************************/
+
+#define SCU_CTRL_OFFSET 0x0000 /* SCU Control Register (Implementation defined) */
+#define SCU_CONFIG_OFFSET 0x0004 /* SCU Configuration Register (Implementation defined) */
+#define SCU_PWRSTATUS_OFFSET 0x0008 /* SCU CPU Power Status Register */
+#define SCU_INVALIDATE_OFFSET 0x000c /* SCU Invalidate All Registers in Secure State */
+#define SCU_FILTERSTART_OFFSET 0x0040 /* Filtering Start Address Register Defined by FILTERSTART input */
+#define SCU_FILTEREND_OFFSET 0x0044 /* Filtering End Address Register Defined by FILTEREND input */
+#define SCU_SAC_OFFSET 0x0050 /* SCU Access Control (SAC) Register */
+#define SCU_SNSAC_OFFSET 0x0054 /* SCU Non-secure Access Control (SNSAC) Register */
+
+/* Register addresses *******************************************************/
+
+#define SCU_CTRL (MPCORE_SCU_VBASE+SCU_CTRL_OFFSET)
+#define SCU_CONFIG (MPCORE_SCU_VBASE+SCU_CONFIG_OFFSET)
+#define SCU_PWRSTATUS (MPCORE_SCU_VBASE+SCU_PWRSTATUS_OFFSET)
+#define SCU_INVALIDATE (MPCORE_SCU_VBASE+SCU_INVALIDATE_OFFSET)
+#define SCU_FILTERSTART (MPCORE_SCU_VBASE+SCU_FILTERSTART_OFFSET)
+#define SCU_FILTEREND (MPCORE_SCU_VBASE+SCU_FILTEREND_OFFSET)
+#define SCU_SAC (MPCORE_SCU_VBASE+SCU_SAC_OFFSET)
+#define SCU_SNSAC (MPCORE_SCU_VBASE+SCU_SNSAC_OFFSET)
+
+/* Register bit-field definitions *******************************************/
+
+/* SCU Control Register (Implementation defined) */
+
+#define SCU_CTRL_ENABLE (1 << 0) /* SCU enable */
+#define SCU_CTRL_ADDRFILTER (1 << 1) /* Address filtering enable */
+#define SCU_CTRL_RAMPARITY (1 << 2) /* SCU RAMs parity enable */
+#define SCU_CTRL_LINFILL (1 << 3) /* SCU speculative linefill enable */
+#define SCU_CTRL_PORT0 (1 << 4) /* Force all device to port0 enable */
+#define SCU_CTRL_STANDBY (1 << 5) /* SCU standby enable */
+#define SCU_CTRL_ICSTANDBY (1 << 6) /* IC standby enable */
+
+/* SCU Configuration Register (Implementation defined) */
+
+#define SCU_CONFIG_NCPUS_SHIFT 0 /* CPU number Number of CPUs present */
+#define SCU_CONFIG_NCPUS_MASK (3 << SCU_CONFIG_NCPUS_SHIFT)
+# define SCU_CONFIG_NCPUS(r) ((((uint32_t)(r) & SCU_CONFIG_NCPUS_MASK) >> SCU_CONFIG_NCPUS_SHIFT) + 1)
+#define SCU_CONFIG_SMPCPUS_SHIFT 4 /* Processors that are in SMP or AMP mode */
+#define SCU_CONFIG_SMPCPUS_MASK (15 << SCU_CONFIG_SMPCPUS_SHIFT)
+# define SCU_CONFIG_CPU_SMP(n) (1 << ((n)+4))
+# define SCU_CONFIG_CPU0_SMP (1 << 4)
+# define SCU_CONFIG_CPU1_SMP (1 << 5)
+# define SCU_CONFIG_CPU2_SMP (1 << 6)
+# define SCU_CONFIG_CPU3_SMP (1 << 7)
+
+#define SCU_CONFIG_TAGRAM_16KB 0
+#define SCU_CONFIG_TAGRAM_32KB 1
+#define SCU_CONFIG_TAGRAM_64KB 2
+
+#define SCU_CONFIG_CPU0_TAGRAM_SHIFT 8 /* CPU 0 tag RAM size */
+#define SCU_CONFIG_CPU0_TAGRAM_MASK (3 << SCU_CONFIG_CPU0_TAGRAM_SHIFT)
+#define SCU_CONFIG_CPU1_TAGRAM_SHIFT 10 /* CPU 1 tag RAM size */
+#define SCU_CONFIG_CPU1_TAGRAM_MASK (3 << SCU_CONFIG_CPU0_TAGRAM_SHIFT)
+#define SCU_CONFIG_CPU2_TAGRAM_SHIFT 12 /* CPU 1 tag RAM size */
+#define SCU_CONFIG_CPU2_TAGRAM_MASK (3 << SCU_CONFIG_CPU0_TAGRAM_SHIFT)
+#define SCU_CONFIG_CPU3_TAGRAM_SHIFT 14 /* CPU 1 tag RAM size */
+#define SCU_CONFIG_CPU3_TAGRAM_MASK (3 << SCU_CONFIG_CPU0_TAGRAM_SHIFT)
+
+/* SCU CPU Power Status Register */
+
+#define SCU_PWRSTATUS_NORMAL 0
+#define SCU_PWRSTATUS_DORMANT 2
+#define SCU_PWRSTATUS_PWROFF 3
+
+#define SCU_PWRSTATUS_CPU0_SHIFT 0 /* CPU0 status Power status */
+#define SCU_PWRSTATUS_CPU0_MASK (3 << SCU_PWRSTATUS_CPU0_SHIFT)
+#define SCU_PWRSTATUS_CPU1_SHIFT 8 /* CPU1 status Power status */
+#define SCU_PWRSTATUS_CPU1_MASK (3 << SCU_PWRSTATUS_CPU1_SHIFT)
+#define SCU_PWRSTATUS_CPU2_SHIFT 16 /* CPU2 status Power status */
+#define SCU_PWRSTATUS_CPU2_MASK (3 << SCU_PWRSTATUS_CPU2_SHIFT)
+#define SCU_PWRSTATUS_CPU3_SHIFT 24 /* CPU3 status Power status */
+#define SCU_PWRSTATUS_CPU3_MASK (3 << SCU_PWRSTATUS_CPU3_SHIFT)
+
+/* SCU Invalidate All Registers in Secure State */
+
+#define SCU_INVALIDATE_ALL_WAYS 15
+#define SCU_INVALIDATE_CPU0_SHIFT 0 /* Ways that must be invalidated for CPU0 */
+#define SCU_INVALIDATE_CPU0_MASK (15 << SCU_INVALIDATE_CPU0_SHIFT)
+#define SCU_INVALIDATE_CPU1_SHIFT 4 /* Ways that must be invalidated for CPU1 */
+#define SCU_INVALIDATE_CPU1_MASK (15 << SCU_INVALIDATE_CPU1_SHIFT)
+#define SCU_INVALIDATE_CPU2_SHIFT 8 /* Ways that must be invalidated for CPU2 */
+#define SCU_INVALIDATE_CPU2_MASK (15 << SCU_INVALIDATE_CPU2_SHIFT)
+#define SCU_INVALIDATE_CPU3_SHIFT 12 /* Ways that must be invalidated for CPU3 */
+#define SCU_INVALIDATE_CPU3_MASK (15 << SCU_INVALIDATE_CPU3_SHIFT)
+
+/* Filtering Start Address Register Defined by FILTERSTART input */
+
+#define SCU_FILTERSTART_SHIFT 10 /* Filtering start address */
+#define SCU_FILTERSTART_MASK (0xfff << SCU_FILTERSTART_SHIFT)
+
+/* Filtering End Address Register Defined by FILTEREND input */
+
+#define SCU_FILTEREND_SHIFT 10 /* Filtering start address */
+#define SCU_FILTEREND_MASK (0xfff << SCU_FILTEREND_SHIFT)
+
+/* SCU Access Control (SAC) Register */
+
+#define SCU_SAC_CPU(n) (1 << (n)) /* CPUn may access components */
+
+/* SCU Non-secure Access Control (SNSAC) Register */
+
+#define SCU_SNSAC_COMP_CPU(n) (1 << (n)) /* CPUn has non-secure access to components */
+#define SCU_SNSAC_PTIM_CPU(n) (1 << ((n)+4)) /* CPUn has non-secure access to private timers */
+#define SCU_SNSAC_GTIM_CPU(n) (1 << ((n)+8)) /* CPUn has non-secure access to global timer */
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: arm_enable_smp
+ *
+ * Description:
+ * Enable the SCU and make certain that current CPU is participating in
+ * the SMP cache coherency.
+ *
+ ****************************************************************************/
+
+void arm_enable_smp(int cpu);
+
+#endif /* __ARCH_ARM_SRC_ARMV7_A_SCU_H */
diff --git a/arch/arm/src/armv7-m/gnu/up_testset.S b/arch/arm/src/armv7-m/gnu/up_testset.S
index 7dd45eee4dbef257817c6ac0095450811b371d80..c1888c56a98fcc5a64381b053c0e8903c585c65e 100644
--- a/arch/arm/src/armv7-m/gnu/up_testset.S
+++ b/arch/arm/src/armv7-m/gnu/up_testset.S
@@ -72,7 +72,7 @@
* Name: up_testset
*
* Description:
- * Perform and atomic test and set operation on the provided spinlock.
+ * Perform an atomic test and set operation on the provided spinlock.
*
* This function must be provided via the architecture-specific logoic.
*
diff --git a/arch/arm/src/armv7-m/iar/up_testset.S b/arch/arm/src/armv7-m/iar/up_testset.S
index 9590e576e77ef8d16927948a82564f75401e38fb..e690aed3de9d7f6ae88d9374e67b6f71d04d32ae 100644
--- a/arch/arm/src/armv7-m/iar/up_testset.S
+++ b/arch/arm/src/armv7-m/iar/up_testset.S
@@ -57,7 +57,7 @@
* Name: up_testset
*
* Description:
- * Perform and atomic test and set operation on the provided spinlock.
+ * Perform an atomic test and set operation on the provided spinlock.
*
* This function must be provided via the architecture-specific logoic.
*
diff --git a/arch/arm/src/armv7-m/mpu.h b/arch/arm/src/armv7-m/mpu.h
index 22348a23a685653a1555b14728ab37c30596f9e1..4a5bab065bda53bc67807f874c0e77683d05adca 100644
--- a/arch/arm/src/armv7-m/mpu.h
+++ b/arch/arm/src/armv7-m/mpu.h
@@ -357,7 +357,7 @@ static inline void mpu_priv_flash(uintptr_t base, size_t size)
/* Select the region */
- putreg32(mpu_allocregion(), MPU_RNR);
+ putreg32(region, MPU_RNR);
/* Select the region base address */
diff --git a/arch/arm/src/armv7-m/up_assert.c b/arch/arm/src/armv7-m/up_assert.c
index b34cfc73950343db2ab09940953f55a9daf14fab..11f29cd653422c3b58535fabcac7249c72115eec 100644
--- a/arch/arm/src/armv7-m/up_assert.c
+++ b/arch/arm/src/armv7-m/up_assert.c
@@ -53,6 +53,7 @@
#include "up_arch.h"
#include "sched/sched.h"
+#include "irq/irq.h"
#include "up_internal.h"
/****************************************************************************
@@ -319,6 +320,12 @@ static void up_dumpstate(void)
#endif
+#ifdef CONFIG_SMP
+ /* Show the CPU number */
+
+ _alert("CPU%d:\n", up_cpu_index());
+#endif
+
/* Then dump the registers (if available) */
up_registerdump();
@@ -351,6 +358,12 @@ static void _up_assert(int errorcode)
(void)up_irq_save();
for (; ; )
{
+#ifdef CONFIG_SMP
+ /* Try (again) to stop activity on other CPUs */
+
+ (void)spin_trylock(&g_cpu_irqlock);
+#endif
+
#ifdef CONFIG_ARCH_LEDS
board_autoled_on(LED_PANIC);
up_mdelay(250);
diff --git a/arch/arm/src/armv7-m/up_schedulesigaction.c b/arch/arm/src/armv7-m/up_schedulesigaction.c
index cf70662510c47a0515ee4825353446af5a522c66..fb6a4c167c6f01d5e847938b853c96a41e1026ba 100644
--- a/arch/arm/src/armv7-m/up_schedulesigaction.c
+++ b/arch/arm/src/armv7-m/up_schedulesigaction.c
@@ -165,6 +165,19 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
#ifdef CONFIG_BUILD_PROTECTED
CURRENT_REGS[REG_LR] = EXC_RETURN_PRIVTHR;
#endif
+
+#ifdef CONFIG_SMP
+ /* In an SMP configuration, the interrupt disable logic also
+ * involves spinlocks that are configured per the TCB irqcount
+ * field. This is logically equivalent to enter_critical_section().
+ * The matching call to leave_critical_section() will be
+ * performed in up_sigdeliver().
+ */
+
+ DEBUGASSERT(tcb->irqcount < INT16_MAX);
+ tcb->irqcount++;
+#endif
+
/* And make sure that the saved context in the TCB is the same
* as the interrupt return context.
*/
@@ -211,6 +224,19 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
#ifdef CONFIG_BUILD_PROTECTED
tcb->xcp.regs[REG_LR] = EXC_RETURN_PRIVTHR;
#endif
+
+#ifdef CONFIG_SMP
+ /* In an SMP configuration, the interrupt disable logic also
+ * involves spinlocks that are configured per the TCB irqcount
+ * field. This is logically equivalent to enter_critical_section();
+ * The matching leave_critical_section will be performed in
+ * The matching call to leave_critical_section() will be performed
+ * in up_sigdeliver().
+ */
+
+ DEBUGASSERT(tcb->irqcount < INT16_MAX);
+ tcb->irqcount++;
+#endif
}
}
diff --git a/arch/arm/src/armv7-m/up_sigdeliver.c b/arch/arm/src/armv7-m/up_sigdeliver.c
index 6169b512796e839588dfaee8b2dd40c5ff8d6b1c..086ed882fce0c75ac3636d94085ca4721e2fd74b 100644
--- a/arch/arm/src/armv7-m/up_sigdeliver.c
+++ b/arch/arm/src/armv7-m/up_sigdeliver.c
@@ -124,9 +124,9 @@ void up_sigdeliver(void)
/* Then restore the task interrupt state */
#ifdef CONFIG_ARMV7M_USEBASEPRI
- up_irq_restore((uint8_t)regs[REG_BASEPRI]);
+ leave_critical_section((uint8_t)regs[REG_BASEPRI]);
#else
- up_irq_restore((uint16_t)regs[REG_PRIMASK]);
+ leave_critical_section((uint16_t)regs[REG_PRIMASK]);
#endif
/* Deliver the signal */
@@ -136,9 +136,18 @@ void up_sigdeliver(void)
/* Output any debug messages BEFORE restoring errno (because they may
* alter errno), then disable interrupts again and restore the original
* errno that is needed by the user logic (it is probably EINTR).
+ *
+ * REVISIT: In SMP mode up_irq_save() probably only disables interrupts
+ * on the local CPU. We do not want to call enter_critical_section()
+ * here, however, because we don't want this state to stick after the
+ * call to up_fullcontextrestore().
+ *
+ * I would prefer that all interrupts are disabled when
+ * up_fullcontextrestore() is called, but that may not be necessary.
*/
sinfo("Resuming\n");
+
(void)up_irq_save();
rtcb->pterrno = saved_errno;
diff --git a/arch/arm/src/armv7-m/up_signal_dispatch.c b/arch/arm/src/armv7-m/up_signal_dispatch.c
index 4a03a26b213e7d39ceedd7086c6c10162d4d6051..9ec7d151529ca35f84e4dc939165e35f8882d9a5 100644
--- a/arch/arm/src/armv7-m/up_signal_dispatch.c
+++ b/arch/arm/src/armv7-m/up_signal_dispatch.c
@@ -46,18 +46,6 @@
#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \
defined(CONFIG_BUILD_KERNEL)) && !defined(CONFIG_DISABLE_SIGNALS)
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/arch/arm/src/armv7-r/Kconfig b/arch/arm/src/armv7-r/Kconfig
index 0582a4fee3361af32e82c9d368bddce074040244..1f46770cb6abcd0e857c97ac0f81462920aa31d6 100644
--- a/arch/arm/src/armv7-r/Kconfig
+++ b/arch/arm/src/armv7-r/Kconfig
@@ -3,7 +3,7 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
-comment "ARMv7-A Configuration Options"
+comment "ARMv7-R Configuration Options"
config ARMV7R_MEMINIT
bool
@@ -19,6 +19,29 @@ config ARMV7R_MEMINIT
the memory initialization first, then explicitly call
arm_data_initialize().
+config ARMV7R_HAVE_ICACHE
+ bool
+ default n
+
+config ARMV7R_HAVE_DCACHE
+ bool
+ default n
+
+config ARMV7R_ICACHE
+ bool "Use I-Cache"
+ default n
+ depends on ARMV7R_HAVE_ICACHE
+
+config ARMV7R_DCACHE
+ bool "Use D-Cache"
+ default n
+ depends on ARMV7R_HAVE_DCACHE
+
+config ARMV7R_DCACHE_WRITETHROUGH
+ bool "D-Cache Write-Through"
+ default n
+ depends on ARMV7R_DCACHE
+
config ARMV7R_HAVE_L2CC
bool
default n
@@ -162,7 +185,7 @@ config ARMV7R_TOOLCHAIN_GNU_OABI
---help---
This option should work for any GNU toolchain configured for arm-elf-.
-endchoice # ARMV7R_HAVE_L2CC
+endchoice # Toolchain Selection
config ARMV7R_OABI_TOOLCHAIN
bool "OABI (vs EABI)"
diff --git a/arch/arm/src/armv7-r/arm_fullcontextrestore.S b/arch/arm/src/armv7-r/arm_fullcontextrestore.S
index 9f197063b27de976981cef4065527029a2b2d1cb..06daa2218262b5b223219b0f85450e505786911e 100644
--- a/arch/arm/src/armv7-r/arm_fullcontextrestore.S
+++ b/arch/arm/src/armv7-r/arm_fullcontextrestore.S
@@ -60,7 +60,6 @@
.cpu cortex-r4f
#endif
.syntax unified
- .file "arm_fullcontextrestore.S"
/****************************************************************************
* Public Functions
@@ -157,20 +156,11 @@ up_fullcontextrestore:
*/
ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the stored CPSR value */
- msr cpsr, r1 /* Set the CPSR */
-
- /* Now recover r0 and r1 */
-
- ldr r0, [sp]
- ldr r1, [sp, #4]
- add sp, sp, #(2*4)
-
- /* Then return to the address at the stop of the stack,
- * destroying the stack frame
- */
+ msr spsr_cxsf, r1 /* Set the SPSR */
- ldr pc, [sp], #4
+ /* Now recover r0-r1, pc and cpsr, destroying the stack frame */
+ ldmia sp!, {r0-r1, pc}^
#endif
.size up_fullcontextrestore, . - up_fullcontextrestore
diff --git a/arch/arm/src/armv7-r/arm_testset.S b/arch/arm/src/armv7-r/arm_testset.S
index 7cd741fed734dfe86cd9b803306c74fc09973435..f82837d5fe8f688779b5620a0ad03fa029631071 100644
--- a/arch/arm/src/armv7-r/arm_testset.S
+++ b/arch/arm/src/armv7-r/arm_testset.S
@@ -70,7 +70,7 @@
* Name: up_testset
*
* Description:
- * Perform and atomic test and set operation on the provided spinlock.
+ * Perform an atomic test and set operation on the provided spinlock.
*
* This function must be provided via the architecture-specific logoic.
*
diff --git a/arch/arm/src/armv7-r/arm_vectors.S b/arch/arm/src/armv7-r/arm_vectors.S
index 216633e3a36f47d7c16ca8ae23af25aec2bd5bd8..bea7c927bcebf14c8e4aee423be394ccb3b58870 100644
--- a/arch/arm/src/armv7-r/arm_vectors.S
+++ b/arch/arm/src/armv7-r/arm_vectors.S
@@ -202,7 +202,7 @@ arm_vectorirq:
/* Restore the CPSR, SVC mode registers and return */
ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */
- msr spsr, r1 /* Set the return mode SPSR */
+ msr spsr_cxsf, r1 /* Set the return mode SPSR */
#ifdef CONFIG_BUILD_PROTECTED
/* Are we leaving in user mode? If so then we need to restore the
@@ -331,7 +331,7 @@ arm_vectorsvc:
/* Restore the CPSR, SVC mode registers and return */
ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */
- msr spsr, r1 /* Set the return mode SPSR */
+ msr spsr_cxsf, r1 /* Set the return mode SPSR */
#ifdef CONFIG_BUILD_PROTECTED
/* Are we leaving in user mode? If so then we need to restore the
@@ -913,7 +913,7 @@ arm_vectorfiq:
/* Restore the CPSR, SVC mode registers and return */
ldr r1, [r0, #(4*REG_CPSR)] /* Fetch the return SPSR */
- msr spsr, r1 /* Set the return mode SPSR */
+ msr spsr_cxsf, r1 /* Set the return mode SPSR */
#ifdef CONFIG_BUILD_PROTECTED
/* Are we leaving in user mode? If so then we need to restore the
diff --git a/arch/arm/src/armv7-r/cache.h b/arch/arm/src/armv7-r/cache.h
index 2c60fe2c3d62d266e01506c6473f4473609efb42..721f40313f29236c6ffcc0b7d0f10ec304129ccf 100644
--- a/arch/arm/src/armv7-r/cache.h
+++ b/arch/arm/src/armv7-r/cache.h
@@ -43,6 +43,7 @@
#include
#include
+#include "sctlr.h"
#include "cp15_cacheops.h"
#include "l2cc.h"
@@ -50,7 +51,17 @@
* Pre-processor Definitions
************************************************************************************/
- /************************************************************************************
+/* Intrinsics are used in these inline functions */
+
+#define arm_isb(n) __asm__ __volatile__ ("isb " #n : : : "memory")
+#define arm_dsb(n) __asm__ __volatile__ ("dsb " #n : : : "memory")
+#define arm_dmb(n) __asm__ __volatile__ ("dmb " #n : : : "memory")
+
+#define ARM_DSB() arm_dsb(15)
+#define ARM_ISB() arm_isb(15)
+#define ARM_DMB() arm_dmb(15)
+
+/************************************************************************************
* Inline Functions
************************************************************************************/
@@ -183,6 +194,70 @@ static inline void arch_flush_dcache(uintptr_t start, uintptr_t end)
l2cc_flush(start, end);
}
+/****************************************************************************
+ * Name: arch_enable_icache
+ *
+ * Description:
+ * Enable the I-Cache
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void arch_enable_icache(void)
+{
+#ifdef CONFIG_ARMV7R_ICACHE
+ uint32_t regval;
+
+ ARM_DSB();
+ ARM_ISB();
+
+ /* Enable the I-Cache */
+
+ regval = cp15_rdsctlr();
+ if ((regval & SCTLR_I) == 0)
+ {
+ cp15_wrsctlr(regval | SCTLR_I);
+ }
+
+ ARM_DSB();
+ ARM_ISB();
+#endif
+}
+
+/****************************************************************************
+* Name: arch_enable_dcache
+*
+* Description:
+* Enable the D-Cache
+*
+* Input Parameters:
+* None
+*
+* Returned Value:
+* None
+*
+****************************************************************************/
+
+static inline void arch_enable_dcache(void)
+{
+#ifdef CONFIG_ARMV7R_DCACHE
+ uint32_t regval;
+
+ /* Enable the D-Cache */
+
+ regval = cp15_rdsctlr();
+ if ((regval & SCTLR_C) == 0)
+ {
+ cp15_wrsctlr(regval | SCTLR_C);
+ }
+#endif
+}
+
/****************************************************************************
* Public Data
****************************************************************************/
diff --git a/arch/arm/src/armv7-r/mpu.h b/arch/arm/src/armv7-r/mpu.h
index e9e29cf13f853807c66f99c72cd8497a0f8c175b..7c1a201567db5188478ece9a7d3bce27a3dc62bc 100644
--- a/arch/arm/src/armv7-r/mpu.h
+++ b/arch/arm/src/armv7-r/mpu.h
@@ -49,6 +49,8 @@
# include
# include "up_arch.h"
+# include "cache.h"
+# include "sctlr.h"
# include "cp15.h"
#endif
@@ -66,7 +68,7 @@
/* Region Base Address Register Definitions */
-#define MPU_RBAR_MASK 0xfffffffc
+#define MPU_RBAR_ADDR_MASK 0xfffffffc
/* Region Size and Enable Register */
@@ -201,7 +203,7 @@ static inline unsigned int mpu_get_mpuir(void)
unsigned int mpuir;
__asm__ __volatile__
(
- "\tmrc " CP15_MPUIR(%0)
+ "\tmrc p15, 0, %0, c0, c0, 4"
: "=r" (mpuir)
:
: "memory"
@@ -222,7 +224,7 @@ static inline void mpu_set_drbar(unsigned int drbar)
{
__asm__ __volatile__
(
- "\tmcr " CP15_DRBAR(%0)
+ "\tmcr p15, 0, %0, c6, c1, 0"
:
: "r" (drbar)
: "memory"
@@ -241,7 +243,7 @@ static inline void mpu_set_drsr(unsigned int drsr)
{
__asm__ __volatile__
(
- "\tmcr " CP15_DRSR(%0)
+ "\tmcr p15, 0, %0, c6, c1, 2"
:
: "r" (drsr)
: "memory"
@@ -260,7 +262,7 @@ static inline void mpu_set_dracr(unsigned int dracr)
{
__asm__ __volatile__
(
- "\tmcr " CP15_DRACR(%0)
+ "\tmcr p15, 0, %0, c6, c1, 4"
:
: "r" (dracr)
: "memory"
@@ -280,7 +282,7 @@ static inline void mpu_set_irbar(unsigned int irbar)
{
__asm__ __volatile__
(
- "\tmcr " CP15_IRBAR(%0)
+ "\tmcr p15, 0, %0, c6, c1, 1"
:
: "r" (irbar)
: "memory"
@@ -301,7 +303,7 @@ static inline void mpu_set_irsr(unsigned int irsr)
{
__asm__ __volatile__
(
- "\tmcr " CP15_IRSR(%0)
+ "\tmcr p15, 0, %0, c6, c1, 3"
:
: "r" (irsr)
: "memory"
@@ -322,7 +324,7 @@ static inline void mpu_set_iracr(unsigned int iracr)
{
__asm__ __volatile__
(
- "\tmcr " CP15_IRACR(%0)
+ "\tmcr p15, 0, %0, c6, c1, 5"
:
: "r" (iracr)
: "memory"
@@ -342,7 +344,7 @@ static inline void mpu_set_rgnr(unsigned int rgnr)
{
__asm__ __volatile__
(
- "\tmcr " CP15_RGNR(%0)
+ "\tmcr p15, 0, %0, c6, c2, 0"
:
: "r" (rgnr)
: "memory"
@@ -390,7 +392,6 @@ static inline void mpu_control(bool enable)
if (enable)
{
regval |= (SCTLR_M | SCTLR_BR);
- cp15_wrsctlr(regval);
}
else
{
@@ -408,7 +409,7 @@ static inline void mpu_control(bool enable)
*
****************************************************************************/
-#if defined(CONFIG_ARMV7M_HAVE_ICACHE) || defined(CONFIG_ARMV7M_DCACHE)
+#if defined(CONFIG_ARMV7R_HAVE_ICACHE) || defined(CONFIG_ARMV7R_DCACHE)
static inline void mpu_priv_stronglyordered(uintptr_t base, size_t size)
{
unsigned int region = mpu_allocregion();
@@ -422,7 +423,7 @@ static inline void mpu_priv_stronglyordered(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar(base & MPU_RBAR_ADDR_MASK) | region | MPU_RBAR_VALID);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
@@ -465,7 +466,7 @@ static inline void mpu_user_flash(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar((base & MPU_RBAR_ADDR_MASK) | region);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
@@ -506,7 +507,7 @@ static inline void mpu_priv_flash(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar((base & MPU_RBAR_ADDR_MASK) | region);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
@@ -546,7 +547,7 @@ static inline void mpu_user_intsram(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar((base & MPU_RBAR_ADDR_MASK) | region);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
@@ -587,7 +588,7 @@ static inline void mpu_priv_intsram(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar((base & MPU_RBAR_ADDR_MASK) | region);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
@@ -628,7 +629,7 @@ static inline void mpu_user_extsram(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar((base & MPU_RBAR_ADDR_MASK) | region);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
@@ -670,7 +671,7 @@ static inline void mpu_priv_extsram(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar((base & MPU_RBAR_ADDR_MASK) | region);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
@@ -712,7 +713,7 @@ static inline void mpu_peripheral(uintptr_t base, size_t size)
/* Select the region base address */
- mpu_set_drbar((base & MPU_RBAR_ADDR_MASK) | region);
+ mpu_set_drbar(base & MPU_RBAR_ADDR_MASK);
/* Select the region size and the sub-region map */
diff --git a/arch/arm/src/c5471/Kconfig b/arch/arm/src/c5471/Kconfig
index 17b615a0973de6b10fe31faaecf11b7afd0054fc..5f46d7684a967f190b343a84a55c81e9e26fae08 100644
--- a/arch/arm/src/c5471/Kconfig
+++ b/arch/arm/src/c5471/Kconfig
@@ -110,3 +110,23 @@ config C5471_BASET10
bool "10BaseT FullDuplex"
endchoice
+
+choice
+ prompt "Ethernet work queue"
+ default C5471_LPWORK if SCHED_LPWORK
+ default C5471_HPWORK if !SCHED_LPWORK && SCHED_HPWORK
+ depends on SCHED_WORKQUEUE
+ ---help---
+ Work queue support is required to use the Ethernet driver. If the
+ low priority work queue is available, then it should be used by the
+ driver.
+
+config C5471_HPWORK
+ bool "High priority"
+ depends on SCHED_HPWORK
+
+config C5471_LPWORK
+ bool "Low priority"
+ depends on SCHED_LPWORK
+
+endchoice # Work queue
diff --git a/arch/arm/src/c5471/c5471_ethernet.c b/arch/arm/src/c5471/c5471_ethernet.c
index b7563aa0545b5909eb66f29080f050120a840245..a163cecaabe482c65e383be8fb72411705ed7d29 100644
--- a/arch/arm/src/c5471/c5471_ethernet.c
+++ b/arch/arm/src/c5471/c5471_ethernet.c
@@ -59,6 +59,7 @@
#include
#include
#include
+#include
#include
#include
@@ -75,6 +76,25 @@
****************************************************************************/
/* Configuration ************************************************************/
+/* If processing is not done at the interrupt level, then work queue support
+ * is required.
+ */
+
+#if !defined(CONFIG_SCHED_WORKQUEUE)
+# error Work queue support is required in this configuration (CONFIG_SCHED_WORKQUEUE)
+#else
+
+ /* Use the low priority work queue if possible */
+
+# if defined(CONFIG_C5471_HPWORK)
+# define ETHWORK HPWORK
+# elif defined(CONFIG_C5471_LPWORK)
+# define ETHWORK LPWORK
+# else
+# error Neither CONFIG_C5471_HPWORK nor CONFIG_C5471_LPWORK defined
+# endif
+#endif
+
/* CONFIG_C5471_NET_NINTERFACES determines the number of physical interfaces
* that will be supported.
*/
@@ -273,12 +293,16 @@
/* This is a helper pointer for accessing the contents of the Ethernet header */
-#define BUF ((struct eth_hdr_s *)c5471->c_dev.d_buf)
+#define BUF ((struct eth_hdr_s *)priv->c_dev.d_buf)
/****************************************************************************
* Private Types
****************************************************************************/
+/* A single packet buffer is used */
+
+static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
+
/* The c5471_driver_s encapsulates all state information for a single c5471
* hardware interface
*/
@@ -288,6 +312,7 @@ struct c5471_driver_s
bool c_bifup; /* true:ifup false:ifdown */
WDOG_ID c_txpoll; /* TX poll timer */
WDOG_ID c_txtimeout; /* TX timeout timer */
+ struct work_s c_work; /* For deferring work to the work queue */
/* Note: According to the C547x documentation: "The software has to maintain
* two pointers to the current RX-CPU and TX-CPU descriptors. At init time,
@@ -356,36 +381,44 @@ static int c5471_phyinit (void);
/* Support logic */
-static inline void c5471_inctxcpu(struct c5471_driver_s *c5471);
-static inline void c5471_incrxcpu(struct c5471_driver_s *c5471);
+static inline void c5471_inctxcpu(struct c5471_driver_s *priv);
+static inline void c5471_incrxcpu(struct c5471_driver_s *priv);
/* Common TX logic */
-static int c5471_transmit(struct c5471_driver_s *c5471);
+static int c5471_transmit(struct c5471_driver_s *priv);
static int c5471_txpoll(struct net_driver_s *dev);
/* Interrupt handling */
#ifdef CONFIG_C5471_NET_STATS
-static void c5471_rxstatus(struct c5471_driver_s *c5471);
+static void c5471_rxstatus(struct c5471_driver_s *priv);
#endif
-static void c5471_receive(struct c5471_driver_s *c5471);
+static void c5471_receive(struct c5471_driver_s *priv);
#ifdef CONFIG_C5471_NET_STATS
-static void c5471_txstatus(struct c5471_driver_s *c5471);
+static void c5471_txstatus(struct c5471_driver_s *priv);
#endif
-static void c5471_txdone(struct c5471_driver_s *c5471);
+static void c5471_txdone(struct c5471_driver_s *priv);
+
+static void c5471_interrupt_work(FAR void *arg);
static int c5471_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */
-static void c5471_polltimer(int argc, uint32_t arg, ...);
-static void c5471_txtimeout(int argc, uint32_t arg, ...);
+static void c5471_txtimeout_work(FAR void *arg);
+static void c5471_txtimeout_expiry(int argc, uint32_t arg, ...);
+
+static void c5471_poll_work(FAR void *arg);
+static void c5471_poll_expiry(int argc, uint32_t arg, ...);
/* NuttX callback functions */
static int c5471_ifup(struct net_driver_s *dev);
static int c5471_ifdown(struct net_driver_s *dev);
+
+static void c5471_txavail_work(FAR void *arg);
static int c5471_txavail(struct net_driver_s *dev);
+
#ifdef CONFIG_NET_IGMP
static int c5471_addmac(struct net_driver_s *dev, FAR const uint8_t *mac);
static int c5471_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
@@ -393,10 +426,10 @@ static int c5471_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac);
/* Initialization functions */
-static void c5471_eimreset (struct c5471_driver_s *c5471);
-static void c5471_eimconfig(struct c5471_driver_s *c5471);
-static void c5471_reset(struct c5471_driver_s *c5471);
-static void c5471_macassign(struct c5471_driver_s *c5471);
+static void c5471_eimreset (struct c5471_driver_s *priv);
+static void c5471_eimconfig(struct c5471_driver_s *priv);
+static void c5471_reset(struct c5471_driver_s *priv);
+static void c5471_macassign(struct c5471_driver_s *priv);
/****************************************************************************
* Private Functions
@@ -411,7 +444,8 @@ static void c5471_macassign(struct c5471_driver_s *c5471);
****************************************************************************/
#ifdef CONFIG_C5471_NET_DUMPBUFFER
-static inline void c5471_dumpbuffer(const char *msg, const uint8_t *buffer, unsigned int nbytes)
+static inline void c5471_dumpbuffer(const char *msg, const uint8_t *buffer,
+ unsigned int nbytes)
{
/* CONFIG_DEBUG_FEATURES, CONFIG_DEBUG_INFO, and CONFIG_DEBUG_NET have to be
* defined or the following does nothing.
@@ -789,20 +823,20 @@ static int c5471_phyinit (void)
*
****************************************************************************/
-static inline void c5471_inctxcpu(struct c5471_driver_s *c5471)
+static inline void c5471_inctxcpu(struct c5471_driver_s *priv)
{
- if (EIM_TXDESC_WRAP_NEXT & getreg32(c5471->c_txcpudesc))
+ if (EIM_TXDESC_WRAP_NEXT & getreg32(priv->c_txcpudesc))
{
/* Loop back around to base of descriptor queue */
- c5471->c_txcpudesc = getreg32(EIM_CPU_TXBA) + EIM_RAM_START;
+ priv->c_txcpudesc = getreg32(EIM_CPU_TXBA) + EIM_RAM_START;
}
else
{
- c5471->c_txcpudesc += 2*sizeof(uint32_t);
+ priv->c_txcpudesc += 2*sizeof(uint32_t);
}
- ninfo("TX CPU desc: %08x\n", c5471->c_txcpudesc);
+ ninfo("TX CPU desc: %08x\n", priv->c_txcpudesc);
}
/****************************************************************************
@@ -812,20 +846,20 @@ static inline void c5471_inctxcpu(struct c5471_driver_s *c5471)
*
****************************************************************************/
-static inline void c5471_incrxcpu(struct c5471_driver_s *c5471)
+static inline void c5471_incrxcpu(struct c5471_driver_s *priv)
{
- if (EIM_RXDESC_WRAP_NEXT & getreg32(c5471->c_rxcpudesc))
+ if (EIM_RXDESC_WRAP_NEXT & getreg32(priv->c_rxcpudesc))
{
/* Loop back around to base of descriptor queue */
- c5471->c_rxcpudesc = getreg32(EIM_CPU_RXBA) + EIM_RAM_START;
+ priv->c_rxcpudesc = getreg32(EIM_CPU_RXBA) + EIM_RAM_START;
}
else
{
- c5471->c_rxcpudesc += 2*sizeof(uint32_t);
+ priv->c_rxcpudesc += 2*sizeof(uint32_t);
}
- ninfo("RX CPU desc: %08x\n", c5471->c_rxcpudesc);
+ ninfo("RX CPU desc: %08x\n", priv->c_rxcpudesc);
}
/****************************************************************************
@@ -836,7 +870,7 @@ static inline void c5471_incrxcpu(struct c5471_driver_s *c5471)
* handling or from watchdog based polling.
*
* Parameters:
- * c5471 - Reference to the driver state structure
+ * priv - Reference to the driver state structure
*
* Returned Value:
* OK on success; a negated errno on failure
@@ -845,9 +879,9 @@ static inline void c5471_incrxcpu(struct c5471_driver_s *c5471)
*
****************************************************************************/
-static int c5471_transmit(struct c5471_driver_s *c5471)
+static int c5471_transmit(struct c5471_driver_s *priv)
{
- struct net_driver_s *dev = &c5471->c_dev;
+ struct net_driver_s *dev = &priv->c_dev;
volatile uint16_t *packetmem;
uint16_t framelen;
bool bfirstframe;
@@ -856,12 +890,12 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
unsigned int i;
unsigned int j;
- nbytes = (dev->d_len + 1) & ~1;
- j = 0;
- bfirstframe = true;
- c5471->c_lastdescstart = c5471->c_rxcpudesc;
+ nbytes = (dev->d_len + 1) & ~1;
+ j = 0;
+ bfirstframe = true;
+ priv->c_lastdescstart = priv->c_rxcpudesc;
- ninfo("Packet size: %d RX CPU desc: %08x\n", nbytes, c5471->c_rxcpudesc);
+ ninfo("Packet size: %d RX CPU desc: %08x\n", nbytes, priv->c_rxcpudesc);
c5471_dumpbuffer("Transmit packet", dev->d_buf, dev->d_len);
while (nbytes)
@@ -869,7 +903,7 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
/* Verify that the hardware is ready to send another packet */
/* Words #0 and #1 of descriptor */
- while (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc))
+ while (EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc))
{
/* Loop until the SWITCH lets go of the descriptor giving us access
* rights to submit our new ether frame to it.
@@ -878,18 +912,18 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
if (bfirstframe)
{
- putreg32((getreg32(c5471->c_rxcpudesc) | EIM_RXDESC_FIF), c5471->c_rxcpudesc);
+ putreg32((getreg32(priv->c_rxcpudesc) | EIM_RXDESC_FIF), priv->c_rxcpudesc);
}
else
{
- putreg32((getreg32(c5471->c_rxcpudesc) & ~EIM_RXDESC_FIF), c5471->c_rxcpudesc);
+ putreg32((getreg32(priv->c_rxcpudesc) & ~EIM_RXDESC_FIF), priv->c_rxcpudesc);
}
- putreg32((getreg32(c5471->c_rxcpudesc) & ~EIM_RXDESC_PADCRC), c5471->c_rxcpudesc);
+ putreg32((getreg32(priv->c_rxcpudesc) & ~EIM_RXDESC_PADCRC), priv->c_rxcpudesc);
if (bfirstframe)
{
- putreg32((getreg32(c5471->c_rxcpudesc) | EIM_RXDESC_PADCRC), c5471->c_rxcpudesc);
+ putreg32((getreg32(priv->c_rxcpudesc) | EIM_RXDESC_PADCRC), priv->c_rxcpudesc);
}
if (nbytes >= EIM_PACKET_BYTES)
@@ -908,7 +942,7 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
/* Words #2 and #3 of descriptor */
- packetmem = (uint16_t *)getreg32(c5471->c_rxcpudesc + sizeof(uint32_t));
+ packetmem = (uint16_t *)getreg32(priv->c_rxcpudesc + sizeof(uint32_t));
for (i = 0; i < nshorts; i++, j++)
{
/* 16-bits at a time. */
@@ -916,43 +950,45 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
packetmem[i] = htons(((uint16_t *)dev->d_buf)[j]);
}
- putreg32(((getreg32(c5471->c_rxcpudesc) & ~EIM_RXDESC_BYTEMASK) | framelen), c5471->c_rxcpudesc);
+ putreg32(((getreg32(priv->c_rxcpudesc) & ~EIM_RXDESC_BYTEMASK) | framelen),
+ priv->c_rxcpudesc);
nbytes -= framelen;
ninfo("Wrote framelen: %d nbytes: %d nshorts: %d\n", framelen, nbytes, nshorts);
if (0 == nbytes)
{
- putreg32((getreg32(c5471->c_rxcpudesc) | EIM_RXDESC_LIF), c5471->c_rxcpudesc);
+ putreg32((getreg32(priv->c_rxcpudesc) | EIM_RXDESC_LIF), priv->c_rxcpudesc);
}
else
{
- putreg32((getreg32(c5471->c_rxcpudesc) & ~EIM_RXDESC_LIF), c5471->c_rxcpudesc);
+ putreg32((getreg32(priv->c_rxcpudesc) & ~EIM_RXDESC_LIF), priv->c_rxcpudesc);
}
/* We're done with that descriptor; give access rights back to h/w */
- putreg32((getreg32(c5471->c_rxcpudesc) | EIM_RXDESC_OWN_HOST), c5471->c_rxcpudesc);
+ putreg32((getreg32(priv->c_rxcpudesc) | EIM_RXDESC_OWN_HOST), priv->c_rxcpudesc);
/* Next, tell Ether Module that those submitted bytes are ready for the wire */
putreg32(0x00000001, EIM_CPU_RXREADY);
- c5471->c_lastdescend = c5471->c_rxcpudesc;
+ priv->c_lastdescend = priv->c_rxcpudesc;
/* Advance to the next free descriptor */
- c5471_incrxcpu(c5471);
+ c5471_incrxcpu(priv);
bfirstframe = false;
}
/* Packet transferred .. Update statistics */
#ifdef CONFIG_C5471_NET_STATS
- c5471->c_txpackets++;
+ priv->c_txpackets++;
#endif
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
- (void)wd_start(c5471->c_txtimeout, C5471_TXTIMEOUT, c5471_txtimeout, 1, (uint32_t)c5471);
+ (void)wd_start(priv->c_txtimeout, C5471_TXTIMEOUT,
+ c5471_txtimeout_expiry, 1, (wdparm_t)priv);
return OK;
}
@@ -979,13 +1015,13 @@ static int c5471_transmit(struct c5471_driver_s *c5471)
static int c5471_txpoll(struct net_driver_s *dev)
{
- struct c5471_driver_s *c5471 = (struct c5471_driver_s *)dev->d_private;
+ struct c5471_driver_s *priv = (struct c5471_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
- if (c5471->c_dev.d_len > 0)
+ if (priv->c_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
@@ -993,10 +1029,10 @@ static int c5471_txpoll(struct net_driver_s *dev)
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
- if (IFF_IS_IPv4(c5471->c_dev.d_flags))
+ if (IFF_IS_IPv4(priv->c_dev.d_flags))
#endif
{
- arp_out(&c5471->c_dev);
+ arp_out(&priv->c_dev);
}
#endif /* CONFIG_NET_IPv4 */
@@ -1005,19 +1041,19 @@ static int c5471_txpoll(struct net_driver_s *dev)
else
#endif
{
- neighbor_out(&c5471->c_dev);
+ neighbor_out(&priv->c_dev);
}
#endif /* CONFIG_NET_IPv6 */
/* Send the packet */
- c5471_transmit(c5471);
+ c5471_transmit(priv);
/* Check if the ESM has let go of the RX descriptor giving us access
* rights to submit another Ethernet frame.
*/
- if ((EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) != 0)
+ if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) != 0)
{
/* No, then return non-zero to terminate the poll */
@@ -1039,7 +1075,7 @@ static int c5471_txpoll(struct net_driver_s *dev)
* An interrupt was received indicating that the last RX packet(s) is done
*
* Parameters:
- * c5471 - Reference to the driver state structure
+ * priv - Reference to the driver state structure
*
* Returned Value:
* None
@@ -1049,9 +1085,9 @@ static int c5471_txpoll(struct net_driver_s *dev)
****************************************************************************/
#ifdef CONFIG_C5471_NET_STATS
-static void c5471_rxstatus(struct c5471_driver_s *c5471)
+static void c5471_rxstatus(struct c5471_driver_s *priv)
{
- uint32_t desc = c5471->c_txcpudesc;
+ uint32_t desc = priv->c_txcpudesc;
uint32_t rxstatus;
/* Walk that last packet we just received to collect xmit status bits. */
@@ -1091,44 +1127,44 @@ static void c5471_rxstatus(struct c5471_driver_s *c5471)
{
if ((rxstatus & EIM_TXDESC_RETRYERROR) != 0)
{
- c5471->c_rxretries++;
- ninfo("c_rxretries: %d\n", c5471->c_rxretries);
+ priv->c_rxretries++;
+ ninfo("c_rxretries: %d\n", priv->c_rxretries);
}
if ((rxstatus & EIM_TXDESC_HEARTBEAT) != 0)
{
- c5471->c_rxheartbeat++;
- ninfo("c_rxheartbeat: %d\n", c5471->c_rxheartbeat);
+ priv->c_rxheartbeat++;
+ ninfo("c_rxheartbeat: %d\n", priv->c_rxheartbeat);
}
if ((rxstatus & EIM_TXDESC_LCOLLISON) != 0)
{
- c5471->c_rxlcollision++;
- ninfo("c_rxlcollision: %d\n", c5471->c_rxlcollision);
+ priv->c_rxlcollision++;
+ ninfo("c_rxlcollision: %d\n", priv->c_rxlcollision);
}
if ((rxstatus & EIM_TXDESC_COLLISION) != 0)
{
- c5471->c_rxcollision++;
- ninfo("c_rxcollision: %d\n", c5471->c_rxcollision);
+ priv->c_rxcollision++;
+ ninfo("c_rxcollision: %d\n", priv->c_rxcollision);
}
if ((rxstatus & EIM_TXDESC_CRCERROR) != 0)
{
- c5471->c_rxcrc++;
- ninfo("c_rxcrc: %d\n", c5471->c_rxcrc);
+ priv->c_rxcrc++;
+ ninfo("c_rxcrc: %d\n", priv->c_rxcrc);
}
if ((rxstatus & EIM_TXDESC_UNDERRUN) != 0)
{
- c5471->c_rxunderrun++;
- ninfo("c_rxunderrun: %d\n", c5471->c_rxunderrun);
+ priv->c_rxunderrun++;
+ ninfo("c_rxunderrun: %d\n", priv->c_rxunderrun);
}
if ((rxstatus & EIM_TXDESC_LOC) != 0)
{
- c5471->c_rxloc++;
- ninfo("c_rxloc: %d\n", c5471->c_rxloc);
+ priv->c_rxloc++;
+ ninfo("c_rxloc: %d\n", priv->c_rxloc);
}
}
}
@@ -1141,7 +1177,7 @@ static void c5471_rxstatus(struct c5471_driver_s *c5471)
* An interrupt was received indicating the availability of a new RX packet
*
* Parameters:
- * c5471 - Reference to the driver state structure
+ * priv - Reference to the driver state structure
*
* Returned Value:
* None
@@ -1150,9 +1186,9 @@ static void c5471_rxstatus(struct c5471_driver_s *c5471)
*
****************************************************************************/
-static void c5471_receive(struct c5471_driver_s *c5471)
+static void c5471_receive(struct c5471_driver_s *priv)
{
- struct net_driver_s *dev = &c5471->c_dev;
+ struct net_driver_s *dev = &priv->c_dev;
uint16_t *packetmem;
bool bmore = true;
int packetlen = 0;
@@ -1166,12 +1202,12 @@ static void c5471_receive(struct c5471_driver_s *c5471)
* the EIM for additional packets that might be received later from the network.
*/
- ninfo("Reading TX CPU desc: %08x\n", c5471->c_txcpudesc);
+ ninfo("Reading TX CPU desc: %08x\n", priv->c_txcpudesc);
while (bmore)
{
/* Words #0 and #1 of descriptor */
- if (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_txcpudesc))
+ if (EIM_TXDESC_OWN_HOST & getreg32(priv->c_txcpudesc))
{
/* No further packets to receive. */
@@ -1182,7 +1218,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
* and update the accumulated packet size
*/
- framelen = (getreg32(c5471->c_txcpudesc) & EIM_TXDESC_BYTEMASK);
+ framelen = (getreg32(priv->c_txcpudesc) & EIM_TXDESC_BYTEMASK);
packetlen += framelen;
/* Check if the received packet will fit within the network packet buffer */
@@ -1191,7 +1227,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
{
/* Get the packet memory from words #2 and #3 of descriptor */
- packetmem = (uint16_t *)getreg32(c5471->c_txcpudesc + sizeof(uint32_t));
+ packetmem = (uint16_t *)getreg32(priv->c_txcpudesc + sizeof(uint32_t));
/* Divide by 2 with round up to get the number of 16-bit words. */
@@ -1201,7 +1237,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
for (i = 0 ; i < nshorts; i++, j++)
{
- /* Copy the data data from the hardware to c5471->c_dev.d_buf 16-bits at
+ /* Copy the data data from the hardware to priv->c_dev.d_buf 16-bits at
* a time.
*/
@@ -1213,7 +1249,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
ninfo("Discarding framelen: %d packetlen\n", framelen, packetlen);
}
- if (getreg32(c5471->c_txcpudesc) & EIM_TXDESC_LIF)
+ if (getreg32(priv->c_txcpudesc) & EIM_TXDESC_LIF)
{
bmore = false;
}
@@ -1222,16 +1258,16 @@ static void c5471_receive(struct c5471_driver_s *c5471)
* the settings of a select few. Can leave descriptor words 2/3 alone.
*/
- putreg32((getreg32(c5471->c_txcpudesc) & (EIM_TXDESC_WRAP_NEXT | EIM_TXDESC_INTRE)),
- c5471->c_txcpudesc);
+ putreg32((getreg32(priv->c_txcpudesc) & (EIM_TXDESC_WRAP_NEXT | EIM_TXDESC_INTRE)),
+ priv->c_txcpudesc);
/* Next, Give ownership of now emptied descriptor back to the Ether Module's SWITCH */
- putreg32((getreg32(c5471->c_txcpudesc) | EIM_TXDESC_OWN_HOST), c5471->c_txcpudesc);
+ putreg32((getreg32(priv->c_txcpudesc) | EIM_TXDESC_OWN_HOST), priv->c_txcpudesc);
/* Advance to the next data buffer */
- c5471_inctxcpu(c5471);
+ c5471_inctxcpu(priv);
}
/* Adjust the packet length to remove the CRC bytes that the network doesn't care about. */
@@ -1241,7 +1277,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
#ifdef CONFIG_C5471_NET_STATS
/* Increment the count of received packets */
- c5471->c_rxpackets++;
+ priv->c_rxpackets++;
#endif
/* If we successfully transferred the data into the network buffer, then pass it on
@@ -1250,7 +1286,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
if (packetlen > 0 && packetlen < CONFIG_NET_ETH_MTU)
{
- /* Set amount of data in c5471->c_dev.d_len. */
+ /* Set amount of data in priv->c_dev.d_len. */
dev->d_len = packetlen;
ninfo("Received packet, packetlen: %d type: %02x\n", packetlen, ntohs(BUF->type));
@@ -1283,7 +1319,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
*/
if (dev->d_len > 0 &&
- (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
+ (EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0)
{
/* Update the Ethernet header with the correct MAC address */
@@ -1302,7 +1338,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
/* And send the packet */
- c5471_transmit(c5471);
+ c5471_transmit(priv);
}
}
else
@@ -1323,7 +1359,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
*/
if (dev->d_len > 0 &&
- (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
+ (EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0)
{
/* Update the Ethernet header with the correct MAC address */
@@ -1342,7 +1378,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
/* And send the packet */
- c5471_transmit(c5471);
+ c5471_transmit(priv);
}
}
else
@@ -1359,9 +1395,9 @@ static void c5471_receive(struct c5471_driver_s *c5471)
*/
if (dev->d_len > 0 &&
- (EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
+ (EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0)
{
- c5471_transmit(c5471);
+ c5471_transmit(priv);
}
}
#endif
@@ -1372,7 +1408,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
/* Increment the count of dropped packets */
nwarn("WARNING: Too big! packetlen: %d\n", packetlen);
- c5471->c_rxdropped++;
+ priv->c_rxdropped++;
}
#endif
}
@@ -1384,7 +1420,7 @@ static void c5471_receive(struct c5471_driver_s *c5471)
* An interrupt was received indicating that the last TX packet(s) is done
*
* Parameters:
- * c5471 - Reference to the driver state structure
+ * priv - Reference to the driver state structure
*
* Returned Value:
* None
@@ -1394,27 +1430,27 @@ static void c5471_receive(struct c5471_driver_s *c5471)
****************************************************************************/
#ifdef CONFIG_C5471_NET_STATS
-static void c5471_txstatus(struct c5471_driver_s *c5471)
+static void c5471_txstatus(struct c5471_driver_s *priv)
{
- uint32_t desc = c5471->c_lastdescstart;
+ uint32_t desc = priv->c_lastdescstart;
uint32_t txstatus;
/* Walk that last packet we just sent to collect xmit status bits. */
txstatus = 0;
- if (c5471->c_lastdescstart && c5471->c_lastdescend)
+ if (priv->c_lastdescstart && priv->c_lastdescend)
{
for (; ; )
{
txstatus |= (getreg32(desc) & EIM_RXDESC_STATUSMASK);
- if (desc == c5471->c_lastdescend)
+ if (desc == priv->c_lastdescend)
{
break;
}
/* This packet is made up of several descriptors, find next one in chain. */
- if (EIM_RXDESC_WRAP_NEXT & getreg32(c5471->c_rxcpudesc))
+ if (EIM_RXDESC_WRAP_NEXT & getreg32(priv->c_rxcpudesc))
{
/* Loop back around to base of descriptor queue. */
@@ -1431,44 +1467,44 @@ static void c5471_txstatus(struct c5471_driver_s *c5471)
{
if ((txstatus & EIM_RXDESC_MISS) != 0)
{
- c5471->c_txmiss++;
- ninfo("c_txmiss: %d\n", c5471->c_txmiss);
+ priv->c_txmiss++;
+ ninfo("c_txmiss: %d\n", priv->c_txmiss);
}
if ((txstatus & EIM_RXDESC_VLAN) != 0)
{
- c5471->c_txvlan++;
- ninfo("c_txvlan: %d\n", c5471->c_txvlan);
+ priv->c_txvlan++;
+ ninfo("c_txvlan: %d\n", priv->c_txvlan);
}
if ((txstatus & EIM_RXDESC_LFRAME) != 0)
{
- c5471->c_txlframe++;
- ninfo("c_txlframe: %d\n", c5471->c_txlframe);
+ priv->c_txlframe++;
+ ninfo("c_txlframe: %d\n", priv->c_txlframe);
}
if ((txstatus & EIM_RXDESC_SFRAME) != 0)
{
- c5471->c_txsframe++;
- ninfo("c_txsframe: %d\n", c5471->c_txsframe);
+ priv->c_txsframe++;
+ ninfo("c_txsframe: %d\n", priv->c_txsframe);
}
if ((txstatus & EIM_RXDESC_CRCERROR) != 0)
{
- c5471->c_txcrc++;
- ninfo("c_txcrc: %d\n", c5471->c_txcrc);
+ priv->c_txcrc++;
+ ninfo("c_txcrc: %d\n", priv->c_txcrc);
}
if ((txstatus & EIM_RXDESC_OVERRUN) != 0)
{
- c5471->c_txoverrun++;
- ninfo("c_txoverrun: %d\n", c5471->c_txoverrun);
+ priv->c_txoverrun++;
+ ninfo("c_txoverrun: %d\n", priv->c_txoverrun);
}
if ((txstatus & EIM_RXDESC_OVERRUN) != 0)
{
- c5471->c_txalign++;
- ninfo("c_txalign: %d\n", c5471->c_txalign);
+ priv->c_txalign++;
+ ninfo("c_txalign: %d\n", priv->c_txalign);
}
}
}
@@ -1481,7 +1517,7 @@ static void c5471_txstatus(struct c5471_driver_s *c5471)
* An interrupt was received indicating that the last TX packet(s) is done
*
* Parameters:
- * c5471 - Reference to the driver state structure
+ * priv - Reference to the driver state structure
*
* Returned Value:
* None
@@ -1490,50 +1526,50 @@ static void c5471_txstatus(struct c5471_driver_s *c5471)
*
****************************************************************************/
-static void c5471_txdone(struct c5471_driver_s *c5471)
+static void c5471_txdone(struct c5471_driver_s *priv)
{
/* If no further xmits are pending, then cancel the TX timeout */
- wd_cancel(c5471->c_txtimeout);
+ wd_cancel(priv->c_txtimeout);
/* Then poll the network for new XMIT data */
- (void)devif_poll(&c5471->c_dev, c5471_txpoll);
+ (void)devif_poll(&priv->c_dev, c5471_txpoll);
}
/****************************************************************************
- * Function: c5471_interrupt
+ * Function: c5471_interrupt_work
*
* Description:
- * Hardware interrupt handler
+ * Perform interrupt related work from the worker thread
*
* Parameters:
- * irq - Number of the IRQ that generated the interrupt
- * context - Interrupt register state save info (architecture-specific)
+ * arg - The argument passed when work_queue() was called.
*
* Returned Value:
* OK on success
*
* Assumptions:
+ * The network is locked.
*
****************************************************************************/
-static int c5471_interrupt(int irq, FAR void *context)
+static void c5471_interrupt_work(FAR void *arg)
{
-#if CONFIG_C5471_NET_NINTERFACES == 1
- register struct c5471_driver_s *c5471 = &g_c5471[0];
-#else
-# error "Additional logic needed to support multiple interfaces"
-#endif
+ FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg;
+
+ /* Process pending Ethernet interrupts */
+
+ net_lock();
/* Get and clear interrupt status bits */
- c5471->c_eimstatus = getreg32(EIM_STATUS);
+ priv->c_eimstatus = getreg32(EIM_STATUS);
/* Handle interrupts according to status bit settings */
/* Check if we received an incoming packet, if so, call c5471_receive() */
- if ((EIM_STATUS_CPU_TX & c5471->c_eimstatus) != 0)
+ if ((EIM_STATUS_CPU_TX & priv->c_eimstatus) != 0)
{
/* An incoming packet has been received by the EIM from the network and
* the interrupt associated with EIM's CPU TX queue has been asserted. It
@@ -1545,17 +1581,17 @@ static int c5471_interrupt(int irq, FAR void *context)
#ifdef CONFIG_C5471_NET_STATS
/* Check for RX errors */
- c5471_rxstatus(c5471);
+ c5471_rxstatus(priv);
#endif
/* Process the received packet */
- c5471_receive(c5471);
+ c5471_receive(priv);
}
/* Check is a packet transmission just completed. If so, call c5471_txdone */
- if ((EIM_STATUS_CPU_RX & c5471->c_eimstatus) != 0)
+ if ((EIM_STATUS_CPU_RX & priv->c_eimstatus) != 0)
{
/* An outgoing packet has been processed by the EIM and the interrupt
* associated with EIM's CPU RX que has been asserted. It is the EIM's
@@ -1566,65 +1602,120 @@ static int c5471_interrupt(int irq, FAR void *context)
#ifdef CONFIG_C5471_NET_STATS
/* Check for TX errors */
- c5471_txstatus(c5471);
+ c5471_txstatus(priv);
#endif
/* Handle the transmission done event */
- c5471_txdone(c5471);
+ c5471_txdone(priv);
}
- /* Enable Ethernet interrupts (perhaps excluding the TX done interrupt if
- * there are no pending transmissions.
+ net_unlock();
+
+ /* Re-enable Ethernet interrupts */
+
+ up_enable_irq(C5471_IRQ_ETHER);
+}
+
+/****************************************************************************
+ * Function: c5471_interrupt
+ *
+ * Description:
+ * Hardware interrupt handler
+ *
+ * Parameters:
+ * irq - Number of the IRQ that generated the interrupt
+ * context - Interrupt register state save info (architecture-specific)
+ *
+ * Returned Value:
+ * OK on success
+ *
+ * Assumptions:
+ *
+ ****************************************************************************/
+
+static int c5471_interrupt(int irq, FAR void *context)
+{
+#if CONFIG_C5471_NET_NINTERFACES == 1
+ register struct c5471_driver_s *priv = &g_c5471[0];
+#else
+# error "Additional logic needed to support multiple interfaces"
+#endif
+
+ /* Disable further Ethernet interrupts. Because Ethernet interrupts are
+ * also disabled if the TX timeout event occurs, there can be no race
+ * condition here.
*/
+ up_disable_irq(C5471_IRQ_ETHER);
+
+ /* TODO: Determine if a TX transfer just completed */
+
+ {
+ /* If a TX transfer just completed, then cancel the TX timeout so
+ * there will be no race condition between any subsequent timeout
+ * expiration and the deferred interrupt processing.
+ */
+
+ wd_cancel(priv->c_txtimeout);
+ }
+
+ /* Cancel any pending poll work */
+
+ work_cancel(ETHWORK, &priv->c_work);
+
+ /* Schedule to perform the interrupt processing on the worker thread. */
+
+ work_queue(ETHWORK, &priv->c_work, c5471_interrupt_work, priv, 0);
return OK;
}
/****************************************************************************
- * Function: c5471_txtimeout
+ * Function: c5471_txtimeout_work
*
* Description:
- * Our TX watchdog timed out. Called from the timer interrupt handler.
- * The last TX never completed. Reset the hardware and start again.
+ * Perform TX timeout related work from the worker thread
*
* Parameters:
- * argc - The number of available arguments
- * arg - The first argument
+ * arg - The argument passed when work_queue() as called.
*
* Returned Value:
- * None
+ * OK on success
*
* Assumptions:
+ * The network is locked.
*
****************************************************************************/
-static void c5471_txtimeout(int argc, uint32_t arg, ...)
+static void c5471_txtimeout_work(FAR void *arg)
{
- struct c5471_driver_s *c5471 = (struct c5471_driver_s *)arg;
+ FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg;
/* Increment statistics */
+ net_lock();
#ifdef CONFIG_C5471_NET_STATS
- c5471->c_txtimeouts++;
- ninfo("c_txtimeouts: %d\n", c5471->c_txtimeouts);
+ priv->c_txtimeouts++;
+ ninfo("c_txtimeouts: %d\n", priv->c_txtimeouts);
#endif
/* Then try to restart the hardware */
- c5471_ifdown(&c5471->c_dev);
- c5471_ifup(&c5471->c_dev);
+ c5471_ifdown(&priv->c_dev);
+ c5471_ifup(&priv->c_dev);
/* Then poll the network for new XMIT data */
- (void)devif_poll(&c5471->c_dev, c5471_txpoll);
+ (void)devif_poll(&priv->c_dev, c5471_txpoll);
+ net_unlock();
}
/****************************************************************************
- * Function: c5471_polltimer
+ * Function: c5471_txtimeout_expiry
*
* Description:
- * Periodic timer handler. Called from the timer interrupt handler.
+ * Our TX watchdog timed out. Called from the timer interrupt handler.
+ * The last TX never completed. Reset the hardware and start again.
*
* Parameters:
* argc - The number of available arguments
@@ -1634,27 +1725,113 @@ static void c5471_txtimeout(int argc, uint32_t arg, ...)
* None
*
* Assumptions:
+ * Global interrupts are disabled by the watchdog logic.
*
****************************************************************************/
-static void c5471_polltimer(int argc, uint32_t arg, ...)
+static void c5471_txtimeout_expiry(int argc, wdparm_t arg, ...)
{
- struct c5471_driver_s *c5471 = (struct c5471_driver_s *)arg;
+ struct c5471_driver_s *priv = (struct c5471_driver_s *)arg;
+
+ /* Disable further Ethernet interrupts. This will prevent some race
+ * conditions with interrupt work. There is still a potential race
+ * condition with interrupt work that is already queued and in progress.
+ */
+
+ up_disable_irq(C5471_IRQ_ETHER);
+
+ /* Cancel any pending poll or interrupt work. This will have no effect
+ * on work that has already been started.
+ */
+
+ work_cancel(ETHWORK, &priv->c_work);
+
+ /* Schedule to perform the TX timeout processing on the worker thread. */
+
+ work_queue(ETHWORK, &priv->c_work, c5471_txtimeout_work, priv, 0);
+}
+
+/****************************************************************************
+ * Function: c5471_poll_work
+ *
+ * Description:
+ * Perform periodic polling from the worker thread
+ *
+ * Parameters:
+ * arg - The argument passed when work_queue() as called.
+ *
+ * Returned Value:
+ * OK on success
+ *
+ * Assumptions:
+ * The network is locked.
+ *
+ ****************************************************************************/
+
+static void c5471_poll_work(FAR void *arg)
+{
+ FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg;
/* Check if the ESM has let go of the RX descriptor giving us access rights
* to submit another Ethernet frame.
*/
- if ((EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
+ net_lock();
+ if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0)
{
/* If so, update TCP timing states and poll the network for new XMIT data */
- (void)devif_timer(&c5471->c_dev, c5471_txpoll);
+ (void)devif_timer(&priv->c_dev, c5471_txpoll);
}
/* Setup the watchdog poll timer again */
- (void)wd_start(c5471->c_txpoll, C5471_WDDELAY, c5471_polltimer, 1, arg);
+ (void)wd_start(priv->c_txpoll, C5471_WDDELAY, c5471_poll_expiry, 1,
+ (wdparm_t)priv);
+ net_unlock();
+}
+
+/****************************************************************************
+ * Function: c5471_poll_expiry
+ *
+ * Description:
+ * Periodic timer handler. Called from the timer interrupt handler.
+ *
+ * Parameters:
+ * argc - The number of available arguments
+ * arg - The first argument
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Global interrupts are disabled by the watchdog logic.
+ *
+ ****************************************************************************/
+
+static void c5471_poll_expiry(int argc, wdparm_t arg, ...)
+{
+ struct c5471_driver_s *priv = (struct c5471_driver_s *)arg;
+
+ /* Is our single work structure available? It may not be if there are
+ * pending interrupt actions.
+ */
+
+ if (work_available(&priv->c_work))
+ {
+ /* Schedule to perform the interrupt processing on the worker thread. */
+
+ work_queue(ETHWORK, &priv->c_work, c5471_poll_work, priv, 0);
+ }
+ else
+ {
+ /* No.. Just re-start the watchdog poll timer, missing one polling
+ * cycle.
+ */
+
+ (void)wd_start(priv->c_txpoll, C5471_WDDELAY, c5471_poll_expiry,
+ 1, arg);
+ }
}
/****************************************************************************
@@ -1677,7 +1854,7 @@ static void c5471_polltimer(int argc, uint32_t arg, ...)
static int c5471_ifup(struct net_driver_s *dev)
{
- struct c5471_driver_s *c5471 = (struct c5471_driver_s *)dev->d_private;
+ struct c5471_driver_s *priv = (struct c5471_driver_s *)dev->d_private;
volatile uint32_t clearbits;
ninfo("Bringing up: %d.%d.%d.%d\n",
@@ -1686,11 +1863,11 @@ static int c5471_ifup(struct net_driver_s *dev)
/* Initilize Ethernet interface */
- c5471_reset(c5471);
+ c5471_reset(priv);
/* Assign the MAC to the device */
- c5471_macassign(c5471);
+ c5471_macassign(priv);
/* Clear pending interrupts by reading the EIM status register */
@@ -1712,11 +1889,12 @@ static int c5471_ifup(struct net_driver_s *dev)
/* Set and activate a timer process */
- (void)wd_start(c5471->c_txpoll, C5471_WDDELAY, c5471_polltimer, 1, (uint32_t)c5471);
+ (void)wd_start(priv->c_txpoll, C5471_WDDELAY, c5471_poll_expiry,
+ 1, (wdparm_t)priv);
/* Enable the Ethernet interrupt */
- c5471->c_bifup = true;
+ priv->c_bifup = true;
up_enable_irq(C5471_IRQ_ETHER);
return OK;
}
@@ -1739,7 +1917,7 @@ static int c5471_ifup(struct net_driver_s *dev)
static int c5471_ifdown(struct net_driver_s *dev)
{
- struct c5471_driver_s *c5471 = (struct c5471_driver_s *)dev->d_private;
+ struct c5471_driver_s *priv = (struct c5471_driver_s *)dev->d_private;
irqstate_t flags;
ninfo("Stopping\n");
@@ -1764,60 +1942,94 @@ static int c5471_ifdown(struct net_driver_s *dev)
/* Cancel the TX poll timer and TX timeout timers */
- wd_cancel(c5471->c_txpoll);
- wd_cancel(c5471->c_txtimeout);
+ wd_cancel(priv->c_txpoll);
+ wd_cancel(priv->c_txtimeout);
/* Reset the device */
- c5471->c_bifup = false;
+ priv->c_bifup = false;
leave_critical_section(flags);
return OK;
}
/****************************************************************************
- * Function: c5471_txavail
+ * Function: c5471_txavail_work
*
* Description:
- * Driver callback invoked when new TX data is available. This is a
- * stimulus perform an out-of-cycle poll and, thereby, reduce the TX
- * latency.
+ * Perform an out-of-cycle poll on the worker thread.
*
* Parameters:
- * dev - Reference to the NuttX driver state structure
+ * arg - Reference to the NuttX driver state structure (cast to void*)
*
* Returned Value:
* None
*
* Assumptions:
- * Called in normal user mode
+ * Called on the higher priority worker thread.
*
****************************************************************************/
-static int c5471_txavail(struct net_driver_s *dev)
+static void c5471_txavail_work(FAR void *arg)
{
- struct c5471_driver_s *c5471 = (struct c5471_driver_s *)dev->d_private;
- irqstate_t flags;
+ FAR struct c5471_driver_s *priv = (FAR struct c5471_driver_s *)arg;
ninfo("Polling\n");
- flags = enter_critical_section();
/* Ignore the notification if the interface is not yet up */
- if (c5471->c_bifup)
+ net_lock();
+ if (priv->c_bifup)
{
/* Check if the ESM has let go of the RX descriptor giving us access
* rights to submit another Ethernet frame.
*/
- if ((EIM_TXDESC_OWN_HOST & getreg32(c5471->c_rxcpudesc)) == 0)
+ if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) == 0)
{
/* If so, then poll the network for new XMIT data */
- (void)devif_poll(&c5471->c_dev, c5471_txpoll);
+ (void)devif_poll(&priv->c_dev, c5471_txpoll);
}
}
- leave_critical_section(flags);
+ net_unlock();
+}
+
+/****************************************************************************
+ * Function: c5471_txavail
+ *
+ * Description:
+ * Driver callback invoked when new TX data is available. This is a
+ * stimulus perform an out-of-cycle poll and, thereby, reduce the TX
+ * latency.
+ *
+ * Parameters:
+ * dev - Reference to the NuttX driver state structure
+ *
+ * Returned Value:
+ * None
+ *
+ * Assumptions:
+ * Called in normal user mode
+ *
+ ****************************************************************************/
+
+static int c5471_txavail(FAR struct net_driver_s *dev)
+{
+ struct c5471_driver_s *priv = (struct c5471_driver_s *)dev->d_private;
+
+ /* Is our single work structure available? It may not be if there are
+ * pending interrupt actions and we will have to ignore the Tx
+ * availability action.
+ */
+
+ if (work_available(&priv->c_work))
+ {
+ /* Schedule to serialize the poll on the worker thread. */
+
+ work_queue(ETHWORK, &priv->c_work, c5471_txavail_work, priv, 0);
+ }
+
return OK;
}
@@ -1895,7 +2107,7 @@ static int c5471_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
*
****************************************************************************/
-static void c5471_eimreset (struct c5471_driver_s *c5471)
+static void c5471_eimreset (struct c5471_driver_s *priv)
{
/* Stop the EIM module clock */
@@ -1925,8 +2137,8 @@ static void c5471_eimreset (struct c5471_driver_s *c5471)
/* All EIM register should now be in there power-up default states */
- c5471->c_lastdescstart = 0;
- c5471->c_lastdescend = 0;
+ priv->c_lastdescstart = 0;
+ priv->c_lastdescend = 0;
}
/****************************************************************************
@@ -1939,7 +2151,7 @@ static void c5471_eimreset (struct c5471_driver_s *c5471)
*
****************************************************************************/
-static void c5471_eimconfig(struct c5471_driver_s *c5471)
+static void c5471_eimconfig(struct c5471_driver_s *priv)
{
volatile uint32_t pbuf;
volatile uint32_t desc;
@@ -2006,7 +2218,7 @@ static void c5471_eimconfig(struct c5471_driver_s *c5471)
/* TX CPU */
ninfo("TX CPU desc: %08x pbuf: %08x\n", desc, pbuf);
- c5471->c_txcpudesc = desc;
+ priv->c_txcpudesc = desc;
putreg32((desc & 0x0000ffff), EIM_CPU_TXBA); /* 16-bit offset address */
for (i = NUM_DESC_TX-1; i >= 0; i--)
{
@@ -2036,7 +2248,7 @@ static void c5471_eimconfig(struct c5471_driver_s *c5471)
/* RX CPU */
ninfo("RX CPU desc: %08x pbuf: %08x\n", desc, pbuf);
- c5471->c_rxcpudesc = desc;
+ priv->c_rxcpudesc = desc;
putreg32((desc & 0x0000ffff), EIM_CPU_RXBA); /* 16-bit offset address */
for (i = NUM_DESC_RX-1; i >= 0; i--)
{
@@ -2147,17 +2359,17 @@ static void c5471_eimconfig(struct c5471_driver_s *c5471)
*
****************************************************************************/
-static void c5471_reset(struct c5471_driver_s *c5471)
+static void c5471_reset(struct c5471_driver_s *priv)
{
#if defined(CONFIG_C5471_PHY_LU3X31T_T64)
ninfo("EIM reset\n");
- c5471_eimreset(c5471);
+ c5471_eimreset(priv);
#endif
ninfo("PHY init\n");
c5471_phyinit();
ninfo("EIM config\n");
- c5471_eimconfig(c5471);
+ c5471_eimconfig(priv);
}
/****************************************************************************
@@ -2172,9 +2384,9 @@ static void c5471_reset(struct c5471_driver_s *c5471)
*
****************************************************************************/
-static void c5471_macassign(struct c5471_driver_s *c5471)
+static void c5471_macassign(struct c5471_driver_s *priv)
{
- struct net_driver_s *dev = &c5471->c_dev;
+ struct net_driver_s *dev = &priv->c_dev;
uint8_t *mptr = dev->d_mac.ether_addr_octet;
register uint32_t tmp;
@@ -2248,6 +2460,7 @@ void up_netinitialize(void)
/* Initialize the driver structure */
memset(g_c5471, 0, CONFIG_C5471_NET_NINTERFACES*sizeof(struct c5471_driver_s));
+ g_c5471[0].c_dev.d_buf = g_pktbuf; /* Single packet buffer */
g_c5471[0].c_dev.d_ifup = c5471_ifup; /* I/F down callback */
g_c5471[0].c_dev.d_ifdown = c5471_ifdown; /* I/F up (new IP address) callback */
g_c5471[0].c_dev.d_txavail = c5471_txavail; /* New TX data callback */
diff --git a/arch/arm/src/calypso/Kconfig b/arch/arm/src/calypso/Kconfig
deleted file mode 100644
index e044280f6269506a88aea11e65cf644a639a958c..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/Kconfig
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# For a description of the syntax of this configuration file,
-# see the file kconfig-language.txt in the NuttX tools repository.
-#
-
-comment "Calypso Configuration Options"
-
-menu "Modem UART Configuration"
-
-config UART_MODEM_BAUD
- int "Modem UART BAUD"
- default 115200
-
-config UART_MODEM_PARITY
- int "Modem UART parity"
- default 0
- ---help---
- Modem UART parity. 0=None, 1=Odd, 2=Even. Default: None
-
-config UART_MODEM_BITS
- int "Modem UART number of bits"
- default 8
- ---help---
- Modem UART number of bits. Default: 8
-
-config UART_MODEM_2STOP
- int "Modem UART two stop bits"
- default 0
- ---help---
- 0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
-
-config UART_MODEM_RXBUFSIZE
- int "Modem UART Rx buffer size"
- default 256
- ---help---
- Modem UART Rx buffer size. Default: 256
-
-config UART_MODEM_TXBUFSIZE
- int "Modem UART Tx buffer size"
- default 256
- ---help---
- Modem UART Tx buffer size. Default: 256
-
-config UART_MODEM_HWFLOWCONTROL
- bool "Hardware flow control"
- default n
- ---help---
- Enabled Modem UART hardware flow control. Default: n
-
-endmenu
-
-menu "IrDA UART Configuration"
-
-config UART_IRDA_BAUD
- int "IrDA UART BAUD"
- default 115200
-
-config UART_IRDA_PARITY
- int "IrDA UART parity"
- default 0
- ---help---
- IrDA UART parity. 0=None, 1=Odd, 2=Even. Default: None
-
-config UART_IRDA_BITS
- int "IrDA UART number of bits"
- default 8
- ---help---
- IrDA UART number of bits. Default: 8
-
-config UART_IRDA_2STOP
- int "IrDA UART two stop bits"
- default 0
- ---help---
- 0=1 stop bit, 1=Two stop bits. Default: 1 stop bit
-
-config UART_IRDA_RXBUFSIZE
- int "IrDA UART Rx buffer size"
- default 256
- ---help---
- IrDA UART Rx buffer size. Default: 256
-
-config UART_IRDA_TXBUFSIZE
- int "IrDA UART Tx buffer size"
- default 256
- ---help---
- IrDA UART Tx buffer size. Default: 256
-
-config UART_IRDA_HWFLOWCONTROL
- bool "Hardware flow control"
- default n
- ---help---
- Enabled IrDA UART hardware flow control. Default: n
-
-endmenu
-
-choice
- prompt "Serial Console Selection"
- default SERIAL_CONSOLE_NONE
- depends on DEV_CONSOLE
-
-# See drivers/Kconfig
-config USE_SERCOMM_CONSOLE
- bool "SERCOMM console"
- select SERCOMM_CONSOLE
-
-config SERIAL_MODEM_CONSOLE
- bool "Serial console on modem UART"
-
-config SERIAL_IRDA_CONSOLE
- bool "Serial console on IrDA UART"
-
-config SERIAL_CONSOLE_NONE
- bool "No serial console"
-
-endchoice
diff --git a/arch/arm/src/calypso/Make.defs b/arch/arm/src/calypso/Make.defs
deleted file mode 100644
index c3d6b6b0bb53d4c625c3e08aefc5c8445bc6dc01..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/Make.defs
+++ /dev/null
@@ -1,71 +0,0 @@
-############################################################################
-# calypso/Make.defs
-#
-# Copyright (C) 2007, 2013-2015 Gregory Nutt. All rights reserved.
-# Author: Gregory Nutt
-#
-# Copyright (C) 2011 Stefan Richter. All rights reserved.
-# Author: Stefan Richter
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# 3. Neither the name Gregory Nutt nor the names of its contributors may be
-# used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-############################################################################
-
-HEAD_ASRC = calypso_head.S
-
-CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_vectors.S
-CMN_ASRCS += up_nommuhead.S vfork.S
-CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copyfullstate.c
-CMN_CSRCS += up_createstack.c up_dataabort.c up_mdelay.c up_udelay.c
-CMN_CSRCS += up_doirq.c up_exit.c up_idle.c up_initialstate.c up_initialize.c
-CMN_CSRCS += up_interruptcontext.c up_prefetchabort.c up_releasepending.c
-CMN_CSRCS += up_releasestack.c up_reprioritizertr.c up_schedulesigaction.c
-CMN_CSRCS += up_sigdeliver.c up_stackframe.c up_syscall.c up_unblocktask.c
-CMN_CSRCS += up_undefinedinsn.c up_usestack.c calypso_power.c up_vfork.c
-
-ifeq ($(CONFIG_ELF),y)
-CMN_CSRCS += up_elf.c
-else ifeq ($(CONFIG_MODULE),y)
-CMN_CSRCS += up_elf.c
-endif
-
-ifeq ($(CONFIG_STACK_COLORATION),y)
-CMN_CSRCS += up_checkstack.c
-endif
-
-CHIP_ASRCS = calypso_lowputc.S
-CHIP_CSRCS = calypso_irq.c calypso_heap.c calypso_serial.c clock.c
-CHIP_CSRCS += calypso_uwire.c calypso_armio.c calypso_keypad.c
-
-ifeq ($(CONFIG_SPI),y)
-CHIP_CSRCS += calypso_spi.c
-endif
-
-ifneq ($(CONFIG_SCHED_TICKLESS),y)
-CHIP_CSRCS += calypso_timer.c
-endif
diff --git a/arch/arm/src/calypso/calypso_armio.c b/arch/arm/src/calypso/calypso_armio.c
deleted file mode 100644
index c210fa34dce0e2b030308775ad9a30056e5f5d04..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_armio.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
- * Driver for shared features of ARMIO modules
- *
- * Copyright (C) 2011 Stefan Richter. All rights reserved.
- * Author: Stefan Richter
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#include
-
-#include
-#include
-
-#include
-#include
-
-#include "up_arch.h"
-
-/****************************************************************************
- * HW access
- ****************************************************************************/
-
-#define BASE_ADDR_ARMIO 0xfffe4800
-#define ARMIO_REG(x) (BASE_ADDR_ARMIO + (x))
-
-enum armio_reg {
- LATCH_IN = 0x00,
- LATCH_OUT = 0x02,
- IO_CNTL = 0x04,
- CNTL_REG = 0x06,
- LOAD_TIM = 0x08,
- KBR_LATCH_REG = 0x0a,
- KBC_REG = 0x0c,
- BUZZ_LIGHT_REG = 0x0e,
- LIGHT_LEVEL = 0x10,
- BUZZER_LEVEL = 0x12,
- GPIO_EVENT_MODE = 0x14,
- KBD_GPIO_INT = 0x16,
- KBD_GPIO_MASKIT = 0x18,
- GPIO_DEBOUNCING = 0x1a,
- GPIO_LATCH = 0x1c,
-};
-
-#define KBD_INT (1 << 0)
-#define GPIO_INT (1 << 1)
-
-/****************************************************************************
- * ARMIO interrupt handler
- * forward keypad events
- * forward GPIO events
- ****************************************************************************/
-
-static int kbd_gpio_irq(int irq, uint32_t *regs)
-{
- return calypso_kbd_irq(irq, regs);
-}
-
-/****************************************************************************
- * Initialize ARMIO
- ****************************************************************************/
-
-void calypso_armio(void)
-{
- /* Enable ARMIO clock */
-
- putreg16(1 << 5, ARMIO_REG(CNTL_REG));
-
- /* Mask GPIO interrupt and keypad interrupt */
-
- putreg16(KBD_INT | GPIO_INT, ARMIO_REG(KBD_GPIO_MASKIT));
-
- /* Attach and enable the interrupt */
-
- irq_attach(IRQ_KEYPAD_GPIO, (xcpt_t)kbd_gpio_irq);
- up_enable_irq(IRQ_KEYPAD_GPIO);
-}
diff --git a/arch/arm/src/calypso/calypso_head.S b/arch/arm/src/calypso/calypso_head.S
deleted file mode 100644
index eb83b68516f261043edeb713474cb864fda7b5d2..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_head.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Place a branch to the real head at the entry point */
-.section .text.start
- b __start
-
-
-/* Exception Vectors like they are needed for the exception vector
- indirection of the internal boot ROM. The following section must
- be liked to appear at 0x80001c */
-.section .text.exceptions
-_undef_instr:
- b up_vectorundefinsn
-_sw_interr:
- b up_vectorswi
-_prefetch_abort:
- b up_vectorprefetch
-_data_abort:
- b up_vectordata
-_reserved:
- b _reserved
-_irq:
- b up_vectorirq
-_fiq:
- b up_vectorfiq
diff --git a/arch/arm/src/calypso/calypso_irq.c b/arch/arm/src/calypso/calypso_irq.c
deleted file mode 100644
index 85f4f084589bb7ac4e68b25f5761191a3bdcfdd3..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_irq.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/****************************************************************************
- * arch/arm/src/calypso/calypso_irq.c
- * Driver for Calypso IRQ controller
- *
- * (C) 2010 by Harald Welte
- * (C) 2011 by Stefan Richter
- *
- * This source code is derivated from Osmocom-BB project and was
- * relicensed as BSD with permission from original authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include
-
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-
-#include "arm.h"
-#include "up_internal.h"
-#include "up_arch.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define BASE_ADDR_IRQ 0xfffffa00
-#define BASE_ADDR_IBOOT_EXC 0x0080001C
-
-enum irq_reg
-{
- IT_REG1 = 0x00,
- IT_REG2 = 0x02,
- MASK_IT_REG1 = 0x08,
- MASK_IT_REG2 = 0x0a,
- IRQ_NUM = 0x10,
- FIQ_NUM = 0x12,
- IRQ_CTRL = 0x14,
-};
-
-#define ILR_IRQ(x) (0x20 + (x*2))
-#define IRQ_REG(x) (BASE_ADDR_IRQ + (x))
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#endif
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/* g_current_regs[] holds a references to the current interrupt level
- * register storage structure. If is non-NULL only during interrupt
- * processing. Access to g_current_regs[] must be through the macro
- * CURRENT_REGS for portability.
- */
-
-volatile uint32_t *g_current_regs[1];
-extern uint32_t _exceptions;
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static uint8_t default_irq_prio[] =
-{
- [IRQ_WATCHDOG] = 0xff,
- [IRQ_TIMER1] = 0xff,
- [IRQ_TIMER2] = 0xff,
- [IRQ_TSP_RX] = 0,
- [IRQ_TPU_FRAME] = 3,
- [IRQ_TPU_PAGE] = 0xff,
- [IRQ_SIMCARD] = 0xff,
- [IRQ_UART_MODEM] = 8,
- [IRQ_KEYPAD_GPIO] = 4,
- [IRQ_RTC_TIMER] = 9,
- [IRQ_RTC_ALARM_I2C] = 10,
- [IRQ_ULPD_GAUGING] = 2,
- [IRQ_EXTERNAL] = 12,
- [IRQ_SPI] = 0xff,
- [IRQ_DMA] = 0xff,
- [IRQ_API] = 0xff,
- [IRQ_SIM_DETECT] = 0,
- [IRQ_EXTERNAL_FIQ] = 7,
- [IRQ_UART_IRDA] = 2,
- [IRQ_ULPD_GSM_TIMER] = 1,
- [IRQ_GEA] = 0xff,
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-static void _irq_enable(enum irq_nr nr, int enable)
-{
- uintptr_t reg = IRQ_REG(MASK_IT_REG1);
- uint16_t val;
-
- if (nr > 15)
- {
- reg = IRQ_REG(MASK_IT_REG2);
- nr -= 16;
- }
-
- val = getreg16(reg);
- if (enable)
- {
- val &= ~(1 << nr);
- }
- else
- {
- val |= (1 << nr);
- }
-
- putreg16(val, reg);
-}
-
-static void set_default_priorities(void)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(default_irq_prio); i++)
- {
- uint16_t val;
- uint8_t prio = default_irq_prio[i];
-
- if (prio > 31)
- {
- prio = 31;
- }
-
- val = getreg16(IRQ_REG(ILR_IRQ(i)));
- val &= ~(0x1f << 2);
- val |= prio << 2;
-
- /* Make edge mode default. Hopefully causes less trouble */
-
- val |= 0x02;
-
- putreg16(val, IRQ_REG(ILR_IRQ(i)));
- }
-}
-
-/* Install the exception handlers to where the ROM loader jumps */
-
-static void calypso_exceptions_install(void)
-{
- uint32_t *exceptions_dst = (uint32_t *) BASE_ADDR_IBOOT_EXC;
- uint32_t *exceptions_src = &_exceptions;
- int i;
-
- for (i = 0; i < 7; i++)
- {
- *exceptions_dst++ = *exceptions_src++;
- }
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_irqinitialize
- *
- * Description:
- * Setup the IRQ and FIQ controllers
- *
- ****************************************************************************/
-
-void up_irqinitialize(void)
-{
- /* Prepare hardware */
-
- calypso_exceptions_install();
- CURRENT_REGS = NULL;
-
- /* Switch to internal ROM */
-
- calypso_bootrom(1);
-
- /* Set default priorities */
-
- set_default_priorities();
-
- /* Mask all interrupts off */
-
- putreg16(0xffff, IRQ_REG(MASK_IT_REG1));
- putreg16(0xffff, IRQ_REG(MASK_IT_REG2));
-
- /* clear all pending interrupts */
- putreg16(0, IRQ_REG(IT_REG1));
- putreg16(0, IRQ_REG(IT_REG2));
-
- /* Enable interrupts globally to the ARM core */
-
-#ifndef CONFIG_SUPPRESS_INTERRUPTS
- up_irq_restore(SVC_MODE | PSR_F_BIT);
-#endif
-}
-
-/****************************************************************************
- * Name: up_disable_irq
- *
- * Description:
- * Disable the IRQ specified by 'irq'
- *
- ****************************************************************************/
-
-void up_disable_irq(int irq)
-{
- if ((unsigned)irq < NR_IRQS)
- {
- _irq_enable(irq, 0);
- }
-}
-
-/****************************************************************************
- * Name: up_enable_irq
- *
- * Description:
- * Enable the IRQ specified by 'irq'
- *
- ****************************************************************************/
-
-void up_enable_irq(int irq)
-{
- if ((unsigned)irq < NR_IRQS)
- {
- _irq_enable(irq, 1);
- }
-}
-
-/****************************************************************************
- * Name: up_prioritize_irq
- *
- * Description:
- * Set the priority of an IRQ.
- *
- ****************************************************************************/
-
-#ifndef CONFIG_ARCH_IRQPRIO
-int up_prioritize_irq(int nr, int prio)
-{
- uint16_t val;
-
- if (prio == -1)
- {
- prio = default_irq_prio[nr];
- }
-
- if (prio > 31)
- {
- prio = 31;
- }
-
- val = prio << 2;
- putreg16(val, IRQ_REG(ILR_IRQ(nr)));
-
- return 0;
-}
-#endif
-
-/****************************************************************************
- * Entry point for interrupts
- ****************************************************************************/
-
-void up_decodeirq(uint32_t *regs)
-{
- uint8_t num, tmp;
- uint32_t *saved_regs;
-
- /* XXX: What is this???
- * Passed to but ignored in IRQ handlers
- * Only valid meaning is apparently non-NULL == IRQ context */
-
- saved_regs = (uint32_t *)CURRENT_REGS;
- CURRENT_REGS = regs;
-
- /* Detect & deliver the IRQ */
-
- num = getreg8(IRQ_REG(IRQ_NUM)) & 0x1f;
- irq_dispatch(num, regs);
-
- /* Start new IRQ agreement */
-
- tmp = getreg8(IRQ_REG(IRQ_CTRL));
- tmp |= 0x01;
- putreg8(tmp, IRQ_REG(IRQ_CTRL));
-
- CURRENT_REGS = saved_regs;
-}
-
-/****************************************************************************
- * Entry point for FIQs
- ****************************************************************************/
-
-void calypso_fiq(void)
-{
- uint8_t num, tmp;
- uint32_t *regs;
-
- /* XXX: What is this???
- * Passed to but ignored in IRQ handlers
- * Only valid meaning is apparently non-NULL == IRQ context */
-
- regs = (uint32_t *)CURRENT_REGS;
- CURRENT_REGS = (uint32_t *)#
-
- /* Detect & deliver like an IRQ but we are in FIQ context */
-
- num = getreg8(IRQ_REG(FIQ_NUM)) & 0x1f;
- irq_dispatch(num, regs);
-
- /* Start new FIQ agreement */
-
- tmp = getreg8(IRQ_REG(IRQ_CTRL));
- tmp |= 0x02;
- putreg8(tmp, IRQ_REG(IRQ_CTRL));
-
- CURRENT_REGS = regs;
-}
diff --git a/arch/arm/src/calypso/calypso_keypad.c b/arch/arm/src/calypso/calypso_keypad.c
deleted file mode 100644
index 2430667ca553012fdcec47709e6576c4ec6d3eb0..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_keypad.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/****************************************************************************
- * Driver for Calypso keypad hardware
- *
- * Copyright (C) 2011 Stefan Richter. All rights reserved.
- * Author: Stefan Richter
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-/****************************************************************************
- * HW access
- ****************************************************************************/
-
-#define BASE_ADDR_ARMIO 0xfffe4800
-#define ARMIO_REG(x) ((void *)BASE_ADDR_ARMIO + (x))
-
-enum armio_reg
-{
- LATCH_IN = 0x00,
- LATCH_OUT = 0x02,
- IO_CNTL = 0x04,
- CNTL_REG = 0x06,
- LOAD_TIM = 0x08,
- KBR_LATCH_REG = 0x0a,
- KBC_REG = 0x0c,
- BUZZ_LIGHT_REG = 0x0e,
- LIGHT_LEVEL = 0x10,
- BUZZER_LEVEL = 0x12,
- GPIO_EVENT_MODE = 0x14,
- KBD_GPIO_INT = 0x16,
- KBD_GPIO_MASKIT = 0x18,
- GPIO_DEBOUNCING = 0x1a,
- GPIO_LATCH = 0x1c,
-};
-
-#define KBD_INT (1 << 0)
-#define GPIO_INT (1 << 1)
-
-/****************************************************************************
- * Decoder functions for matrix and power button
- ****************************************************************************/
-
-static int btn_dec(uint32_t * btn_state, uint8_t col, uint8_t reg,
- char *buf, size_t buflen, size_t * len)
-{
- uint8_t diff = (*btn_state ^ reg) & 0x1f;
-
- while (diff)
- {
- uint8_t val = diff & ~(diff - 1);
- uint8_t sc = val >> 1;
- sc |= sc << 2;
- sc += col;
- sc += (sc & 0x20) ? 0x26 : 0x3f;
-
- if (reg & val)
- {
- sc |= 0x20;
- }
-
- /* Check for space in buffer and dispatch */
-
- if (*len < buflen)
- {
- buf[(*len)++] = sc;
- }
- else
- {
- break;
- }
-
- /* Only change diff if dispatched/buffer not full */
-
- diff ^= val;
- }
-
- /* Store new state of the buttons (but only if they where dispatch) */
-
- *btn_state >>= 5;
-#ifdef INCLUDE_ALL_COLS
- *btn_state |= (reg ^ diff) << 20;
-#else
- *btn_state |= (reg ^ diff) << 15;
-#endif
- return diff;
-}
-
-static int pwr_btn_dec(uint32_t * state, uint8_t reg, char *buf, size_t * len)
-{
- if (reg)
- {
- /* Check for pressed power button. If pressed, ignore other
- * buttons since it collides with an entire row.
- */
-
- if (~*state & 0x80000000)
- {
- buf[0] = 'z';
- *len = 1;
- *state |= 0x80000000;
- }
-
- return 1; /* break loop in caller */
- }
- else
- {
- /* Check for released power button. */
-
- if (*state & 0x80000000)
- {
- buf[0] = 'Z';
- *len = 1;
-
- *state &= 0x7fffffff;
-
- /* Don't scan others when released; might trigger
- * false keystrokes otherwise
- */
-
- return 1;
- }
- }
-
- return 0; /* Continue with other columns */
-}
-
-/****************************************************************************
- * Keypad: Fileops Prototypes and Structures
- ****************************************************************************/
-
-typedef FAR struct file file_t;
-
-static int keypad_open(file_t * filep);
-static int keypad_close(file_t * filep);
-static ssize_t keypad_read(file_t * filep, FAR char *buffer, size_t buflen);
-#ifndef CONFIG_DISABLE_POLL
-static int keypad_poll(file_t * filep, FAR struct pollfd *fds, bool setup);
-#endif
-
-static const struct file_operations keypad_ops =
-{
- keypad_open, /* open */
- keypad_close, /* close */
- keypad_read, /* read */
- 0, /* write */
- 0, /* seek */
- 0, /* ioctl */
-#ifndef CONFIG_DISABLE_POLL
- keypad_poll /* poll */
-#endif
-};
-
-static sem_t kbdsem;
-
-/****************************************************************************
- * Keypad: Fileops
- ****************************************************************************/
-
-static int keypad_open(file_t * filep)
-{
- register uint16_t reg;
-
- /* Unmask keypad interrupt */
-
- reg = readw(ARMIO_REG(KBD_GPIO_MASKIT));
- writew(reg & ~KBD_INT, ARMIO_REG(KBD_GPIO_MASKIT));
-
- return OK;
-}
-
-static int keypad_close(file_t * filep)
-{
- register uint16_t reg;
-
- /* Mask keypad interrupt */
-
- reg = readw(ARMIO_REG(KBD_GPIO_MASKIT));
- writew(reg | KBD_INT, ARMIO_REG(KBD_GPIO_MASKIT));
-
- return OK;
-}
-
-static ssize_t keypad_read(file_t * filep, FAR char *buf, size_t buflen)
-{
- static uint32_t btn_state = 0;
- register uint16_t reg;
- uint16_t col, col_mask;
- size_t len = 0;
-
- if (buf == NULL || buflen < 1)
- {
- /* Well... nothing to do */
-
- return -EINVAL;
- }
-
-retry:
- col = 1;
- col_mask = 0x1e;
-
- if (!btn_state)
- {
- /* Drive all cols low such that all buttons cause events */
-
- writew(0, ARMIO_REG(KBC_REG));
-
- /* No button currently pressed, use IRQ */
-
- reg = readw(ARMIO_REG(KBD_GPIO_MASKIT));
- writew(reg & ~KBD_INT, ARMIO_REG(KBD_GPIO_MASKIT));
- sem_wait(&kbdsem);
- }
- else
- {
- writew(0x1f, ARMIO_REG(KBC_REG));
- usleep(80000);
- }
-
- /* Scan columns */
-
-#ifdef INCLUDE_ALL_COLS
- while (col <= 6)
- {
-#else
- while (col <= 5)
- {
-#endif
- /* Read keypad latch and immediately set new column since
- * synchronization takes about 5usec. For the 1st round, the
- * interrupt has prepared this and the context switch takes
- * long enough to serve as a delay.
- */
-
- reg = readw(ARMIO_REG(KBR_LATCH_REG));
- writew(col_mask, ARMIO_REG(KBC_REG));
-
- /* Turn pressed buttons into 1s */
-
- reg = 0x1f & ~reg;
-
- if (col == 1)
- {
- /* Power/End switch */
-
- if (pwr_btn_dec(&btn_state, reg, buf, &len))
- {
- break;
- }
- }
- else
- {
- /* Non-power switches */
-
- if (btn_dec(&btn_state, col, reg, buf, buflen, &len))
- {
- break;
- }
- }
-
- /* Select next column and respective mask */
-
- col_mask = 0x1f & ~(1 << col++);
-
- /* We have to wait for synchronization of the inputs. The
- * processing is too fast if no/few buttons are processed.
- */
-
- usleep(5);
-
- /* XXX: usleep seems to suffer hugh overhead. Better this!?
- * If nothing else can be done, it's overhead still wastes
- * time 'usefully'.
- */
- /* sched_yield(); up_udelay(2); */
- }
-
- /* If we don't have anything to return, retry to avoid EOF */
-
- if (!len)
- {
- goto retry;
- }
-
- return len;
-}
-
-/****************************************************************************
- * Keypad interrupt handler
- * mask interrupts
- * prepare column drivers for scan
- * posts keypad semaphore
- ****************************************************************************/
-
-int calypso_kbd_irq(int irq, uint32_t * regs)
-{
- register uint16_t reg;
-
- /* Mask keypad interrupt */
-
- reg = readw(ARMIO_REG(KBD_GPIO_MASKIT));
- writew(reg | KBD_INT, ARMIO_REG(KBD_GPIO_MASKIT));
-
- /* Turn off column drivers */
-
- writew(0x1f, ARMIO_REG(KBC_REG));
-
- /* Let the userspace know */
-
- sem_post(&kbdsem);
-
- return 0;
-}
-
-/****************************************************************************
- * Initialize device, add /dev/... nodes
- ****************************************************************************/
-
-void up_keypad(void)
-{
- /* Semaphore; helps leaving IRQ ctx as soon as possible */
-
- sem_init(&kbdsem, 0, 0);
-
- /* Drive cols low in idle state such that all buttons cause events */
-
- writew(0, ARMIO_REG(KBC_REG));
-
- (void)register_driver("/dev/keypad", &keypad_ops, 0444, NULL);
-}
-
-int keypad_kbdinit(void)
-{
- calypso_armio();
- up_keypad();
-
- return OK;
-}
diff --git a/arch/arm/src/calypso/calypso_power.c b/arch/arm/src/calypso/calypso_power.c
deleted file mode 100644
index 11b51a629bf63315435e70725a0df8bd4f47ed56..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_power.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include
-
-#include
-
-#include
-#include
-
-#include "calypso_spi.h"
-
-/****************************************************************************
- * Name: board_power_off
- *
- * Description:
- * Power off the board.
- *
- * If this function returns, then it was not possible to power-off the
- * board due to some other constraints.
- *
- * Input Parameters:
- * status - Status information provided with the power off event.
- *
- * Returned Value:
- * If this function returns, then it was not possible to power-off the
- * board due to some constraints. The return value int this case is a
- * board-specific reason for the failure to shutdown.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_BOARDCTL_POWEROFF
-int board_power_off(int status)
-{
- struct spi_dev_s *spi = calypso_spibus_initialize(0);
- uint16_t tx;
-
- SPI_SETBITS(spi, 16);
- (void)SPI_HWFEATURES(spi, 0);
-
- tx = (1 << 6) | (1 << 1);
- SPI_SNDBLOCK(spi, &tx, 1);
-
- tx = (1 << 6) | (30 << 1);
- SPI_SNDBLOCK(spi, &tx, 1);
-
- return 0;
-}
-#endif
diff --git a/arch/arm/src/calypso/calypso_serial.c b/arch/arm/src/calypso/calypso_serial.c
deleted file mode 100644
index 0c4a44c0c14d90c08489ed35ac9e388a12c10aab..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_serial.c
+++ /dev/null
@@ -1,968 +0,0 @@
-/****************************************************************************
- * arch/arm/src/calypso/calypso_serial.c
- *
- * Copyright (C) 2011 Stefan Richter. All rights reserved.
- * Author: Stefan Richter
- *
- * based on c5471/c5471_serial.c
- * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include "chip.h"
-#include "up_arch.h"
-#include "up_internal.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define BASE_BAUD 115200
-
-#if defined(CONFIG_UART_IRDA_HWFLOWCONTROL) || defined(CONFIG_UART_MODEM_HWFLOWCONTROL)
-# define CONFIG_UART_HWFLOWCONTROL
-#endif
-
-#if UART_FCR_OFFS == UART_EFR_OFFS
-# define UART_MULTIPLEX_REGS
-
-/* HW flow control not supported yet */
-
-# undef CONFIG_UART_HWFLOWCONTROL
-#endif
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-struct uart_regs_s
-{
- uint32_t ier;
- uint32_t lcr;
- uint32_t fcr;
-#ifdef CONFIG_UART_HWFLOWCONTROL
- uint32_t efr;
- uint32_t tcr;
-#endif
-};
-
-struct up_dev_s
-{
- unsigned int uartbase; /* Base address of UART registers */
- unsigned int baud_base; /* Base baud for conversions */
- unsigned int baud; /* Configured baud */
- uint8_t xmit_fifo_size; /* Size of transmit FIFO */
- uint8_t irq; /* IRQ associated with this UART */
- uint8_t parity; /* 0=none, 1=odd, 2=even */
- uint8_t bits; /* Number of bits (7 or 8) */
-#ifdef CONFIG_UART_HWFLOWCONTROL
- bool flowcontrol; /* true: Hardware flow control
- * is enabled. */
-#endif
- bool stopbits2; /* true: Configure with 2
- * stop bits instead of 1 */
- struct uart_regs_s regs; /* Shadow copy of readonly regs */
-
-#ifdef CONFIG_SERCOMM_CONSOLE
- bool sercomm; /* Call sercomm in interrupt if true */
-#endif
-};
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static int up_setup(struct uart_dev_s *dev);
-static void up_shutdown(struct uart_dev_s *dev);
-static int up_attach(struct uart_dev_s *dev);
-static void up_detach(struct uart_dev_s *dev);
-static int up_interrupt(int irq, void *context);
-static int up_ioctl(struct file *filep, int cmd, unsigned long arg);
-static int up_receive(struct uart_dev_s *dev, unsigned int *status);
-static void up_rxint(struct uart_dev_s *dev, bool enable);
-static bool up_rxavailable(struct uart_dev_s *dev);
-static void up_send(struct uart_dev_s *dev, int ch);
-static void up_txint(struct uart_dev_s *dev, bool enable);
-static bool up_txready(struct uart_dev_s *dev);
-static bool up_txempty(struct uart_dev_s *dev);
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static const struct uart_ops_s g_uart_ops =
-{
- .setup = up_setup,
- .shutdown = up_shutdown,
- .attach = up_attach,
- .detach = up_detach,
- .ioctl = up_ioctl,
- .receive = up_receive,
- .rxint = up_rxint,
- .rxavailable = up_rxavailable,
-#ifdef CONFIG_SERIAL_IFLOWCONTROL
- .rxflowcontrol = NULL,
-#endif
- .send = up_send,
- .txint = up_txint,
- .txready = up_txready,
- .txempty = up_txempty,
-};
-
-/* I/O buffers */
-
-static char g_irdarxbuffer[CONFIG_UART_IRDA_RXBUFSIZE];
-static char g_irdatxbuffer[CONFIG_UART_IRDA_TXBUFSIZE];
-static char g_modemrxbuffer[CONFIG_UART_MODEM_RXBUFSIZE];
-static char g_modemtxbuffer[CONFIG_UART_MODEM_TXBUFSIZE];
-
-/* This describes the state of the C5471 serial IRDA port. */
-
-static struct up_dev_s g_irdapriv =
-{
- .xmit_fifo_size = UART_IRDA_XMIT_FIFO_SIZE,
- .baud_base = BASE_BAUD,
- .uartbase = UART_IRDA_BASE,
- .baud = CONFIG_UART_IRDA_BAUD,
- .irq = UART_IRQ_IRDA,
- .parity = CONFIG_UART_IRDA_PARITY,
- .bits = CONFIG_UART_IRDA_BITS,
-#ifdef CONFIG_UART_IRDA_HWFLOWCONTROL
- .flowcontrol = true,
-#endif
- .stopbits2 = CONFIG_UART_IRDA_2STOP,
-
-#ifdef CONFIG_SERCOMM_CONSOLE
- .sercomm = false,
-#endif
-};
-
-static uart_dev_t g_irdaport =
-{
- .recv =
- {
- .size = CONFIG_UART_IRDA_RXBUFSIZE,
- .buffer = g_irdarxbuffer,
- },
- .xmit =
- {
- .size = CONFIG_UART_IRDA_TXBUFSIZE,
- .buffer = g_irdatxbuffer,
- },
- .ops = &g_uart_ops,
- .priv = &g_irdapriv,
-};
-
-/* This describes the state of the C5471 serial Modem port. */
-
-static struct up_dev_s g_modempriv =
-{
- .xmit_fifo_size = UART_XMIT_FIFO_SIZE,
- .baud_base = BASE_BAUD,
- .uartbase = UART_MODEM_BASE,
- .baud = CONFIG_UART_MODEM_BAUD,
- .irq = UART_IRQ_MODEM,
- .parity = CONFIG_UART_MODEM_PARITY,
- .bits = CONFIG_UART_MODEM_BITS,
-#ifdef CONFIG_UART_MODEM_HWFLOWCONTROL
- .flowcontrol = true,
-#endif
- .stopbits2 = CONFIG_UART_MODEM_2STOP,
-
-#ifdef CONFIG_SERCOMM_CONSOLE
- .sercomm = false,
-#endif
-};
-
-static uart_dev_t g_modemport =
-{
- .recv =
- {
- .size = CONFIG_UART_MODEM_RXBUFSIZE,
- .buffer = g_modemrxbuffer,
- },
- .xmit =
- {
- .size = CONFIG_UART_MODEM_TXBUFSIZE,
- .buffer = g_modemtxbuffer,
- },
- .ops = &g_uart_ops,
- .priv = &g_modempriv,
-};
-
-/* Now, which one with be tty0/console and which tty1? */
-
-#ifdef CONFIG_SERIAL_IRDA_CONSOLE
-# define CONSOLE_DEV g_irdaport
-# define TTYS0_DEV g_irdaport
-# define TTYS1_DEV g_modemport
-#else
-# define CONSOLE_DEV g_modemport
-# define TTYS0_DEV g_modemport
-# define TTYS1_DEV g_irdaport
-#endif
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_inserial
- ****************************************************************************/
-
-static inline uint32_t up_inserial(struct up_dev_s *priv, uint32_t offset)
-{
-#if UART_REGISTER_BITS == 8
- return getreg8(priv->uartbase + offset);
-#elif UART_REGISTER_BITS == 32
- return getreg32(priv->uartbase + offset);
-#else
-#error Unsupported number of bits set in UART_REGISTER_BITS
-#endif
-}
-
-/****************************************************************************
- * Name: up_serialout
- ****************************************************************************/
-
-static inline void up_serialout(struct up_dev_s *priv, uint32_t offset, uint32_t value)
-{
-#if UART_REGISTER_BITS == 8
- putreg8(value & 0xff, priv->uartbase + offset);
-#elif UART_REGISTER_BITS == 32
- putreg32(value, priv->uartbase + offset);
-#endif
-}
-
-/****************************************************************************
- * Name: up_disableuartint
- ****************************************************************************/
-
-static inline void up_disableuartint(struct up_dev_s *priv, uint16_t *ier)
-{
- if (ier)
- {
- *ier = priv->regs.ier & UART_IER_INTMASK;
- }
- priv->regs.ier &= ~UART_IER_INTMASK;
- up_serialout(priv, UART_IER_OFFS, priv->regs.ier);
-}
-
-/****************************************************************************
- * Name: up_restoreuartint
- ****************************************************************************/
-
-static inline void up_restoreuartint(struct up_dev_s *priv, uint16_t ier)
-{
- priv->regs.ier |= ier & (UART_IER_RECVINT | UART_IER_XMITINT);
- up_serialout(priv, UART_IER_OFFS, priv->regs.ier);
-}
-
-/****************************************************************************
- * Name: up_waittxready
- ****************************************************************************/
-
-static inline void up_waittxready(struct up_dev_s *priv)
-{
- int tmp;
-
- for (tmp = 1000 ; tmp > 0 ; tmp--)
- {
- if ((up_inserial(priv, UART_SSR_OFFS) & UART_SSR_TXFULL) == 0)
- {
- break;
- }
- }
-}
-/****************************************************************************
- * Name: up_disablebreaks
- ****************************************************************************/
-
-static inline void up_disablebreaks(struct up_dev_s *priv)
-{
- priv->regs.lcr &= ~UART_LCR_BOC;
- up_serialout(priv, UART_LCR_OFFS, priv->regs.lcr);
-}
-
-/****************************************************************************
- * Name: up_enablebreaks
- ****************************************************************************/
-
-static inline void up_enablebreaks(struct up_dev_s *priv)
-{
- priv->regs.lcr |= UART_LCR_BOC;
- up_serialout(priv, UART_LCR_OFFS, priv->regs.lcr);
-}
-
-/****************************************************************************
- * Name: up_setrate
- ****************************************************************************/
-
-static inline void up_setrate(struct up_dev_s *priv, unsigned int rate)
-{
- uint32_t div_bit_rate;
-
- switch (rate)
- {
- case 115200:
- div_bit_rate = BAUD_115200;
- break;
- case 57600:
- div_bit_rate = BAUD_57600;
- break;
- case 38400:
- div_bit_rate = BAUD_38400;
- break;
- case 19200:
- div_bit_rate = BAUD_19200;
- break;
- case 4800:
- div_bit_rate = BAUD_4800;
- break;
- case 2400:
- div_bit_rate = BAUD_2400;
- break;
- case 1200:
- div_bit_rate = BAUD_1200;
- break;
- case 9600:
- default:
- div_bit_rate = BAUD_9600;
- break;
- }
-
-#ifdef UART_DIV_BIT_RATE_OFFS
- up_serialout(priv, UART_DIV_BIT_RATE_OFFS, div_bit_rate);
-#else
- up_serialout(priv, UART_DIV_LOW_OFFS, div_bit_rate);
- up_serialout(priv, UART_DIV_HIGH_OFFS, div_bit_rate >> 8);
-#endif
-}
-
-/****************************************************************************
- * Name: up_setup
- *
- * Description:
- * Configure the UART baud, bits, parity, fifos, etc. This
- * method is called the first time that the serial port is
- * opened.
- *
- ****************************************************************************/
-#include
-static int up_setup(struct uart_dev_s *dev)
-{
-#ifndef CONFIG_SUPPRESS_UART_CONFIG
- struct up_dev_s *priv = dev->priv;
- unsigned int cval;
-
- if (priv->bits == 7)
- {
- cval = UART_LCR_7BITS;
- }
- else
- {
- cval = UART_LCR_8BITS;
- }
-
- if (priv->stopbits2)
- {
- cval |= UART_LCR_2STOP;
- }
-
- if (priv->parity == 1) /* Odd parity */
- {
- cval |= (UART_LCR_PAREN | UART_LCR_PARODD);
- }
- else if (priv->parity == 2) /* Even parity */
- {
- cval |= (UART_LCR_PAREN | UART_LCR_PAREVEN);
- }
-
- /* Both the IrDA and MODEM UARTs support RESET and UART mode. */
-
- up_serialout(priv, UART_MDR_OFFS, MDR_RESET_MODE);
- up_serialout(priv, UART_LCR_OFFS, 0xbf);
- up_serialout(priv, UART_XON1_OFFS, 0x00);
- up_serialout(priv, UART_XON2_OFFS, 0x00);
- up_serialout(priv, UART_XOFF1_OFFS, 0x00);
- up_serialout(priv, UART_XOFF2_OFFS, 0x00);
- up_serialout(priv, UART_EFR_OFFS, 0x00);
- up_serialout(priv, UART_LCR_OFFS, 0x00);
- up_mdelay(5);
-
- up_serialout(priv, UART_MDR_OFFS, MDR_UART_MODE);
- up_mdelay(5);
-
- priv->regs.ier = up_inserial(priv, UART_IER_OFFS);
- priv->regs.lcr = up_inserial(priv, UART_LCR_OFFS);
-#ifdef CONFIG_UART_HWFLOWCONTROL
- if (priv->flowcontrol)
- {
- priv->regs.efr = up_inserial(priv, UART_EFR_OFFS);
- priv->regs.tcr = up_inserial(priv, UART_TCR_OFFS);
- }
-#endif
-
- up_disableuartint(priv, NULL);
-
-#ifdef UART_MULTIPLEX_REGS
- up_serialout(priv, UART_LCR_OFFS, 0x00bf);
-#endif
-
- up_serialout(priv, UART_EFR_OFFS, 0x0010); /* Unprotect enhanced control */
-
-#ifdef UART_MULTIPLEX_REGS
- priv->regs.lcr = 0x80;
- up_serialout(priv, UART_LCR_OFFS, priv->regs.lcr);
- //up_serialout(priv, UART_MCR_OFFS, 1 << 4); /* loopback */
-#endif
-
- up_serialout(priv, UART_TFCR_OFFS, 0); /* Reset to 0 */
- up_serialout(priv, UART_RFCR_OFFS, UART_FCR_RX_CLR); /* Clear RX fifo */
- up_serialout(priv, UART_TFCR_OFFS, UART_FCR_TX_CLR); /* Clear TX fifo */
- priv->regs.fcr = UART_FCR_FIFO_EN;
- up_serialout(priv, UART_TFCR_OFFS, priv->regs.fcr); /* Enable RX/TX fifos */
-
- up_disablebreaks(priv);
-
- /* Set the RX and TX trigger levels to the minimum */
-
- priv->regs.fcr = (priv->regs.fcr & 0xffffff0f) | UART_FCR_FTL;
- up_serialout(priv, UART_RFCR_OFFS, priv->regs.fcr);
-
- up_setrate(priv, priv->baud);
-
-#ifdef UART_MULTIPLEX_REGS
- up_serialout(priv, UART_SCR_OFFS, 1); /* Disable DMA */
- priv->regs.lcr = (uint32_t)cval; /* Configure mode, return to THR/RHR */
-#else
- priv->regs.lcr &= 0xffffffe0; /* clear original field, and... */
- priv->regs.lcr |= (uint32_t)cval; /* Set new bits in that field. */
-#endif
- up_serialout(priv, UART_LCR_OFFS, priv->regs.lcr);
-
-#ifdef CONFIG_UART_HWFLOWCONTROL
- if (priv->flowcontrol)
- {
- /* Set the FIFO level triggers for flow control
- * Halt = 48 bytes, resume = 12 bytes
- */
-
- priv->regs.tcr = (priv->regs.tcr & 0xffffff00) | 0x0000003c;
- up_serialout(priv, UART_TCR_OFFS, priv->regs.tcr);
-
- /* Enable RTS/CTS flow control */
-
- priv->regs.efr |= 0x000000c0;
- up_serialout(priv, UART_EFR_OFFS, priv->regs.efr);
- }
- else
- {
- /* Disable RTS/CTS flow control */
-
- priv->regs.efr &= 0xffffff3f;
- up_serialout(priv, UART_EFR_OFFS, priv->regs.efr);
- }
-#endif
-#endif
- return OK;
-}
-
-/****************************************************************************
- * Name: up_shutdown
- *
- * Description:
- * Disable the UART. This method is called when the serial port is closed
- *
- ****************************************************************************/
-
-static void up_shutdown(struct uart_dev_s *dev)
-{
- struct up_dev_s *priv = (struct up_dev_s *)CONSOLE_DEV.priv;
- up_disableuartint(priv, NULL);
-}
-
-/****************************************************************************
- * Name: up_attach
- *
- * Description:
- * Configure the UART to operation in interrupt driven mode. This method is
- * called when the serial port is opened. Normally, this is just after the
- * the setup() method is called, however, the serial console may operate in
- * a non-interrupt driven mode during the boot phase.
- *
- * RX and TX interrupts are not enabled when by the attach method (unless the
- * hardware supports multiple levels of interrupt enabling). The RX and TX
- * interrupts are not enabled until the txint() and rxint() methods are called.
- *
- ****************************************************************************/
-
-static int up_attach(struct uart_dev_s *dev)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- int ret;
-
- /* Attach and enable the IRQ */
-
- ret = irq_attach(priv->irq, up_interrupt);
- if (ret == OK)
- {
- /* Enable the interrupt (RX and TX interrupts are still disabled
- * in the UART
- */
-
- up_enable_irq(priv->irq);
- }
-
- return ret;
-}
-
-/****************************************************************************
- * Name: up_detach
- *
- * Description:
- * Detach UART interrupts. This method is called when the serial port is
- * closed normally just before the shutdown method is called. The exception is
- * the serial console which is never shutdown.
- *
- ****************************************************************************/
-
-static void up_detach(struct uart_dev_s *dev)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- up_disable_irq(priv->irq);
- irq_detach(priv->irq);
-}
-
-/****************************************************************************
- * Name: up_interrupt
- *
- * Description:
- * This is the UART interrupt handler. It will be invoked
- * when an interrupt received on the 'irq' It should call
- * uart_transmitchars or uart_receivechar to perform the
- * appropriate data transfers. The interrupt handling logic\
- * must be able to map the 'irq' number into the approprite
- * uart_dev_s structure in order to call these functions.
- *
- ****************************************************************************/
-
-static int up_interrupt(int irq, void *context)
-{
- struct uart_dev_s *dev = NULL;
- struct up_dev_s *priv;
- volatile uint32_t cause;
-
- if (g_irdapriv.irq == irq)
- {
- dev = &g_irdaport;
- }
- else if (g_modempriv.irq == irq)
- {
- dev = &g_modemport;
- }
- else
- {
- PANIC();
- }
- priv = (struct up_dev_s *)dev->priv;
-
- cause = up_inserial(priv, UART_ISR_OFFS) & 0x0000003f;
-
- if ((cause & 0x0000000c) == 0x0000000c)
- {
- uint32_t ier_val = 0;
-
- /* Is this an interrupt from the IrDA UART? */
-
- if (irq == UART_IRQ_IRDA)
- {
- /* Save the currently enabled IrDA UART interrupts
- * so that we can restore the IrDA interrupt state
- * below.
- */
-
- ier_val = up_inserial(priv, UART_IER_OFFS);
-
- /* Then disable all IrDA UART interrupts */
-
- up_serialout(priv, UART_IER_OFFS, 0);
- }
-
- /* Receive characters from the RX fifo */
-
-#ifdef CONFIG_SERCOMM_CONSOLE
- if (priv->sercomm)
- {
- sercomm_recvchars(dev);
- }
- else
-#endif
- {
- uart_recvchars(dev);
- }
-
- /* read UART_RHR to clear int condition
- * toss = up_inserialchar(priv,&status);
- */
-
- /* Is this an interrupt from the IrDA UART? */
-
- if (irq == UART_IRQ_IRDA)
- {
- /* Restore the IrDA UART interrupt enables */
-
- up_serialout(priv, UART_IER_OFFS, ier_val);
- }
- }
- else if ((cause & 0x0000000c) == 0x00000004)
- {
-#ifdef CONFIG_SERCOMM_CONSOLE
- if (priv->sercomm)
- {
- sercomm_recvchars(dev);
- }
- else
-#endif
- {
- uart_recvchars(dev);
- }
- }
-
- if ((cause & 0x00000002) != 0)
- {
-#ifdef CONFIG_SERCOMM_CONSOLE
- if (priv->sercomm)
- {
- sercomm_xmitchars(dev);
- }
- else
-#endif
- {
- uart_xmitchars(dev);
- }
- }
-
- return OK;
-}
-
-/****************************************************************************
- * Name: up_ioctl
- *
- * Description:
- * All ioctl calls will be routed through this method
- *
- ****************************************************************************/
-
-static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
-{
- struct inode *inode = filep->f_inode;
- struct uart_dev_s *dev = inode->i_private;
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- int ret = OK;
-
- switch (cmd)
- {
-#ifdef CONFIG_SERIAL_TIOCSERGSTRUCT
- case TIOCSERGSTRUCT:
- {
- struct up_dev_s *user = (struct up_dev_s *)arg;
- if (!user)
- {
- ret = -EINVAL;
- }
- else
- {
- memcpy(user, dev, sizeof(struct up_dev_s));
- }
- }
- break;
-#endif
-
- case TIOCSBRK: /* BSD compatibility: Turn break on, unconditionally */
- {
- irqstate_t flags = enter_critical_section();
- up_enablebreaks(priv);
- leave_critical_section(flags);
- }
- break;
-
- case TIOCCBRK: /* BSD compatibility: Turn break off, unconditionally */
- {
- irqstate_t flags;
- flags = enter_critical_section();
- up_disablebreaks(priv);
- leave_critical_section(flags);
- }
- break;
-
- default:
- ret = -ENOTTY;
- break;
- }
-
- return ret;
-}
-
-/****************************************************************************
- * Name: up_receive
- *
- * Description:
- * Called (usually) from the interrupt level to receive one character from
- * the UART. Error bits associated with the receipt are provided in the
- * the return 'status'.
- *
- ****************************************************************************/
-
-static int up_receive(struct uart_dev_s *dev, unsigned int *status)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- uint32_t rhr;
- uint32_t lsr;
-
- /* Construct a 16bit status word that uses the high byte to
- * hold the status bits associated with framing,parity,break
- * and a low byte that holds error bits of LSR for
- * conditions such as overflow, etc.
- */
-
- rhr = up_inserial(priv, UART_RHR_OFFS);
- lsr = up_inserial(priv, UART_LSR_OFFS);
-
- *status = (unsigned int)((rhr & 0x0000ff00) | (lsr & 0x000000ff));
-
- return rhr & 0x000000ff;
-}
-
-/****************************************************************************
- * Name: up_rxint
- *
- * Description:
- * Call to enable or disable RX interrupts
- *
- ****************************************************************************/
-
-static void up_rxint(struct uart_dev_s *dev, bool enable)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- if (enable)
- {
-#ifndef CONFIG_SUPPRESS_SERIAL_INTS
- priv->regs.ier |= UART_IER_RECVINT;
- up_serialout(priv, UART_IER_OFFS, priv->regs.ier);
-#endif
- }
- else
- {
- priv->regs.ier &= ~UART_IER_RECVINT;
- up_serialout(priv, UART_IER_OFFS, priv->regs.ier);
- }
-}
-
-/****************************************************************************
- * Name: up_rxavailable
- *
- * Description:
- * Return true if the receive fifo is not empty
- *
- ****************************************************************************/
-
-static bool up_rxavailable(struct uart_dev_s *dev)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- return up_inserial(priv, UART_LSR_OFFS) & UART_RX_FIFO_NOEMPTY;
-}
-
-/****************************************************************************
- * Name: up_send
- *
- * Description:
- * This method will send one byte on the UART
- *
- ****************************************************************************/
-
-static void up_send(struct uart_dev_s *dev, int ch)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- up_serialout(priv, UART_THR_OFFS, (uint8_t)ch);
-}
-
-/****************************************************************************
- * Name: up_txint
- *
- * Description:
- * Call to enable or disable TX interrupts
- *
- ****************************************************************************/
-
-static void up_txint(struct uart_dev_s *dev, bool enable)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- if (enable)
- {
-#ifndef CONFIG_SUPPRESS_SERIAL_INTS
- priv->regs.ier |= UART_IER_XMITINT;
- up_serialout(priv, UART_IER_OFFS, priv->regs.ier);
-#endif
- }
- else
- {
- priv->regs.ier &= ~UART_IER_XMITINT;
- up_serialout(priv, UART_IER_OFFS, priv->regs.ier);
- }
-}
-
-/****************************************************************************
- * Name: up_txready
- *
- * Description:
- * Return true if the tranmsit fifo is not full
- *
- ****************************************************************************/
-
-static bool up_txready(struct uart_dev_s *dev)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- return (up_inserial(priv, UART_SSR_OFFS) & UART_SSR_TXFULL) == 0;
-}
-
-/****************************************************************************
- * Name: up_txempty
- *
- * Description:
- * Return true if the transmit fifo is empty
- *
- ****************************************************************************/
-
-static bool up_txempty(struct uart_dev_s *dev)
-{
- struct up_dev_s *priv = (struct up_dev_s *)dev->priv;
- return (up_inserial(priv, UART_LSR_OFFS) & UART_LSR_TREF) != 0;
-}
-
-/****************************************************************************
- * Public Funtions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_earlyserialinit
- *
- * Description:
- * Performs the low level UART initialization early in
- * debug so that the serial console will be available
- * during bootup. This must be called before up_serialinit.
- *
- ****************************************************************************/
-
-void up_earlyserialinit(void)
-{
- up_disableuartint(TTYS0_DEV.priv, NULL);
- up_disableuartint(TTYS1_DEV.priv, NULL);
-
- CONSOLE_DEV.isconsole = true;
- up_setup(&CONSOLE_DEV);
-}
-
-/****************************************************************************
- * Name: up_serialinit
- *
- * Description:
- * Register serial console and serial ports. This assumes
- * that up_earlyserialinit was called previously.
- *
- ****************************************************************************/
-
-void up_serialinit(void)
-{
-#ifdef CONFIG_SERCOMM_CONSOLE
- ((struct up_dev_s *)TTYS0_DEV.priv)->sercomm = true;
- (void)sercomm_register("/dev/console", &TTYS0_DEV);
- (void)uart_register("/dev/ttyS0", &TTYS1_DEV);
-#else
- (void)uart_register("/dev/console", &CONSOLE_DEV);
- (void)uart_register("/dev/ttyS0", &TTYS0_DEV);
- (void)uart_register("/dev/ttyS1", &TTYS1_DEV);
-#endif
-}
-
-/****************************************************************************
- * Name: up_putc
- *
- * Description:
- * Provide priority, low-level access to support OS debug
- * writes
- *
- ****************************************************************************/
-
-int up_putc(int ch)
-{
- struct up_dev_s *priv = (struct up_dev_s *)CONSOLE_DEV.priv;
- uint16_t ier;
-
- up_disableuartint(priv, &ier);
- up_waittxready(priv);
- up_serialout(priv, UART_THR_OFFS, (uint8_t)ch);
-
- /* Check for LF */
-
- if (ch == '\n')
- {
- /* Add CR */
-
- up_waittxready(priv);
- up_serialout(priv, UART_THR_OFFS, '\r');
- }
-
- up_waittxready(priv);
- up_restoreuartint(priv, ier);
- return ch;
-}
-
diff --git a/arch/arm/src/calypso/calypso_spi.c b/arch/arm/src/calypso/calypso_spi.c
deleted file mode 100644
index 36727927c43680dfb23f20f173a80efeb0b14822..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_spi.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/****************************************************************************
- * arch/arm/src/calypso/calypso_spi.c
- * SPI driver for TI Calypso
- *
- * Copyright (C) 2010 Harald Welte
- * Copyright (C) 2011 Stefan Richter
- *
- * Part of this source code is derivated from Osmocom-BB project and was
- * relicensed as BSD with permission from original authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#include "up_arch.h"
-#include "calypso_spi.h"
-
-#warning "MOST OF SPI API IS INCOMPLETE! (Wrapper around Osmocom driver)"
-extern void spi_init(void);
-extern int spi_xfer(uint8_t dev_idx, uint8_t bitlen, const void *dout, void *din);
-
-#ifndef CONFIG_SPI_EXCHANGE
-#error "Calypso HW only supports exchange. Enable CONFIG_SPI_EXCHANGE!"
-#endif
-
-struct calypso_spidev_s
-{
- struct spi_dev_s spidev; /* External driver interface */
- int nbits; /* Number of transfered bits */
- sem_t exclsem; /* Supports mutually exclusive access */
-};
-
-static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
-{
- struct calypso_spidev_s *priv = (struct calypso_spidev_s *)dev;
-
- if (lock)
- {
- /* Take the semaphore (perhaps waiting) */
-
- while (sem_wait(&priv->exclsem) != 0)
- {
- /* The only case that an error should occur here is if the wait
- * was awakened by a signal.
- */
-
- DEBUGASSERT(errno == EINTR);
- }
- }
- else
- {
- (void)sem_post(&priv->exclsem);
- }
-
- return OK;
-}
-
-/* STUBS! */
-
-static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
- bool selected)
-{
-}
-
-static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency)
-{
- return frequency;
-}
-
-static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode)
-{
-}
-
-/* Osmocom wrapper */
-
-static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
-{
- ((FAR struct calypso_spidev_s *)dev)->nbits = nbits;
-}
-
-static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
- FAR void *rxbuffer, size_t nwords)
-{
- FAR struct calypso_spidev_s *priv = (FAR struct calypso_spidev_s *)dev;
- size_t i;
-
- for (i = 0; i < nwords; i++)
- {
- spi_xfer(0, priv->nbits, txbuffer + i, rxbuffer + i);
- }
-}
-
-static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
-{
- uint16_t buf = wd;
- spi_exchange(dev, &buf, &buf, 1);
- return buf;
-}
-
-static const struct spi_ops_s g_spiops =
-{
- .lock = spi_lock,
- .select = spi_select,
- .setfrequency = spi_setfrequency,
- .setmode = spi_setmode,
- .setbits = spi_setbits,
-#ifdef CONFIG_SPI_HWFEATURES
- .hwfeatures = 0,
-#endif
- .status = 0,
-#ifdef CONFIG_SPI_CMDDATA
- .cmddata = 0,
-#endif
- .send = spi_send,
-#ifdef CONFIG_SPI_EXCHANGE
- .exchange = spi_exchange,
-#else
- .sndblock = spi_sndblock,
- .recvblock = spi_recvblock,
-#endif
- .registercallback = 0,
-};
-
-static struct calypso_spidev_s g_spidev =
-{
- .spidev = { &g_spiops },
- .nbits = 0,
- .exclsem = SEM_INITIALIZER(1)
-};
-
-void spi_init(void)
-{
- putreg16(SPI_SET1_EN_CLK | SPI_SET1_WR_IRQ_DIS | SPI_SET1_RDWR_IRQ_DIS,
- SPI_REG(REG_SET1));
-
- putreg16(0x0001, SPI_REG(REG_SET2));
-}
-
-int spi_xfer(uint8_t dev_idx, uint8_t bitlen, const void *dout, void *din)
-{
- uint8_t bytes_per_xfer;
- uint8_t reg_status, reg_ctrl = 0;
- uint32_t tmp;
-
- if (bitlen == 0)
- {
- return 0;
- }
-
- if (bitlen > 32)
- {
- return -1;
- }
-
- if (dev_idx > 4)
- {
- return -1;
- }
-
- bytes_per_xfer = bitlen / 8;
- if (bitlen % 8)
- {
- bytes_per_xfer ++;
- }
-
- reg_ctrl |= (bitlen - 1) << SPI_CTRL_NB_SHIFT;
- reg_ctrl |= (dev_idx & 0x7) << SPI_CTRL_AD_SHIFT;
-
- if (bitlen <= 8)
- {
- tmp = *(uint8_t *)dout;
- tmp <<= 24 + (8-bitlen); /* align to MSB */
- }
- else if (bitlen <= 16)
- {
- tmp = *(uint16_t *)dout;
- tmp <<= 16 + (16-bitlen); /* align to MSB */
- }
- else
- {
- tmp = *(uint32_t *)dout;
- tmp <<= (32-bitlen); /* align to MSB */
- }
-
- spiinfo("spi_xfer(dev_idx=%u, bitlen=%u, data_out=0x%08x): ",
- dev_idx, bitlen, tmp);
-
- /* fill transmit registers */
-
- putreg16(tmp >> 16, SPI_REG(REG_TX_MSB));
- putreg16(tmp & 0xffff, SPI_REG(REG_TX_LSB));
-
- /* initiate transfer */
-
- if (din)
- {
- reg_ctrl |= SPI_CTRL_RDWR;
- }
- else
- {
- reg_ctrl |= SPI_CTRL_WR;
- }
-
- putreg16(reg_ctrl, SPI_REG(REG_CTRL));
- spiinfo("reg_ctrl=0x%04x ", reg_ctrl);
-
- /* wait until the transfer is complete */
-
- while (1)
- {
- reg_status = getreg16(SPI_REG(REG_STATUS));
- spiinfo("status=0x%04x ", reg_status);
- if (din && (reg_status & SPI_STATUS_RE))
- {
- break;
- }
- else if (reg_status & SPI_STATUS_WE)
- {
- break;
- }
- }
-
- /* FIXME: calibrate how much delay we really need (seven 13MHz cycles) */
-
- usleep(1000);
-
- if (din)
- {
- tmp = getreg16(SPI_REG(REG_RX_MSB)) << 16;
- tmp |= getreg16(SPI_REG(REG_RX_LSB));
- spiinfo("data_in=0x%08x ", tmp);
-
- if (bitlen <= 8)
- {
- *(uint8_t *)din = tmp & 0xff;
- }
- else if (bitlen <= 16)
- {
- *(uint16_t *)din = tmp & 0xffff;
- }
- else
- {
- *(uint32_t *)din = tmp;
- }
- }
-
- spiinfo("\n");
-
- return 0;
-}
-
-/****************************************************************************
- * Name: calypso_spibus_initialize
- *
- * Description:
- * Initialize the selected SPI port
- *
- * Input Parameter:
- * Port number (for hardware that has mutiple SPI interfaces)
- *
- * Returned Value:
- * Valid SPI device structure reference on succcess; a NULL on failure
- *
- ****************************************************************************/
-
-FAR struct spi_dev_s *calypso_spibus_initialize(int port)
-{
- switch (port)
- {
- case 0: /* SPI master device */
- spi_init();
- return (FAR struct spi_dev_s *)&g_spidev;
-
- case 1: /* uWire device */
- return NULL;
-
- default:
- return NULL;
- }
-}
diff --git a/arch/arm/src/calypso/calypso_spi.h b/arch/arm/src/calypso/calypso_spi.h
deleted file mode 100644
index 70ca2ad9d0a826788a96d1af5d70865b142801b3..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_spi.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef ___ARCH_ARM_SRC_CALYPSO_CALYPSO_SPI_H
-#define ___ARCH_ARM_SRC_CALYPSO_CALYPSO_SPI_H
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#define BASE_ADDR_SPI 0xfffe3000
-#define SPI_REG(n) (BASE_ADDR_SPI+(n))
-
-#define SPI_SET1_EN_CLK (1 << 0)
-#define SPI_SET1_WR_IRQ_DIS (1 << 4)
-#define SPI_SET1_RDWR_IRQ_DIS (1 << 5)
-
-#define SPI_CTRL_RDWR (1 << 0)
-#define SPI_CTRL_WR (1 << 1)
-#define SPI_CTRL_NB_SHIFT 2
-#define SPI_CTRL_AD_SHIFT 7
-
-#define SPI_STATUS_RE (1 << 0) /* Read End */
-#define SPI_STATUS_WE (1 << 1) /* Write End */
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-enum spi_regs
-{
- REG_SET1 = 0x00,
- REG_SET2 = 0x02,
- REG_CTRL = 0x04,
- REG_STATUS = 0x06,
- REG_TX_LSB = 0x08,
- REG_TX_MSB = 0x0a,
- REG_RX_LSB = 0x0c,
- REG_RX_MSB = 0x0e,
-};
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Name: calypso_spibus_initialize
- *
- * Description:
- * Initialize the selected SPI port
- *
- * Input Parameter:
- * Port number (for hardware that has mutiple SPI interfaces)
- *
- * Returned Value:
- * Valid SPI device structure reference on succcess; a NULL on failure
- *
- ****************************************************************************/
-
-FAR struct spi_dev_s *calypso_spibus_initialize(int port);
-
-#endif /* ___ARCH_ARM_SRC_CALYPSO_CALYPSO_SPI_H */
diff --git a/arch/arm/src/calypso/calypso_timer.c b/arch/arm/src/calypso/calypso_timer.c
deleted file mode 100644
index 86626c5de64944b6b6c854b9445965517e0e4c95..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_timer.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/****************************************************************************
- * arch/arm/src/calypso/calypso_timer.c
- * Calypso DBB internal Timer Driver
- *
- * (C) 2010 by Harald Welte
- * (C) 2011 by Stefan Richter
- *
- * This source code is derivated from Osmocom-BB project and was
- * relicensed as BSD with permission from original authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include "up_arch.h"
-
-#define BASE_ADDR_TIMER 0xfffe3800
-#define TIMER2_OFFSET 0x3000
-
-#define TIMER_REG(n, m) (((n)-1) ? (BASE_ADDR_TIMER + TIMER2_OFFSET + (m)) : (BASE_ADDR_TIMER + (m)))
-
-enum timer_reg
-{
- CNTL_TIMER = 0x00,
- LOAD_TIMER = 0x02,
- READ_TIMER = 0x04,
-};
-
-enum timer_ctl
-{
- CNTL_START = (1 << 0),
- CNTL_AUTO_RELOAD = (1 << 1),
- CNTL_CLOCK_ENABLE = (1 << 5),
-};
-
-/* Regular Timers (1 and 2) */
-
-void hwtimer_enable(int num, int on)
-{
- uint8_t ctl;
-
- if (num < 1 || num > 2)
- {
- printf("Unknown timer %d\n", num);
- return;
- }
-
- ctl = getreg8(TIMER_REG(num, CNTL_TIMER));
- if (on)
- {
- ctl |= CNTL_START | CNTL_CLOCK_ENABLE;
- }
- else
- {
- ctl &= ~CNTL_START;
- }
-
- putreg8(ctl, TIMER_REG(num, CNTL_TIMER));
-}
-
-void hwtimer_config(int num, uint8_t pre_scale, int auto_reload)
-{
- uint8_t ctl;
-
- ctl = (pre_scale & 0x7) << 2;
- if (auto_reload)
- ctl |= CNTL_AUTO_RELOAD;
-
- putreg8(ctl, TIMER_REG(num, CNTL_TIMER));
-}
-
-void hwtimer_load(int num, uint16_t val)
-{
- putreg16(val, TIMER_REG(num, LOAD_TIMER));
-}
-
-uint16_t hwtimer_read(int num)
-{
- uint8_t ctl = getreg8(TIMER_REG(num, CNTL_TIMER));
-
- /* Somehow a read results in an abort */
-
- if ((ctl & (CNTL_START | CNTL_CLOCK_ENABLE)) != (CNTL_START | CNTL_CLOCK_ENABLE))
- {
- return 0xffff;
- }
-
- return getreg16(TIMER_REG(num, READ_TIMER));
-}
-
-/****************************************************************************
- * Watchdog Timer
- ****************************************************************************/
-
-#define BASE_ADDR_WDOG 0xfffff800
-#define WDOG_REG(m) (BASE_ADDR_WDOG + m)
-
-enum wdog_reg
-{
- WD_CNTL_TIMER = CNTL_TIMER,
- WD_LOAD_TIMER = LOAD_TIMER,
- WD_READ_TIMER = 0x02,
- WD_MODE = 0x04,
-};
-
-enum wdog_ctl
-{
- WD_CTL_START = (1 << 7),
- WD_CTL_AUTO_RELOAD = (1 << 8)
-};
-
-enum wdog_mode
-{
- WD_MODE_DIS_ARM = 0xF5,
- WD_MODE_DIS_CONFIRM = 0xA0,
- WD_MODE_ENABLE = (1 << 15)
-};
-
-#define WD_CTL_PRESCALE(value) (((value)&0x07) << 9)
-
-static void wdog_irq(__unused enum irq_nr nr)
-{
- puts("=> WATCHDOG\n");
-}
-
-void wdog_enable(int on)
-{
- if (!on)
- {
- putreg16(WD_MODE_DIS_ARM, WDOG_REG(WD_MODE));
- putreg16(WD_MODE_DIS_CONFIRM, WDOG_REG(WD_MODE));
- }
-}
-
-void wdog_reset(void)
-{
- /* Enable watchdog */
-
- putreg16(WD_MODE_ENABLE, WDOG_REG(WD_MODE));
-
- /* Force expiration */
-
- putreg16(0x0000, WDOG_REG(WD_LOAD_TIMER));
- putreg16(0x0000, WDOG_REG(WD_LOAD_TIMER));
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Function: up_timerisr
- *
- * Description:
- * The timer ISR will perform a variety of services for
- * various portions of the systems.
- *
- ****************************************************************************/
-
-int up_timerisr(int irq, uint32_t *regs)
-{
- /* Process timer interrupt */
-
- sched_process_timer();
- return 0;
-}
-
-/****************************************************************************
- * Function: up_timer_initialize
- *
- * Description:
- * Setup Calypso HW timer 2 to cause system ticks.
- *
- * This function is called during start-up to initialize
- * the timer interrupt.
- *
- ****************************************************************************/
-
-void up_timer_initialize(void)
-{
- up_disable_irq(IRQ_SYSTIMER);
-
- /* The timer runs at 13MHz / 32, i.e. 406.25kHz */
- /* 4062 ticks until expiry yields 100Hz interrupt */
-
- hwtimer_load(2, 4062);
- hwtimer_config(2, 0, 1);
- hwtimer_enable(2, 1);
-
- /* Attach and enable the timer interrupt */
-
- irq_attach(IRQ_SYSTIMER, (xcpt_t)up_timerisr);
- up_enable_irq(IRQ_SYSTIMER);
-}
diff --git a/arch/arm/src/calypso/calypso_uwire.c b/arch/arm/src/calypso/calypso_uwire.c
deleted file mode 100644
index fe2c33b7cc152392786c3e19cd7890b0c42b8c9f..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/calypso_uwire.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
- * arch/arm/src/calypso/calypso_uwire.c
- * Driver for Calypso uWire Master Controller
- *
- * (C) 2010 by Sylvain Munaut
- *
- * This source code is derivated from Osmocom-BB project and was
- * relicensed as BSD with permission from original authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include
-#include
-#include
-
-#include "up_arch.h"
-
-#define BASE_ADDR_UWIRE 0xfffe4000
-#define UWIRE_REG(n) (BASE_ADDR_UWIRE+(n))
-
-enum uwire_regs
-{
- REG_DATA = 0x00,
- REG_CSR = 0x02,
- REG_SR1 = 0x04,
- REG_SR2 = 0x06,
- REG_SR3 = 0x08,
-};
-
-#define UWIRE_CSR_BITS_RD(n) (((n) & 0x1f) << 0)
-#define UWIRE_CSR_BITS_WR(n) (((n) & 0x1f) << 5)
-#define UWIRE_CSR_IDX(n) (((n) & 3) << 10)
-#define UWIRE_CSR_CS_CMD (1 << 12)
-#define UWIRE_CSR_START (1 << 13)
-#define UWIRE_CSR_CSRB (1 << 14)
-#define UWIRE_CSR_RDRB (1 << 15)
-
-#define UWIRE_CSn_EDGE_RD (1 << 0) /* 1=falling 0=rising */
-#define UWIRE_CSn_EDGE_WR (1 << 1) /* 1=falling 0=rising */
-#define UWIRE_CSn_CS_LVL (1 << 2)
-#define UWIRE_CSn_FRQ_DIV2 (0 << 3)
-#define UWIRE_CSn_FRQ_DIV4 (1 << 3)
-#define UWIRE_CSn_FRQ_DIV8 (2 << 3)
-#define UWIRE_CSn_CKH
-
-#define UWIRE_CSn_SHIFT(n) (((n) & 1) ? 6 : 0)
-#define UWIRE_CSn_REG(n) (((n) & 2) ? REG_SR2 : REG_SR1)
-
-#define UWIRE_SR3_CLK_EN (1 << 0)
-#define UWIRE_SR3_CLK_DIV2 (0 << 1)
-#define UWIRE_SR3_CLK_DIV4 (1 << 1)
-#define UWIRE_SR3_CLK_DIV7 (2 << 1)
-#define UWIRE_SR3_CLK_DIV10 (3 << 1)
-
-static inline void _uwire_wait(int mask, int val)
-{
- while ((getreg16(UWIRE_REG(REG_CSR)) & mask) != val);
-}
-
-void uwire_init(void)
-{
- putreg16(UWIRE_SR3_CLK_EN | UWIRE_SR3_CLK_DIV2, UWIRE_REG(REG_SR3));
-
- /* FIXME only init CS0 for now */
-
- putreg16(((UWIRE_CSn_CS_LVL | UWIRE_CSn_FRQ_DIV2) << UWIRE_CSn_SHIFT(0)),
- UWIRE_REG(UWIRE_CSn_REG(0)));
- putreg16(UWIRE_CSR_IDX(0) | UWIRE_CSR_CS_CMD, UWIRE_REG(REG_CSR));
- _uwire_wait(UWIRE_CSR_CSRB, 0);
-}
-
-int uwire_xfer(int cs, int bitlen, const void *dout, void *din)
-{
- uint16_t tmp = 0;
-
- if (bitlen <= 0 || bitlen > 16)
- return -1;
-
- if (cs < 0 || cs > 4)
- return -1;
-
- /* FIXME uwire_init always selects CS0 for now */
-
- _info("uwire_xfer(dev_idx=%u, bitlen=%u\n", cs, bitlen);
-
- /* select the chip */
-
- putreg16(UWIRE_CSR_IDX(0) | UWIRE_CSR_CS_CMD, UWIRE_REG(REG_CSR));
- _uwire_wait(UWIRE_CSR_CSRB, 0);
-
- if (dout)
- {
- if (bitlen <= 8)
- tmp = *(uint8_t *)dout;
- else if (bitlen <= 16)
- tmp = *(uint16_t *)dout;
-
- tmp <<= 16 - bitlen; /* align to MSB */
- putreg16(tmp, UWIRE_REG(REG_DATA));
- _info(", data_out=0x%04hx", tmp);
- }
-
- tmp = (dout ? UWIRE_CSR_BITS_WR(bitlen) : 0) |
- (din ? UWIRE_CSR_BITS_RD(bitlen) : 0) |
- UWIRE_CSR_START;
- putreg16(tmp, UWIRE_REG(REG_CSR));
- _uwire_wait(UWIRE_CSR_CSRB, 0);
-
- if (din)
- {
- _uwire_wait(UWIRE_CSR_RDRB, UWIRE_CSR_RDRB);
-
- tmp = getreg16(UWIRE_REG(REG_DATA));
- _info(", data_in=0x%08x", tmp);
-
- if (bitlen <= 8)
- *(uint8_t *)din = tmp & 0xff;
- else if (bitlen <= 16)
- *(uint16_t *)din = tmp & 0xffff;
- }
-
- /* unselect the chip */
-
- putreg16(UWIRE_CSR_IDX(0) | 0, UWIRE_REG(REG_CSR));
- _uwire_wait(UWIRE_CSR_CSRB, 0);
-
- _info(")\n");
-
- return 0;
-}
diff --git a/arch/arm/src/calypso/chip.h b/arch/arm/src/calypso/chip.h
deleted file mode 100644
index bea381cc385a082fd86bb136b02e84aaa6b5615a..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/chip.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/****************************************************************************
- * calypso/chip.h
- *
- * Copyright (C) 2011 Stefan Richter. All rights reserved.
- * Author: Stefan Richter
- *
- * based on: c5471/chip.h
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#ifndef __ARCH_ARM_SRC_CALYPSO_CHIP_H
-#define __ARCH_ARM_SRC_CALYPSO_CHIP_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/* UARTs ********************************************************************/
-
-#define UART_IRDA_BASE 0xffff5000
-#define UART_MODEM_BASE 0xffff5800
-#define UART_UIR 0xffff6000
-#define UARTn_IO_RANGE 0x00000800
-
-/* Common UART Registers. Expressed as offsets from the BASE address */
-
-#define UART_RHR_OFFS 0x00000000 /* Rcv Holding Register */
-#define UART_THR_OFFS 0x00000000 /* Xmit Holding Register */
-#define UART_FCR_OFFS 0x00000002 /* FIFO Control Register */
-#define UART_RFCR_OFFS 0x00000002 /* Rcv FIFO Control Register */
-#define UART_TFCR_OFFS 0x00000002 /* Xmit FIFO Control Register */
-#define UART_SCR_OFFS 0x00000010 /* Status Control Register */
-#define UART_LCR_OFFS 0x00000003 /* Line Control Register */
-#define UART_LSR_OFFS 0x00000005 /* Line Status Register */
-#define UART_SSR_OFFS 0x00000011 /* Supplementary Status Register */
-#define UART_MCR_OFFS 0x00000004 /* Modem Control Register */
-#define UART_MSR_OFFS 0x00000006 /* Modem Status Register */
-#define UART_IER_OFFS 0x00000001 /* Interrupt Enable Register */
-#define UART_ISR_OFFS 0x00000002 /* Interrupt Status Register */
-#define UART_EFR_OFFS 0x00000002 /* Enhanced Feature Register */
-#define UART_XON1_OFFS 0x00000004 /* XON1 Character Register */
-#define UART_XON2_OFFS 0x00000005 /* XON2 Character Register */
-#define UART_XOFF1_OFFS 0x00000006 /* XOFF1 Character Register */
-#define UART_XOFF2_OFFS 0x00000007 /* XOFF2 Character Register */
-#define UART_SPR_OFFS 0x00000007 /* Scratch-pad Register */
-#define UART_DIV_LOW_OFFS 0x00000000 /* Divisor for baud generation */
-#define UART_DIV_HIGH_OFFS 0x00000001
-#define UART_TCR_OFFS 0x00000006 /* Transmission Control Register */
-#define UART_TLR_OFFS 0x00000007 /* Trigger Level Register */
-#define UART_MDR_OFFS 0x00000008 /* Mode Definition Register */
-
-/* UART Settings ************************************************************/
-
-/* Miscellaneous UART settings. */
-
-#define UART_REGISTER_BITS 8
-#define UART_IRQ_MODEM IRQ_UART_MODEM
-#define UART_IRQ_IRDA IRQ_UART_IRDA
-
-#define UART_RX_FIFO_NOEMPTY 0x00000001
-#define UART_SSR_TXFULL 0x00000001
-#define UART_LSR_TREF 0x00000020
-
-#define UART_XMIT_FIFO_SIZE 64
-#define UART_IRDA_XMIT_FIFO_SIZE 64
-
-/* UART_LCR Register */
- /* Bits 31-7: Reserved */
-#define UART_LCR_BOC 0x00000040 /* Bit 6: Break Control */
- /* Bit 5: Parity Type 2 */
-#define UART_LCR_PAREVEN 0x00000010 /* Bit 4: Parity Type 1 */
-#define UART_LCR_PARODD 0x00000000
-#define UART_LCR_PARMARK 0x00000010
-#define UART_LCR_PARSPACE 0x00000011
-#define UART_LCR_PAREN 0x00000008 /* Bit 3: Paity Enable */
-#define UART_LCR_PARDIS 0x00000000
-#define UART_LCR_2STOP 0x00000004 /* Bit 2: Number of stop bits */
-#define UART_LCR_1STOP 0x00000000
-#define UART_LCR_5BITS 0x00000000 /* Bits 0-1: Word-length */
-#define UART_LCR_6BITS 0x00000001
-#define UART_LCR_7BITS 0x00000002
-#define UART_LCR_8BITS 0x00000003
-
-#define UART_FCR_FTL 0x000000f0
-#define UART_FCR_FIFO_EN 0x00000001
-#define UART_FCR_TX_CLR 0x00000002
-#define UART_FCR_RX_CLR 0x00000004
-
-#define UART_IER_RECVINT 0x00000001
-#define UART_IER_XMITINT 0x00000002
-#define UART_IER_LINESTSINT 0x00000004
-#define UART_IER_MODEMSTSINT 0x00000008 /* IrDA UART only */
-#define UART_IER_XOFFINT 0x00000020
-#define UART_IER_RTSINT 0x00000040 /* IrDA UART only */
-#define UART_IER_CTSINT 0x00000080 /* IrDA UART only */
-#define UART_IER_INTMASK 0x000000ff
-
-#define BAUD_115200 0x00000007
-#define BAUD_57600 0x00000014
-#define BAUD_38400 0x00000021
-#define BAUD_19200 0x00000006
-#define BAUD_9600 0x0000000C
-#define BAUD_4800 0x00000018
-#define BAUD_2400 0x00000030
-#define BAUD_1200 0x00000060
-
-#define MDR_UART_MODE 0x00000000 /* Both IrDA and Modem UARTs */
-#define MDR_SIR_MODE 0x00000001 /* IrDA UART only */
-#define MDR_AUTOBAUDING_MODE 0x00000002 /* Modem UART only */
-#define MDR_RESET_MODE 0x00000007 /* Both IrDA and Modem UARTs */
-
-/* SPI **********************************************************************/
-
-#define MAX_SPI 3
-
-#define SPI_REGISTER_BASE 0xffff2000
-
-/* ARMIO ********************************************************************/
-/* Timers / Watchdog ********************************************************/
-
-#define C5471_TIMER0_CTRL 0xffff2a00
-#define C5471_TIMER0_CNT 0xffff2a04
-#define C5471_TIMER1_CTRL 0xffff2b00
-#define C5471_TIMER1_CNT 0xffff2b04
-#define C5471_TIMER2_CTRL 0xffff2c00
-#define C5471_TIMER2_CNT 0xffff2c04
-
-/* Interrupts ***************************************************************/
-
-#define HAVE_SRC_IRQ_BIN_REG 0
-
-#define INT_FIRST_IO 0xffff2d00
-#define INT_IO_RANGE 0x5C
-
-#define IT_REG 0xffff2d00
-#define MASK_IT_REG 0xffff2d04
-#define SRC_IRQ_REG 0xffff2d08
-#define SRC_FIQ_REG 0xffff2d0c
-#define SRC_IRQ_BIN_REG 0xffff2d10
-#define INT_CTRL_REG 0xffff2d18
-
-#define ILR_IRQ0_REG 0xffff2d1C /* 0-Timer 0 */
-#define ILR_IRQ1_REG 0xffff2d20 /* 1-Timer 1 */
-#define ILR_IRQ2_REG 0xffff2d24 /* 2-Timer 2 */
-#define ILR_IRQ3_REG 0xffff2d28 /* 3-GPIO0 */
-#define ILR_IRQ4_REG 0xffff2d2c /* 4-Ethernet */
-#define ILR_IRQ5_REG 0xffff2d30 /* 5-KBGPIO[7:0] */
-#define ILR_IRQ6_REG 0xffff2d34 /* 6-Uart serial */
-#define ILR_IRQ7_REG 0xffff2d38 /* 7-Uart IRDA */
-#define ILR_IRQ8_REG 0xffff2d3c /* 8-KBGPIO[15:8] */
-#define ILR_IRQ9_REG 0xffff2d40 /* 9-GPIO3 */
-#define ILR_IRQ10_REG 0xffff2d44 /* 10-GPIO2 */
-#define ILR_IRQ11_REG 0xffff2d48 /* 11-I2C */
-#define ILR_IRQ12_REG 0xffff2d4c /* 12-GPIO1 */
-#define ILR_IRQ13_REG 0xffff2d50 /* 13-SPI */
-#define ILR_IRQ14_REG 0xffff2d54 /* 14-GPIO[19:4] */
-#define ILR_IRQ15_REG 0xffff2d58 /* 15-API */
-
-/* CLKM *********************************************************************/
-
-#define CLKM 0xffff2f00
-#define CLKM_CTL_RST 0xffff2f10
-#define CLKM_RESET 0xffff2f18
-
-#define CLKM_RESET_EIM 0x00000008
-#define CLKM_EIM_CLK_STOP 0x00000010
-#define CLKM_CTL_RST_LEAD_RESET 0x00000000
-#define CLKM_CTL_RST_EXT_RESET 0x00000002
-
-/****************************************************************************
- * Inline Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#endif /* __ARCH_ARM_SRC_CALYPSO_CHIP_H */
diff --git a/arch/arm/src/calypso/clock.c b/arch/arm/src/calypso/clock.c
deleted file mode 100644
index 29dc2f8273ad66a264a3eccac1ada2c809c5b1ac..0000000000000000000000000000000000000000
--- a/arch/arm/src/calypso/clock.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
- * arch/arm/src/calypso/clock.c
- * Driver for Calypso clock management
- *
- * (C) 2010 by Harald Welte
- *
- * This source code is derivated from Osmocom-BB project and was
- * relicensed as BSD with permission from original authors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-#include
-
-#include
-#include
-
-//#define DEBUG
-#include
-
-#include
-#include
-
-#include "up_arch.h"
-
-#define REG_DPLL 0xffff9800
-#define DPLL_LOCK (1 << 0)
-#define DPLL_BREAKLN (1 << 1)
-#define DPLL_BYPASS_DIV_SHIFT 2 /* 2 bits */
-#define DPLL_PLL_ENABLE (1 << 4)
-#define DPLL_PLL_DIV_SHIFT 5 /* 2 bits */
-#define DPLL_PLL_MULT_SHIFT 7 /* 5 bits */
-#define DPLL_TEST (1 << 12)
-#define DPLL_IOB (1 << 13) /* Initialize on break */
-#define DPLL_IAI (1 << 14) /* Initialize after Idle */
-
-#define BASE_ADDR_CLKM 0xfffffd00
-#define CLKM_REG(m) (BASE_ADDR_CLKM+(m))
-
-enum clkm_reg
-{
- CNTL_ARM_CLK = 0,
- CNTL_CLK = 2,
- CNTL_RST = 4,
- CNTL_ARM_DIV = 8,
-};
-
-/* CNTL_ARM_CLK */
-
-#define ARM_CLK_BIG_SLEEP (1 << 0) /* MCU Master Clock enabled? */
-#define ARM_CLK_CLKIN_SEL0 (1 << 1) /* MCU source clock (0 = DPLL output, 1 = VTCXO or CLKIN */
-#define ARM_CLK_CLKIN_SEL (1 << 2) /* 0 = VTCXO or 1 = CLKIN */
-#define ARM_CLK_MCLK_DIV5 (1 << 3) /* enable 1.5 or 2.5 division factor */
-#define ARM_CLK_MCLK_DIV_SHIFT 4 /* 3 bits */
-#define ARM_CLK_DEEP_POWER_SHIFT 8
-#define ARM_CLK_DEEP_SLEEP 12
-
-/* CNTL_CLK */
-#define CLK_IRQ_CLK_DIS (1 << 0) /* IRQ clock control (0 always, 1 according ARM_MCLK_EN) */
-#define CLK_BRIDGE_CLK_DIS (1 << 1)
-#define CLK_TIMER_CLK_DIS (1 << 2)
-#define CLK_DPLL_DIS (1 << 3) /* 0: DPLL is not stopped during SLEEP */
-#define CLK_CLKOUT_EN (1 << 4) /* Enable CLKOUT output pins */
-#define CLK_EN_IDLE3_FLG (1 << 5) /* DSP idle flag control (1 =
- * SAM/HOM register forced to HOM when DSP IDLE3) */
-#define CLK_VCLKOUT_DIV2 (1 << 6) /* 1: VCLKOUT-FR is divided by 2 */
-#define CLK_VTCXO_DIV2 (1 << 7) /* 1: VTCXO is dividied by 2 */
-
-#define BASE_ADDR_MEMIF 0xfffffb00
-#define MEMIF_REG(x) (BASE_ADDR_MEMIF+(x))
-
-enum memif_reg
-{
- API_RHEA_CTL = 0x0e,
- EXTRA_CONF = 0x10,
-};
-
-static void dump_reg16(uint32_t addr, char *name)
-{
- printf("%s=0x%04x\n", name, getreg16(addr));
-}
-
-void calypso_clk_dump(void)
-{
- dump_reg16(REG_DPLL, "REG_DPLL");
- dump_reg16(CLKM_REG(CNTL_ARM_CLK), "CNTL_ARM_CLK");
- dump_reg16(CLKM_REG(CNTL_CLK), "CNTL_CLK");
- dump_reg16(CLKM_REG(CNTL_RST), "CNTL_RST");
- dump_reg16(CLKM_REG(CNTL_ARM_DIV), "CNTL_ARM_DIV");
-}
-
-void calypso_pll_set(uint16_t inp)
-{
- uint8_t mult = inp >> 8;
- uint8_t div = inp & 0xff;
- uint16_t reg = getreg16(REG_DPLL);
-
- reg &= ~0x0fe0;
- reg |= (div & 0x3) << DPLL_PLL_DIV_SHIFT;
- reg |= (mult & 0x1f) << DPLL_PLL_MULT_SHIFT;
- reg |= DPLL_PLL_ENABLE;
-
- putreg16(reg, REG_DPLL);
-}
-
-void calypso_reset_set(enum calypso_rst calypso_rst, int active)
-{
- uint8_t reg = getreg8(CLKM_REG(CNTL_RST));
-
- if (active)
- reg |= calypso_rst;
- else
- reg &= ~calypso_rst;
-
- putreg8(reg, CLKM_REG(CNTL_RST));
-}
-
-int calypso_reset_get(enum calypso_rst calypso_rst)
-{
- uint8_t reg = getreg8(CLKM_REG(CNTL_RST));
-
- if (reg & calypso_rst)
- return 1;
- else
- return 0;
-}
-
-void calypso_clock_set(uint8_t vtcxo_div2, uint16_t inp, enum mclk_div mclk_div)
-{
- uint16_t cntl_clock = getreg16(CLKM_REG(CNTL_CLK));
- uint16_t cntl_arm_clk = getreg16(CLKM_REG(CNTL_ARM_CLK));
-
- /* First set the vtcxo_div2 */
-
- cntl_clock &= ~CLK_VCLKOUT_DIV2;
- if (vtcxo_div2)
- cntl_clock |= CLK_VTCXO_DIV2;
- else
- cntl_clock &= ~CLK_VTCXO_DIV2;
-
- putreg16(cntl_clock, CLKM_REG(CNTL_CLK));
-
- /* Then configure the MCLK divider */
-
- cntl_arm_clk &= ~ARM_CLK_CLKIN_SEL0;
- if (mclk_div & 0x80)
- {
- mclk_div &= ~0x80;
- cntl_arm_clk |= ARM_CLK_MCLK_DIV5;
- }
- else
- cntl_arm_clk &= ~ARM_CLK_MCLK_DIV5;
-
- cntl_arm_clk &= ~(0x7 << ARM_CLK_MCLK_DIV_SHIFT);
- cntl_arm_clk |= (mclk_div << ARM_CLK_MCLK_DIV_SHIFT);
- putreg16(cntl_arm_clk, CLKM_REG(CNTL_ARM_CLK));
-
- /* Then finally set the PLL */
-
- calypso_pll_set(inp);
-}
-
-void calypso_mem_cfg(enum calypso_bank bank, uint8_t ws,
- enum calypso_mem_width width, int we)
-{
- putreg16((ws & 0x1f) | ((width & 3) << 5) | ((we & 1) << 7),
- BASE_ADDR_MEMIF + bank);
-}
-
-void calypso_bootrom(int enable)
-{
- uint16_t conf = getreg16(MEMIF_REG(EXTRA_CONF));
-
- conf |= (3 << 8);
-
- if (enable)
- conf &= ~(1 << 9);
-
- putreg16(conf, MEMIF_REG(EXTRA_CONF));
-}
-
-void calypso_debugunit(int enable)
-{
- uint16_t conf = getreg16(MEMIF_REG(EXTRA_CONF));
-
- if (enable)
- conf &= ~(1 << 11);
- else
- conf |= (1 << 11);
-
- putreg16(conf, MEMIF_REG(EXTRA_CONF));
-}
-
-#define REG_RHEA_CNTL 0xfffff900
-#define REG_API_CNTL 0xfffff902
-#define REG_ARM_RHEA 0xfffff904
-
-void calypso_rhea_cfg(uint8_t fac0, uint8_t fac1, uint8_t timeout,
- uint8_t ws_h, uint8_t ws_l, uint8_t w_en0, uint8_t w_en1)
-{
- putreg16(fac0 | (fac1 << 4) | (timeout << 8), REG_RHEA_CNTL);
- putreg16(ws_h | (ws_l << 5), REG_API_CNTL);
- putreg16(w_en0 | (w_en1 << 1), REG_ARM_RHEA);
-}
diff --git a/arch/arm/src/common/up_exit.c b/arch/arm/src/common/up_exit.c
index 4d16f2a8a55c2c0fe8ebf12b55c6fe61118f316c..50ff85a743b471322ecfa6a43e18c10e9922a77c 100644
--- a/arch/arm/src/common/up_exit.c
+++ b/arch/arm/src/common/up_exit.c
@@ -50,6 +50,7 @@
#include "task/task.h"
#include "sched/sched.h"
#include "group/group.h"
+#include "irq/irq.h"
#include "up_internal.h"
/****************************************************************************
@@ -140,11 +141,14 @@ void _exit(int status)
{
struct tcb_s *tcb;
- /* Disable interrupts. They will be restored when the next
- * task is started.
+ /* Disable interrupts. They will be restored when the next task is
+ * started.
*/
(void)up_irq_save();
+#ifdef CONFIG_SMP
+ (void)spin_trylock(&g_cpu_irqlock);
+#endif
sinfo("TCB=%p exiting\n", this_task());
@@ -177,4 +181,3 @@ void _exit(int status)
up_fullcontextrestore(tcb->xcp.regs);
}
-
diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c
index d05f9ae22a6ec6fc9446623a048559b540f1f8f3..1c10e5b14c151ef42d11fa4f952a40d481a2ffee 100644
--- a/arch/arm/src/efm32/efm32_i2c.c
+++ b/arch/arm/src/efm32/efm32_i2c.c
@@ -71,8 +71,9 @@
#include
#include
-#include
#include
+#include
+#include
#include
@@ -681,8 +682,14 @@ static inline void efm32_i2c_sem_post(FAR struct efm32_i2c_priv_s *priv)
static inline void efm32_i2c_sem_init(FAR struct efm32_i2c_priv_s *priv)
{
sem_init(&priv->sem_excl, 0, 1);
+
#ifndef CONFIG_I2C_POLLED
+ /* This semaphore is used for signaling and, hence, should not have
+ * priority inheritance enabled.
+ */
+
sem_init(&priv->sem_isr, 0, 0);
+ sem_setprotocol(&priv->sem_isr, SEM_PRIO_NONE);
#endif
}
diff --git a/arch/arm/src/efm32/efm32_lowputc.c b/arch/arm/src/efm32/efm32_lowputc.c
index b3fa2ee3866e0077a4bf4db7595c3d358cfd7937..26ec02884aa3664881c864eab95903e165785bf2 100644
--- a/arch/arm/src/efm32/efm32_lowputc.c
+++ b/arch/arm/src/efm32/efm32_lowputc.c
@@ -281,7 +281,8 @@ static void efm32_leuart_setbaud(uintptr_t base, uint32_t baud)
void efm32_lowsetup(void)
{
-#if defined(HAVE_UART_DEVICE) || defined(HAVE_LEUART_DEVICE)
+#if defined(HAVE_UART_DEVICE) || defined(HAVE_LEUART_DEVICE) || \
+ defined(HAVE_SPI_DEVICE)
uint32_t regval;
#endif
diff --git a/arch/arm/src/efm32/efm32_spi.c b/arch/arm/src/efm32/efm32_spi.c
index 0bf2c31a86a6a07b9d9be971e70d93aa204232e2..d0ae6d378a2932ea0482bf56aa98fd7c0d8b0d35 100644
--- a/arch/arm/src/efm32/efm32_spi.c
+++ b/arch/arm/src/efm32/efm32_spi.c
@@ -53,6 +53,7 @@
#include
#include
#include
+#include
#include
#include
@@ -1640,6 +1641,13 @@ static int spi_portinitialize(struct efm32_spidev_s *priv)
(void)sem_init(&priv->rxdmasem, 0, 0);
(void)sem_init(&priv->txdmasem, 0, 0);
+
+ /* These semaphores are used for signaling and, hence, should not have
+ * priority inheritance enabled.
+ */
+
+ sem_setprotocol(&priv->rxdmasem, SEM_PRIO_NONE);
+ sem_setprotocol(&priv->txdmasem, SEM_PRIO_NONE);
#endif
/* Enable SPI */
diff --git a/arch/arm/src/efm32/efm32_usbhost.c b/arch/arm/src/efm32/efm32_usbhost.c
index 19f80bc43d4322b130e47cf29eb866d7dd65f0fc..be9bbccf23fe10af9a40d80f3cb5466981424aed 100644
--- a/arch/arm/src/efm32/efm32_usbhost.c
+++ b/arch/arm/src/efm32/efm32_usbhost.c
@@ -52,6 +52,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -5157,6 +5158,12 @@ static inline void efm32_sw_initialize(FAR struct efm32_usbhost_s *priv)
sem_init(&priv->pscsem, 0, 0);
sem_init(&priv->exclsem, 0, 1);
+ /* The pscsem semaphore is used for signaling and, hence, should not have
+ * priority inheritance enabled.
+ */
+
+ sem_setprotocol(&priv->pscsem, SEM_PRIO_NONE);
+
/* Initialize the driver state data */
priv->smstate = SMSTATE_DETACHED;
@@ -5172,8 +5179,15 @@ static inline void efm32_sw_initialize(FAR struct efm32_usbhost_s *priv)
for (i = 0; i < EFM32_MAX_TX_FIFOS; i++)
{
FAR struct efm32_chan_s *chan = &priv->chan[i];
+
chan->chidx = i;
+
+ /* The waitsem semaphore is used for signaling and, hence, should not
+ * have priority inheritance enabled.
+ */
+
sem_init(&chan->waitsem, 0, 0);
+ sem_setprotocol(&chan->waitsem, SEM_PRIO_NONE);
}
}
diff --git a/arch/arm/src/imx1/imx_spi.c b/arch/arm/src/imx1/imx_spi.c
index fb5831438699a061fcad0194bca16d613a5e6c1e..d63c65ed2ea1edfd62e17b151ba1f85b6aafc118 100644
--- a/arch/arm/src/imx1/imx_spi.c
+++ b/arch/arm/src/imx1/imx_spi.c
@@ -50,6 +50,7 @@
#include
#include
+#include
#include
#include "up_internal.h"
@@ -1116,7 +1117,13 @@ FAR struct spi_dev_s *imx_spibus_initialize(int port)
/* Initialize the state structure */
#ifndef CONFIG_SPI_POLLWAIT
+ /* Initialize the semaphore that is used to wake up the waiting
+ * thread when the DMA transfer completes. This semaphore is used for
+ * signaling and, hence, should not have priority inheritance enabled.
+ */
+
sem_init(&priv->waitsem, 0, 0);
+ sem_setprotocol(&priv->waitsem, SEM_PRIO_NONE);
#endif
sem_init(&priv->exclsem, 0, 1);
diff --git a/arch/arm/src/imx6/Make.defs b/arch/arm/src/imx6/Make.defs
index 4870aa1d1de74e3aa0b92853040c9931c3357ed0..9986ac23d9d40e203e128b71d2331cedb70c2c6e 100644
--- a/arch/arm/src/imx6/Make.defs
+++ b/arch/arm/src/imx6/Make.defs
@@ -81,6 +81,7 @@ CMN_CSRCS += arm_unblocktask.c arm_undefinedinsn.c
ifeq ($(CONFIG_SMP),y)
CMN_CSRCS += arm_cpuindex.c arm_cpustart.c arm_cpupause.c arm_cpuidlestack.c
+CMN_CSRCS += arm_scu.c
endif
ifeq ($(CONFIG_DEBUG_IRQ_INFO),y)
diff --git a/arch/arm/src/imx6/chip/imx_memorymap.h b/arch/arm/src/imx6/chip/imx_memorymap.h
index c91fb924e093e1095bb85200a4c28fbbf03404f5..c9ad19dfdf353053ff32ba10c76580e9c046e578 100644
--- a/arch/arm/src/imx6/chip/imx_memorymap.h
+++ b/arch/arm/src/imx6/chip/imx_memorymap.h
@@ -122,6 +122,16 @@
#define IMX_MMDCDDR_PSECTION 0x10000000 /* 10000000-ffffffff 3840 MB MMDC-DDR Controller */
/* 10000000-7fffffff 1792 MB */
+/* By default, NuttX uses a 1-1 memory mapping. So the unused, reserved
+ * address in the top-level memory map are candidates for other mapping uses:
+ *
+ * 00018000-000fffff Reserved -- Not used
+ * 00400000-007fffff Reserved -- Not used
+ * 00d00000-00ffffff Reserved -- Not used
+ * 0220c000-023fffff Reserved -- Not used
+ * 80000000-efffffff Reserved -- Level 2 page table (See below)
+ */
+
/* i.MX6 DMA PSECTION Offsets */
#define IMX_CAAMRAM_OFFSET 0x00000000 /* 00000000-00003fff 16 KB CAAM (16K secure RAM) */
@@ -897,7 +907,7 @@
* 0x80000000-0xefffffff: Undefined (1.75 GB)
*
* That is the offset where the main L2 page tables will be positioned. This
- * corresponds to page table offsets 0x000002000 up to 0x000003c00. That
+ * corresponds to page table offsets 0x00002000 up to 0x00003c00. That
* is 1792 entries, each mapping 4KB of address for a total of 7MB of virtual
* address space)
*
@@ -918,6 +928,14 @@
*/
#ifndef CONFIG_ARCH_LOWVECTORS
+ /* Memory map
+ * VIRTUAL ADDRESS RANGE L1 PG TABLE L2 PG TABLE DESCRIPTION
+ * START END OFFSET SIZE
+ * ---------- ---------- ------------ ----------------------------
+ * 0x80000000 0x803fffff 0x000002000 0x000000400 Vectors (1MiB)
+ * 0x80100000 0x806fffff 0x000002400 0x000001800 Paging (6MiB)
+ */
+
/* Vector L2 page table offset/size */
# define VECTOR_L2_OFFSET 0x000002000
@@ -939,10 +957,18 @@
# define PGTABLE_L2_SIZE 0x000001800
#else
+ /* Memory map
+ * VIRTUAL ADDRESS RANGE L1 PG TABLE L2 PG TABLE DESCRIPTION
+ * START END OFFSET SIZE
+ * ---------- ---------- ------------ ----------------------------
+ * 0x80000000 0x806fffff 0x000002000 0x000001c00 Paging (7MiB)
+ */
+
/* Paging L2 page table offset/size */
# define PGTABLE_L2_OFFSET 0x000002000
# define PGTABLE_L2_SIZE 0x000001c00
+
#endif
/* Paging L2 page table base addresses
@@ -974,14 +1000,30 @@
*/
#ifdef CONFIG_ARCH_LOWVECTORS /* Vectors located at 0x0000:0000 */
-
- /* Vectors will always lie at the beginnin of OCRAM */
+/* Vectors will always lie at the beginning of OCRAM
+ *
+ * OCRAM Memory Map:
+ * ---------- ---------- ---------------------------
+ * START END CONTENT
+ * ---------- ---------- ---------------------------
+ * 0x00000000 0x00010000 Vectors (VECTOR_TABLE_SIZE)
+ * 0x00010000 0x0003c000 Unused
+ * 0x0003c000 0x00004000 Page table (PGTABLE_SIZE)
+ */
# define IMX_VECTOR_PADDR IMX_OCRAM_PBASE
# define IMX_VECTOR_VSRAM IMX_OCRAM_VBASE
# define IMX_VECTOR_VADDR 0x00000000
#else /* Vectors located at 0xffff:0000 -- this probably does not work */
+/* OCRAM Memory Map:
+ * ---------- ---------- ---------------------------
+ * START END CONTENT
+ * ---------- ---------- ---------------------------
+ * 0x00000000 0x00004000 Page table (PGTABLE_SIZE)
+ * 0x00004000 0x00030000 Unused
+ * 0x00030000 0x00010000 Vectors (VECTOR_TABLE_SIZE)
+ */
# define IMX_VECTOR_PADDR (IMX_OCRAM_PBASE + IMX_OCRAM_SIZE - VECTOR_TABLE_SIZE)
# define IMX_VECTOR_VSRAM (IMX_OCRAM_VBASE + IMX_OCRAM_SIZE - VECTOR_TABLE_SIZE)
diff --git a/arch/arm/src/imx6/imx_boot.c b/arch/arm/src/imx6/imx_boot.c
index edfd5304a14386affc0dcda7a02312e0d18515db..6abc6f8b15753ea4479657b7a8a341b6d0ff7703 100644
--- a/arch/arm/src/imx6/imx_boot.c
+++ b/arch/arm/src/imx6/imx_boot.c
@@ -52,6 +52,7 @@
#include "chip.h"
#include "arm.h"
#include "mmu.h"
+#include "scu.h"
#include "cache.h"
#include "fpu.h"
#include "up_internal.h"
@@ -64,6 +65,16 @@
#include "imx_serial.h"
#include "imx_boot.h"
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_FEATURES
+# define PROGRESS(c) imx_lowputc(c)
+#else
+# define PROGRESS(c)
+#endif
+
/****************************************************************************
* Public Data
****************************************************************************/
@@ -388,8 +399,10 @@ static inline void imx_wdtdisable(void)
void arm_boot(void)
{
-#ifdef CONFIG_ARCH_RAMFUNCS
+#if defined(CONFIG_ARCH_RAMFUNCS)
const uint32_t *src;
+#endif
+#if defined(CONFIG_ARCH_RAMFUNCS) || defined(CONFIG_SMP) && defined(SMP_INTERCPU_NONCACHED)
uint32_t *dest;
#endif
@@ -398,7 +411,7 @@ void arm_boot(void)
*/
imx_setupmappings();
- imx_lowputc('A');
+ PROGRESS('A');
/* Make sure that all other CPUs are in the disabled state. This is a
* formality because the other CPUs are actually running then we have
@@ -406,13 +419,21 @@ void arm_boot(void)
*/
imx_cpu_disable();
+ PROGRESS('B');
+
+#ifdef CONFIG_SMP
+ /* Enable SMP cache coherency for CPU0 */
+
+ arm_enable_smp(0);
+ PROGRESS('C');
+#endif
/* Provide a special mapping for the OCRAM interrupt vector positioned in
* high memory.
*/
imx_vectormapping();
- imx_lowputc('B');
+ PROGRESS('D');
#ifdef CONFIG_ARCH_RAMFUNCS
/* Copy any necessary code sections from FLASH to RAM. The correct
@@ -426,14 +447,14 @@ void arm_boot(void)
*dest++ = *src++;
}
- imx_lowputc('C');
+ PROGRESS('E');
/* Flush the copied RAM functions into physical RAM so that will
* be available when fetched into the I-Cache.
*/
arch_clean_dcache((uintptr_t)&_sramfuncs, (uintptr_t)&_eramfuncs)
- imx_lowputc('D');
+ PROGRESS('F');
#endif
/* Setup up vector block. _vector_start and _vector_end are exported from
@@ -441,37 +462,35 @@ void arm_boot(void)
*/
imx_copyvectorblock();
- imx_lowputc('E');
+ PROGRESS('G');
/* Disable the watchdog timer */
imx_wdtdisable();
- imx_lowputc('F');
+ PROGRESS('H');
/* Initialize clocking to settings provided by board-specific logic */
imx_clockconfig();
- imx_lowputc('G');
+ PROGRESS('I');
#ifdef CONFIG_ARCH_FPU
/* Initialize the FPU */
arm_fpuconfig();
- imx_lowputc('H');
+ PROGRESS('J');
#endif
- /* Perform board-specific initialization, This must include:
- *
- * - Initialization of board-specific memory resources (e.g., SDRAM)
- * - Configuration of board specific resources (PIOs, LEDs, etc).
+ /* Perform board-specific memroy initialization, This must include
+ * initialization of board-specific memory resources (e.g., SDRAM)
*
* NOTE: We must use caution prior to this point to make sure that
* the logic does not access any global variables that might lie
* in SDRAM.
*/
- imx_board_initialize();
- imx_lowputc('I');
+ imx_memory_initialize();
+ PROGRESS('K');
#ifdef NEED_SDRAM_REMAPPING
/* SDRAM was configured in a temporary state to support low-level
@@ -480,7 +499,7 @@ void arm_boot(void)
*/
imx_remap();
- imx_lowputc('J');
+ PROGRESS('L');
#endif
#ifdef CONFIG_BOOT_SDRAM_DATA
@@ -489,13 +508,20 @@ void arm_boot(void)
*/
arm_data_initialize();
- imx_lowputc('K');
+ PROGRESS('M');
#endif
+ /* Perform board-specific device initialization. This would include
+ * configuration of board specific resources such as GPIOs, LEDs, etc.
+ */
+
+ imx_board_initialize();
+ PROGRESS('N');
+
/* Perform common, low-level chip initialization (might do nothing) */
imx_lowsetup();
- imx_lowputc('L');
+ PROGRESS('O');
#ifdef USE_EARLYSERIALINIT
/* Perform early serial initialization if we are going to use the serial
@@ -503,7 +529,7 @@ void arm_boot(void)
*/
imx_earlyserialinit();
- imx_lowputc('M');
+ PROGRESS('P');
#endif
/* Now we can enable all other CPUs. The enabled CPUs will start execution
@@ -512,6 +538,6 @@ void arm_boot(void)
*/
imx_cpu_enable();
- imx_lowputc('N');
- imx_lowputc('\n');
+ PROGRESS('Q');
+ PROGRESS('\n');
}
diff --git a/arch/arm/src/imx6/imx_boot.h b/arch/arm/src/imx6/imx_boot.h
index 11c1ef56fe38f2b4795b4172fb7997df90db98a0..7f98d347acd51d0f908c3ef58741333883445cf6 100644
--- a/arch/arm/src/imx6/imx_boot.h
+++ b/arch/arm/src/imx6/imx_boot.h
@@ -110,14 +110,37 @@ void imx_cpu_enable(void);
# define imx_cpu_enable()
#endif
+/****************************************************************************
+ * Name: imx_memory_initialize
+ *
+ * Description:
+ * All i.MX6 architectures must provide the following entry point. This
+ * entry point is called early in the initialization before memory has
+ * been configured. This board-specific function is responsible for
+ * configuring any on-board memories.
+ *
+ * Logic in imx_memory_initialize must be careful to avoid using any
+ * global variables because those will be uninitialized at the time this
+ * function is called.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void imx_memory_initialize(void);
+
/****************************************************************************
* Name: imx_board_initialize
*
* Description:
* All i.MX6 architectures must provide the following entry point. This
- * entry point is called early in the initialization -- after all memory
- * has been configured and mapped but before any devices have been
- * initialized.
+ * entry point is called in the initialization phase -- after
+ * imx_memory_initialize and after all memory has been configured and
+ * mapped but before any devices have been initialized.
*
* Input Parameters:
* None
diff --git a/arch/arm/src/imx6/imx_cpuboot.c b/arch/arm/src/imx6/imx_cpuboot.c
index 50b23b5c1d403f8256df08f9b7eb650a05878f16..818b327a4bc4c3cee317fbefdb7d7c8ee3891685 100644
--- a/arch/arm/src/imx6/imx_cpuboot.c
+++ b/arch/arm/src/imx6/imx_cpuboot.c
@@ -51,9 +51,9 @@
#include "chip/imx_src.h"
#include "sctlr.h"
#include "smp.h"
+#include "scu.h"
#include "fpu.h"
#include "gic.h"
-#include "cp15_cacheops.h"
#ifdef CONFIG_SMP
@@ -260,6 +260,10 @@ void imx_cpu_enable(void)
void arm_cpu_boot(int cpu)
{
+ /* Enable SMP cache coherency for the CPU */
+
+ arm_enable_smp(cpu);
+
#ifdef CONFIG_ARCH_FPU
/* Initialize the FPU */
@@ -297,10 +301,6 @@ void arm_cpu_boot(int cpu)
(void)up_irq_enable();
#endif
- /* Invalidate CPUn L1 so that is will be reloaded from coherent L2. */
-
- cp15_invalidate_dcache_all();
-
/* The next thing that we expect to happen is for logic running on CPU0
* to call up_cpu_start() which generate an SGI and a context switch to
* the configured NuttX IDLE task.
diff --git a/arch/arm/src/imx6/imx_ecspi.c b/arch/arm/src/imx6/imx_ecspi.c
new file mode 100644
index 0000000000000000000000000000000000000000..15c602a7c962ee4348889eec7602ace4bb5ef927
--- /dev/null
+++ b/arch/arm/src/imx6/imx_ecspi.c
@@ -0,0 +1,1445 @@
+/****************************************************************************
+ * arch/arm/src/imx6/imx_ecspi.c
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Derives from the i.MX1 CSPI driver:
+ *
+ * Copyright (C) 2009-2010, 2013, 2016 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include "up_internal.h"
+#include "up_arch.h"
+
+#include "chip.h"
+#include "imx_gpio.h"
+#include "imx_ecspi.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* The i.MX6 supports 25SPI interfaces. Which have been enabled? */
+
+#define __SPI1_NDX 0
+
+#ifdef CONFIG_IMX6_ECSPI1
+# define SPI1_NDX __SPI1_NDX
+# define __SPI1_PRESENT 1
+# define __SPI2_NDX (__SPI1_NDX + 1)
+#else
+# define __SPI1_PRESENT 0
+# define __SPI2_NDX __SPI1_NDX
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI2
+# define SPI2_NDX __SPI2_NDX
+# define __SPI2_PRESENT 1
+# define __SPI3_NDX (__SPI2_NDX + 1)
+#else
+# define __SPI2_PRESENT 0
+# define __SPI3_NDX __SPI2_NDX
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI3
+# define SPI3_NDX __SPI3_NDX
+# define __SPI3_PRESENT 1
+# define __SPI4_NDX (__SPI3_NDX + 1)
+#else
+# define __SPI3_PRESENT 0
+# define __SPI4_NDX __SPI3_NDX
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI4
+# define SPI4_NDX __SPI4_NDX
+# define __SPI4_PRESENT 1
+# define __SPI5_NDX (__SPI4_NDX + 1)
+#else
+# define __SPI4_PRESENT 0
+# define __SPI5_NDX __SPI5_NDX
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI5
+# define SPI5_NDX __SPI5_NDX
+# define __SPI5_PRESENT 1
+# define __SPI6_NDX (__SPI5_NDX + 1)
+#else
+# define __SPI5_PRESENT 0
+# define __SPI6_NDX __SPI5_NDX
+#endif
+
+#define NSPIS (__SPI1_PRESENT + __SPI2_PRESENT + __SPI3_PRESENT + \
+ __SPI4_PRESENT + __SPI5_PRESENT)
+
+/* Compile the rest of the file only if at least one SPI interface has been
+ * enabled.
+ */
+
+#if NSPIS > 0
+
+/* The number of words that will fit in the Tx FIFO */
+
+#define IMX_TXFIFO_WORDS 8
+
+/****************************************************************************
+ * Private Type Definitions
+ ****************************************************************************/
+
+ /* Per SPI callouts to board-specific logic */
+
+typedef CODE void (*imx_select_t)(FAR struct spi_dev_s *dev,
+ enum spi_dev_e devid, bool selected);
+typedef CODE uint8_t (*imx_status_t)(FAR struct spi_dev_s *dev,
+ enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+typedef CODE int (*imx_cmddata_t)(FAR struct spi_dev_s *dev,
+ enum spi_dev_e devid, bool cmd);
+#endif
+
+struct imx_spidev_s
+{
+ const struct spi_ops_s *ops; /* Common SPI operations */
+#ifndef CONFIG_SPI_POLLWAIT
+ sem_t waitsem; /* Wait for transfer to complete */
+#endif
+ sem_t exclsem; /* Supports mutually exclusive access */
+
+ /* These following are the source and destination buffers of the transfer.
+ * they are retained in this structure so that they will be accessible
+ * from an interrupt handler. The actual type of the buffer is uint8_t is
+ * nbits <=8 and uint16_t is nbits >8.
+ */
+
+ void *txbuffer; /* Source buffer */
+ void *rxbuffer; /* Destination buffer */
+
+ /* These are functions pointers that are configured to perform the
+ * appropriate transfer for the particular kind of exchange that is
+ * occurring. Differnt functions may be selected depending on (1)
+ * if the tx or txbuffer is NULL and depending on the number of bits
+ * per word.
+ */
+
+ void (*txword)(struct imx_spidev_s *priv);
+ void (*rxword)(struct imx_spidev_s *priv);
+
+ uint32_t base; /* SPI register base address */
+ uint32_t frequency; /* Current desired SCLK frequency */
+ uint32_t actual; /* Current actual SCLK frequency */
+
+ int ntxwords; /* Number of words left to transfer on the Tx FIFO */
+ int nrxwords; /* Number of words received on the Rx FIFO */
+ int nwords; /* Number of words to be exchanged */
+
+ uint8_t mode; /* Current mode */
+ uint8_t nbits; /* Current number of bits per word */
+ uint8_t spindx; /* SPI index */
+#ifndef CONFIG_SPI_POLLWAIT
+ uint8_t irq; /* SPI IRQ number */
+ xcpt_t handler; /* ECSPI interrupt handler */
+#endif
+
+ /* Per SPI callouts to board-specific logic */
+
+ imx_select_t select; /* Select callout */
+ imx_status_t status; /* Status callout */
+#ifdef CONFIG_SPI_CMDDATA
+ imx_cmddata_t cmddata; /* Cmddata callout */
+#endif
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* SPI register access */
+
+static inline uint32_t spi_getreg(struct imx_spidev_s *priv, unsigned int offset);
+static inline void spi_putreg(struct imx_spidev_s *priv, unsigned int offset, uint32_t value);
+
+/* SPI data transfer */
+
+static void spi_txnull(struct imx_spidev_s *priv);
+static void spi_txuint16(struct imx_spidev_s *priv);
+static void spi_txuint8(struct imx_spidev_s *priv);
+static void spi_rxnull(struct imx_spidev_s *priv);
+static void spi_rxuint16(struct imx_spidev_s *priv);
+static void spi_rxuint8(struct imx_spidev_s *priv);
+static int spi_performtx(struct imx_spidev_s *priv);
+static inline void spi_performrx(struct imx_spidev_s *priv);
+static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
+ void *rxbuffer, unsigned int nwords);
+
+/* Interrupt handling */
+
+#ifndef CONFIG_SPI_POLLWAIT
+static int spi_interrupt(struct imx_spidev_s *priv);
+#ifdef CONFIG_IMX6_ECSPI1
+static int ecspi1_interrupt(int irq, void *context);
+#endif
+#ifdef CONFIG_IMX6_ECSPI2
+static int ecspi2_interrupt(int irq, void *context);
+#endif
+#ifdef CONFIG_IMX6_ECSPI3
+static int ecspi3_interrupt(int irq, void *context);
+#endif
+#ifdef CONFIG_IMX6_ECSPI4
+static int ecspi4_interrupt(int irq, void *context);
+#endif
+#ifdef CONFIG_IMX6_ECSPI5
+static int ecspi5_interrupt(int irq, void *context);
+#endif
+#endif
+
+/* SPI methods */
+
+static int spi_lock(FAR struct spi_dev_s *dev, bool lock);
+static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+ bool selected);
+static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev,
+ uint32_t frequency);
+static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode);
+static void spi_setbits(FAR struct spi_dev_s *dev, int nbits);
+static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd);
+static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+ bool cmd);
+#endif
+#ifdef CONFIG_SPI_EXCHANGE
+static void spi_exchange(FAR struct spi_dev_s *dev,
+ FAR const void *txbuffer,
+ FAR void *rxbuffer, size_t nwords);
+#else
+static void spi_sndblock(FAR struct spi_dev_s *dev,
+ FAR const void *buffer, size_t nwords);
+static void spi_recvblock(FAR struct spi_dev_s *dev,
+ FAR void *buffer, size_t nwords);
+#endif
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* Common SPI operations */
+
+static const struct spi_ops_s g_spiops =
+{
+ .lock = spi_lock,
+ .select = spi_select, /* Provided externally by board logic */
+ .setfrequency = spi_setfrequency,
+ .setmode = spi_setmode,
+ .setbits = spi_setbits,
+#ifdef CONFIG_SPI_HWFEATURES
+ .hwfeatures = 0, /* Not supported */
+#endif
+ .status = spi_status, /* Provided externally by board logic */
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = spi_cmddata,
+#endif
+ .send = spi_send,
+#ifdef CONFIG_SPI_EXCHANGE
+ .exchange = spi_exchange,
+#else
+ .sndblock = spi_sndblock,
+ .recvblock = spi_recvblock,
+#endif
+};
+
+/* This supports is up to five SPI busses/ports */
+
+static struct imx_spidev_s g_spidev[] =
+{
+#ifdef CONFIG_IMX6_ECSPI1
+ {
+ .ops = &g_spiops,
+ .base = IMX_ECSPI1_VBASE,
+ .spindx = SPI1_NDX,
+#ifndef CONFIG_SPI_POLLWAIT
+ .irq = IMX_IRQ_ECSPI1,
+ .handler = ecspi1_interrupt,
+#endif
+ .select = imx_spi1select,
+ .status = imx_spi1status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = imx_spi1cmddata,
+#endif
+ }
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI2
+ , {
+ .ops = &g_spiops,
+ .base = IMX_ECSPI2_VBASE,
+ .spindx = SPI2_NDX,
+#ifndef CONFIG_SPI_POLLWAIT
+ .irq = IMX_IRQ_ECSPI2,
+ .handler = ecspi2_interrupt,
+#endif
+ .select = imx_spi2select,
+ .status = imx_spi2status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = imx_spi2cmddata,
+#endif
+ }
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI3
+ , {
+ .ops = &g_spiops,
+ .base = IMX_ECSPI3_VBASE,
+ .spindx = SPI3_NDX,
+#ifndef CONFIG_SPI_POLLWAIT
+ .irq = IMX_IRQ_ECSPI3,
+ .handler = ecspi3_interrupt,
+#endif
+ .select = imx_spi3select,
+ .status = imx_spi3status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = imx_spi3cmddata,
+#endif
+ }
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI4
+ , {
+ .ops = &g_spiops,
+ .base = IMX_ECSPI4_VBASE,
+ .spindx = SPI4_NDX,
+#ifndef CONFIG_SPI_POLLWAIT
+ .irq = IMX_IRQ_ECSPI4,
+ .handler = ecspi4_interrupt,
+#endif
+ .select = imx_spi4select,
+ .status = imx_spi4status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = imx_spi4cmddata,
+#endif
+ }
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI5
+ , {
+ .ops = &g_spiops,
+ .base = IMX_ECSPI5_VBASE,
+ .spindx = SPI5_NDX,
+#ifndef CONFIG_SPI_POLLWAIT
+ .irq = IMX_IRQ_ECSPI5,
+ .handler = ecspi5_interrupt,
+#endif
+ .select = imx_spi5select,
+ .status = imx_spi5status,
+#ifdef CONFIG_SPI_CMDDATA
+ .cmddata = imx_spi5cmddata,
+#endif
+ }
+#endif
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: spi_getreg
+ *
+ * Description:
+ * Read the SPI register at this offeset
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * offset - Offset to the SPI register from the register base address
+ *
+ * Returned Value:
+ * Value of the register at this offset
+ *
+ ****************************************************************************/
+
+static inline uint32_t spi_getreg(struct imx_spidev_s *priv, unsigned int offset)
+{
+ return getreg32(priv->base + offset);
+}
+
+/****************************************************************************
+ * Name: spi_putreg
+ *
+ * Description:
+ * Write the value to the SPI register at this offeset
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * offset - Offset to the SPI register from the register base address
+ * value - Value to write
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void spi_putreg(struct imx_spidev_s *priv, unsigned int offset, uint32_t value)
+{
+ putreg32(value, priv->base + offset);
+}
+
+/****************************************************************************
+ * Name: spi_txnull, spi_txuint16, and spi_txuint8
+ *
+ * Description:
+ * Transfer all ones, a uint8_t, or uint16_t to Tx FIFO and update the txbuffer
+ * pointer appropriately. The selected function dependes on (1) if there
+ * is a source txbuffer provided, and (2) if the number of bits per
+ * word is <=8 or >8.
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void spi_txnull(struct imx_spidev_s *priv)
+{
+ spi_putreg(priv, ECSPI_TXDATA_OFFSET, 0xffff);
+}
+
+static void spi_txuint16(struct imx_spidev_s *priv)
+{
+ uint16_t *ptr = (uint16_t *)priv->txbuffer;
+ spi_putreg(priv, ECSPI_TXDATA_OFFSET, *ptr++);
+ priv->txbuffer = (void *)ptr;
+}
+
+static void spi_txuint8(struct imx_spidev_s *priv)
+{
+ uint8_t *ptr = (uint8_t *)priv->txbuffer;
+ spi_putreg(priv, ECSPI_TXDATA_OFFSET, *ptr++);
+ priv->txbuffer = (void *)ptr;
+}
+
+/****************************************************************************
+ * Name: spi_rxnull,spi_rxuint16, and spi_rxuint8
+ *
+ * Description:
+ * Discard input, save a uint8_t, or or save a uint16_t from Tx FIFO in the
+ * user rxvbuffer and update the rxbuffer pointer appropriately. The
+ * selected function dependes on (1) if there is a desination rxbuffer
+ * provided, and (2) if the number of bits per word is <=8 or >8.
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void spi_rxnull(struct imx_spidev_s *priv)
+{
+ (void)spi_getreg(priv, ECSPI_RXDATA_OFFSET);
+}
+
+static void spi_rxuint16(struct imx_spidev_s *priv)
+{
+ uint16_t *ptr = (uint16_t *)priv->rxbuffer;
+ *ptr++ = (uint16_t)spi_getreg(priv, ECSPI_TXDATA_OFFSET);
+ priv->rxbuffer = (void *)ptr;
+}
+
+static void spi_rxuint8(struct imx_spidev_s *priv)
+{
+ uint8_t *ptr = (uint8_t *)priv->rxbuffer;
+ *ptr++ = (uint8_t)spi_getreg(priv, ECSPI_TXDATA_OFFSET);
+ priv->rxbuffer = (void *)ptr;
+}
+
+/****************************************************************************
+ * Name: spi_performtx
+ *
+ * Description:
+ * If the Tx FIFO is empty, then transfer as many words as we can to
+ * the FIFO.
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ *
+ * Returned Value:
+ * The number of words written to the Tx FIFO (a value from 0 to 8,
+ * inclusive).
+ *
+ ****************************************************************************/
+
+static int spi_performtx(struct imx_spidev_s *priv)
+{
+ uint32_t regval;
+ int ntxd = 0; /* Number of words written to Tx FIFO */
+
+ /* Check if the Tx FIFO is empty */
+
+ if ((spi_getreg(priv, ECSPI_STATREG_OFFSET) & ECSPI_INT_TE) != 0)
+ {
+ /* Check if all of the Tx words have been sent */
+
+ if (priv->ntxwords > 0)
+ {
+ /* No.. Transfer more words until either the TxFIFO is full or
+ * until all of the user provided data has been sent.
+ */
+
+ for (; ntxd < priv->ntxwords && ntxd < IMX_TXFIFO_WORDS; ntxd++)
+ {
+ priv->txword(priv);
+ }
+
+ /* Update the count of words to to transferred */
+
+ priv->ntxwords -= ntxd;
+ }
+ else
+ {
+ /* Yes.. The transfer is complete, disable Tx FIFO empty interrupt */
+
+ regval = spi_getreg(priv, ECSPI_INTREG_OFFSET);
+ regval &= ~ECSPI_INT_TE;
+ spi_putreg(priv, ECSPI_INTREG_OFFSET, regval);
+ }
+ }
+ return ntxd;
+}
+
+/****************************************************************************
+ * Name: spi_performrx
+ *
+ * Description:
+ * Transfer as many bytes as possible from the Rx FIFO to the user Rx
+ * buffer (if one was provided).
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static inline void spi_performrx(struct imx_spidev_s *priv)
+{
+ /* Loop while data is available in the Rx FIFO */
+
+ while ((spi_getreg(priv, ECSPI_STATREG_OFFSET) & ECSPI_INT_RR) != 0)
+ {
+ /* Have all of the requested words been transferred from the Rx FIFO? */
+
+ if (priv->nrxwords < priv->nwords)
+ {
+ /* No.. Read more data from Rx FIFO */
+
+ priv->rxword(priv);
+ priv->nrxwords++;
+ }
+ }
+}
+
+/****************************************************************************
+ * Name: spi_startxfr
+ *
+ * Description:
+ * If data was added to the Tx FIFO, then start the exchange
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * ntxd - The number of bytes added to the Tx FIFO by spi_performtx.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void spi_startxfr(struct imx_spidev_s *priv, int ntxd)
+{
+ uint32_t regval;
+
+ /* The XCH bit initiates an exchange in master mode. It remains set
+ * remains set while the exchange is in progress but is automatically
+ * clear when all data in the Tx FIFO and shift register are shifted out.
+ * So if we have added data to the Tx FIFO on this interrupt, we must
+ * set the XCH bit to resume the exchange.
+ */
+
+ if (ntxd > 0)
+ {
+ regval = spi_getreg(priv, ECSPI_CONREG_OFFSET);
+ regval |= ECSPI_CONREG_XCH;
+ spi_putreg(priv, ECSPI_CONREG_OFFSET, regval);
+ }
+}
+
+/****************************************************************************
+ * Name: spi_transfer
+ *
+ * Description:
+ * Exchange a block data with the SPI device
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ * txbuffer - The buffer of data to send to the device (may be NULL).
+ * rxbuffer - The buffer to receive data from the device (may be NULL).
+ * nwords - The total number of words to be exchanged. If the interface
+ * uses <= 8 bits per word, then this is the number of uint8_t's;
+ * if the interface uses >8 bits per word, then this is the
+ * number of uint16_t's
+ *
+ * Returned Value:
+ * 0: success, <0:Negated error number on failure
+ *
+ ****************************************************************************/
+
+static int spi_transfer(struct imx_spidev_s *priv, const void *txbuffer,
+ void *rxbuffer, unsigned int nwords)
+{
+#ifndef CONFIG_SPI_POLLWAIT
+ irqstate_t flags;
+ uint32_t regval;
+ int ret;
+#endif
+ int ntxd;
+
+ /* Set up to perform the transfer */
+
+ priv->txbuffer = (uint8_t *)txbuffer; /* Source buffer */
+ priv->rxbuffer = (uint8_t *)rxbuffer; /* Destination buffer */
+ priv->ntxwords = nwords; /* Number of words left to send */
+ priv->nrxwords = 0; /* Number of words received */
+ priv->nwords = nwords; /* Total number of exchanges */
+
+ /* Set up the low-level data transfer function pointers */
+
+ if (priv->nbits > 8)
+ {
+ priv->txword = spi_txuint16;
+ priv->rxword = spi_rxuint16;
+ }
+ else
+ {
+ priv->txword = spi_txuint8;
+ priv->rxword = spi_rxuint8;
+ }
+
+ if (!txbuffer)
+ {
+ priv->txword = spi_txnull;
+ }
+
+ if (!rxbuffer)
+ {
+ priv->rxword = spi_rxnull;
+ }
+
+ /* Prime the Tx FIFO to start the sequence (saves one interrupt) */
+
+#ifndef CONFIG_SPI_POLLWAIT
+ flags = enter_critical_section();
+ ntxd = spi_performtx(priv);
+ spi_startxfr(priv, ntxd);
+
+ /* Enable transmit empty interrupt */
+
+ regval = spi_getreg(priv, ECSPI_INTREG_OFFSET);
+ regval |= ECSPI_INT_TE;
+ spi_putreg(priv, ECSPI_INTREG_OFFSET, regval);
+ leave_critical_section(flags);
+
+ /* Wait for the transfer to complete. Since there is no handshake
+ * with SPI, the following should complete even if there are problems
+ * with the transfer, so it should be safe with no timeout.
+ */
+
+ do
+ {
+ /* Wait to be signaled from the interrupt handler */
+
+ ret = sem_wait(&priv->waitsem);
+ }
+ while (ret < 0 && errno == EINTR);
+
+#else
+ /* Perform the transfer using polling logic. This will totally
+ * dominate the CPU until the transfer is complete. Only recommended
+ * if (1) your SPI is very fast, and (2) if you only use very short
+ * transfers.
+ */
+
+ do
+ {
+ /* Handle outgoing Tx FIFO transfers */
+
+ ntxd = spi_performtx(priv);
+
+ /* Handle incoming Rx FIFO transfers */
+
+ spi_performrx(priv);
+
+ /* Resume the transfer */
+
+ spi_startxfr(priv, ntxd);
+
+ /* If there are other threads at this same priority level,
+ * the following may help:
+ */
+
+ sched_yield();
+ }
+ while (priv->nrxwords < priv->nwords);
+#endif
+ return OK;
+}
+
+/****************************************************************************
+ * Name: spi_interrupt
+ *
+ * Description:
+ * Common ECSPI interrupt handling logic
+ *
+ * Input Parameters:
+ * priv - Device-specific state data
+ *
+ * Returned Value:
+ * 0: success, <0:Negated error number on failure
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_SPI_POLLWAIT
+static int spi_interrupt(struct imx_spidev_s *priv)
+{
+ int ntxd;
+
+ DEBUGASSERT(priv != NULL);
+
+ /* Handle outgoing Tx FIFO transfers */
+
+ ntxd = spi_performtx(priv);
+
+ /* Handle incoming Rx FIFO transfers */
+
+ spi_performrx(priv);
+
+ /* Resume the transfer */
+
+ spi_startxfr(priv, ntxd);
+
+ /* Check if the transfer is complete */
+
+ if (priv->nrxwords >= priv->nwords)
+ {
+ /* Yes, wake up the waiting thread */
+
+ sem_post(&priv->waitsem);
+ }
+
+ return OK;
+}
+#endif
+
+/****************************************************************************
+ * Name: ecspiN_interrupt, N=1..5
+ *
+ * Description:
+ * Individual ECPSI interrupt handlers.
+ *
+ * Input Parameters:
+ * Standard interrupt handler inputs
+ *
+ * Returned Value:
+ * 0: success, <0:Negated error number on failure
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_SPI_POLLWAIT
+#ifdef CONFIG_IMX6_ECSPI1
+static int ecspi1_interrupt(int irq, void *context)
+{
+ return spi_interrupt(&g_spidev[SPI1_NDX]);
+}
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI2
+static int ecspi2_interrupt(int irq, void *context)
+{
+ return spi_interrupt(&g_spidev[SPI2_NDX]);
+}
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI3
+static int ecspi3_interrupt(int irq, void *context)
+{
+ return spi_interrupt(&g_spidev[SPI3_NDX]);
+}
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI4
+static int ecspi4_interrupt(int irq, void *context)
+{
+ return spi_interrupt(&g_spidev[SPI4_NDX]);
+}
+#endif
+
+#ifdef CONFIG_IMX6_ECSPI5
+static int ecspi5_interrupt(int irq, void *context)
+{
+ return spi_interrupt(&g_spidev[SPI5_NDX]);
+}
+#endif
+#endif
+
+/****************************************************************************
+ * Name: spi_lock
+ *
+ * Description:
+ * On SPI busses where there are multiple devices, it will be necessary to
+ * lock SPI to have exclusive access to the busses for a sequence of
+ * transfers. The bus should be locked before the chip is selected. After
+ * locking the SPI bus, the caller should then also call the setfrequency,
+ * setbits, and setmode methods to make sure that the SPI is properly
+ * configured for the device. If the SPI buss is being shared, then it
+ * may have been left in an incompatible state.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * lock - true: Lock spi bus, false: unlock SPI bus
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static int spi_lock(FAR struct spi_dev_s *dev, bool lock)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+
+ if (lock)
+ {
+ /* Take the semaphore (perhaps waiting) */
+
+ while (sem_wait(&priv->exclsem) != 0)
+ {
+ /* The only case that an error should occur here is if the wait
+ * was awakened by a signal.
+ */
+
+ DEBUGASSERT(errno == EINTR);
+ }
+ }
+ else
+ {
+ (void)sem_post(&priv->exclsem);
+ }
+
+ return OK;
+}
+
+/****************************************************************************
+ * Name: spi_select
+ *
+ * Description:
+ * Enable/disable the SPI chip select. The implementation of this method
+ * must include handshaking: If a device is selected, it must hold off
+ * all other attempts to select the device until the device is deselected.
+ * Required.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * devid - Identifies the device to select
+ * selected - true: slave selected, false: slave de-selected
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+ bool selected)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+
+ DEBUGASSERT(priv != NULL && priv->select != NULL);
+ priv->select(dev, devid, selected);
+}
+
+/****************************************************************************
+ * Name: spi_setfrequency
+ *
+ * Description:
+ * Set the SPI frequency.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * frequency - The SPI frequency requested
+ *
+ * Returned Value:
+ * Returns the actual frequency selected
+ *
+ ****************************************************************************/
+
+static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, uint32_t frequency)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ uint32_t actual;
+
+ DEBUGASSERT(priv != NULL);
+ actual = priv->actual;
+
+ if (frequency != priv->frequency)
+ {
+ uint32_t freqbits;
+ uint32_t regval;
+
+ if (frequency >= IMX_PERCLK2_FREQ / 4)
+ {
+ freqbits = ECSPI_CONREG_DIV4;
+ actual = IMX_PERCLK2_FREQ / 4;
+ }
+ else if (frequency >= IMX_PERCLK2_FREQ / 8)
+ {
+ freqbits = ECSPI_CONREG_DIV8;
+ actual = IMX_PERCLK2_FREQ / 8;
+ }
+ else if (frequency >= IMX_PERCLK2_FREQ / 16)
+ {
+ freqbits = ECSPI_CONREG_DIV16;
+ actual = IMX_PERCLK2_FREQ / 16;
+ }
+ else if (frequency >= IMX_PERCLK2_FREQ / 32)
+ {
+ freqbits = ECSPI_CONREG_DIV32;
+ actual = IMX_PERCLK2_FREQ / 32;
+ }
+ else if (frequency >= IMX_PERCLK2_FREQ / 64)
+ {
+ freqbits = ECSPI_CONREG_DIV64;
+ actual = IMX_PERCLK2_FREQ / 64;
+ }
+ else if (frequency >= IMX_PERCLK2_FREQ / 128)
+ {
+ freqbits = ECSPI_CONREG_DIV128;
+ actual = IMX_PERCLK2_FREQ / 128;
+ }
+ else if (frequency >= IMX_PERCLK2_FREQ / 256)
+ {
+ freqbits = ECSPI_CONREG_DIV256;
+ actual = IMX_PERCLK2_FREQ / 256;
+ }
+ else /* if (frequency >= IMX_PERCLK2_FREQ / 512) */
+ {
+ freqbits = ECSPI_CONREG_DIV512;
+ actual = IMX_PERCLK2_FREQ / 512;
+ }
+
+ /* Then set the selected frequency */
+
+ regval = spi_getreg(priv, ECSPI_CONREG_OFFSET);
+ regval &= ~(ECSPI_CONREG_DATARATE_MASK);
+ regval |= freqbits;
+ spi_putreg(priv, ECSPI_CONREG_OFFSET, regval);
+
+ priv->frequency = frequency;
+ priv->actual = actual;
+ }
+
+ return actual;
+}
+
+/****************************************************************************
+ * Name: spi_setmode
+ *
+ * Description:
+ * Set the SPI mode. Optional. See enum spi_mode_e for mode definitions
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * mode - The SPI mode requested
+ *
+ * Returned Value:
+ * none
+ *
+ ****************************************************************************/
+
+static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ if (priv && mode != priv->mode)
+ {
+ uint32_t modebits;
+ uint32_t regval;
+
+ /* Select the CTL register bits based on the selected mode */
+
+ switch (mode)
+ {
+ case SPIDEV_MODE0: /* CPOL=0 CHPHA=0 */
+ modebits = 0;
+ break;
+
+ case SPIDEV_MODE1: /* CPOL=0 CHPHA=1 */
+ modebits = ECSPI_CONREG_PHA;
+ break;
+
+ case SPIDEV_MODE2: /* CPOL=1 CHPHA=0 */
+ modebits = ECSPI_CONREG_POL;
+ break;
+
+ case SPIDEV_MODE3: /* CPOL=1 CHPHA=1 */
+ modebits = ECSPI_CONREG_PHA | ECSPI_CONREG_POL;
+ break;
+
+ default:
+ return;
+ }
+
+ /* Then set the selected mode */
+
+ regval = spi_getreg(priv, ECSPI_CONREG_OFFSET);
+ regval &= ~(ECSPI_CONREG_PHA | ECSPI_CONREG_POL);
+ regval |= modebits;
+ spi_putreg(priv, ECSPI_CONREG_OFFSET, regval);
+ }
+}
+
+/****************************************************************************
+ * Name: spi_setbits
+ *
+ * Description:
+ * Set the number of bits per word.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * nbits - The number of bits requests
+ *
+ * Returned Value:
+ * none
+ *
+ ****************************************************************************/
+
+static void spi_setbits(FAR struct spi_dev_s *dev, int nbits)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ if (priv && nbits != priv->nbits && nbits > 0 && nbits <= 16)
+ {
+ uint32_t regval = spi_getreg(priv, ECSPI_CONREG_OFFSET);
+ regval &= ~ECSPI_CONREG_BITCOUNT_MASK;
+ regval |= ((nbits - 1) << ECSPI_CONREG_BITCOUNT_SHIFT);
+ spi_putreg(priv, ECSPI_CONREG_OFFSET, regval);
+ priv->nbits = nbits;
+ }
+}
+
+/****************************************************************************
+ * Name: spi_send
+ *
+ * Description:
+ * Exchange one word on SPI
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * wd - The word to send. the size of the data is determined by the
+ * number of bits selected for the SPI interface.
+ *
+ * Returned Value:
+ * response
+ *
+ ****************************************************************************/
+
+static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ uint16_t response = 0;
+
+ (void)spi_transfer(priv, &wd, &response, 1);
+ return response;
+}
+
+/****************************************************************************
+ * Name: spi_status
+ *
+ * Description:
+ * Get SPI/MMC status. Optional.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * devid - Identifies the device to report status on
+ *
+ * Returned Value:
+ * Returns a bitset of status values (see SPI_STATUS_* defines)
+ *
+ ****************************************************************************/
+
+static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ uint8_t ret = 0;
+
+ DEBUGASSERT(priv != NULL);
+
+ if (priv->status != NULL);
+ {
+ ret = priv->select(dev, devid);
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ * Name: spi_cmddata
+ *
+ * Description:
+ * Some devices require and additional out-of-band bit to specify if the
+ * next word sent to the device is a command or data. This is typical, for
+ * example, in "9-bit" displays where the 9th bit is the CMD/DATA bit.
+ * This function provides selection of command or data.
+ *
+ * This "latches" the CMD/DATA state. It does not have to be called before
+ * every word is transferred; only when the CMD/DATA state changes. This
+ * method is required if CONFIG_SPI_CMDDATA is selected in the NuttX
+ * configuration
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * cmd - TRUE: The following word is a command; FALSE: the following words
+ * are data.
+ *
+ * Returned Value:
+ * OK unless an error occurs. Then a negated errno value is returned
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPI_CMDDATA
+static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid,
+ bool cmd)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ int ret = -ENOSYS;
+
+ DEBUGASSERT(priv != NULL);
+
+ if (priv->cmddata != NULL);
+ {
+ ret = priv->cmddata(dev, devid, cmd);
+ }
+
+ return ret;
+}
+#endif
+
+/****************************************************************************
+ * Name: SPI_EXCHANGE
+ *
+ * Description:
+ * Exahange a block of data from SPI. Required.
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * buffer - A pointer to the buffer of data to be sent
+ * rxbuffer - A pointer to the buffer in which to recieve data
+ * nwords - the length of data that to be exchanged in units of words.
+ * The wordsize is determined by the number of bits-per-word
+ * selected for the SPI interface. If nbits <= 8, the data is
+ * packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_SPI_EXCHANGE
+static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
+ FAR void *rxbuffer, size_t nwords)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ (void)spi_transfer(priv, txbuffer, rxbuffer, nwords);
+}
+#endif
+
+/****************************************************************************
+ * Name: spi_sndblock
+ *
+ * Description:
+ * Send a block of data on SPI
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * buffer - A pointer to the buffer of data to be sent
+ * nwords - the length of data to send from the buffer in number of words.
+ * The wordsize is determined by the number of bits-per-word
+ * selected for the SPI interface. If nbits <= 8, the data is
+ * packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_SPI_EXCHANGE
+static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ (void)spi_transfer(priv, buffer, NULL, nwords);
+}
+#endif
+
+/****************************************************************************
+ * Name: spi_recvblock
+ *
+ * Description:
+ * Revice a block of data from SPI
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ * buffer - A pointer to the buffer in which to recieve data
+ * nwords - the length of data that can be received in the buffer in number
+ * of words. The wordsize is determined by the number of bits-per-word
+ * selected for the SPI interface. If nbits <= 8, the data is
+ * packed into uint8_t's; if nbits >8, the data is packed into uint16_t's
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_SPI_EXCHANGE
+static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nwords)
+{
+ struct imx_spidev_s *priv = (struct imx_spidev_s *)dev;
+ (void)spi_transfer(priv, NULL, buffer, nwords);
+}
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: imx_spibus_initialize
+ *
+ * Description:
+ * Initialize common parts the selected SPI port. Initialization of
+ * chip select GPIOs must have been performed by board specific logic
+ * prior to calling this function. Specifically: GPIOs should have
+ * been configured for output, and all chip selects disabled.
+ *
+ * One GPIO, SS (PB2 on the eZ8F091) is reserved as a chip select. However,
+ * If multiple devices on on the bus, then multiple chip selects will be
+ * required. Theregore, all GPIO chip management is deferred to board-
+ * specific logic.
+ *
+ * Input Parameter:
+ * Port number (for hardware that has mutiple SPI interfaces)
+ *
+ * Returned Value:
+ * Valid SPI device structre reference on succcess; a NULL on failure
+ *
+ ****************************************************************************/
+
+FAR struct spi_dev_s *imx_spibus_initialize(int port)
+{
+ struct imx_spidev_s *priv;
+ uint8_t regval;
+
+ /* Only the SPI1 interface is supported */
+
+ switch (port)
+ {
+#ifdef CONFIG_IMX6_ECSPI1
+ case 1:
+ /* Select SPI1 */
+
+ priv = &g_spidev[SPI1_NDX];
+
+ /* Configure SPI1 GPIOs (NOTE that SS is not initialized here, the
+ * logic in this file makes no assumptions about chip select)
+ */
+
+ imxgpio_configpfinput(GPIOC, 13); /* Port C, pin 13: RDY */
+ imxgpio_configpfoutput(GPIOC, 14); /* Port C, pin 14: SCLK */
+ imxgpio_configpfinput(GPIOC, 16); /* Port C, pin 16: MISO */
+ imxgpio_configpfoutput(GPIOC, 17); /* Port C, pin 17: MOSI */
+ break;
+#endif /* CONFIG_IMX6_ECSPI1 */
+
+#ifdef CONFIG_IMX6_ECSPI2
+ case 2:
+ /* Select SPI2 */
+
+ priv = &g_spidev[SPI2_NDX];
+
+ /* Configure SPI2 GPIOs */
+ /* SCLK: AIN of Port A, pin 0 -OR- AIN of Port D, pin 7 */
+
+#if 1
+ imxgpio_configoutput(GPIOA, 0); /* Set GIUS=1 OCR=0 DIR=OUT */
+#else
+ imxgpio_configoutput(GPIOD, 7); /* Set GIUS=1 OCR=0 DIR=OUT */
+#endif
+
+ /* SS: AIN of Port A, pin 17 -OR- AIN of Port D, pin 8.(NOTE that SS
+ * is not initialized here, the logic in this file makes no assumptions
+ * about chip select)
+ */
+
+ /* RXD: AOUT of Port A, pin 1 -OR- AOUT of Port D, pin 9 */
+
+#if 1
+ imxgpio_configinput(GPIOA, 1); /* Set GIUS=1 OCR=0 DIR=IN */
+
+ /* Select input from SPI2_RXD_0 pin (AOUT Port A, pin 1) */
+
+ regval = getreg32(IMX_SC_FMCR);
+ regval &= ~FMCR_SPI2_RXDSEL;
+ putreg32(regval, IMX_SC_FMCR);
+#else
+ imxgpio_configinput(GPIOD, 9); /* Set GIUS=1 OCR=0 DIR=IN */
+
+ /* Select input from SPI2_RXD_1 pin (AOUT Port D, pin 9) */
+
+ regval = getreg32(IMX_SC_FMCR);
+ regval |= FMCR_SPI2_RXDSEL;
+ putreg32(regval, IMX_SC_FMCR);
+#endif
+
+ /* TXD: BIN of Port D, pin 31 -OR- AIN of Port D, pin 10 */
+
+#if 1
+ imxgpio_configinput(GPIOD, 31);
+ imxgpio_ocrbin(GPIOD, 31);
+ imxgpio_dirout(GPIOD, 31);
+#else
+ imxgpio_configoutput(GPIOD, 10);
+#endif
+ break;
+#endif /* CONFIG_IMX6_ECSPI2 */
+
+ default:
+ return NULL;
+ }
+
+ /* Initialize the state structure */
+ /* Initialize Semaphores */
+
+#ifndef CONFIG_SPI_POLLWAIT
+ /* Initialize the semaphore that is used to wake up the waiting
+ * thread when the DMA transfer completes. This semaphore is used for
+ * signaling and, hence, should not have priority inheritance enabled.
+ */
+
+ sem_init(&priv->waitsem, 0, 0);
+ sem_setprotocol(&priv->waitsem, SEM_PRIO_NONE);
+#endif
+ sem_init(&priv->exclsem, 0, 1);
+
+ /* Initialize control register: min frequency, ignore ready, master mode, mode=0, 8-bit */
+
+ spi_putreg(priv, ECSPI_CONREG_OFFSET,
+ ECSPI_CONREG_DIV512 | /* Lowest frequency */
+ ECSPI_CONREG_DRCTL_IGNRDY | /* Ignore ready */
+ ECSPI_CONREG_MODE | /* Master mode */
+ (7 << ECSPI_CONREG_BITCOUNT_SHIFT)); /* 8-bit data */
+
+ /* Make sure state agrees with data */
+
+ priv->mode = SPIDEV_MODE0;
+ priv->nbits = 8;
+
+ /* Set the initial clock frequency for identification mode < 400kHz */
+
+ spi_setfrequency((FAR struct spi_dev_s *)priv, 400000);
+
+ /* Enable interrupts on data ready (and certain error conditions */
+
+#ifndef CONFIG_SPI_POLLWAIT
+ spi_putreg(priv, ECSPI_INTREG_OFFSET,
+ ECSPI_INT_RR | /* RXFIFO Data Ready Interrupt Enable */
+ ECSPI_INT_RO | /* RXFIFO Overflow Interrupt Enable */
+ ECSPI_INT_BO); /* Bit Count Overflow Interrupt Enable */
+#else
+ spi_putreg(priv, ECSPI_INTREG_OFFSET, 0); /* No interrupts */
+#endif
+
+ /* Set the clock source=bit clock and number of clocks inserted between
+ * transactions = 2.
+ */
+
+ spi_putreg(priv, ECSPI_PERIODREG_OFFSET, 2);
+
+ /* No DMA */
+
+ spi_putreg(priv, ECSPI_DMAREG_OFFSET, 0);
+
+ /* Attach the interrupt */
+
+#ifndef CONFIG_SPI_POLLWAIT
+ DEBUGVERIFY(irq_attach(priv->irq, priv->handler));
+#endif
+
+ /* Enable SPI */
+
+ regval = spi_getreg(priv, ECSPI_CONREG_OFFSET);
+ regval |= ECSPI_CONREG_SPIEN;
+ spi_putreg(priv, ECSPI_CONREG_OFFSET, regval);
+
+ /* Enable SPI interrupts */
+
+#ifndef CONFIG_SPI_POLLWAIT
+ up_enable_irq(priv->irq);
+#endif
+ return (FAR struct spi_dev_s *)priv;
+}
+
+#endif /* NSPIS > 0 */
diff --git a/arch/arm/src/imx6/imx_irq.c b/arch/arm/src/imx6/imx_irq.c
index e00a8e9527dfa0585a8760d097da4663353c8d45..b15a9a4e6ddbc7a707196b4e51390c3e47398d78 100644
--- a/arch/arm/src/imx6/imx_irq.c
+++ b/arch/arm/src/imx6/imx_irq.c
@@ -134,11 +134,11 @@ void up_irqinitialize(void)
CURRENT_REGS = NULL;
#ifndef CONFIG_SUPPRESS_INTERRUPTS
+#ifdef CONFIG_IMX6_PIO_IRQ
/* Initialize logic to support a second level of interrupt decoding for
* PIO pins.
*/
-#ifdef CONFIG_IMX6_PIO_IRQ
imx_gpioirq_initialize();
#endif
diff --git a/arch/arm/src/kinetis/Kconfig b/arch/arm/src/kinetis/Kconfig
index 17923818b5a495dcba8bbe649f1b1e223b47f1cd..a585a57fe439a02a54bb2e5f05b62fd61ea0b668 100644
--- a/arch/arm/src/kinetis/Kconfig
+++ b/arch/arm/src/kinetis/Kconfig
@@ -254,7 +254,6 @@ config KINETIS_ENET
select ARCH_HAVE_NETDEV_STATISTICS
select NET
select NETDEVICES
- select NET_MULTIBUFFER
---help---
Support Ethernet (K6x only)
@@ -629,6 +628,25 @@ config KINETIS_ENET_NORXER
If selected, then the MII/RMII RXER output will be configured as a
GPIO and pulled low.
+choice
+ prompt "Work queue"
+ default KINETIS_EMAC_LPWORK if SCHED_LPWORK
+ default KINETIS_EMAC_HPWORK if !SCHED_LPWORK && SCHED_HPWORK
+ depends on SCHED_WORKQUEUE
+ ---help---
+ Work queue support is required to use the Ethernet driver. If the
+ low priority work queue is available, then it should be used by the
+ driver.
+
+config KINETIS_EMAC_HPWORK
+ bool "High priority"
+ depends on SCHED_HPWORK
+
+config KINETIS_EMAC_LPWORK
+ bool "Low priority"
+ depends on SCHED_LPWORK
+
+endchoice # Work queue
endmenu # Kinetis Ethernet Configuration
menu "Kinetis SDHC Configuration"
diff --git a/arch/arm/src/kinetis/Make.defs b/arch/arm/src/kinetis/Make.defs
index bb7f54d87bb7b7530c675a2df9142134268e9c97..e4dd09df79082b7241f7eb1e26104fad27a9dbd3 100644
--- a/arch/arm/src/kinetis/Make.defs
+++ b/arch/arm/src/kinetis/Make.defs
@@ -33,11 +33,14 @@
#
############################################################################
-# The start-up, "head", file
-
+ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y)
+HEAD_ASRC =
+else
HEAD_ASRC = kinetis_vectors.S
+endif
-# Common ARM and Cortex-M3 files
+CMN_UASRCS =
+CMN_UCSRCS =
CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S
CMN_ASRCS += up_testset.S vfork.S
@@ -48,9 +51,22 @@ CMN_CSRCS += up_initialstate.c up_interruptcontext.c up_modifyreg8.c
CMN_CSRCS += up_modifyreg16.c up_modifyreg32.c up_releasestack.c
CMN_CSRCS += up_reprioritizertr.c up_schedulesigaction.c up_releasepending.c
CMN_CSRCS += up_sigdeliver.c up_stackframe.c up_unblocktask.c up_usestack.c
-CMN_CSRCS += up_doirq.c up_hardfault.c up_svcall.c up_checkstack.c up_vfork.c
+CMN_CSRCS += up_doirq.c up_hardfault.c up_svcall.c up_vfork.c
CMN_CSRCS += up_systemreset.c
+ifeq ($(CONFIG_ARMV7M_STACKCHECK),y)
+CMN_CSRCS += up_stackcheck.c
+endif
+
+ifeq ($(CONFIG_ARMV7M_CMNVECTOR),y)
+ifeq ($(CONFIG_ARMV7M_LAZYFPU),y)
+CMN_ASRCS += up_lazyexception.S
+else
+CMN_ASRCS += up_exception.S
+endif
+CMN_CSRCS += up_vectors.c
+endif
+
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)
CMN_CSRCS += up_ramvec_initialize.c up_ramvec_attach.c
endif
@@ -67,6 +83,10 @@ CMN_UASRCS += up_signal_handler.S
endif
endif
+ifeq ($(CONFIG_STACK_COLORATION),y)
+CMN_CSRCS += up_checkstack.c
+endif
+
# Use of common/up_etherstub.c is deprecated. The preferred mechanism is to
# use CONFIG_NETDEV_LATEINIT=y to suppress the call to up_netinitialize() in
# up_initialize(). Then this stub would not be needed.
@@ -83,6 +103,19 @@ else ifeq ($(CONFIG_MODULE),y)
CMN_CSRCS += up_elf.c
endif
+ifeq ($(CONFIG_ARCH_FPU),y)
+CMN_ASRCS += up_fpu.S
+ifneq ($(CONFIG_ARMV7M_CMNVECTOR),y)
+CMN_CSRCS += up_copyarmstate.c
+else ifeq ($(CONFIG_ARMV7M_LAZYFPU),y)
+CMN_CSRCS += up_copyarmstate.c
+endif
+endif
+
+ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)
+CMN_CSRCS += up_itm_syslog.c
+endif
+
# Required Kinetis files
CHIP_ASRCS =
@@ -90,7 +123,7 @@ CHIP_ASRCS =
CHIP_CSRCS = kinetis_allocateheap.c kinetis_clockconfig.c
CHIP_CSRCS += kinetis_clrpend.c kinetis_idle.c kinetis_irq.c
CHIP_CSRCS += kinetis_lowputc.c kinetis_pin.c kinetis_pingpio.c
-CHIP_CSRCS += kinetis_serial.c kinetis_start.c kinetis_wdog.c
+CHIP_CSRCS += kinetis_serial.c kinetis_start.c kinetis_uid.c kinetis_wdog.c
CHIP_CSRCS += kinetis_cfmconfig.c
# Configuration-dependent Kinetis files
@@ -131,6 +164,10 @@ ifeq ($(CONFIG_PWM),y)
CHIP_CSRCS += kinetis_pwm.c
endif
+ifeq ($(CONFIG_PWM),y)
+CHIP_CSRCS += kinetis_dma.c
+endif
+
ifeq ($(CONFIG_I2C),y)
CHIP_CSRCS += kinetis_i2c.c
endif
diff --git a/arch/arm/src/kinetis/chip.h b/arch/arm/src/kinetis/chip.h
index 26fa7e38a0daaed85b59748db1c91cf6a1ba7ac1..c16f31b14d9b8f106289ca899f20a8a94673e01d 100644
--- a/arch/arm/src/kinetis/chip.h
+++ b/arch/arm/src/kinetis/chip.h
@@ -46,9 +46,18 @@
* should then include this file for the proper setup.
*/
+#include
#include
#include "chip/kinetis_memorymap.h"
+/* If the common ARMv7-M vector handling logic is used, then it expects the
+ * following definition in this file that provides the number of supported external
+ * interrupts which, for this architecture, is provided in the arch/stm32f7/chip.h
+ * header file.
+ */
+
+#define ARMV7M_PERIPHERAL_INTERRUPTS NR_INTERRUPTS
+
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
diff --git a/arch/arm/src/kinetis/chip/kinetis_k20vectors.h b/arch/arm/src/kinetis/chip/kinetis_k20vectors.h
new file mode 100644
index 0000000000000000000000000000000000000000..ef0730d4aefeaa54860d1b13f35425ba42ee709b
--- /dev/null
+++ b/arch/arm/src/kinetis/chip/kinetis_k20vectors.h
@@ -0,0 +1,156 @@
+/************************************************************************************
+ * arch/arm/src/kinetis/chip/kinetis_k20vectors.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+/* This file is included by kinetis_vectors.S. It provides the macro VECTOR that
+ * supplies ach K20 vector in terms of a (lower-case) ISR label and an
+ * (upper-case) IRQ number as defined in arch/arm/include/kinetis/kinetis_k20irq.h.
+ * kinetis_vectors.S will defined the VECTOR in different ways in order to generate
+ * the interrupt vectors and handlers in their final form.
+ */
+
+#if defined(CONFIG_ARCH_FAMILY_K20)
+
+/* If the common ARMv7-M vector handling is used, then all it needs is the following
+ * definition that provides the number of supported vectors.
+ */
+
+# ifdef CONFIG_ARMV7M_CMNVECTOR
+
+/* Reserve interrupt table entries for I/O interrupts. */
+
+# define ARMV7M_PERIPHERAL_INTERRUPTS NR_INTERRUPTS
+
+# else
+VECTOR(kinetis_dmach0, KINETIS_IRQ_DMACH0) /* Vector 16: DMA channel 0 transfer complete */
+VECTOR(kinetis_dmach1, KINETIS_IRQ_DMACH1) /* Vector 17: DMA channel 1 transfer complete */
+VECTOR(kinetis_dmach2, KINETIS_IRQ_DMACH2) /* Vector 18: DMA channel 2 transfer complete */
+VECTOR(kinetis_dmach3, KINETIS_IRQ_DMACH3) /* Vector 19: DMA channel 3 transfer complete */
+VECTOR(kinetis_dmach4, KINETIS_IRQ_DMACH4) /* Vector 20: DMA channel 4 transfer complete */
+VECTOR(kinetis_dmach5, KINETIS_IRQ_DMACH5) /* Vector 21: DMA channel 5 transfer complete */
+VECTOR(kinetis_dmach6, KINETIS_IRQ_DMACH6) /* Vector 22: DMA channel 6 transfer complete */
+VECTOR(kinetis_dmach7, KINETIS_IRQ_DMACH7) /* Vector 23: DMA channel 7 transfer complete */
+VECTOR(kinetis_dmach8, KINETIS_IRQ_DMACH8) /* Vector 24: DMA channel 8 transfer complete */
+VECTOR(kinetis_dmach9, KINETIS_IRQ_DMACH9) /* Vector 25: DMA channel 9 transfer complete */
+VECTOR(kinetis_dmach10, KINETIS_IRQ_DMACH10) /* Vector 26: DMA channel 10 transfer complete */
+VECTOR(kinetis_dmach11, KINETIS_IRQ_DMACH11) /* Vector 27: DMA channel 11 transfer complete */
+VECTOR(kinetis_dmach12, KINETIS_IRQ_DMACH12) /* Vector 28: DMA channel 12 transfer complete */
+VECTOR(kinetis_dmach13, KINETIS_IRQ_DMACH13) /* Vector 29: DMA channel 13 transfer complete */
+VECTOR(kinetis_dmach14, KINETIS_IRQ_DMACH14) /* Vector 30: DMA channel 14 transfer complete */
+VECTOR(kinetis_dmach15, KINETIS_IRQ_DMACH15) /* Vector 31: DMA channel 15 transfer complete */
+VECTOR(kinetis_dmaerr, KINETIS_IRQ_DMAERR) /* Vector 32: DMA error interrupt channels 0-15 */
+UNUSED(KINETIS_IRQ_RESVD17) /* Vector 33: Reserved */
+VECTOR(kinetis_flashcc, KINETIS_IRQ_FLASHCC) /* Vector 34: Flash memory command complete */
+VECTOR(kinetis_flashrc, KINETIS_IRQ_FLASHRC) /* Vector 35: Flash memory read collision */
+VECTOR(kinetis_smclvd, KINETIS_IRQ_SMCLVD) /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
+VECTOR(kinetis_llwu, KINETIS_IRQ_LLWU) /* Vector 37: LLWU Normal Low Leakage Wakeup */
+VECTOR(kinetis_wdog, KINETIS_IRQ_WDOG) /* Vector 38: Watchdog */
+UNUSED(KINETIS_IRQ_RESVD23) /* Vector 39: Reserved */
+VECTOR(kinetis_i2c0, KINETIS_IRQ_I2C0) /* Vector 40: I2C0 */
+VECTOR(kinetis_i2c1, KINETIS_IRQ_I2C1) /* Vector 41: I2C1 */
+VECTOR(kinetis_spi0, KINETIS_IRQ_SPI0) /* Vector 42: SPI0 all sources */
+VECTOR(kinetis_spi1, KINETIS_IRQ_SPI1) /* Vector 43: SPI1 all sources */
+UNUSED(KINETIS_IRQ_RESVD28) /* Vector 44: Reserved */
+VECTOR(kinetis_can0mb, KINETIS_IRQ_CAN0MB) /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
+VECTOR(kinetis_can0bo, KINETIS_IRQ_CAN0BO) /* Vector 46: CAN0 Bus Off */
+VECTOR(kinetis_can0err, KINETIS_IRQ_CAN0ERR) /* Vector 47: CAN0 Error */
+VECTOR(kinetis_can0tw, KINETIS_IRQ_CAN0TW) /* Vector 48: CAN0 Transmit Warning */
+VECTOR(kinetis_can0rw, KINETIS_IRQ_CAN0RW) /* Vector 49: CAN0 Receive Warning */
+VECTOR(kinetis_can0wu, KINETIS_IRQ_CAN0WU) /* Vector 50: CAN0 Wake UP */
+UNUSED(KINETIS_IRQ_RESVD35) /* Vector 51: Reserved */
+UNUSED(KINETIS_IRQ_RESVD36) /* Vector 52: Reserved */
+UNUSED(KINETIS_IRQ_RESVD37) /* Vector 53: Reserved */
+UNUSED(KINETIS_IRQ_RESVD38) /* Vector 54: Reserved */
+UNUSED(KINETIS_IRQ_RESVD39) /* Vector 55: Reserved */
+UNUSED(KINETIS_IRQ_RESVD40) /* Vector 56: Reserved */
+UNUSED(KINETIS_IRQ_RESVD41) /* Vector 57: Reserved */
+UNUSED(KINETIS_IRQ_RESVD42) /* Vector 58: Reserved */
+UNUSED(KINETIS_IRQ_RESVD43) /* Vector 59: Reserved */
+VECTOR(kinetis_uart0l, KINETIS_IRQ_UART0L) /* Vector 60: UART0 LON */
+VECTOR(kinetis_uart0s, KINETIS_IRQ_UART0S) /* Vector 61: UART0 status */
+VECTOR(kinetis_uart0e, KINETIS_IRQ_UART0E) /* Vector 62: UART0 error */
+VECTOR(kinetis_uart1s, KINETIS_IRQ_UART1S) /* Vector 63: UART1 status */
+VECTOR(kinetis_uart1e, KINETIS_IRQ_UART1E) /* Vector 64: UART1 error */
+VECTOR(kinetis_uart2s, KINETIS_IRQ_UART2S) /* Vector 65: UART2 status */
+VECTOR(kinetis_uart2e, KINETIS_IRQ_UART2E) /* Vector 66: UART2 error */
+UNUSED(KINETIS_IRQ_RESVD51) /* Vector 67: Reserved */
+UNUSED(KINETIS_IRQ_RESVD52) /* Vector 68: Reserved */
+UNUSED(KINETIS_IRQ_RESVD53) /* Vector 69: Reserved */
+UNUSED(KINETIS_IRQ_RESVD54) /* Vector 70: Reserved */
+UNUSED(KINETIS_IRQ_RESVD55) /* Vector 71: Reserved */
+UNUSED(KINETIS_IRQ_RESVD56) /* Vector 72: Reserved */
+VECTOR(kinetis_adc0, KINETIS_IRQ_ADC0) /* Vector 73: ADC0 */
+VECTOR(kinetis_adc1, KINETIS_IRQ_ADC1) /* Vector 74: ADC1 */
+VECTOR(kinetis_cmp0, KINETIS_IRQ_CMP0) /* Vector 75: CMP0 */
+VECTOR(kinetis_cmp1, KINETIS_IRQ_CMP1) /* Vector 76: CMP1 */
+VECTOR(kinetis_cmp2, KINETIS_IRQ_CMP2) /* Vector 77: CMP2 */
+VECTOR(kinetis_ftm0, KINETIS_IRQ_FTM0) /* Vector 78: FTM0 all sources */
+VECTOR(kinetis_ftm1, KINETIS_IRQ_FTM1) /* Vector 79: FTM1 all sources */
+VECTOR(kinetis_ftm2, KINETIS_IRQ_FTM2) /* Vector 80: FTM2 all sources */
+VECTOR(kinetis_cmt, KINETIS_IRQ_CMT) /* Vector 81: CMT */
+VECTOR(kinetis_rtc, KINETIS_IRQ_RTC) /* Vector 82: RTC alarm interrupt */
+VECTOR(kinetis_rtcs, KINETIS_IRQ_RTCS) /* Vector 83: RTC seconds interrupt */
+VECTOR(kinetis_pitch0, KINETIS_IRQ_PITCH0) /* Vector 84: PIT channel 0 */
+VECTOR(kinetis_pitch1, KINETIS_IRQ_PITCH1) /* Vector 85: PIT channel 1 */
+VECTOR(kinetis_pitch2, KINETIS_IRQ_PITCH2) /* Vector 86: PIT channel 2 */
+VECTOR(kinetis_pitch3, KINETIS_IRQ_PITCH3) /* Vector 87: PIT channel 3 */
+VECTOR(kinetis_pdb, KINETIS_IRQ_PDB) /* Vector 88: PDB */
+VECTOR(kinetis_usbotg, KINETIS_IRQ_USBOTG) /* Vector 89: USB OTG */
+VECTOR(kinetis_usbcd, KINETIS_IRQ_USBCD) /* Vector 90: USB charger detect */
+UNUSED(KINETIS_IRQ_RESVD75) /* Vector 91: Reserved */
+UNUSED(KINETIS_IRQ_RESVD76) /* Vector 92: Reserved */
+UNUSED(KINETIS_IRQ_RESVD77) /* Vector 93: Reserved */
+UNUSED(KINETIS_IRQ_RESVD78) /* Vector 94: Reserved */
+UNUSED(KINETIS_IRQ_RESVD79) /* Vector 95: Reserved */
+UNUSED(KINETIS_IRQ_RESVD80) /* Vector 96: Reserved */
+VECTOR(kinetis_dac0, KINETIS_IRQ_DAC0) /* Vector 97: DAC0 */
+UNUSED(KINETIS_IRQ_RESVD82) /* Vector 98: Reserved */
+VECTOR(kinetis_tsi, KINETIS_IRQ_TSI) /* Vector 99: TSI all sources */
+VECTOR(kinetis_mcg, KINETIS_IRQ_MCG) /* Vector 100: MCG */
+VECTOR(kinetis_lpt, KINETIS_IRQ_LPT) /* Vector 101: Low power timer */
+UNUSED(KINETIS_IRQ_RESVD86) /* Vector 102: Reserved */
+VECTOR(kinetis_porta, KINETIS_IRQ_PORTA) /* Vector 103: Pin detect port A */
+VECTOR(kinetis_portb, KINETIS_IRQ_PORTB) /* Vector 104: Pin detect port B */
+VECTOR(kinetis_portc, KINETIS_IRQ_PORTC) /* Vector 105: Pin detect port C */
+VECTOR(kinetis_portd, KINETIS_IRQ_PORTD) /* Vector 106: Pin detect port D */
+VECTOR(kinetis_porte, KINETIS_IRQ_PORTE) /* Vector 107: Pin detect port E */
+UNUSED(KINETIS_IRQ_RESVD92) /* Vector 108: Reserved */
+UNUSED(KINETIS_IRQ_RESVD93) /* Vector 109: Reserved */
+VECTOR(kinetis_swi, KINETIS_IRQ_SWI) /* Vector 110: Software interrupt */
+# endif /* CONFIG_ARMV7M_CMNVECTOR */
+#endif /* CONFIG_STM32_CONNECTIVITYLINE */
diff --git a/arch/arm/src/kinetis/chip/kinetis_k40vectors.h b/arch/arm/src/kinetis/chip/kinetis_k40vectors.h
new file mode 100644
index 0000000000000000000000000000000000000000..08aeb61e20505b23385ed810de68a7678e0e03fa
--- /dev/null
+++ b/arch/arm/src/kinetis/chip/kinetis_k40vectors.h
@@ -0,0 +1,156 @@
+/************************************************************************************
+ * arch/arm/src/kinetis/chip/kinetis_k40vectors.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+/* This file is included by kinetis_vectors.S. It provides the macro VECTOR that
+ * supplies ach K40 vector in terms of a (lower-case) ISR label and an
+ * (upper-case) IRQ number as defined in arch/arm/include/kinetis/kinetis_k40irq.h.
+ * kinetis_vectors.S will defined the VECTOR in different ways in order to generate
+ * the interrupt vectors and handlers in their final form.
+ */
+
+#if defined(CONFIG_ARCH_FAMILY_K40)
+
+/* If the common ARMv7-M vector handling is used, then all it needs is the following
+ * definition that provides the number of supported vectors.
+ */
+
+# ifdef CONFIG_ARMV7M_CMNVECTOR
+
+/* Reserve interrupt table entries for I/O interrupts. */
+
+# define ARMV7M_PERIPHERAL_INTERRUPTS NR_INTERRUPTS
+
+# else
+VECTOR(kinetis_dmach0, KINETIS_IRQ_DMACH0) /* Vector 16: DMA channel 0 transfer complete */
+VECTOR(kinetis_dmach1, KINETIS_IRQ_DMACH1) /* Vector 17: DMA channel 1 transfer complete */
+VECTOR(kinetis_dmach2, KINETIS_IRQ_DMACH2) /* Vector 18: DMA channel 2 transfer complete */
+VECTOR(kinetis_dmach3, KINETIS_IRQ_DMACH3) /* Vector 19: DMA channel 3 transfer complete */
+VECTOR(kinetis_dmach4, KINETIS_IRQ_DMACH4) /* Vector 20: DMA channel 4 transfer complete */
+VECTOR(kinetis_dmach5, KINETIS_IRQ_DMACH5) /* Vector 21: DMA channel 5 transfer complete */
+VECTOR(kinetis_dmach6, KINETIS_IRQ_DMACH6) /* Vector 22: DMA channel 6 transfer complete */
+VECTOR(kinetis_dmach7, KINETIS_IRQ_DMACH7) /* Vector 23: DMA channel 7 transfer complete */
+VECTOR(kinetis_dmach8, KINETIS_IRQ_DMACH8) /* Vector 24: DMA channel 8 transfer complete */
+VECTOR(kinetis_dmach9, KINETIS_IRQ_DMACH9) /* Vector 25: DMA channel 9 transfer complete */
+VECTOR(kinetis_dmach10, KINETIS_IRQ_DMACH10) /* Vector 26: DMA channel 10 transfer complete */
+VECTOR(kinetis_dmach11, KINETIS_IRQ_DMACH11) /* Vector 27: DMA channel 11 transfer complete */
+VECTOR(kinetis_dmach12, KINETIS_IRQ_DMACH12) /* Vector 28: DMA channel 12 transfer complete */
+VECTOR(kinetis_dmach13, KINETIS_IRQ_DMACH13) /* Vector 29: DMA channel 13 transfer complete */
+VECTOR(kinetis_dmach14, KINETIS_IRQ_DMACH14) /* Vector 30: DMA channel 14 transfer complete */
+VECTOR(kinetis_dmach15, KINETIS_IRQ_DMACH15) /* Vector 31: DMA channel 15 transfer complete */
+VECTOR(kinetis_dmaerr, KINETIS_IRQ_DMAERR) /* Vector 32: DMA error interrupt channels 0-15 */
+VECTOR(kinetis_mcm, KINETIS_IRQ_MCM) /* Vector 33: MCM Normal interrupt */
+VECTOR(kinetis_flashcc, KINETIS_IRQ_FLASHCC) /* Vector 34: Flash memory command complete */
+VECTOR(kinetis_flashrc, KINETIS_IRQ_FLASHRC) /* Vector 35: Flash memory read collision */
+VECTOR(kinetis_smclvd, KINETIS_IRQ_SMCLVD) /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
+VECTOR(kinetis_llwu, KINETIS_IRQ_LLWU) /* Vector 37: LLWU Normal Low Leakage Wakeup */
+VECTOR(kinetis_wdog, KINETIS_IRQ_WDOG) /* Vector 38: Watchdog */
+UNUSED(KINETIS_IRQ_RESVD23) /* Vector 39: Reserved */
+VECTOR(kinetis_i2c0, KINETIS_IRQ_I2C0) /* Vector 40: I2C0 */
+VECTOR(kinetis_i2c1, KINETIS_IRQ_I2C1) /* Vector 41: I2C1 */
+VECTOR(kinetis_spi0, KINETIS_IRQ_SPI0) /* Vector 42: SPI0 all sources */
+VECTOR(kinetis_spi1, KINETIS_IRQ_SPI1) /* Vector 43: SPI1 all sources */
+VECTOR(kinetis_spi2, KINETIS_IRQ_SPI2) /* Vector 44: SPI2 all sources */
+VECTOR(kinetis_can0mb, KINETIS_IRQ_CAN0MB) /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
+VECTOR(kinetis_can0bo, KINETIS_IRQ_CAN0BO) /* Vector 46: CAN0 Bus Off */
+VECTOR(kinetis_can0err, KINETIS_IRQ_CAN0ERR) /* Vector 47: CAN0 Error */
+VECTOR(kinetis_can0tw, KINETIS_IRQ_CAN0TW) /* Vector 48: CAN0 Transmit Warning */
+VECTOR(kinetis_can0rw, KINETIS_IRQ_CAN0RW) /* Vector 49: CAN0 Receive Warning */
+VECTOR(kinetis_can0wu, KINETIS_IRQ_CAN0WU) /* Vector 50: CAN0 Wake UP */
+UNUSED(KINETIS_IRQ_RESVD35) /* Vector 51: Reserved */
+UNUSED(KINETIS_IRQ_RESVD36) /* Vector 52: Reserved */
+VECTOR(kinetis_can1mb, KINETIS_IRQ_CAN1MB) /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
+VECTOR(kinetis_can1bo, KINETIS_IRQ_CAN1BO) /* Vector 54: CAN1 Bus Off */
+VECTOR(kinetis_can1err, KINETIS_IRQ_CAN1ERR) /* Vector 55: CAN1 Error */
+VECTOR(kinetis_can1tw, KINETIS_IRQ_CAN1TW) /* Vector 56: CAN1 Transmit Warning */
+VECTOR(kinetis_can1rw, KINETIS_IRQ_CAN1RW) /* Vector 57: CAN1 Receive Warning */
+VECTOR(kinetis_can1wu, KINETIS_IRQ_CAN1WU) /* Vector 58: CAN1 Wake UP */
+UNUSED(KINETIS_IRQ_RESVD43) /* Vector 59: Reserved */
+UNUSED(KINETIS_IRQ_RESVD44) /* Vector 60: Reserved */
+VECTOR(kinetis_uart0s, KINETIS_IRQ_UART0S) /* Vector 61: UART0 status */
+VECTOR(kinetis_uart0e, KINETIS_IRQ_UART0E) /* Vector 62: UART0 error */
+VECTOR(kinetis_uart1s, KINETIS_IRQ_UART1S) /* Vector 63: UART1 status */
+VECTOR(kinetis_uart1e, KINETIS_IRQ_UART1E) /* Vector 64: UART1 error */
+VECTOR(kinetis_uart2s, KINETIS_IRQ_UART2S) /* Vector 65: UART2 status */
+VECTOR(kinetis_uart2e, KINETIS_IRQ_UART2E) /* Vector 66: UART2 error */
+VECTOR(kinetis_uart3s, KINETIS_IRQ_UART3S) /* Vector 67: UART3 status */
+VECTOR(kinetis_uart3e, KINETIS_IRQ_UART3E) /* Vector 68: UART3 error */
+VECTOR(kinetis_uart4s, KINETIS_IRQ_UART4S) /* Vector 69: UART4 status */
+VECTOR(kinetis_uart4e, KINETIS_IRQ_UART4E) /* Vector 70: UART4 error */
+VECTOR(kinetis_uart5s, KINETIS_IRQ_UART5S) /* Vector 71: UART5 status */
+VECTOR(kinetis_uart5e, KINETIS_IRQ_UART5E) /* Vector 72: UART5 error */
+VECTOR(kinetis_adc0, KINETIS_IRQ_ADC0) /* Vector 73: ADC0 */
+VECTOR(kinetis_adc1, KINETIS_IRQ_ADC1) /* Vector 74: ADC1 */
+VECTOR(kinetis_cmp0, KINETIS_IRQ_CMP0) /* Vector 75: CMP0 */
+VECTOR(kinetis_cmp1, KINETIS_IRQ_CMP1) /* Vector 76: CMP1 */
+VECTOR(kinetis_cmp2, KINETIS_IRQ_CMP2) /* Vector 77: CMP2 */
+VECTOR(kinetis_ftm0, KINETIS_IRQ_FTM0) /* Vector 78: FTM0 all sources */
+VECTOR(kinetis_ftm1, KINETIS_IRQ_FTM1) /* Vector 79: FTM1 all sources */
+VECTOR(kinetis_ftm2, KINETIS_IRQ_FTM2) /* Vector 80: FTM2 all sources */
+VECTOR(kinetis_cmt, KINETIS_IRQ_CMT) /* Vector 81: CMT */
+VECTOR(kinetis_rtc, KINETIS_IRQ_RTC) /* Vector 82: RTC alarm interrupt */
+UNUSED(KINETIS_IRQ_RESVD67) /* Vector 83: Reserved */
+VECTOR(kinetis_pitch0, KINETIS_IRQ_PITCH0) /* Vector 84: PIT channel 0 */
+VECTOR(kinetis_pitch1, KINETIS_IRQ_PITCH1) /* Vector 85: PIT channel 1 */
+VECTOR(kinetis_pitch2, KINETIS_IRQ_PITCH2) /* Vector 86: PIT channel 2 */
+VECTOR(kinetis_pitch3, KINETIS_IRQ_PITCH3) /* Vector 87: PIT channel 3 */
+VECTOR(kinetis_pdb, KINETIS_IRQ_PDB) /* Vector 88: PDB */
+VECTOR(kinetis_usbotg, KINETIS_IRQ_USBOTG) /* Vector 89: USB OTG */
+VECTOR(kinetis_usbcd, KINETIS_IRQ_USBCD) /* Vector 90: USB charger detect */
+UNUSED(KINETIS_IRQ_RESVD75) /* Vector 91: Reserved */
+UNUSED(KINETIS_IRQ_RESVD76) /* Vector 92: Reserved */
+UNUSED(KINETIS_IRQ_RESVD77) /* Vector 93: Reserved */
+UNUSED(KINETIS_IRQ_RESVD78) /* Vector 94: Reserved */
+VECTOR(kinetis_i2s0, KINETIS_IRQ_I2S0) /* Vector 95: I2S0 */
+VECTOR(kinetis_sdhc, KINETIS_IRQ_SDHC) /* Vector 96: SDHC */
+VECTOR(kinetis_dac0, KINETIS_IRQ_DAC0) /* Vector 97: DAC0 */
+VECTOR(kinetis_dac1, KINETIS_IRQ_DAC1) /* Vector 98: DAC1 */
+VECTOR(kinetis_tsi, KINETIS_IRQ_TSI) /* Vector 99: TSI all sources */
+VECTOR(kinetis_mcg, KINETIS_IRQ_MCG) /* Vector 100: MCG */
+VECTOR(kinetis_lpt, KINETIS_IRQ_LPT) /* Vector 101: Low power timer */
+VECTOR(kinetis_slcd, KINETIS_IRQ_SLCD) /* Vector 102: Segment LCD all sources */
+VECTOR(kinetis_porta, KINETIS_IRQ_PORTA) /* Vector 103: Pin detect port A */
+VECTOR(kinetis_portb, KINETIS_IRQ_PORTB) /* Vector 104: Pin detect port B */
+VECTOR(kinetis_portc, KINETIS_IRQ_PORTC) /* Vector 105: Pin detect port C */
+VECTOR(kinetis_portd, KINETIS_IRQ_PORTD) /* Vector 106: Pin detect port D */
+VECTOR(kinetis_porte, KINETIS_IRQ_PORTE) /* Vector 107: Pin detect port E */
+UNUSED(KINETIS_IRQ_RESVD92) /* Vector 108: Reserved */
+UNUSED(KINETIS_IRQ_RESVD93) /* Vector 109: Reserved */
+VECTOR(kinetis_swi, KINETIS_IRQ_SWI) /* Vector 110: Software interrupt */
+# endif /* CONFIG_ARMV7M_CMNVECTOR */
+#endif /* CONFIG_ARCH_FAMILY_K40 */
diff --git a/arch/arm/src/kinetis/chip/kinetis_k60vectors.h b/arch/arm/src/kinetis/chip/kinetis_k60vectors.h
new file mode 100644
index 0000000000000000000000000000000000000000..e7b2cf78878de9c46631537c83d0683fba98b290
--- /dev/null
+++ b/arch/arm/src/kinetis/chip/kinetis_k60vectors.h
@@ -0,0 +1,156 @@
+/************************************************************************************
+ * arch/arm/src/kinetis/chip/kinetis_k60vectors.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+/* This file is included by kinetis_vectors.S. It provides the macro VECTOR that
+ * supplies ach K60 vector in terms of a (lower-case) ISR label and an
+ * (upper-case) IRQ number as defined in arch/arm/include/kinetis/kinetis_k60irq.h.
+ * kinetis_vectors.S will defined the VECTOR in different ways in order to generate
+ * the interrupt vectors and handlers in their final form.
+ */
+
+#if defined(CONFIG_ARCH_FAMILY_K60)
+
+/* If the common ARMv7-M vector handling is used, then all it needs is the following
+ * definition that provides the number of supported vectors.
+ */
+
+# ifdef CONFIG_ARMV7M_CMNVECTOR
+
+/* Reserve interrupt table entries for I/O interrupts. */
+
+# define ARMV7M_PERIPHERAL_INTERRUPTS NR_INTERRUPTS
+
+# else
+VECTOR(kinetis_dmach0, KINETIS_IRQ_DMACH0) /* Vector 16: DMA channel 0 transfer complete */
+VECTOR(kinetis_dmach1, KINETIS_IRQ_DMACH1) /* Vector 17: DMA channel 1 transfer complete */
+VECTOR(kinetis_dmach2, KINETIS_IRQ_DMACH2) /* Vector 18: DMA channel 2 transfer complete */
+VECTOR(kinetis_dmach3, KINETIS_IRQ_DMACH3) /* Vector 19: DMA channel 3 transfer complete */
+VECTOR(kinetis_dmach4, KINETIS_IRQ_DMACH4) /* Vector 20: DMA channel 4 transfer complete */
+VECTOR(kinetis_dmach5, KINETIS_IRQ_DMACH5) /* Vector 21: DMA channel 5 transfer complete */
+VECTOR(kinetis_dmach6, KINETIS_IRQ_DMACH6) /* Vector 22: DMA channel 6 transfer complete */
+VECTOR(kinetis_dmach7, KINETIS_IRQ_DMACH7) /* Vector 23: DMA channel 7 transfer complete */
+VECTOR(kinetis_dmach8, KINETIS_IRQ_DMACH8) /* Vector 24: DMA channel 8 transfer complete */
+VECTOR(kinetis_dmach9, KINETIS_IRQ_DMACH9) /* Vector 25: DMA channel 9 transfer complete */
+VECTOR(kinetis_dmach10, KINETIS_IRQ_DMACH10) /* Vector 26: DMA channel 10 transfer complete */
+VECTOR(kinetis_dmach11, KINETIS_IRQ_DMACH11) /* Vector 27: DMA channel 11 transfer complete */
+VECTOR(kinetis_dmach12, KINETIS_IRQ_DMACH12) /* Vector 28: DMA channel 12 transfer complete */
+VECTOR(kinetis_dmach13, KINETIS_IRQ_DMACH13) /* Vector 29: DMA channel 13 transfer complete */
+VECTOR(kinetis_dmach14, KINETIS_IRQ_DMACH14) /* Vector 30: DMA channel 14 transfer complete */
+VECTOR(kinetis_dmach15, KINETIS_IRQ_DMACH15) /* Vector 31: DMA channel 15 transfer complete */
+VECTOR(kinetis_dmaerr, KINETIS_IRQ_DMAERR) /* Vector 32: DMA error interrupt channels 0-15 */
+VECTOR(kinetis_mcm, KINETIS_IRQ_MCM) /* Vector 33: MCM Normal interrupt */
+VECTOR(kinetis_flashcc, KINETIS_IRQ_FLASHCC) /* Vector 34: Flash memory command complete */
+VECTOR(kinetis_flashrc, KINETIS_IRQ_FLASHRC) /* Vector 35: Flash memory read collision */
+VECTOR(kinetis_smclvd, KINETIS_IRQ_SMCLVD) /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
+VECTOR(kinetis_llwu, KINETIS_IRQ_LLWU) /* Vector 37: LLWU Normal Low Leakage Wakeup */
+VECTOR(kinetis_wdog, KINETIS_IRQ_WDOG) /* Vector 38: Watchdog */
+VECTOR(kinetis_rngb, KINETIS_IRQ_RNGB) /* Vector 39: Random number generator */
+VECTOR(kinetis_i2c0, KINETIS_IRQ_I2C0) /* Vector 40: I2C0 */
+VECTOR(kinetis_i2c1, KINETIS_IRQ_I2C1) /* Vector 41: I2C1 */
+VECTOR(kinetis_spi0, KINETIS_IRQ_SPI0) /* Vector 42: SPI0 all sources */
+VECTOR(kinetis_spi1, KINETIS_IRQ_SPI1) /* Vector 43: SPI1 all sources */
+VECTOR(kinetis_spi2, KINETIS_IRQ_SPI2) /* Vector 44: SPI2 all sources */
+VECTOR(kinetis_can0mb, KINETIS_IRQ_CAN0MB) /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
+VECTOR(kinetis_can0bo, KINETIS_IRQ_CAN0BO) /* Vector 46: CAN0 Bus Off */
+VECTOR(kinetis_can0err, KINETIS_IRQ_CAN0ERR) /* Vector 47: CAN0 Error */
+VECTOR(kinetis_can0tw, KINETIS_IRQ_CAN0TW) /* Vector 48: CAN0 Transmit Warning */
+VECTOR(kinetis_can0rw, KINETIS_IRQ_CAN0RW) /* Vector 49: CAN0 Receive Warning */
+VECTOR(kinetis_can0wu, KINETIS_IRQ_CAN0WU) /* Vector 50: CAN0 Wake UP */
+UNUSED(KINETIS_IRQ_RESVD35) /* Vector 51: Reserved */
+UNUSED(KINETIS_IRQ_RESVD36) /* Vector 52: Reserved */
+VECTOR(kinetis_can1mb, KINETIS_IRQ_CAN1MB) /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
+VECTOR(kinetis_can1bo, KINETIS_IRQ_CAN1BO) /* Vector 54: CAN1 Bus Off */
+VECTOR(kinetis_can1err, KINETIS_IRQ_CAN1ERR) /* Vector 55: CAN1 Error */
+VECTOR(kinetis_can1tw, KINETIS_IRQ_CAN1TW) /* Vector 56: CAN1 Transmit Warning */
+VECTOR(kinetis_can1rw, KINETIS_IRQ_CAN1RW) /* Vector 57: CAN1 Receive Warning */
+VECTOR(kinetis_can1wu, KINETIS_IRQ_CAN1WU) /* Vector 58: CAN1 Wake UP */
+UNUSED(KINETIS_IRQ_RESVD43) /* Vector 59: Reserved */
+UNUSED(KINETIS_IRQ_RESVD44) /* Vector 60: Reserved */
+VECTOR(kinetis_uart0s, KINETIS_IRQ_UART0S) /* Vector 61: UART0 status */
+VECTOR(kinetis_uart0e, KINETIS_IRQ_UART0E) /* Vector 62: UART0 error */
+VECTOR(kinetis_uart1s, KINETIS_IRQ_UART1S) /* Vector 63: UART1 status */
+VECTOR(kinetis_uart1e, KINETIS_IRQ_UART1E) /* Vector 64: UART1 error */
+VECTOR(kinetis_uart2s, KINETIS_IRQ_UART2S) /* Vector 65: UART2 status */
+VECTOR(kinetis_uart2e, KINETIS_IRQ_UART2E) /* Vector 66: UART2 error */
+VECTOR(kinetis_uart3s, KINETIS_IRQ_UART3S) /* Vector 67: UART3 status */
+VECTOR(kinetis_uart3e, KINETIS_IRQ_UART3E) /* Vector 68: UART3 error */
+VECTOR(kinetis_uart4s, KINETIS_IRQ_UART4S) /* Vector 69: UART4 status */
+VECTOR(kinetis_uart4e, KINETIS_IRQ_UART4E) /* Vector 70: UART4 error */
+VECTOR(kinetis_uart5s, KINETIS_IRQ_UART5S) /* Vector 71: UART5 status */
+VECTOR(kinetis_uart5e, KINETIS_IRQ_UART5E) /* Vector 72: UART5 error */
+VECTOR(kinetis_adc0, KINETIS_IRQ_ADC0) /* Vector 73: ADC0 */
+VECTOR(kinetis_adc1, KINETIS_IRQ_ADC1) /* Vector 74: ADC1 */
+VECTOR(kinetis_cmp0, KINETIS_IRQ_CMP0) /* Vector 75: CMP0 */
+VECTOR(kinetis_cmp1, KINETIS_IRQ_CMP1) /* Vector 76: CMP1 */
+VECTOR(kinetis_cmp2, KINETIS_IRQ_CMP2) /* Vector 77: CMP2 */
+VECTOR(kinetis_ftm0, KINETIS_IRQ_FTM0) /* Vector 78: FTM0 all sources */
+VECTOR(kinetis_ftm1, KINETIS_IRQ_FTM1) /* Vector 79: FTM1 all sources */
+VECTOR(kinetis_ftm2, KINETIS_IRQ_FTM2) /* Vector 80: FTM2 all sources */
+VECTOR(kinetis_cmt, KINETIS_IRQ_CMT) /* Vector 81: CMT */
+VECTOR(kinetis_rtc, KINETIS_IRQ_RTC) /* Vector 82: RTC alarm interrupt */
+UNUSED(KINETIS_IRQ_RESVD67) /* Vector 83: Reserved */
+VECTOR(kinetis_pitch0, KINETIS_IRQ_PITCH0) /* Vector 84: PIT channel 0 */
+VECTOR(kinetis_pitch1, KINETIS_IRQ_PITCH1) /* Vector 85: PIT channel 1 */
+VECTOR(kinetis_pitch2, KINETIS_IRQ_PITCH2) /* Vector 86: PIT channel 2 */
+VECTOR(kinetis_pitch3, KINETIS_IRQ_PITCH3) /* Vector 87: PIT channel 3 */
+VECTOR(kinetis_pdb, KINETIS_IRQ_PDB) /* Vector 88: PDB */
+VECTOR(kinetis_usbotg, KINETIS_IRQ_USBOTG) /* Vector 89: USB OTG */
+VECTOR(kinetis_usbcd, KINETIS_IRQ_USBCD) /* Vector 90: USB charger detect */
+VECTOR(kinetis_emactmr, KINETIS_IRQ_EMACTMR) /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
+VECTOR(kinetis_emactx, KINETIS_IRQ_EMACTX) /* Vector 92: Ethernet MAC transmit interrupt */
+VECTOR(kinetis_emacrx, KINETIS_IRQ_EMACRX) /* Vector 93: Ethernet MAC receive interrupt */
+VECTOR(kinetis_emacmisc, KINETIS_IRQ_EMACMISC) /* Vector 94: Ethernet MAC error and misc interrupt */
+VECTOR(kinetis_i2s0, KINETIS_IRQ_I2S0) /* Vector 95: I2S0 */
+VECTOR(kinetis_sdhc, KINETIS_IRQ_SDHC) /* Vector 96: SDHC */
+VECTOR(kinetis_dac0, KINETIS_IRQ_DAC0) /* Vector 97: DAC0 */
+VECTOR(kinetis_dac1, KINETIS_IRQ_DAC1) /* Vector 98: DAC1 */
+VECTOR(kinetis_tsi, KINETIS_IRQ_TSI) /* Vector 99: TSI all sources */
+VECTOR(kinetis_mcg, KINETIS_IRQ_MCG) /* Vector 100: MCG */
+VECTOR(kinetis_lpt, KINETIS_IRQ_LPT) /* Vector 101: Low power timer */
+UNUSED(KINETIS_IRQ_RESVD86) /* Vector 102: Reserved */
+VECTOR(kinetis_porta, KINETIS_IRQ_PORTA) /* Vector 103: Pin detect port A */
+VECTOR(kinetis_portb, KINETIS_IRQ_PORTB) /* Vector 104: Pin detect port B */
+VECTOR(kinetis_portc, KINETIS_IRQ_PORTC) /* Vector 105: Pin detect port C */
+VECTOR(kinetis_portd, KINETIS_IRQ_PORTD) /* Vector 106: Pin detect port D */
+VECTOR(kinetis_porte, KINETIS_IRQ_PORTE) /* Vector 107: Pin detect port E */
+UNUSED(KINETIS_IRQ_RESVD92) /* Vector 108: Reserved */
+UNUSED(KINETIS_IRQ_RESVD93) /* Vector 109: Reserved */
+VECTOR(kinetis_swi, KINETIS_IRQ_SWI) /* Vector 110: Software interrupt */
+# endif /* CONFIG_ARMV7M_CMNVECTOR */
+#endif /* CONFIG_ARCH_FAMILY_K60 */
diff --git a/arch/arm/src/kinetis/chip/kinetis_k64vectors.h b/arch/arm/src/kinetis/chip/kinetis_k64vectors.h
new file mode 100644
index 0000000000000000000000000000000000000000..e010253a7fe5c6c7a678c166c2b3f40dea70a85d
--- /dev/null
+++ b/arch/arm/src/kinetis/chip/kinetis_k64vectors.h
@@ -0,0 +1,147 @@
+/************************************************************************************
+ * arch/arm/src/kinetis/chip/kinetis_k64vectors.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+/* This file is included by kinetis_vectors.S. It provides the macro VECTOR that
+ * supplies ach K64 vector in terms of a (lower-case) ISR label and an
+ * (upper-case) IRQ number as defined in arch/arm/include/kinetis/kinetis_k64irq.h.
+ * kinetis_vectors.S will defined the VECTOR in different ways in order to generate
+ * the interrupt vectors and handlers in their final form.
+ */
+
+#if defined(CONFIG_ARCH_FAMILY_K64)
+
+/* If the common ARMv7-M vector handling is used, then all it needs is the following
+ * definition that provides the number of supported vectors.
+ */
+
+# ifdef CONFIG_ARMV7M_CMNVECTOR
+
+/* Reserve interrupt table entries for I/O interrupts. */
+
+# define ARMV7M_PERIPHERAL_INTERRUPTS NR_INTERRUPTS
+
+# else
+VECTOR(kinetis_dmach0, KINETIS_IRQ_DMACH0) /* Vector 16: DMA channel 0 transfer complete */
+VECTOR(kinetis_dmach1, KINETIS_IRQ_DMACH1) /* Vector 17: DMA channel 1 transfer complete */
+VECTOR(kinetis_dmach2, KINETIS_IRQ_DMACH2) /* Vector 18: DMA channel 2 transfer complete */
+VECTOR(kinetis_dmach3, KINETIS_IRQ_DMACH3) /* Vector 19: DMA channel 3 transfer complete */
+VECTOR(kinetis_dmach4, KINETIS_IRQ_DMACH4) /* Vector 20: DMA channel 4 transfer complete */
+VECTOR(kinetis_dmach5, KINETIS_IRQ_DMACH5) /* Vector 21: DMA channel 5 transfer complete */
+VECTOR(kinetis_dmach6, KINETIS_IRQ_DMACH6) /* Vector 22: DMA channel 6 transfer complete */
+VECTOR(kinetis_dmach7, KINETIS_IRQ_DMACH7) /* Vector 23: DMA channel 7 transfer complete */
+VECTOR(kinetis_dmach8, KINETIS_IRQ_DMACH8) /* Vector 24: DMA channel 8 transfer complete */
+VECTOR(kinetis_dmach9, KINETIS_IRQ_DMACH9) /* Vector 25: DMA channel 9 transfer complete */
+VECTOR(kinetis_dmach10, KINETIS_IRQ_DMACH10) /* Vector 26: DMA channel 10 transfer complete */
+VECTOR(kinetis_dmach11, KINETIS_IRQ_DMACH11) /* Vector 27: DMA channel 11 transfer complete */
+VECTOR(kinetis_dmach12, KINETIS_IRQ_DMACH12) /* Vector 28: DMA channel 12 transfer complete */
+VECTOR(kinetis_dmach13, KINETIS_IRQ_DMACH13) /* Vector 29: DMA channel 13 transfer complete */
+VECTOR(kinetis_dmach14, KINETIS_IRQ_DMACH14) /* Vector 30: DMA channel 14 transfer complete */
+VECTOR(kinetis_dmach15, KINETIS_IRQ_DMACH15) /* Vector 31: DMA channel 15 transfer complete */
+VECTOR(kinetis_dmaerr, KINETIS_IRQ_DMAERR) /* Vector 32: DMA error interrupt channels 0-15 */
+VECTOR(kinetis_mcm, KINETIS_IRQ_MCM) /* Vector 33: MCM Normal interrupt */
+VECTOR(kinetis_flashcc, KINETIS_IRQ_FLASHCC) /* Vector 34: Flash memory command complete */
+VECTOR(kinetis_flashrc, KINETIS_IRQ_FLASHRC) /* Vector 35: Flash memory read collision */
+VECTOR(kinetis_smclvd, KINETIS_IRQ_SMCLVD) /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
+VECTOR(kinetis_llwu, KINETIS_IRQ_LLWU) /* Vector 37: LLWU Normal Low Leakage Wakeup */
+VECTOR(kinetis_wdog, KINETIS_IRQ_WDOG) /* Vector 38: Watchdog */
+VECTOR(kinetis_rngb, KINETIS_IRQ_RNGB) /* Vector 39: Random number generator */
+VECTOR(kinetis_i2c0, KINETIS_IRQ_I2C0) /* Vector 40: I2C0 */
+VECTOR(kinetis_i2c1, KINETIS_IRQ_I2C1) /* Vector 41: I2C1 */
+VECTOR(kinetis_spi0, KINETIS_IRQ_SPI0) /* Vector 42: SPI0 all sources */
+VECTOR(kinetis_spi1, KINETIS_IRQ_SPI1) /* Vector 43: SPI1 all sources */
+VECTOR(kinetis_i2s0, KINETIS_IRQ_I2S0) /* Vector 44: Transmit */
+VECTOR(kinetis_i2s1, KINETIS_IRQ_I2S1) /* Vector 45: Transmit */
+UNUSED(KINETIS_IRQ_RESVD30) /* Vector 46: Reserved */
+VECTOR(kinetis_uart0s, KINETIS_IRQ_UART0S) /* Vector 47: UART0 status */
+VECTOR(kinetis_uart0e, KINETIS_IRQ_UART0E) /* Vector 48: UART0 error */
+VECTOR(kinetis_uart1s, KINETIS_IRQ_UART1S) /* Vector 49: UART1 status */
+VECTOR(kinetis_uart1e, KINETIS_IRQ_UART1E) /* Vector 50: UART1 error */
+VECTOR(kinetis_uart2s, KINETIS_IRQ_UART2S) /* Vector 51: UART2 status */
+VECTOR(kinetis_uart2e, KINETIS_IRQ_UART2E) /* Vector 52: UART2 error */
+VECTOR(kinetis_uart3s, KINETIS_IRQ_UART3S) /* Vector 53: UART3 status */
+VECTOR(kinetis_uart3e, KINETIS_IRQ_UART3E) /* Vector 54: UART3 error */
+VECTOR(kinetis_adc0, KINETIS_IRQ_ADC0) /* Vector 55: ADC0 */
+VECTOR(kinetis_cmp0, KINETIS_IRQ_CMP0) /* Vector 56: CMP0 */
+VECTOR(kinetis_cmp1, KINETIS_IRQ_CMP1) /* Vector 57: CMP1 */
+VECTOR(kinetis_ftm0, KINETIS_IRQ_FTM0) /* Vector 58: FTM0 all sources */
+VECTOR(kinetis_ftm1, KINETIS_IRQ_FTM1) /* Vector 59: FTM1 all sources */
+VECTOR(kinetis_ftm2, KINETIS_IRQ_FTM2) /* Vector 60: FTM2 all sources */
+VECTOR(kinetis_cmt, KINETIS_IRQ_CMT) /* Vector 61: CMT */
+VECTOR(kinetis_rtc0, KINETIS_IRQ_RTC) /* Vector 62: RTC alarm interrupt */
+VECTOR(kinetis_rtc1, KINETIS_IRQ_RTCS) /* Vector 63: RTC seconds interrupt */
+VECTOR(kinetis_pitch0, KINETIS_IRQ_PITCH0) /* Vector 64: PIT channel 0 */
+VECTOR(kinetis_pitch1, KINETIS_IRQ_PITCH1) /* Vector 65: PIT channel 1 */
+VECTOR(kinetis_pitch2, KINETIS_IRQ_PITCH2) /* Vector 66: PIT channel 2 */
+VECTOR(kinetis_pitch3, KINETIS_IRQ_PITCH3) /* Vector 67: PIT channel 3 */
+VECTOR(kinetis_pdb, KINETIS_IRQ_PDB) /* Vector 68: PDB */
+VECTOR(kinetis_usbotg, KINETIS_IRQ_USBOTG) /* Vector 69: USB OTG */
+VECTOR(kinetis_usbcd, KINETIS_IRQ_USBCD) /* Vector 70: USB charger detect */
+UNUSED(KINETIS_IRQ_RESVD55) /* Vector 71: Reserved */
+VECTOR(kinetis_dac0, KINETIS_IRQ_DAC0) /* Vector 72: DAC0 */
+VECTOR(kinetis_mcg, KINETIS_IRQ_MCG) /* Vector 73: MCG */
+VECTOR(kinetis_lpt, KINETIS_IRQ_LPT) /* Vector 74: Low power timer */
+VECTOR(kinetis_porta, KINETIS_IRQ_PORTA) /* Vector 75: Pin detect port A */
+VECTOR(kinetis_portb, KINETIS_IRQ_PORTB) /* Vector 76: Pin detect port B */
+VECTOR(kinetis_portc, KINETIS_IRQ_PORTC) /* Vector 77: Pin detect port C */
+VECTOR(kinetis_portd, KINETIS_IRQ_PORTD) /* Vector 78: Pin detect port D */
+VECTOR(kinetis_porte, KINETIS_IRQ_PORTE) /* Vector 79: Pin detect port E */
+VECTOR(kinetis_software, KINETIS_IRQ_SWI) /* Vector 80: Software interrupt */
+VECTOR(kinetis_spi2, KINETIS_IRQ_SPI2) /* Vector 81: SPI2 all sources */
+VECTOR(kinetis_uart4s, KINETIS_IRQ_UART4S) /* Vector 82: UART4 status */
+VECTOR(kinetis_uart4e, KINETIS_IRQ_UART4E) /* Vector 83: UART4 error */
+VECTOR(kinetis_uart5s, KINETIS_IRQ_UART5S) /* Vector 84: UART5 status */
+VECTOR(kinetis_uart5e, KINETIS_IRQ_UART5E) /* Vector 85: UART5 error */
+VECTOR(kinetis_cmp2, KINETIS_IRQ_CMP2) /* Vector 86: CMP2 */
+VECTOR(kinetis_ftm3, KINETIS_IRQ_FTM3) /* Vector 87: FTM3 all sources */
+VECTOR(kinetis_dac1, KINETIS_IRQ_DAC1) /* Vector 88: DAC1 */
+VECTOR(kinetis_adc1, KINETIS_IRQ_ADC1) /* Vector 89: ADC1 */
+VECTOR(kinetis_i2c2, KINETIS_IRQ_I2C2) /* Vector 90: I2C2 */
+VECTOR(kinetis_can0mb, KINETIS_IRQ_CAN0MB) /* Vector 91: CAN0 ORed Message buffer (0-15) */
+VECTOR(kinetis_can0bo, KINETIS_IRQ_CAN0BO) /* Vector 92: CAN0 Bus Off */
+VECTOR(kinetis_can0err, KINETIS_IRQ_CAN0ERR) /* Vector 93: CAN0 Error */
+VECTOR(kinetis_can0tw, KINETIS_IRQ_CAN0TW) /* Vector 94: CAN0 Transmit Warning */
+VECTOR(kinetis_can0rw, KINETIS_IRQ_CAN0RW) /* Vector 95: CAN0 Receive Warning */
+VECTOR(kinetis_can0wu, KINETIS_IRQ_CAN0WU) /* Vector 96: CAN0 Wake UP */
+VECTOR(kinetis_sdhc, KINETIS_IRQ_SDHC) /* Vector 97: SDHC */
+VECTOR(kinetis_emactmr, KINETIS_IRQ_EMACTMR) /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
+VECTOR(kinetis_emactx, KINETIS_IRQ_EMACTX) /* Vector 92: Ethernet MAC transmit interrupt */
+VECTOR(kinetis_emacrx, KINETIS_IRQ_EMACRX) /* Vector 93: Ethernet MAC receive interrupt */
+VECTOR(kinetis_emacmisc, KINETIS_IRQ_EMACMISC) /* Vector 94: Ethernet MAC error and misc interrupt */
+# endif /* CONFIG_ARMV7M_CMNVECTOR */
+#endif /* CONFIG_ARCH_FAMILY_K64 */
diff --git a/arch/arm/src/kinetis/chip/kinetis_k66vectors.h b/arch/arm/src/kinetis/chip/kinetis_k66vectors.h
new file mode 100644
index 0000000000000000000000000000000000000000..982320e07ef2cfdb51d1602823b351732d36f1ed
--- /dev/null
+++ b/arch/arm/src/kinetis/chip/kinetis_k66vectors.h
@@ -0,0 +1,162 @@
+/************************************************************************************
+ * arch/arm/src/kinetis/chip/kinetis_k64vectors.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************************************/
+
+/************************************************************************************
+ * Pre-processor definitions
+ ************************************************************************************/
+/* This file is included by kinetis_vectors.S. It provides the macro VECTOR that
+ * supplies ach K64 vector in terms of a (lower-case) ISR label and an
+ * (upper-case) IRQ number as defined in arch/arm/include/kinetis/kinetis_k64irq.h.
+ * kinetis_vectors.S will defined the VECTOR in different ways in order to generate
+ * the interrupt vectors and handlers in their final form.
+ */
+
+#if defined(CONFIG_ARCH_FAMILY_K64)
+
+/* If the common ARMv7-M vector handling is used, then all it needs is the following
+ * definition that provides the number of supported vectors.
+ */
+
+# ifdef CONFIG_ARMV7M_CMNVECTOR
+
+/* Reserve interrupt table entries for I/O interrupts. */
+
+# define ARMV7M_PERIPHERAL_INTERRUPTS NR_INTERRUPTS
+
+# else
+VECTOR(kinetis_dmach0, KINETIS_IRQ_DMACH0) /* Vector 16: DMA channel 0 transfer complete */
+VECTOR(kinetis_dmach1, KINETIS_IRQ_DMACH1) /* Vector 17: DMA channel 1 transfer complete */
+VECTOR(kinetis_dmach2, KINETIS_IRQ_DMACH2) /* Vector 18: DMA channel 2 transfer complete */
+VECTOR(kinetis_dmach3, KINETIS_IRQ_DMACH3) /* Vector 19: DMA channel 3 transfer complete */
+VECTOR(kinetis_dmach4, KINETIS_IRQ_DMACH4) /* Vector 20: DMA channel 4 transfer complete */
+VECTOR(kinetis_dmach5, KINETIS_IRQ_DMACH5) /* Vector 21: DMA channel 5 transfer complete */
+VECTOR(kinetis_dmach6, KINETIS_IRQ_DMACH6) /* Vector 22: DMA channel 6 transfer complete */
+VECTOR(kinetis_dmach7, KINETIS_IRQ_DMACH7) /* Vector 23: DMA channel 7 transfer complete */
+VECTOR(kinetis_dmach8, KINETIS_IRQ_DMACH8) /* Vector 24: DMA channel 8 transfer complete */
+VECTOR(kinetis_dmach9, KINETIS_IRQ_DMACH9) /* Vector 25: DMA channel 9 transfer complete */
+VECTOR(kinetis_dmach10, KINETIS_IRQ_DMACH10) /* Vector 26: DMA channel 10 transfer complete */
+VECTOR(kinetis_dmach11, KINETIS_IRQ_DMACH11) /* Vector 27: DMA channel 11 transfer complete */
+VECTOR(kinetis_dmach12, KINETIS_IRQ_DMACH12) /* Vector 28: DMA channel 12 transfer complete */
+VECTOR(kinetis_dmach13, KINETIS_IRQ_DMACH13) /* Vector 29: DMA channel 13 transfer complete */
+VECTOR(kinetis_dmach14, KINETIS_IRQ_DMACH14) /* Vector 30: DMA channel 14 transfer complete */
+VECTOR(kinetis_dmach15, KINETIS_IRQ_DMACH15) /* Vector 31: DMA channel 15 transfer complete */
+VECTOR(kinetis_dmaerr, KINETIS_IRQ_DMAERR) /* Vector 32: DMA error interrupt channels 0-15 */
+VECTOR(kinetis_mcm, KINETIS_IRQ_MCM) /* Vector 33: MCM Normal interrupt */
+VECTOR(kinetis_flashcc, KINETIS_IRQ_FLASHCC) /* Vector 34: Flash memory command complete */
+VECTOR(kinetis_flashrc, KINETIS_IRQ_FLASHRC) /* Vector 35: Flash memory read collision */
+VECTOR(kinetis_smclvd, KINETIS_IRQ_SMCLVD) /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
+VECTOR(kinetis_llwu, KINETIS_IRQ_LLWU) /* Vector 37: LLWU Normal Low Leakage Wakeup */
+VECTOR(kinetis_wdog, KINETIS_IRQ_WDOG) /* Vector 38: Watchdog */
+VECTOR(kinetis_rngb, KINETIS_IRQ_RNGB) /* Vector 39: Random number generator */
+VECTOR(kinetis_i2c0, KINETIS_IRQ_I2C0) /* Vector 40: I2C0 */
+VECTOR(kinetis_i2c1, KINETIS_IRQ_I2C1) /* Vector 41: I2C1 */
+VECTOR(kinetis_spi0, KINETIS_IRQ_SPI0) /* Vector 42: SPI0 all sources */
+VECTOR(kinetis_spi1, KINETIS_IRQ_SPI1) /* Vector 43: SPI1 all sources */
+VECTOR(kinetis_i2s0, KINETIS_IRQ_I2S0) /* Vector 44: Transmit */
+VECTOR(kinetis_i2s1, KINETIS_IRQ_I2S1) /* Vector 45: Transmit */
+UNUSED(KINETIS_IRQ_RESVD30) /* Vector 46: Reserved */
+VECTOR(kinetis_uart0s, KINETIS_IRQ_UART0S) /* Vector 47: UART0 status */
+VECTOR(kinetis_uart0e, KINETIS_IRQ_UART0E) /* Vector 48: UART0 error */
+VECTOR(kinetis_uart1s, KINETIS_IRQ_UART1S) /* Vector 49: UART1 status */
+VECTOR(kinetis_uart1e, KINETIS_IRQ_UART1E) /* Vector 50: UART1 error */
+VECTOR(kinetis_uart2s, KINETIS_IRQ_UART2S) /* Vector 51: UART2 status */
+VECTOR(kinetis_uart2e, KINETIS_IRQ_UART2E) /* Vector 52: UART2 error */
+VECTOR(kinetis_uart3s, KINETIS_IRQ_UART3S) /* Vector 53: UART3 status */
+VECTOR(kinetis_uart3e, KINETIS_IRQ_UART3E) /* Vector 54: UART3 error */
+VECTOR(kinetis_adc0, KINETIS_IRQ_ADC0) /* Vector 55: ADC0 */
+VECTOR(kinetis_cmp0, KINETIS_IRQ_CMP0) /* Vector 56: CMP0 */
+VECTOR(kinetis_cmp1, KINETIS_IRQ_CMP1) /* Vector 57: CMP1 */
+VECTOR(kinetis_ftm0, KINETIS_IRQ_FTM0) /* Vector 58: FTM0 all sources */
+VECTOR(kinetis_ftm1, KINETIS_IRQ_FTM1) /* Vector 59: FTM1 all sources */
+VECTOR(kinetis_ftm2, KINETIS_IRQ_FTM2) /* Vector 60: FTM2 all sources */
+VECTOR(kinetis_cmt, KINETIS_IRQ_CMT) /* Vector 61: CMT */
+VECTOR(kinetis_rtc0, KINETIS_IRQ_RTC) /* Vector 62: RTC alarm interrupt */
+VECTOR(kinetis_rtc1, KINETIS_IRQ_RTCS) /* Vector 63: RTC seconds interrupt */
+VECTOR(kinetis_pitch0, KINETIS_IRQ_PITCH0) /* Vector 64: PIT channel 0 */
+VECTOR(kinetis_pitch1, KINETIS_IRQ_PITCH1) /* Vector 65: PIT channel 1 */
+VECTOR(kinetis_pitch2, KINETIS_IRQ_PITCH2) /* Vector 66: PIT channel 2 */
+VECTOR(kinetis_pitch3, KINETIS_IRQ_PITCH3) /* Vector 67: PIT channel 3 */
+VECTOR(kinetis_pdb, KINETIS_IRQ_PDB) /* Vector 68: PDB */
+VECTOR(kinetis_usbotg, KINETIS_IRQ_USBOTG) /* Vector 69: USB OTG */
+VECTOR(kinetis_usbcd, KINETIS_IRQ_USBCD) /* Vector 70: USB charger detect */
+UNUSED(KINETIS_IRQ_RESVD55) /* Vector 71: Reserved */
+VECTOR(kinetis_dac0, KINETIS_IRQ_DAC0) /* Vector 72: DAC0 */
+VECTOR(kinetis_mcg, KINETIS_IRQ_MCG) /* Vector 73: MCG */
+VECTOR(kinetis_lpt, KINETIS_IRQ_LPT) /* Vector 74: Low power timer */
+VECTOR(kinetis_porta, KINETIS_IRQ_PORTA) /* Vector 75: Pin detect port A */
+VECTOR(kinetis_portb, KINETIS_IRQ_PORTB) /* Vector 76: Pin detect port B */
+VECTOR(kinetis_portc, KINETIS_IRQ_PORTC) /* Vector 77: Pin detect port C */
+VECTOR(kinetis_portd, KINETIS_IRQ_PORTD) /* Vector 78: Pin detect port D */
+VECTOR(kinetis_porte, KINETIS_IRQ_PORTE) /* Vector 79: Pin detect port E */
+VECTOR(kinetis_software, KINETIS_IRQ_SWI) /* Vector 80: Software interrupt */
+VECTOR(kinetis_spi2, KINETIS_IRQ_SPI2) /* Vector 81: SPI2 all sources */
+VECTOR(kinetis_uart4s, KINETIS_IRQ_UART4S) /* Vector 82: UART4 status */
+VECTOR(kinetis_uart4e, KINETIS_IRQ_UART4E) /* Vector 83: UART4 error */
+UNUSED(KINETIS_IRQ_RESVD68) /* Vector 84: Reserved */
+UNUSED(KINETIS_IRQ_RESVD69) /* Vector 85: Reserved */
+VECTOR(kinetis_cmp2, KINETIS_IRQ_CMP2) /* Vector 86: CMP2 */
+VECTOR(kinetis_ftm3, KINETIS_IRQ_FTM3) /* Vector 87: FTM3 all sources */
+VECTOR(kinetis_dac1, KINETIS_IRQ_DAC1) /* Vector 88: DAC1 */
+VECTOR(kinetis_adc1, KINETIS_IRQ_ADC1) /* Vector 89: ADC1 */
+VECTOR(kinetis_i2c2, KINETIS_IRQ_I2C2) /* Vector 90: I2C2 */
+VECTOR(kinetis_can0mb, KINETIS_IRQ_CAN0MB) /* Vector 91: CAN0 ORed Message buffer (0-15) */
+VECTOR(kinetis_can0bo, KINETIS_IRQ_CAN0BO) /* Vector 92: CAN0 Bus Off */
+VECTOR(kinetis_can0err, KINETIS_IRQ_CAN0ERR) /* Vector 93: CAN0 Error */
+VECTOR(kinetis_can0tw, KINETIS_IRQ_CAN0TW) /* Vector 94: CAN0 Transmit Warning */
+VECTOR(kinetis_can0rw, KINETIS_IRQ_CAN0RW) /* Vector 95: CAN0 Receive Warning */
+VECTOR(kinetis_can0wu, KINETIS_IRQ_CAN0WU) /* Vector 96: CAN0 Wake UP */
+VECTOR(kinetis_sdhc, KINETIS_IRQ_SDHC) /* Vector 97: SDHC */
+VECTOR(kinetis_emactmr, KINETIS_IRQ_EMACTMR) /* Vector 98: Ethernet MAC IEEE 1588 timer interrupt */
+VECTOR(kinetis_emactx, KINETIS_IRQ_EMACTX) /* Vector 99: Ethernet MAC transmit interrupt */
+VECTOR(kinetis_emacrx, KINETIS_IRQ_EMACRX) /* Vector 100: Ethernet MAC receive interrupt */
+VECTOR(kinetis_emacmisc, KINETIS_IRQ_EMACMISC) /* Vector 101: Ethernet MAC error and misc interrupt */
+VECTOR(kinetis_lpuart0, KINETIS_IRQ_LPUART0) /* Vector 102: LPUART0 Status and error */
+VECTOR(kinetis_tsi0, KINETIS_IRQ_TSI0) /* Vector 103: TSI0 */
+VECTOR(kinetis_tpm1, KINETIS_IRQ_TPM1) /* Vector 104: TPM1 */
+VECTOR(kinetis_tpm2, KINETIS_IRQ_TPM2) /* Vector 105: TPM2 */
+VECTOR(kinetis_usbhsdcd,KINETIS_IRQ_USBHSDCD) /* Vector 106: shared by USBHS DCD & USBHS Phy modules */
+VECTOR(kinetis_i2c3, KINETIS_IRQ_I2C3) /* Vector 107: I2C3 */
+VECTOR(kinetis_cmp3, KINETIS_IRQ_CMP3) /* Vector 108: CMP3 */
+VECTOR(kinetis_usbhsotg,KINETIS_IRQ_USBHSOTG) /* Vector 109: USBHS OTG*/
+VECTOR(kinetis_can1mb, KINETIS_IRQ_CAN1MB) /* Vector 110: CAN1 OR'ed Message buffer (0-15) */
+VECTOR(kinetis_can1bo, KINETIS_IRQ_CAN1BO) /* Vector 111: CAN1 Bus Off */
+VECTOR(kinetis_can1err, KINETIS_IRQ_CAN1ERR ) /* Vector 112: CAN1 Error */
+VECTOR(kinetis_can1tw, KINETIS_IRQ_CAN1TW) /* Vector 113: CAN1 Transmit Warning */
+VECTOR(kinetis_can1rw, KINETIS_IRQ_CAN1RW) /* Vector 114: CAN1 Receive Warning */
+VECTOR(kinetis_can1wu, KINETIS_IRQ_CAN1WU) /* Vector 115: CAN1 Wake UP */
+
+# endif /* CONFIG_ARMV7M_CMNVECTOR */
+#endif /* CONFIG_ARCH_FAMILY_K64 */
diff --git a/arch/arm/src/kinetis/kinetis.h b/arch/arm/src/kinetis/kinetis.h
index bb02f01e92cc3ae81ac9c375f18f85efa0f11200..b4832274c33c838a76ebece7c4a2b8b6870d067c 100644
--- a/arch/arm/src/kinetis/kinetis.h
+++ b/arch/arm/src/kinetis/kinetis.h
@@ -143,8 +143,8 @@
#define PIN_ALT2_OUTPUT (_PIN_MODE_ALT2 | _PIN_OUTPUT)
#define PIN_ALT2_FAST (_PIN_MODE_ALT2 | _PIN_OUTPUT_FAST)
#define PIN_ALT2_SLOW (_PIN_MODE_ALT2 | _PIN_OUTPUT_SLOW)
-#define PIN_ALT2_OPENDRAIN (_PIN_MODE_ALT2 | _PIN_OUTPUT_LOWDRIVE)
-#define PIN_ALT2_LOWDRIVE (_PIN_MODE_ALT2 | _PIN_OUTPUT_OPENDRAIN)
+#define PIN_ALT2_OPENDRAIN (_PIN_MODE_ALT2 | _PIN_OUTPUT_OPENDRAIN)
+#define PIN_ALT2_LOWDRIVE (_PIN_MODE_ALT2 | _PIN_OUTPUT_LOWDRIVE)
#define PIN_ALT2_HIGHDRIVE (_PIN_MODE_ALT2 | _PIN_OUTPUT_HIGHDRIVE)
#define PIN_ALT3 _PIN_MODE_ALT3
@@ -305,40 +305,6 @@
#define PIN30 (30 << _PIN_SHIFT)
#define PIN31 (31 << _PIN_SHIFT)
-/************************************************************************************
- * Public Types
- ************************************************************************************/
-
-typedef FAR void *DMA_HANDLE;
-typedef void (*dma_callback_t)(DMA_HANDLE handle, void *arg, int result);
-
-/* The following is used for sampling DMA registers when CONFIG DEBUG_DMA is selected */
-
-#ifdef CONFIG_DEBUG_DMA
-struct kinetis_dmaglobalregs_s
-{
-#warning "Missing logic"
- /* Global Registers */
-};
-
-struct kinetis_dmachanregs_s
-{
-#warning "Missing logic"
- /* Channel Registers */
-};
-
-struct kinetis_dmaregs_s
-{
- /* Global Registers */
-
- struct kinetis_dmaglobalregs_s gbl;
-
- /* Channel Registers */
-
- struct kinetis_dmachanregs_s ch;
-};
-#endif
-
/************************************************************************************
* Inline Functions
************************************************************************************/
@@ -583,202 +549,6 @@ void kinetis_pindump(uint32_t pinset, const char *msg);
void kinetis_clrpend(int irq);
-/************************************************************************************
- * Name: kinetis_spi[n]select, kinetis_spi[n]status, and kinetis_spi[n]cmddata
- *
- * Description:
- * These external functions must be provided by board-specific logic. They are
- * implementations of the select, status, and cmddata methods of the SPI interface
- * defined by struct spi_ops_s (see include/nuttx/spi/spi.h). All other methods
- * including kinetis_spibus_initialize()) are provided by common Kinetis logic. To use
- * this common SPI logic on your board:
- *
- * 1. Provide logic in kinetis_boardinitialize() to configure SPI chip select
- * pins.
- * 2. Provide kinetis_spi[n]select() and kinetis_spi[n]status() functions
- * in your board-specific logic. These functions will perform chip selection
- * and status operations using GPIOs in the way your board is configured.
- * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
- * kinetis_spi[n]cmddata() functions in your board-specific logic. These
- * functions will perform cmd/data selection operations using GPIOs in the way
- * your board is configured.
- * 3. Add a call to kinetis_spibus_initialize() in your low level application
- * initialization logic
- * 4. The handle returned by kinetis_spibus_initialize() may then be used to bind the
- * SPI driver to higher level logic (e.g., calling
- * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
- * the SPI MMC/SD driver).
- *
- ************************************************************************************/
-
-struct spi_dev_s;
-enum spi_dev_e;
-
-#ifdef CONFIG_KINETIS_SPI0
-void kinetis_spi0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-#ifdef CONFIG_SPI_CMDDATA
-int kinetis_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
-#endif
-#endif
-#ifdef CONFIG_KINETIS_SPI1
-void kinetis_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-#ifdef CONFIG_SPI_CMDDATA
-int kinetis_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
-#endif
-#endif
-#ifdef CONFIG_KINETIS_SPI2
-void kinetis_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
-uint8_t kinetis_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
-#ifdef CONFIG_SPI_CMDDATA
-int kinetis_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
-#endif
-#endif
-
-/****************************************************************************
- * Name: ssp_flush
- *
- * Description:
- * Flush and discard any words left in the RX fifo. This can be called
- * from spi[n]select after a device is deselected (if you worry about such
- * things).
- *
- * Input Parameters:
- * dev - Device-specific state data
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-#if defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI2)
-struct spi_dev_s;
-void spi_flush(FAR struct spi_dev_s *dev);
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmainitialize
- *
- * Description:
- * Initialize the GPDMA subsystem.
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-void kinetis_dmainitilaize(void);
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmachannel
- *
- * Description:
- * Allocate a DMA channel. This function sets aside a DMA channel and
- * gives the caller exclusive access to the DMA channel.
- *
- * Returned Value:
- * One success, this function returns a non-NULL, void* DMA channel
- * handle. NULL is returned on any failure. This function can fail only
- * if no DMA channel is available.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-DMA_HANDLE kinetis_dmachannel(void);
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmafree
- *
- * Description:
- * Release a DMA channel. NOTE: The 'handle' used in this argument must
- * NEVER be used again until kinetis_dmachannel() is called again to re-gain
- * a valid handle.
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-void kinetis_dmafree(DMA_HANDLE handle);
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmasetup
- *
- * Description:
- * Configure DMA for one transfer.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-int kinetis_dmarxsetup(DMA_HANDLE handle, uint32_t control, uint32_t config,
- uint32_t srcaddr, uint32_t destaddr, size_t nbytes);
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmastart
- *
- * Description:
- * Start the DMA transfer
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-int kinetis_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg);
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmastop
- *
- * Description:
- * Cancel the DMA. After kinetis_dmastop() is called, the DMA channel is
- * reset and kinetis_dmasetup() must be called before kinetis_dmastart() can be
- * called again
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-void kinetis_dmastop(DMA_HANDLE handle);
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmasample
- *
- * Description:
- * Sample DMA register contents
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-#ifdef CONFIG_DEBUG_DMA
-void kinetis_dmasample(DMA_HANDLE handle, struct kinetis_dmaregs_s *regs);
-#else
-# define kinetis_dmasample(handle,regs)
-#endif
-#endif
-
-/****************************************************************************
- * Name: kinetis_dmadump
- *
- * Description:
- * Dump previously sampled DMA register contents
- *
- ****************************************************************************/
-
-#ifdef CONFIG_KINETIS_DMA
-#ifdef CONFIG_DEBUG_DMA
-void kinetis_dmadump(DMA_HANDLE handle, const struct kinetis_dmaregs_s *regs,
- const char *msg);
-#else
-# define kinetis_dmadump(handle,regs,msg)
-#endif
-#endif
-
/****************************************************************************
* Name: sdhc_initialize
*
diff --git a/arch/arm/src/kinetis/kinetis_clrpend.c b/arch/arm/src/kinetis/kinetis_clrpend.c
index 7f0395c4aeb2f1cbe7f9038a275b2ad40a8bbe99..faf35271d8f1d4bff1ae7147fb71fd61cfedcd2f 100644
--- a/arch/arm/src/kinetis/kinetis_clrpend.c
+++ b/arch/arm/src/kinetis/kinetis_clrpend.c
@@ -82,23 +82,23 @@ void kinetis_clrpend(int irq)
{
/* Check for external interrupt */
- if (irq >= KINETIS_IRQ_EXTINT)
+ if (irq >= KINETIS_IRQ_FIRST)
{
- if (irq < (KINETIS_IRQ_EXTINT+32))
+ if (irq < (KINETIS_IRQ_FIRST+32))
{
- putreg32(1 << (irq - KINETIS_IRQ_EXTINT), NVIC_IRQ0_31_CLRPEND);
+ putreg32(1 << (irq - KINETIS_IRQ_FIRST), NVIC_IRQ0_31_CLRPEND);
}
- else if (irq < (KINETIS_IRQ_EXTINT+64))
+ else if (irq < (KINETIS_IRQ_FIRST+64))
{
- putreg32(1 << (irq - KINETIS_IRQ_EXTINT - 32), NVIC_IRQ32_63_CLRPEND);
+ putreg32(1 << (irq - KINETIS_IRQ_FIRST - 32), NVIC_IRQ32_63_CLRPEND);
}
- else if (irq < (KINETIS_IRQ_EXTINT+96))
+ else if (irq < (KINETIS_IRQ_FIRST+96))
{
- putreg32(1 << (irq - KINETIS_IRQ_EXTINT - 64), NVIC_IRQ64_95_CLRPEND);
+ putreg32(1 << (irq - KINETIS_IRQ_FIRST - 64), NVIC_IRQ64_95_CLRPEND);
}
else if (irq < NR_IRQS)
{
- putreg32(1 << (irq - KINETIS_IRQ_EXTINT - 96), NVIC_IRQ96_127_CLRPEND);
+ putreg32(1 << (irq - KINETIS_IRQ_FIRST - 96), NVIC_IRQ96_127_CLRPEND);
}
}
}
diff --git a/arch/arm/src/kinetis/kinetis_dma.c b/arch/arm/src/kinetis/kinetis_dma.c
new file mode 100644
index 0000000000000000000000000000000000000000..fda8c5fb4fe73efb580c8b551644e2271874b6fc
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_dma.c
@@ -0,0 +1,199 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/kinetis_dma.c
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include "up_arch.h"
+#include "up_internal.h"
+
+#include "kinetis_config.h"
+#include "chip.h"
+#include "kinetis_dma.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+
+/****************************************************************************
+ * Name: kinetis_dmainitialize
+ *
+ * Description:
+ * Initialize the DMA subsystem.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void kinetis_dmainitilaize(void)
+{
+
+}
+
+/****************************************************************************
+ * Name: kinetis_dmachannel
+ *
+ * Description:
+ * Allocate a DMA channel. This function sets aside a DMA channel and
+ * gives the caller exclusive access to the DMA channel.
+ *
+ * Returned Value:
+ * One success, this function returns a non-NULL, void* DMA channel
+ * handle. NULL is returned on any failure. This function can fail only
+ * if no DMA channel is available.
+ *
+ ****************************************************************************/
+
+DMA_HANDLE kinetis_dmachannel(void)
+{
+ return NULL;
+}
+
+/****************************************************************************
+ * Name: kinetis_dmafree
+ *
+ * Description:
+ * Release a DMA channel. NOTE: The 'handle' used in this argument must
+ * NEVER be used again until kinetis_dmachannel() is called again to re-gain
+ * a valid handle.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void kinetis_dmafree(DMA_HANDLE handle)
+{
+
+}
+
+/****************************************************************************
+ * Name: kinetis_dmasetup
+ *
+ * Description:
+ * Configure DMA for one transfer.
+ *
+ ****************************************************************************/
+
+int kinetis_dmarxsetup(DMA_HANDLE handle, uint32_t control, uint32_t config,
+ uint32_t srcaddr, uint32_t destaddr, size_t nbytes)
+{
+ return -1;
+}
+
+/****************************************************************************
+ * Name: kinetis_dmastart
+ *
+ * Description:
+ * Start the DMA transfer
+ *
+ ****************************************************************************/
+
+int kinetis_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg)
+{
+ return -1;
+}
+
+
+/****************************************************************************
+ * Name: kinetis_dmastop
+ *
+ * Description:
+ * Cancel the DMA. After kinetis_dmastop() is called, the DMA channel is
+ * reset and kinetis_dmasetup() must be called before kinetis_dmastart() can be
+ * called again
+ *
+ ****************************************************************************/
+
+void kinetis_dmastop(DMA_HANDLE handle)
+{
+}
+
+/****************************************************************************
+ * Name: kinetis_dmasample
+ *
+ * Description:
+ * Sample DMA register contents
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_DMA
+void kinetis_dmasample(DMA_HANDLE handle, struct kinetis_dmaregs_s *regs)
+{
+
+}
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmadump
+ *
+ * Description:
+ * Dump previously sampled DMA register contents
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_DMA
+void kinetis_dmadump(DMA_HANDLE handle, const struct kinetis_dmaregs_s *regs,
+ const char *msg)
+{
+
+}
+#endif
+
diff --git a/arch/arm/src/kinetis/kinetis_dma.h b/arch/arm/src/kinetis/kinetis_dma.h
new file mode 100644
index 0000000000000000000000000000000000000000..bea264983342d8d06a968b7095d54035605fc520
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_dma.h
@@ -0,0 +1,219 @@
+/****************************************************************************
+ * arch/arm/src/kenetis/kinetis_dma.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_KINETEIS_KINETEIS_DMA_H
+#define __ARCH_ARM_SRC_KINETEIS_KINETEIS_DMA_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+#include
+
+#include "chip/kinetis_dma.h"
+
+/****************************************************************************
+ * Pre-processor Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+typedef FAR void *DMA_HANDLE;
+typedef void (*dma_callback_t)(DMA_HANDLE handle, void *arg, int result);
+
+/* The following is used for sampling DMA registers when CONFIG DEBUG_DMA is selected */
+
+#ifdef CONFIG_DEBUG_DMA
+struct kinetis_dmaglobalregs_s
+{
+#warning "Missing logic"
+ /* Global Registers */
+};
+
+struct kinetis_dmachanregs_s
+{
+#warning "Missing logic"
+ /* Channel Registers */
+};
+
+struct kinetis_dmaregs_s
+{
+ /* Global Registers */
+
+ struct kinetis_dmaglobalregs_s gbl;
+
+ /* Channel Registers */
+
+ struct kinetis_dmachanregs_s ch;
+};
+#endif
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+
+/************************************************************************************
+ * Public Functions
+ ************************************************************************************/
+
+/****************************************************************************
+ * Name: kinetis_dmainitialize
+ *
+ * Description:
+ * Initialize the GPDMA subsystem.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void kinetis_dmainitilaize(void);
+
+/****************************************************************************
+ * Name: kinetis_dmachannel
+ *
+ * Description:
+ * Allocate a DMA channel. This function sets aside a DMA channel and
+ * gives the caller exclusive access to the DMA channel.
+ *
+ * Returned Value:
+ * One success, this function returns a non-NULL, void* DMA channel
+ * handle. NULL is returned on any failure. This function can fail only
+ * if no DMA channel is available.
+ *
+ ****************************************************************************/
+
+DMA_HANDLE kinetis_dmachannel(void);
+
+/****************************************************************************
+ * Name: kinetis_dmafree
+ *
+ * Description:
+ * Release a DMA channel. NOTE: The 'handle' used in this argument must
+ * NEVER be used again until kinetis_dmachannel() is called again to re-gain
+ * a valid handle.
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void kinetis_dmafree(DMA_HANDLE handle);
+
+/****************************************************************************
+ * Name: kinetis_dmasetup
+ *
+ * Description:
+ * Configure DMA for one transfer.
+ *
+ ****************************************************************************/
+
+int kinetis_dmarxsetup(DMA_HANDLE handle, uint32_t control, uint32_t config,
+ uint32_t srcaddr, uint32_t destaddr, size_t nbytes);
+
+/****************************************************************************
+ * Name: kinetis_dmastart
+ *
+ * Description:
+ * Start the DMA transfer
+ *
+ ****************************************************************************/
+
+int kinetis_dmastart(DMA_HANDLE handle, dma_callback_t callback, void *arg);
+
+/****************************************************************************
+ * Name: kinetis_dmastop
+ *
+ * Description:
+ * Cancel the DMA. After kinetis_dmastop() is called, the DMA channel is
+ * reset and kinetis_dmasetup() must be called before kinetis_dmastart() can be
+ * called again
+ *
+ ****************************************************************************/
+
+void kinetis_dmastop(DMA_HANDLE handle);
+
+/****************************************************************************
+ * Name: kinetis_dmasample
+ *
+ * Description:
+ * Sample DMA register contents
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_DMA
+void kinetis_dmasample(DMA_HANDLE handle, struct kinetis_dmaregs_s *regs);
+#else
+# define kinetis_dmasample(handle,regs)
+#endif
+
+/****************************************************************************
+ * Name: kinetis_dmadump
+ *
+ * Description:
+ * Dump previously sampled DMA register contents
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_DEBUG_DMA
+void kinetis_dmadump(DMA_HANDLE handle, const struct kinetis_dmaregs_s *regs,
+ const char *msg);
+#else
+# define kinetis_dmadump(handle,regs,msg)
+#endif
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ARCH_ARM_SRC_KINETEIS_KINETEIS_DMA_H */
diff --git a/arch/arm/src/kinetis/kinetis_enet.c b/arch/arm/src/kinetis/kinetis_enet.c
index dc0be25e1640b36ac77a36960cf6b50a5561a536..30707e47ac1ecb885d0410eb8424397ca623cfe7 100644
--- a/arch/arm/src/kinetis/kinetis_enet.c
+++ b/arch/arm/src/kinetis/kinetis_enet.c
@@ -53,14 +53,11 @@
#include
#include
#include
+#include
#include
#include
#include
-#ifdef CONFIG_NET_NOINTS
-# include
-#endif
-
#ifdef CONFIG_NET_PKT
# include
#endif
@@ -80,12 +77,23 @@
* Pre-processor Definitions
****************************************************************************/
-/* If processing is not done at the interrupt level, then high priority
- * work queue support is required.
+/* If processing is not done at the interrupt level, then work queue support
+ * is required.
*/
-#if defined(CONFIG_NET_NOINTS) && !defined(CONFIG_SCHED_HPWORK)
-# error High priority work queue support is required
+#if !defined(CONFIG_SCHED_WORKQUEUE)
+# error Work queue support is required
+#else
+
+ /* Select work queue */
+
+# if defined(CONFIG_KINETIS_EMAC_HPWORK)
+# define ETHWORK HPWORK
+# elif defined(CONFIG_KINETIS_EMAC_LPWORK)
+# define ETHWORK LPWORK
+# else
+# error Neither CONFIG_KINETIS_EMAC_HPWORK nor CONFIG_KINETIS_EMAC_LPWORK defined
+# endif
#endif
/* CONFIG_KINETIS_ENETNETHIFS determines the number of physical interfaces
@@ -107,10 +115,6 @@
#define NENET_NBUFFERS \
(CONFIG_KINETIS_ENETNTXBUFFERS+CONFIG_KINETIS_ENETNRXBUFFERS)
-#ifndef CONFIG_NET_MULTIBUFFER
-# error "CONFIG_NET_MULTIBUFFER is required in the configuration"
-#endif
-
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per
* second.
*/
@@ -211,9 +215,7 @@ struct kinetis_driver_s
uint8_t phyaddr; /* Selected PHY address */
WDOG_ID txpoll; /* TX poll timer */
WDOG_ID txtimeout; /* TX timeout timer */
-#ifdef CONFIG_NET_NOINTS
struct work_s work; /* For deferring work to the work queue */
-#endif
struct enet_desc_s *txdesc; /* A pointer to the list of TX descriptor */
struct enet_desc_s *rxdesc; /* A pointer to the list of RX descriptors */
@@ -271,24 +273,15 @@ static int kinetis_txpoll(struct net_driver_s *dev);
static void kinetis_receive(FAR struct kinetis_driver_s *priv);
static void kinetis_txdone(FAR struct kinetis_driver_s *priv);
-static inline void kinetis_interrupt_process(FAR struct kinetis_driver_s *priv);
-#ifdef CONFIG_NET_NOINTS
static void kinetis_interrupt_work(FAR void *arg);
-#endif
static int kinetis_interrupt(int irq, FAR void *context);
/* Watchdog timer expirations */
-static inline void kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv);
-#ifdef CONFIG_NET_NOINTS
static void kinetis_txtimeout_work(FAR void *arg);
-#endif
static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...);
-static inline void kinetis_poll_process(FAR struct kinetis_driver_s *priv);
-#ifdef CONFIG_NET_NOINTS
static void kinetis_poll_work(FAR void *arg);
-#endif
static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...);
/* NuttX callback functions */
@@ -296,10 +289,7 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...);
static int kinetis_ifup(struct net_driver_s *dev);
static int kinetis_ifdown(struct net_driver_s *dev);
-static inline void kinetis_txavail_process(FAR struct kinetis_driver_s *priv);
-#ifdef CONFIG_NET_NOINTS
static void kinetis_txavail_work(FAR void *arg);
-#endif
static int kinetis_txavail(struct net_driver_s *dev);
#ifdef CONFIG_NET_IGMP
@@ -816,27 +806,31 @@ static void kinetis_txdone(FAR struct kinetis_driver_s *priv)
}
/****************************************************************************
- * Function: kinetis_interrupt_process
+ * Function: kinetis_interrupt_work
*
* Description:
- * Interrupt processing. This may be performed either within the interrupt
- * handler or on the worker thread, depending upon the configuration
+ * Perform interrupt related work from the worker thread
*
* Parameters:
- * priv - Reference to the driver state structure
+ * arg - The argument passed when work_queue() was called.
*
* Returned Value:
- * None
+ * OK on success
*
* Assumptions:
* The network is locked.
*
****************************************************************************/
-static inline void kinetis_interrupt_process(FAR struct kinetis_driver_s *priv)
+static void kinetis_interrupt_work(FAR void *arg)
{
+ FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
uint32_t pending;
+ /* Process pending Ethernet interrupts */
+
+ net_lock();
+
/* Get the set of unmasked, pending interrupt. */
pending = getreg32(KINETIS_ENET_EIR) & getreg32(KINETIS_ENET_EIMR);
@@ -884,36 +878,8 @@ static inline void kinetis_interrupt_process(FAR struct kinetis_driver_s *priv)
putreg32(ENET_RDAR, KINETIS_ENET_RDAR);
}
-}
-/****************************************************************************
- * Function: kinetis_interrupt_work
- *
- * Description:
- * Perform interrupt related work from the worker thread
- *
- * Parameters:
- * arg - The argument passed when work_queue() was called.
- *
- * Returned Value:
- * OK on success
- *
- * Assumptions:
- * The network is locked.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_NOINTS
-static void kinetis_interrupt_work(FAR void *arg)
-{
- FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
- net_lock_t state;
-
- /* Process pending Ethernet interrupts */
-
- state = net_lock();
- kinetis_interrupt_process(priv);
- net_unlock(state);
+ net_unlock();
/* Re-enable Ethernet interrupts */
@@ -924,7 +890,6 @@ static void kinetis_interrupt_work(FAR void *arg)
up_enable_irq(KINETIS_IRQ_EMACRX);
up_enable_irq(KINETIS_IRQ_EMACMISC);
}
-#endif
/****************************************************************************
* Function: kinetis_interrupt
@@ -950,7 +915,6 @@ static int kinetis_interrupt(int irq, FAR void *context)
{
register FAR struct kinetis_driver_s *priv = &g_enet[0];
-#ifdef CONFIG_NET_NOINTS
/* Disable further Ethernet interrupts. Because Ethernet interrupts are
* also disabled if the TX timeout event occurs, there can be no race
* condition here.
@@ -974,42 +938,38 @@ static int kinetis_interrupt(int irq, FAR void *context)
/* Cancel any pending poll work */
- work_cancel(HPWORK, &priv->work);
+ work_cancel(ETHWORK, &priv->work);
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(HPWORK, &priv->work, kinetis_interrupt_work, priv, 0);
-
-#else
- /* Process the interrupt now */
-
- kinetis_interrupt_process(priv);
-#endif
-
+ work_queue(ETHWORK, &priv->work, kinetis_interrupt_work, priv, 0);
return OK;
}
/****************************************************************************
- * Function: kinetis_txtimeout_process
+ * Function: kinetis_txtimeout_work
*
* Description:
- * Process a TX timeout. Called from the either the watchdog timer
- * expiration logic or from the worker thread, depending upon the
- * configuration. The timeout means that the last TX never completed.
- * Reset the hardware and start again.
+ * Perform TX timeout related work from the worker thread
*
* Parameters:
- * priv - Reference to the driver state structure
+ * arg - The argument passed when work_queue() as called.
*
* Returned Value:
- * None
+ * OK on success
+ *
+ * Assumptions:
+ * The network is locked.
*
****************************************************************************/
-static inline void kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv)
+static void kinetis_txtimeout_work(FAR void *arg)
{
+ FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
+
/* Increment statistics and dump debug info */
+ net_lock();
NETDEV_TXTIMEOUTS(&priv->dev);
/* Take the interface down and bring it back up. The is the most agressive
@@ -1022,39 +982,9 @@ static inline void kinetis_txtimeout_process(FAR struct kinetis_driver_s *priv)
/* Then poll the network for new XMIT data */
(void)devif_poll(&priv->dev, kinetis_txpoll);
+ net_unlock();
}
-/****************************************************************************
- * Function: kinetis_txtimeout_work
- *
- * Description:
- * Perform TX timeout related work from the worker thread
- *
- * Parameters:
- * arg - The argument passed when work_queue() as called.
- *
- * Returned Value:
- * OK on success
- *
- * Assumptions:
- * The network is locked.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_NOINTS
-static void kinetis_txtimeout_work(FAR void *arg)
-{
- FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
- net_lock_t state;
-
- /* Process pending Ethernet interrupts */
-
- state = net_lock();
- kinetis_txtimeout_process(priv);
- net_unlock(state);
-}
-#endif
-
/****************************************************************************
* Function: kinetis_txtimeout_expiry
*
@@ -1078,7 +1008,6 @@ static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...)
{
FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
-#ifdef CONFIG_NET_NOINTS
/* Disable further Ethernet interrupts. This will prevent some race
* conditions with interrupt work. There is still a potential race
* condition with interrupt work that is already queued and in progress.
@@ -1093,41 +1022,39 @@ static void kinetis_txtimeout_expiry(int argc, uint32_t arg, ...)
* on work that has already been started.
*/
- work_cancel(HPWORK, &priv->work);
+ work_cancel(ETHWORK, &priv->work);
/* Schedule to perform the TX timeout processing on the worker thread. */
- work_queue(HPWORK, &priv->work, kinetis_txtimeout_work, priv, 0);
-#else
- /* Process the timeout now */
-
- kinetis_txtimeout_process(priv);
-#endif
+ work_queue(ETHWORK, &priv->work, kinetis_txtimeout_work, priv, 0);
}
/****************************************************************************
- * Function: kinetis_poll_process
+ * Function: kinetis_poll_work
*
* Description:
- * Perform the periodic poll. This may be called either from watchdog
- * timer logic or from the worker thread, depending upon the configuration.
+ * Perform periodic polling from the worker thread
*
* Parameters:
- * priv - Reference to the driver state structure
+ * arg - The argument passed when work_queue() as called.
*
* Returned Value:
- * None
+ * OK on success
*
* Assumptions:
+ * The network is locked.
*
****************************************************************************/
-static inline void kinetis_poll_process(FAR struct kinetis_driver_s *priv)
+static void kinetis_poll_work(FAR void *arg)
{
+ FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
+
/* Check if there is there is a transmission in progress. We cannot perform
* the TX poll if he are unable to accept another packet for transmission.
*/
+ net_lock();
if (!kinetics_txringfull(priv))
{
/* If so, update TCP timing states and poll the network for new XMIT data. Hmmm..
@@ -1142,39 +1069,9 @@ static inline void kinetis_poll_process(FAR struct kinetis_driver_s *priv)
(void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry,
1, (wdparm_t)priv);
+ net_unlock();
}
-/****************************************************************************
- * Function: kinetis_poll_work
- *
- * Description:
- * Perform periodic polling from the worker thread
- *
- * Parameters:
- * arg - The argument passed when work_queue() as called.
- *
- * Returned Value:
- * OK on success
- *
- * Assumptions:
- * The network is locked.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_NOINTS
-static void kinetis_poll_work(FAR void *arg)
-{
- FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
- net_lock_t state;
-
- /* Perform the poll */
-
- state = net_lock();
- kinetis_poll_process(priv);
- net_unlock(state);
-}
-#endif
-
/****************************************************************************
* Function: kinetis_polltimer_expiry
*
@@ -1197,7 +1094,6 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...)
{
FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
-#ifdef CONFIG_NET_NOINTS
/* Is our single work structure available? It may not be if there are
* pending interrupt actions.
*/
@@ -1206,7 +1102,7 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...)
{
/* Schedule to perform the interrupt processing on the worker thread. */
- work_queue(HPWORK, &priv->work, kinetis_poll_work, priv, 0);
+ work_queue(ETHWORK, &priv->work, kinetis_poll_work, priv, 0);
}
else
{
@@ -1217,12 +1113,6 @@ static void kinetis_polltimer_expiry(int argc, uint32_t arg, ...)
(void)wd_start(priv->txpoll, KINETIS_WDDELAY, kinetis_polltimer_expiry,
1, (wdparm_t)arg);
}
-
-#else
- /* Process the interrupt now */
-
- kinetis_poll_process(priv);
-#endif
}
/****************************************************************************
@@ -1409,29 +1299,29 @@ static int kinetis_ifdown(struct net_driver_s *dev)
}
/****************************************************************************
- * Function: kinetis_txavail_process
+ * Function: kinetis_txavail_work
*
* Description:
- * Perform an out-of-cycle poll.
+ * Perform an out-of-cycle poll on the worker thread.
*
* Parameters:
- * dev - Reference to the NuttX driver state structure
+ * arg - Reference to the NuttX driver state structure (cast to void*)
*
* Returned Value:
* None
*
* Assumptions:
- * Called in normal user mode
+ * Called on the higher priority worker thread.
*
****************************************************************************/
-static inline void kinetis_txavail_process(FAR struct kinetis_driver_s *priv)
+static void kinetis_txavail_work(FAR void *arg)
{
- net_lock_t state;
+ FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
/* Ignore the notification if the interface is not yet up */
- state = net_lock();
+ net_lock();
if (priv->bifup)
{
/* Check if there is room in the hardware to hold another outgoing
@@ -1448,37 +1338,9 @@ static inline void kinetis_txavail_process(FAR struct kinetis_driver_s *priv)
}
}
- net_unlock(state);
+ net_unlock();
}
-/****************************************************************************
- * Function: kinetis_txavail_work
- *
- * Description:
- * Perform an out-of-cycle poll on the worker thread.
- *
- * Parameters:
- * arg - Reference to the NuttX driver state structure (cast to void*)
- *
- * Returned Value:
- * None
- *
- * Assumptions:
- * Called on the higher priority worker thread.
- *
- ****************************************************************************/
-
-#ifdef CONFIG_NET_NOINTS
-static void kinetis_txavail_work(FAR void *arg)
-{
- FAR struct kinetis_driver_s *priv = (FAR struct kinetis_driver_s *)arg;
-
- /* Perform the poll */
-
- kinetis_txavail_process(priv);
-}
-#endif
-
/****************************************************************************
* Function: kinetis_txavail
*
@@ -1503,7 +1365,6 @@ static int kinetis_txavail(struct net_driver_s *dev)
FAR struct kinetis_driver_s *priv =
(FAR struct kinetis_driver_s *)dev->d_private;
-#ifdef CONFIG_NET_NOINTS
/* Is our single work structure available? It may not be if there are
* pending interrupt actions and we will have to ignore the Tx
* availability action.
@@ -1513,15 +1374,9 @@ static int kinetis_txavail(struct net_driver_s *dev)
{
/* Schedule to serialize the poll on the worker thread. */
- work_queue(HPWORK, &priv->work, kinetis_txavail_work, priv, 0);
+ work_queue(ETHWORK, &priv->work, kinetis_txavail_work, priv, 0);
}
-#else
- /* Perform the out-of-cycle poll now */
-
- kinetis_txavail_process(priv);
-#endif
-
return OK;
}
diff --git a/arch/arm/src/kinetis/kinetis_i2c.c b/arch/arm/src/kinetis/kinetis_i2c.c
index 1713bdbbb1d64d7f326620d83d97c6418867fbbe..337e24b4d39de0a3eff8ae123d376e38ce01246d 100644
--- a/arch/arm/src/kinetis/kinetis_i2c.c
+++ b/arch/arm/src/kinetis/kinetis_i2c.c
@@ -49,6 +49,7 @@
#include
#include
+#include
#include
#include
@@ -202,8 +203,8 @@ static uint8_t kinetis_i2c_getreg(struct kinetis_i2cdev_s *priv,
*
****************************************************************************/
-static void kinetis_i2c_putreg(struct kinetis_i2cdev_s *priv, uint8_t offset,
- uint8_t value)
+static void kinetis_i2c_putreg(struct kinetis_i2cdev_s *priv, uint8_t value,
+ uint8_t offset)
{
putreg8(value, priv->base + offset);
}
@@ -1105,9 +1106,17 @@ struct i2c_master_s *kinetis_i2cbus_initialize(int port)
leave_critical_section(flags);
+ /* Initialize semaphores */
+
sem_init(&priv->mutex, 0, 1);
sem_init(&priv->wait, 0, 0);
+ /* The wait semaphore is used for signaling and, hence, should not have
+ * priority inheritance enabled.
+ */
+
+ sem_setprotocol(&priv->wait, SEM_PRIO_NONE);
+
/* Allocate a watchdog timer */
priv->timeout = wd_create();
diff --git a/arch/arm/src/kinetis/kinetis_irq.c b/arch/arm/src/kinetis/kinetis_irq.c
index a969bbacd7abbabf1d2ac3347fda9d3d585a71b8..7830d8756e2f899b603203c4193d1bca88f5a468 100644
--- a/arch/arm/src/kinetis/kinetis_irq.c
+++ b/arch/arm/src/kinetis/kinetis_irq.c
@@ -258,27 +258,27 @@ static int kinetis_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit,
/* Check for external interrupt */
- if (irq >= KINETIS_IRQ_EXTINT)
+ if (irq >= KINETIS_IRQ_FIRST)
{
- if (irq < (KINETIS_IRQ_EXTINT+32))
+ if (irq < (KINETIS_IRQ_FIRST+32))
{
*regaddr = (NVIC_IRQ0_31_ENABLE + offset);
- *bit = 1 << (irq - KINETIS_IRQ_EXTINT);
+ *bit = 1 << (irq - KINETIS_IRQ_FIRST);
}
- else if (irq < (KINETIS_IRQ_EXTINT+64))
+ else if (irq < (KINETIS_IRQ_FIRST+64))
{
*regaddr = (NVIC_IRQ32_63_ENABLE + offset);
- *bit = 1 << (irq - KINETIS_IRQ_EXTINT - 32);
+ *bit = 1 << (irq - KINETIS_IRQ_FIRST - 32);
}
- else if (irq < (KINETIS_IRQ_EXTINT+96))
+ else if (irq < (KINETIS_IRQ_FIRST+96))
{
*regaddr = (NVIC_IRQ64_95_ENABLE + offset);
- *bit = 1 << (irq - KINETIS_IRQ_EXTINT - 64);
+ *bit = 1 << (irq - KINETIS_IRQ_FIRST - 64);
}
else if (irq < NR_IRQS)
{
*regaddr = (NVIC_IRQ96_127_ENABLE + offset);
- *bit = 1 << (irq - KINETIS_IRQ_EXTINT - 96);
+ *bit = 1 << (irq - KINETIS_IRQ_FIRST - 96);
}
else
{
@@ -472,7 +472,7 @@ void up_disable_irq(int irq)
* clear the bit in the System Handler Control and State Register.
*/
- if (irq >= KINETIS_IRQ_EXTINT)
+ if (irq >= KINETIS_IRQ_FIRST)
{
putreg32(bit, regaddr);
}
@@ -509,7 +509,7 @@ void up_enable_irq(int irq)
* set the bit in the System Handler Control and State Register.
*/
- if (irq >= KINETIS_IRQ_EXTINT)
+ if (irq >= KINETIS_IRQ_FIRST)
{
putreg32(bit, regaddr);
}
@@ -560,7 +560,7 @@ int up_prioritize_irq(int irq, int priority)
DEBUGASSERT(irq >= KINETIS_IRQ_MEMFAULT && irq < NR_IRQS &&
(unsigned)priority <= NVIC_SYSH_PRIORITY_MIN);
- if (irq < KINETIS_IRQ_EXTINT)
+ if (irq < KINETIS_IRQ_FIRST)
{
/* NVIC_SYSH_PRIORITY() maps {0..15} to one of three priority
* registers (0-3 are invalid)
@@ -573,7 +573,7 @@ int up_prioritize_irq(int irq, int priority)
{
/* NVIC_IRQ_PRIORITY() maps {0..} to one of many priority registers */
- irq -= KINETIS_IRQ_EXTINT;
+ irq -= KINETIS_IRQ_FIRST;
regaddr = NVIC_IRQ_PRIORITY(irq);
}
diff --git a/arch/arm/src/kinetis/kinetis_pindma.c b/arch/arm/src/kinetis/kinetis_pindma.c
index 40acdc036b58b07092851a87d490e610257ee698..411f371bbbc746a54bbb380e29d4de094eba5e8c 100644
--- a/arch/arm/src/kinetis/kinetis_pindma.c
+++ b/arch/arm/src/kinetis/kinetis_pindma.c
@@ -37,12 +37,24 @@
* Included Files
****************************************************************************/
-#include
#include
+#include
+#include
+#include
+#include
+
+#include
+
#include
#include "up_internal.h"
+#include "kinetis_config.h"
+#include "chip.h"
+#include "kinetis.h"
+
+
+
#ifdef CONFIG_KINETIS_DMA
/****************************************************************************
diff --git a/arch/arm/src/kinetis/kinetis_sdhc.c b/arch/arm/src/kinetis/kinetis_sdhc.c
index 0f1197b6e7b9d08420d8a3906d7a1a0a11155b31..b724bfec917489d171ea3b278814e904d56976fb 100644
--- a/arch/arm/src/kinetis/kinetis_sdhc.c
+++ b/arch/arm/src/kinetis/kinetis_sdhc.c
@@ -52,6 +52,7 @@
#include
#include
#include
+#include
#include
#include
@@ -2774,8 +2775,18 @@ FAR struct sdio_dev_s *sdhc_initialize(int slotno)
DEBUGASSERT(slotno == 0);
/* Initialize the SDHC slot structure data structure */
+ /* Initialize semaphores */
sem_init(&priv->waitsem, 0, 0);
+
+ /* The waitsem semaphore is used for signaling and, hence, should not have
+ * priority inheritance enabled.
+ */
+
+ sem_setprotocol(&priv->waitsem, SEM_PRIO_NONE);
+
+ /* Create a watchdog timer */
+
priv->waitwdog = wd_create();
DEBUGASSERT(priv->waitwdog);
diff --git a/arch/arm/src/kinetis/kinetis_spi.h b/arch/arm/src/kinetis/kinetis_spi.h
new file mode 100644
index 0000000000000000000000000000000000000000..19ce126d1026ff623ddaef56bebc7d892844cc4b
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_spi.h
@@ -0,0 +1,166 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/kinetis_spi.h
+ *
+ * Copyright (C) 2016 Gregory Nutt. All rights reserved.
+ * Authors: David Sidrane
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_KINETIS_KINETIS_SPI_H
+#define __ARCH_ARM_SRC_KINETIS_KINETIS_SPI_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include "chip/kinetis_dspi.h"
+
+/************************************************************************************
+ * Pre-processor Definitions
+ ************************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/************************************************************************************
+ * Public Data
+ ************************************************************************************/
+
+struct spi_dev_s;
+enum spi_dev_e;
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/************************************************************************************
+ * Name: kinetis_spibus_initialize
+ *
+ * Description:
+ * Initialize the selected SPI bus
+ *
+ * Input Parameter:
+ * bus number (for hardware that has mutiple SPI interfaces)
+ *
+ * Returned Value:
+ * Valid SPI device structure reference on succcess; a NULL on failure
+ *
+ ************************************************************************************/
+
+FAR struct spi_dev_s *kinetis_spibus_initialize(int bus);
+
+/************************************************************************************
+ * Name: kinetis_spi[n]select, kinetis_spi[n]status, and kinetis_spi[n]cmddata
+ *
+ * Description:
+ * These external functions must be provided by board-specific logic. They are
+ * implementations of the select, status, and cmddata methods of the SPI interface
+ * defined by struct spi_ops_s (see include/nuttx/spi/spi.h). All other methods
+ * including kinetis_spibus_initialize()) are provided by common Kinetis logic. To use
+ * this common SPI logic on your board:
+ *
+ * 1. Provide logic in kinetis_boardinitialize() to configure SPI chip select
+ * pins.
+ * 2. Provide kinetis_spi[n]select() and kinetis_spi[n]status() functions
+ * in your board-specific logic. These functions will perform chip selection
+ * and status operations using GPIOs in the way your board is configured.
+ * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
+ * kinetis_spi[n]cmddata() functions in your board-specific logic. These
+ * functions will perform cmd/data selection operations using GPIOs in the way
+ * your board is configured.
+ * 3. Add a call to kinetis_spibus_initialize() in your low level application
+ * initialization logic
+ * 4. The handle returned by kinetis_spibus_initialize() may then be used to bind the
+ * SPI driver to higher level logic (e.g., calling
+ * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
+ * the SPI MMC/SD driver).
+ *
+ ************************************************************************************/
+
+#ifdef CONFIG_KINETIS_SPI0
+void kinetis_spi0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+uint8_t kinetis_spi0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+int kinetis_spi0cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
+#endif
+#ifdef CONFIG_KINETIS_SPI1
+void kinetis_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+uint8_t kinetis_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+int kinetis_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
+#endif
+#ifdef CONFIG_KINETIS_SPI2
+void kinetis_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected);
+uint8_t kinetis_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid);
+#ifdef CONFIG_SPI_CMDDATA
+int kinetis_spi2cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
+#endif
+#endif
+
+/****************************************************************************
+ * Name: ssp_flush
+ *
+ * Description:
+ * Flush and discard any words left in the RX fifo. This can be called
+ * from spi[n]select after a device is deselected (if you worry about such
+ * things).
+ *
+ * Input Parameters:
+ * dev - Device-specific state data
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+#if defined(CONFIG_KINETIS_SPI0) || defined(CONFIG_KINETIS_SPI1) || defined(CONFIG_KINETIS_SPI2)
+struct spi_dev_s;
+void spi_flush(FAR struct spi_dev_s *dev);
+#endif
+
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ARCH_ARM_SRC_KINETIS_KINETIS_SPI_H */
diff --git a/arch/arm/src/kinetis/kinetis_start.c b/arch/arm/src/kinetis/kinetis_start.c
index 21885d926823fdaaaf592fff9639b81b11fd6ef3..7f209b1351b2abaa35c1f6f0432369d1e5f19dae 100644
--- a/arch/arm/src/kinetis/kinetis_start.c
+++ b/arch/arm/src/kinetis/kinetis_start.c
@@ -54,9 +54,59 @@
#include "chip/kinetis_smc.h"
#include "kinetis_userspace.h"
+#ifdef CONFIG_ARCH_FPU
+# include "nvic.h"
+#endif
+
+/****************************************************************************
+ * Private Function prototypes
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_FPU
+static inline void stm32_fpuconfig(void);
+#endif
+#ifdef CONFIG_STACK_COLORATION
+static void go_os_start(void *pv, unsigned int nbytes)
+ __attribute__ ((naked, no_instrument_function, noreturn));
+#endif
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/* Memory Map ***************************************************************/
+/*
+ * 0x0000:0000 - Beginning of the internal FLASH. Address of vectors.
+ * Mapped as boot memory address 0x0000:0000 at reset.
+ * 0x07ff:ffff - End of flash region (assuming the max of 2MiB of FLASH).
+ * 0x1fff:0000 - Start of internal SRAM and start of .data (_sdata)
+ * - End of .data (_edata) and start of .bss (_sbss)
+ * - End of .bss (_ebss) and bottom of idle stack
+ * - _ebss + CONFIG_IDLETHREAD_STACKSIZE = end of idle stack,
+ * start of heap. NOTE that the ARM uses a decrement before
+ * store stack so that the correct initial value is the end of
+ * the stack + 4;
+ * 0x2002:ffff - End of internal SRAM and end of heap (a
+ */
+
+#define IDLE_STACK ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE-4)
+#define HEAP_BASE ((uintptr_t)&_ebss+CONFIG_IDLETHREAD_STACKSIZE)
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* g_idle_topstack: _sbss is the start of the BSS region as defined by the
+ * linker script. _ebss lies at the end of the BSS region. The idle task
+ * stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE.
+ * The IDLE thread is the thread that the system boots on and, eventually,
+ * becomes the IDLE, do nothing task that runs only when there is nothing
+ * else to run. The heap continues from there until the end of memory.
+ * g_idle_topstack is a read-only variable the provides this computed
+ * address.
+ */
+#if defined(CONFIG_ARMV7M_CMNVECTOR)
+const uintptr_t g_idle_topstack = HEAP_BASE;
+#endif
/****************************************************************************
* Private Data
@@ -70,6 +120,143 @@
* Private Functions
****************************************************************************/
+
+#ifdef CONFIG_ARMV7M_STACKCHECK
+/* we need to get r10 set before we can allow instrumentation calls */
+
+void __start(void) __attribute__ ((no_instrument_function));
+#endif
+
+/****************************************************************************
+ * Name: stm32_fpuconfig
+ *
+ * Description:
+ * Configure the FPU. Relative bit settings:
+ *
+ * CPACR: Enables access to CP10 and CP11
+ * CONTROL.FPCA: Determines whether the FP extension is active in the
+ * current context:
+ * FPCCR.ASPEN: Enables automatic FP state preservation, then the
+ * processor sets this bit to 1 on successful completion of any FP
+ * instruction.
+ * FPCCR.LSPEN: Enables lazy context save of FP state. When this is
+ * done, the processor reserves space on the stack for the FP state,
+ * but does not save that state information to the stack.
+ *
+ * Software must not change the value of the ASPEN bit or LSPEN bit while either:
+ * - the CPACR permits access to CP10 and CP11, that give access to the FP
+ * extension, or
+ * - the CONTROL.FPCA bit is set to 1
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_FPU
+#if defined(CONFIG_ARMV7M_CMNVECTOR) && !defined(CONFIG_ARMV7M_LAZYFPU)
+
+static inline void stm32_fpuconfig(void)
+{
+ uint32_t regval;
+
+ /* Set CONTROL.FPCA so that we always get the extended context frame
+ * with the volatile FP registers stacked above the basic context.
+ */
+
+ regval = getcontrol();
+ regval |= (1 << 2);
+ setcontrol(regval);
+
+ /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend
+ * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we
+ * are going to turn on CONTROL.FPCA for all contexts.
+ */
+
+ regval = getreg32(NVIC_FPCCR);
+ regval &= ~((1 << 31) | (1 << 30));
+ putreg32(regval, NVIC_FPCCR);
+
+ /* Enable full access to CP10 and CP11 */
+
+ regval = getreg32(NVIC_CPACR);
+ regval |= ((3 << (2*10)) | (3 << (2*11)));
+ putreg32(regval, NVIC_CPACR);
+}
+
+#else
+
+static inline void stm32_fpuconfig(void)
+{
+ uint32_t regval;
+
+ /* Clear CONTROL.FPCA so that we do not get the extended context frame
+ * with the volatile FP registers stacked in the saved context.
+ */
+
+ regval = getcontrol();
+ regval &= ~(1 << 2);
+ setcontrol(regval);
+
+ /* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend
+ * with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we
+ * are going to keep CONTROL.FPCA off for all contexts.
+ */
+
+ regval = getreg32(NVIC_FPCCR);
+ regval &= ~((1 << 31) | (1 << 30));
+ putreg32(regval, NVIC_FPCCR);
+
+ /* Enable full access to CP10 and CP11 */
+
+ regval = getreg32(NVIC_CPACR);
+ regval |= ((3 << (2*10)) | (3 << (2*11)));
+ putreg32(regval, NVIC_CPACR);
+}
+
+#endif
+
+#else
+# define stm32_fpuconfig()
+#endif
+
+/****************************************************************************
+ * Name: go_os_start
+ *
+ * Description:
+ * Set the IDLE stack to the
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_STACK_COLORATION
+static void go_os_start(void *pv, unsigned int nbytes)
+{
+ /* Set the IDLE stack to the stack coloration value then jump to
+ * os_start(). We take extreme care here because were currently
+ * executing on this stack.
+ *
+ * We want to avoid sneak stack access generated by the compiler.
+ */
+
+ __asm__ __volatile__
+ (
+ "\tmovs r1, r1, lsr #2\n" /* R1 = nwords = nbytes >> 2 */
+ "\tbeq 2f\n" /* (should not happen) */
+
+ "\tbic r0, r0, #3\n" /* R0 = Aligned stackptr */
+ "\tmovw r2, #0xbeef\n" /* R2 = STACK_COLOR = 0xdeadbeef */
+ "\tmovt r2, #0xdead\n"
+
+ "1:\n" /* Top of the loop */
+ "\tsub r1, r1, #1\n" /* R1 nwords-- */
+ "\tcmp r1, #0\n" /* Check (nwords == 0) */
+ "\tstr r2, [r0], #4\n" /* Save stack color word, increment stackptr */
+ "\tbne 1b\n" /* Bottom of the loop */
+
+ "2:\n"
+ "\tmov r14, #0\n" /* LR = return address (none) */
+ "\tb os_start\n" /* Branch to os_start */
+ );
+}
+#endif
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -87,6 +274,12 @@ void __start(void)
const uint32_t *src;
uint32_t *dest;
+#ifdef CONFIG_ARMV7M_STACKCHECK
+ /* Set the stack limit before we attempt to call any functions */
+
+ __asm__ volatile ("sub r10, sp, %0" : : "r" (CONFIG_IDLETHREAD_STACKSIZE - 64) : );
+#endif
+
/* Disable the watchdog timer */
kinetis_wddisable();
@@ -134,7 +327,7 @@ void __start(void)
* can get debug output as soon as possible (This depends on clock
* configuration).
*/
-
+ stm32_fpuconfig();
kinetis_lowsetup();
#ifdef USE_EARLYSERIALINIT
up_earlyserialinit();
diff --git a/arch/arm/src/kinetis/kinetis_uid.c b/arch/arm/src/kinetis/kinetis_uid.c
new file mode 100644
index 0000000000000000000000000000000000000000..954c667f4181f436a71553756716884e06e16c89
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_uid.c
@@ -0,0 +1,70 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/kinetis_uid.c
+ *
+ * Copyright (C) 2016 Neil Hancock. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+#include
+#include
+#include "kinetis_uid.h"
+
+#ifdef CONFIG_BOARDCTL_UNIQUEID
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: kinetis_get_uniqueid
+ ****************************************************************************/
+
+void kinetis_get_uniqueid(uint8_t *uniqueid)
+{
+ uint32_t *unique_u32;
+ int i;
+
+ unique_u32 = (uint32_t *)uniqueid;
+
+ /* Copy into buffer LS first, which in the Kinetis is the highest memory */
+
+ for (i = 0; i < (KINETIS_UID_SIZE / sizeof(uint32_t)); i++)
+ {
+ unique_u32[i] = *((uint32_t*)(KINETIS_SIM_UIDL) - i);
+ }
+}
+
+#endif /* CONFIG_BOARDCTL_UNIQUEID */
diff --git a/arch/arm/src/kinetis/kinetis_uid.h b/arch/arm/src/kinetis/kinetis_uid.h
new file mode 100644
index 0000000000000000000000000000000000000000..29299da5822fdb4571a3b518242d38cc8ae76892
--- /dev/null
+++ b/arch/arm/src/kinetis/kinetis_uid.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * arch/arm/src/kinetis/kinetis_uid.h
+ *
+ * Copyright (C) 2016 Neil Hancock. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_ARM_SRC_KINETIS_UID_H
+#define __ARCH_ARM_SRC_KINETIS_UID_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define KINETIS_UID_SIZE 16
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+void kinetis_get_uniqueid(uint8_t *uniqueid);
+
+#endif /* __ARCH_ARM_SRC_KINETIS_UID_H */
diff --git a/arch/arm/src/kinetis/kinetis_vectors.S b/arch/arm/src/kinetis/kinetis_vectors.S
index 39f07fc000f041f11ddcaaf0293f876aa2b12faa..48c74c705974668caf40465d773cd2fa91daebd1 100644
--- a/arch/arm/src/kinetis/kinetis_vectors.S
+++ b/arch/arm/src/kinetis/kinetis_vectors.S
@@ -1,9 +1,9 @@
-/************************************************************************************************
+/*****************************************************************************
* arch/arm/src/kinetis/kinetis_vectors.S
- * arch/arm/src/chip/kinetis_vectors.S
*
- * Copyright (C) 2011, 2013-2015 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt
+ * Copyright (C) 2011, 2013-2016 Gregory Nutt. All rights reserved.
+ * Authors: Gregory Nutt
+ * David Sidrane
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,11 +32,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************************************************/
+ ****************************************************************************/
-/************************************************************************************************
+/*****************************************************************************
* Included Files
- ************************************************************************************************/
+ ****************************************************************************/
#include
@@ -45,23 +45,25 @@
#include "chip.h"
#include "exc_return.h"
-/************************************************************************************************
+/*****************************************************************************
* Pre-processor Definitions
- ************************************************************************************************/
-/* Configuration ********************************************************************************/
+ ****************************************************************************/
+/* Configuration ************************************************************/
#ifdef CONFIG_ARCH_HIPRI_INTERRUPT
- /* In kernel mode without an interrupt stack, this interrupt handler will set the MSP to the
- * stack pointer of the interrupted thread. If the interrupted thread was a privileged
- * thread, that will be the MSP otherwise it will be the PSP. If the PSP is used, then the
- * value of the MSP will be invalid when the interrupt handler returns because it will be a
- * pointer to an old position in the unprivileged stack. Then when the high priority
- * interrupt occurs and uses this stale MSP, there will most likely be a system failure.
+ /* In kernel mode without an interrupt stack, this interrupt handler will set the
+ * MSP to the stack pointer of the interrupted thread. If the interrupted thread
+ * was a privileged thread, that will be the MSP otherwise it will be the PSP. If
+ * the PSP is used, then the value of the MSP will be invalid when the interrupt
+ * handler returns because it will be a pointer to an old position in the
+ * unprivileged stack. Then when the high priority interrupt occurs and uses this
+ * stale MSP, there will most likely be a system failure.
*
- * If the interrupt stack is selected, on the other hand, then the interrupt handler will
- * always set the the MSP to the interrupt stack. So when the high priority interrupt occurs,
- * it will either use the MSP of the last privileged thread to run or, in the case of the
- * nested interrupt, the interrupt stack if no privileged task has run.
+ * If the interrupt stack is selected, on the other hand, then the interrupt
+ * handler will always set the the MSP to the interrupt stack. So when the high
+ * priority interrupt occurs, it will either use the MSP of the last privileged
+ * thread to run or, in the case of the nested interrupt, the interrupt stack if
+ * no privileged task has run.
*/
# if defined(CONFIG_BUILD_PROTECTED) && CONFIG_ARCH_INTERRUPTSTACK < 4
@@ -77,7 +79,7 @@
# endif
#endif
-/* Memory Map ***********************************************************************************/
+/* Memory Map ***********************************************************************/
/*
* 0x0000:0000 - Beginning of FLASH. Address of vectors
* 0x1800:0000 - Start of CPU SRAM and start of .data (_sdata)
@@ -92,9 +94,9 @@
#define IDLE_STACK (_ebss+CONFIG_IDLETHREAD_STACKSIZE-4)
#define HEAP_BASE (_ebss+CONFIG_IDLETHREAD_STACKSIZE)
-/************************************************************************************************
+/************************************************************************************
* Public Symbols
- ************************************************************************************************/
+ ************************************************************************************/
.syntax unified
.thumb
@@ -106,9 +108,9 @@
.globl __start
-/************************************************************************************************
+/************************************************************************************
* Macros
- ************************************************************************************************/
+ ************************************************************************************/
/* On entry into an IRQ, the hardware automatically saves the xPSR, PC, LR, R12, R0-R3
* registers on the stack, then branches to an instantantiation of the following
@@ -123,9 +125,9 @@
b exception_common
.endm
-/************************************************************************************************
+/************************************************************************************
* Vectors
- ************************************************************************************************/
+ ************************************************************************************/
.section .vectors, "ax"
.code 16
@@ -135,7 +137,7 @@
_vectors:
-/* Processor Exceptions *************************************************************************/
+/* Processor Exceptions */
.word IDLE_STACK /* Vector 0: Reset stack pointer */
.word __start /* Vector 1: Reset vector */
@@ -154,437 +156,38 @@ _vectors:
.word kinetis_pendsv /* Vector 14: Pendable system service request */
.word kinetis_systick /* Vector 15: System tick */
-/* External Interrupts **************************************************************************/
-/* K20 Family ***********************************************************************************
- *
- * The interrupt vectors for the following parts is defined in Freescale document
- * K20P64M72SF1RM
- */
-
-#if defined(KINETIS_K20)
- .word kinetis_dmach0 /* Vector 16: DMA channel 0 transfer complete */
- .word kinetis_dmach1 /* Vector 17: DMA channel 1 transfer complete */
- .word kinetis_dmach2 /* Vector 18: DMA channel 2 transfer complete */
- .word kinetis_dmach3 /* Vector 19: DMA channel 3 transfer complete */
- .word kinetis_dmach4 /* Vector 20: DMA channel 4 transfer complete */
- .word kinetis_dmach5 /* Vector 21: DMA channel 5 transfer complete */
- .word kinetis_dmach6 /* Vector 22: DMA channel 6 transfer complete */
- .word kinetis_dmach7 /* Vector 23: DMA channel 7 transfer complete */
- .word kinetis_dmach8 /* Vector 24: DMA channel 8 transfer complete */
- .word kinetis_dmach9 /* Vector 25: DMA channel 9 transfer complete */
- .word kinetis_dmach10 /* Vector 26: DMA channel 10 transfer complete */
- .word kinetis_dmach11 /* Vector 27: DMA channel 11 transfer complete */
- .word kinetis_dmach12 /* Vector 28: DMA channel 12 transfer complete */
- .word kinetis_dmach13 /* Vector 29: DMA channel 13 transfer complete */
- .word kinetis_dmach14 /* Vector 30: DMA channel 14 transfer complete */
- .word kinetis_dmach15 /* Vector 31: DMA channel 15 transfer complete */
- .word kinetis_dmaerr /* Vector 32: DMA error interrupt channels 0-15 */
- .word kinetis_reserved /* Vector 33: Reserved */
- .word kinetis_flashcc /* Vector 34: Flash memory command complete */
- .word kinetis_flashrc /* Vector 35: Flash memory read collision */
- .word kinetis_smclvd /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- .word kinetis_llwu /* Vector 37: LLWU Normal Low Leakage Wakeup */
- .word kinetis_wdog /* Vector 38: Watchdog */
- .word kinetis_reserved /* Vector 39: Reserved */
- .word kinetis_i2c0 /* Vector 40: I2C0 */
- .word kinetis_i2c1 /* Vector 41: I2C1 */
- .word kinetis_spi0 /* Vector 42: SPI0 all sources */
- .word kinetis_spi1 /* Vector 43: SPI1 all sources */
- .word kinetis_reserved /* Vector 44: Reserved */
- .word kinetis_can0mb /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
- .word kinetis_can0bo /* Vector 46: CAN0 Bus Off */
- .word kinetis_can0err /* Vector 47: CAN0 Error */
- .word kinetis_can0tw /* Vector 48: CAN0 Transmit Warning */
- .word kinetis_can0rw /* Vector 49: CAN0 Receive Warning */
- .word kinetis_can0wu /* Vector 50: CAN0 Wake UP */
- .word kinetis_reserved /* Vector 51: Reserved */
- .word kinetis_reserved /* Vector 52: Reserved */
- .word kinetis_reserved /* Vector 53: Reserved */
- .word kinetis_reserved /* Vector 54: Reserved */
- .word kinetis_reserved /* Vector 55: Reserved */
- .word kinetis_reserved /* Vector 56: Reserved */
- .word kinetis_reserved /* Vector 57: Reserved */
- .word kinetis_reserved /* Vector 58: Reserved */
- .word kinetis_reserved /* Vector 59: Reserved */
- .word kinetis_reserved /* Vector 60: Reserved */
- .word kinetis_uart0s /* Vector 61: UART0 status */
- .word kinetis_uart0e /* Vector 62: UART0 error */
- .word kinetis_uart1s /* Vector 63: UART1 status */
- .word kinetis_uart1e /* Vector 64: UART1 error */
- .word kinetis_uart2s /* Vector 65: UART2 status */
- .word kinetis_uart2e /* Vector 66: UART2 error */
- .word kinetis_reserved /* Vector 67: Reserved */
- .word kinetis_reserved /* Vector 68: Reserved */
- .word kinetis_reserved /* Vector 69: Reserved */
- .word kinetis_reserved /* Vector 70: Reserved */
- .word kinetis_reserved /* Vector 71: Reserved */
- .word kinetis_reserved /* Vector 72: Reserved */
- .word kinetis_adc0 /* Vector 73: ADC0 */
- .word kinetis_adc1 /* Vector 74: ADC1 */
- .word kinetis_cmp0 /* Vector 75: CMP0 */
- .word kinetis_cmp1 /* Vector 76: CMP1 */
- .word kinetis_cmp2 /* Vector 77: CMP2 */
- .word kinetis_ftm0 /* Vector 78: FTM0 all sources */
- .word kinetis_ftm1 /* Vector 79: FTM1 all sources */
- .word kinetis_ftm2 /* Vector 80: FTM2 all sources */
- .word kinetis_cmt /* Vector 81: CMT */
- .word kinetis_rtc /* Vector 82: RTC alarm interrupt */
- .word kinetis_reserved /* Vector 83: Reserved */
- .word kinetis_pitch0 /* Vector 84: PIT channel 0 */
- .word kinetis_pitch1 /* Vector 85: PIT channel 1 */
- .word kinetis_pitch2 /* Vector 86: PIT channel 2 */
- .word kinetis_pitch3 /* Vector 87: PIT channel 3 */
- .word kinetis_pdb /* Vector 88: PDB */
- .word kinetis_usbotg /* Vector 88: USB OTG */
- .word kinetis_usbcd /* Vector 90: USB charger detect */
- .word kinetis_reserved /* Vector 91: Reserved */
- .word kinetis_reserved /* Vector 92: Reserved */
- .word kinetis_reserved /* Vector 93: Reserved */
- .word kinetis_reserved /* Vector 94: Reserved */
- .word kinetis_reserved /* Vector 95: Reserved */
- .word kinetis_reserved /* Vector 96: Reserved */
- .word kinetis_dac0 /* Vector 97: DAC0 */
- .word kinetis_reserved /* Vector 98: Reserved */
- .word kinetis_tsi /* Vector 99: TSI all sources */
- .word kinetis_mcg /* Vector 100: MCG */
- .word kinetis_lpt /* Vector 101: Low power timer */
- .word kinetis_reserved /* Vector 102: Reserved */
- .word kinetis_porta /* Vector 103: Pin detect port A */
- .word kinetis_portb /* Vector 104: Pin detect port B */
- .word kinetis_portc /* Vector 105: Pin detect port C */
- .word kinetis_portd /* Vector 106: Pin detect port D */
- .word kinetis_porte /* Vector 107: Pin detect port E */
- .word kinetis_reserved /* Vector 108: Reserved */
- .word kinetis_reserved /* Vector 109: Reserved */
- .word kinetis_swi /* Vector 110: Software interrupt */
-
-/* K40 Family ***********************************************************************************
- *
- * The interrupt vectors for the following parts is defined in Freescale document
- * K40P144M100SF2RM
- */
-
-#elif defined(KINETIS_K40)
-
- .word kinetis_dmach0 /* Vector 16: DMA channel 0 transfer complete */
- .word kinetis_dmach1 /* Vector 17: DMA channel 1 transfer complete */
- .word kinetis_dmach2 /* Vector 18: DMA channel 2 transfer complete */
- .word kinetis_dmach3 /* Vector 19: DMA channel 3 transfer complete */
- .word kinetis_dmach4 /* Vector 20: DMA channel 4 transfer complete */
- .word kinetis_dmach5 /* Vector 21: DMA channel 5 transfer complete */
- .word kinetis_dmach6 /* Vector 22: DMA channel 6 transfer complete */
- .word kinetis_dmach7 /* Vector 23: DMA channel 7 transfer complete */
- .word kinetis_dmach8 /* Vector 24: DMA channel 8 transfer complete */
- .word kinetis_dmach9 /* Vector 25: DMA channel 9 transfer complete */
- .word kinetis_dmach10 /* Vector 26: DMA channel 10 transfer complete */
- .word kinetis_dmach11 /* Vector 27: DMA channel 11 transfer complete */
- .word kinetis_dmach12 /* Vector 28: DMA channel 12 transfer complete */
- .word kinetis_dmach13 /* Vector 29: DMA channel 13 transfer complete */
- .word kinetis_dmach14 /* Vector 30: DMA channel 14 transfer complete */
- .word kinetis_dmach15 /* Vector 31: DMA channel 15 transfer complete */
- .word kinetis_dmaerr /* Vector 32: DMA error interrupt channels 0-15 */
- .word kinetis_mcm /* Vector 33: MCM Normal interrupt */
- .word kinetis_flashcc /* Vector 34: Flash memory command complete */
- .word kinetis_flashrc /* Vector 35: Flash memory read collision */
- .word kinetis_smclvd /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- .word kinetis_llwu /* Vector 37: LLWU Normal Low Leakage Wakeup */
- .word kinetis_wdog /* Vector 38: Watchdog */
- .word kinetis_reserved /* Vector 39: Reserved */
- .word kinetis_i2c0 /* Vector 40: I2C0 */
- .word kinetis_i2c1 /* Vector 41: I2C1 */
- .word kinetis_spi0 /* Vector 42: SPI0 all sources */
- .word kinetis_spi1 /* Vector 43: SPI1 all sources */
- .word kinetis_spi2 /* Vector 44: SPI2 all sources */
- .word kinetis_can0mb /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
- .word kinetis_can0bo /* Vector 46: CAN0 Bus Off */
- .word kinetis_can0err /* Vector 47: CAN0 Error */
- .word kinetis_can0tw /* Vector 48: CAN0 Transmit Warning */
- .word kinetis_can0rw /* Vector 49: CAN0 Receive Warning */
- .word kinetis_can0wu /* Vector 50: CAN0 Wake UP */
- .word kinetis_reserved /* Vector 51: Reserved */
- .word kinetis_reserved /* Vector 52: Reserved */
- .word kinetis_can1mb /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
- .word kinetis_can1bo /* Vector 54: CAN1 Bus Off */
- .word kinetis_can1err /* Vector 55: CAN1 Error */
- .word kinetis_can1tw /* Vector 56: CAN1 Transmit Warning */
- .word kinetis_can1rw /* Vector 57: CAN1 Receive Warning */
- .word kinetis_can1wu /* Vector 58: CAN1 Wake UP */
- .word kinetis_reserved /* Vector 59: Reserved */
- .word kinetis_reserved /* Vector 60: Reserved */
- .word kinetis_uart0s /* Vector 61: UART0 status */
- .word kinetis_uart0e /* Vector 62: UART0 error */
- .word kinetis_uart1s /* Vector 63: UART1 status */
- .word kinetis_uart1e /* Vector 64: UART1 error */
- .word kinetis_uart2s /* Vector 65: UART2 status */
- .word kinetis_uart2e /* Vector 66: UART2 error */
- .word kinetis_uart3s /* Vector 67: UART3 status */
- .word kinetis_uart3e /* Vector 68: UART3 error */
- .word kinetis_uart4s /* Vector 69: UART4 status */
- .word kinetis_uart4e /* Vector 70: UART4 error */
- .word kinetis_uart5s /* Vector 71: UART5 status */
- .word kinetis_uart5e /* Vector 72: UART5 error */
- .word kinetis_adc0 /* Vector 73: ADC0 */
- .word kinetis_adc1 /* Vector 74: ADC1 */
- .word kinetis_cmp0 /* Vector 75: CMP0 */
- .word kinetis_cmp1 /* Vector 76: CMP1 */
- .word kinetis_cmp2 /* Vector 77: CMP2 */
- .word kinetis_ftm0 /* Vector 78: FTM0 all sources */
- .word kinetis_ftm1 /* Vector 79: FTM1 all sources */
- .word kinetis_ftm2 /* Vector 80: FTM2 all sources */
- .word kinetis_cmt /* Vector 81: CMT */
- .word kinetis_rtc /* Vector 82: RTC alarm interrupt */
- .word kinetis_reserved /* Vector 83: Reserved */
- .word kinetis_pitch0 /* Vector 84: PIT channel 0 */
- .word kinetis_pitch1 /* Vector 85: PIT channel 1 */
- .word kinetis_pitch2 /* Vector 86: PIT channel 2 */
- .word kinetis_pitch3 /* Vector 87: PIT channel 3 */
- .word kinetis_pdb /* Vector 88: PDB */
- .word kinetis_usbotg /* Vector 88: USB OTG */
- .word kinetis_usbcd /* Vector 90: USB charger detect */
- .word kinetis_reserved /* Vector 91: Reserved */
- .word kinetis_reserved /* Vector 92: Reserved */
- .word kinetis_reserved /* Vector 93: Reserved */
- .word kinetis_reserved /* Vector 94: Reserved */
- .word kinetis_i2s0 /* Vector 95: I2S0 */
- .word kinetis_sdhc /* Vector 96: SDHC */
- .word kinetis_dac0 /* Vector 97: DAC0 */
- .word kinetis_dac1 /* Vector 98: DAC1 */
- .word kinetis_tsi /* Vector 97: TSI all sources */
- .word kinetis_mcg /* Vector 100: MCG */
- .word kinetis_lpt /* Vector 101: Low power timer */
- .word kinetis_slcd /* Vector 102: Segment LCD all sources */
- .word kinetis_porta /* Vector 103: Pin detect port A */
- .word kinetis_portb /* Vector 104: Pin detect port B */
- .word kinetis_portc /* Vector 105: Pin detect port C */
- .word kinetis_portd /* Vector 106: Pin detect port D */
- .word kinetis_porte /* Vector 107: Pin detect port E */
- .word kinetis_reserved /* Vector 108: Reserved */
- .word kinetis_reserved /* Vector 109: Reserved */
- .word kinetis_swi /* Vector 110: Software interrupt */
-
-/* K60 Family ***********************************************************************************
- *
- * The memory map for the following parts is defined in Freescale document
- * K60P144M100SF2RM
- */
-
-#elif defined(KINETIS_K60)
-
- .word kinetis_dmach0 /* Vector 16: DMA channel 0 transfer complete */
- .word kinetis_dmach1 /* Vector 17: DMA channel 1 transfer complete */
- .word kinetis_dmach2 /* Vector 18: DMA channel 2 transfer complete */
- .word kinetis_dmach3 /* Vector 19: DMA channel 3 transfer complete */
- .word kinetis_dmach4 /* Vector 20: DMA channel 4 transfer complete */
- .word kinetis_dmach5 /* Vector 21: DMA channel 5 transfer complete */
- .word kinetis_dmach6 /* Vector 22: DMA channel 6 transfer complete */
- .word kinetis_dmach7 /* Vector 23: DMA channel 7 transfer complete */
- .word kinetis_dmach8 /* Vector 24: DMA channel 8 transfer complete */
- .word kinetis_dmach9 /* Vector 25: DMA channel 9 transfer complete */
- .word kinetis_dmach10 /* Vector 26: DMA channel 10 transfer complete */
- .word kinetis_dmach11 /* Vector 27: DMA channel 11 transfer complete */
- .word kinetis_dmach12 /* Vector 28: DMA channel 12 transfer complete */
- .word kinetis_dmach13 /* Vector 29: DMA channel 13 transfer complete */
- .word kinetis_dmach14 /* Vector 30: DMA channel 14 transfer complete */
- .word kinetis_dmach15 /* Vector 31: DMA channel 15 transfer complete */
- .word kinetis_dmaerr /* Vector 32: DMA error interrupt channels 0-15 */
- .word kinetis_mcm /* Vector 33: MCM Normal interrupt */
- .word kinetis_flashcc /* Vector 34: Flash memory command complete */
- .word kinetis_flashrc /* Vector 35: Flash memory read collision */
- .word kinetis_smclvd /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- .word kinetis_llwu /* Vector 37: LLWU Normal Low Leakage Wakeup */
- .word kinetis_wdog /* Vector 38: Watchdog */
- .word kinetis_rngb /* Vector 39: Random number generator */
- .word kinetis_i2c0 /* Vector 40: I2C0 */
- .word kinetis_i2c1 /* Vector 41: I2C1 */
- .word kinetis_spi0 /* Vector 42: SPI0 all sources */
- .word kinetis_spi1 /* Vector 43: SPI1 all sources */
- .word kinetis_spi2 /* Vector 44: SPI2 all sources */
- .word kinetis_can0mb /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
- .word kinetis_can0bo /* Vector 46: CAN0 Bus Off */
- .word kinetis_can0err /* Vector 47: CAN0 Error */
- .word kinetis_can0tw /* Vector 48: CAN0 Transmit Warning */
- .word kinetis_can0rw /* Vector 49: CAN0 Receive Warning */
- .word kinetis_can0wu /* Vector 50: CAN0 Wake UP */
- .word kinetis_reserved /* Vector 51: Reserved */
- .word kinetis_reserved /* Vector 52: Reserved */
- .word kinetis_can1mb /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
- .word kinetis_can1bo /* Vector 54: CAN1 Bus Off */
- .word kinetis_can1err /* Vector 55: CAN1 Error */
- .word kinetis_can1tw /* Vector 56: CAN1 Transmit Warning */
- .word kinetis_can1rw /* Vector 57: CAN1 Receive Warning */
- .word kinetis_can1wu /* Vector 58: CAN1 Wake UP */
- .word kinetis_reserved /* Vector 59: Reserved */
- .word kinetis_reserved /* Vector 60: Reserved */
- .word kinetis_uart0s /* Vector 61: UART0 status */
- .word kinetis_uart0e /* Vector 62: UART0 error */
- .word kinetis_uart1s /* Vector 63: UART1 status */
- .word kinetis_uart1e /* Vector 64: UART1 error */
- .word kinetis_uart2s /* Vector 65: UART2 status */
- .word kinetis_uart2e /* Vector 66: UART2 error */
- .word kinetis_uart3s /* Vector 67: UART3 status */
- .word kinetis_uart3e /* Vector 68: UART3 error */
- .word kinetis_uart4s /* Vector 69: UART4 status */
- .word kinetis_uart4e /* Vector 70: UART4 error */
- .word kinetis_uart5s /* Vector 71: UART5 status */
- .word kinetis_uart5e /* Vector 72: UART5 error */
- .word kinetis_adc0 /* Vector 73: ADC0 */
- .word kinetis_adc1 /* Vector 74: ADC1 */
- .word kinetis_cmp0 /* Vector 75: CMP0 */
- .word kinetis_cmp1 /* Vector 76: CMP1 */
- .word kinetis_cmp2 /* Vector 77: CMP2 */
- .word kinetis_ftm0 /* Vector 78: FTM0 all sources */
- .word kinetis_ftm1 /* Vector 79: FTM1 all sources */
- .word kinetis_ftm2 /* Vector 80: FTM2 all sources */
- .word kinetis_cmt /* Vector 81: CMT */
- .word kinetis_rtc /* Vector 82: RTC alarm interrupt */
- .word kinetis_reserved /* Vector 83: Reserved */
- .word kinetis_pitch0 /* Vector 84: PIT channel 0 */
- .word kinetis_pitch1 /* Vector 85: PIT channel 1 */
- .word kinetis_pitch2 /* Vector 86: PIT channel 2 */
- .word kinetis_pitch3 /* Vector 87: PIT channel 3 */
- .word kinetis_pdb /* Vector 88: PDB */
- .word kinetis_usbotg /* Vector 88: USB OTG */
- .word kinetis_usbcd /* Vector 90: USB charger detect */
- .word kinetis_emactmr /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
- .word kinetis_emactx /* Vector 92: Ethernet MAC transmit interrupt */
- .word kinetis_emacrx /* Vector 93: Ethernet MAC receive interrupt */
- .word kinetis_emacmisc /* Vector 94: Ethernet MAC error and misc interrupt */
- .word kinetis_i2s0 /* Vector 95: I2S0 */
- .word kinetis_sdhc /* Vector 96: SDHC */
- .word kinetis_dac0 /* Vector 97: DAC0 */
- .word kinetis_dac1 /* Vector 98: DAC1 */
- .word kinetis_tsi /* Vector 97: TSI all sources */
- .word kinetis_mcg /* Vector 100: MCG */
- .word kinetis_lpt /* Vector 101: Low power timer */
- .word kinetis_reserved /* Vector 102: Reserved */
- .word kinetis_porta /* Vector 103: Pin detect port A */
- .word kinetis_portb /* Vector 104: Pin detect port B */
- .word kinetis_portc /* Vector 105: Pin detect port C */
- .word kinetis_portd /* Vector 106: Pin detect port D */
- .word kinetis_porte /* Vector 107: Pin detect port E */
- .word kinetis_reserved /* Vector 108: Reserved */
- .word kinetis_reserved /* Vector 109: Reserved */
- .word kinetis_reserved /* Vector 110: Reserved */
- .word kinetis_reserved /* Vector 111: Reserved */
- .word kinetis_reserved /* Vector 112: Reserved */
- .word kinetis_reserved /* Vector 113: Reserved */
- .word kinetis_reserved /* Vector 114: Reserved */
- .word kinetis_reserved /* Vector 115: Reserved */
- .word kinetis_reserved /* Vector 116: Reserved */
- .word kinetis_reserved /* Vector 117: Reserved */
- .word kinetis_reserved /* Vector 118: Reserved */
- .word kinetis_reserved /* Vector 119: Reserved */
-
-/* K64 Family ***********************************************************************************
- *
- * The memory map for the following parts is defined in Freescale document
- * MK64FX512VLL12
- */
-
-#elif defined(KINETIS_K64)
-
- .word kinetis_dmach0 /* Vector 16: DMA channel 0 transfer complete */
- .word kinetis_dmach1 /* Vector 17: DMA channel 1 transfer complete */
- .word kinetis_dmach2 /* Vector 18: DMA channel 2 transfer complete */
- .word kinetis_dmach3 /* Vector 19: DMA channel 3 transfer complete */
- .word kinetis_dmach4 /* Vector 20: DMA channel 4 transfer complete */
- .word kinetis_dmach5 /* Vector 21: DMA channel 5 transfer complete */
- .word kinetis_dmach6 /* Vector 22: DMA channel 6 transfer complete */
- .word kinetis_dmach7 /* Vector 23: DMA channel 7 transfer complete */
- .word kinetis_dmach8 /* Vector 24: DMA channel 8 transfer complete */
- .word kinetis_dmach9 /* Vector 25: DMA channel 9 transfer complete */
- .word kinetis_dmach10 /* Vector 26: DMA channel 10 transfer complete */
- .word kinetis_dmach11 /* Vector 27: DMA channel 11 transfer complete */
- .word kinetis_dmach12 /* Vector 28: DMA channel 12 transfer complete */
- .word kinetis_dmach13 /* Vector 29: DMA channel 13 transfer complete */
- .word kinetis_dmach14 /* Vector 30: DMA channel 14 transfer complete */
- .word kinetis_dmach15 /* Vector 31: DMA channel 15 transfer complete */
- .word kinetis_dmaerr /* Vector 32: DMA error interrupt channels 0-15 */
- .word kinetis_mcm /* Vector 33: MCM Normal interrupt */
- .word kinetis_flashcc /* Vector 34: Flash memory command complete */
- .word kinetis_flashrc /* Vector 35: Flash memory read collision */
- .word kinetis_smclvd /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- .word kinetis_llwu /* Vector 37: LLWU Normal Low Leakage Wakeup */
- .word kinetis_wdog /* Vector 38: Watchdog */
- .word kinetis_rngb /* Vector 39: Random number generator */
- .word kinetis_i2c0 /* Vector 40: I2C0 */
- .word kinetis_i2c1 /* Vector 41: I2C1 */
- .word kinetis_spi0 /* Vector 42: SPI0 all sources */
- .word kinetis_spi1 /* Vector 43: SPI1 all sources */
- .word kinetis_i2s0 /* Vector 44: Transmit */
- .word kinetis_i2s1 /* Vector 45: Transmit */
- .word kinetis_reserved /* Vector 46: Reserved */
- .word kinetis_uart0s /* Vector 47: UART0 status */
- .word kinetis_uart0e /* Vector 48: UART0 error */
- .word kinetis_uart1s /* Vector 49: UART1 status */
- .word kinetis_uart1e /* Vector 50: UART1 error */
- .word kinetis_uart2s /* Vector 51: UART2 status */
- .word kinetis_uart2e /* Vector 52: UART2 error */
- .word kinetis_uart3s /* Vector 53: UART3 status */
- .word kinetis_uart3e /* Vector 54: UART3 error */
- .word kinetis_adc0 /* Vector 55: ADC0 */
- .word kinetis_cmp0 /* Vector 56: CMP0 */
- .word kinetis_cmp1 /* Vector 57: CMP1 */
- .word kinetis_ftm0 /* Vector 58: FTM0 all sources */
- .word kinetis_ftm1 /* Vector 59: FTM1 all sources */
- .word kinetis_ftm2 /* Vector 60: FTM2 all sources */
- .word kinetis_cmt /* Vector 61: CMT */
- .word kinetis_rtc0 /* Vector 62: RTC alarm interrupt */
- .word kinetis_rtc1 /* Vector 63: RTC seconds interrupt */
- .word kinetis_pitch0 /* Vector 64: PIT channel 0 */
- .word kinetis_pitch1 /* Vector 65: PIT channel 1 */
- .word kinetis_pitch2 /* Vector 66: PIT channel 2 */
- .word kinetis_pitch3 /* Vector 67: PIT channel 3 */
- .word kinetis_pdb /* Vector 68: PDB */
- .word kinetis_usbotg /* Vector 68: USB OTG */
- .word kinetis_usbcd /* Vector 70: USB charger detect */
- .word kinetis_reserved /* Vector 71: Reserved */
- .word kinetis_dac0 /* Vector 72: DAC0 */
- .word kinetis_mcg /* Vector 73: MCG */
- .word kinetis_lpt /* Vector 74: Low power timer */
- .word kinetis_porta /* Vector 75: Pin detect port A */
- .word kinetis_portb /* Vector 76: Pin detect port B */
- .word kinetis_portc /* Vector 77: Pin detect port C */
- .word kinetis_portd /* Vector 78: Pin detect port D */
- .word kinetis_porte /* Vector 79: Pin detect port E */
- .word kinetis_software /* Vector 80: Software interrupt */
- .word kinetis_spi2 /* Vector 81: SPI2 all sources */
- .word kinetis_uart4s /* Vector 82: UART4 status */
- .word kinetis_uart4e /* Vector 83: UART4 error */
- .word kinetis_uart5s /* Vector 84: UART5 status */
- .word kinetis_uart5e /* Vector 85: UART5 error */
- .word kinetis_cmp2 /* Vector 86: CMP2 */
- .word kinetis_ftm3 /* Vector 87: FTM3 all sources */
- .word kinetis_dac1 /* Vector 88: DAC1 */
- .word kinetis_adc1 /* Vector 89: ADC1 */
- .word kinetis_i2c2 /* Vector 90: I2C2 */
- .word kinetis_can0mb /* Vector 91: CAN0 ORed Message buffer (0-15) */
- .word kinetis_can0bo /* Vector 92: CAN0 Bus Off */
- .word kinetis_can0err /* Vector 93: CAN0 Error */
- .word kinetis_can0tw /* Vector 94: CAN0 Transmit Warning */
- .word kinetis_can0rw /* Vector 95: CAN0 Receive Warning */
- .word kinetis_can0wu /* Vector 96: CAN0 Wake UP */
- .word kinetis_sdhc /* Vector 97: SDHC */
- .word kinetis_emactmr /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
- .word kinetis_emactx /* Vector 92: Ethernet MAC transmit interrupt */
- .word kinetis_emacrx /* Vector 93: Ethernet MAC receive interrupt */
- .word kinetis_emacmisc /* Vector 94: Ethernet MAC error and misc interrupt */
-
+/* External Interrupts */
+
+#if !defined(CONFIG_KINETIS_NOEXT_VECTORS)
+#undef VECTOR
+#define VECTOR(l,i) .word l
+
+#undef UNUSED
+#define UNUSED(i) .word kinetis_reserved
+
+#if defined(CONFIG_ARCH_FAMILY_K20)
+# include "chip/kinetis_k20vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K40)
+# include "chip/kinetis_k40vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K60)
+# include "chip/kinetis_k60vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K64)
+# include "chip/kinetis_k64vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K66)
+# include "chip/kinetis_k66vectors.h"
#else
-# error "No vectors for this Kinetis part"
+# error "No vectors for Kinetis K chip"
#endif
+#endif /* CONFIG_KINETIS_NOEXT_VECTORS */
+ .size _vectors, .-_vectors
-/************************************************************************************************
+/************************************************************************************
* .text
- ************************************************************************************************/
-
+ ************************************************************************************/
.text
.type handlers, function
.thumb_func
handlers:
-
-/* Processor Exceptions *************************************************************************/
-
HANDLER kinetis_reserved, KINETIS_IRQ_RESERVED /* Unexpected/reserved vector */
HANDLER kinetis_nmi, KINETIS_IRQ_NMI /* Vector 2: Non-Maskable Interrupt (NMI) */
HANDLER kinetis_hardfault, KINETIS_IRQ_HARDFAULT /* Vector 3: Hard fault */
@@ -596,365 +199,30 @@ handlers:
HANDLER kinetis_pendsv, KINETIS_IRQ_PENDSV /* Vector 14: Penable system service request */
HANDLER kinetis_systick, KINETIS_IRQ_SYSTICK /* Vector 15: System tick */
-/* External Interrupts **************************************************************************/
-/* K20 Family ***********************************************************************************
- *
- * The interrupt vectors for the following parts is defined in Freescale document
- * K20P64M72SF1RM
- */
-
-#if defined(KINETIS_K20)
-
- HANDLER kinetis_dmach0, KINETIS_IRQ_DMACH0 /* Vector 16: DMA channel 0 transfer complete */
- HANDLER kinetis_dmach1, KINETIS_IRQ_DMACH1 /* Vector 17: DMA channel 1 transfer complete */
- HANDLER kinetis_dmach2, KINETIS_IRQ_DMACH2 /* Vector 18: DMA channel 2 transfer complete */
- HANDLER kinetis_dmach3, KINETIS_IRQ_DMACH3 /* Vector 19: DMA channel 3 transfer complete */
- HANDLER kinetis_dmach4, KINETIS_IRQ_DMACH4 /* Vector 20: DMA channel 4 transfer complete */
- HANDLER kinetis_dmach5, KINETIS_IRQ_DMACH5 /* Vector 21: DMA channel 5 transfer complete */
- HANDLER kinetis_dmach6, KINETIS_IRQ_DMACH6 /* Vector 22: DMA channel 6 transfer complete */
- HANDLER kinetis_dmach7, KINETIS_IRQ_DMACH7 /* Vector 23: DMA channel 7 transfer complete */
- HANDLER kinetis_dmach8, KINETIS_IRQ_DMACH8 /* Vector 24: DMA channel 8 transfer complete */
- HANDLER kinetis_dmach9, KINETIS_IRQ_DMACH9 /* Vector 25: DMA channel 9 transfer complete */
- HANDLER kinetis_dmach10, KINETIS_IRQ_DMACH10 /* Vector 26: DMA channel 10 transfer complete */
- HANDLER kinetis_dmach11, KINETIS_IRQ_DMACH11 /* Vector 27: DMA channel 11 transfer complete */
- HANDLER kinetis_dmach12, KINETIS_IRQ_DMACH12 /* Vector 28: DMA channel 12 transfer complete */
- HANDLER kinetis_dmach13, KINETIS_IRQ_DMACH13 /* Vector 29: DMA channel 13 transfer complete */
- HANDLER kinetis_dmach14, KINETIS_IRQ_DMACH14 /* Vector 30: DMA channel 14 transfer complete */
- HANDLER kinetis_dmach15, KINETIS_IRQ_DMACH15 /* Vector 31: DMA channel 15 transfer complete */
- HANDLER kinetis_dmaerr, KINETIS_IRQ_DMAERR /* Vector 32: DMA error interrupt channels 0-15 */
- HANDLER kinetis_flashcc, KINETIS_IRQ_FLASHCC /* Vector 34: Flash memory command complete */
- HANDLER kinetis_flashrc, KINETIS_IRQ_FLASHRC /* Vector 35: Flash memory read collision */
- HANDLER kinetis_smclvd, KINETIS_IRQ_SMCLVD /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- HANDLER kinetis_llwu, KINETIS_IRQ_LLWU /* Vector 37: LLWU Normal Low Leakage Wakeup */
- HANDLER kinetis_wdog, KINETIS_IRQ_WDOG /* Vector 38: Watchdog */
- HANDLER kinetis_i2c0, KINETIS_IRQ_I2C0 /* Vector 40: I2C0 */
- HANDLER kinetis_i2c1, KINETIS_IRQ_I2C1 /* Vector 41: I2C1 */
- HANDLER kinetis_spi0, KINETIS_IRQ_SPI0 /* Vector 42: SPI0 all sources */
- HANDLER kinetis_spi1, KINETIS_IRQ_SPI1 /* Vector 43: SPI1 all sources */
- HANDLER kinetis_can0mb, KINETIS_IRQ_CAN0MB /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
- HANDLER kinetis_can0bo, KINETIS_IRQ_CAN0BO /* Vector 46: CAN0 Bus Off */
- HANDLER kinetis_can0err, KINETIS_IRQ_CAN0ERR /* Vector 47: CAN0 Error */
- HANDLER kinetis_can0tw, KINETIS_IRQ_CAN0TW /* Vector 48: CAN0 Transmit Warning */
- HANDLER kinetis_can0rw, KINETIS_IRQ_CAN0RW /* Vector 49: CAN0 Receive Warning */
- HANDLER kinetis_can0wu, KINETIS_IRQ_CAN0WU /* Vector 50: CAN0 Wake UP */
- HANDLER kinetis_uart0s, KINETIS_IRQ_UART0S /* Vector 61: UART0 status */
- HANDLER kinetis_uart0e, KINETIS_IRQ_UART0E /* Vector 62: UART0 error */
- HANDLER kinetis_uart1s, KINETIS_IRQ_UART1S /* Vector 63: UART1 status */
- HANDLER kinetis_uart1e, KINETIS_IRQ_UART1E /* Vector 64: UART1 error */
- HANDLER kinetis_uart2s, KINETIS_IRQ_UART2S /* Vector 65: UART2 status */
- HANDLER kinetis_uart2e, KINETIS_IRQ_UART2E /* Vector 66: UART2 error */
- HANDLER kinetis_adc0, KINETIS_IRQ_ADC0 /* Vector 73: ADC0 */
- HANDLER kinetis_adc1, KINETIS_IRQ_ADC1 /* Vector 74: ADC1 */
- HANDLER kinetis_cmp0, KINETIS_IRQ_CMP0 /* Vector 75: CMP0 */
- HANDLER kinetis_cmp1, KINETIS_IRQ_CMP1 /* Vector 76: CMP1 */
- HANDLER kinetis_cmp2, KINETIS_IRQ_CMP2 /* Vector 77: CMP2 */
- HANDLER kinetis_ftm0, KINETIS_IRQ_FTM0 /* Vector 78: FTM0 all sources */
- HANDLER kinetis_ftm1, KINETIS_IRQ_FTM1 /* Vector 79: FTM1 all sources */
- HANDLER kinetis_ftm2, KINETIS_IRQ_FTM2 /* Vector 80: FTM2 all sources */
- HANDLER kinetis_cmt, KINETIS_IRQ_CMT /* Vector 81: CMT */
- HANDLER kinetis_rtc, KINETIS_IRQ_RTC /* Vector 82: RTC alarm interrupt */
- HANDLER kinetis_pitch0, KINETIS_IRQ_PITCH0 /* Vector 84: PIT channel 0 */
- HANDLER kinetis_pitch1, KINETIS_IRQ_PITCH1 /* Vector 85: PIT channel 1 */
- HANDLER kinetis_pitch2, KINETIS_IRQ_PITCH2 /* Vector 86: PIT channel 2 */
- HANDLER kinetis_pitch3, KINETIS_IRQ_PITCH3 /* Vector 87: PIT channel 3 */
- HANDLER kinetis_pdb, KINETIS_IRQ_PDB /* Vector 88: PDB */
- HANDLER kinetis_usbotg, KINETIS_IRQ_USBOTG /* Vector 88: USB OTG */
- HANDLER kinetis_usbcd, KINETIS_IRQ_USBCD /* Vector 90: USB charger detect */
- HANDLER kinetis_dac0, KINETIS_IRQ_DAC0 /* Vector 97: DAC0 */
- HANDLER kinetis_tsi, KINETIS_IRQ_TSI /* Vector 97: TSI all sources */
- HANDLER kinetis_mcg, KINETIS_IRQ_MCG /* Vector 100: MCG */
- HANDLER kinetis_lpt, KINETIS_IRQ_LPT /* Vector 101: Low power timer */
- HANDLER kinetis_porta, KINETIS_IRQ_PORTA /* Vector 103: Pin detect port A */
- HANDLER kinetis_portb, KINETIS_IRQ_PORTB /* Vector 104: Pin detect port B */
- HANDLER kinetis_portc, KINETIS_IRQ_PORTC /* Vector 105: Pin detect port C */
- HANDLER kinetis_portd, KINETIS_IRQ_PORTD /* Vector 106: Pin detect port D */
- HANDLER kinetis_porte, KINETIS_IRQ_PORTE /* Vector 107: Pin detect port E */
- HANDLER kinetis_swi, KINETIS_IRQ_SWI /* Vector 110: Software interrupt */
-
-/* K40 Family ***********************************************************************************
- *
- * The interrupt vectors for the following parts is defined in Freescale document
- * K40P144M100SF2RM
- */
-
-#elif defined(KINETIS_K40)
-
- HANDLER kinetis_dmach0, KINETIS_IRQ_DMACH0 /* Vector 16: DMA channel 0 transfer complete */
- HANDLER kinetis_dmach1, KINETIS_IRQ_DMACH1 /* Vector 17: DMA channel 1 transfer complete */
- HANDLER kinetis_dmach2, KINETIS_IRQ_DMACH2 /* Vector 18: DMA channel 2 transfer complete */
- HANDLER kinetis_dmach3, KINETIS_IRQ_DMACH3 /* Vector 19: DMA channel 3 transfer complete */
- HANDLER kinetis_dmach4, KINETIS_IRQ_DMACH4 /* Vector 20: DMA channel 4 transfer complete */
- HANDLER kinetis_dmach5, KINETIS_IRQ_DMACH5 /* Vector 21: DMA channel 5 transfer complete */
- HANDLER kinetis_dmach6, KINETIS_IRQ_DMACH6 /* Vector 22: DMA channel 6 transfer complete */
- HANDLER kinetis_dmach7, KINETIS_IRQ_DMACH7 /* Vector 23: DMA channel 7 transfer complete */
- HANDLER kinetis_dmach8, KINETIS_IRQ_DMACH8 /* Vector 24: DMA channel 8 transfer complete */
- HANDLER kinetis_dmach9, KINETIS_IRQ_DMACH9 /* Vector 25: DMA channel 9 transfer complete */
- HANDLER kinetis_dmach10, KINETIS_IRQ_DMACH10 /* Vector 26: DMA channel 10 transfer complete */
- HANDLER kinetis_dmach11, KINETIS_IRQ_DMACH11 /* Vector 27: DMA channel 11 transfer complete */
- HANDLER kinetis_dmach12, KINETIS_IRQ_DMACH12 /* Vector 28: DMA channel 12 transfer complete */
- HANDLER kinetis_dmach13, KINETIS_IRQ_DMACH13 /* Vector 29: DMA channel 13 transfer complete */
- HANDLER kinetis_dmach14, KINETIS_IRQ_DMACH14 /* Vector 30: DMA channel 14 transfer complete */
- HANDLER kinetis_dmach15, KINETIS_IRQ_DMACH15 /* Vector 31: DMA channel 15 transfer complete */
- HANDLER kinetis_dmaerr, KINETIS_IRQ_DMAERR /* Vector 32: DMA error interrupt channels 0-15 */
- HANDLER kinetis_mcm, KINETIS_IRQ_MCM /* Vector 33: MCM Normal interrupt */
- HANDLER kinetis_flashcc, KINETIS_IRQ_FLASHCC /* Vector 34: Flash memory command complete */
- HANDLER kinetis_flashrc, KINETIS_IRQ_FLASHRC /* Vector 35: Flash memory read collision */
- HANDLER kinetis_smclvd, KINETIS_IRQ_SMCLVD /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- HANDLER kinetis_llwu, KINETIS_IRQ_LLWU /* Vector 37: LLWU Normal Low Leakage Wakeup */
- HANDLER kinetis_wdog, KINETIS_IRQ_WDOG /* Vector 38: Watchdog */
- HANDLER kinetis_i2c0, KINETIS_IRQ_I2C0 /* Vector 40: I2C0 */
- HANDLER kinetis_i2c1, KINETIS_IRQ_I2C1 /* Vector 41: I2C1 */
- HANDLER kinetis_spi0, KINETIS_IRQ_SPI0 /* Vector 42: SPI0 all sources */
- HANDLER kinetis_spi1, KINETIS_IRQ_SPI1 /* Vector 43: SPI1 all sources */
- HANDLER kinetis_spi2, KINETIS_IRQ_SPI2 /* Vector 44: SPI2 all sources */
- HANDLER kinetis_can0mb, KINETIS_IRQ_CAN0MB /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
- HANDLER kinetis_can0bo, KINETIS_IRQ_CAN0BO /* Vector 46: CAN0 Bus Off */
- HANDLER kinetis_can0err, KINETIS_IRQ_CAN0ERR /* Vector 47: CAN0 Error */
- HANDLER kinetis_can0tw, KINETIS_IRQ_CAN0TW /* Vector 48: CAN0 Transmit Warning */
- HANDLER kinetis_can0rw, KINETIS_IRQ_CAN0RW /* Vector 49: CAN0 Receive Warning */
- HANDLER kinetis_can0wu, KINETIS_IRQ_CAN0WU /* Vector 50: CAN0 Wake UP */
- HANDLER kinetis_can1mb, KINETIS_IRQ_CAN1MB /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
- HANDLER kinetis_can1bo, KINETIS_IRQ_CAN1BO /* Vector 54: CAN1 Bus Off */
- HANDLER kinetis_can1err, KINETIS_IRQ_CAN1ERR /* Vector 55: CAN1 Error */
- HANDLER kinetis_can1tw, KINETIS_IRQ_CAN1TW /* Vector 56: CAN1 Transmit Warning */
- HANDLER kinetis_can1rw, KINETIS_IRQ_CAN1RW /* Vector 57: CAN1 Receive Warning */
- HANDLER kinetis_can1wu, KINETIS_IRQ_CAN1WU /* Vector 58: CAN1 Wake UP */
- HANDLER kinetis_uart0s, KINETIS_IRQ_UART0S /* Vector 61: UART0 status */
- HANDLER kinetis_uart0e, KINETIS_IRQ_UART0E /* Vector 62: UART0 error */
- HANDLER kinetis_uart1s, KINETIS_IRQ_UART1S /* Vector 63: UART1 status */
- HANDLER kinetis_uart1e, KINETIS_IRQ_UART1E /* Vector 64: UART1 error */
- HANDLER kinetis_uart2s, KINETIS_IRQ_UART2S /* Vector 65: UART2 status */
- HANDLER kinetis_uart2e, KINETIS_IRQ_UART2E /* Vector 66: UART2 error */
- HANDLER kinetis_uart3s, KINETIS_IRQ_UART3S /* Vector 67: UART3 status */
- HANDLER kinetis_uart3e, KINETIS_IRQ_UART3E /* Vector 68: UART3 error */
- HANDLER kinetis_uart4s, KINETIS_IRQ_UART4S /* Vector 69: UART4 status */
- HANDLER kinetis_uart4e, KINETIS_IRQ_UART4E /* Vector 70: UART4 error */
- HANDLER kinetis_uart5s, KINETIS_IRQ_UART5S /* Vector 71: UART5 status */
- HANDLER kinetis_uart5e, KINETIS_IRQ_UART5E /* Vector 72: UART5 error */
- HANDLER kinetis_adc0, KINETIS_IRQ_ADC0 /* Vector 73: ADC0 */
- HANDLER kinetis_adc1, KINETIS_IRQ_ADC1 /* Vector 74: ADC1 */
- HANDLER kinetis_cmp0, KINETIS_IRQ_CMP0 /* Vector 75: CMP0 */
- HANDLER kinetis_cmp1, KINETIS_IRQ_CMP1 /* Vector 76: CMP1 */
- HANDLER kinetis_cmp2, KINETIS_IRQ_CMP2 /* Vector 77: CMP2 */
- HANDLER kinetis_ftm0, KINETIS_IRQ_FTM0 /* Vector 78: FTM0 all sources */
- HANDLER kinetis_ftm1, KINETIS_IRQ_FTM1 /* Vector 79: FTM1 all sources */
- HANDLER kinetis_ftm2, KINETIS_IRQ_FTM2 /* Vector 80: FTM2 all sources */
- HANDLER kinetis_cmt, KINETIS_IRQ_CMT /* Vector 81: CMT */
- HANDLER kinetis_rtc, KINETIS_IRQ_RTC /* Vector 82: RTC alarm interrupt */
- HANDLER kinetis_pitch0, KINETIS_IRQ_PITCH0 /* Vector 84: PIT channel 0 */
- HANDLER kinetis_pitch1, KINETIS_IRQ_PITCH1 /* Vector 85: PIT channel 1 */
- HANDLER kinetis_pitch2, KINETIS_IRQ_PITCH2 /* Vector 86: PIT channel 2 */
- HANDLER kinetis_pitch3, KINETIS_IRQ_PITCH3 /* Vector 87: PIT channel 3 */
- HANDLER kinetis_pdb, KINETIS_IRQ_PDB /* Vector 88: PDB */
- HANDLER kinetis_usbotg, KINETIS_IRQ_USBOTG /* Vector 88: USB OTG */
- HANDLER kinetis_usbcd, KINETIS_IRQ_USBCD /* Vector 90: USB charger detect */
- HANDLER kinetis_i2s0, KINETIS_IRQ_I2S0 /* Vector 95: I2S0 */
- HANDLER kinetis_sdhc, KINETIS_IRQ_SDHC /* Vector 96: SDHC */
- HANDLER kinetis_dac0, KINETIS_IRQ_DAC0 /* Vector 97: DAC0 */
- HANDLER kinetis_dac1, KINETIS_IRQ_DAC1 /* Vector 98: DAC1 */
- HANDLER kinetis_tsi, KINETIS_IRQ_TSI /* Vector 97: TSI all sources */
- HANDLER kinetis_mcg, KINETIS_IRQ_MCG /* Vector 100: MCG */
- HANDLER kinetis_lpt, KINETIS_IRQ_LPT /* Vector 101: Low power timer */
- HANDLER kinetis_slcd, KINETIS_IRQ_SLCD /* Vector 102: Segment LCD all sources */
- HANDLER kinetis_porta, KINETIS_IRQ_PORTA /* Vector 103: Pin detect port A */
- HANDLER kinetis_portb, KINETIS_IRQ_PORTB /* Vector 104: Pin detect port B */
- HANDLER kinetis_portc, KINETIS_IRQ_PORTC /* Vector 105: Pin detect port C */
- HANDLER kinetis_portd, KINETIS_IRQ_PORTD /* Vector 106: Pin detect port D */
- HANDLER kinetis_porte, KINETIS_IRQ_PORTE /* Vector 107: Pin detect port E */
- HANDLER kinetis_swi, KINETIS_IRQ_SWI /* Vector 110: Software interrupt */
-
-/* K60 Family ***********************************************************************************
- *
- * The memory map for the following parts is defined in Freescale document
- * K60P144M100SF2RM
- */
+#if !defined(CONFIG_KINETIS_NOEXT_VECTORS)
-#elif defined(KINETIS_K60)
-
- HANDLER kinetis_dmach0, KINETIS_IRQ_DMACH0 /* Vector 16: DMA channel 0 transfer complete */
- HANDLER kinetis_dmach1, KINETIS_IRQ_DMACH1 /* Vector 17: DMA channel 1 transfer complete */
- HANDLER kinetis_dmach2, KINETIS_IRQ_DMACH2 /* Vector 18: DMA channel 2 transfer complete */
- HANDLER kinetis_dmach3, KINETIS_IRQ_DMACH3 /* Vector 19: DMA channel 3 transfer complete */
- HANDLER kinetis_dmach4, KINETIS_IRQ_DMACH4 /* Vector 20: DMA channel 4 transfer complete */
- HANDLER kinetis_dmach5, KINETIS_IRQ_DMACH5 /* Vector 21: DMA channel 5 transfer complete */
- HANDLER kinetis_dmach6, KINETIS_IRQ_DMACH6 /* Vector 22: DMA channel 6 transfer complete */
- HANDLER kinetis_dmach7, KINETIS_IRQ_DMACH7 /* Vector 23: DMA channel 7 transfer complete */
- HANDLER kinetis_dmach8, KINETIS_IRQ_DMACH8 /* Vector 24: DMA channel 8 transfer complete */
- HANDLER kinetis_dmach9, KINETIS_IRQ_DMACH9 /* Vector 25: DMA channel 9 transfer complete */
- HANDLER kinetis_dmach10, KINETIS_IRQ_DMACH10 /* Vector 26: DMA channel 10 transfer complete */
- HANDLER kinetis_dmach11, KINETIS_IRQ_DMACH11 /* Vector 27: DMA channel 11 transfer complete */
- HANDLER kinetis_dmach12, KINETIS_IRQ_DMACH12 /* Vector 28: DMA channel 12 transfer complete */
- HANDLER kinetis_dmach13, KINETIS_IRQ_DMACH13 /* Vector 29: DMA channel 13 transfer complete */
- HANDLER kinetis_dmach14, KINETIS_IRQ_DMACH14 /* Vector 30: DMA channel 14 transfer complete */
- HANDLER kinetis_dmach15, KINETIS_IRQ_DMACH15 /* Vector 31: DMA channel 15 transfer complete */
- HANDLER kinetis_dmaerr, KINETIS_IRQ_DMAERR /* Vector 32: DMA error interrupt channels 0-15 */
- HANDLER kinetis_mcm, KINETIS_IRQ_MCM /* Vector 33: MCM Normal interrupt */
- HANDLER kinetis_flashcc, KINETIS_IRQ_FLASHCC /* Vector 34: Flash memory command complete */
- HANDLER kinetis_flashrc, KINETIS_IRQ_FLASHRC /* Vector 35: Flash memory read collision */
- HANDLER kinetis_smclvd, KINETIS_IRQ_SMCLVD /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- HANDLER kinetis_llwu, KINETIS_IRQ_LLWU /* Vector 37: LLWU Normal Low Leakage Wakeup */
- HANDLER kinetis_wdog, KINETIS_IRQ_WDOG /* Vector 38: Watchdog */
- HANDLER kinetis_rngb, KINETIS_IRQ_RNGB /* Vector 39: Random number generator */
- HANDLER kinetis_i2c0, KINETIS_IRQ_I2C0 /* Vector 40: I2C0 */
- HANDLER kinetis_i2c1, KINETIS_IRQ_I2C1 /* Vector 41: I2C1 */
- HANDLER kinetis_spi0, KINETIS_IRQ_SPI0 /* Vector 42: SPI0 all sources */
- HANDLER kinetis_spi1, KINETIS_IRQ_SPI1 /* Vector 43: SPI1 all sources */
- HANDLER kinetis_spi2, KINETIS_IRQ_SPI2 /* Vector 44: SPI2 all sources */
- HANDLER kinetis_can0mb, KINETIS_IRQ_CAN0MB /* Vector 45: CAN0 OR'ed Message buffer (0-15) */
- HANDLER kinetis_can0bo, KINETIS_IRQ_CAN0BO /* Vector 46: CAN0 Bus Off */
- HANDLER kinetis_can0err, KINETIS_IRQ_CAN0ERR /* Vector 47: CAN0 Error */
- HANDLER kinetis_can0tw, KINETIS_IRQ_CAN0TW /* Vector 48: CAN0 Transmit Warning */
- HANDLER kinetis_can0rw, KINETIS_IRQ_CAN0RW /* Vector 49: CAN0 Receive Warning */
- HANDLER kinetis_can0wu, KINETIS_IRQ_CAN0WU /* Vector 50: CAN0 Wake UP */
- HANDLER kinetis_can1mb, KINETIS_IRQ_CAN1MB /* Vector 53: CAN1 OR'ed Message buffer (0-15) */
- HANDLER kinetis_can1bo, KINETIS_IRQ_CAN1BO /* Vector 54: CAN1 Bus Off */
- HANDLER kinetis_can1err, KINETIS_IRQ_CAN1ERR /* Vector 55: CAN1 Error */
- HANDLER kinetis_can1tw, KINETIS_IRQ_CAN1TW /* Vector 56: CAN1 Transmit Warning */
- HANDLER kinetis_can1rw, KINETIS_IRQ_CAN1RW /* Vector 57: CAN1 Receive Warning */
- HANDLER kinetis_can1wu, KINETIS_IRQ_CAN1WU /* Vector 58: CAN1 Wake UP */
- HANDLER kinetis_uart0s, KINETIS_IRQ_UART0S /* Vector 61: UART0 status */
- HANDLER kinetis_uart0e, KINETIS_IRQ_UART0E /* Vector 62: UART0 error */
- HANDLER kinetis_uart1s, KINETIS_IRQ_UART1S /* Vector 63: UART1 status */
- HANDLER kinetis_uart1e, KINETIS_IRQ_UART1E /* Vector 64: UART1 error */
- HANDLER kinetis_uart2s, KINETIS_IRQ_UART2S /* Vector 65: UART2 status */
- HANDLER kinetis_uart2e, KINETIS_IRQ_UART2E /* Vector 66: UART2 error */
- HANDLER kinetis_uart3s, KINETIS_IRQ_UART3S /* Vector 67: UART3 status */
- HANDLER kinetis_uart3e, KINETIS_IRQ_UART3E /* Vector 68: UART3 error */
- HANDLER kinetis_uart4s, KINETIS_IRQ_UART4S /* Vector 69: UART4 status */
- HANDLER kinetis_uart4e, KINETIS_IRQ_UART4E /* Vector 70: UART4 error */
- HANDLER kinetis_uart5s, KINETIS_IRQ_UART5S /* Vector 71: UART5 status */
- HANDLER kinetis_uart5e, KINETIS_IRQ_UART5E /* Vector 72: UART5 error */
- HANDLER kinetis_adc0, KINETIS_IRQ_ADC0 /* Vector 73: ADC0 */
- HANDLER kinetis_adc1, KINETIS_IRQ_ADC1 /* Vector 74: ADC1 */
- HANDLER kinetis_cmp0, KINETIS_IRQ_CMP0 /* Vector 75: CMP0 */
- HANDLER kinetis_cmp1, KINETIS_IRQ_CMP1 /* Vector 76: CMP1 */
- HANDLER kinetis_cmp2, KINETIS_IRQ_CMP2 /* Vector 77: CMP2 */
- HANDLER kinetis_ftm0, KINETIS_IRQ_FTM0 /* Vector 78: FTM0 all sources */
- HANDLER kinetis_ftm1, KINETIS_IRQ_FTM1 /* Vector 79: FTM1 all sources */
- HANDLER kinetis_ftm2, KINETIS_IRQ_FTM2 /* Vector 80: FTM2 all sources */
- HANDLER kinetis_cmt, KINETIS_IRQ_CMT /* Vector 81: CMT */
- HANDLER kinetis_rtc, KINETIS_IRQ_RTC /* Vector 82: RTC alarm interrupt */
- HANDLER kinetis_pitch0, KINETIS_IRQ_PITCH0 /* Vector 84: PIT channel 0 */
- HANDLER kinetis_pitch1, KINETIS_IRQ_PITCH1 /* Vector 85: PIT channel 1 */
- HANDLER kinetis_pitch2, KINETIS_IRQ_PITCH2 /* Vector 86: PIT channel 2 */
- HANDLER kinetis_pitch3, KINETIS_IRQ_PITCH3 /* Vector 87: PIT channel 3 */
- HANDLER kinetis_pdb, KINETIS_IRQ_PDB /* Vector 88: PDB */
- HANDLER kinetis_usbotg, KINETIS_IRQ_USBOTG /* Vector 88: USB OTG */
- HANDLER kinetis_usbcd, KINETIS_IRQ_USBCD /* Vector 90: USB charger detect */
- HANDLER kinetis_emactmr, KINETIS_IRQ_EMACTMR /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
- HANDLER kinetis_emactx, KINETIS_IRQ_EMACTX /* Vector 92: Ethernet MAC transmit interrupt */
- HANDLER kinetis_emacrx, KINETIS_IRQ_EMACRX /* Vector 93: Ethernet MAC receive interrupt */
- HANDLER kinetis_emacmisc, KINETIS_IRQ_EMACMISC /* Vector 94: Ethernet MAC error and misc interrupt */
- HANDLER kinetis_i2s0, KINETIS_IRQ_I2S0 /* Vector 95: I2S0 */
- HANDLER kinetis_sdhc, KINETIS_IRQ_SDHC /* Vector 96: SDHC */
- HANDLER kinetis_dac0, KINETIS_IRQ_DAC0 /* Vector 97: DAC0 */
- HANDLER kinetis_dac1, KINETIS_IRQ_DAC1 /* Vector 98: DAC1 */
- HANDLER kinetis_tsi, KINETIS_IRQ_TSI /* Vector 97: TSI all sources */
- HANDLER kinetis_mcg, KINETIS_IRQ_MCG /* Vector 100: MCG */
- HANDLER kinetis_lpt, KINETIS_IRQ_LPT /* Vector 101: Low power timer */
- HANDLER kinetis_porta, KINETIS_IRQ_PORTA /* Vector 103: Pin detect port A */
- HANDLER kinetis_portb, KINETIS_IRQ_PORTB /* Vector 104: Pin detect port B */
- HANDLER kinetis_portc, KINETIS_IRQ_PORTC /* Vector 105: Pin detect port C */
- HANDLER kinetis_portd, KINETIS_IRQ_PORTD /* Vector 106: Pin detect port D */
- HANDLER kinetis_porte, KINETIS_IRQ_PORTE /* Vector 107: Pin detect port E */
-
-/* K64 Family ***********************************************************************************
- *
- * The memory map for the following parts is defined in Freescale document
- * MK64FX512VLL12
- */
+#undef VECTOR
+#define VECTOR(l,i) HANDLER l, i
-#elif defined(KINETIS_K64)
-
- HANDLER kinetis_dmach0, KINETIS_IRQ_DMACH0 /* Vector 16: DMA channel 0 transfer complete */
- HANDLER kinetis_dmach1, KINETIS_IRQ_DMACH1 /* Vector 17: DMA channel 1 transfer complete */
- HANDLER kinetis_dmach2, KINETIS_IRQ_DMACH2 /* Vector 18: DMA channel 2 transfer complete */
- HANDLER kinetis_dmach3, KINETIS_IRQ_DMACH3 /* Vector 19: DMA channel 3 transfer complete */
- HANDLER kinetis_dmach4, KINETIS_IRQ_DMACH4 /* Vector 20: DMA channel 4 transfer complete */
- HANDLER kinetis_dmach5, KINETIS_IRQ_DMACH5 /* Vector 21: DMA channel 5 transfer complete */
- HANDLER kinetis_dmach6, KINETIS_IRQ_DMACH6 /* Vector 22: DMA channel 6 transfer complete */
- HANDLER kinetis_dmach7, KINETIS_IRQ_DMACH7 /* Vector 23: DMA channel 7 transfer complete */
- HANDLER kinetis_dmach8, KINETIS_IRQ_DMACH8 /* Vector 24: DMA channel 8 transfer complete */
- HANDLER kinetis_dmach9, KINETIS_IRQ_DMACH9 /* Vector 25: DMA channel 9 transfer complete */
- HANDLER kinetis_dmach10, KINETIS_IRQ_DMACH10 /* Vector 26: DMA channel 10 transfer complete */
- HANDLER kinetis_dmach11, KINETIS_IRQ_DMACH11 /* Vector 27: DMA channel 11 transfer complete */
- HANDLER kinetis_dmach12, KINETIS_IRQ_DMACH12 /* Vector 28: DMA channel 12 transfer complete */
- HANDLER kinetis_dmach13, KINETIS_IRQ_DMACH13 /* Vector 29: DMA channel 13 transfer complete */
- HANDLER kinetis_dmach14, KINETIS_IRQ_DMACH14 /* Vector 30: DMA channel 14 transfer complete */
- HANDLER kinetis_dmach15, KINETIS_IRQ_DMACH15 /* Vector 31: DMA channel 15 transfer complete */
- HANDLER kinetis_dmaerr, KINETIS_IRQ_DMAERR /* Vector 32: DMA error interrupt channels 0-15 */
- HANDLER kinetis_mcm, KINETIS_IRQ_MCM /* Vector 33: MCM Normal interrupt */
- HANDLER kinetis_flashcc, KINETIS_IRQ_FLASHCC /* Vector 34: Flash memory command complete */
- HANDLER kinetis_flashrc, KINETIS_IRQ_FLASHRC /* Vector 35: Flash memory read collision */
- HANDLER kinetis_smclvd, KINETIS_IRQ_SMCLVD /* Vector 36: Mode Controller low-voltage detect, low-voltage warning */
- HANDLER kinetis_llwu, KINETIS_IRQ_LLWU /* Vector 37: LLWU Normal Low Leakage Wakeup */
- HANDLER kinetis_wdog, KINETIS_IRQ_WDOG /* Vector 38: Watchdog */
- HANDLER kinetis_rngb, KINETIS_IRQ_RNGB /* Vector 39: Random number generator */
- HANDLER kinetis_i2c0, KINETIS_IRQ_I2C0 /* Vector 40: I2C0 */
- HANDLER kinetis_i2c1, KINETIS_IRQ_I2C1 /* Vector 41: I2C1 */
- HANDLER kinetis_spi0, KINETIS_IRQ_SPI0 /* Vector 42: SPI0 all sources */
- HANDLER kinetis_spi1, KINETIS_IRQ_SPI1 /* Vector 43: SPI1 all sources */
- HANDLER kinetis_i2s0, KINETIS_IRQ_I2S0 /* Vector 44: Transmit */
- HANDLER kinetis_i2s1, KINETIS_IRQ_I2S1 /* Vector 45: Transmit */
- HANDLER kinetis_uart0s, KINETIS_IRQ_UART0S /* Vector 47: UART0 status */
- HANDLER kinetis_uart0e, KINETIS_IRQ_UART0E /* Vector 48: UART0 error */
- HANDLER kinetis_uart1s, KINETIS_IRQ_UART1S /* Vector 49: UART1 status */
- HANDLER kinetis_uart1e, KINETIS_IRQ_UART1E /* Vector 50: UART1 error */
- HANDLER kinetis_uart2s, KINETIS_IRQ_UART2S /* Vector 51: UART2 status */
- HANDLER kinetis_uart2e, KINETIS_IRQ_UART2E /* Vector 52: UART2 error */
- HANDLER kinetis_uart3s, KINETIS_IRQ_UART3S /* Vector 53: UART3 status */
- HANDLER kinetis_uart3e, KINETIS_IRQ_UART3E /* Vector 54: UART3 error */
- HANDLER kinetis_adc0, KINETIS_IRQ_ADC0 /* Vector 55: ADC0 */
- HANDLER kinetis_cmp0, KINETIS_IRQ_CMP0 /* Vector 56: CMP0 */
- HANDLER kinetis_cmp1, KINETIS_IRQ_CMP1 /* Vector 57: CMP1 */
- HANDLER kinetis_ftm0, KINETIS_IRQ_FTM0 /* Vector 58: FTM0 all sources */
- HANDLER kinetis_ftm1, KINETIS_IRQ_FTM1 /* Vector 59: FTM1 all sources */
- HANDLER kinetis_ftm2, KINETIS_IRQ_FTM2 /* Vector 60: FTM2 all sources */
- HANDLER kinetis_cmt, KINETIS_IRQ_CMT /* Vector 61: CMT */
- HANDLER kinetis_rtc0, KINETIS_IRQ_RTC0 /* Vector 62: RTC alarm interrupt */
- HANDLER kinetis_rtc1, KINETIS_IRQ_RTC1 /* Vector 63: RTC seconds interrupt */
- HANDLER kinetis_pitch0, KINETIS_IRQ_PITCH0 /* Vector 64: PIT channel 0 */
- HANDLER kinetis_pitch1, KINETIS_IRQ_PITCH1 /* Vector 65: PIT channel 1 */
- HANDLER kinetis_pitch2, KINETIS_IRQ_PITCH2 /* Vector 66: PIT channel 2 */
- HANDLER kinetis_pitch3, KINETIS_IRQ_PITCH3 /* Vector 67: PIT channel 3 */
- HANDLER kinetis_pdb, KINETIS_IRQ_PDB /* Vector 68: PDB */
- HANDLER kinetis_usbotg, KINETIS_IRQ_USBOTG /* Vector 68: USB OTG */
- HANDLER kinetis_usbcd, KINETIS_IRQ_USBCD /* Vector 70: USB charger detect */
- HANDLER kinetis_dac0, KINETIS_IRQ_DAC0 /* Vector 72: DAC0 */
- HANDLER kinetis_mcg, KINETIS_IRQ_MCG /* Vector 73: MCG */
- HANDLER kinetis_lpt, KINETIS_IRQ_LPT /* Vector 74: Low power timer */
- HANDLER kinetis_porta, KINETIS_IRQ_PORTA /* Vector 75: Pin detect port A */
- HANDLER kinetis_portb, KINETIS_IRQ_PORTB /* Vector 76: Pin detect port B */
- HANDLER kinetis_portc, KINETIS_IRQ_PORTC /* Vector 77: Pin detect port C */
- HANDLER kinetis_portd, KINETIS_IRQ_PORTD /* Vector 78: Pin detect port D */
- HANDLER kinetis_porte, KINETIS_IRQ_PORTE /* Vector 79: Pin detect port E */
- HANDLER kinetis_software, KINETIS_IRQ_SOFTWARE /* Vector 80: Software interrupt */
- HANDLER kinetis_spi2, KINETIS_IRQ_SPI2 /* Vector 81: SPI2 all sources */
- HANDLER kinetis_uart4s, KINETIS_IRQ_UART4S /* Vector 82: UART4 status */
- HANDLER kinetis_uart4e, KINETIS_IRQ_UART4E /* Vector 83: UART4 error */
- HANDLER kinetis_uart5s, KINETIS_IRQ_UART5S /* Vector 84: UART5 status */
- HANDLER kinetis_uart5e, KINETIS_IRQ_UART5E /* Vector 85: UART5 error */
- HANDLER kinetis_cmp2, KINETIS_IRQ_CMP2 /* Vector 86: CMP2 */
- HANDLER kinetis_ftm3, KINETIS_IRQ_FTM3 /* Vector 87: FTM3 all sources */
- HANDLER kinetis_dac1, KINETIS_IRQ_DAC1 /* Vector 88: DAC1 */
- HANDLER kinetis_adc1, KINETIS_IRQ_ADC1 /* Vector 89: ADC1 */
- HANDLER kinetis_i2c2, KINETIS_IRQ_I2C2 /* Vector 90: I2C2 */
- HANDLER kinetis_can0mb, KINETIS_IRQ_CAN0MB /* Vector 91: CAN0 ORed Message buffer (0-15) */
- HANDLER kinetis_can0bo, KINETIS_IRQ_CAN0BO /* Vector 92: CAN0 Bus Off */
- HANDLER kinetis_can0err, KINETIS_IRQ_CAN0ERR /* Vector 93: CAN0 Error */
- HANDLER kinetis_can0tw, KINETIS_IRQ_CAN0TW /* Vector 94: CAN0 Transmit Warning */
- HANDLER kinetis_can0rw, KINETIS_IRQ_CAN0RW /* Vector 95: CAN0 Receive Warning */
- HANDLER kinetis_can0wu, KINETIS_IRQ_CAN0WU /* Vector 96: CAN0 Wake UP */
- HANDLER kinetis_sdhc, KINETIS_IRQ_SDHC /* Vector 97: SDHC */
- HANDLER kinetis_emactmr, KINETIS_IRQ_EMACTMR /* Vector 91: Ethernet MAC IEEE 1588 timer interrupt */
- HANDLER kinetis_emactx, KINETIS_IRQ_EMACTX /* Vector 92: Ethernet MAC transmit interrupt */
- HANDLER kinetis_emacrx, KINETIS_IRQ_EMACRX /* Vector 93: Ethernet MAC receive interrupt */
- HANDLER kinetis_emacmisc, KINETIS_IRQ_EMACMISC /* Vector 94: Ethernet MAC error and misc interrupt */
+#undef UNUSED
+#define UNUSED(i)
+#if defined(CONFIG_ARCH_FAMILY_K20)
+# include "chip/kinetis_k20vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K40)
+# include "chip/kinetis_k40vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K60)
+# include "chip/kinetis_k60vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K64)
+# include "chip/kinetis_k64vectors.h"
+#elif defined(CONFIG_ARCH_FAMILY_K66)
+# include "chip/kinetis_k66vectors.h"
#else
-# error "No handlers for this Kinetis part"
+# error "No vectors for Kinetis K chip"
#endif
+#endif /* CONFIG_KINETIS_NOEXT_VECTORS */
+
/* Common IRQ handling logic. On entry here, the return stack is on either
* the PSP or the MSP and looks like the following:
*
@@ -1096,7 +364,7 @@ exception_common:
*
* Here:
* r0 = Address of the register save area
-
+ *
* NOTE: It is a requirement that up_restorefpu() preserve the value of
* r0!
*/
@@ -1183,7 +451,7 @@ exception_common:
ldr r14, =EXC_RETURN_PRIVTHR /* Load the special value */
#endif
- /* Restore the interrupt state */
+ /* Restore the interrupt state */
#ifdef CONFIG_ARMV7M_USEBASEPRI
msr basepri, r3 /* Restore interrupts priority masking */
@@ -1202,13 +470,13 @@ exception_common:
bx r14 /* And return */
.size handlers, .-handlers
-/************************************************************************************************
+/************************************************************************************
* Name: g_intstackalloc/g_intstackbase
*
* Description:
* Shouldn't happen
*
- ************************************************************************************************/
+ ************************************************************************************/
#if CONFIG_ARCH_INTERRUPTSTACK > 7
.bss
@@ -1220,11 +488,12 @@ g_intstackalloc:
g_intstackbase:
.size g_intstackalloc, .-g_intstackalloc
#endif
+
#endif /* CONFIG_ARMV7M_CMNVECTOR */
-/************************************************************************************************
+/************************************************************************************
* .rodata
- ************************************************************************************************/
+ ************************************************************************************/
.section .rodata, "a"
diff --git a/arch/arm/src/kl/Make.defs b/arch/arm/src/kl/Make.defs
index d7712f0983c2a868e54f756ff21d1c2e02cfc830..6af672fd4656fc33c8355e7398b62b4e3a8c4713 100644
--- a/arch/arm/src/kl/Make.defs
+++ b/arch/arm/src/kl/Make.defs
@@ -70,7 +70,7 @@ CMN_CSRCS += up_dumpnvic.c
endif
CHIP_ASRCS =
-CHIP_CSRCS = kl_clockconfig.c kl_gpio.c kl_idle.c kl_irq.c kl_getc.c
+CHIP_CSRCS = kl_clockconfig.c kl_gpio.c kl_idle.c kl_irq.c
CHIP_CSRCS += kl_lowputc.c kl_serial.c kl_start.c kl_cfmconfig.c
ifneq ($(CONFIG_SCHED_TICKLESS),y)
diff --git a/arch/arm/src/kl/kl_spi.h b/arch/arm/src/kl/kl_spi.h
index 466ab832f8ed50b70eedd17442011e3e88ab89e9..227ab9e6c5de91173367631ef02a9c999f742fa8 100644
--- a/arch/arm/src/kl/kl_spi.h
+++ b/arch/arm/src/kl/kl_spi.h
@@ -126,6 +126,11 @@ int kl_spi1cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool cmd);
#endif
#endif
+#if defined(__cplusplus)
+}
+#endif
+#undef EXTERN
+
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_KL_SPI0 || CONFIG_KL_SPI1 */
#endif /* __ARCH_ARM_SRC_KL_KL_SPI_H */
diff --git a/arch/arm/src/lpc11xx/Make.defs b/arch/arm/src/lpc11xx/Make.defs
index a347d99946db688d542fd0710eff486accc2a8be..d9fcb5e1526d502b979fb38cc6548fe5af44e35a 100644
--- a/arch/arm/src/lpc11xx/Make.defs
+++ b/arch/arm/src/lpc11xx/Make.defs
@@ -71,7 +71,7 @@ endif
CHIP_ASRCS =
CHIP_CSRCS = lpc11_clockconfig.c lpc11_gpio.c lpc11_i2c.c lpc11_idle.c
-CHIP_CSRCS += lpc11_irq.c lpc11_lowputc.c lpc11_getc.c lpc11_serial.c
+CHIP_CSRCS += lpc11_irq.c lpc11_lowputc.c lpc11_serial.c
CHIP_CSRCS += lpc11_spi.c lpc11_ssp.c lpc11_start.c
# Configuration-dependent LPC11xx files
diff --git a/arch/arm/src/lpc11xx/lpc11_i2c.c b/arch/arm/src/lpc11xx/lpc11_i2c.c
index 184290a602fbc3a7dad9ab122cec2a5fa615ff40..b8f91daee714dbc0b2884cbed37be4f1ab33b2cd 100644
--- a/arch/arm/src/lpc11xx/lpc11_i2c.c
+++ b/arch/arm/src/lpc11xx/lpc11_i2c.c
@@ -59,6 +59,7 @@
#include
#include