Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  * cs_internal.h
  3  *
  4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Public License version 2 as
  6  * published by the Free Software Foundation.
  7  *
  8  * The initial developer of the original code is David A. Hinds
  9  * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
 10  * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
 11  *
 12  * (C) 1999             David A. Hinds
 13  */
 14 
 15 #ifndef _LINUX_CS_INTERNAL_H
 16 #define _LINUX_CS_INTERNAL_H
 17 
 18 #include <linux/config.h>
 19 
 20 #define CLIENT_MAGIC    0x51E6
 21 typedef struct client_t client_t;
 22 
 23 /* Flags in client state */
 24 #define CLIENT_CONFIG_LOCKED    0x0001
 25 #define CLIENT_IRQ_REQ          0x0002
 26 #define CLIENT_IO_REQ           0x0004
 27 #define CLIENT_UNBOUND          0x0008
 28 #define CLIENT_STALE            0x0010
 29 #define CLIENT_WIN_REQ(i)       (0x20<<(i))
 30 #define CLIENT_CARDBUS          0x8000
 31 
 32 #define REGION_MAGIC    0xE3C9
 33 typedef struct region_t {
 34     u_short             region_magic;
 35     u_short             state;
 36     dev_info_t          dev_info;
 37     client_handle_t     mtd;
 38     u_int               MediaID;
 39     region_info_t       info;
 40 } region_t;
 41 
 42 #define REGION_STALE    0x01
 43 
 44 /* Each card function gets one of these guys */
 45 typedef struct config_t {
 46     u_int               state;
 47     u_int               Attributes;
 48     u_int               Vcc, Vpp1, Vpp2;
 49     u_int               IntType;
 50     u_int               ConfigBase;
 51     u_char              Status, Pin, Copy, Option, ExtStatus;
 52     u_int               Present;
 53     u_int               CardValues;
 54     io_req_t            io;
 55     struct {
 56         u_int           Attributes;
 57     } irq;
 58 } config_t;
 59 
 60 struct cis_cache_entry {
 61         struct list_head        node;
 62         unsigned int            addr;
 63         unsigned int            len;
 64         unsigned int            attr;
 65         unsigned char           cache[0];
 66 };
 67 
 68 /* Flags in config state */
 69 #define CONFIG_LOCKED           0x01
 70 #define CONFIG_IRQ_REQ          0x02
 71 #define CONFIG_IO_REQ           0x04
 72 
 73 /* Flags in socket state */
 74 #define SOCKET_PRESENT          0x0008
 75 #define SOCKET_INUSE            0x0010
 76 #define SOCKET_SUSPEND          0x0080
 77 #define SOCKET_WIN_REQ(i)       (0x0100<<(i))
 78 #define SOCKET_REGION_INFO      0x4000
 79 #define SOCKET_CARDBUS          0x8000
 80 #define SOCKET_CARDBUS_CONFIG   0x10000
 81 
 82 static inline int cs_socket_get(struct pcmcia_socket *skt)
 83 {
 84         int ret;
 85 
 86         WARN_ON(skt->state & SOCKET_INUSE);
 87 
 88         ret = try_module_get(skt->owner);
 89         if (ret)
 90                 skt->state |= SOCKET_INUSE;
 91         return ret;
 92 }
 93 
 94 static inline void cs_socket_put(struct pcmcia_socket *skt)
 95 {
 96         if (skt->state & SOCKET_INUSE) {
 97                 skt->state &= ~SOCKET_INUSE;
 98                 module_put(skt->owner);
 99         }
100 }
101 
102 #define CHECK_HANDLE(h) \
103     (((h) == NULL) || ((h)->client_magic != CLIENT_MAGIC))
104 
105 #define CHECK_SOCKET(s) \
106     (((s) >= sockets) || (socket_table[s]->ops == NULL))
107 
108 #define SOCKET(h) (h->Socket)
109 #define CONFIG(h) (&SOCKET(h)->config[(h)->Function])
110 
111 #define CHECK_REGION(r) \
112     (((r) == NULL) || ((r)->region_magic != REGION_MAGIC))
113 
114 #define CHECK_ERASEQ(q) \
115     (((q) == NULL) || ((q)->eraseq_magic != ERASEQ_MAGIC))
116 
117 #define EVENT(h, e, p) \
118     ((h)->event_handler((e), (p), &(h)->event_callback_args))
119 
120 /* In cardbus.c */
121 int cb_alloc(struct pcmcia_socket *s);
122 void cb_free(struct pcmcia_socket *s);
123 int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len, void *ptr);
124 
125 /* In cistpl.c */
126 int read_cis_mem(struct pcmcia_socket *s, int attr,
127                  u_int addr, u_int len, void *ptr);
128 void write_cis_mem(struct pcmcia_socket *s, int attr,
129                    u_int addr, u_int len, void *ptr);
130 void release_cis_mem(struct pcmcia_socket *s);
131 void destroy_cis_cache(struct pcmcia_socket *s);
132 int verify_cis_cache(struct pcmcia_socket *s);
133 int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse);
134 
135 /* In rsrc_mgr */
136 void pcmcia_validate_mem(struct pcmcia_socket *s);
137 struct resource *find_io_region(unsigned long base, int num, unsigned long align,
138                    struct pcmcia_socket *s);
139 int adjust_io_region(struct resource *res, unsigned long r_start,
140                      unsigned long r_end, struct pcmcia_socket *s);
141 struct resource *find_mem_region(u_long base, u_long num, u_long align,
142                     int low, struct pcmcia_socket *s);
143 int adjust_resource_info(client_handle_t handle, adjust_t *adj);
144 void release_resource_db(struct pcmcia_socket *s);
145 
146 /* In socket_sysfs.c */
147 extern struct class_interface pccard_sysfs_interface;
148 
149 /* In cs.c */
150 extern struct rw_semaphore pcmcia_socket_list_rwsem;
151 extern struct list_head pcmcia_socket_list;
152 int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req);
153 int pccard_get_configuration_info(struct pcmcia_socket *s, unsigned int function, config_info_t *config);
154 int pccard_reset_card(struct pcmcia_socket *skt);
155 int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status);
156 int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int function, conf_reg_t *reg);
157 
158 
159 struct pcmcia_callback{
160         struct module   *owner;
161         int             (*event) (struct pcmcia_socket *s, event_t event, int priority);
162 };
163 
164 int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
165 
166 #define cs_socket_name(skt)     ((skt)->dev.class_id)
167 
168 #ifdef DEBUG
169 extern int cs_debug_level(int);
170 
171 #define cs_dbg(skt, lvl, fmt, arg...) do {              \
172         if (cs_debug_level(lvl))                        \
173                 printk(KERN_DEBUG "cs: %s: " fmt,       \
174                        cs_socket_name(skt) , ## arg);   \
175 } while (0)
176 
177 #else
178 #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0)
179 #endif
180 
181 #define cs_err(skt, fmt, arg...) \
182         printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.class_id , ## arg)
183 
184 #endif /* _LINUX_CS_INTERNAL_H */
185 
  This page was automatically generated by the LXR engine.