Received: by 10.213.65.68 with SMTP id h4csp3781347imn; Tue, 3 Apr 2018 10:31:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx48DgkLlfrHL1GXitjiLDK95AFWfHFtosNNwwuuqPtaf30+U+Mu1XFtekKe5l14FQOneC2ED X-Received: by 10.98.201.70 with SMTP id k67mr11193400pfg.141.1522776670735; Tue, 03 Apr 2018 10:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522776670; cv=none; d=google.com; s=arc-20160816; b=VohdTM89S/KubMInmKjslUW+sM7XNbb1HomUt4x6XobJ2dOGSbFKYhoIk19Kr0Yz7l u72iTC7rRR4E+fj+Q/QvnFqde3BUsJ6PsBA4xdkGLuz4ZKif+jmnRHFvzskCG91hWAne 8n0NxIdpqU8xw2COwUQ+ts4lPd/RdETea85GzCbt2lFoSZie8BCJ+Fm4+JkEOMpfSqH1 bI9BUlksXUXUVH+sVw4+bpORJ8vmH9qpyqunrkavYg36lEsnFineiPEjXdty0GxCsqKY GbcuPwbcQDA8PVmWfVMBVsWHnl8H1DxDS3iHpGcayEvDmAJcXLu1uJTUGL4YVUbjyPMu SeRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=YYzWbE3M2L5wxnuPqHguWUhsI3N9aJJIy3nXZ6kYzm0=; b=tTtsvwrnDr2pevPvC+EM3/yTuPeCFjxF23mxL4syviF30ENABPhJGodwU9eZ84XOWK 2wwknf4Ybc38t2yWw0gwh+akvXX2hseHITo4CJSMvX/ZGc+Gzl63KZBN2DMjd33TRQXu q5Wd2fPZo7YlrwYCcdry+UgTrQdiCwIBfHU0DlWAuDB809fQvHKBDuhxhcSMIn4r5X6Q bS2IDe/payGw+JPkhYLPQ3nr8lNSRJvMBrwogjOSJWJGiXgp9PgyoIMhQ/Htr/2h5+UD AYw6CCcTIYahN64DYTeic0StPaEoE1h/LF+/MxW53s7Pp/aaRUuSQFkRycTR0R3+EXrm AXmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=a1bUMlaS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3-v6si917282pli.274.2018.04.03.10.30.56; Tue, 03 Apr 2018 10:31:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=a1bUMlaS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752246AbeDCR3t (ORCPT + 99 others); Tue, 3 Apr 2018 13:29:49 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:36446 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbeDCR3q (ORCPT ); Tue, 3 Apr 2018 13:29:46 -0400 Received: by mail-wr0-f178.google.com with SMTP id y55so19484220wry.3 for ; Tue, 03 Apr 2018 10:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=YYzWbE3M2L5wxnuPqHguWUhsI3N9aJJIy3nXZ6kYzm0=; b=a1bUMlaSZeNofasBoMOcIskVy8l8mDoFjRLV5BO33jZsunsEVn3HAZBwQQzTImQ+P4 /H2gflTOrFAbZSlNNSPqzL3O/ZrJgUmUlv+AdkzeHnd6xywBqAF4eNu+1pkqMrDIFogV i5QL9qFJnCtICHhAHy1fD53r6HhfdTiBoGj9VJI4jOAKLPSVCy02eeq5sLlucMItb6/p OfkOIvQU7/7jQtEVhEZVaaPrhIOQbm5BsjoxRRONwxan3pFGNtE64F8FWV3FkrhsosDS sAoaJB8esKV4BVG2h9D0YWdFpg2s4qGBQveYT+rKpY/WcfknF5ofC7S1E15wUX3dMx// Q15w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=YYzWbE3M2L5wxnuPqHguWUhsI3N9aJJIy3nXZ6kYzm0=; b=XrTKkcGStm8usYijs17AQaEQwVVxpKnlAov6W/j1/VNEXGKizQhUs7xxxdtr+5MMLK tTep6+kxxQH/2BpHk97aP/vbc0HUqliUF3s7CiV7cPY3i4ya6GJQfbh7zUSFqqRcZusy ldcY9WiPpsCjhsCFd2qoPEXrFquvAtis/0QbdQ6JH0NurZE/fbel6oyGD14Tt7Z83wlz iSYDpI4pYS3MbaMeM4qjUDcxmOpNkqziN/bT06wTKPYK4+Ca+qhAvOiSNFkeGX8asqjz D/20DRVzlXfzyZ8uUPUXJ7UGHHUuNmaQLLBOR6xmFZvOYtVEtGxnB5vvvvvyN5j4UAV5 BJdw== X-Gm-Message-State: AElRT7EBhUPG6bw82IUqaxEXpaOMXnxOVdgfpMPa5UqBByQZu92ruP+e JpVrcCFULZCr8mKKHNGTCp4Jgm2XX14v5bHFKpXoqA== X-Received: by 10.223.224.130 with SMTP id c2mr10131623wri.220.1522776585136; Tue, 03 Apr 2018 10:29:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.6.66 with HTTP; Tue, 3 Apr 2018 10:29:44 -0700 (PDT) In-Reply-To: <20180403164715.GA5676@lunn.ch> References: <1522250043-8065-1-git-send-email-tharvey@gateworks.com> <1522250043-8065-3-git-send-email-tharvey@gateworks.com> <20180403164715.GA5676@lunn.ch> From: Tim Harvey Date: Tue, 3 Apr 2018 10:29:44 -0700 Message-ID: Subject: Re: [PATCH v3 2/4] mfd: add Gateworks System Controller core driver To: Andrew Lunn Cc: Lee Jones , Rob Herring , Mark Rutland , Mark Brown , Dmitry Torokhov , Wim Van Sebroeck , Guenter Roeck , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-watchdog@vger.kernel.org, Randy Dunlap , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 3, 2018 at 9:47 AM, Andrew Lunn wrote: > On Tue, Apr 03, 2018 at 08:48:27AM -0700, Tim Harvey wrote: >> On Wed, Mar 28, 2018 at 8:14 AM, Tim Harvey wrote: >> > The Gateworks System Controller (GSC) is an I2C slave controller >> > implemented with an MSP430 micro-controller whose firmware embeds the >> > following features: >> > - I/O expander (16 GPIO's) using PCA955x protocol >> > - Real Time Clock using DS1672 protocol >> > - User EEPROM using AT24 protocol >> > - HWMON using custom protocol >> > - Interrupt controller with tamper detect, user pushbotton >> > - Watchdog controller capable of full board power-cycle >> > - Power Control capable of full board power-cycle >> > >> > see http://trac.gateworks.com/wiki/gsc for more details >> > >> >> > + >> > +/* >> > + * gsc_powerdown - API to use GSC to power down board for a specific time >> > + * >> > + * secs - number of seconds to remain powered off >> > + */ >> > +static int gsc_powerdown(struct gsc_dev *gsc, unsigned long secs) >> > +{ >> > + int ret; >> > + unsigned char regs[4]; >> > + >> > + dev_info(&gsc->i2c->dev, "GSC powerdown for %ld seconds\n", >> > + secs); >> > + regs[0] = secs & 0xff; >> > + regs[1] = (secs >> 8) & 0xff; >> > + regs[2] = (secs >> 16) & 0xff; >> > + regs[3] = (secs >> 24) & 0xff; >> > + ret = regmap_bulk_write(gsc->regmap, GSC_TIME_ADD, regs, 4); >> > + >> > + return ret; >> > +} >> >> Any feedback on the 'powerdown' sysfs attribute that hooks to this >> function? This allows the GSC to disable the board primary power >> supply for 2^32 seconds and is often used to 'reset' the board >> although it could also be used to put the board in a power down state >> longer. I'm wondering if there is a more appropriate API for this in >> the kernel that I don't know about. > > Hi Tim > > RTC can cause wakeup when an alarm is set. It looks like the DS1672 > does not have this. But you are emulating the DS1672 right? You could > add a second emulated RTC which does support an alarm? DS3232? Andrew, Thanks for the response! An RTC alarm may indeed be a good route for the overall sleep functionality I will look into that. What about the 'reset' functionality? Is there something in the power supply API for hooking in a GPIO based power switch (in my case it would be i2c) as I would think that would be common for ATX supplies? I didn't see anything in Documentation/power. This is what led me to the restart handler idea. Ultimately when someone issues a 'reboot' I would like it to use the GSC to power-cycle the board. > >> I would also like to register a restart handler using this but I >> believe that ARM restart handlers currently can not use I2C - is that >> correct? > > There are plenty which use GPIOs, or UARTs. Not seen any which use > i2c. What do you think does not work at this point? I'll have to dig around for the e-mail thread. I recall someone else trying to implement a restart handler for something hanging off i2c and the issue was that by the time the (ARM) restart handler got called interrupts were disabled making i2c unreliable. I have hooked the ARM restart handler to my GSC powerdown in some kernels and have had mixed results. When the handler gets called from a clean 'reboot' things seem fine but if its called from some error condition that halts the kernel it seems that i2c may not be reliable anymore. Regards, Tim