From patchwork Fri Jul 1 06:44:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Christophe PLAGNIOL-VILLARD X-Patchwork-Id: 934642 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6170KsH003899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 1 Jul 2011 07:00:43 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QcXhx-00043m-IQ; Fri, 01 Jul 2011 07:00:09 +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 1QcXhw-0003QX-UJ; Fri, 01 Jul 2011 07:00:08 +0000 Received: from 13.98.mail-out.ovh.net ([188.165.35.94] helo=98.mail-out.ovh.net) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QcXhq-0003OZ-5M for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2011 07:00:04 +0000 Received: from mail31.ha.ovh.net (b7.ovh.net [213.186.33.57]) by 98.mail-out.ovh.net (Postfix) with SMTP id A999D4B2B09 for ; Fri, 1 Jul 2011 08:59:32 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 1 Jul 2011 08:59:56 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 1 Jul 2011 08:59:54 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 7/8] at91: factorize sram init Date: Fri, 1 Jul 2011 08:44:41 +0200 Message-Id: <1309502682-16897-7-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1309502682-16897-1-git-send-email-plagnioj@jcrosoft.com> References: <1309502682-16897-1-git-send-email-plagnioj@jcrosoft.com> X-Ovh-Tracer-Id: 8100286881236626429 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -180 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110701_030002_642845_564643E2 X-CRM114-Status: GOOD ( 19.07 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [188.165.35.94 listed in list.dnswl.org] Cc: Patrice Vilchez , Nicolas Ferre , Jean-Christophe PLAGNIOL-VILLARD 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: , MIME-Version: 1.0 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 (demeter1.kernel.org [140.211.167.41]); Fri, 01 Jul 2011 07:00:43 +0000 (UTC) Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: Nicolas Ferre Cc: Patrice Vilchez --- arch/arm/mach-at91/at91cap9.c | 11 +------- arch/arm/mach-at91/at91rm9200.c | 6 +--- arch/arm/mach-at91/at91sam9260.c | 53 ++++++------------------------------- arch/arm/mach-at91/at91sam9261.c | 22 +-------------- arch/arm/mach-at91/at91sam9263.c | 17 +---------- arch/arm/mach-at91/at91sam9g45.c | 11 +------- arch/arm/mach-at91/at91sam9rl.c | 12 +-------- arch/arm/mach-at91/generic.h | 2 + arch/arm/mach-at91/setup.c | 20 ++++++++++++++ 9 files changed, 39 insertions(+), 115 deletions(-) diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c index 8fabf91..bfc6844 100644 --- a/arch/arm/mach-at91/at91cap9.c +++ b/arch/arm/mach-at91/at91cap9.c @@ -29,15 +29,6 @@ #include "generic.h" #include "clock.h" -static struct map_desc at91cap9_sram_desc[] __initdata = { - { - .virtual = AT91_IO_VIRT_BASE - AT91CAP9_SRAM_SIZE, - .pfn = __phys_to_pfn(AT91CAP9_SRAM_BASE), - .length = AT91CAP9_SRAM_SIZE, - .type = MT_DEVICE, - }, -}; - /* -------------------------------------------------------------------- * Clocks * -------------------------------------------------------------------- */ @@ -337,7 +328,7 @@ static void at91cap9_poweroff(void) static void __init at91cap9_map_io(void) { - iotable_init(at91cap9_sram_desc, ARRAY_SIZE(at91cap9_sram_desc)); + at91_init_sram(0, AT91CAP9_SRAM_BASE, AT91CAP9_SRAM_SIZE); } static void __init at91cap9_initialize(void) diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c index 0104078..f73302d 100644 --- a/arch/arm/mach-at91/at91rm9200.c +++ b/arch/arm/mach-at91/at91rm9200.c @@ -30,11 +30,6 @@ static struct map_desc at91rm9200_io_desc[] __initdata = { .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC), .length = SZ_16K, .type = MT_DEVICE, - }, { - .virtual = AT91_IO_VIRT_BASE - AT91RM9200_SRAM_SIZE, - .pfn = __phys_to_pfn(AT91RM9200_SRAM_BASE), - .length = AT91RM9200_SRAM_SIZE, - .type = MT_DEVICE, }, }; @@ -306,6 +301,7 @@ static void at91rm9200_reset(void) static void __init at91rm9200_map_io(void) { /* Map peripherals */ + at91_init_sram(0, AT91RM9200_SRAM_BASE, AT91RM9200_SRAM_SIZE); iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc)); } diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c index 1addfef..cb397be 100644 --- a/arch/arm/mach-at91/at91sam9260.c +++ b/arch/arm/mach-at91/at91sam9260.c @@ -27,41 +27,6 @@ #include "generic.h" #include "clock.h" -static struct map_desc at91sam9260_sram_desc[] __initdata = { - { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE, - .pfn = __phys_to_pfn(AT91SAM9260_SRAM0_BASE), - .length = AT91SAM9260_SRAM0_SIZE, - .type = MT_DEVICE, - }, { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9260_SRAM0_SIZE - AT91SAM9260_SRAM1_SIZE, - .pfn = __phys_to_pfn(AT91SAM9260_SRAM1_BASE), - .length = AT91SAM9260_SRAM1_SIZE, - .type = MT_DEVICE, - } -}; - -static struct map_desc at91sam9g20_sram_desc[] __initdata = { - { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE, - .pfn = __phys_to_pfn(AT91SAM9G20_SRAM0_BASE), - .length = AT91SAM9G20_SRAM0_SIZE, - .type = MT_DEVICE, - }, { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE - AT91SAM9G20_SRAM1_SIZE, - .pfn = __phys_to_pfn(AT91SAM9G20_SRAM1_BASE), - .length = AT91SAM9G20_SRAM1_SIZE, - .type = MT_DEVICE, - } -}; - -static struct map_desc at91sam9xe_sram_desc[] __initdata = { - { - .pfn = __phys_to_pfn(AT91SAM9XE_SRAM_BASE), - .type = MT_DEVICE, - } -}; - /* -------------------------------------------------------------------- * Clocks * -------------------------------------------------------------------- */ @@ -334,20 +299,20 @@ static void __init at91sam9xe_map_io(void) sram_size = SZ_16K; } - at91sam9xe_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size; - at91sam9xe_sram_desc->length = sram_size; - - iotable_init(at91sam9xe_sram_desc, ARRAY_SIZE(at91sam9xe_sram_desc)); + at91_init_sram(0, AT91SAM9XE_SRAM_BASE, sram_size); } static void __init at91sam9260_map_io(void) { - if (cpu_is_at91sam9xe()) + if (cpu_is_at91sam9xe()) { at91sam9xe_map_io(); - else if (cpu_is_at91sam9g20()) - iotable_init(at91sam9g20_sram_desc, ARRAY_SIZE(at91sam9g20_sram_desc)); - else - iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc)); + } else if (cpu_is_at91sam9g20()) { + at91_init_sram(0, AT91SAM9G20_SRAM0_BASE, AT91SAM9G20_SRAM0_SIZE); + at91_init_sram(1, AT91SAM9G20_SRAM1_BASE, AT91SAM9G20_SRAM1_SIZE); + } else { + at91_init_sram(0, AT91SAM9260_SRAM0_BASE, AT91SAM9260_SRAM0_SIZE); + at91_init_sram(1, AT91SAM9260_SRAM1_BASE, AT91SAM9260_SRAM1_SIZE); + } } static void __init at91sam9260_initialize(void) diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c index 8f97bd4..d522b47 100644 --- a/arch/arm/mach-at91/at91sam9261.c +++ b/arch/arm/mach-at91/at91sam9261.c @@ -26,24 +26,6 @@ #include "generic.h" #include "clock.h" -static struct map_desc at91sam9261_sram_desc[] __initdata = { - { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9261_SRAM_SIZE, - .pfn = __phys_to_pfn(AT91SAM9261_SRAM_BASE), - .length = AT91SAM9261_SRAM_SIZE, - .type = MT_DEVICE, - }, -}; - -static struct map_desc at91sam9g10_sram_desc[] __initdata = { - { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9G10_SRAM_SIZE, - .pfn = __phys_to_pfn(AT91SAM9G10_SRAM_BASE), - .length = AT91SAM9G10_SRAM_SIZE, - .type = MT_DEVICE, - }, -}; - /* -------------------------------------------------------------------- * Clocks * -------------------------------------------------------------------- */ @@ -297,9 +279,9 @@ static void at91sam9261_poweroff(void) static void __init at91sam9261_map_io(void) { if (cpu_is_at91sam9g10()) - iotable_init(at91sam9g10_sram_desc, ARRAY_SIZE(at91sam9g10_sram_desc)); + at91_init_sram(0, AT91SAM9G10_SRAM_BASE, AT91SAM9G10_SRAM_SIZE); else - iotable_init(at91sam9261_sram_desc, ARRAY_SIZE(at91sam9261_sram_desc)); + at91_init_sram(0, AT91SAM9261_SRAM_BASE, AT91SAM9261_SRAM_SIZE); } static void __init at91sam9261_initialize(void) diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c index da13f02..044f3c9 100644 --- a/arch/arm/mach-at91/at91sam9263.c +++ b/arch/arm/mach-at91/at91sam9263.c @@ -25,20 +25,6 @@ #include "generic.h" #include "clock.h" -static struct map_desc at91sam9263_sram_desc[] __initdata = { - { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9263_SRAM0_SIZE, - .pfn = __phys_to_pfn(AT91SAM9263_SRAM0_BASE), - .length = AT91SAM9263_SRAM0_SIZE, - .type = MT_DEVICE, - }, { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9263_SRAM0_SIZE - AT91SAM9263_SRAM1_SIZE, - .pfn = __phys_to_pfn(AT91SAM9263_SRAM1_BASE), - .length = AT91SAM9263_SRAM1_SIZE, - .type = MT_DEVICE, - }, -}; - /* -------------------------------------------------------------------- * Clocks * -------------------------------------------------------------------- */ @@ -311,7 +297,8 @@ static void at91sam9263_poweroff(void) static void __init at91sam9263_map_io(void) { - iotable_init(at91sam9263_sram_desc, ARRAY_SIZE(at91sam9263_sram_desc)); + at91_init_sram(0, AT91SAM9263_SRAM0_BASE, AT91SAM9263_SRAM0_SIZE); + at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE); } static void __init at91sam9263_initialize(void) diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c index cbc0645..e04c5fb 100644 --- a/arch/arm/mach-at91/at91sam9g45.c +++ b/arch/arm/mach-at91/at91sam9g45.c @@ -26,15 +26,6 @@ #include "generic.h" #include "clock.h" -static struct map_desc at91sam9g45_sram_desc[] __initdata = { - { - .virtual = AT91_IO_VIRT_BASE - AT91SAM9G45_SRAM_SIZE, - .pfn = __phys_to_pfn(AT91SAM9G45_SRAM_BASE), - .length = AT91SAM9G45_SRAM_SIZE, - .type = MT_DEVICE, - } -}; - /* -------------------------------------------------------------------- * Clocks * -------------------------------------------------------------------- */ @@ -327,7 +318,7 @@ static void at91sam9g45_poweroff(void) static void __init at91sam9g45_map_io(void) { - iotable_init(at91sam9g45_sram_desc, ARRAY_SIZE(at91sam9g45_sram_desc)); + at91_init_sram(0, AT91SAM9G45_SRAM_BASE, AT91SAM9G45_SRAM_SIZE); } static void __init at91sam9g45_initialize(void) diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c index 55ee7d0..a238105 100644 --- a/arch/arm/mach-at91/at91sam9rl.c +++ b/arch/arm/mach-at91/at91sam9rl.c @@ -26,13 +26,6 @@ #include "generic.h" #include "clock.h" -static struct map_desc at91sam9rl_sram_desc[] __initdata = { - { - .pfn = __phys_to_pfn(AT91SAM9RL_SRAM_BASE), - .type = MT_DEVICE, - } -}; - /* -------------------------------------------------------------------- * Clocks * -------------------------------------------------------------------- */ @@ -293,11 +286,8 @@ static void __init at91sam9rl_map_io(void) sram_size = SZ_16K; } - at91sam9rl_sram_desc->virtual = AT91_IO_VIRT_BASE - sram_size; - at91sam9rl_sram_desc->length = sram_size; - /* Map SRAM */ - iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc)); + at91_init_sram(0, AT91SAM9RL_SRAM_BASE, sram_size); } static void __init at91sam9rl_initialize(void) diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index a9d6ed4..938b34f 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -12,6 +12,8 @@ /* Map io */ extern void __init at91_map_io(void); +extern void __init at91_init_sram(int bank, unsigned long base, + unsigned int length); /* Processors */ extern void __init at91rm9200_set_type(int type); diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index 43251ef..816599f 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c @@ -45,6 +45,26 @@ void __init at91_init_interrupts(unsigned int *priority) at91_gpio_irq_setup(); } +static struct map_desc sram_desc[2] __initdata; + +void __init at91_init_sram(int bank, unsigned long base, unsigned int length) +{ + struct map_desc *desc = &sram_desc[bank]; + + desc->virtual = AT91_IO_VIRT_BASE - length; + if (bank > 0) + desc->virtual -= sram_desc[bank - 1].length; + + desc->pfn = __phys_to_pfn(base); + desc->length = length; + desc->type = MT_DEVICE; + + pr_info("AT91: sram at 0x%lx of 0x%x mapped at 0x%lx\n", + base, length, desc->virtual); + + iotable_init(desc, 1); +} + static struct map_desc at91_io_desc __initdata = { .virtual = AT91_VA_BASE_SYS, .pfn = __phys_to_pfn(AT91_BASE_SYS),