Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp931400rwb; Wed, 14 Dec 2022 04:45:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4TlsbuNPy9LF5yve3Khnq0AQFq4GMiHbcAGFW3/KdEs0YNOGDKZW8QQxOVpMC+iHfcobZv X-Received: by 2002:a05:6a20:47d3:b0:a2:d0b1:7c95 with SMTP id ey19-20020a056a2047d300b000a2d0b17c95mr25306376pzb.21.1671021949837; Wed, 14 Dec 2022 04:45:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671021949; cv=none; d=google.com; s=arc-20160816; b=v4FsyQdyLfzXBtPfskK20Ix2otNzXykH+fvaVnMCYTdOmNUCxd1hEKnhdgGjXsaTVR 6Ch5AjGuc7UH8VqSyREeAzuJPTCM4uSKFxHuisCPLiLH3V3n0xy+YZC7yWBF5kOar8VQ JIhxczVAC58i4hI3X+/xJutZfqMc/3XdRVsH1LbJfEHYqTSPp3xqx0EmVU9rYhPeO1jm x8kLFp9a3PKP4CK2Q///QlFReDosN72j/Zmjq/7Gaf42qgrFYjP0VHUSnLElOGdjv7OU wHyf75BDhNxoMMnqyycHfkL9ka6fo5/gdPxcUVxIqXG7ZQRK2Fd/R+BtlAU3X3AO8I0R prPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=azo7orbjiRSezN63u1QFsZfaSV1rIV/pBSbsk2QFUuQ=; b=uKth1QyoP4UzLecgLwCreQMVJ3nw+ttTc6VHw/T2Q8f4Vug7tNk5uISpaNLTVM5Uu9 gNoYtS/41NkT9UjctSXnqSF7eIoajt4ogsOxuC86ueokHURZkCd6qunEyb8zF1C3G+DB VyMUKwPuj3A0J0S0CXYzZLoErd7zK/3Oyh8aZKazhAGchxK4/E9AggiX++28y4WuTyMi yPv/cosGbBs3PSpyXMf4b44vM2OFtP3PVCJs1pFRN2ZuKBHHR5H+YurHQSgfcs40/J+y awPN34ESbcFS7ompUhzebAfU23P9LmhyeAatl5qAvf8hAWNeq6IhgWFbbIPFy+Qy+90s Og1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b="TPftpv/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 193-20020a6300ca000000b00479139fe810si15698073pga.619.2022.12.14.04.45.38; Wed, 14 Dec 2022 04:45:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b="TPftpv/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238326AbiLNMjw (ORCPT + 70 others); Wed, 14 Dec 2022 07:39:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238302AbiLNMj0 (ORCPT ); Wed, 14 Dec 2022 07:39:26 -0500 Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C88121E08 for ; Wed, 14 Dec 2022 04:38:08 -0800 (PST) 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 Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lukasz Majewski 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 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 */ -- 2.20.1