This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Reset a PCI device?


Indeed my problem was that the device was already initialized.  I solved
it by forcing COMMAND_ACTIVE to be false by clearing the PCI Command
register before calling cyg_pci_get_device_info().  Probably there is a
cleaner way to do this, and I welcome suggestions.

Attached below is the code I added to make the 82559 work, in case
anyone else has a similar problem.

Scott

> Is there a way to reset a PCI device that has already been configured so
> that it will go back to having uninitialized BARs, sizes and addresses?
> 
> Basically I want 
> 
> if ((dev_info->command & CYG_PCI_CFG_COMMAND_ACTIVE) == 0) { stuff }
> 
> to return true in the cyg_pci_get_dvice_info() call.
> 
> I'm trying to get RedBoot to re-initialize a system that was already
> initialized by another boot-loader.  I think this is whats preventing my
> 82559 from passing the self test.
> 
> Thanks,
> Scott
> 

Index: if_i82559.c
===================================================================
RCS file:
/cvs/ecos/ecos/packages/devs/eth/intel/i82559/current/src/if_i82559.c,v
retrieving revision 1.22
diff -u -r1.22 if_i82559.c
--- if_i82559.c 27 Feb 2003 15:06:57 -0000      1.22
+++ if_i82559.c 25 Apr 2003 01:04:04 -0000
@@ -2852,6 +2870,17 @@
 #endif
            // Allocate it a stats window:
            p_i82559->p_statistics =
pciwindow_mem_alloc(sizeof(I82559_COUNTERS));
+
+           // make sure that eCos views the device as inactive
+           {
+             cyg_uint8 bus = CYG_PCI_DEV_GET_BUS(devid);
+             cyg_uint8 devfn = CYG_PCI_DEV_GET_DEVFN(devid);
+
+#ifdef DEBUG
+             db_printf("Forcing PCI command register to 0x0\n");
+#endif
+             cyg_pcihw_write_config_uint16(bus, devfn,
CYG_PCI_CFG_COMMAND, 0x0);
+           }

             cyg_pci_get_device_info(devid, &dev_info);



-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]