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.9/arch/mips/Kconfig
18 ===================================================================
19 --- linux-3.10.9.orig/arch/mips/Kconfig 2013-08-28 16:34:42.449951676 +0200
20 +++ linux-3.10.9/arch/mips/Kconfig 2013-08-28 16:34:43.361951711 +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.9/drivers/pinctrl/Kconfig
31 ===================================================================
32 --- linux-3.10.9.orig/drivers/pinctrl/Kconfig 2013-08-21 00:40:47.000000000 +0200
33 +++ linux-3.10.9/drivers/pinctrl/Kconfig 2013-08-28 16:34:43.361951711 +0200
38 +config PINCTRL_RT2880
46 Index: linux-3.10.9/drivers/pinctrl/Makefile
47 ===================================================================
48 --- linux-3.10.9.orig/drivers/pinctrl/Makefile 2013-08-21 00:40:47.000000000 +0200
49 +++ linux-3.10.9/drivers/pinctrl/Makefile 2013-08-28 16:34:43.361951711 +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.9/drivers/pinctrl/pinctrl-rt2880.c
59 ===================================================================
60 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
61 +++ linux-3.10.9/drivers/pinctrl/pinctrl-rt2880.c 2013-08-28 16:34:43.361951711 +0200
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 */
286 + mode |= p->groups[group].mask << p->groups[group].shift;
287 + /* mark the pins as gpio */
288 + for (i = 0; i < p->groups[group].func[0].pin_count; i++)
289 + p->gpio[p->groups[group].func[0].pins[i]] = 1;
291 + mode |= p->func[func]->value << p->groups[group].shift;
293 + rt_sysc_w32(mode, SYSC_REG_GPIO_MODE);
298 +static int rt2880_pmx_group_gpio_request_enable(struct pinctrl_dev *pctrldev,
299 + struct pinctrl_gpio_range *range,
302 + struct rt2880_priv *p = pinctrl_dev_get_drvdata(pctrldev);
304 + if (!p->gpio[pin]) {
305 + dev_err(p->dev, "pin %d is not set to gpio mux\n", pin);
312 +static const struct pinmux_ops rt2880_pmx_group_ops = {
313 + .get_functions_count = rt2880_pmx_func_count,
314 + .get_function_name = rt2880_pmx_func_name,
315 + .get_function_groups = rt2880_pmx_group_get_groups,
316 + .enable = rt2880_pmx_group_enable,
317 + .gpio_request_enable = rt2880_pmx_group_gpio_request_enable,
320 +static struct pinctrl_desc rt2880_pctrl_desc = {
321 + .owner = THIS_MODULE,
322 + .name = "rt2880-pinmux",
323 + .pctlops = &rt2880_pctrl_ops,
324 + .pmxops = &rt2880_pmx_group_ops,
327 +static struct rt2880_pmx_func gpio_func = {
331 +static int rt2880_pinmux_index(struct rt2880_priv *p)
333 + struct rt2880_pmx_func **f;
334 + struct rt2880_pmx_group *mux = p->groups;
337 + /* count the mux functions */
338 + while (mux->name) {
343 + /* allocate the group names array needed by the gpio function */
344 + p->group_names = devm_kzalloc(p->dev, sizeof(char *) * p->group_count, GFP_KERNEL);
345 + if (!p->group_names)
348 + for (i = 0; i < p->group_count; i++) {
349 + p->group_names[i] = p->groups[i].name;
350 + p->func_count += p->groups[i].func_count;
353 + /* we have a dummy function[0] for gpio */
356 + /* allocate our function and group mapping index buffers */
357 + f = p->func = devm_kzalloc(p->dev, sizeof(struct rt2880_pmx_func) * p->func_count, GFP_KERNEL);
358 + gpio_func.groups = devm_kzalloc(p->dev, sizeof(int) * p->group_count, GFP_KERNEL);
359 + if (!f || !gpio_func.groups)
362 + /* add a backpointer to the function so it knows its group */
363 + gpio_func.group_count = p->group_count;
364 + for (i = 0; i < gpio_func.group_count; i++)
365 + gpio_func.groups[i] = i;
370 + /* add remaining functions */
371 + for (i = 0; i < p->group_count; i++) {
372 + 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 + /* pin 0 is always a gpio */
421 + for (i = 0; i < p->max_pins; i++) {
422 + /* strlen("ioXY") + 1 = 5 */
423 + char *name = devm_kzalloc(p->dev, 5, GFP_KERNEL);
426 + dev_err(p->dev, "Failed to allocate pad name\n");
429 + snprintf(name, 5, "io%d", i);
430 + p->pads[i].number = i;
431 + p->pads[i].name = name;
433 + p->desc->pins = p->pads;
434 + p->desc->npins = p->max_pins;
439 +static int rt2880_pinmux_probe(struct platform_device *pdev)
441 + struct rt2880_priv *p;
442 + struct pinctrl_dev *dev;
443 + struct device_node *np;
445 + if (!rt2880_pinmux_data)
448 + /* setup the private data */
449 + p = devm_kzalloc(&pdev->dev, sizeof(struct rt2880_priv), GFP_KERNEL);
453 + p->dev = &pdev->dev;
454 + p->desc = &rt2880_pctrl_desc;
455 + p->groups = rt2880_pinmux_data;
456 + platform_set_drvdata(pdev, p);
458 + /* init the device */
459 + if (rt2880_pinmux_index(p)) {
460 + dev_err(&pdev->dev, "failed to load index\n");
463 + if (rt2880_pinmux_pins(p)) {
464 + dev_err(&pdev->dev, "failed to load pins\n");
467 + dev = pinctrl_register(p->desc, &pdev->dev, p);
469 + return PTR_ERR(dev);
471 + /* finalize by adding gpio ranges for enables gpio controllers */
472 + for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") {
473 + const __be32 *ngpio, *gpiobase;
474 + struct pinctrl_gpio_range *range;
477 + if (!of_device_is_available(np))
480 + ngpio = of_get_property(np, "ralink,num-gpios", NULL);
481 + gpiobase = of_get_property(np, "ralink,gpio-base", NULL);
482 + if (!ngpio || !gpiobase) {
483 + dev_err(&pdev->dev, "failed to load chip info\n");
487 + range = devm_kzalloc(p->dev, sizeof(struct pinctrl_gpio_range) + 4, GFP_KERNEL);
488 + range->name = name = (char *) &range[1];
489 + sprintf(name, "pio");
490 + range->npins = __be32_to_cpu(*ngpio);
491 + range->base = __be32_to_cpu(*gpiobase);
492 + pinctrl_add_gpio_range(dev, range);
498 +static const struct of_device_id rt2880_pinmux_match[] = {
499 + { .compatible = "ralink,rt2880-pinmux" },
502 +MODULE_DEVICE_TABLE(of, rt2880_pinmux_match);
504 +static struct platform_driver rt2880_pinmux_driver = {
505 + .probe = rt2880_pinmux_probe,
507 + .name = "rt2880-pinmux",
508 + .owner = THIS_MODULE,
509 + .of_match_table = rt2880_pinmux_match,
513 +int __init rt2880_pinmux_init(void)
515 + return platform_driver_register(&rt2880_pinmux_driver);
518 +core_initcall_sync(rt2880_pinmux_init);
519 Index: linux-3.10.9/arch/mips/include/asm/mach-ralink/pinmux.h
520 ===================================================================
521 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
522 +++ linux-3.10.9/arch/mips/include/asm/mach-ralink/pinmux.h 2013-08-28 16:34:43.361951711 +0200
525 + * This program is free software; you can redistribute it and/or modify
526 + * it under the terms of the GNU General Public License version 2 as
527 + * publishhed by the Free Software Foundation.
529 + * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
532 +#ifndef _RT288X_PINMUX_H__
533 +#define _RT288X_PINMUX_H__
535 +#define FUNC(name, value, pin_first, pin_count) { name, value, pin_first, pin_count }
536 +#define GRP(_name, _func, _mask, _shift) \
537 + { .name = _name, .mask = _mask, .shift = _shift, \
539 + .func_count = ARRAY_SIZE(_func) }
541 +struct rt2880_pmx_group;
543 +struct rt2880_pmx_func {
557 +struct rt2880_pmx_group {
564 + struct rt2880_pmx_func *func;
568 +extern struct rt2880_pmx_group *rt2880_pinmux_data;
571 Index: linux-3.10.9/arch/mips/ralink/mt7620.c
572 ===================================================================
573 --- linux-3.10.9.orig/arch/mips/ralink/mt7620.c 2013-08-28 16:34:42.829951688 +0200
574 +++ linux-3.10.9/arch/mips/ralink/mt7620.c 2013-08-28 16:34:43.361951711 +0200
576 #include <asm/mipsregs.h>
577 #include <asm/mach-ralink/ralink_regs.h>
578 #include <asm/mach-ralink/mt7620.h>
579 +#include <asm/mach-ralink/pinmux.h>
584 /* the pll dividers */
585 static u32 mt7620_clk_divider[] = { 2, 3, 4, 8 };
587 -static struct ralink_pinmux_grp mode_mux[] = {
590 - .mask = MT7620_GPIO_MODE_I2C,
595 - .mask = MT7620_GPIO_MODE_SPI,
599 - .name = "uartlite",
600 - .mask = MT7620_GPIO_MODE_UART1,
605 - .mask = MT7620_GPIO_MODE_WDT,
610 - .mask = MT7620_GPIO_MODE_MDIO,
615 - .mask = MT7620_GPIO_MODE_RGMII1,
619 - .name = "spi refclk",
620 - .mask = MT7620_GPIO_MODE_SPI_REF_CLK,
625 - .mask = MT7620_GPIO_MODE_JTAG,
629 - /* shared lines with jtag */
631 - .mask = MT7620_GPIO_MODE_EPHY,
636 - .mask = MT7620_GPIO_MODE_JTAG,
641 - .mask = MT7620_GPIO_MODE_RGMII2,
646 - .mask = MT7620_GPIO_MODE_WLED,
650 +static struct rt2880_pmx_func i2c_grp[] = { FUNC("i2c", 1, 1, 2) };
651 +static struct rt2880_pmx_func spi_grp[] = { FUNC("spi", 1, 3, 4) };
652 +static struct rt2880_pmx_func uartf_grp[] = {
653 + FUNC("uartf", MT7620_GPIO_MODE_UARTF, 7, 8),
654 + FUNC("pcm uartf", MT7620_GPIO_MODE_PCM_UARTF, 7, 8),
655 + FUNC("pcm i2s", MT7620_GPIO_MODE_PCM_I2S, 7, 8),
656 + FUNC("i2s uartf", MT7620_GPIO_MODE_I2S_UARTF, 7, 8),
657 + FUNC("pcm gpio", MT7620_GPIO_MODE_PCM_GPIO, 11, 4),
658 + FUNC("gpio uartf", MT7620_GPIO_MODE_GPIO_UARTF, 7, 4),
659 + FUNC("gpio i2s", MT7620_GPIO_MODE_GPIO_I2S, 7, 4),
662 -static struct ralink_pinmux_grp uart_mux[] = {
665 - .mask = MT7620_GPIO_MODE_UARTF,
669 - .name = "pcm uartf",
670 - .mask = MT7620_GPIO_MODE_PCM_UARTF,
675 - .mask = MT7620_GPIO_MODE_PCM_I2S,
679 - .name = "i2s uartf",
680 - .mask = MT7620_GPIO_MODE_I2S_UARTF,
684 - .name = "pcm gpio",
685 - .mask = MT7620_GPIO_MODE_PCM_GPIO,
689 - .name = "gpio uartf",
690 - .mask = MT7620_GPIO_MODE_GPIO_UARTF,
694 - .name = "gpio i2s",
695 - .mask = MT7620_GPIO_MODE_GPIO_I2S,
700 - .mask = MT7620_GPIO_MODE_GPIO,
704 -struct ralink_pinmux rt_gpio_pinmux = {
707 - .uart_shift = MT7620_GPIO_MODE_UART0_SHIFT,
708 - .uart_mask = MT7620_GPIO_MODE_UART0_MASK,
709 +static struct rt2880_pmx_func uartlite_grp[] = { FUNC("uartlite", 1, 15, 2) };
710 +static struct rt2880_pmx_func wdt_grp[] = { FUNC("wdt", 1, 17, 1) };
711 +static struct rt2880_pmx_func mdio_grp[] = { FUNC("mdio", 1, 22, 2) };
712 +static struct rt2880_pmx_func rgmii1_grp[] = { FUNC("rgmii1", 1, 24, 12) };
713 +static struct rt2880_pmx_func refclk_grp[] = { FUNC("spi refclk", 1, 37, 3) };
714 +static struct rt2880_pmx_func ephy_grp[] = { FUNC("ephy", 1, 40, 5) };
715 +static struct rt2880_pmx_func rgmii2_grp[] = { FUNC("rgmii2", 1, 60, 12) };
716 +static struct rt2880_pmx_func wled_grp[] = { FUNC("wled", 1, 72, 1) };
718 +static struct rt2880_pmx_group mt7620a_pinmux_data[] = {
719 + GRP("i2c", i2c_grp, 1, MT7620_GPIO_MODE_I2C),
720 + GRP("spi", spi_grp, 1, MT7620_GPIO_MODE_SPI),
721 + GRP("uartlite", uartlite_grp, 1, MT7620_GPIO_MODE_UART1),
722 + GRP("wdt", wdt_grp, 1, MT7620_GPIO_MODE_WDT),
723 + GRP("mdio", mdio_grp, 1, MT7620_GPIO_MODE_MDIO),
724 + GRP("rgmii1", rgmii1_grp, 1, MT7620_GPIO_MODE_RGMII1),
725 + GRP("spi refclk", refclk_grp, 1, MT7620_GPIO_MODE_SPI_REF_CLK),
726 + GRP("rgmii2", rgmii2_grp, 1, MT7620_GPIO_MODE_RGMII2),
727 + GRP("ephy", ephy_grp, 1, MT7620_GPIO_MODE_EPHY),
728 + GRP("wled", wled_grp, 1, MT7620_GPIO_MODE_WLED),
729 + GRP("uartf", uartf_grp, MT7620_GPIO_MODE_UART0_MASK,
730 + MT7620_GPIO_MODE_UART0_SHIFT),
734 void __init ralink_clk_init(void)
736 (pmu0 & PMU_SW_SET) ? ("sw") : ("hw"));
737 pr_info("Digital PMU set to %s control\n",
738 (pmu1 & DIG_SW_SEL) ? ("sw") : ("hw"));
740 + rt2880_pinmux_data = mt7620a_pinmux_data;
742 Index: linux-3.10.9/arch/mips/ralink/rt305x.c
743 ===================================================================
744 --- linux-3.10.9.orig/arch/mips/ralink/rt305x.c 2013-08-28 16:34:43.061951698 +0200
745 +++ linux-3.10.9/arch/mips/ralink/rt305x.c 2013-08-28 16:34:43.365951713 +0200
747 #include <asm/mipsregs.h>
748 #include <asm/mach-ralink/ralink_regs.h>
749 #include <asm/mach-ralink/rt305x.h>
750 +#include <asm/mach-ralink/pinmux.h>
754 enum rt305x_soc_type rt305x_soc;
756 -static struct ralink_pinmux_grp mode_mux[] = {
759 - .mask = RT305X_GPIO_MODE_I2C,
760 - .gpio_first = RT305X_GPIO_I2C_SD,
761 - .gpio_last = RT305X_GPIO_I2C_SCLK,
764 - .mask = RT305X_GPIO_MODE_SPI,
765 - .gpio_first = RT305X_GPIO_SPI_EN,
766 - .gpio_last = RT305X_GPIO_SPI_CLK,
768 - .name = "uartlite",
769 - .mask = RT305X_GPIO_MODE_UART1,
770 - .gpio_first = RT305X_GPIO_UART1_TXD,
771 - .gpio_last = RT305X_GPIO_UART1_RXD,
774 - .mask = RT305X_GPIO_MODE_JTAG,
775 - .gpio_first = RT305X_GPIO_JTAG_TDO,
776 - .gpio_last = RT305X_GPIO_JTAG_TDI,
779 - .mask = RT305X_GPIO_MODE_MDIO,
780 - .gpio_first = RT305X_GPIO_MDIO_MDC,
781 - .gpio_last = RT305X_GPIO_MDIO_MDIO,
784 - .mask = RT305X_GPIO_MODE_SDRAM,
785 - .gpio_first = RT305X_GPIO_SDRAM_MD16,
786 - .gpio_last = RT305X_GPIO_SDRAM_MD31,
789 - .mask = RT305X_GPIO_MODE_RGMII,
790 - .gpio_first = RT305X_GPIO_GE0_TXD0,
791 - .gpio_last = RT305X_GPIO_GE0_RXCLK,
793 +static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
794 +static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
795 +static struct rt2880_pmx_func uartf_func[] = {
796 + FUNC("uartf", RT305X_GPIO_MODE_UARTF, 7, 8),
797 + FUNC("pcm uartf", RT305X_GPIO_MODE_PCM_UARTF, 7, 8),
798 + FUNC("pcm i2s", RT305X_GPIO_MODE_PCM_I2S, 7, 8),
799 + FUNC("i2s uartf", RT305X_GPIO_MODE_I2S_UARTF, 7, 8),
800 + FUNC("pcm gpio", RT305X_GPIO_MODE_PCM_GPIO, 11, 4),
801 + FUNC("gpio uartf", RT305X_GPIO_MODE_GPIO_UARTF, 7, 4),
802 + FUNC("gpio i2s", RT305X_GPIO_MODE_GPIO_I2S, 7, 4),
804 +static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
805 +static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 25) };
806 +static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
807 +static struct rt2880_pmx_func rt5350_led_func[] = { FUNC("led", 0, 22, 5) };
808 +static struct rt2880_pmx_func sdram_func[] = { FUNC("sdram", 0, 24, 16) };
809 +static struct rt2880_pmx_func rt3352_rgmii_func[] = { FUNC("rgmii", 0, 24, 12) };
810 +static struct rt2880_pmx_func rgmii_func[] = { FUNC("rgmii", 0, 40, 12) };
811 +static struct rt2880_pmx_func rt3352_lna_func[] = { FUNC("lna", 0, 36, 2) };
812 +static struct rt2880_pmx_func rt3352_pa_func[] = { FUNC("pa", 0, 38, 2) };
813 +static struct rt2880_pmx_func rt3352_led_func[] = { FUNC("led", 0, 40, 5) };
815 +static struct rt2880_pmx_group rt3050_pinmux_data[] = {
816 + GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
817 + GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
818 + GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
819 + RT305X_GPIO_MODE_UART0_SHIFT),
820 + GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
821 + GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
822 + GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
823 + GRP("rgmii", rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
824 + GRP("sdram", sdram_func, 1, RT305X_GPIO_MODE_SDRAM),
828 +static struct rt2880_pmx_group rt3352_pinmux_data[] = {
829 + GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
830 + GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
831 + GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
832 + RT305X_GPIO_MODE_UART0_SHIFT),
833 + GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
834 + GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
835 + GRP("mdio", mdio_func, 1, RT305X_GPIO_MODE_MDIO),
836 + GRP("rgmii", rt3352_rgmii_func, 1, RT305X_GPIO_MODE_RGMII),
837 + GRP("lna", rt3352_lna_func, 1, RT3352_GPIO_MODE_LNA),
838 + GRP("pa", rt3352_pa_func, 1, RT3352_GPIO_MODE_PA),
839 + GRP("led", rt3352_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
843 -static struct ralink_pinmux_grp uart_mux[] = {
846 - .mask = RT305X_GPIO_MODE_UARTF,
847 - .gpio_first = RT305X_GPIO_7,
848 - .gpio_last = RT305X_GPIO_14,
850 - .name = "pcm uartf",
851 - .mask = RT305X_GPIO_MODE_PCM_UARTF,
852 - .gpio_first = RT305X_GPIO_7,
853 - .gpio_last = RT305X_GPIO_14,
856 - .mask = RT305X_GPIO_MODE_PCM_I2S,
857 - .gpio_first = RT305X_GPIO_7,
858 - .gpio_last = RT305X_GPIO_14,
860 - .name = "i2s uartf",
861 - .mask = RT305X_GPIO_MODE_I2S_UARTF,
862 - .gpio_first = RT305X_GPIO_7,
863 - .gpio_last = RT305X_GPIO_14,
865 - .name = "pcm gpio",
866 - .mask = RT305X_GPIO_MODE_PCM_GPIO,
867 - .gpio_first = RT305X_GPIO_10,
868 - .gpio_last = RT305X_GPIO_14,
870 - .name = "gpio uartf",
871 - .mask = RT305X_GPIO_MODE_GPIO_UARTF,
872 - .gpio_first = RT305X_GPIO_7,
873 - .gpio_last = RT305X_GPIO_10,
875 - .name = "gpio i2s",
876 - .mask = RT305X_GPIO_MODE_GPIO_I2S,
877 - .gpio_first = RT305X_GPIO_7,
878 - .gpio_last = RT305X_GPIO_10,
881 - .mask = RT305X_GPIO_MODE_GPIO,
883 +static struct rt2880_pmx_group rt5350_pinmux_data[] = {
884 + GRP("i2c", i2c_func, 1, RT305X_GPIO_MODE_I2C),
885 + GRP("spi", spi_func, 1, RT305X_GPIO_MODE_SPI),
886 + GRP("uartf", uartf_func, RT305X_GPIO_MODE_UART0_MASK,
887 + RT305X_GPIO_MODE_UART0_SHIFT),
888 + GRP("uartlite", uartlite_func, 1, RT305X_GPIO_MODE_UART1),
889 + GRP("jtag", jtag_func, 1, RT305X_GPIO_MODE_JTAG),
890 + GRP("led", rt5350_led_func, 1, RT5350_GPIO_MODE_PHY_LED),
894 static void rt305x_wdt_reset(void)
896 rt_sysc_w32(t, SYSC_REG_SYSTEM_CONFIG);
899 -struct ralink_pinmux rt_gpio_pinmux = {
902 - .uart_shift = RT305X_GPIO_MODE_UART0_SHIFT,
903 - .uart_mask = RT305X_GPIO_MODE_UART0_MASK,
904 - .wdt_reset = rt305x_wdt_reset,
907 static unsigned long rt5350_get_mem_size(void)
909 void __iomem *sysc = (void __iomem *) KSEG1ADDR(RT305X_SYSC_BASE);
910 @@ -291,11 +264,14 @@
911 soc_info->mem_base = RT305X_SDRAM_BASE;
912 if (soc_is_rt5350()) {
913 soc_info->mem_size = rt5350_get_mem_size();
914 + rt2880_pinmux_data = rt5350_pinmux_data;
915 } else if (soc_is_rt305x() || soc_is_rt3350()) {
916 soc_info->mem_size_min = RT305X_MEM_SIZE_MIN;
917 soc_info->mem_size_max = RT305X_MEM_SIZE_MAX;
918 + rt2880_pinmux_data = rt3050_pinmux_data;
919 } else if (soc_is_rt3352()) {
920 soc_info->mem_size_min = RT3352_MEM_SIZE_MIN;
921 soc_info->mem_size_max = RT3352_MEM_SIZE_MAX;
922 + rt2880_pinmux_data = rt3352_pinmux_data;
925 Index: linux-3.10.9/arch/mips/include/asm/mach-ralink/rt305x.h
926 ===================================================================
927 --- linux-3.10.9.orig/arch/mips/include/asm/mach-ralink/rt305x.h 2013-08-21 00:40:47.000000000 +0200
928 +++ linux-3.10.9/arch/mips/include/asm/mach-ralink/rt305x.h 2013-08-28 16:34:43.365951713 +0200
929 @@ -125,24 +125,28 @@
930 #define RT305X_GPIO_GE0_TXD0 40
931 #define RT305X_GPIO_GE0_RXCLK 51
933 -#define RT305X_GPIO_MODE_I2C BIT(0)
934 -#define RT305X_GPIO_MODE_SPI BIT(1)
935 #define RT305X_GPIO_MODE_UART0_SHIFT 2
936 #define RT305X_GPIO_MODE_UART0_MASK 0x7
937 #define RT305X_GPIO_MODE_UART0(x) ((x) << RT305X_GPIO_MODE_UART0_SHIFT)
938 -#define RT305X_GPIO_MODE_UARTF 0x0
939 -#define RT305X_GPIO_MODE_PCM_UARTF 0x1
940 -#define RT305X_GPIO_MODE_PCM_I2S 0x2
941 -#define RT305X_GPIO_MODE_I2S_UARTF 0x3
942 -#define RT305X_GPIO_MODE_PCM_GPIO 0x4
943 -#define RT305X_GPIO_MODE_GPIO_UARTF 0x5
944 -#define RT305X_GPIO_MODE_GPIO_I2S 0x6
945 -#define RT305X_GPIO_MODE_GPIO 0x7
946 -#define RT305X_GPIO_MODE_UART1 BIT(5)
947 -#define RT305X_GPIO_MODE_JTAG BIT(6)
948 -#define RT305X_GPIO_MODE_MDIO BIT(7)
949 -#define RT305X_GPIO_MODE_SDRAM BIT(8)
950 -#define RT305X_GPIO_MODE_RGMII BIT(9)
951 +#define RT305X_GPIO_MODE_UARTF 0
952 +#define RT305X_GPIO_MODE_PCM_UARTF 1
953 +#define RT305X_GPIO_MODE_PCM_I2S 2
954 +#define RT305X_GPIO_MODE_I2S_UARTF 3
955 +#define RT305X_GPIO_MODE_PCM_GPIO 4
956 +#define RT305X_GPIO_MODE_GPIO_UARTF 5
957 +#define RT305X_GPIO_MODE_GPIO_I2S 6
958 +#define RT305X_GPIO_MODE_GPIO 7
960 +#define RT305X_GPIO_MODE_I2C 0
961 +#define RT305X_GPIO_MODE_SPI 1
962 +#define RT305X_GPIO_MODE_UART1 5
963 +#define RT305X_GPIO_MODE_JTAG 6
964 +#define RT305X_GPIO_MODE_MDIO 7
965 +#define RT305X_GPIO_MODE_SDRAM 8
966 +#define RT305X_GPIO_MODE_RGMII 9
967 +#define RT5350_GPIO_MODE_PHY_LED 14
968 +#define RT3352_GPIO_MODE_LNA 18
969 +#define RT3352_GPIO_MODE_PA 20
971 #define RT3352_SYSC_REG_SYSCFG0 0x010
972 #define RT3352_SYSC_REG_SYSCFG1 0x014
973 Index: linux-3.10.9/arch/mips/include/asm/mach-ralink/mt7620.h
974 ===================================================================
975 --- linux-3.10.9.orig/arch/mips/include/asm/mach-ralink/mt7620.h 2013-08-28 16:34:42.625951682 +0200
976 +++ linux-3.10.9/arch/mips/include/asm/mach-ralink/mt7620.h 2013-08-28 18:32:38.370254386 +0200
978 #define MT7620_DDR2_SIZE_MIN 32
979 #define MT7620_DDR2_SIZE_MAX 256
981 -#define MT7620_GPIO_MODE_I2C BIT(0)
982 #define MT7620_GPIO_MODE_UART0_SHIFT 2
983 #define MT7620_GPIO_MODE_UART0_MASK 0x7
984 #define MT7620_GPIO_MODE_UART0(x) ((x) << MT7620_GPIO_MODE_UART0_SHIFT)
986 #define MT7620_GPIO_MODE_GPIO_UARTF 0x5
987 #define MT7620_GPIO_MODE_GPIO_I2S 0x6
988 #define MT7620_GPIO_MODE_GPIO 0x7
989 -#define MT7620_GPIO_MODE_UART1 BIT(5)
990 -#define MT7620_GPIO_MODE_MDIO BIT(8)
991 -#define MT7620_GPIO_MODE_RGMII1 BIT(9)
992 -#define MT7620_GPIO_MODE_RGMII2 BIT(10)
993 -#define MT7620_GPIO_MODE_SPI BIT(11)
994 -#define MT7620_GPIO_MODE_SPI_REF_CLK BIT(12)
995 -#define MT7620_GPIO_MODE_WLED BIT(13)
996 -#define MT7620_GPIO_MODE_JTAG BIT(15)
997 -#define MT7620_GPIO_MODE_EPHY BIT(15)
998 -#define MT7620_GPIO_MODE_WDT BIT(22)
1000 +#define MT7620_GPIO_MODE_I2C 0
1001 +#define MT7620_GPIO_MODE_UART1 5
1002 +#define MT7620_GPIO_MODE_MDIO 8
1003 +#define MT7620_GPIO_MODE_RGMII1 9
1004 +#define MT7620_GPIO_MODE_RGMII2 10
1005 +#define MT7620_GPIO_MODE_SPI 11
1006 +#define MT7620_GPIO_MODE_SPI_REF_CLK 12
1007 +#define MT7620_GPIO_MODE_WLED 13
1008 +#define MT7620_GPIO_MODE_JTAG 15
1009 +#define MT7620_GPIO_MODE_EPHY 15
1010 +#define MT7620_GPIO_MODE_WDT 22
1013 Index: linux-3.10.9/arch/mips/include/asm/mach-ralink/rt3883.h
1014 ===================================================================
1015 --- linux-3.10.9.orig/arch/mips/include/asm/mach-ralink/rt3883.h 2013-08-21 00:40:47.000000000 +0200
1016 +++ linux-3.10.9/arch/mips/include/asm/mach-ralink/rt3883.h 2013-08-28 18:33:57.554258201 +0200
1018 #define RT3883_CLKCFG1_PCI_CLK_EN BIT(19)
1019 #define RT3883_CLKCFG1_UPHY0_CLK_EN BIT(18)
1021 -#define RT3883_GPIO_MODE_I2C BIT(0)
1022 -#define RT3883_GPIO_MODE_SPI BIT(1)
1023 #define RT3883_GPIO_MODE_UART0_SHIFT 2
1024 #define RT3883_GPIO_MODE_UART0_MASK 0x7
1025 #define RT3883_GPIO_MODE_UART0(x) ((x) << RT3883_GPIO_MODE_UART0_SHIFT)
1026 @@ -125,11 +123,15 @@
1027 #define RT3883_GPIO_MODE_GPIO_UARTF 0x5
1028 #define RT3883_GPIO_MODE_GPIO_I2S 0x6
1029 #define RT3883_GPIO_MODE_GPIO 0x7
1030 -#define RT3883_GPIO_MODE_UART1 BIT(5)
1031 -#define RT3883_GPIO_MODE_JTAG BIT(6)
1032 -#define RT3883_GPIO_MODE_MDIO BIT(7)
1033 -#define RT3883_GPIO_MODE_GE1 BIT(9)
1034 -#define RT3883_GPIO_MODE_GE2 BIT(10)
1036 +#define RT3883_GPIO_MODE_I2C 0
1037 +#define RT3883_GPIO_MODE_SPI 1
1038 +#define RT3883_GPIO_MODE_UART1 5
1039 +#define RT3883_GPIO_MODE_JTAG 6
1040 +#define RT3883_GPIO_MODE_MDIO 7
1041 +#define RT3883_GPIO_MODE_GE1 9
1042 +#define RT3883_GPIO_MODE_GE2 10
1044 #define RT3883_GPIO_MODE_PCI_SHIFT 11
1045 #define RT3883_GPIO_MODE_PCI_MASK 0x7
1046 #define RT3883_GPIO_MODE_PCI (RT3883_GPIO_MODE_PCI_MASK << RT3883_GPIO_MODE_PCI_SHIFT)
1047 Index: linux-3.10.9/arch/mips/ralink/common.h
1048 ===================================================================
1049 --- linux-3.10.9.orig/arch/mips/ralink/common.h 2013-08-28 16:34:42.453951675 +0200
1050 +++ linux-3.10.9/arch/mips/ralink/common.h 2013-08-28 18:10:55.014197854 +0200
1053 #define RAMIPS_SYS_TYPE_LEN 32
1055 -struct ralink_pinmux_grp {
1062 -struct ralink_pinmux {
1063 - struct ralink_pinmux_grp *mode;
1064 - struct ralink_pinmux_grp *uart;
1067 - void (*wdt_reset)(void);
1068 - struct ralink_pinmux_grp *pci;
1072 -extern struct ralink_pinmux rt_gpio_pinmux;
1074 struct ralink_soc_info {
1075 unsigned char sys_type[RAMIPS_SYS_TYPE_LEN];
1076 unsigned char *compatible;
1077 Index: linux-3.10.9/arch/mips/ralink/rt3883.c
1078 ===================================================================
1079 --- linux-3.10.9.orig/arch/mips/ralink/rt3883.c 2013-08-21 00:40:47.000000000 +0200
1080 +++ linux-3.10.9/arch/mips/ralink/rt3883.c 2013-08-28 18:47:07.442290690 +0200
1081 @@ -17,132 +17,50 @@
1082 #include <asm/mipsregs.h>
1083 #include <asm/mach-ralink/ralink_regs.h>
1084 #include <asm/mach-ralink/rt3883.h>
1085 +#include <asm/mach-ralink/pinmux.h>
1089 -static struct ralink_pinmux_grp mode_mux[] = {
1092 - .mask = RT3883_GPIO_MODE_I2C,
1093 - .gpio_first = RT3883_GPIO_I2C_SD,
1094 - .gpio_last = RT3883_GPIO_I2C_SCLK,
1097 - .mask = RT3883_GPIO_MODE_SPI,
1098 - .gpio_first = RT3883_GPIO_SPI_CS0,
1099 - .gpio_last = RT3883_GPIO_SPI_MISO,
1101 - .name = "uartlite",
1102 - .mask = RT3883_GPIO_MODE_UART1,
1103 - .gpio_first = RT3883_GPIO_UART1_TXD,
1104 - .gpio_last = RT3883_GPIO_UART1_RXD,
1107 - .mask = RT3883_GPIO_MODE_JTAG,
1108 - .gpio_first = RT3883_GPIO_JTAG_TDO,
1109 - .gpio_last = RT3883_GPIO_JTAG_TCLK,
1112 - .mask = RT3883_GPIO_MODE_MDIO,
1113 - .gpio_first = RT3883_GPIO_MDIO_MDC,
1114 - .gpio_last = RT3883_GPIO_MDIO_MDIO,
1117 - .mask = RT3883_GPIO_MODE_GE1,
1118 - .gpio_first = RT3883_GPIO_GE1_TXD0,
1119 - .gpio_last = RT3883_GPIO_GE1_RXCLK,
1122 - .mask = RT3883_GPIO_MODE_GE2,
1123 - .gpio_first = RT3883_GPIO_GE2_TXD0,
1124 - .gpio_last = RT3883_GPIO_GE2_RXCLK,
1127 - .mask = RT3883_GPIO_MODE_PCI,
1128 - .gpio_first = RT3883_GPIO_PCI_AD0,
1129 - .gpio_last = RT3883_GPIO_PCI_AD31,
1132 - .mask = RT3883_GPIO_MODE_LNA_A,
1133 - .gpio_first = RT3883_GPIO_LNA_PE_A0,
1134 - .gpio_last = RT3883_GPIO_LNA_PE_A2,
1137 - .mask = RT3883_GPIO_MODE_LNA_G,
1138 - .gpio_first = RT3883_GPIO_LNA_PE_G0,
1139 - .gpio_last = RT3883_GPIO_LNA_PE_G2,
1141 +static struct rt2880_pmx_func i2c_func[] = { FUNC("i2c", 0, 1, 2) };
1142 +static struct rt2880_pmx_func spi_func[] = { FUNC("spi", 0, 3, 4) };
1143 +static struct rt2880_pmx_func uartf_func[] = {
1144 + FUNC("uartf", RT3883_GPIO_MODE_UARTF, 7, 8),
1145 + FUNC("pcm uartf", RT3883_GPIO_MODE_PCM_UARTF, 7, 8),
1146 + FUNC("pcm i2s", RT3883_GPIO_MODE_PCM_I2S, 7, 8),
1147 + FUNC("i2s uartf", RT3883_GPIO_MODE_I2S_UARTF, 7, 8),
1148 + FUNC("pcm gpio", RT3883_GPIO_MODE_PCM_GPIO, 11, 4),
1149 + FUNC("gpio uartf", RT3883_GPIO_MODE_GPIO_UARTF, 7, 4),
1150 + FUNC("gpio i2s", RT3883_GPIO_MODE_GPIO_I2S, 7, 4),
1153 -static struct ralink_pinmux_grp uart_mux[] = {
1156 - .mask = RT3883_GPIO_MODE_UARTF,
1157 - .gpio_first = RT3883_GPIO_7,
1158 - .gpio_last = RT3883_GPIO_14,
1160 - .name = "pcm uartf",
1161 - .mask = RT3883_GPIO_MODE_PCM_UARTF,
1162 - .gpio_first = RT3883_GPIO_7,
1163 - .gpio_last = RT3883_GPIO_14,
1165 - .name = "pcm i2s",
1166 - .mask = RT3883_GPIO_MODE_PCM_I2S,
1167 - .gpio_first = RT3883_GPIO_7,
1168 - .gpio_last = RT3883_GPIO_14,
1170 - .name = "i2s uartf",
1171 - .mask = RT3883_GPIO_MODE_I2S_UARTF,
1172 - .gpio_first = RT3883_GPIO_7,
1173 - .gpio_last = RT3883_GPIO_14,
1175 - .name = "pcm gpio",
1176 - .mask = RT3883_GPIO_MODE_PCM_GPIO,
1177 - .gpio_first = RT3883_GPIO_11,
1178 - .gpio_last = RT3883_GPIO_14,
1180 - .name = "gpio uartf",
1181 - .mask = RT3883_GPIO_MODE_GPIO_UARTF,
1182 - .gpio_first = RT3883_GPIO_7,
1183 - .gpio_last = RT3883_GPIO_10,
1185 - .name = "gpio i2s",
1186 - .mask = RT3883_GPIO_MODE_GPIO_I2S,
1187 - .gpio_first = RT3883_GPIO_7,
1188 - .gpio_last = RT3883_GPIO_10,
1191 - .mask = RT3883_GPIO_MODE_GPIO,
1193 +static struct rt2880_pmx_func uartlite_func[] = { FUNC("uartlite", 0, 15, 2) };
1194 +static struct rt2880_pmx_func jtag_func[] = { FUNC("jtag", 0, 17, 25) };
1195 +static struct rt2880_pmx_func mdio_func[] = { FUNC("mdio", 0, 22, 2) };
1196 +static struct rt2880_pmx_func lna_a_func[] = { FUNC("lna a", 0, 32, 3) };
1197 +static struct rt2880_pmx_func lna_g_func[] = { FUNC("lna a", 0, 35, 3) };
1198 +static struct rt2880_pmx_func pci_func[] = {
1199 + FUNC("pci-dev", 0, 40, 32),
1200 + FUNC("pci-host2", 1, 40, 32),
1201 + FUNC("pci-host1", 2, 40, 32),
1202 + FUNC("pci-fnc", 3, 40, 32)
1204 +static struct rt2880_pmx_func ge1_func[] = { FUNC("ge1", 0, 72, 12) };
1205 +static struct rt2880_pmx_func ge2_func[] = { FUNC("ge1", 0, 84, 12) };
1207 -static struct ralink_pinmux_grp pci_mux[] = {
1209 - .name = "pci-dev",
1211 - .gpio_first = RT3883_GPIO_PCI_AD0,
1212 - .gpio_last = RT3883_GPIO_PCI_AD31,
1214 - .name = "pci-host2",
1216 - .gpio_first = RT3883_GPIO_PCI_AD0,
1217 - .gpio_last = RT3883_GPIO_PCI_AD31,
1219 - .name = "pci-host1",
1221 - .gpio_first = RT3883_GPIO_PCI_AD0,
1222 - .gpio_last = RT3883_GPIO_PCI_AD31,
1224 - .name = "pci-fnc",
1226 - .gpio_first = RT3883_GPIO_PCI_AD0,
1227 - .gpio_last = RT3883_GPIO_PCI_AD31,
1229 - .name = "pci-gpio",
1231 - .gpio_first = RT3883_GPIO_PCI_AD0,
1232 - .gpio_last = RT3883_GPIO_PCI_AD31,
1234 +static struct rt2880_pmx_group rt3883_pinmux_data[] = {
1235 + GRP("i2c", i2c_func, 1, RT3883_GPIO_MODE_I2C),
1236 + GRP("spi", spi_func, 1, RT3883_GPIO_MODE_SPI),
1237 + GRP("uartf", uartf_func, RT3883_GPIO_MODE_UART0_MASK,
1238 + RT3883_GPIO_MODE_UART0_SHIFT),
1239 + GRP("uartlite", uartlite_func, 1, RT3883_GPIO_MODE_UART1),
1240 + GRP("jtag", jtag_func, 1, RT3883_GPIO_MODE_JTAG),
1241 + GRP("mdio", mdio_func, 1, RT3883_GPIO_MODE_MDIO),
1242 + GRP("lna a", lna_a_func, 1, RT3883_GPIO_MODE_LNA_A),
1243 + GRP("lna g", lna_g_func, 1, RT3883_GPIO_MODE_LNA_G),
1244 + GRP("pci", pci_func, RT3883_GPIO_MODE_PCI_MASK,
1245 + RT3883_GPIO_MODE_PCI_SHIFT),
1246 + GRP("ge1", ge1_func, 1, RT3883_GPIO_MODE_GE1),
1247 + GRP("ge2", ge2_func, 1, RT3883_GPIO_MODE_GE2),
1251 static void rt3883_wdt_reset(void)
1253 rt_sysc_w32(t, RT3883_SYSC_REG_SYSCFG1);
1256 -struct ralink_pinmux rt_gpio_pinmux = {
1259 - .uart_shift = RT3883_GPIO_MODE_UART0_SHIFT,
1260 - .uart_mask = RT3883_GPIO_MODE_UART0_MASK,
1261 - .wdt_reset = rt3883_wdt_reset,
1263 - .pci_shift = RT3883_GPIO_MODE_PCI_SHIFT,
1264 - .pci_mask = RT3883_GPIO_MODE_PCI_MASK,
1267 void __init ralink_clk_init(void)
1269 unsigned long cpu_rate, sys_rate;
1271 soc_info->mem_base = RT3883_SDRAM_BASE;
1272 soc_info->mem_size_min = RT3883_MEM_SIZE_MIN;
1273 soc_info->mem_size_max = RT3883_MEM_SIZE_MAX;
1275 + rt2880_pinmux_data = rt3883_pinmux_data;