From patchwork Thu Apr 17 02:24:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bard Liao X-Patchwork-Id: 4005291 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 086ED9F375 for ; Thu, 17 Apr 2014 02:25:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D400220306 for ; Thu, 17 Apr 2014 02:25:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D21C220303 for ; Thu, 17 Apr 2014 02:25:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EA9212650FE; Thu, 17 Apr 2014 04:24:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id A7EAC264FBB; Thu, 17 Apr 2014 04:24:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1C39B265015; Thu, 17 Apr 2014 04:24:47 +0200 (CEST) Received: from rtits2.realtek.com (rtits2.realtek.com [60.250.210.242]) by alsa0.perex.cz (Postfix) with ESMTP id 3EC24264F41 for ; Thu, 17 Apr 2014 04:24:37 +0200 (CEST) X-SpamFilter-By: BOX Solutions SpamTrap 5.39 with qID s3H2OVew009890, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitcas11.realtek.com.tw[172.21.6.12]) by rtits2.realtek.com (8.14.5/2.37/5.60) with ESMTP id s3H2OVew009890 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 17 Apr 2014 10:24:32 +0800 Received: from sw-server.rtdomain (172.21.81.164) by RTITCAS11.realtek.com.tw (172.21.6.12) with Microsoft SMTP Server id 14.3.174.1; Thu, 17 Apr 2014 10:24:32 +0800 From: To: , Date: Thu, 17 Apr 2014 10:24:06 +0800 Message-ID: <1397701446-11977-1-git-send-email-bardliao@realtek.com> X-Mailer: git-send-email 1.8.1.1.439.g50a6b54 MIME-Version: 1.0 X-Originating-IP: [172.21.81.164] Cc: oder_chiou@realtek.com, Bard Liao , alsa-devel@alsa-project.org, jarkko.nikula@linux.intel.com, flove@realtek.com Subject: [alsa-devel] [PATCH v2] ASoC: rt5640: Add minimal support for RT5642 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bard Liao We have been using rt5640.c codec driver with RT5642 codec chip before commit 022d21f004c1 ("ASoC: rt5640: add rt5639 support"). That commits starts using device ID reading in reset register for adding device specific controls and routes runtime. Now since device ID appears to be different between RT5640 and RT5642 the driver doesn't add those controls and routes that are valid also on RT5642. Fix this by adding a device ID found by debugging and minimal code for supporting RT5642. Signed-off-by: Jarkko Nikula Signed-off-by: Bard Liao --- This patch add a mask for reading the device ID. This can remove the affect of other bits which is not related to device ID. --- sound/soc/codecs/rt5640.c | 8 +++++--- sound/soc/codecs/rt5640.h | 10 +++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 6674372..79635ee 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1997,8 +1997,9 @@ static int rt5640_probe(struct snd_soc_codec *codec) snd_soc_update_bits(codec, RT5640_MICBIAS, 0x0030, 0x0030); snd_soc_update_bits(codec, RT5640_DSP_PATH2, 0xfc00, 0x0c00); - switch (snd_soc_read(codec, RT5640_RESET)) { - case RT5640_RESET_ID: + switch (snd_soc_read(codec, RT5640_RESET) & RT5640_ID_MASK) { + case RT5640_ID_5640: + case RT5640_ID_5642: snd_soc_add_codec_controls(codec, rt5640_specific_snd_controls, ARRAY_SIZE(rt5640_specific_snd_controls)); @@ -2009,7 +2010,7 @@ static int rt5640_probe(struct snd_soc_codec *codec) rt5640_specific_dapm_routes, ARRAY_SIZE(rt5640_specific_dapm_routes)); break; - case RT5639_RESET_ID: + case RT5640_ID_5639: snd_soc_dapm_new_controls(&codec->dapm, rt5639_specific_dapm_widgets, ARRAY_SIZE(rt5639_specific_dapm_widgets)); @@ -2149,6 +2150,7 @@ static const struct regmap_config rt5640_regmap = { static const struct i2c_device_id rt5640_i2c_id[] = { { "rt5640", 0 }, { "rt5639", 0 }, + { "rt5642", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index 3b50459..ded2059 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h @@ -14,9 +14,6 @@ #include -#define RT5639_RESET_ID 0x0008 -#define RT5640_RESET_ID 0x000c - /* Info */ #define RT5640_RESET 0x00 #define RT5640_VENDOR_ID 0xfd @@ -195,6 +192,13 @@ #define RT5640_R_VOL_MASK (0x3f) #define RT5640_R_VOL_SFT 0 +/* SW Reset & Device ID (0x00) */ +#define RT5640_ID_MASK (0x3 << 1) +#define RT5640_ID_5639 (0x0 << 1) +#define RT5640_ID_5640 (0x1 << 1) +#define RT5640_ID_5642 (0x3 << 1) + + /* IN1 and IN2 Control (0x0d) */ /* IN3 and IN4 Control (0x0e) */ #define RT5640_BST_SFT1 12