summaryrefslogtreecommitdiffstats
path: root/bsps/powerpc/beatnik/include/bsp.h
blob: e980f1a056e2ffc9de1f3298a12fb1c3ceec3a5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*
 *  bsp.h  -- contain BSP API definition.
 */

/*
 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 *
 *  S. Kate Feng 2003-2007 : Modified it to support the mvme5500 BSP.
 *
 *  Modified for the 'beatnik' BSP by T. Straumann, 2005-2007.
 */

#ifndef LIBBSP_BEATNIK_BSP_H
#define LIBBSP_BEATNIK_BSP_H

#ifndef ASM

#include <bspopts.h>
#include <bsp/default-initial-extension.h>

#include <rtems.h>
#include <libcpu/io.h>
#include <bsp/vectors.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Board type */
typedef enum {
  Unknown = 0,
  MVME5500,
  MVME6100
} BSP_BoardType;

BSP_BoardType BSP_getBoardType(void);

/* Discovery Version */

typedef enum {
  unknown    = 0,
  GT_64260_A,      /* Revision 0x10 */
  GT_64260_B,      /* Revision 0x20 */
  MV_64360,
} DiscoveryVersion;

/* Determine the type of discovery chip on this board; info
 * is cached and repeated calls just return the cached value.
 *
 * If a non-zero argument is passed, the routine panics
 * (rtems_panic) if no recognized bridge is found;
 */
DiscoveryVersion BSP_getDiscoveryVersion(int assertion);

/*
 *  confdefs.h overrides for this BSP:
 *   - Interrupt stack space is not minimum if defined.
 */
#define BSP_INTERRUPT_STACK_SIZE          (16 * 1024)

/*
 *  base address definitions for several devices
 */
#define BSP_MV64x60_BASE        (0xf1000000)
#define BSP_MV64x60_DEV1_BASE   (0xf1100000)
#define BSP_UART_IOBASE_COM1    ((BSP_MV64x60_DEV1_BASE)+0x20000)
#define BSP_UART_IOBASE_COM2    ((BSP_MV64x60_DEV1_BASE)+0x21000)
#define BSP_UART_USE_SHARED_IRQS

#define BSP_NVRAM_BASE_ADDR      (0xf1110000)
#define BSP_NVRAM_END_ADDR       (0xf1117fff)
#define BSP_NVRAM_RTC_START      (0xf1117ff8)

#define BSP_NVRAM_BOOTPARMS_START  (0xf1111000)
#define BSP_NVRAM_BOOTPARMS_END    (0xf1111fff)


/* This is only active/used during early init. It defines
 * the hose0 base for the shared/generic pci code.
 * Our own BSP specific pci initialization will then
 * override the PCI configuration (see gt_pci_init.c:BSP_pci_initialize)
 */

#define PCI_CONFIG_ADDR        (BSP_MV64x60_BASE + 0xcf8)
#define PCI_CONFIG_DATA        (BSP_MV64x60_BASE + 0xcfc)

/* our wonderful PCI initialization remaps everything to CPU addresses
 * - before calling BSP_pci_initialize() this is NOT VALID, however
 * and the deprecated inl()/outl() etc won't work!
 */
#define _IO_BASE          0x00000000
/* wonderful MotLoad has the base address as seen from the
 * CPU programmed into config space :-)
 */
#define PCI_MEM_BASE               0
#define PCI_MEM_BASE_ADJUSTMENT    0
#define PCI_DRAM_OFFSET            0

extern void BSP_motload_pci_fixup(void);

/* PCI <-> local address mapping - no sophisticated windows
 * (i.e., no support for cached regions etc. you read a BAR
 * from config space and that's 1:1 where the CPU sees it).
 * Our memory is mapped 1:1 to PCI also.
 */
#define BSP_PCI2LOCAL_ADDR(a) ((uint32_t)(a))
#define BSP_LOCAL2PCI_ADDR(a) ((uint32_t)(a))

#define BSP_CONFIG_NUM_PCI_CACHE_SLOTS  32

#define BSP_CONSOLE_PORT      BSP_UART_COM1
#define BSP_UART_BAUD_BASE    115200

/* I2C Devices */
/* Note that the i2c addresses stated in the manual are
 * left-shifted by one bit.
 */
#define BSP_VPD_I2C_ADDR      (0xA8>>1)    /* the VPD EEPROM  */
#define BSP_USR_I2C_ADDR      (0xAA>>1)    /* the user EEPROM */
#define BSP_THM_I2C_ADDR      (0x90>>1)    /* the DS1621 temperature sensor & thermostat */

#define BSP_I2C_BUS_DESCRIPTOR    gt64260_i2c_bus_descriptor

#define BSP_I2C_BUS0_NAME             "/dev/i2c0"

#define BSP_I2C_VPD_EEPROM_NAME       "vpd-eeprom"
#define BSP_I2C_USR_EEPROM_NAME       "usr-eeprom"
#define BSP_I2C_DS1621_NAME           "ds1621"
#define BSP_I2C_THM_NAME              BSP_I2C_DS1621_NAME
#define BSP_I2C_DS1621_RAW_NAME       "ds1621-raw"

