* [RFC] S3C24xx: Enable only the clocks of used units
@ 2010-10-18 16:59 Juergen Beisert
2010-10-19 1:42 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 4+ messages in thread
From: Juergen Beisert @ 2010-10-18 16:59 UTC (permalink / raw)
To: barebox
From: Juergen Beisert <juergen@kreuzholzen.de>
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.
Signed-off-by: Juergen Beisert <juergen@kreuzholzen.de>
---
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(-)
Index: barebox-2010.10.0/arch/arm/mach-s3c24xx/generic.c
===================================================================
--- barebox-2010.10.0.orig/arch/arm/mach-s3c24xx/generic.c
+++ barebox-2010.10.0/arch/arm/mach-s3c24xx/generic.c
@@ -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 */
Index: barebox-2010.10.0/arch/arm/mach-s3c24xx/include/mach/s3c24x0-clocks.h
===================================================================
--- /dev/null
+++ barebox-2010.10.0/arch/arm/mach-s3c24xx/include/mach/s3c24x0-clocks.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 Juergen Beisert
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef _MACH_CLOCKS_H_
+# define _MACH_CLOCKS_H_
+
+/* Bits in register CLKCON to control unit's clock */
+#define CLK_AC97 (1 << 20)
+#define CLK_CAMERA (1 << 19)
+#define CLK_SPI (1 << 18)
+#define CLK_IIS (1 << 17)
+#define CLK_IIC (1 << 16)
+#define CLK_ADC (1 << 15)
+#define CLK_RTC (1 << 14)
+#define CLK_GPIO (1 << 13)
+#define CLK_UART2 (1 << 12)
+#define CLK_UART1 (1 << 11)
+#define CLK_UART0 (1 << 10)
+#define CLK_SDI (1 << 9)
+#define CLK_PWMTIMER (1 << 8)
+#define CLK_USBDEV (1 << 7)
+#define CLK_USBHOST (1 << 6)
+#define CLK_LCDC (1 << 5)
+#define CLK_NAND (1 << 4)
+
+#ifndef __ASSEMBLY__
+void s3c244x_mod_clock(unsigned, int);
+#endif
+
+#endif /* _MACH_CLOCKS_H_ */
Index: barebox-2010.10.0/arch/arm/mach-s3c24xx/lowlevel-init.S
===================================================================
--- barebox-2010.10.0.orig/arch/arm/mach-s3c24xx/lowlevel-init.S
+++ barebox-2010.10.0/arch/arm/mach-s3c24xx/lowlevel-init.S
@@ -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]
/* ??????? */
Index: barebox-2010.10.0/drivers/mtd/nand/nand_s3c2410.c
===================================================================
--- barebox-2010.10.0.orig/drivers/mtd/nand/nand_s3c2410.c
+++ barebox-2010.10.0/drivers/mtd/nand/nand_s3c2410.c
@@ -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 dev
if (!host)
return -ENOMEM;
+ s3c244x_mod_clock(CLK_NAND, 1);
+
host->dev = dev;
host->base = dev->map_base;
Index: barebox-2010.10.0/drivers/serial/serial_s3c24x0.c
===================================================================
--- barebox-2010.10.0.orig/drivers/serial/serial_s3c24x0.c
+++ barebox-2010.10.0/drivers/serial/serial_s3c24x0.c
@@ -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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] S3C24xx: Enable only the clocks of used units
2010-10-18 16:59 [RFC] S3C24xx: Enable only the clocks of used units Juergen Beisert
@ 2010-10-19 1:42 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-19 6:55 ` Juergen Beisert
0 siblings, 1 reply; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-19 1:42 UTC (permalink / raw)
To: Juergen Beisert; +Cc: barebox
> - 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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] S3C24xx: Enable only the clocks of used units
2010-10-19 1:42 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-19 6:55 ` Juergen Beisert
2010-10-19 8:27 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 4+ messages in thread
From: Juergen Beisert @ 2010-10-19 6:55 UTC (permalink / raw)
To: barebox
Jean-Christophe PLAGNIOL-VILLARD wrote:
> > - 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
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] S3C24xx: Enable only the clocks of used units
2010-10-19 6:55 ` Juergen Beisert
@ 2010-10-19 8:27 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 0 replies; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-19 8:27 UTC (permalink / raw)
To: Juergen Beisert; +Cc: barebox
On 08:55 Tue 19 Oct , Juergen Beisert wrote:
> Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > - 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 (????).
make because you had c definition in the header?
>
> 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
yeah excalty
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-19 8:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-18 16:59 [RFC] S3C24xx: Enable only the clocks of used units Juergen Beisert
2010-10-19 1:42 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-19 6:55 ` Juergen Beisert
2010-10-19 8:27 ` Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox