j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: blueswirl Date: 2009-01-07 16:51:40 +0100 (Wed, 07 Jan 2009) New Revision: 366
Modified: openbios-devel/drivers/pci.c openbios-devel/drivers/pci_database.h Log: Correctly create "reg" property for PCI devices (Laurent Vivier)
Modified: openbios-devel/drivers/pci.c =================================================================== --- openbios-devel/drivers/pci.c 2009-01-07 15:50:03 UTC (rev 365) +++ openbios-devel/drivers/pci.c 2009-01-07 15:51:40 UTC (rev 366) @@ -176,22 +176,12 @@
int eth_config_cb (const pci_config_t *config) { - phandle_t ph; - cell props[12]; - int i; + phandle_t ph = get_cur_dev();;
- ph = find_dev(config->path); - set_property(ph, "network-type", "ethernet", 9); set_property(ph, "removable", "network", 8); set_property(ph, "category", "net", 4);
- for (i = 0; i < 7; i++) - { - props[i*2] = config->assigned[i] & ~0x0000000F; - props[i*2 + 1] = config->sizes[i]; - } - set_property(ph, "reg", (char *)props, i * 2 * sizeof(cell)); return 0; }
@@ -295,6 +285,44 @@ ncells * sizeof(cell)); }
+static void pci_set_reg(const pci_config_t *config) +{ + phandle_t dev = get_cur_dev(); + cell props[38]; + int ncells; + int i; + uint32_t mask; + int space_code, flags; + + ncells = 0; + pci_encode_phys_addr(props + ncells, 0, CONFIGURATION_SPACE, + config->dev, 0, 0); + ncells += 3; + + props[ncells++] = 0x00000000; + props[ncells++] = 0x00000000; + + for (i = 0; i < 6; i++) { + if (!config->assigned[i] || !config->sizes[i]) + continue; + + pci_decode_pci_addr(config->regions[i], + &flags, &space_code, &mask); + + pci_encode_phys_addr(props + ncells, + flags, space_code, config->dev, + PCI_BASE_ADDR_0 + (i * sizeof(uint32_t)), + config->regions[i] & ~mask); + ncells += 3; + + /* set size */ + + props[ncells++] = 0x00000000; + props[ncells++] = config->sizes[i]; + } + set_property(dev, "reg", (char *)props, ncells * sizeof(cell)); +} + int macio_config_cb (const pci_config_t *config) { #ifdef CONFIG_DRIVER_MACIO @@ -378,6 +406,7 @@ set_property(dev, "compatible", pci_dev->compat, pci_compat_len(pci_dev));
+ pci_set_reg(config); pci_set_assigned_addresses(config); pci_set_interrupt_map(config);
@@ -396,20 +425,6 @@ pci_dev->config_cb(config); }
-static void ob_pci_add_reg(pci_addr addr) -{ - PUSH(0); - PUSH(0); - PUSH(addr&(~arch->cfg_base)); - fword("pci-addr-encode"); - PUSH(0); - PUSH(0); - fword("pci-len-encode"); - fword("encode+"); - push_str("reg"); - fword("property"); -} - #ifdef CONFIG_XBOX static char pci_xbox_blacklisted (int bus, int devnum, int fn) { @@ -486,6 +501,8 @@ else config_addr = PCI_BASE_ADDR_0 + reg * 4;
+ config->regions[reg] = pci_config_read32(addr, config_addr); + /* get region size */
pci_config_write32(addr, config_addr, 0xffffffff); @@ -594,7 +611,6 @@
ob_pci_configure(addr, &config, mem_base, io_base); ob_pci_add_properties(addr, pci_dev, &config); - ob_pci_add_reg(addr);
if (ccode == 0x0600 || ccode == 0x0604) { /* host or bridge */
Modified: openbios-devel/drivers/pci_database.h =================================================================== --- openbios-devel/drivers/pci_database.h 2009-01-07 15:50:03 UTC (rev 365) +++ openbios-devel/drivers/pci_database.h 2009-01-07 15:51:40 UTC (rev 366) @@ -3,6 +3,7 @@ struct pci_config_t { char path[256]; uint32_t dev; /* bus, dev, fn */ + uint32_t regions[7]; uint32_t assigned[7]; uint32_t sizes[7]; int irq_pin;