Skip to contentSkip to conversation

make platform_init() weak for 8xx

PATCH In review Andreas Oberritter 2 participants 6 messages Jul 19, 2004 – Jul 27, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make platform_init() weak for 8xx

Hi Tom,

this patch renames platform_init to m8xx_init in m8xx_setup.c and adds new weak platform_init, which can be overridden by boards to allow them to e.g. register platform_devices like redwood5.c does for 40x.

===== arch/ppc/syslib/m8xx_setup.c 1.29 vs edited =====

arch/ppc/syslib/m8xx_setup.c +10 -1
@@ -47,6 +47,7 @@
 #include <asm/xmon.h>
 
 #include "ppc8xx_pic.h"
+#include "m8xx_setup.h"
 
 static int m8xx_set_rtc_time(unsigned long time);
 static unsigned long m8xx_get_rtc_time(void);
@@ -363,7 +364,7 @@
 }
 
 void __init
-platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+m8xx_init(unsigned long r3, unsigned long r4, unsigned long r5,
 		unsigned long r6, unsigned long r7)
 {
 	parse_bootinfo(find_bootinfo());
@@ -413,3 +414,11 @@
 	m8xx_ide_init();
 #endif
 }
+
+void __init __attribute__ ((weak))
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+		unsigned long r6, unsigned long r7)
+{
+	m8xx_init(r3, r4, r5, r6, r7);
+}
+
arch/ppc/syslib/m8xx_setup.h new file +12 -0
@@ -0,0 +1,12 @@
+/*
+ * arch/ppc/syslib/m8xx_setup.h
+ */
+
+#ifndef _PPC_SYSLIB_M8XX_SETUP_H
+#define _PPC_SYSLIB_M8XX_SETUP_H
+
+void m8xx_init(unsigned long r3, unsigned long r4, unsigned long r5,
+		unsigned long r6, unsigned long r7);
+void m8xx_setup_arch(void);
+
+#endif /* _PPC_SYSLIB_M8XX_SETUP_H */
#1 lore raw
Quoted 5 lines · Andreas Oberritter

Hi Tom,

this patch renames platform_init to m8xx_init in m8xx_setup.c and adds new weak platform_init, which can be overridden by boards to allow them to e.g. register platform_devices like redwood5.c does for 40x.

First, I don't see the redwood5 example you're talking about. Second, this takes us in the direction of 82xx. Until the 82xx abstractions get flushed out a bit more, I remain unconvinced that they're really the right way to go (perhaps hooking the other direction would work better, e.g. platform_init() calls board_init(), with a weak version provided, and some functions forced to be provided by board.c, such as m8xx_map_io).

--
Tom Rini
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

#2 lore raw
Quoted 6 lines · Tom Rini
Quoted 3 lines · Andreas Oberritter

this patch renames platform_init to m8xx_init in m8xx_setup.c and adds new weak platform_init, which can be overridden by boards to allow them to e.g. register platform_devices like redwood5.c does for 40x.

First, I don't see the redwood5 example you're talking about.

http://ppc.bkbits.net:8080/linuxppc-2.5/anno/arch/ppc/platforms/4xx/[email protected]?nav=index.html

Quoted 6 lines

Second, this takes us in the direction of 82xx. Until the 82xx abstractions get flushed out a bit more, I remain unconvinced that they're really the right way to go (perhaps hooking the other direction would work better, e.g. platform_init() calls board_init(), with a weak version provided, and some functions forced to be provided by board.c, such as m8xx_map_io).

I chose this way because it seemed to be a simple way to port the dbox2 board to 2.6 using the new device API. Is there another 8xx board which uses the device API for its onboard peripherials and can be used as a reference? Can I get my devices registered without modifying platform_init, or shall I send a patch with the board_init() you mentioned? See my board.c attached.

Regards,
Andreas

/*
* arch/ppc/platforms/dbox2.c
*
* setup routines for the dbox2 board
*
* Copyright (C) 2004 Andreas Oberritter <[email protected]> *
*/

#include <linux/device.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <asm/commproc.h>
#include <asm/io.h>
#include <syslib/m8xx_setup.h>

