linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Kevin Hilman <khilman@ti.com>,
	Russell King - ARM Linux <linux@arm.linux.org.uk>,
	Ingo Molnar <mingo@elte.hu>, Nicolas Pitre <nico@fluxnic.net>,
	david@lang.hm, Linus Torvalds <torvalds@linux-foundation.org>,
	Tony Lindgren <tony@atomide.com>,
	David Brown <davidb@codeaurora.org>,
	lkml <linux-kernel@vger.kernel.org>,
	linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [GIT PULL] omap changes for v2.6.39 merge window
Date: Thu, 31 Mar 2011 18:58:49 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.00.1103311826070.22418@localhost6.localdomain6> (raw)
In-Reply-To: <201103311723.02301.arnd@arndb.de>

On Thu, 31 Mar 2011, Arnd Bergmann wrote:

> On Thursday 31 March 2011, Kevin Hilman wrote:
> > Some SoCs families (like OMAP) have huge amount of diversity even within
> > the SoC family, so better abstractions and generic infrastrucure
> > improvements are an obvious win, even staying within the SoC.
> 
> But that's the point. The incentive is there for managing the infrastructure
> within the SoC, but not across SoCs. Allow me to use OMAP as a bad example
> while pointing out that it's really one of the best supported platforms
> we currently have, while the others are usually much worse in terms of
> working with the community (or at least they are behind on the learning
> curve but getting there):
> 
> * OMAP2 introduced the hwmod concept as an attempt to reduce duplication
>   between board code, but the code was done on the mach-omap2 level
>   instead of finding a way to make it work across SOC vendors, or using
>   an existing solution.
> 
> * The IOMMU code in omap2 duplicates the API we have in the common kernel,
>   with slight differences, instead of using the existing code, making it
>   impossible to share a driver between SOC families.
> 
> * The ti-st code duplicates parts of the bluetooth layer (apparently
>   that is getting fixed soon).
> 
> * The DSS display drivers introduce new infrastructure include new bus
>   types that have the complexity to make them completely generic, but
>   in practice can only work on OMAP, and are clearly not written with
>   cross-vendor abstractions in mind.

Right, but the problem starts in way simpler areas like irq chips and
gpio stuff, where lots of the IP cores are similar and trivial enough
to be shared across many SoC families.

Even the OMAP "consolidated" code is silly:

static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
{
	void __iomem *reg = bank->base;
	u32 l = 0;

	switch (bank->method) {
#ifdef CONFIG_ARCH_OMAP1
	case METHOD_MPUIO:
		reg += OMAP_MPUIO_OUTPUT / bank->stride;
		l = __raw_readl(reg);
		if (enable)
			l |= 1 << gpio;
		else
			l &= ~(1 << gpio);
		break;
#endif
#ifdef CONFIG_ARCH_OMAP15XX
	case METHOD_GPIO_1510:
		reg += OMAP1510_GPIO_DATA_OUTPUT;
		l = __raw_readl(reg);
		if (enable)
			l |= 1 << gpio;
		else
			l &= ~(1 << gpio);
		break;
#endif
#ifdef CONFIG_ARCH_OMAP16XX
	case METHOD_GPIO_1610:
		if (enable)
			reg += OMAP1610_GPIO_SET_DATAOUT;
		else
			reg += OMAP1610_GPIO_CLEAR_DATAOUT;
		l = 1 << gpio;
		break;
#endif
#if defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
	case METHOD_GPIO_7XX:
		reg += OMAP7XX_GPIO_DATA_OUTPUT;
		l = __raw_readl(reg);
		if (enable)
			l |= 1 << gpio;
		else
			l &= ~(1 << gpio);
		break;
#endif
#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
	case METHOD_GPIO_24XX:
		if (enable)
			reg += OMAP24XX_GPIO_SETDATAOUT;
	else
			reg += OMAP24XX_GPIO_CLEARDATAOUT;
		l = 1 << gpio;
		break;
#endif
#ifdef CONFIG_ARCH_OMAP4
	case METHOD_GPIO_44XX:
		if (enable)
			reg += OMAP4_GPIO_SETDATAOUT;
		else
			reg += OMAP4_GPIO_CLEARDATAOUT;
		l = 1 << gpio;
		break;
#endif
	default:
		WARN_ON(1);
		return;
	}
	__raw_writel(l, reg);
}

