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