Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4468644ybi; Tue, 11 Jun 2019 07:10:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzb8S+oQLCRRW4jfvS5eXRuLRUvAPOlQmXse9YGxKP3HOi2Gr/zOf9zga/GtVRjPqlPj8T6 X-Received: by 2002:aa7:9212:: with SMTP id 18mr41417018pfo.120.1560262229665; Tue, 11 Jun 2019 07:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560262229; cv=none; d=google.com; s=arc-20160816; b=FAWjug5rvmEhaaPku3Fmq/Y//PP6wfBtyhjEFLvdpBY1ThmCTY1PiyDe4yRFTvqHiv NzKBtp/ztBgozlBWXCMsEzUFypwVsq/sx+aarJ3KtuWwrOT8tabh0vpzdAUC6v62ksfy 4gBTHigrTf0Q+UEzb4pvAx6vGkIzSfChTLc/22Gl3LHDgKUNspch9TfkH+XFp5LAgPzY NMlBbtZEMCzvSrmwMo8AO0FECh5u/g4bqdWpXEQcnZ+nDytn2HIvIp2sqbzUCr29O9mR 7Y4JdIuWPbvCNXg9SB0pPzuIOATFbB1tU/55bh/oYztxhmT5GWONkCUEIi+Jlvfgrs/u 9kew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cXqOG44E/uFRwFL08SqLbYUCqYcb6T6xscM4OP1VTo8=; b=UtgAyjgS2HGBoXGvP68k58bzhD0WDpDc9/LoHJbESdV/53pHkpjJcCT673hifmndSv dIUXg3jUdzIZOwK92flMY8Cp1sFS1PKJWnWIYbRq8/gfg/fu2qWs5RDwYjviT8uN6g2R GC8fq/zbWlciFoyY9rmCbr+ccp6EY/QZeidPdcNz0ppQptVDy8JCKDVsEotmobE6mqd/ HmKJhYFnReb8hC5zzu8UUf7SuNiUHwixP66DcgsLQK54BEWDI1g0Uh3XviWcDBOCdQ4B VPyUUxFMB6vNNj8DzlG9INRvW9ouWiqgmvkSSkqYaVA0NBf97I5SHJZP1z+1XGhwWHvA 11RQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e127si12444234pgc.214.2019.06.11.07.10.13; Tue, 11 Jun 2019 07:10:29 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391594AbfFKOFg (ORCPT + 99 others); Tue, 11 Jun 2019 10:05:36 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:55721 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389902AbfFKOFB (ORCPT ); Tue, 11 Jun 2019 10:05:01 -0400 Received: from [167.98.27.226] (helo=happy.office.codethink.co.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1hahOT-0003vU-LT; Tue, 11 Jun 2019 15:04:57 +0100 From: Michael Drake To: Andrzej Hajda , Laurent Pinchart , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Drake Cc: David Airlie , Daniel Vetter , Rob Herring , Mark Rutland , linux-kernel@lists.codethink.co.uk, Patrick Glaser , Nate Case Subject: [PATCH v1 06/11] ti948: Reconfigure in the alive check when device returns Date: Tue, 11 Jun 2019 15:04:07 +0100 Message-Id: <20190611140412.32151-7-michael.drake@codethink.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190611140412.32151-1-michael.drake@codethink.co.uk> References: <20190611140412.32151-1-michael.drake@codethink.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the alive check detects a transition to the alive state, the device configuration is rewritten. Signed-off-by: Michael Drake Cc: Patrick Glaser Cc: Nate Case --- drivers/gpu/drm/bridge/ti948.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/ti948.c b/drivers/gpu/drm/bridge/ti948.c index 86daa3701b91..b5c766711c4b 100644 --- a/drivers/gpu/drm/bridge/ti948.c +++ b/drivers/gpu/drm/bridge/ti948.c @@ -132,6 +132,8 @@ struct ti948_reg_val { * @reg_names: Array of regulator names, or NULL. * @regs: Array of regulators, or NULL. * @reg_count: Number of entries in reg_names and regs arrays. + * @alive_check: Context for the alive checking work item. + * @alive: Whether the device is alive or not (alive_check). */ struct ti948_ctx { struct i2c_client *i2c; @@ -141,6 +143,8 @@ struct ti948_ctx { const char **reg_names; struct regulator **regs; size_t reg_count; + struct delayed_work alive_check; + bool alive; }; static bool ti948_readable_reg(struct device *dev, unsigned int reg) @@ -346,6 +350,8 @@ static int ti948_power_on(struct ti948_ctx *ti948) if (ret != 0) return ret; + ti948->alive = true; + msleep(500); return 0; @@ -356,6 +362,8 @@ static int ti948_power_off(struct ti948_ctx *ti948) int i; int ret; + ti948->alive = false; + for (i = ti948->reg_count; i > 0; i--) { dev_info(&ti948->i2c->dev, "Disabling %s regulator\n", ti948->reg_names[i - 1]); @@ -388,8 +396,17 @@ static void ti948_alive_check(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); struct ti948_ctx *ti948 = delayed_work_to_ti948_ctx(dwork); + int ret = ti948_device_check(ti948); - dev_info(&ti948->i2c->dev, "%s Alive check!\n", __func__); + if (ti948->alive == false && ret == 0) { + dev_info(&ti948->i2c->dev, "Device has come back to life!\n"); + ti948_write_config_seq(ti948); + ti948->alive = true; + + } else if (ti948->alive == true && ret != 0) { + dev_info(&ti948->i2c->dev, "Device has stopped responding\n"); + ti948->alive = false; + } /* Reschedule ourself for the next check. */ schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY); -- 2.20.1