#define  BSP_I2C_VPD_EEPROM_DEV_NAME      (BSP_I2C_BUS0_NAME"."BSP_I2C_VPD_EEPROM_NAME)
#define  BSP_I2C_USR_EEPROM_DEV_NAME      (BSP_I2C_BUS0_NAME"."BSP_I2C_USR_EEPROM_NAME)
#define  BSP_I2C_DS1621_DEV_NAME          (BSP_I2C_BUS0_NAME"."BSP_I2C_DS1621_NAME)
#define BSP_I2C_THM_DEV_NAME              BSP_I2C_DS1621_DEV_NAME
#define  BSP_I2C_DS1621_RAW_DEV_NAME      (BSP_I2C_BUS0_NAME"."BSP_I2C_DS1621_RAW_NAME)


/* Initialize the I2C driver and register all devices 
 * RETURNS 0 on success, -1 on error.
 *
 * Access to the VPD and user EEPROMS as well
 * as the ds1621 temperature sensor is possible
 * by means of file nodes
 *
 *   /dev/i2c0.vpd-eeprom   (read-only)
 *   /dev/i2c0.usr-eeprom   (read-write)
 *   /dev/i2c0.ds1621       (read-only; one byte: board-temp in degC)
 *   /dev/i2c0.ds1621-raw   (read-write; transfer bytes to/from the ds1621)
 */
int BSP_i2c_initialize(void);

/* Networking; */
#if defined(RTEMS_NETWORKING)
#include <bsp/bsp_bsdnet_attach.h>
#endif

/* NOT FOR PUBLIC USE BELOW HERE */
#define BSP_PCI_HOSE0_MEM_BASE    0x80000000  /* must be aligned to size */
#define BSP_PCI_HOSE0_MEM_SIZE    0x20000000

#define BSP_PCI_HOSE1_MEM_BASE    0xe0000000

#define BSP_DEV_AND_PCI_IO_BASE   0xf0000000
#define BSP_DEV_AND_PCI_IO_SIZE   0x10000000

/* maintain coherency between CPU and GT64340 Ethernet
 * (andpossibly other Discovery components).
 */
#define BSP_RW_PAGE_ATTRIBUTES  TRIV121_ATTR_M

extern unsigned BSP_pci_hose1_bus_base;

void BSP_pci_initialize(void);

/* Exception Handling */

/* Use a task notepad to attach user exception handler info;
 * may be changed by application startup code (EPICS uses 11)
 */
#define BSP_EXCEPTION_NOTEPAD    14
  
#ifndef ASM

#define outport_byte(port,value) outb(value,port)
#define outport_word(port,value) outw(value,port)
#define outport_long(port,value) outl(value,port)

#define inport_byte(port,value) (value = inb(port))
#define inport_word(port,value) (value = inw(port))
#define inport_long(port,value) (value = inl(port))
/*
 * Vital Board data Start using DATA RESIDUAL
 */
/*
 * Total memory using RESIDUAL DATA
 */
extern unsigned int BSP_mem_size;
/*
 * Start of the heap
 */
extern unsigned int BSP_heap_start;
/*
 * PCI Bus Frequency
 */
extern unsigned int BSP_bus_frequency;
/*
 * processor clock frequency
 */
extern unsigned int BSP_processor_frequency;
/*
 * Time base divisior (how many tick for 1 second).
 */
extern unsigned int BSP_time_base_divisor;

extern char BSP_productIdent[20];
extern char BSP_serialNumber[20];

extern char BSP_enetAddr0[7];
extern char BSP_enetAddr1[7];

/*
 * The commandline as passed from the bootloader.
 */
extern char *BSP_commandline_string;


#define BSP_Convert_decrementer( _value ) \
  ((unsigned long long) ((((unsigned long long)BSP_time_base_divisor) * 1000000ULL) /((unsigned long long) BSP_bus_frequency)) * ((unsigned long long) (_value)))

extern rtems_configuration_table  BSP_Configuration;
extern void bsp_reset(void);
extern int BSP_disconnect_clock_handler (void);
extern int BSP_connect_clock_handler (void);

/* clear hostbridge errors
 *
 * enableMCP: whether to enable MCP checkstop / machine check interrupts
 *            on the hostbridge and in HID0.
 *
 *            NOTE: The 5500 and 6100 boards have NO PHYSICAL CONNECTION
 *                  to MCP so 'enableMCP' will always fail!
 *
 * quiet    : be silent
 *
 * RETURNS  : PCI status (hose 0 in byte 0, host 1 in byte 1) and
 *            VME bridge status (upper 16 bits).
 *            Zero if no errors were found.
 */
extern unsigned long _BSP_clear_hostbridge_errors(int enableMCP, int quiet);

/* clear vme bridge errors and return (bridge-dependent) 16-bit status
 *
 * quiet    : be silent
 *
 * RETURNS  : 0 if there were no errors, non-zero, bridge-dependent
 *            16-bit error status on error.
 *
 */
extern unsigned short (*_BSP_clear_vmebridge_errors)(int);

/*
 * Prototypes for debug helpers
 */
void discovery_pic_set_debug_irq(int on);
void discovery_pic_install_debug_irq(void);

/*
 * Prototypes for methods called only from .S for dependency tracking
 */
char *save_boot_params(
  void *r3,
  void *r4,
  void *r5,
  char *cmdline_start,
  char *cmdline_end
);
void zero_bss(void);

/*
 * Prototypes for methods in the BSP that cross file boundaries
 */
uint32_t probeMemoryEnd(void);

#endif

#ifdef __cplusplus
}
#endif

#endif /* !ASM */

#endif