From patchwork Mon Mar 9 16:42:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartley Sweeten X-Patchwork-Id: 24206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from yx-out-2122.google.com (yx-out-2122.google.com [74.125.44.26]) by ozlabs.org (Postfix) with ESMTP id 66C39DE0A0 for ; Tue, 10 Mar 2009 03:42:42 +1100 (EST) Received: by yx-out-2122.google.com with SMTP id 8so1113202yxj.11 for ; Mon, 09 Mar 2009 09:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received :received:received:x-mimeole:content-class:mime-version:content-type :content-transfer-encoding:subject:date:message-id:in-reply-to :x-ms-has-attach:x-ms-tnef-correlator:thread-topic:thread-index :references:from:to:cc:x-originalarrivaltime:reply-to:sender :precedence:x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; bh=9r1wo+2RhyjLF9qA3/If2URe9Be0EgFkSFXK985uhQw=; b=XXOYG6QOO0dV+iOG8cl/QOP9+sLcmcW8TCCXCnUhI67MsiUwq/oUwcwLhLJ3HYqCgT tjU9fJnu4XUUIdSA+bZec+r/R1kXW4XXSAJJt8fH97zchmj0e0v++HE1KO0HaKtRvw/9 0atZ5RwzIRgwdRfJAw2AjpV+v/55XMhFkG8eg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :x-mimeole:content-class:mime-version:content-type :content-transfer-encoding:subject:date:message-id:in-reply-to :x-ms-has-attach:x-ms-tnef-correlator:thread-topic:thread-index :references:from:to:cc:x-originalarrivaltime:reply-to:sender :precedence:x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; b=gzyPj3JYiZ2h50EpAUn9Rhvd9DLn64HC/GIWoreUykQs65xvtXWnql/j4Y1AVPaPf9 +S98T7BK2OgnsqKbafdrAC5Iik/O86Nk5jOycAo2KUFEK2LqeEzlrETvD/Aqy5uWEpfQ fVSwpfKy103eS9DmmJBko0smEvRbPCZKjXGJk= Received: by 10.151.41.21 with SMTP id t21mr1008512ybj.11.1236616957265; Mon, 09 Mar 2009 09:42:37 -0700 (PDT) Received: by 10.176.101.40 with SMTP id y40gr1996yqb.0; Mon, 09 Mar 2009 09:42:37 -0700 (PDT) X-Sender: hartleys@visionengravers.com X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.90.103.13 with SMTP id a13mr3747208agc.9.1236616956500; Mon, 09 Mar 2009 09:42:36 -0700 (PDT) Received: from psmtp.com (exprod6ob113.obsmtp.com [64.18.1.30]) by gmr-mx.google.com with SMTP id 14si787520gxk.3.2009.03.09.09.42.35; Mon, 09 Mar 2009 09:42:36 -0700 (PDT) Received-SPF: neutral (google.com: 64.18.1.30 is neither permitted nor denied by best guess record for domain of hartleys@visionengravers.com) client-ip=64.18.1.30; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 64.18.1.30 is neither permitted nor denied by best guess record for domain of hartleys@visionengravers.com) smtp.mail=hartleys@visionengravers.com Received: from source ([63.240.6.3]) (using TLSv1) by exprod6ob113.postini.com ([64.18.5.12]) with SMTP ID DSNKSbVG+xn+jBIL7D2iuAZfi9ra/bu3GE7d@postini.com; Mon, 09 Mar 2009 09:42:36 PDT Received: from D01HOST03.Mi8.com ([172.16.1.25]) by Outbound02.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 9 Mar 2009 12:42:34 -0400 Received: from mi8nycmail19.Mi8.com ([172.16.7.219]) by D01HOST03.Mi8.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 9 Mar 2009 12:42:34 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message Mime-Version: 1.0 Subject: [rtc-linux] Re: [PATCH] ep93xx-rtc: use ioremap'ed addresses Date: Mon, 9 Mar 2009 12:42:32 -0400 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [rtc-linux] RE: [PATCH] ep93xx-rtc: use ioremap'ed addresses Thread-Index: AcmTSylijZyacXvjQJadaX1uq0yV+AALvaGwAJhKVCACvqHsIA== References: <20090220120529.09ab182a@i1501.lan.towertech.it> From: "H Hartley Sweeten" To: "Alessandro Zummo" , Cc: "arm kernel" X-OriginalArrivalTime: 09 Mar 2009 16:42:34.0117 (UTC) FILETIME=[0BFA5350:01C9A0D6] Reply-To: rtc-linux@googlegroups.com Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com Any comments on this patch? Regards, Hartley -----Original Message----- From: hartleys Sent: Monday, February 23, 2009 10:26 AM To: hartleys; Alessandro Zummo; rtc-linux@googlegroups.com Cc: arm kernel Subject: RE: [rtc-linux] RE: [PATCH] ep93xx-rtc: use ioremap'ed addresses This patch updates the rtc-ep93xx.c driver to use ioremap'ed addresses. This removes the dependency on and properly reports the memory addresses used by the driver in /proc/iomem. In addition, ep93xx_rtc_init() is updated to use platform_driver_probe() instead of platform_driver_register(). Also, the device_create_file() calls are now properly checked for error conditions. The created sysfs files are also now removed when the driver is removed. Signed-off-by: H Hartley Sweeten --- *preload = comp & 0xffff; @@ -37,7 +40,8 @@ static int ep93xx_get_swcomp(struct device *dev, unsigned short *preload, static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) { - unsigned long time = __raw_readl(EP93XX_RTC_DATA); + void __iomem *mmio_base = dev->platform_data; + unsigned long time = __raw_readl(mmio_base + EP93XX_RTC_DATA); rtc_time_to_tm(time, tm); return 0; @@ -45,7 +49,9 @@ static int ep93xx_rtc_read_time(struct device *dev, struct rtc_time *tm) static int ep93xx_rtc_set_mmss(struct device *dev, unsigned long secs) { - __raw_writel(secs + 1, EP93XX_RTC_LOAD); + void __iomem *mmio_base = dev->platform_data; + + __raw_writel(secs + 1, mmio_base + EP93XX_RTC_LOAD); return 0; } @@ -90,29 +96,75 @@ static ssize_t ep93xx_sysfs_show_comp_delete(struct device *dev, static DEVICE_ATTR(comp_delete, S_IRUGO, ep93xx_sysfs_show_comp_delete, NULL); -static int __devinit ep93xx_rtc_probe(struct platform_device *dev) +static int __init ep93xx_rtc_probe(struct platform_device *dev) { - struct rtc_device *rtc = rtc_device_register("ep93xx", - &dev->dev, &ep93xx_rtc_ops, THIS_MODULE); + struct resource *res; + void __iomem *mmio_base; + struct rtc_device *rtc; + int err; + + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + if (res == NULL) + return -ENXIO; + + res = request_mem_region(res->start, resource_size(res), dev->name); + if (res == NULL) + return -EBUSY; + + mmio_base = ioremap(res->start, resource_size(res)); + if (mmio_base == NULL) { + err = -ENXIO; + goto fail; + } + + dev->dev.platform_data = mmio_base; + rtc = rtc_device_register(dev->name, + &dev->dev, &ep93xx_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { - return PTR_ERR(rtc); + err = PTR_ERR(rtc); + goto fail; } platform_set_drvdata(dev, rtc); - device_create_file(&dev->dev, &dev_attr_comp_preload); - device_create_file(&dev->dev, &dev_attr_comp_delete); + err = device_create_file(&dev->dev, &dev_attr_comp_preload); + if (err) + goto fail; + err = device_create_file(&dev->dev, &dev_attr_comp_delete); + if (err) { + device_remove_file(&dev->dev, &dev_attr_comp_preload); + goto fail; + } return 0; + +fail: + if (mmio_base) { + iounmap(mmio_base); + dev->dev.platform_data = NULL; + } + release_mem_region(res->start, resource_size(res)); + return err; } -static int __devexit ep93xx_rtc_remove(struct platform_device *dev) +static int __exit ep93xx_rtc_remove(struct platform_device *dev) { struct rtc_device *rtc = platform_get_drvdata(dev); + void __iomem *mmio_base = dev->dev.platform_data; + struct resource *res; + + /* cleanup sysfs */ + device_remove_file(&dev->dev, &dev_attr_comp_delete); + device_remove_file(&dev->dev, &dev_attr_comp_preload); + + rtc_device_unregister(rtc); + + iounmap(mmio_base); + dev->dev.platform_data = NULL; - if (rtc) - rtc_device_unregister(rtc); + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + release_mem_region(res->start, resource_size(res)); platform_set_drvdata(dev, NULL); @@ -122,23 +174,22 @@ static int __devexit ep93xx_rtc_remove(struct platform_device *dev) /* work with hotplug and coldplug */ MODULE_ALIAS("platform:ep93xx-rtc"); -static struct platform_driver ep93xx_rtc_platform_driver = { +static struct platform_driver ep93xx_rtc_driver = { .driver = { .name = "ep93xx-rtc", .owner = THIS_MODULE, }, - .probe = ep93xx_rtc_probe, - .remove = __devexit_p(ep93xx_rtc_remove), + .remove = __exit_p(ep93xx_rtc_remove), }; static int __init ep93xx_rtc_init(void) { - return platform_driver_register(&ep93xx_rtc_platform_driver); + return platform_driver_probe(&ep93xx_rtc_driver, ep93xx_rtc_probe); } static void __exit ep93xx_rtc_exit(void) { - platform_driver_unregister(&ep93xx_rtc_platform_driver); + platform_driver_unregister(&ep93xx_rtc_driver); } MODULE_AUTHOR("Alessandro Zummo "); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. -~----------~----~----~----~------~----~------~--~--- diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index 6d9152d..90254d8 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c @@ -449,11 +449,19 @@ static struct amba_device uart3_device = { .periphid = 0x00041010, }; +static struct resource ep93xx_rtc_resource[] = { + { + .start = EP93XX_RTC_PHYS_BASE, + .end = EP93XX_RTC_PHYS_BASE + 0x10c - 1, + .flags = IORESOURCE_MEM, + }, +}; static struct platform_device ep93xx_rtc_device = { - .name = "ep93xx-rtc", - .id = -1, - .num_resources = 0, + .name = "ep93xx-rtc", + .id = -1, + .num_resources = ARRAY_SIZE(ep93xx_rtc_resource), + .resource = ep93xx_rtc_resource, }; diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h index 22d6c9a..68e6b23 100644 --- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h +++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h @@ -146,6 +146,7 @@ #define EP93XX_PWM_BASE (EP93XX_APB_VIRT_BASE + 0x00110000) #define EP93XX_RTC_BASE (EP93XX_APB_VIRT_BASE + 0x00120000) +#define EP93XX_RTC_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x00120000) #define EP93XX_SYSCON_BASE (EP93XX_APB_VIRT_BASE + 0x00130000) #define EP93XX_SYSCON_REG(x) (EP93XX_SYSCON_BASE + (x)) diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index f7a3283..26e3b0f 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c @@ -12,19 +12,22 @@ #include #include #include -#include +#include -#define EP93XX_RTC_REG(x) (EP93XX_RTC_BASE + (x)) -#define EP93XX_RTC_DATA EP93XX_RTC_REG(0x0000) -#define EP93XX_RTC_LOAD EP93XX_RTC_REG(0x000C) -#define EP93XX_RTC_SWCOMP EP93XX_RTC_REG(0x0108) +#define EP93XX_RTC_DATA 0x000 +#define EP93XX_RTC_MATCH 0x004 +#define EP93XX_RTC_STATUS 0x008 +#define EP93XX_RTC_LOAD 0x00C +#define EP93XX_RTC_CONTROL 0x010 +#define EP93XX_RTC_SWCOMP 0x108 #define DRV_VERSION "0.2" static int ep93xx_get_swcomp(struct device *dev, unsigned short *preload, unsigned short *delete) { - unsigned short comp = __raw_readl(EP93XX_RTC_SWCOMP); + void __iomem *mmio_base = dev->platform_data; + unsigned long comp = __raw_readl(mmio_base + EP93XX_RTC_SWCOMP); if (preload)