Commit Graph

30 Commits

Author SHA1 Message Date
Martin Aberg
039edd2adc leon, grcan: removed unused txerror, rxerror 2017-05-14 12:31:59 +02:00
Martin Aberg
ee078c217d leon, grcan: fixed historical comment 2017-05-14 12:31:59 +02:00
Daniel Hellstrom
9154155110 leon, grcan: semaphore reset count required after flushing
It is also required to use semaphore release instead of flush when stopping
or on BUSOFF/AHBERR condition. Otherwise a task just about to wait
(taking the semaphore) could end up locked because the semaphore count is
still the same.

There was previously a scenario where the semaphore flush would not always make
semaphore obtain to return in case of BUSOFF, AHBERROR or grcan_stop. It has to
do with the rtems_semaphore_flush() not releasing the semaphore but just aborts
any _current_ waiter.
2017-05-14 12:31:58 +02:00
Daniel Hellstrom
9855690300 leon, grcan: split hw_stop() into hw and sw stop
this is to avoid owning the spin-lock during semaphore operations.
2017-05-14 12:31:58 +02:00
Martin Aberg
3a650d3b2c leon, grcan: RTEMS_NO_TIMEOUT on tx_sem 2017-05-14 12:31:58 +02:00
Martin Aberg
2d3d8f96b2 leon, grcan: redesigned bus-off and AHB error handling
When bus-off condition is detected by the ISR, it sets the started flag to
STATE_BUSOFF. This is monitored by the user functions grcan_read() and
grcan_write() each time they want to enable DMA or update interrupt mask. If
they detect that ISR has detected bus-off then they will return either with an
error or with the number of CAN messages processed. Future calls to functions
which require STARTED mode will be rejected and grcan_isstarted() will return
0. The next call to grcan_stop() will do the transition from BUSOFF->STOPPED
and the device can then be started again with grcan_start().

Similar to a bus-off condition, the AHB error condition detected by the ISR
will trigger the same shut-down logic of the driver. The difference is that
the state entered is STATE_AHBERR and the routines will return a different
value to indicate AHB error state.

This commit also fixes an issue where ISR was not always unregistered on close.

User functions can cause these transitions:
  STATE_STOPPED -> STATE_STARTED (grcan_start)
  STATE_STARTED -> STATE_STOPPED (grcan_stop)
  STATE_BUSOFF  -> STATE_STOPPED (grcan_stop, grcan_close)
  STATE_AHBERR  -> STATE_STOPPED (grcan_stop, grcan_close)

ISR can cause these transition
  STATE_STARTED -> STATE_BUSOFF (grcan_interrupt)
  STATE_STARTED -> STATE_AHBERR (grcan_interrupt)

STATE_BUSOFF/AHBERR is entered from ISR on bus-off condition. At transition
the ISR disables DMA, masks all interrupts and flushes semaphores.

Other related updates:

 * Statistics are updated from the ISR. Update is now spin-locked to ensure a
   consistent user view.
 * The debug output has been updated to include state changes.
 * For read/write/flush, return error (-4) if driver aborted the operation
   due to bus-off. Likewise if abourted due to AHB error -5 is returned.
 * Collect bus-off statistics

Related to the new BUSOFF and AHBERR states the API has been updated to
reflect the current SW driver state. The isstarted() function has been
replaced with get_state().
2017-05-14 12:31:58 +02:00
Daniel Hellstrom
ca4c4164b5 leon, grcan: updated device name and use it for ISR 2017-05-14 12:31:58 +02:00
Martin Aberg
057496906f leon, grcan: fixed race on interrupt mask register
There was a potential read-modify-write race on the interrupt mask (imr)
register between the ISR and user functions.
2017-05-14 12:31:58 +02:00
Martin Aberg
5d367c56cf leon, grcan: unregister interrupt handler at close 2017-05-14 12:31:58 +02:00
Martin Aberg
c297060b11 leon, grcan: protect statistics on copy to user
Locking the stats structure when copying to user buffer ensures a consistent
view to the user.
2017-05-14 12:31:57 +02:00
Martin Aberg
7b8a920a27 leon, grcan: use RTEMS 4.12 SMP interrupt lock 2017-05-14 12:31:57 +02:00
Martin Aberg
bc40b4def8 leon, grcan: consistent indentation
This commit does not contain any change of functionality.
2017-05-14 12:31:57 +02:00
Martin Aberg
ad203e5887 leon, grcan: function based user interface
This commit preserves all driver services, using a function based user
interface instead of the I/O interface.

