Patchwork [1/3] imx51: add pata device

login
register
mail settings
Submitter Arnaud Patard (Rtp)
Date July 22, 2011, 10:37 a.m.
Message ID <20110722103832.403681566@rtp-net.org>
Download mbox | patch
Permalink /patch/106253/
State New
Headers show

Comments

Arnaud Patard (Rtp) - July 22, 2011, 10:37 a.m.
Declare the pata device found on mx51

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Fabio Estevam - July 22, 2011, 3:14 p.m.
On Fri, Jul 22, 2011 at 7:37 AM, Arnaud Patard
<arnaud.patard@rtp-net.org> wrote:
...
> +#define imx_mxc_pata_data_entry_single(soc)                            \
> +       {                                                               \
> +               .iobase = soc ## _ATA_BASE_ADDR,                        \
> +               .irq = soc ## _MXC_INT_ATA,                             \

Why not imx_pata_data_entry_single instead?

 "imx_mxc" looks redundant.

Regards,

Fabio Estevam
Uwe Kleine-König - July 22, 2011, 7:09 p.m.
On Fri, Jul 22, 2011 at 12:14:15PM -0300, Fabio Estevam wrote:
> On Fri, Jul 22, 2011 at 7:37 AM, Arnaud Patard
> <arnaud.patard@rtp-net.org> wrote:
> ...
> > +#define imx_mxc_pata_data_entry_single(soc)                            \
> > +       {                                                               \
> > +               .iobase = soc ## _ATA_BASE_ADDR,                        \
> > +               .irq = soc ## _MXC_INT_ATA,                             \
> 
> Why not imx_pata_data_entry_single instead?
> 
>  "imx_mxc" looks redundant.
imx is the platform prefix, mxc_pata the device's name. So IMHO the name
is right and consistent with the other device registration stuff.

Best regards
Uwe
Uwe Kleine-König - July 22, 2011, 7:10 p.m.
Hello Arnaud,

On Fri, Jul 22, 2011 at 12:37:11PM +0200, Arnaud Patard wrote:
> +extern const struct imx_mxc_pata_data im51_mxc_pata_data;
imx51 please

Uwe
Arnaud Patard (Rtp) - July 22, 2011, 8:28 p.m.
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:

> On Fri, Jul 22, 2011 at 12:14:15PM -0300, Fabio Estevam wrote:
>> On Fri, Jul 22, 2011 at 7:37 AM, Arnaud Patard
>> <arnaud.patard@rtp-net.org> wrote:
>> ...
>> > +#define imx_mxc_pata_data_entry_single(soc)                            \
>> > +       {                                                               \
>> > +               .iobase = soc ## _ATA_BASE_ADDR,                        \
>> > +               .irq = soc ## _MXC_INT_ATA,                             \
>> 
>> Why not imx_pata_data_entry_single instead?
>> 
>>  "imx_mxc" looks redundant.
> imx is the platform prefix, mxc_pata the device's name. So IMHO the name
> is right and consistent with the other device registration stuff.

From looking at devices-imx51.h, I don't see no obvious consistant
naming scheme :

extern const struct imx_fec_data imx51_fec_data;
...
extern const struct imx_imx_i2c_data imx51_imx_i2c_data[];
...
extern const struct imx_mxc_nand_data imx51_mxc_nand_data;
...
extern const struct imx_spi_imx_data imx51_cspi_data;

So, I can use either imx_pata_data or keep imx_mxc_pata_data or
imx_imx_pata_data or imx_pata_imx_data. What do you both prefer ?

Thanks,
Arnaud
Uwe Kleine-König - July 22, 2011, 9:10 p.m.
On Fri, Jul 22, 2011 at 10:28:49PM +0200, Arnaud Patard wrote:
> Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:
> 
> > On Fri, Jul 22, 2011 at 12:14:15PM -0300, Fabio Estevam wrote:
> >> On Fri, Jul 22, 2011 at 7:37 AM, Arnaud Patard
> >> <arnaud.patard@rtp-net.org> wrote:
> >> ...
> >> > +#define imx_mxc_pata_data_entry_single(soc)                            \
> >> > +       {                                                               \
> >> > +               .iobase = soc ## _ATA_BASE_ADDR,                        \
> >> > +               .irq = soc ## _MXC_INT_ATA,                             \
> >> 
> >> Why not imx_pata_data_entry_single instead?
> >> 
> >>  "imx_mxc" looks redundant.
> > imx is the platform prefix, mxc_pata the device's name. So IMHO the name
> > is right and consistent with the other device registration stuff.
> 
> From looking at devices-imx51.h, I don't see no obvious consistant
> naming scheme :
> 
> extern const struct imx_fec_data imx51_fec_data;
driver name: fec
> ...
> extern const struct imx_imx_i2c_data imx51_imx_i2c_data[];
driver name: imx_i2c
> ...
> extern const struct imx_mxc_nand_data imx51_mxc_nand_data;
driver name: mxc_nand
> ...
> extern const struct imx_spi_imx_data imx51_cspi_data;
driver name: spi_imx

So the driver names are not consistent, ok. But the names used in
devices-imx51.h match these. It's always imx_${drivername}_data.

> So, I can use either imx_pata_data or keep imx_mxc_pata_data or
> imx_imx_pata_data or imx_pata_imx_data. What do you both prefer ?
So if your driver is called "mxc_pata", please use
imx_mxc_pata_data_entry_single.

Best regards
Uwe

Patch

Index: linux-2.6-submit/arch/arm/mach-mx5/devices-imx51.h
===================================================================
--- linux-2.6-submit.orig/arch/arm/mach-mx5/devices-imx51.h	2011-07-16 22:37:43.000000000 +0200
+++ linux-2.6-submit/arch/arm/mach-mx5/devices-imx51.h	2011-07-22 10:20:06.000000000 +0200
@@ -52,3 +52,7 @@  extern const struct imx_mxc_pwm_data imx
 extern const struct imx_imx_keypad_data imx51_imx_keypad_data;
 #define imx51_add_imx_keypad(pdata)	\
 	imx_add_imx_keypad(&imx51_imx_keypad_data, pdata)
+
+extern const struct imx_mxc_pata_data im51_mxc_pata_data;
+#define imx51_add_mxc_pata() \
+	imx_add_mxc_pata(&im51_mxc_pata_data)
Index: linux-2.6-submit/arch/arm/plat-mxc/devices/Kconfig
===================================================================
--- linux-2.6-submit.orig/arch/arm/plat-mxc/devices/Kconfig	2011-07-16 22:37:42.000000000 +0200
+++ linux-2.6-submit/arch/arm/plat-mxc/devices/Kconfig	2011-07-22 10:20:05.000000000 +0200
@@ -31,6 +31,9 @@  config IMX_HAVE_PLATFORM_IMX_I2C
 config IMX_HAVE_PLATFORM_IMX_KEYPAD
 	bool
 
+config IMX_HAVE_PLATFORM_IMX_PATA
+	bool
+
 config IMX_HAVE_PLATFORM_IMX_SSI
 	bool
 
Index: linux-2.6-submit/arch/arm/plat-mxc/devices/Makefile
===================================================================
--- linux-2.6-submit.orig/arch/arm/plat-mxc/devices/Makefile	2011-07-16 22:37:42.000000000 +0200
+++ linux-2.6-submit/arch/arm/plat-mxc/devices/Makefile	2011-07-22 10:20:05.000000000 +0200
@@ -10,6 +10,7 @@  obj-y += platform-imx-dma.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_FB) += platform-imx-fb.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_KEYPAD) += platform-imx-keypad.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_PATA) += platform-imx-pata.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o
Index: linux-2.6-submit/arch/arm/plat-mxc/devices/platform-imx-pata.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6-submit/arch/arm/plat-mxc/devices/platform-imx-pata.c	2011-07-20 22:48:53.000000000 +0200
@@ -0,0 +1,38 @@ 
+/*
+ * 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.
+ */
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx_mxc_pata_data_entry_single(soc)				\
+	{								\
+		.iobase = soc ## _ATA_BASE_ADDR,			\
+		.irq = soc ## _MXC_INT_ATA,				\
+	}
+
+#ifdef CONFIG_SOC_IMX51
+const struct imx_mxc_pata_data im51_mxc_pata_data __initconst =
+	imx_mxc_pata_data_entry_single(MX51);
+#endif /* ifdef CONFIG_SOC_IMX51 */
+
+struct platform_device *__init imx_add_mxc_pata(
+		const struct imx_mxc_pata_data *data)
+{
+	struct resource res[] = {
+		{
+			.start = data->iobase,
+			.end = data->iobase + SZ_16K - 1,
+			.flags = IORESOURCE_MEM,
+		},
+		{
+			.start = data->irq,
+			.end = data->irq,
+			.flags = IORESOURCE_IRQ,
+		},
+	};
+	return imx_add_platform_device("pata_imx", -1,
+			res, ARRAY_SIZE(res), NULL, 0);
+}
+
Index: linux-2.6-submit/arch/arm/plat-mxc/include/mach/devices-common.h
===================================================================
--- linux-2.6-submit.orig/arch/arm/plat-mxc/include/mach/devices-common.h	2011-07-16 22:37:43.000000000 +0200
+++ linux-2.6-submit/arch/arm/plat-mxc/include/mach/devices-common.h	2011-07-22 10:20:06.000000000 +0200
@@ -250,6 +250,13 @@  struct platform_device *__init imx_add_m
 		const struct imx_mxc_nand_data *data,
 		const struct mxc_nand_platform_data *pdata);
 
+struct imx_mxc_pata_data {
+	resource_size_t iobase;
+	resource_size_t irq;
+};
+struct platform_device *__init imx_add_mxc_pata(
+		const struct imx_mxc_pata_data *data);
+
 struct imx_mxc_pwm_data {
 	int id;
 	resource_size_t iobase;