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

4.104.114.9
Last change on this file since 10a9260 was 10a9260, checked in by Till Straumann <strauman@…>, on Mar 26, 2008 at 1:35:51 AM

2008-03-25 Till Straumann <strauman@…>

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