Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030866AbbEEIgQ (ORCPT ); Tue, 5 May 2015 04:36:16 -0400 Received: from mail1.bemta3.messagelabs.com ([195.245.230.170]:48045 "EHLO mail1.bemta3.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965631AbbEEIgL (ORCPT ); Tue, 5 May 2015 04:36:11 -0400 X-Env-Sender: stwiss.opensource@diasemi.com X-Msg-Ref: server-6.tower-38.messagelabs.com!1430814966!18656298!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 6.13.14; banners=-,-,- X-VirusChecked: Checked From: "Opensource [Steve Twiss]" To: Geert Uytterhoeven , "Opensource [Steve Twiss]" CC: Lee Jones , Samuel Ortiz , DT , David Dajun Chen , Dmitry Torokhov , INPUT , Ian Campbell , Kumar Gala , LKML , "Mark Rutland" , Pawel Moll , Rob Herring , Support Opensource Subject: RE: [PATCH V3 3/3] mfd: da9063: MFD support for OnKey driver Thread-Topic: [PATCH V3 3/3] mfd: da9063: MFD support for OnKey driver Thread-Index: AQHQgzlq4anvgT4LkkaYcKjBlHUWE51rZbaAgAGo5IA= Date: Tue, 5 May 2015 08:36:05 +0000 Message-ID: <6ED8E3B22081A4459DAC7699F3695FB7014B219017@SW-EX-MBX02.diasemi.com> References: <639fd177d5ddd4ce80df45f9d774cc971b286ef9.1430393194.git.stwiss.opensource@diasemi.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.20.26.77] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id t458aKPP001046 Content-Length: 4605 Lines: 108 On 04 May 2015 08:47, Geert Uytterhoeven wrote: > On Thu, Apr 30, 2015 at 1:26 PM, S Twiss > wrote: > > Add MFD support for the DA9063 OnKey driver > > Thanks for your patch! > > > +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; > > The code above doesn't seem to match the patch description. > Can you please explain why it is needed? > Hi Geert, Yes, at first it does seem that the fault-log clearing function is unrelated to the "MFD support for the DA9063 OnKey driver", but there is an important connection that makes it essential for the OnKey driver in this case. I have made some explanation of the OnKey's operation in this thread here: https://lkml.org/lkml/2015/4/29/406 But I only described the OnKey's point-of-view for case (4) of the "OnKey operation" Case (4): the long-long press and no key release -- the hardware power-cut when software is unable to respond (for whatever reason). In this case, if the software was not responsive and a hardware shutdown of the device was chosen, the FAULT_LOG would persist with information that would be accessible when the device was restarted: it would be possible to take action the next time the device was turned on again (maybe to trigger some mitigation exercise in the bootloader -- e.g. say to complete memory checks or put the device into a safe mode). However this mitigation exercise and clearance of the fault-log cannot be counted on outside the Linux kernel and so the clearance function da9063_clear_fault_log () has been done here. If this clearance function did not exist, then after a hardware shutdown (due to S/W failure), the next time the device is restarted the FAULT_LOG would persist with values from the previous error. Regards, Steve ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?