Skip to contentSkip to conversation

Create common framework for AT91 device initialisation

PATCH Superseded Ryan Mallon 4 participants 30 messages Apr 29, 2011 – May 2, 2011

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Create common framework for AT91 device initialisation

Each AT91 variant (AT91RM9200, AT91SAM9260, etc) currently has its own devices file, which includes the MMIO address, interrupt configuration, GPIO setup, etc for each device. This results in a large amount of duplicated code.

This patch set introduces a framework for adding shared devices for the AT91 platform and replaces the multiple device setup implementations for each device with single implementations in the new framework. This has a net reduction of nearly 5000 lines of code.

Each of the arch/arm/mach-at91/*_devices.c files becomes a collection of structures (with some initialisation callbacks where necessary) with a table of devices which are present on the particular AT91 variant. All structures/functions are marked as __init/__initdata so there is little additional memory overhead. This also means that the #ifdefs around each device can be removed from the *_devices.c files (but remain in the new common devices.c file) without overhead.

This patch series does not introduce any functional changes to how the board files add devices, it only replaces the duplicate device initialisation code with common versions. The patch series attempts to have minimum change by rewriting as little as possible of the actual device initialisation functions.

This is also a step towards allowing more than one AT91 variant to be built into a single kernel by removing duplicate function names across the *_devices.c files.

I have build tested the patch series for all of the AT91 variants and devices, and have boot tested it on the AT91SAM9G20 (Snapper 9G20 board) and tested basic device functionality.

Changes from v1:
- Moved __initdata to the end of lines
- Fixed at572d940hf EMAC MMIO base
- Fixed some whitespace issues

Changes from v2:
- Renamed UART identifiers from AT91_ID_USx to AT91_UART_USx. The AT91_UARTx names are already in use. See patch 12 for more details.
- Removed some left over debugging.

Ryan Mallon (23):
at91: Add common devices framework
at91: Make Ethernet device common
at91: Make USB OHCI/EHCI devices common
at91: Make UDC device common
at91: Make MMC device common
at91: Make NAND device common
at91: Make TWI device common
at91: Make SPI device common
at91: Make TCB device common
at91: Make RTT device common
at91: Make watchdog device common
at91: Make UART devices common
at91: Make PWM device common
at91: Make SSC device common
at91: Make AC97 device common
at91: Make LCD controller device common
at91: Make touchscreen device common
at91: Make HDMAC device common
at91: Make RTC device common
at91: Make high speed USB gadget device common
at91: Make compact flash device common
at91: Move at91sam9263 CAN device to common devices
at91: Remove mAgic and ISI device code

 arch/arm/mach-at91/Makefile               |    2 +-
 arch/arm/mach-at91/at572d940hf.c          |    4 +
 arch/arm/mach-at91/at572d940hf_devices.c  | 1022 +++-------------
 arch/arm/mach-at91/at91cap9.c             |    4 +
 arch/arm/mach-at91/at91cap9_devices.c     | 1411 ++++----------------
 arch/arm/mach-at91/at91rm9200.c           |    4 +
 arch/arm/mach-at91/at91rm9200_devices.c   | 1321 ++++---------------
 arch/arm/mach-at91/at91sam9260.c          |    4 +
 arch/arm/mach-at91/at91sam9260_devices.c  | 1471 ++++-----------------
 arch/arm/mach-at91/at91sam9261.c          |    4 +
 arch/arm/mach-at91/at91sam9261_devices.c  | 1172 ++++--------------
 arch/arm/mach-at91/at91sam9263.c          |    4 +
 arch/arm/mach-at91/at91sam9263_devices.c  | 1589 +++++------------------
 arch/arm/mach-at91/at91sam9g45.c          |    4 +
 arch/arm/mach-at91/at91sam9g45_devices.c  | 1779 +++++---------------------
 arch/arm/mach-at91/at91sam9rl.c           |    4 +
 arch/arm/mach-at91/at91sam9rl_devices.c   | 1332 ++++----------------
 arch/arm/mach-at91/board-1arm.c           |    6 +-
 arch/arm/mach-at91/board-afeb-9260v1.c    |   10 +-
 arch/arm/mach-at91/board-at572d940hf_ek.c |   12 +-
 arch/arm/mach-at91/board-cam60.c          |    2 +-
 arch/arm/mach-at91/board-cap9adk.c        |    4 +-
 arch/arm/mach-at91/board-carmeva.c        |    6 +-
 arch/arm/mach-at91/board-cpu9krea.c       |   16 +-
 arch/arm/mach-at91/board-cpuat91.c        |   12 +-
 arch/arm/mach-at91/board-csb337.c         |    4 +-
 arch/arm/mach-at91/board-csb637.c         |    4 +-
 arch/arm/mach-at91/board-eb9200.c         |    8 +-
 arch/arm/mach-at91/board-ecbat91.c        |    6 +-
 arch/arm/mach-at91/board-eco920.c         |    2 +-
 arch/arm/mach-at91/board-flexibity.c      |    2 +-
 arch/arm/mach-at91/board-foxg20.c         |   16 +-
 arch/arm/mach-at91/board-gsia18s.c        |   14 +-
 arch/arm/mach-at91/board-kafa.c           |    6 +-
 arch/arm/mach-at91/board-kb9202.c         |   10 +-
 arch/arm/mach-at91/board-neocore926.c     |    6 +-
 arch/arm/mach-at91/board-pcontrol-g20.c   |   10 +-
 arch/arm/mach-at91/board-picotux200.c     |    6 +-
 arch/arm/mach-at91/board-qil-a9260.c      |   10 +-
 arch/arm/mach-at91/board-rm9200dk.c       |    6 +-
 arch/arm/mach-at91/board-rm9200ek.c       |    6 +-
 arch/arm/mach-at91/board-sam9-l9260.c     |    8 +-
 arch/arm/mach-at91/board-sam9260ek.c      |   10 +-
 arch/arm/mach-at91/board-sam9261ek.c      |    6 +-
 arch/arm/mach-at91/board-sam9263ek.c      |    6 +-
 arch/arm/mach-at91/board-sam9g20ek.c      |   10 +-
 arch/arm/mach-at91/board-sam9m10g45ek.c   |    2 +-
 arch/arm/mach-at91/board-sam9rlek.c       |    4 +-
 arch/arm/mach-at91/board-snapper9260.c    |   14 +-
 arch/arm/mach-at91/board-stamp9g20.c      |   20 +-
 arch/arm/mach-at91/board-usb-a9260.c      |    4 +-
 arch/arm/mach-at91/board-usb-a9263.c      |    4 +-
 arch/arm/mach-at91/board-yl-9200.c        |   10 +-
 arch/arm/mach-at91/devices.c              | 1999 +++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h              |  237 ++++
 arch/arm/mach-at91/include/mach/board.h   |   21 +-
 56 files changed, 4480 insertions(+), 9190 deletions(-)
 create mode 100644 arch/arm/mach-at91/devices.c
 create mode 100644 arch/arm/mach-at91/devices.h
#1 lore raw

PATCH v3 1/23 at91: Add common devices framework

Each AT91 variant (AT91RM9200, AT91SAM9260, etc) currently has its own devices file, which includes the MMIO address, interrupt configuration, GPIO setup, etc for each device. This results in a large amount of duplicated code.

This patch introduces a framework for adding shared devices for the AT91 platform. The subsequent patches in this series replace the multiple device setup implementations for each device with single implementations in the new framework.

---
 arch/arm/mach-at91/Makefile  |    2 +-
 arch/arm/mach-at91/devices.c |   70 ++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h |   36 +++++++++++++++++++++
 3 files changed, 107 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-at91/devices.c
 create mode 100644 arch/arm/mach-at91/devices.h
arch/arm/mach-at91/Makefile +1 -1
index a83835e..14962f2 100644
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y		:= irq.o gpio.o
+obj-y		:= irq.o gpio.o devices.o
 obj-m		:=
 obj-n		:=
 obj-		:=
arch/arm/mach-at91/devices.c new file +70 -0

70 lines not on this page · raw message

arch/arm/mach-at91/devices.h new file +36 -0
new file mode 100644
index 0000000..738f736
@@ -0,0 +1,36 @@
+/*
+ * arch/arm/mach-at91/devices.h
+ *
+ *  Copyright (C) 2011 Bluewater Systems
+ *  Copyright (C) 2011 Ryan Mallon <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#ifndef _AT91_DEVICES_H
+#define _AT91_DEVICES_H
+
+enum {
+	AT91_PIN_PERIPH_A,
+	AT91_PIN_PERIPH_B,
+	AT91_PIN_GPIO,
+};
+
+struct at91_pin_config {
+	int pin;
+	int mode;
+	int pullup;
+	int direction;
+	int value;
+};
+
+struct at91_device_table {
+};
+
+extern void __init at91_init_devices(struct at91_device_table *device_table);
+
+#endif /* _AT91_DEVICES_H */
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v3 2/23 at91: Make Ethernet device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at572d940hf.c         |    4 +
 arch/arm/mach-at91/at572d940hf_devices.c |   83 +++++++----------------
 arch/arm/mach-at91/at91cap9.c            |    4 +
 arch/arm/mach-at91/at91cap9_devices.c    |  103 ++++++++++------------------
 arch/arm/mach-at91/at91rm9200.c          |    4 +
 arch/arm/mach-at91/at91rm9200_devices.c  |  103 ++++++++++------------------
 arch/arm/mach-at91/at91sam9260.c         |    4 +
 arch/arm/mach-at91/at91sam9260_devices.c |  104 +++++++++++------------------
 arch/arm/mach-at91/at91sam9263.c         |    4 +
 arch/arm/mach-at91/at91sam9263_devices.c |  102 ++++++++++------------------
 arch/arm/mach-at91/at91sam9g45.c         |    4 +
 arch/arm/mach-at91/at91sam9g45_devices.c |  108 +++++++++++-------------------
 arch/arm/mach-at91/devices.c             |   61 +++++++++++++++++
 arch/arm/mach-at91/devices.h             |   10 +++
 14 files changed, 309 insertions(+), 389 deletions(-)
arch/arm/mach-at91/at572d940hf.c +4 -0
index a6b9c68..48c1ec2 100644
@@ -34,6 +34,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void at572d940hf_init_devices(void);
+
 static struct map_desc at572d940hf_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -307,6 +309,8 @@ void __init at572d940hf_initialize(unsigned long main_clock)
 	/* Map peripherals */
 	iotable_init(at572d940hf_io_desc, ARRAY_SIZE(at572d940hf_io_desc));
 
+	at572d940hf_init_devices();
+
 	at91_arch_reset = at572d940hf_reset;
 	at91_extern_irq = (1 << AT572D940HF_ID_IRQ0) | (1 << AT572D940HF_ID_IRQ1)
 			| (1 << AT572D940HF_ID_IRQ2);
arch/arm/mach-at91/at572d940hf_devices.c +25 -58

105 lines not on this page · raw message

arch/arm/mach-at91/at91cap9.c +4 -0
index 7337617..6413530 100644
@@ -28,6 +28,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void at91cap9_init_devices(void);
+
 static struct map_desc at91cap9_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -308,6 +310,8 @@ void __init at91cap9_initialize(unsigned long main_clock)
 	/* Map peripherals */
 	iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc));
 
+	at91cap9_init_devices();
+
 	at91_arch_reset = at91cap9_reset;
 	pm_power_off = at91cap9_poweroff;
 	at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1);
arch/arm/mach-at91/at91cap9_devices.c +37 -66

125 lines not on this page · raw message

arch/arm/mach-at91/at91rm9200.c +4 -0
index 2e9ecad..dea90df 100644
@@ -22,6 +22,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void at91rm9200_init_devices(void);
+
 static struct map_desc at91rm9200_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -275,6 +277,8 @@ void __init at91rm9200_initialize(unsigned long main_clock, unsigned short banks
 	/* Map peripherals */
 	iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
 
+	at91rm9200_init_devices();
+
 	at91_arch_reset = at91rm9200_reset;
 	at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1)
 			| (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3)
arch/arm/mach-at91/at91rm9200_devices.c +37 -66

125 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260.c +4 -0
index 195208b..7445f48 100644
@@ -25,6 +25,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void at91sam9260_init_devices(void);
+
 static struct map_desc at91sam9260_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -315,6 +317,8 @@ void __init at91sam9260_initialize(unsigned long main_clock)
 	/* Map peripherals */
 	iotable_init(at91sam9260_io_desc, ARRAY_SIZE(at91sam9260_io_desc));
 
+	at91sam9260_init_devices();
+
 	if (cpu_is_at91sam9xe())
 		at91sam9xe_initialize();
 	else if (cpu_is_at91sam9g20())
arch/arm/mach-at91/at91sam9260_devices.c +38 -66

126 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263.c +4 -0
index 249f900..739fc1f 100644
@@ -24,6 +24,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void at91sam9263_init_devices(void);
+
 static struct map_desc at91sam9263_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -284,6 +286,8 @@ void __init at91sam9263_initialize(unsigned long main_clock)
 	/* Map peripherals */
 	iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc));
 
+	at91sam9263_init_devices();
+
 	at91_arch_reset = at91sam9_alt_reset;
 	pm_power_off = at91sam9263_poweroff;
 	at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
arch/arm/mach-at91/at91sam9263_devices.c +37 -65

124 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45.c +4 -0
index c67b47f..357e5d7 100644
@@ -25,6 +25,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void at91sam9g45_init_devices(void);
+
 static struct map_desc at91sam9g45_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -311,6 +313,8 @@ void __init at91sam9g45_initialize(unsigned long main_clock)
 	/* Map peripherals */
 	iotable_init(at91sam9g45_io_desc, ARRAY_SIZE(at91sam9g45_io_desc));
 
+	at91sam9g45_init_devices();
+
 	at91_arch_reset = at91sam9g45_reset;
 	pm_power_off = at91sam9g45_poweroff;
 	at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0);
arch/arm/mach-at91/at91sam9g45_devices.c +40 -68

128 lines not on this page · raw message

arch/arm/mach-at91/devices.c +61 -0

75 lines not on this page · raw message

arch/arm/mach-at91/devices.h +10 -0
index 738f736..7bed3e7 100644
@@ -28,7 +28,17 @@ struct at91_pin_config {
 	int value;
 };
 
+struct at91_dev_table_ethernet {
+	unsigned 		mmio_base;
+	int 			irq;
+	struct at91_pin_config	*rmii_pins;
+	int 			nr_rmii_pins;
+	struct at91_pin_config	*mii_pins;
+	int 			nr_mii_pins;
+};
+
 struct at91_device_table {
+	struct at91_dev_table_ethernet		*ethernet;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH v3 2/23 at91: Make Ethernet device common

Quoted 11 lines · Ryan Mallon
arch/arm/mach-at91/devices.c +11 -0
+#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
+static u64 eth_dmamask = DMA_BIT_MASK(32);
+static struct at91_eth_data eth_data;
+
+static struct resource eth_resources[] = {
+	[0] = {
+		.end	= SZ_16K,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.flags	= IORESOURCE_IRQ,

arch/arm/mach-at91/devices.c static inline void __init init_resource_irq(struct resource *res, int irq) · line 94

Quoted 10 lines
arch/arm/mach-at91/devices.c +10 -0
+	},
+};
+
+static struct platform_device at91_eth_device = {
+	.name		= "macb",
+	.id		= -1,
+	.dev		= {
+				.dma_mask		= &eth_dmamask,
+				.coherent_dma_mask	= DMA_BIT_MASK(32),
+				.platform_data		= &eth_data,

These three lines have twice as many tabs as is needed.

arch/arm/mach-at91/devices.c static inline void __init init_resource_irq(struct resource *res, int irq) · line 106

Quoted 12 lines
arch/arm/mach-at91/devices.c +12 -0
+	},
+	.resource	= eth_resources,
+	.num_resources	= ARRAY_SIZE(eth_resources),
+};
+
+void __init at91_add_device_eth(struct at91_eth_data *data)
+{
+	struct at91_dev_table_ethernet *info = devices->ethernet;
+
+	BUG_ON(!info);
+	init_resource_mem(&eth_resources[0], info->mmio_base);
+	init_resource_irq(&eth_resources[1], info->irq);

Hmm. How about something like this instead:

	struct resource eth_res[2];
	int err;

	BUG_ON(!info);

	init_resource_mem(&eth_res[0], info->mmio_base, SZ_16K);
	init_resource_irq(&eth_res[1], info->irq);

	...

	err = platform_device_add_resources(&at91_eth_device, eth_res, 2);
	if (err) {
		pr_err("eth: unable to add resources: %d\n", err);
		return;
	}

	err = platform_device_add_data(&at91_eth_device, data, sizeof(*data));
	if (err) {
		pr_err("eth: unable to add platform data: %d\n", err);
		/* res leaked */
		return;
	}

	err = platform_device_register(&at91_eth_device);
	if (err) {
		pr_err("eth: unable to register device: %d\n", err);
		/* res and data leaked */
	}

With Uwe's patches, we can plug those leaks. Note that we can't use platform_device_register_resndata() because it doesn't set the DMA masks etc (which is one of the problems I've always had with interfaces which try to wrap too much stuff up - they always lack something.)

This would get rid of the need to have the resources and platform data storage declared for each and every device. I'd suggest wrapping the last bit adding the platform data and resources up in its own function common to each device as its going to be the same for everything. Remember to pass the size of the platform data though.

#4 lore raw

PATCH v3 2/23 at91: Make Ethernet device common

Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · Ryan Mallon
arch/arm/mach-at91/devices.c +15 -0
+#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
+static u64 eth_dmamask = DMA_BIT_MASK(32);
+static struct at91_eth_data eth_data;
+
+static struct resource eth_resources[] = {
+	[0] = {
+		.end	= SZ_16K,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device at91_eth_device = {
Quoted 8 lines

arch/arm/mach-at91/devices.c static inline void __init init_resource_irq(struct resource *res, int irq) · line 94

Quoted 6 lines
arch/arm/mach-at91/devices.c +6 -0
+	.name		= "macb",
+	.id		= -1,
+	.dev		= {
+				.dma_mask		= &eth_dmamask,
+				.coherent_dma_mask	= DMA_BIT_MASK(32),
+				.platform_data		= &eth_data,

These three lines have twice as many tabs as is needed.

Hartley pointed this out also. The reason it is this way is because I cut and pasted the code from one of the existing implementations (to make the changeset minimal). I can fix this if preferred.

Quoted 50 lines

arch/arm/mach-at91/devices.c static inline void __init init_resource_irq(struct resource *res, int irq) · line 106

Quoted 13 lines
arch/arm/mach-at91/devices.c +12 -0
+	},
+	.resource	= eth_resources,
+	.num_resources	= ARRAY_SIZE(eth_resources),
+};
+
+void __init at91_add_device_eth(struct at91_eth_data *data)
+{
+	struct at91_dev_table_ethernet *info = devices->ethernet;
+
+	BUG_ON(!info);
+	init_resource_mem(&eth_resources[0], info->mmio_base);
+	init_resource_irq(&eth_resources[1], info->irq);

Hmm. How about something like this instead:

	struct resource eth_res[2];
	int err;

	BUG_ON(!info);

	init_resource_mem(&eth_res[0], info->mmio_base, SZ_16K);
	init_resource_irq(&eth_res[1], info->irq);

	...

	err = platform_device_add_resources(&at91_eth_device, eth_res, 2);
	if (err) {
		pr_err("eth: unable to add resources: %d\n", err);
		return;
	}

	err = platform_device_add_data(&at91_eth_device, data, sizeof(*data));
	if (err) {
		pr_err("eth: unable to add platform data: %d\n", err);
		/* res leaked */
		return;
	}

	err = platform_device_register(&at91_eth_device);
	if (err) {
		pr_err("eth: unable to register device: %d\n", err);
		/* res and data leaked */
	}

With Uwe's patches, we can plug those leaks. Note that we can't use platform_device_register_resndata() because it doesn't set the DMA masks etc (which is one of the problems I've always had with interfaces which try to wrap too much stuff up - they always lack something.)

Quoted 5 lines

This would get rid of the need to have the resources and platform data storage declared for each and every device. I'd suggest wrapping the last bit adding the platform data and resources up in its own function common to each device as its going to be the same for everything. Remember to pass the size of the platform data though.

That seems sensible. It should be possible to make the whole lot generic. i.e.

static void __init add_device(struct device *dev, struct resource *res,
int nr_res, void *data, size_t data_size)

{
	if (res) {
 		err = platform_device_add_resources(dev, res, nr_res);
 		if (err) {
 			pr_err("eth: unable to add resources: %d\n", err);
 			return;
 		}
	}

	if (data) {
 		err = platform_device_add_data(dev, data, data_size);
 		if (err) {
 			pr_err("eth: unable to add platform data: %d\n", err);
 			/* res leaked */
 			return;
 		}
	}

err = platform_device_register(dev);
if (err) {
pr_err("eth: unable to register device: %d\n", err); /* res and data leaked */
}
}

void __init at91_add_device_eth(struct at91_eth_data *data)

{
	struct at91_dev_table_ethernet *info = devices->ethernet;
	struct resource res[2];

	BUG_ON(!info);
	init_resource_mem(&res[0], info->mmio_base, SZ_16K);
	init_resource_irq(&res[1], info->irq);
	add_device(&at91_eth_device, res, ARRAY_SIZE(res),
			 data, sizeof(*data));
}

Is this what you mean?

~Ryan

#5 lore raw

PATCH v3 2/23 at91: Make Ethernet device common

Quoted 129 lines · Ryan Mallon
Quoted 16 lines · Russell King - ARM Linux
Quoted 15 lines · Ryan Mallon
arch/arm/mach-at91/devices.c +15 -0
+#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
+static u64 eth_dmamask = DMA_BIT_MASK(32);
+static struct at91_eth_data eth_data;
+
+static struct resource eth_resources[] = {
+	[0] = {
+		.end	= SZ_16K,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device at91_eth_device = {
Quoted 8 lines

arch/arm/mach-at91/devices.c static inline void __init init_resource_irq(struct resource *res, int irq) · line 94

Quoted 6 lines
arch/arm/mach-at91/devices.c +6 -0
+	.name		= "macb",
+	.id		= -1,
+	.dev		= {
+				.dma_mask		= &eth_dmamask,
+				.coherent_dma_mask	= DMA_BIT_MASK(32),
+				.platform_data		= &eth_data,

These three lines have twice as many tabs as is needed.

Hartley pointed this out also. The reason it is this way is because I cut and pasted the code from one of the existing implementations (to make the changeset minimal). I can fix this if preferred.

Quoted 50 lines

arch/arm/mach-at91/devices.c static inline void __init init_resource_irq(struct resource *res, int irq) · line 106

Quoted 13 lines
arch/arm/mach-at91/devices.c +12 -0
+	},
+	.resource	= eth_resources,
+	.num_resources	= ARRAY_SIZE(eth_resources),
+};
+
+void __init at91_add_device_eth(struct at91_eth_data *data)
+{
+	struct at91_dev_table_ethernet *info = devices->ethernet;
+
+	BUG_ON(!info);
+	init_resource_mem(&eth_resources[0], info->mmio_base);
+	init_resource_irq(&eth_resources[1], info->irq);

Hmm. How about something like this instead:

	struct resource eth_res[2];
	int err;

	BUG_ON(!info);

	init_resource_mem(&eth_res[0], info->mmio_base, SZ_16K);
	init_resource_irq(&eth_res[1], info->irq);

	...

	err = platform_device_add_resources(&at91_eth_device, eth_res, 2);
	if (err) {
		pr_err("eth: unable to add resources: %d\n", err);
		return;
	}

	err = platform_device_add_data(&at91_eth_device, data, sizeof(*data));
	if (err) {
		pr_err("eth: unable to add platform data: %d\n", err);
		/* res leaked */
		return;
	}

	err = platform_device_register(&at91_eth_device);
	if (err) {
		pr_err("eth: unable to register device: %d\n", err);
		/* res and data leaked */
	}

With Uwe's patches, we can plug those leaks. Note that we can't use platform_device_register_resndata() because it doesn't set the DMA masks etc (which is one of the problems I've always had with interfaces which try to wrap too much stuff up - they always lack something.)

Quoted 5 lines

This would get rid of the need to have the resources and platform data storage declared for each and every device. I'd suggest wrapping the last bit adding the platform data and resources up in its own function common to each device as its going to be the same for everything. Remember to pass the size of the platform data though.

That seems sensible. It should be possible to make the whole lot generic. i.e.

static void __init add_device(struct device *dev, struct resource *res,
int nr_res, void *data, size_t data_size)

{
	if (res) {
(quoted diff) +0 -0
 		err = platform_device_add_resources(dev, res, nr_res);
 		if (err) {
 			pr_err("eth: unable to add resources: %d\n", err);
 			return;
 		}
	}

	if (data) {
(quoted diff) +0 -0
 		err = platform_device_add_data(dev, data, data_size);
 		if (err) {
 			pr_err("eth: unable to add platform data: %d\n", err);
 			/* res leaked */
 			return;
 		}
	}
(quoted diff) +0 -0
 	err = platform_device_register(dev);
 	if (err) {
 		pr_err("eth: unable to register device: %d\n", err);
 		/* res and data leaked */
 	}	

}

void __init at91_add_device_eth(struct at91_eth_data *data)

{
	struct at91_dev_table_ethernet *info = devices->ethernet;
	struct resource res[2];

	BUG_ON(!info);
	init_resource_mem(&res[0], info->mmio_base, SZ_16K);
	init_resource_irq(&res[1], info->irq);
	add_device(&at91_eth_device, res, ARRAY_SIZE(res),
			 data, sizeof(*data));
}
Quoted 1 line

Is this what you mean?

Yes.

#6 lore raw

PATCH v3 3/23 at91: Make USB OHCI/EHCI devices common

In reply to Ryan Mallon

Replace the individual USB OHCI and EHCI (AT91SAM9G45 only) device code for each at91 variant with a single implementation in devices.c. Rename at91_add_device_usbh to at91_add_device_usbh_ohci (as it is on AT91SAM9G45) to make the API consistent for all variants.

---
 arch/arm/mach-at91/at572d940hf_devices.c  |   45 +----------
 arch/arm/mach-at91/at91cap9_devices.c     |   54 ++------------
 arch/arm/mach-at91/at91rm9200_devices.c   |   44 +----------
 arch/arm/mach-at91/at91sam9260_devices.c  |   44 +----------
 arch/arm/mach-at91/at91sam9261.c          |    4 +
 arch/arm/mach-at91/at91sam9261_devices.c  |   53 +++----------
 arch/arm/mach-at91/at91sam9263_devices.c  |   52 +------------
 arch/arm/mach-at91/at91sam9g45_devices.c  |  105 ++------------------------
 arch/arm/mach-at91/board-1arm.c           |    2 +-
 arch/arm/mach-at91/board-afeb-9260v1.c    |    2 +-
 arch/arm/mach-at91/board-at572d940hf_ek.c |    2 +-
 arch/arm/mach-at91/board-cam60.c          |    2 +-
 arch/arm/mach-at91/board-cap9adk.c        |    2 +-
 arch/arm/mach-at91/board-carmeva.c        |    2 +-
 arch/arm/mach-at91/board-cpu9krea.c       |    2 +-
 arch/arm/mach-at91/board-cpuat91.c        |    2 +-
 arch/arm/mach-at91/board-csb337.c         |    2 +-
 arch/arm/mach-at91/board-csb637.c         |    2 +-
 arch/arm/mach-at91/board-eb9200.c         |    2 +-
 arch/arm/mach-at91/board-ecbat91.c        |    2 +-
 arch/arm/mach-at91/board-eco920.c         |    2 +-
 arch/arm/mach-at91/board-flexibity.c      |    2 +-
 arch/arm/mach-at91/board-foxg20.c         |    2 +-
 arch/arm/mach-at91/board-gsia18s.c        |    2 +-
 arch/arm/mach-at91/board-kafa.c           |    2 +-
 arch/arm/mach-at91/board-kb9202.c         |    2 +-
 arch/arm/mach-at91/board-neocore926.c     |    2 +-
 arch/arm/mach-at91/board-pcontrol-g20.c   |    2 +-
 arch/arm/mach-at91/board-picotux200.c     |    2 +-
 arch/arm/mach-at91/board-qil-a9260.c      |    2 +-
 arch/arm/mach-at91/board-rm9200dk.c       |    2 +-
 arch/arm/mach-at91/board-rm9200ek.c       |    2 +-
 arch/arm/mach-at91/board-sam9-l9260.c     |    2 +-
 arch/arm/mach-at91/board-sam9260ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9261ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9263ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9g20ek.c      |    2 +-
 arch/arm/mach-at91/board-snapper9260.c    |    2 +-
 arch/arm/mach-at91/board-stamp9g20.c      |    4 +-
 arch/arm/mach-at91/board-usb-a9260.c      |    2 +-
 arch/arm/mach-at91/board-usb-a9263.c      |    2 +-
 arch/arm/mach-at91/board-yl-9200.c        |    2 +-
 arch/arm/mach-at91/devices.c              |  117 +++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h              |   13 +++
 arch/arm/mach-at91/include/mach/board.h   |    1 -
 45 files changed, 212 insertions(+), 390 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +4 -41
index 203802a..07aff96 100644
@@ -42,49 +42,11 @@
  *  USB Host
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
-static u64 ohci_dmamask = DMA_BIT_MASK(32);
-static struct at91_usbh_data usbh_data;
-
-static struct resource usbh_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_UHP_BASE,
-		.end	= AT572D940HF_UHP_BASE + SZ_1M - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_UHP,
-		.end	= AT572D940HF_ID_UHP,
-		.flags	= IORESOURCE_IRQ,
-	},
+static struct at91_dev_table_usb_ohci device_usbh_ohci __initdata = {
+	.mmio_base	= AT572D940HF_UHP_BASE,
+	.irq		= AT572D940HF_ID_UHP,
 };
 
-static struct platform_device at572d940hf_usbh_device = {
-	.name		= "at91_ohci",
-	.id		= -1,
-	.dev		= {
-				.dma_mask		= &ohci_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &usbh_data,
-	},
-	.resource	= usbh_resources,
-	.num_resources	= ARRAY_SIZE(usbh_resources),
-};
-
-void __init at91_add_device_usbh(struct at91_usbh_data *data)
-{
-	if (!data)
-		return;
-
-	usbh_data = *data;
-	platform_device_register(&at572d940hf_usbh_device);
-
-}
-#else
-void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  USB Device (Gadget)
  * -------------------------------------------------------------------- */
@@ -913,6 +875,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,
 };
 
 void __init at572d940hf_init_devices(void)
arch/arm/mach-at91/at91cap9_devices.c +7 -47

71 lines not on this page · raw message

arch/arm/mach-at91/at91rm9200_devices.c +4 -40

58 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +4 -40

58 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261.c +4 -0
index fcad886..dd0a96d 100644
@@ -25,6 +25,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void at91sam9261_init_devices(void);
+
 static struct map_desc at91sam9261_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -272,6 +274,8 @@ void __init at91sam9261_initialize(unsigned long main_clock)
 	/* Map peripherals */
 	iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc));
 
+	at91sam9261_init_devices();
+
 	if (cpu_is_at91sam9g10())
 		iotable_init(at91sam9g10_sram_desc, ARRAY_SIZE(at91sam9g10_sram_desc));
 	else
arch/arm/mach-at91/at91sam9261_devices.c +12 -41

72 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +4 -48

66 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +8 -97

126 lines not on this page · raw message

arch/arm/mach-at91/board-1arm.c +1 -1
index 8a3fc84..244e8bb 100644
@@ -85,7 +85,7 @@ static void __init onearm_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&onearm_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&onearm_usbh_data);
+	at91_add_device_usbh_ohci(&onearm_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&onearm_udc_data);
 }
