mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 05/14] ppc mpc5200: add function to configure a chipselect
Date: Tue, 27 Sep 2011 10:28:20 +0200	[thread overview]
Message-ID: <1317112109-23311-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1317112109-23311-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/ppc/mach-mpc5xxx/cpu.c                  |   70 ++++++++++++++++++++++++++
 arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h |    4 ++
 2 files changed, 74 insertions(+), 0 deletions(-)

diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c
index cf2ca2f..649f08a 100644
--- a/arch/ppc/mach-mpc5xxx/cpu.c
+++ b/arch/ppc/mach-mpc5xxx/cpu.c
@@ -30,6 +30,7 @@
 #include <mach/mpc5xxx.h>
 #include <asm/processor.h>
 #include <asm/byteorder.h>
+#include <asm/io.h>
 #include <init.h>
 #include <types.h>
 #include <mach/clocks.h>
@@ -130,3 +131,72 @@ unsigned long mpc5200_get_sdram_size(unsigned int cs)
 
 	return size;
 }
+
+struct mpc5200_cs {
+	void *start;
+	void *stop;
+	void *cfg;
+	unsigned int addecr;
+};
+
+static struct mpc5200_cs chipselects[] = {
+	{
+		.start = (void *)MPC5XXX_CS0_START,
+		.stop = (void *)MPC5XXX_CS0_STOP,
+		.cfg = (void *)MPC5XXX_CS0_CFG,
+		.addecr = 1 << 16,
+	}, {
+		.start = (void *)MPC5XXX_CS1_START,
+		.stop = (void *)MPC5XXX_CS1_STOP,
+		.cfg = (void *)MPC5XXX_CS1_CFG,
+		.addecr = 1 << 17,
+	}, {
+		.start = (void *)MPC5XXX_CS2_START,
+		.stop = (void *)MPC5XXX_CS2_STOP,
+		.cfg = (void *)MPC5XXX_CS2_CFG,
+		.addecr = 1 << 18,
+	}, {
+		.start = (void *)MPC5XXX_CS3_START,
+		.stop = (void *)MPC5XXX_CS3_STOP,
+		.cfg = (void *)MPC5XXX_CS3_CFG,
+		.addecr = 1 << 19,
+	}, {
+		.start = (void *)MPC5XXX_CS4_START,
+		.stop = (void *)MPC5XXX_CS4_STOP,
+		.cfg = (void *)MPC5XXX_CS4_CFG,
+		.addecr = 1 << 20,
+	}, {
+		.start = (void *)MPC5XXX_CS5_START,
+		.stop = (void *)MPC5XXX_CS5_STOP,
+		.cfg = (void *)MPC5XXX_CS5_CFG,
+		.addecr = 1 << 21,
+	}, {
+		.start = (void *)MPC5XXX_CS6_START,
+		.stop = (void *)MPC5XXX_CS6_STOP,
+		.cfg = (void *)MPC5XXX_CS6_CFG,
+		.addecr = 1 << 26,
+	}, {
+		.start = (void *)MPC5XXX_CS7_START,
+		.stop = (void *)MPC5XXX_CS7_STOP,
+		.cfg = (void *)MPC5XXX_CS7_CFG,
+		.addecr = 1 << 27,
+	}, {
+		.start = (void *)MPC5XXX_BOOTCS_START,
+		.stop = (void *)MPC5XXX_BOOTCS_STOP,
+		.cfg = (void *)MPC5XXX_CS0_CFG,
+		.addecr = 1 << 25,
+	},
+};
+
+void mpc5200_setup_cs(int cs, unsigned long start, unsigned long size, u32 cfg)
+{
+	u32 addecr;
+
+	out_be32(chipselects[cs].start, START_REG(start));
+	out_be32(chipselects[cs].stop, STOP_REG(start, size));
+	out_be32(chipselects[cs].cfg, cfg);
+
+	addecr = in_be32((void *)MPC5XXX_ADDECR);
+	addecr |= chipselects[cs].addecr | 1;
+	out_be32((void *)MPC5XXX_ADDECR, addecr);
+}
diff --git a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
index aad2418..558f331 100644
--- a/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
+++ b/arch/ppc/mach-mpc5xxx/include/mach/mpc5xxx.h
@@ -782,6 +782,10 @@ void loadtask(int basetask, int tasks);
 /* retrieve configured sdram size connected to a chipselect */
 unsigned long mpc5200_get_sdram_size(unsigned int cs);
 
+/* configure a local plus bus chip select */
+#define MPC5200_BOOTCS 8
+void mpc5200_setup_cs(int cs, unsigned long start, unsigned long size, u32 cfg);
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASMPPC_MPC5XXX_H */
-- 
1.7.6.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-09-27  8:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27  8:28 more ppc and pcm030 cleanup Sascha Hauer
2011-09-27  8:28 ` [PATCH 01/14] ppc: remove mgt5100 support from code Sascha Hauer
2011-09-27  8:28 ` [PATCH 02/14] ppc: add a get_pc() function Sascha Hauer
2011-09-27  8:28 ` [PATCH 03/14] remove EARLY_INIT and EARLY_CONSOLE support Sascha Hauer
2011-09-27  8:28 ` [PATCH 04/14] ppc mpc5200: add function to determine configured sdram size Sascha Hauer
2011-09-27  8:28 ` Sascha Hauer [this message]
2011-09-27  8:28 ` [PATCH 06/14] ppc mpc5200: add function to setup bus clocks Sascha Hauer
2011-09-27  8:28 ` [PATCH 07/14] ppc mpc5200b: cleanup lowlevel startup Sascha Hauer
2011-09-27  8:28 ` [PATCH 08/14] pcm030: use new functionality Sascha Hauer
2011-09-27  8:28 ` [PATCH 09/14] ppc: hardcode sdram base to 0x0 Sascha Hauer
2011-09-27  8:28 ` [PATCH 10/14] mpc5200: hardcode MBAR to 0xf0000000 Sascha Hauer
2011-09-27  8:28 ` [PATCH 11/14] mpc5200: hardcode internal sram for initram Sascha Hauer
2011-09-27  8:28 ` [PATCH 12/14] pcm030: fix /dev/self0 and /dev/env0 Sascha Hauer
2011-09-27  8:28 ` [PATCH 13/14] ppc mpc5200: remove bus clock switching from generic code Sascha Hauer
2011-09-27  8:28 ` [PATCH 14/14] pcm030: cleanup config.h Sascha Hauer

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=1317112109-23311-6-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@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