brcmfmac: add device tree support for SDIO devices
authorChen-Yu Tsai <wens@csie.org>
Sun, 29 Jun 2014 14:16:59 +0000 (16:16 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 29 Jul 2014 14:32:56 +0000 (10:32 -0400)
brcmfmac devices can use an out-of-band interrupt on a GPIO line.
Currently this is specified using platform data. Add support for
specifying out-of-band interrupt via device tree.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
[arend@broadcom.com: conditionalize more of-code, use driver debug routines]
Signed-off-by: Arend van Spriel <arend@broadcom.com>
[hdegoede@redhat.com: drop clk / reg_on gpio handling, as there is no consensus
 on how to handle this yet]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/brcm80211/brcmfmac/Makefile
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
drivers/net/wireless/brcm80211/brcmfmac/of.c [new file with mode: 0644]
drivers/net/wireless/brcm80211/brcmfmac/of.h [new file with mode: 0644]

index de0cff3df38950bd3194180d3f964990ce36d723..14e8a8d33520a92a49b86bbe2b52df3737f5e864 100644 (file)
@@ -46,3 +46,5 @@ brcmfmac-$(CONFIG_BRCMDBG) += \
                dhd_dbg.o
 brcmfmac-$(CONFIG_BRCM_TRACING) += \
                tracepoint.o
+brcmfmac-$(CONFIG_OF) += \
+               of.o
index f467cafe3e8f0803459807c03a13f9ab0fc19576..dc2db47a1c73a970522e3c7afe6cdfa268731db3 100644 (file)
@@ -42,6 +42,7 @@
 #include "dhd_bus.h"
 #include "dhd_dbg.h"
 #include "sdio_host.h"
+#include "of.h"
 
 #define SDIOH_API_ACCESS_RETRY_LIMIT   2
 
@@ -1044,6 +1045,9 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
        sdiodev->dev = &sdiodev->func[1]->dev;
        sdiodev->pdata = brcmfmac_sdio_pdata;
 
+       if (!sdiodev->pdata)
+               brcmf_of_probe(sdiodev);
+
        atomic_set(&sdiodev->suspend, false);
        init_waitqueue_head(&sdiodev->request_word_wait);
        init_waitqueue_head(&sdiodev->request_buffer_wait);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/of.c b/drivers/net/wireless/brcm80211/brcmfmac/of.c
new file mode 100644 (file)
index 0000000..f05f527
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <linux/init.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
+#include <linux/mmc/card.h>
+#include <linux/platform_data/brcmfmac-sdio.h>
+#include <linux/mmc/sdio_func.h>
+
+#include <defs.h>
+#include "dhd_dbg.h"
+#include "sdio_host.h"
+
+void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
+{
+       struct device *dev = sdiodev->dev;
+       struct device_node *np = dev->of_node;
+       int irq;
+       u32 irqf;
+       u32 val;
+
+       if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
+               return;
+
+       sdiodev->pdata = devm_kzalloc(dev, sizeof(*sdiodev->pdata), GFP_KERNEL);
+       if (!sdiodev->pdata)
+               return;
+
+       irq = irq_of_parse_and_map(np, 0);
+       if (irq < 0) {
+               brcmf_err("interrupt could not be mapped: err=%d\n", irq);
+               devm_kfree(dev, sdiodev->pdata);
+               return;
+       }
+       irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
+
+       sdiodev->pdata->oob_irq_supported = true;
+       sdiodev->pdata->oob_irq_nr = irq;
+       sdiodev->pdata->oob_irq_flags = irqf;
+
+       if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
+               sdiodev->pdata->drive_strength = val;
+}
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/of.h b/drivers/net/wireless/brcm80211/brcmfmac/of.h
new file mode 100644 (file)
index 0000000..5f7c355
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2014 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef CONFIG_OF
+void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev);
+#else
+static void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
+{
+}
+#endif /* CONFIG_OF */