Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp207301pxy; Fri, 7 May 2021 01:07:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/zQ/yvlLq2y11X/0Deqd+bR0wBwYVjayhcek5uJB5/a52py4uvbqCQ3e8Fxu/k17cL9Ck X-Received: by 2002:a17:906:3544:: with SMTP id s4mr8809175eja.73.1620374849716; Fri, 07 May 2021 01:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620374849; cv=none; d=google.com; s=arc-20160816; b=WJymq6fwmLdDoWL2fhn3Nbeq1/Oa0rQ2LswhI14VxLiSDjgeAr0YNb+/mp0rIOR0Xs Ne4ru3csB+KWV2n9L46cQvGf9gXfdi0CrcDXKiozkmV8xEHmFWXFyl/ksNmrYDhumICm 7KXt4xyXpcdIcABNwJYdUzOS6EnJnzD7scmpAp0IdF5VT/xxXsFWVWRkXqS/fVY/V5Yu FOvCmQw9+MxQClJid/di18DSvxIjnIZzAw2zyiI/f0W00bN9olaJfsokP0DJRSsDt0iy LXsUc3yrqk986MRGKr+Ep3LJp52DoJ3WIDdzQyUiZ69BIy/KK5xC5BPNp2BDT5K1F6DV 0dKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:date:message-id:in-reply-to:subject :cc:to:from:user-agent:references:dkim-signature; bh=FVGhI0piG/ZT4z3Zm+F7e5QmKPHr5hT6fO27OeIGutE=; b=cyCeCiSPe7xpjr+y7qIfCtFNYOqSdUqARpHSjrBK6GF7UTav9WDQQsGBGICYrnLVK0 3bvC51JJ7Kko1BuyLIEge3yir8P0Jq+m/SRzkGHhngJXvkKNwoGwwwQHIWc1jdqLbUIx ejfCbWHhVcVF84oeA2N0ZJ66COjJJr3/4YYm5jKTANpRBnqLbuy2GZe9eeIWGk7hVJ0Q PHiRvz4IO+aUGUshXX5A+3OGGgQZEV/9/npfs/8zWchln2gk60LJGakhCFUssUwJ9IWe rrk6Ju6jf7hl9qdPQlOqE4DC7ukwLH0hjHDV/EQ7oGcyWfSovZcV7M2HPcU91DiJa4x1 aBzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=z+XBo5R6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si331353eds.436.2021.05.07.01.07.04; Fri, 07 May 2021 01:07:29 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=z+XBo5R6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235487AbhEGHkI (ORCPT + 99 others); Fri, 7 May 2021 03:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235498AbhEGHj4 (ORCPT ); Fri, 7 May 2021 03:39:56 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 635EAC061574 for ; Fri, 7 May 2021 00:38:55 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id l7so9095194edb.1 for ; Fri, 07 May 2021 00:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=FVGhI0piG/ZT4z3Zm+F7e5QmKPHr5hT6fO27OeIGutE=; b=z+XBo5R6JvT8Y/3Vvp7a8IhFg5DOTNiOhZHUOfwNW9F9cvzxk9e0JfqlXSNTMVs4iS ijaqMc/rM87W50WuKQS9+5xQvvqJymy9S94wGVw43B3hp/zogfm9SUDw/9fiq12EpX4K l5WEsUo5LwRC9awZm8SMSMiPwxj/YDUSepflwnOGZGi30uBuEBfkJmcz8zIZ+1hF+zdU Fb4YWgcpA4T6fi48UadwBMhnCVi1cIHHOXRBuuxRTFOCV2vgoC6HwCF0QH0wsAPC/XCX p+lHNmqpLAzaEBDFDzE80+MU+iY7/xXHlOFIlS1qnZizA5qJSRT3ynHacFWCgqIlNvue kN3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=FVGhI0piG/ZT4z3Zm+F7e5QmKPHr5hT6fO27OeIGutE=; b=k+ezQXTPHN2nYgLptbCjGWcCl17KmP1OEiU4PHfTATd0+mzUTZtVEOOVYT1lXTLh/D cMUn3boztm+ZMSleFmqtDQEU06Vs1XPPS/wUv4NhPtEMw/2mTWOUWsG4kcWx04T3Ac+a 3AU8HxwfBh/Rr4x3ATuoU+tiAbefrBH2TJzfekk7fTf4+7myHYCc4iVmJKMBhz0Zk+SE ycSmXKOGWRq6wTBvHPFiBcWNIcvl6K0Foctm+waihAxzxTcPDQhsA+TGDSysocjCOEY1 a2N/k0/v3djxZQhdS+tkA/UbRVyy//yqY9/edHo/mLIAuzkv5J0fAaxOhrP31o38Eq4r e7Ow== X-Gm-Message-State: AOAM532o71K8S2u9rOJcVuL+qV1XGBgcgzIHiGENX34x2yZRzKaKQWd3 3f7m/r7i5itHt9okPxf59ha825qjxV/wFQ== X-Received: by 2002:a05:6402:268f:: with SMTP id w15mr9534035edd.321.1620373134041; Fri, 07 May 2021 00:38:54 -0700 (PDT) Received: from localhost (82-65-169-74.subs.proxad.net. [82.65.169.74]) by smtp.gmail.com with ESMTPSA id b12sm3549997eds.23.2021.05.07.00.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 00:38:53 -0700 (PDT) References: <20210505072607.3815442-1-narmstrong@baylibre.com> <20210505072607.3815442-4-narmstrong@baylibre.com> User-agent: mu4e 1.4.15; emacs 27.1 From: Jerome Brunet To: Neil Armstrong , broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] sound: meson: g12a-toacodec: add support for SM1 TOACODEC In-reply-to: Message-ID: <1jlf8rngc3.fsf@starbuckisacylon.baylibre.com> Date: Fri, 07 May 2021 09:38:52 +0200 MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 05 May 2021 at 09:27, Neil Armstrong wrote: > On 05/05/2021 09:26, Neil Armstrong wrote: >> This adds support for the TOACODEC found in Amlogic SM1 SoCs. >> >> The bits are shifted for more selection of clock sources, so this only >> maps the same support for G12A to the SM1 bits. >> >> Signed-off-by: Neil Armstrong >> --- >> sound/soc/meson/g12a-toacodec.c | 64 ++++++++++++++++++++++++++++++++- >> 1 file changed, 63 insertions(+), 1 deletion(-) >> >> diff --git a/sound/soc/meson/g12a-toacodec.c b/sound/soc/meson/g12a-toacodec.c >> index 2084c9542c9c..5437ecba9c47 100644 >> --- a/sound/soc/meson/g12a-toacodec.c >> +++ b/sound/soc/meson/g12a-toacodec.c >> @@ -21,13 +21,22 @@ >> >> #define TOACODEC_CTRL0 0x0 >> #define CTRL0_ENABLE_SHIFT 31 >> +#define CTRL0_DAT_SEL_SM1_MSB 19 >> +#define CTRL0_DAT_SEL_SM1_LSB 18 >> #define CTRL0_DAT_SEL_MSB 15 >> #define CTRL0_DAT_SEL_LSB 14 >> +#define CTRL0_LANE_SEL_SM1 16 >> #define CTRL0_LANE_SEL 12 >> +#define CTRL0_LRCLK_SEL_SM1_MSB 14 >> +#define CTRL0_LRCLK_SEL_SM1_LSB 12 >> #define CTRL0_LRCLK_SEL_MSB 9 >> #define CTRL0_LRCLK_SEL_LSB 8 >> +#define CTRL0_LRCLK_INV_SM1 BIT(10) >> +#define CTRL0_BLK_CAP_INV_SM1 BIT(9) >> #define CTRL0_BLK_CAP_INV BIT(7) >> +#define CTRL0_BCLK_O_INV_SM1 BIT(8) >> #define CTRL0_BCLK_O_INV BIT(6) >> +#define CTRL0_BCLK_SEL_SM1_MSB 6 >> #define CTRL0_BCLK_SEL_MSB 5 >> #define CTRL0_BCLK_SEL_LSB 4 >> #define CTRL0_MCLK_SEL GENMASK(2, 0) >> @@ -41,6 +50,7 @@ struct g12a_toacodec { >> }; >> >> struct g12a_toacodec_match_data { >> + const struct snd_soc_component_driver *component_drv; >> struct reg_field field_dat_sel; >> struct reg_field field_lrclk_sel; >> struct reg_field field_bclk_sel; >> @@ -98,11 +108,20 @@ static SOC_ENUM_SINGLE_DECL(g12a_toacodec_mux_enum, TOACODEC_CTRL0, >> CTRL0_DAT_SEL_LSB, >> g12a_toacodec_mux_texts); >> >> +static SOC_ENUM_SINGLE_DECL(sm1_toacodec_mux_enum, TOACODEC_CTRL0, >> + CTRL0_DAT_SEL_SM1_LSB, >> + g12a_toacodec_mux_texts); >> + >> static const struct snd_kcontrol_new g12a_toacodec_mux = >> SOC_DAPM_ENUM_EXT("Source", g12a_toacodec_mux_enum, >> snd_soc_dapm_get_enum_double, >> g12a_toacodec_mux_put_enum); >> >> +static const struct snd_kcontrol_new sm1_toacodec_mux = >> + SOC_DAPM_ENUM_EXT("Source", sm1_toacodec_mux_enum, >> + snd_soc_dapm_get_enum_double, >> + g12a_toacodec_mux_put_enum); >> + >> static const struct snd_kcontrol_new g12a_toacodec_out_enable = >> SOC_DAPM_SINGLE_AUTODISABLE("Switch", TOACODEC_CTRL0, >> CTRL0_ENABLE_SHIFT, 1, 0); >> @@ -114,6 +133,13 @@ static const struct snd_soc_dapm_widget g12a_toacodec_widgets[] = { >> &g12a_toacodec_out_enable), >> }; >> >> +static const struct snd_soc_dapm_widget sm1_toacodec_widgets[] = { >> + SND_SOC_DAPM_MUX("SRC", SND_SOC_NOPM, 0, 0, >> + &sm1_toacodec_mux), >> + SND_SOC_DAPM_SWITCH("OUT EN", SND_SOC_NOPM, 0, 0, >> + &g12a_toacodec_out_enable), >> +}; >> + >> static int g12a_toacodec_input_hw_params(struct snd_pcm_substream *substream, >> struct snd_pcm_hw_params *params, >> struct snd_soc_dai *dai) >> @@ -184,6 +210,13 @@ static int g12a_toacodec_component_probe(struct snd_soc_component *c) >> CTRL0_BLK_CAP_INV); >> } >> >> +static int sm1_toacodec_component_probe(struct snd_soc_component *c) >> +{ >> + /* Initialize the static clock parameters */ >> + return snd_soc_component_write(c, TOACODEC_CTRL0, >> + CTRL0_BLK_CAP_INV_SM1); >> +} >> + >> static const struct snd_soc_dapm_route g12a_toacodec_routes[] = { >> { "SRC", "I2S A", "IN A Playback" }, >> { "SRC", "I2S B", "IN B Playback" }, >> @@ -196,6 +229,10 @@ static const struct snd_kcontrol_new g12a_toacodec_controls[] = { >> SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL, 3, 0), >> }; >> >> +static const struct snd_kcontrol_new sm1_toacodec_controls[] = { >> + SOC_SINGLE("Lane Select", TOACODEC_CTRL0, CTRL0_LANE_SEL_SM1, 3, 0), >> +}; >> + >> static const struct snd_soc_component_driver g12a_toacodec_component_drv = { >> .probe = g12a_toacodec_component_probe, >> .controls = g12a_toacodec_controls, >> @@ -208,6 +245,18 @@ static const struct snd_soc_component_driver g12a_toacodec_component_drv = { >> .non_legacy_dai_naming = 1, >> }; >> >> +static const struct snd_soc_component_driver sm1_toacodec_component_drv = { >> + .probe = sm1_toacodec_component_probe, >> + .controls = sm1_toacodec_controls, >> + .num_controls = ARRAY_SIZE(sm1_toacodec_controls), >> + .dapm_widgets = sm1_toacodec_widgets, >> + .num_dapm_widgets = ARRAY_SIZE(sm1_toacodec_widgets), >> + .dapm_routes = g12a_toacodec_routes, >> + .num_dapm_routes = ARRAY_SIZE(g12a_toacodec_routes), >> + .endianness = 1, >> + .non_legacy_dai_naming = 1, >> +}; >> + >> static const struct regmap_config g12a_toacodec_regmap_cfg = { >> .reg_bits = 32, >> .val_bits = 32, >> @@ -215,16 +264,29 @@ static const struct regmap_config g12a_toacodec_regmap_cfg = { >> }; >> >> static const struct g12a_toacodec_match_data g12a_toacodec_match_data = { >> + .component_drv = &g12a_toacodec_component_drv, >> .field_dat_sel = REG_FIELD(TOACODEC_CTRL0, CTRL0_DAT_SEL_LSB, CTRL0_DAT_SEL_MSB), >> .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, CTRL0_LRCLK_SEL_LSB, CTRL0_LRCLK_SEL_MSB), >> .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, CTRL0_BCLK_SEL_LSB, CTRL0_BCLK_SEL_MSB), >> }; >> >> +static const struct g12a_toacodec_match_data sm1_toacodec_match_data = { >> + .component_drv = &sm1_toacodec_component_drv, >> + .field_dat_sel = REG_FIELD(TOACODEC_CTRL0, CTRL0_DAT_SEL_SM1_LSB, CTRL0_DAT_SEL_SM1_MSB), >> + .field_lrclk_sel = REG_FIELD(TOACODEC_CTRL0, CTRL0_LRCLK_SEL_SM1_LSB, >> + CTRL0_LRCLK_SEL_SM1_MSB), >> + .field_bclk_sel = REG_FIELD(TOACODEC_CTRL0, CTRL0_BCLK_SEL_LSB, CTRL0_BCLK_SEL_SM1_MSB), >> +}; If you make another round, the LSB/MSB defines don't really help readability here (and in the other patch) Feel free to put the values directly. >> + >> static const struct of_device_id g12a_toacodec_of_match[] = { >> { >> .compatible = "amlogic,g12a-toacodec", >> .data = &g12a_toacodec_match_data, >> }, >> + { >> + .compatible = "amlogic,sm1-toacodec", >> + .data = &sm1_toacodec_match_data, >> + }, >> {} >> }; >> MODULE_DEVICE_TABLE(of, g12a_toacodec_of_match); >> @@ -278,7 +340,7 @@ static int g12a_toacodec_probe(struct platform_device *pdev) >> return PTR_ERR(priv->field_bclk_sel); >> >> return devm_snd_soc_register_component(dev, >> - &g12a_toacodec_component_drv, g12a_toacodec_dai_drv, >> + data->component_drv, g12a_toacodec_dai_drv, >> ARRAY_SIZE(g12a_toacodec_dai_drv)); >> } >> >> > > Oops, spurious one, please ignore it. > > Neil