7 * This file contains OS dependent structures.
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 #include <linux/compiler.h>
32 #include <linux/version.h>
34 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
35 # include <linux/irq.h>
38 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
39 # include <linux/usb/ch9.h>
41 # include <linux/usb_ch9.h>
44 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
45 # include <linux/usb/gadget.h>
47 # include <linux/usb_gadget.h>
50 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
59 # include <asm/unaligned.h>
60 # include <asm/sizes.h>
61 # include <asm/param.h>
63 # if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
64 # include <asm/arch/hardware.h>
65 # include <asm/arch/lm.h>
66 # include <asm/arch/irqs.h>
67 # include <asm/arch/regs-irq.h>
69 /* in 2.6.31, at least, we seem to have lost the generic LM infrastructure -
70 here we assume that the machine architecture provides definitions
74 # include <mach/hardware.h>
78 #ifdef PLATFORM_INTERFACE
79 #include <linux/platform_device.h>
81 #include <asm/mach/map.h>
85 /** The OS page size */
86 #define DWC_OS_PAGE_SIZE PAGE_SIZE
88 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
92 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
93 # define IRQF_SHARED SA_SHIRQ
96 typedef struct os_dependent {
97 /** Base address returned from ioremap() */
100 /** Register offset for Diagnostic API */
103 /** Base address for MPHI peripheral */
106 /** mphi_base actually points to the SWIRQ block */
109 /** IRQ number (<0 if not valid) */
112 /** FIQ number (<0 if not valid) */
116 struct lm_device *lmdev;
117 #elif defined(PCI_INTERFACE)
118 struct pci_dev *pcidev;
120 /** Start address of a PCI region */
121 resource_size_t rsrc_start;
123 /** Length address of a PCI region */
124 resource_size_t rsrc_len;
125 #elif defined(PLATFORM_INTERFACE)
126 struct platform_device *platformdev;
137 /* Type for the our device on the chosen bus */
138 #if defined(LM_INTERFACE)
139 typedef struct lm_device dwc_bus_dev_t;
140 #elif defined(PCI_INTERFACE)
141 typedef struct pci_dev dwc_bus_dev_t;
142 #elif defined(PLATFORM_INTERFACE)
143 typedef struct platform_device dwc_bus_dev_t;
146 /* Helper macro to retrieve drvdata from the device on the chosen bus */
147 #if defined(LM_INTERFACE)
148 #define DWC_OTG_BUSDRVDATA(_dev) lm_get_drvdata(_dev)
149 #elif defined(PCI_INTERFACE)
150 #define DWC_OTG_BUSDRVDATA(_dev) pci_get_drvdata(_dev)
151 #elif defined(PLATFORM_INTERFACE)
152 #define DWC_OTG_BUSDRVDATA(_dev) platform_get_drvdata(_dev)
156 * Helper macro returning the otg_device structure of a given struct device
158 * c.f. static dwc_otg_device_t *dwc_otg_drvdev(struct device *_dev)
161 #define DWC_OTG_GETDRVDEV(_var, _dev) do { \
162 struct lm_device *lm_dev = \
163 container_of(_dev, struct lm_device, dev); \
164 _var = lm_get_drvdata(lm_dev); \
167 #elif defined(PCI_INTERFACE)
168 #define DWC_OTG_GETDRVDEV(_var, _dev) do { \
169 _var = dev_get_drvdata(_dev); \
172 #elif defined(PLATFORM_INTERFACE)
173 #define DWC_OTG_GETDRVDEV(_var, _dev) do { \
174 struct platform_device *platform_dev = \
175 container_of(_dev, struct platform_device, dev); \
176 _var = platform_get_drvdata(platform_dev); \
182 * Helper macro returning the struct dev of the given struct os_dependent
184 * c.f. static struct device *dwc_otg_getdev(struct os_dependent *osdep)
187 #define DWC_OTG_OS_GETDEV(_osdep) \
188 ((_osdep).lmdev == NULL? NULL: &(_osdep).lmdev->dev)
189 #elif defined(PCI_INTERFACE)
190 #define DWC_OTG_OS_GETDEV(_osdep) \
191 ((_osdep).pci_dev == NULL? NULL: &(_osdep).pci_dev->dev)
192 #elif defined(PLATFORM_INTERFACE)
193 #define DWC_OTG_OS_GETDEV(_osdep) \
194 ((_osdep).platformdev == NULL? NULL: &(_osdep).platformdev->dev)
200 #endif /* _DWC_OS_DEP_H_ */