diff options
| author | Hante Meuleman <meuleman@broadcom.com> | 2013-04-12 04:55:55 -0400 |
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2013-04-12 14:27:55 -0400 |
| commit | 668761ac01d6f5a36b8e5a24d4e154550e2c4c3b (patch) | |
| tree | aaf5ab3af476a7b293b0b8d9e78aef42ea77c2d6 /include/linux/platform_data | |
| parent | 979c29205ffa607c59ba2c9f9c083b967d356c97 (diff) | |
brcmfmac: define and use platform specific data for SDIO.
This patch adds support for platform specific data for SDIO
fullmac devices. Currently OOB interrupts are configured by Kconfig
BRCMFMAC_SDIO_OOB but that is now determined dynamically by checking
availibility of platform data.
Cc: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: Piotr Haber <phaber@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include/linux/platform_data')
| -rw-r--r-- | include/linux/platform_data/brcmfmac-sdio.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/include/linux/platform_data/brcmfmac-sdio.h b/include/linux/platform_data/brcmfmac-sdio.h new file mode 100644 index 000000000000..1ade657d5fc1 --- /dev/null +++ b/include/linux/platform_data/brcmfmac-sdio.h | |||
| @@ -0,0 +1,124 @@ | |||
| 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 | |||
| 31 | static void brcmfmac_power_on(void) | ||
| 32 | { | ||
| 33 | } | ||
| 34 | |||
| 35 | static void brcmfmac_power_off(void) | ||
| 36 | { | ||
| 37 | } | ||
| 38 | |||
| 39 | static void brcmfmac_reset(void) | ||
| 40 | { | ||
| 41 | } | ||
| 42 | |||
| 43 | static 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 | |||
| 49 | static 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 | |||
| 55 | void __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 | * power_on: This function is called by the brcmfmac when the module gets | ||
| 94 | * loaded. This can be particularly useful for low power devices. The platform | ||
| 95 | * spcific routine may for example decide to power up the complete device. | ||
| 96 | * If there is no use-case for this function then provide NULL. | ||
| 97 | * | ||
| 98 | * power_off: This function is called by the brcmfmac when the module gets | ||
| 99 | * unloaded. At this point the device can be powered down or otherwise be reset. | ||
| 100 | * So if an actual power_off is not supported but reset is then reset the device | ||
| 101 | * when this function gets called. This can be particularly useful for low power | ||
| 102 | * devices. If there is no use-case for this function (either power-down or | ||
| 103 | * reset) then provide NULL. | ||
| 104 | * | ||
| 105 | * reset: This function can get called if the device communication broke down. | ||
| 106 | * This functionality is particularly useful in case of SDIO type devices. It is | ||
| 107 | * possible to reset a dongle via sdio data interface, but it requires that | ||
| 108 | * this is fully functional. This function is chip/module specific and this | ||
| 109 | * function should return only after the complete reset has completed. | ||
| 110 | */ | ||
| 111 | |||
| 112 | #define BRCMFMAC_SDIO_PDATA_NAME "brcmfmac_sdio" | ||
| 113 | |||
| 114 | struct brcmfmac_sdio_platform_data { | ||
| 115 | unsigned int drive_strength; | ||
| 116 | bool oob_irq_supported; | ||
| 117 | unsigned int oob_irq_nr; | ||
| 118 | unsigned long oob_irq_flags; | ||
| 119 | void (*power_on)(void); | ||
| 120 | void (*power_off)(void); | ||
| 121 | void (*reset)(void); | ||
| 122 | }; | ||
| 123 | |||
| 124 | #endif /* _LINUX_BRCMFMAC_PLATFORM_H */ | ||
