Skip to contentSkip to conversation

early platform patches

PATCH In review Magnus Damm 2 participants 13 messages Jan 23, 2009 – Jan 29, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover early platform patches

early platform patches

[PATCH 001/011] early platform driver V3
[PATCH 002/011] sh: add plat_early_device_setup() function [PATCH 003/011] sh: plat_early_device_setup() for sh2 [PATCH 004/011] sh: plat_early_device_setup() for sh2a [PATCH 005/011] sh: plat_early_device_setup() for sh3 [PATCH 006/011] sh: plat_early_device_setup() for sh4 [PATCH 007/011] sh: plat_early_device_setup() for sh4a [PATCH 008/011] sh: add early platform support for earlyprintk [PATCH 009/011] sh-sci: add early platform support [PATCH 010/011] sh: add early platform support for earlytimer [PATCH 011/011] sh_cmt: add early platform support

These patches add early platform driver support to the serial port driver and the CMT timer driver on the SuperH architecture.

The following patch sets posted to linuxsh-dev are required:

- [PATCH 000/013] sh-sci: platform device, clock and console changes
- [PATCH 00/05] sh: timer patches

The early platform driver V3 patch is a replacement for V2 in -mm.

Thanks for the feedback so far, more is always welcome. =)

---

 Documentation/driver-model/platform.txt |   59 +++++++
 arch/sh/Kconfig.debug                   |   27 ---
 arch/sh/include/asm/device.h            |    2 
 arch/sh/kernel/cpu/sh2/setup-sh7619.c   |    5 
 arch/sh/kernel/cpu/sh2a/setup-mxg.c     |    5 
 arch/sh/kernel/cpu/sh2a/setup-sh7201.c  |    5 
 arch/sh/kernel/cpu/sh2a/setup-sh7203.c  |    5 
 arch/sh/kernel/cpu/sh2a/setup-sh7206.c  |    5 
 arch/sh/kernel/cpu/sh3/setup-sh7705.c   |    5 
 arch/sh/kernel/cpu/sh3/setup-sh770x.c   |    5 
 arch/sh/kernel/cpu/sh3/setup-sh7710.c   |    5 
 arch/sh/kernel/cpu/sh3/setup-sh7720.c   |    5 
 arch/sh/kernel/cpu/sh4/setup-sh4-202.c  |    5 
 arch/sh/kernel/cpu/sh4/setup-sh7750.c   |    5 
 arch/sh/kernel/cpu/sh4/setup-sh7760.c   |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7343.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7366.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7722.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7723.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7763.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7770.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7780.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-sh7785.c  |    5 
 arch/sh/kernel/cpu/sh4a/setup-shx3.c    |    5 
 arch/sh/kernel/early_printk.c           |  142 ------------------
 arch/sh/kernel/setup.c                  |   10 +
 arch/sh/kernel/time_32.c                |   11 +
 drivers/base/platform.c                 |  239 +++++++++++++++++++++++++++++++
 drivers/clocksource/sh_cmt.c            |   18 ++
 drivers/serial/sh-sci.c                 |   49 +++++-
 include/linux/init.h                    |    1 
 include/linux/platform_device.h         |   42 +++++
 init/main.c                             |    7 
 33 files changed, 533 insertions(+), 179 deletions(-)
#1 lore raw

PATCH 1/11 early platform driver V3

From: Magnus Damm <[email protected]>

This patch is V3 of the early platform driver implementation.

Platform drivers are great for embedded platforms because we can separate driver configuration from the actual driver. So base addresses, interrupts and other configuration can be kept with the processor or board code, and the platform driver can be reused by many different platforms.

For early devices we have nothing today. For instance, to configure early timers and early serial ports we cannot use platform devices. This because the setup order during boot. Timers are needed before the platform driver core code is available. The same goes for early printk support. Early in this case means before initcalls.

These early drivers today have their configuration either hard coded or they receive it using some special configuration method. This is working quite well, but if we want to support both regular kernel modules and early devices then we need to have two ways of configuring the same driver. A single way would be better.

The early platform driver patch is basically a set of functions that allow drivers to register themselves and architecture code to locate them and probe. Registration happens through early_param(). The time for the probe is decided by the architecture code.

See Documentation/driver-model/platform.txt for more details.

---

Tested with serial ports and timers on sh7722 and sh7723.

