From patchwork Thu Apr 30 11:26:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Twiss X-Patchwork-Id: 6302071 Return-Path: X-Original-To: patchwork-linux-input@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 CB104BEEE1 for ; Thu, 30 Apr 2015 11:33:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6C04201EC for ; Thu, 30 Apr 2015 11:33:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B316B200E9 for ; Thu, 30 Apr 2015 11:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751948AbbD3Ldf (ORCPT ); Thu, 30 Apr 2015 07:33:35 -0400 Received: from mail1.bemta5.messagelabs.com ([195.245.231.144]:50813 "EHLO mail1.bemta5.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbbD3Ldb (ORCPT ); Thu, 30 Apr 2015 07:33:31 -0400 Received: from [85.158.139.35] by server-8.bemta-5.messagelabs.com id B0/0B-19484-BF212455; Thu, 30 Apr 2015 11:33:15 +0000 X-Env-Sender: stwiss.opensource@diasemi.com X-Msg-Ref: server-13.tower-179.messagelabs.com!1430393580!38732102!1 X-Originating-IP: [82.210.246.133] X-StarScan-Received: X-StarScan-Version: 6.13.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27514 invoked from network); 30 Apr 2015 11:33:00 -0000 Received: from mailrelay1.diasemi.com (HELO NB-EX-CASHUB01.diasemi.com) (82.210.246.133) by server-13.tower-179.messagelabs.com with AES128-SHA encrypted SMTP; 30 Apr 2015 11:33:00 -0000 Received: from mailrelay1.diasemi.com (10.1.17.243) by NB-EX-CASHUB01.diasemi.com (10.1.16.140) with Microsoft SMTP Server id 14.3.181.6; Thu, 30 Apr 2015 13:33:00 +0200 Received: from swsrvapps-01.diasemi.com (Not Verified[10.20.28.141]) by mailrelay1.diasemi.com with ESMTP Gateway id ; Thu, 30 Apr 2015 13:32:59 +0200 Received: (from stwiss@localhost) by swsrvapps-01.diasemi.com (8.14.3/8.14.3/Submit/Dlg) id t3UBWxhE029375; Thu, 30 Apr 2015 12:32:59 +0100 X-Authentication-Warning: swsrvapps-01.diasemi.com: stwiss set sender to stwiss.opensource@diasemi.com using -f Message-ID: <639fd177d5ddd4ce80df45f9d774cc971b286ef9.1430393194.git.stwiss.opensource@diasemi.com> In-Reply-To: References: From: S Twiss Date: Thu, 30 Apr 2015 12:26:34 +0100 Subject: [PATCH V3 3/3] mfd: da9063: MFD support for OnKey driver To: Lee Jones , Samuel Ortiz , Steve Twiss CC: DT , David Dajun Chen , Dmitry Torokhov , INPUT , Ian Campbell , Kumar Gala , LKML , Mark Rutland , Pawel Moll , Rob Herring , Support Opensource MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: 68589ee3-dc76-43d0-9079-ac9e3637ce03 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Steve Twiss Add MFD support for the DA9063 OnKey driver Signed-off-by: Steve Twiss --- Version History Changes in V3 - The MFD code was originally in [PATCH V2 1/2]. This is now been moved into this patch [PATCH V3 3/3]. - Whitespace cleanup This patch applies against linux-next and v4.1-rc1 drivers/mfd/da9063-core.c | 54 ++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/da9063/pdata.h | 1 + 2 files changed, 55 insertions(+) diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c index facd361..af841c1 100644 --- a/drivers/mfd/da9063-core.c +++ b/drivers/mfd/da9063-core.c @@ -60,6 +60,7 @@ static struct resource da9063_rtc_resources[] = { static struct resource da9063_onkey_resources[] = { { + .name = "ONKEY", .start = DA9063_IRQ_ONKEY, .end = DA9063_IRQ_ONKEY, .flags = IORESOURCE_IRQ, @@ -97,6 +98,7 @@ static const struct mfd_cell da9063_devs[] = { .name = DA9063_DRVNAME_ONKEY, .num_resources = ARRAY_SIZE(da9063_onkey_resources), .resources = da9063_onkey_resources, + .of_compatible = "dlg,da9063-onkey", }, { .name = DA9063_DRVNAME_RTC, @@ -109,12 +111,64 @@ static const struct mfd_cell da9063_devs[] = { }, }; +static int da9063_clear_fault_log(struct da9063 *da9063) +{ + int ret = 0; + int fault_log = 0; + + ret = regmap_read(da9063->regmap, DA9063_REG_FAULT_LOG, &fault_log); + if (ret < 0) { + dev_err(da9063->dev, "Cannot read FAULT_LOG.\n"); + return -EIO; + } + + if (fault_log) { + if (fault_log & DA9063_TWD_ERROR) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_TWD_ERROR\n"); + if (fault_log & DA9063_POR) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_POR\n"); + if (fault_log & DA9063_VDD_FAULT) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_VDD_FAULT\n"); + if (fault_log & DA9063_VDD_START) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_VDD_START\n"); + if (fault_log & DA9063_TEMP_CRIT) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_TEMP_CRIT\n"); + if (fault_log & DA9063_KEY_RESET) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_KEY_RESET\n"); + if (fault_log & DA9063_NSHUTDOWN) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_NSHUTDOWN\n"); + if (fault_log & DA9063_WAIT_SHUT) + dev_dbg(da9063->dev, + "Fault log entry detected: DA9063_WAIT_SHUT\n"); + } + + ret = regmap_write(da9063->regmap, + DA9063_REG_FAULT_LOG, + fault_log); + if (ret < 0) + dev_err(da9063->dev, + "Cannot reset FAULT_LOG values %d\n", ret); + + return ret; +} + int da9063_device_init(struct da9063 *da9063, unsigned int irq) { struct da9063_pdata *pdata = da9063->dev->platform_data; int model, variant_id, variant_code; int ret; + ret = da9063_clear_fault_log(da9063); + if (ret < 0) + dev_err(da9063->dev, "Cannot clear fault log\n"); + if (pdata) { da9063->flags = pdata->flags; da9063->irq_base = pdata->irq_base; diff --git a/include/linux/mfd/da9063/pdata.h b/include/linux/mfd/da9063/pdata.h index 95c8742..612383b 100644 --- a/include/linux/mfd/da9063/pdata.h +++ b/include/linux/mfd/da9063/pdata.h @@ -103,6 +103,7 @@ struct da9063; struct da9063_pdata { int (*init)(struct da9063 *da9063); int irq_base; + bool key_power; unsigned flags; struct da9063_regulators_pdata *regulators_pdata; struct led_platform_data *leds_pdata;