1/* 2 * Copyright (c) 2013 Broadcom Corporation 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17#ifndef _LINUX_BRCMFMAC_PLATFORM_H 18#define _LINUX_BRCMFMAC_PLATFORM_H 19 20/* 21 * Platform specific driver functions and data. Through the platform specific 22 * device data functions can be provided to help the brcmfmac driver to 23 * operate with the device in combination with the used platform. 24 * 25 * Use the platform data in the following (similar) way: 26 * 27 * 28#include <brcmfmac_platform.h> 29 30 31static void brcmfmac_power_on(void) 32{ 33} 34 35static void brcmfmac_power_off(void) 36{ 37} 38 39static void brcmfmac_reset(void) 40{ 41} 42 43static struct brcmfmac_sdio_platform_data brcmfmac_sdio_pdata = { 44 .power_on = brcmfmac_power_on, 45 .power_off = brcmfmac_power_off, 46 .reset = brcmfmac_reset 47}; 48 49static struct platform_device brcmfmac_device = { 50 .name = BRCMFMAC_SDIO_PDATA_NAME, 51 .id = PLATFORM_DEVID_NONE, 52 .dev.platform_data = &brcmfmac_sdio_pdata 53}; 54 55void __init brcmfmac_init_pdata(void) 56{ 57 brcmfmac_sdio_pdata.oob_irq_supported = true; 58 brcmfmac_sdio_pdata.oob_irq_nr = gpio_to_irq(GPIO_BRCMF_SDIO_OOB); 59 brcmfmac_sdio_pdata.oob_irq_flags = IORESOURCE_IRQ | 60 IORESOURCE_IRQ_HIGHLEVEL; 61 platform_device_register(&brcmfmac_device); 62} 63 * 64 * 65 * Note: the brcmfmac can be loaded as module or be statically built-in into 66 * the kernel. If built-in then do note that it uses module_init (and 67 * module_exit) routines which equal device_initcall. So if you intend to 68 * create a module with the platform specific data for the brcmfmac and have 69 * it built-in to the kernel then use a higher initcall then device_initcall 70 * (see init.h). If this is not done then brcmfmac will load without problems 71 * but will not pickup the platform data. 72 * 73 * When the driver does not "detect" platform driver data then it will continue 74 * without reporting anything and just assume there is no data needed. Which is 75 * probably true for most platforms. 76 * 77 * Explanation of the platform_data fields: 78 * 79 * drive_strength: is the preferred drive_strength to be used for the SDIO 80 * pins. If 0 then a default value will be used. This is the target drive 81 * strength, the exact drive strength which will be used depends on the 82 * capabilities of the device. 83 * 84 * oob_irq_supported: does the board have support for OOB interrupts. SDIO 85 * in-band interrupts are relatively slow and for having less overhead on 86 * interrupt processing an out of band interrupt can be used. If the HW 87 * supports this then enable this by setting this field to true and configure 88 * the oob related fields. 89 * 90 * oob_irq_nr, oob_irq_flags: the OOB interrupt information. The values are 91 * used for registering the irq using request_irq function. 92 * 93 * broken_sg_support: flag for broken sg list support of SDIO host controller. 94 * Set this to true if the SDIO host controller has higher align requirement 95 * than 32 bytes for each scatterlist item. 96 * 97 * sd_head_align: alignment requirement for start of data buffer 98 * 99 * sd_sgentry_align: length alignment requirement for each sg entry 100 * 101 * power_on: This function is called by the brcmfmac when the module gets 102 * loaded. This can be particularly useful for low power devices. The platform 103 * spcific routine may for example decide to power up the complete device. 104 * If there is no use-case for this function then provide NULL. 105 * 106 * power_off: This function is called by the brcmfmac when the module gets 107 * unloaded. At this point the device can be powered down or otherwise be reset. 108 * So if an actual power_off is not supported but reset is then reset the device 109 * when this function gets called. This can be particularly useful for low power 110 * devices. If there is no use-case for this function (either power-down or 111 * reset) then provide NULL. 112 * 113 * reset: This function can get called if the device communication broke down. 114 * This functionality is particularly useful in case of SDIO type devices. It is 115 * possible to reset a dongle via sdio data interface, but it requires that 116 * this is fully functional. This function is chip/module specific and this 117 * function should return only after the complete reset has completed. 118 */ 119 120#define BRCMFMAC_SDIO_PDATA_NAME "brcmfmac_sdio" 121 122struct brcmfmac_sdio_platform_data { 123 unsigned int drive_strength; 124 bool oob_irq_supported; 125 unsigned int oob_irq_nr; 126 unsigned long oob_irq_flags; 127 bool broken_sg_support; 128 unsigned short sd_head_align; 129 unsigned short sd_sgentry_align; 130 void (*power_on)(void); 131 void (*power_off)(void); 132 void (*reset)(void); 133}; 134 135#endif /* _LINUX_BRCMFMAC_PLATFORM_H */ 136