From patchwork Sun Mar 31 21:56:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Clouter X-Patchwork-Id: 232630 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-we0-x23d.google.com (mail-we0-x23d.google.com [IPv6:2a00:1450:400c:c03::23d]) (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 864852C018A for ; Mon, 1 Apr 2013 08:56:40 +1100 (EST) Received: by mail-we0-f189.google.com with SMTP id r3sf617446wey.26 for ; Sun, 31 Mar 2013 14:56:36 -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=ji6npvcYUJZx8I1/h0QDXCg7/jBFIt4Qxc0fo85MtBw=; b=dA0K3SwNcB9KqqrHF0w6rYBqaMcKtQ8EcIQQMNNV55HDoY2Da2nd+qxSJWjpFQ4BTv QGc2wsBA2dCj2PCCfCJfnYHKKfwGwCnzq2CUo7O5Wk+bMs/h1bbHsHOqGR9bKxtUq5x8 WAO91ahDZbL01TVfuIEsgp2M/N6KiVfSf3PG+6FfhchaKX6ylBe9qAyzS6/+bq1s5T// hY5qnkwJo5lGAGDVw6fZe7dHX3F59UjkJzqgsBxukHqZGfkZSRHPG69fNYwLRgrUMuH6 tzZ49aiGj8XJJxG8cave1TvWqv+23KI2EvRg8yy8nd+Y544kq9iDJJaPW/yflbaKKOWS n6ew== X-Received: by 10.180.87.198 with SMTP id ba6mr321150wib.5.1364766995817; Sun, 31 Mar 2013 14:56:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.180.208.11 with SMTP id ma11ls323553wic.37.canary; Sun, 31 Mar 2013 14:56:35 -0700 (PDT) X-Received: by 10.180.95.3 with SMTP id dg3mr1201788wib.4.1364766995525; Sun, 31 Mar 2013 14:56:35 -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 bk3si335212wib.3.2013.03.31.14.56.35 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 31 Mar 2013 14:56:35 -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=0802e14cf1=alex@digriz.org.uk) client-ip=2a03:9800:10:2d:3203:b3a5:8bdc:5b68; Received: from [2a01:348:45:1000:d0c7:5dd8:2ab9:8725] (helo=berk.digriz.org.uk) by marmot.wormnet.eu with smtp (Exim 4.80) (envelope-from ) id 1UMQEe-0005WD-OO; Sun, 31 Mar 2013 22:56:22 +0100 Received: (nullmailer pid 7142 invoked by uid 1000); Sun, 31 Mar 2013 21:56:13 -0000 From: Alexander Clouter To: Alessandro Zummo , Hartley Sweeten , Grant Likely , Jason Cooper , Ryan Mallon , Rob Herring Cc: devicetree-discuss@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com, Alexander Clouter Subject: [rtc-linux] [PATCH 2/3] arm: orion5x: fixup ts78xx to be able to use the rtc-m48t86 again. Date: Sun, 31 Mar 2013 22:56:10 +0100 Message-Id: <1364766971-5914-3-git-send-email-alex@digriz.org.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364766971-5914-1-git-send-email-alex@digriz.org.uk> References: <1364766971-5914-1-git-send-email-alex@digriz.org.uk> X-WormNet-Spam-Score: -1.1 (-) X-WormNet-Spam-Report: from marmot.wormnet.eu -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, 172; hammy, 78; neutral, 70; 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=0802e14cf1=alex@digriz.org.uk) smtp.mail=prvs=0802e14cf1=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: , This patch fixes the board to be able to use the rtc-m48t86 driver again. Signed-off-by: Alexander Clouter --- arch/arm/mach-orion5x/ts78xx-setup.c | 79 ++++++++-------------------------- 1 file changed, 18 insertions(+), 61 deletions(-) diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c index e960855..4ed4c56 100644 --- a/arch/arm/mach-orion5x/ts78xx-setup.c +++ b/arch/arm/mach-orion5x/ts78xx-setup.c @@ -16,13 +16,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include "common.h" #include "mpp.h" @@ -80,78 +80,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_resources[] = { + 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_resources, + .num_resources = ARRAY_SIZE(ts78xx_ts_rtc_resources), }; -/* - * 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)