Create properties for an oldworld machine if needed.

If arch is ppc and machine arch id is heathrow, we create:

- properties in root node for a powermac beige
  (Linux says "Powermac G3 (Silk)")

- "AAPL,interrupts" and "AAPL,address" properties in PCI device tree.



git-svn-id: svn://coreboot.org/openbios/openbios-devel@388 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Laurent Vivier
2009-01-11 01:03:16 +00:00
parent c93afa0cca
commit 358bee9e5d
5 changed files with 141 additions and 10 deletions

View File

@@ -24,6 +24,7 @@
#include "openbios/bindings.h"
#include "openbios/pci.h"
#include "openbios/nvram.h"
#include "openbios/drivers.h"
#include "qemu/qemu.h"
#include "ofmem.h"
#include "openbios-version.h"
@@ -46,8 +47,9 @@ struct cpudef {
void (*initfn)(const struct cpudef *cpu);
};
static uint16_t machine_id = 0;
extern void unexpected_excep( int vector );
extern void ob_pci_init( void );
extern void setup_timers( void );
void
@@ -64,6 +66,16 @@ enum {
ARCH_HEATHROW,
};
int is_apple(void)
{
return 1;
}
int is_oldworld(void)
{
return machine_id == ARCH_HEATHROW;
}
static const pci_arch_t known_arch[] = {
[ARCH_PREP] = { "PREP", 0x1057, 0x4801, 0x80800000, 0x800c0000,
0x80000000, 0x00100000, 0xf0000000, 0x10000000,
@@ -120,7 +132,6 @@ void
entry( void )
{
uint32_t temp = 0;
uint16_t machine_id = 0;
char buf[5], qemu_uuid[16];
arch = &known_arch[ARCH_HEATHROW];
@@ -430,6 +441,88 @@ arch_of_init( void )
const struct cpudef *cpu;
char buf[64];
/* set device tree root info */
push_str("/");
fword("find-device");
switch(machine_id) {
case ARCH_HEATHROW: /* OldWord */
/* model */
push_str("Power Macintosh");
fword("model");
/* compatible */
push_str("AAPL,PowerMac G3");
fword("encode-string");
push_str("MacRISC");
fword("encode-string");
fword("encode+");
push_str("compatible");
fword("property");
/* misc */
push_str("device-tree");
fword("encode-string");
push_str("AAPL,original-name");
fword("property");
PUSH(0);
fword("encode-int");
push_str("AAPL,cpu-id");
fword("property");
PUSH(66 * 1000 * 1000);
fword("encode-int");
push_str("clock-frequency");
fword("property");
break;
case ARCH_MAC99:
case ARCH_PREP:
default:
/* model */
push_str("PowerMac1,1");
fword("model");
/* compatible */
push_str("PowerMac1,1");
fword("encode-string");
push_str("MacRISC");
fword("encode-string");
fword("encode+");
push_str("Power Macintosh");
fword("encode-string");
fword("encode+");
push_str("compatible");
fword("property");
/* misc */
push_str("bootrom");
fword("device-type");
PUSH(100 * 1000 * 1000);
fword("encode-int");
push_str("clock-frequency");
fword("property");
break;
}
/* Perhaps we can store UUID here ? */
push_str("0000000000000");
fword("encode-string");
push_str("system-id");
fword("property");
/* memory info */
push_str("/memory");

View File

@@ -11,12 +11,6 @@
" /" find-device
" bootrom" device-type
" PowerMac1,1" model
" PowerMac1,1" encode-string
" MacRisc" encode-string encode+
" Power Macintosh" encode-string encode+ " compatible" property
" 0000000000000" encode-string " system-id" property
1 encode-int " #address-cells" property
1 encode-int " #size-cells" property
h# 05f5e100 encode-int " clock-frequency" property

View File

@@ -1,5 +1,6 @@
#include "openbios/config.h"
#include "openbios/bindings.h"
#include "openbios/drivers.h"
#include "libc/byteorder.h"
#include "libc/vsprintf.h"
@@ -200,7 +201,7 @@ ob_cuda_initialize (int *idx)
* non-standard oldworld property (needed by linux 2.6.18)
*/
set_int_property(ph, "AAPL,interrupts", 0x12);
OLDWORLD(set_int_property(ph, "AAPL,interrupts", 0x12));
bind_func("ppc32-reset-all", ppc32_reset_all);
push_str("' ppc32-reset-all to reset-all");

View File

@@ -291,6 +291,30 @@ static inline void pci_decode_pci_addr(pci_addr addr, int *flags,
}
}
/*
* "Designing PCI Cards and Drivers for Power Macintosh Computers", p. 454
*
* "AAPL,address" provides an array of 32-bit logical addresses
* Nth entry corresponding to Nth "assigned-address" base address entry.
*/
static void pci_set_AAPL_address(const pci_config_t *config)
{
phandle_t dev = get_cur_dev();
cell props[7];
int ncells, i;
ncells = 0;
for (i = 0; i < 6; i++) {
if (!config->assigned[i] || !config->sizes[i])
continue;
props[ncells++] = config->assigned[i] & ~0x0000000F;
}
if (ncells)
set_property(dev, "AAPL,address", (char *)props,
ncells * sizeof(cell));
}
static void pci_set_assigned_addresses(const pci_config_t *config)
{
phandle_t dev = get_cur_dev();
@@ -452,8 +476,11 @@ static void ob_pci_add_properties(pci_addr addr, const pci_dev_t *pci_dev,
set_int_property(dev, "revision-id", rev);
set_int_property(dev, "class-code", class_code << 8);
if (config->irq_pin)
if (config->irq_pin) {
OLDWORLD(set_int_property(dev, "AAPL,interrupts",
config->irq_line));
set_int_property(dev, "interrupts", config->irq_pin);
}
set_int_property(dev, "min-grant", pci_config_read8(addr, PCI_MIN_GNT));
set_int_property(dev, "max-latency", pci_config_read8(addr, PCI_MAX_LAT));
@@ -510,6 +537,7 @@ static void ob_pci_add_properties(pci_addr addr, const pci_dev_t *pci_dev,
pci_set_reg(config);
pci_set_assigned_addresses(config);
OLDWORLD(pci_set_AAPL_address(config));
#ifdef CONFIG_DEBUG_PCI
printk("\n");

View File

@@ -16,6 +16,21 @@
#ifdef CONFIG_DRIVER_PCI
/* drivers/pci.c */
int ob_pci_init(void);
#ifdef CONFIG_PPC
extern int is_apple(void);
extern int is_oldworld(void);
#else
static inline int is_apple(void)
{
return 0;
}
static inline int is_oldworld(void)
{
return 0;
}
#endif
#define AAPL(_cmd) do { if (is_apple()) _cmd; } while(0)
#define OLDWORLD(_cmd) do { if (is_oldworld()) _cmd; } while(0)
#endif
#ifdef CONFIG_DRIVER_SBUS
/* drivers/sbus.c */