blob: b7174998c24aa92a76b2cb693c3e8471b12ec236 [file] [log] [blame]
Hante Meuleman668761a2013-04-12 10:55:55 +02001/*
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 *
Franky Lin3b81a682013-06-26 14:20:18 +020093 * 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 *
Hante Meuleman668761a2013-04-12 10:55:55 +020097 * power_on: This function is called by the brcmfmac when the module gets
98 * loaded. This can be particularly useful for low power devices. The platform
99 * spcific routine may for example decide to power up the complete device.
100 * If there is no use-case for this function then provide NULL.
101 *
102 * power_off: This function is called by the brcmfmac when the module gets
103 * unloaded. At this point the device can be powered down or otherwise be reset.
104 * So if an actual power_off is not supported but reset is then reset the device
105 * when this function gets called. This can be particularly useful for low power
106 * devices. If there is no use-case for this function (either power-down or
107 * reset) then provide NULL.
108 *
109 * reset: This function can get called if the device communication broke down.
110 * This functionality is particularly useful in case of SDIO type devices. It is
111 * possible to reset a dongle via sdio data interface, but it requires that
112 * this is fully functional. This function is chip/module specific and this
113 * function should return only after the complete reset has completed.
114 */
115
116#define BRCMFMAC_SDIO_PDATA_NAME "brcmfmac_sdio"
117
118struct brcmfmac_sdio_platform_data {
119 unsigned int drive_strength;
120 bool oob_irq_supported;
121 unsigned int oob_irq_nr;
122 unsigned long oob_irq_flags;
Franky Lin3b81a682013-06-26 14:20:18 +0200123 bool broken_sg_support;
Hante Meuleman668761a2013-04-12 10:55:55 +0200124 void (*power_on)(void);
125 void (*power_off)(void);
126 void (*reset)(void);
127};
128
129#endif /* _LINUX_BRCMFMAC_PLATFORM_H */