Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp394823ybg; Wed, 3 Jun 2020 03:40:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMhv0sby6Zs/ZRv9ZeMRqmK1DU09FBFNTmB6SeRSV6riuYICh5x6WAbQN5N8cN7yDMHPzo X-Received: by 2002:a05:6402:155a:: with SMTP id p26mr29470231edx.376.1591180821816; Wed, 03 Jun 2020 03:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591180821; cv=none; d=google.com; s=arc-20160816; b=QOe1v12QmhclHYB1QmT+OEBpxWUaKCaKg3Se5biLeLyXe5R7ub/op72Bt4xTKgnGEQ n5UbAhJEOPQFuCJAML9rNVdMtZdaTIc9V7ShgrzXDP8MN0JrPrUEQn3ptfuPOIj0Ro/N J1BMW7ZO/tvFy6PzIvoCcJv+AadVctCnLRIBLJ6+Ccc4TKkjRiq0sL0dg/H4napJZaM0 /KWcTNGnbLq6ZxwUkAKpUfYf6WnBaUovl6xrJZnoyjwC2kwSCgbyR8Dl+lmTPh4qlMGU HdG+O+RQr3dWTgPw5PpmRYncDl+6cZ/YoKLZl7qUlzamjdFLhvyI35LBDi4ucUlwhW0O Q2Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from; bh=xovdMjsXLFh4AT2rFWQnqy91b4CXc49lN8Eeg00N2MU=; b=WXd4DdQPBE5Vsb6eqKBdVFfM1Qptw5iI/UTMahXQjPqGxfTx0laYb3nu/qNsD+Yxkz D+D4vvwOmPzU429doZpkdlEZrKa1FtVp6JegDM5dv6QpMAJ/xIn133/GNRB/YUlBfFDj nIbrXpGZ5XGTxPGcoUT1LGUEn8ffGCJx55vTIufmvXA8pk9vgDNknUiH0hfptiMs6UCT +w9o9go4Fjo9meMpwW+Ho4i8oGKQy5OXahAL9aNsLUvI97CBeTe6oQtpuolW3OXRwBJI AfLrok/CmROxNMmQPSaszYt+hirVs5ICS3ZWVEMFnvsX5joA9MoUG0bHIXVDzLXlLKUO UzfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn13si557913edb.68.2020.06.03.03.39.59; Wed, 03 Jun 2020 03:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726038AbgFCKhi (ORCPT + 99 others); Wed, 3 Jun 2020 06:37:38 -0400 Received: from inva021.nxp.com ([92.121.34.21]:53340 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725859AbgFCKhg (ORCPT ); Wed, 3 Jun 2020 06:37:36 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 77BD5200E03; Wed, 3 Jun 2020 12:37:34 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3D04F200DFE; Wed, 3 Jun 2020 12:37:29 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 80710402B1; Wed, 3 Jun 2020 18:37:22 +0800 (SGT) From: Shengjiu Wang To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org, ckeepax@opensource.cirrus.com, allison@lohutok.net, info@metux.net, tglx@linutronix.de, patches@opensource.cirrus.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/2] ASoC: wm8960: Support headphone jack detection function Date: Wed, 3 Jun 2020 18:26:53 +0800 Message-Id: <1591180013-12416-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1591180013-12416-1-git-send-email-shengjiu.wang@nxp.com> References: <1591180013-12416-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two platform variables for headphone jack detection. "hp_cfg" is for configuration of heaphone jack detection. "gpio_cfg" is for configuration of gpio, the gpio is used for plug & unplug interrupt on SoC. Signed-off-by: Shengjiu Wang --- include/sound/wm8960.h | 17 +++++++++++++++++ sound/soc/codecs/wm8960.c | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/sound/wm8960.h b/include/sound/wm8960.h index d22e84805025..275fd5b201ce 100644 --- a/include/sound/wm8960.h +++ b/include/sound/wm8960.h @@ -16,6 +16,23 @@ struct wm8960_data { bool capless; /* Headphone outputs configured in capless mode */ bool shared_lrclk; /* DAC and ADC LRCLKs are wired together */ + + /* + * Setup for headphone detection + * + * hp_cfg[0]: HPSEL[1:0] of R48 (Additional Control 4) + * hp_cfg[1]: {HPSWEN:HPSWPOL} of R24 (Additional Control 2). + * hp_cfg[2]: {TOCLKSEL:TOEN} of R23 (Additional Control 1). + */ + u32 hp_cfg[3]; + + /* + * Setup for gpio configuration + * + * gpio_cfg[0]: ALRCGPIO of R9 (Audio interface) + * gpio_cfg[1]: {GPIOPOL:GPIOSEL[2:0]} of R48 (Additional Control 4). + */ + u32 gpio_cfg[2]; }; #endif diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 6cf0f6612bda..2f7f0493144a 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -1389,6 +1389,12 @@ static void wm8960_set_pdata_from_of(struct i2c_client *i2c, if (of_property_read_bool(np, "wlf,shared-lrclk")) pdata->shared_lrclk = true; + + of_property_read_u32_array(np, "wlf,gpio-cfg", pdata->gpio_cfg, + ARRAY_SIZE(pdata->gpio_cfg)); + + of_property_read_u32_array(np, "wlf,hp-cfg", pdata->hp_cfg, + ARRAY_SIZE(pdata->hp_cfg)); } static int wm8960_i2c_probe(struct i2c_client *i2c, @@ -1446,6 +1452,20 @@ static int wm8960_i2c_probe(struct i2c_client *i2c, regmap_update_bits(wm8960->regmap, WM8960_LOUT2, 0x100, 0x100); regmap_update_bits(wm8960->regmap, WM8960_ROUT2, 0x100, 0x100); + /* ADCLRC pin configured as GPIO. */ + regmap_update_bits(wm8960->regmap, WM8960_IFACE2, 1 << 6, + wm8960->pdata.gpio_cfg[0] << 6); + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 0xF << 4, + wm8960->pdata.gpio_cfg[1] << 4); + + /* Enable headphone jack detect */ + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL4, 3 << 2, + wm8960->pdata.hp_cfg[0] << 2); + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL2, 3 << 5, + wm8960->pdata.hp_cfg[1] << 5); + regmap_update_bits(wm8960->regmap, WM8960_ADDCTL1, 3, + wm8960->pdata.hp_cfg[2]); + i2c_set_clientdata(i2c, wm8960); ret = devm_snd_soc_register_component(&i2c->dev, -- 2.21.0