1 From d59fe652e3674e98caa688b4ddc9308007267adc Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Mon, 19 Aug 2013 13:49:52 +0200
4 Subject: [PATCH] pinctrl: ralink; add pinctrl driver
6 Signed-off-by: John Crispin <blogic@openwrt.org>
8 arch/mips/Kconfig | 2 +
9 arch/mips/ralink/common.h | 21 +--
10 arch/mips/ralink/dts/mt7620a.dtsi | 7 +
11 drivers/pinctrl/Kconfig | 5 +
12 drivers/pinctrl/Makefile | 1 +
13 drivers/pinctrl/pinctrl-rt2880.c | 368 +++++++++++++++++++++++++++++++++++++
14 6 files changed, 385 insertions(+), 19 deletions(-)
15 create mode 100644 drivers/pinctrl/pinctrl-rt2880.c
17 Index: linux-3.10.17/arch/mips/Kconfig
18 ===================================================================
19 --- linux-3.10.17.orig/arch/mips/Kconfig 2013-10-26 17:19:49.094708911 +0200
20 +++ linux-3.10.17/arch/mips/Kconfig 2013-10-26 17:19:49.926708932 +0200
22 select HAVE_MACH_CLKDEV
24 select ARCH_REQUIRE_GPIOLIB
26 + select PINCTRL_RT2880
29 bool "SGI IP22 (Indy/Indigo2)"
30 Index: linux-3.10.17/drivers/pinctrl/Kconfig
31 ===================================================================
32 --- linux-3.10.17.orig/drivers/pinctrl/Kconfig 2013-10-18 19:44:19.000000000 +0200
33 +++ linux-3.10.17/drivers/pinctrl/Kconfig 2013-10-26 17:19:49.930708931 +0200
38 +config PINCTRL_RT2880
46 Index: linux-3.10.17/drivers/pinctrl/Makefile
47 ===================================================================
48 --- linux-3.10.17.orig/drivers/pinctrl/Makefile 2013-10-18 19:44:19.000000000 +0200
49 +++ linux-3.10.17/drivers/pinctrl/Makefile 2013-10-26 17:19:49.930708931 +0200
51 obj-$(CONFIG_PINCTRL_S3C64XX) += pinctrl-s3c64xx.o
52 obj-$(CONFIG_PINCTRL_XWAY) += pinctrl-xway.o
53 obj-$(CONFIG_PINCTRL_LANTIQ) += pinctrl-lantiq.o
54 +obj-$(CONFIG_PINCTRL_RT2880) += pinctrl-rt2880.o
56 obj-$(CONFIG_PLAT_ORION) += mvebu/
57 obj-$(CONFIG_ARCH_SHMOBILE) += sh-pfc/
58 Index: linux-3.10.17/drivers/pinctrl/pinctrl-rt2880.c
59 ===================================================================
60 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
61 +++ linux-3.10.17/drivers/pinctrl/pinctrl-rt2880.c 2013-10-27 16:22:50.132754888 +0100
64 + * linux/drivers/pinctrl/pinctrl-rt2880.c
66 + * This program is free software; you can redistribute it and/or modify
67 + * it under the terms of the GNU General Public License version 2 as
68 + * publishhed by the Free Software Foundation.
70 + * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
73 +#include <linux/module.h>
74 +#include <linux/device.h>
75 +#include <linux/io.h>
76 +#include <linux/platform_device.h>
77 +#include <linux/slab.h>
78 +#include <linux/of.h>
79 +#include <linux/pinctrl/pinctrl.h>
80 +#include <linux/pinctrl/pinconf.h>
81 +#include <linux/pinctrl/pinmux.h>
82 +#include <linux/pinctrl/consumer.h>
83 +#include <linux/pinctrl/machine.h>
85 +#include <asm/mach-ralink/ralink_regs.h>
86 +#include <asm/mach-ralink/pinmux.h>
87 +#include <asm/mach-ralink/mt7620.h>
91 +#define SYSC_REG_GPIO_MODE 0x60
96 + struct pinctrl_pin_desc *pads;
97 + struct pinctrl_desc *desc;
99 + struct rt2880_pmx_func **func;
102 + struct rt2880_pmx_group *groups;
103 + const char **group_names;
110 +struct rt2880_pmx_group *rt2880_pinmux_data = NULL;
112 +static int rt2880_get_group_count(struct pinctrl_dev *pctrldev)
114 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
116 + return p->group_count;
119 +static const char *rt2880_get_group_name(struct pinctrl_dev *pctrldev,
122 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
124 + if (group >= p->group_count)
127 + return p->group_names[group];
130 +static int rt2880_get_group_pins(struct pinctrl_dev *pctrldev,
132 + const unsigned **pins,
133 + unsigned *num_pins)
135 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
137 + if (group >= p->group_count)
140 + *pins = p->groups[group].func[0].pins;
141 + *num_pins = p->groups[group].func[0].pin_count;
146 +static void rt2880_pinctrl_dt_free_map(struct pinctrl_dev *pctrldev,
147 + struct pinctrl_map *map, unsigned num_maps)
151 + for (i = 0; i < num_maps; i++)
152 + if (map[i].type == PIN_MAP_TYPE_CONFIGS_PIN ||
153 + map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP)
154 + kfree(map[i].data.configs.configs);
158 +static void rt2880_pinctrl_pin_dbg_show(struct pinctrl_dev *pctrldev,
159 + struct seq_file *s,
162 + seq_printf(s, "ralink pio");
165 +static void rt2880_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctrldev,
166 + struct device_node *np,
167 + struct pinctrl_map **map)
169 + const char *function;
170 + int func = of_property_read_string(np, "ralink,function", &function);
171 + int grps = of_property_count_strings(np, "ralink,group");
177 + for (i = 0; i < grps; i++) {
180 + of_property_read_string_index(np, "ralink,group", i, &group);
182 + (*map)->type = PIN_MAP_TYPE_MUX_GROUP;
183 + (*map)->name = function;
184 + (*map)->data.mux.group = group;
185 + (*map)->data.mux.function = function;
190 +static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev,
191 + struct device_node *np_config,
192 + struct pinctrl_map **map,
193 + unsigned *num_maps)
196 + struct pinctrl_map *tmp;
197 + struct device_node *np;
199 + for_each_child_of_node(np_config, np) {
200 + int ret = of_property_count_strings(np, "ralink,group");
209 + *map = kzalloc(max_maps * sizeof(struct pinctrl_map), GFP_KERNEL);
215 + for_each_child_of_node(np_config, np)
216 + rt2880_pinctrl_dt_subnode_to_map(pctrldev, np, &tmp);
217 + *num_maps = max_maps;
222 +static const struct pinctrl_ops rt2880_pctrl_ops = {
223 + .get_groups_count = rt2880_get_group_count,
224 + .get_group_name = rt2880_get_group_name,
225 + .get_group_pins = rt2880_get_group_pins,
226 + .pin_dbg_show = rt2880_pinctrl_pin_dbg_show,
227 + .dt_node_to_map = rt2880_pinctrl_dt_node_to_map,
228 + .dt_free_map = rt2880_pinctrl_dt_free_map,
231 +static int rt2880_pmx_func_count(struct pinctrl_dev *pctrldev)
233 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
235 + return p->func_count;
238 +static const char *rt2880_pmx_func_name(struct pinctrl_dev *pctrldev,
241 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
243 + return p->func[func]->name;
246 +static int rt2880_pmx_group_get_groups(struct pinctrl_dev *pctrldev,
248 + const char * const **groups,
249 + unsigned * const num_groups)
251 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
253 + if (p->func[func]->group_count == 1)
254 + *groups = &p->group_names[p->func[func]->groups[0]];
256 + *groups = p->group_names;
258 + *num_groups = p->func[func]->group_count;
263 +static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev,
267 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
270 + /* dont allow double use */
271 + if (p->groups[group].enabled) {
272 + dev_err(p->dev, "%s is already enabled\n", p->groups[group].name);
276 + p->groups[group].enabled = 1;
277 + p->func[func]->enabled = 1;
279 + mode = rt_sysc_r32(SYSC_REG_GPIO_MODE);
280 + mode &= ~(p->groups[group].mask << p->groups[group].shift);
282 + /* function 0 is gpio and needs special handling */
287 + mode |= p->groups[group].gpio << p->groups[group].shift;
288 + /* mark the pins as gpio */
289 + for (i = 0; i < p->groups[group].func[0].pin_count; i++)
290 + p->gpio[p->groups[group].func[0].pins[i]] = 1;
292 + mode |= p->func[func]->value << p->groups[group].shift;
294 + rt_sysc_w32(mode, SYSC_REG_GPIO_MODE);
300 +static int rt2880_pmx_group_gpio_request_enable(struct pinctrl_dev *pctrldev,
301 + struct pinctrl_gpio_range *range,
304 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
306 + if (!p->gpio[pin]) {
307 + dev_err(p->dev, "pin %d is not set to gpio mux\n", pin);
314 +static const struct pinmux_ops rt2880_pmx_group_ops = {
315 + .get_functions_count = rt2880_pmx_func_count,
316 + .get_function_name = rt2880_pmx_func_name,
317 + .get_function_groups = rt2880_pmx_group_get_groups,
318 + .enable = rt2880_pmx_group_enable,
319 + .gpio_request_enable = rt2880_pmx_group_gpio_request_enable,
322 +static struct pinctrl_desc rt2880_pctrl_desc = {
323 + .owner = THIS_MODULE,
324 + .name = "rt2880-pinmux",
325 + .pctlops = &rt2880_pctrl_ops,
326 + .pmxops = &rt2880_pmx_group_ops,
329 +static struct rt2880_pmx_func gpio_func = {
333 +static int rt2880_pinmux_index(struct rt2880_priv *p)
335 + struct rt2880_pmx_func **f;
336 + struct rt2880_pmx_group *mux = p->groups;
339 + /* count the mux functions */
340 + while (mux->name) {
345 + /* allocate the group names array needed by the gpio function */
346 + p->group_names = devm_kzalloc(p->dev, sizeof(char *) * p->group_count, GFP_KERNEL);
347 + if (!p->group_names)
350 + for (i = 0; i < p->group_count; i++) {
351 + p->group_names[i] = p->groups[i].name;
352 + p->func_count += p->groups[i].func_count;
355 + /* we have a dummy function[0] for gpio */
358 + /* allocate our function and group mapping index buffers */
359 + f = p->func = devm_kzalloc(p->dev, sizeof(struct rt2880_pmx_func) * p->func_count, GFP_KERNEL);
360 + gpio_func.groups = devm_kzalloc(p->dev, sizeof(int) * p->group_count, GFP_KERNEL);
361 + if (!f || !gpio_func.groups)
364 + /* add a backpointer to the function so it knows its group */
365 + gpio_func.group_count = p->group_count;
366 + for (i = 0; i < gpio_func.group_count; i++)
367 + gpio_func.groups[i] = i;
372 + /* add remaining functions */
373 + for (i = 0; i < p->group_count; i++) {
374 + for (j = 0; j < p->groups[i].func_count; j++) {
375 + f[c] = &p->groups[i].func[j];
376 + f[c]->groups = devm_kzalloc(p->dev, sizeof(int), GFP_KERNEL);
377 + f[c]->groups[0] = i;
378 + f[c]->group_count = 1;
385 +static int rt2880_pinmux_pins(struct rt2880_priv *p)
389 + /* loop over the functions and initialize the pins array. also work out the highest pin used */
390 + for (i = 0; i < p->func_count; i++) {
393 + if (!p->func[i]->pin_count)
396 + p->func[i]->pins = devm_kzalloc(p->dev, sizeof(int) * p->func[i]->pin_count, GFP_KERNEL);
397 + for (j = 0; j < p->func[i]->pin_count; j++)
398 + p->func[i]->pins[j] = p->func[i]->pin_first + j;
400 + pin = p->func[i]->pin_first + p->func[i]->pin_count;
401 + if (pin > p->max_pins)
405 + /* the buffer that tells us which pins are gpio */
406 + p->gpio = devm_kzalloc(p->dev,sizeof(uint8_t) * p->max_pins,
408 + /* the pads needed to tell pinctrl about our pins */
409 + p->pads = devm_kzalloc(p->dev,
410 + sizeof(struct pinctrl_pin_desc) * p->max_pins,
412 + if (!p->pads || !p->gpio ) {
413 + dev_err(p->dev, "Failed to allocate gpio data\n");
417 + memset(p->gpio, 1, sizeof(uint8_t) * p->max_pins);
418 + for (i = 0; i < p->func_count; i++) {
419 + if (!p->func[i]->pin_count)
422 + for (j = 0; j < p->func[i]->pin_count; j++)
423 + p->gpio[p->func[i]->pins[j]] = 0;
426 + /* pin 0 is always a gpio */
430 + for (i = 0; i < p->max_pins; i++) {
431 + /* strlen("ioXY") + 1 = 5 */
432 + char *name = devm_kzalloc(p->dev, 5, GFP_KERNEL);
435 + dev_err(p->dev, "Failed to allocate pad name\n");
438 + snprintf(name, 5, "io%d", i);
439 + p->pads[i].number = i;
440 + p->pads[i].name = name;
442 + p->desc->pins = p->pads;
443 + p->desc->npins = p->max_pins;
448 +static int rt2880_pinmux_probe(struct platform_device *pdev)
450 + struct rt2880_priv *p;
451 + struct pinctrl_dev *dev;
452 + struct device_node *np;
454 + if (!rt2880_pinmux_data)
457 + /* setup the private data */
458 + p = devm_kzalloc(&pdev->dev, sizeof(struct rt2880_priv), GFP_KERNEL);
462 + p->dev = &pdev->dev;
463 + p->desc = &rt2880_pctrl_desc;
464 + p->groups = rt2880_pinmux_data;
465 + platform_set_drvdata(pdev, p);
467 + /* init the device */
468 + if (rt2880_pinmux_index(p)) {
469 + dev_err(&pdev->dev, "failed to load index\n");
472 + if (rt2880_pinmux_pins(p)) {
473 + dev_err(&pdev->dev, "failed to load pins\n");
476 + dev = pinctrl_register(p->desc, &pdev->dev, p);
478 + return PTR_ERR(dev);
480 + /* finalize by adding gpio ranges for enables gpio controllers */
481 + for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") {
482 + const __be32 *ngpio, *gpiobase;
483 + struct pinctrl_gpio_range *range;
486 + if (!of_device_is_available(np))
489 + ngpio = of_get_property(np, "ralink,num-gpios", NULL);
490 + gpiobase = of_get_property(np, "ralink,gpio-base", NULL);
491 + if (!ngpio || !gpiobase) {
492 + dev_err(&pdev->dev, "failed to load chip info\n");
496 + range = devm_kzalloc(p->dev, sizeof(struct pinctrl_gpio_range) + 4, GFP_KERNEL);
497 + range->name = name = (char *) &range[1];
498 + sprintf(name, "pio");
499 + range->npins = __be32_to_cpu(*ngpio);
500 + range->base = __be32_to_cpu(*gpiobase);
501 + range->pin_base = range->base;
502 + pinctrl_add_gpio_range(dev, range);
508 +static const struct of_device_id rt2880_pinmux_match[] = {
509 + { .compatible = "ralink,rt2880-pinmux" },
512 +MODULE_DEVICE_TABLE(of, rt2880_pinmux_match);
514 +static struct platform_driver rt2880_pinmux_driver = {
515 + .probe = rt2880_pinmux_probe,
517 + .name = "rt2880-pinmux",
518 + .owner = THIS_MODULE,
519 + .of_match_table = rt2880_pinmux_match,
523 +int __init rt2880_pinmux_init(void)
525 + return platform_driver_register(&rt2880_pinmux_driver);
528 +core_initcall_sync(rt2880_pinmux_init);
529 Index: linux-3.10.17/arch/mips/include/asm/mach-ralink/pinmux.h
530 ===================================================================
531 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
532 +++ linux-3.10.17/arch/mips/include/asm/mach-ralink/pinmux.h 2013-10-27 07:28:38.999991133 +0100
535 + * This program is free software; you can redistribute it and/or modify
536 + * it under the terms of the GNU General Public License version 2 as
537 + * publishhed by the Free Software Foundation.
539 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
542 +#ifndef _RT288X_PINMUX_H__
543 +#define _RT288X_PINMUX_H__
545 +#define FUNC(name, value, pin_first, pin_count) { name, value, pin_first, pin_count }
546 +#define GRP(_name, _func, _mask, _shift) \
547 + { .name = _name, .mask = _mask, .shift = _shift, \
548 + .func = _func, .gpio = _mask, \
549 + .func_count = ARRAY_SIZE(_func) }
551 +#define GRP_G(_name, _func, _mask, _gpio, _shift) \
552 + { .name = _name, .mask = _mask, .shift = _shift, \
553 + .func = _func, .gpio = _gpio, \
554 + .func_count = ARRAY_SIZE(_func) }
556 +struct rt2880_pmx_group;
558 +struct rt2880_pmx_func {
572 +struct rt2880_pmx_group {
580 + struct rt2880_pmx_func *func;
584 +extern struct rt2880_pmx_group *rt2880_pinmux_data;
587 Index: linux-3.10.17/arch/mips/ralink/mt7620.c
588 ===================================================================
589 --- linux-3.10.17.orig/arch/mips/ralink/mt7620.c 2013-10-26 17:19:49.462708921 +0200
590 +++ linux-3.10.17/arch/mips/ralink/mt7620.c 2013-10-27 13:33:02.148512122 +0100
592 #include <asm/mipsregs.h>
593 #include <asm/mach-ralink/ralink_regs.h>
594 #include <asm/mach-ralink/mt7620.h>
595 +#include <asm/mach-ralink/pinmux.h>
600 /* the pll dividers */
601 static u32 mt7620_clk_divider[] = { 2, 3, 4, 8 };
603 -static struct ralink_pinmux_grp mode_mux[] = {
606 - .mask = MT7620_GPIO_MODE_I2C,
611 - .mask = MT7620_GPIO_MODE_SPI,
615 - .name = "uartlite",
616 - .mask = MT7620_GPIO_MODE_UART1,
621 - .mask = MT7620_GPIO_MODE_WDT,
626 - .mask = MT7620_GPIO_MODE_MDIO,
631 - .mask = MT7620_GPIO_MODE_RGMII1,
635 - .name = "spi refclk",
636 - .mask = MT7620_GPIO_MODE_SPI_REF_CLK,
641 - .mask = MT7620_GPIO_MODE_JTAG,
645 - /* shared lines with jtag */
647 - .mask = MT7620_GPIO_MODE_EPHY,
652 - .mask = MT7620_GPIO_MODE_JTAG,
657 - .mask = MT7620_GPIO_MODE_RGMII2,
662 - .mask = MT7620_GPIO_MODE_WLED,
666 +static struct rt2880_pmx_func i2c_grp[] = { FUNC("i2c", 0, 1, 2) };
667 +static struct rt2880_pmx_func spi_grp[] = { FUNC("spi", 0, 3, 4) };
668 +static struct rt2880_pmx_func uartlite_grp[] = { FUNC("uartlite", 0, 15, 2) };
669 +static struct rt2880_pmx_func mdio_grp[] = { FUNC("mdio", 0, 22, 2) };
670 +static struct rt2880_pmx_func rgmii1_grp[] = { FUNC("rgmii1", 0, 24, 12) };
671 +static struct rt2880_pmx_func refclk_grp[] = { FUNC("spi refclk", 0, 37, 3) };
672 +static struct rt2880_pmx_func ephy_grp[] = { FUNC("ephy", 0, 40, 5) };
673 +static struct rt2880_pmx_func rgmii2_grp[] = { FUNC("rgmii2", 0, 60, 12) };
674 +static struct rt2880_pmx_func wled_grp[] = { FUNC("wled", 0, 72, 1) };
675 +static struct rt2880_pmx_func pa_grp[] = { FUNC("pa", 0, 18, 4) };
676 +static struct rt2880_pmx_func uartf_grp[] = {
677 + FUNC("uartf", MT7620_GPIO_MODE_UARTF, 7, 8),
678 + FUNC("pcm uartf", MT7620_GPIO_MODE_PCM_UARTF, 7, 8),
679 + FUNC("pcm i2s", MT7620_GPIO_MODE_PCM_I2S, 7, 8),
680 + FUNC("i2s uartf", MT7620_GPIO_MODE_I2S_UARTF, 7, 8),
681 + FUNC("pcm gpio", MT7620_GPIO_MODE_PCM_GPIO, 11, 4),
682 + FUNC("gpio uartf", MT7620_GPIO_MODE_GPIO_UARTF, 7, 4),
683 + FUNC("gpio i2s", MT7620_GPIO_MODE_GPIO_I2S, 7, 4),
686 -static struct ralink_pinmux_grp uart_mux[] = {
689 - .mask = MT7620_GPIO_MODE_UARTF,
693 - .name = "pcm uartf",
694 - .mask = MT7620_GPIO_MODE_PCM_UARTF,
699 - .mask = MT7620_GPIO_MODE_PCM_I2S,
703 - .name = "i2s uartf",
704 - .mask = MT7620_GPIO_MODE_I2S_UARTF,
708 - .name = "pcm gpio",
709 - .mask = MT7620_GPIO_MODE_PCM_GPIO,
713 - .name = "gpio uartf",
714 - .mask = MT7620_GPIO_MODE_GPIO_UARTF,
718 - .name = "gpio i2s",
719 - .mask = MT7620_GPIO_MODE_GPIO_I2S,
724 - .mask = MT7620_GPIO_MODE_GPIO,
726 +static struct rt2880_pmx_func wdt_grp[] = {
727 + FUNC("wdt rst", 0, 17, 1),
728 + FUNC("wdt refclk", 0, 17, 1),
730 +static struct rt2880_pmx_func pcie_rst_grp[] = {
731 + FUNC("pcie rst", MT7620_GPIO_MODE_PCIE_RST, 36, 1),
732 + FUNC("pcie refclk", MT7620_GPIO_MODE_PCIE_REF, 36, 1)
734 +static struct rt2880_pmx_func nd_sd_grp[] = {
735 + FUNC("nand", MT7620_GPIO_MODE_NAND, 45, 15),
736 + FUNC("sd", MT7620_GPIO_MODE_SD, 45, 15)
739 -struct ralink_pinmux rt_gpio_pinmux = {
742 - .uart_shift = MT7620_GPIO_MODE_UART0_SHIFT,
743 - .uart_mask = MT7620_GPIO_MODE_UART0_MASK,
744 +static struct rt2880_pmx_group mt7620a_pinmux_data[] = {
745 + GRP("i2c", i2c_grp, 1, MT7620_GPIO_MODE_I2C),
746 + GRP("uartf", uartf_grp, MT7620_GPIO_MODE_UART0_MASK,
747 + MT7620_GPIO_MODE_UART0_SHIFT),
748 + GRP("spi", spi_grp, 1, MT7620_GPIO_MODE_SPI),
749 + GRP("uartlite", uartlite_grp, 1, MT7620_GPIO_MODE_UART1),
750 + GRP_G("wdt", wdt_grp, MT7620_GPIO_MODE_WDT_MASK,
751 + MT7620_GPIO_MODE_WDT_GPIO, MT7620_GPIO_MODE_WDT_SHIFT),
752 + GRP("mdio", mdio_grp, 1, MT7620_GPIO_MODE_MDIO),
753 + GRP("rgmii1", rgmii1_grp, 1, MT7620_GPIO_MODE_RGMII1),
754 + GRP("spi refclk", refclk_grp, 1, MT7620_GPIO_MODE_SPI_REF_CLK),
755 + GRP_G("pcie", pcie_rst_grp, MT7620_GPIO_MODE_PCIE_MASK,
756 + MT7620_GPIO_MODE_PCIE_GPIO, MT7620_GPIO_MODE_PCIE_SHIFT),
757 + GRP_G("nd_sd", nd_sd_grp, MT7620_GPIO_MODE_ND_SD_MASK,
758 + MT7620_GPIO_MODE_ND_SD_GPIO, MT7620_GPIO_MODE_ND_SD_SHIFT),
759 + GRP("rgmii2", rgmii2_grp, 1, MT7620_GPIO_MODE_RGMII2),
760 + GRP("wled", wled_grp, 1, MT7620_GPIO_MODE_WLED),
761 + GRP("ephy", ephy_grp, 1, MT7620_GPIO_MODE_EPHY),
762 + GRP("pa", pa_grp, 1, MT7620_GPIO_MODE_PA),
766 void __init ralink_clk_init(void)
768 (pmu0 & PMU_SW_SET) ? ("sw") : ("hw"));
769 pr_info("Digital PMU set to %s control\n",
770 (pmu1 & DIG_SW_SEL) ? ("sw") : ("hw"));
772 + rt2880_pinmux_data = mt7620a_pinmux_data;
774 Index: linux-3.10.17/arch/mips/ralink/rt305x.c
775 ===================================================================
776 --- linux-3.10.17.orig/arch/mips/ralink/rt305x.c 2013-10-26 17:19:49.722708926 +0200
777 +++ linux-3.10.17/arch/mips/ralink/rt305x.c 2013-10-27 16:23:29.836755834 +0100
779 #include <asm/mipsregs.h>
780 #include <asm/mach-ralink/ralink_regs.h>
781 #include <asm/mach-ralink/rt305x.h>
782 +#include <asm/mach-ralink/pinmux.h>
786 enum rt305x_soc_type rt305x_soc;
788 -static struct ralink_pinmux_grp mode_mux[] = {
791 - .mask = RT305X_GPIO_MODE_I2C,
792 - .gpio_first = RT305X_GPIO_I2C_SD,
793 - .gpio_last = RT305X_GPIO_I2C_SCLK,
796 - .mask = RT305X_GPIO_MODE_SPI,
797 - .gpio_first = RT305X_GPIO_SPI_EN,
798 - .gpio_last = RT305X_GPIO_SPI_CLK,
800 - .name = "uartlite",
801 - .mask = RT305X_GPIO_MODE_UART1,
802 - .gpio_first = RT305X_GPIO_UART1_TXD,
803 - .gpio_last = RT305X_GPIO_UART1_RXD,
806 - .mask = RT305X_GPIO_MODE_JTAG,
807 - .gpio_first = RT305X_GPIO_JTAG_TDO,
808 - .gpio_last = RT305X_GPIO_JTAG_TDI,
811 - .mask = RT305X_GPIO_MODE_MDIO,
812 - .gpio_first = RT305X_GPIO_MDIO_MDC,
813 - .gpio_last = RT305X_GPIO_MDIO_MDIO,
816 - .mask = RT305X_GPIO_MODE_SDRAM,
817 - .gpio_first = RT305X_GPIO_SDRAM_MD16,
818 - .gpio_last = RT305X_GPIO_SDRAM_MD31,
821 - .mask = RT305X_GPIO_MODE_RGMII,
822 - .gpio_first = RT305X_GPIO_GE0_TXD0,
823 - .gpio_last = RT305X_GPIO_GE0_RXCLK,
825 +static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
826 +static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
827 +static struct rt2880_pmx_func uartf_func[] = {
828 + FUNC("uartf", RT305X_GPIO_MODE_UARTF, 7, 8),
829 + FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 8),
830 + FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 8),
831 + FUNC("i2s uartf", RT305X_GPIO_MODE_I2S_UARTF, 7, 8),
832 + FUNC("pcm gpio", RT305X_GPIO_MODE_PCM_GPIO, 11, 4),
833 + FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 7, 4),
834 + FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 7, 4),
836 +static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
837 +static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
838 +static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
839 +static struct rt2880_pmx_func rt5350_led_func[] = { FUNC("led", 0, 22, 5) };
840 +static struct rt2880_pmx_func sdram_func[] = { FUNC("sdram", 0, 24, 16) };
841 +static struct rt2880_pmx_func rt3352_rgmii_func[] = { FUNC("rgmii", 0, 24, 12) };
842 +static struct rt2880_pmx_func rgmii_func[] = { FUNC("rgmii", 0, 40, 12) };
843 +static struct rt2880_pmx_func rt3352_lna_func[] = { FUNC("lna", 0, 36, 2) };
844 +static struct rt2880_pmx_func rt3352_pa_func[] = { FUNC("pa", 0, 38, 2) };
845 +static struct rt2880_pmx_func rt3352_led_func[] = { FUNC("led", 0, 40, 5) };
847 +static struct rt2880_pmx_group rt3050_pinmux_data[] = {
848 + GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
849 + GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
850 + GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
851 + RT305X_GPIO_MODE_UART0_SHIFT),
852 + GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
853 + GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
854 + GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
855 + GRP("rgmii", rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
856 + GRP("sdram", sdram_func, 1, RT305X_GPIO_MODE_SDRAM),
860 +static struct rt2880_pmx_group rt3352_pinmux_data[] = {
861 + GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
862 + GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
863 + GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
864 + RT305X_GPIO_MODE_UART0_SHIFT),
865 + GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
866 + GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
867 + GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
868 + GRP("rgmii", rt3352_rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
869 + GRP("lna", rt3352_lna_func, 1, RT3352_GPIO_MODE_LNA),
870 + GRP("pa", rt3352_pa_func, 1, RT3352_GPIO_MODE_PA),
871 + GRP("led", rt3352_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
875 -static struct ralink_pinmux_grp uart_mux[] = {
878 - .mask = RT305X_GPIO_MODE_UARTF,
879 - .gpio_first = RT305X_GPIO_7,
880 - .gpio_last = RT305X_GPIO_14,
882 - .name = "pcm uartf",
883 - .mask = RT305X_GPIO_MODE_PCM_UARTF,
884 - .gpio_first = RT305X_GPIO_7,
885 - .gpio_last = RT305X_GPIO_14,
888 - .mask = RT305X_GPIO_MODE_PCM_I2S,
889 - .gpio_first = RT305X_GPIO_7,
890 - .gpio_last = RT305X_GPIO_14,
892 - .name = "i2s uartf",
893 - .mask = RT305X_GPIO_MODE_I2S_UARTF,
894 - .gpio_first = RT305X_GPIO_7,
895 - .gpio_last = RT305X_GPIO_14,
897 - .name = "pcm gpio",
898 - .mask = RT305X_GPIO_MODE_PCM_GPIO,
899 - .gpio_first = RT305X_GPIO_10,
900 - .gpio_last = RT305X_GPIO_14,
902 - .name = "gpio uartf",
903 - .mask = RT305X_GPIO_MODE_GPIO_UARTF,
904 - .gpio_first = RT305X_GPIO_7,
905 - .gpio_last = RT305X_GPIO_10,
907 - .name = "gpio i2s",
908 - .mask = RT305X_GPIO_MODE_GPIO_I2S,
909 - .gpio_first = RT305X_GPIO_7,
910 - .gpio_last = RT305X_GPIO_10,
913 - .mask = RT305X_GPIO_MODE_GPIO,
915 +static struct rt2880_pmx_group rt5350_pinmux_data[] = {
916 + GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
917 + GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
918 + GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
919 + RT305X_GPIO_MODE_UART0_SHIFT),
920 + GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
921 + GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
922 + GRP("led", rt5350_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
926 static void rt305x_wdt_reset(void)
928 rt_sysc_w32(t, SYSC_REG_SYSTEM_CONFIG);
931 -struct ralink_pinmux rt_gpio_pinmux = {
934 - .uart_shift = RT305X_GPIO_MODE_UART0_SHIFT,
935 - .uart_mask = RT305X_GPIO_MODE_UART0_MASK,
936 - .wdt_reset = rt305x_wdt_reset,
939 static unsigned long rt5350_get_mem_size(void)
941 void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT305X_SYSC_BASE);
942 @@ -291,11 +264,14 @@
943 soc_info->mem_base = RT305X_SDRAM_BASE;
944 if (soc_is_rt5350()) {
945 soc_info->mem_size = rt5350_get_mem_size();
946 + rt2880_pinmux_data = rt5350_pinmux_data;
947 } else if (soc_is_rt305x() || soc_is_rt3350()) {
948 soc_info->mem_size_min = RT305X_MEM_SIZE_MIN;
949 soc_info->mem_size_max = RT305X_MEM_SIZE_MAX;
950 + rt2880_pinmux_data = rt3050_pinmux_data;
951 } else if (soc_is_rt3352()) {
952 soc_info->mem_size_min = RT3352_MEM_SIZE_MIN;
953 soc_info->mem_size_max = RT3352_MEM_SIZE_MAX;
954 + rt2880_pinmux_data = rt3352_pinmux_data;
957 Index: linux-3.10.17/arch/mips/include/asm/mach-ralink/rt305x.h
958 ===================================================================
959 --- linux-3.10.17.orig/arch/mips/include/asm/mach-ralink/rt305x.h 2013-10-18 19:44:19.000000000 +0200
960 +++ linux-3.10.17/arch/mips/include/asm/mach-ralink/rt305x.h 2013-10-26 17:19:49.934708931 +0200
961 @@ -125,24 +125,28 @@
962 #define RT305X_GPIO_GE0_TXD0 40
963 #define RT305X_GPIO_GE0_RXCLK 51
965 -#define RT305X_GPIO_MODE_I2C BIT(0)
966 -#define RT305X_GPIO_MODE_SPI BIT(1)
967 #define RT305X_GPIO_MODE_UART0_SHIFT 2
968 #define RT305X_GPIO_MODE_UART0_MASK 0x7
969 #define RT305X_GPIO_MODE_UART0(x) ((x) << RT305X_GPIO_MODE_UART0_SHIFT)
970 -#define RT305X_GPIO_MODE_UARTF 0x0
971 -#define RT305X_GPIO_MODE_PCM_UARTF 0x1
972 -#define RT305X_GPIO_MODE_PCM_I2S 0x2
973 -#define RT305X_GPIO_MODE_I2S_UARTF 0x3
974 -#define RT305X_GPIO_MODE_PCM_GPIO 0x4
975 -#define RT305X_GPIO_MODE_GPIO_UARTF 0x5
976 -#define RT305X_GPIO_MODE_GPIO_I2S 0x6
977 -#define RT305X_GPIO_MODE_GPIO 0x7
978 -#define RT305X_GPIO_MODE_UART1 BIT(5)
979 -#define RT305X_GPIO_MODE_JTAG BIT(6)
980 -#define RT305X_GPIO_MODE_MDIO BIT(7)
981 -#define RT305X_GPIO_MODE_SDRAM BIT(8)
982 -#define RT305X_GPIO_MODE_RGMII BIT(9)
983 +#define RT305X_GPIO_MODE_UARTF 0
984 +#define RT305X_GPIO_MODE_PCM_UARTF 1
985 +#define RT305X_GPIO_MODE_PCM_I2S 2
986 +#define RT305X_GPIO_MODE_I2S_UARTF 3
987 +#define RT305X_GPIO_MODE_PCM_GPIO 4
988 +#define RT305X_GPIO_MODE_GPIO_UARTF 5
989 +#define RT305X_GPIO_MODE_GPIO_I2S 6
990 +#define RT305X_GPIO_MODE_GPIO 7
992 +#define RT305X_GPIO_MODE_I2C 0
993 +#define RT305X_GPIO_MODE_SPI 1
994 +#define RT305X_GPIO_MODE_UART1 5
995 +#define RT305X_GPIO_MODE_JTAG 6
996 +#define RT305X_GPIO_MODE_MDIO 7
997 +#define RT305X_GPIO_MODE_SDRAM 8
998 +#define RT305X_GPIO_MODE_RGMII 9
999 +#define RT5350_GPIO_MODE_PHY_LED 14
1000 +#define RT3352_GPIO_MODE_LNA 18
1001 +#define RT3352_GPIO_MODE_PA 20
1003 #define RT3352_SYSC_REG_SYSCFG0 0x010
1004 #define RT3352_SYSC_REG_SYSCFG1 0x014
1005 Index: linux-3.10.17/arch/mips/include/asm/mach-ralink/mt7620.h
1006 ===================================================================
1007 --- linux-3.10.17.orig/arch/mips/include/asm/mach-ralink/mt7620.h 2013-10-26 17:19:49.250708916 +0200
1008 +++ linux-3.10.17/arch/mips/include/asm/mach-ralink/mt7620.h 2013-10-27 13:13:24.892484072 +0100
1010 #define MT7620_DDR2_SIZE_MIN 32
1011 #define MT7620_DDR2_SIZE_MAX 256
1013 -#define MT7620_GPIO_MODE_I2C BIT(0)
1014 #define MT7620_GPIO_MODE_UART0_SHIFT 2
1015 #define MT7620_GPIO_MODE_UART0_MASK 0x7
1016 #define MT7620_GPIO_MODE_UART0(x) ((x) << MT7620_GPIO_MODE_UART0_SHIFT)
1018 #define MT7620_GPIO_MODE_GPIO_UARTF 0x5
1019 #define MT7620_GPIO_MODE_GPIO_I2S 0x6
1020 #define MT7620_GPIO_MODE_GPIO 0x7
1021 -#define MT7620_GPIO_MODE_UART1 BIT(5)
1022 -#define MT7620_GPIO_MODE_MDIO BIT(8)
1023 -#define MT7620_GPIO_MODE_RGMII1 BIT(9)
1024 -#define MT7620_GPIO_MODE_RGMII2 BIT(10)
1025 -#define MT7620_GPIO_MODE_SPI BIT(11)
1026 -#define MT7620_GPIO_MODE_SPI_REF_CLK BIT(12)
1027 -#define MT7620_GPIO_MODE_WLED BIT(13)
1028 -#define MT7620_GPIO_MODE_JTAG BIT(15)
1029 -#define MT7620_GPIO_MODE_EPHY BIT(15)
1030 -#define MT7620_GPIO_MODE_WDT BIT(22)
1032 +#define MT7620_GPIO_MODE_NAND 0
1033 +#define MT7620_GPIO_MODE_SD 1
1034 +#define MT7620_GPIO_MODE_ND_SD_GPIO 2
1035 +#define MT7620_GPIO_MODE_ND_SD_MASK 0x3
1036 +#define MT7620_GPIO_MODE_ND_SD_SHIFT 18
1038 +#define MT7620_GPIO_MODE_PCIE_RST 0
1039 +#define MT7620_GPIO_MODE_PCIE_REF 1
1040 +#define MT7620_GPIO_MODE_PCIE_GPIO 2
1041 +#define MT7620_GPIO_MODE_PCIE_MASK 0x3
1042 +#define MT7620_GPIO_MODE_PCIE_SHIFT 16
1044 +#define MT7620_GPIO_MODE_WDT_RST 0
1045 +#define MT7620_GPIO_MODE_WDT_REF 1
1046 +#define MT7620_GPIO_MODE_WDT_GPIO 2
1047 +#define MT7620_GPIO_MODE_WDT_MASK 0x3
1048 +#define MT7620_GPIO_MODE_WDT_SHIFT 21
1050 +#define MT7620_GPIO_MODE_I2C 0
1051 +#define MT7620_GPIO_MODE_UART1 5
1052 +#define MT7620_GPIO_MODE_MDIO 8
1053 +#define MT7620_GPIO_MODE_RGMII1 9
1054 +#define MT7620_GPIO_MODE_RGMII2 10
1055 +#define MT7620_GPIO_MODE_SPI 11
1056 +#define MT7620_GPIO_MODE_SPI_REF_CLK 12
1057 +#define MT7620_GPIO_MODE_WLED 13
1058 +#define MT7620_GPIO_MODE_JTAG 15
1059 +#define MT7620_GPIO_MODE_EPHY 15
1060 +#define MT7620_GPIO_MODE_PA 20
1063 Index: linux-3.10.17/arch/mips/include/asm/mach-ralink/rt3883.h
1064 ===================================================================
1065 --- linux-3.10.17.orig/arch/mips/include/asm/mach-ralink/rt3883.h 2013-10-18 19:44:19.000000000 +0200
1066 +++ linux-3.10.17/arch/mips/include/asm/mach-ralink/rt3883.h 2013-10-26 17:19:49.934708931 +0200
1068 #define RT3883_CLKCFG1_PCI_CLK_EN BIT(19)
1069 #define RT3883_CLKCFG1_UPHY0_CLK_EN BIT(18)
1071 -#define RT3883_GPIO_MODE_I2C BIT(0)
1072 -#define RT3883_GPIO_MODE_SPI BIT(1)
1073 #define RT3883_GPIO_MODE_UART0_SHIFT 2
1074 #define RT3883_GPIO_MODE_UART0_MASK 0x7
1075 #define RT3883_GPIO_MODE_UART0(x) ((x) << RT3883_GPIO_MODE_UART0_SHIFT)
1076 @@ -125,11 +123,15 @@
1077 #define RT3883_GPIO_MODE_GPIO_UARTF 0x5
1078 #define RT3883_GPIO_MODE_GPIO_I2S 0x6
1079 #define RT3883_GPIO_MODE_GPIO 0x7
1080 -#define RT3883_GPIO_MODE_UART1 BIT(5)
1081 -#define RT3883_GPIO_MODE_JTAG BIT(6)
1082 -#define RT3883_GPIO_MODE_MDIO BIT(7)
1083 -#define RT3883_GPIO_MODE_GE1 BIT(9)
1084 -#define RT3883_GPIO_MODE_GE2 BIT(10)
1086 +#define RT3883_GPIO_MODE_I2C 0
1087 +#define RT3883_GPIO_MODE_SPI 1
1088 +#define RT3883_GPIO_MODE_UART1 5
1089 +#define RT3883_GPIO_MODE_JTAG 6
1090 +#define RT3883_GPIO_MODE_MDIO 7
1091 +#define RT3883_GPIO_MODE_GE1 9
1092 +#define RT3883_GPIO_MODE_GE2 10
1094 #define RT3883_GPIO_MODE_PCI_SHIFT 11
1095 #define RT3883_GPIO_MODE_PCI_MASK 0x7
1096 #define RT3883_GPIO_MODE_PCI (RT3883_GPIO_MODE_PCI_MASK << RT3883_GPIO_MODE_PCI_SHIFT)
1097 Index: linux-3.10.17/arch/mips/ralink/common.h
1098 ===================================================================
1099 --- linux-3.10.17.orig/arch/mips/ralink/common.h 2013-10-26 17:19:49.094708911 +0200
1100 +++ linux-3.10.17/arch/mips/ralink/common.h 2013-10-26 17:19:49.934708931 +0200
1103 #define RAMIPS_SYS_TYPE_LEN 32
1105 -struct ralink_pinmux_grp {
1112 -struct ralink_pinmux {
1113 - struct ralink_pinmux_grp *mode;
1114 - struct ralink_pinmux_grp *uart;
1117 - void (*wdt_reset)(void);
1118 - struct ralink_pinmux_grp *pci;
1122 -extern struct ralink_pinmux rt_gpio_pinmux;
1124 struct ralink_soc_info {
1125 unsigned char sys_type[RAMIPS_SYS_TYPE_LEN];
1126 unsigned char *compatible;
1127 Index: linux-3.10.17/arch/mips/ralink/rt3883.c
1128 ===================================================================
1129 --- linux-3.10.17.orig/arch/mips/ralink/rt3883.c 2013-10-18 19:44:19.000000000 +0200
1130 +++ linux-3.10.17/arch/mips/ralink/rt3883.c 2013-10-27 16:23:36.824756002 +0100
1131 @@ -17,132 +17,50 @@
1132 #include <asm/mipsregs.h>
1133 #include <asm/mach-ralink/ralink_regs.h>
1134 #include <asm/mach-ralink/rt3883.h>
1135 +#include <asm/mach-ralink/pinmux.h>
1139 -static struct ralink_pinmux_grp mode_mux[] = {
1142 - .mask = RT3883_GPIO_MODE_I2C,
1143 - .gpio_first = RT3883_GPIO_I2C_SD,
1144 - .gpio_last = RT3883_GPIO_I2C_SCLK,
1147 - .mask = RT3883_GPIO_MODE_SPI,
1148 - .gpio_first = RT3883_GPIO_SPI_CS0,
1149 - .gpio_last = RT3883_GPIO_SPI_MISO,
1151 - .name = "uartlite",
1152 - .mask = RT3883_GPIO_MODE_UART1,
1153 - .gpio_first = RT3883_GPIO_UART1_TXD,
1154 - .gpio_last = RT3883_GPIO_UART1_RXD,
1157 - .mask = RT3883_GPIO_MODE_JTAG,
1158 - .gpio_first = RT3883_GPIO_JTAG_TDO,
1159 - .gpio_last = RT3883_GPIO_JTAG_TCLK,
1162 - .mask = RT3883_GPIO_MODE_MDIO,
1163 - .gpio_first = RT3883_GPIO_MDIO_MDC,
1164 - .gpio_last = RT3883_GPIO_MDIO_MDIO,
1167 - .mask = RT3883_GPIO_MODE_GE1,
1168 - .gpio_first = RT3883_GPIO_GE1_TXD0,
1169 - .gpio_last = RT3883_GPIO_GE1_RXCLK,
1172 - .mask = RT3883_GPIO_MODE_GE2,
1173 - .gpio_first = RT3883_GPIO_GE2_TXD0,
1174 - .gpio_last = RT3883_GPIO_GE2_RXCLK,
1177 - .mask = RT3883_GPIO_MODE_PCI,
1178 - .gpio_first = RT3883_GPIO_PCI_AD0,
1179 - .gpio_last = RT3883_GPIO_PCI_AD31,
1182 - .mask = RT3883_GPIO_MODE_LNA_A,
1183 - .gpio_first = RT3883_GPIO_LNA_PE_A0,
1184 - .gpio_last = RT3883_GPIO_LNA_PE_A2,
1187 - .mask = RT3883_GPIO_MODE_LNA_G,
1188 - .gpio_first = RT3883_GPIO_LNA_PE_G0,
1189 - .gpio_last = RT3883_GPIO_LNA_PE_G2,
1191 +static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
1192 +static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
1193 +static struct rt2880_pmx_func uartf_func[] = {
1194 + FUNC("uartf", RT3883_GPIO_MODE_UARTF, 7, 8),
1195 + FUNC("pcm uartf", RT3883_GPIO_MODE_PCM_UARTF, 7, 8),
1196 + FUNC("pcm i2s", RT3883_GPIO_MODE_PCM_I2S, 7, 8),
1197 + FUNC("i2s uartf", RT3883_GPIO_MODE_I2S_UARTF, 7, 8),
1198 + FUNC("pcm gpio", RT3883_GPIO_MODE_PCM_GPIO, 11, 4),
1199 + FUNC("gpio uartf", RT3883_GPIO_MODE_GPIO_UARTF, 7, 4),
1200 + FUNC("gpio i2s", RT3883_GPIO_MODE_GPIO_I2S, 7, 4),
1203 -static struct ralink_pinmux_grp uart_mux[] = {
1206 - .mask = RT3883_GPIO_MODE_UARTF,
1207 - .gpio_first = RT3883_GPIO_7,
1208 - .gpio_last = RT3883_GPIO_14,
1210 - .name = "pcm uartf",
1211 - .mask = RT3883_GPIO_MODE_PCM_UARTF,
1212 - .gpio_first = RT3883_GPIO_7,
1213 - .gpio_last = RT3883_GPIO_14,
1215 - .name = "pcm i2s",
1216 - .mask = RT3883_GPIO_MODE_PCM_I2S,
1217 - .gpio_first = RT3883_GPIO_7,
1218 - .gpio_last = RT3883_GPIO_14,
1220 - .name = "i2s uartf",
1221 - .mask = RT3883_GPIO_MODE_I2S_UARTF,
1222 - .gpio_first = RT3883_GPIO_7,
1223 - .gpio_last = RT3883_GPIO_14,
1225 - .name = "pcm gpio",
1226 - .mask = RT3883_GPIO_MODE_PCM_GPIO,
1227 - .gpio_first = RT3883_GPIO_11,
1228 - .gpio_last = RT3883_GPIO_14,
1230 - .name = "gpio uartf",
1231 - .mask = RT3883_GPIO_MODE_GPIO_UARTF,
1232 - .gpio_first = RT3883_GPIO_7,
1233 - .gpio_last = RT3883_GPIO_10,
1235 - .name = "gpio i2s",
1236 - .mask = RT3883_GPIO_MODE_GPIO_I2S,
1237 - .gpio_first = RT3883_GPIO_7,
1238 - .gpio_last = RT3883_GPIO_10,
1241 - .mask = RT3883_GPIO_MODE_GPIO,
1243 +static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
1244 +static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 5) };
1245 +static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
1246 +static struct rt2880_pmx_func lna_a_func[] = { FUNC("lna a", 0, 32, 3) };
1247 +static struct rt2880_pmx_func lna_g_func[] = { FUNC("lna a", 0, 35, 3) };
1248 +static struct rt2880_pmx_func pci_func[] = {
1249 + FUNC("pci-dev", 0, 40, 32),
1250 + FUNC("pci-host2", 1, 40, 32),
1251 + FUNC("pci-host1", 2, 40, 32),
1252 + FUNC("pci-fnc", 3, 40, 32)
1254 +static struct rt2880_pmx_func ge1_func[] = { FUNC("ge1", 0, 72, 12) };
1255 +static struct rt2880_pmx_func ge2_func[] = { FUNC("ge1", 0, 84, 12) };
1257 -static struct ralink_pinmux_grp pci_mux[] = {
1259 - .name = "pci-dev",
1261 - .gpio_first = RT3883_GPIO_PCI_AD0,
1262 - .gpio_last = RT3883_GPIO_PCI_AD31,
1264 - .name = "pci-host2",
1266 - .gpio_first = RT3883_GPIO_PCI_AD0,
1267 - .gpio_last = RT3883_GPIO_PCI_AD31,
1269 - .name = "pci-host1",
1271 - .gpio_first = RT3883_GPIO_PCI_AD0,
1272 - .gpio_last = RT3883_GPIO_PCI_AD31,
1274 - .name = "pci-fnc",
1276 - .gpio_first = RT3883_GPIO_PCI_AD0,
1277 - .gpio_last = RT3883_GPIO_PCI_AD31,
1279 - .name = "pci-gpio",
1281 - .gpio_first = RT3883_GPIO_PCI_AD0,
1282 - .gpio_last = RT3883_GPIO_PCI_AD31,
1284 +static struct rt2880_pmx_group rt3883_pinmux_data[] = {
1285 + GRP("i2c", i2c_func, 1, RT3883_GPIO_MODE_I2C),
1286 + GRP("spi", spi_func, 1, RT3883_GPIO_MODE_SPI),
1287 + GRP("uartf", uartf_func, RT3883_GPIO_MODE_UART0_MASK,
1288 + RT3883_GPIO_MODE_UART0_SHIFT),
1289 + GRP("uartlite", uartlite_func, 1, RT3883_GPIO_MODE_UART1),
1290 + GRP("jtag", jtag_func, 1, RT3883_GPIO_MODE_JTAG),
1291 + GRP("mdio", mdio_func, 1, RT3883_GPIO_MODE_MDIO),
1292 + GRP("lna a", lna_a_func, 1, RT3883_GPIO_MODE_LNA_A),
1293 + GRP("lna g", lna_g_func, 1, RT3883_GPIO_MODE_LNA_G),
1294 + GRP("pci", pci_func, RT3883_GPIO_MODE_PCI_MASK,
1295 + RT3883_GPIO_MODE_PCI_SHIFT),
1296 + GRP("ge1", ge1_func, 1, RT3883_GPIO_MODE_GE1),
1297 + GRP("ge2", ge2_func, 1, RT3883_GPIO_MODE_GE2),
1301 static void rt3883_wdt_reset(void)
1303 rt_sysc_w32(t, RT3883_SYSC_REG_SYSCFG1);
1306 -struct ralink_pinmux rt_gpio_pinmux = {
1309 - .uart_shift = RT3883_GPIO_MODE_UART0_SHIFT,
1310 - .uart_mask = RT3883_GPIO_MODE_UART0_MASK,
1311 - .wdt_reset = rt3883_wdt_reset,
1313 - .pci_shift = RT3883_GPIO_MODE_PCI_SHIFT,
1314 - .pci_mask = RT3883_GPIO_MODE_PCI_MASK,
1317 void __init ralink_clk_init(void)
1319 unsigned long cpu_rate, sys_rate;
1321 soc_info->mem_base = RT3883_SDRAM_BASE;
1322 soc_info->mem_size_min = RT3883_MEM_SIZE_MIN;
1323 soc_info->mem_size_max = RT3883_MEM_SIZE_MAX;
1325 + rt2880_pinmux_data = rt3883_pinmux_data;