Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1295534imm; Thu, 4 Oct 2018 11:09:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV62faTz9mdmim4RASDoaNFZzY+/MyeznqA/g/UP5shRKpDa5RXElyv7ZGs9Oy2uPOu3P1AWs X-Received: by 2002:a63:4952:: with SMTP id y18-v6mr6806775pgk.32.1538676575920; Thu, 04 Oct 2018 11:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538676575; cv=none; d=google.com; s=arc-20160816; b=EozqSwJ1WIVSKTZ6oe89aAM8eTBEZ5YPqCkqX9x2abOBHYffpOdA8OSzt4ZiSfXIHw 45yO1ZOltsszeyHdxX+IgOuvEaAYRroQESk177eTGX2paHb1gDs3ABNlXuYvu8OW2FEL 9wHsyyqY3BxwZeX7RvDCdK11ap3eN/ZE2MGAuKGkNTkpNCLIDBDojl4sTnAzYi0ktaZZ alV+DnMcPCQ5tdhXwv9RxXv4mTc/cmohJzW10CvjqvVbCAL9g9yzxl66EXxDwvji3KhX eBdqwo7tk8w5lKtwWMoCs9T1V22Vora3T5W0NlwTcxH/fCIlL4hAii9K+MREQ1DekshL YqNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Rc2BejUY+DGC78oQJZ/wNVi17aLhtRmkPLlU9vHL27I=; b=wmKNc5qeRXXid32RQhZpeXk8KeIxmz/eM1nN2TD6zQgCAzt9LLpWvaiWMu9o7tk86X +PmuVsLnuSIrt8EMQiNwMejZDZAhUfv90scXtis6EvRPdSA0xVjSDO4it/COTn5iEe1d ebPhNyt52je5R20JRy/lzgMuVttZgdy7+mTlWSC8At/Vjc3eZ7jocGQLZ7nJeaDNRrmI Yb/0Z4gzV29LlnSG8828Oy9udOge/pQGQ2VhB7myEahu15qF3Hs/IPSoP+gf2aJKyccn lt0D/HI2dBDMWSfUMMCk+XsvAHdgAtAfGJ0jlUmGT/Xlf704IQBGMSg8YKXyXrN84WHA WgQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=ywXRpYIe; 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 l15-v6si4705512pgj.528.2018.10.04.11.09.20; Thu, 04 Oct 2018 11:09:35 -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=@lunn.ch header.s=20171124 header.b=ywXRpYIe; 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 S1727957AbeJEBDW (ORCPT + 99 others); Thu, 4 Oct 2018 21:03:22 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:54073 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727407AbeJEBDW (ORCPT ); Thu, 4 Oct 2018 21:03:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=Rc2BejUY+DGC78oQJZ/wNVi17aLhtRmkPLlU9vHL27I=; b=ywXRpYIeQmqC4WYSoOLZyLUNvbIQlNc+arAaz430JrAJ8Uh1jH4+RYKo9S753+u30vMr6eANDVBL3il6Z+2h8xUVt+/YAbAitWv8DsJizE8qVbiQsmkZsfDtDKxmRh/HKPO11iYjDveNDWq3LaK3M7NlvJ8qz8ixPPY6eocCjcM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.84_2) (envelope-from ) id 1g883T-0008ST-6p; Thu, 04 Oct 2018 20:08:55 +0200 Date: Thu, 4 Oct 2018 20:08:55 +0200 From: Andrew Lunn To: Nicolas Cavallari Cc: Andrew Morton , Russell King , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: Reboot using an i2c power-system-controller ? Message-ID: <20181004180855.GG4730@lunn.ch> References: <20181004162339.19493-1-nicolas.cavallari@green-communications.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181004162339.19493-1-nicolas.cavallari@green-communications.fr> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 04, 2018 at 06:23:37PM +0200, Nicolas Cavallari wrote: > So i got this ARM board with a rtc controlled by i2c that can also cut > power. I want to use it to reboot, because it will also cut power to > clumsy USB and MMC devices. > So the natural thing to do would be to just register a restart_handler > that will kindly do i2c (saw at least a driver doing it), or use > arm_pm_restart and be done with it. > > Well that what I though. Most of my naive attempts were met with > occasional failures and now my understanding is that I do not > understand why anything works in the first place. Hi Nicolas I doubt you can use the platform i2c driver. If you look at how this is done for sending commands over a UART to a micro-controller, you will see the reset driver hijack the UART device. They poke registers with the require baud rate settings, and then poke registers with the bytes to send, polling for completion of each byte if needed. To get this working reliably, i suspect you are going to need to do the same with your i2c bus controller. Directly control it, stop any in progress transfers, setup a new transfer, and hope you can do it polled IO, not DMA. Andrew