From patchwork Fri May 29 22:19:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 6511711 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 767C69F38D for ; Fri, 29 May 2015 22:26:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 931C72082F for ; Fri, 29 May 2015 22:26:26 +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 AFB2B2061C for ; Fri, 29 May 2015 22:26:25 +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 1YySge-0006I7-FZ; Fri, 29 May 2015 22:23:32 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YySfT-0005fp-Cf for linux-arm-kernel@lists.infradead.org; Fri, 29 May 2015 22:22:20 +0000 Received: by pabru16 with SMTP id ru16so69605341pab.1 for ; Fri, 29 May 2015 15:21:58 -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=eL4Ag/d97Gz6IwWtGMizxpA1zY9PDQYhcbw//uznkns=; b=SUUii6ZgAQ+E4/qvSV+CXwheX9u6ry4LP+yArnLJehBoynfchzhyHXTUaJ+nlCiXUW +LZrQUY0A0goXTxV4i5QM6laVFj1ECwE9t8BtwBWhqy08uzWTe+Qg1inf6zARCt0/GRb +vtNN+rvOcEKapHW+Qt0PxDDJGYPvl0j0REVWsYWfXw1oBdPEOF9Vr8OwldUHTYKnatk kG8DnZTdc/YPGwh2f5hPUhFP9T660JRUBT2M3Cmqtgti4j+ZrBQh4/Up31IElRRSCtyM 3JS/1LzOJrFXkHYJe/dSD1RkjHP8vh2HPGZmt2yGDDWyqtlmXZairhi9zq2a2w8lj24a 7oag== X-Gm-Message-State: ALoCoQkjgBMR47SOEd/Yw37rgziLbVIhXlSK4GZZ4A6BNqm5kvPm20wvv9T3NkItC7KjyW2liULb X-Received: by 10.68.105.195 with SMTP id go3mr2238418pbb.48.1432938118138; Fri, 29 May 2015 15:21:58 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by mx.google.com with ESMTPSA id nb10sm6605761pdb.76.2015.05.29.15.21.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 May 2015 15:21:57 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/4] rtc: 88pm80x: add device tree support Date: Sat, 30 May 2015 03:49:21 +0530 Message-Id: <1432937962-4537-4-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432937962-4537-1-git-send-email-vaibhav.hiremath@linaro.org> References: <1432937962-4537-1-git-send-email-vaibhav.hiremath@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150529_152219_542308_573941EA X-CRM114-Status: GOOD ( 13.18 ) X-Spam-Score: -1.8 (-) Cc: devicetree@vger.kernel.org, sameo@linux.intel.com, rtc-linux@googlegroups.com, a.zummo@towertech.it, linux-kernel@vger.kernel.org, Vaibhav Hiremath , robh+dt@kernel.org, alexandre.belloni@free-electrons.com, 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 --- 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);