Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1150025imm; Tue, 2 Oct 2018 03:42:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Q/CeNjQNIJVRxm5ztdWE5fpRNpT9fqTPRX4mpFCfFJxWdg2Q8NT1R2qLQX0VDRJ+ikEIM X-Received: by 2002:a62:25c5:: with SMTP id l188-v6mr15543973pfl.179.1538476920102; Tue, 02 Oct 2018 03:42:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538476920; cv=none; d=google.com; s=arc-20160816; b=XmFTjk9az4oIsSF2y3s3LkV3mkwYwSr6tWJ4/djgDNrMhbmR8Hk861q4De/rN9yxA8 Kwps1SEEb6ow35MH+X8g/Nijo6mUh51JyH7GL/EUdR9RtD9ebUYOYCN3orlx0pzO0aED f4F1ulLWp7bKEHrEF8xzYwiBuK7GIC/7Fauq+PoMiSCqsshGLmIx0LUoy+hIry/CZpU/ zV4brl4rf8/xppjjnJftotqR82Az+xo0bTh7J34gvsWi5bOnpXPLBH5O+YSGSzXRflif r9XaVfIHj0MfnOUTUznAujlZWVyPO69+R/aNL9Tbeq13bH6s2wL3P71S820GpkePV++/ E/Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=IJ+UrDi+9Z4ND8oyuxt1ZVbLCdBXyXomap23rmmLSRU=; b=x41zSZQSehfEo5K3CBzkCBnCXHRx/c4FpR2aOKwitLslhCw+zRn5ui8LywE8aRO/1o vPb+2xuyoP57D2imWIVHrUsPx5AqNveMu5YWdSZ/hDaujWWlkYPHKCDBbUHpifRL2vQN WSL8nWBAg/sOqIYSvGu6DLpvT6gicLWllwdkBYEXe732fE7B7MSBUhMuT5uiVou1qWRf TtCfEhkgTIAf7vnuFcVDrstDHAv0pa7za4glNgfXd/N5aCUUcmZATnS6xoDFxmq+h8ng ZB7LJ9/BMu/NkX1haM+QIpZGJ2lQBDS+dnqioLCxiBHgLKCvRQ9BoYZtxw216vRkTIbO vGLA== 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=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si15113311pls.366.2018.10.02.03.41.44; Tue, 02 Oct 2018 03:42:00 -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=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727400AbeJBRYQ (ORCPT + 99 others); Tue, 2 Oct 2018 13:24:16 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:34820 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727007AbeJBRYP (ORCPT ); Tue, 2 Oct 2018 13:24:15 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w92Aee4C030652; Tue, 2 Oct 2018 05:41:36 -0500 Authentication-Results: ppops.net; spf=none smtp.mailfrom=rf@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0a-001ae601.pphosted.com with ESMTP id 2mugjdhm6q-1; Tue, 02 Oct 2018 05:41:36 -0500 Received: from EX17.ad.cirrus.com (unknown [172.20.9.81]) by mail1.cirrus.com (Postfix) with ESMTP id 91BD2611C8C1; Tue, 2 Oct 2018 05:41:35 -0500 (CDT) Received: from imbe.wolfsonmicro.main (198.61.95.81) by EX17.ad.cirrus.com (172.20.9.81) with Microsoft SMTP Server id 14.3.408.0; Tue, 2 Oct 2018 11:41:34 +0100 Received: from edi-sw-dsktp006.ad.cirrus.com (edi-sw-dsktp006.ad.cirrus.com [198.90.251.121]) by imbe.wolfsonmicro.main (8.14.4/8.14.4) with ESMTP id w92AfYlG022871; Tue, 2 Oct 2018 11:41:34 +0100 From: Richard Fitzgerald To: CC: , , "Richard Fitzgerald" Subject: [PATCH v2 2/2] mfd: madera: Wait for BOOT_DONE before reading device ID Date: Tue, 2 Oct 2018 11:41:34 +0100 Message-ID: <20181002104134.29003-2-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181002104134.29003-1-rf@opensource.cirrus.com> References: <20181002104134.29003-1-rf@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810020106 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It isn't safe to read the device ID in the SOFTWARE_RESET register until the silicon boot sequence has completed. This patch rearranges the code to wait until BOOT_DONE is set. If we don't have a hard reset line we want to defer writing a soft reset command until we have identified the silicon as something we recognize. As the BOOT_DONE bit is sticky it is safe to wait for it without issuing a soft reset first, because the most recent power-up will have caused a boot sequence and set the bit. Note that the boot sequence is not the same as a reset so we still have to soft reset to get the codec into a known state. Signed-off-by: Stuart Henderson Signed-off-by: Richard Fitzgerald --- drivers/mfd/madera-core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/mfd/madera-core.c b/drivers/mfd/madera-core.c index 1dedfe68a3dc..e114ca5e6c3f 100644 --- a/drivers/mfd/madera-core.c +++ b/drivers/mfd/madera-core.c @@ -455,10 +455,13 @@ int madera_dev_init(struct madera *madera) regcache_cache_only(madera->regmap, false); regcache_cache_only(madera->regmap_32bit, false); - /* - * Now we can power up and verify that this is a chip we know about - * before we start doing any writes to its registers. - */ + /* BOOT_DONE must be set before we can read the device ID */ + ret = madera_wait_for_boot(madera); + if (ret) { + dev_err(madera->dev, "Device failed initial boot: %d\n", ret); + goto err_reset; + } + ret = regmap_read(madera->regmap, MADERA_SOFTWARE_RESET, &hwid); if (ret) { dev_err(dev, "Failed to read ID register: %d\n", ret); @@ -528,12 +531,13 @@ int madera_dev_init(struct madera *madera) ret = madera_soft_reset(madera); if (ret) goto err_reset; - } - ret = madera_wait_for_boot(madera); - if (ret) { - dev_err(madera->dev, "Device failed initial boot: %d\n", ret); - goto err_reset; + ret = madera_wait_for_boot(madera); + if (ret) { + dev_err(madera->dev, "Device failed initial soft reboot: %d\n", + ret); + goto err_reset; + } } ret = regmap_read(madera->regmap, MADERA_HARDWARE_REVISION, -- 2.11.0