public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Mundt <lethal@linux-sh.org>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH] - Merger of companionchips HD64461 and HD64465 header files.
Date: Mon, 04 Feb 2008 03:13:51 +0000	[thread overview]
Message-ID: <20080204031351.GA25862@linux-sh.org> (raw)

On Wed, Jan 16, 2008 at 10:29:02PM -0800, Kristoffer Ericson wrote:
> This is the header patch, I've already fixed the build errors in my
> local tree, but need to apply to linux-sh tree.  I also removed the
> io.h file since it really shouldn't be needed any longer. I got a
> devboard with hd64465 companionchipset so I plan to get it up to shape
> shortly, this is step one.
> 
> Just want quick feedback on the idea and how the patch looks. (should
> io.h stay? Is the lcd functions hd6446x or hd64461 specific?)
> 
> Ive confirmed hp6xx booting as usual using these hd6446x defines (of
> course changed in all effected files) in my local tree.
> 
There are a few things that need some thinking about with hd6446x.
One of the main things is where exactly we need the information for the
I/O base. It would be really nice if we could just rip out the hardcoded
I/O base from the Kconfig and allow hp6xx and others to simply hand this
off as a platform device. The only place we seem to need the I/O base
early is for doing the PCMCIA memory aperture remapping (or more
specifically, setting up the special PTE bits for this), but we can
already do that from the setup code where we register the platform
device, since we'll already know the I/O base at that time.

> --- /dev/null
> +++ b/include/asm-sh/hd64465_gpio.h
> @@ -0,0 +1,46 @@
> +#ifndef _ASM_SH_HD64465_GPIO_
> +#define _ASM_SH_HD64465_GPIO_ 1
> +/*
> + * $Id: gpio.h,v 1.3 2003/05/04 19:30:14 lethal Exp $
> + *
> + * Hitachi HD64465 companion chip: General Purpose IO pins support.
> + * This layer enables other device drivers to configure GPIO
> + * pins, get and set their values, and register an interrupt
> + * routine for when input pins change in hardware.
> + *
> + * by Greg Banks <gbanks@pocketpenguins.com>
> + * (c) 2000 PocketPenguins Inc.
> + */
> +#include <asm/hd64465.h>
> +
> +/* Macro to construct a portpin number (used in all
> + * subsequent functions) from a port letter and a pin
> + * number, e.g. HD64465_GPIO_PORTPIN('A', 5).
> + */
> +#define HD64465_GPIO_PORTPIN(port,pin)	(((port)-'A')<<3|(pin))
> +
> +/* Pin configuration constants for _configure() */
> +#define HD64465_GPIO_FUNCTION2	0	/* use the pin's *other* function */
> +#define HD64465_GPIO_OUT	1	/* output */
> +#define HD64465_GPIO_IN_PULLUP	2	/* input, pull-up MOS on */
> +#define HD64465_GPIO_IN		3	/* input */
> +
> +/* Configure a pin's direction */
> +extern void hd64465_gpio_configure(int portpin, int direction);
> +
> +/* Get, set value */
> +extern void hd64465_gpio_set_pin(int portpin, unsigned int value);
> +extern unsigned int hd64465_gpio_get_pin(int portpin);
> +extern void hd64465_gpio_set_port(int port, unsigned int value);
> +extern unsigned int hd64465_gpio_get_port(int port);
> +
> +/* mode constants for _register_irq() */
> +#define HD64465_GPIO_FALLING	0
> +#define HD64465_GPIO_RISING	1
> +
> +/* Interrupt on external value change */
> +extern void hd64465_gpio_register_irq(int portpin, int mode,
> +	void (*handler)(int portpin, void *dev), void *dev);
> +extern void hd64465_gpio_unregister_irq(int portpin);
> +
> +#endif /* _ASM_SH_HD64465_GPIO_  */

It's really not worth dragging around this broken GPIO code. Obviously
there's nothing in-tree that's making use of this, so I would just rip it
out completely and add it back in under gpio-lib (currently in -mm, and
queued for 2.6.25) if there's a real need for it.

> +/* System adresses */
> +#define HD6446x_SRR		(CONFIG_HD6446x_IOBASE + 0x000c)
> +#define HD6446x_SDID		(CONFIG_HD6446x_IOBASE + 0x0010)
> +#define HD6446x_HD64465_SDID	0x8122						/* HD64465 device ID */
> +
Do not use lower case characters in CONFIG_ space. Also, hardcoding all
of these CONFIG_XXX_IOBASE things all over the place is ultimately not
helpful. You should have a proper mfd driver managing this device, and
force the drivers to go through that in a centralized location.

You would basically be better off purging any mention of hd6446x (and
h64461/h64465) from include/asm-sh and starting over by defining the bare
essentials for what you need, and then building on top of that. This
existing code has been around forever, and it's obviously not going to
get cleaner any time soon without drastic measures.

> +/* arch/sh/cchips/hd6446x/hd64461/setup.c */
> +int hd6446x_irq_demux(int irq);
> +void hd6446x_register_irq_demux(int irq,
> +				int (*demux) (int irq, void *dev), void *dev);
> +void hd6446x_unregister_irq_demux(int irq);
> +
There doesn't seem to be any compelling need for this either. You can get
away with IRQF_SHARED, or setting up a chained handler.

Also, all of the changes that this header depends on (ie. the Kconfig
bits) are completely absent, so this patch would simply break the tree if
it were applied.

In short, the hd6446x stuff is so hopelessly broken and bitrotted, you
are better off spending some time rewriting it completely rather than
trying to keep the existing support limping along. The drivers should
generally be unaffected with the exception of how they get at their
registers, but that's a fairly trivial fixup. You really want to start
with a sane mfd driver before worrying about the rest of these
trivialities.

             reply	other threads:[~2008-02-04  3:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04  3:13 Paul Mundt [this message]
2008-02-04  8:57 ` [PATCH] - Merger of companionchips HD64461 and HD64465 header Kristoffer Ericson

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=20080204031351.GA25862@linux-sh.org \
    --to=lethal@linux-sh.org \
    --cc=linux-sh@vger.kernel.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