enum dbox2_mid {
	MID_NOKIA	= 1,
	MID_PHILIPS	= 2,
	MID_SAGEM	= 3,
};
const char *manuf_name[3] = {
	"Nokia",
	"Philips",
	"Sagem",
};
static struct resource enx_resources[] = {
	[0] = {
		.start	= 0x08000000,
		.end	= 0x080033ff,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= 0x09000000,
		.end	= 0x091fffff,
		.flags	= IORESOURCE_MEM,
	},
	[2] = {
		.start	= SIU_IRQ1,
		.end	= SIU_IRQ1,
		.flags	= IORESOURCE_IRQ,
	},
};
static struct platform_device enx_device = {
	.name		= "enx",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(enx_resources),
	.resource	= enx_resources,
};
static struct resource gtx_resources[] = {
	[0] = {
		.start	= 0x08400000,
		.end	= 0x08402fff,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= 0x08000000,
		.end	= 0x081fffff,
		.flags	= IORESOURCE_MEM,
	},
	[2] = {
		.start	= SIU_IRQ1,
		.end	= SIU_IRQ1,
		.flags	= IORESOURCE_IRQ,
	},
};
static struct platform_device gtx_device = {
	.name		= "gtx",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(gtx_resources),
	.resource	= gtx_resources,
};
static struct resource fp_resources[] = {
	[0] = {
		.start	= SIU_IRQ2,
		.end	= SIU_IRQ2,
		.flags	= IORESOURCE_IRQ,
	},
};
static struct platform_device fp_device = {
	.name		= "fp",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(fp_resources),
	.resource	= fp_resources,
};
static struct resource cam_resources[] = {
	[0] = {
		.start	= 0x0c000000,
		.end	= 0x0c01ffff,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= SIU_IRQ3,
		.end	= SIU_IRQ3,
		.flags	= IORESOURCE_IRQ,
	},
};
static struct platform_device cam_device = {
	.name		= "cam",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(cam_resources),
	.resource	= cam_resources,
};
static struct resource avia_resources[] = {
	[0] = {
		.start	= 0x0a000000,
		.end	= 0x0a0001ff,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= SIU_IRQ4,
		.end	= SIU_IRQ4,
		.flags	= IORESOURCE_IRQ,
	},
};
static struct platform_device avia_device = {
	.name		= "avia",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(avia_resources),
	.resource	= avia_resources,
};
static struct platform_device *dbox2_devs[] __initdata = {
	&enx_device,
	&fp_device,
	&cam_device,
	&avia_device,
};

static int __init dbox2_add_devices(void)

{
	u8 *config_area;
	int manuf_id;

	config_area = ioremap(0x1001ffe0, 0x20);
	if (!config_area) {
		printk(KERN_ERR "dbox2: could not map config area!\n");
		return -EIO;
	}
	manuf_id = config_area[0];
	iounmap(config_area);

	if ((manuf_id < MID_NOKIA) || (manuf_id > MID_SAGEM)) {
		printk(KERN_ERR "dbox2: invalid config area!\n");
		return -EIO;
	}

	printk(KERN_INFO "dbox2: %s board detected.\n", manuf_name[manuf_id - 1]);

	if (manuf_id == MID_NOKIA) {
		dbox2_devs[0] = &gtx_device;
	} else if (manuf_id == MID_PHILIPS) {
		cam_resources[0].start += 0x40000;
		cam_resources[0].end += 0x40000;
	}

	return platform_add_devices(dbox2_devs, ARRAY_SIZE(dbox2_devs));
}

static void __init dbox2_setup_arch(void)

{
	m8xx_setup_arch();

	device_initcall(dbox2_add_devices);
}

void __init platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7)

{
	m8xx_init(r3, r4, r5, r6, r7);

	ppc_md.setup_arch = dbox2_setup_arch;
}
#3 lore raw
Quoted 9 lines · Andreas Oberritter
Quoted 6 lines · Tom Rini
Quoted 3 lines · Andreas Oberritter

this patch renames platform_init to m8xx_init in m8xx_setup.c and adds new weak platform_init, which can be overridden by boards to allow them to e.g. register platform_devices like redwood5.c does for 40x.

First, I don't see the redwood5 example you're talking about.

http://ppc.bkbits.net:8080/linuxppc-2.5/anno/arch/ppc/platforms/4xx/[email protected]?nav=index.html

Ah, I follow you now. This too, seems awkward to me. I'm making myself a note to talk with Matt Porter when I see him tomorrow about this.

