]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/usb/host/dwc_otg/dwc_otg_os_dep.h
ARM64/DWC_OTG: Port dwc_otg driver to ARM64
[mirror_ubuntu-artful-kernel.git] / drivers / usb / host / dwc_otg / dwc_otg_os_dep.h
1 #ifndef _DWC_OS_DEP_H_
2 #define _DWC_OS_DEP_H_
3
4 /**
5 * @file
6 *
7 * This file contains OS dependent structures.
8 *
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/init.h>
15 #include <linux/device.h>
16 #include <linux/errno.h>
17 #include <linux/types.h>
18 #include <linux/slab.h>
19 #include <linux/list.h>
20 #include <linux/interrupt.h>
21 #include <linux/ctype.h>
22 #include <linux/string.h>
23 #include <linux/dma-mapping.h>
24 #include <linux/jiffies.h>
25 #include <linux/delay.h>
26 #include <linux/timer.h>
27 #include <linux/workqueue.h>
28 #include <linux/stat.h>
29 #include <linux/pci.h>
30
31 #include <linux/version.h>
32
33 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
34 # include <linux/irq.h>
35 #endif
36
37 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
38 # include <linux/usb/ch9.h>
39 #else
40 # include <linux/usb_ch9.h>
41 #endif
42
43 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
44 # include <linux/usb/gadget.h>
45 #else
46 # include <linux/usb_gadget.h>
47 #endif
48
49 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
50 # include <asm/irq.h>
51 #endif
52
53 #ifdef PCI_INTERFACE
54 # include <asm/io.h>
55 #endif
56
57 #ifdef LM_INTERFACE
58 # include <asm/unaligned.h>
59 # include <asm/sizes.h>
60 # include <asm/param.h>
61 # include <asm/io.h>
62 # if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
63 # include <asm/arch/hardware.h>
64 # include <asm/arch/lm.h>
65 # include <asm/arch/irqs.h>
66 # include <asm/arch/regs-irq.h>
67 # else
68 /* in 2.6.31, at least, we seem to have lost the generic LM infrastructure -
69 here we assume that the machine architecture provides definitions
70 in its own header
71 */
72 # include <mach/lm.h>
73 # include <mach/hardware.h>
74 # endif
75 #endif
76
77 #ifdef PLATFORM_INTERFACE
78 #include <linux/platform_device.h>
79 #ifdef CONFIG_ARM
80 #include <asm/mach/map.h>
81 #endif
82 #endif
83
84 /** The OS page size */
85 #define DWC_OS_PAGE_SIZE PAGE_SIZE
86
87 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
88 typedef int gfp_t;
89 #endif
90
91 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
92 # define IRQF_SHARED SA_SHIRQ
93 #endif
94
95 typedef struct os_dependent {
96 /** Base address returned from ioremap() */
97 void *base;
98
99 /** Register offset for Diagnostic API */
100 uint32_t reg_offset;
101
102 /** Base address for MPHI peripheral */
103 void *mphi_base;
104
105 #ifdef LM_INTERFACE
106 struct lm_device *lmdev;
107 #elif defined(PCI_INTERFACE)
108 struct pci_dev *pcidev;
109
110 /** Start address of a PCI region */
111 resource_size_t rsrc_start;
112
113 /** Length address of a PCI region */
114 resource_size_t rsrc_len;
115 #elif defined(PLATFORM_INTERFACE)
116 struct platform_device *platformdev;
117 #endif
118
119 } os_dependent_t;
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125
126
127 /* Type for the our device on the chosen bus */
128 #if defined(LM_INTERFACE)
129 typedef struct lm_device dwc_bus_dev_t;
130 #elif defined(PCI_INTERFACE)
131 typedef struct pci_dev dwc_bus_dev_t;
132 #elif defined(PLATFORM_INTERFACE)
133 typedef struct platform_device dwc_bus_dev_t;
134 #endif
135
136 /* Helper macro to retrieve drvdata from the device on the chosen bus */
137 #if defined(LM_INTERFACE)
138 #define DWC_OTG_BUSDRVDATA(_dev) lm_get_drvdata(_dev)
139 #elif defined(PCI_INTERFACE)
140 #define DWC_OTG_BUSDRVDATA(_dev) pci_get_drvdata(_dev)
141 #elif defined(PLATFORM_INTERFACE)
142 #define DWC_OTG_BUSDRVDATA(_dev) platform_get_drvdata(_dev)
143 #endif
144
145 /**
146 * Helper macro returning the otg_device structure of a given struct device
147 *
148 * c.f. static dwc_otg_device_t *dwc_otg_drvdev(struct device *_dev)
149 */
150 #ifdef LM_INTERFACE
151 #define DWC_OTG_GETDRVDEV(_var, _dev) do { \
152 struct lm_device *lm_dev = \
153 container_of(_dev, struct lm_device, dev); \
154 _var = lm_get_drvdata(lm_dev); \
155 } while (0)
156
157 #elif defined(PCI_INTERFACE)
158 #define DWC_OTG_GETDRVDEV(_var, _dev) do { \
159 _var = dev_get_drvdata(_dev); \
160 } while (0)
161
162 #elif defined(PLATFORM_INTERFACE)
163 #define DWC_OTG_GETDRVDEV(_var, _dev) do { \
164 struct platform_device *platform_dev = \
165 container_of(_dev, struct platform_device, dev); \
166 _var = platform_get_drvdata(platform_dev); \
167 } while (0)
168 #endif
169
170
171 /**
172 * Helper macro returning the struct dev of the given struct os_dependent
173 *
174 * c.f. static struct device *dwc_otg_getdev(struct os_dependent *osdep)
175 */
176 #ifdef LM_INTERFACE
177 #define DWC_OTG_OS_GETDEV(_osdep) \
178 ((_osdep).lmdev == NULL? NULL: &(_osdep).lmdev->dev)
179 #elif defined(PCI_INTERFACE)
180 #define DWC_OTG_OS_GETDEV(_osdep) \
181 ((_osdep).pci_dev == NULL? NULL: &(_osdep).pci_dev->dev)
182 #elif defined(PLATFORM_INTERFACE)
183 #define DWC_OTG_OS_GETDEV(_osdep) \
184 ((_osdep).platformdev == NULL? NULL: &(_osdep).platformdev->dev)
185 #endif
186
187
188
189
190 #endif /* _DWC_OS_DEP_H_ */