The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386/isa/pcic.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * TODO:
    3  * [1] integrate into current if_ed.c
    4  * [2] parse tuples to find out where to map the shared memory buffer,
    5  *     and what to write into the configuration register
    6  * [3] move pcic-specific code into a separate module.
    7  *
    8  * Device driver for IBM PCMCIA Credit Card Adapter for Ethernet,
    9  * if_ze.c
   10  *
   11  * Based on the Device driver for National Semiconductor DS8390 ethernet
   12  * adapters by David Greenman.  Modifications for PCMCIA by Keith Moore.
   13  * Adapted for FreeBSD 1.1.5 by Jordan Hubbard.
   14  *
   15  * Currently supports only the IBM Credit Card Adapter for Ethernet, but
   16  * could probably work with other PCMCIA cards also, if it were modified
   17  * to get the locations of the PCMCIA configuration option register (COR)
   18  * by parsing the configuration tuples, rather than by hard-coding in
   19  * the value expected by IBM's card.
   20  *
   21  * Sources for data on the PCMCIA/IBM CCAE specific portions of the driver:
   22  *
   23  * [1] _Local Area Network Credit Card Adapters Technical Reference_,
   24  *     IBM Corp., SC30-3585-00, part # 33G9243.
   25  * [2] "pre-alpha" PCMCIA support code for Linux by Barry Jaspan.
   26  * [3] Intel 82536SL PC Card Interface Controller Data Sheet, Intel
   27  *     Order Number 290423-002
   28  * [4] National Semiconductor DP83902A ST-NIC (tm) Serial Network
   29  *     Interface Controller for Twisted Pair data sheet.
   30  *
   31  *
   32  * Copyright (C) 1993, David Greenman. This software may be used, modified,
   33  *   copied, distributed, and sold, in both source and binary form provided
   34  *   that the above copyright and these terms are retained. Under no
   35  *   circumstances is the author responsible for the proper functioning
   36  *   of this software, nor does the author assume any responsibility
   37  *   for damages incurred with its use.
   38  */
   39 
   40 #ifndef __PCIC_H__
   41 #define __PCIC_H__
   42 
   43 /*****************************************************************************
   44  *                 pcmcia controller chip (PCIC) support                     *
   45  *               (eventually, move this to a separate file)                  *
   46  *****************************************************************************/
   47 #include <i386/isa/ic/i82365.h>
   48 
   49 /*
   50  * Each PCIC chip (82365SL or clone) can handle two card slots, and there
   51  * can be up to four PCICs in a system.  (On some machines, not all of the
   52  * address lines are decoded, so a card may appear to be in more than one
   53  * slot.)
   54  */
   55 #define MAXSLOT 8
   56 
   57 /*
   58  * To access a register on the PCIC for a particular slot, you
   59  * first write the correct OFFSET value for that slot in the
   60  * INDEX register for the PCIC controller.  You then read or write
   61  * the value from or to the DATA register for that controller.
   62  *
   63  * The first pair of chips shares I/O addresses for DATA and INDEX,
   64  * as does the second pair.   (To the programmer, it looks like each
   65  * pair is a single chip.)  The i/o port addresses are hard-wired
   66  * into the PCIC; so the following addresses should be valid for
   67  * any machine that uses this chip.
   68  */
   69 
   70 #define PCIC_INDEX_0    0x3E0   /* index reg, chips 0 and 1 */
   71 #define PCIC_DATA_0     0x3E1   /* data register, chips 0 and 1 */
   72 #define PCIC_INDEX_1    0x3E2   /* index reg, chips 1 and 2 */
   73 #define PCIC_DATA_1     0x3E3   /* data register, chips 1 and 2 */
   74 
   75 /*
   76  * Given a slot number, calculate the INDEX and DATA registers
   77  * to talk to that slot.  OFFSET is added to the register number
   78  * to address the registers for a particular slot.
   79  */
   80 #define INDEX(slot) ((slot) < 4 ? PCIC_INDEX_0 : PCIC_INDEX_1)
   81 #define DATA(slot) ((slot) < 4 ? PCIC_DATA_0 : PCIC_DATA_1)
   82 #define OFFSET(slot) ((slot) % 4 * 0x40)
   83 
   84 /*
   85  * There are 5 sets (windows) of memory mapping registers on the PCIC chip
   86  * for each slot, numbered 0..4.
   87  *
   88  * They start at 10/50 hex within the chip's register space (not system
   89  * I/O space), and are eight addresses apart.  These are actually pairs of
   90  * 8-bit-wide registers (low byte first, then high byte) since the
   91  * address fields are actually 12 bits long.  The upper bits are used
   92  * for other things like 8/16-bit select and wait states.
   93  *
   94  * Memory mapping registers include start/stop addresses to define the
   95  * region to be mapped (in terms of system memory addresses), and
   96  * an offset register to allow for translation from system space
   97  * to card space.  The lower 12 bits aren't included in these, so memory is
   98  * mapped in 4K chunks.
   99  */
  100 #define MEM_START_ADDR(window) (((window) * 0x08) + 0x10)
  101 #define MEM_STOP_ADDR(window) (((window) * 0x08) + 0x12)
  102 #define MEM_OFFSET(window) (((window) * 0x08) + 0x14)
  103 /*
  104  * this bit gets set in the address window enable register (PCIC_ADDRWINE)
  105  * to enable a particular address window.
  106  */
  107 #define MEM_ENABLE_BIT(window) ((1) << (window))
  108 
  109 /*
  110  * There are two i/o port addressing windows.  I/O ports cannot be
  111  * relocated within system i/o space (unless the card doesn't decode
  112  * all of the address bits); unlike card memory, there is no address
  113  * translation offset.
  114  */
  115 #define IO_START_ADDR(window) ((window) ? PCIC_IO1_STL : PCIC_IO0_STL)
  116 #define IO_STOP_ADDR(window) ((window) ? PCIC_IO1_SPL : PCIC_IO0_SPL)
  117 #define IO_ENABLE_BIT(window) ((window) ? PCIC_IO1_EN : PCIC_IO0_EN)
  118 #define IO_CS16_BIT(window) ((window) ? PCIC_IO1_CS16 : PCIC_IO0_CS16)
  119 
  120 /*
  121  * types of mapped memory
  122  */
  123 enum memtype { COMMON, ATTRIBUTE };
  124 
  125 /*
  126  * read a byte from a pcic register for a particular slot
  127  */
  128 static __inline unsigned char
  129 pcic_getb (int slot, int reg)
  130 {
  131     outb (INDEX(slot), OFFSET (slot) + reg);
  132     return inb (DATA (slot));
  133 }
  134 
  135 /*
  136  * write a byte to a pcic register for a particular slot
  137  */
  138 static __inline void
  139 pcic_putb (int slot, int reg, unsigned char val)
  140 {
  141     outb (INDEX(slot), OFFSET (slot) + reg);
  142     outb (DATA (slot), val);
  143 }
  144 
  145 /*
  146  * read a word from a pcic register for a particular slot
  147  */
  148 static __inline unsigned short
  149 pcic_getw (int slot, int reg)
  150 {
  151     return pcic_getb (slot, reg) | (pcic_getb (slot, reg+1) << 8);
  152 }
  153 
  154 /*
  155  * write a word to a pcic register at a particular slot
  156  */
  157 static __inline void
  158 pcic_putw (int slot, int reg, unsigned short val)
  159 {
  160     pcic_putb (slot, reg, val & 0xff);
  161     pcic_putb (slot, reg + 1, (val >> 8) & 0xff);
  162 }
  163 
  164 
  165 void pcic_print_regs (int slot);
  166 void pcic_map_memory (int slot, int window, unsigned long sys_addr,
  167                       unsigned long card_addr, unsigned long length,
  168                       enum memtype type, int width);
  169 void pcic_unmap_memory (int slot, int window);
  170 void pcic_map_io (int slot, int window, unsigned short base,
  171                   unsigned short length, unsigned short width);
  172 #ifdef TEST
  173 void pcic_unmap_io (int slot, int window);
  174 #endif /* TEST */
  175 void pcic_map_irq (int slot, int irq);
  176 void pcic_power_on (int slot);
  177 void pcic_power_off (int slot);
  178 void pcic_reset (int slot);
  179 
  180 
  181 #endif /* __PCIC_H__ */

Cache object: 5f90ed4a091a9e994e2ef3e45fae0b32


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.