The messages count parameter is now number of CAN messages instead of
number of bytes.
2017-05-14 12:31:57 +02:00
Sebastian Huber
f97536dcd3 basdefs.h: Add and use RTEMS_UNUSED 2015-10-26 09:13:19 +01:00
Daniel Hellstrom
4d3e70f4a6 DRVMGR: KEY_TYPE now a enum drvmgr_kt 2015-04-17 01:10:30 +02:00
Daniel Hellstrom
5823bae82b LEON: move driver headers to bsp/ directory 2015-04-17 01:10:26 +02:00
Daniel Hellstrom
3681925508 LEON: updated shared drivers to Driver Manger framework
Some bugfixes at the same time. After this patch the drivers
may be used on RASTA systems having a big-endian PCI layout.

Removed not up to date changelogs, rely on git log instead.
2015-04-17 01:10:17 +02:00
Joel Sherrill
56fb691566 sparc/shared: Fix warnings 2014-10-19 17:00:57 -05:00
Chris Johns
c49985691f Change all references of rtems.com to rtems.org. 2014-03-21 08:10:47 +11:00
Joel Sherrill
f07b0e6563 sparc/.../grcan.c: Switch to using RTEMS_COMPILER_UNUSED_ATTRIBUTE 2013-09-22 09:41:49 -05:00
Joel Sherrill
34b57d61be sparc/.../grcan.c: Fix multiple warnings 2013-09-21 16:10:17 -05:00
Daniel Hellstrom
226d48d826 LEON: moved register definitions into grlib header file
Some register layout definitions for LEON3 reside in ambapp.h which
does not really has anything to do with device registers. The
register structures has been incorrectly named LEON3_*, the cores
are not only used on LEON3 but on LEON4 and perhaps on LEON5 when
that day comes. Some structures has been renamed according to the
GRLIB core name instead, which CPU that actually use it is not
relevant. Drivers has been updated with the new names.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
2012-05-16 13:29:13 -04:00
Daniel Hellstrom
7a01a888a7 LEON: updated drivers to use new AMBAPP Layer
The drivers are updated to use the new AMBA layer, however the
backwards-compatibility interface (ambapp_old) is used.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
2012-04-17 22:01:47 -04:00
Ralf Corsepius
d6d3eb7d71 2011-02-11 Ralf Corsépius <ralf.corsepius@rtems.org>
* shared/1553/b1553brm.c, shared/can/grcan.c, shared/can/occan.c,
	shared/spw/grspw.c, shared/uart/apbuart.c:
	Use "__asm__" instead of "asm" for improved c99-compliance.
2011-02-11 12:22:07 +00:00
Ralf Corsepius
44b06ca617 Whitespace removal. 2009-11-29 15:33:28 +00:00
Joel Sherrill
e3481dcd4f 2007-11-30 Daniel Hellstrom <daniel@gaisler.com>
* shared/can/grcan.c, shared/can/grcan_rasta.c,
	shared/include/ambapp.h: GRCAN CAN driver. Fixes Interrupt
	enabling/disabling in the driver, interrupt may not be restored
	correctly. Implements the baud rate calculation routine. Removed
	unnecessary printk. Fixed scanning to support GRCAN and GRHCAN
	hardware. Added GRCAN device number to ambapp.h.
2007-11-30 16:48:13 +00:00
Joel Sherrill
a3ae7d7a5f 2007-09-18 Joel Sherrill <joel.sherrill@OARcorp.com>
* shared/1553/b1553brm.c, shared/can/grcan.c: Remove include of sched.h
2007-09-18 20:59:57 +00:00
Joel Sherrill
7459fbf9f5 2007-09-12 Daniel Hellstrom <daniel@gaisler.com>
* shared/can/grcan.c, shared/include/debug_defs.h, shared/spw/grspw.c:
	Remove use of DEBUG_printf.
2007-09-12 15:38:57 +00:00
Joel Sherrill
13279f5dcf 2007-09-07 Daniel Hellstrom <daniel@gaisler.com>
* shared/1553/b1553brm.c, shared/can/grcan.c, shared/can/grcan_rasta.c,
	shared/can/occan.c, shared/spw/grspw.c, shared/spw/grspw_pci.c,
	shared/uart/apbuart.c: Remove warnings.
2007-09-07 14:34:18 +00:00
Joel Sherrill
226455f9ff 2007-09-06 Daniel Hellstrom <daniel@gaisler.com>
New drivers: PCI, b1553BRM, SpaceWire(GRSPW), CAN (GRCAN,OC_CAN),
	Raw UART.
	* shared/1553/b1553brm.c, shared/1553/b1553brm_pci.c,
	shared/1553/b1553brm_rasta.c, shared/can/grcan.c,
	shared/can/grcan_rasta.c, shared/can/occan.c, shared/can/occan_pci.c,
	shared/spw/grspw.c, shared/spw/grspw_pci.c, shared/spw/grspw_rasta.c,
	shared/uart/apbuart.c, shared/uart/apbuart_pci.c,
	shared/uart/apbuart_rasta.c: New files missed in previous commit.
2007-09-06 13:27:25 +00:00