Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:57

0001 /* Miscellaneous small BSP routines; reboot, board CSR, ... */
0002 
0003 /*
0004  * Authorship
0005  * ----------
0006  * This software ('mvme3100' RTEMS BSP) was created by
0007  *
0008  *     Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
0009  *     Stanford Linear Accelerator Center, Stanford University.
0010  *
0011  * Acknowledgement of sponsorship
0012  * ------------------------------
0013  * The 'mvme3100' BSP was produced by
0014  *     the Stanford Linear Accelerator Center, Stanford University,
0015  *     under Contract DE-AC03-76SFO0515 with the Department of Energy.
0016  *
0017  * Government disclaimer of liability
0018  * ----------------------------------
0019  * Neither the United States nor the United States Department of Energy,
0020  * nor any of their employees, makes any warranty, express or implied, or
0021  * assumes any legal liability or responsibility for the accuracy,
0022  * completeness, or usefulness of any data, apparatus, product, or process
0023  * disclosed, or represents that its use would not infringe privately owned
0024  * rights.
0025  *
0026  * Stanford disclaimer of liability
0027  * --------------------------------
0028  * Stanford University makes no representations or warranties, express or
0029  * implied, nor assumes any liability for the use of this software.
0030  *
0031  * Stanford disclaimer of copyright
0032  * --------------------------------
0033  * Stanford University, owner of the copyright, hereby disclaims its
0034  * copyright and all other rights in this software.  Hence, anyone may
0035  * freely use it for any purpose without restriction.
0036  *
0037  * Maintenance of notices
0038  * ----------------------
0039  * In the interest of clarity regarding the origin and status of this
0040  * SLAC software, this and all the preceding Stanford University notices
0041  * are to remain affixed to any copy or derivative of this software made
0042  * or distributed by the recipient and are to be affixed to any copy of
0043  * software made or distributed by the recipient that contains a copy or
0044  * derivative of this software.
0045  *
0046  * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
0047  */
0048 
0049 #include <bsp.h>
0050 #include <bsp/bootcard.h>
0051 
0052 
0053 void bsp_reset( rtems_fatal_source source, rtems_fatal_code code )
0054 {
0055 uint8_t v;
0056 
0057     (void) source;
0058     (void) code;
0059 
0060     /*
0061      * AFAIK, the hardest reset available; cleared
0062      * some errors a VME-bus reset wouldn't (hung
0063      * i2c bus)...
0064      */
0065     v  = in_8( BSP_MVME3100_SYS_CR );
0066     v &= ~BSP_MVME3100_SYS_CR_RESET_MSK;
0067     v |=  BSP_MVME3100_SYS_CR_RESET;
0068     out_8( BSP_MVME3100_SYS_CR, v );
0069     RTEMS_UNREACHABLE();
0070 }
0071 
0072 uint8_t
0073 BSP_setSysReg(volatile uint8_t *r, uint8_t mask)
0074 {
0075 uint8_t               v;
0076 rtems_interrupt_level l;
0077 
0078     if ( !mask )
0079         return in_8( r );
0080 
0081     rtems_interrupt_disable(l);
0082         v = in_8( r );
0083         if ( mask ) {
0084             out_8( r,  v | mask );
0085         }
0086     rtems_interrupt_enable(l);
0087     return v;
0088 }
0089 
0090 uint8_t
0091 BSP_clrSysReg(volatile uint8_t *r, uint8_t mask)
0092 {
0093 uint8_t               v;
0094 rtems_interrupt_level l;
0095 
0096     if ( !mask )
0097         return in_8( r );
0098 
0099     rtems_interrupt_disable(l);
0100         v = in_8( r );
0101         if ( mask ) {
0102             out_8( r,  v & ~mask );
0103         }
0104     rtems_interrupt_enable(l);
0105     return v;
0106 }
0107 
0108 uint8_t
0109 BSP_setLEDs(uint8_t mask)
0110 {
0111     return BSP_setSysReg( BSP_MVME3100_SYS_IND_REG, mask );
0112 }
0113 
0114 uint8_t
0115 BSP_clrLEDs(uint8_t mask)
0116 {
0117     return BSP_clrSysReg( BSP_MVME3100_SYS_IND_REG, mask );
0118 }
0119 
0120 uint8_t
0121 BSP_eeprom_write_protect(void)
0122 {
0123 uint8_t           m = BSP_MVME3100_SYS_CR_EEPROM_WP;
0124 volatile uint8_t *r = BSP_MVME3100_SYS_CR;
0125 
0126     return m & BSP_setSysReg( r, m );
0127 }
0128 
0129 uint8_t
0130 BSP_eeprom_write_enable(void)
0131 {
0132 uint8_t           m = BSP_MVME3100_SYS_CR_EEPROM_WP;
0133 volatile uint8_t *r = BSP_MVME3100_SYS_CR;
0134 
0135     return m & BSP_clrSysReg( r, m );
0136 }