So we have 2 types of sections:

#1
      data = read_reg();
      if (enable)
      	 data |= bit;
      else
         data &= ~bit;
      write_reg(data);

#2
      if (enable)
      	 write_enable_reg(bit);
      else
         write_disable_reg(bit);

But the code above has 6 cases in the switch because nobody abstracted
it out consequently. Not to talk about the ifdef mess.

So now look at tons of other gpio implementations all over the DOZENS
of ARM plat-/mach- space and guess what.

Most have either type #1 or type #2 just slightly different copied,
less or better abstracted and I'm pretty damned sure, that you could
consolidate all that stuff into a handful or even less drivers which
provide the code across the board.

Same for irq chips. Most of these gpio things have callbacks which do:

irq_xxx(struct irq_data *d)
{
	gpio = irq_data_get_irq_chip_data(d);
	irq = d->irq - gpio->base_irq;
	reg = convert_to_reg(gpio, irq);
	mask = convert_to_mask(gpio);

	write(reg, mask);
}

I saw all those incarnations lately and you can boil them down to a
handful or less as well which fit all over the place.

Start off with such a trivial, but immense effective cleanup and see
what it helps to share code even accross SoC vendors. They all glue
together random IP blocks from the market and there are not soo many
sources which are relevant. This makes sense in all aspects:

      1) less and better code
      2) faster setup for new SoCs
      3) shared benefit for all vendors

Thanks,

	tglx

  reply	other threads:[~2011-03-31 16:59 UTC|newest]

