From patchwork Wed Dec 14 12:37:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 13073032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1504CC001B2 for ; Wed, 14 Dec 2022 12:39:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 38B0023F4; Wed, 14 Dec 2022 13:39:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 38B0023F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1671021597; bh=/YbLUsvgSr7xXcoYflW3WHwlVzGrGQrJ5ZMfGnZ0Hq8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Wi1JCWRrY2s/CS+KI/xxRSWrCGL1hC+EN8+1wT2LgtEmJwSnDYSZs6Aru5+32txNi qlvcLAAr3KXkd7TxB+/9N4l+08ieMzjAJbxICT9egAwZZz2yZ/06uQL0RzWq07WYzl RRIvCLXhn5QDk0kAUyY767jb/c6X2ZRiBwkObaeI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1226CF80534; Wed, 14 Dec 2022 13:38:13 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B7D68F804D7; Wed, 14 Dec 2022 13:38:09 +0100 (CET) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B9BB8F80310 for ; Wed, 14 Dec 2022 13:38:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B9BB8F80310 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=TPftpv/V Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 978F385169; Wed, 14 Dec 2022 13:38:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671021487; bh=azo7orbjiRSezN63u1QFsZfaSV1rIV/pBSbsk2QFUuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TPftpv/VbeTQrvMqbqLhmRtuiZNvMJGxbLDrpQ8ADXPp3FvRUIYsm0CXNFt+46N1E kewJiPCBbL74uQ/zqtkbpGza9v3QmS1f2Ox7BtQolwsxASqF/kpJeVqJkLxY4ZEBlI N4eprHJ00BubbAo8pl93pVWnPm0hXn9e9PSulBgBd1N8I834/dRV3LxlO2yfLRVcl+ dymehn2B7u7L03eb/sv95hriJ18UGDyTeJrIKCfHxOiE4Nym6Ws23uwWrt64gFVXPK rTYJ0YhnJ/O3mk8pmfLsakNruTA9H+Lcu4CQ0DeGE1gfpW/sS1V4QpngjNU0VziuZy 9b3ZbaiiToFEQ== From: Lukasz Majewski To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Charles Keepax , Stephen Kitt Subject: [PATCH 4/4] ASoC: wm8940: Read chip ID when wm8940 codec probing Date: Wed, 14 Dec 2022 13:37:43 +0100 Message-Id: <20221214123743.3713843-5-lukma@denx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221214123743.3713843-1-lukma@denx.de> References: <20221214123743.3713843-1-lukma@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lukasz Majewski Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The wm8940 provides the chip ID information via I2C. In this patch this information is read and if not matching expected value, the probe function is aborted. This prevents from using (i.e. inserting) other wm89* modules which use the sam I2C bus address. Signed-off-by: Lukasz Majewski Acked-by: Charles Keepax --- sound/soc/codecs/wm8940.c | 11 +++++++++++ sound/soc/codecs/wm8940.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index 13cb57210b4b..244998ebab4d 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c @@ -769,6 +769,17 @@ static int wm8940_probe(struct snd_soc_component *component) int ret; u16 reg; + /* + * Check chip ID for wm8940 - value of 0x00 offset + * SOFTWARE_RESET on write + * CHIP_ID on read + */ + reg = snd_soc_component_read(component, WM8940_SOFTRESET); + if (reg != WM8940_CHIP_ID) { + dev_err(component->dev, "Wrong wm8940 chip ID: 0x%x\n", reg); + return -ENODEV; + } + ret = wm8940_reset(component); if (ret < 0) { dev_err(component->dev, "Failed to issue reset\n"); diff --git a/sound/soc/codecs/wm8940.h b/sound/soc/codecs/wm8940.h index eb051ed29bb8..8fbddcaa7449 100644 --- a/sound/soc/codecs/wm8940.h +++ b/sound/soc/codecs/wm8940.h @@ -98,5 +98,8 @@ struct wm8940_setup_data { /* Bit definitions */ #define WM8940_SPKMUTE BIT(6) +/* Chip ID */ +#define WM8940_CHIP_ID 0x8940 + #endif /* _WM8940_H */