arch/arm/mach-at91/board-afeb-9260v1.c +1 -1
index cba7f77..88d08ae 100644
@@ -189,7 +189,7 @@ static void __init afeb9260_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&afeb9260_usbh_data);
+	at91_add_device_usbh_ohci(&afeb9260_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&afeb9260_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-at572d940hf_ek.c +1 -1
index 3929f1c..c9ab05d 100644
@@ -297,7 +297,7 @@ static void __init eb_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&eb_usbh_data);
+	at91_add_device_usbh_ohci(&eb_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&eb_udc_data);
 	/* I2C */
arch/arm/mach-at91/board-cam60.c +1 -1
index b54e3e6..014271d 100644
@@ -191,7 +191,7 @@ static void __init cam60_board_init(void)
 	/* USB Host */
 	/* enable USB power supply circuit */
 	at91_set_gpio_output(AT91_PIN_PB18, 1);
-	at91_add_device_usbh(&cam60_usbh_data);
+	at91_add_device_usbh_ohci(&cam60_usbh_data);
 	/* NAND */
 	cam60_add_device_nand();
 }
arch/arm/mach-at91/board-cap9adk.c +1 -1
index e727444..0d60378 100644
@@ -374,7 +374,7 @@ static void __init cap9adk_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&cap9adk_usbh_data);
+	at91_add_device_usbh_ohci(&cap9adk_usbh_data);
 	/* USB HS */
 	at91_add_device_usba(&cap9adk_usba_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-carmeva.c +1 -1
index 2e74a19..9d007a8 100644
@@ -145,7 +145,7 @@ static void __init carmeva_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&carmeva_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&carmeva_usbh_data);
+	at91_add_device_usbh_ohci(&carmeva_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&carmeva_udc_data);
 	/* I2C */
arch/arm/mach-at91/board-cpu9krea.c +1 -1
index 3838594..65c6513 100644
@@ -351,7 +351,7 @@ static void __init cpu9krea_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&cpu9krea_usbh_data);
+	at91_add_device_usbh_ohci(&cpu9krea_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&cpu9krea_udc_data);
 	/* NAND */
arch/arm/mach-at91/board-cpuat91.c +1 -1
index 2f4dd8c..ce3525d 100644
@@ -162,7 +162,7 @@ static void __init cpuat91_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&cpuat91_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&cpuat91_usbh_data);
+	at91_add_device_usbh_ohci(&cpuat91_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&cpuat91_udc_data);
 	/* MMC */
arch/arm/mach-at91/board-csb337.c +1 -1
index 464839d..ff7b8c0 100644
@@ -235,7 +235,7 @@ static void __init csb337_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&csb337_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&csb337_usbh_data);
+	at91_add_device_usbh_ohci(&csb337_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&csb337_udc_data);
 	/* I2C */
arch/arm/mach-at91/board-csb637.c +1 -1
index 431688c..74d5b7e 100644
@@ -125,7 +125,7 @@ static void __init csb637_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&csb637_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&csb637_usbh_data);
+	at91_add_device_usbh_ohci(&csb637_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&csb637_udc_data);
 	/* I2C */
arch/arm/mach-at91/board-eb9200.c +1 -1
index 6cf6566..3705082 100644
@@ -105,7 +105,7 @@ static void __init eb9200_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&eb9200_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&eb9200_usbh_data);
+	at91_add_device_usbh_ohci(&eb9200_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&eb9200_udc_data);
 	/* I2C */
arch/arm/mach-at91/board-ecbat91.c +1 -1
index de2fd04..df4a07f 100644
@@ -154,7 +154,7 @@ static void __init ecb_at91board_init(void)
 	at91_add_device_eth(&ecb_at91eth_data);
 
 	/* USB Host */
-	at91_add_device_usbh(&ecb_at91usbh_data);
+	at91_add_device_usbh_ohci(&ecb_at91usbh_data);
 
 	/* I2C */
 	at91_add_device_i2c(NULL, 0);
arch/arm/mach-at91/board-eco920.c +1 -1
index a158a0c..7988b58 100644
@@ -114,7 +114,7 @@ static void __init eco920_board_init(void)
 {
 	at91_add_device_serial();
 	at91_add_device_eth(&eco920_eth_data);
-	at91_add_device_usbh(&eco920_usbh_data);
+	at91_add_device_usbh_ohci(&eco920_usbh_data);
 	at91_add_device_udc(&eco920_udc_data);
 
 	at91_add_device_mmc(0, &eco920_mmc_data);
arch/arm/mach-at91/board-flexibity.c +1 -1
index c8a62dc..096d5d2 100644
@@ -140,7 +140,7 @@ static void __init flexibity_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&flexibity_usbh_data);
+	at91_add_device_usbh_ohci(&flexibity_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&flexibity_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-foxg20.c +1 -1
index dfc7dfe..6688ec2 100644
@@ -244,7 +244,7 @@ static void __init foxg20_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&foxg20_usbh_data);
+	at91_add_device_usbh_ohci(&foxg20_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&foxg20_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-gsia18s.c +1 -1
index bc28136..8b1d498 100644
@@ -561,7 +561,7 @@ static int __init gsia18s_power_off_init(void)
 static void __init gsia18s_board_init(void)
 {
 	stamp9g20_board_init();
-	at91_add_device_usbh(&usbh_data);
+	at91_add_device_usbh_ohci(&usbh_data);
 	at91_add_device_udc(&udc_data);
 	at91_add_device_eth(&macb_data);
 	gsia18s_leds_init();
arch/arm/mach-at91/board-kafa.c +1 -1
index d2e1f4e..a0cac24 100644
@@ -83,7 +83,7 @@ static void __init kafa_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&kafa_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&kafa_usbh_data);
+	at91_add_device_usbh_ohci(&kafa_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&kafa_udc_data);
 	/* I2C */
arch/arm/mach-at91/board-kb9202.c +1 -1
index a13d206..59eafa2 100644
@@ -121,7 +121,7 @@ static void __init kb9202_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&kb9202_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&kb9202_usbh_data);
+	at91_add_device_usbh_ohci(&kb9202_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&kb9202_udc_data);
 	/* MMC */
arch/arm/mach-at91/board-neocore926.c +1 -1
index fe5f1d4..bffbbdf 100644
@@ -351,7 +351,7 @@ static void __init neocore926_board_init(void)
 	at91_add_device_serial();
 
 	/* USB Host */
-	at91_add_device_usbh(&neocore926_usbh_data);
+	at91_add_device_usbh_ohci(&neocore926_usbh_data);
 
 	/* USB Device */
 	at91_add_device_udc(&neocore926_udc_data);
arch/arm/mach-at91/board-pcontrol-g20.c +1 -1
index feb6578..4c5848d 100644
@@ -205,7 +205,7 @@ static struct spi_board_info pcontrol_g20_spi_devices[] = {
 static void __init pcontrol_g20_board_init(void)
 {
 	stamp9g20_board_init();
-	at91_add_device_usbh(&usbh_data);
+	at91_add_device_usbh_ohci(&usbh_data);
 	at91_add_device_eth(&macb_data);
 	at91_add_device_i2c(pcontrol_g20_i2c_devices,
 		ARRAY_SIZE(pcontrol_g20_i2c_devices));
arch/arm/mach-at91/board-picotux200.c +1 -1
index 55dad3a..419456d 100644
@@ -111,7 +111,7 @@ static void __init picotux200_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&picotux200_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&picotux200_usbh_data);
+	at91_add_device_usbh_ohci(&picotux200_usbh_data);
 	/* I2C */
 	at91_add_device_i2c(NULL, 0);
 	/* MMC */
arch/arm/mach-at91/board-qil-a9260.c +1 -1
index 69d15a8..255a984 100644
@@ -244,7 +244,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-rm9200dk.c +1 -1
index 4c1047c..3d54963 100644
@@ -197,7 +197,7 @@ static void __init dk_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&dk_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&dk_usbh_data);
+	at91_add_device_usbh_ohci(&dk_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&dk_udc_data);
 	at91_set_multi_drive(dk_udc_data.pullup_pin, 1);	/* pullup_pin is connected to reset */
arch/arm/mach-at91/board-rm9200ek.c +1 -1
index 9df1be8..25fe19f 100644
@@ -167,7 +167,7 @@ static void __init ek_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&ek_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	at91_set_multi_drive(ek_udc_data.pullup_pin, 1);	/* pullup_pin is connected to reset */
arch/arm/mach-at91/board-sam9-l9260.c +1 -1
index 25a26be..589e2f4 100644
@@ -195,7 +195,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-sam9260ek.c +1 -1
index de1816e..b98e766 100644
@@ -332,7 +332,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-sam9261ek.c +1 -1
index 14acc90..e631172 100644
@@ -586,7 +586,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* I2C */
arch/arm/mach-at91/board-sam9263ek.c +1 -1
index bfe490d..fae6ebf 100644
@@ -423,7 +423,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-sam9g20ek.c +1 -1
index ca8198b..c25e44c 100644
@@ -379,7 +379,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-snapper9260.c +1 -1
index 17f7d9b..ca14290 100644
@@ -169,7 +169,7 @@ static void __init snapper9260_board_init(void)
 	at91_add_device_i2c(snapper9260_i2c_devices,
 			    ARRAY_SIZE(snapper9260_i2c_devices));
 	at91_add_device_serial();
-	at91_add_device_usbh(&snapper9260_usbh_data);
+	at91_add_device_usbh_ohci(&snapper9260_usbh_data);
 	at91_add_device_udc(&snapper9260_udc_data);
 	at91_add_device_eth(&snapper9260_macb_data);
 	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK |
arch/arm/mach-at91/board-stamp9g20.c +2 -2
index f8902b1..1e7a73a 100644
@@ -268,7 +268,7 @@ static void __init portuxg20_board_init(void)
 {
 	stamp9g20_board_init();
 	/* USB Host */
-	at91_add_device_usbh(&usbh_data);
+	at91_add_device_usbh_ohci(&usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&portuxg20_udc_data);
 	/* Ethernet */
@@ -285,7 +285,7 @@ static void __init stamp9g20evb_board_init(void)
 {
 	stamp9g20_board_init();
 	/* USB Host */
-	at91_add_device_usbh(&usbh_data);
+	at91_add_device_usbh_ohci(&usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&stamp9g20evb_udc_data);
 	/* Ethernet */
arch/arm/mach-at91/board-usb-a9260.c +1 -1
index 07784ba..9b5cbf5 100644
@@ -208,7 +208,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* NAND */
arch/arm/mach-at91/board-usb-a9263.c +1 -1
index b614508..535af00 100644
@@ -222,7 +222,7 @@ static void __init ek_board_init(void)
 	/* Serial */
 	at91_add_device_serial();
 	/* USB Host */
-	at91_add_device_usbh(&ek_usbh_data);
+	at91_add_device_usbh_ohci(&ek_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* SPI */
arch/arm/mach-at91/board-yl-9200.c +1 -1
index e0f0080..bd5ebfd 100644
@@ -567,7 +567,7 @@ static void __init yl9200_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&yl9200_eth_data);
 	/* USB Host */
-	at91_add_device_usbh(&yl9200_usbh_data);
+	at91_add_device_usbh_ohci(&yl9200_usbh_data);
 	/* USB Device */
 	at91_add_device_udc(&yl9200_udc_data);
 	/* I2C */
arch/arm/mach-at91/devices.c +117 -0

131 lines not on this page · raw message

arch/arm/mach-at91/devices.h +13 -0
index 7bed3e7..eb4de05 100644
@@ -28,6 +28,11 @@ struct at91_pin_config {
 	int value;
 };
 
+struct at91_dev_table_basic_device {
+	unsigned 		mmio_base;
+	int 			irq;
+};
+
 struct at91_dev_table_ethernet {
 	unsigned 		mmio_base;
 	int 			irq;
@@ -37,8 +42,16 @@ struct at91_dev_table_ethernet {
 	int 			nr_mii_pins;
 };
 
+struct at91_dev_table_usb_ohci {
+	unsigned 		mmio_base;
+	int 			irq;
+	void			(*device_init)(void);
+};
+
 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;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
arch/arm/mach-at91/include/mach/board.h +0 -1
index 2b499eb..dd0855d 100644
@@ -99,7 +99,6 @@ struct at91_usbh_data {
 	u8		ports;		/* number of ports on root hub */
 	u8		vbus_pin[2];	/* port power-control pin */
 };
-extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
 extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);
 extern void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data);
 
Signature · 1 line
1.7.0.4
#7 lore raw

PATCH v3 4/23 at91: Make UDC device common

In reply to Ryan Mallon

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

---
 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(-)
arch/arm/mach-at91/at572d940hf_devices.c +4 -44
index 07aff96..da27bdb 100644
@@ -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)
arch/arm/mach-at91/at91rm9200_devices.c +4 -44

62 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +4 -44

62 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +4 -43

61 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +4 -44

62 lines not on this page · raw message

arch/arm/mach-at91/devices.c +52 -0

58 lines not on this page · raw message

arch/arm/mach-at91/devices.h +1 -0
index eb4de05..9203f58 100644
@@ -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);
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH v3 5/23 at91: Make MMC device common

In reply to Ryan Mallon

Replace the individual MMC code for each at91 variant with a single implementation in devices.c. Both the AT91 MMC and Atmel MCI drivers are converted here to use the common data in both instances.

---
 arch/arm/mach-at91/at572d940hf_devices.c |   79 ++--------
 arch/arm/mach-at91/at91cap9_devices.c    |  134 ++++-------------
 arch/arm/mach-at91/at91rm9200_devices.c  |   96 +++----------
 arch/arm/mach-at91/at91sam9260_devices.c |  192 +++---------------------
 arch/arm/mach-at91/at91sam9261_devices.c |   76 ++--------
 arch/arm/mach-at91/at91sam9263_devices.c |  173 ++++++----------------
 arch/arm/mach-at91/at91sam9g45_devices.c |  189 +++++-------------------
 arch/arm/mach-at91/at91sam9rl.c          |    4 +
 arch/arm/mach-at91/at91sam9rl_devices.c  |   85 +++--------
 arch/arm/mach-at91/devices.c             |  237 ++++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |   15 ++
 11 files changed, 455 insertions(+), 825 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +15 -64
index da27bdb..2d029a7 100644
@@ -84,72 +84,22 @@ static struct at91_dev_table_ethernet device_eth __initdata = {
  *  MMC / SD
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
-static u64 mmc_dmamask = DMA_BIT_MASK(32);
-static struct at91_mmc_data mmc_data;
-
-static struct resource mmc_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_MCI,
-		.end	= AT572D940HF_BASE_MCI + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_MCI,
-		.end	= AT572D940HF_ID_MCI,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at572d940hf_mmc_device = {
-	.name		= "at91_mci",
-	.id		= -1,
-	.dev		= {
-				.dma_mask		= &mmc_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &mmc_data,
-	},
-	.resource	= mmc_resources,
-	.num_resources	= ARRAY_SIZE(mmc_resources),
+static struct at91_dev_table_mmc device_mmc __initdata = {
+	.mmio_base	= AT572D940HF_BASE_MCI,
+	.irq		= AT572D940HF_ID_MCI,
+	.clock_pin	= {AT91_PIN_PC22, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.slot[0]	= {
+		 /* mmc_id 0, slot a */
+		 .cmd_pin	= {AT91_PIN_PC23, AT91_PIN_PERIPH_A, 1, 0, 0},
+		 .data_pins	= {
+			  {AT91_PIN_PC24, AT91_PIN_PERIPH_A, 1, 0, 0},
+			  {AT91_PIN_PC25, AT91_PIN_PERIPH_A, 1, 0, 0},
+			  {AT91_PIN_PC26, AT91_PIN_PERIPH_A, 1, 0, 0},
+			  {AT91_PIN_PC27, AT91_PIN_PERIPH_A, 1, 0, 0},
+		 },
+	 },
 };
 
-void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
-{
-	if (!data)
-		return;
-
-	/* input/irq */
-	if (data->det_pin) {
-		at91_set_gpio_input(data->det_pin, 1);
-		at91_set_deglitch(data->det_pin, 1);
-	}
-	if (data->wp_pin)
-		at91_set_gpio_input(data->wp_pin, 1);
-	if (data->vcc_pin)
-		at91_set_gpio_output(data->vcc_pin, 0);
-
-	/* CLK */
-	at91_set_A_periph(AT91_PIN_PC22, 0);
-
-	/* CMD */
-	at91_set_A_periph(AT91_PIN_PC23, 1);
-
-	/* DAT0, maybe DAT1..DAT3 */
-	at91_set_A_periph(AT91_PIN_PC24, 1);
-	if (data->wire4) {
-		at91_set_A_periph(AT91_PIN_PC25, 1);
-		at91_set_A_periph(AT91_PIN_PC26, 1);
-		at91_set_A_periph(AT91_PIN_PC27, 1);
-	}
-
-	mmc_data = *data;
-	platform_device_register(&at572d940hf_mmc_device);
-}
-#else
-void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  NAND / SmartMedia
  * -------------------------------------------------------------------- */
@@ -836,6 +786,7 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
 	.ethernet	= &device_eth,
 	.usbh_ohci	= &device_usbh_ohci,
 	.udc		= &device_udc,
+	.mmc[0]		= &device_mmc,
 };
 
 void __init at572d940hf_init_devices(void)
arch/arm/mach-at91/at91cap9_devices.c +28 -106

152 lines not on this page · raw message

arch/arm/mach-at91/at91rm9200_devices.c +21 -75

112 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +21 -171

208 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +13 -63

91 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +44 -129

193 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +36 -153

207 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl.c +4 -0
index 6a9d24e..9ca108a 100644
@@ -24,6 +24,8 @@
 #include "generic.h"
 #include "clock.h"
 
+extern void __init at91sam9rl_init_devices(void);
+
 static struct map_desc at91sam9rl_io_desc[] __initdata = {
 	{
 		.virtual	= AT91_VA_BASE_SYS,
@@ -259,6 +261,8 @@ void __init at91sam9rl_initialize(unsigned long main_clock)
 	/* Map peripherals */
 	iotable_init(at91sam9rl_io_desc, ARRAY_SIZE(at91sam9rl_io_desc));
 
+	at91sam9rl_init_devices();
+
 	cidr = at91_sys_read(AT91_DBGU_CIDR);
 
 	switch (cidr & AT91_CIDR_SRAMSIZ) {
arch/arm/mach-at91/at91sam9rl_devices.c +21 -64

106 lines not on this page · raw message

arch/arm/mach-at91/devices.c +237 -0

243 lines not on this page · raw message

arch/arm/mach-at91/devices.h +15 -0
index 9203f58..eab2f54 100644
@@ -48,11 +48,26 @@ struct at91_dev_table_usb_ohci {
 	void			(*device_init)(void);
 };
 
+struct at91_mmc_pins {
+	struct at91_pin_config	cmd_pin;
+	struct at91_pin_config	data_pins[8];
+	int			bus_width;
+};
+
+struct at91_dev_table_mmc {
+	unsigned 		mmio_base;
+	int			irq;
+	const char		*clock_asc;
+	struct at91_pin_config	clock_pin;
+	struct at91_mmc_pins	slot[2];
+};
+
 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;
+	struct at91_dev_table_mmc		*mmc[2];
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#9 lore raw

PATCH v3 6/23 at91: Make NAND device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at572d940hf_devices.c |   65 ++++--------------------
 arch/arm/mach-at91/at91cap9_devices.c    |   62 ++--------------------
 arch/arm/mach-at91/at91rm9200_devices.c  |   81 +++++++-----------------------
 arch/arm/mach-at91/at91sam9260_devices.c |   62 ++--------------------
 arch/arm/mach-at91/at91sam9261_devices.c |   63 ++++-------------------
 arch/arm/mach-at91/at91sam9263_devices.c |   62 ++--------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |   62 ++--------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   66 ++----------------------
 arch/arm/mach-at91/devices.c             |   76 ++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |   12 ++++
 10 files changed, 158 insertions(+), 453 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +11 -54
index 2d029a7..771e1bf 100644
@@ -104,64 +104,20 @@ static struct at91_dev_table_mmc device_mmc __initdata = {
  *  NAND / SmartMedia
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
-static struct atmel_nand_data nand_data;
-
-#define NAND_BASE	AT91_CHIPSELECT_3
-
-static struct resource nand_resources[] = {
-	{
-		.start	= NAND_BASE,
-		.end	= NAND_BASE + SZ_256M - 1,
-		.flags	= IORESOURCE_MEM,
-	}
+static struct at91_pin_config nand_pins[] __initdata = {
+	{AT91_PIN_PB28, AT91_PIN_PERIPH_A, 0, 0, 0},	/* A[22] */
+	{AT91_PIN_PA28, AT91_PIN_PERIPH_B, 0, 0, 0},	/* NANDOE */
+	{AT91_PIN_PA29, AT91_PIN_PERIPH_B, 0, 0, 0},	/* NANDWE */
 };
 
-static struct platform_device at572d940hf_nand_device = {
-	.name		= "atmel_nand",
-	.id		= -1,
-	.dev		= {
-				.platform_data	= &nand_data,
-	},
-	.resource	= nand_resources,
-	.num_resources	= ARRAY_SIZE(nand_resources),
+static struct at91_dev_table_nand device_nand __initdata = {
+	.chip_select	= 3,
+	.enable_reg	= AT91_MATRIX_EBICSA,
+	.enable		= AT91_MATRIX_CS3A_SMC_SMARTMEDIA,
+	.pins		= nand_pins,
+	.nr_pins	= ARRAY_SIZE(nand_pins),
 };
 
-void __init at91_add_device_nand(struct atmel_nand_data *data)
-{
-	unsigned long csa;
-
-	if (!data)
-		return;
-
-	csa = at91_sys_read(AT91_MATRIX_EBICSA);
-	at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
-
-	/* enable pin */
-	if (data->enable_pin)
-		at91_set_gpio_output(data->enable_pin, 1);
-
-	/* ready/busy pin */
-	if (data->rdy_pin)
-		at91_set_gpio_input(data->rdy_pin, 1);
-
-	/* card detect pin */
-	if (data->det_pin)
-		at91_set_gpio_input(data->det_pin, 1);
-
-	at91_set_A_periph(AT91_PIN_PB28, 0);		/* A[22] */
-	at91_set_B_periph(AT91_PIN_PA28, 0);		/* NANDOE */
-	at91_set_B_periph(AT91_PIN_PA29, 0);		/* NANDWE */
-
-	nand_data = *data;
-	platform_device_register(&at572d940hf_nand_device);
-}
-
-#else
-void __init at91_add_device_nand(struct atmel_nand_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  TWI (i2c)
  * -------------------------------------------------------------------- */
@@ -787,6 +743,7 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
 	.usbh_ohci	= &device_usbh_ohci,
 	.udc		= &device_udc,
 	.mmc[0]		= &device_mmc,
+	.nand		= &device_nand,
 };
 
 void __init at572d940hf_init_devices(void)
arch/arm/mach-at91/at91cap9_devices.c +6 -56

76 lines not on this page · raw message

arch/arm/mach-at91/at91rm9200_devices.c +19 -62

95 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +6 -56

76 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +10 -53

79 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +6 -56

76 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +6 -56

76 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +6 -60

80 lines not on this page · raw message

arch/arm/mach-at91/devices.c +76 -0

82 lines not on this page · raw message

arch/arm/mach-at91/devices.h +12 -0
index eab2f54..3e9ec54 100644
@@ -62,12 +62,24 @@ struct at91_dev_table_mmc {
 	struct at91_mmc_pins	slot[2];
 };
 
+struct at91_dev_table_nand {
+	unsigned		chip_select;
+	unsigned		enable_reg;
+	unsigned		enable;
+	unsigned		ecc_mmio_base;
+	unsigned		flags_reg;
+	unsigned		flags;
+	struct at91_pin_config	*pins;
+	int			nr_pins;
+};
+
 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;
 	struct at91_dev_table_mmc		*mmc[2];
+	struct at91_dev_table_nand		*nand;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#10 lore raw

PATCH v3 7/23 at91: Make TWI device common

In reply to Ryan Mallon

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

The AT91SAM9G45 has an additional argument to at91_add_device_i2c for the bus number. We change the other variants to use this API for consistency.

---
 arch/arm/mach-at91/at572d940hf_devices.c  |  111 +++--------------------
 arch/arm/mach-at91/at91cap9_devices.c     |   76 ++---------------
 arch/arm/mach-at91/at91rm9200_devices.c   |   77 ++---------------
 arch/arm/mach-at91/at91sam9260_devices.c  |   78 ++---------------
 arch/arm/mach-at91/at91sam9261_devices.c  |   77 ++---------------
 arch/arm/mach-at91/at91sam9263_devices.c  |   77 ++---------------
 arch/arm/mach-at91/at91sam9g45_devices.c  |  136 +++--------------------------
 arch/arm/mach-at91/at91sam9rl_devices.c   |   77 ++---------------
 arch/arm/mach-at91/board-afeb-9260v1.c    |    2 +-
 arch/arm/mach-at91/board-at572d940hf_ek.c |    2 +-
 arch/arm/mach-at91/board-cap9adk.c        |    2 +-
 arch/arm/mach-at91/board-carmeva.c        |    2 +-
 arch/arm/mach-at91/board-cpu9krea.c       |    2 +-
 arch/arm/mach-at91/board-cpuat91.c        |    2 +-
 arch/arm/mach-at91/board-csb337.c         |    2 +-
 arch/arm/mach-at91/board-csb637.c         |    2 +-
 arch/arm/mach-at91/board-eb9200.c         |    2 +-
 arch/arm/mach-at91/board-ecbat91.c        |    2 +-
 arch/arm/mach-at91/board-foxg20.c         |    2 +-
 arch/arm/mach-at91/board-gsia18s.c        |    2 +-
 arch/arm/mach-at91/board-kafa.c           |    2 +-
 arch/arm/mach-at91/board-kb9202.c         |    2 +-
 arch/arm/mach-at91/board-neocore926.c     |    2 +-
 arch/arm/mach-at91/board-pcontrol-g20.c   |    2 +-
 arch/arm/mach-at91/board-picotux200.c     |    2 +-
 arch/arm/mach-at91/board-qil-a9260.c      |    2 +-
 arch/arm/mach-at91/board-rm9200dk.c       |    2 +-
 arch/arm/mach-at91/board-rm9200ek.c       |    2 +-
 arch/arm/mach-at91/board-sam9-l9260.c     |    2 +-
 arch/arm/mach-at91/board-sam9260ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9261ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9263ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9g20ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9rlek.c       |    2 +-
 arch/arm/mach-at91/board-snapper9260.c    |    2 +-
 arch/arm/mach-at91/board-stamp9g20.c      |    4 +-
 arch/arm/mach-at91/board-usb-a9260.c      |    2 +-
 arch/arm/mach-at91/board-usb-a9263.c      |    2 +-
 arch/arm/mach-at91/board-yl-9200.c        |    2 +-
 arch/arm/mach-at91/devices.c              |  122 ++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h              |    9 ++
 arch/arm/mach-at91/include/mach/board.h   |    4 -
 42 files changed, 233 insertions(+), 675 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +14 -97
index 771e1bf..482de24 100644
@@ -122,107 +122,22 @@ static struct at91_dev_table_nand device_nand __initdata = {
  *  TWI (i2c)
  * -------------------------------------------------------------------- */
 
-/*
- * Prefer the GPIO code since the TWI controller isn't robust
- * (gets overruns and underruns under load) and can only issue
- * repeated STARTs in one scenario (the driver doesn't yet handle them).
- */
-
-#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
-
-static struct i2c_gpio_platform_data pdata = {
-	.sda_pin		= AT91_PIN_PC7,
-	.sda_is_open_drain	= 1,
-	.scl_pin		= AT91_PIN_PC8,
-	.scl_is_open_drain	= 1,
-	.udelay			= 2,		/* ~100 kHz */
-};
-
-static struct platform_device at572d940hf_twi_device {
-	.name			= "i2c-gpio",
-	.id			= -1,
-	.dev.platform_data	= &pdata,
-};
-
-void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
-{
-	at91_set_GPIO_periph(AT91_PIN_PC7, 1);		/* TWD (SDA) */
-	at91_set_multi_drive(AT91_PIN_PC7, 1);
-
-	at91_set_GPIO_periph(AT91_PIN_PA8, 1);		/* TWCK (SCL) */
-	at91_set_multi_drive(AT91_PIN_PC8, 1);
-
-	i2c_register_board_info(0, devices, nr_devices);
-	platform_device_register(&at572d940hf_twi_device);
-}
-
-#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
-
-static struct resource twi0_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_TWI0,
-		.end	= AT572D940HF_BASE_TWI0 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_TWI0,
-		.end	= AT572D940HF_ID_TWI0,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at572d940hf_twi0_device = {
-	.name		= "at91_i2c",
-	.id		= 0,
-	.resource	= twi0_resources,
-	.num_resources	= ARRAY_SIZE(twi0_resources),
+static struct at91_dev_table_twi device_twi0 __initdata = {
+	.mmio_base	= AT572D940HF_BASE_TWI0,
+	.irq		= AT572D940HF_ID_TWI0,
+	.sda_pin 	= {AT91_PIN_PC7, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.scl_pin	= {AT91_PIN_PC8, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.udelay		= 2,
 };
 
-static struct resource twi1_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_TWI1,
-		.end	= AT572D940HF_BASE_TWI1 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_TWI1,
-		.end	= AT572D940HF_ID_TWI1,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at572d940hf_twi1_device = {
-	.name		= "at91_i2c",
-	.id		= 1,
-	.resource	= twi1_resources,
-	.num_resources	= ARRAY_SIZE(twi1_resources),
+static struct at91_dev_table_twi device_twi1 __initdata = {
+	.mmio_base	= AT572D940HF_BASE_TWI1,
+	.irq		= AT572D940HF_ID_TWI1,
+	.sda_pin 	= {AT91_PIN_PC7, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.scl_pin	= {AT91_PIN_PC8, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.udelay		= 2,
 };
 
-void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
-{
-	/* pins used for TWI0 interface */
-	at91_set_A_periph(AT91_PIN_PC7, 0);		/* TWD */
-	at91_set_multi_drive(AT91_PIN_PC7, 1);
-
-	at91_set_A_periph(AT91_PIN_PC8, 0);		/* TWCK */
-	at91_set_multi_drive(AT91_PIN_PC8, 1);
-
-	/* pins used for TWI1 interface */
-	at91_set_A_periph(AT91_PIN_PC20, 0);		/* TWD */
-	at91_set_multi_drive(AT91_PIN_PC20, 1);
-
-	at91_set_A_periph(AT91_PIN_PC21, 0);		/* TWCK */
-	at91_set_multi_drive(AT91_PIN_PC21, 1);
-
-	i2c_register_board_info(0, devices, nr_devices);
-	platform_device_register(&at572d940hf_twi0_device);
-	platform_device_register(&at572d940hf_twi1_device);
-}
-#else
-void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  SPI
  * -------------------------------------------------------------------- */
@@ -744,6 +659,8 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
 	.udc		= &device_udc,
 	.mmc[0]		= &device_mmc,
 	.nand		= &device_nand,
+	.twi[0]		= &device_twi0,
+	.twi[1]		= &device_twi1,
 };
 
 void __init at572d940hf_init_devices(void)
arch/arm/mach-at91/at91cap9_devices.c +7 -69

90 lines not on this page · raw message

arch/arm/mach-at91/at91rm9200_devices.c +7 -70

91 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +7 -71

92 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +7 -70

91 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +7 -70

91 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +14 -122

152 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +7 -70

91 lines not on this page · raw message

arch/arm/mach-at91/board-afeb-9260v1.c +1 -1
index 88d08ae..c64b7d6 100644
@@ -208,7 +208,7 @@ static void __init afeb9260_board_init(void)
 	/* MMC */
 	at91_add_device_mmc(0, &afeb9260_mmc_data);
 	/* I2C */
-	at91_add_device_i2c(afeb9260_i2c_devices,
+	at91_add_device_i2c(0, afeb9260_i2c_devices,
 			ARRAY_SIZE(afeb9260_i2c_devices));
 	/* Audio */
 	at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
arch/arm/mach-at91/board-at572d940hf_ek.c +1 -1
index c9ab05d..edbbce4 100644
@@ -301,7 +301,7 @@ static void __init eb_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&eb_udc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* NOR */
 	eb_add_device_nor();
 	/* NAND */
arch/arm/mach-at91/board-cap9adk.c +1 -1
index 0d60378..4fe8c55 100644
@@ -390,7 +390,7 @@ static void __init cap9adk_board_init(void)
 	/* NOR Flash */
 	cap9adk_add_device_nor();
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* LCD Controller */
 	at91_add_device_lcdc(&cap9adk_lcdc_data);
 	/* AC97 */
arch/arm/mach-at91/board-carmeva.c +1 -1
index 9d007a8..b9033cb 100644
@@ -149,7 +149,7 @@ static void __init carmeva_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&carmeva_udc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* SPI */
 	at91_add_device_spi(carmeva_spi_devices, ARRAY_SIZE(carmeva_spi_devices));
 	/* Compact Flash */
arch/arm/mach-at91/board-cpu9krea.c +1 -1
index 65c6513..9a88ca0 100644
@@ -361,7 +361,7 @@ static void __init cpu9krea_board_init(void)
 	/* MMC */
 	at91_add_device_mmc(0, &cpu9krea_mmc_data);
 	/* I2C */
-	at91_add_device_i2c(cpu9krea_i2c_devices,
+	at91_add_device_i2c(0, cpu9krea_i2c_devices,
 		ARRAY_SIZE(cpu9krea_i2c_devices));
 	/* LEDs */
 	at91_gpio_leds(cpu9krea_leds, ARRAY_SIZE(cpu9krea_leds));
arch/arm/mach-at91/board-cpuat91.c +1 -1
index ce3525d..fbdd54b 100644
@@ -168,7 +168,7 @@ static void __init cpuat91_board_init(void)
 	/* MMC */
 	at91_add_device_mmc(0, &cpuat91_mmc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* Platform devices */
 	platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
 }
arch/arm/mach-at91/board-csb337.c +1 -1
index ff7b8c0..f611720 100644
@@ -239,7 +239,7 @@ static void __init csb337_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&csb337_udc_data);
 	/* I2C */
-	at91_add_device_i2c(csb337_i2c_devices, ARRAY_SIZE(csb337_i2c_devices));
+	at91_add_device_i2c(0, csb337_i2c_devices, ARRAY_SIZE(csb337_i2c_devices));
 	/* Compact Flash */
 	at91_set_gpio_input(AT91_PIN_PB22, 1);		/* IOIS16 */
 	at91_add_device_cf(&csb337_cf_data);
arch/arm/mach-at91/board-csb637.c +1 -1
index 74d5b7e..bc26bf7 100644
@@ -129,7 +129,7 @@ static void __init csb637_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&csb637_udc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* SPI */
 	at91_add_device_spi(NULL, 0);
 	/* NOR flash */
arch/arm/mach-at91/board-eb9200.c +1 -1
index 3705082..eed4d6c 100644
@@ -109,7 +109,7 @@ static void __init eb9200_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&eb9200_udc_data);
 	/* I2C */
-	at91_add_device_i2c(eb9200_i2c_devices, ARRAY_SIZE(eb9200_i2c_devices));
+	at91_add_device_i2c(0, eb9200_i2c_devices, ARRAY_SIZE(eb9200_i2c_devices));
 	/* Compact Flash */
 	at91_add_device_cf(&eb9200_cf_data);
 	/* SPI */
arch/arm/mach-at91/board-ecbat91.c +1 -1
index df4a07f..b730b01 100644
@@ -157,7 +157,7 @@ static void __init ecb_at91board_init(void)
 	at91_add_device_usbh_ohci(&ecb_at91usbh_data);
 
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 
 	/* MMC */
 	at91_add_device_mmc(0, &ecb_at91mmc_data);
arch/arm/mach-at91/board-foxg20.c +1 -1
index 6688ec2..79c54fc 100644
@@ -254,7 +254,7 @@ static void __init foxg20_board_init(void)
 	/* MMC */
 	at91_add_device_mmc(0, &foxg20_mmc_data);
 	/* I2C */
-	at91_add_device_i2c(foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices));
+	at91_add_device_i2c(0, foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices));
 	/* LEDs */
 	at91_gpio_leds(foxg20_leds, ARRAY_SIZE(foxg20_leds));
 	/* Push Buttons */
arch/arm/mach-at91/board-gsia18s.c +1 -1
index 8b1d498..e32833d 100644
@@ -567,7 +567,7 @@ static void __init gsia18s_board_init(void)
 	gsia18s_leds_init();
 	gsia18s_pcf_leds_init();
 	gsia18s_add_device_buttons();
-	at91_add_device_i2c(gsia18s_i2c_devices,
+	at91_add_device_i2c(0, gsia18s_i2c_devices,
 				ARRAY_SIZE(gsia18s_i2c_devices));
 	at91_add_device_cf(&gsia18s_cf1_data);
 	at91_add_device_spi(gsia18s_spi_devices,
arch/arm/mach-at91/board-kafa.c +1 -1
index a0cac24..1edff1b 100644
@@ -87,7 +87,7 @@ static void __init kafa_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&kafa_udc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* SPI */
 	at91_add_device_spi(NULL, 0);
 }
arch/arm/mach-at91/board-kb9202.c +1 -1
index 59eafa2..682e9f4 100644
@@ -127,7 +127,7 @@ static void __init kb9202_board_init(void)
 	/* MMC */
 	at91_add_device_mmc(0, &kb9202_mmc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* SPI */
 	at91_add_device_spi(NULL, 0);
 	/* NAND */
arch/arm/mach-at91/board-neocore926.c +1 -1
index bffbbdf..f2c79fb 100644
@@ -373,7 +373,7 @@ static void __init neocore926_board_init(void)
 	neocore926_add_device_nand();
 
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 
 	/* LCD Controller */
 	at91_add_device_lcdc(&neocore926_lcdc_data);
arch/arm/mach-at91/board-pcontrol-g20.c +1 -1
index 4c5848d..ad9cc28 100644
@@ -207,7 +207,7 @@ static void __init pcontrol_g20_board_init(void)
 	stamp9g20_board_init();
 	at91_add_device_usbh_ohci(&usbh_data);
 	at91_add_device_eth(&macb_data);
-	at91_add_device_i2c(pcontrol_g20_i2c_devices,
+	at91_add_device_i2c(0, pcontrol_g20_i2c_devices,
 		ARRAY_SIZE(pcontrol_g20_i2c_devices));
 	add_device_pcontrol();
 	at91_add_device_spi(pcontrol_g20_spi_devices,
arch/arm/mach-at91/board-picotux200.c +1 -1
index 419456d..2b0958b 100644
@@ -113,7 +113,7 @@ static void __init picotux200_board_init(void)
 	/* USB Host */
 	at91_add_device_usbh_ohci(&picotux200_usbh_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* MMC */
 	at91_set_gpio_output(AT91_PIN_PB22, 1);	/* this MMC card slot can optionally use SPI signaling (CS3). */
 	at91_add_device_mmc(0, &picotux200_mmc_data);
arch/arm/mach-at91/board-qil-a9260.c +1 -1
index 255a984..c00b292 100644
@@ -252,7 +252,7 @@ static void __init ek_board_init(void)
 	/* NAND */
 	ek_add_device_nand();
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* Ethernet */
 	at91_add_device_eth(&ek_macb_data);
 	/* MMC */
arch/arm/mach-at91/board-rm9200dk.c +1 -1
index 3d54963..746b6ea 100644
@@ -204,7 +204,7 @@ static void __init dk_board_init(void)
 	/* Compact Flash */
 	at91_add_device_cf(&dk_cf_data);
 	/* I2C */
-	at91_add_device_i2c(dk_i2c_devices, ARRAY_SIZE(dk_i2c_devices));
+	at91_add_device_i2c(0, dk_i2c_devices, ARRAY_SIZE(dk_i2c_devices));
 	/* SPI */
 	at91_add_device_spi(dk_spi_devices, ARRAY_SIZE(dk_spi_devices));
 #ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
arch/arm/mach-at91/board-rm9200ek.c +1 -1
index 25fe19f..5e1dca0 100644
@@ -172,7 +172,7 @@ static void __init ek_board_init(void)
 	at91_add_device_udc(&ek_udc_data);
 	at91_set_multi_drive(ek_udc_data.pullup_pin, 1);	/* pullup_pin is connected to reset */
 	/* I2C */
-	at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
+	at91_add_device_i2c(0, ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
 	/* SPI */
 	at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
 #ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
arch/arm/mach-at91/board-sam9-l9260.c +1 -1
index 589e2f4..bc62008 100644
@@ -207,7 +207,7 @@ static void __init ek_board_init(void)
 	/* MMC */
 	at91_add_device_mmc(0, &ek_mmc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 }
 
 MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
arch/arm/mach-at91/board-sam9260ek.c +1 -1
index b98e766..c8c53ac 100644
@@ -344,7 +344,7 @@ static void __init ek_board_init(void)
 	/* MMC */
 	at91_add_device_mmc(0, &ek_mmc_data);
 	/* I2C */
-	at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
+	at91_add_device_i2c(0, ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
 	/* SSC (to AT73C213) */
 	at73c213_set_clk(&at73c213_data);
 	at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
arch/arm/mach-at91/board-sam9261ek.c +1 -1
index e631172..3e848ba 100644
@@ -590,7 +590,7 @@ static void __init ek_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&ek_udc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* NAND */
 	ek_add_device_nand();
 	/* DM9000 ethernet */
arch/arm/mach-at91/board-sam9263ek.c +1 -1
index fae6ebf..5e1aac1 100644
@@ -438,7 +438,7 @@ static void __init ek_board_init(void)
 	/* NAND */
 	ek_add_device_nand();
 	/* I2C */
-	at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
+	at91_add_device_i2c(0, ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
 	/* LCD Controller */
 	at91_add_device_lcdc(&ek_lcdc_data);
 	/* Push Buttons */
arch/arm/mach-at91/board-sam9g20ek.c +1 -1
index c25e44c..3dd5013 100644
@@ -393,7 +393,7 @@ static void __init ek_board_init(void)
 	/* MMC */
 	ek_add_device_mmc();
 	/* I2C */
-	at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
+	at91_add_device_i2c(0, ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
 	/* LEDs */
 	ek_add_device_gpio_leds();
 	/* Push Buttons */
arch/arm/mach-at91/board-sam9rlek.c +1 -1
index 3bf3408..475b485 100644
@@ -308,7 +308,7 @@ static void __init ek_board_init(void)
 	/* USB HS */
 	at91_add_device_usba(&ek_usba_udc_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* NAND */
 	ek_add_device_nand();
 	/* SPI */
arch/arm/mach-at91/board-snapper9260.c +1 -1
index ca14290..e93a11b 100644
@@ -166,7 +166,7 @@ static void __init snapper9260_add_device_nand(void)
 
 static void __init snapper9260_board_init(void)
 {
-	at91_add_device_i2c(snapper9260_i2c_devices,
+	at91_add_device_i2c(0, snapper9260_i2c_devices,
 			    ARRAY_SIZE(snapper9260_i2c_devices));
 	at91_add_device_serial();
 	at91_add_device_usbh_ohci(&snapper9260_usbh_data);
arch/arm/mach-at91/board-stamp9g20.c +2 -2
index 1e7a73a..9b7f333 100644
@@ -274,7 +274,7 @@ static void __init portuxg20_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&macb_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* SPI */
 	at91_add_device_spi(portuxg20_spi_devices, ARRAY_SIZE(portuxg20_spi_devices));
 	/* LEDs */
@@ -291,7 +291,7 @@ static void __init stamp9g20evb_board_init(void)
 	/* Ethernet */
 	at91_add_device_eth(&macb_data);
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* LEDs */
 	at91_gpio_leds(stamp9g20evb_leds, ARRAY_SIZE(stamp9g20evb_leds));
 }
arch/arm/mach-at91/board-usb-a9260.c +1 -1
index 9b5cbf5..8c3bbde 100644
@@ -214,7 +214,7 @@ static void __init ek_board_init(void)
 	/* NAND */
 	ek_add_device_nand();
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* Ethernet */
 	at91_add_device_eth(&ek_macb_data);
 	/* Push Buttons */
arch/arm/mach-at91/board-usb-a9263.c +1 -1
index 535af00..6e9f2ef 100644
@@ -232,7 +232,7 @@ static void __init ek_board_init(void)
 	/* NAND */
 	ek_add_device_nand();
 	/* I2C */
-	at91_add_device_i2c(NULL, 0);
+	at91_add_device_i2c(0, NULL, 0);
 	/* Push Buttons */
 	ek_add_device_buttons();
 	/* LEDs */
arch/arm/mach-at91/board-yl-9200.c +1 -1
index bd5ebfd..ef80db1 100644
@@ -571,7 +571,7 @@ static void __init yl9200_board_init(void)
 	/* USB Device */
 	at91_add_device_udc(&yl9200_udc_data);
 	/* I2C */
-	at91_add_device_i2c(yl9200_i2c_devices, ARRAY_SIZE(yl9200_i2c_devices));
+	at91_add_device_i2c(0, yl9200_i2c_devices, ARRAY_SIZE(yl9200_i2c_devices));
 	/* MMC */
 	at91_add_device_mmc(0, &yl9200_mmc_data);
 	/* NAND */
arch/arm/mach-at91/devices.c +122 -0

134 lines not on this page · raw message

arch/arm/mach-at91/devices.h +9 -0
index 3e9ec54..9b99be2 100644
@@ -73,6 +73,14 @@ struct at91_dev_table_nand {
 	int			nr_pins;
 };
 
+struct at91_dev_table_twi {
+	unsigned		mmio_base;
+	int			irq;
+	struct at91_pin_config	scl_pin;
+	struct at91_pin_config	sda_pin;
+	int			udelay;		/* For i2c-gpio */
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -80,6 +88,7 @@ struct at91_device_table {
 	struct at91_dev_table_basic_device	*udc;
 	struct at91_dev_table_mmc		*mmc[2];
 	struct at91_dev_table_nand		*nand;
+	struct at91_dev_table_twi		*twi[2];
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
arch/arm/mach-at91/include/mach/board.h +0 -4
index dd0855d..94232a4 100644
@@ -116,11 +116,7 @@ struct atmel_nand_data {
 extern void __init at91_add_device_nand(struct atmel_nand_data *data);
 
  /* I2C*/
-#if defined(CONFIG_ARCH_AT91SAM9G45)
 extern void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices);
-#else
-extern void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices);
-#endif
 
  /* SPI */
 extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices);
Signature · 1 line
1.7.0.4
#11 lore raw

PATCH v3 8/23 at91: Make SPI device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at572d940hf_devices.c |  122 +++++-------------------------
 arch/arm/mach-at91/at91cap9_devices.c    |  122 +++++-------------------------
 arch/arm/mach-at91/at91rm9200_devices.c  |   69 ++---------------
 arch/arm/mach-at91/at91sam9260_devices.c |  122 +++++-------------------------
 arch/arm/mach-at91/at91sam9261_devices.c |  122 +++++-------------------------
 arch/arm/mach-at91/at91sam9263_devices.c |  122 +++++-------------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |  122 +++++-------------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   67 ++--------------
 arch/arm/mach-at91/devices.c             |  103 +++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |   11 +++
 10 files changed, 252 insertions(+), 730 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +20 -102
index 482de24..5f497c6 100644
@@ -142,114 +142,30 @@ static struct at91_dev_table_twi device_twi1 __initdata = {
  *  SPI
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
-static u64 spi_dmamask = DMA_BIT_MASK(32);
-
-static struct resource spi0_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_SPI0,
-		.end	= AT572D940HF_BASE_SPI0 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_SPI0,
-		.end	= AT572D940HF_ID_SPI0,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at572d940hf_spi0_device = {
-	.name		= "atmel_spi",
-	.id		= 0,
-	.dev		= {
-				.dma_mask		= &spi_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
+static struct at91_dev_table_spi device_spi0 __initdata = {
+	.mmio_base		= AT572D940HF_BASE_SPI0,
+	.irq			= AT572D940HF_ID_SPI0,
+	.clk_asc		= "spi0_clk",
+	.standard_cs_pins	= {
+		AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6,
 	},
-	.resource	= spi0_resources,
-	.num_resources	= ARRAY_SIZE(spi0_resources),
+	.pin_miso		= {AT91_PIN_PA0, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.pin_mosi		= {AT91_PIN_PA1, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.pin_spck		= {AT91_PIN_PA2, AT91_PIN_PERIPH_A, 0, 0, 0},
 };
 
-static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
-
-static struct resource spi1_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_SPI1,
-		.end	= AT572D940HF_BASE_SPI1 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_SPI1,
-		.end	= AT572D940HF_ID_SPI1,
-		.flags	= IORESOURCE_IRQ,
+static struct at91_dev_table_spi device_spi1 __initdata = {
+	.mmio_base		= AT572D940HF_BASE_SPI1,
+	.irq			= AT572D940HF_ID_SPI1,
+	.clk_asc		= "spi1_clk",
+	.standard_cs_pins	= {
+		AT91_PIN_PC3, AT91_PIN_PC4, AT91_PIN_PC5, AT91_PIN_PC6,
 	},
+	.pin_miso		= {AT91_PIN_PC0, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.pin_mosi		= {AT91_PIN_PC1, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.pin_spck		= {AT91_PIN_PC2, AT91_PIN_PERIPH_A, 0, 0, 0},
 };
 
-static struct platform_device at572d940hf_spi1_device = {
-	.name		= "atmel_spi",
-	.id		= 1,
-	.dev		= {
-				.dma_mask		= &spi_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-	},
-	.resource	= spi1_resources,
-	.num_resources	= ARRAY_SIZE(spi1_resources),
-};
-
-static const unsigned spi1_standard_cs[4] = { AT91_PIN_PC3, AT91_PIN_PC4, AT91_PIN_PC5, AT91_PIN_PC6 };
-
-void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
-{
-	int i;
-	unsigned long cs_pin;
-	short enable_spi0 = 0;
-	short enable_spi1 = 0;
-
-	/* Choose SPI chip-selects */
-	for (i = 0; i < nr_devices; i++) {
-		if (devices[i].controller_data)
-			cs_pin = (unsigned long) devices[i].controller_data;
-		else if (devices[i].bus_num == 0)
-			cs_pin = spi0_standard_cs[devices[i].chip_select];
-		else
-			cs_pin = spi1_standard_cs[devices[i].chip_select];
-
-		if (devices[i].bus_num == 0)
-			enable_spi0 = 1;
-		else
-			enable_spi1 = 1;
-
-		/* enable chip-select pin */
-		at91_set_gpio_output(cs_pin, 1);
-
-		/* pass chip-select pin to driver */
-		devices[i].controller_data = (void *) cs_pin;
-	}
-
-	spi_register_board_info(devices, nr_devices);
-
-	/* Configure SPI bus(es) */
-	if (enable_spi0) {
-		at91_set_A_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
-		at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
-		at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
-
-		at91_clock_associate("spi0_clk", &at572d940hf_spi0_device.dev, "spi_clk");
-		platform_device_register(&at572d940hf_spi0_device);
-	}
-	if (enable_spi1) {
-		at91_set_A_periph(AT91_PIN_PC0, 0);	/* SPI1_MISO */
-		at91_set_A_periph(AT91_PIN_PC1, 0);	/* SPI1_MOSI */
-		at91_set_A_periph(AT91_PIN_PC2, 0);	/* SPI1_SPCK */
-
-		at91_clock_associate("spi1_clk", &at572d940hf_spi1_device.dev, "spi_clk");
-		platform_device_register(&at572d940hf_spi1_device);
-	}
-}
-#else
-void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  Timer/Counter blocks
  * -------------------------------------------------------------------- */
@@ -661,6 +577,8 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
 	.nand		= &device_nand,
 	.twi[0]		= &device_twi0,
 	.twi[1]		= &device_twi1,
+	.spi[0]		= &device_spi0,
+	.spi[1]		= &device_spi1,
 };
 
 void __init at572d940hf_init_devices(void)
arch/arm/mach-at91/at91cap9_devices.c +20 -102

140 lines not on this page · raw message

arch/arm/mach-at91/at91rm9200_devices.c +9 -60

84 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +20 -102

140 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +20 -102

140 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +20 -102

140 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +20 -102

140 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +9 -58

82 lines not on this page · raw message

arch/arm/mach-at91/devices.c +103 -0

109 lines not on this page · raw message

arch/arm/mach-at91/devices.h +11 -0
index 9b99be2..ba85523 100644
@@ -81,6 +81,16 @@ struct at91_dev_table_twi {
 	int			udelay;		/* For i2c-gpio */
 };
 
+struct at91_dev_table_spi {
+	unsigned		mmio_base;
+	int			irq;
+	const char		*clk_asc;
+	int			standard_cs_pins[4];
+	struct at91_pin_config	pin_miso;
+	struct at91_pin_config	pin_mosi;
+	struct at91_pin_config	pin_spck;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -89,6 +99,7 @@ struct at91_device_table {
 	struct at91_dev_table_mmc		*mmc[2];
 	struct at91_dev_table_nand		*nand;
 	struct at91_dev_table_twi		*twi[2];
+	struct at91_dev_table_spi		*spi[2];
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#12 lore raw

PATCH v3 9/23 at91: Make TCB device common

In reply to Ryan Mallon

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

This also fixes a bug on the AT572D940HF, where at91_add_device_tc was never called.

---
 arch/arm/mach-at91/at572d940hf_devices.c |   52 +++-------------
 arch/arm/mach-at91/at91cap9_devices.c    |   38 +++---------
 arch/arm/mach-at91/at91rm9200_devices.c  |   93 ++++++----------------------
 arch/arm/mach-at91/at91sam9260_devices.c |   91 ++++++----------------------
 arch/arm/mach-at91/at91sam9261_devices.c |   52 +++-------------
 arch/arm/mach-at91/at91sam9263_devices.c |   38 +++---------
 arch/arm/mach-at91/at91sam9g45_devices.c |   64 +++++--------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   52 +++-------------
 arch/arm/mach-at91/devices.c             |   99 ++++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |   13 ++++
 10 files changed, 212 insertions(+), 380 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +10 -42
index 5f497c6..f5f35e1 100644
@@ -170,51 +170,19 @@ static struct at91_dev_table_spi device_spi1 __initdata = {
  *  Timer/Counter blocks
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_ATMEL_TCLIB
-
-static struct resource tcb_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_TCB,
-		.end	= AT572D940HF_BASE_TCB + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_TC0,
-		.end	= AT572D940HF_ID_TC0,
-		.flags	= IORESOURCE_IRQ,
-	},
-	[2] = {
-		.start	= AT572D940HF_ID_TC1,
-		.end	= AT572D940HF_ID_TC1,
-		.flags	= IORESOURCE_IRQ,
-	},
-	[3] = {
-		.start	= AT572D940HF_ID_TC2,
-		.end	= AT572D940HF_ID_TC2,
-		.flags	= IORESOURCE_IRQ,
-	},
+static struct at91_tcb_res tcb_resources[] __initdata = {
+	/* this chip has a separate clock and irq for each TC channel */
+	{AT572D940HF_ID_TC0, "tc0_clk", "t0_clk"},
+	{AT572D940HF_ID_TC1, "tc1_clk", "t1_clk"},
+	{AT572D940HF_ID_TC2, "tc2_clk", "t2_clk"},
 };
 
-static struct platform_device at572d940hf_tcb_device = {
-	.name		= "atmel_tcb",
-	.id		= 0,
-	.resource	= tcb_resources,
-	.num_resources	= ARRAY_SIZE(tcb_resources),
+static struct at91_dev_table_tcb device_tcb __initdata = {
+	.mmio_base	= AT572D940HF_BASE_TCB,
+	.resources	= tcb_resources,
+	.nr_resources	= ARRAY_SIZE(tcb_resources),
 };
 
-static void __init at91_add_device_tc(void)
-{
-	/* this chip has a separate clock and irq for each TC channel */
-	at91_clock_associate("tc0_clk", &at572d940hf_tcb_device.dev, "t0_clk");
-	at91_clock_associate("tc1_clk", &at572d940hf_tcb_device.dev, "t1_clk");
-	at91_clock_associate("tc2_clk", &at572d940hf_tcb_device.dev, "t2_clk");
-	platform_device_register(&at572d940hf_tcb_device);
-}
-#else
-static void __init at91_add_device_tc(void) { }
-#endif
-
-
 /* --------------------------------------------------------------------
  *  RTT
  * -------------------------------------------------------------------- */
@@ -579,6 +547,7 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
 	.twi[1]		= &device_twi1,
 	.spi[0]		= &device_spi0,
 	.spi[1]		= &device_spi1,
+	.tcb[0]		= &device_tcb,
 };
 
 void __init at572d940hf_init_devices(void)
@@ -596,7 +565,6 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_rtt();
 	at91_add_device_watchdog();
-	at91_add_device_tc();
 	return 0;
 }
 
arch/arm/mach-at91/at91cap9_devices.c +8 -30
index a54b6a5..555221e 100644
@@ -279,39 +279,17 @@ static struct at91_dev_table_spi device_spi1 __initdata = {
  *  Timer/Counter block
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_ATMEL_TCLIB
-
-static struct resource tcb_resources[] = {
-	[0] = {
-		.start	= AT91CAP9_BASE_TCB0,
-		.end	= AT91CAP9_BASE_TCB0 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91CAP9_ID_TCB,
-		.end	= AT91CAP9_ID_TCB,
-		.flags	= IORESOURCE_IRQ,
-	},
+static struct at91_tcb_res tcb_resources[] __initdata = {
+	/* this chip has one clock and irq for all three TC channels */
+	{AT91CAP9_ID_TCB, "tcb_clk", "t0_clk"},
 };
 
-static struct platform_device at91cap9_tcb_device = {
-	.name		= "atmel_tcb",
-	.id		= 0,
-	.resource	= tcb_resources,
-	.num_resources	= ARRAY_SIZE(tcb_resources),
+static struct at91_dev_table_tcb device_tcb __initdata = {
+	.mmio_base	= AT91CAP9_BASE_TCB0,
+	.resources	= tcb_resources,
+	.nr_resources	= ARRAY_SIZE(tcb_resources),
 };
 
-static void __init at91_add_device_tc(void)
-{
-	/* this chip has one clock and irq for all three TC channels */
-	at91_clock_associate("tcb_clk", &at91cap9_tcb_device.dev, "t0_clk");
-	platform_device_register(&at91cap9_tcb_device);
-}
-#else
-static void __init at91_add_device_tc(void) { }
-#endif
-
-
 /* --------------------------------------------------------------------
  *  RTT
  * -------------------------------------------------------------------- */
@@ -907,6 +885,7 @@ static struct at91_device_table at91cap9_device_table __initdata = {
 	.twi[0]		= &device_twi,
 	.spi[0]		= &device_spi0,
 	.spi[1]		= &device_spi1,
+	.tcb[0]		= &device_tcb,
 };
 
 void __init at91cap9_init_devices(void)
@@ -923,7 +902,6 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_rtt();
 	at91_add_device_watchdog();
-	at91_add_device_tc();
 	return 0;
 }
 
arch/arm/mach-at91/at91rm9200_devices.c +20 -73

119 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +18 -73

117 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +10 -42

74 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +8 -30
index b049f93..1b488ec 100644
@@ -509,39 +509,17 @@ void __init at91_add_device_isi(void) {}
  *  Timer/Counter block
  * -------------------------------------------------------------------- */
 
-#ifdef CONFIG_ATMEL_TCLIB
-
-static struct resource tcb_resources[] = {
-	[0] = {
-		.start	= AT91SAM9263_BASE_TCB0,
-		.end	= AT91SAM9263_BASE_TCB0 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91SAM9263_ID_TCB,
-		.end	= AT91SAM9263_ID_TCB,
-		.flags	= IORESOURCE_IRQ,
-	},
+static struct at91_tcb_res tcb_resources[] __initdata = {
+	/* this chip has one clock and irq for all three TC channels */
+	{AT91SAM9263_ID_TCB, "tcb_clk", "t0_clk"},
 };
 
-static struct platform_device at91sam9263_tcb_device = {
-	.name		= "atmel_tcb",
-	.id		= 0,
-	.resource	= tcb_resources,
-	.num_resources	= ARRAY_SIZE(tcb_resources),
+static struct at91_dev_table_tcb device_tcb __initdata = {
+	.mmio_base	= AT91SAM9263_BASE_TCB0,
+	.resources	= tcb_resources,
+	.nr_resources	= ARRAY_SIZE(tcb_resources),
 };
 
-static void __init at91_add_device_tc(void)
-{
-	/* this chip has one clock and irq for all three TC channels */
-	at91_clock_associate("tcb_clk", &at91sam9263_tcb_device.dev, "t0_clk");
-	platform_device_register(&at91sam9263_tcb_device);
-}
-#else
-static void __init at91_add_device_tc(void) { }
-#endif
-
-
 /* --------------------------------------------------------------------
  *  RTT
  * -------------------------------------------------------------------- */
@@ -1027,6 +1005,7 @@ static struct at91_device_table at91sam9263_device_table __initdata = {
 	.twi[0]		= &device_twi,
 	.spi[0]		= &device_spi0,
 	.spi[1]		= &device_spi1,
+	.tcb[0]		= &device_tcb,
 };
 
 void __init at91sam9263_init_devices(void)
@@ -1043,7 +1022,6 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_rtt();
 	at91_add_device_watchdog();
-	at91_add_device_tc();
 	return 0;
 }
 
arch/arm/mach-at91/at91sam9g45_devices.c +16 -48

90 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +10 -42

74 lines not on this page · raw message

arch/arm/mach-at91/devices.c +99 -0

106 lines not on this page · raw message

arch/arm/mach-at91/devices.h +13 -0
index ba85523..41b6f6e 100644
@@ -91,6 +91,18 @@ struct at91_dev_table_spi {
 	struct at91_pin_config	pin_spck;
 };
 
+struct at91_tcb_res {
+	int			irq;
+	const char		*clock_asc;
+	const char		*clock_name;
+};
+
+struct at91_dev_table_tcb {
+	unsigned		mmio_base;
+	struct at91_tcb_res	*resources;
+	int			nr_resources;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -100,6 +112,7 @@ struct at91_device_table {
 	struct at91_dev_table_nand		*nand;
 	struct at91_dev_table_twi		*twi[2];
 	struct at91_dev_table_spi		*spi[2];
+	struct at91_dev_table_tcb		*tcb[2];
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#13 lore raw

PATCH v3 10/23 at91: Make RTT device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at572d940hf_devices.c |   23 ++------------
 arch/arm/mach-at91/at91cap9_devices.c    |   23 ++------------
 arch/arm/mach-at91/at91sam9260_devices.c |   23 ++------------
 arch/arm/mach-at91/at91sam9261_devices.c |   23 ++------------
 arch/arm/mach-at91/at91sam9263_devices.c |   40 +++--------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |   23 ++------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   23 ++------------
 arch/arm/mach-at91/devices.c             |   51 ++++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |    5 +++
 9 files changed, 80 insertions(+), 154 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +3 -20
index f5f35e1..c8be92a 100644
@@ -187,27 +187,10 @@ static struct at91_dev_table_tcb device_tcb __initdata = {
  *  RTT
  * -------------------------------------------------------------------- */
 
-static struct resource rtt_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT,
-		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device at572d940hf_rtt_device = {
-	.name		= "at91_rtt",
-	.id		= 0,
-	.resource	= rtt_resources,
-	.num_resources	= ARRAY_SIZE(rtt_resources),
+static struct at91_dev_table_rtt device_rtt __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT,
 };
 
-static void __init at91_add_device_rtt(void)
-{
-	platform_device_register(&at572d940hf_rtt_device);
-}
-
-
 /* --------------------------------------------------------------------
  *  Watchdog
  * -------------------------------------------------------------------- */
@@ -548,6 +531,7 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
 	.spi[0]		= &device_spi0,
 	.spi[1]		= &device_spi1,
 	.tcb[0]		= &device_tcb,
+	.rtt[0]		= &device_rtt,
 };
 
 void __init at572d940hf_init_devices(void)
@@ -563,7 +547,6 @@ void __init at572d940hf_init_devices(void)
  */
 static int __init at91_add_standard_devices(void)
 {
-	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	return 0;
 }
arch/arm/mach-at91/at91cap9_devices.c +3 -20
index 555221e..79778c9 100644
@@ -294,27 +294,10 @@ static struct at91_dev_table_tcb device_tcb __initdata = {
  *  RTT
  * -------------------------------------------------------------------- */
 
-static struct resource rtt_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT,
-		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device at91cap9_rtt_device = {
-	.name		= "at91_rtt",
-	.id		= 0,
-	.resource	= rtt_resources,
-	.num_resources	= ARRAY_SIZE(rtt_resources),
+static struct at91_dev_table_rtt device_rtt __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT,
 };
 
-static void __init at91_add_device_rtt(void)
-{
-	platform_device_register(&at91cap9_rtt_device);
-}
-
-
 /* --------------------------------------------------------------------
  *  Watchdog
  * -------------------------------------------------------------------- */
@@ -886,6 +869,7 @@ static struct at91_device_table at91cap9_device_table __initdata = {
 	.spi[0]		= &device_spi0,
 	.spi[1]		= &device_spi1,
 	.tcb[0]		= &device_tcb,
+	.rtt[0]		= &device_rtt,
 };
 
 void __init at91cap9_init_devices(void)
@@ -900,7 +884,6 @@ void __init at91cap9_init_devices(void)
  */
 static int __init at91_add_standard_devices(void)
 {
-	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	return 0;
 }
arch/arm/mach-at91/at91sam9260_devices.c +3 -20
index 55dce25..d3d7fd5 100644
@@ -192,27 +192,10 @@ static struct at91_dev_table_tcb device_tcb1 __initdata = {
  *  RTT
  * -------------------------------------------------------------------- */
 
-static struct resource rtt_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT,
-		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device at91sam9260_rtt_device = {
-	.name		= "at91_rtt",
-	.id		= 0,
-	.resource	= rtt_resources,
-	.num_resources	= ARRAY_SIZE(rtt_resources),
+static struct at91_dev_table_rtt device_rtt __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT,
 };
 
-static void __init at91_add_device_rtt(void)
-{
-	platform_device_register(&at91sam9260_rtt_device);
-}
-
-
 /* --------------------------------------------------------------------
  *  Watchdog
  * -------------------------------------------------------------------- */
@@ -815,6 +798,7 @@ static struct at91_device_table at91sam9260_device_table __initdata = {
 	.spi[1]		= &device_spi1,
 	.tcb[0]		= &device_tcb0,
 	.tcb[1]		= &device_tcb1,
+	.rtt[0]		= &device_rtt,
 };
 
 void __init at91sam9260_init_devices(void)
@@ -829,7 +813,6 @@ void __init at91sam9260_init_devices(void)
  */
 static int __init at91_add_standard_devices(void)
 {
-	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	return 0;
 }
arch/arm/mach-at91/at91sam9261_devices.c +3 -20
index 558c593..2977c82 100644
@@ -244,27 +244,10 @@ static struct at91_dev_table_tcb device_tcb __initdata = {
  *  RTT
  * -------------------------------------------------------------------- */
 
-static struct resource rtt_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT,
-		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device at91sam9261_rtt_device = {
-	.name		= "at91_rtt",
-	.id		= 0,
-	.resource	= rtt_resources,
-	.num_resources	= ARRAY_SIZE(rtt_resources),
+static struct at91_dev_table_rtt device_rtt __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT,
 };
 
-static void __init at91_add_device_rtt(void)
-{
-	platform_device_register(&at91sam9261_rtt_device);
-}
-
-
 /* --------------------------------------------------------------------
  *  Watchdog
  * -------------------------------------------------------------------- */
@@ -701,6 +684,7 @@ static struct at91_device_table at91sam9261_device_table __initdata = {
 	.spi[0]		= &device_spi0,
 	.spi[1]		= &device_spi1,
 	.tcb[0]		= &device_tcb,
+	.rtt[0]		= &device_rtt,
 };
 
 void __init at91sam9261_init_devices(void)
@@ -716,7 +700,6 @@ void __init at91sam9261_init_devices(void)
  */
 static int __init at91_add_standard_devices(void)
 {
-	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	return 0;
 }
arch/arm/mach-at91/at91sam9263_devices.c +6 -34
index 1b488ec..7feb18e 100644
@@ -524,43 +524,14 @@ static struct at91_dev_table_tcb device_tcb __initdata = {
  *  RTT
  * -------------------------------------------------------------------- */
 
-static struct resource rtt0_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT0,
-		.end	= AT91_BASE_SYS + AT91_RTT0 + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device at91sam9263_rtt0_device = {
-	.name		= "at91_rtt",
-	.id		= 0,
-	.resource	= rtt0_resources,
-	.num_resources	= ARRAY_SIZE(rtt0_resources),
-};
-
-static struct resource rtt1_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT1,
-		.end	= AT91_BASE_SYS + AT91_RTT1 + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
+static struct at91_dev_table_rtt device_rtt0 __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT0,
 };
 
-static struct platform_device at91sam9263_rtt1_device = {
-	.name		= "at91_rtt",
-	.id		= 1,
-	.resource	= rtt1_resources,
-	.num_resources	= ARRAY_SIZE(rtt1_resources),
+static struct at91_dev_table_rtt device_rtt1 __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT1,
 };
 
-static void __init at91_add_device_rtt(void)
-{
-	platform_device_register(&at91sam9263_rtt0_device);
-	platform_device_register(&at91sam9263_rtt1_device);
-}
-
-
 /* --------------------------------------------------------------------
  *  Watchdog
  * -------------------------------------------------------------------- */
@@ -1006,6 +977,8 @@ static struct at91_device_table at91sam9263_device_table __initdata = {
 	.spi[0]		= &device_spi0,
 	.spi[1]		= &device_spi1,
 	.tcb[0]		= &device_tcb,
+	.rtt[0]		= &device_rtt0,
+	.rtt[1]		= &device_rtt1,
 };
 
 void __init at91sam9263_init_devices(void)
@@ -1020,7 +993,6 @@ void __init at91sam9263_init_devices(void)
  */
 static int __init at91_add_standard_devices(void)
 {
-	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	return 0;
 }
arch/arm/mach-at91/at91sam9g45_devices.c +3 -20
index f236ce8..3e1b5ff 100644
@@ -561,27 +561,10 @@ void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
  *  RTT
  * -------------------------------------------------------------------- */
 
-static struct resource rtt_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT,
-		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device at91sam9g45_rtt_device = {
-	.name		= "at91_rtt",
-	.id		= 0,
-	.resource	= rtt_resources,
-	.num_resources	= ARRAY_SIZE(rtt_resources),
+static struct at91_dev_table_rtt device_rtt __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT,
 };
 
-static void __init at91_add_device_rtt(void)
-{
-	platform_device_register(&at91sam9g45_rtt_device);
-}
-
-
 /* --------------------------------------------------------------------
  *  Watchdog
  * -------------------------------------------------------------------- */
@@ -1076,6 +1059,7 @@ static struct at91_device_table at91sam9g45_device_table __initdata = {
 	.spi[1]		= &device_spi1,
 	.tcb[0]		= &device_tcb0,
 	.tcb[1]		= &device_tcb1,
+	.rtt[0]		= &device_rtt,
 };
 
 void __init at91sam9g45_init_devices(void)
@@ -1092,7 +1076,6 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_hdmac();
 	at91_add_device_rtc();
-	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	return 0;
 }
arch/arm/mach-at91/at91sam9rl_devices.c +3 -20
index d462ba0..0d78c8f 100644
@@ -439,27 +439,10 @@ static void __init at91_add_device_rtc(void) {}
  *  RTT
  * -------------------------------------------------------------------- */
 
-static struct resource rtt_resources[] = {
-	{
-		.start	= AT91_BASE_SYS + AT91_RTT,
-		.end	= AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
-		.flags	= IORESOURCE_MEM,
-	}
-};
-
-static struct platform_device at91sam9rl_rtt_device = {
-	.name		= "at91_rtt",
-	.id		= 0,
-	.resource	= rtt_resources,
-	.num_resources	= ARRAY_SIZE(rtt_resources),
+static struct at91_dev_table_rtt device_rtt __initdata = {
+	.mmio_base	=  AT91_BASE_SYS + AT91_RTT,
 };
 
-static void __init at91_add_device_rtt(void)
-{
-	platform_device_register(&at91sam9rl_rtt_device);
-}
-
-
 /* --------------------------------------------------------------------
  *  Watchdog
  * -------------------------------------------------------------------- */
@@ -955,6 +938,7 @@ static struct at91_device_table at91sam9rl_device_table __initdata = {
 	.twi[0]		= &device_twi,
 	.spi[0]		= &device_spi,
 	.tcb[0]		= &device_tcb,
+	.rtt[0]		= &device_rtt,
 };
 
 void __init at91sam9rl_init_devices(void)
@@ -972,7 +956,6 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_hdmac();
 	at91_add_device_rtc();
-	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	return 0;
 }
arch/arm/mach-at91/devices.c +51 -0

63 lines not on this page · raw message

arch/arm/mach-at91/devices.h +5 -0
index 41b6f6e..d7855ec 100644
@@ -103,6 +103,10 @@ struct at91_dev_table_tcb {
 	int			nr_resources;
 };
 
+struct at91_dev_table_rtt {
+	unsigned		mmio_base;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -113,6 +117,7 @@ struct at91_device_table {
 	struct at91_dev_table_twi		*twi[2];
 	struct at91_dev_table_spi		*spi[2];
 	struct at91_dev_table_tcb		*tcb[2];
+	struct at91_dev_table_rtt		*rtt[2];
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#14 lore raw

PATCH v3 11/23 at91: Make watchdog device common

In reply to Ryan Mallon

The code for the watchdog device for each of the at91 variants is identical. Remove it from each variant and replace them with a single version in devices.c

---
 arch/arm/mach-at91/at572d940hf_devices.c |   34 ------------------------------
 arch/arm/mach-at91/at91cap9_devices.c    |   33 -----------------------------
 arch/arm/mach-at91/at91rm9200_devices.c  |   22 -------------------
 arch/arm/mach-at91/at91sam9260_devices.c |   33 -----------------------------
 arch/arm/mach-at91/at91sam9261_devices.c |   34 ------------------------------
 arch/arm/mach-at91/at91sam9263_devices.c |   33 -----------------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |   21 ------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   21 ------------------
 arch/arm/mach-at91/devices.c             |   23 ++++++++++++++++++++
 9 files changed, 23 insertions(+), 231 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +0 -34
index c8be92a..9220201 100644
@@ -192,26 +192,6 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
-static struct platform_device at572d940hf_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at572d940hf_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  UART
  * -------------------------------------------------------------------- */
 
@@ -538,17 +518,3 @@ void __init at572d940hf_init_devices(void)
 {
 	at91_init_devices(&at572d940hf_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_watchdog();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/at91cap9_devices.c +0 -33
index 79778c9..dce861c 100644
@@ -299,26 +299,6 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
-static struct platform_device at91cap9_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at91cap9_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  PWM
  * --------------------------------------------------------------------*/
 
@@ -876,16 +856,3 @@ void __init at91cap9_init_devices(void)
 {
 	at91_init_devices(&at91cap9_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_watchdog();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/at91rm9200_devices.c +0 -22
index 5e9f269..6cec253 100644
@@ -295,27 +295,6 @@ static void __init at91_add_device_rtc(void)
 static void __init at91_add_device_rtc(void) {}
 #endif
 
-
-/* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91RM9200_WATCHDOG) || defined(CONFIG_AT91RM9200_WATCHDOG_MODULE)
-static struct platform_device at91rm9200_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at91rm9200_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  SSC -- Synchronous Serial Controller
  * -------------------------------------------------------------------- */
@@ -812,7 +791,6 @@ void __init at91rm9200_init_devices(void)
 static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_rtc();
-	at91_add_device_watchdog();
 	return 0;
 }
 
arch/arm/mach-at91/at91sam9260_devices.c +0 -33
index d3d7fd5..8f1f866 100644
@@ -197,26 +197,6 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
-static struct platform_device at91sam9260_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at91sam9260_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  SSC -- Synchronous Serial Controller
  * -------------------------------------------------------------------- */
 
@@ -805,16 +785,3 @@ void __init at91sam9260_init_devices(void)
 {
 	at91_init_devices(&at91sam9260_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_watchdog();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/at91sam9261_devices.c +0 -34
index 2977c82..bc9f0c7 100644
@@ -249,26 +249,6 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
-static struct platform_device at91sam9261_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at91sam9261_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  SSC -- Synchronous Serial Controller
  * -------------------------------------------------------------------- */
 
@@ -691,17 +671,3 @@ void __init at91sam9261_init_devices(void)
 {
 	at91_init_devices(&at91sam9261_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_watchdog();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/at91sam9263_devices.c +0 -33
index 7feb18e..109e230 100644
@@ -533,26 +533,6 @@ static struct at91_dev_table_rtt device_rtt1 __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
-static struct platform_device at91sam9263_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at91sam9263_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  PWM
  * --------------------------------------------------------------------*/
 
@@ -985,16 +965,3 @@ void __init at91sam9263_init_devices(void)
 {
 	at91_init_devices(&at91sam9263_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_watchdog();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/at91sam9g45_devices.c +0 -21
index 3e1b5ff..96631f3 100644
@@ -566,26 +566,6 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
-static struct platform_device at91sam9g45_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at91sam9g45_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  PWM
  * --------------------------------------------------------------------*/
 
@@ -1076,7 +1056,6 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_hdmac();
 	at91_add_device_rtc();
-	at91_add_device_watchdog();
 	return 0;
 }
 
arch/arm/mach-at91/at91sam9rl_devices.c +0 -21
index 0d78c8f..fa11eac 100644
@@ -444,26 +444,6 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  Watchdog
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
-static struct platform_device at91sam9rl_wdt_device = {
-	.name		= "at91_wdt",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_watchdog(void)
-{
-	platform_device_register(&at91sam9rl_wdt_device);
-}
-#else
-static void __init at91_add_device_watchdog(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  PWM
  * --------------------------------------------------------------------*/
 
@@ -956,7 +936,6 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_hdmac();
 	at91_add_device_rtc();
-	at91_add_device_watchdog();
 	return 0;
 }
 
arch/arm/mach-at91/devices.c +23 -0
index 5e97738..760ed81 100644
@@ -973,6 +973,28 @@ static void __init at91_add_device_rtt(void)
 	}
 }
 
+/* --------------------------------------------------------------------
+ *  Watchdog
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_AT91SAM9X_WATCHDOG)        || \
+    defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) || \
+    defined(CONFIG_AT91RM9200_WATCHDOG)       || \
+    defined(CONFIG_AT91RM9200_WATCHDOG_MODULE)
+static struct platform_device at91_wdt_device = {
+	.name		= "at91_wdt",
+	.id		= -1,
+	.num_resources	= 0,
+};
+
+static void __init at91_add_device_watchdog(void)
+{
+	platform_device_register(&at91_wdt_device);
+}
+#else
+static void __init at91_add_device_watchdog(void) {}
+#endif
+
 void __init at91_init_devices(struct at91_device_table *device_table)
 {
 	devices = device_table;
@@ -982,6 +1004,7 @@ static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_tc();
 	at91_add_device_rtt();
+	at91_add_device_watchdog();
 	return 0;
 }
 
Signature · 1 line
1.7.0.4
#15 lore raw

PATCH v3 12/23 at91: Make UART devices common

In reply to Ryan Mallon

Replace the individual UART, including debug UART, code for each at91 variiant with a single implementation in devices.c

The original code used the interrupt numbers for the UARTs as unique identifiers. Because the interrupt numbers differ between the AT91 variants we introduce a new enum for the UART ids. The AT91_UARTx names are already used by the early UART code as the base address of the UART, so we cannot use those names. Instead we introduce AT91_UART_DBGU and AT91_UART_USx.

---
 arch/arm/mach-at91/at572d940hf_devices.c  |  267 +++--------------
 arch/arm/mach-at91/at91cap9_devices.c     |  285 ++++---------------
 arch/arm/mach-at91/at91rm9200_devices.c   |  358 +++++------------------
 arch/arm/mach-at91/at91sam9260_devices.c  |  449 ++++++-----------------------
 arch/arm/mach-at91/at91sam9261_devices.c  |  273 ++++--------------
 arch/arm/mach-at91/at91sam9263_devices.c  |  286 ++++---------------
 arch/arm/mach-at91/at91sam9g45_devices.c  |  348 +++++------------------
 arch/arm/mach-at91/at91sam9rl_devices.c   |  360 +++++------------------
 arch/arm/mach-at91/board-1arm.c           |    4 +-
 arch/arm/mach-at91/board-afeb-9260v1.c    |    4 +-
 arch/arm/mach-at91/board-at572d940hf_ek.c |    6 +-
 arch/arm/mach-at91/board-carmeva.c        |    2 +-
 arch/arm/mach-at91/board-cpu9krea.c       |   12 +-
 arch/arm/mach-at91/board-cpuat91.c        |    8 +-
 arch/arm/mach-at91/board-eb9200.c         |    4 +-
 arch/arm/mach-at91/board-ecbat91.c        |    2 +-
 arch/arm/mach-at91/board-foxg20.c         |   12 +-
 arch/arm/mach-at91/board-gsia18s.c        |   10 +-
 arch/arm/mach-at91/board-kafa.c           |    2 +-
 arch/arm/mach-at91/board-kb9202.c         |    6 +-
 arch/arm/mach-at91/board-neocore926.c     |    2 +-
 arch/arm/mach-at91/board-pcontrol-g20.c   |    6 +-
 arch/arm/mach-at91/board-picotux200.c     |    2 +-
 arch/arm/mach-at91/board-qil-a9260.c      |    6 +-
 arch/arm/mach-at91/board-rm9200dk.c       |    2 +-
 arch/arm/mach-at91/board-rm9200ek.c       |    2 +-
 arch/arm/mach-at91/board-sam9-l9260.c     |    4 +-
 arch/arm/mach-at91/board-sam9260ek.c      |    4 +-
 arch/arm/mach-at91/board-sam9263ek.c      |    2 +-
 arch/arm/mach-at91/board-sam9g20ek.c      |    4 +-
 arch/arm/mach-at91/board-sam9m10g45ek.c   |    2 +-
 arch/arm/mach-at91/board-sam9rlek.c       |    2 +-
 arch/arm/mach-at91/board-snapper9260.c    |    6 +-
 arch/arm/mach-at91/board-stamp9g20.c      |   12 +-
 arch/arm/mach-at91/board-yl-9200.c        |    6 +-
 arch/arm/mach-at91/devices.c              |  300 +++++++++++++++++++
 arch/arm/mach-at91/devices.h              |   17 ++
 arch/arm/mach-at91/include/mach/board.h   |   10 +
 38 files changed, 919 insertions(+), 2168 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +47 -220
index 9220201..9910fc8 100644
@@ -195,238 +195,61 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
  *  UART
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_SERIAL_ATMEL)
-static struct resource dbgu_resources[] = {
-	[0] = {
-		.start	= AT91_VA_BASE_SYS + AT91_DBGU,
-		.end	= AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
-		.flags	= IORESOURCE_MEM,
+static struct at91_dev_table_uart device_dbgu __initdata = {
+	.mmio_base	= AT91_VA_BASE_SYS + AT91_DBGU,
+	.irq		= AT91_ID_SYS,
+	.clock_asc	= "mck",
+	.uart_data	= {
+		.use_dma_tx	= 0,
+		.use_dma_rx	= 0,
+		.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
 	},
-	[1] = {
-		.start	= AT91_ID_SYS,
-		.end	= AT91_ID_SYS,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct atmel_uart_data dbgu_data = {
-	.use_dma_tx	= 0,
-	.use_dma_rx	= 0,		/* DBGU not capable of receive DMA */
-	.regs		= (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
-};
-
-static u64 dbgu_dmamask = DMA_BIT_MASK(32);
-
-static struct platform_device at572d940hf_dbgu_device = {
-	.name		= "atmel_usart",
-	.id		= 0,
-	.dev		= {
-				.dma_mask		= &dbgu_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &dbgu_data,
-	},
-	.resource	= dbgu_resources,
-	.num_resources	= ARRAY_SIZE(dbgu_resources),
-};
-
-static inline void configure_dbgu_pins(void)
-{
-	at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */
-	at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */
-}
-
-static struct resource uart0_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_US0,
-		.end	= AT572D940HF_BASE_US0 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_US0,
-		.end	= AT572D940HF_ID_US0,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct atmel_uart_data uart0_data = {
-	.use_dma_tx	= 1,
-	.use_dma_rx	= 1,
+	.tx_pin		= {AT91_PIN_PC31, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rx_pin		= {AT91_PIN_PC30, AT91_PIN_PERIPH_A, 0, 0, 0},
 };
 
-static u64 uart0_dmamask = DMA_BIT_MASK(32);
-
-static struct platform_device at572d940hf_uart0_device = {
-	.name		= "atmel_usart",
-	.id		= 1,
-	.dev		= {
-				.dma_mask		= &uart0_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &uart0_data,
+static struct at91_dev_table_uart device_uart0 __initdata = {
+	.mmio_base	= AT572D940HF_BASE_US0,
+	.irq		= AT572D940HF_ID_US0,
+	.clock_asc	= "usart0_clk",
+	.uart_data	= {
+		.use_dma_tx	= 1,
+		.use_dma_rx	= 1,
 	},
-	.resource	= uart0_resources,
-	.num_resources	= ARRAY_SIZE(uart0_resources),
+	.tx_pin		= {AT91_PIN_PA8,  AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rx_pin		= {AT91_PIN_PA7,  AT91_PIN_PERIPH_A, 0, 0, 0},
+	.rts_pin	= {AT91_PIN_PA10, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.cts_pin	= {AT91_PIN_PA9,  AT91_PIN_PERIPH_A, 0, 0, 0},
 };
 
-static inline void configure_usart0_pins(unsigned pins)
-{
-	at91_set_A_periph(AT91_PIN_PA8, 1);		/* TXD0 */
-	at91_set_A_periph(AT91_PIN_PA7, 0);		/* RXD0 */
-
-	if (pins & ATMEL_UART_RTS)
-		at91_set_A_periph(AT91_PIN_PA10, 0);	/* RTS0 */
-	if (pins & ATMEL_UART_CTS)
-		at91_set_A_periph(AT91_PIN_PA9, 0);	/* CTS0 */
-}
-
-static struct resource uart1_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_US1,
-		.end	= AT572D940HF_BASE_US1 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_US1,
-		.end	= AT572D940HF_ID_US1,
-		.flags	= IORESOURCE_IRQ,
+static struct at91_dev_table_uart device_uart1 __initdata = {
+	.mmio_base	= AT572D940HF_BASE_US1,
+	.irq		= AT572D940HF_ID_US1,
+	.clock_asc	= "usart1_clk",
+	.uart_data	= {
+		.use_dma_tx	= 1,
+		.use_dma_rx	= 1,
 	},
+	.tx_pin		= {AT91_PIN_PC10, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rx_pin		= {AT91_PIN_PC9,  AT91_PIN_PERIPH_A, 0, 0, 0},
+	.rts_pin	= {AT91_PIN_PA12, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.cts_pin	= {AT91_PIN_PA11, AT91_PIN_PERIPH_A, 0, 0, 0},
 };
 
-static struct atmel_uart_data uart1_data = {
-	.use_dma_tx	= 1,
-	.use_dma_rx	= 1,
-};
-
-static u64 uart1_dmamask = DMA_BIT_MASK(32);
-
-static struct platform_device at572d940hf_uart1_device = {
-	.name		= "atmel_usart",
-	.id		= 2,
-	.dev		= {
-				.dma_mask		= &uart1_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &uart1_data,
+static struct at91_dev_table_uart device_uart2 __initdata = {
+	.mmio_base	= AT572D940HF_BASE_US2,
+	.irq		= AT572D940HF_ID_US2,
+	.clock_asc	= "usart2_clk",
+	.uart_data	= {
+		.use_dma_tx	= 1,
+		.use_dma_rx	= 1,
 	},
-	.resource	= uart1_resources,
-	.num_resources	= ARRAY_SIZE(uart1_resources),
+	.tx_pin		= {AT91_PIN_PC15, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rx_pin		= {AT91_PIN_PC14,  AT91_PIN_PERIPH_A, 0, 0, 0},
+	.rts_pin	= {AT91_PIN_PA17, AT91_PIN_PERIPH_A, 0, 0, 0},
+	.cts_pin	= {AT91_PIN_PA16, AT91_PIN_PERIPH_A, 0, 0, 0},
 };
 
-static inline void configure_usart1_pins(unsigned pins)
-{
-	at91_set_A_periph(AT91_PIN_PC10, 1);		/* TXD1 */
-	at91_set_A_periph(AT91_PIN_PC9 , 0);		/* RXD1 */
-
-	if (pins & ATMEL_UART_RTS)
-		at91_set_A_periph(AT91_PIN_PC12, 0);	/* RTS1 */
-	if (pins & ATMEL_UART_CTS)
-		at91_set_A_periph(AT91_PIN_PC11, 0);	/* CTS1 */
-}
-
-static struct resource uart2_resources[] = {
-	[0] = {
-		.start	= AT572D940HF_BASE_US2,
-		.end	= AT572D940HF_BASE_US2 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT572D940HF_ID_US2,
-		.end	= AT572D940HF_ID_US2,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct atmel_uart_data uart2_data = {
-	.use_dma_tx	= 1,
-	.use_dma_rx	= 1,
-};
-
-static u64 uart2_dmamask = DMA_BIT_MASK(32);
-
-static struct platform_device at572d940hf_uart2_device = {
-	.name		= "atmel_usart",
-	.id		= 3,
-	.dev		= {
-				.dma_mask		= &uart2_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &uart2_data,
-	},
-	.resource	= uart2_resources,
-	.num_resources	= ARRAY_SIZE(uart2_resources),
-};
-
-static inline void configure_usart2_pins(unsigned pins)
-{
-	at91_set_A_periph(AT91_PIN_PC15, 1);		/* TXD2 */
-	at91_set_A_periph(AT91_PIN_PC14, 0);		/* RXD2 */
-
-	if (pins & ATMEL_UART_RTS)
-		at91_set_A_periph(AT91_PIN_PC17, 0);	/* RTS2 */
-	if (pins & ATMEL_UART_CTS)
-		at91_set_A_periph(AT91_PIN_PC16, 0);	/* CTS2 */
-}
-
-static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];	/* the UARTs to use */
-struct platform_device *atmel_default_console_device;	/* the serial console device */
-
-void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
-{
-	struct platform_device *pdev;
-
-	switch (id) {
-		case 0:		/* DBGU */
-			pdev = &at572d940hf_dbgu_device;
-			configure_dbgu_pins();
-			at91_clock_associate("mck", &pdev->dev, "usart");
-			break;
-		case AT572D940HF_ID_US0:
-			pdev = &at572d940hf_uart0_device;
-			configure_usart0_pins(pins);
-			at91_clock_associate("usart0_clk", &pdev->dev, "usart");
-			break;
-		case AT572D940HF_ID_US1:
-			pdev = &at572d940hf_uart1_device;
-			configure_usart1_pins(pins);
-			at91_clock_associate("usart1_clk", &pdev->dev, "usart");
-			break;
-		case AT572D940HF_ID_US2:
-			pdev = &at572d940hf_uart2_device;
-			configure_usart2_pins(pins);
-			at91_clock_associate("usart2_clk", &pdev->dev, "usart");
-			break;
-		default:
-			return;
-	}
-	pdev->id = portnr;		/* update to mapped ID */
-
-	if (portnr < ATMEL_MAX_UART)
-		at91_uarts[portnr] = pdev;
-}
-
-void __init at91_set_serial_console(unsigned portnr)
-{
-	if (portnr < ATMEL_MAX_UART)
-		atmel_default_console_device = at91_uarts[portnr];
-}
-
-void __init at91_add_device_serial(void)
-{
-	int i;
-
-	for (i = 0; i < ATMEL_MAX_UART; i++) {
-		if (at91_uarts[i])
-			platform_device_register(at91_uarts[i]);
-	}
-
-	if (!atmel_default_console_device)
-		printk(KERN_INFO "AT91: No default serial console defined.\n");
-}
-
-#else
-void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
-void __init at91_set_serial_console(unsigned portnr) {}
-void __init at91_add_device_serial(void) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  mAgic
  * -------------------------------------------------------------------- */
@@ -512,6 +335,10 @@ static struct at91_device_table at572d940hf_device_table __initdata = {
 	.spi[1]		= &device_spi1,
 	.tcb[0]		= &device_tcb,
 	.rtt[0]		= &device_rtt,
+	.dbgu		= &device_dbgu,
+	.uart[0]	= &device_uart0,
+	.uart[1]	= &device_uart1,
+	.uart[2]	= &device_uart2,
 };
 
 void __init at572d940hf_init_devices(void)
arch/arm/mach-at91/at91cap9_devices.c +57 -228

299 lines not on this page · raw message

arch/arm/mach-at91/at91rm9200_devices.c +74 -284

379 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +91 -358

475 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +51 -222

293 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +57 -229

300 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +72 -276

362 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +76 -284

374 lines not on this page · raw message

arch/arm/mach-at91/board-1arm.c +2 -2
index 244e8bb..9a4ff1b 100644
@@ -48,10 +48,10 @@ static void __init onearm_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
-	at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
+	at91_register_uart(AT91_UART_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
 
 	/* USART1 on ttyS2 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
-	at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS
+	at91_register_uart(AT91_UART_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS
 			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
 			   | ATMEL_UART_RI);
 
arch/arm/mach-at91/board-afeb-9260v1.c +2 -2
index c64b7d6..9c7073a 100644
@@ -57,13 +57,13 @@ static void __init afeb9260_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
-	at91_register_uart(AT91SAM9260_ID_US0, 1,
+	at91_register_uart(AT91_UART_US0, 1,
 			     ATMEL_UART_CTS | ATMEL_UART_RTS
 			   | ATMEL_UART_DTR | ATMEL_UART_DSR
 			   | ATMEL_UART_DCD | ATMEL_UART_RI);
 
 	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
-	at91_register_uart(AT91SAM9260_ID_US1, 2,
+	at91_register_uart(AT91_UART_US1, 2,
 			ATMEL_UART_CTS | ATMEL_UART_RTS);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
arch/arm/mach-at91/board-at572d940hf_ek.c +3 -3
index edbbce4..8955133 100644
@@ -55,13 +55,13 @@ static void __init eb_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1. (Rx & Tx only) */
-	at91_register_uart(AT572D940HF_ID_US0, 1, 0);
+	at91_register_uart(AT91_UART_US0, 1, 0);
 
 	/* USART1 on ttyS2. (Rx & Tx only) */
-	at91_register_uart(AT572D940HF_ID_US1, 2, 0);
+	at91_register_uart(AT91_UART_US1, 2, 0);
 
 	/* USART2 on ttyS3. (Tx & Rx only */
-	at91_register_uart(AT572D940HF_ID_US2, 3, 0);
+	at91_register_uart(AT91_UART_US2, 3, 0);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
arch/arm/mach-at91/board-carmeva.c +1 -1
index b9033cb..a1afc1b 100644
@@ -49,7 +49,7 @@ static void __init carmeva_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
-	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
+	at91_register_uart(AT91_UART_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
 			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
 			   | ATMEL_UART_RI);
 
arch/arm/mach-at91/board-cpu9krea.c +6 -6
index 9a88ca0..99f74b0 100644
@@ -56,26 +56,26 @@ static void __init cpu9krea_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
-	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |
+	at91_register_uart(AT91_UART_US0, 1, ATMEL_UART_CTS |
 		ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
 		ATMEL_UART_DCD | ATMEL_UART_RI);
 
 	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
-	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |
+	at91_register_uart(AT91_UART_US1, 2, ATMEL_UART_CTS |
 		ATMEL_UART_RTS);
 
 	/* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
-	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |
+	at91_register_uart(AT91_UART_US2, 3, ATMEL_UART_CTS |
 		ATMEL_UART_RTS);
 
 	/* USART3 on ttyS4. (Rx, Tx) */
-	at91_register_uart(AT91SAM9260_ID_US3, 4, 0);
+	at91_register_uart(AT91_UART_US3, 4, 0);
 
 	/* USART4 on ttyS5. (Rx, Tx) */
-	at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
+	at91_register_uart(AT91_UART_US4, 5, 0);
 
 	/* USART5 on ttyS6. (Rx, Tx) */
-	at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
+	at91_register_uart(AT91_UART_US5, 6, 0);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
arch/arm/mach-at91/board-cpuat91.c +4 -4
index fbdd54b..689aef6 100644
@@ -59,19 +59,19 @@ static void __init cpuat91_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
-	at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS |
+	at91_register_uart(AT91_UART_US0, 1, ATMEL_UART_CTS |
 		ATMEL_UART_RTS);
 
 	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
-	at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS |
+	at91_register_uart(AT91_UART_US1, 2, ATMEL_UART_CTS |
 		ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
 		ATMEL_UART_DCD | ATMEL_UART_RI);
 
 	/* USART2 on ttyS3 (Rx, Tx) */
-	at91_register_uart(AT91RM9200_ID_US2, 3, 0);
+	at91_register_uart(AT91_UART_US2, 3, 0);
 
 	/* USART3 on ttyS4 (Rx, Tx, CTS, RTS) */
-	at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_CTS |
+	at91_register_uart(AT91_UART_US3, 4, ATMEL_UART_CTS |
 		ATMEL_UART_RTS);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
arch/arm/mach-at91/board-eb9200.c +2 -2
index eed4d6c..9d7dba2 100644
@@ -49,12 +49,12 @@ static void __init eb9200_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
-	at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
+	at91_register_uart(AT91_UART_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
 			| ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
 			| ATMEL_UART_RI);
 
 	/* USART2 on ttyS2. (Rx, Tx) - IRDA */
-	at91_register_uart(AT91RM9200_ID_US2, 2, 0);
+	at91_register_uart(AT91_UART_US2, 2, 0);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
arch/arm/mach-at91/board-ecbat91.c +1 -1
index b730b01..4f0c76c 100644
@@ -54,7 +54,7 @@ static void __init ecb_at91map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1. (Rx & Tx only) */
-	at91_register_uart(AT91RM9200_ID_US0, 1, 0);
+	at91_register_uart(AT91_UART_US0, 1, 0);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
arch/arm/mach-at91/board-foxg20.c +6 -6
index 79c54fc..fb3cfdd 100644
@@ -66,7 +66,7 @@ static void __init foxg20_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
-	at91_register_uart(AT91SAM9260_ID_US0, 1,
+	at91_register_uart(AT91_UART_US0, 1,
 				ATMEL_UART_CTS
 				| ATMEL_UART_RTS
 				| ATMEL_UART_DTR
@@ -75,23 +75,23 @@ static void __init foxg20_map_io(void)
 				| ATMEL_UART_RI);
 
 	/* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
-	at91_register_uart(AT91SAM9260_ID_US1, 2,
+	at91_register_uart(AT91_UART_US1, 2,
 		ATMEL_UART_CTS
 		| ATMEL_UART_RTS);
 
 	/* USART2 on ttyS3. (Rx & Tx only) */
-	at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
+	at91_register_uart(AT91_UART_US2, 3, 0);
 
 	/* USART3 on ttyS4. (Rx, Tx, RTS, CTS) */
-	at91_register_uart(AT91SAM9260_ID_US3, 4,
+	at91_register_uart(AT91_UART_US3, 4,
 		ATMEL_UART_CTS
 		| ATMEL_UART_RTS);
 
 	/* USART4 on ttyS5. (Rx & Tx only) */
-	at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
+	at91_register_uart(AT91_UART_US4, 5, 0);
 
 	/* USART5 on ttyS6. (Rx & Tx only) */
-	at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
+	at91_register_uart(AT91_UART_US5, 6, 0);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
arch/arm/mach-at91/board-gsia18s.c +5 -5
index e32833d..06d9be7 100644
@@ -46,7 +46,7 @@ static void __init gsia18s_map_io(void)
 	 * USART0 on ttyS1 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI).
 	 * Used for Internal Analog Modem.
 	 */
-	at91_register_uart(AT91SAM9260_ID_US0, 1,
+	at91_register_uart(AT91_UART_US0, 1,
 				ATMEL_UART_CTS | ATMEL_UART_RTS |
 				ATMEL_UART_DTR | ATMEL_UART_DSR |
 				ATMEL_UART_DCD | ATMEL_UART_RI);
@@ -54,25 +54,25 @@ static void __init gsia18s_map_io(void)
 	 * USART1 on ttyS2 (Rx, Tx, CTS, RTS).
 	 * Used for GPS or WiFi or Data stream.
 	 */
-	at91_register_uart(AT91SAM9260_ID_US1, 2,
+	at91_register_uart(AT91_UART_US1, 2,
 				ATMEL_UART_CTS | ATMEL_UART_RTS);
 	/*
 	 * USART2 on ttyS3 (Rx, Tx, CTS, RTS).
 	 * Used for External Modem.
 	 */
-	at91_register_uart(AT91SAM9260_ID_US2, 3,
+	at91_register_uart(AT91_UART_US2, 3,
 				ATMEL_UART_CTS | ATMEL_UART_RTS);
 	/*
 	 * USART3 on ttyS4 (Rx, Tx, RTS).
 	 * Used for RS-485.
 	 */
-	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
+	at91_register_uart(AT91_UART_US3, 4, ATMEL_UART_RTS);
 
 	/*
 	 * USART4 on ttyS5 (Rx, Tx).
 	 * Used for TRX433 Radio Module.
 	 */
-	at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
+	at91_register_uart(AT91_UART_US4, 5, 0);
 }
 
 static void __init init_irq(void)
arch/arm/mach-at91/board-kafa.c +1 -1
index 1edff1b..ddab49b 100644
@@ -51,7 +51,7 @@ static void __init kafa_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
-	at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
+	at91_register_uart(AT91_UART_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
arch/arm/mach-at91/board-kb9202.c +3 -3
index 682e9f4..22a421b 100644
@@ -54,13 +54,13 @@ static void __init kb9202_map_io(void)
 	at91_register_uart(0, 0, 0);
 
 	/* USART0 on ttyS1 (Rx & Tx only) */
-	at91_register_uart(AT91RM9200_ID_US0, 1, 0);
+	at91_register_uart(AT91_UART_US0, 1, 0);
 
 	/* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */
-	at91_register_uart(AT91RM9200_ID_US1, 2, 0);
+	at91_register_uart(AT91_UART_US1, 2, 0);
 
 	/* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */
-	at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
+	at91_register_uart(AT91_UART_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
 
 	/* set serial console to ttyS0 (ie, DBGU) */
 	at91_set_serial_console(0);
arch/arm/mach-at91/board-neocore926.c +1 -1
index f2c79fb..a76c43e 100644
@@ -60,7 +60,7 @@ static void __init neocore926_map_io(void)
 	at91_register_uart(0, 0, 0);
 
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-pcontrol-g20.c +3 -3
index ad9cc28..777c35c 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-picotux200.c +1 -1
index 2b0958b..3c88f0b 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-qil-a9260.c +3 -3
index c00b292..1cbc7ef 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-rm9200dk.c +1 -1
index 746b6ea..192440d 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-rm9200ek.c +1 -1
index 5e1dca0..0d91eb7 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-sam9-l9260.c +2 -2
index bc62008..c6119f1 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-sam9260ek.c +2 -2
index c8c53ac..2bfac4e 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-sam9263ek.c +1 -1
index 5e1aac1..994db00 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-sam9g20ek.c +2 -2
index 3dd5013..cc43eae 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-sam9m10g45ek.c +1 -1
index 6c999db..85b8519 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-sam9rlek.c +1 -1
index 475b485..9c7a971 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-snapper9260.c +3 -3
index e93a11b..4c90ee3 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-stamp9g20.c +6 -6
index 9b7f333..915128a 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/board-yl-9200.c +3 -3
index ef80db1..3939065 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/devices.c +300 -0

300 lines not on this page · raw message

arch/arm/mach-at91/devices.h +17 -0
index d7855ec..c535f58 100644

Lines of this file are not shown. View the raw message.

arch/arm/mach-at91/include/mach/board.h +10 -0
index 94232a4..25a6127 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.0.4

Part of the diff is not shown here. View the raw message.

#16 lore raw

PATCH v3 13/23 at91: Make PWM device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at91cap9_devices.c    |   56 +++++-------------------------
 arch/arm/mach-at91/at91sam9263_devices.c |   55 +++++------------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |   55 +++++------------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   55 +++++------------------------
 arch/arm/mach-at91/devices.c             |   55 +++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |    7 ++++
 6 files changed, 98 insertions(+), 185 deletions(-)
arch/arm/mach-at91/at91cap9_devices.c +9 -47
index 754a562..30889ec 100644
@@ -302,56 +302,17 @@ static struct at91_dev_table_rtt device_rtt __initdata = {
  *  PWM
  * --------------------------------------------------------------------*/
 
-#if defined(CONFIG_ATMEL_PWM)
-static u32 pwm_mask;
-
-static struct resource pwm_resources[] = {
-	[0] = {
-		.start	= AT91CAP9_BASE_PWMC,
-		.end	= AT91CAP9_BASE_PWMC + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91CAP9_ID_PWMC,
-		.end	= AT91CAP9_ID_PWMC,
-		.flags	= IORESOURCE_IRQ,
+static struct at91_dev_table_pwm device_pwm __initdata = {
+	.mmio_base	= AT91CAP9_BASE_PWMC,
+	.irq		= AT91CAP9_ID_PWMC,
+	.pwm_pins	= {
+		{AT91_PIN_PB19, AT91_PIN_PERIPH_A, 1, 0, 0},
+		{AT91_PIN_PB8,  AT91_PIN_PERIPH_B, 1, 0, 0},
+		{AT91_PIN_PC29, AT91_PIN_PERIPH_B, 1, 0, 0},
+		{AT91_PIN_PA11, AT91_PIN_PERIPH_B, 1, 0, 0},
 	},
 };
 
-static struct platform_device at91cap9_pwm0_device = {
-	.name	= "atmel_pwm",
-	.id	= -1,
-	.dev	= {
-		.platform_data		= &pwm_mask,
-	},
-	.resource	= pwm_resources,
-	.num_resources	= ARRAY_SIZE(pwm_resources),
-};
-
-void __init at91_add_device_pwm(u32 mask)
-{
-	if (mask & (1 << AT91_PWM0))
-		at91_set_A_periph(AT91_PIN_PB19, 1);	/* enable PWM0 */
-
-	if (mask & (1 << AT91_PWM1))
-		at91_set_B_periph(AT91_PIN_PB8, 1);	/* enable PWM1 */
-
-	if (mask & (1 << AT91_PWM2))
-		at91_set_B_periph(AT91_PIN_PC29, 1);	/* enable PWM2 */
-
-	if (mask & (1 << AT91_PWM3))
-		at91_set_B_periph(AT91_PIN_PA11, 1);	/* enable PWM3 */
-
-	pwm_mask = mask;
-
-	platform_device_register(&at91cap9_pwm0_device);
-}
-#else
-void __init at91_add_device_pwm(u32 mask) {}
-#endif
-
-
-
 /* --------------------------------------------------------------------
  *  AC97
  * -------------------------------------------------------------------- */
@@ -679,6 +640,7 @@ static struct at91_device_table at91cap9_device_table __initdata = {
 	.uart[0]	= &device_uart0,
 	.uart[1]	= &device_uart1,
 	.uart[2]	= &device_uart2,
+	.pwm		= &device_pwm,
 };
 
 void __init at91cap9_init_devices(void)
arch/arm/mach-at91/at91sam9263_devices.c +9 -46

70 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +9 -46

70 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +9 -46

70 lines not on this page · raw message

arch/arm/mach-at91/devices.c +55 -0

61 lines not on this page · raw message

arch/arm/mach-at91/devices.h +7 -0
index c535f58..52563be 100644
@@ -122,6 +122,12 @@ struct at91_dev_table_uart {
 	struct at91_pin_config	dsr_pin;
 };
 
+struct at91_dev_table_pwm {
+	unsigned		mmio_base;
+	int			irq;
+	struct at91_pin_config	pwm_pins[4];
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -135,6 +141,7 @@ struct at91_device_table {
 	struct at91_dev_table_rtt		*rtt[2];
 	struct at91_dev_table_uart		*dbgu;
 	struct at91_dev_table_uart		*uart[6];
+	struct at91_dev_table_pwm		*pwm;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#17 lore raw

PATCH v3 14/23 at91: Make SSC device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at91cap9_devices.c    |  142 ++++------------------
 arch/arm/mach-at91/at91rm9200_devices.c  |  199 ++++++------------------------
 arch/arm/mach-at91/at91sam9260_devices.c |   85 ++-----------
 arch/arm/mach-at91/at91sam9261_devices.c |  199 ++++++------------------------
 arch/arm/mach-at91/at91sam9263_devices.c |  146 ++++------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |  146 ++++------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |  142 ++++------------------
 arch/arm/mach-at91/board-afeb-9260v1.c   |    2 +-
 arch/arm/mach-at91/board-sam9260ek.c     |    2 +-
 arch/arm/mach-at91/board-sam9261ek.c     |    2 +-
 arch/arm/mach-at91/board-sam9g20ek.c     |    2 +-
 arch/arm/mach-at91/board-snapper9260.c   |    4 +-
 arch/arm/mach-at91/devices.c             |  167 +++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |   14 ++
 14 files changed, 371 insertions(+), 881 deletions(-)
arch/arm/mach-at91/at91cap9_devices.c +24 -118
index 30889ec..0a2272b 100644
@@ -444,128 +444,32 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
  *  SSC -- Synchronous Serial Controller
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
-static u64 ssc0_dmamask = DMA_BIT_MASK(32);
-
-static struct resource ssc0_resources[] = {
-	[0] = {
-		.start	= AT91CAP9_BASE_SSC0,
-		.end	= AT91CAP9_BASE_SSC0 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91CAP9_ID_SSC0,
-		.end	= AT91CAP9_ID_SSC0,
-		.flags	= IORESOURCE_IRQ,
-	},
+static struct at91_dev_table_ssc device_ssc0 __initdata = {
+	.mmio_base	= AT91CAP9_BASE_SSC0,
+	.irq		= AT91CAP9_ID_SSC0,
+	.clock_asc	= "ssc0_clk",
+	.clock_name	= "ssc",
+	.tf_pin		= {AT91_PIN_PB0, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.tk_pin		= {AT91_PIN_PB1, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.td_pin		= {AT91_PIN_PB2, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rd_pin		= {AT91_PIN_PB3, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rk_pin		= {AT91_PIN_PB4, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rf_pin		= {AT91_PIN_PB5, AT91_PIN_PERIPH_A, 1, 0, 0},
 };
 
-static struct platform_device at91cap9_ssc0_device = {
-	.name	= "ssc",
-	.id	= 0,
-	.dev	= {
-		.dma_mask		= &ssc0_dmamask,
-		.coherent_dma_mask	= DMA_BIT_MASK(32),
-	},
-	.resource	= ssc0_resources,
-	.num_resources	= ARRAY_SIZE(ssc0_resources),
+static struct at91_dev_table_ssc device_ssc1 __initdata = {
+	.mmio_base	= AT91CAP9_BASE_SSC1,
+	.irq		= AT91CAP9_ID_SSC1,
+	.clock_asc	= "ssc0_clk",
+	.clock_name	= "ssc",
+	.tf_pin		= {AT91_PIN_PB6,  AT91_PIN_PERIPH_A, 1, 0, 0},
+	.tk_pin		= {AT91_PIN_PB7,  AT91_PIN_PERIPH_A, 1, 0, 0},
+	.td_pin		= {AT91_PIN_PB8,  AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rd_pin		= {AT91_PIN_PB9,  AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rk_pin		= {AT91_PIN_PB10, AT91_PIN_PERIPH_A, 1, 0, 0},
+	.rf_pin		= {AT91_PIN_PB11, AT91_PIN_PERIPH_A, 1, 0, 0},
 };
 
-static inline void configure_ssc0_pins(unsigned pins)
-{
-	if (pins & ATMEL_SSC_TF)
-		at91_set_A_periph(AT91_PIN_PB0, 1);
-	if (pins & ATMEL_SSC_TK)
-		at91_set_A_periph(AT91_PIN_PB1, 1);
-	if (pins & ATMEL_SSC_TD)
-		at91_set_A_periph(AT91_PIN_PB2, 1);
-	if (pins & ATMEL_SSC_RD)
-		at91_set_A_periph(AT91_PIN_PB3, 1);
-	if (pins & ATMEL_SSC_RK)
-		at91_set_A_periph(AT91_PIN_PB4, 1);
-	if (pins & ATMEL_SSC_RF)
-		at91_set_A_periph(AT91_PIN_PB5, 1);
-}
-
-static u64 ssc1_dmamask = DMA_BIT_MASK(32);
-
-static struct resource ssc1_resources[] = {
-	[0] = {
-		.start	= AT91CAP9_BASE_SSC1,
-		.end	= AT91CAP9_BASE_SSC1 + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91CAP9_ID_SSC1,
-		.end	= AT91CAP9_ID_SSC1,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at91cap9_ssc1_device = {
-	.name	= "ssc",
-	.id	= 1,
-	.dev	= {
-		.dma_mask		= &ssc1_dmamask,
-		.coherent_dma_mask	= DMA_BIT_MASK(32),
-	},
-	.resource	= ssc1_resources,
-	.num_resources	= ARRAY_SIZE(ssc1_resources),
-};
-
-static inline void configure_ssc1_pins(unsigned pins)
-{
-	if (pins & ATMEL_SSC_TF)
-		at91_set_A_periph(AT91_PIN_PB6, 1);
-	if (pins & ATMEL_SSC_TK)
-		at91_set_A_periph(AT91_PIN_PB7, 1);
-	if (pins & ATMEL_SSC_TD)
-		at91_set_A_periph(AT91_PIN_PB8, 1);
-	if (pins & ATMEL_SSC_RD)
-		at91_set_A_periph(AT91_PIN_PB9, 1);
-	if (pins & ATMEL_SSC_RK)
-		at91_set_A_periph(AT91_PIN_PB10, 1);
-	if (pins & ATMEL_SSC_RF)
-		at91_set_A_periph(AT91_PIN_PB11, 1);
-}
-
-/*
- * SSC controllers are accessed through library code, instead of any
- * kind of all-singing/all-dancing driver.  For example one could be
- * used by a particular I2S audio codec's driver, while another one
- * on the same system might be used by a custom data capture driver.
- */
-void __init at91_add_device_ssc(unsigned id, unsigned pins)
-{
-	struct platform_device *pdev;
-
-	/*
-	 * NOTE: caller is responsible for passing information matching
-	 * "pins" to whatever will be using each particular controller.
-	 */
-	switch (id) {
-	case AT91CAP9_ID_SSC0:
-		pdev = &at91cap9_ssc0_device;
-		configure_ssc0_pins(pins);
-		at91_clock_associate("ssc0_clk", &pdev->dev, "ssc");
-		break;
-	case AT91CAP9_ID_SSC1:
-		pdev = &at91cap9_ssc1_device;
-		configure_ssc1_pins(pins);
-		at91_clock_associate("ssc1_clk", &pdev->dev, "ssc");
-		break;
-	default:
-		return;
-	}
-
-	platform_device_register(pdev);
-}
-
-#else
-void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  UART
  * -------------------------------------------------------------------- */
@@ -641,6 +545,8 @@ static struct at91_device_table at91cap9_device_table __initdata = {
 	.uart[1]	= &device_uart1,
 	.uart[2]	= &device_uart2,
 	.pwm		= &device_pwm,
+	.ssc[0]		= &device_ssc0,
+	.ssc[1]		= &device_ssc1,
 };
 
 void __init at91cap9_init_devices(void)
arch/arm/mach-at91/at91rm9200_devices.c +36 -163

217 lines not on this page · raw message

arch/arm/mach-at91/at91sam9260_devices.c +12 -73

99 lines not on this page · raw message

arch/arm/mach-at91/at91sam9261_devices.c +36 -163

217 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +26 -120

160 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +26 -120

160 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +24 -118

158 lines not on this page · raw message

arch/arm/mach-at91/board-afeb-9260v1.c +1 -1
index 9c7073a..b285cc6 100644
@@ -211,7 +211,7 @@ static void __init afeb9260_board_init(void)
 	at91_add_device_i2c(0, afeb9260_i2c_devices,
 			ARRAY_SIZE(afeb9260_i2c_devices));
 	/* Audio */
-	at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
+	at91_add_device_ssc(0, ATMEL_SSC_TX);
 	/* IDE */
 	at91_add_device_cf(&afeb9260_cf_data);
 }
arch/arm/mach-at91/board-sam9260ek.c +1 -1
index 2bfac4e..d4f27f9 100644
@@ -347,7 +347,7 @@ static void __init ek_board_init(void)
 	at91_add_device_i2c(0, ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
 	/* SSC (to AT73C213) */
 	at73c213_set_clk(&at73c213_data);
-	at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
+	at91_add_device_ssc(0, ATMEL_SSC_TX);
 	/* LEDs */
 	at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
 	/* Push Buttons */
arch/arm/mach-at91/board-sam9261ek.c +1 -1
index 3e848ba..1139b69 100644
@@ -604,7 +604,7 @@ static void __init ek_board_init(void)
 	ek_add_device_ts();
 	/* SSC (to AT73C213) */
 	at73c213_set_clk(&at73c213_data);
-	at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
+	at91_add_device_ssc(1, ATMEL_SSC_TX);
 #else
 	/* MMC */
 	at91_add_device_mmc(0, &ek_mmc_data);
arch/arm/mach-at91/board-sam9g20ek.c +1 -1
index cc43eae..940f6a0 100644
@@ -401,7 +401,7 @@ static void __init ek_board_init(void)
 	/* PCK0 provides MCLK to the WM8731 */
 	at91_set_B_periph(AT91_PIN_PC1, 0);
 	/* SSC (for WM8731) */
-	at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
+	at91_add_device_ssc(0, ATMEL_SSC_TX);
 }
 
 MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
arch/arm/mach-at91/board-snapper9260.c +2 -2
index 4c90ee3..99a1b6d 100644
@@ -172,8 +172,8 @@ static void __init snapper9260_board_init(void)
 	at91_add_device_usbh_ohci(&snapper9260_usbh_data);
 	at91_add_device_udc(&snapper9260_udc_data);
 	at91_add_device_eth(&snapper9260_macb_data);
-	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK |
-						 ATMEL_SSC_TD | ATMEL_SSC_RD));
+	at91_add_device_ssc(0, (ATMEL_SSC_TF | ATMEL_SSC_TK |
+				ATMEL_SSC_TD | ATMEL_SSC_RD));
 	snapper9260_add_device_nand();
 }
 
arch/arm/mach-at91/devices.c +167 -0

173 lines not on this page · raw message

arch/arm/mach-at91/devices.h +14 -0
index 52563be..177fc3d 100644
@@ -128,6 +128,19 @@ struct at91_dev_table_pwm {
 	struct at91_pin_config	pwm_pins[4];
 };
 
+struct at91_dev_table_ssc {
+	unsigned		mmio_base;
+	int			irq;
+	const char		*clock_asc;
+	const char		*clock_name;
+	struct at91_pin_config	tf_pin;
+	struct at91_pin_config	tk_pin;
+	struct at91_pin_config	td_pin;
+	struct at91_pin_config	rf_pin;
+	struct at91_pin_config	rd_pin;
+	struct at91_pin_config	rk_pin;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -142,6 +155,7 @@ struct at91_device_table {
 	struct at91_dev_table_uart		*dbgu;
 	struct at91_dev_table_uart		*uart[6];
 	struct at91_dev_table_pwm		*pwm;
+	struct at91_dev_table_ssc		*ssc[4];
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#18 lore raw

PATCH v3 15/23 at91: Make AC97 device common

In reply to Ryan Mallon

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

---
 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(-)
arch/arm/mach-at91/at91cap9_devices.c +9 -48
index 0a2272b..b2392f0 100644
@@ -317,57 +317,17 @@ static struct at91_dev_table_pwm device_pwm __initdata = {
  *  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 at91_dev_table_ac97 device_ac97 __initdata = {
+	.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 at91cap9_device_table __initdata = {
 	.pwm		= &device_pwm,
 	.ssc[0]		= &device_ssc0,
 	.ssc[1]		= &device_ssc1,
+	.ac97		= &device_ac97,
 };
 
 void __init at91cap9_init_devices(void)
arch/arm/mach-at91/at91sam9263_devices.c +9 -47

71 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +9 -48

72 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +9 -48

72 lines not on this page · raw message

arch/arm/mach-at91/devices.c +54 -0

60 lines not on this page · raw message

arch/arm/mach-at91/devices.h +7 -0
index 177fc3d..3d6ca83 100644
@@ -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);
Signature · 1 line
1.7.0.4
#19 lore raw

PATCH v3 16/23 at91: Make LCD controller device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at91cap9_devices.c    |   96 ++++++++--------------
 arch/arm/mach-at91/at91sam9261_devices.c |  133 ++++++++++--------------------
 arch/arm/mach-at91/at91sam9263_devices.c |   94 +++++++--------------
 arch/arm/mach-at91/at91sam9g45_devices.c |  111 +++++++++----------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   89 ++++++--------------
 arch/arm/mach-at91/devices.c             |   75 +++++++++++++++++
 arch/arm/mach-at91/devices.h             |   11 +++
 7 files changed, 261 insertions(+), 348 deletions(-)
arch/arm/mach-at91/at91cap9_devices.c +34 -62
index b2392f0..e6adc98 100644
@@ -332,73 +332,44 @@ static struct at91_dev_table_ac97 device_ac97 __initdata = {
  *  LCD Controller
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
-static u64 lcdc_dmamask = DMA_BIT_MASK(32);
-static struct atmel_lcdfb_info lcdc_data;
-
-static struct resource lcdc_resources[] = {
-	[0] = {
-		.start	= AT91CAP9_LCDC_BASE,
-		.end	= AT91CAP9_LCDC_BASE + SZ_4K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91CAP9_ID_LCDC,
-		.end	= AT91CAP9_ID_LCDC,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at91_lcdc_device = {
-	.name		= "atmel_lcdfb",
-	.id		= 0,
-	.dev		= {
-				.dma_mask		= &lcdc_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &lcdc_data,
-	},
-	.resource	= lcdc_resources,
-	.num_resources	= ARRAY_SIZE(lcdc_resources),
-};
-
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
+static void __init at91cap9_lcdc_init(void)
 {
-	if (!data)
-		return;
-
 	if (cpu_is_at91cap9_revB())
 		irq_set_irq_type(AT91CAP9_ID_LCDC, IRQ_TYPE_LEVEL_HIGH);
-
-	at91_set_A_periph(AT91_PIN_PC1, 0);	/* LCDHSYNC */
-	at91_set_A_periph(AT91_PIN_PC2, 0);	/* LCDDOTCK */
-	at91_set_A_periph(AT91_PIN_PC3, 0);	/* LCDDEN */
-	at91_set_B_periph(AT91_PIN_PB9, 0);	/* LCDCC */
-	at91_set_A_periph(AT91_PIN_PC6, 0);	/* LCDD2 */
-	at91_set_A_periph(AT91_PIN_PC7, 0);	/* LCDD3 */
-	at91_set_A_periph(AT91_PIN_PC8, 0);	/* LCDD4 */
-	at91_set_A_periph(AT91_PIN_PC9, 0);	/* LCDD5 */
-	at91_set_A_periph(AT91_PIN_PC10, 0);	/* LCDD6 */
-	at91_set_A_periph(AT91_PIN_PC11, 0);	/* LCDD7 */
-	at91_set_A_periph(AT91_PIN_PC14, 0);	/* LCDD10 */
-	at91_set_A_periph(AT91_PIN_PC15, 0);	/* LCDD11 */
-	at91_set_A_periph(AT91_PIN_PC16, 0);	/* LCDD12 */
-	at91_set_A_periph(AT91_PIN_PC17, 0);	/* LCDD13 */
-	at91_set_A_periph(AT91_PIN_PC18, 0);	/* LCDD14 */
-	at91_set_A_periph(AT91_PIN_PC19, 0);	/* LCDD15 */
-	at91_set_A_periph(AT91_PIN_PC22, 0);	/* LCDD18 */
-	at91_set_A_periph(AT91_PIN_PC23, 0);	/* LCDD19 */
-	at91_set_A_periph(AT91_PIN_PC24, 0);	/* LCDD20 */
-	at91_set_A_periph(AT91_PIN_PC25, 0);	/* LCDD21 */
-	at91_set_A_periph(AT91_PIN_PC26, 0);	/* LCDD22 */
-	at91_set_A_periph(AT91_PIN_PC27, 0);	/* LCDD23 */
-
-	lcdc_data = *data;
-	platform_device_register(&at91_lcdc_device);
 }
-#else
-void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
-#endif
 
+static struct at91_pin_config lcdc_pins[] __initdata = {
+	{AT91_PIN_PC1,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDHSYNC */
+	{AT91_PIN_PC2,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDDOTCK */
+	{AT91_PIN_PC3,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDDEN */
+	{AT91_PIN_PB9,  AT91_PIN_PERIPH_B, 0, 0, 0},	/* LCDCC */
+	{AT91_PIN_PC6,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD2 */
+	{AT91_PIN_PC7,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD3 */
+	{AT91_PIN_PC8,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD4 */
+	{AT91_PIN_PC9,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD5 */
+	{AT91_PIN_PC10, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD6 */
+	{AT91_PIN_PC11, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD7 */
+	{AT91_PIN_PC14, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD10 */
+	{AT91_PIN_PC15, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD11 */
+	{AT91_PIN_PC16, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD12 */
+	{AT91_PIN_PC17, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD13 */
+	{AT91_PIN_PC18, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD14 */
+	{AT91_PIN_PC19, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD15 */
+	{AT91_PIN_PC22, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD18 */
+	{AT91_PIN_PC23, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD19 */
+	{AT91_PIN_PC24, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD20 */
+	{AT91_PIN_PC25, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD21 */
+	{AT91_PIN_PC26, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD22 */
+	{AT91_PIN_PC27, AT91_PIN_PERIPH_A, 0, 0, 0},	/* LCDD23 */
+};
+
+static struct at91_dev_table_lcdc device_lcdc __initdata = {
+	.mmio_base	= AT91CAP9_LCDC_BASE,
+	.irq		= AT91CAP9_ID_LCDC,
+	.device_init	= at91cap9_lcdc_init,
+	.pins		= lcdc_pins,
+	.nr_pins	= ARRAY_SIZE(lcdc_pins),
+};
 
 /* --------------------------------------------------------------------
  *  SSC -- Synchronous Serial Controller
@@ -508,6 +479,7 @@ static struct at91_device_table at91cap9_device_table __initdata = {
 	.ssc[0]		= &device_ssc0,
 	.ssc[1]		= &device_ssc1,
 	.ac97		= &device_ac97,
+	.lcdc		= &device_lcdc,
 };
 
 void __init at91cap9_init_devices(void)
arch/arm/mach-at91/at91sam9261_devices.c +43 -90

150 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +31 -63

108 lines not on this page · raw message

arch/arm/mach-at91/at91sam9g45_devices.c +39 -72

125 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +28 -61

105 lines not on this page · raw message

arch/arm/mach-at91/devices.c +75 -0

81 lines not on this page · raw message

arch/arm/mach-at91/devices.h +11 -0
index 3d6ca83..65a036c 100644
@@ -147,6 +147,16 @@ struct at91_dev_table_ac97 {
 	struct at91_pin_config	pins[4];	/* FS, CK, TX, RX */
 };
 
+struct at91_dev_table_lcdc {
+	unsigned		mmio_base;
+	int			irq;
+	unsigned		sram_base;	/* Only on AT91SAM9261 */
+	unsigned		sram_size;
+	void			(*device_init)(void);
+	struct at91_pin_config	*pins;
+	int			nr_pins;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -163,6 +173,7 @@ struct at91_device_table {
 	struct at91_dev_table_pwm		*pwm;
 	struct at91_dev_table_ssc		*ssc[4];
 	struct at91_dev_table_ac97		*ac97;
+	struct at91_dev_table_lcdc		*lcdc;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#20 lore raw

PATCH v3 17/23 at91: Make touchscreen device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at91sam9g45_devices.c |   53 +++++------------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   53 +++++------------------------
 arch/arm/mach-at91/devices.c             |   49 +++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |    7 ++++
 4 files changed, 74 insertions(+), 88 deletions(-)
arch/arm/mach-at91/at91sam9g45_devices.c +9 -44
index 7d84fb7..783f600 100644
@@ -436,53 +436,17 @@ static void __init at91_add_device_rtc(void) {}
  *  Touchscreen
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE)
-static u64 tsadcc_dmamask = DMA_BIT_MASK(32);
-static struct at91_tsadcc_data tsadcc_data;
-
-static struct resource tsadcc_resources[] = {
-	[0] = {
-		.start	= AT91SAM9G45_BASE_TSC,
-		.end	= AT91SAM9G45_BASE_TSC + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91SAM9G45_ID_TSC,
-		.end	= AT91SAM9G45_ID_TSC,
-		.flags	= IORESOURCE_IRQ,
-	}
-};
-
-static struct platform_device at91sam9g45_tsadcc_device = {
-	.name		= "atmel_tsadcc",
-	.id		= -1,
-	.dev		= {
-				.dma_mask		= &tsadcc_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &tsadcc_data,
+static struct at91_dev_table_tsadcc device_tsadcc __initdata = {
+	.mmio_base	= AT91SAM9G45_BASE_TSC,
+	.irq		= AT91SAM9G45_ID_TSC,
+	.pins		= {
+		{AT91_PIN_PD20, AT91_PIN_GPIO, 0, GPIOF_DIR_IN, 0}, /* AD0_XR */
+		{AT91_PIN_PD21, AT91_PIN_GPIO, 0, GPIOF_DIR_IN, 0}, /* AD0_XL */
+		{AT91_PIN_PD22, AT91_PIN_GPIO, 0, GPIOF_DIR_IN, 0}, /* AD0_YT */
+		{AT91_PIN_PD23, AT91_PIN_GPIO, 0, GPIOF_DIR_IN, 0}, /* AD0_TB */
 	},
-	.resource	= tsadcc_resources,
-	.num_resources	= ARRAY_SIZE(tsadcc_resources),
 };
 
-void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data)
-{
-	if (!data)
-		return;
-
-	at91_set_gpio_input(AT91_PIN_PD20, 0);	/* AD0_XR */
-	at91_set_gpio_input(AT91_PIN_PD21, 0);	/* AD1_XL */
-	at91_set_gpio_input(AT91_PIN_PD22, 0);	/* AD2_YT */
-	at91_set_gpio_input(AT91_PIN_PD23, 0);	/* AD3_TB */
-
-	tsadcc_data = *data;
-	platform_device_register(&at91sam9g45_tsadcc_device);
-}
-#else
-void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  RTT
  * -------------------------------------------------------------------- */
@@ -633,6 +597,7 @@ static struct at91_device_table at91sam9g45_device_table __initdata = {
 	.ssc[1]		= &device_ssc1,
 	.ac97		= &device_ac97,
 	.lcdc		= &device_lcdc,
+	.tsadcc		= &device_tsadcc,
 };
 
 void __init at91sam9g45_init_devices(void)
arch/arm/mach-at91/at91sam9rl_devices.c +9 -44

68 lines not on this page · raw message

arch/arm/mach-at91/devices.c +49 -0

55 lines not on this page · raw message

arch/arm/mach-at91/devices.h +7 -0
index 65a036c..4b68228 100644
@@ -157,6 +157,12 @@ struct at91_dev_table_lcdc {
 	int			nr_pins;
 };
 
+struct at91_dev_table_tsadcc {
+	unsigned		mmio_base;
+	int			irq;
+	struct at91_pin_config	pins[4];	/* XR, XL, YT, TB */
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -174,6 +180,7 @@ struct at91_device_table {
 	struct at91_dev_table_ssc		*ssc[4];
 	struct at91_dev_table_ac97		*ac97;
 	struct at91_dev_table_lcdc		*lcdc;
+	struct at91_dev_table_tsadcc		*tsadcc;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#21 lore raw

PATCH v3 18/23 at91: Make HDMAC device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at91sam9g45_devices.c |   46 +++--------------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   43 ++-------------------------
 arch/arm/mach-at91/devices.c             |   46 ++++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |    8 +++++
 4 files changed, 63 insertions(+), 80 deletions(-)
arch/arm/mach-at91/at91sam9g45_devices.c +5 -41
index 783f600..f67a675 100644
@@ -36,49 +36,13 @@
  *  HDMAC - AHB DMA Controller
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
-static u64 hdmac_dmamask = DMA_BIT_MASK(32);
-
-static struct at_dma_platform_data atdma_pdata = {
+static struct at91_dev_table_hdmac device_hdmac __initdata = {
+	.mmio_base	= AT91_BASE_SYS + AT91_DMA,
+	.irq		= AT91SAM9G45_ID_DMA,
 	.nr_channels	= 8,
+	.have_slave	= 1,
 };
 
-static struct resource hdmac_resources[] = {
-	[0] = {
-		.start	= AT91_BASE_SYS + AT91_DMA,
-		.end	= AT91_BASE_SYS + AT91_DMA + SZ_512 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91SAM9G45_ID_DMA,
-		.end	= AT91SAM9G45_ID_DMA,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device at_hdmac_device = {
-	.name		= "at_hdmac",
-	.id		= -1,
-	.dev		= {
-				.dma_mask		= &hdmac_dmamask,
-				.coherent_dma_mask	= DMA_BIT_MASK(32),
-				.platform_data		= &atdma_pdata,
-	},
-	.resource	= hdmac_resources,
-	.num_resources	= ARRAY_SIZE(hdmac_resources),
-};
-
-void __init at91_add_device_hdmac(void)
-{
-	dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask);
-	dma_cap_set(DMA_SLAVE, atdma_pdata.cap_mask);
-	platform_device_register(&at_hdmac_device);
-}
-#else
-void __init at91_add_device_hdmac(void) {}
-#endif
-
-
 /* --------------------------------------------------------------------
  *  USB Host (OHCI)
  * -------------------------------------------------------------------- */
@@ -598,6 +562,7 @@ static struct at91_device_table at91sam9g45_device_table __initdata = {
 	.ac97		= &device_ac97,
 	.lcdc		= &device_lcdc,
 	.tsadcc		= &device_tsadcc,
+	.hdmac		= &device_hdmac,
 };
 
 void __init at91sam9g45_init_devices(void)
@@ -612,7 +577,6 @@ void __init at91sam9g45_init_devices(void)
  */
 static int __init at91_add_standard_devices(void)
 {
-	at91_add_device_hdmac();
 	at91_add_device_rtc();
 	return 0;
 }
arch/arm/mach-at91/at91sam9rl_devices.c +4 -39

64 lines not on this page · raw message

arch/arm/mach-at91/devices.c +46 -0

57 lines not on this page · raw message

arch/arm/mach-at91/devices.h +8 -0
index 4b68228..417c959 100644
@@ -163,6 +163,13 @@ struct at91_dev_table_tsadcc {
 	struct at91_pin_config	pins[4];	/* XR, XL, YT, TB */
 };
 
+struct at91_dev_table_hdmac {
+	unsigned		mmio_base;
+	int			irq;
+	int			nr_channels;
+	int			have_slave;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -181,6 +188,7 @@ struct at91_device_table {
 	struct at91_dev_table_ac97		*ac97;
 	struct at91_dev_table_lcdc		*lcdc;
 	struct at91_dev_table_tsadcc		*tsadcc;
+	struct at91_dev_table_hdmac		*hdmac;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#22 lore raw

PATCH v3 19/23 at91: Make RTC device common

In reply to Ryan Mallon

The RTC device code for the AT91RM9200, AT91SAM9G45 and AT91SAM9RL are all exactly the same. Remove the individual implementations and replace them with a single version in devices.c

---
 arch/arm/mach-at91/at91rm9200_devices.c  |   33 -----------------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |   33 -----------------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |   34 ------------------------------
 arch/arm/mach-at91/devices.c             |   20 +++++++++++++++++
 4 files changed, 20 insertions(+), 100 deletions(-)
arch/arm/mach-at91/at91rm9200_devices.c +0 -33
index 9f678de..f251ed1 100644
@@ -277,25 +277,6 @@ static struct at91_dev_table_tcb device_tcb1 __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  RTC
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
-static struct platform_device at91rm9200_rtc_device = {
-	.name		= "at91_rtc",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_rtc(void)
-{
-	platform_device_register(&at91rm9200_rtc_device);
-}
-#else
-static void __init at91_add_device_rtc(void) {}
-#endif
-
-/* --------------------------------------------------------------------
  *  SSC -- Synchronous Serial Controller
  * -------------------------------------------------------------------- */
 
@@ -444,17 +425,3 @@ void __init at91rm9200_init_devices(void)
 {
 	at91_init_devices(&at91rm9200_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_rtc();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/at91sam9g45_devices.c +0 -33
index f67a675..3627c2e 100644
@@ -377,26 +377,6 @@ static struct at91_dev_table_tcb device_tcb1 __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  RTC
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
-static struct platform_device at91sam9g45_rtc_device = {
-	.name		= "at91_rtc",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_rtc(void)
-{
-	platform_device_register(&at91sam9g45_rtc_device);
-}
-#else
-static void __init at91_add_device_rtc(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  Touchscreen
  * -------------------------------------------------------------------- */
 
@@ -569,16 +549,3 @@ void __init at91sam9g45_init_devices(void)
 {
 	at91_init_devices(&at91sam9g45_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_rtc();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/at91sam9rl_devices.c +0 -34
index 3dac87f..2aa465b 100644
@@ -271,26 +271,6 @@ static struct at91_dev_table_tsadcc device_tsadcc __initdata = {
 };
 
 /* --------------------------------------------------------------------
- *  RTC
- * -------------------------------------------------------------------- */
-
-#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
-static struct platform_device at91sam9rl_rtc_device = {
-	.name		= "at91_rtc",
-	.id		= -1,
-	.num_resources	= 0,
-};
-
-static void __init at91_add_device_rtc(void)
-{
-	platform_device_register(&at91sam9rl_rtc_device);
-}
-#else
-static void __init at91_add_device_rtc(void) {}
-#endif
-
-
-/* --------------------------------------------------------------------
  *  RTT
  * -------------------------------------------------------------------- */
 
@@ -445,17 +425,3 @@ void __init at91sam9rl_init_devices(void)
 {
 	at91_init_devices(&at91sam9rl_device_table);
 }
-
-/* -------------------------------------------------------------------- */
-
-/*
- * These devices are always present and don't need any board-specific
- * setup.
- */
-static int __init at91_add_standard_devices(void)
-{
-	at91_add_device_rtc();
-	return 0;
-}
-
-arch_initcall(at91_add_standard_devices);
arch/arm/mach-at91/devices.c +20 -0
index a79d477..b867663 100644
@@ -1745,12 +1745,32 @@ void __init at91_add_device_hdmac(void)
 void __init at91_add_device_hdmac(void) {}
 #endif
 
+/* --------------------------------------------------------------------
+ *  RTC
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
+static struct platform_device at91_rtc_device = {
+	.name		= "at91_rtc",
+	.id		= -1,
+	.num_resources	= 0,
+};
+
+static void __init at91_add_device_rtc(void)
+{
+	platform_device_register(&at91_rtc_device);
+}
+#else
+static void __init at91_add_device_rtc(void) {}
+#endif
+
 static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_tc();
 	at91_add_device_rtt();
 	at91_add_device_watchdog();
 	at91_add_device_hdmac();
+	at91_add_device_rtc();
 	return 0;
 }
 
Signature · 1 line
1.7.0.4
#23 lore raw

PATCH v3 20/23 at91: Make high speed USB gadget device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at91cap9_devices.c    |  114 ++++++------------------------
 arch/arm/mach-at91/at91sam9g45_devices.c |   94 ++++---------------------
 arch/arm/mach-at91/at91sam9rl_devices.c  |  100 ++++----------------------
 arch/arm/mach-at91/devices.c             |   79 +++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |   20 +++++
 5 files changed, 150 insertions(+), 257 deletions(-)
arch/arm/mach-at91/at91cap9_devices.c +23 -91
index e6adc98..cb12e0c 100644
@@ -51,105 +51,36 @@ static struct at91_dev_table_usb_ohci device_usbh_ohci __initdata = {
  *  USB HS Device (Gadget)
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE)
-
-static struct resource usba_udc_resources[] = {
-	[0] = {
-		.start	= AT91CAP9_UDPHS_FIFO,
-		.end	= AT91CAP9_UDPHS_FIFO + SZ_512K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91CAP9_BASE_UDPHS,
-		.end	= AT91CAP9_BASE_UDPHS + SZ_1K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[2] = {
-		.start	= AT91CAP9_ID_UDPHS,
-		.end	= AT91CAP9_ID_UDPHS,
-		.flags	= IORESOURCE_IRQ,
-	},
-};
-
-#define EP(nam, idx, maxpkt, maxbk, dma, isoc)			\
-	[idx] = {						\
-		.name		= nam,				\
-		.index		= idx,				\
-		.fifo_size	= maxpkt,			\
-		.nr_banks	= maxbk,			\
-		.can_dma	= dma,				\
-		.can_isoc	= isoc,				\
-	}
-
-static struct usba_ep_data usba_udc_ep[] = {
-	EP("ep0", 0,   64, 1, 0, 0),
-	EP("ep1", 1, 1024, 3, 1, 1),
-	EP("ep2", 2, 1024, 3, 1, 1),
-	EP("ep3", 3, 1024, 2, 1, 1),
-	EP("ep4", 4, 1024, 2, 1, 1),
-	EP("ep5", 5, 1024, 2, 1, 0),
-	EP("ep6", 6, 1024, 2, 1, 0),
-	EP("ep7", 7, 1024, 2, 0, 0),
-};
-
-#undef EP
-
-/*
- * pdata doesn't have room for any endpoints, so we need to
- * append room for the ones we need right after it.
- */
-static struct {
-	struct usba_platform_data pdata;
-	struct usba_ep_data ep[8];
-} usba_udc_data;
-
-static struct platform_device at91_usba_udc_device = {
-	.name		= "atmel_usba_udc",
-	.id		= -1,
-	.dev		= {
-				.platform_data	= &usba_udc_data.pdata,
-	},
-	.resource	= usba_udc_resources,
-	.num_resources	= ARRAY_SIZE(usba_udc_resources),
-};
-
-void __init at91_add_device_usba(struct usba_platform_data *data)
+static void at91cap9_usba_init(void)
 {
 	if (cpu_is_at91cap9_revB()) {
 		irq_set_irq_type(AT91CAP9_ID_UDPHS, IRQ_TYPE_LEVEL_HIGH);
 		at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS |
-						  AT91_MATRIX_UDPHS_BYPASS_LOCK);
-	}
-	else
+			       AT91_MATRIX_UDPHS_BYPASS_LOCK);
+	} else {
 		at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS);
-
-	/*
-	 * Invalid pins are 0 on AT91, but the usba driver is shared
-	 * with AVR32, which use negative values instead. Once/if
-	 * gpio_is_valid() is ported to AT91, revisit this code.
-	 */
-	usba_udc_data.pdata.vbus_pin = -EINVAL;
-	usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
-	memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));;
-
-	if (data && data->vbus_pin > 0) {
-		at91_set_gpio_input(data->vbus_pin, 0);
-		at91_set_deglitch(data->vbus_pin, 1);
-		usba_udc_data.pdata.vbus_pin = data->vbus_pin;
 	}
-
-	/* Pullup pin is handled internally by USB device peripheral */
-
-	/* Clocks */
-	at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk");
-	at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk");
-
-	platform_device_register(&at91_usba_udc_device);
 }
-#else
-void __init at91_add_device_usba(struct usba_platform_data *data) {}
-#endif
 
+static struct usba_ep_data usba_udc_ep[] = {
+	AT91_UDC_HS_EP("ep0", 0,   64, 1, 0, 0),
+	AT91_UDC_HS_EP("ep1", 1, 1024, 3, 1, 1),
+	AT91_UDC_HS_EP("ep2", 2, 1024, 3, 1, 1),
+	AT91_UDC_HS_EP("ep3", 3, 1024, 2, 1, 1),
+	AT91_UDC_HS_EP("ep4", 4, 1024, 2, 1, 1),
+	AT91_UDC_HS_EP("ep5", 5, 1024, 2, 1, 0),
+	AT91_UDC_HS_EP("ep6", 6, 1024, 2, 1, 0),
+	AT91_UDC_HS_EP("ep7", 7, 1024, 2, 0, 0),
+};
+
+static struct at91_dev_table_udc_hs device_udc_hs __initdata = {
+	.fifo_base	= AT91CAP9_UDPHS_FIFO,
+	.mmio_base	= AT91CAP9_BASE_UDPHS,
+	.irq		= AT91CAP9_ID_UDPHS,
+	.device_init	= at91cap9_usba_init,
+	.endpoints	= usba_udc_ep,
+	.nr_endpoints	= ARRAY_SIZE(usba_udc_ep),
+};
 
 /* --------------------------------------------------------------------
  *  Ethernet
@@ -480,6 +411,7 @@ static struct at91_device_table at91cap9_device_table __initdata = {
 	.ssc[1]		= &device_ssc1,
 	.ac97		= &device_ac97,
 	.lcdc		= &device_lcdc,
+	.udc_hs		= &device_udc_hs,
 };
 
 void __init at91cap9_init_devices(void)
arch/arm/mach-at91/at91sam9g45_devices.c +14 -80

111 lines not on this page · raw message

arch/arm/mach-at91/at91sam9rl_devices.c +14 -86

117 lines not on this page · raw message

arch/arm/mach-at91/devices.c +79 -0

85 lines not on this page · raw message

arch/arm/mach-at91/devices.h +20 -0
index 417c959..a1374fa 100644
@@ -170,6 +170,25 @@ struct at91_dev_table_hdmac {
 	int			have_slave;
 };
 
+#define AT91_UDC_HS_EP(nam, idx, maxpkt, maxbk, dma, isoc)	\
+	[idx] = {						\
+		.name		= nam,				\
+		.index		= idx,				\
+		.fifo_size	= maxpkt,			\
+		.nr_banks	= maxbk,			\
+		.can_dma	= dma,				\
+		.can_isoc	= isoc,				\
+	}
+
+struct at91_dev_table_udc_hs {
+	unsigned		fifo_base;
+	unsigned		mmio_base;
+	int			irq;
+	void			(*device_init)(void);
+	struct usba_ep_data	*endpoints;
+	int			nr_endpoints;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -189,6 +208,7 @@ struct at91_device_table {
 	struct at91_dev_table_lcdc		*lcdc;
 	struct at91_dev_table_tsadcc		*tsadcc;
 	struct at91_dev_table_hdmac		*hdmac;
+	struct at91_dev_table_udc_hs		*udc_hs;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#24 lore raw

PATCH v3 21/23 at91: Make compact flash device common

In reply to Ryan Mallon

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

---
 arch/arm/mach-at91/at91rm9200_devices.c  |   74 ++++++--------------
 arch/arm/mach-at91/at91sam9260_devices.c |  114 +++++++-----------------------
 arch/arm/mach-at91/at91sam9263_devices.c |  102 +++++++--------------------
 arch/arm/mach-at91/devices.c             |  105 +++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |   14 ++++
 5 files changed, 193 insertions(+), 216 deletions(-)
arch/arm/mach-at91/at91rm9200_devices.c +22 -52
index f251ed1..5ffa946 100644
@@ -84,38 +84,12 @@ static struct at91_dev_table_ethernet device_eth __initdata = {
  *  Compact Flash / PCMCIA
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
-static struct at91_cf_data cf_data;
-
-#define CF_BASE		AT91_CHIPSELECT_4
-
-static struct resource cf_resources[] = {
-	[0] = {
-		.start	= CF_BASE,
-		/* ties up CS4, CS5 and CS6 */
-		.end	= CF_BASE + (0x30000000 - 1),
-		.flags	= IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
-	},
-};
-
-static struct platform_device at91rm9200_cf_device = {
-	.name		= "at91_cf",
-	.id		= -1,
-	.dev		= {
-				.platform_data		= &cf_data,
-	},
-	.resource	= cf_resources,
-	.num_resources	= ARRAY_SIZE(cf_resources),
-};
-
-void __init at91_add_device_cf(struct at91_cf_data *data)
+static int __init at91rm9200_cf_init(struct at91_cf_data *data, int *slot)
 {
 	unsigned int csa;
 
-	if (!data)
-		return;
-
 	data->chipselect = 4;		/* can only use EBI ChipSelect 4 */
+	*slot = 0;			/* only one CF slot */
 
 	/* CF takes over CS4, CS5, CS6 */
 	csa = at91_sys_read(AT91_EBI_CSA);
@@ -136,35 +110,30 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
 				| AT91_SMC_RWHOLD_(4)	/* hold time */
 	);
 
-	/* input/irq */
-	if (data->irq_pin) {
-		at91_set_gpio_input(data->irq_pin, 1);
-		at91_set_deglitch(data->irq_pin, 1);
-	}
-	at91_set_gpio_input(data->det_pin, 1);
-	at91_set_deglitch(data->det_pin, 1);
-
-	/* outputs, initially off */
-	if (data->vcc_pin)
-		at91_set_gpio_output(data->vcc_pin, 0);
-	at91_set_gpio_output(data->rst_pin, 0);
+	return 0;
+}
 
+static struct at91_pin_config cf_pins[] __initdata = {
 	/* force poweron defaults for these pins ... */
-	at91_set_A_periph(AT91_PIN_PC9, 0);	/* A25/CFRNW */
-	at91_set_A_periph(AT91_PIN_PC10, 0);	/* NCS4/CFCS */
-	at91_set_A_periph(AT91_PIN_PC11, 0);	/* NCS5/CFCE1 */
-	at91_set_A_periph(AT91_PIN_PC12, 0);	/* NCS6/CFCE2 */
+	{AT91_PIN_PC9,  AT91_PIN_PERIPH_A, 0, 0, 0},	/* A25/CFRNW */
+	{AT91_PIN_PC10, AT91_PIN_PERIPH_A, 0, 0, 0},	/* NCS4/CFCS */
+	{AT91_PIN_PC11, AT91_PIN_PERIPH_A, 0, 0, 0},	/* NCS5/CFCE1 */
+	{AT91_PIN_PC12, AT91_PIN_PERIPH_A, 0, 0, 0},	/* NCS6/CFCE2 */
 
 	/* nWAIT is _not_ a default setting */
-	at91_set_A_periph(AT91_PIN_PC6, 1);	/* nWAIT */
-
-	cf_data = *data;
-	platform_device_register(&at91rm9200_cf_device);
-}
-#else
-void __init at91_add_device_cf(struct at91_cf_data *data) {}
-#endif
+	{AT91_PIN_PC6,  AT91_PIN_PERIPH_A, 1, 0, 0},	/* nWAIT */
+};
 
+static struct at91_dev_table_cf device_cf __initdata = {
+	.slot[0]	= {
+		/* ties up CS4, CS5 and CS6 */
+		.mmio_base	= AT91_CHIPSELECT_4,
+		.mmio_size	= 0x30000000,
+	},
+	.device_init	= at91rm9200_cf_init,
+	.pins		= cf_pins,
+	.nr_pins	= ARRAY_SIZE(cf_pins),
+};
 
 /* --------------------------------------------------------------------
  *  MMC / SD
@@ -419,6 +388,7 @@ static struct at91_device_table at91rm9200_device_table __initdata = {
 	.ssc[0]		= &device_ssc0,
 	.ssc[1]		= &device_ssc1,
 	.ssc[2]		= &device_ssc2,
+	.cf		= &device_cf,
 };
 
 void __init at91rm9200_init_devices(void)
arch/arm/mach-at91/at91sam9260_devices.c +26 -88

149 lines not on this page · raw message

arch/arm/mach-at91/at91sam9263_devices.c +26 -76

134 lines not on this page · raw message

arch/arm/mach-at91/devices.c +105 -0

111 lines not on this page · raw message

arch/arm/mach-at91/devices.h +14 -0
index a1374fa..74f1b9a 100644
@@ -189,6 +189,19 @@ struct at91_dev_table_udc_hs {
 	int			nr_endpoints;
 };
 
+struct at91_cf_slot {
+	unsigned		mmio_base;
+	unsigned		mmio_size;
+};
+
+struct at91_dev_table_cf {
+	struct at91_cf_slot	slot[2];
+	int			(*device_init)(struct at91_cf_data *data,
+					       int *slot);
+	struct at91_pin_config	*pins;
+	int			nr_pins;
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -209,6 +222,7 @@ struct at91_device_table {
 	struct at91_dev_table_tsadcc		*tsadcc;
 	struct at91_dev_table_hdmac		*hdmac;
 	struct at91_dev_table_udc_hs		*udc_hs;
+	struct at91_dev_table_cf		*cf;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#25 lore raw

PATCH v3 22/23 at91: Move at91sam9263 CAN device to common devices

In reply to Ryan Mallon

The CAN device is only used on the AT91SAM9263. Move it to the common devices.c file to be consistent with other devices.

---
 arch/arm/mach-at91/at91sam9263_devices.c |   37 +++++-----------------------
 arch/arm/mach-at91/devices.c             |   38 ++++++++++++++++++++++++++++++
 arch/arm/mach-at91/devices.h             |    7 +++++
 3 files changed, 52 insertions(+), 30 deletions(-)
arch/arm/mach-at91/at91sam9263_devices.c +7 -30
index 70cf41a..b06246c 100644
@@ -263,39 +263,15 @@ static struct at91_dev_table_ac97 device_ac97 __initdata = {
  *  CAN Controller
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_CAN_AT91) || defined(CONFIG_CAN_AT91_MODULE)
-static struct resource can_resources[] = {
-	[0] = {
-		.start	= AT91SAM9263_BASE_CAN,
-		.end	= AT91SAM9263_BASE_CAN + SZ_16K - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-	[1] = {
-		.start	= AT91SAM9263_ID_CAN,
-		.end	= AT91SAM9263_ID_CAN,
-		.flags	= IORESOURCE_IRQ,
+static struct at91_dev_table_can device_can __initdata = {
+	.mmio_base	= AT91SAM9263_BASE_CAN,
+	.irq		= AT91SAM9263_ID_CAN,
+	.pins		= {
+		{AT91_PIN_PA13, AT91_PIN_PERIPH_A, 0, 0, 0},	/* CANTX */
+		{AT91_PIN_PA14, AT91_PIN_PERIPH_A, 0, 0, 0},	/* CANRX */
 	},
 };
 
-static struct platform_device at91sam9263_can_device = {
-	.name		= "at91_can",
-	.id		= -1,
-	.resource	= can_resources,
-	.num_resources	= ARRAY_SIZE(can_resources),
-};
-
-void __init at91_add_device_can(struct at91_can_data *data)
-{
-	at91_set_A_periph(AT91_PIN_PA13, 0);	/* CANTX */
-	at91_set_A_periph(AT91_PIN_PA14, 0);	/* CANRX */
-	at91sam9263_can_device.dev.platform_data = data;
-
-	platform_device_register(&at91sam9263_can_device);
-}
-#else
-void __init at91_add_device_can(struct at91_can_data *data) {}
-#endif
-
 /* --------------------------------------------------------------------
  *  LCD Controller
  * -------------------------------------------------------------------- */
@@ -536,6 +512,7 @@ static struct at91_device_table at91sam9263_device_table __initdata = {
 	.ac97		= &device_ac97,
 	.lcdc		= &device_lcdc,
 	.cf		= &device_cf,
+	.can		= &device_can,
 };
 
 void __init at91sam9263_init_devices(void)
arch/arm/mach-at91/devices.c +38 -0
index 0273b82..1bf4658 100644
@@ -1948,6 +1948,44 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
 void __init at91_add_device_cf(struct at91_cf_data *data) {}
 #endif
 
+/* --------------------------------------------------------------------
+ *  CAN Controller
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_CAN_AT91) || defined(CONFIG_CAN_AT91_MODULE)
+static struct resource can_resources[] = {
+	[0] = {
+		.end	= SZ_16K,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device at91_can_device = {
+	.name		= "at91_can",
+	.id		= -1,
+	.resource	= can_resources,
+	.num_resources	= ARRAY_SIZE(can_resources),
+};
+
+void __init at91_add_device_can(struct at91_can_data *data)
+{
+	struct at91_dev_table_can *info = devices->can;
+
+	BUG_ON(!info);
+	init_resource_mem(&can_resources[0], info->mmio_base);
+	init_resource_irq(&can_resources[1], info->irq);
+
+	at91_config_pins(info->pins, ARRAY_SIZE(info->pins));
+	at91_can_device.dev.platform_data = data;
+	platform_device_register(&at91sam9263_can_device);
+}
+#else
+void __init at91_add_device_can(struct at91_can_data *data) {}
+#endif
+
 static int __init at91_add_standard_devices(void)
 {
 	at91_add_device_tc();
arch/arm/mach-at91/devices.h +7 -0
index 74f1b9a..846f36f 100644
@@ -202,6 +202,12 @@ struct at91_dev_table_cf {
 	int			nr_pins;
 };
 
+struct at91_dev_table_can {
+	unsigned		mmio_base;
+	int			irq;
+	struct at91_pin_config	pins[2];	/* TX, RX */
+};
+
 struct at91_device_table {
 	struct at91_dev_table_ethernet		*ethernet;
 	struct at91_dev_table_usb_ohci		*usbh_ohci;
@@ -223,6 +229,7 @@ struct at91_device_table {
 	struct at91_dev_table_hdmac		*hdmac;
 	struct at91_dev_table_udc_hs		*udc_hs;
 	struct at91_dev_table_cf		*cf;
+	struct at91_dev_table_can		*can;
 };
 
 extern void __init at91_init_devices(struct at91_device_table *device_table);
Signature · 1 line
1.7.0.4
#26 lore raw

PATCH v3 23/23 at91: Remove mAgic and ISI device code

In reply to Ryan Mallon

The AT572D940HF mAgic device and the AT91SAM9263 ISI device do not have drivers yet and therefore the platform code in arch/arm/mach-at91 is unused and can be removed.

---
 arch/arm/mach-at91/at572d940hf_devices.c  |   73 -----------------------------
 arch/arm/mach-at91/at91sam9263_devices.c  |   50 --------------------
 arch/arm/mach-at91/board-at572d940hf_ek.c |    2 -
 arch/arm/mach-at91/include/mach/board.h   |    6 --
 4 files changed, 0 insertions(+), 131 deletions(-)
arch/arm/mach-at91/at572d940hf_devices.c +0 -73
index 9910fc8..26aa567 100644
@@ -250,79 +250,6 @@ static struct at91_dev_table_uart device_uart2 __initdata = {
 	.cts_pin	= {AT91_PIN_PA16, AT91_PIN_PERIPH_A, 0, 0, 0},
 };
 
-/* --------------------------------------------------------------------
- *  mAgic
- * -------------------------------------------------------------------- */
-
-#ifdef CONFIG_MAGICV
-static struct resource mAgic_resources[] = {
-	{
-		.start = AT91_MAGIC_PM_BASE,
-		.end   = AT91_MAGIC_PM_BASE + AT91_MAGIC_PM_SIZE - 1,
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start = AT91_MAGIC_DM_I_BASE,
-		.end   = AT91_MAGIC_DM_I_BASE + AT91_MAGIC_DM_I_SIZE - 1,
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start = AT91_MAGIC_DM_F_BASE,
-		.end   = AT91_MAGIC_DM_F_BASE + AT91_MAGIC_DM_F_SIZE - 1,
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start = AT91_MAGIC_DM_DB_BASE,
-		.end   = AT91_MAGIC_DM_DB_BASE + AT91_MAGIC_DM_DB_SIZE - 1,
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start = AT91_MAGIC_REGS_BASE,
-		.end   = AT91_MAGIC_REGS_BASE + AT91_MAGIC_REGS_SIZE - 1,
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start = AT91_MAGIC_EXTPAGE_BASE,
-		.end   = AT91_MAGIC_EXTPAGE_BASE + AT91_MAGIC_EXTPAGE_SIZE - 1,
-		.flags = IORESOURCE_MEM,
-	},
-	{
-		.start  = AT572D940HF_ID_MSIRQ0,
-		.end    = AT572D940HF_ID_MSIRQ0,
-		.flags  = IORESOURCE_IRQ,
-	},
-	{
-		.start  = AT572D940HF_ID_MHALT,
-		.end    = AT572D940HF_ID_MHALT,
-		.flags  = IORESOURCE_IRQ,
-	},
-	{
-		.start  = AT572D940HF_ID_MEXC,
-		.end    = AT572D940HF_ID_MEXC,
-		.flags  = IORESOURCE_IRQ,
-	},
-	{
-		.start  = AT572D940HF_ID_MEDMA,
-		.end    = AT572D940HF_ID_MEDMA,
-		.flags  = IORESOURCE_IRQ,
-	},
-};
-
-static struct platform_device mAgic_device = {
-	.name           = "mAgic",
-	.id             = -1,
-	.num_resources  = ARRAY_SIZE(mAgic_resources),
-	.resource       = mAgic_resources,
-};
-
-void __init at91_add_device_mAgic(void)
-{
-	platform_device_register(&mAgic_device);
-}
-#else
-void __init at91_add_device_mAgic(void) {}
-#endif
-
 static struct at91_device_table at572d940hf_device_table __initdata = {
 	.ethernet	= &device_eth,
 	.usbh_ohci	= &device_usbh_ohci,
arch/arm/mach-at91/at91sam9263_devices.c +0 -50

56 lines not on this page · raw message

arch/arm/mach-at91/board-at572d940hf_ek.c +0 -2
index 8955133..ff62346 100644
@@ -312,8 +312,6 @@ static void __init eb_board_init(void)
 	at91_add_device_mmc(0, &eb_mmc_data);
 	/* Ethernet */
 	at91_add_device_eth(&eb_eth_data);
-	/* mAgic */
-	at91_add_device_mAgic();
 }
 
 MACHINE_START(AT572D940HFEB, "Atmel AT91D940HF-EB")
arch/arm/mach-at91/include/mach/board.h +0 -6
index 25a6127..33ba440 100644
@@ -186,9 +186,6 @@ extern void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data);
  /* AC97 */
 extern void __init at91_add_device_ac97(struct ac97c_platform_data *data);
 
- /* ISI */
-extern void __init at91_add_device_isi(void);
-
  /* Touchscreen Controller */
 struct at91_tsadcc_data {
 	unsigned int    adc_clock;
@@ -208,9 +205,6 @@ extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
 extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
 extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);
 
- /* AT572D940HF DSP */
-extern void __init at91_add_device_mAgic(void);
-
 /* FIXME: this needs a better location, but gets stuff building again */
 extern int at91_suspend_entering_slow_clock(void);
 
Signature · 1 line
1.7.0.4
#27 lore raw

v3 cover Create common framework for AT91 device initialisation

In reply to Ryan Mallon
Quoted 25 lines · Ryan Mallon

Each AT91 variant (AT91RM9200, AT91SAM9260, etc) currently has its own devices file, which includes the MMIO address, interrupt configuration, GPIO setup, etc for each device. This results in a large amount of duplicated code.

This patch set introduces a framework for adding shared devices for the AT91 platform and replaces the multiple device setup implementations for each device with single implementations in the new framework. This has a net reduction of nearly 5000 lines of code.

Each of the arch/arm/mach-at91/*_devices.c files becomes a collection of structures (with some initialisation callbacks where necessary) with a table of devices which are present on the particular AT91 variant. All structures/functions are marked as __init/__initdata so there is little additional memory overhead. This also means that the #ifdefs around each device can be removed from the *_devices.c files (but remain in the new common devices.c file) without overhead.

This patch series does not introduce any functional changes to how the board files add devices, it only replaces the duplicate device initialisation code with common versions. The patch series attempts to have minimum change by rewriting as little as possible of the actual device initialisation functions.

Quoted 7 lines

This is also a step towards allowing more than one AT91 variant to be built into a single kernel by removing duplicate function names across the *_devices.c files.

I have build tested the patch series for all of the AT91 variants and devices, and have boot tested it on the AT91SAM9G20 (Snapper 9G20 board) and tested basic device functionality.

Ryan,

This patch series does not apply to linux-next.

It appears Jean-Christophe PLAGNIOL-VILLARD has recently committed a number of patches to that branch.

at91: move clock subsystem init to soc generic init
at91: move register clocks to soc generic init
at91: move st timer to drivers/clocksource
at91: move pit timer to drivers/clocksource
at91: switch st timer to early platform devices
at91: switch pit timer to early platform devices
at91: move gpio to drivers/gpio
at91: switch gpio to early platfrom device
at91: switch to CLKDEV_LOOKUP
at91: use structure to store the current soc
at91: merge board usb-a9260 and usb-a9263 together
at91: factorize at91 interrupts init to soc
at91: introduce commom AT91_BASE_SYS
at91rm9200: introduce at91rm9200_set_type to specficy cpu package
at91: 9260 and 9g20 add support of join SRAM Memory Mapping at91/board-eco920: remove at91_beeper ressource as no driver at91_beeper exist
atmel_serial: keep the platform_device unchanged
at91: remove MTD_NAND_ATMEL_BUSWIDTH_16 option
at91: Add ARCH_ID and basic cpu macros definition for 5series chips family.

There are also these three ahead of Linus' linux-2.6 tree:

arm: at91: fix compiler warning for eb01 board build
ARM: at91: AT91CAP9 has a macb device
treewide: remove extra semicolons

Regards,
Hartley

#28 lore raw

v3 cover Create common framework for AT91 device initialisation

Quoted 61 lines · H Hartley Sweeten
Quoted 25 lines · Ryan Mallon

Each AT91 variant (AT91RM9200, AT91SAM9260, etc) currently has its own devices file, which includes the MMIO address, interrupt configuration, GPIO setup, etc for each device. This results in a large amount of duplicated code.

This patch set introduces a framework for adding shared devices for the AT91 platform and replaces the multiple device setup implementations for each device with single implementations in the new framework. This has a net reduction of nearly 5000 lines of code.

Each of the arch/arm/mach-at91/*_devices.c files becomes a collection of structures (with some initialisation callbacks where necessary) with a table of devices which are present on the particular AT91 variant. All structures/functions are marked as __init/__initdata so there is little additional memory overhead. This also means that the #ifdefs around each device can be removed from the *_devices.c files (but remain in the new common devices.c file) without overhead.

This patch series does not introduce any functional changes to how the board files add devices, it only replaces the duplicate device initialisation code with common versions. The patch series attempts to have minimum change by rewriting as little as possible of the actual device initialisation functions.

Quoted 7 lines

This is also a step towards allowing more than one AT91 variant to be built into a single kernel by removing duplicate function names across the *_devices.c files.

I have build tested the patch series for all of the AT91 variants and devices, and have boot tested it on the AT91SAM9G20 (Snapper 9G20 board) and tested basic device functionality.

Ryan,

This patch series does not apply to linux-next.

It appears Jean-Christophe PLAGNIOL-VILLARD has recently committed a number of patches to that branch.

at91: move clock subsystem init to soc generic init
at91: move register clocks to soc generic init
at91: move st timer to drivers/clocksource
at91: move pit timer to drivers/clocksource
at91: switch st timer to early platform devices
at91: switch pit timer to early platform devices
at91: move gpio to drivers/gpio
at91: switch gpio to early platfrom device
at91: switch to CLKDEV_LOOKUP
at91: use structure to store the current soc
at91: merge board usb-a9260 and usb-a9263 together
at91: factorize at91 interrupts init to soc
at91: introduce commom AT91_BASE_SYS
at91rm9200: introduce at91rm9200_set_type to specficy cpu package
at91: 9260 and 9g20 add support of join SRAM Memory Mapping at91/board-eco920: remove at91_beeper ressource as no driver at91_beeper exist
atmel_serial: keep the platform_device unchanged
at91: remove MTD_NAND_ATMEL_BUSWIDTH_16 option
at91: Add ARCH_ID and basic cpu macros definition for 5series chips family.

Quoted 5 lines

There are also these three ahead of Linus' linux-2.6 tree:

arm: at91: fix compiler warning for eb01 board build
ARM: at91: AT91CAP9 has a macb device
treewide: remove extra semicolons

Ok, I have more changes to make anyway so I will rebase against these three. I do not want to rebase on top of the Jean-Christophe's patches because I do not think that they are ready for mainline inclusion. See the discussion in the other thread.

~Ryan

#29 lore raw

v3 cover Create common framework for AT91 device initialisation

Quoted 64 lines · Ryan Mallon
Quoted 63 lines · H Hartley Sweeten
Quoted 25 lines · Ryan Mallon

Each AT91 variant (AT91RM9200, AT91SAM9260, etc) currently has its own devices file, which includes the MMIO address, interrupt configuration, GPIO setup, etc for each device. This results in a large amount of duplicated code.

This patch set introduces a framework for adding shared devices for the AT91 platform and replaces the multiple device setup implementations for each device with single implementations in the new framework. This has a net reduction of nearly 5000 lines of code.

Each of the arch/arm/mach-at91/*_devices.c files becomes a collection of structures (with some initialisation callbacks where necessary) with a table of devices which are present on the particular AT91 variant. All structures/functions are marked as __init/__initdata so there is little additional memory overhead. This also means that the #ifdefs around each device can be removed from the *_devices.c files (but remain in the new common devices.c file) without overhead.

This patch series does not introduce any functional changes to how the board files add devices, it only replaces the duplicate device initialisation code with common versions. The patch series attempts to have minimum change by rewriting as little as possible of the actual device initialisation functions.

Quoted 7 lines

This is also a step towards allowing more than one AT91 variant to be built into a single kernel by removing duplicate function names across the *_devices.c files.

I have build tested the patch series for all of the AT91 variants and devices, and have boot tested it on the AT91SAM9G20 (Snapper 9G20 board) and tested basic device functionality.

Ryan,

This patch series does not apply to linux-next.

It appears Jean-Christophe PLAGNIOL-VILLARD has recently committed a number of patches to that branch.

at91: move clock subsystem init to soc generic init
at91: move register clocks to soc generic init
at91: move st timer to drivers/clocksource
at91: move pit timer to drivers/clocksource
at91: switch st timer to early platform devices
at91: switch pit timer to early platform devices
at91: move gpio to drivers/gpio
at91: switch gpio to early platfrom device
at91: switch to CLKDEV_LOOKUP
at91: use structure to store the current soc
at91: merge board usb-a9260 and usb-a9263 together
at91: factorize at91 interrupts init to soc
at91: introduce commom AT91_BASE_SYS
at91rm9200: introduce at91rm9200_set_type to specficy cpu package
at91: 9260 and 9g20 add support of join SRAM Memory Mapping at91/board-eco920: remove at91_beeper ressource as no driver at91_beeper exist
atmel_serial: keep the platform_device unchanged
at91: remove MTD_NAND_ATMEL_BUSWIDTH_16 option
at91: Add ARCH_ID and basic cpu macros definition for 5series chips family.

There are also these three ahead of Linus' linux-2.6 tree:

Quoted 8 lines
Quoted 3 lines

arm: at91: fix compiler warning for eb01 board build
ARM: at91: AT91CAP9 has a macb device
treewide: remove extra semicolons

Ok, I have more changes to make anyway so I will rebase against these three. I do not want to rebase on top of the Jean-Christophe's patches because I do not think that they are ready for mainline inclusion. See the discussion in the other thread.

The soc fix need to first, the devices resource after
as the alot of devices resources need to be fix and api changes before such as RTC, GPIO, AT91_BASE_SYS, switch to clkdev, board init etc...

otherwise the factorisation of the resources will not be able to be tested and we need to re-updated due to design issue.

So please wait we finish this fix first as they are bigger issues

And this will allow to test the factorisation more easly and ensure we break nothing

Best Regards,
J.