source: rtems/bsps/powerpc/mvme3100/flash/flashcfg.c @ 762fa62

5
Last change on this file since 762fa62 was bf16ee5, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 25, 2018 at 8:24:49 AM

bsp/mvme3100: Move flashcfg.c to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/* BSP-specific bits of flash programmer support */
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#include <rtems.h>
49#include <bsp.h>
50#include <libcpu/spr.h>
51#include <stdio.h>
52
53#include <bsp/flashPgmPvt.h>
54
55SPR_RO(TBRL)
56
57#define STATIC  static
58
59static struct bankdesc mvme3100Flash[] = {
60        /*
61         * Bank is populated from the top; make max_size negative to
62         * indicate this
63         */
64        { 0xf8000000, 0, - 0x08000000, 2, BSP_flash_vendor_spansion, 0, 0, 0  },
65};
66
67STATIC struct bankdesc *
68bankcheck(int bank, int quiet)
69{
70        if ( bank ) {
71                if ( !quiet )
72                        fprintf(stderr,"Invalid flash bank #%i\n",bank);
73                return 0;
74        }
75        return &mvme3100Flash[bank];
76}
77
78STATIC int
79flash_wp(int bank, int enbl)
80{
81uint8_t mask = enbl < 0 ? 0 : BSP_MVME3100_FLASH_CSR_F_WP_SW;
82uint8_t val;
83
84        if ( bank != 0 ) {
85                fprintf(stderr,"Invalid flash bank #%i\n",bank);
86                return -1;
87        }
88
89        if ( enbl )
90                val = BSP_setSysReg( BSP_MVME3100_FLASH_CSR, mask );
91        else
92                val = BSP_clrSysReg( BSP_MVME3100_FLASH_CSR, mask );
93
94        if ( BSP_MVME3100_FLASH_CSR_F_WP_HW & val ) {
95                fprintf(stderr,"Flash: hardware write-protection engaged (switch)\n");
96                return -1;
97        }
98        if ( enbl < 0 )
99                return val & (BSP_MVME3100_FLASH_CSR_F_WP_HW | BSP_MVME3100_FLASH_CSR_F_WP_SW );
100        return 0;
101}
102
103STATIC uint32_t
104read_us_timer(void)
105{
106uint32_t mhz = BSP_bus_frequency/BSP_time_base_divisor/1000;
107
108        return _read_TBRL()/mhz;
109}
110
111/* BSP ops (detect banks, handle write-protection on board) */
112struct flash_bsp_ops BSP_flashBspOps = {
113        bankcheck:         bankcheck,
114        flash_wp:          flash_wp,
115        read_us_timer: read_us_timer,
116};
Note: See TracBrowser for help on using the repository browser.