source: rtems/c/src/lib/libbsp/powerpc/mvme3100/include/bsp.h @ a052181

4.115
Last change on this file since a052181 was a052181, checked in by Sebastian Huber <sebastian.huber@…>, on 11/14/12 at 08:59:10

score: Add RTEMS_FATAL_SOURCE_EXIT

Include <bsp/default-initial-extension.h> in all BSPs. Call
rtems_fatal() with RTEMS_FATAL_SOURCE_EXIT as source and the exit()
status code as fatal code in every bsp_cleanup(). Move previous
bsp_cleanup() code into bsp_fatal_extension().

  • Property mode set to 100644
File size: 11.4 KB
Line 
1/*
2 *  bsp.h  -- contain BSP API definition.
3 *
4 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
5 *
6 *  The license and distribution terms for this file may be
7 *  found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  Adapted for the mvme3100 BSP by T. Straumann, 2007.
11 */
12#ifndef _BSP_H
13#define _BSP_H
14
15#include <bspopts.h>
16#include <bsp/default-initial-extension.h>
17
18#include <rtems.h>
19#include <rtems/console.h>
20#include <libcpu/io.h>
21#include <rtems/clockdrv.h>
22#include <bsp/vectors.h>
23
24/*
25 *  confdefs.h overrides for this BSP:
26 */
27
28#define BSP_INTERRUPT_STACK_SIZE          (16 * 1024)
29
30/*
31 * diagram illustrating the role of the configuration
32 * constants
33 *  PCI_MEM_WIN0:        CPU starting addr where PCI memory space is visible
34 *  PCI_MEM_BASE:        CPU address of PCI mem addr. zero. (regardless of this
35 *                       address being 'visible' or not!).
36 * _VME_A32_WIN0_ON_PCI: PCI starting addr of the 1st window to VME
37 * _VME_A32_WIN0_ON_VME: VME address of that same window
38 *
39 * AFAIK, only PreP boards have a non-zero PCI_MEM_BASE (i.e., an offset between
40 * CPU and PCI addresses). The mvme2300 'ppcbug' firmware configures the PCI
41 * bus using PCI base addresses! I.e., drivers need to add PCI_MEM_BASE to
42 * the base address read from PCI config.space in order to translate that
43 * into a CPU address.
44 *
45 * NOTE: VME addresses should NEVER be translated using these constants!
46 *       they are strictly for BSP internal use. Drivers etc. should use
47 *       the translation routines int VME.h (BSP_vme2local_adrs/BSP_local2vme_adrs).
48 *
49 *           CPU ADDR                  PCI_ADDR                                VME ADDR
50 *
51 *           00000000                  XXXXXXXX                                XXXXXXXX
52 *    ^  ^   ........
53 *    |  |
54 *    |  |  e.g., RAM                  XXXXXXXX
55 *    |  |                                                                     00000000
56 *    |  |  .........                                                          ^
57 *    |  |            (possible offset                                         |
58 *    |  |             between pci and XXXXXXXX                                | ......
59 *    |  |             cpu addresses)                                          |
60 *    |  v                                                                     |
61 *    |  PCI_MEM_BASE  ------------->  00000000 ---------------                |
62 *    |     ........                   ........               ^                |
63 *    |                                invisible              |                |
64 *    |     ........                   from CPU               |                |
65 *    v                                                       |                |
66 *       PCI_MEM_WIN0 =============  first visible PCI addr   |                |
67 *                                                            |                |
68 *        pci devices   pci window                            |                |
69 *       visible here                                         v                v
70 *                      mapped by   ========== _VME_A32_WIN0_ON_PCI =======  _VME_A32_WIN0_ON_VME
71 *                                                 vme window
72 *        VME devices   hostbridge                 mapped by
73 *       visible here                              universe
74 *                    =====================================================
75 *
76 */
77
78/* fundamental addresses for BSP (CHRPxxx and PREPxxx are from libcpu/io.h) */
79#define _IO_BASE            0xe0000000 /* Motload's PCI IO base */
80#define _ISA_MEM_BASE           CHRP_ISA_MEM_BASE
81/* address of our ram on the PCI bus   */
82#define PCI_DRAM_OFFSET         CHRP_PCI_DRAM_OFFSET
83/* offset of pci memory as seen from the CPU */
84#define PCI_MEM_BASE            0
85/* where (in CPU addr. space) does the PCI window start */
86#define PCI_MEM_WIN0            0x80000000
87
88/*
89 *  Base address definitions for several devices
90 */
91
92#define BSP_OPEN_PIC_BASE_OFFSET 0x40000
93#define BSP_OPEN_PIC_BIG_ENDIAN
94
95#define BSP_8540_CCSR_BASE   (0xe1000000)
96
97#define BSP_UART_IOBASE_COM1 (BSP_8540_CCSR_BASE+0x4500)
98#define BSP_UART_IOBASE_COM2 (BSP_8540_CCSR_BASE+0x4600)
99#define PCI_CONFIG_ADDR      (BSP_8540_CCSR_BASE+0x8000)
100#define PCI_CONFIG_DATA      (BSP_8540_CCSR_BASE+0x8004)
101#define PCI_CONFIG_WR_ADDR( addr, val ) out_be32((unsigned int*)(addr), (val))
102
103#define BSP_CONSOLE_PORT        BSP_UART_COM1
104#define BSP_UART_BAUD_BASE      (-9600) /* use existing divisor to determine clock rate */
105#define BSP_UART_USE_SHARED_IRQS
106
107#define BSP_MVME3100_IRQ_DETECT_REG ((volatile uint8_t *)0xe2000007)
108
109/* I2C Devices */
110/* Note that the i2c addresses stated in the manual are
111 * left-shifted by one bit.
112 */
113#define BSP_VPD_I2C_ADDR                        (0xA8>>1)               /* the VPD EEPROM  */
114#define BSP_USR0_I2C_ADDR                       (0xA4>>1)               /* the 1st user EEPROM */
115#define BSP_USR1_I2C_ADDR                       (0xA6>>1)               /* the 2nd user EEPROM */
116#define BSP_THM_I2C_ADDR                        (0x90>>1)               /* the DS1621 temperature sensor & thermostat */
117#define BSP_RTC_I2C_ADDR                        (0xD0>>1)               /* the DS1375 wall-clock */
118
119#define BSP_I2C_BUS_DESCRIPTOR          mpc8540_i2c_bus_descriptor
120
121#define BSP_I2C_BUS0_NAME             "/dev/i2c0"
122
123#define BSP_I2C_VPD_EEPROM_NAME       "vpd-eeprom"
124#define BSP_I2C_USR_EEPROM_NAME       "usr-eeprom"
125#define BSP_I2C_USR1_EEPROM_NAME      "usr1-eeprom"
126#define BSP_I2C_DS1621_NAME           "ds1621"
127#define BSP_I2C_THM_NAME              BSP_I2C_DS1621_NAME
128#define BSP_I2C_DS1621_RAW_NAME       "ds1621-raw"
129#define BSP_I2C_DS1375_RAW_NAME       "ds1375-raw"
130#define BSP_I2C_RTC_RAW_NAME          BSP_I2C_DS1375_RAW_NAME
131
132#define BSP_I2C_VPD_EEPROM_DEV_NAME      (BSP_I2C_BUS0_NAME"."BSP_I2C_VPD_EEPROM_NAME)
133#define BSP_I2C_USR_EEPROM_DEV_NAME      (BSP_I2C_BUS0_NAME"."BSP_I2C_USR_EEPROM_NAME)
134#define BSP_I2C_USR1_EEPROM_DEV_NAME     (BSP_I2C_BUS0_NAME"."BSP_I2C_USR1_EEPROM_NAME)
135#define BSP_I2C_DS1621_DEV_NAME          (BSP_I2C_BUS0_NAME"."BSP_I2C_DS1621_NAME)
136#define BSP_I2C_THM_DEV_NAME              BSP_I2C_DS1621_DEV_NAME
137#define BSP_I2C_DS1621_RAW_DEV_NAME      (BSP_I2C_BUS0_NAME"."BSP_I2C_DS1621_RAW_NAME)
138#define BSP_I2C_DS1375_RAW_DEV_NAME      (BSP_I2C_BUS0_NAME"."BSP_I2C_DS1375_RAW_NAME)
139
140/* Definitions useful for bootloader (netboot); where to find
141 * boot/'environment' parameters.
142 */
143#define BSP_EEPROM_BOOTPARMS_NAME        BSP_I2C_USR1_EEPROM_DEV_NAME
144#define BSP_EEPROM_BOOTPARMS_SIZE        1024
145#define BSP_EEPROM_BOOTPARMS_OFFSET      0
146#define BSP_BOOTPARMS_WRITE_ENABLE()     do { BSP_eeprom_write_enable(); } while (0)
147#define BSP_BOOTPARMS_WRITE_DISABLE()    do { BSP_eeprom_write_protect();} while (0)
148
149
150#ifdef __cplusplus
151extern "C" {
152#endif
153/* Initialize the I2C driver and register all devices
154 * RETURNS 0 on success, -1 on error.
155 *
156 * Access to the VPD and user EEPROMS as well
157 * as the ds1621 temperature sensor is possible
158 * by means of file nodes
159 *
160 *   /dev/i2c0.vpd-eeprom   (read-only)
161 *   /dev/i2c0.usr-eeprom   (read-write)
162 *   /dev/i2c0.usr1-eeprom  (read-write)
163 *   /dev/i2c0.ds1621       (read-only; one byte: board-temp in degC)
164 *   /dev/i2c0.ds1621-raw   (read-write; transfer bytes to/from the ds1621)
165 *   /dev/i2c0.ds1375-raw   (read-write; transfer bytes to/from the ds1375)
166 *
167 */
168int
169BSP_i2c_initialize();
170
171/* System Control Register */
172#define BSP_MVME3100_SYS_CR                             ((volatile uint8_t *)0xe2000001)
173#define BSP_MVME3100_SYS_CR_RESET_MSK           (7<<5)
174#define BSP_MVME3100_SYS_CR_RESET                       (5<<5)
175#define BSP_MVME3100_SYS_CR_EEPROM_WP           (1<<1)
176#define BSP_MVME3100_SYS_CR_TSTAT_MSK           (1<<0)
177
178/* LED support */
179#define BSP_MVME3100_SYS_IND_REG                ((volatile uint8_t *)0xe2000002)
180#define BSP_LED_BRD_FAIL                                        (1<<0)
181#define BSP_LED_USR1                                            (1<<1)
182#define BSP_LED_USR2                                            (1<<2)
183#define BSP_LED_USR3                                            (1<<3)
184
185/* Flash CSR   */
186#define BSP_MVME3100_FLASH_CSR                  ((volatile uint8_t *)0xe2000003)
187#define BSP_MVME3100_FLASH_CSR_FLASH_RDY        (1<<0)
188#define BSP_MVME3100_FLASH_CSR_FBT_BLK_SEL      (1<<1)
189#define BSP_MVME3100_FLASH_CSR_F_WP_HW          (1<<2)
190#define BSP_MVME3100_FLASH_CSR_F_WP_SW          (1<<3)
191#define BSP_MVME3100_FLASH_CSR_MAP_SEL          (1<<4)
192
193/* Phy interrupt detect */
194#define BSP_MVME3100_IRQ_DETECT_REG             ((volatile uint8_t *)0xe2000007)
195
196/* Atomically set bits in a sys-register; The bits set in 'mask'
197 * are set in the register others; are left unmodified.
198 *
199 * RETURNS: old state.
200 *
201 * NOTE   : since BSP_setSysReg( reg, 0 ) does not make
202 *          any changes this call may be used
203 *          to read the current status w/o modifying it.
204 */
205uint8_t
206BSP_setSysReg(volatile uint8_t *r, uint8_t mask);
207
208/* Atomically clear bits in a sys-register; The bits set in 'mask'
209 * are cleared in the register; others are left unmodified.
210 *
211 * RETURNS: old state.
212 *
213 * NOTE   : since BSP_clrSysReg( reg, 0 ) does not make
214 *          any changes this call may be used
215 *          to read the current status w/o modifying it.
216 */
217
218uint8_t
219BSP_clrSysReg(volatile uint8_t *r, uint8_t mask);
220
221/* Convenience wrappers around BSP_setSysReg()/BSP_clrSysReg() */
222
223/* Set write-protection for all EEPROM devices
224 * RETURNS: old status
225 */
226uint8_t
227BSP_eeprom_write_protect();
228
229/* Disengage write-protection for all EEPROM devices
230 * RETURNS: old status
231 */
232uint8_t
233BSP_eeprom_write_enable();
234
235/* Set LEDs that have their bit set in the mask
236 *
237 * RETURNS: old status.
238 *
239 * NOTE   : since BSP_setLEDs( 0 ) does not make
240 *          any changes this call may be used
241 *          to read the current status w/o modifying it.
242 */
243uint8_t
244BSP_setLEDs(uint8_t mask);
245
246/* Clear LEDs that have their bit set in the mask
247 *
248 * RETURNS: old status
249 *
250 * NOTE:  : see above (BSP_setLEDs)
251 */
252uint8_t
253BSP_clrLEDs(uint8_t mask);
254
255#if 0
256#define outport_byte(port,value) outb(value,port)
257#define outport_word(port,value) outw(value,port)
258#define outport_long(port,value) outl(value,port)
259
260#define inport_byte(port,value) (value = inb(port))
261#define inport_word(port,value) (value = inw(port))
262#define inport_long(port,value) (value = inl(port))
263#endif
264
265/*
266 * Total memory using RESIDUAL DATA
267 */
268extern unsigned int BSP_mem_size;
269/*
270 * PCI Bus Frequency
271 */
272extern unsigned int BSP_bus_frequency;
273/*
274 * processor clock frequency
275 */
276extern unsigned int BSP_processor_frequency;
277/*
278 * Time base divisior (how many tick for 1 second).
279 */
280extern unsigned int BSP_time_base_divisor;
281/*
282 * The commandline as passed from the bootloader.
283 */
284extern char *BSP_commandline_string;
285
286#define BSP_Convert_decrementer( _value ) \
287  ((unsigned long long) ((((unsigned long long)BSP_time_base_divisor) * 1000000ULL) /((unsigned long long) BSP_bus_frequency)) * ((unsigned long long) (_value)))
288
289extern rtems_configuration_table  BSP_Configuration;
290extern void BSP_panic(char *s);
291/* extern int printk(const char *, ...) __attribute__((format(printf, 1, 2))); */
292extern int BSP_disconnect_clock_handler (void);
293extern int BSP_connect_clock_handler (void);
294
295/* clear hostbridge errors
296 *
297 * NOTE: The routine returns always (-1) if 'enableMCP==1'
298 *       [semantics needed by libbspExt] if the MCP input is not wired.
299 *       It returns and clears the error bits of the PCI status register.
300 *       MCP support is disabled because:
301 *         a) the 2100 has no raven chip
302 *         b) the raven (2300) would raise machine check interrupts
303 *            on PCI config space access to empty slots.
304 */
305extern unsigned long _BSP_clear_hostbridge_errors(int enableMCP, int quiet);
306extern void BSP_motload_pci_fixup();
307
308struct rtems_bsdnet_ifconfig;
309
310int
311rtems_tsec_attach(struct rtems_bsdnet_ifconfig *ifcfg, int attaching);
312
313#define RTEMS_BSP_NETWORK_DRIVER_NAME   "tse1"
314#define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_tsec_attach
315
316#ifdef __cplusplus
317}
318#endif
319
320#endif
Note: See TracBrowser for help on using the repository browser.