1 | /* Miscellaneous small BSP routines; reboot, board CSR, ... */ |
---|
2 | |
---|
3 | /* |
---|
4 | * Authorship |
---|
5 | * ---------- |
---|
6 | * This software ('mvme3100' RTEMS BSP) was created by |
---|
7 | * |
---|
8 | * Till Straumann <strauman@slac.stanford.edu>, 2005-2007, |
---|
9 | * Stanford Linear Accelerator Center, Stanford University. |
---|
10 | * |
---|
11 | * Acknowledgement of sponsorship |
---|
12 | * ------------------------------ |
---|
13 | * The 'mvme3100' BSP was produced by |
---|
14 | * the Stanford Linear Accelerator Center, Stanford University, |
---|
15 | * under Contract DE-AC03-76SFO0515 with the Department of Energy. |
---|
16 | * |
---|
17 | * Government disclaimer of liability |
---|
18 | * ---------------------------------- |
---|
19 | * Neither the United States nor the United States Department of Energy, |
---|
20 | * nor any of their employees, makes any warranty, express or implied, or |
---|
21 | * assumes any legal liability or responsibility for the accuracy, |
---|
22 | * completeness, or usefulness of any data, apparatus, product, or process |
---|
23 | * disclosed, or represents that its use would not infringe privately owned |
---|
24 | * rights. |
---|
25 | * |
---|
26 | * Stanford disclaimer of liability |
---|
27 | * -------------------------------- |
---|
28 | * Stanford University makes no representations or warranties, express or |
---|
29 | * implied, nor assumes any liability for the use of this software. |
---|
30 | * |
---|
31 | * Stanford disclaimer of copyright |
---|
32 | * -------------------------------- |
---|
33 | * Stanford University, owner of the copyright, hereby disclaims its |
---|
34 | * copyright and all other rights in this software. Hence, anyone may |
---|
35 | * freely use it for any purpose without restriction. |
---|
36 | * |
---|
37 | * Maintenance of notices |
---|
38 | * ---------------------- |
---|
39 | * In the interest of clarity regarding the origin and status of this |
---|
40 | * SLAC software, this and all the preceding Stanford University notices |
---|
41 | * are to remain affixed to any copy or derivative of this software made |
---|
42 | * or distributed by the recipient and are to be affixed to any copy of |
---|
43 | * software made or distributed by the recipient that contains a copy or |
---|
44 | * derivative of this software. |
---|
45 | * |
---|
46 | * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 |
---|
47 | */ |
---|
48 | |
---|
49 | #include <bsp.h> |
---|
50 | #include <bsp/bootcard.h> |
---|
51 | |
---|
52 | void |
---|
53 | bsp_reset(void) |
---|
54 | { |
---|
55 | uint8_t v; |
---|
56 | /* |
---|
57 | * AFAIK, the hardest reset available; cleared |
---|
58 | * some errors a VME-bus reset wouldn't (hung |
---|
59 | * i2c bus)... |
---|
60 | */ |
---|
61 | v = in_8( BSP_MVME3100_SYS_CR ); |
---|
62 | v &= ~BSP_MVME3100_SYS_CR_RESET_MSK; |
---|
63 | v |= BSP_MVME3100_SYS_CR_RESET; |
---|
64 | out_8( BSP_MVME3100_SYS_CR, v ); |
---|
65 | } |
---|
66 | |
---|
67 | uint8_t |
---|
68 | BSP_setSysReg(volatile uint8_t *r, uint8_t mask) |
---|
69 | { |
---|
70 | uint8_t v; |
---|
71 | rtems_interrupt_level l; |
---|
72 | |
---|
73 | if ( !mask ) |
---|
74 | return in_8( r ); |
---|
75 | |
---|
76 | rtems_interrupt_disable(l); |
---|
77 | v = in_8( r ); |
---|
78 | if ( mask ) { |
---|
79 | out_8( r, v | mask ); |
---|
80 | } |
---|
81 | rtems_interrupt_enable(l); |
---|
82 | return v; |
---|
83 | } |
---|
84 | |
---|
85 | uint8_t |
---|
86 | BSP_clrSysReg(volatile uint8_t *r, uint8_t mask) |
---|
87 | { |
---|
88 | uint8_t v; |
---|
89 | rtems_interrupt_level l; |
---|
90 | |
---|
91 | if ( !mask ) |
---|
92 | return in_8( r ); |
---|
93 | |
---|
94 | rtems_interrupt_disable(l); |
---|
95 | v = in_8( r ); |
---|
96 | if ( mask ) { |
---|
97 | out_8( r, v & ~mask ); |
---|
98 | } |
---|
99 | rtems_interrupt_enable(l); |
---|
100 | return v; |
---|
101 | } |
---|
102 | |
---|
103 | uint8_t |
---|
104 | BSP_setLEDs(uint8_t mask) |
---|
105 | { |
---|
106 | return BSP_setSysReg( BSP_MVME3100_SYS_IND_REG, mask ); |
---|
107 | } |
---|
108 | |
---|
109 | uint8_t |
---|
110 | BSP_clrLEDs(uint8_t mask) |
---|
111 | { |
---|
112 | return BSP_clrSysReg( BSP_MVME3100_SYS_IND_REG, mask ); |
---|
113 | } |
---|
114 | |
---|
115 | uint8_t |
---|
116 | BSP_eeprom_write_protect(void) |
---|
117 | { |
---|
118 | uint8_t m = BSP_MVME3100_SYS_CR_EEPROM_WP; |
---|
119 | volatile uint8_t *r = BSP_MVME3100_SYS_CR; |
---|
120 | |
---|
121 | return m & BSP_setSysReg( r, m ); |
---|
122 | } |
---|
123 | |
---|
124 | uint8_t |
---|
125 | BSP_eeprom_write_enable(void) |
---|
126 | { |
---|
127 | uint8_t m = BSP_MVME3100_SYS_CR_EEPROM_WP; |
---|
128 | volatile uint8_t *r = BSP_MVME3100_SYS_CR; |
---|
129 | |
---|
130 | return m & BSP_clrSysReg( r, m ); |
---|
131 | } |
---|