Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp817496rwb; Thu, 15 Dec 2022 02:54:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DbyOggKuD8opQLXI+E+8WBMenFihYh/ohAIuvXi1gWQIRugRXRe2PGStVh+Q7T2bSFCQm X-Received: by 2002:a62:79d0:0:b0:575:fd73:fc94 with SMTP id u199-20020a6279d0000000b00575fd73fc94mr29886690pfc.23.1671101668251; Thu, 15 Dec 2022 02:54:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671101668; cv=none; d=google.com; s=arc-20160816; b=de8nu0QtAFsfgmWpTyFba0qINizKigjD/6jUNBpQXarTDRS6Qlr90S/lg4KM2halJi XK2BGpgawx+IENN3TxPaipFuUQYazh7E/seABIYCxmWidCxecczi0pRiaKtKf5TjTJU8 ck9YfZFD0RcKoBYbA0ftlInAKZJdVb86wnQu9U2ComB18sE0JXahVgv18EFK0V7B7Px1 t/t3H2Q5XpxQuL6aoT2NbwAWaGXfcjrVMp2EOK17IqAwLbmfjQqo1SdC3kn1pYiwhBo3 qQbYoSJgv7n/HT9WZYMzTIocIqDt5GGAEoUVyIB50qvuG/ls8N6eikQnJW8AZg08apfV qbJQ== 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=vUFV5R8bOhefsqOpqWAdoI5RFb/9UxmbNJq1tx/Av7g=; b=vvWjWaDmEB2OeZB/QX9rD3jVBTN+uyCgBYx1yEPgfwbIEa58dfF27mM0I+a7eAlk5n JiKxMkynGAQ1kiXMXZbxjWwOYin3T3Da/krEl4mi/XZUBTp/Wu7wAm3M9MxLHqZuMxYg 2GkYnJ7Gb2jmY8i80R9nuSCmcLIvzN/dDWLj4BlBqxXcjRDOAYRSnOu/YTQiauAYv0VM FyxUt1FBkD0QE9tLQvcGbBGxL7ViyBT8xyaf7E+Wl86PHfFkeWvbtZ3MHEyGYmgmN7Gw 8pkuOWcYq01ro3GRg/ObEYjaZcWrKqg8R/5prN47XihygKX6QtPheIwIcZPI8J/ok/xl TOYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=NRrPSD+Q; 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 125-20020a620483000000b00572ee9a0c46si2195428pfe.346.2022.12.15.02.54.19; Thu, 15 Dec 2022 02:54:28 -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=NRrPSD+Q; 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 S230052AbiLOJgn (ORCPT + 68 others); Thu, 15 Dec 2022 04:36:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbiLOJgh (ORCPT ); Thu, 15 Dec 2022 04:36:37 -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 4E2BB2981A for ; Thu, 15 Dec 2022 01:36:36 -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 E21F98546A; Thu, 15 Dec 2022 10:36:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671096994; bh=vUFV5R8bOhefsqOpqWAdoI5RFb/9UxmbNJq1tx/Av7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NRrPSD+QLVUK3bepqgOCbe1axpXNykKURsTidZFGb2i2YHXhFlYKXkVB3df1TllF9 cee8OuERe/R8yjf67/nDbOdl+ZV57tykGA3vsSCscbzk+BLAdQtOGyIPCeuZydFMKt uTzrY2xSzlRoQMb5MuCE/gyvmv+v7MO4W0DPJA2CKRof26JAhrEryHfcWaVJYLvaKT D5O6ursxmW1VLyAiInpTi+Mv7mEO+WRkWWAe8rbLj7g8CcXK6yRzXZods/jwRbUmxm IywzQZWnSkAXjsYV/GH8Vtudl/SAR5G0P6q1bJyIgSMWs7+ZeHje1F9V4lA1DohMkx X/t6BZBh0oErg== From: Lukasz Majewski To: Liam Girdwood , Mark Brown , Charles Keepax Cc: Jaroslav Kysela , Takashi Iwai , Stephen Kitt , patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH v2 3/3] ASoC: wm8940: Read chip ID when wm8940 codec probing Date: Thu, 15 Dec 2022 10:36:15 +0100 Message-Id: <20221215093615.3794156-3-lukma@denx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221215093615.3794156-1-lukma@denx.de> References: <20221214123743.3713843-1-lukma@denx.de> <20221215093615.3794156-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 same I2C bus address. Signed-off-by: Lukasz Majewski Acked-by: Charles Keepax --- Changes for v2: - None --- 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 1b02d5e8a007..8eb4782c9232 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c @@ -760,6 +760,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 0d4f53ada2e6..86bbf902ef5a 100644 --- a/sound/soc/codecs/wm8940.h +++ b/sound/soc/codecs/wm8940.h @@ -95,5 +95,8 @@ struct wm8940_setup_data { #define WM8940_OPCLKDIV_3 2 #define WM8940_OPCLKDIV_4 3 +/* Chip ID */ +#define WM8940_CHIP_ID 0x8940 + #endif /* _WM8940_H */ -- 2.20.1