From patchwork Sun Feb 5 18:29:36 2012 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: 139658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wi0-f184.google.com (mail-wi0-f184.google.com [209.85.212.184]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 0905C1007D2 for ; Mon, 6 Feb 2012 05:35:03 +1100 (EST) Received: by wibhm2 with SMTP id hm2sf10163823wib.11 for ; Sun, 05 Feb 2012 10:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:x-ovh-mailout :subject:date:message-id:x-mailer:in-reply-to:references :x-ovh-tracer-id:x-ovh-remote:x-ovh-local:x-ovh-spamstate :x-ovh-spamscore:x-ovh-spamcause:x-spam-check:x-vr-spamstate :x-vr-spamscore:x-vr-spamcause:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type; bh=mYK+gWdi9xZlk9f+AO29oRzgm8IluoIeMAYJQteb6cw=; b=PmMfGKtKfBQhvmiE7/jAHDBk+PMSAF8jMW7EYIbEIDeeRjke5wjrPP5Q1xkLyxXjcP qtMV/B/Ab/JMYIUJQsPg13OfRHl9iYS3j58LKuTl31EZXBxD2HgY/4FWPMu6xL/mQQMC 0sVQK8SdYxlOH9Q94yXDlzFf8kbaGOAv8bcqM= Received: by 10.180.89.37 with SMTP id bl5mr2979907wib.3.1328466899550; Sun, 05 Feb 2012 10:34:59 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.216.208.215 with SMTP id q65ls20659666weo.2.gmail; Sun, 05 Feb 2012 10:34:58 -0800 (PST) Received: by 10.180.92.9 with SMTP id ci9mr1753884wib.1.1328466898905; Sun, 05 Feb 2012 10:34:58 -0800 (PST) Received: by 10.180.92.9 with SMTP id ci9mr1753883wib.1.1328466898896; Sun, 05 Feb 2012 10:34:58 -0800 (PST) Received: from mo3.mail-out.ovh.net (8.mo3.mail-out.ovh.net. [87.98.172.249]) by gmr-mx.google.com with ESMTP id e6si7744035wie.3.2012.02.05.10.34.58; Sun, 05 Feb 2012 10:34:58 -0800 (PST) Received-SPF: pass (google.com: domain of plagnioj@jcrosoft.com designates 87.98.172.249 as permitted sender) client-ip=87.98.172.249; Received: from mail617.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo3.mail-out.ovh.net (Postfix) with SMTP id E4D441004127 for ; Sun, 5 Feb 2012 19:37:08 +0100 (CET) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 5 Feb 2012 20:34:58 +0200 Received: from ns32433.ovh.net (HELO localhost) (plagnioj%jcrosoft.com@213.251.161.87) by ns0.ovh.net with SMTP; 5 Feb 2012 20:34:55 +0200 From: Jean-Christophe PLAGNIOL-VILLARD To: linux-arm-kernel@lists.infradead.org Cc: Jean-Christophe PLAGNIOL-VILLARD , rtc-linux@googlegroups.com X-Ovh-Mailout: 178.32.228.3 (mo3.mail-out.ovh.net) Subject: [rtc-linux] [PATCH 2/2] ARM: at91: make gpbr soc independent Date: Sun, 5 Feb 2012 19:29:36 +0100 Message-Id: <1328466576-29384-2-git-send-email-plagnioj@jcrosoft.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1328466576-29384-1-git-send-email-plagnioj@jcrosoft.com> References: <1328466576-29384-1-git-send-email-plagnioj@jcrosoft.com> X-Ovh-Tracer-Id: 14685956910436035581 X-Ovh-Remote: 213.251.161.87 (ns32433.ovh.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-OVH-SPAMSTATE: OK X-OVH-SPAMSCORE: 0 X-OVH-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeegtddrgedtucetggdotefuucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-Spam-Check: DONE|U 0.5/N X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeegtddrgedtucetggdotefuucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucenucfhrhhomheplfgvrghnqdevhhhrihhsthhophhhvgcurffntefipffkqffnqdggkffnnfettfffuceophhlrghgnhhiohhjsehjtghrohhsohhfthdrtghomheqnecujfgurhephffvufffkffojghfsedttdertdertddt X-Original-Sender: plagnioj@jcrosoft.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of plagnioj@jcrosoft.com designates 87.98.172.249 as permitted sender) smtp.mail=plagnioj@jcrosoft.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , use genalloc to manage the pool of backup register Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Cc: rtc-linux@googlegroups.com --- Hi, if you don't mind I'll apply this via at91 tree as it's needed to finish a cleanup on at91 to allow multiple soc in the same kernel Best Regards, J. arch/arm/Kconfig | 1 + arch/arm/mach-at91/at91sam9260_devices.c | 1 + arch/arm/mach-at91/at91sam9261_devices.c | 1 + arch/arm/mach-at91/at91sam9263_devices.c | 1 + arch/arm/mach-at91/at91sam9g45_devices.c | 1 + arch/arm/mach-at91/at91sam9rl_devices.c | 1 + arch/arm/mach-at91/generic.h | 1 + arch/arm/mach-at91/include/mach/at91sam9260.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9261.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9263.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9g45.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9rl.h | 2 +- arch/arm/mach-at91/setup.c | 29 +++++++++++++++++++++++++ drivers/rtc/rtc-at91sam9.c | 18 +++++++++++++-- 14 files changed, 60 insertions(+), 16 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 92c9c79..dd49374 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -322,6 +322,7 @@ config ARCH_AT91 select ARCH_REQUIRE_GPIOLIB select HAVE_CLK select CLKDEV_LOOKUP + select GENERIC_ALLOCATOR help This enables support for systems based on the Atmel AT91RM9200, AT91SAM9 processors. diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 2760146..d86319f 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c @@ -1333,6 +1333,7 @@ void __init at91_add_device_cf(struct at91_cf_data * data) {} */ static int __init at91_add_standard_devices(void) { + at91_init_gpbr(AT91SAM9260_BASE_GPBR, 16); at91_add_device_rtt(); at91_add_device_watchdog(); at91_add_device_tc(); diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index 52c1f1a..64e194d 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c @@ -1061,6 +1061,7 @@ void __init at91_add_device_serial(void) {} */ static int __init at91_add_standard_devices(void) { + at91_init_gpbr(AT91SAM9261_BASE_GPBR, 16); at91_add_device_rtt(); at91_add_device_watchdog(); at91_add_device_tc(); diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index 1de4c4f..4ba3e18 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c @@ -1447,6 +1447,7 @@ void __init at91_add_device_serial(void) {} */ static int __init at91_add_standard_devices(void) { + at91_init_gpbr(AT91SAM9263_BASE_GPBR, 80); at91_add_device_rtt(); at91_add_device_watchdog(); at91_add_device_tc(); diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index 8c036ff..33c7f44 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c @@ -1732,6 +1732,7 @@ void __init at91_add_device_serial(void) {} */ static int __init at91_add_standard_devices(void) { + at91_init_gpbr(AT91SAM9G45_BASE_GPBR, 80); at91_add_device_hdmac(); at91_add_device_rtc(); at91_add_device_rtt(); diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c index 936cf20..df9224d 100644 --- a/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/arch/arm/mach-at91/at91sam9rl_devices.c @@ -1202,6 +1202,7 @@ void __init at91_add_device_serial(void) {} */ static int __init at91_add_standard_devices(void) { + at91_init_gpbr(AT91SAM9G45_BASE_GPBR, 16); at91_add_device_hdmac(); at91_add_device_rtc(); at91_add_device_rtt(); diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index 7a5e23a..cbf43b1 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -14,6 +14,7 @@ extern void __init at91_map_io(void); extern void __init at91_init_sram(int bank, unsigned long base, unsigned int length); +extern void __init at91_init_gpbr(unsigned long base, unsigned int length); /* Processors */ extern void __init at91rm9200_set_type(int type); diff --git a/arch/arm/mach-at91/include/mach/at91sam9260.h b/arch/arm/mach-at91/include/mach/at91sam9260.h index 5cfc9dc..08ae9af 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9260.h +++ b/arch/arm/mach-at91/include/mach/at91sam9260.h @@ -78,10 +78,8 @@ #define AT91SAM9260_BASE_ADC 0xfffe0000 /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals */ -#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS) - #define AT91SAM9260_BASE_ECC 0xffffe800 #define AT91SAM9260_BASE_SDRAMC 0xffffea00 #define AT91SAM9260_BASE_SMC 0xffffec00 @@ -95,6 +93,7 @@ #define AT91SAM9260_BASE_RTT 0xfffffd20 #define AT91SAM9260_BASE_PIT 0xfffffd30 #define AT91SAM9260_BASE_WDT 0xfffffd40 +#define AT91SAM9260_BASE_GPBR 0xfffffd50 #define AT91_USART0 AT91SAM9260_BASE_US0 #define AT91_USART1 AT91SAM9260_BASE_US1 diff --git a/arch/arm/mach-at91/include/mach/at91sam9261.h b/arch/arm/mach-at91/include/mach/at91sam9261.h index e4c936c..1124bd2 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9261.h +++ b/arch/arm/mach-at91/include/mach/at91sam9261.h @@ -63,10 +63,8 @@ /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals */ -#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS) - #define AT91SAM9261_BASE_SMC 0xffffec00 #define AT91SAM9261_BASE_SDRAMC 0xffffea00 #define AT91SAM9261_BASE_MATRIX 0xffffee00 @@ -79,6 +77,7 @@ #define AT91SAM9261_BASE_RTT 0xfffffd20 #define AT91SAM9261_BASE_PIT 0xfffffd30 #define AT91SAM9261_BASE_WDT 0xfffffd40 +#define AT91SAM9261_BASE_GPBR 0xfffffd50 #define AT91_USART0 AT91SAM9261_BASE_US0 #define AT91_USART1 AT91SAM9261_BASE_US1 diff --git a/arch/arm/mach-at91/include/mach/at91sam9263.h b/arch/arm/mach-at91/include/mach/at91sam9263.h index dda083d..d96cbb2 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9263.h +++ b/arch/arm/mach-at91/include/mach/at91sam9263.h @@ -72,10 +72,8 @@ #define AT91SAM9263_BASE_2DGE 0xfffc8000 /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals */ -#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS) - #define AT91SAM9263_BASE_ECC0 0xffffe000 #define AT91SAM9263_BASE_SDRAMC0 0xffffe200 #define AT91SAM9263_BASE_SMC0 0xffffe400 @@ -95,6 +93,7 @@ #define AT91SAM9263_BASE_PIT 0xfffffd30 #define AT91SAM9263_BASE_WDT 0xfffffd40 #define AT91SAM9263_BASE_RTT1 0xfffffd50 +#define AT91SAM9263_BASE_GPBR 0xfffffd60 #define AT91_USART0 AT91SAM9263_BASE_US0 #define AT91_USART1 AT91SAM9263_BASE_US1 diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h index a824e15..8851a4b 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9g45.h +++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h @@ -84,10 +84,8 @@ #define AT91SAM9G45_BASE_TC5 0xfffd4080 /* - * System Peripherals (offset from AT91_BASE_SYS) + * System Peripherals */ -#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS) - #define AT91SAM9G45_BASE_ECC 0xffffe200 #define AT91SAM9G45_BASE_DDRSDRC1 0xffffe400 #define AT91SAM9G45_BASE_DDRSDRC0 0xffffe600 @@ -105,6 +103,7 @@ #define AT91SAM9G45_BASE_RTT 0xfffffd20 #define AT91SAM9G45_BASE_PIT 0xfffffd30 #define AT91SAM9G45_BASE_WDT 0xfffffd40 +#define AT91SAM9G45_BASE_GPBR 0xfffffd60 #define AT91SAM9G45_BASE_RTC 0xfffffdb0 #define AT91_USART0 AT91SAM9G45_BASE_US0 diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl.h b/arch/arm/mach-at91/include/mach/at91sam9rl.h index 2d7176a..e0073eb 100644 --- a/arch/arm/mach-at91/include/mach/at91sam9rl.h +++ b/arch/arm/mach-at91/include/mach/at91sam9rl.h @@ -70,7 +70,6 @@ * System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS) -#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS) #define AT91SAM9RL_BASE_DMA 0xffffe600 #define AT91SAM9RL_BASE_ECC 0xffffe800 @@ -87,6 +86,7 @@ #define AT91SAM9RL_BASE_RTT 0xfffffd20 #define AT91SAM9RL_BASE_PIT 0xfffffd30 #define AT91SAM9RL_BASE_WDT 0xfffffd40 +#define AT91SAM9RL_BASE_GPBR 0xfffffd60 #define AT91SAM9RL_BASE_RTC 0xfffffe00 #define AT91_USART0 AT91SAM9RL_BASE_US0 diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index 79ec878..a2c577e 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -51,6 +52,34 @@ void __init at91_init_interrupts(unsigned int *priority) at91_gpio_irq_setup(); } +void __init at91_init_gpbr(unsigned long base, unsigned int length) +{ + struct gen_pool *pool; + void __iomem *virt; + + pool = gen_pool_create_byname("gpbr", 2, -1); + + if (!pool) + goto err_create; + + virt = ioremap(base, length); + if (!virt) + goto err_ioremap; + if (gen_pool_add_virt(pool, (unsigned long)virt, base, length, -1)) + goto fail_add_virt; + + pr_info("AT91: create GPBR pool of 0x%x at 0x%lx (mapped at 0x%p)\n", + length, base, virt); + return; + +fail_add_virt: + iounmap(virt); +err_ioremap: + gen_pool_destroy(pool); +err_create: + pr_err("gpbr: genalloc pool failed to create\n"); +} + static struct map_desc sram_desc[2] __initdata; void __init at91_init_sram(int bank, unsigned long base, unsigned int length) diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index ee3c122..7df6cb4 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,7 @@ struct sam9_rtc { void __iomem *rtt; struct rtc_device *rtcdev; u32 imr; + void __iomem *gpbr; }; #define rtt_readl(rtc, field) \ @@ -65,9 +67,9 @@ struct sam9_rtc { __raw_writel((val), (rtc)->rtt + AT91_RTT_ ## field) #define gpbr_readl(rtc) \ - at91_sys_read(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR) + __raw_readl((rtc)->gpbr) #define gpbr_writel(rtc, val) \ - at91_sys_write(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR, (val)) + __raw_writel((val), (rtc)->gpbr) /* * Read current time and date in RTC @@ -302,6 +304,13 @@ static int __init at91_rtc_probe(struct platform_device *pdev) if (!rtc) return -ENOMEM; + rtc->gpbr = (void __iomem*)gen_pool_alloc_byname("gpbr", 4); + if (!rtc->gpbr) { + dev_err(&pdev->dev, "failed to alloc gpbr, aborting.\n"); + ret = -ENOMEM; + goto fail; + } + /* platform setup code should have handled this; sigh */ if (!device_can_wakeup(&pdev->dev)) device_init_wakeup(&pdev->dev, 1); @@ -311,7 +320,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev) if (!rtc->rtt) { dev_err(&pdev->dev, "failed to map registers, aborting.\n"); ret = -ENOMEM; - goto fail; + goto fail_ioremap; } mr = rtt_readl(rtc, MR); @@ -357,6 +366,8 @@ static int __init at91_rtc_probe(struct platform_device *pdev) fail_register: iounmap(rtc->rtt); +fail_ioremap: + gen_pool_free_byname("gpbr", (unsigned long)rtc->gpbr, 4); fail: platform_set_drvdata(pdev, NULL); kfree(rtc); @@ -378,6 +389,7 @@ static int __exit at91_rtc_remove(struct platform_device *pdev) rtc_device_unregister(rtc->rtcdev); iounmap(rtc->rtt); + gen_pool_free_byname("gpbr", (unsigned long)rtc->gpbr, 4); platform_set_drvdata(pdev, NULL); kfree(rtc); return 0;