From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [RFC] S3C24xx: Enable only the clocks of used units
Date: Mon, 18 Oct 2010 18:59:51 +0200 [thread overview]
Message-ID: <201010181859.51317.jbe@pengutronix.de> (raw)
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
next reply other threads:[~2010-10-18 16:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-18 16:59 Juergen Beisert [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201010181859.51317.jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox