Skip to content

Commit

Permalink
i.MX2: make SoC devices globally available
Browse files Browse the repository at this point in the history
Make SoC devices globally available to boards rather than using
a device specific init function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
  • Loading branch information
Sascha Hauer committed Sep 9, 2008
1 parent 5cf0942 commit 7e90534
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 52 deletions.
15 changes: 15 additions & 0 deletions arch/arm/mach-mx2/devices.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

extern struct platform_device mxc_gpt1;
extern struct platform_device mxc_gpt2;
extern struct platform_device mxc_gpt3;
extern struct platform_device mxc_gpt4;
extern struct platform_device mxc_gpt5;
extern struct platform_device mxc_wdt;
extern struct platform_device mxc_irda_device;
extern struct platform_device mxc_uart_device0;
extern struct platform_device mxc_uart_device1;
extern struct platform_device mxc_uart_device2;
extern struct platform_device mxc_uart_device3;
extern struct platform_device mxc_uart_device4;
extern struct platform_device mxc_uart_device5;

12 changes: 8 additions & 4 deletions arch/arm/mach-mx2/mx27ads.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <mach/iomux-mx1-mx2.h>
#include <mach/board-mx27ads.h>

#include "devices.h"

/* ADS's NOR flash */
static struct physmap_flash_data mx27ads_flash_data = {
.width = 2,
Expand Down Expand Up @@ -251,12 +253,14 @@ static struct imxuart_platform_data uart_pdata[] = {

static void __init mx27ads_board_init(void)
{
int i;

gpio_fec_active();

for (i = 0; i < 6; i++)
imx_init_uart(i, &uart_pdata[i]);
mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);
mxc_register_device(&mxc_uart_device3, &uart_pdata[3]);
mxc_register_device(&mxc_uart_device4, &uart_pdata[4]);
mxc_register_device(&mxc_uart_device5, &uart_pdata[5]);

platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
}
Expand Down
8 changes: 5 additions & 3 deletions arch/arm/mach-mx2/pcm038.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <mach/imx-uart.h>
#include <mach/board-pcm038.h>

#include "devices.h"

/*
* Phytec's phyCORE-i.MX27 comes with 32MiB flash,
* 16 bit width
Expand Down Expand Up @@ -170,11 +172,11 @@ static struct platform_device *platform_devices[] __initdata = {

static void __init pcm038_init(void)
{
int i;
gpio_fec_active();

for (i = 0; i < 3; i++)
imx_init_uart(i, &uart_pdata[i]);
mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);
mxc_register_device(&mxc_uart_device2, &uart_pdata[2]);

platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));

Expand Down
51 changes: 6 additions & 45 deletions arch/arm/mach-mx2/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static struct resource uart0[] = {
},
};

static struct platform_device mxc_uart_device0 = {
struct platform_device mxc_uart_device0 = {
.name = "imx-uart",
.id = 0,
.resource = uart0,
Expand All @@ -54,7 +54,7 @@ static struct resource uart1[] = {
},
};

static struct platform_device mxc_uart_device1 = {
struct platform_device mxc_uart_device1 = {
.name = "imx-uart",
.id = 1,
.resource = uart1,
Expand All @@ -73,7 +73,7 @@ static struct resource uart2[] = {
},
};

static struct platform_device mxc_uart_device2 = {
struct platform_device mxc_uart_device2 = {
.name = "imx-uart",
.id = 2,
.resource = uart2,
Expand All @@ -92,7 +92,7 @@ static struct resource uart3[] = {
},
};

static struct platform_device mxc_uart_device3 = {
struct platform_device mxc_uart_device3 = {
.name = "imx-uart",
.id = 3,
.resource = uart3,
Expand All @@ -111,7 +111,7 @@ static struct resource uart4[] = {
},
};

static struct platform_device mxc_uart_device4 = {
struct platform_device mxc_uart_device4 = {
.name = "imx-uart",
.id = 4,
.resource = uart4,
Expand All @@ -130,48 +130,9 @@ static struct resource uart5[] = {
},
};

static struct platform_device mxc_uart_device5 = {
struct platform_device mxc_uart_device5 = {
.name = "imx-uart",
.id = 5,
.resource = uart5,
.num_resources = ARRAY_SIZE(uart5),
};

/*
* Register only those UARTs that physically exists
*/
int __init imx_init_uart(int uart_no, struct imxuart_platform_data *pdata)
{
switch (uart_no) {
case 0:
mxc_uart_device0.dev.platform_data = pdata;
platform_device_register(&mxc_uart_device0);
break;
case 1:
mxc_uart_device1.dev.platform_data = pdata;
platform_device_register(&mxc_uart_device1);
break;
#ifndef CONFIG_MXC_IRDA
case 2:
mxc_uart_device2.dev.platform_data = pdata;
platform_device_register(&mxc_uart_device2);
break;
#endif
case 3:
mxc_uart_device3.dev.platform_data = pdata;
platform_device_register(&mxc_uart_device3);
break;
case 4:
mxc_uart_device4.dev.platform_data = pdata;
platform_device_register(&mxc_uart_device4);
break;
case 5:
mxc_uart_device5.dev.platform_data = pdata;
platform_device_register(&mxc_uart_device5);
break;
default:
return -ENODEV;
}

return 0;
}

0 comments on commit 7e90534

Please sign in to comment.