xref: /openbmc/linux/include/linux/platform_data/brcmfmac.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
14d792895SHante Meuleman /*
24d792895SHante Meuleman  * Copyright (c) 201 Broadcom Corporation
34d792895SHante Meuleman  *
44d792895SHante Meuleman  * Permission to use, copy, modify, and/or distribute this software for any
54d792895SHante Meuleman  * purpose with or without fee is hereby granted, provided that the above
64d792895SHante Meuleman  * copyright notice and this permission notice appear in all copies.
74d792895SHante Meuleman  *
84d792895SHante Meuleman  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
94d792895SHante Meuleman  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
104d792895SHante Meuleman  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
114d792895SHante Meuleman  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
124d792895SHante Meuleman  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
134d792895SHante Meuleman  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
144d792895SHante Meuleman  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
154d792895SHante Meuleman  */
164d792895SHante Meuleman 
174d792895SHante Meuleman #ifndef _LINUX_BRCMFMAC_PLATFORM_H
184d792895SHante Meuleman #define _LINUX_BRCMFMAC_PLATFORM_H
194d792895SHante Meuleman 
204d792895SHante Meuleman 
214d792895SHante Meuleman #define BRCMFMAC_PDATA_NAME		"brcmfmac"
224d792895SHante Meuleman 
234d792895SHante Meuleman #define BRCMFMAC_COUNTRY_BUF_SZ		4
244d792895SHante Meuleman 
254d792895SHante Meuleman 
264d792895SHante Meuleman /*
274d792895SHante Meuleman  * Platform specific driver functions and data. Through the platform specific
284d792895SHante Meuleman  * device data functions and data can be provided to help the brcmfmac driver to
294d792895SHante Meuleman  * operate with the device in combination with the used platform.
304d792895SHante Meuleman  */
314d792895SHante Meuleman 
324d792895SHante Meuleman 
334d792895SHante Meuleman /**
344d792895SHante Meuleman  * Note: the brcmfmac can be loaded as module or be statically built-in into
354d792895SHante Meuleman  * the kernel. If built-in then do note that it uses module_init (and
364d792895SHante Meuleman  * module_exit) routines which equal device_initcall. So if you intend to
374d792895SHante Meuleman  * create a module with the platform specific data for the brcmfmac and have
384d792895SHante Meuleman  * it built-in to the kernel then use a higher initcall then device_initcall
394d792895SHante Meuleman  * (see init.h). If this is not done then brcmfmac will load without problems
404d792895SHante Meuleman  * but will not pickup the platform data.
414d792895SHante Meuleman  *
424d792895SHante Meuleman  * When the driver does not "detect" platform driver data then it will continue
434d792895SHante Meuleman  * without reporting anything and just assume there is no data needed. Which is
444d792895SHante Meuleman  * probably true for most platforms.
454d792895SHante Meuleman  */
464d792895SHante Meuleman 
474d792895SHante Meuleman /**
484d792895SHante Meuleman  * enum brcmf_bus_type - Bus type identifier. Currently SDIO, USB and PCIE are
494d792895SHante Meuleman  *			 supported.
504d792895SHante Meuleman  */
514d792895SHante Meuleman enum brcmf_bus_type {
524d792895SHante Meuleman 	BRCMF_BUSTYPE_SDIO,
534d792895SHante Meuleman 	BRCMF_BUSTYPE_USB,
544d792895SHante Meuleman 	BRCMF_BUSTYPE_PCIE
554d792895SHante Meuleman };
564d792895SHante Meuleman 
574d792895SHante Meuleman 
584d792895SHante Meuleman /**
594d792895SHante Meuleman  * struct brcmfmac_sdio_pd - SDIO Device specific platform data.
604d792895SHante Meuleman  *
614d792895SHante Meuleman  * @txglomsz:		SDIO txglom size. Use 0 if default of driver is to be
624d792895SHante Meuleman  *			used.
634d792895SHante Meuleman  * @drive_strength:	is the preferred drive_strength to be used for the SDIO
644d792895SHante Meuleman  *			pins. If 0 then a default value will be used. This is
654d792895SHante Meuleman  *			the target drive strength, the exact drive strength
664d792895SHante Meuleman  *			which will be used depends on the capabilities of the
674d792895SHante Meuleman  *			device.
684d792895SHante Meuleman  * @oob_irq_supported:	does the board have support for OOB interrupts. SDIO
694d792895SHante Meuleman  *			in-band interrupts are relatively slow and for having
704d792895SHante Meuleman  *			less overhead on interrupt processing an out of band
714d792895SHante Meuleman  *			interrupt can be used. If the HW supports this then
724d792895SHante Meuleman  *			enable this by setting this field to true and configure
734d792895SHante Meuleman  *			the oob related fields.
744d792895SHante Meuleman  * @oob_irq_nr,
754d792895SHante Meuleman  * @oob_irq_flags:	the OOB interrupt information. The values are used for
764d792895SHante Meuleman  *			registering the irq using request_irq function.
774d792895SHante Meuleman  * @broken_sg_support:	flag for broken sg list support of SDIO host controller.
784d792895SHante Meuleman  *			Set this to true if the SDIO host controller has higher
794d792895SHante Meuleman  *			align requirement than 32 bytes for each scatterlist
804d792895SHante Meuleman  *			item.
814d792895SHante Meuleman  * @sd_head_align:	alignment requirement for start of data buffer.
824d792895SHante Meuleman  * @sd_sgentry_align:	length alignment requirement for each sg entry.
834d792895SHante Meuleman  * @reset:		This function can get called if the device communication
844d792895SHante Meuleman  *			broke down. This functionality is particularly useful in
854d792895SHante Meuleman  *			case of SDIO type devices. It is possible to reset a
864d792895SHante Meuleman  *			dongle via sdio data interface, but it requires that
874d792895SHante Meuleman  *			this is fully functional. This function is chip/module
884d792895SHante Meuleman  *			specific and this function should return only after the
894d792895SHante Meuleman  *			complete reset has completed.
904d792895SHante Meuleman  */
914d792895SHante Meuleman struct brcmfmac_sdio_pd {
924d792895SHante Meuleman 	int		txglomsz;
934d792895SHante Meuleman 	unsigned int	drive_strength;
944d792895SHante Meuleman 	bool		oob_irq_supported;
954d792895SHante Meuleman 	unsigned int	oob_irq_nr;
964d792895SHante Meuleman 	unsigned long	oob_irq_flags;
974d792895SHante Meuleman 	bool		broken_sg_support;
984d792895SHante Meuleman 	unsigned short	sd_head_align;
994d792895SHante Meuleman 	unsigned short	sd_sgentry_align;
1004d792895SHante Meuleman 	void		(*reset)(void);
1014d792895SHante Meuleman };
1024d792895SHante Meuleman 
1034d792895SHante Meuleman /**
1044d792895SHante Meuleman  * struct brcmfmac_pd_cc_entry - Struct for translating user space country code
1054d792895SHante Meuleman  *				 (iso3166) to firmware country code and
1064d792895SHante Meuleman  *				 revision.
1074d792895SHante Meuleman  *
1084d792895SHante Meuleman  * @iso3166:	iso3166 alpha 2 country code string.
1094d792895SHante Meuleman  * @cc:		firmware country code string.
1104d792895SHante Meuleman  * @rev:	firmware country code revision.
1114d792895SHante Meuleman  */
1124d792895SHante Meuleman struct brcmfmac_pd_cc_entry {
1134d792895SHante Meuleman 	char	iso3166[BRCMFMAC_COUNTRY_BUF_SZ];
1144d792895SHante Meuleman 	char	cc[BRCMFMAC_COUNTRY_BUF_SZ];
1154d792895SHante Meuleman 	s32	rev;
1164d792895SHante Meuleman };
1174d792895SHante Meuleman 
1184d792895SHante Meuleman /**
1194d792895SHante Meuleman  * struct brcmfmac_pd_cc - Struct for translating country codes as set by user
1204d792895SHante Meuleman  *			   space to a country code and rev which can be used by
1214d792895SHante Meuleman  *			   firmware.
1224d792895SHante Meuleman  *
1234d792895SHante Meuleman  * @table_size:	number of entries in table (> 0)
1244d792895SHante Meuleman  * @table:	array of 1 or more elements with translation information.
1254d792895SHante Meuleman  */
1264d792895SHante Meuleman struct brcmfmac_pd_cc {
1274d792895SHante Meuleman 	int				table_size;
1283fd445a4SLen Baker 	struct brcmfmac_pd_cc_entry	table[];
1294d792895SHante Meuleman };
1304d792895SHante Meuleman 
1314d792895SHante Meuleman /**
1324d792895SHante Meuleman  * struct brcmfmac_pd_device - Device specific platform data. (id/rev/bus_type)
1334d792895SHante Meuleman  *			       is the unique identifier of the device.
1344d792895SHante Meuleman  *
1354d792895SHante Meuleman  * @id:			ID of the device for which this data is. In case of SDIO
1364d792895SHante Meuleman  *			or PCIE this is the chipid as identified by chip.c In
1374d792895SHante Meuleman  *			case of USB this is the chipid as identified by the
1384d792895SHante Meuleman  *			device query.
1394d792895SHante Meuleman  * @rev:		chip revision, see id.
1404d792895SHante Meuleman  * @bus_type:		The type of bus. Some chipid/rev exist for different bus
1414d792895SHante Meuleman  *			types. Each bus type has its own set of settings.
1424d792895SHante Meuleman  * @feature_disable:	Bitmask of features to disable (override), See feature.c
1434d792895SHante Meuleman  *			in brcmfmac for details.
1444d792895SHante Meuleman  * @country_codes:	If available, pointer to struct for translating country
1454d792895SHante Meuleman  *			codes.
1464d792895SHante Meuleman  * @bus:		Bus specific (union) device settings. Currently only
1474d792895SHante Meuleman  *			SDIO.
1484d792895SHante Meuleman  */
1494d792895SHante Meuleman struct brcmfmac_pd_device {
1504d792895SHante Meuleman 	unsigned int		id;
1514d792895SHante Meuleman 	unsigned int		rev;
1524d792895SHante Meuleman 	enum brcmf_bus_type	bus_type;
1534d792895SHante Meuleman 	unsigned int		feature_disable;
1544d792895SHante Meuleman 	struct brcmfmac_pd_cc	*country_codes;
1554d792895SHante Meuleman 	union {
1564d792895SHante Meuleman 		struct brcmfmac_sdio_pd sdio;
1574d792895SHante Meuleman 	} bus;
1584d792895SHante Meuleman };
1594d792895SHante Meuleman 
1604d792895SHante Meuleman /**
1614d792895SHante Meuleman  * struct brcmfmac_platform_data - BRCMFMAC specific platform data.
1624d792895SHante Meuleman  *
1634d792895SHante Meuleman  * @power_on:	This function is called by the brcmfmac driver when the module
1644d792895SHante Meuleman  *		gets loaded. This can be particularly useful for low power
1654d792895SHante Meuleman  *		devices. The platform spcific routine may for example decide to
1664d792895SHante Meuleman  *		power up the complete device. If there is no use-case for this
1674d792895SHante Meuleman  *		function then provide NULL.
1684d792895SHante Meuleman  * @power_off:	This function is called by the brcmfmac when the module gets
1694d792895SHante Meuleman  *		unloaded. At this point the devices can be powered down or
1704d792895SHante Meuleman  *		otherwise be reset. So if an actual power_off is not supported
1714d792895SHante Meuleman  *		but reset is supported by the devices then reset the devices
1724d792895SHante Meuleman  *		when this function gets called. This can be particularly useful
1734d792895SHante Meuleman  *		for low power devices. If there is no use-case for this
1744d792895SHante Meuleman  *		function then provide NULL.
1754d792895SHante Meuleman  */
1764d792895SHante Meuleman struct brcmfmac_platform_data {
1774d792895SHante Meuleman 	void	(*power_on)(void);
1784d792895SHante Meuleman 	void	(*power_off)(void);
1794d792895SHante Meuleman 	char	*fw_alternative_path;
1804d792895SHante Meuleman 	int	device_count;
181*5224f790SGustavo A. R. Silva 	struct brcmfmac_pd_device devices[];
1824d792895SHante Meuleman };
1834d792895SHante Meuleman 
1844d792895SHante Meuleman 
1854d792895SHante Meuleman #endif /* _LINUX_BRCMFMAC_PLATFORM_H */
186