ARM: mach-shmobile: sh7372 A3SP prototype support
Magnus Damm
maintainerPATCH 2/3 ARM: mach-shmobile: sh7372 A3SP prototype support
From: Magnus Damm <[email protected]>
Prototype code to add support for A3SP on sh7372.
Lightly tested on Mackerel, adding AP4EVB support is still on the TODO.
Also, please note that using the serial console for output from the power domain control callbacks is not supported due to the usage of Runtime PM in the SCIF serial console driver code.
Not suitable for merge until we have QoS support.
---
arch/arm/mach-shmobile/board-mackerel.c | 8 ++++++++ arch/arm/mach-shmobile/include/mach/sh7372.h | 1 + arch/arm/mach-shmobile/pm-sh7372.c | 23 +++++++++++++++++------ arch/arm/mach-shmobile/setup-sh7372.c | 13 +++++++++++++ 4 files changed, 39 insertions(+), 6 deletions(-)
arch/arm/mach-shmobile/board-mackerel.c +8 -0
@@ -1584,6 +1584,14 @@ static void __init mackerel_init(void)sh7372_add_device_to_domain (&sh7372_a4lc, &lcdc_device);sh7372_add_device_to_domain (&sh7372_a4lc, &hdmi_lcdc_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &usbhs0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &usbhs1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &sh_mmcif_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi0_device); +#if !defined(CONFIG_MMC_SH_MMCIF ) && !defined(CONFIG_MMC_SH_MMCIF_MODULE ) +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi1_device); +#endif +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi2_device);hdmi_init_pm_clock ();sh7372_pm_init ();
arch/arm/mach-shmobile/include/mach/sh7372.h +1 -0
@@ -487,6 +487,7 @@ static inline struct sh7372_pm_domain *textern struct sh7372_pm_domain sh7372_a4lc;extern struct sh7372_pm_domain sh7372_a3rv;extern struct sh7372_pm_domain sh7372_a3ri; +extern struct sh7372_pm_domain sh7372_a3sp;extern struct sh7372_pm_domain sh7372_a3sg;extern void sh7372_init_pm_domain (struct sh7372_pm_domain *sh7372_pd);
arch/arm/mach-shmobile/pm-sh7372.c +17 -6
@@ -7,7 +7,7 @@* License. See the file "COPYING" in the main directory of this archive * for more details. */ - +#define DEBUG #include <linux/pm.h> #include <linux/suspend.h> #include <linux/cpuidle.h>
@@ -28,10 +28,10 @@#define SYSTBCR 0xe6150024#define SBAR 0xe6180020#define APARMBAREA 0xe6f10020 -#define SPDCR 0xe6180008#define SWUCR 0xe6180014#define PSTR 0xe6180080 +#define PDNSEL 0xe6180254#define PSTR_RETRIES 100#define PSTR_DELAY_US 10
@@ -55,8 +55,10 @@ static int pd_power_down(struct generic_ } } -pr_debug ("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n" , - mask,__raw_readl (PSTR )); +/* we cannot output debug message for A3SP */ +if (genpd != &sh7372_a3sp.genpd) +pr_debug ("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n" , + mask,__raw_readl (PSTR ));return 0 ; }
@@ -85,8 +87,10 @@ static int pd_power_up(struct generic_pm ret = -EIO ; out: -pr_debug ("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n" , - mask,__raw_readl (PSTR )); +/* we cannot output debug message for A3SP */ +if (genpd != &sh7372_a3sp.genpd) +pr_debug ("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n" , + mask,__raw_readl (PSTR ));return ret; }
@@ -127,6 +131,10 @@ struct sh7372_pm_domain sh7372_a3ri = { .bit_shift = 8, }; +struct sh7372_pm_domain sh7372_a3sp = { + .bit_shift =11 , +}; +struct sh7372_pm_domain sh7372_a3sg = { .bit_shift =13 , };
@@ -211,6 +219,9 @@ void __init sh7372_pm_init(void)__raw_writel (0x0000a501 ,DBGREG9 );__raw_writel (0x00000000 ,DBGREG1 ); +/* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */ +__raw_writel (0 ,PDNSEL ); +sh7372_suspend_init ();sh7372_cpuidle_init (); }
arch/arm/mach-shmobile/setup-sh7372.c +13 -0
@@ -845,6 +845,7 @@ void __init sh7372_add_standard_devices(sh7372_init_pm_domain (&sh7372_a3rv);sh7372_init_pm_domain (&sh7372_a3ri);sh7372_init_pm_domain (&sh7372_a3sg); +sh7372_init_pm_domain (&sh7372_a3sp);platform_add_devices (sh7372_early_devices,ARRAY_SIZE (sh7372_early_devices));
@@ -853,6 +854,18 @@ void __init sh7372_add_standard_devices( ARRAY_SIZE(sh7372_late_devices));sh7372_add_device_to_domain (&sh7372_a3rv, &vpu_device); + +sh7372_add_device_to_domain (&sh7372_a3sp, &scif0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif2_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif3_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif4_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif5_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif6_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &iic1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &dma0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &dma1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &dma2_device); }void __init sh7372_add_early_devices (void )
Magnus Damm
maintainerPATCH 2/3 ARM: mach-shmobile: sh7372 A3SP support
From: Magnus Damm <[email protected]>
This patch adds sh7372 A3SP power domain support.
The sh7372 A3SP hardware power domain contains a wide range of I/O devices. The list of I/O devices include SCIF serial ports, DMA Engine hardware, SD and MMC controller hardware, USB controllers and I2C master controllers.
This patch adds the A3SP low level code which powers the hardware power domain on and off. It also ties in platform devices to the pm domain support code.
It is worth noting that the serial console is hooked up to SCIFA0 on most sh7372 boards, and the SCIFA0 port is included in the A3SP hardware power domain. For this reason we cannot output debug messages from the low level power control code in the case of A3SP.
This patch seems to work quite fine except for Suspend-to-RAM that is broken with this patch applied. QoS support is needed in drivers before we can enable the A3SP power control on the fly.
---
Depends on USB-DMAC patches by Morimoto-san.
arch/arm/mach-shmobile/board-ap4evb.c | 4 ++++ arch/arm/mach-shmobile/board-mackerel.c | 8 ++++++++ arch/arm/mach-shmobile/include/mach/sh7372.h | 1 + arch/arm/mach-shmobile/pm-sh7372.c | 19 +++++++++++++++---- arch/arm/mach-shmobile/setup-sh7372.c | 14 ++++++++++++++ 5 files changed, 42 insertions(+), 4 deletions(-)
arch/arm/mach-shmobile/board-ap4evb.c +4 -0
@@ -1408,6 +1408,10 @@ static void __init ap4evb_init(void)sh7372_add_device_to_domain (&sh7372_a4lc, &lcdc_device);sh7372_add_device_to_domain (&sh7372_a4mp, &fsi_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &sh_mmcif_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi1_device); +hdmi_init_pm_clock ();fsi_init_pm_clock ();sh7372_pm_init ();
arch/arm/mach-shmobile/board-mackerel.c +8 -0
@@ -1588,6 +1588,14 @@ static void __init mackerel_init(void)sh7372_add_device_to_domain (&sh7372_a4lc, &lcdc_device);sh7372_add_device_to_domain (&sh7372_a4lc, &hdmi_lcdc_device);sh7372_add_device_to_domain (&sh7372_a4mp, &fsi_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &usbhs0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &usbhs1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &sh_mmcif_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi0_device); +#if !defined(CONFIG_MMC_SH_MMCIF ) && !defined(CONFIG_MMC_SH_MMCIF_MODULE ) +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi1_device); +#endif +sh7372_add_device_to_domain (&sh7372_a3sp, &sdhi2_device);hdmi_init_pm_clock ();sh7372_pm_init ();
arch/arm/mach-shmobile/include/mach/sh7372.h +1 -0
@@ -493,6 +493,7 @@ extern struct sh7372_pm_domain sh7372_a4extern struct sh7372_pm_domain sh7372_d4;extern struct sh7372_pm_domain sh7372_a3rv;extern struct sh7372_pm_domain sh7372_a3ri; +extern struct sh7372_pm_domain sh7372_a3sp;extern struct sh7372_pm_domain sh7372_a3sg;extern void sh7372_init_pm_domain (struct sh7372_pm_domain *sh7372_pd);
arch/arm/mach-shmobile/pm-sh7372.c +15 -4
@@ -92,8 +92,10 @@ static int pd_power_down(struct generic_ } } -pr_debug ("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n" , - mask,__raw_readl (PSTR )); +/* we cannot output debug message for A3SP */ +if (genpd != &sh7372_a3sp.genpd) +pr_debug ("sh7372 power domain down 0x%08x -> PSTR = 0x%08x\n" , + mask,__raw_readl (PSTR ));return 0 ; }
@@ -122,8 +124,10 @@ static int pd_power_up(struct generic_pm ret = -EIO ; out: -pr_debug ("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n" , - mask,__raw_readl (PSTR )); +/* we cannot output debug message for A3SP */ +if (genpd != &sh7372_a3sp.genpd) +pr_debug ("sh7372 power domain up 0x%08x -> PSTR = 0x%08x\n" , + mask,__raw_readl (PSTR ));return ret; }
@@ -216,6 +220,10 @@ struct sh7372_pm_domain sh7372_a3ri = { .bit_shift = 8, }; +struct sh7372_pm_domain sh7372_a3sp = { + .bit_shift =11 , +}; +struct sh7372_pm_domain sh7372_a3sg = { .bit_shift =13 , };
@@ -450,6 +458,9 @@ void __init sh7372_pm_init(void)__raw_writel (0x0000a501 ,DBGREG9 );__raw_writel (0x00000000 ,DBGREG1 ); +/* do not convert A3SM, A3SP, A3SG, A4R power down into A4S */ +__raw_writel (0 ,PDNSEL ); +sh7372_suspend_init ();sh7372_cpuidle_init (); }
arch/arm/mach-shmobile/setup-sh7372.c +14 -0
@@ -993,6 +993,7 @@ void __init sh7372_add_standard_devices(sh7372_init_pm_domain (&sh7372_a3rv);sh7372_init_pm_domain (&sh7372_a3ri);sh7372_init_pm_domain (&sh7372_a3sg); +sh7372_init_pm_domain (&sh7372_a3sp);platform_add_devices (sh7372_early_devices,ARRAY_SIZE (sh7372_early_devices));
@@ -1003,6 +1004,19 @@ void __init sh7372_add_standard_devices(sh7372_add_device_to_domain (&sh7372_a3rv, &vpu_device);sh7372_add_device_to_domain (&sh7372_a4mp, &spu0_device);sh7372_add_device_to_domain (&sh7372_a4mp, &spu1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif2_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif3_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif4_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif5_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &scif6_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &iic1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &dma0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &dma1_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &dma2_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &usb_dma0_device); +sh7372_add_device_to_domain (&sh7372_a3sp, &usb_dma1_device); }void __init sh7372_add_early_devices (void )
Magnus Damm
maintainerPATCH 2/3 ARM: mach-shmobile: sh7372 A3SM support
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
This patch adds sh7372 A3SM power domain support.
The sh7372 A3SM hardware power domain contains the ARM Cortex-A8 CPU Core including L2 cache. This sleep mode can be seen as a one step deeper sleep mode from the already existing Core Standby mode.
To wake up from A3SM sleep only a few wakeup sources are supported - so the regular INTC controller will not be able to help us unfortunately.
The code in this patch will enter A3SM sleep via the regular Suspend-to-RAM interface in the case of only wakeups supported by A3SM are enabled. If unsupported wakeups are enabled then Core Standby will be used instead.
---
To be able to enter A3SM you need to apply MSTP patches for MSIOF, CMT and USB-DMAC. You may also have to disable the serial console on the kernel command line.
arch/arm/mach-shmobile/include/mach/common.h | 3 arch/arm/mach-shmobile/pm-sh7372.c | 209 +++++++++++++++++++++++++- arch/arm/mach-shmobile/sleep-sh7372.S | 55 ++++++ 3 files changed, 256 insertions(+), 11 deletions(-)
arch/arm/mach-shmobile/include/mach/common.h +2 -1
@@ -35,7 +35,8 @@ extern void sh7372_add_standard_devices(extern void sh7372_clock_init (void );extern void sh7372_pinmux_init (void );extern void sh7372_pm_init (void ); -extern void sh7372_resume_core_standby (void ); +extern void sh7372_resume_core_standby_a3sm (void ); +extern int sh7372_do_idle_a3sm (unsigned long unused);extern struct clk sh7372_extal1_clk;extern struct clk sh7372_extal2_clk;
arch/arm/mach-shmobile/pm-sh7372.c +201 -8
253 lines not on this page · raw message
arch/arm/mach-shmobile/sleep-sh7372.S +53 -2
60 lines not on this page · raw message
Magnus Damm
maintainerPATCH 2/3 ARM: mach-shmobile: sh7372 generic board support via DT
In reply to Magnus DammFrom: Magnus Damm <[email protected]>
Add generic DT board support for the sh7372 SoC.
SCIF serial ports and timers are kept as regular platform devices. Other on-chip and on-board devices should be configured via the device tree.
Tested on the mackerel board via kexec using a zImage kernel with an appended dtb.
---
arch/arm/mach-shmobile/setup-sh7372.c | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
arch/arm/mach-shmobile/setup-sh7372.c +39 -0
@@ -1082,3 +1082,42 @@ void __init sh7372_add_early_devices(voi/* override timer setup with soc-specific code */ shmobile_timer.init = sh7372_earlytimer_init; } + +#ifdef CONFIG_USE_OF + +void __init sh7372_add_early_devices_dt (void ) +{ +shmobile_setup_delay (800 ,1 ,3 );/* Cortex-A8 @ 800MHz */ + +early_platform_add_devices (sh7372_early_devices, +ARRAY_SIZE (sh7372_early_devices)); + +/* setup early console here as well */ +shmobile_setup_console (); +} + +void __init sh7372_add_standard_devices_dt (void ) +{ +/* clocks are setup late during boot in the case of DT */ +sh7372_clock_init (); + +platform_add_devices (sh7372_early_devices, +ARRAY_SIZE (sh7372_early_devices)); +} + +static const char *sh7372_boards_compat_dt[]__initdata = { +"renesas,sh7372" , +NULL , +}; + +DT_MACHINE_START (SH7372_DT ,"Generic SH7372 (Flattened Device Tree)" ) + .map_io = sh7372_map_io, + .init_early = sh7372_add_early_devices_dt, + .init_irq = sh7372_init_irq, + .handle_irq = shmobile_handle_irq_intc, + .init_machine = sh7372_add_standard_devices_dt, + .timer = &shmobile_timer, + .dt_compat = sh7372_boards_compat_dt, +MACHINE_END + +#endif /* CONFIG_USE_OF */
Re: [PATCH 02/03] ARM: mach-shmobile: sh7372 generic board support via DT
In reply to Magnus DammQuoted 10 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Add generic DT board support for the sh7372 SoC.
SCIF serial ports and timers are kept as regular platform devices. Other on-chip and on-board devices should be configured via the device tree.
Tested on the mackerel board via kexec using a zImage kernel with an appended dtb.
This looks good as a start, very nice!
Quoted 3 lines
arch/arm/mach-shmobile/setup-sh7372.c | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
I think so far everyone has added the device tree source files to the kernel when they did the conversion. I'd suggest you do that, too.
Quoted 9 lines
arch/arm/mach-shmobile/setup-sh7372.c +3
-0@@ -1082,3 +1082,42 @@ void __init sh7372_add_early_devices(voi/* override timer setup with soc-specific code */ shmobile_timer.init = sh7372_earlytimer_init; } + +#ifdef CONFIG_USE_OF +
arch/arm/mach-shmobile/setup-sh7372.c void __init sh7372_add_early_devices(voi · line 1097
Quoted 10 lines
arch/arm/mach-shmobile/setup-sh7372.c +10
-0+void __init sh7372_add_early_devices_dt (void ) +{ +shmobile_setup_delay (800 ,1 ,3 );/* Cortex-A8 @ 800MHz */ + +early_platform_add_devices (sh7372_early_devices, +ARRAY_SIZE (sh7372_early_devices)); + +/* setup early console here as well */ +shmobile_setup_console (); +}
Are these always 800MHz? Maybe it would be better to read the "clock-frequency" property from the root node and use the value that is given for a particular board.
Arnd
Magnus Damm
maintainerRe: [PATCH 02/03] ARM: mach-shmobile: sh7372 generic board support via DT
In reply to Magnus DammHi Arnd,
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Magnus Damm
From: Magnus Damm <[email protected]>
Add generic DT board support for the sh7372 SoC.
Quoted 8 lines
Quoted 6 lines
SCIF serial ports and timers are kept as regular platform devices. Other on-chip and on-board devices should be configured via the device tree.
Tested on the mackerel board via kexec using a zImage kernel with an appended dtb.
This looks good as a start, very nice!
Thanks for checking the code! I appreciate your input!
Quoted 5 lines
Quoted 2 lines
arch/arm/mach-shmobile/setup-sh7372.c | 39 +++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)I think so far everyone has added the device tree source files to the kernel when they did the conversion. I'd suggest you do that, too.
Sure, that indeed sounds like a good idea. I intend to hack on V2 next week and that is most likely a good time to include dts and dtsi files. At this point they are rather boring due to interrupt bindings not working, so we cannot even hook up board specific ethernet controllers via the device tree due to lack of interrupts. My plan is to hack up some IRQ domain prototype code to play more with the DT and also create some proper dts/dtsi files.
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-shmobile/setup-sh7372.c 2012-03-06 14:04:36.000000000 +0900 renamed from arch/arm/mach-shmobile/setup-sh7372.c +9
-0@@ -1082,3 +1082,42 @@ void __init sh7372_add_early_devices(voi /* override timer setup with soc-specific code */ shmobile_timer.init = sh7372_earlytimer_init; } + +#ifdef CONFIG_USE_OF + +void __init sh7372_add_early_devices_dt(void) +{ + shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */ + + early_platform_add_devices(sh7372_early_devices, + ARRAY_SIZE(sh7372_early_devices));
Quoted 8 lines
arch/arm/mach-shmobile/setup-sh7372.c 2012-03-06 14:04:36.000000000 +0900 void __init sh7372_add_early_devices(voi · line 1097
Quoted 4 lines
arch/arm/mach-shmobile/setup-sh7372.c 2012-03-06 14:04:36.000000000 +0900 renamed from arch/arm/mach-shmobile/setup-sh7372.c +4
-0+ + /* setup early console here as well */ + shmobile_setup_console(); +}Are these always 800MHz? Maybe it would be better to read the "clock-frequency" property from the root node and use the value that is given for a particular board.
You are correct that the CPU frequency may change depending on a few things. At this point the actual hardware is configured to use with whatever value the boot loader has setup for us, which should work well with the worst case loops-per-jiffy value based on the spec of the SoC.
My idea with the code above is keep it as simple as possible and be fail safe. So the 800 Mhz value in this case is coming from the sh7372 data sheet as the maximum allowed frequency for sh7372. The point in setting the maximum allowed frequency is to come up with a OK worst case loops per jiffy value without using any timer during early boot. The non-DT mach-shmobile platforms are using early platform driver code to allow setting up a timer early during boot, and this timer is then used with the common calibrate delay loops-per-jiffy calculation code. With this shmobile_setup_delay() function we can delay the timer creation until whenever the normal driver model code is setting up drivers. This should make it easy to use DT for timers too.
So, as you pointed out, the frequency setting may not be fixed. Both the boot loader setting may be different and we may also use frequency scaling over time to adjust the frequency. Whenever we change the frequency we do want to update the loops-per-jiffy to reflect the new value. Ideally I'd like to use the common calibrate delay code to figure out the timing in a generic way, and this is something that certainly can be done whenever the full driver model is up and running. Or at least we could have some shared ARM core specific delay presets somewhere under arch/arm.
Initially my patch had some late initcall that recalculated the delay after the driver model (and also timers) have been initialized. This looked like it would work in theory and it would match well with whatever that needs to be done together with cpu frequency scaling. This sounds a bit like what you requested. However, it seems to me that the generic calibrate delay code that ARM is using doesn't allow updating the loops-per-jiffy value! The loops-per-jiffy value is stored in a static per-cpu variable and the code does not seem to like recalculating the delay after the first time. Perhaps someone is working on fixing that up. Architectures like blackfin do their own thing and do not make use of the generic calibrate delay code, and I believe they update the loops-per-jiffy directly from their cpufreq drivers. ARM platforms that do frequency scaling must use some other technique.
Anyway, so based on this I decided to go with a static worst case frequency value to calculate a safe loops-per-jiffy value and at the same time add "adjust generic calibrate delay code to allow updating frequency over time" to my TODO list. I feel it is better to solve that issue in a generic way and use the common calibrate delay code to calculate a proper delay value instead of extending my local mach-shmobile code more.
Does it sound sane?
Thanks,
/ magnus
Re: [PATCH 02/03] ARM: mach-shmobile: sh7372 generic board support via DT
In reply to Magnus DammQuoted 6 lines · Magnus Damm
Quoted 5 lines
Quoted 2 lines
arch/arm/mach-shmobile/setup-sh7372.c | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)I think so far everyone has added the device tree source files to the kernel when they did the conversion. I'd suggest you do that, too.
Quoted 7 lines
Sure, that indeed sounds like a good idea. I intend to hack on V2 next week and that is most likely a good time to include dts and dtsi files. At this point they are rather boring due to interrupt bindings not working, so we cannot even hook up board specific ethernet controllers via the device tree due to lack of interrupts. My plan is to hack up some IRQ domain prototype code to play more with the DT and also create some proper dts/dtsi files.
Ok. Note that a number of people are currently working on IRQ controller bindings for various platforms, and some of that is now in the arm-soc tree but not in v3.3. Best look at what others are doing so you don't end up duplicating too much work.
Quoted 30 lines
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-shmobile/setup-sh7372.c 2012-03-06 14:04:36.000000000 +0900 renamed from arch/arm/mach-shmobile/setup-sh7372.c +9
-0@@ -1082,3 +1082,42 @@ void __init sh7372_add_early_devices(voi /* override timer setup with soc-specific code */ shmobile_timer.init = sh7372_earlytimer_init; } + +#ifdef CONFIG_USE_OF + +void __init sh7372_add_early_devices_dt(void) +{ + shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */ + + early_platform_add_devices(sh7372_early_devices, + ARRAY_SIZE(sh7372_early_devices));Quoted 8 lines
arch/arm/mach-shmobile/setup-sh7372.c 2012-03-06 14:04:36.000000000 +0900 void __init sh7372_add_early_devices(voi · line 1097
Quoted 4 lines
arch/arm/mach-shmobile/setup-sh7372.c 2012-03-06 14:04:36.000000000 +0900 renamed from arch/arm/mach-shmobile/setup-sh7372.c +4
-0+ + /* setup early console here as well */ + shmobile_setup_console(); +}Are these always 800MHz? Maybe it would be better to read the "clock-frequency" property from the root node and use the value that is given for a particular board.
You are correct that the CPU frequency may change depending on a few things. At this point the actual hardware is configured to use with whatever value the boot loader has setup for us, which should work well with the worst case loops-per-jiffy value based on the spec of the SoC.
Quoted 11 lines
My idea with the code above is keep it as simple as possible and be fail safe. So the 800 Mhz value in this case is coming from the sh7372 data sheet as the maximum allowed frequency for sh7372. The point in setting the maximum allowed frequency is to come up with a OK worst case loops per jiffy value without using any timer during early boot. The non-DT mach-shmobile platforms are using early platform driver code to allow setting up a timer early during boot, and this timer is then used with the common calibrate delay loops-per-jiffy calculation code. With this
shmobile_setup_delay()function we can delay the timer creation until whenever the normal driver model code is setting up drivers. This should make it easy to use DT for timers too.
Ok.
Quoted 6 lines
Initially my patch had some late initcall that recalculated the delay after the driver model (and also timers) have been initialized. This looked like it would work in theory and it would match well with whatever that needs to be done together with cpu frequency scaling. This sounds a bit like what you requested. However, it seems to me that the generic calibrate delay code that ARM is using doesn't allow
Quoted 8 lines
updating the loops-per-jiffy value! The loops-per-jiffy value is stored in a static per-cpu variable and the code does not seem to like recalculating the delay after the first time. Perhaps someone is working on fixing that up. Architectures like blackfin do their own thing and do not make use of the generic calibrate delay code, and I believe they update the loops-per-jiffy directly from their cpufreq drivers. ARM platforms that do frequency scaling must use some other technique.
I think we do the same on ARM, at least that's what I got from reading drivers/cpufreq/omap-cpufreq.c, which updates per_cpu(cpu_data, i).loops_per_jiffy in a loop when changing the frequency.
Quoted 9 lines
Anyway, so based on this I decided to go with a static worst case frequency value to calculate a safe loops-per-jiffy value and at the same time add "adjust generic calibrate delay code to allow updating frequency over time" to my TODO list. I feel it is better to solve that issue in a generic way and use the common calibrate delay code to calculate a proper delay value instead of extending my local mach-shmobile code more.
Does it sound sane?
Yes, sounds good for now.
Arnd