Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ipack.h
Go to the documentation of this file.
1 /*
2  * Industry-pack bus.
3  *
4  * (C) 2011 Samuel Iglesias Gonsalvez <[email protected]>, CERN
5  * (C) 2012 Samuel Iglesias Gonsalvez <[email protected]>, Igalia
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; version 2 of the License.
10  */
11 
12 #include <linux/mod_devicetable.h>
13 #include <linux/device.h>
14 #include <linux/interrupt.h>
15 
16 #include "ipack_ids.h"
17 
18 #define IPACK_IDPROM_OFFSET_I 0x01
19 #define IPACK_IDPROM_OFFSET_P 0x03
20 #define IPACK_IDPROM_OFFSET_A 0x05
21 #define IPACK_IDPROM_OFFSET_C 0x07
22 #define IPACK_IDPROM_OFFSET_MANUFACTURER_ID 0x09
23 #define IPACK_IDPROM_OFFSET_MODEL 0x0B
24 #define IPACK_IDPROM_OFFSET_REVISION 0x0D
25 #define IPACK_IDPROM_OFFSET_RESERVED 0x0F
26 #define IPACK_IDPROM_OFFSET_DRIVER_ID_L 0x11
27 #define IPACK_IDPROM_OFFSET_DRIVER_ID_H 0x13
28 #define IPACK_IDPROM_OFFSET_NUM_BYTES 0x15
29 #define IPACK_IDPROM_OFFSET_CRC 0x17
30 
31 struct ipack_bus_ops;
32 struct ipack_driver;
33 
39 };
40 
49  unsigned int size;
50 };
51 
67 struct ipack_device {
68  unsigned int bus_nr;
69  unsigned int slot;
75  struct device dev;
76  u8 *id;
77  size_t id_avail;
81  unsigned int id_crc_correct:1;
82  unsigned int speed_8mhz:1;
83  unsigned int speed_32mhz:1;
84 };
85 
94  int (*probe) (struct ipack_device *dev);
95  void (*remove) (struct ipack_device *dev);
96 };
97 
104 struct ipack_driver {
106  const struct ipack_device_id *id_table;
107  const struct ipack_driver_ops *ops;
108 };
109 
128  int (*map_space) (struct ipack_device *dev, unsigned int memory_size, int space);
129  int (*unmap_space) (struct ipack_device *dev, int space);
131  irqreturn_t (*handler)(void *), void *arg);
132  int (*free_irq) (struct ipack_device *dev);
134  int (*set_clockrate) (struct ipack_device *dev, int mherz);
138 };
139 
149  struct device *parent;
150  int slots;
151  int bus_nr;
152  const struct ipack_bus_ops *ops;
153 };
154 
166  const struct ipack_bus_ops *ops);
167 
172 
179 int ipack_driver_register(struct ipack_driver *edrv, struct module *owner,
180  const char *name);
181 void ipack_driver_unregister(struct ipack_driver *edrv);
182 
194 
202 #define DEFINE_IPACK_DEVICE_TABLE(_table) \
203  const struct ipack_device_id _table[] __devinitconst
204 
214 #define IPACK_DEVICE(_format, vend, dev) \
215  .format = (_format), \
216  .vendor = (vend), \
217  .device = (dev)