From patchwork Thu Aug 4 23:25:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andres Salomon X-Patchwork-Id: 1037162 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p74NQJqe008104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 4 Aug 2011 23:26:40 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qp7Ie-0001nH-E1; Thu, 04 Aug 2011 23:26:00 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qp7Id-0006Tz-Un; Thu, 04 Aug 2011 23:25:59 +0000 Received: from lunge.queued.net ([173.255.254.236]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qp7IZ-0006Tf-8h for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2011 23:25:56 +0000 Received: from debxo (c-67-183-64-140.hsd1.wa.comcast.net [67.183.64.140]) by lunge.queued.net (Postfix) with ESMTPSA id 495042857B4; Thu, 4 Aug 2011 16:25:53 -0700 (PDT) Date: Thu, 4 Aug 2011 16:25:51 -0700 From: Andres Salomon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC v1] ARM: olpc: Add support for calling into the XO-1.75's OpenFirmware (OFW) Message-ID: <20110804162551.2b92b2cf@debxo> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; i486-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110804_192555_517888_0ECA8184 X-CRM114-Status: GOOD ( 28.50 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.8 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Grant Likely , Russell King , dsd@laptop.org, linux-kernel@vger.kernel.org, Haojian Zhuang , Mitch Bradley , "H. Peter Anvin" , eric.y.miao@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 04 Aug 2011 23:26:40 +0000 (UTC) Add support for saving OFW's cif, and later calling into it to run OFW commands from the kernel. OFW remains resident in memory after boot, and the physical/virtual addresses are passed in a boot tag. We parse that, and map the addresses. This is currently only used by the OLPC XO-1.75, so it's named olpc_ofw(). Signed-off-by: Andres Salomon --- Documentation/arm/Setup | 2 + arch/arm/Kconfig | 8 ++ arch/arm/include/asm/olpc_ofw.h | 23 ++++++ arch/arm/include/asm/setup.h | 24 ++++++ arch/arm/mach-mmp/Makefile | 1 + arch/arm/mach-mmp/include/mach/vmalloc.h | 2 +- arch/arm/mach-mmp/olpc-xo-1-75.c | 7 ++ arch/arm/mach-mmp/olpc_ofw.c | 118 ++++++++++++++++++++++++++++++ 8 files changed, 184 insertions(+), 1 deletions(-) create mode 100644 arch/arm/include/asm/olpc_ofw.h create mode 100644 arch/arm/mach-mmp/olpc_ofw.c I'm looking for input on our mechanism for calling into OLPC's openfirmware on arm. Some of the x86 folks are cc'd as they had lots of comment when we did this for x86 OLPC machines. There's a device tree patch on top of this that can be seen here: http://dev.laptop.org/git/olpc-3.0/patch/?id=12377851f9a64a9e2098adf09f858bed7d3eae7c Unlike the XO-1, I'd like to get this OFW communication mechanism ACKed prior to OLPC's mass production of these units. diff --git a/Documentation/arm/Setup b/Documentation/arm/Setup index 0cb1e64..e9272ff 100644 --- a/Documentation/arm/Setup +++ b/Documentation/arm/Setup @@ -124,6 +124,8 @@ below: These are now obsolete, and should not be used. +TODO: document olpc stuff + commandline Kernel command line parameters. Details can be found elsewhere. diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5adeb8b..a1d9801 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -2028,6 +2028,14 @@ config ARCH_SUSPEND_POSSIBLE endmenu +if ARCH_MMP +config OLPC + bool "One Laptop Per Child support" + ---help--- + Add support for detecting the unique features of the OLPC + XO hardware. +endif + source "net/Kconfig" source "drivers/Kconfig" diff --git a/arch/arm/include/asm/olpc_ofw.h b/arch/arm/include/asm/olpc_ofw.h new file mode 100644 index 0000000..5346e9f --- /dev/null +++ b/arch/arm/include/asm/olpc_ofw.h @@ -0,0 +1,23 @@ +#ifndef _ASM_ARM_OLPC_OFW_H +#define _ASM_ARM_OLPC_OFW_H + +#ifdef CONFIG_OLPC + +/* run an OFW command by calling into the firmware */ +#define olpc_ofw(name, args, res) \ + __olpc_ofw((name), ARRAY_SIZE(args), args, ARRAY_SIZE(res), res) + +extern int __olpc_ofw(const char *name, int nr_args, const void **args, + int nr_res, void **res); + +/* map OFW's page tables into kernel memory */ +extern void setup_olpc_ofw_mapping(void); + +/* check if OFW was detected during boot */ +extern bool olpc_ofw_present(void); + +#else /* !CONFIG_OLPC */ +static inline void setup_olpc_ofw_mapping(void) { } +#endif /* !CONFIG_OLPC */ + +#endif /* _ASM_ARM_OLPC_OFW_H */ diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h index ee2ad8a..c75889e 100644 --- a/arch/arm/include/asm/setup.h +++ b/arch/arm/include/asm/setup.h @@ -143,6 +143,25 @@ struct tag_memclk { __u32 fmemclk; }; +/* OLPC OpenFirmware callback parameters: see arch/arm/mach-mmp/olpc_ofw.c */ +#define ATAG_OLPC_OFW 0x41000502 + +struct tag_olpc_ofw { + __u32 cif_handler; /* callback into OFW */ + + /* map_desc one - OFW's main memory */ + __u32 ofw_va; + __u32 ofw_pfn; /* physical address's PFN */ + __u32 ofw_length; + __u32 ofw_mem_type; /* MT_ */ + + /* map_desc two - OFW's frame buffer */ + __u32 fb_va; + __u32 fb_pfn; /* physical address's PFN */ + __u32 fb_length; + __u32 fb_mem_type; /* MT_ */ +}; + struct tag { struct tag_header hdr; union { @@ -165,6 +184,11 @@ struct tag { * DC21285 specific */ struct tag_memclk memclk; + + /* + * OLPC specific - for OLPC's OpenFirmware implementation + */ + struct tag_olpc_ofw olpc_ofw; } u; }; diff --git a/arch/arm/mach-mmp/Makefile b/arch/arm/mach-mmp/Makefile index 00a4954..398da1d 100644 --- a/arch/arm/mach-mmp/Makefile +++ b/arch/arm/mach-mmp/Makefile @@ -23,3 +23,4 @@ obj-$(CONFIG_MACH_FLINT) += flint.o obj-$(CONFIG_MACH_MARVELL_JASPER) += jasper.o obj-$(CONFIG_MACH_TETON_BGA) += teton_bga.o obj-$(CONFIG_MACH_OLPC_XO_1_75) += olpc-xo-1-75.o +obj-$(CONFIG_OLPC) += olpc_ofw.o diff --git a/arch/arm/mach-mmp/include/mach/vmalloc.h b/arch/arm/mach-mmp/include/mach/vmalloc.h index 1d0bac0..3801e26 100644 --- a/arch/arm/mach-mmp/include/mach/vmalloc.h +++ b/arch/arm/mach-mmp/include/mach/vmalloc.h @@ -2,4 +2,4 @@ * linux/arch/arm/mach-mmp/include/mach/vmalloc.h */ -#define VMALLOC_END 0xfe000000UL +#define VMALLOC_END 0xfd600000UL diff --git a/arch/arm/mach-mmp/olpc-xo-1-75.c b/arch/arm/mach-mmp/olpc-xo-1-75.c index 46261db..9efb351 100644 --- a/arch/arm/mach-mmp/olpc-xo-1-75.c +++ b/arch/arm/mach-mmp/olpc-xo-1-75.c @@ -29,6 +29,7 @@ #include