Changes since V2:
- use strict_strtoul() instead of simple_strtoul()
- command line parsing fixes to support "class_str=drv_name.id"
- added early_platform_add_devices() for device registration
- broke out early_platform_driver_register_all() function
- modified early_platform_driver_probe() to support user_only case
- added cleanup code
- added documentation

Changes since V1:
- changed function names to use "early_" prefix
- use struct early_platform_driver for data
- added support for matching against pdev->id
- use early_platform_init() in device drivers
- added more comments

 Documentation/driver-model/platform.txt |   59 +++++++
 drivers/base/platform.c                 |  239 +++++++++++++++++++++++++++++++
 include/linux/init.h                    |    1 
 include/linux/platform_device.h         |   42 +++++
 init/main.c                             |    7 
 5 files changed, 347 insertions(+), 1 deletion(-)
Documentation/driver-model/platform.txt +59 -0
@@ -169,3 +169,62 @@ three different ways to find such a matc
       be probed later if another device registers.  (Which is OK, since
       this interface is only for use with non-hotpluggable devices.)
 
+
+Early Platform Devices and Drivers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The early platform interfaces provide platform data to platform device
+drivers early on during the system boot. The code is built on top of the
+early_param() command line parsing and can be executed very early on.
+
+Example: "earlyprintk" class early serial console in 6 steps
+
+1. Registering early platform device data
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The architecture code registers platform device data using the function
+early_platform_add_devices(). In the case of early serial console this
+should be hardware configuration for the serial port. Devices registered
+at this point will later on be matched against early platform drivers.
+
+2. Parsing kernel command line
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The architecture code calls parse_early_param() to parse the kernel
+command line. This will execute all matching early_param() callbacks.
+User specified early platform devices will be registered at this point.
+For the early serial console case the user can specify port on the
+kernel command line as "earlyprintk=serial.0" where "earlyprintk" is
+the class string, "serial" is the name of the platfrom driver and
+0 is the platform device id. If the id is -1 then the dot and the
+id can be omitted.
+
+3. Installing early platform drivers belonging to a certain class
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The architecture code may optionally force registration of all early
+platform drivers belonging to a certain class using the function
+early_platform_driver_register_all(). User specified devices from
+step 2 have priority over these. This step is omitted by the serial
+driver example since the early serial driver code should be disabled
+unless the user has specified port on the kernel command line.
+
+4. Early platform driver registration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Compiled-in platform drivers making use of early_platform_init() are
+automatically registered during step 2 or 3. The serial driver example
+should use early_platform_init("earlyprintk", &platform_driver).
+
+5. Probing of early platform drivers belonging to a certain class
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The architecture code calls early_platform_driver_probe() to match
+registered early platform devices associated with a certain class with
+registered early platform drivers. Matched devices will get probed().
+This step can be executed at any point during the early boot. As soon
+as possible may be good for the serial port case.
+
+6. Inside the early platform driver probe()
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The driver code needs to take special care during early boot, especially
+when it comes to memory allocation and interrupt registration. The code
+in the probe() function can use is_early_platform_device() to check if
+it is called at early platform device or at the regular platform device
+time. The early serial driver performs register_console() at this point.
+
+For further information, see <linux/platform_device.h>.
drivers/base/platform.c +239 -0

248 lines not on this page · raw message

