diff options
author | Imre Kaloz <kaloz@openwrt.org> | 2014-03-18 18:54:27 +0000 |
---|---|---|
committer | Imre Kaloz <kaloz@openwrt.org> | 2014-03-18 18:54:27 +0000 |
commit | 7777f1ed2c60c4642014270860907e59647baf00 (patch) | |
tree | 322fb9ef5f66790238b90c2b68df7d5b806f06e3 /target/linux/omap/patches-3.12/900-wlcore-Add-support-for-DT-platform-data.patch | |
parent | 4cc6898f944b6e51df2f61dfb9e3fc22c39d8119 (diff) | |
download | upstream-7777f1ed2c60c4642014270860907e59647baf00.tar.gz upstream-7777f1ed2c60c4642014270860907e59647baf00.tar.bz2 upstream-7777f1ed2c60c4642014270860907e59647baf00.zip |
[mac80211][omap]: switch to the newer DT bindings for wl1xxx
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@39946 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/omap/patches-3.12/900-wlcore-Add-support-for-DT-platform-data.patch')
-rw-r--r-- | target/linux/omap/patches-3.12/900-wlcore-Add-support-for-DT-platform-data.patch | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/target/linux/omap/patches-3.12/900-wlcore-Add-support-for-DT-platform-data.patch b/target/linux/omap/patches-3.12/900-wlcore-Add-support-for-DT-platform-data.patch new file mode 100644 index 0000000000..750d9e3d68 --- /dev/null +++ b/target/linux/omap/patches-3.12/900-wlcore-Add-support-for-DT-platform-data.patch @@ -0,0 +1,155 @@ +When running with DT, we no longer have a board file that can set up the +platform data for wlcore. Allow this data to be passed from DT. + +Since some platforms use a gpio-irq, add support for passing either the +irq number or the gpio number. For the latter case, the driver will +request the gpio and convert it to the irq number. If an irq is +specified, it'll be used as is. + +[Arik - the pdev_data pointer does not belong to us and is freed when +the device is released. Dereference to our private data first.] + +Signed-off-by: Ido Yariv <ido@wizery.com> +Signed-off-by: Arik Nemtsov <arik@wizery.com> +--- + drivers/net/wireless/ti/wlcore/sdio.c | 71 ++++++++++++++++++++++++++++++++--- + include/linux/wl12xx.h | 3 +- + 2 files changed, 67 insertions(+), 7 deletions(-) + +--- a/drivers/net/wireless/ti/wlcore/sdio.c ++++ b/drivers/net/wireless/ti/wlcore/sdio.c +@@ -34,6 +34,7 @@ + #include <linux/wl12xx.h> + #include <linux/pm_runtime.h> + #include <linux/printk.h> ++#include <linux/of.h> + + #include "wlcore.h" + #include "wl12xx_80211.h" +@@ -214,6 +215,61 @@ static struct wl1271_if_operations sdio_ + .set_block_size = wl1271_sdio_set_block_size, + }; + ++static const struct of_device_id wlcore_of_match[] = { ++ { ++ .compatible = "wlcore", ++ }, ++ {} ++}; ++MODULE_DEVICE_TABLE(of, wlcore_of_match); ++ ++static struct wl12xx_platform_data *get_platform_data(struct device *dev) ++{ ++ struct wl12xx_platform_data *pdata; ++ struct device_node *np; ++ u32 gpio; ++ ++ pdata = wl12xx_get_platform_data(); ++ if (!IS_ERR(pdata)) ++ return kmemdup(pdata, sizeof(*pdata), GFP_KERNEL); ++ ++ np = of_find_matching_node(NULL, wlcore_of_match); ++ if (!np) { ++ dev_err(dev, "No platform data set\n"); ++ return NULL; ++ } ++ ++ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); ++ if (!pdata) { ++ dev_err(dev, "Can't allocate platform data\n"); ++ return NULL; ++ } ++ ++ if (of_property_read_u32(np, "irq", &pdata->irq)) { ++ if (!of_property_read_u32(np, "gpio", &gpio) && ++ !gpio_request_one(gpio, GPIOF_IN, "wlcore_irq")) { ++ pdata->gpio = gpio; ++ pdata->irq = gpio_to_irq(gpio); ++ } ++ } ++ ++ /* Optional fields */ ++ pdata->use_eeprom = of_property_read_bool(np, "use-eeprom"); ++ of_property_read_u32(np, "board-ref-clock", &pdata->board_ref_clock); ++ of_property_read_u32(np, "board-tcxo-clock", &pdata->board_tcxo_clock); ++ of_property_read_u32(np, "platform-quirks", &pdata->platform_quirks); ++ ++ return pdata; ++} ++ ++static void del_platform_data(struct wl12xx_platform_data *pdata) ++{ ++ if (pdata->gpio) ++ gpio_free(pdata->gpio); ++ ++ kfree(pdata); ++} ++ + static int wl1271_probe(struct sdio_func *func, + const struct sdio_device_id *id) + { +@@ -248,12 +304,9 @@ static int wl1271_probe(struct sdio_func + /* Use block mode for transferring over one block size of data */ + func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; + +- pdev_data->pdata = wl12xx_get_platform_data(); +- if (IS_ERR(pdev_data->pdata)) { +- ret = PTR_ERR(pdev_data->pdata); +- dev_err(glue->dev, "missing wlan platform data: %d\n", ret); ++ pdev_data->pdata = get_platform_data(&func->dev); ++ if (!(pdev_data->pdata)) + goto out_free_glue; +- } + + /* if sdio can keep power while host is suspended, enable wow */ + mmcflags = sdio_get_host_pm_caps(func); +@@ -282,7 +335,7 @@ static int wl1271_probe(struct sdio_func + if (!glue->core) { + dev_err(glue->dev, "can't allocate platform_device"); + ret = -ENOMEM; +- goto out_free_glue; ++ goto out_free_pdata; + } + + glue->core->dev.parent = &func->dev; +@@ -316,6 +369,9 @@ static int wl1271_probe(struct sdio_func + out_dev_put: + platform_device_put(glue->core); + ++out_free_pdata: ++ del_platform_data(pdev_data->pdata); ++ + out_free_glue: + kfree(glue); + +@@ -329,11 +385,14 @@ out: + static void wl1271_remove(struct sdio_func *func) + { + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); ++ struct wlcore_platdev_data *pdev_data = glue->core->dev.platform_data; ++ struct wl12xx_platform_data *pdata = pdev_data->pdata; + + /* Undo decrement done above in wl1271_probe */ + pm_runtime_get_noresume(&func->dev); + + platform_device_unregister(glue->core); ++ del_platform_data(pdata); + kfree(glue); + } + +--- a/include/linux/wl12xx.h ++++ b/include/linux/wl12xx.h +@@ -51,11 +51,12 @@ enum { + struct wl12xx_platform_data { + void (*set_power)(bool enable); + /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */ ++ int gpio; + int irq; + bool use_eeprom; + int board_ref_clock; + int board_tcxo_clock; +- unsigned long platform_quirks; ++ u32 platform_quirks; + bool pwr_in_suspend; + }; + |