From patchwork Wed Jun 17 18:58:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 6627801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 123F9C0020 for ; Wed, 17 Jun 2015 19:19:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2270D207E8 for ; Wed, 17 Jun 2015 19:19:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 205C3207B9 for ; Wed, 17 Jun 2015 19:19:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5IpY-0006HO-Eh; Wed, 17 Jun 2015 19:17:00 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5IpU-0006G0-QG for linux-arm-kernel@bombadil.infradead.org; Wed, 17 Jun 2015 19:16:56 +0000 Received: from mail-pa0-f48.google.com ([209.85.220.48]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z5IaZ-0001Fq-QG for linux-arm-kernel@lists.infradead.org; Wed, 17 Jun 2015 19:01:32 +0000 Received: by pacyx8 with SMTP id yx8so42430587pac.2 for ; Wed, 17 Jun 2015 12:01:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EpqYMkYFSfFzpC59S88imFnM6jQjl40UIvagGpnwsWQ=; b=RDJrPCIwJCJrXcYJp6GGEjTgcpLGei2kz88/ELa3Cjr26nDFSs5a+dWu4qSjdE0UP3 lZ45aNw33cf+NH0mNEUkTHlBRJtdCTL4fbVRn66QcaL/oTgJ3Qnt2S2mObx91vduMrTy QJ0LHIZrBYZr923TMFDZ8SAGC8MQCi+rI0DjD1sHgjfKgTU/TBk1hb68QZ5yJ9ty/BSW D2jSMAMKiWPok0IBHPFpGbLBmtTs0YtiiVZOtda9OCqGHM0CjhfiFYTSyTe55YHubUDb UNTInD3Ujt0uvmBte2nGuCtS+SuTicuPZWhIxSgjUXmE7mgvqOOdTvWFSknk3PCboWmZ rShA== X-Gm-Message-State: ALoCoQk9ivWytazyGxZ/djoV2mL9o8+kquoOjJTIY6duF1eAtMuAYwZ84iF5zV5yjs0cGXlg/OWZ X-Received: by 10.66.62.202 with SMTP id a10mr8342109pas.42.1434567669601; Wed, 17 Jun 2015 12:01:09 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by mx.google.com with ESMTPSA id y1sm5521122pdy.2.2015.06.17.12.01.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Jun 2015 12:01:08 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Subject: [PATCH-v2] rtc: 88pm80x: add device tree support Date: Thu, 18 Jun 2015 00:28:06 +0530 Message-Id: <1434567488-6477-3-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434567488-6477-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1434567488-6477-1-git-send-email-vaibhav.hiremath@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150617_200131_989769_0BB70983 X-CRM114-Status: GOOD ( 13.45 ) X-Spam-Score: -2.6 (--) Cc: devicetree@vger.kernel.org, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, Vaibhav Hiremath , robh+dt@kernel.org, Chao Xie , lee.jones@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Along with DT support, this patch also cleans up the unnecessary code around 'rtc_wakeup' initialization. Signed-off-by: Chao Xie Signed-off-by: Vaibhav Hiremath --- Link to V1: https://lkml.org/lkml/2015/5/29/757 drivers/rtc/rtc-88pm80x.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c index 7df0579..8f66519 100644 --- a/drivers/rtc/rtc-88pm80x.c +++ b/drivers/rtc/rtc-88pm80x.c @@ -251,17 +251,26 @@ static SIMPLE_DEV_PM_OPS(pm80x_rtc_pm_ops, pm80x_rtc_suspend, pm80x_rtc_resume); static int pm80x_rtc_probe(struct platform_device *pdev) { struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct pm80x_platform_data *pm80x_pdata = - dev_get_platdata(pdev->dev.parent); - struct pm80x_rtc_pdata *pdata = NULL; + struct pm80x_rtc_pdata *pdata = dev_get_platdata(&pdev->dev); struct pm80x_rtc_info *info; + struct device_node *node = pdev->dev.of_node; struct rtc_time tm; unsigned long ticks = 0; int ret; - pdata = dev_get_platdata(&pdev->dev); - if (pdata == NULL) - dev_warn(&pdev->dev, "No platform data!\n"); + if (!pdata && !node) { + dev_err(&pdev->dev, + "pm80x-rtc requires platform data or of_node\n"); + return -EINVAL; + } + + if (!pdata) { + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(&pdev->dev, "failed to allocate memory\n"); + return -ENOMEM; + } + } info = devm_kzalloc(&pdev->dev, sizeof(struct pm80x_rtc_info), GFP_KERNEL); @@ -327,11 +336,8 @@ static int pm80x_rtc_probe(struct platform_device *pdev) regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_RTC1_USE_XO, PM800_RTC1_USE_XO); - if (pm80x_pdata) { - pdata = pm80x_pdata->rtc; - if (pdata) - info->rtc_dev->dev.platform_data = &pdata->rtc_wakeup; - } + /* remeber whether this power up is caused by PMIC RTC or not */ + info->rtc_dev->dev.platform_data = &pdata->rtc_wakeup; device_init_wakeup(&pdev->dev, 1);