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/dev/cardbus/cardbusvar.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 /*      $NetBSD: cardbusvar.h,v 1.25 2003/07/08 10:06:29 itojun Exp $   */
    2 
    3 /*
    4  * Copyright (c) 1998, 1999 and 2000
    5  *       HAYAKAWA Koichi.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by the author.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission.
   20  *
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   25  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
   26  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   30  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   32  * POSSIBILITY OF SUCH DAMAGE.
   33  */
   34 
   35 #ifndef _DEV_CARDBUS_CARDBUSVAR_H_
   36 #define _DEV_CARDBUS_CARDBUSVAR_H_
   37 
   38 #include <dev/cardbus/cardbusreg.h>
   39 #if 1
   40 #include <dev/cardbus/rbus.h>
   41 #endif
   42 
   43 
   44 
   45 typedef void *cardbus_chipset_tag_t;
   46 typedef int cardbus_intr_handle_t;
   47 
   48 
   49 #if rbus
   50 /*
   51  * struct cardbus_functions contains the pointers for basic cardbus
   52  * functions.  Those functions must be provided by cardbus bridge.
   53  * The child devices can use those functions.  The contained functions
   54  * are: cardbus_space_alloc, cardbus_space_free,
   55  * cardbus_intr_establish, cardbus_intr_disestablish, cardbus_ctrl,
   56  * cardbus_power, cardbus_make_tag, cardbus_free_tag and
   57  * cardbus_conf_write.
   58  *
   59  *      int (*cardbus_space_alloc)(cardbus_chipset_tag_t ct, rbus_tag_t rb,
   60  *          bus_addr_t addr, bus_size_t size,
   61  *          bus_addr_t mask, bus_size_t align,
   62  *          int flags, bus_addr_t *addrp,
   63  *          bus_space_handle_t *bshp);
   64  *
   65  *      int (*cardbus_space_free)(cardbus_chipset_tag_t ct, rbus_tag_t rb,
   66  *          bus_space_handle_t, bus_size_t);
   67  *
   68  * cardbus_space_alloc and cardbus_space_free allocates and
   69  * disallocate bus space for the requesters.
   70  *      
   71  *      void *(*cardbus_intr_establish)(cardbus_chipset_tag_t ct, int irq,
   72  *           int level, int (*ih)(void *), void *sc);
   73  *
   74  *      void (*cardbus_intr_disestablish)(cardbus_chipset_tag_t ct, void *ih);
   75  *      int (*cardbus_ctrl)(cardbus_chipset_tag_t ct, int command);
   76  *      int (*cardbus_power)(cardbus_chipset_tag_t ct, int voltage);
   77  *
   78  *      cardbustag_t (*cardbus_make_tag)(cardbus_chipset_tag_t ct,
   79  *          int busno, int devno, int functionno);
   80  *      void (*cardbus_free_tag)(cardbus_chipset_tag_t ct, cardbustag_t tag);
   81  *      cardbusreg_t (*cardbus_conf_read)(cardbus_chipset_tag_t ct,
   82  *          cardbustag_t tag, int offs);
   83  *      void (*cardbus_conf_write)(cardbus_chipset_tag_t ct,
   84  *          cardbustag_t tag, int offs, cardbusreg_t val);
   85  */
   86 typedef struct cardbus_functions {
   87         int (*cardbus_space_alloc) __P((cardbus_chipset_tag_t, rbus_tag_t,
   88             bus_addr_t, bus_size_t, bus_addr_t, bus_size_t,
   89             int, bus_addr_t *, bus_space_handle_t *));
   90         int (*cardbus_space_free) __P((cardbus_chipset_tag_t, rbus_tag_t,
   91             bus_space_handle_t, bus_size_t));
   92         void *(*cardbus_intr_establish) __P((cardbus_chipset_tag_t, int, int,
   93             int (*)(void *), void *));
   94         void (*cardbus_intr_disestablish) __P((cardbus_chipset_tag_t, void *));
   95         int (*cardbus_ctrl) __P((cardbus_chipset_tag_t, int));
   96         int (*cardbus_power) __P((cardbus_chipset_tag_t, int));
   97 
   98         cardbustag_t (*cardbus_make_tag) __P((cardbus_chipset_tag_t, int, int,
   99             int));
  100         void (*cardbus_free_tag) __P((cardbus_chipset_tag_t, cardbustag_t));
  101         cardbusreg_t (*cardbus_conf_read) __P((cardbus_chipset_tag_t,
  102             cardbustag_t, int));
  103         void (*cardbus_conf_write) __P((cardbus_chipset_tag_t, cardbustag_t,
  104             int, cardbusreg_t));
  105 } cardbus_function_t, *cardbus_function_tag_t;
  106 
  107 #else
  108 
  109 typedef struct cardbus_functions {
  110         int (*cardbus_ctrl) __P((cardbus_chipset_tag_t, int));
  111         int (*cardbus_power) __P((cardbus_chipset_tag_t, int));
  112         int (*cardbus_mem_open) __P((cardbus_chipset_tag_t, int, u_int32_t,
  113             u_int32_t));
  114         int (*cardbus_mem_close) __P((cardbus_chipset_tag_t, int));
  115         int (*cardbus_io_open) __P((cardbus_chipset_tag_t, int, u_int32_t,
  116             u_int32_t));
  117         int (*cardbus_io_close) __P((cardbus_chipset_tag_t, int));
  118         void *(*cardbus_intr_establish) __P((cardbus_chipset_tag_t, int, int,
  119             int (*)(void *), void *));
  120         void (*cardbus_intr_disestablish) __P((cardbus_chipset_tag_t, void *));
  121 
  122         cardbustag_t (*cardbus_make_tag) __P((cardbus_chipset_tag_t, int, int,
  123             int));
  124         cardbusreg_t (*cardbus_conf_read) __P((cardbus_chipset_tag_t,
  125             cardbustag_t, int));
  126         void (*cardbus_conf_write) __P((cardbus_chipset_tag_t, cardbustag_t,
  127             int, cardbusreg_t));
  128 } cardbus_function_t, *cardbus_function_tag_t;
  129 #endif /* rbus */
  130 
  131 /*
  132  * struct cbslot_attach_args is the attach argument for cardbus card.
  133  */
  134 struct cbslot_attach_args {
  135         char *cba_busname;
  136         bus_space_tag_t cba_iot;        /* cardbus i/o space tag */
  137         bus_space_tag_t cba_memt;       /* cardbus mem space tag */
  138         bus_dma_tag_t cba_dmat;         /* DMA tag */
  139 
  140         int cba_bus;                    /* cardbus bus number */
  141 
  142         cardbus_chipset_tag_t cba_cc;   /* cardbus chipset */
  143         cardbus_function_tag_t cba_cf; /* cardbus functions */
  144         int cba_intrline;               /* interrupt line */
  145 
  146 #if rbus
  147         rbus_tag_t cba_rbus_iot;        /* CardBus i/o rbus tag */
  148         rbus_tag_t cba_rbus_memt;       /* CardBus mem rbus tag */
  149 #endif
  150 
  151         int cba_cacheline;              /* cache line size */
  152         int cba_lattimer;               /* latency timer */
  153 };
  154 
  155 
  156 #define cbslotcf_dev  cf_loc[0]
  157 #define cbslotcf_func cf_loc[1]
  158 #define CBSLOT_UNK_DEV -1
  159 #define CBSLOT_UNK_FUNC -1
  160 
  161 
  162 struct cardbus_devfunc;
  163 
  164 /*
  165  * struct cardbus_softc is the softc for cardbus card.
  166  */
  167 struct cardbus_softc {
  168         struct device sc_dev;           /* fundamental device structure */
  169 
  170         int sc_bus;                     /* cardbus bus number */
  171         int sc_device;                  /* cardbus device number */
  172         int sc_intrline;                /* CardBus intrline */
  173   
  174         bus_space_tag_t sc_iot;         /* CardBus I/O space tag */
  175         bus_space_tag_t sc_memt;        /* CardBus MEM space tag */
  176         bus_dma_tag_t sc_dmat;          /* DMA tag */
  177 
  178         cardbus_chipset_tag_t sc_cc;    /* CardBus chipset */
  179         cardbus_function_tag_t sc_cf;   /* CardBus function */
  180 
  181 #if rbus
  182         rbus_tag_t sc_rbus_iot;         /* CardBus i/o rbus tag */
  183         rbus_tag_t sc_rbus_memt;        /* CardBus mem rbus tag */
  184 #endif
  185 
  186         int sc_cacheline;               /* cache line size */
  187         int sc_lattimer;                /* latency timer */
  188         int sc_volt;                    /* applied Vcc voltage */
  189 #define PCCARD_33V  0x02
  190 #define PCCARD_XXV  0x04
  191 #define PCCARD_YYV  0x08
  192         int sc_poweron_func;
  193   struct cardbus_devfunc *sc_funcs;     /* list of cardbus device functions */
  194 };
  195 
  196 
  197 /*
  198  * struct cardbus_devfunc:
  199  *
  200  *   This is the data deposit for each function of a CardBus device.
  201  *   This structure is used for memory or i/o space allocation and
  202  *   disallocation.
  203  */
  204 typedef struct cardbus_devfunc {
  205         cardbus_chipset_tag_t ct_cc;
  206         cardbus_function_tag_t ct_cf;
  207         struct cardbus_softc *ct_sc;    /* pointer to the parent */
  208         int ct_bus;                     /* bus number */
  209         int ct_dev;                     /* device number */
  210         int ct_func;                    /* function number */
  211 
  212 #if rbus
  213         rbus_tag_t ct_rbus_iot;         /* CardBus i/o rbus tag */
  214         rbus_tag_t ct_rbus_memt;        /* CardBus mem rbus tag */
  215 #endif
  216 
  217         u_int32_t ct_bar[6];            /* Base Address Regs 0 to 6 */
  218         u_int32_t ct_lc;                /* Latency timer and cache line size */
  219         /* u_int32_t ct_cisreg; */      /* CIS reg: is it needed??? */
  220 
  221         struct device *ct_device;       /* pointer to the device */
  222 
  223         struct cardbus_devfunc *ct_next;
  224 
  225         /* some data structure needed for tuple??? */
  226 } *cardbus_devfunc_t;
  227 
  228 
  229 /* XXX various things extracted from CIS */
  230 struct cardbus_cis_info {
  231         int32_t         manufacturer;
  232         int32_t         product;
  233         char            cis1_info_buf[256];
  234         char*           cis1_info[4];
  235         struct cb_bar_info {
  236                 unsigned int flags;
  237                 unsigned int size;
  238         } bar[7];
  239         unsigned int    funcid;
  240         union {
  241                 struct {
  242                         int uart_type;
  243                         int uart_present;
  244                 } serial;
  245                 struct {
  246                         char netid[6];
  247                         char netid_present;
  248                         char __filler;
  249                 } network;
  250         } funce;
  251 };
  252 
  253 struct cardbus_attach_args {
  254         int ca_unit;
  255         cardbus_devfunc_t ca_ct;
  256 
  257         bus_space_tag_t ca_iot;         /* CardBus I/O space tag */
  258         bus_space_tag_t ca_memt;        /* CardBus MEM space tag */
  259         bus_dma_tag_t ca_dmat;          /* DMA tag */
  260 
  261         u_int ca_bus;
  262         u_int ca_device;
  263         u_int ca_function;
  264         cardbustag_t ca_tag;
  265         cardbusreg_t ca_id;
  266         cardbusreg_t ca_class;
  267 
  268         /* interrupt information */
  269         cardbus_intr_line_t ca_intrline;
  270 
  271 #if rbus
  272         rbus_tag_t ca_rbus_iot;         /* CardBus i/o rbus tag */
  273         rbus_tag_t ca_rbus_memt;        /* CardBus mem rbus tag */
  274 #endif
  275 
  276         struct cardbus_cis_info ca_cis;
  277 };
  278 
  279 
  280 #define CARDBUS_ENABLE  1       /* enable the channel */
  281 #define CARDBUS_DISABLE 2       /* disable the channel */
  282 #define CARDBUS_RESET   4
  283 #define CARDBUS_CD      7
  284 #  define CARDBUS_NOCARD 0
  285 #  define CARDBUS_5V_CARD 0x01  /* XXX: It must not exist */
  286 #  define CARDBUS_3V_CARD 0x02
  287 #  define CARDBUS_XV_CARD 0x04
  288 #  define CARDBUS_YV_CARD 0x08
  289 #define CARDBUS_IO_ENABLE    100
  290 #define CARDBUS_IO_DISABLE   101
  291 #define CARDBUS_MEM_ENABLE   102
  292 #define CARDBUS_MEM_DISABLE  103
  293 #define CARDBUS_BM_ENABLE    104 /* bus master */
  294 #define CARDBUS_BM_DISABLE   105
  295 
  296 #define CARDBUS_VCC_UC  0x0000
  297 #define CARDBUS_VCC_3V  0x0001
  298 #define CARDBUS_VCC_XV  0x0002
  299 #define CARDBUS_VCC_YV  0x0003
  300 #define CARDBUS_VCC_0V  0x0004
  301 #define CARDBUS_VCC_5V  0x0005  /* ??? */
  302 #define CARDBUS_VCCMASK 0x000f
  303 #define CARDBUS_VPP_UC  0x0000
  304 #define CARDBUS_VPP_VCC 0x0010
  305 #define CARDBUS_VPP_12V 0x0030
  306 #define CARDBUS_VPP_0V  0x0040
  307 #define CARDBUS_VPPMASK 0x00f0
  308 
  309 
  310 #include "locators.h"
  311 
  312 /*
  313  * Locators devices that attach to 'cardbus', as specified to config.
  314  */
  315 #define cardbuscf_dev cf_loc[CARDBUSCF_DEV]
  316 #define CARDBUS_UNK_DEV CARDBUSCF_DEV_DEFAULT
  317 
  318 #define cardbuscf_function cf_loc[CARDBUSCF_FUNCTION]
  319 #define CARDBUS_UNK_FUNCTION CARDBUSCF_FUNCTION_DEFAULT
  320 
  321 int cardbus_attach_card __P((struct cardbus_softc *));
  322 void cardbus_detach_card __P((struct cardbus_softc *));
  323 void *cardbus_intr_establish __P((cardbus_chipset_tag_t, cardbus_function_tag_t,
  324     cardbus_intr_handle_t, int, int (*) (void *), void *arg));
  325 void cardbus_intr_disestablish __P((cardbus_chipset_tag_t,
  326     cardbus_function_tag_t, void *));
  327 
  328 int cardbus_mapreg_map __P((struct cardbus_softc *, int, int, cardbusreg_t,
  329     int, bus_space_tag_t *, bus_space_handle_t *, bus_addr_t *, bus_size_t *));
  330 int cardbus_mapreg_unmap __P((struct cardbus_softc *, int, int,
  331     bus_space_tag_t, bus_space_handle_t, bus_size_t));
  332 
  333 int cardbus_save_bar __P((cardbus_devfunc_t));
  334 int cardbus_restore_bar __P((cardbus_devfunc_t));
  335 
  336 int cardbus_function_enable __P((struct cardbus_softc *, int));
  337 int cardbus_function_disable __P((struct cardbus_softc *, int));
  338 
  339 int cardbus_get_capability __P((cardbus_chipset_tag_t, cardbus_function_tag_t,
  340     cardbustag_t, int, int *, cardbusreg_t *));
  341 
  342 #define Cardbus_function_enable(ct) cardbus_function_enable((ct)->ct_sc, (ct)->ct_func)
  343 #define Cardbus_function_disable(ct) cardbus_function_disable((ct)->ct_sc, (ct)->ct_func)
  344 
  345 
  346 
  347 #define Cardbus_mapreg_map(ct, reg, type, busflags, tagp, handlep, basep, sizep) \
  348         cardbus_mapreg_map((ct)->ct_sc, (ct->ct_func), (reg), (type),\
  349                            (busflags), (tagp), (handlep), (basep), (sizep))
  350 #define Cardbus_mapreg_unmap(ct, reg, tag, handle, size) \
  351         cardbus_mapreg_unmap((ct)->ct_sc, (ct->ct_func), (reg), (tag), (handle), (size))
  352 
  353 #define Cardbus_make_tag(ct) (*(ct)->ct_cf->cardbus_make_tag)((ct)->ct_cc, (ct)->ct_bus, (ct)->ct_dev, (ct)->ct_func)
  354 #define cardbus_make_tag(cc, cf, bus, device, function) ((cf)->cardbus_make_tag)((cc), (bus), (device), (function))
  355 
  356 #define Cardbus_free_tag(ct, tag) (*(ct)->ct_cf->cardbus_free_tag)((ct)->ct_cc, (tag))
  357 #define cardbus_free_tag(cc, cf, tag) (*(cf)->cardbus_free_tag)(cc, (tag))
  358 
  359 #define Cardbus_conf_read(ct, tag, offs) (*(ct)->ct_cf->cardbus_conf_read)((ct)->ct_cf, (tag), (offs))
  360 #define cardbus_conf_read(cc, cf, tag, offs) ((cf)->cardbus_conf_read)((cc), (tag), (offs))
  361 #define Cardbus_conf_write(ct, tag, offs, val) (*(ct)->ct_cf->cardbus_conf_write)((ct)->ct_cf, (tag), (offs), (val))
  362 #define cardbus_conf_write(cc, cf, tag, offs, val) ((cf)->cardbus_conf_write)((cc), (tag), (offs), (val))
  363 
  364 #endif /* !_DEV_CARDBUS_CARDBUSVAR_H_ */

Cache object: bbdd50f6b627b9594b30ab06b075cec4


[ 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.