1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (c) 201 Broadcom Corporation 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Permission to use, copy, modify, and/or distribute this software for any 5*4882a593Smuzhiyun * purpose with or without fee is hereby granted, provided that the above 6*4882a593Smuzhiyun * copyright notice and this permission notice appear in all copies. 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9*4882a593Smuzhiyun * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10*4882a593Smuzhiyun * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11*4882a593Smuzhiyun * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12*4882a593Smuzhiyun * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13*4882a593Smuzhiyun * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14*4882a593Smuzhiyun * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15*4882a593Smuzhiyun */ 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun #ifndef _LINUX_BRCMFMAC_PLATFORM_H 18*4882a593Smuzhiyun #define _LINUX_BRCMFMAC_PLATFORM_H 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun #define BRCMFMAC_PDATA_NAME "brcmfmac" 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun #define BRCMFMAC_COUNTRY_BUF_SZ 4 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /* 27*4882a593Smuzhiyun * Platform specific driver functions and data. Through the platform specific 28*4882a593Smuzhiyun * device data functions and data can be provided to help the brcmfmac driver to 29*4882a593Smuzhiyun * operate with the device in combination with the used platform. 30*4882a593Smuzhiyun */ 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /** 34*4882a593Smuzhiyun * Note: the brcmfmac can be loaded as module or be statically built-in into 35*4882a593Smuzhiyun * the kernel. If built-in then do note that it uses module_init (and 36*4882a593Smuzhiyun * module_exit) routines which equal device_initcall. So if you intend to 37*4882a593Smuzhiyun * create a module with the platform specific data for the brcmfmac and have 38*4882a593Smuzhiyun * it built-in to the kernel then use a higher initcall then device_initcall 39*4882a593Smuzhiyun * (see init.h). If this is not done then brcmfmac will load without problems 40*4882a593Smuzhiyun * but will not pickup the platform data. 41*4882a593Smuzhiyun * 42*4882a593Smuzhiyun * When the driver does not "detect" platform driver data then it will continue 43*4882a593Smuzhiyun * without reporting anything and just assume there is no data needed. Which is 44*4882a593Smuzhiyun * probably true for most platforms. 45*4882a593Smuzhiyun */ 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun /** 48*4882a593Smuzhiyun * enum brcmf_bus_type - Bus type identifier. Currently SDIO, USB and PCIE are 49*4882a593Smuzhiyun * supported. 50*4882a593Smuzhiyun */ 51*4882a593Smuzhiyun enum brcmf_bus_type { 52*4882a593Smuzhiyun BRCMF_BUSTYPE_SDIO, 53*4882a593Smuzhiyun BRCMF_BUSTYPE_USB, 54*4882a593Smuzhiyun BRCMF_BUSTYPE_PCIE 55*4882a593Smuzhiyun }; 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /** 59*4882a593Smuzhiyun * struct brcmfmac_sdio_pd - SDIO Device specific platform data. 60*4882a593Smuzhiyun * 61*4882a593Smuzhiyun * @txglomsz: SDIO txglom size. Use 0 if default of driver is to be 62*4882a593Smuzhiyun * used. 63*4882a593Smuzhiyun * @drive_strength: is the preferred drive_strength to be used for the SDIO 64*4882a593Smuzhiyun * pins. If 0 then a default value will be used. This is 65*4882a593Smuzhiyun * the target drive strength, the exact drive strength 66*4882a593Smuzhiyun * which will be used depends on the capabilities of the 67*4882a593Smuzhiyun * device. 68*4882a593Smuzhiyun * @oob_irq_supported: does the board have support for OOB interrupts. SDIO 69*4882a593Smuzhiyun * in-band interrupts are relatively slow and for having 70*4882a593Smuzhiyun * less overhead on interrupt processing an out of band 71*4882a593Smuzhiyun * interrupt can be used. If the HW supports this then 72*4882a593Smuzhiyun * enable this by setting this field to true and configure 73*4882a593Smuzhiyun * the oob related fields. 74*4882a593Smuzhiyun * @oob_irq_nr, 75*4882a593Smuzhiyun * @oob_irq_flags: the OOB interrupt information. The values are used for 76*4882a593Smuzhiyun * registering the irq using request_irq function. 77*4882a593Smuzhiyun * @broken_sg_support: flag for broken sg list support of SDIO host controller. 78*4882a593Smuzhiyun * Set this to true if the SDIO host controller has higher 79*4882a593Smuzhiyun * align requirement than 32 bytes for each scatterlist 80*4882a593Smuzhiyun * item. 81*4882a593Smuzhiyun * @sd_head_align: alignment requirement for start of data buffer. 82*4882a593Smuzhiyun * @sd_sgentry_align: length alignment requirement for each sg entry. 83*4882a593Smuzhiyun * @reset: This function can get called if the device communication 84*4882a593Smuzhiyun * broke down. This functionality is particularly useful in 85*4882a593Smuzhiyun * case of SDIO type devices. It is possible to reset a 86*4882a593Smuzhiyun * dongle via sdio data interface, but it requires that 87*4882a593Smuzhiyun * this is fully functional. This function is chip/module 88*4882a593Smuzhiyun * specific and this function should return only after the 89*4882a593Smuzhiyun * complete reset has completed. 90*4882a593Smuzhiyun */ 91*4882a593Smuzhiyun struct brcmfmac_sdio_pd { 92*4882a593Smuzhiyun int txglomsz; 93*4882a593Smuzhiyun unsigned int drive_strength; 94*4882a593Smuzhiyun bool oob_irq_supported; 95*4882a593Smuzhiyun unsigned int oob_irq_nr; 96*4882a593Smuzhiyun unsigned long oob_irq_flags; 97*4882a593Smuzhiyun bool broken_sg_support; 98*4882a593Smuzhiyun unsigned short sd_head_align; 99*4882a593Smuzhiyun unsigned short sd_sgentry_align; 100*4882a593Smuzhiyun void (*reset)(void); 101*4882a593Smuzhiyun }; 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun /** 104*4882a593Smuzhiyun * struct brcmfmac_pd_cc_entry - Struct for translating user space country code 105*4882a593Smuzhiyun * (iso3166) to firmware country code and 106*4882a593Smuzhiyun * revision. 107*4882a593Smuzhiyun * 108*4882a593Smuzhiyun * @iso3166: iso3166 alpha 2 country code string. 109*4882a593Smuzhiyun * @cc: firmware country code string. 110*4882a593Smuzhiyun * @rev: firmware country code revision. 111*4882a593Smuzhiyun */ 112*4882a593Smuzhiyun struct brcmfmac_pd_cc_entry { 113*4882a593Smuzhiyun char iso3166[BRCMFMAC_COUNTRY_BUF_SZ]; 114*4882a593Smuzhiyun char cc[BRCMFMAC_COUNTRY_BUF_SZ]; 115*4882a593Smuzhiyun s32 rev; 116*4882a593Smuzhiyun }; 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun /** 119*4882a593Smuzhiyun * struct brcmfmac_pd_cc - Struct for translating country codes as set by user 120*4882a593Smuzhiyun * space to a country code and rev which can be used by 121*4882a593Smuzhiyun * firmware. 122*4882a593Smuzhiyun * 123*4882a593Smuzhiyun * @table_size: number of entries in table (> 0) 124*4882a593Smuzhiyun * @table: array of 1 or more elements with translation information. 125*4882a593Smuzhiyun */ 126*4882a593Smuzhiyun struct brcmfmac_pd_cc { 127*4882a593Smuzhiyun int table_size; 128*4882a593Smuzhiyun struct brcmfmac_pd_cc_entry table[0]; 129*4882a593Smuzhiyun }; 130*4882a593Smuzhiyun 131*4882a593Smuzhiyun /** 132*4882a593Smuzhiyun * struct brcmfmac_pd_device - Device specific platform data. (id/rev/bus_type) 133*4882a593Smuzhiyun * is the unique identifier of the device. 134*4882a593Smuzhiyun * 135*4882a593Smuzhiyun * @id: ID of the device for which this data is. In case of SDIO 136*4882a593Smuzhiyun * or PCIE this is the chipid as identified by chip.c In 137*4882a593Smuzhiyun * case of USB this is the chipid as identified by the 138*4882a593Smuzhiyun * device query. 139*4882a593Smuzhiyun * @rev: chip revision, see id. 140*4882a593Smuzhiyun * @bus_type: The type of bus. Some chipid/rev exist for different bus 141*4882a593Smuzhiyun * types. Each bus type has its own set of settings. 142*4882a593Smuzhiyun * @feature_disable: Bitmask of features to disable (override), See feature.c 143*4882a593Smuzhiyun * in brcmfmac for details. 144*4882a593Smuzhiyun * @country_codes: If available, pointer to struct for translating country 145*4882a593Smuzhiyun * codes. 146*4882a593Smuzhiyun * @bus: Bus specific (union) device settings. Currently only 147*4882a593Smuzhiyun * SDIO. 148*4882a593Smuzhiyun */ 149*4882a593Smuzhiyun struct brcmfmac_pd_device { 150*4882a593Smuzhiyun unsigned int id; 151*4882a593Smuzhiyun unsigned int rev; 152*4882a593Smuzhiyun enum brcmf_bus_type bus_type; 153*4882a593Smuzhiyun unsigned int feature_disable; 154*4882a593Smuzhiyun struct brcmfmac_pd_cc *country_codes; 155*4882a593Smuzhiyun union { 156*4882a593Smuzhiyun struct brcmfmac_sdio_pd sdio; 157*4882a593Smuzhiyun } bus; 158*4882a593Smuzhiyun }; 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun /** 161*4882a593Smuzhiyun * struct brcmfmac_platform_data - BRCMFMAC specific platform data. 162*4882a593Smuzhiyun * 163*4882a593Smuzhiyun * @power_on: This function is called by the brcmfmac driver when the module 164*4882a593Smuzhiyun * gets loaded. This can be particularly useful for low power 165*4882a593Smuzhiyun * devices. The platform spcific routine may for example decide to 166*4882a593Smuzhiyun * power up the complete device. If there is no use-case for this 167*4882a593Smuzhiyun * function then provide NULL. 168*4882a593Smuzhiyun * @power_off: This function is called by the brcmfmac when the module gets 169*4882a593Smuzhiyun * unloaded. At this point the devices can be powered down or 170*4882a593Smuzhiyun * otherwise be reset. So if an actual power_off is not supported 171*4882a593Smuzhiyun * but reset is supported by the devices then reset the devices 172*4882a593Smuzhiyun * when this function gets called. This can be particularly useful 173*4882a593Smuzhiyun * for low power devices. If there is no use-case for this 174*4882a593Smuzhiyun * function then provide NULL. 175*4882a593Smuzhiyun */ 176*4882a593Smuzhiyun struct brcmfmac_platform_data { 177*4882a593Smuzhiyun void (*power_on)(void); 178*4882a593Smuzhiyun void (*power_off)(void); 179*4882a593Smuzhiyun char *fw_alternative_path; 180*4882a593Smuzhiyun int device_count; 181*4882a593Smuzhiyun struct brcmfmac_pd_device devices[0]; 182*4882a593Smuzhiyun }; 183*4882a593Smuzhiyun 184*4882a593Smuzhiyun 185*4882a593Smuzhiyun #endif /* _LINUX_BRCMFMAC_PLATFORM_H */ 186