From patchwork Mon Jun 18 09:29:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9383 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3501523F19 for ; Mon, 18 Jun 2012 09:29:46 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id F2580A1855B for ; Mon, 18 Jun 2012 09:29:45 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so3902905yhp.11 for ; Mon, 18 Jun 2012 02:29:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=h3Yclj1mlwM9yv1ckQMzVwV+a+XG+crRb3xqU4zEP78=; b=A3vkNrjsY9Su5YtAXL2WoYKJ6cgq19JhVIYXQMJ0tHgf8f7RLdOQYNPYJVljArMFaj C5VN+Nmimqu180U9fFkPTvE/iKzg9CwWyF6TR0CxbeqzlKsUl/sjvap347UIyQ3Ro1ji 2oh4eCV9yAPRgh2hdHniE3P5tFIwr8/SmgfhSgc70Cd7rgKnteWeII+fkRax/ci0yEsH SSi0T2FQFRTKjX+LOuIUcEj1hxLjJf0S841uz9xmDceyyi3V9JTmNTJTBH2zRr8Wa9wf JJeIVSoACt6NfDxtwdU+g8K5EEsxF62nr9eHAyRZoY0nhqC7YSfmFQnRgEhO/5kgDJxM dqsw== Received: by 10.50.46.232 with SMTP id y8mr7641650igm.57.1340011785593; Mon, 18 Jun 2012 02:29:45 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp56539ibb; Mon, 18 Jun 2012 02:29:44 -0700 (PDT) Received: by 10.14.185.137 with SMTP id u9mr3520334eem.220.1340011784138; Mon, 18 Jun 2012 02:29:44 -0700 (PDT) Received: from eu1sys200aog109.obsmtp.com (eu1sys200aog109.obsmtp.com. [207.126.144.127]) by mx.google.com with SMTP id v8si8242548eem.12.2012.06.18.02.29.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 02:29:44 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.127 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.127; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.127 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob109.postini.com ([207.126.147.11]) with SMTP ID DSNKT970+smNILcgaspzQjR9Os5EPi/wQvrq@postini.com; Mon, 18 Jun 2012 09:29:43 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 603B9137; Mon, 18 Jun 2012 09:29:06 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id F099E2755; Mon, 18 Jun 2012 09:29:05 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 54C4324C2F5; Mon, 18 Jun 2012 11:29:00 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 18 Jun 2012 11:29:05 +0200 From: Linus Walleij To: Andrew Morton Cc: Alessandro Zummo , , Linus Walleij Subject: [PATCH 2/3] rtc: pl031: use per-vendor variables for special init Date: Mon, 18 Jun 2012 11:29:03 +0200 Message-ID: <1340011743-5076-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQk9X4O3VgycPZMS3IhIHt/PQAao9r8G/KiYNNFDHtN+15wF4CXpXy/rsVZhYdSzz+H+Pv4T From: Linus Walleij Instead of hard-checking for certain vendor codes, follow the pattern of other AMBA (PrimeCell) drivers and use variables in the vendor data. Get rid of the locally cached vendor and hardware revision since we already have the nice vendor data variable in the state. Signed-off-by: Linus Walleij --- drivers/rtc/rtc-pl031.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 575fbbf..e66afb8 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -71,17 +71,21 @@ /** * struct pl031_vendor_data - per-vendor variations * @ops: the vendor-specific operations used on this silicon version + * @clockwatch: if this is an ST Microelectronics silicon version with a + * clockwatch function + * @st_weekday: if this is an ST Microelectronics silicon version that need + * the weekday fix */ struct pl031_vendor_data { struct rtc_class_ops ops; + bool clockwatch; + bool st_weekday; }; struct pl031_local { struct pl031_vendor_data *vendor; struct rtc_device *rtc; void __iomem *base; - u8 hw_designer; - u8 hw_revision:4; }; static int pl031_alarm_irq_enable(struct device *dev, @@ -336,14 +340,11 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) amba_set_drvdata(adev, ldata); - ldata->hw_designer = amba_manf(adev); - ldata->hw_revision = amba_rev(adev); - - dev_dbg(&adev->dev, "designer ID = 0x%02x\n", ldata->hw_designer); - dev_dbg(&adev->dev, "revision = 0x%01x\n", ldata->hw_revision); + dev_dbg(&adev->dev, "designer ID = 0x%02x\n", amba_manf(adev)); + dev_dbg(&adev->dev, "revision = 0x%01x\n", amba_rev(adev)); /* Enable the clockwatch on ST Variants */ - if (ldata->hw_designer == AMBA_VENDOR_ST) + if (vendor->clockwatch) writel(readl(ldata->base + RTC_CR) | RTC_CR_CWEN, ldata->base + RTC_CR); @@ -351,7 +352,7 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) * On ST PL031 variants, the RTC reset value does not provide correct * weekday for 2000-01-01. Correct the erroneous sunday to saturday. */ - if (ldata->hw_designer == AMBA_VENDOR_ST) { + if (vendor->st_weekday) { if (readl(ldata->base + RTC_YDR) == 0x2000) { time = readl(ldata->base + RTC_DR); if ((time & @@ -413,6 +414,8 @@ static struct pl031_vendor_data stv1_pl031 = { .set_alarm = pl031_set_alarm, .alarm_irq_enable = pl031_alarm_irq_enable, }, + .clockwatch = true, + .st_weekday = true, }; /* And the second ST derivative */ @@ -424,6 +427,8 @@ static struct pl031_vendor_data stv2_pl031 = { .set_alarm = pl031_stv2_set_alarm, .alarm_irq_enable = pl031_alarm_irq_enable, }, + .clockwatch = true, + .st_weekday = true, }; static struct amba_id pl031_ids[] = {