Author: blueswirl
Date: 2009-01-07 16:55:19 +0100 (Wed, 07 Jan 2009)
New Revision: 368
Modified:
openbios-devel/drivers/pci.c
openbios-devel/drivers/pci_database.c
openbios-devel/drivers/pci_database.h
Log:
Create special properties for host and bridge (Laurent Vivier)
Modified: openbios-devel/drivers/pci.c
===================================================================
--- openbios-devel/drivers/pci.c 2009-01-07 15:53:14 UTC (rev 367)
+++ openbios-devel/drivers/pci.c 2009-01-07 15:55:19 UTC (rev 368)
@@ -164,6 +164,88 @@
{ "encode-unit", ob_pci_encode_unit },
};
+static void pci_set_bus_range(const pci_config_t *config)
+{
+ phandle_t dev = get_cur_dev();
+ cell props[2];
+
+ props[0] = (config->dev >> 16) & 0xFF;
+ props[1] = 1;
+ set_property(dev, "bus-range", (char *)props, 2 * sizeof(cell));
+}
+
+static void pci_host_set_reg(const pci_config_t *config)
+{
+ phandle_t dev = get_cur_dev();
+ cell props[2];
+
+ props[0] = arch->cfg_base;
+ props[1] = arch->cfg_len;
+ set_property(dev, "reg", (char *)props, 2 * sizeof(cell));
+}
+
+static void pci_host_set_ranges(const pci_config_t *config)
+{
+ phandle_t dev = get_cur_dev();
+ cell props[32];
+ int ncells;
+
+ ncells = 0;
+ if (arch->io_base) {
+ pci_encode_phys_addr(props + ncells, 0, IO_SPACE,
+ config->dev, 0, 0);
+ ncells += 3;
+ props[ncells++] = arch->io_base;
+ props[ncells++] = 0x00000000;
+ props[ncells++] = arch->io_len;
+ }
+ if (arch->rbase) {
+ pci_encode_phys_addr(props + ncells, 0, MEMORY_SPACE_32,
+ config->dev, 0, 0);
+ ncells += 3;
+ props[ncells++] = arch->rbase;
+ props[ncells++] = 0x00000000;
+ props[ncells++] = arch->rlen;
+ }
+ if (arch->mem_base) {
+ pci_encode_phys_addr(props + ncells, 0, MEMORY_SPACE_32,
+ config->dev, 0, arch->mem_base);
+ ncells += 3;
+ props[ncells++] = arch->mem_base;
+ props[ncells++] = 0x00000000;
+ props[ncells++] = arch->mem_len;
+ }
+ set_property(dev, "ranges", (char *)props, ncells * sizeof(cell));
+}
+
+int host_config_cb(const pci_config_t *config)
+{
+ phandle_t aliases;
+
+ aliases = find_dev("/aliases");
+ if (aliases)
+ set_property(aliases, "pci",
+ config->path, strlen(config->path) + 1);
+
+ pci_host_set_reg(config);
+ pci_host_set_ranges(config);
+ pci_set_bus_range(config);
+
+ return 0;
+}
+
+int bridge_config_cb(const pci_config_t *config)
+{
+ phandle_t aliases;
+
+ aliases = find_dev("/aliases");
+ set_property(aliases, "bridge", config->path, strlen(config->path) + 1);
+
+ pci_set_bus_range(config);
+
+ return 0;
+}
+
int ide_config_cb2 (const pci_config_t *config)
{
ob_ide_init(config->path,
Modified: openbios-devel/drivers/pci_database.c
===================================================================
--- openbios-devel/drivers/pci_database.c 2009-01-07 15:53:14 UTC (rev 367)
+++ openbios-devel/drivers/pci_database.c 2009-01-07 15:55:19 UTC (rev 368)
@@ -269,7 +269,7 @@
0x1057, 0x0002, "pci",
"pci", "MOT,MPC106", "grackle\0",
3, 2, 1,
- NULL, NULL
+ host_config_cb, NULL
},
{
0x1057, 0x4801, NULL,
@@ -290,7 +290,7 @@
0x1011, 0x0026, NULL,
"pci-bridge", "DEV,21154", "DEV,21154\0pci-bridge\0",
3, 2, 1,
- NULL, NULL,
+ bridge_config_cb, NULL,
},
{
0xFFFF, 0xFFFF,
Modified: openbios-devel/drivers/pci_database.h
===================================================================
--- openbios-devel/drivers/pci_database.h 2009-01-07 15:53:14 UTC (rev 367)
+++ openbios-devel/drivers/pci_database.h 2009-01-07 15:55:19 UTC (rev 368)
@@ -29,6 +29,8 @@
extern int eth_config_cb(const pci_config_t *config);
extern int macio_config_cb(const pci_config_t *config);
extern int vga_config_cb(const pci_config_t *config);
+extern int host_config_cb(const pci_config_t *config);
+extern int bridge_config_cb(const pci_config_t *config);
static inline int pci_compat_len(const pci_dev_t *dev)
{