Quoted 7 lines
Quoted 6 lines

Second, this takes us in the direction of 82xx. Until the 82xx abstractions get flushed out a bit more, I remain unconvinced that they're really the right way to go (perhaps hooking the other direction would work better, e.g. platform_init() calls board_init(), with a weak version provided, and some functions forced to be provided by board.c, such as m8xx_map_io).

Quoted 6 lines

I chose this way because it seemed to be a simple way to port the dbox2 board to 2.6 using the new device API. Is there another 8xx board which uses the device API for its onboard peripherials and can be used as a reference? Can I get my devices registered without modifying platform_init, or shall I send a patch with the board_init() you mentioned? See my board.c attached.

There currently isn't a reference platform for what you speak of. My preference would be to see what I described given a shot to see if it looks better or worse (and it better, or worse, in the flow of things). But, tomorrow I leave for OLS, so if I don't reply, well, that's my excuse.

--
Tom Rini
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

#4 lore raw

PATCH 1/1 add board_init() (was [PATCH] make platform_init() weak for 8xx)

Am Mo, den 19.07.2004 schrieb Tom Rini um 20:20:

Quoted 17 lines · Andreas Oberritter
Quoted 9 lines · Tom Rini
Quoted 6 lines

Second, this takes us in the direction of 82xx. Until the 82xx abstractions get flushed out a bit more, I remain unconvinced that they're really the right way to go (perhaps hooking the other direction would work better, e.g. platform_init() calls board_init(), with a weak version provided, and some functions forced to be provided by board.c, such as m8xx_map_io).

Quoted 6 lines

I chose this way because it seemed to be a simple way to port the dbox2 board to 2.6 using the new device API. Is there another 8xx board which uses the device API for its onboard peripherials and can be used as a reference? Can I get my devices registered without modifying platform_init, or shall I send a patch with the board_init() you mentioned? See my board.c attached.

Quoted 3 lines

There currently isn't a reference platform for what you speak of. My preference would be to see what I described given a shot to see if it looks better or worse (and it better, or worse, in the flow of things).

How about this patch?

Regards,
Andreas

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2004/07/23 15:54:13+02:00 [email protected]
# add weak board_init() function which can be overridden by board support code
#

# arch/ppc/syslib/m8xx_setup.c
#   2004/07/23 15:53:53+02:00 [email protected] +6 -0
#   add weak board_init() function which can be overridden by board support code
#
diff -Nru a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c
--- a/arch/ppc/syslib/m8xx_setup.c	2004-07-23 15:54:57 +02:00
+++ b/arch/ppc/syslib/m8xx_setup.c	2004-07-23 15:54:57 +02:00
@@ -61,6 +61,11 @@
 extern void m8xx_wdt_handler_install(bd_t *bp);
 extern void rpxfb_alloc_pages(void);

+void __attribute__ ((weak))
+board_init(void)
+{
+}
+
void __init
m8xx_setup_arch(void)
{
@@ -103,6 +108,7 @@
}
#endif
#endif
+ board_init();
}

void

#5 lore raw

Re: [PATCH] add board_init() (was [PATCH] make platform_init() weak for 8xx)

Quoted 18 lines · Andreas Oberritter

Am Mo, den 19.07.2004 schrieb Tom Rini um 20:20:

Quoted 17 lines · Andreas Oberritter
Quoted 15 lines · Tom Rini
Quoted 6 lines

Second, this takes us in the direction of 82xx. Until the 82xx abstractions get flushed out a bit more, I remain unconvinced that they're really the right way to go (perhaps hooking the other direction would work better, e.g. platform_init() calls board_init(), with a weak version provided, and some functions forced to be provided by board.c, such as m8xx_map_io).

I chose this way because it seemed to be a simple way to port the dbox2 board to 2.6 using the new device API. Is there another 8xx board which uses the device API for its onboard peripherials and can be used as a reference? Can I get my devices registered without modifying platform_init, or shall I send a patch with the board_init() you mentioned? See my board.c attached.

Quoted 5 lines
Quoted 3 lines

There currently isn't a reference platform for what you speak of. My preference would be to see what I described given a shot to see if it looks better or worse (and it better, or worse, in the flow of things).

How about this patch?

Yes, I think that's about it.

--
Tom Rini
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/