From patchwork Mon Apr 1 23:22:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Clouter X-Patchwork-Id: 232834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wi0-x23b.google.com (mail-wi0-x23b.google.com [IPv6:2a00:1450:400c:c05::23b]) (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 D16632C01B3 for ; Tue, 2 Apr 2013 10:23:18 +1100 (EST) Received: by mail-wi0-f187.google.com with SMTP id hm14sf869478wib.4 for ; Mon, 01 Apr 2013 16:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-received:mime-version:x-beenthere:x-received:received-spf:from:to :cc:subject:date:message-id:x-mailer:in-reply-to:references :x-wormnet-spam-score:x-wormnet-spam-report: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=ngX/NtTQzX2EG4RnSgUoXu09fZrLecFE3qXewTd5ivg=; b=wVvTK3j3+EOTEUx8kM7zVc3kV+5K47+Hb61qZGTZ1qHp2jRibLnD7z5g3jNNEa4r5B +LX33P2QFZqMtv2B4BEF/xC3V+YolX8qjuIQBQgv3bKzHvMqJU5rO0Ig8IyP3mCWDHrA /i6P4sbIjpuSfd/5eo4oYjmFMdTn0lvLxBFr2vny7Fh3AF4akDW9MrbdMTasnLfWp5LJ ZU/W0E5zEIhSXClQwnguXw55YPcZ9OIF9d6yicrSXqsq3CfxBaUzN9iAW8/jj9SvM5oX eQjMo/HA2JbMjrfWbD2/G6VNFeHi+4ulI5CGC/RmrzycuWwgaeckZzB8yBzInB4p25Vl CdSw== X-Received: by 10.180.87.74 with SMTP id v10mr913203wiz.2.1364858594953; Mon, 01 Apr 2013 16:23:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.180.106.167 with SMTP id gv7ls723116wib.16.canary; Mon, 01 Apr 2013 16:23:14 -0700 (PDT) X-Received: by 10.180.95.3 with SMTP id dg3mr2138087wib.4.1364858594523; Mon, 01 Apr 2013 16:23:14 -0700 (PDT) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [2a03:9800:10:2d:3203:b3a5:8bdc:5b68]) by gmr-mx.google.com with ESMTPS id v5si676574wij.0.2013.04.01.16.23.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 01 Apr 2013 16:23:14 -0700 (PDT) Received-SPF: neutral (google.com: 2a03:9800:10:2d:3203:b3a5:8bdc:5b68 is neither permitted nor denied by best guess record for domain of prvs=080340ab33=alex@digriz.org.uk) client-ip=2a03:9800:10:2d:3203:b3a5:8bdc:5b68; Received: from [2a01:348:45:1000:e978:af85:4e49:7987] (helo=berk.digriz.org.uk) by marmot.wormnet.eu with smtp (Exim 4.80) (envelope-from ) id 1UMo44-0002IS-Gu; Tue, 02 Apr 2013 00:23:02 +0100 Received: (nullmailer pid 17771 invoked by uid 1000); Mon, 01 Apr 2013 23:22:47 -0000 From: Alexander Clouter To: Alessandro Zummo , Hartley Sweeten , Grant Likely , Jason Cooper , Ryan Mallon , Rob Herring , Andrew Lunn Cc: devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com, Alexander Clouter Subject: [rtc-linux] [PATCH 4/6] arm: orion5x: move ts78xx to use rtc-m48t86 driver side memory interface Date: Tue, 2 Apr 2013 00:22:43 +0100 Message-Id: <1364858565-17192-5-git-send-email-alex@digriz.org.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364858565-17192-1-git-send-email-alex@digriz.org.uk> References: <1364858565-17192-1-git-send-email-alex@digriz.org.uk> X-WormNet-Spam-Score: 0.6 (/) X-WormNet-Spam-Report: from marmot.wormnet.eu 1.7 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS Tokens: new, 103; hammy, 128; neutral, 75; spammy, 3. X-Original-Sender: alex@digriz.org.uk X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2a03:9800:10:2d:3203:b3a5:8bdc:5b68 is neither permitted nor denied by best guess record for domain of prvs=080340ab33=alex@digriz.org.uk) smtp.mail=prvs=080340ab33=alex@digriz.org.uk; dkim=pass header.i=@digriz.org.uk 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: , Remove platform_data hooks into rtc-m48t86 and use named resource regions. Signed-off-by: Alexander Clouter Acked-by: Jason Cooper --- arch/arm/mach-orion5x/ts78xx-setup.c | 78 ++++++++-------------------------- 1 file changed, 17 insertions(+), 61 deletions(-) diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c index ffe3603..613216f 100644 --- a/arch/arm/mach-orion5x/ts78xx-setup.c +++ b/arch/arm/mach-orion5x/ts78xx-setup.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -80,78 +79,35 @@ static struct mv_sata_platform_data ts78xx_sata_data = { /***************************************************************************** * RTC M48T86 - nicked^Wborrowed from arch/arm/mach-ep93xx/ts72xx.c ****************************************************************************/ -#define TS_RTC_CTRL (TS78XX_FPGA_REGS_VIRT_BASE + 0x808) -#define TS_RTC_DATA (TS78XX_FPGA_REGS_VIRT_BASE + 0x80c) +#define TS_RTC_INDEX (TS78XX_FPGA_REGS_PHYS_BASE + 0x808) +#define TS_RTC_DATA (TS78XX_FPGA_REGS_PHYS_BASE + 0x80c) -static unsigned char ts78xx_ts_rtc_readbyte(unsigned long addr) -{ - writeb(addr, TS_RTC_CTRL); - return readb(TS_RTC_DATA); -} - -static void ts78xx_ts_rtc_writebyte(unsigned char value, unsigned long addr) -{ - writeb(addr, TS_RTC_CTRL); - writeb(value, TS_RTC_DATA); -} - -static struct m48t86_ops ts78xx_ts_rtc_ops = { - .readbyte = ts78xx_ts_rtc_readbyte, - .writebyte = ts78xx_ts_rtc_writebyte, +static struct resource ts78xx_ts_rtc_resource[] = { + DEFINE_RES_NAMED(TS_RTC_INDEX, 4, "rtc_index", IORESOURCE_MEM), + DEFINE_RES_NAMED(TS_RTC_DATA, 4, "rtc_data", IORESOURCE_MEM), }; static struct platform_device ts78xx_ts_rtc_device = { .name = "rtc-m48t86", .id = -1, - .dev = { - .platform_data = &ts78xx_ts_rtc_ops, - }, - .num_resources = 0, + .resource = ts78xx_ts_rtc_resource, + .num_resources = ARRAY_SIZE(ts78xx_ts_rtc_resource), }; -/* - * TS uses some of the user storage space on the RTC chip so see if it is - * present; as it's an optional feature at purchase time and not all boards - * will have it present - * - * I've used the method TS use in their rtc7800.c example for the detection - * - * TODO: track down a guinea pig without an RTC to see if we can work out a - * better RTC detection routine - */ static int ts78xx_ts_rtc_load(void) { int rc; - unsigned char tmp_rtc0, tmp_rtc1; - - tmp_rtc0 = ts78xx_ts_rtc_readbyte(126); - tmp_rtc1 = ts78xx_ts_rtc_readbyte(127); - - ts78xx_ts_rtc_writebyte(0x00, 126); - ts78xx_ts_rtc_writebyte(0x55, 127); - if (ts78xx_ts_rtc_readbyte(127) == 0x55) { - ts78xx_ts_rtc_writebyte(0xaa, 127); - if (ts78xx_ts_rtc_readbyte(127) == 0xaa - && ts78xx_ts_rtc_readbyte(126) == 0x00) { - ts78xx_ts_rtc_writebyte(tmp_rtc0, 126); - ts78xx_ts_rtc_writebyte(tmp_rtc1, 127); - - if (ts78xx_fpga.supports.ts_rtc.init == 0) { - rc = platform_device_register(&ts78xx_ts_rtc_device); - if (!rc) - ts78xx_fpga.supports.ts_rtc.init = 1; - } else - rc = platform_device_add(&ts78xx_ts_rtc_device); - - if (rc) - pr_info("RTC could not be registered: %d\n", - rc); - return rc; - } - } - pr_info("RTC not found\n"); - return -ENODEV; + if (ts78xx_fpga.supports.ts_rtc.init == 0) { + rc = platform_device_register(&ts78xx_ts_rtc_device); + if (!rc) + ts78xx_fpga.supports.ts_rtc.init = 1; + } else + rc = platform_device_add(&ts78xx_ts_rtc_device); + + if (rc) + pr_info("RTC could not be registered: %d\n", rc); + return rc; }; static void ts78xx_ts_rtc_unload(void)