aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ipack
diff options
context:
space:
mode:
authorSamuel Iglesias Gonsalvez <siglesias@igalia.com>2012-11-16 13:33:45 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-16 14:29:35 -0500
commit7dbce021a6df9d4812385d11729140829abc3f95 (patch)
treeedc216569234ff566e84bc692800f4f945658925 /drivers/ipack
parent14dc124f1b2feebe1883bb8b51545d26eaca99b7 (diff)
ipack: move header files to include/linux
Move ipack header files to include/linux/ directory where they belong. Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/ipack')
-rw-r--r--drivers/ipack/carriers/tpci200.h3
-rw-r--r--drivers/ipack/devices/ipoctal.c3
-rw-r--r--drivers/ipack/ipack.c3
-rw-r--r--drivers/ipack/ipack.h215
4 files changed, 5 insertions, 219 deletions
diff --git a/drivers/ipack/carriers/tpci200.h b/drivers/ipack/carriers/tpci200.h
index 8d9be277b34d..a7a151dab83c 100644
--- a/drivers/ipack/carriers/tpci200.h
+++ b/drivers/ipack/carriers/tpci200.h
@@ -20,8 +20,7 @@
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/swab.h> 21#include <linux/swab.h>
22#include <linux/io.h> 22#include <linux/io.h>
23 23#include <linux/ipack.h>
24#include "../ipack.h"
25 24
26#define TPCI200_NB_SLOT 0x4 25#define TPCI200_NB_SLOT 0x4
27#define TPCI200_NB_BAR 0x6 26#define TPCI200_NB_BAR 0x6
diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c
index 783f120338d1..7f568e268a1e 100644
--- a/drivers/ipack/devices/ipoctal.c
+++ b/drivers/ipack/devices/ipoctal.c
@@ -22,7 +22,8 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include <linux/atomic.h> 23#include <linux/atomic.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include "../ipack.h" 25#include <linux/ipack.h>
26#include "../ipack_ids.h"
26#include "ipoctal.h" 27#include "ipoctal.h"
27#include "scc2698.h" 28#include "scc2698.h"
28 29
diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c
index 6d5079de52b9..cc5498347acb 100644
--- a/drivers/ipack/ipack.c
+++ b/drivers/ipack/ipack.c
@@ -13,7 +13,8 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/idr.h> 14#include <linux/idr.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include "ipack.h" 16#include <linux/ipack.h>
17#include "ipack_ids.h"
17 18
18#define to_ipack_dev(device) container_of(device, struct ipack_device, dev) 19#define to_ipack_dev(device) container_of(device, struct ipack_device, dev)
19#define to_ipack_driver(drv) container_of(drv, struct ipack_driver, driver) 20#define to_ipack_driver(drv) container_of(drv, struct ipack_driver, driver)
diff --git a/drivers/ipack/ipack.h b/drivers/ipack/ipack.h
deleted file mode 100644
index 6760bfaf0ac4..000000000000
--- a/drivers/ipack/ipack.h
+++ /dev/null
@@ -1,215 +0,0 @@
1/*
2 * Industry-pack bus.
3 *
4 * Copyright (C) 2011-2012 CERN (www.cern.ch)
5 * Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
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
31struct ipack_bus_ops;
32struct ipack_driver;
33
34enum ipack_space {
35 IPACK_IO_SPACE = 0,
36 IPACK_ID_SPACE,
37 IPACK_INT_SPACE,
38 IPACK_MEM8_SPACE,
39 IPACK_MEM16_SPACE,
40 /* Dummy for counting the number of entries. Must remain the last
41 * entry */
42 IPACK_SPACE_COUNT,
43};
44
45/**
46 */
47struct ipack_region {
48 phys_addr_t start;
49 size_t size;
50};
51
52/**
53 * struct ipack_device
54 *
55 * @slot: Slot where the device is plugged in the carrier board
56 * @bus: ipack_bus_device where the device is plugged to.
57 * @id_space: Virtual address to ID space.
58 * @io_space: Virtual address to IO space.
59 * @mem_space: Virtual address to MEM space.
60 * @dev: device in kernel representation.
61 *
62 * Warning: Direct access to mapped memory is possible but the endianness
63 * is not the same with PCI carrier or VME carrier. The endianness is managed
64 * by the carrier board throught bus->ops.
65 */
66struct ipack_device {
67 unsigned int slot;
68 struct ipack_bus_device *bus;
69 struct device dev;
70 void (*release) (struct ipack_device *dev);
71 struct ipack_region region[IPACK_SPACE_COUNT];
72 u8 *id;
73 size_t id_avail;
74 u32 id_vendor;
75 u32 id_device;
76 u8 id_format;
77 unsigned int id_crc_correct:1;
78 unsigned int speed_8mhz:1;
79 unsigned int speed_32mhz:1;
80};
81
82/**
83 * struct ipack_driver_ops -- Callbacks to IPack device driver
84 *
85 * @probe: Probe function
86 * @remove: Prepare imminent removal of the device. Services provided by the
87 * device should be revoked.
88 */
89
90struct ipack_driver_ops {
91 int (*probe) (struct ipack_device *dev);
92 void (*remove) (struct ipack_device *dev);
93};
94
95/**
96 * struct ipack_driver -- Specific data to each ipack device driver
97 *
98 * @driver: Device driver kernel representation
99 * @ops: Callbacks provided by the IPack device driver
100 */
101struct ipack_driver {
102 struct device_driver driver;
103 const struct ipack_device_id *id_table;
104 const struct ipack_driver_ops *ops;
105};
106
107/**
108 * struct ipack_bus_ops - available operations on a bridge module
109 *
110 * @map_space: map IP address space
111 * @unmap_space: unmap IP address space
112 * @request_irq: request IRQ
113 * @free_irq: free IRQ
114 * @get_clockrate: Returns the clockrate the carrier is currently
115 * communicating with the device at.
116 * @set_clockrate: Sets the clock-rate for carrier / module communication.
117 * Should return -EINVAL if the requested speed is not supported.
118 * @get_error: Returns the error state for the slot the device is attached
119 * to.
120 * @get_timeout: Returns 1 if the communication with the device has
121 * previously timed out.
122 * @reset_timeout: Resets the state returned by get_timeout.
123 */
124struct ipack_bus_ops {
125 int (*request_irq) (struct ipack_device *dev,
126 irqreturn_t (*handler)(void *), void *arg);
127 int (*free_irq) (struct ipack_device *dev);
128 int (*get_clockrate) (struct ipack_device *dev);
129 int (*set_clockrate) (struct ipack_device *dev, int mherz);
130 int (*get_error) (struct ipack_device *dev);
131 int (*get_timeout) (struct ipack_device *dev);
132 int (*reset_timeout) (struct ipack_device *dev);
133};
134
135/**
136 * struct ipack_bus_device
137 *
138 * @dev: pointer to carrier device
139 * @slots: number of slots available
140 * @bus_nr: ipack bus number
141 * @ops: bus operations for the mezzanine drivers
142 */
143struct ipack_bus_device {
144 struct device *parent;
145 int slots;
146 int bus_nr;
147 const struct ipack_bus_ops *ops;
148};
149
150/**
151 * ipack_bus_register -- register a new ipack bus
152 *
153 * @parent: pointer to the parent device, if any.
154 * @slots: number of slots available in the bus device.
155 * @ops: bus operations for the mezzanine drivers.
156 *
157 * The carrier board device should call this function to register itself as
158 * available bus device in ipack.
159 */
160struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
161 const struct ipack_bus_ops *ops);
162
163/**
164 * ipack_bus_unregister -- unregister an ipack bus
165 */
166int ipack_bus_unregister(struct ipack_bus_device *bus);
167
168/**
169 * ipack_driver_register -- Register a new ipack device driver
170 *
171 * Called by a ipack driver to register itself as a driver
172 * that can manage ipack devices.
173 */
174int ipack_driver_register(struct ipack_driver *edrv, struct module *owner,
175 const char *name);
176void ipack_driver_unregister(struct ipack_driver *edrv);
177
178/**
179 * ipack_device_register -- register an IPack device with the kernel
180 * @dev: the new device to register.
181 *
182 * Register a new IPack device ("module" in IndustryPack jargon). The call
183 * is done by the carrier driver. The carrier should populate the fields
184 * bus and slot as well as the region array of @dev prior to calling this
185 * function. The rest of the fields will be allocated and populated
186 * during registration.
187 *
188 * Return zero on success or error code on failure.
189 */
190int ipack_device_register(struct ipack_device *dev);
191void ipack_device_unregister(struct ipack_device *dev);
192
193/**
194 * DEFINE_IPACK_DEVICE_TABLE - macro used to describe a IndustryPack table
195 * @_table: device table name
196 *
197 * This macro is used to create a struct ipack_device_id array (a device table)
198 * in a generic manner.
199 */
200#define DEFINE_IPACK_DEVICE_TABLE(_table) \
201 const struct ipack_device_id _table[] __devinitconst
202
203/**
204 * IPACK_DEVICE - macro used to describe a specific IndustryPack device
205 * @_format: the format version (currently either 1 or 2, 8 bit value)
206 * @vend: the 8 or 24 bit IndustryPack Vendor ID
207 * @dev: the 8 or 16 bit IndustryPack Device ID
208 *
209 * This macro is used to create a struct ipack_device_id that matches a specific
210 * device.
211 */
212#define IPACK_DEVICE(_format, vend, dev) \
213 .format = (_format), \
214 .vendor = (vend), \
215 .device = (dev)