Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936494AbcJTNCs convert rfc822-to-8bit (ORCPT ); Thu, 20 Oct 2016 09:02:48 -0400 Received: from mail1.bemta5.messagelabs.com ([195.245.231.141]:7676 "EHLO mail1.bemta5.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932543AbcJTNCp (ORCPT ); Thu, 20 Oct 2016 09:02:45 -0400 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupik+JIrShJLcpLzFFi42KJ27nUWDfjAEe Ewat2bYuZ85ewWkx9+ITNYv6Rc6wWhxe9YLSYf+Uaq8X9r0cZLb5d6WCyuPnpG6vF5V1z2Cw+ 9x5htLixbh+7xZOFZ5gsll6/yGTRuvcIkPuwj83i1owXrA4CHmvmrWH02DnrLrvHtc1iHov3v GTy2LSqk83jzrU9bB47vzewexy/sZ3J4/MmuQDOKNbMvKT8igTWjK1rXzEXLJOoOP2+n62B8a dwFyMXh5DAMkaJuTPus3cxcnKwCRhKzHvznhEkISKwi1HiyNV7rCAOs8AzZok5EzYwglQJCyR KrN6+lRnEFhFIkvi14yOUbSWx4cEbFhCbRUBV4lBzA9hUXoEAib/zljJDrDvBKDF5yTywBCdQ w8mXW8AaGAVkJb40rgYbxCwgLnHryXwmEFtCQEBiyZ7zzBC2qMTLx/9YIWx5ibW/nkDF7SVe3 3vHAmHrSzx6/IgRwjaUWDXtAFTcXOL4f4gaZgEdiQW7P7FB2NoSyxa+ZoY4VFDi5MwnLBMYxW chOWMWkpZZSFpmIWlZwMiyilGjOLWoLLVI19BEL6koMz2jJDcxM0fX0MBULze1uDgxPTUnMal YLzk/dxMjMI0wAMEOxrOnPQ8xSnIwKYnyvtnLESHEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgtdh P1BOsCg1PbUiLTMHmNBg0hIcPEoivBogad7igsTc4sx0iNQpRkUpcd6b+4ASAiCJjNI8uDZYE r3EKCslzMsIdIgQT0FqUW5mCar8K0ZxDkYlYV4tkPE8mXklcNNfAS1mAlpckwa2uCQRISXVwG iiFxarpsO2bN2jS2lfTE4tf2DNfUaJ+93OxfxRG7JP6biHMiRNmCOoW822hTtoj9LHyHMnovr Mr7Hel37gcL+11n3yDY38h8vOrXa+8vz2uY3Pdwg5L1g0L0Vod5P/oZBvx748ny74vJrp1Raf hKeXd7J3SHPo7nZ6+LJ4Sa/lhAaBDr+Mq/xKLMUZiYZazEXFiQAFulPUnQMAAA== X-Env-Sender: stwiss.opensource@diasemi.com X-Msg-Ref: server-9.tower-179.messagelabs.com!1476968552!61661538!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked From: Steve Twiss To: Keerthy , Eduardo Valentin , LINUX-KERNEL , LINUX-PM , Zhang Rui CC: DEVICETREE , Dmitry Torokhov , Guenter Roeck , LINUX-INPUT , LINUX-WATCHDOG , Lee Jones , "Liam Girdwood" , Mark Brown , Mark Rutland , Rob Herring , Support Opensource , Wim Van Sebroeck Subject: RE: [PATCH V1 05/10] thermal: da9062/61: Thermal junction temperature monitoring driver Thread-Topic: [PATCH V1 05/10] thermal: da9062/61: Thermal junction temperature monitoring driver Thread-Index: AQHSH7B3m++mOrvh0ECD7ljm7p6YrKCcZ0SAgBT8QTA= Date: Thu, 20 Oct 2016 13:02:31 +0000 Message-ID: <6ED8E3B22081A4459DAC7699F3695FB7018CCE4535@SW-EX-MBX02.diasemi.com> References: <3bc9fd76-2885-b07a-9df8-7802b7535da2@ti.com> In-Reply-To: <3bc9fd76-2885-b07a-9df8-7802b7535da2@ti.com> 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] x-kse-attachmentfiltering-interceptor-info: protection disabled x-kse-serverinfo: sw-ex-cashub02.diasemi.com, 9 x-kse-antivirus-interceptor-info: scan successful x-kse-antivirus-info: Clean, bases: 20/10/2016 11:06:00 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3083 Lines: 79 On 07 October 2016 06:29 Keerthy wrote: > On Thursday 06 October 2016 02:13 PM, Steve Twiss wrote: > > From: Steve Twiss > > > > +static int da9062_thermal_probe(struct platform_device *pdev) > > +{ > > + struct da9062 *chip = dev_get_drvdata(pdev->dev.parent); > > + struct da9062_thermal *thermal; > > + unsigned int pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD; > > + const struct of_device_id *match; > > + int ret = 0; > > + > > + match = of_match_node(da9062_compatible_reg_id_table, > > + pdev->dev.of_node); > > + if (!match) > > + return -ENXIO; > > + > > + if (pdev->dev.of_node) { > > + if (!of_property_read_u32(pdev->dev.of_node, > > + "dlg,tjunc-temp-polling-period-ms", > > + &pp_tmp)) { > > + if (pp_tmp < DA9062_MIN_POLLING_MS_PERIOD || > > + pp_tmp > DA9062_MAX_POLLING_MS_PERIOD) > > + pp_tmp = DA9062_DEFAULT_POLLING_MS_PERIOD; > > + } > > + > > + dev_dbg(&pdev->dev, > > + "TJUNC temp polling period set at %d ms\n", > > + pp_tmp); > > + } > > + > > + thermal = devm_kzalloc(&pdev->dev, sizeof(struct da9062_thermal), > > + GFP_KERNEL); > > + if (!thermal) { > > + ret = -ENOMEM; > > + goto err; > > + } > > + > > + thermal->config = match->data; > > + > > + INIT_DELAYED_WORK(&thermal->work, da9062_thermal_poll_on); > > + mutex_init(&thermal->lock); > > thermal_zone_device_register itself does > INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); > > refer: drivers/thermal/thermal_core.c > > It does a periodic monitoring of the temperature as well. Do you really > want to have an additional work for monitoring temperature in your > driver also? The thermal triggering mechanism is interrupt based and happens when the temperature rises above a given threshold level. The component cannot return an exact temperature, it only has knowledge if the temperature is above or below a given threshold value. A status bit must be polled to detect when the temperature falls below that threshold level again. If I was to use the core's polling_delay it would request get_temp() every x milliseconds. This would work: I could test the status bit to decide if the temperature was above or below the threshold, and enable or disable the interrupt accordingly. But during normal operation, when the temperature is in the normal range, I would be polling through I2C every x milliseconds instead of just waiting for an IRQ trigger event before starting my polling operations to detect when the temperature level fell below the threshold. Since an over-temperature is supposed to be a very rare event, I decided to go with the IRQ based trigger and then kick-off a separate work-queue to poll the status bit and detect when the temperature dropped below the threshold level. This seemed a more efficient way of handling this. I have looked through thermal core, and there doesn't seem to be an obvious way of toggling on/off thermal core polling when I need to poll the temperature through get_temp(). So, I was going to stick with this method for PATCH V2. Regards, Steve