Thread overview: 159+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17 18:30 [GIT PULL] omap changes for v2.6.39 merge window Tony Lindgren
2011-03-18  2:50 ` Linus Torvalds
2011-03-18  7:06   ` Tony Lindgren
2011-03-18 10:15   ` Russell King - ARM Linux
2011-03-18 11:13     ` Uwe Kleine-König
2011-03-30 17:06     ` Arnd Bergmann
2011-03-30 19:21       ` Linus Torvalds
2011-03-30 20:41         ` Nicolas Pitre
2011-03-30 21:02           ` Linus Torvalds
2011-03-30 23:31             ` Nicolas Pitre
2011-03-30 23:59               ` Russell King - ARM Linux
2011-03-31  0:15                 ` Tony Lindgren
2011-03-31  0:31               ` Bill Gatliff
2011-03-31  0:39               ` david
2011-03-31  3:17                 ` Nicolas Pitre
2011-03-31  3:29                   ` Dave Airlie
2011-03-31  4:38                     ` Nicolas Pitre
2011-03-31  9:54                       ` Alan Cox
2011-03-31 10:50                         ` Russell King - ARM Linux
2011-03-31 12:23                           ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-31 12:38                           ` Catalin Marinas
2011-03-31 13:01                             ` Russell King - ARM Linux
2011-03-31 14:55                               ` Bill Gatliff
2011-04-01 12:41                                 ` Arnd Bergmann
2011-03-31 18:12                               ` Sam Ravnborg
2011-03-31 18:17                                 ` Russell King - ARM Linux
2011-03-31 18:34                                   ` Jesse Barnes
2011-03-31 13:54                           ` Thomas Gleixner
2011-03-31 17:22                           ` david
2011-03-31 18:08                             ` Koen Kooi
2011-03-31  5:05                   ` david
2011-03-31  7:15                     ` Nicolas Pitre
2011-03-31  8:06                       ` Ingo Molnar
2011-03-31  8:30                         ` Russell King - ARM Linux
2011-03-31 10:41                           ` Ingo Molnar
2011-03-31 13:25                             ` Russell King - ARM Linux
2011-03-31 12:04                           ` Thomas Gleixner
2011-03-31 14:43                             ` Kevin Hilman
2011-03-31 15:01                               ` Thomas Gleixner
2011-03-31 15:05                                 ` Russell King - ARM Linux
2011-03-31 15:45                                   ` david
2011-03-31 15:23                               ` Arnd Bergmann
2011-03-31 16:58                                 ` Thomas Gleixner [this message]
2011-03-31 18:23                                   ` Nicolas Pitre
2011-03-31 18:55                                     ` Thomas Gleixner
2011-04-01 11:32                                   ` Arnd Bergmann
2011-03-31 20:35                                 ` Kevin Hilman
2011-04-01 11:29                                   ` Arnd Bergmann
2011-04-01  7:32                                 ` Tomi Valkeinen
2011-04-01 11:22                                   ` Arnd Bergmann
2011-04-01 11:55                                     ` Tomi Valkeinen
2011-04-01 12:07                                       ` Arnd Bergmann
2011-04-01 12:15                                         ` Tomi Valkeinen
2011-03-31 16:03                           ` david
2011-03-31 16:45                             ` Russell King - ARM Linux
2011-03-31 17:17                               ` Linus Torvalds
2011-03-31 19:25                                 ` Nicolas Pitre
2011-03-31 20:05                                   ` Linus Torvalds
2011-03-31 20:28                                     ` Linus Torvalds
2011-03-31 22:49                                     ` Nicolas Pitre
2011-04-01  0:53                                       ` Mark Brown
2011-04-01  4:50                                       ` David Brown
2011-04-01  7:45                                         ` Ingo Molnar
2011-04-01 13:54                                           ` Arnd Bergmann
     [not found]                                             ` <4D95E112.4020400@vollmann.ch>
2011-04-01 14:59                                               ` Arnd Bergmann
     [not found]                                                 ` <4D95EF8E.9080902@vollmann.ch>
2011-04-01 15:50                                                   ` Arnd Bergmann
2011-04-01 17:44                                                     ` Russell King - ARM Linux
2011-04-01 19:54                                                     ` Nicolas Pitre
2011-04-01 21:00                                                       ` Uwe Kleine-König
2011-04-01 22:08                                                       ` Arnd Bergmann
2011-04-02  2:24                                                         ` Nicolas Pitre
2011-04-03 15:26                                                           ` Arnd Bergmann
2011-04-03 16:03                                                             ` Russell King - ARM Linux
2011-04-04  0:59                                                               ` Arnd Bergmann
2011-04-04  8:26                                                                 ` Marc Zyngier
2011-04-04 11:03                                                                 ` Catalin Marinas
2011-04-04 11:21                                                                   ` Russell King - ARM Linux
2011-04-04 13:24                                                                     ` Marc Zyngier
2011-04-04 13:31                                                                       ` Russell King - ARM Linux
2011-04-04 13:57                                                                         ` Marc Zyngier
2011-04-04 20:08                                                                           ` Linus Walleij
2011-04-05  6:40                                                                             ` Santosh Shilimkar
2011-04-05  7:45                                                                               ` Russell King - ARM Linux
2011-04-05 14:15                                                                                 ` Catalin Marinas
2011-04-05 22:16                                                                               ` Linus Walleij
2011-04-06  6:43                                                                                 ` Santosh Shilimkar
2011-04-05 22:22                                                                               ` Linus Walleij
2011-04-06  6:41                                                                                 ` Santosh Shilimkar
2011-04-05  7:30                                                                             ` Marc Zyngier
2011-05-26 13:38                                                               ` Pavel Machek
2011-04-02  2:59                                                       ` Mark Brown
2011-04-04  5:16                                                   ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-04  9:27                                                   ` Nicolas Ferre
2011-04-01 21:10                                                 ` Kevin Hilman
2011-04-01 21:32                                                   ` Arnd Bergmann
2011-04-01 21:51                                                     ` Catalin Marinas
2011-04-03 22:18                                               ` Benjamin Herrenschmidt
2011-04-04  0:14                                                 ` Arnd Bergmann
2011-04-04  2:49                                                 ` Nicolas Pitre
2011-04-01 15:27                                             ` Will Deacon
2011-04-01 15:55                                               ` Arnd Bergmann
2011-04-01 16:39                                                 ` Linus Torvalds
2011-04-03 22:26                                                   ` Benjamin Herrenschmidt
2011-04-05 23:19                                                   ` Linus Walleij
2011-04-06  8:41                                                     ` Catalin Marinas
2011-04-07  1:44                                                       ` Arnd Bergmann
2011-04-01 20:19                                                 ` Nicolas Pitre
2011-04-02  4:38                                                   ` Richard Cochran
2011-04-02  3:27                                                 ` Mark Brown
2011-04-06  6:11                                             ` Barry Song
2011-04-06  7:31                                               ` Bryan Wu
2011-03-31 21:40                                   ` Thomas Gleixner
2011-03-31 17:56                             ` Nicolas Pitre
2011-03-31 18:34                               ` Thomas Gleixner
2011-03-31 19:02                               ` Linus Torvalds
2011-03-31  8:09                     ` Russell King - ARM Linux
2011-03-31 10:49                       ` Felipe Balbi
2011-03-31 18:00                       ` Alexander Holler
2011-03-31  5:45               ` Geert Uytterhoeven
2011-03-31  7:21                 ` Nicolas Pitre
2011-03-30 22:08           ` Tony Lindgren
2011-03-30 21:10         ` Thomas Gleixner
2011-03-30 21:54           ` Tony Lindgren
2011-03-30 22:25             ` Thomas Gleixner
2011-03-30 22:45               ` Tony Lindgren
2011-03-30 22:56                 ` Thomas Gleixner
2011-04-01  1:42                   ` Mark Brown
2011-03-30 22:38             ` Paul E. McKenney
2011-03-30 22:47               ` Tony Lindgren
2011-03-30 23:13                 ` Paul E. McKenney
2011-03-30 23:14                 ` Thomas Gleixner
2011-03-30 23:28                   ` Tony Lindgren
2011-03-31 11:00           ` Artem Bityutskiy
2011-03-31 13:54             ` Arnd Bergmann
2011-03-30 21:44         ` Tony Lindgren
2011-03-30 22:20           ` Linus Torvalds
2011-03-30 22:39             ` Tony Lindgren
2011-03-31  0:15         ` Russell King - ARM Linux
2011-03-31  0:55           ` Linus Torvalds
2011-03-31  1:15             ` Bill Gatliff
2011-03-31  1:37               ` Linus Torvalds
2011-03-31  1:44                 ` Bill Gatliff
2011-03-31  1:56                   ` Linus Torvalds
2011-03-31  2:20                     ` Bill Gatliff
2011-03-31  3:24                       ` Linus Torvalds
2011-03-31  6:42                         ` Olof Johansson
2011-03-31  6:56                         ` David Brown
2011-03-31 11:27                         ` Felipe Balbi
2011-03-31 13:39                 ` Thomas Gleixner
2011-03-31  4:09             ` Nicolas Pitre
2011-03-31 10:11               ` Thomas Gleixner
2011-03-30 21:07       ` Russell King - ARM Linux
2011-03-30 22:14         ` Tony Lindgren
2011-04-01  1:17           ` Mark Brown
2011-04-01 14:17         ` Arnd Bergmann
2011-03-18  3:02 ` Linus Torvalds
2011-03-18  7:09   ` Tony Lindgren
2011-03-18  8:06     ` Ohad Ben-Cohen
2011-03-18 23:43       ` Tony Lindgren

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=alpine.LFD.2.00.1103311826070.22418@localhost6.localdomain6 \
    --to=tglx@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=david@lang.hm \
    --cc=davidb@codeaurora.org \
    --cc=hpa@zytor.com \
    --cc=khilman@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mingo@elte.hu \
    --cc=nico@fluxnic.net \
    --cc=tony@atomide.com \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).