4 * Copyright (C) 2014 MEN Mikroelektronik GmbH (www.men.de)
5 * Author: Johannes Thumshirn <johannes.thumshirn@men.de>
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.
14 #include <linux/mod_devicetable.h>
15 #include <linux/device.h>
16 #include <linux/irqreturn.h>
22 * struct mcb_bus - MEN Chameleon Bus
24 * @dev: pointer to carrier device
25 * @children: the child busses
26 * @bus_nr: mcb bus number
27 * @get_irq: callback to get IRQ number
30 struct list_head children;
32 struct device *carrier;
34 int (*get_irq)(struct mcb_device *dev);
36 #define to_mcb_bus(b) container_of((b), struct mcb_bus, dev)
39 * struct mcb_device - MEN Chameleon Bus device
41 * @bus_list: internal list handling for bus code
42 * @dev: device in kernel representation
43 * @bus: mcb bus the device is plugged to
44 * @subordinate: subordinate MCBus in case of bridge
45 * @is_added: flag to check if device is added to bus
46 * @driver: associated mcb_driver
48 * @inst: instance in Chameleon table
49 * @group: group in Chameleon table
50 * @var: variant in Chameleon table
51 * @bar: BAR in Chameleon table
52 * @rev: revision in Chameleon table
54 * @memory: memory resource
57 struct list_head bus_list;
60 struct mcb_bus *subordinate;
62 struct mcb_driver *driver;
72 #define to_mcb_device(x) container_of((x), struct mcb_device, dev)
75 * struct mcb_driver - MEN Chameleon Bus device driver
77 * @driver: device_driver
78 * @id_table: mcb id table
79 * @probe: probe callback
80 * @remove: remove callback
81 * @shutdown: shutdown callback
84 struct device_driver driver;
85 const struct mcb_device_id *id_table;
86 int (*probe)(struct mcb_device *mdev, const struct mcb_device_id *id);
87 void (*remove)(struct mcb_device *mdev);
88 void (*shutdown)(struct mcb_device *mdev);
90 #define to_mcb_driver(x) container_of((x), struct mcb_driver, driver)
92 static inline void *mcb_get_drvdata(struct mcb_device *dev)
94 return dev_get_drvdata(&dev->dev);
97 static inline void mcb_set_drvdata(struct mcb_device *dev, void *data)
99 dev_set_drvdata(&dev->dev, data);
102 extern int __must_check __mcb_register_driver(struct mcb_driver *drv,
103 struct module *owner,
104 const char *mod_name);
105 #define mcb_register_driver(driver) \
106 __mcb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
107 extern void mcb_unregister_driver(struct mcb_driver *driver);
108 #define module_mcb_driver(__mcb_driver) \
109 module_driver(__mcb_driver, mcb_register_driver, mcb_unregister_driver);
110 extern void mcb_bus_add_devices(const struct mcb_bus *bus);
111 extern int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev);
112 extern struct mcb_bus *mcb_alloc_bus(struct device *carrier);
113 extern struct mcb_bus *mcb_bus_get(struct mcb_bus *bus);
114 extern void mcb_bus_put(struct mcb_bus *bus);
115 extern struct mcb_device *mcb_alloc_dev(struct mcb_bus *bus);
116 extern void mcb_free_dev(struct mcb_device *dev);
117 extern void mcb_release_bus(struct mcb_bus *bus);
118 extern struct resource *mcb_request_mem(struct mcb_device *dev,
120 extern void mcb_release_mem(struct resource *mem);
121 extern int mcb_get_irq(struct mcb_device *dev);
123 #endif /* _LINUX_MCB_H */