public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Standard driver call to enable/disable PCI ROM
@ 2003-08-19 19:45 Jon Smirl
  2003-08-19 20:06 ` Russell King
  0 siblings, 1 reply; 9+ messages in thread
From: Jon Smirl @ 2003-08-19 19:45 UTC (permalink / raw)
  To: Linux Kernel Mailing List

I needed to enable a PCI ROM and read a few things
from it, and then disable it again. It might be worth
adding a standard PCI API in 2.6 for this.

Here's the code I used...

static void * __init aty128_map_ROM(struct pci_dev
                   *dev, const struct aty128fb_par
*par)
{
   void *rom;
   struct resource *r =
      &dev->resource[PCI_ROM_RESOURCE];
                                                      
   /* assign address if it doesn't have one */
   if (r->start == 0)
      pci_assign_resource(dev,
                                    PCI_ROM_RESOURCE);
                                                      
   /* enable if needed */
   if (!(r->flags & PCI_ROM_ADDRESS_ENABLE)) {
      pci_write_config_dword(dev,
                     dev->rom_base_reg, r->start | 
                     PCI_ROM_ADDRESS_ENABLE);
      r->flags |= PCI_ROM_ADDRESS_ENABLE;
   }
   rom = ioremap(r->start, r->end - r->start + 1);
   if (!rom) {
     printk(KERN_ERR "aty128fb: ROM failed to map\n");
     return NULL;
   }
   /* Very simple test to make sure it appeared */
   if (readb(rom) != 0x55) {
      printk(KERN_ERR "aty128fb: Invalid ROM
            signature %x should be 0x55\n",
readb(rom));          
      aty128_unmap_ROM(dev, rom);
      return NULL;
   }
   return rom;
}
                                            
static void __init aty128_unmap_ROM(struct pci_dev
                                             *dev,
void * rom)
{
   /* leave it disabled and unassigned */
   struct resource *r =
         &dev->resource[PCI_ROM_RESOURCE];
                                            
   iounmap(rom);
                                            
   r->flags &= ~PCI_ROM_ADDRESS_ENABLE;
   r->end -= r->start;
   r->start = 0;
   /* This will disable and set address to unassigned
*/
   pci_write_config_dword(dev, dev->rom_base_reg, 0);
   release_resource(r);
}


=====
Jon Smirl
jonsmirl@yahoo.com

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-08-20  0:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-19 19:45 Standard driver call to enable/disable PCI ROM Jon Smirl
2003-08-19 20:06 ` Russell King
2003-08-19 20:46   ` Jon Smirl
2003-08-19 20:52     ` Russell King
2003-08-19 21:17       ` David S. Miller
2003-08-19 21:32         ` Russell King
2003-08-19 21:54           ` Jon Smirl
2003-08-20  0:05         ` Jamie Lokier
2003-08-20  0:02           ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox