This source file includes following definitions.
- macio_resource_count
- macio_resource_start
- macio_resource_end
- macio_resource_len
- macio_irq_count
- macio_irq
- macio_set_drvdata
- macio_get_drvdata
- macio_get_of_node
- macio_get_pci_dev
1
2 #ifndef __MACIO_ASIC_H__
3 #define __MACIO_ASIC_H__
4 #ifdef __KERNEL__
5
6 #include <linux/of_device.h>
7
8 extern struct bus_type macio_bus_type;
9
10
11 struct macio_driver;
12 struct macio_chip;
13
14 #define MACIO_DEV_COUNT_RESOURCES 8
15 #define MACIO_DEV_COUNT_IRQS 8
16
17
18
19
20
21
22
23
24
25 struct macio_bus
26 {
27 struct macio_chip *chip;
28 int index;
29 #ifdef CONFIG_PCI
30 struct pci_dev *pdev;
31 #endif
32 };
33
34
35
36
37
38 struct macio_dev
39 {
40 struct macio_bus *bus;
41 struct macio_dev *media_bay;
42 struct platform_device ofdev;
43 struct device_dma_parameters dma_parms;
44 int n_resources;
45 struct resource resource[MACIO_DEV_COUNT_RESOURCES];
46 int n_interrupts;
47 struct resource interrupt[MACIO_DEV_COUNT_IRQS];
48 };
49 #define to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
50 #define of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
51
52 extern struct macio_dev *macio_dev_get(struct macio_dev *dev);
53 extern void macio_dev_put(struct macio_dev *dev);
54
55
56
57
58
59
60 static inline int macio_resource_count(struct macio_dev *dev)
61 {
62 return dev->n_resources;
63 }
64
65 static inline unsigned long macio_resource_start(struct macio_dev *dev, int resource_no)
66 {
67 return dev->resource[resource_no].start;
68 }
69
70 static inline unsigned long macio_resource_end(struct macio_dev *dev, int resource_no)
71 {
72 return dev->resource[resource_no].end;
73 }
74
75 static inline unsigned long macio_resource_len(struct macio_dev *dev, int resource_no)
76 {
77 struct resource *res = &dev->resource[resource_no];
78 if (res->start == 0 || res->end == 0 || res->end < res->start)
79 return 0;
80 return resource_size(res);
81 }
82
83 extern int macio_enable_devres(struct macio_dev *dev);
84
85 extern int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name);
86 extern void macio_release_resource(struct macio_dev *dev, int resource_no);
87 extern int macio_request_resources(struct macio_dev *dev, const char *name);
88 extern void macio_release_resources(struct macio_dev *dev);
89
90 static inline int macio_irq_count(struct macio_dev *dev)
91 {
92 return dev->n_interrupts;
93 }
94
95 static inline int macio_irq(struct macio_dev *dev, int irq_no)
96 {
97 return dev->interrupt[irq_no].start;
98 }
99
100 static inline void macio_set_drvdata(struct macio_dev *dev, void *data)
101 {
102 dev_set_drvdata(&dev->ofdev.dev, data);
103 }
104
105 static inline void* macio_get_drvdata(struct macio_dev *dev)
106 {
107 return dev_get_drvdata(&dev->ofdev.dev);
108 }
109
110 static inline struct device_node *macio_get_of_node(struct macio_dev *mdev)
111 {
112 return mdev->ofdev.dev.of_node;
113 }
114
115 #ifdef CONFIG_PCI
116 static inline struct pci_dev *macio_get_pci_dev(struct macio_dev *mdev)
117 {
118 return mdev->bus->pdev;
119 }
120 #endif
121
122
123
124
125 struct macio_driver
126 {
127 int (*probe)(struct macio_dev* dev, const struct of_device_id *match);
128 int (*remove)(struct macio_dev* dev);
129
130 int (*suspend)(struct macio_dev* dev, pm_message_t state);
131 int (*resume)(struct macio_dev* dev);
132 int (*shutdown)(struct macio_dev* dev);
133
134 #ifdef CONFIG_PMAC_MEDIABAY
135 void (*mediabay_event)(struct macio_dev* dev, int mb_state);
136 #endif
137 struct device_driver driver;
138 };
139 #define to_macio_driver(drv) container_of(drv,struct macio_driver, driver)
140
141 extern int macio_register_driver(struct macio_driver *);
142 extern void macio_unregister_driver(struct macio_driver *);
143
144 #endif
145 #endif