S3C24xx: Enable only the clocks of used units
Subsystems (6)
RFC 1/1 S3C24xx: Enable only the clocks of used units
From: Juergen Beisert <[email protected]>
Subject: [RFC] S3C24xx: Enable only the clocks of used units
This patch disables most of the processor's clocks and enable them on demand only.
--- arch/arm/mach-s3c24xx/generic.c | 22 +++++++++ arch/arm/mach-s3c24xx/include/mach/s3c24x0-clocks.h | 46 ++++++++++++++++++++ arch/arm/mach-s3c24xx/lowlevel-init.S | 12 ++++- drivers/mtd/nand/nand_s3c2410.c | 3 + drivers/serial/serial_s3c24x0.c | 3 + 5 files changed, 84 insertions(+), 2 deletions(-)
arch/arm/mach-s3c24xx/generic.c +22 -0
@@ -28,6 +28,7 @@#include <clock.h> #include <asm/io.h> #include <mach/s3c24x0-iomap.h> +#include <mach/s3c24x0-clocks.h> #define LOCKTIME (S3C24X0_CLOCK_POWER_BASE)#define MPLLCON (S3C24X0_CLOCK_POWER_BASE + 0x4)
@@ -202,6 +203,25 @@ unsigned s3c24x0_get_memory_size(void) }/** +* Enable or disable unit's clock +* @param unit Unit to manipulate (refer CLK_* macros) +* @param state 1 for enable, 0 for disable +*/ +void s3c244x_mod_clock (unsigned unit,int state) +{ +uint32_t clkcon; + + clkcon =readl (CLKCON ); + +if (state !=0 ) + clkcon |= unit; +else + clkcon &= ~unit; + +writel (clkcon,CLKCON ); +} + +/** * Show the user the current clock settings */ int s3c24xx_dump_clocks (void )
@@ -236,6 +256,8 @@ static int clocksource_init (void) {unsigned p_clk =s3c24xx_get_pclk (); +s3c244x_mod_clock (CLK_PWMTIMER ,1 ); +writel (0x00000000 ,TCON );/* stop all timers */ writel (0x00ffffff ,TCFG0 );/* PCLK / (255 + 1) for timer 4 */ writel (0x00030000 ,TCFG1 );/* /16 */
arch/arm/mach-s3c24xx/include/mach/s3c24x0-clocks.h new file +46 -0
46 lines not on this page · raw message
arch/arm/mach-s3c24xx/lowlevel-init.S +10 -2
@@ -20,6 +20,7 @@ #include <config.h> #include <mach/s3c24x0-iomap.h> +#include <mach/s3c24x0-clocks.h> .section ".text_bare_init.s3c24x0_disable_wd","ax"
@@ -83,8 +84,15 @@ s3c24x0_pll_init: mov r1, #BOARD_SPECIFIC_CLKDIVN str r1, [r0, #20] - /* enable all devices on this chip */ - mov r1, #0xFFFFFFF0 + /* + * Disable the clocks for most devices on this chip. + * They will be enabled again on demand + */ +#ifdef CONFIG_S3C24XX_NAND_BOOT + ldr r1, =0x6010 /* (CLK_RTC | CLK_GPIO | CLK_NAND) */ +#else + mov r1, #0x6000 /* (CLK_RTC | CLK_GPIO) */ +#endif str r1, [r0, #12] /* ??????? */
drivers/mtd/nand/nand_s3c2410.c +3 -0
@@ -32,6 +32,7 @@#include <linux/mtd/nand.h> #include <mach/s3c24xx-generic.h> #include <mach/s3c24x0-iomap.h> +#include <mach/s3c24x0-clocks.h> #include <mach/s3c24x0-nand.h> #include <asm/io.h> #include <asm-generic/errno.h>
@@ -358,6 +359,8 @@ static int s3c24x0_nand_probe(struct devif (!host)return -ENOMEM ; +s3c244x_mod_clock (CLK_NAND ,1 ); + host->dev = dev; host->base = dev->map_base;
drivers/serial/serial_s3c24x0.c +3 -0
@@ -27,6 +27,7 @@#include <asm/io.h> #include <mach/s3c24xx-generic.h> #include <mach/s3c24x0-iomap.h> +#include <mach/s3c24x0-clocks.h> /* Note: Offsets are for little endian access */ #define ULCON 0x00/* line control */
@@ -123,6 +124,8 @@ static int s3c24x0_serial_probe(struct d cdev =malloc (sizeof (struct console_device )); +s3c244x_mod_clock (CLK_UART0 |CLK_UART1 |CLK_UART2 ,1 ); + dev->type_data = cdev; cdev->dev = dev; cdev->f_caps =CONSOLE_STDIN |CONSOLE_STDOUT |CONSOLE_STDERR ;
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
arch/arm/mach-s3c24xx/lowlevel-init.S s3c24x0_pll_init: · line 94
Quoted 9 lines
arch/arm/mach-s3c24xx/lowlevel-init.S +8
-1- mov r1, #0xFFFFFFF0 + /* + * Disable the clocks for most devices on this chip. + * They will be enabled again on demand + */ +#ifdef CONFIG_S3C24XX_NAND_BOOT + ldr r1, =0x6010 /* (CLK_RTC | CLK_GPIO | CLK_NAND) */ +#else + mov r1, #0x6000 /* (CLK_RTC | CLK_GPIO) */
how about use the macro and define a macro to avoid the ifdef
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
arch/arm/mach-s3c24xx/lowlevel-init.S s3c24x0_pll_init: · line 94
Quoted 9 lines
arch/arm/mach-s3c24xx/lowlevel-init.S +8
-1- mov r1, #0xFFFFFFF0 + /* + * Disable the clocks for most devices on this chip. + * They will be enabled again on demand + */ +#ifdef CONFIG_S3C24XX_NAND_BOOT + ldr r1, =0x6010 /* (CLK_RTC | CLK_GPIO | CLK_NAND) */ +#else + mov r1, #0x6000 /* (CLK_RTC | CLK_GPIO) */how about use the macro and define a macro to avoid the ifdef
I tried with macros, but the assembler failed. Can't remember why. But I tried again a few minutes ago .... and now it works (????).
Do you mean something like this instead?
[...]
#ifdef CONFIG_S3C24XX_NAND_BOOT
# define FORCED_CLOCKS (CLK_RTC | CLK_GPIO | CLK_NAND) #else # define FORCED_CLOCKS (CLK_RTC | CLK_GPIO) #endif
/*
* Disable the clocks for most devices on this chip.
* They will be enabled again on demand
*/
ldr r1, =FORCED_CLOCKS
[...]
jbe
Signature · 9 lines
Pengutronix e.K. | Juergen Beisert | Linux Solutions for Science and Industry | Phone: +49-8766-939 228 | Vertretung Sued/Muenchen, Germany | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de/ | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 13 lines · Juergen Beisert
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
arch/arm/mach-s3c24xx/lowlevel-init.S s3c24x0_pll_init: · line 94
Quoted 9 lines
arch/arm/mach-s3c24xx/lowlevel-init.S +8
-1- mov r1, #0xFFFFFFF0 + /* + * Disable the clocks for most devices on this chip. + * They will be enabled again on demand + */ +#ifdef CONFIG_S3C24XX_NAND_BOOT + ldr r1, =0x6010 /* (CLK_RTC | CLK_GPIO | CLK_NAND) */ +#else + mov r1, #0x6000 /* (CLK_RTC | CLK_GPIO) */how about use the macro and define a macro to avoid the ifdef
Quoted 2 lines
I tried with macros, but the assembler failed. Can't remember why. But I tried again a few minutes ago .... and now it works (????).
make because you had c definition in the header?
Quoted 10 lines
Do you mean something like this instead?
[...]
#ifdefCONFIG_S3C24XX_NAND_BOOT# define FORCED_CLOCKS (CLK_RTC | CLK_GPIO | CLK_NAND) #else # define FORCED_CLOCKS (CLK_RTC | CLK_GPIO) #endif
Quoted 5 lines
/*
* Disable the clocks for most devices on this chip.
* They will be enabled again on demand
*/
ldr r1, =FORCED_CLOCKS
yeah excalty
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox