summaryrefslogtreecommitdiff
path: root/arch/arm/mach-ux500
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2012-01-05 14:19:29 +0000
committerLee Jones <lee.jones@linaro.org>2012-01-05 14:19:29 +0000
commitc25f66c1a33c069f55713a170b4f811df068ae0c (patch)
tree4f5b68ff8be7e5dc02253d1029d35c6f9a852af6 /arch/arm/mach-ux500
parent52e6ef79dbf4c5922ff09766fd251ce661ac5045 (diff)
parent17fb1719bca96b5b716321b972fde41e7c89d6b1 (diff)
Merge branch 'tracking-igloo_kernel-wlan' into merge-integration-linux-ux500
Diffstat (limited to 'arch/arm/mach-ux500')
-rw-r--r--arch/arm/mach-ux500/board-mop500-wlan.c214
-rw-r--r--arch/arm/mach-ux500/board-mop500-wlan.h17
-rw-r--r--arch/arm/mach-ux500/board-u5500-wlan.c109
-rw-r--r--arch/arm/mach-ux500/board-u5500-wlan.h18
-rw-r--r--arch/arm/mach-ux500/include/mach/cw1200_plat.h26
5 files changed, 384 insertions, 0 deletions
diff --git a/arch/arm/mach-ux500/board-mop500-wlan.c b/arch/arm/mach-ux500/board-mop500-wlan.c
new file mode 100644
index 00000000000..52cd23b2852
--- /dev/null
+++ b/arch/arm/mach-ux500/board-mop500-wlan.c
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * Author: Dmitry Tarnyagin <dmitry.tarnyagin@stericsson.com>
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+#include <asm/mach-types.h>
+#include <mach/irqs.h>
+#include <plat/pincfg.h>
+#include <linux/clk.h>
+#include <mach/cw1200_plat.h>
+
+#include "pins.h"
+
+static void cw1200_release(struct device *dev);
+static int cw1200_power_ctrl(const struct cw1200_platform_data *pdata,
+ bool enable);
+static int cw1200_clk_ctrl(const struct cw1200_platform_data *pdata,
+ bool enable);
+
+static struct resource cw1200_href_resources[] = {
+ {
+ .start = 215,
+ .end = 215,
+ .flags = IORESOURCE_IO,
+ .name = "cw1200_reset",
+ },
+ {
+ .start = NOMADIK_GPIO_TO_IRQ(216),
+ .end = NOMADIK_GPIO_TO_IRQ(216),
+ .flags = IORESOURCE_IRQ,
+ .name = "cw1200_irq",
+ },
+};
+
+static struct resource cw1200_href60_resources[] = {
+ {
+ .start = 85,
+ .end = 85,
+ .flags = IORESOURCE_IO,
+ .name = "cw1200_reset",
+ },
+ {
+ .start = NOMADIK_GPIO_TO_IRQ(4),
+ .end = NOMADIK_GPIO_TO_IRQ(4),
+ .flags = IORESOURCE_IRQ,
+ .name = "cw1200_irq",
+ },
+};
+
+static struct cw1200_platform_data cw1200_platform_data = {
+ .clk_ctrl = cw1200_clk_ctrl,
+};
+
+static struct platform_device cw1200_device = {
+ .name = "cw1200_wlan",
+ .dev = {
+ .platform_data = &cw1200_platform_data,
+ .release = cw1200_release,
+ .init_name = "cw1200_wlan",
+ },
+};
+
+const struct cw1200_platform_data *cw1200_get_platform_data(void)
+{
+ return &cw1200_platform_data;
+}
+EXPORT_SYMBOL_GPL(cw1200_get_platform_data);
+
+static int cw1200_pins_enable(bool enable)
+{
+ struct ux500_pins *pins = NULL;
+ int ret = 0;
+
+ pins = ux500_pins_get("sdi1");
+
+ if (!pins) {
+ printk(KERN_ERR "cw1200: Pins are not found. "
+ "Check platform data.\n");
+ return -ENOENT;
+ }
+
+ if (enable)
+ ret = ux500_pins_enable(pins);
+ else
+ ret = ux500_pins_disable(pins);
+
+ if (ret)
+ printk(KERN_ERR "cw1200: Pins can not be %s: %d.\n",
+ enable ? "enabled" : "disabled",
+ ret);
+
+ ux500_pins_put(pins);
+
+ return ret;
+}
+
+static int cw1200_power_ctrl(const struct cw1200_platform_data *pdata,
+ bool enable)
+{
+ static const char *vdd_name = "vdd";
+ struct regulator *vdd;
+ int ret = 0;
+
+ vdd = regulator_get(&cw1200_device.dev, vdd_name);
+ if (IS_ERR(vdd)) {
+ ret = PTR_ERR(vdd);
+ dev_warn(&cw1200_device.dev,
+ "%s: Failed to get regulator '%s': %d\n",
+ __func__, vdd_name, ret);
+ } else {
+ if (enable)
+ ret = regulator_enable(vdd);
+ else
+ ret = regulator_disable(vdd);
+
+ if (ret) {
+ dev_warn(&cw1200_device.dev,
+ "%s: Failed to %s regulator '%s': %d\n",
+ __func__, enable ? "enable" : "disable",
+ vdd_name, ret);
+ }
+ regulator_put(vdd);
+ }
+ return ret;
+}
+
+static int cw1200_clk_ctrl(const struct cw1200_platform_data *pdata,
+ bool enable)
+{
+ static const char *clock_name = "sys_clk_out";
+ struct clk *clk_dev;
+ int ret = 0;
+
+ clk_dev = clk_get(&cw1200_device.dev, clock_name);
+
+ if (IS_ERR(clk_dev)) {
+ ret = PTR_ERR(clk_dev);
+ dev_warn(&cw1200_device.dev,
+ "%s: Failed to get clk '%s': %d\n",
+ __func__, clock_name, ret);
+
+ } else {
+
+ if (enable)
+ ret = clk_enable(clk_dev);
+ else
+ clk_disable(clk_dev);
+
+ if (ret) {
+ dev_warn(&cw1200_device.dev,
+ "%s: Failed to %s clk enable: %d\n",
+ __func__, clock_name, ret);
+ }
+ }
+
+ return ret;
+}
+
+int __init mop500_wlan_init(void)
+{
+ int ret;
+
+ if (machine_is_u8500() ||
+ machine_is_nomadik() ||
+ machine_is_snowball()) {
+ cw1200_device.num_resources = ARRAY_SIZE(cw1200_href_resources);
+ cw1200_device.resource = cw1200_href_resources;
+ } else if (machine_is_hrefv60()) {
+ cw1200_device.num_resources =
+ ARRAY_SIZE(cw1200_href60_resources);
+ cw1200_device.resource = cw1200_href60_resources;
+ } else {
+ dev_err(&cw1200_device.dev,
+ "Unsupported mach type %d "
+ "(check mach-types.h)\n",
+ __machine_arch_type);
+ return -ENOTSUPP;
+ }
+
+ if (machine_is_snowball())
+ cw1200_platform_data.mmc_id = "mmc2";
+ else
+ cw1200_platform_data.mmc_id = "mmc3";
+
+ cw1200_platform_data.reset = &cw1200_device.resource[0];
+ cw1200_platform_data.irq = &cw1200_device.resource[1];
+
+ cw1200_device.dev.release = cw1200_release;
+
+ if (machine_is_snowball())
+ cw1200_platform_data.power_ctrl = cw1200_power_ctrl;
+
+ ret = cw1200_pins_enable(true);
+ if (WARN_ON(ret))
+ return ret;
+
+ ret = platform_device_register(&cw1200_device);
+ if (ret)
+ cw1200_pins_enable(false);
+
+ return ret;
+}
+
+static void cw1200_release(struct device *dev)
+{
+ cw1200_pins_enable(false);
+}
diff --git a/arch/arm/mach-ux500/board-mop500-wlan.h b/arch/arm/mach-ux500/board-mop500-wlan.h
new file mode 100644
index 00000000000..c6788adc46f
--- /dev/null
+++ b/arch/arm/mach-ux500/board-mop500-wlan.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * License terms: GNU General Public License (GPL), version 2
+ *
+ * U8500 board specific cw1200 (WLAN device) initialization.
+ *
+ * Author: Dmitry Tarnyagin <dmitry.tarnyagin@stericsson.com>
+ *
+ */
+
+#ifndef __BOARD_MOP500_WLAN_H
+#define __BOARD_MOP500_WLAN_H
+
+int mop500_wlan_init(void);
+
+#endif
diff --git a/arch/arm/mach-ux500/board-u5500-wlan.c b/arch/arm/mach-ux500/board-u5500-wlan.c
new file mode 100644
index 00000000000..8459ebd6aac
--- /dev/null
+++ b/arch/arm/mach-ux500/board-u5500-wlan.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * Author: Dmitry Tarnyagin <dmitry.tarnyagin@stericsson.com>
+ *Author: Bartosz Markowski <bartosz.markowski@tieto.com> for ST-Ericsson
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
+#include <asm/mach-types.h>
+#include <mach/irqs.h>
+#include <plat/pincfg.h>
+#include "pins.h"
+#include <mach/cw1200_plat.h>
+
+static void cw1200_release(struct device *dev);
+
+static struct resource cw1200_u5500_resources[] = {
+ {
+ .start = NOMADIK_GPIO_TO_IRQ(129),
+ .end = NOMADIK_GPIO_TO_IRQ(129),
+ .flags = IORESOURCE_IRQ,
+ .name = "cw1200_irq",
+ },
+};
+
+static struct cw1200_platform_data cw1200_u5500_platform_data = { 0 };
+
+static struct platform_device cw1200_device = {
+ .name = "cw1200_wlan",
+ .dev = {
+ .platform_data = &cw1200_u5500_platform_data,
+ .release = cw1200_release,
+ .init_name = "cw1200_wlan",
+ },
+};
+
+const struct cw1200_platform_data *cw1200_u5500_get_platform_data(void)
+{
+ return &cw1200_u5500_platform_data;
+}
+EXPORT_SYMBOL_GPL(cw1200_u5500_get_platform_data);
+
+static int cw1200_pins_enable(bool enable)
+{
+ struct ux500_pins *pins = NULL;
+ int ret = 0;
+
+ pins = ux500_pins_get("sdi3");
+
+ if (!pins) {
+ printk(KERN_ERR "cw1200: Pins are not found. "
+ "Check platform data.\n");
+ return -ENOENT;
+ }
+
+ if (enable)
+ ret = ux500_pins_enable(pins);
+ else
+ ret = ux500_pins_disable(pins);
+
+ if (ret)
+ printk(KERN_ERR "cw1200: Pins can not be %s: %d.\n",
+ enable ? "enabled" : "disabled",
+ ret);
+
+ ux500_pins_put(pins);
+
+ return ret;
+}
+
+int __init u5500_wlan_init(void)
+{
+ int ret;
+
+ if (machine_is_u5500()) {
+ cw1200_device.num_resources = ARRAY_SIZE(cw1200_u5500_resources);
+ cw1200_device.resource = cw1200_u5500_resources;
+ } else {
+ dev_err(&cw1200_device.dev,
+ "Unsupported mach type %d "
+ "(check mach-types.h)\n",
+ __machine_arch_type);
+ return -ENOTSUPP;
+ }
+
+ cw1200_u5500_platform_data.mmc_id = "mmc2";
+ cw1200_u5500_platform_data.irq = &cw1200_device.resource[0];
+
+ cw1200_device.dev.release = cw1200_release;
+
+ ret = cw1200_pins_enable(true);
+ if (WARN_ON(ret))
+ return ret;
+
+ ret = platform_device_register(&cw1200_device);
+ if (ret)
+ cw1200_pins_enable(false);
+
+ return ret;
+}
+
+static void cw1200_release(struct device *dev)
+{
+ cw1200_pins_enable(false);
+}
diff --git a/arch/arm/mach-ux500/board-u5500-wlan.h b/arch/arm/mach-ux500/board-u5500-wlan.h
new file mode 100644
index 00000000000..89fd41166fd
--- /dev/null
+++ b/arch/arm/mach-ux500/board-u5500-wlan.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * License terms: GNU General Public License (GPL), version 2
+ *
+ * U5500 board specific cw1200 (WLAN device) initialization.
+ *
+ * Author: Dmitry Tarnyagin <dmitry.tarnyagin@stericsson.com>
+ * Author: Bartosz Markowski <bartosz.markowski@tieto.com> for ST-Ericsson
+ *
+ */
+
+#ifndef __BOARD_U5500_WLAN_H
+#define __BOARD_U5500_WLAN_H
+
+int u5500_wlan_init(void);
+
+#endif
diff --git a/arch/arm/mach-ux500/include/mach/cw1200_plat.h b/arch/arm/mach-ux500/include/mach/cw1200_plat.h
new file mode 100644
index 00000000000..4d30dbd3979
--- /dev/null
+++ b/arch/arm/mach-ux500/include/mach/cw1200_plat.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2011
+ *
+ * Author: Dmitry Tarnyagin <dmitry.tarnyagin@stericsson.com>
+ * License terms: GNU General Public License (GPL) version 2
+ */
+
+#ifndef CW1200_PLAT_H_INCLUDED
+#define CW1200_PLAT_H_INCLUDED
+
+#include <linux/ioport.h>
+
+struct cw1200_platform_data {
+ const char *mmc_id;
+ const struct resource *irq;
+ const struct resource *reset;
+ int (*power_ctrl)(const struct cw1200_platform_data *pdata,
+ bool enable);
+ int (*clk_ctrl)(const struct cw1200_platform_data *pdata,
+ bool enable);
+};
+
+/* Declaration only. Should be implemented in arch/xxx/mach-yyy */
+const struct cw1200_platform_data *cw1200_get_platform_data(void);
+
+#endif /* CW1200_PLAT_H_INCLUDED */