xref: /linux-6.15/include/linux/ipack.h (revision b886d83c)
1*b886d83cSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
27dbce021SSamuel Iglesias Gonsalvez /*
37dbce021SSamuel Iglesias Gonsalvez  * Industry-pack bus.
47dbce021SSamuel Iglesias Gonsalvez  *
57dbce021SSamuel Iglesias Gonsalvez  * Copyright (C) 2011-2012 CERN (www.cern.ch)
67dbce021SSamuel Iglesias Gonsalvez  * Author: Samuel Iglesias Gonsalvez <[email protected]>
77dbce021SSamuel Iglesias Gonsalvez  */
87dbce021SSamuel Iglesias Gonsalvez 
97dbce021SSamuel Iglesias Gonsalvez #include <linux/mod_devicetable.h>
107dbce021SSamuel Iglesias Gonsalvez #include <linux/device.h>
117dbce021SSamuel Iglesias Gonsalvez #include <linux/interrupt.h>
127dbce021SSamuel Iglesias Gonsalvez 
137dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_I			0x01
147dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_P			0x03
157dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_A			0x05
167dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_C			0x07
177dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_MANUFACTURER_ID	0x09
187dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_MODEL		0x0B
197dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_REVISION		0x0D
207dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_RESERVED		0x0F
217dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_DRIVER_ID_L		0x11
227dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_DRIVER_ID_H		0x13
237dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_NUM_BYTES		0x15
247dbce021SSamuel Iglesias Gonsalvez #define IPACK_IDPROM_OFFSET_CRC			0x17
257dbce021SSamuel Iglesias Gonsalvez 
2627cf2d1bSSamuel Iglesias Gonsalvez /*
2727cf2d1bSSamuel Iglesias Gonsalvez  * IndustryPack Fromat, Vendor and Device IDs.
2827cf2d1bSSamuel Iglesias Gonsalvez  */
2927cf2d1bSSamuel Iglesias Gonsalvez 
3027cf2d1bSSamuel Iglesias Gonsalvez /* ID section format versions */
3127cf2d1bSSamuel Iglesias Gonsalvez #define IPACK_ID_VERSION_INVALID	0x00
3227cf2d1bSSamuel Iglesias Gonsalvez #define IPACK_ID_VERSION_1		0x01
3327cf2d1bSSamuel Iglesias Gonsalvez #define IPACK_ID_VERSION_2		0x02
3427cf2d1bSSamuel Iglesias Gonsalvez 
3527cf2d1bSSamuel Iglesias Gonsalvez /* Vendors and devices. Sort key: vendor first, device next. */
3627cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_RESERVED1	0x00
3727cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_RESERVED2	0xFF
3827cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED01	0x01
3927cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED02	0x02
4027cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED03	0x03
4127cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED04	0x04
4227cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED05	0x05
4327cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED06	0x06
4427cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED07	0x07
4527cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED08	0x08
4627cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED09	0x09
4727cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED10	0x0A
4827cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED11	0x0B
4927cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED12	0x0C
5027cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED13	0x0D
5127cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED14	0x0E
5227cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_UNREGISTRED15	0x0F
5327cf2d1bSSamuel Iglesias Gonsalvez 
5427cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_VENDOR_ID_SBS            0xF0
5527cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_DEVICE_ID_SBS_OCTAL_232  0x22
5627cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_DEVICE_ID_SBS_OCTAL_422  0x2A
5727cf2d1bSSamuel Iglesias Gonsalvez #define IPACK1_DEVICE_ID_SBS_OCTAL_485  0x48
5827cf2d1bSSamuel Iglesias Gonsalvez 
597dbce021SSamuel Iglesias Gonsalvez struct ipack_bus_ops;
607dbce021SSamuel Iglesias Gonsalvez struct ipack_driver;
617dbce021SSamuel Iglesias Gonsalvez 
627dbce021SSamuel Iglesias Gonsalvez enum ipack_space {
637dbce021SSamuel Iglesias Gonsalvez 	IPACK_IO_SPACE    = 0,
647dbce021SSamuel Iglesias Gonsalvez 	IPACK_ID_SPACE,
657dbce021SSamuel Iglesias Gonsalvez 	IPACK_INT_SPACE,
667dbce021SSamuel Iglesias Gonsalvez 	IPACK_MEM8_SPACE,
677dbce021SSamuel Iglesias Gonsalvez 	IPACK_MEM16_SPACE,
687dbce021SSamuel Iglesias Gonsalvez 	/* Dummy for counting the number of entries.  Must remain the last
697dbce021SSamuel Iglesias Gonsalvez 	 * entry */
707dbce021SSamuel Iglesias Gonsalvez 	IPACK_SPACE_COUNT,
717dbce021SSamuel Iglesias Gonsalvez };
727dbce021SSamuel Iglesias Gonsalvez 
737dbce021SSamuel Iglesias Gonsalvez /**
747dbce021SSamuel Iglesias Gonsalvez  */
757dbce021SSamuel Iglesias Gonsalvez struct ipack_region {
767dbce021SSamuel Iglesias Gonsalvez 	phys_addr_t start;
777dbce021SSamuel Iglesias Gonsalvez 	size_t      size;
787dbce021SSamuel Iglesias Gonsalvez };
797dbce021SSamuel Iglesias Gonsalvez 
807dbce021SSamuel Iglesias Gonsalvez /**
817dbce021SSamuel Iglesias Gonsalvez  *	struct ipack_device
827dbce021SSamuel Iglesias Gonsalvez  *
837dbce021SSamuel Iglesias Gonsalvez  *	@slot: Slot where the device is plugged in the carrier board
847dbce021SSamuel Iglesias Gonsalvez  *	@bus: ipack_bus_device where the device is plugged to.
857dbce021SSamuel Iglesias Gonsalvez  *	@id_space: Virtual address to ID space.
867dbce021SSamuel Iglesias Gonsalvez  *	@io_space: Virtual address to IO space.
877dbce021SSamuel Iglesias Gonsalvez  *	@mem_space: Virtual address to MEM space.
887dbce021SSamuel Iglesias Gonsalvez  *	@dev: device in kernel representation.
897dbce021SSamuel Iglesias Gonsalvez  *
907dbce021SSamuel Iglesias Gonsalvez  * Warning: Direct access to mapped memory is possible but the endianness
917dbce021SSamuel Iglesias Gonsalvez  * is not the same with PCI carrier or VME carrier. The endianness is managed
927dbce021SSamuel Iglesias Gonsalvez  * by the carrier board throught bus->ops.
937dbce021SSamuel Iglesias Gonsalvez  */
947dbce021SSamuel Iglesias Gonsalvez struct ipack_device {
957dbce021SSamuel Iglesias Gonsalvez 	unsigned int slot;
967dbce021SSamuel Iglesias Gonsalvez 	struct ipack_bus_device *bus;
977dbce021SSamuel Iglesias Gonsalvez 	struct device dev;
987dbce021SSamuel Iglesias Gonsalvez 	void (*release) (struct ipack_device *dev);
997dbce021SSamuel Iglesias Gonsalvez 	struct ipack_region      region[IPACK_SPACE_COUNT];
1007dbce021SSamuel Iglesias Gonsalvez 	u8                      *id;
1017dbce021SSamuel Iglesias Gonsalvez 	size_t			 id_avail;
1027dbce021SSamuel Iglesias Gonsalvez 	u32			 id_vendor;
1037dbce021SSamuel Iglesias Gonsalvez 	u32			 id_device;
1047dbce021SSamuel Iglesias Gonsalvez 	u8			 id_format;
1057dbce021SSamuel Iglesias Gonsalvez 	unsigned int		 id_crc_correct:1;
1067dbce021SSamuel Iglesias Gonsalvez 	unsigned int		 speed_8mhz:1;
1077dbce021SSamuel Iglesias Gonsalvez 	unsigned int		 speed_32mhz:1;
1087dbce021SSamuel Iglesias Gonsalvez };
1097dbce021SSamuel Iglesias Gonsalvez 
1107dbce021SSamuel Iglesias Gonsalvez /**
1117dbce021SSamuel Iglesias Gonsalvez  * struct ipack_driver_ops -- Callbacks to IPack device driver
1127dbce021SSamuel Iglesias Gonsalvez  *
1137dbce021SSamuel Iglesias Gonsalvez  * @probe:  Probe function
1147dbce021SSamuel Iglesias Gonsalvez  * @remove: Prepare imminent removal of the device.  Services provided by the
1157dbce021SSamuel Iglesias Gonsalvez  *          device should be revoked.
1167dbce021SSamuel Iglesias Gonsalvez  */
1177dbce021SSamuel Iglesias Gonsalvez 
1187dbce021SSamuel Iglesias Gonsalvez struct ipack_driver_ops {
1197dbce021SSamuel Iglesias Gonsalvez 	int (*probe) (struct ipack_device *dev);
1207dbce021SSamuel Iglesias Gonsalvez 	void (*remove) (struct ipack_device *dev);
1217dbce021SSamuel Iglesias Gonsalvez };
1227dbce021SSamuel Iglesias Gonsalvez 
1237dbce021SSamuel Iglesias Gonsalvez /**
1247dbce021SSamuel Iglesias Gonsalvez  * struct ipack_driver -- Specific data to each ipack device driver
1257dbce021SSamuel Iglesias Gonsalvez  *
1267dbce021SSamuel Iglesias Gonsalvez  * @driver: Device driver kernel representation
1277dbce021SSamuel Iglesias Gonsalvez  * @ops:    Callbacks provided by the IPack device driver
1287dbce021SSamuel Iglesias Gonsalvez  */
1297dbce021SSamuel Iglesias Gonsalvez struct ipack_driver {
1307dbce021SSamuel Iglesias Gonsalvez 	struct device_driver driver;
1317dbce021SSamuel Iglesias Gonsalvez 	const struct ipack_device_id *id_table;
1327dbce021SSamuel Iglesias Gonsalvez 	const struct ipack_driver_ops *ops;
1337dbce021SSamuel Iglesias Gonsalvez };
1347dbce021SSamuel Iglesias Gonsalvez 
1357dbce021SSamuel Iglesias Gonsalvez /**
1367dbce021SSamuel Iglesias Gonsalvez  *	struct ipack_bus_ops - available operations on a bridge module
1377dbce021SSamuel Iglesias Gonsalvez  *
1387dbce021SSamuel Iglesias Gonsalvez  *	@map_space: map IP address space
1397dbce021SSamuel Iglesias Gonsalvez  *	@unmap_space: unmap IP address space
1407dbce021SSamuel Iglesias Gonsalvez  *	@request_irq: request IRQ
1417dbce021SSamuel Iglesias Gonsalvez  *	@free_irq: free IRQ
1427dbce021SSamuel Iglesias Gonsalvez  *	@get_clockrate: Returns the clockrate the carrier is currently
1437dbce021SSamuel Iglesias Gonsalvez  *		communicating with the device at.
1447dbce021SSamuel Iglesias Gonsalvez  *	@set_clockrate: Sets the clock-rate for carrier / module communication.
1457dbce021SSamuel Iglesias Gonsalvez  *		Should return -EINVAL if the requested speed is not supported.
1467dbce021SSamuel Iglesias Gonsalvez  *	@get_error: Returns the error state for the slot the device is attached
1477dbce021SSamuel Iglesias Gonsalvez  *		to.
1487dbce021SSamuel Iglesias Gonsalvez  *	@get_timeout: Returns 1 if the communication with the device has
1497dbce021SSamuel Iglesias Gonsalvez  *		previously timed out.
1507dbce021SSamuel Iglesias Gonsalvez  *	@reset_timeout: Resets the state returned by get_timeout.
1517dbce021SSamuel Iglesias Gonsalvez  */
1527dbce021SSamuel Iglesias Gonsalvez struct ipack_bus_ops {
1537dbce021SSamuel Iglesias Gonsalvez 	int (*request_irq) (struct ipack_device *dev,
1547dbce021SSamuel Iglesias Gonsalvez 			    irqreturn_t (*handler)(void *), void *arg);
1557dbce021SSamuel Iglesias Gonsalvez 	int (*free_irq) (struct ipack_device *dev);
1567dbce021SSamuel Iglesias Gonsalvez 	int (*get_clockrate) (struct ipack_device *dev);
1577dbce021SSamuel Iglesias Gonsalvez 	int (*set_clockrate) (struct ipack_device *dev, int mherz);
1587dbce021SSamuel Iglesias Gonsalvez 	int (*get_error) (struct ipack_device *dev);
1597dbce021SSamuel Iglesias Gonsalvez 	int (*get_timeout) (struct ipack_device *dev);
1607dbce021SSamuel Iglesias Gonsalvez 	int (*reset_timeout) (struct ipack_device *dev);
1617dbce021SSamuel Iglesias Gonsalvez };
1627dbce021SSamuel Iglesias Gonsalvez 
1637dbce021SSamuel Iglesias Gonsalvez /**
1647dbce021SSamuel Iglesias Gonsalvez  *	struct ipack_bus_device
1657dbce021SSamuel Iglesias Gonsalvez  *
1667dbce021SSamuel Iglesias Gonsalvez  *	@dev: pointer to carrier device
1677dbce021SSamuel Iglesias Gonsalvez  *	@slots: number of slots available
1687dbce021SSamuel Iglesias Gonsalvez  *	@bus_nr: ipack bus number
1697dbce021SSamuel Iglesias Gonsalvez  *	@ops: bus operations for the mezzanine drivers
1707dbce021SSamuel Iglesias Gonsalvez  */
1717dbce021SSamuel Iglesias Gonsalvez struct ipack_bus_device {
17236c53b3cSFederico Vaga 	struct module *owner;
1737dbce021SSamuel Iglesias Gonsalvez 	struct device *parent;
1747dbce021SSamuel Iglesias Gonsalvez 	int slots;
1757dbce021SSamuel Iglesias Gonsalvez 	int bus_nr;
1767dbce021SSamuel Iglesias Gonsalvez 	const struct ipack_bus_ops *ops;
1777dbce021SSamuel Iglesias Gonsalvez };
1787dbce021SSamuel Iglesias Gonsalvez 
1797dbce021SSamuel Iglesias Gonsalvez /**
1807dbce021SSamuel Iglesias Gonsalvez  *	ipack_bus_register -- register a new ipack bus
1817dbce021SSamuel Iglesias Gonsalvez  *
1827dbce021SSamuel Iglesias Gonsalvez  * @parent: pointer to the parent device, if any.
1837dbce021SSamuel Iglesias Gonsalvez  * @slots: number of slots available in the bus device.
1847dbce021SSamuel Iglesias Gonsalvez  * @ops: bus operations for the mezzanine drivers.
1857dbce021SSamuel Iglesias Gonsalvez  *
1867dbce021SSamuel Iglesias Gonsalvez  * The carrier board device should call this function to register itself as
1877dbce021SSamuel Iglesias Gonsalvez  * available bus device in ipack.
1887dbce021SSamuel Iglesias Gonsalvez  */
1897dbce021SSamuel Iglesias Gonsalvez struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots,
19036c53b3cSFederico Vaga 					    const struct ipack_bus_ops *ops,
19136c53b3cSFederico Vaga 					    struct module *owner);
1927dbce021SSamuel Iglesias Gonsalvez 
1937dbce021SSamuel Iglesias Gonsalvez /**
1947dbce021SSamuel Iglesias Gonsalvez  *	ipack_bus_unregister -- unregister an ipack bus
1957dbce021SSamuel Iglesias Gonsalvez  */
1967dbce021SSamuel Iglesias Gonsalvez int ipack_bus_unregister(struct ipack_bus_device *bus);
1977dbce021SSamuel Iglesias Gonsalvez 
1987dbce021SSamuel Iglesias Gonsalvez /**
1997dbce021SSamuel Iglesias Gonsalvez  * ipack_driver_register -- Register a new ipack device driver
2007dbce021SSamuel Iglesias Gonsalvez  *
2017dbce021SSamuel Iglesias Gonsalvez  * Called by a ipack driver to register itself as a driver
2027dbce021SSamuel Iglesias Gonsalvez  * that can manage ipack devices.
2037dbce021SSamuel Iglesias Gonsalvez  */
2047dbce021SSamuel Iglesias Gonsalvez int ipack_driver_register(struct ipack_driver *edrv, struct module *owner,
2057dbce021SSamuel Iglesias Gonsalvez 			  const char *name);
2067dbce021SSamuel Iglesias Gonsalvez void ipack_driver_unregister(struct ipack_driver *edrv);
2077dbce021SSamuel Iglesias Gonsalvez 
2087dbce021SSamuel Iglesias Gonsalvez /**
209e926301bSSamuel Iglesias Gonsalvez  *	ipack_device_init -- initialize an IPack device
210e926301bSSamuel Iglesias Gonsalvez  * @dev: the new device to initialize.
2117dbce021SSamuel Iglesias Gonsalvez  *
212e926301bSSamuel Iglesias Gonsalvez  * Initialize a new IPack device ("module" in IndustryPack jargon). The call
2137dbce021SSamuel Iglesias Gonsalvez  * is done by the carrier driver.  The carrier should populate the fields
2147dbce021SSamuel Iglesias Gonsalvez  * bus and slot as well as the region array of @dev prior to calling this
2157dbce021SSamuel Iglesias Gonsalvez  * function.  The rest of the fields will be allocated and populated
216e926301bSSamuel Iglesias Gonsalvez  * during initalization.
2177dbce021SSamuel Iglesias Gonsalvez  *
2187dbce021SSamuel Iglesias Gonsalvez  * Return zero on success or error code on failure.
219e926301bSSamuel Iglesias Gonsalvez  *
220e926301bSSamuel Iglesias Gonsalvez  * NOTE: _Never_ directly free @dev after calling this function, even
221e926301bSSamuel Iglesias Gonsalvez  * if it returned an error! Always use ipack_put_device() to give up the
222e926301bSSamuel Iglesias Gonsalvez  * reference initialized in this function instead.
2237dbce021SSamuel Iglesias Gonsalvez  */
224e926301bSSamuel Iglesias Gonsalvez int ipack_device_init(struct ipack_device *dev);
225e926301bSSamuel Iglesias Gonsalvez 
226e926301bSSamuel Iglesias Gonsalvez /**
227e926301bSSamuel Iglesias Gonsalvez  *	ipack_device_add -- Add an IPack device
228e926301bSSamuel Iglesias Gonsalvez  * @dev: the new device to add.
229e926301bSSamuel Iglesias Gonsalvez  *
230e926301bSSamuel Iglesias Gonsalvez  * Add a new IPack device. The call is done by the carrier driver
231e926301bSSamuel Iglesias Gonsalvez  * after calling ipack_device_init().
232e926301bSSamuel Iglesias Gonsalvez  *
233e926301bSSamuel Iglesias Gonsalvez  * Return zero on success or error code on failure.
234e926301bSSamuel Iglesias Gonsalvez  *
235e926301bSSamuel Iglesias Gonsalvez  * NOTE: _Never_ directly free @dev after calling this function, even
236e926301bSSamuel Iglesias Gonsalvez  * if it returned an error! Always use ipack_put_device() to give up the
237e926301bSSamuel Iglesias Gonsalvez  * reference initialized in this function instead.
238e926301bSSamuel Iglesias Gonsalvez  */
239e926301bSSamuel Iglesias Gonsalvez int ipack_device_add(struct ipack_device *dev);
240e926301bSSamuel Iglesias Gonsalvez void ipack_device_del(struct ipack_device *dev);
2417dbce021SSamuel Iglesias Gonsalvez 
242fa882867SSamuel Iglesias Gonsalvez void ipack_get_device(struct ipack_device *dev);
243fa882867SSamuel Iglesias Gonsalvez void ipack_put_device(struct ipack_device *dev);
244fa882867SSamuel Iglesias Gonsalvez 
2457dbce021SSamuel Iglesias Gonsalvez /**
2467dbce021SSamuel Iglesias Gonsalvez  * DEFINE_IPACK_DEVICE_TABLE - macro used to describe a IndustryPack table
2477dbce021SSamuel Iglesias Gonsalvez  * @_table: device table name
2487dbce021SSamuel Iglesias Gonsalvez  *
2497dbce021SSamuel Iglesias Gonsalvez  * This macro is used to create a struct ipack_device_id array (a device table)
2507dbce021SSamuel Iglesias Gonsalvez  * in a generic manner.
2517dbce021SSamuel Iglesias Gonsalvez  */
2527dbce021SSamuel Iglesias Gonsalvez #define DEFINE_IPACK_DEVICE_TABLE(_table) \
253d79251f0SBill Pemberton 	const struct ipack_device_id _table[]
2547dbce021SSamuel Iglesias Gonsalvez /**
2557dbce021SSamuel Iglesias Gonsalvez  * IPACK_DEVICE - macro used to describe a specific IndustryPack device
2567dbce021SSamuel Iglesias Gonsalvez  * @_format: the format version (currently either 1 or 2, 8 bit value)
2577dbce021SSamuel Iglesias Gonsalvez  * @vend:    the 8 or 24 bit IndustryPack Vendor ID
2587dbce021SSamuel Iglesias Gonsalvez  * @dev:     the 8 or 16  bit IndustryPack Device ID
2597dbce021SSamuel Iglesias Gonsalvez  *
2607dbce021SSamuel Iglesias Gonsalvez  * This macro is used to create a struct ipack_device_id that matches a specific
2617dbce021SSamuel Iglesias Gonsalvez  * device.
2627dbce021SSamuel Iglesias Gonsalvez  */
2637dbce021SSamuel Iglesias Gonsalvez #define IPACK_DEVICE(_format, vend, dev) \
2647dbce021SSamuel Iglesias Gonsalvez 	 .format = (_format), \
2657dbce021SSamuel Iglesias Gonsalvez 	 .vendor = (vend), \
2667dbce021SSamuel Iglesias Gonsalvez 	 .device = (dev)
26736c53b3cSFederico Vaga 
26836c53b3cSFederico Vaga /**
26936c53b3cSFederico Vaga  * ipack_get_carrier - it increase the carrier ref. counter of
27036c53b3cSFederico Vaga  *                     the carrier module
27136c53b3cSFederico Vaga  * @dev: mezzanine device which wants to get the carrier
27236c53b3cSFederico Vaga  */
ipack_get_carrier(struct ipack_device * dev)27336c53b3cSFederico Vaga static inline int ipack_get_carrier(struct ipack_device *dev)
27436c53b3cSFederico Vaga {
27536c53b3cSFederico Vaga 	return try_module_get(dev->bus->owner);
27636c53b3cSFederico Vaga }
27736c53b3cSFederico Vaga 
27836c53b3cSFederico Vaga /**
27936c53b3cSFederico Vaga  * ipack_get_carrier - it decrease the carrier ref. counter of
28036c53b3cSFederico Vaga  *                     the carrier module
28136c53b3cSFederico Vaga  * @dev: mezzanine device which wants to get the carrier
28236c53b3cSFederico Vaga  */
ipack_put_carrier(struct ipack_device * dev)28336c53b3cSFederico Vaga static inline void ipack_put_carrier(struct ipack_device *dev)
28436c53b3cSFederico Vaga {
28536c53b3cSFederico Vaga 	module_put(dev->bus->owner);
28636c53b3cSFederico Vaga }
287