Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4058594ybi; Mon, 15 Jul 2019 03:12:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9GDORAS5J5r2vbiwB5KHttlcTols179th99Fiqg8Auo4wGw4sOTBkHubBylNKfEHoIGwq X-Received: by 2002:a65:5687:: with SMTP id v7mr26578723pgs.263.1563185562099; Mon, 15 Jul 2019 03:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563185562; cv=none; d=google.com; s=arc-20160816; b=gu1Ha3Jmnyho+902/c6pvYbAT1dIGn7WmDYWw8zo8YNx+XCgTriE52kK6/jVq96C6R zZapIDwYiSnRbgJBzUIy86EI19UpUVbYdmqLfCQKex06etms7NWqSi2JdyEYoigAgU1y kTsF6/J8z3EUONtBBkmkrXC0JyGNQ7UIItMdEWUqbWxcxhoae4IDHedw4N8v+d0DodQV MoN5Ush77WpPOUFGeRUytJidK+eHdV6paGVP8YPROcAbfQdaPlboE4/ngA1uvKJqcAVa ELSF2Nk6I7sXp9zIWofhV0w2s0BU5i229SsYHBIO1xiPZuJKbFEgRQ2R+gYES7fey4/j 11gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=PCNrzRBtsGc1Om9sAeS9lBVN+c+LesN5DYqZlpWwkOI=; b=FjduUpVgOMIpjTFCeauvGEwhpSBWFzByy1x1qWGlN4lJSi2S+XaK6jUlWU9Lifi3qg guDGPS8AwP1++UXYqBgQHjaI6zKWR4/5iL3Kv9MYeeYuqXHkxtmbUK/s697cemAV8rFu emosM0aCArO8bPekSrKWbh9Kn120VjYwsrn68BtaHdnUkRHhrVN9NTxC2sj+zwVQWjdH b3XkwSj1wJWb0SSrDLCnLUxjtziUPYnX8IZbT3ZfSwepQ75BWGrT7wkCV/8MaIS9g66a guJ+l6k9pfB51Xru86LXbeaN4wC51lrLBMmNx7IjLxmgRq5Zq69Hhtotaftbnw/rVjm6 zJoA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si15521083pla.363.2019.07.15.03.12.25; Mon, 15 Jul 2019 03:12:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729748AbfGOKLE (ORCPT + 99 others); Mon, 15 Jul 2019 06:11:04 -0400 Received: from mail-sz.amlogic.com ([211.162.65.117]:38479 "EHLO mail-sz.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729428AbfGOKLE (ORCPT ); Mon, 15 Jul 2019 06:11:04 -0400 X-Greylist: delayed 901 seconds by postgrey-1.27 at vger.kernel.org; Mon, 15 Jul 2019 06:11:02 EDT Received: from localhost.localdomain (10.28.8.29) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server id 15.1.1591.10; Mon, 15 Jul 2019 17:56:28 +0800 From: chunguo feng To: CC: , , , , , , , , , Subject: [PATCH] ASoC: max98383: fix i2c probe failure Date: Mon, 15 Jul 2019 17:55:56 +0800 Message-ID: <20190715095556.1614-1-chunguo.feng@amlogic.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.28.8.29] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: fengchunguo Added reset_gpio configuration for i2c probe successfully. If not,i2c address can't be found rightly. Error information: max98373 3-0031: Failed to read: 0x21FF Fixed: [3.761299@3] max98373 3-0031: MAX98373 revisionID: 0x43 [3.828911@3] asoc-aml-card auge_sound: max98373-aif1 <-> TDM-B mapping ok Signed-off-by: fengchunguo --- sound/soc/codecs/max98373.c | 34 ++++++++++++++++++++++++++++++---- sound/soc/codecs/max98373.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c index 528695cd6a1c..9a1eb7222357 100644 --- a/sound/soc/codecs/max98373.c +++ b/sound/soc/codecs/max98373.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include "max98373.h" @@ -895,6 +896,17 @@ static void max98373_slot_config(struct i2c_client *i2c, else max98373->i_slot = 1; + max98373->reset_gpio = of_get_named_gpio(dev->of_node, + "maxim,reset-gpio", 0); + if (!gpio_is_valid(max98373->reset_gpio)) { + dev_err(dev, "Looking up %s property in node %s failed %d\n", + "maxim,reset-gpio", dev->of_node->full_name, + max98373->reset_gpio); + } else { + dev_dbg(dev, "maxim,reset-gpio=%d", + max98373->reset_gpio); + } + if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value)) max98373->spkfb_slot = value & 0xF; else @@ -923,7 +935,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c, else max98373->interleave_mode = false; - /* regmap initialization */ max98373->regmap = devm_regmap_init_i2c(i2c, &max98373_regmap); @@ -934,6 +945,24 @@ static int max98373_i2c_probe(struct i2c_client *i2c, return ret; } + /* voltage/current slot & gpio configuration */ + max98373_slot_config(i2c, max98373); + + /* Power on device */ + if (gpio_is_valid(max98373->reset_gpio)) { + ret = gpio_request(max98373->reset_gpio, "MAX98373_RESET"); + if (ret) { + dev_err(&i2c->dev, "%s: Failed to request gpio %d\n", + __func__, max98373->reset_gpio); + gpio_free(max98373->reset_gpio); + return -EINVAL; + } + gpio_direction_output(max98373->reset_gpio, 0); + msleep(50); + gpio_direction_output(max98373->reset_gpio, 1); + msleep(20); + } + /* Check Revision ID */ ret = regmap_read(max98373->regmap, MAX98373_R21FF_REV_ID, ®); @@ -944,9 +973,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c, } dev_info(&i2c->dev, "MAX98373 revisionID: 0x%02X\n", reg); - /* voltage/current slot configuration */ - max98373_slot_config(i2c, max98373); - /* codec registeration */ ret = devm_snd_soc_register_component(&i2c->dev, &soc_codec_dev_max98373, max98373_dai, ARRAY_SIZE(max98373_dai)); diff --git a/sound/soc/codecs/max98373.h b/sound/soc/codecs/max98373.h index f6a37aa02f26..533d2053f608 100644 --- a/sound/soc/codecs/max98373.h +++ b/sound/soc/codecs/max98373.h @@ -203,6 +203,7 @@ struct max98373_priv { struct regmap *regmap; + int reset_gpio; unsigned int v_slot; unsigned int i_slot; unsigned int spkfb_slot; -- 2.18.0