~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/board/esd/cms700/cms700.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * (C) Copyright 2005-2007
 
3
 * Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
 
4
 *
 
5
 * SPDX-License-Identifier:     GPL-2.0+
 
6
 */
 
7
 
 
8
#include <common.h>
 
9
#include <asm/processor.h>
 
10
#include <asm/io.h>
 
11
#include <command.h>
 
12
#include <malloc.h>
 
13
 
 
14
DECLARE_GLOBAL_DATA_PTR;
 
15
 
 
16
extern void lxt971_no_sleep(void);
 
17
 
 
18
int board_early_init_f (void)
 
19
{
 
20
        /*
 
21
         * IRQ 0-15  405GP internally generated; active high; level sensitive
 
22
         * IRQ 16    405GP internally generated; active low; level sensitive
 
23
         * IRQ 17-24 RESERVED
 
24
         * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
 
25
         * IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
 
26
         * IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
 
27
         * IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
 
28
         * IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
 
29
         * IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
 
30
         * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
 
31
         */
 
32
        mtdcr(UIC0SR, 0xFFFFFFFF);       /* clear all ints */
 
33
        mtdcr(UIC0ER, 0x00000000);       /* disable all ints */
 
34
        mtdcr(UIC0CR, 0x00000000);       /* set all to be non-critical*/
 
35
        mtdcr(UIC0PR, 0xFFFFFF80);       /* set int polarities */
 
36
        mtdcr(UIC0TR, 0x10000000);       /* set int trigger levels */
 
37
        mtdcr(UIC0VCR, 0x00000001);      /* set vect base=0,INT0 highest priority*/
 
38
        mtdcr(UIC0SR, 0xFFFFFFFF);       /* clear all ints */
 
39
 
 
40
        /*
 
41
         * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
 
42
         */
 
43
        mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */
 
44
 
 
45
        /*
 
46
         * Reset CPLD via GPIO12 (CS3) pin
 
47
         */
 
48
        out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_PLD_RESET);
 
49
        udelay(1000); /* wait 1ms */
 
50
        out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_PLD_RESET);
 
51
        udelay(1000); /* wait 1ms */
 
52
 
 
53
        return 0;
 
54
}
 
55
 
 
56
int misc_init_r (void)
 
57
{
 
58
        /* adjust flash start and offset */
 
59
        gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
 
60
        gd->bd->bi_flashoffset = 0;
 
61
 
 
62
        /*
 
63
         * Setup and enable EEPROM write protection
 
64
         */
 
65
        out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
 
66
 
 
67
        return (0);
 
68
}
 
69
 
 
70
 
 
71
/*
 
72
 * Check Board Identity:
 
73
 */
 
74
#define LED_REG (CONFIG_SYS_PLD_BASE + 0x1000)
 
75
int checkboard (void)
 
76
{
 
77
        char str[64];
 
78
        int flashcnt;
 
79
        int delay;
 
80
 
 
81
        puts ("Board: ");
 
82
 
 
83
        if (getenv_f("serial#", str, sizeof(str))  == -1) {
 
84
                puts ("### No HW ID - assuming CMS700");
 
85
        } else {
 
86
                puts(str);
 
87
        }
 
88
 
 
89
        printf(" (PLD-Version=%02d)\n",
 
90
               in_8((void *)(CONFIG_SYS_PLD_BASE + 0x1001)));
 
91
 
 
92
        /*
 
93
         * Flash LEDs
 
94
         */
 
95
        for (flashcnt = 0; flashcnt < 3; flashcnt++) {
 
96
                out_8((void *)LED_REG, 0x00); /* LEDs off */
 
97
                for (delay = 0; delay < 100; delay++)
 
98
                        udelay(1000);
 
99
                out_8((void *)LED_REG, 0x0f); /* LEDs on */
 
100
                for (delay = 0; delay < 50; delay++)
 
101
                        udelay(1000);
 
102
        }
 
103
        out_8((void *)LED_REG, 0x70);
 
104
 
 
105
        return 0;
 
106
}
 
107
 
 
108
/* ------------------------------------------------------------------------- */
 
109
 
 
110
#if defined(CONFIG_SYS_EEPROM_WREN)
 
111
/* Input: <dev_addr>  I2C address of EEPROM device to enable.
 
112
 *         <state>     -1: deliver current state
 
113
 *                     0: disable write
 
114
 *                     1: enable write
 
115
 *  Returns:           -1: wrong device address
 
116
 *                      0: dis-/en- able done
 
117
 *                   0/1: current state if <state> was -1.
 
118
 */
 
119
int eeprom_write_enable (unsigned dev_addr, int state)
 
120
{
 
121
        if (CONFIG_SYS_I2C_EEPROM_ADDR != dev_addr) {
 
122
                return -1;
 
123
        } else {
 
124
                switch (state) {
 
125
                case 1:
 
126
                        /* Enable write access, clear bit GPIO_SINT2. */
 
127
                        out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_EEPROM_WP);
 
128
                        state = 0;
 
129
                        break;
 
130
                case 0:
 
131
                        /* Disable write access, set bit GPIO_SINT2. */
 
132
                        out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
 
133
                        state = 0;
 
134
                        break;
 
135
                default:
 
136
                        /* Read current status back. */
 
137
                        state = (0 == (in_be32((void *)GPIO0_OR) & CONFIG_SYS_EEPROM_WP));
 
138
                        break;
 
139
                }
 
140
        }
 
141
        return state;
 
142
}
 
143
 
 
144
int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
145
{
 
146
        int query = argc == 1;
 
147
        int state = 0;
 
148
 
 
149
        if (query) {
 
150
                /* Query write access state. */
 
151
                state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, -1);
 
152
                if (state < 0) {
 
153
                        puts ("Query of write access state failed.\n");
 
154
                } else {
 
155
                        printf ("Write access for device 0x%0x is %sabled.\n",
 
156
                                CONFIG_SYS_I2C_EEPROM_ADDR, state ? "en" : "dis");
 
157
                        state = 0;
 
158
                }
 
159
        } else {
 
160
                if ('0' == argv[1][0]) {
 
161
                        /* Disable write access. */
 
162
                        state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 0);
 
163
                } else {
 
164
                        /* Enable write access. */
 
165
                        state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 1);
 
166
                }
 
167
                if (state < 0) {
 
168
                        puts ("Setup of write access state failed.\n");
 
169
                }
 
170
        }
 
171
 
 
172
        return state;
 
173
}
 
174
 
 
175
U_BOOT_CMD(eepwren,     2,      0,      do_eep_wren,
 
176
        "Enable / disable / query EEPROM write access",
 
177
        ""
 
178
);
 
179
#endif /* #if defined(CONFIG_SYS_EEPROM_WREN) */
 
180
 
 
181
/* ------------------------------------------------------------------------- */
 
182
 
 
183
void reset_phy(void)
 
184
{
 
185
#ifdef CONFIG_LXT971_NO_SLEEP
 
186
 
 
187
        /*
 
188
         * Disable sleep mode in LXT971
 
189
         */
 
190
        lxt971_no_sleep();
 
191
#endif
 
192
}