source: rtems/bsps/powerpc/mvme3100/include/bsp.h @ 8f8ccee

5
Last change on this file since 8f8ccee was c4ccf26c, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 17, 2018 at 4:57:46 AM

bsps: Convert all bsp_predriver_hook()

Use RTEMS_SYSINIT_ITEM() instead.

Update #2408.

  • Property mode set to 100644
File size: 11.8 KB
Line 
1/**
2 *  @file
3 *
4 *  @ingroup mvme3100_bsp
5 *
6 *  @brief This file contains BSP API definition.
7 */
8
9/*
10 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 *
16 *  Adapted for the mvme3100 BSP by T. Straumann, 2007.
17 */
18#ifndef LIBBSP_POWERPC_MVME3100_BSP_H
19#define LIBBSP_POWERPC_MVME3100_BSP_H
20
21#ifndef ASM
22
23#include <bspopts.h>
24#include <bsp/default-initial-extension.h>
25
26#include <rtems.h>
27#include <libcpu/io.h>
28#include <bsp/vectors.h>
29
30/**
31 *  @defgroup mvme3100_bsp confdefs.h overrides
32 *
33 *  @ingroup powerpc_mvme3100
34 *
35 *  @brief confdefs.h overrides for this BSP:
36 */
37
38#define BSP_INTERRUPT_STACK_SIZE          (16 * 1024)
39
40/*
41 * diagram illustrating the role of the configuration
42 * constants
43 *  PCI_MEM_WIN0:        CPU starting addr where PCI memory space is visible
44 *  PCI_MEM_BASE:        CPU address of PCI mem addr. zero. (regardless of this
45 *                       address being 'visible' or not!).
46 * _VME_A32_WIN0_ON_PCI: PCI starting addr of the 1st window to VME
47 * _VME_A32_WIN0_ON_VME: VME address of that same window
48 *
49 * AFAIK, only PreP boards have a non-zero PCI_MEM_BASE (i.e., an offset between
50 * CPU and PCI addresses). The mvme2300 'ppcbug' firmware configures the PCI
51 * bus using PCI base addresses! I.e., drivers need to add PCI_MEM_BASE to
52 * the base address read from PCI config.space in order to translate that
53 * into a CPU address.
54 *
55 * NOTE: VME addresses should NEVER be translated using these constants!
56 *       they are strictly for BSP internal use. Drivers etc. should use
57 *       the translation routines int VME.h (BSP_vme2local_adrs/BSP_local2vme_adrs).
58 *
59 *           CPU ADDR                  PCI_ADDR                                VME ADDR
60 *
61 *           00000000                  XXXXXXXX                                XXXXXXXX
62 *    ^  ^   ........
63 *    |  |
64 *    |  |  e.g., RAM                  XXXXXXXX
65 *    |  |                                                                     00000000
66 *    |  |  .........                                                          ^
67 *    |  |            (possible offset                                         |
68 *    |  |             between pci and XXXXXXXX                                | ......
69 *    |  |             cpu addresses)                                          |
70 *    |  v                                                                     |
71 *    |  PCI_MEM_BASE  ------------->  00000000 ---------------                |
72 *    |     ........                   ........               ^                |
73 *    |                                invisible              |                |
74 *    |     ........                   from CPU               |                |
75 *    v                                                       |                |
76 *       PCI_MEM_WIN0 =============  first visible PCI addr   |                |
77 *                                                            |                |
78 *        pci devices   pci window                            |                |
79 *       visible here                                         v                v
80 *                      mapped by   ========== _VME_A32_WIN0_ON_PCI =======  _VME_A32_WIN0_ON_VME
81 *                                                 vme window
82 *        VME devices   hostbridge                 mapped by
83 *       visible here                              universe
84 *                    =====================================================
85 *
86 */
87
88/* fundamental addresses for BSP (CHRPxxx and PREPxxx are from libcpu/io.h) */
89#define _IO_BASE            0xe0000000 /* Motload's PCI IO base */
90#define _ISA_MEM_BASE           CHRP_ISA_MEM_BASE
91/* address of our ram on the PCI bus   */
92#define PCI_DRAM_OFFSET         CHRP_PCI_DRAM_OFFSET
93/* offset of pci memory as seen from the CPU */
94#define PCI_MEM_BASE            0
95/* where (in CPU addr. space) does the PCI window start */
96#define PCI_MEM_WIN0            0x80000000
97
98/*
99 *  Base address definitions for several devices
100 */
101
102#define BSP_OPEN_PIC_BASE_OFFSET 0x40000
103#define BSP_OPEN_PIC_BIG_ENDIAN
104
105#define BSP_8540_CCSR_BASE   (0xe1000000)
106
107#define BSP_UART_IOBASE_COM1 (BSP_8540_CCSR_BASE+0x4500)
108#define BSP_UART_IOBASE_COM2 (BSP_8540_CCSR_BASE+0x4600)
109#define PCI_CONFIG_ADDR      (BSP_8540_CCSR_BASE+0x8000)
110#define PCI_CONFIG_DATA      (BSP_8540_CCSR_BASE+0x8004)
111#define PCI_CONFIG_WR_ADDR( addr, val ) out_be32((uint32_t*)(addr), (val))
112
113#define BSP_CONSOLE_PORT        BSP_UART_COM1
114#define BSP_UART_BAUD_BASE      (-9600) /* use existing divisor to determine clock rate */
115#define BSP_UART_USE_SHARED_IRQS
116
117#define BSP_MVME3100_IRQ_DETECT_REG ((volatile uint8_t *)0xe2000007)
118
119/* I2C Devices */
120/* Note that the i2c addresses stated in the manual are
121 * left-shifted by one bit.
122 */
123#define BSP_VPD_I2C_ADDR                        (0xA8>>1)               /* the VPD EEPROM  */
124#define BSP_USR0_I2C_ADDR                       (0xA4>>1)               /* the 1st user EEPROM */
125#define BSP_USR1_I2C_ADDR                       (0xA6>>1)               /* the 2nd user EEPROM */
126#define BSP_THM_I2C_ADDR                        (0x90>>1)               /* the DS1621 temperature sensor & thermostat */
127#define BSP_RTC_I2C_ADDR                        (0xD0>>1)               /* the DS1375 wall-clock */
128
129#define BSP_I2C_BUS_DESCRIPTOR          mpc8540_i2c_bus_descriptor
130
131#define BSP_I2C_BUS0_NAME             "/dev/i2c0"
132
133#define BSP_I2C_VPD_EEPROM_NAME       "vpd-eeprom"
134#define BSP_I2C_USR_EEPROM_NAME       "usr-eeprom"
135#define BSP_I2C_USR1_EEPROM_NAME      "usr1-eeprom"
136#define BSP_I2C_DS1621_NAME           "ds1621"
137#define BSP_I2C_THM_NAME              BSP_I2C_DS1621_NAME
138#define BSP_I2C_DS1621_RAW_NAME       "ds1621-raw"
139#define BSP_I2C_DS1375_RAW_NAME       "ds1375-raw"
140#define BSP_I2C_RTC_RAW_NAME          BSP_I2C_DS1375_RAW_NAME
141
142#define BSP_I2C_VPD_EEPROM_DEV_NAME      (BSP_I2C_BUS0_NAME "." BSP_I2C_VPD_EEPROM_NAME)
143#define BSP_I2C_USR_EEPROM_DEV_NAME      (BSP_I2C_BUS0_NAME "." BSP_I2C_USR_EEPROM_NAME)
144#define BSP_I2C_USR1_EEPROM_DEV_NAME     (BSP_I2C_BUS0_NAME "." BSP_I2C_USR1_EEPROM_NAME)
145#define BSP_I2C_DS1621_DEV_NAME          (BSP_I2C_BUS0_NAME "." BSP_I2C_DS1621_NAME)
146#define BSP_I2C_THM_DEV_NAME              BSP_I2C_DS1621_DEV_NAME
147#define BSP_I2C_DS1621_RAW_DEV_NAME      (BSP_I2C_BUS0_NAME "." BSP_I2C_DS1621_RAW_NAME)
148#define BSP_I2C_DS1375_RAW_DEV_NAME      (BSP_I2C_BUS0_NAME "." BSP_I2C_DS1375_RAW_NAME)
149
150/* Definitions useful for bootloader (netboot); where to find
151 * boot/'environment' parameters.
152 */
153#define BSP_EEPROM_BOOTPARMS_NAME        BSP_I2C_USR1_EEPROM_DEV_NAME
154#define BSP_EEPROM_BOOTPARMS_SIZE        1024
155#define BSP_EEPROM_BOOTPARMS_OFFSET      0
156#define BSP_BOOTPARMS_WRITE_ENABLE()     do { BSP_eeprom_write_enable(); } while (0)
157#define BSP_BOOTPARMS_WRITE_DISABLE()    do { BSP_eeprom_write_protect();} while (0)
158
159
160#ifdef __cplusplus
161extern "C" {
162#endif
163/* Initialize the I2C driver and register all devices
164 * RETURNS 0 on success, -1 on error.
165 *
166 * Access to the VPD and user EEPROMS as well
167 * as the ds1621 temperature sensor is possible
168 * by means of file nodes
169 *
170 *   /dev/i2c0.vpd-eeprom   (read-only)
171 *   /dev/i2c0.usr-eeprom   (read-write)
172 *   /dev/i2c0.usr1-eeprom  (read-write)
173 *   /dev/i2c0.ds1621       (read-only; one byte: board-temp in degC)
174 *   /dev/i2c0.ds1621-raw   (read-write; transfer bytes to/from the ds1621)
175 *   /dev/i2c0.ds1375-raw   (read-write; transfer bytes to/from the ds1375)
176 *
177 */
178int BSP_i2c_initialize(void);
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 BSP_setSysReg(volatile uint8_t *r, uint8_t mask);
215
216/* Atomically clear bits in a sys-register; The bits set in 'mask'
217 * are cleared in the register; others are left unmodified.
218 *
219 * RETURNS: old state.
220 *
221 * NOTE   : since BSP_clrSysReg( reg, 0 ) does not make
222 *          any changes this call may be used
223 *          to read the current status w/o modifying it.
224 */
225
226uint8_t BSP_clrSysReg(volatile uint8_t *r, uint8_t mask);
227
228/* Convenience wrappers around BSP_setSysReg()/BSP_clrSysReg() */
229
230/* Set write-protection for all EEPROM devices
231 * RETURNS: old status
232 */
233uint8_t BSP_eeprom_write_protect(void);
234
235/* Disengage write-protection for all EEPROM devices
236 * RETURNS: old status
237 */
238uint8_t BSP_eeprom_write_enable(void);
239
240/* Set LEDs that have their bit set in the mask
241 *
242 * RETURNS: old status.
243 *
244 * NOTE   : since BSP_setLEDs( 0 ) does not make
245 *          any changes this call may be used
246 *          to read the current status w/o modifying it.
247 */
248uint8_t BSP_setLEDs(uint8_t mask);
249
250/* Clear LEDs that have their bit set in the mask
251 *
252 * RETURNS: old status
253 *
254 * NOTE:  : see above (BSP_setLEDs)
255 */
256uint8_t BSP_clrLEDs(uint8_t mask);
257
258#if 0
259#define outport_byte(port,value) outb(value,port)
260#define outport_word(port,value) outw(value,port)
261#define outport_long(port,value) outl(value,port)
262
263#define inport_byte(port,value) (value = inb(port))
264#define inport_word(port,value) (value = inw(port))
265#define inport_long(port,value) (value = inl(port))
266#endif
267
268/*
269 * Total memory using RESIDUAL DATA
270 */
271extern unsigned int BSP_mem_size;
272/*
273 * PCI Bus Frequency
274 */
275extern unsigned int BSP_bus_frequency;
276/*
277 * processor clock frequency
278 */
279extern unsigned int BSP_processor_frequency;
280/*
281 * Time base divisior (how many tick for 1 second).
282 */
283extern unsigned int BSP_time_base_divisor;
284/*
285 * The commandline as passed from the bootloader.
286 */
287extern char *BSP_commandline_string;
288
289#define BSP_Convert_decrementer( _value ) \
290  ((unsigned long long) ((((unsigned long long)BSP_time_base_divisor) * 1000000ULL) /((unsigned long long) BSP_bus_frequency)) * ((unsigned long long) (_value)))
291
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(void);
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/*
317 * Prototypes for methods called only from .S for dependency tracking
318 */
319char *save_boot_params(
320  void *r3,
321  void *r4,
322  void *r5,
323  char *cmdline_start,
324  char *cmdline_end
325);
326void zero_bss(void);
327
328/*
329 * Prototypes for methods in the BSP that cross file boundaries
330 */
331extern void BSP_vme_config(void);
332extern void BSP_pciConfigDump_early( void );
333
334#ifdef __cplusplus
335}
336#endif
337
338#endif /* !ASM */
339
340#endif
Note: See TracBrowser for help on using the repository browser.