From patchwork Wed May 12 08:34:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 98942 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4C8XjWR027455 for ; Wed, 12 May 2010 08:33:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753901Ab0ELIdk (ORCPT ); Wed, 12 May 2010 04:33:40 -0400 Received: from mail-pz0-f204.google.com ([209.85.222.204]:56815 "EHLO mail-pz0-f204.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754781Ab0ELIdi (ORCPT ); Wed, 12 May 2010 04:33:38 -0400 Received: by mail-pz0-f204.google.com with SMTP id 42so1280265pzk.4 for ; Wed, 12 May 2010 01:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :in-reply-to:references:subject; bh=W8ZmN/Li0JruYpekFvIwHvzSNyjdXoW3kkOULs/VTUs=; b=St+zgqbe57Rch5bj/RHvB7Dz2wJ4otWGD0ey9ThZulM3wGUDAAdEqemQTipswOvU/y mK/v02/PdfUI3Gg1I95EeTqGEOvzFLm/akyBLP04opoGdn5boHo9Ts2W/g7BPj9k9nMU IkLYKisV4twjCpj5FHYpWWjxtswz/q2s9aeOw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=vNmKg+sJ2WnCu7iQDnNORtlYWhoba/au7jHUqU92jc6LWZF3fNWxK2PZlFdbhRAsb4 lPrJMeDqbD0Zmm8Iz6P/5Msp4lSa0D2gv6D2c/HJuL9hWf3jSDb9P0BB1yiazeLhHRZn pHzBUd4HcT0+db0yFjvVabmSC8fvgqMrg62rI= Received: by 10.115.101.22 with SMTP id d22mr5551284wam.136.1273653217723; Wed, 12 May 2010 01:33:37 -0700 (PDT) Received: from [127.0.0.1] (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id b6sm42665589wam.9.2010.05.12.01.33.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 12 May 2010 01:33:37 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org Date: Wed, 12 May 2010 17:34:51 +0900 Message-Id: <20100512083451.9395.54283.sendpatchset@t400s> In-Reply-To: <20100512083443.9395.90768.sendpatchset@t400s> References: <20100512083443.9395.90768.sendpatchset@t400s> Subject: [PATCH 01/05] ARM: mach-shmobile: Add memchunk support Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 12 May 2010 08:33:46 +0000 (UTC) --- 0001/arch/arm/mach-shmobile/Makefile +++ work/arch/arm/mach-shmobile/Makefile 2010-05-12 15:50:29.000000000 +0900 @@ -3,7 +3,7 @@ # # Common objects -obj-y := timer.o console.o +obj-y := timer.o console.o memory.o # CPU objects obj-$(CONFIG_ARCH_SH7367) += setup-sh7367.o clock-sh7367.o intc-sh7367.o --- 0001/arch/arm/mach-shmobile/include/mach/common.h +++ work/arch/arm/mach-shmobile/include/mach/common.h 2010-05-12 15:50:15.000000000 +0900 @@ -4,6 +4,10 @@ extern struct sys_timer shmobile_timer; extern void shmobile_setup_console(void); +/* allocate contiguous memory chunk and fill in struct resource */ +extern int platform_resource_setup_memory(struct platform_device *pdev, + char *name, unsigned long memsize); + extern void sh7367_init_irq(void); extern void sh7367_add_early_devices(void); extern void sh7367_add_standard_devices(void); --- /dev/null +++ work/arch/arm/mach-shmobile/memory.c 2010-05-12 15:50:16.000000000 +0900 @@ -0,0 +1,74 @@ +/* + * arch/sh/mm/consistent.c + * + * Copyright (C) 2004 - 2007 Paul Mundt + * + * Declared coherent memory functions based on arch/x86/kernel/pci-dma_32.c + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ +#include +#include +#include +#include +#include +#include +#include + +static int __init memchunk_setup(char *str) +{ + return 1; /* accept anything that begins with "memchunk." */ +} +__setup("memchunk.", memchunk_setup); + +static void __init memchunk_cmdline_override(char *name, unsigned long *sizep) +{ + char *p = boot_command_line; + int k = strlen(name); + + while ((p = strstr(p, "memchunk."))) { + p += 9; /* strlen("memchunk.") */ + if (!strncmp(name, p, k) && p[k] == '=') { + p += k + 1; + *sizep = memparse(p, NULL); + pr_info("%s: forcing memory chunk size to 0x%08lx\n", + name, *sizep); + break; + } + } +} + +int __init platform_resource_setup_memory(struct platform_device *pdev, + char *name, unsigned long memsize) +{ + struct resource *r; + dma_addr_t dma_handle; + void *buf; + + r = pdev->resource + pdev->num_resources - 1; + if (r->flags) { + pr_warning("%s: unable to find empty space for resource\n", + name); + return -EINVAL; + } + + memchunk_cmdline_override(name, &memsize); + if (!memsize) + return 0; + + buf = dma_alloc_coherent(NULL, memsize, &dma_handle, GFP_KERNEL); + if (!buf) { + pr_warning("%s: unable to allocate memory\n", name); + return -ENOMEM; + } + + memset(buf, 0, memsize); + + r->flags = IORESOURCE_MEM; + r->start = dma_handle; + r->end = r->start + memsize - 1; + r->name = name; + return 0; +}