mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: girish <girishvg@gmail.com>
To: Paul Mundt <lethal@linux-sh.org>
Cc: B.Zolnierkiewicz@elka.pw.edu.pl, linux-kernel@vger.kernel.org,
	linux-ide@vger.kernel.org, rmk@arm.linux.org.uk, gregkh@suse.de,
	ysato@users.sourceforge.jp
Subject: Re: [PATCH] Generic platform device IDE driver
Date: Wed, 4 Oct 2006 20:30:36 +0900	[thread overview]
Message-ID: <A1AC65D6-07AC-42CB-80F1-9621DBCACF83@gmail.com> (raw)
In-Reply-To: <20061004074535.GA7180@localhost.hsdv.com>


question:  where is linux/ide-platform.h header?

On Oct 4, 2006, at 4:45 PM, Paul Mundt wrote:

> Currently the platforms that have very simplistic needs for IDE  
> devices
> are forced to invent their own driver for adding the built-in devices.
> At the moment ARM is the in-tree user in this category, h8300 could be
> switched to something more generic, and SH is roughly in the same
> category as ARM.
>
> The only constant that really tends to change between these platforms
> are the I/O base and the IRQ, with everything else rather constant.  
> The
> ctl base could also change, but everyone seems to keep it at 0x206, so
> it's debatable whether it's worth leaving this configurable or not.
>
> I've hacked together a quick driver, 'ide-platform' (for lack of a
> better name), that allows for these specifics to be passed in via
> platform device resources (registering a device per-port) rather than
> having to add more of these things to drivers/ide.
>
> With this we can remove ide_arm (and the h8300 driver can likely be
> reworked to use this too), and I don't have to invent a new driver for
> SH that does effectively the same thing.
>
> This is intended purely for the simple NO_DMA ide_generic case..  
> nothing
> complicated.
>
> What do people think about this, is there a better way to do this?
>
> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
>
> --
>
>  drivers/ide/Makefile       |    3 +-
>  drivers/ide/ide-platform.c |   60 +++++++++++++++++++++++++++++++++ 
> ++++++++++++
>  drivers/ide/ide.c          |    3 ++
>  3 files changed, 65 insertions(+), 1 deletion(-)
>
> commit f2da2c8c9b5e648ca9a43d9d3fed9bcd356f0efd
> Author: Paul Mundt <lethal@linux-sh.org>
> Date:   Wed Oct 4 16:41:21 2006 +0900
>
>     ide: Simple platform device IDE driver.
>
>     This adds a trivial platform device IDE driver. Users are  
> required to
>     register a couple of resources:
>
>     	- I/O Base
>     	- CTL Base
>     	- IRQ
>
>     Signed-off-by: Paul Mundt <lethal@linux-sh.org>
>
> diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
> index 569fae7..24c9a0f 100644
> --- a/drivers/ide/Makefile
> +++ b/drivers/ide/Makefile
> @@ -13,7 +13,8 @@ EXTRA_CFLAGS				+= -Idrivers/ide
>
>  obj-$(CONFIG_BLK_DEV_IDE)		+= pci/
>
> -ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide- 
> taskfile.o
> +ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide- 
> taskfile.o \
> +	      ide-platform.o
>
>  ide-core-$(CONFIG_BLK_DEV_CMD640)	+= pci/cmd640.o
>
> diff --git a/drivers/ide/ide-platform.c b/drivers/ide/ide-platform.c
> new file mode 100644
> index 0000000..6d89878
> --- /dev/null
> +++ b/drivers/ide/ide-platform.c
> @@ -0,0 +1,60 @@
> +/*
> + * Generic IDE platform device driver
> + *
> + * Copyright (C) 2006  Paul Mundt
> + *
> + * This file is subject to the terms and conditions of the GNU  
> General Public
> + * License.  See the file "COPYING" in the main directory of this  
> archive
> + * for more details.
> + */
> +#include <linux/init.h>
> +#include <linux/ide.h>
> +#include <linux/platform_device.h>
> +
> +/*
> + * Users use per-port registration with a simple set of 3 resources
> + * per port:
> + * 		- I/O Base (IORESOURCE_IO)
> + * 		- CTL Base (IORESOURCE_IO)
> + * 		- IRQ	   (IORESOURCE_IRQ)
> + */
> +static int __devinit ide_platform_probe(struct platform_device *dev)
> +{
> +	struct resource *io_res, *ctl_res;
> +	hw_regs_t hw;
> +
> +	if (unlikely(dev->num_resources != 3)) {
> +		dev_err(&dev->dev, "invalid number of resources\n");
> +		return -EINVAL;
> +	}
> +
> +	io_res = platform_get_resource(dev, IORESOURCE_IO, 0);
> +	if (unlikely(io_res == NULL))
> +		return -EINVAL;
> +
> +	ctl_res = platform_get_resource(dev, IORESOURCE_IO, 1);
> +	if (unlikely(ctl_res == NULL))
> +		return -EINVAL;
> +
> +	memset(&hw, 0, sizeof(hw_regs_t));
> +	ide_std_init_ports(&hw, io_res->start, ctl_res->start);
> +
> +	hw.irq		= platform_get_irq(dev, 0);
> +	hw.chipset	= ide_generic;
> +
> +	return ide_register_hw(&hw, NULL);
> +}
> +
> +static struct platform_driver ide_platform_driver = {
> +	.probe		= ide_platform_probe,
> +	.driver		= {
> +		.name	= "ide-platform",
> +		.owner	= THIS_MODULE,
> +	},
> +};
> +
> +void __init ide_platform_init(void)
> +{
> +	printk(KERN_INFO "ide-platform: platform device IDE interface\n");
> +	platform_driver_register(&ide_platform_driver);
> +}
> diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
> index 287a662..994cdd4 100644
> --- a/drivers/ide/ide.c
> +++ b/drivers/ide/ide.c
> @@ -1782,6 +1782,7 @@ done:
>  }
>
>  extern void pnpide_init(void);
> +extern void ide_platform_init(void);
>  extern void h8300_ide_init(void);
>
>  /*
> @@ -1793,6 +1794,8 @@ #ifdef CONFIG_BLK_DEV_IDEPCI
>  	ide_scan_pcibus(ide_scan_direction);
>  #endif /* CONFIG_BLK_DEV_IDEPCI */
>
> +	ide_platform_init();
> +
>  #ifdef CONFIG_ETRAX_IDE
>  	{
>  		extern void init_e100_ide(void);
> -
> To unsubscribe from this list: send the line "unsubscribe linux- 
> kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  reply	other threads:[~2006-10-04 11:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-04  7:45 Paul Mundt
2006-10-04 11:30 ` girish [this message]
2006-10-04 20:02   ` Paul Mundt
2006-10-04 12:25     ` girish
2006-10-04 11:41 ` Alan Cox
2006-10-04 20:05   ` Paul Mundt
2006-10-04 14:38     ` Alan Cox
2006-10-05  9:16       ` Paul Mundt
     [not found]         ` <200610111450.41909.matthias.fuchs@esd-electronics.com>
2006-10-12  6:13           ` Paul Mundt
2006-10-13  7:52             ` Russell King
2006-10-13 12:28               ` Paul Mundt
2006-10-13 12:46                 ` Jeff Garzik

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=A1AC65D6-07AC-42CB-80F1-9621DBCACF83@gmail.com \
    --to=girishvg@gmail.com \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=gregkh@suse.de \
    --cc=lethal@linux-sh.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=ysato@users.sourceforge.jp \
    /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

Powered by JetHome