source: rtems/c/src/lib/libbsp/powerpc/mvme3100/flash/flashcfg.c @ b599faa

4.104.114.95
Last change on this file since b599faa was b599faa, checked in by Till Straumann <strauman@…>, on 12/14/07 at 06:30:15
  • imported MVME3100 BSP (from SLAC repository)
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/* $Id$ */
2
3/* BSP-specific bits of flash programmer support */
4
5/*
6 * Authorship
7 * ----------
8 * This software ('mvme3100' RTEMS BSP) was created by
9 *
10 *     Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
11 *         Stanford Linear Accelerator Center, Stanford University.
12 *
13 * Acknowledgement of sponsorship
14 * ------------------------------
15 * The 'mvme3100' BSP was produced by
16 *     the Stanford Linear Accelerator Center, Stanford University,
17 *         under Contract DE-AC03-76SFO0515 with the Department of Energy.
18 *
19 * Government disclaimer of liability
20 * ----------------------------------
21 * Neither the United States nor the United States Department of Energy,
22 * nor any of their employees, makes any warranty, express or implied, or
23 * assumes any legal liability or responsibility for the accuracy,
24 * completeness, or usefulness of any data, apparatus, product, or process
25 * disclosed, or represents that its use would not infringe privately owned
26 * rights.
27 *
28 * Stanford disclaimer of liability
29 * --------------------------------
30 * Stanford University makes no representations or warranties, express or
31 * implied, nor assumes any liability for the use of this software.
32 *
33 * Stanford disclaimer of copyright
34 * --------------------------------
35 * Stanford University, owner of the copyright, hereby disclaims its
36 * copyright and all other rights in this software.  Hence, anyone may
37 * freely use it for any purpose without restriction. 
38 *
39 * Maintenance of notices
40 * ----------------------
41 * In the interest of clarity regarding the origin and status of this
42 * SLAC software, this and all the preceding Stanford University notices
43 * are to remain affixed to any copy or derivative of this software made
44 * or distributed by the recipient and are to be affixed to any copy of
45 * software made or distributed by the recipient that contains a copy or
46 * derivative of this software.
47 *
48 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
49 */
50#include <rtems.h>
51#include <bsp.h>
52#include <libcpu/spr.h>
53#include <stdio.h>
54
55#include <bsp/flashPgmPvt.h>
56
57SPR_RO(TBRL)
58
59#define STATIC  static
60
61static struct bankdesc mvme3100Flash[] = {
62        /*
63         * Bank is populated from the top; make max_size negative to
64         * indicate this
65         */
66        { 0xf8000000, 0, - 0x08000000, 2, BSP_flash_vendor_spansion, 0, 0, 0  },
67};
68
69STATIC struct bankdesc *
70bankcheck(int bank, int quiet)
71{
72        if ( bank ) {
73                if ( !quiet )
74                        fprintf(stderr,"Invalid flash bank #%i\n",bank);
75                return 0;
76        }
77        return &mvme3100Flash[bank];
78}
79
80STATIC int
81flash_wp(int bank, int enbl)
82{
83uint8_t mask = enbl < 0 ? 0 : BSP_MVME3100_FLASH_CSR_F_WP_SW;
84uint8_t val;
85
86        if ( bank != 0 ) {
87                fprintf(stderr,"Invalid flash bank #%i\n",bank);
88                return -1;
89        }
90
91        if ( enbl )
92                val = BSP_setSysReg( BSP_MVME3100_FLASH_CSR, mask );
93        else
94                val = BSP_clrSysReg( BSP_MVME3100_FLASH_CSR, mask );
95
96        if ( BSP_MVME3100_FLASH_CSR_F_WP_HW & val ) {
97                fprintf(stderr,"Flash: hardware write-protection engaged (switch)\n");
98                return -1;
99        }
100        if ( enbl < 0 )
101                return val & (BSP_MVME3100_FLASH_CSR_F_WP_HW | BSP_MVME3100_FLASH_CSR_F_WP_SW );
102        return 0;
103}
104
105STATIC uint32_t
106read_us_timer()
107{
108uint32_t mhz = BSP_bus_frequency/BSP_time_base_divisor/1000;
109
110        return _read_TBRL()/mhz;
111}
112
113/* BSP ops (detect banks, handle write-protection on board) */
114struct flash_bsp_ops BSP_flashBspOps = {
115        bankcheck:         bankcheck,
116        flash_wp:          flash_wp,
117        read_us_timer: read_us_timer,
118};
Note: See TracBrowser for help on using the repository browser.