2013-06-23 15:50:49 +00:00
|
|
|
From c7107291df4035794c67d7a904fe7419fedc5922 Mon Sep 17 00:00:00 2001
|
2013-04-03 09:59:10 +00:00
|
|
|
From: John Crispin <blogic@openwrt.org>
|
2013-04-25 19:02:42 +00:00
|
|
|
Date: Mon, 22 Apr 2013 23:11:42 +0200
|
2013-06-23 15:50:49 +00:00
|
|
|
Subject: [PATCH 45/79] MIPS: ralink: add pinmux driver
|
2013-04-03 09:59:10 +00:00
|
|
|
|
|
|
|
Add code to setup the pinmux on ralonk SoC. The SoC has a single 32 bit register
|
|
|
|
for this functionality with simple on/off bits. Building a full featured pinctrl
|
|
|
|
driver would be overkill.
|
|
|
|
|
|
|
|
Signed-off-by: John Crispin <blogic@openwrt.org>
|
|
|
|
---
|
|
|
|
arch/mips/ralink/Makefile | 2 +-
|
2013-04-25 19:02:42 +00:00
|
|
|
arch/mips/ralink/common.h | 2 ++
|
2013-04-03 09:59:10 +00:00
|
|
|
arch/mips/ralink/of.c | 2 ++
|
2013-06-23 15:50:49 +00:00
|
|
|
arch/mips/ralink/pinmux.c | 77 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
4 files changed, 82 insertions(+), 1 deletion(-)
|
2013-04-03 09:59:10 +00:00
|
|
|
create mode 100644 arch/mips/ralink/pinmux.c
|
|
|
|
|
2013-06-23 15:50:49 +00:00
|
|
|
diff --git a/arch/mips/ralink/Makefile b/arch/mips/ralink/Makefile
|
|
|
|
index 38cf1a8..341b4de 100644
|
2013-05-08 08:53:53 +00:00
|
|
|
--- a/arch/mips/ralink/Makefile
|
|
|
|
+++ b/arch/mips/ralink/Makefile
|
2013-04-03 09:59:10 +00:00
|
|
|
@@ -6,7 +6,7 @@
|
|
|
|
# Copyright (C) 2009-2011 Gabor Juhos <juhosg@openwrt.org>
|
|
|
|
# Copyright (C) 2013 John Crispin <blogic@openwrt.org>
|
|
|
|
|
|
|
|
-obj-y := prom.o of.o reset.o clk.o irq.o
|
|
|
|
+obj-y := prom.o of.o reset.o clk.o irq.o pinmux.o
|
|
|
|
|
2013-04-25 19:02:42 +00:00
|
|
|
obj-$(CONFIG_SOC_RT288X) += rt288x.o
|
2013-04-03 09:59:10 +00:00
|
|
|
obj-$(CONFIG_SOC_RT305X) += rt305x.o
|
2013-06-23 15:50:49 +00:00
|
|
|
diff --git a/arch/mips/ralink/common.h b/arch/mips/ralink/common.h
|
|
|
|
index 83144c3..f113fd6 100644
|
2013-05-08 08:53:53 +00:00
|
|
|
--- a/arch/mips/ralink/common.h
|
|
|
|
+++ b/arch/mips/ralink/common.h
|
2013-06-23 15:50:49 +00:00
|
|
|
@@ -50,4 +50,6 @@ extern void prom_soc_init(struct ralink_soc_info *soc_info);
|
2013-04-03 09:59:10 +00:00
|
|
|
|
|
|
|
__iomem void *plat_of_remap_node(const char *node);
|
|
|
|
|
|
|
|
+void ralink_pinmux(void);
|
|
|
|
+
|
|
|
|
#endif /* _RALINK_COMMON_H__ */
|
2013-06-23 15:50:49 +00:00
|
|
|
diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
|
|
|
|
index fb15695..f916774 100644
|
2013-05-08 08:53:53 +00:00
|
|
|
--- a/arch/mips/ralink/of.c
|
|
|
|
+++ b/arch/mips/ralink/of.c
|
|
|
|
@@ -110,6 +110,8 @@ static int __init plat_of_setup(void)
|
2013-04-03 09:59:10 +00:00
|
|
|
if (of_platform_populate(NULL, of_ids, NULL, NULL))
|
|
|
|
panic("failed to populate DT\n");
|
|
|
|
|
|
|
|
+ ralink_pinmux();
|
|
|
|
+
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-23 15:50:49 +00:00
|
|
|
diff --git a/arch/mips/ralink/pinmux.c b/arch/mips/ralink/pinmux.c
|
|
|
|
new file mode 100644
|
|
|
|
index 0000000..1720216
|
2013-05-08 08:53:53 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/arch/mips/ralink/pinmux.c
|
2013-05-04 11:36:51 +00:00
|
|
|
@@ -0,0 +1,77 @@
|
2013-04-03 09:59:10 +00:00
|
|
|
+/*
|
|
|
|
+ * This program is free software; you can redistribute it and/or modify it
|
|
|
|
+ * under the terms of the GNU General Public License version 2 as published
|
|
|
|
+ * by the Free Software Foundation.
|
|
|
|
+ *
|
|
|
|
+ * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <linux/kernel.h>
|
|
|
|
+#include <linux/of.h>
|
|
|
|
+
|
|
|
|
+#include <asm/mach-ralink/ralink_regs.h>
|
|
|
|
+
|
|
|
|
+#include "common.h"
|
|
|
|
+
|
|
|
|
+#define SYSC_REG_GPIO_MODE 0x60
|
|
|
|
+
|
2013-05-04 11:36:51 +00:00
|
|
|
+static int ralink_mux_mask(const char *name, struct ralink_pinmux_grp *grps, u32* mask)
|
2013-04-03 09:59:10 +00:00
|
|
|
+{
|
2013-05-06 16:45:20 +00:00
|
|
|
+ for (; grps && grps->name; grps++)
|
2013-05-04 11:36:51 +00:00
|
|
|
+ if (!strcmp(grps->name, name)) {
|
|
|
|
+ *mask = grps->mask;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
2013-04-03 09:59:10 +00:00
|
|
|
+
|
2013-05-04 11:36:51 +00:00
|
|
|
+ return -1;
|
2013-04-03 09:59:10 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ralink_pinmux(void)
|
|
|
|
+{
|
|
|
|
+ const __be32 *wdt;
|
|
|
|
+ struct device_node *np;
|
|
|
|
+ struct property *prop;
|
|
|
|
+ const char *uart, *pin;
|
|
|
|
+ u32 mode = 0;
|
2013-05-04 11:36:51 +00:00
|
|
|
+ int m;
|
2013-04-03 09:59:10 +00:00
|
|
|
+
|
|
|
|
+ np = of_find_compatible_node(NULL, NULL, "ralink,rt3050-sysc");
|
|
|
|
+ if (!np)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ of_property_for_each_string(np, "ralink,gpiomux", prop, pin) {
|
2013-05-04 11:36:51 +00:00
|
|
|
+ if (!ralink_mux_mask(pin, rt_gpio_pinmux.mode, &m)) {
|
2013-04-03 09:59:10 +00:00
|
|
|
+ mode |= m;
|
|
|
|
+ pr_debug("pinmux: registered gpiomux \"%s\"\n", pin);
|
|
|
|
+ } else {
|
|
|
|
+ pr_err("pinmux: failed to load \"%s\"\n", pin);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2013-04-06 11:46:34 +00:00
|
|
|
+ of_property_for_each_string(np, "ralink,pinmux", prop, pin) {
|
2013-05-04 11:36:51 +00:00
|
|
|
+ if (!ralink_mux_mask(pin, rt_gpio_pinmux.mode, &m)) {
|
2013-04-03 09:59:10 +00:00
|
|
|
+ mode &= ~m;
|
|
|
|
+ pr_debug("pinmux: registered pinmux \"%s\"\n", pin);
|
|
|
|
+ } else {
|
|
|
|
+ pr_err("pinmux: failed to load group \"%s\"\n", pin);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ of_property_read_string(np, "ralink,uartmux", &uart);
|
|
|
|
+ if (uart) {
|
2013-05-06 16:45:20 +00:00
|
|
|
+ mode &= ~(rt_gpio_pinmux.uart_mask << rt_gpio_pinmux.uart_shift);
|
2013-05-04 11:36:51 +00:00
|
|
|
+ if (ralink_mux_mask(uart, rt_gpio_pinmux.uart, &m)) {
|
|
|
|
+ pr_err("pinmux: failed to load uartmux \"%s\"\n", uart);
|
2013-05-06 16:45:20 +00:00
|
|
|
+ mode |= rt_gpio_pinmux.uart_mask << rt_gpio_pinmux.uart_shift;
|
2013-04-03 09:59:10 +00:00
|
|
|
+ } else {
|
2013-05-06 16:45:20 +00:00
|
|
|
+ mode |= m << rt_gpio_pinmux.uart_shift;
|
2013-05-04 11:36:51 +00:00
|
|
|
+ pr_debug("pinmux: registered uartmux \"%s\"\n", uart);
|
2013-04-03 09:59:10 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ wdt = of_get_property(np, "ralink,wdtmux", NULL);
|
2013-04-25 19:02:42 +00:00
|
|
|
+ if (wdt && *wdt && rt_gpio_pinmux.wdt_reset)
|
|
|
|
+ rt_gpio_pinmux.wdt_reset();
|
2013-04-03 09:59:10 +00:00
|
|
|
+
|
|
|
|
+ rt_sysc_w32(mode, SYSC_REG_GPIO_MODE);
|
|
|
|
+}
|
2013-06-23 15:50:49 +00:00
|
|
|
--
|
|
|
|
1.7.10.4
|
|
|
|
|