From: ryan@bluewatersys.com (Ryan Mallon)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 15/23] at91: Make AC97 device common
Date: Wed, 20 Apr 2011 13:10:19 +1200 [thread overview]
Message-ID: <1303261827-27730-17-git-send-email-ryan@bluewatersys.com> (raw)
In-Reply-To: <1303261827-27730-1-git-send-email-ryan@bluewatersys.com>
Replace the individual AC97 code for each at91 variant with a single
implementation in devices.c
Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>
---
arch/arm/mach-at91/at91cap9_devices.c | 57 +++++-------------------------
arch/arm/mach-at91/at91sam9263_devices.c | 56 +++++------------------------
arch/arm/mach-at91/at91sam9g45_devices.c | 57 +++++-------------------------
arch/arm/mach-at91/at91sam9rl_devices.c | 57 +++++-------------------------
arch/arm/mach-at91/devices.c | 54 ++++++++++++++++++++++++++++
arch/arm/mach-at91/devices.h | 7 ++++
6 files changed, 97 insertions(+), 191 deletions(-)
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index 8fb598b..ae8e118 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -317,57 +317,17 @@ static struct __initdata at91_dev_table_pwm device_pwm = {
* AC97
* -------------------------------------------------------------------- */
-#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
-static u64 ac97_dmamask = DMA_BIT_MASK(32);
-static struct ac97c_platform_data ac97_data;
-
-static struct resource ac97_resources[] = {
- [0] = {
- .start = AT91CAP9_BASE_AC97C,
- .end = AT91CAP9_BASE_AC97C + SZ_16K - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91CAP9_ID_AC97C,
- .end = AT91CAP9_ID_AC97C,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device at91cap9_ac97_device = {
- .name = "atmel_ac97c",
- .id = 1,
- .dev = {
- .dma_mask = &ac97_dmamask,
- .coherent_dma_mask = DMA_BIT_MASK(32),
- .platform_data = &ac97_data,
+static struct __initdata at91_dev_table_ac97 device_ac97 = {
+ .mmio_base = AT91CAP9_BASE_AC97C,
+ .irq = AT91CAP9_ID_AC97C,
+ .pins = {
+ {AT91_PIN_PA6, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97FS */
+ {AT91_PIN_PA7, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97CK */
+ {AT91_PIN_PA8, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97TX */
+ {AT91_PIN_PA9, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97RX */
},
- .resource = ac97_resources,
- .num_resources = ARRAY_SIZE(ac97_resources),
};
-void __init at91_add_device_ac97(struct ac97c_platform_data *data)
-{
- if (!data)
- return;
-
- at91_set_A_periph(AT91_PIN_PA6, 0); /* AC97FS */
- at91_set_A_periph(AT91_PIN_PA7, 0); /* AC97CK */
- at91_set_A_periph(AT91_PIN_PA8, 0); /* AC97TX */
- at91_set_A_periph(AT91_PIN_PA9, 0); /* AC97RX */
-
- /* reset */
- if (data->reset_pin)
- at91_set_gpio_output(data->reset_pin, 0);
-
- ac97_data = *data;
- platform_device_register(&at91cap9_ac97_device);
-}
-#else
-void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* LCD Controller
* -------------------------------------------------------------------- */
@@ -547,6 +507,7 @@ static struct at91_device_table __initdata at91cap9_device_table = {
.pwm = &device_pwm,
.ssc[0] = &device_ssc0,
.ssc[1] = &device_ssc1,
+ .ac97 = &device_ac97,
};
void __init at91cap9_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 3ff223c..6155a9f 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -299,56 +299,17 @@ static struct __initdata at91_dev_table_spi device_spi1 = {
* AC97
* -------------------------------------------------------------------- */
-#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
-static u64 ac97_dmamask = DMA_BIT_MASK(32);
-static struct ac97c_platform_data ac97_data;
-
-static struct resource ac97_resources[] = {
- [0] = {
- .start = AT91SAM9263_BASE_AC97C,
- .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91SAM9263_ID_AC97C,
- .end = AT91SAM9263_ID_AC97C,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device at91sam9263_ac97_device = {
- .name = "atmel_ac97c",
- .id = 0,
- .dev = {
- .dma_mask = &ac97_dmamask,
- .coherent_dma_mask = DMA_BIT_MASK(32),
- .platform_data = &ac97_data,
+static struct __initdata at91_dev_table_ac97 device_ac97 = {
+ .mmio_base = AT91SAM9263_BASE_AC97C,
+ .irq = AT91SAM9263_ID_AC97C,
+ .pins = {
+ {AT91_PIN_PB0, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97FS */
+ {AT91_PIN_PB1, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97CK */
+ {AT91_PIN_PB2, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97TX */
+ {AT91_PIN_PB3, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97RX */
},
- .resource = ac97_resources,
- .num_resources = ARRAY_SIZE(ac97_resources),
};
-void __init at91_add_device_ac97(struct ac97c_platform_data *data)
-{
- if (!data)
- return;
-
- at91_set_A_periph(AT91_PIN_PB0, 0); /* AC97FS */
- at91_set_A_periph(AT91_PIN_PB1, 0); /* AC97CK */
- at91_set_A_periph(AT91_PIN_PB2, 0); /* AC97TX */
- at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */
-
- /* reset */
- if (data->reset_pin)
- at91_set_gpio_output(data->reset_pin, 0);
-
- ac97_data = *data;
- platform_device_register(&at91sam9263_ac97_device);
-}
-#else
-void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
-#endif
-
/* --------------------------------------------------------------------
* CAN Controller
* -------------------------------------------------------------------- */
@@ -656,6 +617,7 @@ static struct at91_device_table __initdata at91sam9263_device_table = {
.pwm = &device_pwm,
.ssc[0] = &device_ssc0,
.ssc[1] = &device_ssc1,
+ .ac97 = &device_ac97,
};
void __init at91sam9263_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index fcfb1ca..3f71e45 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -331,57 +331,17 @@ static struct __initdata at91_dev_table_spi device_spi1 = {
* AC97
* -------------------------------------------------------------------- */
-#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
-static u64 ac97_dmamask = DMA_BIT_MASK(32);
-static struct ac97c_platform_data ac97_data;
-
-static struct resource ac97_resources[] = {
- [0] = {
- .start = AT91SAM9G45_BASE_AC97C,
- .end = AT91SAM9G45_BASE_AC97C + SZ_16K - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91SAM9G45_ID_AC97C,
- .end = AT91SAM9G45_ID_AC97C,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device at91sam9g45_ac97_device = {
- .name = "atmel_ac97c",
- .id = 0,
- .dev = {
- .dma_mask = &ac97_dmamask,
- .coherent_dma_mask = DMA_BIT_MASK(32),
- .platform_data = &ac97_data,
+static struct __initdata at91_dev_table_ac97 device_ac97 = {
+ .mmio_base = AT91SAM9G45_BASE_AC97C,
+ .irq = AT91SAM9G45_ID_AC97C,
+ .pins = {
+ {AT91_PIN_PD8, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97FS */
+ {AT91_PIN_PD9, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97CK */
+ {AT91_PIN_PD7, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97TX */
+ {AT91_PIN_PD6, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97RX */
},
- .resource = ac97_resources,
- .num_resources = ARRAY_SIZE(ac97_resources),
};
-void __init at91_add_device_ac97(struct ac97c_platform_data *data)
-{
- if (!data)
- return;
-
- at91_set_A_periph(AT91_PIN_PD8, 0); /* AC97FS */
- at91_set_A_periph(AT91_PIN_PD9, 0); /* AC97CK */
- at91_set_A_periph(AT91_PIN_PD7, 0); /* AC97TX */
- at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */
-
- /* reset */
- if (data->reset_pin)
- at91_set_gpio_output(data->reset_pin, 0);
-
- ac97_data = *data;
- platform_device_register(&at91sam9g45_ac97_device);
-}
-#else
-void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* LCD Controller
* -------------------------------------------------------------------- */
@@ -705,6 +665,7 @@ static struct at91_device_table __initdata at91sam9g45_device_table = {
.pwm = &device_pwm,
.ssc[0] = &device_ssc0,
.ssc[1] = &device_ssc1,
+ .ac97 = &device_ac97,
};
void __init at91sam9g45_init_devices(void)
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 606d790..3b6010b 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -227,57 +227,17 @@ static struct __initdata at91_dev_table_spi device_spi = {
* AC97
* -------------------------------------------------------------------- */
-#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
-static u64 ac97_dmamask = DMA_BIT_MASK(32);
-static struct ac97c_platform_data ac97_data;
-
-static struct resource ac97_resources[] = {
- [0] = {
- .start = AT91SAM9RL_BASE_AC97C,
- .end = AT91SAM9RL_BASE_AC97C + SZ_16K - 1,
- .flags = IORESOURCE_MEM,
- },
- [1] = {
- .start = AT91SAM9RL_ID_AC97C,
- .end = AT91SAM9RL_ID_AC97C,
- .flags = IORESOURCE_IRQ,
- },
-};
-
-static struct platform_device at91sam9rl_ac97_device = {
- .name = "atmel_ac97c",
- .id = 0,
- .dev = {
- .dma_mask = &ac97_dmamask,
- .coherent_dma_mask = DMA_BIT_MASK(32),
- .platform_data = &ac97_data,
+static struct __initdata at91_dev_table_ac97 device_ac97 = {
+ .mmio_base = AT91SAM9RL_BASE_AC97C,
+ .irq = AT91SAM9RL_ID_AC97C,
+ .pins = {
+ {AT91_PIN_PD1, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97FS */
+ {AT91_PIN_PD2, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97CK */
+ {AT91_PIN_PD3, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97TX */
+ {AT91_PIN_PD4, AT91_PIN_PERIPH_A, 0, 0, 0}, /* AC97RX */
},
- .resource = ac97_resources,
- .num_resources = ARRAY_SIZE(ac97_resources),
};
-void __init at91_add_device_ac97(struct ac97c_platform_data *data)
-{
- if (!data)
- return;
-
- at91_set_A_periph(AT91_PIN_PD1, 0); /* AC97FS */
- at91_set_A_periph(AT91_PIN_PD2, 0); /* AC97CK */
- at91_set_A_periph(AT91_PIN_PD3, 0); /* AC97TX */
- at91_set_A_periph(AT91_PIN_PD4, 0); /* AC97RX */
-
- /* reset */
- if (data->reset_pin)
- at91_set_gpio_output(data->reset_pin, 0);
-
- ac97_data = *data;
- platform_device_register(&at91sam9rl_ac97_device);
-}
-#else
-void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
-#endif
-
-
/* --------------------------------------------------------------------
* LCD Controller
* -------------------------------------------------------------------- */
@@ -580,6 +540,7 @@ static struct at91_device_table __initdata at91sam9rl_device_table = {
.pwm = &device_pwm,
.ssc[0] = &device_ssc0,
.ssc[1] = &device_ssc1,
+ .ac97 = &device_ac97,
};
void __init at91sam9rl_init_devices(void)
diff --git a/arch/arm/mach-at91/devices.c b/arch/arm/mach-at91/devices.c
index 2cab70b..86f0640 100644
--- a/arch/arm/mach-at91/devices.c
+++ b/arch/arm/mach-at91/devices.c
@@ -1525,6 +1525,60 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins)
void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
#endif
+/* --------------------------------------------------------------------
+ * AC97
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
+static u64 ac97_dmamask = DMA_BIT_MASK(32);
+static struct ac97c_platform_data ac97_data;
+
+static struct resource ac97_resources[] = {
+ [0] = {
+ .end = SZ_16K,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static struct platform_device at91_ac97_device = {
+ .name = "atmel_ac97c",
+ .id = 0,
+ .dev = {
+ .dma_mask = &ac97_dmamask,
+ .coherent_dma_mask = DMA_BIT_MASK(32),
+ .platform_data = &ac97_data,
+ },
+ .resource = ac97_resources,
+ .num_resources = ARRAY_SIZE(ac97_resources),
+};
+
+void __init at91_add_device_ac97(struct ac97c_platform_data *data)
+{
+ struct at91_dev_table_ac97 *info = devices->ac97;
+
+ BUG_ON(!info);
+ init_resource_mem(&ac97_resources[0], info->mmio_base);
+ init_resource_irq(&ac97_resources[0], info->irq);
+
+ if (!data)
+ return;
+
+ at91_config_pins(info->pins, ARRAY_SIZE(info->pins));
+
+ /* reset */
+ if (data->reset_pin)
+ at91_set_gpio_output(data->reset_pin, 0);
+
+ ac97_data = *data;
+ platform_device_register(&at91sam9g45_ac97_device);
+}
+#else
+void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
+#endif
+
static int __init at91_add_standard_devices(void)
{
at91_add_device_tc();
diff --git a/arch/arm/mach-at91/devices.h b/arch/arm/mach-at91/devices.h
index 177fc3d..3d6ca83 100644
--- a/arch/arm/mach-at91/devices.h
+++ b/arch/arm/mach-at91/devices.h
@@ -141,6 +141,12 @@ struct at91_dev_table_ssc {
struct at91_pin_config rk_pin;
};
+struct at91_dev_table_ac97 {
+ unsigned mmio_base;
+ int irq;
+ struct at91_pin_config pins[4]; /* FS, CK, TX, RX */
+};
+
struct at91_device_table {
struct at91_dev_table_ethernet *ethernet;
struct at91_dev_table_usb_ohci *usbh_ohci;
@@ -156,6 +162,7 @@ struct at91_device_table {
struct at91_dev_table_uart *uart[6];
struct at91_dev_table_pwm *pwm;
struct at91_dev_table_ssc *ssc[4];
+ struct at91_dev_table_ac97 *ac97;
};
extern void __init at91_init_devices(struct at91_device_table *device_table);
--
1.7.0.4
next prev parent reply other threads:[~2011-04-20 1:10 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 1:10 [RFC PATCH 00/23] at91: Replace duplicate device initialisation code with common code Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 01/23] at91: Add common devices framework Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 02/23] at91: Make Ethernet device common Ryan Mallon
2011-04-20 2:10 ` H Hartley Sweeten
2011-04-20 2:33 ` Ryan Mallon
2011-04-20 18:23 ` H Hartley Sweeten
2011-04-20 8:36 ` Uwe Kleine-König
2011-04-20 10:34 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-20 11:07 ` Ryan Mallon
2011-04-20 20:41 ` Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 03/23] at91: Make USB OHCI/EHCI devices common Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 04/23] at91: Make UDC device common Ryan Mallon
2011-04-20 1:10 ` [PATCH 05/23] at91: Make MMC device (at91_mci) common Ryan Mallon
2011-04-20 1:12 ` Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 05/23] at91: Make MMC device common Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 06/23] at91: Make NAND " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 07/23] at91: Make TWI " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 08/23] at91: Make SPI " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 09/23] at91: Make TCB " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 10/23] at91: Make RTT " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 11/23] at91: Make watchdog " Ryan Mallon
2011-04-20 17:10 ` H Hartley Sweeten
2011-04-20 1:10 ` [RFC PATCH 13/23] at91: Make PWM " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 14/23] at91: Make SSC " Ryan Mallon
2011-04-20 1:10 ` Ryan Mallon [this message]
2011-04-20 1:10 ` [RFC PATCH 16/23] at91: Make LCD controller " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 17/23] at91: Make touchscreen " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 18/23] at91: Make HDMAC " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 19/23] at91: Make RTC " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 20/23] at91: Make high speed USB gadget " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 21/23] at91: Make compact flash " Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 22/23] at91: Move at91sam9263 CAN device to common devices Ryan Mallon
2011-04-20 1:10 ` [RFC PATCH 23/23] at91: Remove mAgic and ISI device code Ryan Mallon
2011-04-20 1:11 ` [RFC PATCH 12/23] at91: Make UART devices common Ryan Mallon
2011-04-20 3:47 ` [RFC PATCH 00/23] at91: Replace duplicate device initialisation code with common code Jean-Christophe PLAGNIOL-VILLARD
2011-04-20 3:58 ` Ryan Mallon
2011-04-20 4:03 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-20 17:14 ` H Hartley Sweeten
2011-04-20 21:07 ` Ryan Mallon
2011-04-21 0:56 ` Detlef Vollmann
2011-04-21 1:04 ` Ryan Mallon
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=1303261827-27730-17-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).