From patchwork Thu Mar 16 17:51:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Brandt X-Patchwork-Id: 739929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qk0-x239.google.com (mail-qk0-x239.google.com [IPv6:2607:f8b0:400d:c09::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vkbdL5Nx6z9s0g for ; Fri, 17 Mar 2017 04:51:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="eJCMhETz"; dkim-atps=neutral Received: by mail-qk0-x239.google.com with SMTP id 23sf30784411qke.1 for ; Thu, 16 Mar 2017 10:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=8zfWEkb8qRqVA4ehJ/YefMC1ljN6N91aOm/z5PA1xBM=; b=eJCMhETzz9595OUHfVEJowgM/j9vytKDTN9Q8MoBa95Yjl+Qq3vHPdMc3LQB3tD9AX 2yZSJQlvyzeGvMk0tsSiWoTfBLlJNy7b9TPqBnBpH5ZZySDs1IBwzW/3pLc9WtPucNFU fz+qfGwTx5qqMK9Us+N6vf6tak99/O17cuZg5qrMEBSrHvymWejdcrS8rS8aIO6X3W5g ShfOOmSFy5SDo07LAZFN06eLg2xdA7/a4sMqFSwsX0UD7EsAQqrosNDtzcSpAvFB+1JZ RXZWzTh+++BuAtaNC3wRU4PWSSqUFJqSM5n07dL9Z0v85I0au7JoXihpY60/xmAhWWlE Oobw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=8zfWEkb8qRqVA4ehJ/YefMC1ljN6N91aOm/z5PA1xBM=; b=ElNBzNNnuofDMMLZuebyJdAk0D2bJSCNbhaksvqbl8ry/+93Yi4/AX3UlKGmoL0EzP Tuj5+QJIoP+ZK607AnorUuA9dl7CXY9frxWCyFY0rkIUZeJI3PsFYfad14pDUVRieDAJ nGQhHLrzuvUWjDF8TVw2/Y3xgqDTYmG5GTiA572zdbAWO78NvKOW96BldTCNKnoLfnVm ySY29zkc0q8LeLGyVO+dL6RIEVozJ2otuVb/SEveefZevOcXz7zdTSB+mTTgv3LFAwDU 5Bco1WOvizKbGALsBig/eb+Z+KueiTKWEmL498ONBaGUKbBq5EtjRbPZ7PqZW3tyR/M3 LIGA== Sender: rtc-linux@googlegroups.com X-Gm-Message-State: AFeK/H2xyHxokHCtTuzeqRdy2W1u/sfa41i8w431aMFgttBfSb7JZ1d7plIPDBke1e6Y0w== X-Received: by 10.157.22.200 with SMTP id s8mr1269127ots.16.1489686708902; Thu, 16 Mar 2017 10:51:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.157.30.168 with SMTP id n37ls5862961otn.25.gmail; Thu, 16 Mar 2017 10:51:48 -0700 (PDT) X-Received: by 10.157.27.231 with SMTP id v36mr4579276otv.125.1489686708468; Thu, 16 Mar 2017 10:51:48 -0700 (PDT) Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com. [210.160.252.173]) by gmr-mx.google.com with ESMTP id g82si1022444pfb.5.2017.03.16.10.51.47 for ; Thu, 16 Mar 2017 10:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of chris.brandt@renesas.com designates 210.160.252.173 as permitted sender) client-ip=210.160.252.173; Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 17 Mar 2017 02:51:46 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id AB5553C29A; Fri, 17 Mar 2017 02:51:46 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 8E403480A5; Fri, 17 Mar 2017 02:51:46 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 86D9C48014; Fri, 17 Mar 2017 02:51:46 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id CAB17231; Fri, 17 Mar 2017 02:51:46 +0900 X-IronPort-AV: E=Sophos;i="5.36,173,1486393200"; d="scan'208";a="236898182" Received: from unknown (HELO rtamta01.rta.renesas.com) ([143.103.48.75]) by relmlii1.idc.renesas.com with ESMTP; 17 Mar 2017 02:51:45 +0900 Received: from localhost.localdomain (unknown [143.103.58.85]) by rtamta01.rta.renesas.com (Postfix) with ESMTP id 6B270560; Thu, 16 Mar 2017 17:51:39 +0000 (UTC) From: Chris Brandt To: Alessandro Zummo , Alexandre Belloni , Rob Herring , Mark Rutland , Simon Horman , Geert Uytterhoeven Cc: rtc-linux@googlegroups.com, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Chris Brandt Subject: [rtc-linux] [PATCH 1/5] rtc: rtc-sh: add support for rza series Date: Thu, 16 Mar 2017 13:51:08 -0400 Message-Id: <20170316175112.27913-2-chris.brandt@renesas.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170316175112.27913-1-chris.brandt@renesas.com> References: <20170316175112.27913-1-chris.brandt@renesas.com> X-Original-Sender: chris.brandt@renesas.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of chris.brandt@renesas.com designates 210.160.252.173 as permitted sender) smtp.mailfrom=chris.brandt@renesas.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-Spam-Checked-In-Group: rtc-linux@googlegroups.com X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This same RTC is used in RZ/A series MPUs, therefore with some slight changes, this driver can be reused. Additionally, since ARM architectures require Device Tree configurations, device tree support has been added. Signed-off-by: Chris Brandt Reviewed-by: Geert Uytterhoeven --- drivers/rtc/Kconfig | 4 ++-- drivers/rtc/rtc-sh.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index ee1b0e9..77d1495 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1303,10 +1303,10 @@ config RTC_DRV_SA1100 config RTC_DRV_SH tristate "SuperH On-Chip RTC" - depends on SUPERH && HAVE_CLK + depends on (SUPERH || ARCH_RENESAS) && HAVE_CLK help Say Y here to enable support for the on-chip RTC found in - most SuperH processors. + most SuperH processors. This RTC is also found in RZ/A SoCs. To compile this driver as a module, choose M here: the module will be called rtc-sh. diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index c626e43..2ef4ac7 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -27,7 +27,15 @@ #include #include #include +#ifdef CONFIG_SUPERH #include +#else +/* Default values for RZ/A RTC */ +#define rtc_reg_size sizeof(u16) +#define RTC_BIT_INVERTED 0 /* no chip bugs */ +#define RTC_CAP_4_DIGIT_YEAR (1 << 0) +#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR +#endif #define DRV_NAME "sh-rtc" @@ -570,6 +578,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) rtc->alarm_irq = platform_get_irq(pdev, 2); res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (res == NULL) + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (unlikely(res == NULL)) { dev_err(&pdev->dev, "No IO resource\n"); return -ENOENT; @@ -608,6 +618,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) clk_enable(rtc->clk); rtc->capabilities = RTC_DEF_CAPABILITIES; + +#ifdef CONFIG_SUPERH if (dev_get_platdata(&pdev->dev)) { struct sh_rtc_platform_info *pinfo = dev_get_platdata(&pdev->dev); @@ -618,6 +630,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) */ rtc->capabilities |= pinfo->capabilities; } +#endif if (rtc->carry_irq <= 0) { /* register shared periodic/carry/alarm irq */ @@ -738,10 +751,17 @@ static int sh_rtc_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(sh_rtc_pm_ops, sh_rtc_suspend, sh_rtc_resume); +static const struct of_device_id sh_rtc_of_match[] = { + { .compatible = "renesas,sh-rtc", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, sh_rtc_of_match); + static struct platform_driver sh_rtc_platform_driver = { .driver = { .name = DRV_NAME, .pm = &sh_rtc_pm_ops, + .of_match_table = sh_rtc_of_match, }, .remove = __exit_p(sh_rtc_remove), };