linux/include/linux/zorro.h
<<
>>
Prefs
   1/*
   2 *  linux/zorro.h -- Amiga AutoConfig (Zorro) Bus Definitions
   3 *
   4 *  Copyright (C) 1995--2003 Geert Uytterhoeven
   5 *
   6 *  This file is subject to the terms and conditions of the GNU General Public
   7 *  License.  See the file COPYING in the main directory of this archive
   8 *  for more details.
   9 */
  10
  11#ifndef _LINUX_ZORRO_H
  12#define _LINUX_ZORRO_H
  13
  14#include <linux/device.h>
  15
  16
  17    /*
  18     *  Each Zorro board has a 32-bit ID of the form
  19     *
  20     *      mmmmmmmmmmmmmmmmppppppppeeeeeeee
  21     *
  22     *  with
  23     *
  24     *      mmmmmmmmmmmmmmmm    16-bit Manufacturer ID (assigned by CBM (sigh))
  25     *      pppppppp            8-bit Product ID (assigned by manufacturer)
  26     *      eeeeeeee            8-bit Extended Product ID (currently only used
  27     *                          for some GVP boards)
  28     */
  29
  30
  31#define ZORRO_MANUF(id)         ((id) >> 16)
  32#define ZORRO_PROD(id)          (((id) >> 8) & 0xff)
  33#define ZORRO_EPC(id)           ((id) & 0xff)
  34
  35#define ZORRO_ID(manuf, prod, epc) \
  36    ((ZORRO_MANUF_##manuf << 16) | ((prod) << 8) | (epc))
  37
  38typedef __u32 zorro_id;
  39
  40
  41#define ZORRO_WILDCARD          (0xffffffff)    /* not official */
  42
  43/* Include the ID list */
  44#include <linux/zorro_ids.h>
  45
  46
  47    /*
  48     *  GVP identifies most of its products through the 'extended product code'
  49     *  (epc). The epc has to be ANDed with the GVP_PRODMASK before the
  50     *  identification.
  51     */
  52
  53#define GVP_PRODMASK                    (0xf8)
  54#define GVP_SCSICLKMASK                 (0x01)
  55
  56enum GVP_flags {
  57    GVP_IO              = 0x01,
  58    GVP_ACCEL           = 0x02,
  59    GVP_SCSI            = 0x04,
  60    GVP_24BITDMA        = 0x08,
  61    GVP_25BITDMA        = 0x10,
  62    GVP_NOBANK          = 0x20,
  63    GVP_14MHZ           = 0x40,
  64};
  65
  66
  67struct Node {
  68    struct  Node *ln_Succ;      /* Pointer to next (successor) */
  69    struct  Node *ln_Pred;      /* Pointer to previous (predecessor) */
  70    __u8    ln_Type;
  71    __s8    ln_Pri;             /* Priority, for sorting */
  72    __s8    *ln_Name;           /* ID string, null terminated */
  73} __attribute__ ((packed));
  74
  75struct ExpansionRom {
  76    /* -First 16 bytes of the expansion ROM */
  77    __u8  er_Type;              /* Board type, size and flags */
  78    __u8  er_Product;           /* Product number, assigned by manufacturer */
  79    __u8  er_Flags;             /* Flags */
  80    __u8  er_Reserved03;        /* Must be zero ($ff inverted) */
  81    __u16 er_Manufacturer;      /* Unique ID, ASSIGNED BY COMMODORE-AMIGA! */
  82    __u32 er_SerialNumber;      /* Available for use by manufacturer */
  83    __u16 er_InitDiagVec;       /* Offset to optional "DiagArea" structure */
  84    __u8  er_Reserved0c;
  85    __u8  er_Reserved0d;
  86    __u8  er_Reserved0e;
  87    __u8  er_Reserved0f;
  88} __attribute__ ((packed));
  89
  90/* er_Type board type bits */
  91#define ERT_TYPEMASK    0xc0
  92#define ERT_ZORROII     0xc0
  93#define ERT_ZORROIII    0x80
  94
  95/* other bits defined in er_Type */
  96#define ERTB_MEMLIST    5               /* Link RAM into free memory list */
  97#define ERTF_MEMLIST    (1<<5)
  98
  99struct ConfigDev {
 100    struct Node         cd_Node;
 101    __u8                cd_Flags;       /* (read/write) */
 102    __u8                cd_Pad;         /* reserved */
 103    struct ExpansionRom cd_Rom;         /* copy of board's expansion ROM */
 104    void                *cd_BoardAddr;  /* where in memory the board was placed */
 105    __u32               cd_BoardSize;   /* size of board in bytes */
 106    __u16               cd_SlotAddr;    /* which slot number (PRIVATE) */
 107    __u16               cd_SlotSize;    /* number of slots (PRIVATE) */
 108    void                *cd_Driver;     /* pointer to node of driver */
 109    struct ConfigDev    *cd_NextCD;     /* linked list of drivers to config */
 110    __u32               cd_Unused[4];   /* for whatever the driver wants */
 111} __attribute__ ((packed));
 112
 113#define ZORRO_NUM_AUTO          16
 114
 115#ifdef __KERNEL__
 116
 117#include <linux/init.h>
 118#include <linux/ioport.h>
 119
 120#include <asm/zorro.h>
 121
 122
 123    /*
 124     *  Zorro devices
 125     */
 126
 127struct zorro_dev {
 128    struct ExpansionRom rom;
 129    zorro_id id;
 130    struct zorro_driver *driver;        /* which driver has allocated this device */
 131    struct device dev;                  /* Generic device interface */
 132    u16 slotaddr;
 133    u16 slotsize;
 134    char name[64];
 135    struct resource resource;
 136};
 137
 138#define to_zorro_dev(n) container_of(n, struct zorro_dev, dev)
 139
 140
 141    /*
 142     *  Zorro bus
 143     */
 144
 145struct zorro_bus {
 146    struct list_head devices;           /* list of devices on this bus */
 147    unsigned int num_resources;         /* number of resources */
 148    struct resource resources[4];       /* address space routed to this bus */
 149    struct device dev;
 150    char name[10];
 151};
 152
 153extern struct zorro_bus zorro_bus;      /* single Zorro bus */
 154extern struct bus_type zorro_bus_type;
 155
 156
 157    /*
 158     *  Zorro device IDs
 159     */
 160
 161struct zorro_device_id {
 162        zorro_id id;                    /* Device ID or ZORRO_WILDCARD */
 163        unsigned long driver_data;      /* Data private to the driver */
 164};
 165
 166
 167    /*
 168     *  Zorro device drivers
 169     */
 170
 171struct zorro_driver {
 172    struct list_head node;
 173    char *name;
 174    const struct zorro_device_id *id_table;     /* NULL if wants all devices */
 175    int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id);        /* New device inserted */
 176    void (*remove)(struct zorro_dev *z);        /* Device removed (NULL if not a hot-plug capable driver) */
 177    struct device_driver driver;
 178};
 179
 180#define to_zorro_driver(drv)    container_of(drv, struct zorro_driver, driver)
 181
 182
 183#define zorro_for_each_dev(dev) \
 184        for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
 185
 186
 187/* New-style probing */
 188extern int zorro_register_driver(struct zorro_driver *);
 189extern void zorro_unregister_driver(struct zorro_driver *);
 190extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
 191static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
 192{
 193    return z->driver;
 194}
 195
 196
 197extern unsigned int zorro_num_autocon;  /* # of autoconfig devices found */
 198extern struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
 199
 200
 201    /*
 202     *  Zorro Functions
 203     */
 204
 205extern struct zorro_dev *zorro_find_device(zorro_id id,
 206                                           struct zorro_dev *from);
 207
 208#define zorro_resource_start(z) ((z)->resource.start)
 209#define zorro_resource_end(z)   ((z)->resource.end)
 210#define zorro_resource_len(z)   ((z)->resource.end-(z)->resource.start+1)
 211#define zorro_resource_flags(z) ((z)->resource.flags)
 212
 213#define zorro_request_device(z, name) \
 214    request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
 215#define zorro_release_device(z) \
 216    release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
 217
 218/* Similar to the helpers above, these manipulate per-zorro_dev
 219 * driver-specific data.  They are really just a wrapper around
 220 * the generic device structure functions of these calls.
 221 */
 222static inline void *zorro_get_drvdata (struct zorro_dev *z)
 223{
 224        return dev_get_drvdata(&z->dev);
 225}
 226
 227static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
 228{
 229        dev_set_drvdata(&z->dev, data);
 230}
 231
 232
 233    /*
 234     *  Bitmask indicating portions of available Zorro II RAM that are unused
 235     *  by the system. Every bit represents a 64K chunk, for a maximum of 8MB
 236     *  (128 chunks, physical 0x00200000-0x009fffff).
 237     *
 238     *  If you want to use (= allocate) portions of this RAM, you should clear
 239     *  the corresponding bits.
 240     */
 241
 242extern DECLARE_BITMAP(zorro_unused_z2ram, 128);
 243
 244#define Z2RAM_START             (0x00200000)
 245#define Z2RAM_END               (0x00a00000)
 246#define Z2RAM_SIZE              (0x00800000)
 247#define Z2RAM_CHUNKSIZE         (0x00010000)
 248#define Z2RAM_CHUNKMASK         (0x0000ffff)
 249#define Z2RAM_CHUNKSHIFT        (16)
 250
 251
 252#endif /* __KERNEL__ */
 253
 254#endif /* _LINUX_ZORRO_H */
 255
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.