Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / ppc-chrp / efika / bestcomm / bestcomm_init.c
blob74c9f5ee5f269949d1e3823c373696d85ef34c1c
1 /*
2 * bestcomm_init.c
4 * Created on: Mar 15, 2009
5 * Author: misc
6 */
8 #define DEBUG 1
10 #include <aros/debug.h>
11 #include <aros/symbolsets.h>
12 #include <proto/openfirmware.h>
13 #include <proto/kernel.h>
15 #include "bestcomm_private.h"
17 static int bestcomm_init(struct BestCommBase *BestCommBase)
19 int retval = TRUE;
20 void *OpenFirmwareBase;
21 void *key, *prop;
23 D(bug("[SDMA] BestComm Init.\n"));
25 OpenFirmwareBase = OpenResource("openfirmware.resource");
27 /* Get some addresses from OF tree */
28 if (OpenFirmwareBase)
30 key = OF_OpenKey("/builtin");
31 if (key)
33 prop = OF_FindProperty(key, "reg");
34 if (prop)
36 reg_t *reg = OF_GetPropValue(prop);
37 BestCommBase->bc_MBAR = (uint8_t *)reg->addr;
41 key = OF_OpenKey("/builtin/sram");
42 if (key)
44 prop = OF_FindProperty(key, "reg");
45 if (prop)
47 reg_t *reg = OF_GetPropValue(prop);
48 BestCommBase->bc_SRAM = reg->addr;
49 BestCommBase->bc_SRAMSize = reg->size;
51 D(bug("[SDMA] %d bytes SRAM at %08x\n", BestCommBase->bc_SRAMSize, BestCommBase->bc_SRAM));
52 if (BestCommBase->bc_SRAMSize)
54 /* Get memory for Free bitmap. Here, 1=free and 0=in use */
55 BestCommBase->bc_SRAMFree = AllocMem((BestCommBase->bc_SRAMSize >> 4) / (8*sizeof(uint32_t)), MEMF_CLEAR|MEMF_PUBLIC);
57 prop = OF_FindProperty(key, "available");
58 if (prop)
60 int i;
61 const int regs = OF_GetPropLen(prop) / sizeof(reg_t);
62 reg_t *reg = OF_GetPropValue(prop);
64 for (i=0; i < regs; i++)
66 D(bug("[SDMA] addr=%08x len=%d\n", reg[i].addr, reg[i].size));
74 key = OF_OpenKey("/builtin/bestcomm");
75 if (key)
77 void *prop = OF_FindProperty(key, "reg");
78 if (prop)
80 BestCommBase->bc_BestComm = *(void **)OF_GetPropValue(prop);
82 D(bug("[SDMA] bestcomm at %08x\n", BestCommBase->bc_BestComm));
85 else
86 retval = FALSE;
90 return retval;
94 ADD2INITLIB(bestcomm_init, 0)