mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: linux-mips@linux-mips.org
Cc: Florian Fainelli <florian.fainelli@broadcom.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Kevin Cernekee <cernekee@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	James Hogan <jhogan@kernel.org>,
	Paul Burton <paul.burton@mips.com>,
	Matt Redfearn <matt.redfearn@mips.com>,
	"Maciej W. Rozycki" <macro@mips.com>,
	Huacai Chen <chenhc@lemote.com>,
	Kate Stewart <kstewart@linuxfoundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Marcin Nowakowski <marcin.nowakowski@mips.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Ingo Molnar <mingo@kernel.org>,
	David Howells <dhowells@redhat.com>,
	Kees Cook <keescook@chromium.org>, Thomas Meyer <thomas@m3y3r.de>,
	"Bryan O'Donoghue" <pure.logic@nexus-software.ie>,
	Robin Murphy <robin.murphy@arm.com>,
	Michal Hocko <mhocko@suse.com>,
	Lucas Stach <l.stach@pengutronix.de>,
	Vladimir Murzin <vladimir.murzin@arm.com>,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH RFC 5/6] MIPS: BMIPS: Handshake with CFE
Date: Tue, 23 Jan 2018 17:47:05 -0800	[thread overview]
Message-ID: <1516758426-8127-6-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1516758426-8127-1-git-send-email-f.fainelli@gmail.com>

From: Florian Fainelli <florian.fainelli@broadcom.com>

Handshake with CFE and retrieve the environment variable DRAM0_SIZE,
which will tell us, on Broadcom STB chips, the amount of populated RAM
that we have on the first memory controller (aka MEMC0). This is
necessary in order to know how and if we can make use of eXtended
KSEG0/1.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 arch/mips/bmips/setup.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c
index 3b6f687f177c..d1b7b8b82ae1 100644
--- a/arch/mips/bmips/setup.c
+++ b/arch/mips/bmips/setup.c
@@ -19,6 +19,7 @@
 #include <linux/of_platform.h>
 #include <linux/libfdt.h>
 #include <linux/smp.h>
+#include <linux/kernel.h>
 #include <asm/addrspace.h>
 #include <asm/bmips.h>
 #include <asm/bootinfo.h>
@@ -28,12 +29,18 @@
 #include <asm/smp-ops.h>
 #include <asm/time.h>
 #include <asm/traps.h>
+#include <asm/fw/cfe/cfe_api.h>
+#include <asm/fw/cfe/cfe_error.h>
 
 #define RELO_NORMAL_VEC		BIT(18)
 
 #define REG_BCM6328_OTP		((void __iomem *)CKSEG1ADDR(0x1000062c))
 #define BCM6328_TP1_DISABLED	BIT(9)
 
+unsigned long __initdata cfe_seal;
+unsigned long __initdata cfe_entry;
+unsigned long __initdata cfe_handle;
+
 static const unsigned long kbase = VMLINUX_LOAD_ADDRESS & 0xfff00000;
 
 struct bmips_quirk {
@@ -123,9 +130,45 @@ static const struct bmips_quirk bmips_quirk_list[] = {
 	{ },
 };
 
+static unsigned long dram0_size_mb;
+
+extern void bmips_tlb_init(void);
+
+static char __initdata cfe_buf[COMMAND_LINE_SIZE];
+
+static inline int __init parse_ulong(const char *buf, unsigned long *val)
+{
+	char *endp;
+	unsigned long tmp;
+
+	tmp = simple_strtoul(buf, &endp, 0);
+	if (*endp == 0) {
+		*val = tmp;
+		return 0;
+	}
+
+	return -1;
+}
+
+#define FETCH(name, fn, arg) do { \
+	if (cfe_getenv(name, cfe_buf, COMMAND_LINE_SIZE) == CFE_OK) { \
+		fn(cfe_buf, arg); \
+        } \
+        } while (0)
+
+static void __init __maybe_unused cfe_read_configuration(void)
+{
+	if (cfe_seal != CFE_EPTSEAL)
+		return;
+
+	FETCH("DRAM0_SIZE", parse_ulong, &dram0_size_mb);
+}
+
 void __init prom_init(void)
 {
+	cfe_init(cfe_handle, cfe_entry);
 	bmips_cpu_setup();
+	cfe_read_configuration();
 	register_bmips_smp_ops();
 }
 
-- 
2.7.4

  parent reply	other threads:[~2018-01-24  1:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24  1:47 [PATCH RFC 0/6] MIPS: Broadcom eXtended KSEG0/1 support Florian Fainelli
2018-01-24  1:47 ` [PATCH RFC 1/6] MIPS: Allow board to override TLB initialization Florian Fainelli
2018-01-24  1:47 ` [PATCH RFC 2/6] MIPS: Allow platforms to override mapping/unmapping coherent Florian Fainelli
2018-01-24  1:47 ` [PATCH RFC 3/6] MIPS: BMIPS: Avoid referencing CKSEG1 Florian Fainelli
2018-02-02 17:38   ` Maciej W. Rozycki
2018-01-24  1:47 ` [PATCH RFC 4/6] MIPS: Prepare for supporting eXtended KSEG0/1 Florian Fainelli
2018-01-24  1:47 ` Florian Fainelli [this message]
2018-01-24  1:47 ` [PATCH RFC 6/6] MIPS: BMIPS: Add support for eXtended KSEG0/1 (XKS01) Florian Fainelli
2018-01-26  8:31 ` [PATCH RFC 0/6] MIPS: Broadcom eXtended KSEG0/1 support Steven J. Hill
2018-01-29 20:10   ` Florian Fainelli

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=1516758426-8127-6-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bart.vanassche@sandisk.com \
    --cc=cernekee@gmail.com \
    --cc=chenhc@lemote.com \
    --cc=dhowells@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jhogan@kernel.org \
    --cc=keescook@chromium.org \
    --cc=kstewart@linuxfoundation.org \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=macro@mips.com \
    --cc=marcin.nowakowski@mips.com \
    --cc=matt.redfearn@mips.com \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=paul.burton@mips.com \
    --cc=pure.logic@nexus-software.ie \
    --cc=ralf@linux-mips.org \
    --cc=robin.murphy@arm.com \
    --cc=thomas@m3y3r.de \
    --cc=vladimir.murzin@arm.com \
    /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

all inboxes | Powered by JetHome®