All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonas Gorski <jogo@openwrt.org>
To: John Crispin <blogic@openwrt.org>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Gabor Juhos <juhosg@openwrt.org>,
	linux-mips@linux-mips.org
Subject: Re: [PATCH 06/18] MIPS: ralink: add pinmux driver
Date: Wed, 10 Apr 2013 15:51:29 +0200	[thread overview]
Message-ID: <CAOiHx==gGkztMopkWCF4Td1NtKHiyG0FcL2TA59XWpAsHZtuhA@mail.gmail.com> (raw)
In-Reply-To: <1365594447-13068-7-git-send-email-blogic@openwrt.org>

On 10 April 2013 13:47, John Crispin <blogic@openwrt.org> wrote:
> 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.

Bindings documentation, pretty please?

>
> Signed-off-by: John Crispin <blogic@openwrt.org>
> ---
>  arch/mips/ralink/Makefile |    2 +-
>  arch/mips/ralink/common.h |    8 +++-
>  arch/mips/ralink/of.c     |    2 +
>  arch/mips/ralink/pinmux.c |   95 +++++++++++++++++++++++++++++++++++++++++++++
>  arch/mips/ralink/rt305x.c |    6 +--
>  5 files changed, 107 insertions(+), 6 deletions(-)
>  create mode 100644 arch/mips/ralink/pinmux.c
>
> diff --git a/arch/mips/ralink/Makefile b/arch/mips/ralink/Makefile
> index 939757f..39ef249 100644
> --- a/arch/mips/ralink/Makefile
> +++ b/arch/mips/ralink/Makefile
> @@ -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
>
>  obj-$(CONFIG_SOC_RT305X) += rt305x.o
>
> diff --git a/arch/mips/ralink/common.h b/arch/mips/ralink/common.h
> index 3009903..193c76c 100644
> --- a/arch/mips/ralink/common.h
> +++ b/arch/mips/ralink/common.h
> @@ -22,9 +22,13 @@ struct ralink_pinmux {
>         struct ralink_pinmux_grp *mode;
>         struct ralink_pinmux_grp *uart;
>         int uart_shift;
> +       u32 uart_mask;
>         void (*wdt_reset)(void);
> +       struct ralink_pinmux_grp *pci;
> +       int pci_shift;
> +       u32 pci_mask;
>  };
> -extern struct ralink_pinmux gpio_pinmux;
> +extern struct ralink_pinmux rt_pinmux;
>
>  struct ralink_soc_info {
>         unsigned char sys_type[RAMIPS_SYS_TYPE_LEN];
> @@ -41,4 +45,6 @@ extern void prom_soc_init(struct ralink_soc_info *soc_info);
>
>  __iomem void *plat_of_remap_node(const char *node);
>
> +void ralink_pinmux(void);
> +
>  #endif /* _RALINK_COMMON_H__ */
> diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
> index 4165e70..ecf1482 100644
> --- a/arch/mips/ralink/of.c
> +++ b/arch/mips/ralink/of.c
> @@ -101,6 +101,8 @@ static int __init plat_of_setup(void)
>         if (of_platform_populate(NULL, of_ids, NULL, NULL))
>                 panic("failed to populate DT\n");
>
> +       ralink_pinmux();
> +
>         return 0;
>  }
>
> diff --git a/arch/mips/ralink/pinmux.c b/arch/mips/ralink/pinmux.c
> new file mode 100644
> index 0000000..c10df50
> --- /dev/null
> +++ b/arch/mips/ralink/pinmux.c
> @@ -0,0 +1,95 @@
> +/*
> + *  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
> +
> +static u32 ralink_mux_mask(const char *name, struct ralink_pinmux_grp *grps)
> +{
> +       for (; grps->name; grps++)
> +               if (!strcmp(grps->name, name))
> +                       return grps->mask;
> +
> +       return 0;
> +}
> +
> +void ralink_pinmux(void)

Since you are only calling it from init code, couldn't it be also __init?

> +{
> +       const __be32 *wdt;
> +       struct device_node *np;
> +       struct property *prop;
> +       const char *uart, *pci, *pin;
> +       u32 mode = 0;
> +
> +       np = of_find_compatible_node(NULL, NULL, "ralink,rt3050-sysc");
> +       if (!np)
> +               return;
> +
> +       of_property_for_each_string(np, "ralink,gpiomux", prop, pin) {
> +               int m = ralink_mux_mask(pin, rt_pinmux.mode);

Missing empty line.

> +               if (m) {
> +                       mode |= m;
> +                       pr_debug("pinmux: registered gpiomux \"%s\"\n", pin);
> +               } else {
> +                       pr_err("pinmux: failed to load \"%s\"\n", pin);
> +               }
> +       }
> +
> +       of_property_for_each_string(np, "ralink,pinmux", prop, pin) {
> +               int m = ralink_mux_mask(pin, rt_pinmux.mode);

Missing empty line.

> +               if (m) {
> +                       mode &= ~m;
> +                       pr_debug("pinmux: registered pinmux \"%s\"\n", pin);
> +               } else {
> +                       pr_err("pinmux: failed to load group \"%s\"\n", pin);
> +               }
> +       }
> +
> +       uart = NULL;
> +       if (rt_pinmux.uart)
> +               of_property_read_string(np, "ralink,uartmux", &uart);
> +
> +       if (uart) {
> +               int m = ralink_mux_mask(uart, rt_pinmux.uart);
> +
> +               if (m) {
> +                       mode &= ~(rt_pinmux.uart_mask << rt_pinmux.uart_shift);
> +                       mode |= m << rt_pinmux.uart_shift;
> +                       pr_debug("pinmux: registered uartmux \"%s\"\n", uart);
> +               } else {
> +                       pr_debug("pinmux: unknown uartmux \"%s\"\n", uart);
> +               }
> +       }
> +
> +       wdt = of_get_property(np, "ralink,wdtmux", NULL);
> +       if (wdt && *wdt && rt_pinmux.wdt_reset)
> +               rt_pinmux.wdt_reset();
> +
> +       pci = NULL;
> +       if (rt_pinmux.pci)
> +               of_property_read_string(np, "ralink,pcimux", &pci);
> +
> +       if (pci) {
> +               int m = ralink_mux_mask(pci, rt_pinmux.pci);

Missing empty line.

> +               mode &= ~(rt_pinmux.pci_mask << rt_pinmux.pci_shift);
> +               if (m) {
> +                       mode |= (m << rt_pinmux.pci_shift);
> +                       pr_debug("pinmux: registered pcimux \"%s\"\n", pci);
> +               } else {
> +                       pr_debug("pinmux: registered pcimux \"gpio\"\n");
> +               }
> +       }
> +
> +       rt_sysc_w32(mode, SYSC_REG_GPIO_MODE);
> +}


Jonas

  reply	other threads:[~2013-04-10 13:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10 11:47 [PATCH 00/18] MIPS: ralink: add several new Ralink SoC John Crispin
2013-04-10 11:47 ` [PATCH 01/18] MIPS: ralink: add PCI IRQ handling John Crispin
2013-04-10 11:47 ` [PATCH 02/18] MIPS: ralink: fix RT305x clock setup John Crispin
2013-04-10 13:47   ` Jonas Gorski
2013-04-10 13:49   ` Sergei Shtylyov
2013-04-10 11:47 ` [PATCH 03/18] MIPS: ralink: add missing comment in irq driver John Crispin
2013-04-10 11:47 ` [PATCH 04/18] MIPS: ralink: add RT5350 sdram register defines John Crispin
2013-04-10 11:47 ` [PATCH 05/18] MIPS: ralink: add RT3352 usb " John Crispin
2013-04-10 11:47 ` [PATCH 06/18] MIPS: ralink: add pinmux driver John Crispin
2013-04-10 13:51   ` Jonas Gorski [this message]
2013-04-10 11:47 ` [PATCH 07/18] MIPS: ralink: extend RT3050 dtsi file John Crispin
2013-04-10 11:47 ` [PATCH 08/18] MIPS: ralink: add RT5350 " John Crispin
2013-04-10 13:53   ` Jonas Gorski
2013-04-10 13:54     ` John Crispin
2013-04-10 11:47 ` [PATCH 09/18] MIPS: ralink: make early_printk work on RT2880 John Crispin
2013-04-10 11:47 ` [PATCH 10/18] MIPS: ralink: adds support for RT2880 SoC family John Crispin
2013-04-10 11:47 ` [PATCH 11/18] MIPS: ralink: add rt2880 dts files John Crispin
2013-04-10 11:47 ` [PATCH 12/18] MIPS: ralink: adds support for RT3883 SoC family John Crispin
2013-04-10 11:47 ` [PATCH 13/18] MIPS: ralink: add rt3883 dts files John Crispin
2013-04-10 11:47 ` [PATCH 14/18] MIPS: ralink: adds support for MT7620 SoC family John Crispin
2013-04-10 11:47 ` [PATCH 15/18] MIPS: ralink: add MT7620 dts files John Crispin
2013-04-10 11:47 ` [PATCH 16/18] MIPS: ralink: add support for periodic timer irq John Crispin
2013-04-10 13:41   ` Lars-Peter Clausen
2013-04-10 11:47 ` [PATCH 17/18] MIPS: ralink: add cpu-feature-overrides.h John Crispin
2013-04-10 11:47 ` [PATCH 18/18] MIPS: ralink: add support for runtime memory detection John Crispin
2013-04-10 13:56   ` Jonas Gorski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOiHx==gGkztMopkWCF4Td1NtKHiyG0FcL2TA59XWpAsHZtuhA@mail.gmail.com' \
    --to=jogo@openwrt.org \
    --cc=blogic@openwrt.org \
    --cc=juhosg@openwrt.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.