Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2465266rwb; Fri, 16 Dec 2022 02:22:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf669Gi1MDgc4Se/vn4AjXoFJJ+l9Emd2MqR5q+fvEJhaN0N/kxAfRGh5Z4QuQ/xE+QuBYUG X-Received: by 2002:a17:902:8204:b0:188:ec14:bf17 with SMTP id x4-20020a170902820400b00188ec14bf17mr31067108pln.11.1671186172245; Fri, 16 Dec 2022 02:22:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671186172; cv=none; d=google.com; s=arc-20160816; b=ljwCsY4PKGBdD+Sg3j4fEStJsbeGiT8w/nuxs69bvgRSsP1nByD2CfCIZIdXusZPJW Ej3B/vZmdLp+swYMGM7OqAddNr/8ugAoOtA7KtYCS1LhXevYucLbJGmvCsuzCpAFHmnK 3fHc6dlMCojQvUs8kDVrp4CtY0xtKDvdvLY1K1rRpYTyxzjB53qfEuTbL8OYxhin+LEl JLXgcTVSOi5j9nRcul+qhepXb1uqD9dQmIYbOBezzkgLI/QO1I2UOkigsstjSzBcaadM nBHJEHnsEhIxSXeKYp4hdLIcto7f7sIFLFRhk5mvzbL6YAVbZ23uutPlVICY0Dtup+7x kzew== 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=/H6fBZQRWEmDLxoUqkA4ISnIrcRGBzcSkN81MSyyxEM=; b=JhxNkBKa52ECtcY+3tmmjO71Hgt9JPJ0WwwSag5ugLKBLpAJaC+45C1ySkwTcuphkx 6kLU2RbKUfI3S4lYght9waza5mIFKQeosUulPKQNFdAaME3Bi1ejOBMIXHO30sEbm1i2 F0zsVEHIRZ0tOMQsYQvDd/5UuitcraAEJcTaFp7RJve/PFzod02uXDEL4lkJuhfYsToe 6ed6Q2kC4FZam9hVGCsqdCT/zSwg8LQZ6r1+yTa+nhMH9NNYYFEsftRoZzOHGO5mFoZI hff/SOgC5rEYhKuPCcpzuwcdQqeDxSUaSFxzlMuvGcZ1gcOd0lu4JV5TTHR4EvDELMIb 8+KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=fNAU4cYJ; 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 p5-20020a170902ebc500b001889d3b1c07si2063535plg.566.2022.12.16.02.22.42; Fri, 16 Dec 2022 02:22:52 -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=fNAU4cYJ; 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 S230233AbiLPJqu (ORCPT + 68 others); Fri, 16 Dec 2022 04:46:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbiLPJqm (ORCPT ); Fri, 16 Dec 2022 04:46:42 -0500 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB582CE11 for ; Fri, 16 Dec 2022 01:46:41 -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 48ECD85205; Fri, 16 Dec 2022 10:46:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671183999; bh=/H6fBZQRWEmDLxoUqkA4ISnIrcRGBzcSkN81MSyyxEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fNAU4cYJpyQEcY4v4lZZsysJ4r16bYRseOWLGq0HSYwdeMNCAyO5EUouJzYFPioMU hMkozV+HklaqCTbdk3M23L20P6nBwrnCiJ6OBWxtrmjWVU27GcvsELssJeqCQzAFGh 9Lr9w8sLCj8fHEK0WPbbHAiIS42BcXtYCjjcbQBhLXzZeg8OzABuccZB8E8jf/ZGWq 2qgk/dbQlWo/LoTNm6LTkyxNPCmiZMsjNhV1JmPIRtAHSC3I+x0fSeqMgnsYpimBmP cWjhGUjkH/DDNO5zLx/FqTcf5iQdfpedBgVjf7txkeOvXB28+W3fPt+M4vk5/UWwQ7 zqoXWfkOko0sA== 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 v3 3/3] ASoC: wm8940: Read chip ID when wm8940 codec probing Date: Fri, 16 Dec 2022 10:46:24 +0100 Message-Id: <20221216094624.3849278-3-lukma@denx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221216094624.3849278-1-lukma@denx.de> References: <20221216094624.3849278-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 Changes for v3: - 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