Hi Hans,
I have put some effort in adding device tree support in brcmfmac.
Unfortunately, I had no luck getting MMC up and running on pandaboard
extension header. So no way to test the patches. Would/could you be
willing to do so.
Regards,
Arend
--
You received this message because you are subscribed to the Google Groups
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
>From cdee67e76c7527cabd2308c447d8d3374d1b8581 Mon Sep 17 00:00:00 2001
From: Arend van Spriel <[email protected]>
Date: Fri, 31 Jan 2014 10:22:09 +0100
Subject: [PATCH 1/2] dt: bindings: add bindings for Broadcom bcm43xx sdio
devices
The Broadcom bcm43xx sdio devices are fullmac devices that may be
integrated in ARM platforms. Currently, the brcmfmac driver for
these devices support use of platform data. This patch specifies
the bindings that allow this platform data to be expressed in the
devicetree.
Reviewed-by: Hante Meuleman <[email protected]>
Reviewed-by: Franky (Zhenhui) Lin <[email protected]>
Reviewed-by: Daniel (Deognyoun) Kim <[email protected]>
Reviewed-by: Pieter-Paul Giesberts <[email protected]>
Signed-off-by: Arend van Spriel <[email protected]>
---8<-----------------------------------------------------
Currently the platform data also holds alignment requirements and
broke sg indication but those do not really characterize the device
so I did not include those.
---
.../staging/net/wireless/brcm,bcm43xx-fmac.txt | 40 ++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 Documentation/devicetree/bindings/staging/net/wireless/brcm,bcm43xx-fmac.txt
diff --git a/Documentation/devicetree/bindings/staging/net/wireless/brcm,bcm43xx-fmac.txt b/Documentation/devicetree/bindings/staging/net/wireless/brcm,bcm43xx-fmac.txt
new file mode 100644
index 0000000..aa8eb76
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/net/wireless/brcm,bcm43xx-fmac.txt
@@ -0,0 +1,40 @@
+Broadcom BCM43xx Fullmac wireless SDIO devices
+
+This node provides properties for controlling the Broadcom wireless device. The
+node is expected to be specified as a child node to the SDIO controller that
+connects the device to the system.
+
+Required properties:
+
+ - compatible : Should be "brcm,bcm43xx-fmac".
+ - brcm,wlan-supply : phandle for gpio to control power for the device/module.
+
+Optional properties:
+ - brcm,wlan-reset : phandle for gpio to reset the device/module.
+ - brcm,drive-strength : drive strength used for SDIO pins on device.
+ (default = 6mA).
+ - interrupt-parent : the phandle for the interrupt controller to which the
+ device interrupts are connected.
+ - interrupts : specifies attributes for the out-of-band interrupt (host-wake).
+ When not specified the device will use in-band SDIO interrupts.
+ - interrupt-names : name of the out-of-band interrupt, which must be set
+ to "host-wake".
+ - clocks : specifies the clocks needed for the device.
+ The device requires two clocks which must be named "sysclk"
+ and "sleepclk".
+ - clock-names : specifies the names of clocks.
+
+Example:
+
+bcm4335 {
+ compatible = "brcm,bcm43xx-fmac";
+ brcm,wlan-supply = <&wlan-pwr>;
+ brcm,wlan-reset = <&wlan-rst>;
+ brcm,drive-strength = <4>;
+ interrupt-parent = <&gpx2>;
+ interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "host-wake";
+ clocks = <&osc 1>, <&osc 2>;
+ clock-names = "sysclk", "sleepclk";
+};
+
--
1.7.9.5
>From 31295c88b01e7fc78360b0067b47e51fa6b52ba6 Mon Sep 17 00:00:00 2001
From: Chen-Yu Tsai <[email protected]>
Date: Tue, 7 Jan 2014 18:42:22 +0800
Subject: [PATCH 2/2] brcmfmac: add device tree support for SDIO devices
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 <[email protected]>
[[email protected]: conditionalize more of-code, use driver debug routines]
Signed-off-by: Arend van Spriel <[email protected]>
---
drivers/net/wireless/brcm80211/brcmfmac/Makefile | 2 +
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 22 ++-
drivers/net/wireless/brcm80211/brcmfmac/of.c | 158 ++++++++++++++++++++++
drivers/net/wireless/brcm80211/brcmfmac/of.h | 33 +++++
4 files changed, 210 insertions(+), 5 deletions(-)
create mode 100644 drivers/net/wireless/brcm80211/brcmfmac/of.c
create mode 100644 drivers/net/wireless/brcm80211/brcmfmac/of.h
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/Makefile b/drivers/net/wireless/brcm80211/brcmfmac/Makefile
index 57cddee..96c5fc4 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/Makefile
+++ b/drivers/net/wireless/brcm80211/brcmfmac/Makefile
@@ -44,3 +44,5 @@ brcmfmac-$(CONFIG_BRCMDBG) += \
dhd_dbg.o
brcmfmac-$(CONFIG_BRCM_TRACING) += \
tracepoint.o
+brcmfmac-$(CONFIG_OF) += \
+ of.o
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index fa35b23..03f7353 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -33,6 +33,7 @@
#include <linux/suspend.h>
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <net/cfg80211.h>
#include <defs.h>
@@ -44,6 +45,7 @@
#include "dhd_dbg.h"
#include "sdio_host.h"
#include "sdio_chip.h"
+#include "of.h"
#define SDIOH_API_ACCESS_RETRY_LIMIT 2
@@ -966,7 +968,6 @@ MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
static struct brcmfmac_sdio_platform_data *brcmfmac_sdio_pdata;
-
static int brcmf_ops_sdio_probe(struct sdio_func *func,
const struct sdio_device_id *id)
{
@@ -1013,6 +1014,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);
@@ -1115,11 +1119,13 @@ static struct sdio_driver brcmf_sdmmc_driver = {
.remove = brcmf_ops_sdio_remove,
.name = BRCMFMAC_SDIO_PDATA_NAME,
.id_table = brcmf_sdmmc_ids,
-#ifdef CONFIG_PM_SLEEP
.drv = {
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(brcmf_of_ids),
+#ifdef CONFIG_PM_SLEEP
.pm = &brcmf_sdio_pm_ops,
- },
#endif /* CONFIG_PM_SLEEP */
+ },
};
static int brcmf_sdio_pd_probe(struct platform_device *pdev)
@@ -1169,8 +1175,10 @@ void brcmf_sdio_exit(void)
if (brcmfmac_sdio_pdata)
platform_driver_unregister(&brcmf_sdio_pd);
- else
+ else {
sdio_unregister_driver(&brcmf_sdmmc_driver);
+ brcmf_of_exit();
+ }
}
void __init brcmf_sdio_init(void)
@@ -1180,6 +1188,10 @@ void __init brcmf_sdio_init(void)
brcmf_dbg(SDIO, "Enter\n");
ret = platform_driver_probe(&brcmf_sdio_pd, brcmf_sdio_pd_probe);
- if (ret == -ENODEV)
+ if (ret == -ENODEV) {
brcmf_dbg(SDIO, "No platform data available.\n");
+ /* see if devicetree contains data */
+ brcmf_of_init();
+ }
}
+
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/of.c b/drivers/net/wireless/brcm80211/brcmfmac/of.c
new file mode 100644
index 0000000..f4cb8a8
--- /dev/null
+++ b/drivers/net/wireless/brcm80211/brcmfmac/of.c
@@ -0,0 +1,158 @@
+/*
+ * 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/gpio/consumer.h>
+#include <linux/of_gpio.h>
+#include <linux/of_irq.h>
+#include <linux/clk.h>
+#include <linux/mmc/card.h>
+#include <linux/platform_data/brcmfmac-sdio.h>
+
+#include <defs.h>
+#include "dhd_dbg.h"
+#include "sdio_host.h"
+
+struct brcmf_of_gpio_list {
+ struct list_head list;
+ struct gpio_desc *gpio;
+};
+
+struct brcmf_of_clock_list {
+ struct list_head list;
+ struct clk *clock;
+};
+
+const struct of_device_id brcmf_of_ids[] = {
+ { .compatible = "brcm,bcm43xx-fmac" },
+ { /* sentinal */ },
+};
+MODULE_DEVICE_TABLE(of, brcmf_of_ids);
+
+static LIST_HEAD(gpio_list);
+static LIST_HEAD(clock_list);
+
+static void brcmf_of_power_on(struct device_node *np)
+{
+ struct brcmf_of_gpio_list *item;
+ struct gpio_desc *pwr;
+ enum of_gpio_flags flags;
+
+ pwr = of_get_named_gpiod_flags(np, "brcm,wlan-supply", 0,
+ &flags);
+ if (!pwr) {
+ brcmf_err("no brcm,wlan-supply specified\n");
+ return;
+ }
+
+ if (gpio_request(desc_to_gpio(pwr), "wlan-supply")) {
+ brcmf_err("Failed to request gpio(wlan-supply)\n");
+ gpiod_put(pwr);
+ } else {
+ item = kzalloc(sizeof(*item), GFP_KERNEL);
+ item->gpio = pwr;
+ list_add(&item->list, &gpio_list);
+ gpiod_direction_output(pwr, 0);
+ gpiod_set_value_cansleep(pwr, 1);
+ }
+}
+
+static void brcmf_of_clocks_enable(struct device_node *np)
+{
+ struct brcmf_of_clock_list *item;
+ struct clk *clk;
+
+ clk = of_clk_get_by_name(np, "sysclk");
+ if (clk) {
+ item = kzalloc(sizeof(*item), GFP_KERNEL);
+ item->clock = clk;
+ list_add(&item->list, &clock_list);
+ clk_prepare_enable(clk);
+ }
+ clk = of_clk_get_by_name(np, "sleepclk");
+ if (clk) {
+ item = kzalloc(sizeof(*item), GFP_KERNEL);
+ item->clock = clk;
+ list_add(&item->list, &clock_list);
+ clk_prepare_enable(clk);
+ }
+}
+
+void __init brcmf_of_init(void)
+{
+ struct device_node *np;
+
+ brcmf_dbg(SDIO, "Enter\n");
+ for_each_matching_node(np, brcmf_of_ids) {
+ /* enable card and optional clocks */
+ brcmf_of_clocks_enable(np);
+ brcmf_of_power_on(np);
+ }
+}
+
+void brcmf_of_exit(void)
+{
+ struct brcmf_of_gpio_list *pwr;
+ struct brcmf_of_gpio_list *pwr_next;
+ struct brcmf_of_clock_list *clk;
+ struct brcmf_of_clock_list *clk_next;
+
+ list_for_each_entry_safe(pwr, pwr_next, &gpio_list, list) {
+ /* gpio goes back to original state on put */
+ gpiod_put(pwr->gpio);
+ list_del(&pwr->list);
+ kfree(pwr);
+ }
+ list_for_each_entry_safe(clk, clk_next, &clock_list, list) {
+ clk_disable_unprepare(clk->clock);
+ clk_put(clk->clock);
+ list_del(&clk->list);
+ kfree(clk);
+ }
+
+}
+
+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)
+ 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
index 0000000..5d9ec06
--- /dev/null
+++ b/drivers/net/wireless/brcm80211/brcmfmac/of.h
@@ -0,0 +1,33 @@
+/*
+ * 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
+extern const struct of_device_id brcmf_of_ids[];
+void __init brcmf_of_init(void);
+void brcmf_of_exit(void);
+void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev);
+#else
+static void __init brcmf_of_init(void)
+{
+}
+static void brcmf_of_exit(void)
+{
+}
+static void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
+{
+}
+#endif /* CONFIG_OF */
+
+
--
1.7.9.5