include/linux/init.h +1 -0
@@ -247,6 +247,7 @@ struct obs_kernel_param {
 
 /* Relies on boot_command_line being set */
 void __init parse_early_param(void);
+void __init parse_early_options(char *cmdline);
 #endif /* __ASSEMBLY__ */
 
 /**
include/linux/platform_device.h +42 -0

46 lines not on this page · raw message

init/main.c +6 -1
@@ -490,6 +490,11 @@ static int __init do_early_param(char *p
 	return 0;
 }
 
+void __init parse_early_options(char *cmdline)
+{
+	parse_args("early options", cmdline, NULL, 0, do_early_param);
+}
+
 /* Arch code calls this early on, or if not, just before other parsing. */
 void __init parse_early_param(void)
 {
@@ -501,7 +506,7 @@ void __init parse_early_param(void)
 
 	/* All fall through to do_early_param. */
 	strlcpy(tmp_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-	parse_args("early options", tmp_cmdline, NULL, 0, do_early_param);
+	parse_early_options(tmp_cmdline);
 	done = 1;
 }
 
#2 lore raw

PATCH 2/11 sh: add plat_early_device_setup() function

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds the function plat_early_device_setup() which cpu code can use for early platform device registation.

---

 arch/sh/include/asm/device.h |    2 ++
 arch/sh/kernel/setup.c       |    7 +++++++
 2 files changed, 9 insertions(+)
arch/sh/include/asm/device.h +2 -0
@@ -10,3 +10,5 @@ struct platform_device;
 int platform_resource_setup_memory(struct platform_device *pdev,
 				   char *name, unsigned long memsize);
 
+void plat_early_device_setup(void);
+
arch/sh/kernel/setup.c +7 -0
@@ -29,6 +29,7 @@
 #include <linux/mmzone.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/platform_device.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 #include <asm/page.h>
@@ -329,6 +330,10 @@ static int __init parse_elfcorehdr(char 
 early_param("elfcorehdr", parse_elfcorehdr);
 #endif
 
+void __init __attribute__ ((weak)) plat_early_device_setup(void)
+{
+}
+
 void __init setup_arch(char **cmdline_p)
 {
 	enable_mmu();
@@ -382,6 +387,8 @@ void __init setup_arch(char **cmdline_p)
 
 	parse_early_param();
 
+	plat_early_device_setup();
+
 	sh_mv_setup();
 
 	/*
#3 lore raw

PATCH 3/11 sh: plat_early_device_setup() for sh2

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds sh2 code to register early platform devices using plat_early_device_setup().

---

 arch/sh/kernel/cpu/sh2/setup-sh7619.c |    5 +++++
 1 file changed, 5 insertions(+)
arch/sh/kernel/cpu/sh2/setup-sh7619.c +5 -0
@@ -149,6 +149,11 @@ static int __init sh7619_devices_setup(v
 }
 __initcall(sh7619_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7619_devices, ARRAY_SIZE(sh7619_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
#4 lore raw

PATCH 4/11 sh: plat_early_device_setup() for sh2a

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds sh2a code to register early platform devices using plat_early_device_setup().

---

 arch/sh/kernel/cpu/sh2a/setup-mxg.c    |    5 +++++
 arch/sh/kernel/cpu/sh2a/setup-sh7201.c |    5 +++++
 arch/sh/kernel/cpu/sh2a/setup-sh7203.c |    5 +++++
 arch/sh/kernel/cpu/sh2a/setup-sh7206.c |    5 +++++
 4 files changed, 20 insertions(+)
arch/sh/kernel/cpu/sh2a/setup-mxg.c +5 -0
@@ -158,6 +158,11 @@ static int __init mxg_devices_setup(void
 }
 __initcall(mxg_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(mxg_devices, ARRAY_SIZE(mxg_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
arch/sh/kernel/cpu/sh2a/setup-sh7201.c +5 -0
@@ -397,6 +397,11 @@ static int __init sh7201_devices_setup(v
 }
 __initcall(sh7201_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7201_devices, ARRAY_SIZE(sh7201_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
arch/sh/kernel/cpu/sh2a/setup-sh7203.c +5 -0
@@ -342,6 +342,11 @@ static int __init sh7203_devices_setup(v
 }
 __initcall(sh7203_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7203_devices, ARRAY_SIZE(sh7203_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
arch/sh/kernel/cpu/sh2a/setup-sh7206.c +5 -0
@@ -243,6 +243,11 @@ static int __init sh7206_devices_setup(v
 }
 __initcall(sh7206_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7206_devices, ARRAY_SIZE(sh7206_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
#5 lore raw

PATCH 5/11 sh: plat_early_device_setup() for sh3

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds sh3 code to register early platform devices using plat_early_device_setup().

---

 arch/sh/kernel/cpu/sh3/setup-sh7705.c |    5 +++++
 arch/sh/kernel/cpu/sh3/setup-sh770x.c |    5 +++++
 arch/sh/kernel/cpu/sh3/setup-sh7710.c |    5 +++++
 arch/sh/kernel/cpu/sh3/setup-sh7720.c |    5 +++++
 4 files changed, 20 insertions(+)
arch/sh/kernel/cpu/sh3/setup-sh7705.c +5 -0
@@ -158,6 +158,11 @@ static int __init sh7705_devices_setup(v
 }
 __initcall(sh7705_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7705_devices, ARRAY_SIZE(sh7705_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
arch/sh/kernel/cpu/sh3/setup-sh770x.c +5 -0
@@ -204,6 +204,11 @@ static int __init sh770x_devices_setup(v
 }
 __initcall(sh770x_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh770x_devices, ARRAY_SIZE(sh770x_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
arch/sh/kernel/cpu/sh3/setup-sh7710.c +5 -0
@@ -165,6 +165,11 @@ static int __init sh7710_devices_setup(v
 }
 __initcall(sh7710_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7710_devices, ARRAY_SIZE(sh7710_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	register_intc_controller(&intc_desc);
arch/sh/kernel/cpu/sh3/setup-sh7720.c +5 -0
@@ -152,6 +152,11 @@ static int __init sh7720_devices_setup(v
 }
 __initcall(sh7720_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7720_devices, ARRAY_SIZE(sh7720_devices));
+}
+
 enum {
 	UNUSED = 0,
 
#6 lore raw

PATCH 6/11 sh: plat_early_device_setup() for sh4

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds sh4 code to register early platform devices using plat_early_device_setup().

---

 arch/sh/kernel/cpu/sh4/setup-sh4-202.c |    5 +++++
 arch/sh/kernel/cpu/sh4/setup-sh7750.c  |    5 +++++
 arch/sh/kernel/cpu/sh4/setup-sh7760.c  |    5 +++++
 3 files changed, 15 insertions(+)
arch/sh/kernel/cpu/sh4/setup-sh4-202.c +5 -0
@@ -38,6 +38,11 @@ static int __init sh4202_devices_setup(v
 }
 __initcall(sh4202_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh4202_devices, ARRAY_SIZE(sh4202_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 	/* do nothing - all IRL interrupts are handled by the board code */
arch/sh/kernel/cpu/sh4/setup-sh7750.c +5 -0
@@ -95,6 +95,11 @@ static int __init sh7750_devices_setup(v
 }
 __initcall(sh7750_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7750_devices, ARRAY_SIZE(sh7750_devices));
+}
+
 enum {
 	UNUSED = 0,
 
arch/sh/kernel/cpu/sh4/setup-sh7760.c +5 -0
@@ -207,6 +207,11 @@ static int __init sh7760_devices_setup(v
 }
 __initcall(sh7760_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7760_devices, ARRAY_SIZE(sh7760_devices));
+}
+
 #define INTC_ICR	0xffd00000UL
 #define INTC_ICR_IRLM	(1 << 7)
 
#7 lore raw

PATCH 7/11 sh: plat_early_device_setup() for sh4a

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds sh4a code to register early platform devices using plat_early_device_setup().

---

 arch/sh/kernel/cpu/sh4a/setup-sh7343.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-sh7366.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-sh7722.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-sh7723.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-sh7763.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-sh7770.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-sh7780.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-sh7785.c |    5 +++++
 arch/sh/kernel/cpu/sh4a/setup-shx3.c   |    5 +++++
 9 files changed, 45 insertions(+)
arch/sh/kernel/cpu/sh4a/setup-sh7343.c +5 -0
@@ -267,6 +267,11 @@ static int __init sh7343_devices_setup(v
 }
 __initcall(sh7343_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7343_devices, ARRAY_SIZE(sh7343_devices));
+}
+
 enum {
 	UNUSED = 0,
 
arch/sh/kernel/cpu/sh4a/setup-sh7366.c +5 -0
@@ -223,6 +223,11 @@ static int __init sh7366_devices_setup(v
 }
 __initcall(sh7366_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7366_devices, ARRAY_SIZE(sh7366_devices));
+}
+
 enum {
 	UNUSED=0,
 
arch/sh/kernel/cpu/sh4a/setup-sh7722.c +5 -0
@@ -288,6 +288,11 @@ static int __init sh7722_devices_setup(v
 }
 __initcall(sh7722_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7722_devices, ARRAY_SIZE(sh7722_devices));
+}
+
 enum {
 	UNUSED=0,
 
arch/sh/kernel/cpu/sh4a/setup-sh7723.c +5 -0
@@ -338,6 +338,11 @@ static int __init sh7723_devices_setup(v
 }
 __initcall(sh7723_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7723_devices, ARRAY_SIZE(sh7723_devices));
+}
+
 enum {
 	UNUSED=0,
 
arch/sh/kernel/cpu/sh4a/setup-sh7763.c +5 -0
@@ -155,6 +155,11 @@ static int __init sh7763_devices_setup(v
 }
 __initcall(sh7763_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7363_devices, ARRAY_SIZE(sh7363_devices));
+}
+
 enum {
 	UNUSED = 0,
 
arch/sh/kernel/cpu/sh4a/setup-sh7770.c +5 -0
@@ -87,6 +87,11 @@ static int __init sh7770_devices_setup(v
 }
 __initcall(sh7770_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7770_devices, ARRAY_SIZE(sh7770_devices));
+}
+
 void __init plat_irq_setup(void)
 {
 }
arch/sh/kernel/cpu/sh4a/setup-sh7780.c +5 -0
@@ -86,6 +86,11 @@ static int __init sh7780_devices_setup(v
 }
 __initcall(sh7780_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7780_devices, ARRAY_SIZE(sh7780_devices));
+}
+
 enum {
 	UNUSED = 0,
 
arch/sh/kernel/cpu/sh4a/setup-sh7785.c +5 -0
@@ -121,6 +121,11 @@ static int __init sh7785_devices_setup(v
 }
 __initcall(sh7785_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(sh7785_devices, ARRAY_SIZE(sh7785_devices));
+}
+
 enum {
 	UNUSED = 0,
 
arch/sh/kernel/cpu/sh4a/setup-shx3.c +5 -0
@@ -88,6 +88,11 @@ static int __init shx3_devices_setup(voi
 }
 __initcall(shx3_devices_setup);
 
+void __init plat_early_device_setup(void)
+{
+	early_platform_add_devices(shx3_devices, ARRAY_SIZE(shx3_devices));
+}
+
 enum {
 	UNUSED = 0,
 
#8 lore raw

PATCH 8/11 sh: add early platform support for earlyprintk

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds early platform "earlyprintk" class support.

---

 arch/sh/kernel/setup.c |    3 +++
 1 file changed, 3 insertions(+)
arch/sh/kernel/setup.c +3 -0
@@ -389,6 +389,9 @@ void __init setup_arch(char **cmdline_p)
 
 	plat_early_device_setup();
 
+	/* Let earlyprintk output early console messages */
+	early_platform_driver_probe("earlyprintk", 1, 1);
+
 	sh_mv_setup();
 
 	/*
#9 lore raw

PATCH 9/11 sh-sci: add early platform support

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch removes the old duplicated early serial code and adds early platform support to the sh-sci driver.

---

 arch/sh/Kconfig.debug         |   27 -------
 arch/sh/kernel/early_printk.c |  142 -----------------------------------------
 drivers/serial/sh-sci.c       |   48 +++++++++++--
 3 files changed, 41 insertions(+), 176 deletions(-)
arch/sh/Kconfig.debug +1 -26
@@ -19,34 +19,9 @@ config SH_STANDARD_BIOS
 	  mask ROM and no flash (WindowsCE machines fall in this category).
 	  If unsure, say N.
 
-config EARLY_SCIF_CONSOLE
-	bool "Use early SCIF console"
-	help
-	  This enables an early console using a fixed SCIF port. This can
-	  be used by platforms that are either not running the SH
-	  standard BIOS, or do not wish to use the BIOS callbacks for the
-	  serial I/O.
-
-config EARLY_SCIF_CONSOLE_PORT
-	hex
-	depends on EARLY_SCIF_CONSOLE
-	default "0xa4400000" if CPU_SUBTYPE_SH7712 || CPU_SUBTYPE_SH7705
-	default "0xa4430000" if CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721
-	default "0xf8420000" if CPU_SUBTYPE_SH7619
-	default "0xff804000" if CPU_SUBTYPE_MXG
-	default "0xffc30000" if CPU_SUBTYPE_SHX3
-	default "0xffe00000" if CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7763 || \
-				CPU_SUBTYPE_SH7722 || CPU_SUBTYPE_SH7366 || \
-				CPU_SUBTYPE_SH7343
-	default "0xffe80000" if CPU_SH4
-	default "0xffea0000" if CPU_SUBTYPE_SH7785
-	default "0xfffe8000" if CPU_SUBTYPE_SH7203
-	default "0xfffe9800" if CPU_SUBTYPE_SH7206 || CPU_SUBTYPE_SH7263
-	default "0x00000000"
-
 config EARLY_PRINTK
 	bool "Early printk support"
-	depends on SH_STANDARD_BIOS || EARLY_SCIF_CONSOLE
+	depends on SH_STANDARD_BIOS
 	help
 	  Say Y here to redirect kernel printk messages to the serial port
 	  used by the SH-IPL bootloader, starting very early in the boot
arch/sh/kernel/early_printk.c +0 -142

160 lines not on this page · raw message

drivers/serial/sh-sci.c +40 -8

88 lines not on this page · raw message

#10 lore raw

PATCH 10/11 sh: add early platform support for earlytimer

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds early platform "earlytimer" class support.

---

 arch/sh/kernel/time_32.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
arch/sh/kernel/time_32.c +11 -0
@@ -218,6 +218,8 @@ unsigned long long sched_clock(void)
 
 void __init time_init(void)
 {
+	int n;
+
 	if (board_time_init)
 		board_time_init();
 
@@ -236,6 +238,15 @@ void __init time_init(void)
 	 * initialized for us.
 	 */
 	sys_timer = get_sys_timer();
+
+	/* Make sure all compiled-in early timers register themselves.
+	 * Run probe() for one "earlytimer" device.
+	 */
+	early_platform_driver_register_all("earlytimer");
+	n = early_platform_driver_probe("earlytimer", 1, 0);
+	if (n)
+		return;
+
 	if (sys_timer)
 		pr_info("Using %s for system timer\n", sys_timer->name);
 	else
#11 lore raw

PATCH 11/11 sh_cmt: add early platform support

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

This adds early platform support to the sh_cmt timer driver.

---

 drivers/clocksource/sh_cmt.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/clocksource/sh_cmt.c +16 -2
@@ -567,9 +567,19 @@ static int sh_cmt_setup(struct sh_cmt_pr
 static int __devinit sh_cmt_probe(struct platform_device *pdev)
 {
 	struct sh_cmt_priv *p = platform_get_drvdata(pdev);
+	struct sh_cmt_config *cfg = pdev->dev.platform_data;
 	int ret;
 
-	p = kmalloc(sizeof(*p), GFP_KERNEL);
+	if (p) {
+		pr_info("sh_cmt: %s kept as earlytimer\n", cfg->name);
+		return 0;
+	}
+
+	if (is_early_platform_device(pdev))
+		p = alloc_bootmem(sizeof(*p));
+	else
+		p = kmalloc(sizeof(*p), GFP_KERNEL);
+
 	if (p == NULL) {
 		dev_err(&pdev->dev, "failed to allocate driver data\n");
 		return -ENOMEM;
@@ -577,7 +587,10 @@ static int __devinit sh_cmt_probe(struct
 
 	ret = sh_cmt_setup(p, pdev);
 	if (ret) {
-		kfree(p);
+		if (is_early_platform_device(pdev))
+			free_bootmem(__pa(p), sizeof(*p));
+		else
+			kfree(p);
 
 		platform_set_drvdata(pdev, NULL);
 	}
@@ -607,6 +620,7 @@ static void __exit sh_cmt_exit(void)
 	platform_driver_unregister(&sh_cmt_device_driver);
 }
 
+early_platform_init("earlytimer", &sh_cmt_device_driver);
 module_init(sh_cmt_init);
 module_exit(sh_cmt_exit);
 
#12 lore raw
In reply to Magnus Damm
Quoted 14 lines · On Fri, 23 Jan 2009 19:57:21 +0900 Magnus Damm <[email protected]> wrote:

early platform patches

[PATCH 001/011] early platform driver V3
[PATCH 002/011] sh: add plat_early_device_setup() function [PATCH 003/011] sh: plat_early_device_setup() for sh2 [PATCH 004/011] sh: plat_early_device_setup() for sh2a [PATCH 005/011] sh: plat_early_device_setup() for sh3 [PATCH 006/011] sh: plat_early_device_setup() for sh4 [PATCH 007/011] sh: plat_early_device_setup() for sh4a [PATCH 008/011] sh: add early platform support for earlyprintk [PATCH 009/011] sh-sci: add early platform support [PATCH 010/011] sh: add early platform support for earlytimer [PATCH 011/011] sh_cmt: add early platform support

Quoted 7 lines

These patches add early platform driver support to the serial port driver and the CMT timer driver on the SuperH architecture.

The following patch sets posted to linuxsh-dev are required:

- [PATCH 000/013] sh-sci: platform device, clock and console changes
- [PATCH 00/05] sh: timer patches

Oh, that explains all the rejects.

Quoted 2 lines

The early platform driver V3 patch is a replacement for V2 in -mm.

Well, it looks OK to me, but I don't really know what I'm looking at.

David, Kay, Tejun: would you be able to take a look at 001/011 sometime, please?

Thanks