From patchwork Mon Oct 31 20:39:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 689638 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-lf0-x240.google.com (mail-lf0-x240.google.com [IPv6:2a00:1450:4010:c07::240]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t76196hdlz9vDl for ; Tue, 1 Nov 2016 07:49:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b=X5tr/OBq; dkim-atps=neutral Received: by mail-lf0-x240.google.com with SMTP id o20sf8834169lfg.0 for ; Mon, 31 Oct 2016 13:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; 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=3Zxy6Ebrun0q0wf5VmBbRj+fOaRGcXuixnwuaCfypk0=; b=X5tr/OBqxTUAAZVKdzAmbV6HldZo6nkmM0uvM0f2UZHdZZbGVUoq/GIFRBuDh7x2D1 zUnLC4mx1BcFpgijJ+NUvu5KqwDUfhXgKzsN4A01MkMR4fk2FJCxOx2YEXyKJmX1mTVX EBHey+noIcKXn2LSsTOuSMkWhfq8dx1kTiDklTJSWiGwsjf11ZaXL+BTMb3SajhHUbgi 9/CUW7MGwotUfkpr6YJHh30RxMB0PKi+tx5VM5mXYcE8KRqg+7QzACbx74zZJx65Fp76 K6+jOULJlZt5cNn6g9uwwhnpYEzKekCvB2hMKA9JJm4YscWQ4Rt2PpmdcNC417KrA4z/ QJgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; 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=3Zxy6Ebrun0q0wf5VmBbRj+fOaRGcXuixnwuaCfypk0=; b=fY5rdNw6rzy+0EikXdoyW3N93k+BWUZfndINlToj3URJKDMVHsen+IWnx1ZOqLW/0Y kEMvgfqo4jMCs/w17CTxPVC5h7+drSqaX54KTwWLb5HLSLNKSrsJJ2co6MbwV3kE1yCX +LPmadCdc+W5AxAzJLvD/SaQV4ZdM6GLZCGIbYKeeKz7L4hebr+deU1EBc7PHirgSb5G /I/kRHDJe/m0GfhZvTsRxstCvGA0wxLOcNCJPl28D43QT+5GeuU6chAQhxXNl3dMed8W eI8PQ4cAMuEIQs22gju8rAAtpdxMvw0nwizTT5prhcmqkZImevTp3aVBDOwSZgHnjoGt SgmQ== Sender: rtc-linux@googlegroups.com X-Gm-Message-State: ABUngvcG5cU2JD6UikgX8mJA6Ye2N3t3QAi3fnNSsgbyO0g+igZG3dQMyilLMkpdVBZb3Q== X-Received: by 10.25.15.201 with SMTP id 70mr49861lfp.4.1477946446838; Mon, 31 Oct 2016 13:40:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.25.18.68 with SMTP id h65ls143429lfi.46.gmail; Mon, 31 Oct 2016 13:40:46 -0700 (PDT) X-Received: by 10.25.221.130 with SMTP id w2mr2208377lfi.8.1477946446428; Mon, 31 Oct 2016 13:40:46 -0700 (PDT) Received: from outils.crapouillou.net (outils.crapouillou.net. [89.234.176.41]) by gmr-mx.google.com with ESMTPS id f4si2288481wmf.1.2016.10.31.13.40.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 13:40:46 -0700 (PDT) Received-SPF: pass (google.com: domain of paul@outils.crapouillou.net designates 89.234.176.41 as permitted sender) client-ip=89.234.176.41; From: Paul Cercueil To: rtc-linux@googlegroups.com, Alessandro Zummo , Alexandre Belloni , Rob Herring , Mark Rutland , Ralf Baechle , Maarten ter Huurne , Lars-Peter Clausen , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org Cc: Paul Cercueil Subject: [rtc-linux] [PATCH v3 3/7] rtc: rtc-jz4740: Add support for devicetree Date: Mon, 31 Oct 2016 21:39:47 +0100 Message-Id: <20161031203951.5444-3-paul@crapouillou.net> In-Reply-To: <20161031203951.5444-1-paul@crapouillou.net> References: <20161030230247.20538-1-paul@crapouillou.net> <20161031203951.5444-1-paul@crapouillou.net> X-Original-Sender: paul@crapouillou.net X-Original-Authentication-Results: gmr-mx.google.com; dkim=temperror (no key for signature) header.i=@crapouillou.net; spf=pass (google.com: domain of paul@outils.crapouillou.net designates 89.234.176.41 as permitted sender) smtp.mailfrom=paul@outils.crapouillou.net 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: , See Documentation/devicetree/bindings/rtc/ingenic,jz4740-rtc.txt for a description of the bindings. Signed-off-by: Paul Cercueil Acked-by: Maarten ter Huurne --- drivers/rtc/rtc-jz4740.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) v2: No change v3: No change diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c index c616efe..4213554 100644 --- a/drivers/rtc/rtc-jz4740.c +++ b/drivers/rtc/rtc-jz4740.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -245,6 +246,13 @@ void jz4740_rtc_poweroff(struct device *dev) } EXPORT_SYMBOL_GPL(jz4740_rtc_poweroff); +static const struct of_device_id jz4740_rtc_of_match[] = { + { .compatible = "ingenic,jz4740-rtc", .data = (void *) ID_JZ4740 }, + { .compatible = "ingenic,jz4780-rtc", .data = (void *) ID_JZ4780 }, + {}, +}; +MODULE_DEVICE_TABLE(of, jz4740_rtc_of_match); + static int jz4740_rtc_probe(struct platform_device *pdev) { int ret; @@ -252,12 +260,17 @@ static int jz4740_rtc_probe(struct platform_device *pdev) uint32_t scratchpad; struct resource *mem; const struct platform_device_id *id = platform_get_device_id(pdev); + const struct of_device_id *of_id = of_match_device( + jz4740_rtc_of_match, &pdev->dev); rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); if (!rtc) return -ENOMEM; - rtc->type = id->driver_data; + if (of_id) + rtc->type = (enum jz4740_rtc_type) of_id->data; + else + rtc->type = id->driver_data; rtc->irq = platform_get_irq(pdev, 0); if (rtc->irq < 0) { @@ -345,6 +358,7 @@ static struct platform_driver jz4740_rtc_driver = { .driver = { .name = "jz4740-rtc", .pm = JZ4740_RTC_PM_OPS, + .of_match_table = of_match_ptr(jz4740_rtc_of_match), }, .id_table = jz4740_rtc_ids, };