[RFC] setting resources available to pcmcia

David Woodhouse dwmw2 at infradead.org
Fri Jun 13 18:07:03 BST 2003


On Fri, 2003-06-13 at 16:53, Dominik Brodowski wrote:
> I assume that a PCI-to-PCI bridge needs to be "above" the PCMCIA socket for
> this to become true?


> > It _must_ use memory in the range 0xf5000000-0xf50fffff and I/O in the
> > range 0x2000-0x2fff, or it doesn't even get to see the PCI transactions.
> > Currently this is done by an evil hack -- I configure cardmgr
> > accordingly, and also see the 'membase' and 'isa_setup' module
> > parameters in Marcelo's drivers/pcmcia/i82092.c.
> 
> Can the socket driver know this mem and I/O range?

Look closer and you'll see it already goes trawling its parent bridge to
find the memory range, since it needs that for the card setup anyway.
You can trivially do same for I/O, although I'd hope there'd be a
slightly nicer way of doing it...

Note also the bit about clearing NO_ISA in the bridges on the way down
to the card in question...

        if (membase == -1) {
                for (i = 0; i < 4; i++) {
                        if ((dev->bus->resource[i]->flags & (IORESOURCE_MEM|IORESOURCE_READONLY|IORESOURCE_CACHEABLE|IORESOURCE_SHADOWABLE))
                            == IORESOURCE_MEM) {
                                membase = dev->bus->resource[i]->start >> 24;
                                goto mem_ok;
                        }
                }
                printk(KERN_WARNING "No suitable memory range for i82092aa found\n");
                return -ENOSPC;
        }
 mem_ok:
        if (membase)
                printk(KERN_NOTICE "i82092 memory base address set to 0x%02x000000\n", membase);
                                                                                                                                                                                                      
        /* If we're down the end of the PCI bus chain where ISA cycles don't get sent, then
           only 1/4 of the I/O address space is going to be usable, unless we make sure that
           the NO_ISA bit in the Bridge Control register of all upstream busses is cleared.
           Since some PCMCIA cards (most serial ports, for example) will decode 10 bits and
           respond only to addresses where bits 8 and 9 are non-zero, we need to do this. */
        for (parent = dev->bus->self;
             parent && (parent->class>>8) == PCI_CLASS_BRIDGE_PCI;
             parent = parent->bus->self) {
                uint16_t brctl;
                                                                                                                                                                                                      
                if (pci_read_config_word(parent, PCI_BRIDGE_CONTROL, &brctl)) {
                        printk(KERN_WARNING "Error reading bridge control word from device %s\n", parent->slot_name);
                        continue;
                }
                                                                                                                                                                                                      
                if (!(brctl & PCI_BRIDGE_CTL_NO_ISA))
                        continue;
                                                                                                                                                                                                      
                if (isa_setup) {
                        printk(KERN_NOTICE "PCI bridge %s has NOISA bit set. Clearing to allow full PCMCIA operation\n",
                               parent->slot_name);
                        brctl &= ~PCI_BRIDGE_CTL_NO_ISA;
                        if (pci_write_config_word(parent, PCI_BRIDGE_CONTROL, brctl))
                                printk(KERN_WARNING "Error writing bridge control word from device %s\n", parent->slot_name);
                } else {
                        printk(KERN_NOTICE "PCI bridge %s has NOISA bit set. Some I/O addresses for PCMCIA cards will not work.\n",
                               parent->slot_name);
                        printk(KERN_NOTICE "Perhaps use 'isa_setup=1' option to i82092.o?\n");
                        break;
                }
        }
                                                                                                                                                                                                      


> I'm brewing up a new plan...

A plan which doesn't involve userspace having to set up available
ranges, but instead perhaps relies on 'reserve=' options on the command
line to avoid the _really_ painful breakage situations, and _optional_
screwing from userspace for the rest, would be nice.

I really want nfsroot on PCMCIA Ethernet and CompactFlash-root to work.



-- 
dwmw2




More information about the linux-pcmcia mailing list