linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ryan@bluewatersys.com (Ryan Mallon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 04/23] at91: Make UDC device common
Date: Fri, 29 Apr 2011 14:59:13 +1200	[thread overview]
Message-ID: <1304045972-19319-5-git-send-email-ryan@bluewatersys.com> (raw)
In-Reply-To: <1304045972-19319-1-git-send-email-ryan@bluewatersys.com>

Replace the individual UDC device code for each at91 variant with a
single implementation in devices.c

Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>
---
 arch/arm/mach-at91/at572d940hf_devices.c |   48 ++-------------------------
 arch/arm/mach-at91/at91rm9200_devices.c  |   48 ++-------------------------
 arch/arm/mach-at91/at91sam9260_devices.c |   48 ++-------------------------
 arch/arm/mach-at91/at91sam9261_devices.c |   47 ++------------------------
 arch/arm/mach-at91/at91sam9263_devices.c |   48 ++-------------------------
 arch/arm/mach-at91/devices.c             |   52 ++++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |    1 +
 7 files changed, 73 insertions(+), 219 deletions(-)

diff --git a/arch/arm/mach-at91/at572d940hf_devices.c b/arch/arm/mach-at91/at572d940hf_devices.c
index 07aff96..da27bdb 100644
--- a/arch/arm/mach-at91/at572d940hf_devices.c
+++ b/arch/arm/mach-at91/at572d940hf_devices.c
@@ -51,52 +51,11 @@ static struct at91_dev_table_usb_ohci device_usbh_ohci __initdata = {
  *  USB Device (Gadget)
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_USB_GADGET_AT91
-static struct at91_udc_data udc_data;
-
-static struct resource udc_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_UDP,
-		.end	= AT572D940HF_BASE_UDP + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_UDP,
-		.end	= AT572D940HF_ID_UDP,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at572d940hf_udc_device = {
-	.name		= "at91_udc",
-	.id		= -1,
-	.dev		= {
-				.platform_data		= &udc_data,
-	},
-	.resource	= udc_resources,
-	.num_resources	= ARRAY_SIZE(udc_resources),
+static struct at91_dev_table_basic_device device_udc __initdata = {
+	.mmio_base	= AT572D940HF_BASE_UDP,
+	.irq		= AT572D940HF_ID_UDP,
 };
 
-void __init at91_add_device_udc(struct at91_udc_data *data)
-{
-	if (!data)
-		return;
-
-	if (data->vbus_pin) {
-		at91_set_gpio_input(data->vbus_pin, 0);
-		at91_set_deglitch(data->vbus_pin, 1);
-	}
-
-	/* Pullup pin is handled internally */
-
-	udc_data = *data;
-	platform_device_register(&at572d940hf_udc_device);
-}
-#else
-void __init at91_add_device_udc(struct at91_udc_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  Ethernet
  * -------------------------------------------------------------------- */
@@ -876,6 +835,7 @@ void __init at91_add_device_mAgic(void) {}
 static struct at91_device_table at572d940hf_device_table __initdata = {
 	.ethernet	= &device_eth,
 	.usbh_ohci	= &device_usbh_ohci,
+	.udc		= &device_udc,
 };
 
 void __init at572d940hf_init_devices(void)
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index e6fa6a4..09e771c 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -38,52 +38,11 @@ static struct at91_dev_table_usb_ohci device_usbh_ohci __initdata = {
  *  USB Device (Gadget)
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_USB_GADGET_AT91
-static struct at91_udc_data udc_data;
-
-static struct resource udc_resources[] = {
-	[0] = {
-		.start	= AT91RM9200_BASE_UDP,
-		.end	= AT91RM9200_BASE_UDP + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91RM9200_ID_UDP,
-		.end	= AT91RM9200_ID_UDP,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at91rm9200_udc_device = {
-	.name		= "at91_udc",
-	.id		= -1,
-	.dev		= {
-				.platform_data		= &udc_data,
-	},
-	.resource	= udc_resources,
-	.num_resources	= ARRAY_SIZE(udc_resources),
+static struct at91_dev_table_basic_device device_udc __initdata = {
+	.mmio_base	= AT91RM9200_BASE_UDP,
+	.irq		= AT91RM9200_ID_UDP,
 };
 
-void __init at91_add_device_udc(struct at91_udc_data *data)
-{
-	if (!data)
-		return;
-
-	if (data->vbus_pin) {
-		at91_set_gpio_input(data->vbus_pin, 0);
-		at91_set_deglitch(data->vbus_pin, 1);
-	}
-	if (data->pullup_pin)
-		at91_set_gpio_output(data->pullup_pin, 0);
-
-	udc_data = *data;
-	platform_device_register(&at91rm9200_udc_device);
-}
-#else
-void __init at91_add_device_udc(struct at91_udc_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  Ethernet
  * -------------------------------------------------------------------- */
@@ -1099,6 +1058,7 @@ void __init at91_add_device_serial(void) {}
 static struct at91_device_table at91rm9200_device_table __initdata = {
 	.ethernet	= &device_eth,
 	.usbh_ohci	= &device_usbh_ohci,
+	.udc		= &device_udc,
 };
 
 void __init at91rm9200_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 03848b8..16ec548 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -39,52 +39,11 @@ static struct at91_dev_table_usb_ohci device_usbh_ohci __initdata = {
  *  USB Device (Gadget)
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_USB_GADGET_AT91
-static struct at91_udc_data udc_data;
-
-static struct resource udc_resources[] = {
-	[0] = {
-		.start	= AT91SAM9260_BASE_UDP,
-		.end	= AT91SAM9260_BASE_UDP + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91SAM9260_ID_UDP,
-		.end	= AT91SAM9260_ID_UDP,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at91_udc_device = {
-	.name		= "at91_udc",
-	.id		= -1,
-	.dev		= {
-				.platform_data		= &udc_data,
-	},
-	.resource	= udc_resources,
-	.num_resources	= ARRAY_SIZE(udc_resources),
+static struct at91_dev_table_basic_device device_udc __initdata = {
+	.mmio_base	= AT91SAM9260_BASE_UDP,
+	.irq		= AT91SAM9260_ID_UDP,
 };
 
-void __init at91_add_device_udc(struct at91_udc_data *data)
-{
-	if (!data)
-		return;
-
-	if (data->vbus_pin) {
-		at91_set_gpio_input(data->vbus_pin, 0);
-		at91_set_deglitch(data->vbus_pin, 1);
-	}
-
-	/* Pullup pin is handled internally by USB device peripheral */
-
-	udc_data = *data;
-	platform_device_register(&at91_udc_device);
-}
-#else
-void __init at91_add_device_udc(struct at91_udc_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  Ethernet
  * -------------------------------------------------------------------- */
@@ -1255,6 +1214,7 @@ void __init at91_add_device_cf(struct at91_cf_data * data) {}
 static struct at91_device_table at91sam9260_device_table __initdata = {
 	.ethernet	= &device_eth,
 	.usbh_ohci	= &device_usbh_ohci,
+	.udc		= &device_udc,
 };
 
 void __init at91sam9260_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index c7c2403..8fe0fd3 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -42,51 +42,11 @@ static struct at91_dev_table_usb_ohci device_usbh_ohci __initdata = {
  *  USB Device (Gadget)
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_USB_GADGET_AT91
-static struct at91_udc_data udc_data;
-
-static struct resource udc_resources[] = {
-	[0] = {
-		.start	= AT91SAM9261_BASE_UDP,
-		.end	= AT91SAM9261_BASE_UDP + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91SAM9261_ID_UDP,
-		.end	= AT91SAM9261_ID_UDP,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at91sam9261_udc_device = {
-	.name		= "at91_udc",
-	.id		= -1,
-	.dev		= {
-				.platform_data		= &udc_data,
-	},
-	.resource	= udc_resources,
-	.num_resources	= ARRAY_SIZE(udc_resources),
+static struct at91_dev_table_basic_device device_udc __initdata = {
+	.mmio_base	= AT91SAM9261_BASE_UDP,
+	.irq		= AT91SAM9261_ID_UDP,
 };
 
-void __init at91_add_device_udc(struct at91_udc_data *data)
-{
-	if (!data)
-		return;
-
-	if (data->vbus_pin) {
-		at91_set_gpio_input(data->vbus_pin, 0);
-		at91_set_deglitch(data->vbus_pin, 1);
-	}
-
-	/* Pullup pin is handled internally by USB device peripheral */
-
-	udc_data = *data;
-	platform_device_register(&at91sam9261_udc_device);
-}
-#else
-void __init at91_add_device_udc(struct at91_udc_data *data) {}
-#endif
-
 /* --------------------------------------------------------------------
  *  MMC / SD
  * -------------------------------------------------------------------- */
@@ -1009,6 +969,7 @@ void __init at91_add_device_serial(void) {}
 
 static struct at91_device_table at91sam9261_device_table __initdata = {
 	.usbh_ohci	= &device_usbh_ohci,
+	.udc		= &device_udc,
 };
 
 void __init at91sam9261_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 9252c48..2f9b0d2 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -42,52 +42,11 @@ static struct at91_dev_table_usb_ohci device_usbh_ohci __initdata = {
  *  USB Device (Gadget)
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_USB_GADGET_AT91
-static struct at91_udc_data udc_data;
-
-static struct resource udc_resources[] = {
-	[0] = {
-		.start	= AT91SAM9263_BASE_UDP,
-		.end	= AT91SAM9263_BASE_UDP + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91SAM9263_ID_UDP,
-		.end	= AT91SAM9263_ID_UDP,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at91_udc_device = {
-	.name		= "at91_udc",
-	.id		= -1,
-	.dev		= {
-				.platform_data		= &udc_data,
-	},
-	.resource	= udc_resources,
-	.num_resources	= ARRAY_SIZE(udc_resources),
+static struct at91_dev_table_basic_device device_udc __initdata = {
+	.mmio_base	= AT91SAM9263_BASE_UDP,
+	.irq		= AT91SAM9263_ID_UDP,
 };
 
-void __init at91_add_device_udc(struct at91_udc_data *data)
-{
-	if (!data)
-		return;
-
-	if (data->vbus_pin) {
-		at91_set_gpio_input(data->vbus_pin, 0);
-		at91_set_deglitch(data->vbus_pin, 1);
-	}
-
-	/* Pullup pin is handled internally by USB device peripheral */
-
-	udc_data = *data;
-	platform_device_register(&at91_udc_device);
-}
-#else
-void __init at91_add_device_udc(struct at91_udc_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  Ethernet
  * -------------------------------------------------------------------- */
@@ -1347,6 +1306,7 @@ void __init at91_add_device_serial(void) {}
 static struct at91_device_table at91sam9263_device_table __initdata = {
 	.ethernet	= &device_eth,
 	.usbh_ohci	= &device_usbh_ohci,
+	.udc		= &device_udc,
 };
 
 void __init at91sam9263_init_devices(void)
diff --git a/arch/arm/mach-at91/devices.c b/arch/arm/mach-at91/devices.c
index 4ad81a8..c138367 100644
--- a/arch/arm/mach-at91/devices.c
+++ b/arch/arm/mach-at91/devices.c
@@ -185,6 +185,58 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) {}
 #endif
 
 /* --------------------------------------------------------------------
+ *  USB Device (Gadget)
+ * -------------------------------------------------------------------- */
+#ifdef CONFIG_USB_GADGET_AT91
+
+static struct at91_udc_data udc_data;
+
+static struct resource udc_resources[] = {
+	[0] = {
+		.end	= SZ_16K,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device at91_udc_device = {
+	.name		= "at91_udc",
+	.id		= -1,
+	.dev		= {
+				.platform_data		= &udc_data,
+	},
+	.resource	= udc_resources,
+	.num_resources	= ARRAY_SIZE(udc_resources),
+};
+
+void __init at91_add_device_udc(struct at91_udc_data *data)
+{
+	struct at91_dev_table_basic_device *info = devices->udc;
+
+	BUG_ON(!info);
+	init_resource_mem(&udc_resources[0], info->mmio_base);
+	init_resource_irq(&udc_resources[1], info->irq);
+
+	if (!data)
+		return;
+
+	if (data->vbus_pin) {
+		at91_set_gpio_input(data->vbus_pin, 0);
+		at91_set_deglitch(data->vbus_pin, 1);
+	}
+	if (data->pullup_pin)
+		at91_set_gpio_output(data->pullup_pin, 0);
+
+	udc_data = *data;
+	platform_device_register(&at91_udc_device);
+}
+#else
+void __init at91_add_device_udc(struct at91_udc_data *data) {}
+#endif
+
+/* --------------------------------------------------------------------
  *  Ethernet
  * -------------------------------------------------------------------- */
 
diff --git a/arch/arm/mach-at91/devices.h b/arch/arm/mach-at91/devices.h
index eb4de05..9203f58 100644
--- a/arch/arm/mach-at91/devices.h
+++ b/arch/arm/mach-at91/devices.h
@@ -52,6 +52,7 @@ struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
 	struct at91_dev_table_basic_device	*usbh_ehci;
+	struct at91_dev_table_basic_device	*udc;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
-- 
1.7.0.4

  parent reply	other threads:[~2011-04-29  2:59 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-29  2:59 [PATCH v3 00/23] Create common framework for AT91 device initialisation Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 01/23] at91: Add common devices framework Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 02/23] at91: Make Ethernet device common Ryan Mallon
2011-04-29  9:08   ` Russell King - ARM Linux
2011-04-29  9:38     ` Ryan Mallon
2011-04-29  9:54       ` Russell King - ARM Linux
2011-04-29  2:59 ` [PATCH v3 03/23] at91: Make USB OHCI/EHCI devices common Ryan Mallon
2011-04-29  2:59 ` Ryan Mallon [this message]
2011-04-29  2:59 ` [PATCH v3 05/23] at91: Make MMC device common Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 06/23] at91: Make NAND " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 07/23] at91: Make TWI " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 08/23] at91: Make SPI " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 09/23] at91: Make TCB " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 10/23] at91: Make RTT " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 11/23] at91: Make watchdog " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 12/23] at91: Make UART devices common Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 13/23] at91: Make PWM device common Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 14/23] at91: Make SSC " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 15/23] at91: Make AC97 " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 16/23] at91: Make LCD controller " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 17/23] at91: Make touchscreen " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 18/23] at91: Make HDMAC " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 19/23] at91: Make RTC " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 20/23] at91: Make high speed USB gadget " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 21/23] at91: Make compact flash " Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 22/23] at91: Move at91sam9263 CAN device to common devices Ryan Mallon
2011-04-29  2:59 ` [PATCH v3 23/23] at91: Remove mAgic and ISI device code Ryan Mallon
2011-04-29 18:04 ` [PATCH v3 00/23] Create common framework for AT91 device initialisation H Hartley Sweeten
2011-04-29 20:14   ` Ryan Mallon
2011-05-02 19:46     ` Jean-Christophe PLAGNIOL-VILLARD

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=1304045972-19319-5-git-send-email-ryan@bluewatersys.com \
    --to=ryan@bluewatersys.com \
    --cc=linux-arm-kernel@lists.infradead.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).