From patchwork Fri Jan 6 09:15:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 640105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E473C54EBD for ; Fri, 6 Jan 2023 09:19:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5F5C314129; Fri, 6 Jan 2023 10:18:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5F5C314129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996787; bh=mvlrlWGPrgMMNVvWDqjbjUGYhSv1a/l4do+dVGBQu+8=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=CN8zG+CXvlRywUoVOszLxs+Maz75lGmWh+AATHNzSnHQgvIqvNlE70FLMXxuwnAMj 9PUDQIIxXn4K0WE48CnQG1Y1HxdXpBY+scFLW0PvQL8+WJH2C4TRDwsfGr3we95Qq7 qshwtuidbh8iVT11Q4/ajU9ijx+L1KS5HdzKNvpk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 141BAF805BD; Fri, 6 Jan 2023 10:16:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 03DE7F8055B; Fri, 6 Jan 2023 10:16:16 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2082.outbound.protection.outlook.com [40.107.129.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 071E1F8057B for ; Fri, 6 Jan 2023 10:16:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 071E1F8057B ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VN2nP9B1IE3R43jz/nBznfgbwi286KnWI1u9a1sG73qIrRIre0yGt5zAgDn+UxbxKFUMhzM1NgHnPHvGTLroY+kJg6mded/T/Z32tm7vTCyIHzSAF3r7ABzvapusdAxddGkkB2HEYmIp4Hzqfc0Irgqy7YkeIG9EpuWWmOBdnC933MgNpBTTYga1tddTxSiKpvwjuMyPTM0FitR6F5DkVCyQnjcIxpCWNqjIH3AWsbnD9Q2KGc4rOOPv9Qk2YFMElRyibLTt1iCkc0oWNSLYhloyfI2zVam/7g7BFLyBkxuPO1bZ7hSqFKN75gFKItF08DnSqJ5Te3JvpxK9XlSxzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mFu054Sld/rX/gGh+pjGNYT/fTOLWAFMzCUqhejRh28=; b=ZJW1pWMXDqiofYUTXBpNhd2s7epcuL14ZQxa93IGfMlBa3Zj95JJxMg0AqX4lgSK7YUQGmH0+SgFZ/ZYVlnT9KyByxV3J5lDfj11o+FwYl/imxTcpKlYc4uHrtqVDYu56+e5EIyDX/3LbLZOqxk0M4TsKYoKWjuthrwC7KEXw9cAf+4/76Lx6l7V+KwsPd2UU6RTRaPT/M87/zffJN773o9hwfYMLZoMmZW0+ROdM7cmUAv73aL+KEHCFIkDJUpHvsz0pMLSw4r95301HlJ5gDUqK2sZyz2hHDU3mH11oZiYqcPdKIh4zZE9Hz8IBqfyshrqWU/kuO0/s7xGDm0wIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:55 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:55 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 01/14] ASoC: sma1303: Add driver for Iron Device SMA1303 Amp Date: Fri, 6 Jan 2023 18:15:30 +0900 Message-Id: <20230106091543.2440-2-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 27a71c7d-548e-4ebd-048c-08daefc69d76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JiUxDGSoFBWtU58LBRQdoRCxIhTIOdLBfL6Eatb5IJhS3v3voVfyOmAH9iddUsIHpybv/O8VXT/5EmZJJrF64FseIR4WHHawT4m6/ttOHE2mylxXEB6gilY0yjXgW4CJTsxVKYVgACty1uvIXImQvE+Uitv5n0KDW7RF0c4IDbrKxw4Vdd1Lhf+aWqIWbCooLciowNmyybD6uhJ+U8ZUPCvYh42zmSHd9LsAvjYW7ySajZ+d9jdzaWXnzov8WNbmwUQYOYoGGOLiU0JxVlVrB+bquMwsTMJnC9UZGRc273TeB6NKT84EFiqqBBBIHfqmMJZjidPAaOwgxXaP+yGqPVJ3jNBX9vmKPJYZFan/5F5AACmMELKo2bYfj1wEPGxLJcBfCG+AMxG4AmbgG0VTzA+jL3SrVJxjrQlAj9NpvLEgR2xLL2wJmtu5i2/QLbNjhsLvXbdL2+c5IkaSXrsea1JdPoNJCtpKcBKGrSiWRDiEzpY/ibzats0QQuiQ9cx1WvLb47RPFz4B4PB/kvW8a2sziHuNIj/hsYn1658w6dQMdqZIvDWrFKT1t0plRBjebwRZUPrqHJ252xPZTkQbNKdaGidb0YiOfonhFtbpEIGkIM1VORZ8gtsKs2eeIoBGNZWfs/gIriVwLJYmRmPkVsCzU6laRfiooVIU2wfl7+cKxdOrxycgZhaeyeM/fWDHoxwTXsAzrfKp3QlI+DHj1ldCxUzq/DFSHme2og+NGkU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(30864003)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003)(2004002)(579004)(559001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UONLcWEJSj/Ie3yANBOQm2/3EuMNoowFPwK2RHnUxF/QgehwBvzR1fHULB3yX7YBw1/gVyFAkBlCLl4YlNqs4aIRKc991GxP26AQtBhH84lBwlXX4WaOp8nSWrIaELLNnufi2dLXt3awV8BFsskxwVyOQgO4MONKO0EvRcRMOffqvbNLJ7q/R4HLpBIyATOwMy9bEWilg8nnkIvqwY6rCDcA7C06U5ETeDn//wMYCSimDrkRmeOg65H2BB1B80Vd0HBASNiz3+KrMlJHuFRyp2EHItXiAIRs4KASfgppRC/I7hNZMwnwavOwIKTcTOt4joro7nHHBaRq465eoCsRssg9QlG8lEDWrAl608jtR/1ZEGDd7yCpgNhOwhR3oY+kArzMSSKT6sBwViFWbilHCHUGSkkVxZbaZqkxrAAhpjXzgcCnMZoYPiKPB1+g7G24Iegva5NzjPy1DPs/DPm+N8B38rGA1vm2l6qBL2oEXJA4Olpy3Sj1MSBzEvODie3OxuiLzNXb5WYVYxyrkeU3N5uU0ZpNT39aYd2H8QPgiZKhYlMKB6U98gd0gnB0vnYv7Y8hfTy4lcEUnFVms1WfQlVVMBgTpL+a6YHuMAC5a9MVp/WR1n3Am4acmlMlAlt2vRzuQfh98yhq3keOkRueQfmL02P/3TZHesSbgulfRw4YPwGgyTQcmxOAHbyyWe/RFMOftVGJTLc06mXCdTVoRgGwGJWsA85VlQ4zmLcNvGmvmDYwC0VDzloroFpHkdXDZrnbSIS+Kj+6e09hqsN+Z0d4pdAjTXcAzkFS0tRd8AsbRtslxRFnSvVEQwdmjstqABRBkKrzIiEAhkvAJ0AJLKClRK5d0An4qZmPT2kY+3EFL9tM+KXzoHz6PGOBboa1aAPUg4Al/zJMNYTmVkBTI/sXf22Ot36yFHslBkcslzbtaDdw68Xrs4yG1cr/LSL2Rv2gbTxqCzmKpcOYZnlMnNi5u4IfwbKGhAjM0aTQJk2tqDaxynly1pKVqDzWetQEgmNahCM446JbZ07gj1lH716tpQQKNo26KUoZlzSBqAD1q55yClrRrLXElxYU5g4msfNknvp/CPpK4s/kjFUKD2VaekKom2JEzIwiVgTLI2HmTnzhJ2/RnYCUonvBlA5JlGQdH20oPqN6r8JVuObXx87/l+vNr/H6aTiaLu2pERx4QoloVjC6UHejqCoCJW+erMbhKqkOyFT4bjSEDtwO0/Kw3+CpUWvmpmqiKGTsPqiSl9MA5zSXCHA0DZiHd2l/wB694+Q5tjiDWK2UV10Cawms94DqYZgGja7xi+Q3SoRIibIfDPFxs85ib9nreV6Yv5INKwlpVkRO8CpRAWNCrUj09D2JUcYdeZFpI15cUstBVhLYlDPXBjMNgSLOYoEO6F9LfrVUtVThK1PG0+9J9nThgckQIAon8cxg9rxJtOZyhRXWRATBH/NK871T0rQxyumQiwd7/TBOjieYGmUn57ahs0ViGbthUcBnQN2WFs6B5sHE4sX6+3gRQrTilFzvsvEHpeXM4EJqQakYDppNkqg3S4ZSP2Liu245eX3znmfwHL1lR17sBL0I0UwiXZl8 X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27a71c7d-548e-4ebd-048c-08daefc69d76 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:55.6447 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SivI2MlzjWi8mDUn8aktT2td03IvHdJ4mlmuLaexmU5YRlvKOpHO0sVsxzXTSv8xErJgmRSyqVA9uJ/b7VlmgS+UYVtTxER8XtAiravvRSM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The Iron Device SMA1303 is a boosted Class-D audio amplifier. Signed-off-by: Kiseok Jo --- sound/soc/codecs/Kconfig | 7 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/sma1303.c | 2117 ++++++++++++++++++++++++++++++++++++ sound/soc/codecs/sma1303.h | 609 +++++++++++ 4 files changed, 2735 insertions(+) create mode 100644 sound/soc/codecs/sma1303.c create mode 100644 sound/soc/codecs/sma1303.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 0f9d71490075..83d2981a400e 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -206,6 +206,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_SI476X imply SND_SOC_SIMPLE_AMPLIFIER imply SND_SOC_SIMPLE_MUX + imply SND_SOC_SMA1303 imply SND_SOC_SPDIF imply SND_SOC_SRC4XXX_I2C imply SND_SOC_SSM2305 @@ -1492,6 +1493,12 @@ config SND_SOC_SIMPLE_MUX tristate "Simple Audio Mux" depends on GPIOLIB +config SND_SOC_SMA1303 + tristate "Iron Device SMA1303 Audio Amplifier" + depends on I2C + help + Enable support for Iron Device SMA1303 Boosted Class-D amplifier + config SND_SOC_SPDIF tristate "S/PDIF CODEC" diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 71d3ce5867e4..89ffd06e9290 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -233,6 +233,7 @@ snd-soc-sigmadsp-objs := sigmadsp.o snd-soc-sigmadsp-i2c-objs := sigmadsp-i2c.o snd-soc-sigmadsp-regmap-objs := sigmadsp-regmap.o snd-soc-si476x-objs := si476x.o +snd-soc-sma1303-objs := sma1303.o snd-soc-spdif-tx-objs := spdif_transmitter.o snd-soc-spdif-rx-objs := spdif_receiver.o snd-soc-src4xxx-objs := src4xxx.o @@ -588,6 +589,7 @@ obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o obj-$(CONFIG_SND_SOC_SIGMADSP_REGMAP) += snd-soc-sigmadsp-regmap.o obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o +obj-$(CONFIG_SND_SOC_SMA1303) += snd-soc-sma1303.o obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o obj-$(CONFIG_SND_SOC_SRC4XXX) += snd-soc-src4xxx.o obj-$(CONFIG_SND_SOC_SRC4XXX_I2C) += snd-soc-src4xxx-i2c.o diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c new file mode 100644 index 000000000000..50b471920fc8 --- /dev/null +++ b/sound/soc/codecs/sma1303.c @@ -0,0 +1,2117 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* sma1303.c -- sma1303 ALSA SoC Audio driver + * + * Copyright 2022 Iron Device Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sma1303.h" + +#define CHECK_PERIOD_TIME 1 /* sec per HZ */ + +#define PLL_MATCH(_input_clk_name, _output_clk_name, _input_clk,\ + _post_n, _n, _vco, _p_cp)\ +{\ + .input_clk_name = _input_clk_name,\ + .output_clk_name = _output_clk_name,\ + .input_clk = _input_clk,\ + .post_n = _post_n,\ + .n = _n,\ + .vco = _vco,\ + .p_cp = _p_cp,\ +} + +enum sma1303_type { + SMA1303, +}; + +struct sma1303_pll_match { + char *input_clk_name; + char *output_clk_name; + unsigned int input_clk; + unsigned int post_n; + unsigned int n; + unsigned int vco; + unsigned int p_cp; +}; + +struct sma1303_priv { + enum sma1303_type devtype; + struct device *dev; + struct attribute_group *attr_grp; + struct kobject *kobj; + struct regmap *regmap; + struct sma1303_pll_match *pll_matches; + struct mutex lock; + struct delayed_work check_fault_work; + bool amp_power_status; + bool usage_status; + int num_of_pll_matches; + unsigned int sys_clk_id; + unsigned int init_vol; + unsigned int cur_vol; + unsigned int tdm_slot_rx; + unsigned int tdm_slot_tx; + unsigned int tsdw_cnt; + unsigned int format; + unsigned int rev_num; + unsigned int last_over_temp; + unsigned int last_ocp_val; + unsigned int last_bclk; + unsigned int frame_size; + unsigned int amp_mode; + long check_fault_period; + long check_fault_status; +}; + +static struct sma1303_pll_match sma1303_pll_matches[] = { +PLL_MATCH("1.411MHz", "24.595MHz", 1411200, 0x07, 0xF4, 0x8B, 0x03), +PLL_MATCH("1.536MHz", "24.576MHz", 1536000, 0x07, 0xE0, 0x8B, 0x03), +PLL_MATCH("3.072MHz", "24.576MHz", 3072000, 0x07, 0x70, 0x8B, 0x03), +PLL_MATCH("6.144MHz", "24.576MHz", 6144000, 0x07, 0x70, 0x8B, 0x07), +PLL_MATCH("12.288MHz", "24.576MHz", 12288000, 0x07, 0x70, 0x8B, 0x0B), +PLL_MATCH("19.2MHz", "24.343MHz", 19200000, 0x07, 0x47, 0x8B, 0x0A), +PLL_MATCH("24.576MHz", "24.576MHz", 24576000, 0x07, 0x70, 0x8B, 0x0F), +}; + +static int sma1303_startup(struct snd_soc_component *); +static int sma1303_shutdown(struct snd_soc_component *); + +static const struct reg_default sma1303_reg_def[] = { + { 0x00, 0x80 }, + { 0x01, 0x00 }, + { 0x02, 0x00 }, + { 0x03, 0x11 }, + { 0x04, 0x17 }, + { 0x09, 0x00 }, + { 0x0A, 0x31 }, + { 0x0B, 0x98 }, + { 0x0C, 0x84 }, + { 0x0D, 0x07 }, + { 0x0E, 0x3F }, + { 0x10, 0x00 }, + { 0x11, 0x00 }, + { 0x12, 0x00 }, + { 0x14, 0x5C }, + { 0x15, 0x01 }, + { 0x16, 0x0F }, + { 0x17, 0x0F }, + { 0x18, 0x0F }, + { 0x19, 0x00 }, + { 0x1A, 0x00 }, + { 0x1B, 0x00 }, + { 0x23, 0x19 }, + { 0x24, 0x00 }, + { 0x25, 0x00 }, + { 0x26, 0x04 }, + { 0x33, 0x00 }, + { 0x36, 0x92 }, + { 0x37, 0x27 }, + { 0x3B, 0x5A }, + { 0x3C, 0x20 }, + { 0x3D, 0x00 }, + { 0x3E, 0x03 }, + { 0x3F, 0x0C }, + { 0x8B, 0x07 }, + { 0x8C, 0x70 }, + { 0x8D, 0x8B }, + { 0x8E, 0x6F }, + { 0x8F, 0x03 }, + { 0x90, 0x26 }, + { 0x91, 0x42 }, + { 0x92, 0xE0 }, + { 0x94, 0x35 }, + { 0x95, 0x0C }, + { 0x96, 0x42 }, + { 0x97, 0x95 }, + { 0xA0, 0x00 }, + { 0xA1, 0x3B }, + { 0xA2, 0xC8 }, + { 0xA3, 0x28 }, + { 0xA4, 0x40 }, + { 0xA5, 0x01 }, + { 0xA6, 0x41 }, + { 0xA7, 0x00 }, +}; + +static bool sma1303_readable_register(struct device *dev, unsigned int reg) +{ + bool result; + + if (reg > SMA1303_FF_DEVICE_INDEX) + return false; + + switch (reg) { + case SMA1303_00_SYSTEM_CTRL ... SMA1303_04_INPUT1_CTRL4: + case SMA1303_09_OUTPUT_CTRL ... SMA1303_0E_MUTE_VOL_CTRL: + case SMA1303_10_SYSTEM_CTRL1 ... SMA1303_12_SYSTEM_CTRL3: + case SMA1303_14_MODULATOR ... SMA1303_1B_BASS_SPK7: + case SMA1303_23_COMP_LIM1 ... SMA1303_26_COMP_LIM4: + case SMA1303_33_SDM_CTRL ... SMA1303_34_OTP_DATA1: + case SMA1303_36_PROTECTION ... SMA1303_38_OTP_TRM0: + case SMA1303_3B_TEST1 ... SMA1303_3F_ATEST2: + case SMA1303_8B_PLL_POST_N ... SMA1303_92_FDPEC_CTRL: + case SMA1303_94_BOOST_CTRL1 ... SMA1303_97_BOOST_CTRL4: + case SMA1303_A0_PAD_CTRL0 ... SMA1303_A7_CLK_MON: + case SMA1303_FA_STATUS1 ... SMA1303_FB_STATUS2: + result = true; + break; + case SMA1303_FF_DEVICE_INDEX: + result = true; + break; + default: + result = false; + } + return result; +} + +static bool sma1303_writeable_register(struct device *dev, unsigned int reg) +{ + bool result; + + if (reg > SMA1303_FF_DEVICE_INDEX) + return false; + + switch (reg) { + case SMA1303_00_SYSTEM_CTRL ... SMA1303_04_INPUT1_CTRL4: + case SMA1303_09_OUTPUT_CTRL ... SMA1303_0E_MUTE_VOL_CTRL: + case SMA1303_10_SYSTEM_CTRL1 ... SMA1303_12_SYSTEM_CTRL3: + case SMA1303_14_MODULATOR ... SMA1303_1B_BASS_SPK7: + case SMA1303_23_COMP_LIM1 ... SMA1303_26_COMP_LIM4: + case SMA1303_33_SDM_CTRL: + case SMA1303_36_PROTECTION ... SMA1303_37_SLOPE_CTRL: + case SMA1303_3B_TEST1 ... SMA1303_3F_ATEST2: + case SMA1303_8B_PLL_POST_N ... SMA1303_92_FDPEC_CTRL: + case SMA1303_94_BOOST_CTRL1 ... SMA1303_97_BOOST_CTRL4: + case SMA1303_A0_PAD_CTRL0 ... SMA1303_A7_CLK_MON: + result = true; + break; + default: + result = false; + } + return result; +} + +static bool sma1303_volatile_register(struct device *dev, unsigned int reg) +{ + bool result; + + switch (reg) { + case SMA1303_FA_STATUS1 ... SMA1303_FB_STATUS2: + result = true; + break; + case SMA1303_FF_DEVICE_INDEX: + result = true; + break; + default: + result = false; + } + return result; +} + +static const DECLARE_TLV_DB_SCALE(sma1303_spk_tlv, -6000, 50, 0); + +static int sma1303_regmap_write(struct regmap *map, struct device *dev, + unsigned int reg, unsigned int val) +{ + int ret = 0; + + ret = regmap_write(map, reg, val); + if (ret < 0) { + dev_err(dev, "Failed to write, register: 0x%02X, ret: %d\n", + reg, ret); + } + return ret; +} + +static int sma1303_regmap_update_bits(struct regmap *map, struct device *dev, + unsigned int reg, unsigned int mask, unsigned int val) +{ + int ret = 0; + + ret = regmap_update_bits(map, reg, mask, val); + if (ret < 0) { + dev_err(dev, "Failed to write, register: 0x%02X, ret: %d\n", + reg, ret); + } + return ret; +} + +static int bytes_ext_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol, int reg) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + struct soc_bytes_ext *params = (void *)kcontrol->private_value; + unsigned int i, reg_val; + u8 *val; + int ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + val = (u8 *)ucontrol->value.bytes.data; + for (i = 0; i < params->max; i++) { + ret = regmap_read(sma1303->regmap, reg + i, ®_val); + if (ret < 0) { + dev_err(component->dev, + "Failed to read, register: %x ret: %d\n", + reg + i, ret); + return ret; + } + if (sizeof(reg_val) > 2) + reg_val = cpu_to_le32(reg_val); + else + reg_val = cpu_to_le16(reg_val); + memcpy(val + i, ®_val, sizeof(u8)); + } + + return 0; +} + +static int bytes_ext_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol, int reg) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + struct soc_bytes_ext *params = (void *)kcontrol->private_value; + void *data; + u8 *val; + int i, ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + data = kmemdup(ucontrol->value.bytes.data, + params->max, GFP_KERNEL | GFP_DMA); + if (!data) + return -ENOMEM; + + val = (u8 *)data; + for (i = 0; i < params->max; i++) { + ret = sma1303_regmap_write( + sma1303->regmap, component->dev, + reg + i, *(val + i)); + if (ret < 0) { + kfree(data); + return ret; + } + } + kfree(data); + + return 0; +} + +static int amp_usage_status_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + ucontrol->value.integer.value[0] = sma1303->usage_status; + + if (sma1303->usage_status) + dev_info(component->dev, "Amplifier Power Control Enabled\n"); + else + dev_info(component->dev, "Amplifier Power Control Disabled\n"); + + return 0; +} + +static int amp_usage_status_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + if ((sma1303->usage_status + != ucontrol->value.integer.value[0]) + && (!ucontrol->value.integer.value[0])) { + dev_info(component->dev, "%s\n", "Force AMP Power Down"); + ret = sma1303_shutdown(component); + if (ret < 0) { + ucontrol->value.integer.value[0] + = sma1303->usage_status; + return ret; + } + + } + sma1303->usage_status = ucontrol->value.integer.value[0]; + + return 0; +} + +static const char * const sma1303_amp_mode_text[] = { + "1 Chip", "Mono on 2 chips", "Left in 2 chips", "Right in 2chips"}; + +static const struct soc_enum sma1303_amp_mode_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_amp_mode_text), + sma1303_amp_mode_text); +static int sma1303_amp_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + ucontrol->value.integer.value[0] = sma1303->amp_mode; + + switch (sma1303->amp_mode) { + case ONE_CHIP_SOLUTION: + dev_info(component->dev, "Amplifier 1 Chip Solution\n"); + break; + case MONO_TWO_CHIP_SOLUTION: + dev_info(component->dev, "Amplifier Mono 2 Chips Solution\n"); + break; + case LEFT_TWO_CHIP_SOLUTION: + dev_info(component->dev, "Amplifier Stereo(Left) 2 Chips Solution\n"); + break; + case RIGHT_TWO_CHIP_SOLUTION: + dev_info(component->dev, "Amplifier Stereo(Right) 2 Chips Solution\n"); + break; + default: + dev_err(component->dev, "Invalid Value"); + return ret; + } + return 0; + +} + +static int sma1303_amp_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return -1; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return -1; + } + + sma1303->amp_mode = ucontrol->value.integer.value[0]; + + switch (sma1303->amp_mode) { + case ONE_CHIP_SOLUTION: + case MONO_TWO_CHIP_SOLUTION: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_11_SYSTEM_CTRL2, + MONOMIX_MASK, MONOMIX_ON); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_11_SYSTEM_CTRL2, + LR_DATA_SW_MASK, LR_DATA_SW_NORMAL); + break; + case LEFT_TWO_CHIP_SOLUTION: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_11_SYSTEM_CTRL2, + MONOMIX_MASK, MONOMIX_OFF); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_11_SYSTEM_CTRL2, + LR_DATA_SW_MASK, LR_DATA_SW_NORMAL); + break; + case RIGHT_TWO_CHIP_SOLUTION: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_11_SYSTEM_CTRL2, + MONOMIX_MASK, MONOMIX_OFF); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_11_SYSTEM_CTRL2, + LR_DATA_SW_MASK, LR_DATA_SW_SWAP); + break; + default: + dev_err(component->dev, "Invalid Value"); + ret += -1; + } + + return ret; +} + +static const char * const sma1303_outport_config_text[] = { + "Enable", "Disable"}; + +static const struct soc_enum sma1303_outport_config_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_outport_config_text), + sma1303_outport_config_text); + +static int sma1303_outport_config_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = -1, data, val; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + ret = regmap_read(sma1303->regmap, SMA1303_09_OUTPUT_CTRL, &data); + if (ret < 0) { + dev_err(component->dev, + "Failed to read, register: %x ret: %d\n", + SMA1303_09_OUTPUT_CTRL, ret); + return ret; + } + + val = data & PORT_CONFIG_MASK; + switch (val) { + case INPUT_PORT_ONLY: + ucontrol->value.integer.value[0] = 1; + break; + case OUTPUT_PORT_ENABLE: + ucontrol->value.integer.value[0] = 0; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x value: %d\n", + SMA1303_09_OUTPUT_CTRL, val); + return ret; + } + + return 0; +} + +static int sma1303_outport_config_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int sel = (int)ucontrol->value.integer.value[0]; + int val, ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + switch (sel) { + case 0: + val = OUTPUT_PORT_ENABLE; + break; + case 1: + val = INPUT_PORT_ONLY; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x\n", + SMA1303_09_OUTPUT_CTRL); + return ret; + } + + return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_09_OUTPUT_CTRL, PORT_CONFIG_MASK, val); +} + +static const char * const sma1303_spkmute_text[] = { + "Unmute", "Mute"}; + +static const struct soc_enum sma1303_spkmute_enum = + SOC_ENUM_SINGLE(SMA1303_0E_MUTE_VOL_CTRL, 0, + ARRAY_SIZE(sma1303_spkmute_text), + sma1303_spkmute_text); + +static const char * const sma1303_spkmode_text[] = { + "Off", "On"}; + +static const struct soc_enum sma1303_spkmode_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_spkmode_text), + sma1303_spkmode_text); + +static int sma1303_spkmode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int val, data, ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + ret = regmap_read(sma1303->regmap, SMA1303_10_SYSTEM_CTRL1, &data); + if (ret < 0) { + dev_err(component->dev, + "Failed to read, register: %x ret: %d\n", + SMA1303_10_SYSTEM_CTRL1, ret); + return ret; + } + + val = data & SPK_MODE_MASK; + if (sma1303->amp_mode == ONE_CHIP_SOLUTION) { + switch (val) { + case SPK_OFF: + ucontrol->value.integer.value[0] = 0; + break; + case SPK_MONO: + ucontrol->value.integer.value[0] = 1; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x\n", + SMA1303_10_SYSTEM_CTRL1); + return ret; + } + } else { + switch (val) { + case SPK_OFF: + ucontrol->value.integer.value[0] = 0; + break; + case SPK_STEREO: + ucontrol->value.integer.value[0] = 1; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x\n", + SMA1303_10_SYSTEM_CTRL1); + return ret; + } + } + + return 0; +} + +static int sma1303_spkmode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int sel = (int)ucontrol->value.integer.value[0]; + int val, ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + switch (sel) { + case 0: + val = SPK_OFF; + break; + case 1: + if (sma1303->amp_mode == ONE_CHIP_SOLUTION) + val = SPK_MONO; + else + val = SPK_STEREO; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x\n", + SMA1303_10_SYSTEM_CTRL1); + return ret; + } + + return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, val); +} + +static int postscaler_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return bytes_ext_get(kcontrol, ucontrol, SMA1303_90_POSTSCALER); +} + +static int postscaler_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return bytes_ext_put(kcontrol, ucontrol, SMA1303_90_POSTSCALER); +} + +static const char * const sma1303_postscaler_config_text[] = { + "Enable", "Disable"}; + +static const struct soc_enum sma1303_postscaler_config_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_postscaler_config_text), + sma1303_postscaler_config_text); + +static int sma1303_postscaler_config_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = -1, data, val; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + ret = regmap_read(sma1303->regmap, SMA1303_90_POSTSCALER, &data); + if (ret < 0) { + dev_err(component->dev, + "Failed to read, register: %x ret: %d\n", + SMA1303_90_POSTSCALER, ret); + return ret; + } + + val = data & BYP_POST_MASK; + switch (val) { + case BYP_POST_SCALER: + ucontrol->value.integer.value[0] = 1; + break; + case EN_POST_SCALER: + ucontrol->value.integer.value[0] = 0; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x value: %d\n", + SMA1303_90_POSTSCALER, val); + return ret; + } + + return 0; +} + +static int sma1303_postscaler_config_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int sel = (int)ucontrol->value.integer.value[0]; + int val, ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + switch (sel) { + case 0: + val = EN_POST_SCALER; + break; + case 1: + val = BYP_POST_SCALER; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x\n", + SMA1303_90_POSTSCALER); + return ret; + } + + return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_90_POSTSCALER, BYP_POST_MASK, val); +} + +static const char * const sma1303_o_format_text[] = { + "LJ", "I2S", "TDM"}; + +static const struct soc_enum sma1303_o_format_enum = +SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_o_format_text), sma1303_o_format_text); + +static int sma1303_o_format_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int val, data, ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + ret = regmap_read(sma1303->regmap, SMA1303_A4_TOP_MAN3, &data); + val = data & O_FORMAT_MASK; + switch (val) { + case O_FMT_LJ: + ucontrol->value.integer.value[0] = 0; + break; + case O_FMT_I2S: + ucontrol->value.integer.value[0] = 1; + break; + case O_FMT_TDM: + ucontrol->value.integer.value[0] = 2; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x\n", + SMA1303_A4_TOP_MAN3); + return ret; + } + + return 0; +} +static int sma1303_o_format_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int sel = (int)ucontrol->value.integer.value[0]; + int val, ret = -1; + + if (component == NULL) { + pr_err("%s:component is NULL\n", __func__); + return ret; + } + if (sma1303 == NULL) { + pr_err("%s:sma1303 is NULL\n", __func__); + return ret; + } + + switch (sel) { + case 0: + val = O_FMT_LJ; + break; + case 1: + val = O_FMT_I2S; + break; + case 2: + val = O_FMT_TDM; + break; + default: + dev_err(component->dev, + "Invalid value, register: %x\n", + SMA1303_A4_TOP_MAN3); + return ret; + } + + return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_A4_TOP_MAN3, O_FORMAT_MASK, val); +} + +static const char * const sma1303_sdo_source_texts[] = { + "Disable", "Format_C", "Mixer_Out", "After_DSP", "After_Post"}; +static const unsigned int sma1303_sdo_source_values[] = { + OUT_SEL_DISABLE, + FORMAT_CONVERTER, + MIXER_OUTPUT, + SPEAKER_PATH, + POSTSCALER_OUTPUT}; +static SOC_VALUE_ENUM_SINGLE_DECL(sma1303_sdo_source_enum, + SMA1303_09_OUTPUT_CTRL, + 0, PORT_OUT_SEL_MASK, + sma1303_sdo_source_texts, + sma1303_sdo_source_values); +static const struct snd_kcontrol_new sma1303_sdo_source_mux = + SOC_DAPM_ENUM("SDO Source", sma1303_sdo_source_enum); + +static const struct snd_kcontrol_new sma1303_snd_controls[] = { +SOC_SINGLE_EXT("Amplifier Usage", SND_SOC_NOPM, 0, 1, 0, + amp_usage_status_get, amp_usage_status_put), +SOC_ENUM_EXT("Amplifier Mode", sma1303_amp_mode_enum, + sma1303_amp_mode_get, sma1303_amp_mode_put), +SOC_ENUM_EXT("Outport config", sma1303_outport_config_enum, + sma1303_outport_config_get, sma1303_outport_config_put), +SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL, + 0, 167, 1, sma1303_spk_tlv), +SOC_ENUM("Speaker Mute Switch", sma1303_spkmute_enum), +SOC_ENUM_EXT("Speaker Output", sma1303_spkmode_enum, + sma1303_spkmode_get, sma1303_spkmode_put), +SND_SOC_BYTES_EXT("Postscaler Set", 1, + postscaler_get, postscaler_put), +SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum, + sma1303_postscaler_config_get, sma1303_postscaler_config_put), +SOC_ENUM_EXT("Output Format", sma1303_o_format_enum, + sma1303_o_format_get, sma1303_o_format_put), +}; + +static int sma1303_startup(struct snd_soc_component *component) +{ + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + + if (sma1303->amp_power_status) { + dev_info(component->dev, "%s : %s\n", + __func__, "Already AMP Power on"); + return ret; + } + + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_8E_PLL_CTRL, PLL_PD2_MASK, PLL_OPERATION2); + + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_ON); + + if (sma1303->amp_mode == ONE_CHIP_SOLUTION) + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_MONO); + else + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_STEREO); + + if (sma1303->check_fault_status) { + if (sma1303->check_fault_period > 0) + queue_delayed_work(system_freezable_wq, + &sma1303->check_fault_work, + sma1303->check_fault_period * HZ); + else + queue_delayed_work(system_freezable_wq, + &sma1303->check_fault_work, + CHECK_PERIOD_TIME * HZ); + } + + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_UNMUTE); + + sma1303->amp_power_status = true; + + return ret; +} + +static int sma1303_shutdown(struct snd_soc_component *component) +{ + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + + if (!(sma1303->amp_power_status)) { + dev_info(component->dev, "%s : %s\n", + __func__, "Already AMP Shutdown"); + return ret; + } + + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_MUTE); + + cancel_delayed_work_sync(&sma1303->check_fault_work); + + msleep(55); + + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_OFF); + + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_OFF); + + ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + SMA1303_8E_PLL_CTRL, PLL_PD2_MASK, PLL_PD2); + + sma1303->amp_power_status = false; + + return ret; +} + +static int sma1303_clk_supply_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + dev_info(component->dev, "%s : PRE_PMU\n", __func__); + break; + + case SND_SOC_DAPM_POST_PMD: + dev_info(component->dev, "%s : POST_PMD\n", __func__); + break; + } + + return 0; +} + +static int sma1303_dac_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + dev_info(component->dev, "%s : PRE_PMU\n", __func__); + + if (sma1303->usage_status) + sma1303_startup(component); + + break; + + case SND_SOC_DAPM_POST_PMU: + dev_info(component->dev, "%s : POST_PMU\n", __func__); + + break; + + case SND_SOC_DAPM_PRE_PMD: + dev_info(component->dev, "%s : PRE_PMD\n", __func__); + + sma1303_shutdown(component); + + break; + + case SND_SOC_DAPM_POST_PMD: + dev_info(component->dev, "%s : POST_PMD\n", __func__); + + break; + } + + return 0; +} + +static int sma1303_dac_feedback_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + dev_info(component->dev, + "%s : DAC feedback ON\n", __func__); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_09_OUTPUT_CTRL, + PORT_CONFIG_MASK|PORT_OUT_SEL_MASK, + OUTPUT_PORT_ENABLE|SPEAKER_PATH); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A3_TOP_MAN2, + SDO_OUTPUT_MASK, NORMAL_OUT); + break; + + case SND_SOC_DAPM_PRE_PMD: + dev_info(component->dev, + "%s : DAC feedback OFF\n", __func__); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_09_OUTPUT_CTRL, + PORT_OUT_SEL_MASK, OUT_SEL_DISABLE); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A3_TOP_MAN2, SDO_OUTPUT_MASK, + HIGH_Z_OUT); + break; + } + + return ret; +} + +static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = { +SND_SOC_DAPM_SUPPLY("CLK_SUPPLY", SND_SOC_NOPM, 0, 0, sma1303_clk_supply_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), +SND_SOC_DAPM_DAC_E("DAC", "Playback", SND_SOC_NOPM, 0, 0, sma1303_dac_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), +SND_SOC_DAPM_ADC_E("DAC_FEEDBACK", "Capture", SND_SOC_NOPM, 0, 0, + sma1303_dac_feedback_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), +SND_SOC_DAPM_OUTPUT("SPK"), +SND_SOC_DAPM_INPUT("SDO"), +SND_SOC_DAPM_MUX("SDO Source", SND_SOC_NOPM, 0, 0, &sma1303_sdo_source_mux), +}; + +static const struct snd_soc_dapm_route sma1303_audio_map[] = { +{"DAC", NULL, "CLK_SUPPLY"}, +{"SPK", NULL, "DAC"}, +{"SDO Source", "Disable", "SDO"}, +{"SDO Source", "Format_C", "SDO"}, +{"SDO Source", "Mixer_Out", "SDO"}, +{"SDO Source", "After_DSP", "SDO"}, +{"SDO Source", "After_Post", "SDO"}, +{"DAC_FEEDBACK", NULL, "SDO Source"}, +}; + +static int sma1303_setup_pll(struct snd_soc_component *component, + unsigned int bclk) +{ + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + + int i = 0, ret = 0; + + dev_info(component->dev, "%s : BCLK = %dHz\n", + __func__, bclk); + + if (sma1303->sys_clk_id == SMA1303_PLL_CLKIN_MCLK) { + dev_info(component->dev, "%s : MCLK is not supported\n", + __func__); + } else if (sma1303->sys_clk_id == SMA1303_PLL_CLKIN_BCLK) { + for (i = 0; i < sma1303->num_of_pll_matches; i++) { + if (sma1303->pll_matches[i].input_clk == bclk) + break; + } + if (i == sma1303->num_of_pll_matches) { + dev_info(component->dev, "%s : No matching value between pll table and SCK\n", + __func__); + return -EINVAL; + } + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A2_TOP_MAN1, + PLL_PD_MASK|PLL_REF_CLK_MASK, + PLL_OPERATION|PLL_SCK); + } + + ret += sma1303_regmap_write(sma1303->regmap, component->dev, + SMA1303_8B_PLL_POST_N, + sma1303->pll_matches[i].post_n); + + ret += sma1303_regmap_write(sma1303->regmap, component->dev, + SMA1303_8C_PLL_N, + sma1303->pll_matches[i].n); + + ret += sma1303_regmap_write(sma1303->regmap, component->dev, + SMA1303_8D_PLL_A_SETTING, + sma1303->pll_matches[i].vco); + + ret += sma1303_regmap_write(sma1303->regmap, component->dev, + SMA1303_8F_PLL_P_CP, + sma1303->pll_matches[i].p_cp); + + return ret; +} + +static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + unsigned int input_format = 0; + unsigned int bclk = 0; + int ret = 0; + + if (sma1303->format == SND_SOC_DAIFMT_DSP_A) + bclk = params_rate(params) * sma1303->frame_size; + else + bclk = params_rate(params) * params_physical_width(params) + * params_channels(params); + + dev_info(component->dev, + "%s : rate = %d : bit size = %d : channel = %d\n", + __func__, params_rate(params), params_width(params), + params_channels(params)); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + + if (sma1303->usage_status && + (sma1303->sys_clk_id == SMA1303_PLL_CLKIN_MCLK + || sma1303->sys_clk_id == SMA1303_PLL_CLKIN_BCLK)) { + + if (sma1303->last_bclk != bclk) { + if (sma1303->amp_power_status) { + sma1303_shutdown(component); + sma1303_setup_pll(component, bclk); + sma1303_startup(component); + } else + sma1303_setup_pll(component, bclk); + + sma1303->last_bclk = bclk; + } + } + + switch (params_rate(params)) { + case 8000: + case 12000: + case 16000: + case 24000: + case 32000: + case 44100: + case 48000: + case 96000: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A2_TOP_MAN1, + DAC_DN_CONV_MASK, DAC_DN_CONV_DISABLE); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + LEFTPOL_MASK, LOW_FIRST_CH); + break; + + case 192000: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A2_TOP_MAN1, + DAC_DN_CONV_MASK, DAC_DN_CONV_ENABLE); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + LEFTPOL_MASK, HIGH_FIRST_CH); + break; + + default: + dev_err(component->dev, "%s not support rate : %d\n", + __func__, params_rate(params)); + + return -EINVAL; + } + + } else { + + switch (params_format(params)) { + + case SNDRV_PCM_FORMAT_S16_LE: + dev_info(component->dev, + "%s set format SNDRV_PCM_FORMAT_S16_LE\n", + __func__); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A4_TOP_MAN3, + SCK_RATE_MASK, SCK_32FS); + break; + + case SNDRV_PCM_FORMAT_S24_LE: + dev_info(component->dev, + "%s set format SNDRV_PCM_FORMAT_S24_LE\n", + __func__); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A4_TOP_MAN3, + SCK_RATE_MASK, SCK_64FS); + break; + case SNDRV_PCM_FORMAT_S32_LE: + dev_info(component->dev, + "%s set format SNDRV_PCM_FORMAT_S32_LE\n", + __func__); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A4_TOP_MAN3, + SCK_RATE_MASK, SCK_64FS); + break; + default: + dev_err(component->dev, + "%s not support data bit : %d\n", __func__, + params_format(params)); + return -EINVAL; + } + } + + switch (params_width(params)) { + case 16: + switch (sma1303->format) { + case SND_SOC_DAIFMT_I2S: + input_format |= STANDARD_I2S; + break; + case SND_SOC_DAIFMT_LEFT_J: + input_format |= LJ; + break; + case SND_SOC_DAIFMT_RIGHT_J: + input_format |= RJ_16BIT; + break; + } + break; + case 24: + case 32: + switch (sma1303->format) { + case SND_SOC_DAIFMT_I2S: + input_format |= STANDARD_I2S; + break; + case SND_SOC_DAIFMT_LEFT_J: + input_format |= LJ; + break; + case SND_SOC_DAIFMT_RIGHT_J: + input_format |= RJ_24BIT; + break; + } + break; + + default: + dev_err(component->dev, + "%s not support data bit : %d\n", __func__, + params_format(params)); + return -EINVAL; + } + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + I2S_MODE_MASK, input_format); + return ret; +} + +static int sma1303_dai_set_sysclk_amp(struct snd_soc_dai *dai, + int clk_id, unsigned int freq, int dir) +{ + struct snd_soc_component *component = dai->component; + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + + switch (clk_id) { + case SMA1303_EXTERNAL_CLOCK_19_2: + break; + case SMA1303_EXTERNAL_CLOCK_24_576: + break; + case SMA1303_PLL_CLKIN_MCLK: + break; + case SMA1303_PLL_CLKIN_BCLK: + break; + default: + dev_err(component->dev, "Invalid clk id: %d\n", clk_id); + return -EINVAL; + } + sma1303->sys_clk_id = clk_id; + return 0; +} + +static int sma1303_dai_mute(struct snd_soc_dai *dai, int mute, int stream) +{ + struct snd_soc_component *component = dai->component; + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + + if (stream == SNDRV_PCM_STREAM_CAPTURE) + return ret; + + if (!(sma1303->amp_power_status)) { + dev_info(component->dev, "%s : %s\n", + __func__, "Already AMP Shutdown"); + return ret; + } + + if (mute) { + dev_info(component->dev, "%s : %s\n", __func__, "MUTE"); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_0E_MUTE_VOL_CTRL, + SPK_MUTE_MASK, SPK_MUTE); + } else { + dev_info(component->dev, "%s : %s\n", __func__, "UNMUTE"); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_0E_MUTE_VOL_CTRL, + SPK_MUTE_MASK, SPK_UNMUTE); + } + + return ret; +} + +static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, + unsigned int fmt) +{ + struct snd_soc_component *component = dai->component; + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + + case SND_SOC_DAIFMT_CBS_CFS: + dev_info(component->dev, + "%s : %s\n", __func__, "I2S/TDM Device mode"); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + CONTROLLER_DEVICE_MASK, DEVICE_MODE); + break; + + case SND_SOC_DAIFMT_CBM_CFM: + dev_info(component->dev, + "%s : %s\n", __func__, "I2S/TDM Controller mode"); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + CONTROLLER_DEVICE_MASK, CONTROLLER_MODE); + break; + + default: + dev_err(component->dev, + "Unsupported Controller/Device : 0x%x\n", fmt); + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + + case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_RIGHT_J: + case SND_SOC_DAIFMT_LEFT_J: + case SND_SOC_DAIFMT_DSP_A: + case SND_SOC_DAIFMT_DSP_B: + sma1303->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; + break; + default: + dev_err(component->dev, + "Unsupported Audio Interface Format : 0x%x\n", fmt); + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + + case SND_SOC_DAIFMT_IB_NF: + dev_info(component->dev, "%s : %s\n", + __func__, "Invert BCLK + Normal Frame"); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + SCK_RISING_MASK, SCK_RISING_EDGE); + break; + case SND_SOC_DAIFMT_IB_IF: + dev_info(component->dev, "%s : %s\n", + __func__, "Invert BCLK + Invert Frame"); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + LEFTPOL_MASK|SCK_RISING_MASK, + HIGH_FIRST_CH|SCK_RISING_EDGE); + break; + case SND_SOC_DAIFMT_NB_IF: + dev_info(component->dev, "%s : %s\n", + __func__, "Normal BCLK + Invert Frame"); + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_01_INPUT1_CTRL1, + LEFTPOL_MASK, HIGH_FIRST_CH); + break; + case SND_SOC_DAIFMT_NB_NF: + dev_info(component->dev, "%s : %s\n", + __func__, "Normal BCLK + Normal Frame"); + break; + default: + dev_err(component->dev, + "Unsupported Bit & Frameclock : 0x%x\n", fmt); + return -EINVAL; + } + + return ret; +} + +static int sma1303_dai_set_tdm_slot(struct snd_soc_dai *dai, + unsigned int tx_mask, unsigned int rx_mask, + int slots, int slot_width) +{ + struct snd_soc_component *component = dai->component; + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + + dev_info(component->dev, "%s : slots = %d, slot_width - %d\n", + __func__, slots, slot_width); + + sma1303->frame_size = slot_width * slots; + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A4_TOP_MAN3, + O_FORMAT_MASK, O_FMT_TDM); + + switch (slot_width) { + case 16: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A6_TDM2, + TDM_DL_MASK, TDM_DL_16); + break; + case 32: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A6_TDM2, + TDM_DL_MASK, TDM_DL_32); + break; + default: + dev_err(component->dev, "%s not support TDM %d slot_width\n", + __func__, slot_width); + } + + switch (slots) { + case 4: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A6_TDM2, + TDM_N_SLOT_MASK, TDM_N_SLOT_4); + break; + case 8: + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A6_TDM2, + TDM_N_SLOT_MASK, TDM_N_SLOT_8); + break; + default: + dev_err(component->dev, "%s not support TDM %d slots\n", + __func__, slots); + } + + if (sma1303->tdm_slot_rx < slots) + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A5_TDM1, TDM_SLOT1_RX_POS_MASK, + (sma1303->tdm_slot_rx) << 3); + else + dev_err(component->dev, "%s Incorrect tdm-slot-rx %d set\n", + __func__, sma1303->tdm_slot_rx); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A5_TDM1, + TDM_CLK_POL_MASK, TDM_CLK_POL_RISE); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A5_TDM1, + TDM_TX_MODE_MASK, TDM_TX_MONO); + + if (sma1303->tdm_slot_tx < slots) + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_A6_TDM2, TDM_SLOT1_TX_POS_MASK, + (sma1303->tdm_slot_tx) << 3); + else + dev_err(component->dev, "%s Incorrect tdm-slot-tx %d set\n", + __func__, sma1303->tdm_slot_tx); + + return ret; +} + +static const struct snd_soc_dai_ops sma1303_dai_ops_amp = { + .set_sysclk = sma1303_dai_set_sysclk_amp, + .set_fmt = sma1303_dai_set_fmt_amp, + .hw_params = sma1303_dai_hw_params_amp, + .mute_stream = sma1303_dai_mute, + .set_tdm_slot = sma1303_dai_set_tdm_slot, +}; + +#define SMA1303_RATES SNDRV_PCM_RATE_8000_192000 +#define SMA1303_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_S32_LE) + +static struct snd_soc_dai_driver sma1303_dai[] = { +{ + .name = "sma1303-amplifier", + .id = 0, + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SMA1303_RATES, + .formats = SMA1303_FORMATS, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + .rates = SMA1303_RATES, + .formats = SMA1303_FORMATS, + }, + .ops = &sma1303_dai_ops_amp, +} +}; + +static void sma1303_check_fault_worker(struct work_struct *work) +{ + struct sma1303_priv *sma1303 = + container_of(work, struct sma1303_priv, check_fault_work.work); + int ret = 0; + unsigned int over_temp, ocp_val, uvlo_val; + + mutex_lock(&sma1303->lock); + + if (sma1303->tsdw_cnt) + ret = regmap_read(sma1303->regmap, + SMA1303_0A_SPK_VOL, &sma1303->cur_vol); + else + ret = regmap_read(sma1303->regmap, + SMA1303_0A_SPK_VOL, &sma1303->init_vol); + + if (ret != 0) { + dev_err(sma1303->dev, + "failed to read SMA1303_0A_SPK_VOL : %d\n", ret); + mutex_unlock(&sma1303->lock); + return; + } + + ret = regmap_read(sma1303->regmap, SMA1303_FA_STATUS1, &over_temp); + if (ret != 0) { + dev_err(sma1303->dev, + "failed to read SMA1303_FA_STATUS1 : %d\n", ret); + mutex_unlock(&sma1303->lock); + return; + } + + ret = regmap_read(sma1303->regmap, SMA1303_FB_STATUS2, &ocp_val); + if (ret != 0) { + dev_err(sma1303->dev, + "failed to read SMA1303_FB_STATUS2 : %d\n", ret); + mutex_unlock(&sma1303->lock); + return; + } + + ret = regmap_read(sma1303->regmap, SMA1303_FF_DEVICE_INDEX, &uvlo_val); + if (ret != 0) { + dev_err(sma1303->dev, + "failed to read SMA1303_FF_DEVICE_INDEX : %d\n", ret); + mutex_unlock(&sma1303->lock); + return; + } + + if (~over_temp & OT1_OK_STATUS) { + dev_crit(sma1303->dev, + "%s : OT1(Over Temperature Level 1)\n", __func__); + + if ((sma1303->cur_vol + 6) <= 0xFF) + sma1303_regmap_write( + sma1303->regmap, sma1303->dev, + SMA1303_0A_SPK_VOL, sma1303->cur_vol + 6); + + sma1303->tsdw_cnt++; + } else if (sma1303->tsdw_cnt) { + sma1303_regmap_write( + sma1303->regmap, sma1303->dev, + SMA1303_0A_SPK_VOL, sma1303->init_vol); + sma1303->tsdw_cnt = 0; + sma1303->cur_vol = sma1303->init_vol; + } + + if (~over_temp & OT2_OK_STATUS) { + dev_crit(sma1303->dev, + "%s : OT2(Over Temperature Level 2)\n", __func__); + } + if (ocp_val & OCP_SPK_STATUS) { + dev_crit(sma1303->dev, + "%s : OCP_SPK(Over Current Protect SPK)\n", __func__); + } + if (ocp_val & OCP_BST_STATUS) { + dev_crit(sma1303->dev, + "%s : OCP_BST(Over Current Protect Boost)\n", __func__); + } + if ((ocp_val & CLK_MON_STATUS) && (sma1303->amp_power_status)) { + dev_crit(sma1303->dev, + "%s : CLK_FAULT(No clock input)\n", __func__); + } + if (uvlo_val & UVLO_BST_STATUS) { + dev_crit(sma1303->dev, + "%s : UVLO(Under Voltage Lock Out)\n", __func__); + } + + if ((over_temp != sma1303->last_over_temp) || + (ocp_val != sma1303->last_ocp_val)) { + + dev_crit(sma1303->dev, "Please check AMP status"); + dev_info(sma1303->dev, "STATUS1=0x%02X : STATUS2=0x%02X\n", + over_temp, ocp_val); + sma1303->last_over_temp = over_temp; + sma1303->last_ocp_val = ocp_val; + } + + if (sma1303->check_fault_status) { + if (sma1303->check_fault_period > 0) + queue_delayed_work(system_freezable_wq, + &sma1303->check_fault_work, + sma1303->check_fault_period * HZ); + else + queue_delayed_work(system_freezable_wq, + &sma1303->check_fault_work, + CHECK_PERIOD_TIME * HZ); + } + + if (!(~over_temp & OT1_OK_STATUS) && !(~over_temp & OT2_OK_STATUS) + && !(ocp_val & OCP_SPK_STATUS) + && !(ocp_val & OCP_BST_STATUS) + && !(ocp_val & CLK_MON_STATUS) + && !(uvlo_val & UVLO_BST_STATUS)) { + } + + mutex_unlock(&sma1303->lock); +} + +#ifdef CONFIG_PM +static int sma1303_suspend(struct snd_soc_component *component) +{ + return 0; +} + +static int sma1303_resume(struct snd_soc_component *component) +{ + return 0; +} +#else +#define sma1303_suspend NULL +#define sma1303_resume NULL +#endif + +static int sma1303_probe(struct snd_soc_component *component) +{ + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = + snd_soc_component_get_dapm(component); + char *dapm_widget_str = NULL; + int prefix_len = 0, str_max = 30, ret = 0, i = 0; + unsigned int status, otp_stat; + + if (component->name_prefix != NULL) { + dev_info(component->dev, "%s : component name prefix - %s\n", + __func__, component->name_prefix); + + prefix_len = strlen(component->name_prefix); + dapm_widget_str = kzalloc(prefix_len + str_max, GFP_KERNEL); + + if (!dapm_widget_str) { + kfree(dapm_widget_str); + return -ENOMEM; + } + + strcpy(dapm_widget_str, component->name_prefix); + strcat(dapm_widget_str, " Playback"); + + snd_soc_dapm_ignore_suspend(dapm, dapm_widget_str); + + memset(dapm_widget_str + prefix_len, 0, str_max); + + strcpy(dapm_widget_str, component->name_prefix); + strcat(dapm_widget_str, " SPK"); + + snd_soc_dapm_ignore_suspend(dapm, dapm_widget_str); + + kfree(dapm_widget_str); + } else { + snd_soc_dapm_ignore_suspend(dapm, "Playback"); + snd_soc_dapm_ignore_suspend(dapm, "SPK"); + } + + snd_soc_dapm_sync(dapm); + + ret += sma1303_regmap_update_bits( + sma1303->regmap, component->dev, + SMA1303_00_SYSTEM_CTRL, + RESETBYI2C_MASK, RESETBYI2C_RESET); + + ret += regmap_read(sma1303->regmap, SMA1303_FF_DEVICE_INDEX, &status); + if (ret < 0) { + dev_err(sma1303->dev, + "failed to read, register: %02X, ret: %d\n", + SMA1303_FF_DEVICE_INDEX, ret); + return ret; + } + sma1303->rev_num = status & REV_NUM_STATUS; + if (sma1303->rev_num == REV_NUM_TV0) + dev_info(component->dev, "SMA1303 Trimming Version 0\n"); + else if (sma1303->rev_num == REV_NUM_TV1) + dev_info(component->dev, "SMA1303 Trimming Version 1\n"); + + ret += regmap_read(sma1303->regmap, SMA1303_FB_STATUS2, &otp_stat); + if (ret < 0) + dev_err(sma1303->dev, + "failed to read, register: %02X, ret: %d\n", + SMA1303_FF_DEVICE_INDEX, ret); + + if (((sma1303->rev_num == REV_NUM_TV0) && + ((otp_stat & 0x0E) == OTP_STAT_OK_0)) || + ((sma1303->rev_num != REV_NUM_TV0) && + ((otp_stat & 0x0C) == OTP_STAT_OK_1))) + dev_info(component->dev, "SMA1303 OTP Status Successful\n"); + else + dev_info(component->dev, "SMA1303 OTP Status Fail\n"); + + for (i = 0; i < (unsigned int)ARRAY_SIZE(sma1303_reg_def); i++) + ret += sma1303_regmap_write( + sma1303->regmap, component->dev, + sma1303_reg_def[i].reg, + sma1303_reg_def[i].def); + + ret += sma1303_regmap_write(sma1303->regmap, component->dev, + SMA1303_0A_SPK_VOL, sma1303->init_vol); + + dev_info(component->dev, + "%s init_vol is 0x%x\n", __func__, sma1303->init_vol); + + return ret; +} + +static void sma1303_remove(struct snd_soc_component *component) +{ + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + + cancel_delayed_work_sync(&sma1303->check_fault_work); +} + +static const struct snd_soc_component_driver sma1303_component = { + .probe = sma1303_probe, + .remove = sma1303_remove, + .suspend = sma1303_suspend, + .resume = sma1303_resume, + .controls = sma1303_snd_controls, + .num_controls = ARRAY_SIZE(sma1303_snd_controls), + .dapm_widgets = sma1303_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sma1303_dapm_widgets), + .dapm_routes = sma1303_audio_map, + .num_dapm_routes = ARRAY_SIZE(sma1303_audio_map), +}; + +const struct regmap_config sma_i2c_regmap = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = SMA1303_FF_DEVICE_INDEX, + .readable_reg = sma1303_readable_register, + .writeable_reg = sma1303_writeable_register, + .volatile_reg = sma1303_volatile_register, + + .cache_type = REGCACHE_NONE, + .reg_defaults = sma1303_reg_def, + .num_reg_defaults = ARRAY_SIZE(sma1303_reg_def), +}; + +static ssize_t check_fault_period_show(struct device *dev, + struct device_attribute *devattr, char *buf) +{ + struct sma1303_priv *sma1303 = dev_get_drvdata(dev); + int rc; + + rc = (int)snprintf(buf, PAGE_SIZE, + "%ld\n", sma1303->check_fault_period); + + return (ssize_t)rc; +} + +static ssize_t check_fault_period_store(struct device *dev, + struct device_attribute *devattr, const char *buf, size_t count) +{ + struct sma1303_priv *sma1303 = dev_get_drvdata(dev); + int ret; + + ret = kstrtol(buf, 10, &sma1303->check_fault_period); + + if (ret) + return -EINVAL; + + return (ssize_t)count; +} + +static DEVICE_ATTR_RW(check_fault_period); + +static ssize_t check_fault_status_show(struct device *dev, + struct device_attribute *devattr, char *buf) +{ + struct sma1303_priv *sma1303 = dev_get_drvdata(dev); + int rc; + + rc = (int)snprintf(buf, PAGE_SIZE, + "%ld\n", sma1303->check_fault_status); + + return (ssize_t)rc; +} + +static ssize_t check_fault_status_store(struct device *dev, + struct device_attribute *devattr, const char *buf, size_t count) +{ + struct sma1303_priv *sma1303 = dev_get_drvdata(dev); + int ret; + + ret = kstrtol(buf, 10, &sma1303->check_fault_status); + + if (ret) + return -EINVAL; + + if (sma1303->check_fault_status) { + if (sma1303->check_fault_period > 0) + queue_delayed_work(system_freezable_wq, + &sma1303->check_fault_work, + sma1303->check_fault_period * HZ); + else + queue_delayed_work(system_freezable_wq, + &sma1303->check_fault_work, + CHECK_PERIOD_TIME * HZ); + } + + return (ssize_t)count; +} + +static DEVICE_ATTR_RW(check_fault_status); + +static struct attribute *sma1303_attr[] = { + &dev_attr_check_fault_period.attr, + &dev_attr_check_fault_status.attr, + NULL, +}; + +static struct attribute_group sma1303_attr_group = { + .attrs = sma1303_attr, +}; + +static int sma1303_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct sma1303_priv *sma1303; + struct device_node *np = client->dev.of_node; + int ret; + u32 value; + unsigned int device_info; + + dev_info(&client->dev, "%s is here. Driver version REV018\n", __func__); + + sma1303 = devm_kzalloc(&client->dev, sizeof(struct sma1303_priv), + GFP_KERNEL); + + if (!sma1303) + return -ENOMEM; + + sma1303->regmap = devm_regmap_init_i2c(client, &sma_i2c_regmap); + + if (IS_ERR(sma1303->regmap)) { + ret = PTR_ERR(sma1303->regmap); + dev_err(&client->dev, + "Failed to allocate register map: %d\n", ret); + + devm_kfree(&client->dev, sma1303); + + return ret; + } + + if (np) { + if (!of_property_read_u32(np, "tdm-slot-rx", &value)) { + dev_info(&client->dev, + "tdm slot rx is '%d' from DT\n", value); + sma1303->tdm_slot_rx = value; + } else { + dev_info(&client->dev, + "Default setting of tdm slot rx is '0'\n"); + sma1303->tdm_slot_rx = 0; + } + if (!of_property_read_u32(np, "tdm-slot-tx", &value)) { + dev_info(&client->dev, + "tdm slot tx is '%d' from DT\n", value); + sma1303->tdm_slot_tx = value; + } else { + dev_info(&client->dev, + "Default setting of tdm slot tx is '0'\n"); + sma1303->tdm_slot_tx = 0; + } + if (!of_property_read_u32(np, "sys-clk-id", &value)) { + switch (value) { + case SMA1303_EXTERNAL_CLOCK_19_2: + case SMA1303_EXTERNAL_CLOCK_24_576: + case SMA1303_PLL_CLKIN_MCLK: + dev_info(&client->dev, "MCLK is not supported\n"); + break; + case SMA1303_PLL_CLKIN_BCLK: + dev_info(&client->dev, + "Take an BCLK(SCK) and covert it to an internal PLL for use\n"); + break; + default: + dev_err(&client->dev, + "Invalid sys-clk-id: %d\n", value); + return -EINVAL; + } + sma1303->sys_clk_id = value; + } else { + dev_info(&client->dev, "Use the internal PLL clock by default\n"); + sma1303->sys_clk_id = SMA1303_PLL_CLKIN_BCLK; + } + } else { + dev_err(&client->dev, + "device node initialization error\n"); + devm_kfree(&client->dev, sma1303); + return -ENODEV; + } + + ret = regmap_read(sma1303->regmap, + SMA1303_FF_DEVICE_INDEX, &device_info); + + if ((ret != 0) || ((device_info & 0xF8) != DEVICE_ID)) { + dev_err(&client->dev, "device initialization error (%d 0x%02X)", + ret, device_info); + } + dev_info(&client->dev, "chip version 0x%02X\n", device_info); + + sma1303->last_over_temp = 0xC0; + sma1303->last_ocp_val = 0x0A; + sma1303->tsdw_cnt = 0; + sma1303->init_vol = 0x31; + sma1303->cur_vol = sma1303->init_vol; + sma1303->last_bclk = 0; + + INIT_DELAYED_WORK(&sma1303->check_fault_work, + sma1303_check_fault_worker); + + mutex_init(&sma1303->lock); + sma1303->check_fault_period = CHECK_PERIOD_TIME; + + sma1303->devtype = id->driver_data; + sma1303->dev = &client->dev; + sma1303->kobj = &client->dev.kobj; + + i2c_set_clientdata(client, sma1303); + + sma1303->amp_mode = ONE_CHIP_SOLUTION; + sma1303->usage_status = true; + sma1303->amp_power_status = false; + sma1303->check_fault_status = true; + sma1303->pll_matches = sma1303_pll_matches; + sma1303->num_of_pll_matches = + ARRAY_SIZE(sma1303_pll_matches); + + ret = devm_snd_soc_register_component(&client->dev, + &sma1303_component, sma1303_dai, 1); + + if (ret) { + dev_err(&client->dev, "Failed to register component"); + snd_soc_unregister_component(&client->dev); + + if (sma1303) + devm_kfree(&client->dev, sma1303); + + return ret; + } + + sma1303->attr_grp = &sma1303_attr_group; + ret = sysfs_create_group(sma1303->kobj, sma1303->attr_grp); + + if (ret) { + dev_err(&client->dev, + "failed to create attribute group [%d]\n", ret); + sma1303->attr_grp = NULL; + } + + return ret; +} + +static void sma1303_i2c_remove(struct i2c_client *client) +{ + struct sma1303_priv *sma1303 = + (struct sma1303_priv *) i2c_get_clientdata(client); + + cancel_delayed_work_sync(&sma1303->check_fault_work); + + snd_soc_unregister_component(&client->dev); + + if (sma1303) + devm_kfree(&client->dev, sma1303); +} + +static const struct i2c_device_id sma1303_i2c_id[] = { + {"sma1303", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, sma1303_i2c_id); + +static const struct of_device_id sma1303_of_match[] = { + { .compatible = "irondevice,sma1303", }, + { } +}; +MODULE_DEVICE_TABLE(of, sma1303_of_match); + +static struct i2c_driver sma1303_i2c_driver = { + .driver = { + .name = "sma1303", + .of_match_table = sma1303_of_match, + }, + .probe = sma1303_i2c_probe, + .remove = sma1303_i2c_remove, + .id_table = sma1303_i2c_id, +}; + +static int __init sma1303_init(void) +{ + int ret; + + ret = i2c_add_driver(&sma1303_i2c_driver); + + if (ret) + pr_err("Failed to register sma1303 I2C driver: %d\n", ret); + + return ret; +} + +static void __exit sma1303_exit(void) +{ + i2c_del_driver(&sma1303_i2c_driver); +} + +module_init(sma1303_init); +module_exit(sma1303_exit); + +MODULE_DESCRIPTION("ALSA SoC SMA1303 driver"); +MODULE_AUTHOR("Gyuhwa Park, "); +MODULE_AUTHOR("Kiseok Jo, "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/sma1303.h b/sound/soc/codecs/sma1303.h new file mode 100644 index 000000000000..d1fa2acaba85 --- /dev/null +++ b/sound/soc/codecs/sma1303.h @@ -0,0 +1,609 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * sma1303.h -- sma1303 ALSA SoC Audio driver + * + * Copyright 2022 Iron Device Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _SMA1303_H +#define _SMA1303_H + +#define SMA1303_I2C_ADDR_00 0x1e +#define SMA1303_I2C_ADDR_01 0x3e +#define SMA1303_I2C_ADDR_10 0x5e +#define SMA1303_I2C_ADDR_11 0x7e + +#define SMA1303_EXTERNAL_CLOCK_19_2 0x00 +#define SMA1303_EXTERNAL_CLOCK_24_576 0x01 +#define SMA1303_PLL_CLKIN_MCLK 0x02 +#define SMA1303_PLL_CLKIN_BCLK 0x03 + +#define ONE_CHIP_SOLUTION 0x00 +#define MONO_TWO_CHIP_SOLUTION 0x01 +#define LEFT_TWO_CHIP_SOLUTION 0x02 +#define RIGHT_TWO_CHIP_SOLUTION 0x03 + +/* + * SMA1303 Register Definition + */ + +/* SMA1303 Register Addresses */ +#define SMA1303_00_SYSTEM_CTRL 0x00 +#define SMA1303_01_INPUT1_CTRL1 0x01 +#define SMA1303_02_INPUT1_CTRL2 0x02 +#define SMA1303_03_INPUT1_CTRL3 0x03 +#define SMA1303_04_INPUT1_CTRL4 0x04 +/* 0x05 ~ 0x08 : Reserved */ +#define SMA1303_09_OUTPUT_CTRL 0x09 +#define SMA1303_0A_SPK_VOL 0x0a +#define SMA1303_0B_BST_TEST 0x0b +#define SMA1303_0C_BST_TEST1 0x0c +#define SMA1303_0D_SPK_TEST 0x0d +#define SMA1303_0E_MUTE_VOL_CTRL 0x0e +/* 0x0F : Reserved */ +#define SMA1303_10_SYSTEM_CTRL1 0x10 +#define SMA1303_11_SYSTEM_CTRL2 0x11 +#define SMA1303_12_SYSTEM_CTRL3 0x12 +/* 0x13 : Reserved */ +#define SMA1303_14_MODULATOR 0x14 +#define SMA1303_15_BASS_SPK1 0x15 +#define SMA1303_16_BASS_SPK2 0x16 +#define SMA1303_17_BASS_SPK3 0x17 +#define SMA1303_18_BASS_SPK4 0x18 +#define SMA1303_19_BASS_SPK5 0x19 +#define SMA1303_1A_BASS_SPK6 0x1a +#define SMA1303_1B_BASS_SPK7 0x1b +/* 0x1C ~ 0x22 : Reserved */ +#define SMA1303_23_COMP_LIM1 0x23 +#define SMA1303_24_COMP_LIM2 0x24 +#define SMA1303_25_COMP_LIM3 0x25 +#define SMA1303_26_COMP_LIM4 0x26 +/* 0x27 ~ 0x32 : Reserved */ +#define SMA1303_33_SDM_CTRL 0x33 +#define SMA1303_34_OTP_DATA1 0x34 +/* 0x35 : Reserved */ +#define SMA1303_36_PROTECTION 0x36 +#define SMA1303_37_SLOPE_CTRL 0x37 +#define SMA1303_38_OTP_TRM0 0x38 +/* 0x39 ~ 0x3A : Reserved */ +#define SMA1303_3B_TEST1 0x3b +#define SMA1303_3C_TEST2 0x3c +#define SMA1303_3D_TEST3 0x3d +#define SMA1303_3E_ATEST1 0x3e +#define SMA1303_3F_ATEST2 0x3f +/* 0x40 ~ 0x8A : Reserved */ +#define SMA1303_8B_PLL_POST_N 0x8b +#define SMA1303_8C_PLL_N 0x8c +#define SMA1303_8D_PLL_A_SETTING 0x8d +#define SMA1303_8E_PLL_CTRL 0x8e +#define SMA1303_8F_PLL_P_CP 0x8f +#define SMA1303_90_POSTSCALER 0x90 +#define SMA1303_91_CLASS_G_CTRL 0x91 +#define SMA1303_92_FDPEC_CTRL 0x92 +/* 0x93 : Reserved */ +#define SMA1303_94_BOOST_CTRL1 0x94 +#define SMA1303_95_BOOST_CTRL2 0x95 +#define SMA1303_96_BOOST_CTRL3 0x96 +#define SMA1303_97_BOOST_CTRL4 0x97 +/* 0x98 ~ 0x9F : Reserved */ +#define SMA1303_A0_PAD_CTRL0 0xa0 +#define SMA1303_A1_PAD_CTRL1 0xa1 +#define SMA1303_A2_TOP_MAN1 0xa2 +#define SMA1303_A3_TOP_MAN2 0xa3 +#define SMA1303_A4_TOP_MAN3 0xa4 +#define SMA1303_A5_TDM1 0xa5 +#define SMA1303_A6_TDM2 0xa6 +#define SMA1303_A7_CLK_MON 0xa7 +/* 0xA8 ~ 0xF9 : Reserved */ +#define SMA1303_FA_STATUS1 0xfa +#define SMA1303_FB_STATUS2 0xfb +/* 0xFC ~ 0xFE : Reserved */ +#define SMA1303_FF_DEVICE_INDEX 0xff + +/* SMA1303 Registers Bit Fields */ + +/* SYSTEM_CTRL : 0x00 */ +#define RESETBYI2C_MASK (1<<1) +#define RESETBYI2C_NORMAL (0<<1) +#define RESETBYI2C_RESET (1<<1) + +#define POWER_MASK (1<<0) +#define POWER_OFF (0<<0) +#define POWER_ON (1<<0) + +/* INTPUT CTRL1 : 0x01 */ +#define CONTROLLER_DEVICE_MASK (1<<7) +#define DEVICE_MODE (0<<7) +#define CONTROLLER_MODE (1<<7) + +#define I2S_MODE_MASK (7<<4) +#define STANDARD_I2S (0<<4) +#define LJ (1<<4) +#define RJ_16BIT (4<<4) +#define RJ_18BIT (5<<4) +#define RJ_20BIT (6<<4) +#define RJ_24BIT (7<<4) + +#define LEFTPOL_MASK (1<<3) +#define LOW_FIRST_CH (0<<3) +#define HIGH_FIRST_CH (1<<3) + +#define SCK_RISING_MASK (1<<2) +#define SCK_FALLING_EDGE (0<<2) +#define SCK_RISING_EDGE (1<<2) + +/* INTPUT CTRL2 : 0x02 */ +#define IMODE_MASK (3<<6) +#define I2S (0<<6) +#define PCM_SHORT (1<<6) +#define PCM_LONG (2<<6) + +#define RIGHT_FIRST_MASK (1<<5) +#define LEFT_NORMAL (0<<5) +#define RIGHT_INVERTED (1<<5) + +#define PCM_ALAW_MASK (1<<4) +#define PCM_U_DECODING (0<<4) +#define PCM_A_DECODING (1<<4) + +#define PCM_COMP_MASK (1<<3) +#define PCM_LINEAR (0<<3) +#define PCM_COMPANDING (1<<3) + +#define INPUTSEL_MASK (1<<2) +#define PCM_8KHZ (0<<2) +#define PCM_16KHZ (1<<2) + +#define PCM_STEREO_MASK (1<<1) +#define PCM_MONO (0<<1) +#define PCM_STEREO (1<<1) + +#define PCM_DL_MASK (1<<0) +#define PCM_8BIT (0<<0) +#define PCM_16BIT (1<<0) + +/* INTPUT CTRL3 : 0x03 */ +#define PCM_N_SLOT_MASK (15<<0) +#define PCM_N_SLOT1 (0<<0) +#define PCM_N_SLOT2 (1<<0) +#define PCM_N_SLOT3 (2<<0) +#define PCM_N_SLOT4 (3<<0) +#define PCM_N_SLOT5 (4<<0) +#define PCM_N_SLOT6 (5<<0) +#define PCM_N_SLOT7 (6<<0) +#define PCM_N_SLOT8 (7<<0) +#define PCM_N_SLOT9 (8<<0) +#define PCM_N_SLOT10 (9<<0) +#define PCM_N_SLOT11 (10<<0) +#define PCM_N_SLOT12 (11<<0) +#define PCM_N_SLOT13 (12<<0) +#define PCM_N_SLOT14 (13<<0) +#define PCM_N_SLOT15 (14<<0) +#define PCM_N_SLOT16 (15<<0) + +/* INTPUT CTRL4 : 0x04 */ +#define PCM1_SLOT_MASK (15<<4) +#define PCM1_SLOT1 (0<<4) +#define PCM1_SLOT2 (1<<4) +#define PCM1_SLOT3 (2<<4) +#define PCM1_SLOT4 (3<<4) +#define PCM1_SLOT5 (4<<4) +#define PCM1_SLOT6 (5<<4) +#define PCM1_SLOT7 (6<<4) +#define PCM1_SLOT8 (7<<4) +#define PCM1_SLOT9 (8<<4) +#define PCM1_SLOT10 (9<<4) +#define PCM1_SLOT11 (10<<4) +#define PCM1_SLOT12 (11<<4) +#define PCM1_SLOT13 (12<<4) +#define PCM1_SLOT14 (13<<4) +#define PCM1_SLOT15 (14<<4) +#define PCM1_SLOT16 (15<<4) + +#define PCM2_SLOT_MASK (15<<0) +#define PCM2_SLOT1 (0<<0) +#define PCM2_SLOT2 (1<<0) +#define PCM2_SLOT3 (2<<0) +#define PCM2_SLOT4 (3<<0) +#define PCM2_SLOT5 (4<<0) +#define PCM2_SLOT6 (5<<0) +#define PCM2_SLOT7 (6<<0) +#define PCM2_SLOT8 (7<<0) +#define PCM2_SLOT9 (8<<0) +#define PCM2_SLOT10 (9<<0) +#define PCM2_SLOT11 (10<<0) +#define PCM2_SLOT12 (11<<0) +#define PCM2_SLOT13 (12<<0) +#define PCM2_SLOT14 (13<<0) +#define PCM2_SLOT15 (14<<0) +#define PCM2_SLOT16 (15<<0) + +/* OUTPUT CTRL : 0x09 */ +#define PORT_CONFIG_MASK (3<<5) +#define INPUT_PORT_ONLY (0<<5) +#define OUTPUT_PORT_ENABLE (2<<5) + +#define PORT_OUT_SEL_MASK (7<<0) +#define OUT_SEL_DISABLE (0<<0) +#define FORMAT_CONVERTER (1<<0) +#define MIXER_OUTPUT (2<<0) +#define SPEAKER_PATH (3<<0) +#define POSTSCALER_OUTPUT (4<<0) + +/* BST_TEST : 0x0B */ +#define BST_OFF_SLOPE_MASK (3<<6) +#define BST_OFF_SLOPE_6_7ns (0<<6) +#define BST_OFF_SLOPE_4_8ns (1<<6) +#define BST_OFF_SLOPE_2_6ns (2<<6) +#define BST_OFF_SLOPE_1_2ns (3<<6) + +#define OCP_TEST_MASK (1<<5) +#define OCP_NORMAL_MODE (0<<5) +#define OCP_TEST_MODE (1<<5) + +#define BST_FAST_LEBN_MASK (1<<4) +#define BST_SHORT_LEB (0<<4) +#define BST_LONG_LEB (1<<4) + +#define HIGH_PGAIN_MASK (1<<3) +#define NORMAL_P_GAIN (0<<3) +#define HIGH_P_GAIN (1<<3) + +#define VCOMP_MASK (1<<2) +#define VCOMP_NORMAL_MODE (0<<2) +#define VCOMP_V_MON_MODE (1<<2) + +#define PMOS_ON_MASK (1<<1) +#define PMOS_NORMAL_MODE (0<<1) +#define PMOS_TEST_MODE (1<<1) + +#define NMOS_ON_MASK (1<<0) +#define NMOS_NORMAL_MODE (0<<0) +#define NMOS_TEST_MODE (1<<0) + +/* BST_TEST1 : 0x0C */ +#define SET_OCP_H_MASK (3<<6) +#define HIGH_OCP_4_5_LVL (0<<6) +#define HIGH_OCP_3_2_LVL (1<<6) +#define HIGH_OCP_2_1_LVL (2<<6) +#define HIGH_OCP_0_9_LVL (3<<6) + +#define OCL_TEST_MASK (1<<5) +#define OCL_NORMAL_MODE (0<<5) +#define OCL_TEST_MODE (1<<5) + +#define LOOP_CHECK_MASK (1<<4) +#define BST_LOOP_NORMAL_MODE (0<<4) +#define BST_LOOP_CHECK_MODE (1<<4) + +#define EN_SH_PRT_MASK (1<<3) +#define EN_SH_PRT_DISABLE (0<<3) +#define EN_SH_PRT_ENABLE (1<<3) + +/* SPK_TEST : 0x0D */ +#define VREF_MON_MASK (1<<3) +#define VREF_NORMAL_MODE (0<<3) +#define VREF_V_MON_MODE (1<<3) + +#define SPK_OCP_DLYN_MASK (1<<2) +#define SPK_OCP_LONG_DELAY (0<<2) +#define SPK_OCP_NORMAL (1<<2) + +#define SPK_OFF_SLOPE_MASK (3<<0) +#define SPK_OFF_SLOPE_SLOW (0<<0) +#define SPK_OFF_SLOPE_FAST (3<<0) + +/* MUTE_VOL_CTRL : 0x0E */ +#define VOL_SLOPE_MASK (3<<6) +#define VOL_SLOPE_OFF (0<<6) +#define VOL_SLOPE_SLOW (1<<6) +#define VOL_SLOPE_MID (2<<6) +#define VOL_SLOPE_FAST (3<<6) + +#define MUTE_SLOPE_MASK (3<<4) +#define MUTE_SLOPE_OFF (0<<4) +#define MUTE_SLOPE_SLOW (1<<4) +#define MUTE_SLOPE_MID (2<<4) +#define MUTE_SLOPE_FAST (3<<4) + +#define SPK_MUTE_MASK (1<<0) +#define SPK_UNMUTE (0<<0) +#define SPK_MUTE (1<<0) + +/* SYSTEM_CTRL1 :0x10 */ +#define SPK_MODE_MASK (7<<2) +#define SPK_OFF (0<<2) +#define SPK_MONO (1<<2) +#define SPK_STEREO (4<<2) + +/* SYSTEM_CTRL2 : 0x11 */ +#define SPK_BS_MASK (1<<6) +#define SPK_BS_BYP (0<<6) +#define SPK_BS_EN (1<<6) +#define SPK_LIM_MASK (1<<5) +#define SPK_LIM_BYP (0<<5) +#define SPK_LIM_EN (1<<5) + +#define LR_DATA_SW_MASK (1<<4) +#define LR_DATA_SW_NORMAL (0<<4) +#define LR_DATA_SW_SWAP (1<<4) + +#define MONOMIX_MASK (1<<0) +#define MONOMIX_OFF (0<<0) +#define MONOMIX_ON (1<<0) + +/* SYSTEM_CTRL3 : 0x12 */ +#define INPUT_MASK (3<<6) +#define INPUT_0_DB (0<<6) +#define INPUT_M6_DB (1<<6) +#define INPUT_M12_DB (2<<6) +#define INPUT_INFI_DB (3<<6) +#define INPUT_R_MASK (3<<4) +#define INPUT_R_0_DB (0<<4) +#define INPUT_R_M6_DB (1<<4) +#define INPUT_R_M12_DB (2<<4) +#define INPUT_R_INFI_DB (3<<4) + +/* Modulator : 0x14 */ +#define SPK_HYSFB_MASK (3<<6) +#define HYSFB_625K (0<<6) +#define HYSFB_414K (1<<6) +#define HYSFB_297K (2<<6) +#define HYSFB_226K (3<<6) +#define SPK_BDELAY_MASK (63<<0) + +/* SDM CONTROL : 0x33 */ +#define SDM_Q_SEL_MASK (1<<2) +#define QUART_SEL_1_DIV_4 (0<<2) +#define QUART_SEL_1_DIV_8 (1<<2) + +/* OTP_DATA1 : 0x34 */ +#define OTP_LVL_MASK (1<<5) +#define OTP_LVL_NORMAL (0<<5) +#define OTP_LVL_LOW (1<<5) + +/* PROTECTION : 0x36 */ +#define EDGE_DIS_MASK (1<<7) +#define EDGE_DIS_ENABLE (0<<7) +#define EDGE_DIS_DISABLE (1<<7) + +#define SPK_OCP_DIS_MASK (1<<3) +#define SPK_OCP_ENABLE (0<<3) +#define SPK_OCP_DISABLE (1<<3) + +#define OCP_MODE_MASK (1<<2) +#define AUTO_RECOVER (0<<2) +#define SHUT_DOWN_PERMANENT (1<<2) + +#define OTP_MODE_MASK (3<<0) +#define OTP_MODE_DISABLE (0<<0) +#define IG_THR1_SHUT_THR2 (1<<0) +#define REC_THR1_SHUT_THR2 (2<<0) +#define SHUT_THR1_SHUT_THR2 (3<<0) + +/* TEST2 : 0x3C */ +#define SPK_HSDM_BP_MASK (1<<4) +#define SPK_HSDM_ENABLE (0<<4) +#define SPK_HSDM_BYPASS (1<<4) + +#define SDM_SYNC_DIS_MASK (1<<5) +#define SDM_SYNC_NORMAL (0<<5) +#define SDM_SYNC_DISABLE (1<<5) + +/* ATEST2 : 0x3F */ +#define SPK_OUT_FREQ_MASK (1<<2) +#define SPK_OUT_FREQ_360K (0<<2) +#define SPK_OUT_FREQ_410K (1<<2) + +#define LOW_POWER_MODE_MASK (1<<3) +#define LOW_POWER_MODE_DISABLE (0<<3) +#define LOW_POWER_MODE_ENABLE (1<<3) + +#define THERMAL_ADJUST_MASK (3<<5) +#define THERMAL_150_110 (0<<5) +#define THERMAL_160_120 (1<<5) +#define THERMAL_140_100 (2<<5) + +#define FAST_OFF_DRIVE_SPK_MASK (1<<0) +#define FAST_OFF_DRIVE_SPK_DISABLE (0<<0) +#define FAST_OFF_DRIVE_SPK_ENABLE (1<<0) + +/* PLL_CTRL : 0x8E */ +#define TRM_LVL_MASK (1<<4) +#define TRM_LVL_NORMAL (0<<4) +#define TRM_LVL_LOW (1<<4) + +#define LOW_OCL_MODE_MASK (1<<3) +#define LOW_OCL_MODE (0<<3) +#define NORMAL_OCL_MODE (1<<3) + +#define PLL_PD2_MASK (7<<0) +#define PLL_PD2 (7<<0) +#define PLL_OPERATION2 (0<<0) + +/* POSTSCALER : 0x90 */ +#define BYP_POST_MASK (1<<0) +#define EN_POST_SCALER (0<<0) +#define BYP_POST_SCALER (1<<0) + +/* FDPEC CONTROL : 0x92 */ +#define FLT_VDD_GAIN_MASK (15<<4) +#define FLT_VDD_GAIN_2P40 (0<<4) +#define FLT_VDD_GAIN_2P45 (1<<4) +#define FLT_VDD_GAIN_2P50 (2<<4) +#define FLT_VDD_GAIN_2P55 (3<<4) +#define FLT_VDD_GAIN_2P60 (4<<4) +#define FLT_VDD_GAIN_2P65 (5<<4) +#define FLT_VDD_GAIN_2P70 (6<<4) +#define FLT_VDD_GAIN_2P75 (7<<4) +#define FLT_VDD_GAIN_2P80 (8<<4) +#define FLT_VDD_GAIN_2P85 (9<<4) +#define FLT_VDD_GAIN_2P90 (10<<4) +#define FLT_VDD_GAIN_2P95 (11<<4) +#define FLT_VDD_GAIN_3P00 (12<<4) +#define FLT_VDD_GAIN_3P05 (13<<4) +#define FLT_VDD_GAIN_3P10 (14<<4) +#define FLT_VDD_GAIN_3P15 (15<<4) + +#define DIS_FCHG_MASK (1<<2) +#define EN_FAST_CHARGE (0<<2) +#define DIS_FAST_CHARGE (1<<2) + +/* BOOST_CONTROL4 : 0x97 */ +#define TRM_VBST_MASK (7<<2) +#define TRM_VBST_5P5 (0<<2) +#define TRM_VBST_5P6 (1<<2) +#define TRM_VBST_5P7 (2<<2) +#define TRM_VBST_5P8 (3<<2) +#define TRM_VBST_5P9 (4<<2) +#define TRM_VBST_6P0 (5<<2) +#define TRM_VBST_6P1 (6<<2) +#define TRM_VBST_6P2 (7<<2) + +/* TOP_MAN1 : 0xA2 */ +#define PLL_LOCK_SKIP_MASK (1<<7) +#define PLL_LOCK_ENABLE (0<<7) +#define PLL_LOCK_DISABLE (1<<7) + +#define PLL_PD_MASK (1<<6) +#define PLL_OPERATION (0<<6) +#define PLL_PD (1<<6) + +#define PLL_DIV_MASK (3<<4) +#define PLL_OUT (0<<4) +#define PLL_OUT_2 (1<<4) +#define PLL_OUT_4 (2<<4) +#define PLL_OUT_8 (3<<4) + +#define PLL_REF_CLK_MASK (1<<3) +#define PLL_REF_CLK1 (0<<3) +#define PLL_SCK (1<<3) + +#define DAC_DN_CONV_MASK (1<<2) +#define DAC_DN_CONV_DISABLE (0<<2) +#define DAC_DN_CONV_ENABLE (1<<2) + +#define SDO_IO_MASK (1<<1) +#define HIGH_Z_LRCK_H (0<<1) +#define HIGH_Z_LRCK_L (1<<1) + +#define SDO_OUTPUT2_MASK (1<<0) +#define SDO_NORMAL (0<<0) +#define SDO_OUTPUT_ONLY (1<<0) + +/* TOP_MAN2 : 0xA3 */ +#define MON_OSC_PLL_MASK (1<<7) +#define PLL_SDO (0<<7) +#define PLL_OSC (1<<7) + +#define TEST_CLKO_EN_MASK (1<<6) +#define NORMAL_SDO (0<<6) +#define CLK_OUT_SDO (1<<6) + +#define SDO_OUTPUT_MASK (1<<3) +#define NORMAL_OUT (0<<3) +#define HIGH_Z_OUT (1<<3) + +#define CLOCK_MON_MASK (1<<1) +#define CLOCK_MON (0<<1) +#define CLOCK_NOT_MON (1<<1) + +#define OSC_PD_MASK (1<<0) +#define NORMAL_OPERATION_OSC (0<<0) +#define POWER_DOWN_OSC (1<<0) + +/* TOP_MAN3 0xA4 */ +#define O_FORMAT_MASK (7<<5) +#define O_FMT_LJ (1<<5) +#define O_FMT_I2S (2<<5) +#define O_FMT_TDM (4<<5) + +#define SCK_RATE_MASK (1<<3) +#define SCK_64FS (0<<3) +#define SCK_32FS (2<<3) + +#define LRCK_POL_MASK (1<<0) +#define L_VALID (0<<0) +#define R_VALID (1<<0) + +/* TDM1 FORMAT : 0xA5 */ +#define TDM_CLK_POL_MASK (1<<7) +#define TDM_CLK_POL_RISE (0<<7) +#define TDM_CLK_POL_FALL (1<<7) + +#define TDM_TX_MODE_MASK (1<<6) +#define TDM_TX_MONO (0<<6) +#define TDM_TX_STEREO (1<<6) + +#define TDM_SLOT1_RX_POS_MASK (7<<3) +#define TDM_SLOT1_RX_POS_0 (0<<3) +#define TDM_SLOT1_RX_POS_1 (1<<3) +#define TDM_SLOT1_RX_POS_2 (2<<3) +#define TDM_SLOT1_RX_POS_3 (3<<3) +#define TDM_SLOT1_RX_POS_4 (4<<3) +#define TDM_SLOT1_RX_POS_5 (5<<3) +#define TDM_SLOT1_RX_POS_6 (6<<3) +#define TDM_SLOT1_RX_POS_7 (7<<3) + +#define TDM_SLOT2_RX_POS_MASK (7<<0) +#define TDM_SLOT2_RX_POS_0 (0<<0) +#define TDM_SLOT2_RX_POS_1 (1<<0) +#define TDM_SLOT2_RX_POS_2 (2<<0) +#define TDM_SLOT2_RX_POS_3 (3<<0) +#define TDM_SLOT2_RX_POS_4 (4<<0) +#define TDM_SLOT2_RX_POS_5 (5<<0) +#define TDM_SLOT2_RX_POS_6 (6<<0) +#define TDM_SLOT2_RX_POS_7 (7<<0) + +/* TDM2 FORMAT : 0xA6 */ +#define TDM_DL_MASK (1<<7) +#define TDM_DL_16 (0<<7) +#define TDM_DL_32 (1<<7) + +#define TDM_N_SLOT_MASK (1<<6) +#define TDM_N_SLOT_4 (0<<6) +#define TDM_N_SLOT_8 (1<<6) + +#define TDM_SLOT1_TX_POS_MASK (7<<3) +#define TDM_SLOT1_TX_POS_0 (0<<3) +#define TDM_SLOT1_TX_POS_1 (1<<3) +#define TDM_SLOT1_TX_POS_2 (2<<3) +#define TDM_SLOT1_TX_POS_3 (3<<3) +#define TDM_SLOT1_TX_POS_4 (4<<3) +#define TDM_SLOT1_TX_POS_5 (5<<3) +#define TDM_SLOT1_TX_POS_6 (6<<3) +#define TDM_SLOT1_TX_POS_7 (7<<3) + +#define TDM_SLOT2_TX_POS_MASK (7<<0) +#define TDM_SLOT2_TX_POS_0 (0<<0) +#define TDM_SLOT2_TX_POS_1 (1<<0) +#define TDM_SLOT2_TX_POS_2 (2<<0) +#define TDM_SLOT2_TX_POS_3 (3<<0) +#define TDM_SLOT2_TX_POS_4 (4<<0) +#define TDM_SLOT2_TX_POS_5 (5<<0) +#define TDM_SLOT2_TX_POS_6 (6<<0) +#define TDM_SLOT2_TX_POS_7 (7<<0) + +/* STATUS1 : 0xFA */ +#define OT1_OK_STATUS (1<<7) +#define OT2_OK_STATUS (1<<6) + +/* STATUS2 : 0xFB */ +#define OCP_SPK_STATUS (1<<5) +#define OCP_BST_STATUS (1<<4) +#define OTP_STAT_OK_0 (5<<1) +#define OTP_STAT_OK_1 (2<<2) + +#define CLK_MON_STATUS (1<<0) + +/* DEVICE_INFO : 0xFF */ +#define DEVICE_ID (2<<3) +#define UVLO_BST_STATUS (1<<2) +#define REV_NUM_STATUS (3<<0) +#define REV_NUM_TV0 (0<<0) +#define REV_NUM_TV1 (1<<0) + +#endif From patchwork Fri Jan 6 09:15:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 639710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBD89C5479D for ; Fri, 6 Jan 2023 09:17:48 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A171184D3; Fri, 6 Jan 2023 10:16:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A171184D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996665; bh=1Qa3+2GkBbW9EfG6aEy7ULobdXNWd+HsJlqr3jL2HcY=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Ds80SaBs8cwesWkBAZO9+8Z8g4X0jpsVZNXD/I9QFoIvcqprEg+97fYOlLFZo7Y1d vgycAyqtN+Qa/+ODOQUpqUMKAX/BfVrQTo7E+vIEExDNKcKD4MjOkG0vzjfT8JMJhR mgQvL8HV4u2UbwiYexU1modF4e3L2Oq2GuPDxIlE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 74A2CF80520; Fri, 6 Jan 2023 10:16:10 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2F422F8053D; Fri, 6 Jan 2023 10:16:08 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2040.outbound.protection.outlook.com [40.107.129.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 121EFF8025A for ; Fri, 6 Jan 2023 10:16:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 121EFF8025A ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FS2s8quwAwPLNoxSuprpFigsF6PqTwBT9EO/QOrYUFYQmUqd1pHkCtGiUQ9dVF90mPKF+Cdp6VKV6F6ZwXCJJ4yNw2tJ1ZFCNiRGiKVayF0bzs/+gCffsoKyv2clD3Y3TnVDDaD71ZyYL+gxNLzmuSqdN2MRoFx2nrpyIaOLjnC7NUhQ1bPCg1ZSlXZA3NU2Td5aaOM5jSLhuNSU21RKU5vH3ePYUeA9B7KHeMAlnHrynvwPreG1Z7t6QyIXkf8n46/Skp7PA884gWbv8fgSLlTR0F7hfmShkcazArT1yVerC+X6FVnL7DY7B2lL5/x3mDBADNc65M8cTAPpyE6NaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LYbvXoJ2XmLdIJqD74b7ZIzghKUJ3PhvxbyYUmdgF2g=; b=K8srrcbNYOd451rM25bzY0/ifogdums7Rg43a6Ep+gKDlmXOoQuidVGzcsmjaKNRxcWZiZO3m5K4+tYz8qGK4FBWPf3Q51mGtJchQdxUWRlxzisICvzpQr535FFKNkVOt9ZoJmF02aIZzYIEuneYLY5fgTluoZDrBZ4032MZNMzwgqtyp0+pzdlqP+9XY6BEF1PuIw9sMb5/NU5kDFPzrSu51nS1O+Qns4vJqODeNooNuV6PNJq3gsN179Hhk49D92e9EEHBt+ng9irdu4mgfZ8bVuk5Z0r6/LVZFccVQuDcGNnM0hlyy9Rxc+8WgkjXRcXM/u8On7dKwMXbsSVMTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:56 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:56 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 02/14] ASoC: dt-bindings: sma1303: Iron Device SMA1303 Amp Date: Fri, 6 Jan 2023 18:15:31 +0900 Message-Id: <20230106091543.2440-3-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: adb73e3a-773e-4bca-4c80-08daefc69de1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HEUgHib0W8IIYDTEAmxgwY1ko4TkYjbKMyUy3vgu95TEdttDKI7dUk/PZ4Fm8ONhj4UCzd2CTwiPGZLzK2oLTb6/1TUKs1Ef3OHSx4AajVVKYUa3QSYpSRnIlrm9YQ0wa84wbeuY76Kimxxa/IJ9aq126kb3fnhlAW0sBXSy/2b9WhQr5cboJAk7w4PEB3NqXcbhaLKNz+dUwEoEAquHv31azY1flUQTQuH2G9dHVZ/haQTIhkgPisTvEuyZ1p3lGIWu/8OjXQwtZR4jE0slZyxpHfer3uGkOYNNGO/ULjg3/Sh6coLEIy4OH5kG1b65HH2tcEJ343ph96NP2r5LPUkhk4aekF/Bcq0LFIQufpuuGB0QJ04fePRvhYnKfcaGS0BqL72yh8YXdlt7z4Rh7RUEaGnDNi4f05P2f/YsP4Em531JPYwiQ7H7g3kzuNhn+TyVKHdJ+SOd4WdXwkrGMU0bpj2Qa6kGqfPIWJRsc7Ow4a5Xhx8V6AGLSbD20/xCAo5tm55Mmpa5nV/XSeFY95HsiVfRd2nRf43q6WUSjQ3doWPB0g4iU4M+W0lK4isUUMWCCiYTdkMKSQgP8yfsydh+a4j2yXG16RRPAZeqxiz50qV++ig1oLTjmi1cgMDxOb6cAIb4gikfLFIZT5y+8xEoMRn4k3wZZ06WRFUOBu7XHfzllRYdVVzqDnz20/bwrmwSzdnZdR1QS2T9IKFKlyx5loeyIxscLWFnhuMcyjc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(966005)(66556008)(316002)(6486002)(478600001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UXIDmOHbYGVsLNLut4Gtce6wujdPBVhMUjX0KGpFBeRjgrcgeqOC/PJJaNMDJ2YDMmY5sqee6YIrTCE2yb+6mSHcAMSYCF6yTR6pw2kgV5+nX/IBs+xK+TOJaw3PnHIIT7RfF3Drvhjdf+i1h3UN+8o2tCtRMll2+Xn3KbI1u+k3wAjoswm+/TvPXs93+eRGEgC71F7e0rv3c6uPO8uwzMQyhHpKZrRI/wZEKKwxTtxc2cuX9LTgWu904YnHp/cXo8E5R58/GLVpDZxLb7ZsNTd3KAlt3HYC6YcyYw7iEhhoWxZRmnSxgdnz4PSe05WoFcneydcqNjmkf9nVUmDxlkUvtGGHU0EXTQ32NX4X8wdxBrfbpTU9R+tWzmijL5EXFo2kdfoB4+KRkHP7bvZHv/0I1iPGTE3wxxEfxo5/i8l9Q/q1BPDuGIB/UM6Ou8dAXHr8f8DueT3ppLohXLQTklRnrlpBjK/jP3iMdikzsi71r/o+S524F9c15+gUTqIc9wdh4EuyfOjidlaA4nx1CsT/UlPckSvS2YtwS6ZRF9QrmG9yeQi1lIAxohWT6I6Z26/RHDlJppE3O8vWBxGT04cF95MK9DpSnskij2vaFzRQVcLvi8NmzZutqm9kXRaMi7UqPoaSs4GF7BSWcnN7jXw/EJYAi7W5i8aBC+vpUWmjgVwDEHXrAEtyX5m5SZKzaRv+oUc3bxuNGuOkH95TOiX/36LmWVCczQBQhOvpaMp5ZeuZ9QtvF08sueMNwbBtPAitYblIOjfzgzeR2s3gr9u2qPSKrfWkJ2aCAl57h83q0CcNCo4Jwv8H5q6WkTEvcQtSnWZhcwt5Z5jrKlYQ0wj8vrKMF3j7XGgIHMB0ye4XG0uBzzFIer9rm2fvRHxqtPItOMte3xSRSSIgox1z+pcLUs0UYHaJ7yZji10iv/bz04+tTbZGYoDDKYs10siHKNkdbIKJVmdp7meq/ndSly25X8JlF6ho69YUcRq60DJVQnVETZ1QjK5PEnK37QwMYnI0wNvjpfHxhrF7FjOx46w7ukqBEHMlXw1Is+rZzst1ydhvNaq/I7wrSy7rZPr3SkzJiAtustzdpezP8r08fuQB8BlSKzsrhoku6EKsy0sRdAA67uzvTdaB0A9IFuNwywniVl/R6N7yps+oXSg0sxCxtEulzO21fF0Nd4re5vyUgYQTwUUfl1nOqkR0ArPtX8EvQF+ndMKXjwzfawAA7vixY83CvWoiYAYQ9u20Ch7h27QOmI86g8BoPaM+ns3j8cBIdNVw2z73EJBplmI5AZyA5dOGsNQuYB38lEZDOkIKNlHU58VKWmNP8ykTvLQL5yulNl/+OW0F/yWE3E75l6IOU422fq3MJKqXDJ6kyw/3a6HBOcQOWzj5JXrdtNKg9MWX1QpfnnYxXxgxsu+v8sHiZY7ONow0lu3xIdFHN550ITGyjq4T+WT7nV18os7K63uSeIC7h0FwdDRG0rAotdIfX5vuWAeb6wtA4L1RdW7ndO43ME4zENZOeY+fetjQy5kjV7fXwLR0/HrSupDGB8t+zwRSv4z+hQ6EwvqUXA6Y10lDFJflIE1s5GFq74yH X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: adb73e3a-773e-4bca-4c80-08daefc69de1 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:55.9885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UyHvKKNnBrBNrzSaz4Dex5Dr3tjubO10eMmss0a3NMb/kZCkqYT9nppiaNeUZ2FwFJ8MlKO/O3PD1Yq4dmbWgzxiICxLFSB8wsWnZK9tnZ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Modified the schema binding and added the vendor prefixes. Signed-off-by: Kiseok Jo --- .../bindings/sound/irondevice,sma1303.yaml | 40 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.yaml | 2 + 2 files changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml diff --git a/Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml b/Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml new file mode 100644 index 000000000000..8c3b85f962ff --- /dev/null +++ b/Documentation/devicetree/bindings/sound/irondevice,sma1303.yaml @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/irondevice,sma1303.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Iron Device SMA1303 Audio Amplifier + +maintainers: + - Kiseok Jo + +description: + SMA1303 digital class-D audio amplifier with an integrated boost converter. + +allOf: + - $ref: name-prefix.yaml# + +properties: + compatible: + const: irondevice,sma1303 + + reg: + description: + I2C address of the amplifier. See the datasheet for possible values. + +required: + - compatible + - reg + +additionalProperties: true + +examples: + - | + #include + i2c_bus { + sma1303_amp: sma1303@1e { + compatible = "irondevice,sma1303"; + reg = <0x1e>; + }; + }; \ No newline at end of file diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 70ffb3780621..271ff119764a 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -635,6 +635,8 @@ patternProperties: description: Inverse Path "^iom,.*": description: Iomega Corporation + "^irondevice,.*": + description: Iron Device Corporation "^isee,.*": description: ISEE 2007 S.L. "^isil,.*": From patchwork Fri Jan 6 09:15:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 639711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9ACC0C5479D for ; Fri, 6 Jan 2023 09:17:28 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 48D711411C; Fri, 6 Jan 2023 10:16:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 48D711411C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996646; bh=Fmo8oFqw0cD3FSNuTWr51NQS06foqERLa8iCGUV7F5g=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=aBDubKcNsWNpByqs4xbC8q18UOIEHsj7QfCQILfSCmqpI4uqwpDLR1Dhj5Onl48cS PYle/skwPnyOqz8VkFVYS8MzyZF0PSh7DR4h1y++yMiMoUlMFCWUDiIgTyJC4Uh1bv zUvq3gg6qkBRQQIq4u1d2Rjyu7DBcVjpMiMQsPpg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0FAD7F804AD; Fri, 6 Jan 2023 10:16:08 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4DEBFF8025A; Fri, 6 Jan 2023 10:16:06 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2059.outbound.protection.outlook.com [40.107.129.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5A988F80217 for ; Fri, 6 Jan 2023 10:16:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5A988F80217 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UOBbPKpk+pDDo/BmLshiqxBrx0YOFU48SF+9tryQ5r234OJodDa/2Z47nnfEb6yfoGJ8vxJCN5fTZbliIZfFKxEigcwLD9F47uC6TObfZKIIFpXLlSj6wuWs1UrZzStwngGOfUD7mUceaOwDZkqbJ7GDCQVY96cyAh4lqmiQN7qoY1kUp+Vz9VprOC61xrZgBzDEZYNYS9mf12vy61YCSEXS4Tyt9Vk2aC1E0V54QJesurI65WEScQAHZH5b5z27GpC+GeNGIrvI8XCXsD+US7NaWCip+ZYe+whNoCQch19xrLB84nZ/UUFCfY5zBgksHtzmjbgrjlptQdJyoXyThQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m8lU592bRchRfZZ8/8ztJ09tqoCoLHzsDqN/cE2ldWE=; b=ZC586MD2W7+x4C/3wB5ubV+VuPU3zhgQ4/+xwMnFrk06SEamA3zNWUFy0srnKjtO5d+bbvkAhJqwtxNzQcQ7xqRKOg4ePrtwO3EhZPhtKkUGtSSrKk3x9G8VxhADAdX5jmM9/IGxmrfAJYxyThv0vhQT/xhK6VYqgcMuMQDX6++twO60l4w8EGD4TTjqVZLDl33S+CdJTrEoy6ty6H8nZgA+0kID9DZonUOmUFFfv2fDqeSeNap2oN5Kms5YY6sbqt9eWHyCRtiioe+FDu5YcjapgVum/qlmsT8ne5z2TlJswmVknjF1yfSDwrDUmqd9Rww6R6fRNiFgTenrbD1Nfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:56 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:56 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 03/14] Add the i2c-retry count and callback function in regmap function. Date: Fri, 6 Jan 2023 18:15:32 +0900 Message-Id: <20230106091543.2440-4-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: b138784d-95c9-4764-aad4-08daefc69e21 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EO4mKrmOCinRAUb0UAWHQFjwb2nia0fCgsMkDeSrhxoVsOvE2BpsQCdAn8H71O57YSi8rHgjljkURTGigLQcZT5HwSBPhIed1+/t93iIBSUbrqJG0yo4oUtXzW2ZYcCC50TD+RNQinGm/vhZ4dK56bj3we9YILTUBK1UxGEr0/cQXS9LVMKRlcfoGr4rVnDEM/L46MZ+lLyeGN/nzLxT5mhz5I1YzX4taWi4s/KnhdgpD6OxKfZCMu7z+4D+YfKvK3vZDzYYSVDnp0uCFjQcje9Xa9qELxpygiMi0elg6looXSckeNBuJBdfXTN3shsuamzq/2vb56KDrKAC60juGWIf59ai+OqUIrYvvEBaK3OMHqmvr3pTRz6DBYKn1FpZXHdXFJF2hLz6WEQL2Wc7hGlFUc4tpgIjOGELM8ZcAgFOD8lXDcNPEwAXBu/RA7Ob3FDTp5Wa55LjvLJxE47pKFgr/AIXtk1/CX3FZ1t3gHkbxc1Gwcb/I+Snm3dys1Ee95pgEfo7A6YadLJEIRBbUTbiCZmkyHQ1x14AH521NwCjLXOVsQnTynyWsCchlplbPT724338AoKUAaeCftRra+2MVz3mEYsqAd0gfImaKOwTpg8DNZhdI1u8c4xauXUkphzvwVBDsCoaIi7+XKxIRluVF4qOs0QQoHkB6oxqBzjvcFa1cFduT5/peRY+eo73 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(30864003)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 40qMGHXD36cdBIkpBoEcLPHo613VQmcZQLTRuC7gccdCFniAjgOiUS+vCnpsDU6NQVbGcwr6aaU2JX00/dwunaItr3GrUk4RpFgyEvXOB+4+8K2I2Lrg5uZFDRcXLgUphm8UuCrHPhcRn018I/4l+e3LimNkuBeX50rfsE/hf5nG/byFhck0NI3iHhcL3Va0oBgTRoFJLrspAvlNF63olV/noUTzrBn8GyvMY5QthppCXTHgv+/IuOPst2bM1ZfOnfVQMT9LX1ARa4mX8QFrqmUy3V3RP0skSRoPVxUM4DCgHa1YeMj4hdW9rYMrKZHg1YYfZzt+MMI93kDyTHNDprejxNOswF/n+6khKghiXbEM924uHuojSlLUTjnUy9/im1DKMTzXEM2ZTJudwhr0w7opbhgkVps/aZjw+A+3FwfC2pALBTTDaILPQ/QoXRYpsDXDreEKsu3g4APNx56CTL36p/uYktIXsoW0dOp0W1t+/bgj9a5Yc3T7thc1FOZIOKOS3RFxU7oJfo0YL0WQwtYzkdcMy79nZar+v8aRrmyU5c2wb+gSRyl/2CpW5HeXM3Uk7uzMWwaMomHym1b/e9u6Tl03shtRI2TP11QWdF9QdBdk+VAT98mGNOMib8DJR6abgRWeKWgshi6XYc702PCoHOW98pQdHowj+Q2mSmUQQFIioVJOiscFcbiejHTid9qA8nkEFdIeas2yCZRIuygPqmYw1VPcgU0qb698bOfaBL56c0Cdb6v9CJvlrHkjvHGiYiNBle+yDTfxV7ZN6HOMNZWNZltrOhk9+rWBuKxaJYt9Pv7zLi570g6qc7HrxdsYx6pETRHZfYNbGJ2v504/D9n7l5FxPHHrMJxf2PVSz+09hKvo3D1ThoTpvhEs+9YhDzfcYbr26oixVm8RLdWkXTfQCaAlvKrDB/x4vlYGUJJIdcGvV6pgQdiiCV23RyvVYQZkNd2K0UySi6x+PSfu57wSW9nX/vzxb69inYV1nkaYBIVbvASoitVhm8y63TNv/EmnHCouZME105qmDXlxscYTm7kqUlsWOrnhfWdPxVxSubeLSBKXpY/TCveg55RR/+uWCNHCjS5yKhbJ6SrqVQF2dKBMR/0r2pSMByM+jOM2pSsWNkWKFdM6Bw9g+BN/4+/b5vD6w9izC/NfxibcbspVMNZr7l1RWlVxbNum2Z99Xh2ssVmKQnMVhoPcg4J6dNKzYTbdtKbVuqP32Mwoc++Deb88tcsSY8lAqaENvPWXGMUSYZLf3djsxhabwelTSwFTT+a0HW7Xy770DpeS4CgT+jlpICwIfJXcr4Tm54z4yDLq5IIZCKCkNNyYiFxZ+hGhrmAAZiIYcytr5+eaKXLDX5aPL2X+IVfTRhjFNqrbgt2cLKxIoAW7OZytshKffG2r/eao5H11RRDRnHPpzZBCeZG6bwpKq/cdzhhgIMknB9XISXloiq8gcHP1dlEt81ep/uGNdjujYaBC2tJe2Q+AAhfnrn9WKFEB4oKWrHDHih4IBracgEhPS2CzZ5cqZ/gbDEEdq08NR2xF6ycQtioMJCKkQfqFvs86XljQ5OnaU7CXK6OA1FbVF0Dc X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: b138784d-95c9-4764-aad4-08daefc69e21 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:56.5353 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FoUThxie7ln2T0Hcz4Ehq87xhTS+oDln6pHQ1vxq8I+jfNGhq+aA5YWZOZHR7PVUgZgInoOfJ1HsiGfxoEAm40TZnhjTdulmwM/dTkt2TLU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Kiseok Jo Reported-by: Mark Brown --- sound/soc/codecs/sma1303.c | 261 ++++++++++++++++++++----------------- sound/soc/codecs/sma1303.h | 9 ++ 2 files changed, 147 insertions(+), 123 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 50b471920fc8..8bd59a481f2d 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -47,6 +47,8 @@ enum sma1303_type { SMA1303, }; +struct callback_ops gCallback; + struct sma1303_pll_match { char *input_clk_name; char *output_clk_name; @@ -69,6 +71,7 @@ struct sma1303_priv { bool amp_power_status; bool usage_status; int num_of_pll_matches; + int retry_cnt; unsigned int sys_clk_id; unsigned int init_vol; unsigned int cur_vol; @@ -233,28 +236,66 @@ static bool sma1303_volatile_register(struct device *dev, unsigned int reg) static const DECLARE_TLV_DB_SCALE(sma1303_spk_tlv, -6000, 50, 0); -static int sma1303_regmap_write(struct regmap *map, struct device *dev, +void sma1303_set_callback_func(struct callback_ops ops) +{ + if (ops.set_i2c_err) + gCallback.set_i2c_err = ops.set_i2c_err; +} +EXPORT_SYMBOL(sma1303_set_callback_func); + +static int sma1303_regmap_write(struct sma1303_priv *sma1303, unsigned int reg, unsigned int val) { int ret = 0; + int cnt = sma1303->retry_cnt; - ret = regmap_write(map, reg, val); - if (ret < 0) { - dev_err(dev, "Failed to write, register: 0x%02X, ret: %d\n", - reg, ret); + while (cnt--) { + ret = regmap_write(sma1303->regmap, reg, val); + if (ret < 0) { + dev_err(sma1303->dev, + "Failed to write [0x%02X]\n", reg); + if (gCallback.set_i2c_err) + gCallback.set_i2c_err(sma1303->dev, ret); + } else + break; } return ret; } -static int sma1303_regmap_update_bits(struct regmap *map, struct device *dev, +static int sma1303_regmap_update_bits(struct sma1303_priv *sma1303, unsigned int reg, unsigned int mask, unsigned int val) { int ret = 0; + int cnt = sma1303->retry_cnt; - ret = regmap_update_bits(map, reg, mask, val); - if (ret < 0) { - dev_err(dev, "Failed to write, register: 0x%02X, ret: %d\n", - reg, ret); + while (cnt--) { + ret = regmap_update_bits(sma1303->regmap, reg, mask, val); + if (ret < 0) { + dev_err(sma1303->dev, + "Failed to update [0x%02X]\n", reg); + if (gCallback.set_i2c_err) + gCallback.set_i2c_err(sma1303->dev, ret); + } else + break; + } + return ret; +} + +static int sma1303_regmap_read(struct sma1303_priv *sma1303, + unsigned int reg, unsigned int *val) +{ + int ret; + int cnt = sma1303->retry_cnt; + + while (cnt--) { + ret = regmap_read(sma1303->regmap, reg, val); + if (ret < 0) { + dev_err(sma1303->dev, + "Failed to read [0x%02X]\n", reg); + if (gCallback.set_i2c_err) + gCallback.set_i2c_err(sma1303->dev, ret); + } else + break; } return ret; } @@ -280,7 +321,7 @@ static int bytes_ext_get(struct snd_kcontrol *kcontrol, } val = (u8 *)ucontrol->value.bytes.data; for (i = 0; i < params->max; i++) { - ret = regmap_read(sma1303->regmap, reg + i, ®_val); + ret = sma1303_regmap_read(sma1303, reg + i, ®_val); if (ret < 0) { dev_err(component->dev, "Failed to read, register: %x ret: %d\n", @@ -323,9 +364,7 @@ static int bytes_ext_put(struct snd_kcontrol *kcontrol, val = (u8 *)data; for (i = 0; i < params->max; i++) { - ret = sma1303_regmap_write( - sma1303->regmap, component->dev, - reg + i, *(val + i)); + ret = sma1303_regmap_write(sma1303, reg + i, *(val + i)); if (ret < 0) { kfree(data); return ret; @@ -463,32 +502,26 @@ static int sma1303_amp_mode_put(struct snd_kcontrol *kcontrol, switch (sma1303->amp_mode) { case ONE_CHIP_SOLUTION: case MONO_TWO_CHIP_SOLUTION: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, MONOMIX_MASK, MONOMIX_ON); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, LR_DATA_SW_MASK, LR_DATA_SW_NORMAL); break; case LEFT_TWO_CHIP_SOLUTION: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, MONOMIX_MASK, MONOMIX_OFF); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, LR_DATA_SW_MASK, LR_DATA_SW_NORMAL); break; case RIGHT_TWO_CHIP_SOLUTION: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, MONOMIX_MASK, MONOMIX_OFF); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, LR_DATA_SW_MASK, LR_DATA_SW_SWAP); break; @@ -524,7 +557,7 @@ static int sma1303_outport_config_get(struct snd_kcontrol *kcontrol, return ret; } - ret = regmap_read(sma1303->regmap, SMA1303_09_OUTPUT_CTRL, &data); + ret = sma1303_regmap_read(sma1303, SMA1303_09_OUTPUT_CTRL, &data); if (ret < 0) { dev_err(component->dev, "Failed to read, register: %x ret: %d\n", @@ -582,7 +615,7 @@ static int sma1303_outport_config_put(struct snd_kcontrol *kcontrol, return ret; } - return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + return sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, PORT_CONFIG_MASK, val); } @@ -618,7 +651,7 @@ static int sma1303_spkmode_get(struct snd_kcontrol *kcontrol, return ret; } - ret = regmap_read(sma1303->regmap, SMA1303_10_SYSTEM_CTRL1, &data); + ret = sma1303_regmap_read(sma1303, SMA1303_10_SYSTEM_CTRL1, &data); if (ret < 0) { dev_err(component->dev, "Failed to read, register: %x ret: %d\n", @@ -695,7 +728,7 @@ static int sma1303_spkmode_put(struct snd_kcontrol *kcontrol, return ret; } - return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + return sma1303_regmap_update_bits(sma1303, SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, val); } @@ -735,7 +768,7 @@ static int sma1303_postscaler_config_get(struct snd_kcontrol *kcontrol, return ret; } - ret = regmap_read(sma1303->regmap, SMA1303_90_POSTSCALER, &data); + ret = sma1303_regmap_read(sma1303, SMA1303_90_POSTSCALER, &data); if (ret < 0) { dev_err(component->dev, "Failed to read, register: %x ret: %d\n", @@ -793,7 +826,7 @@ static int sma1303_postscaler_config_put(struct snd_kcontrol *kcontrol, return ret; } - return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + return sma1303_regmap_update_bits(sma1303, SMA1303_90_POSTSCALER, BYP_POST_MASK, val); } @@ -820,7 +853,7 @@ static int sma1303_o_format_get(struct snd_kcontrol *kcontrol, return ret; } - ret = regmap_read(sma1303->regmap, SMA1303_A4_TOP_MAN3, &data); + ret = sma1303_regmap_read(sma1303, SMA1303_A4_TOP_MAN3, &data); val = data & O_FORMAT_MASK; switch (val) { case O_FMT_LJ: @@ -876,7 +909,7 @@ static int sma1303_o_format_put(struct snd_kcontrol *kcontrol, return ret; } - return sma1303_regmap_update_bits(sma1303->regmap, component->dev, + return sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, O_FORMAT_MASK, val); } @@ -927,17 +960,17 @@ static int sma1303_startup(struct snd_soc_component *component) return ret; } - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_8E_PLL_CTRL, PLL_PD2_MASK, PLL_OPERATION2); - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_ON); if (sma1303->amp_mode == ONE_CHIP_SOLUTION) - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_MONO); else - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_STEREO); if (sma1303->check_fault_status) { @@ -951,7 +984,7 @@ static int sma1303_startup(struct snd_soc_component *component) CHECK_PERIOD_TIME * HZ); } - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_UNMUTE); sma1303->amp_power_status = true; @@ -970,20 +1003,20 @@ static int sma1303_shutdown(struct snd_soc_component *component) return ret; } - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_MUTE); cancel_delayed_work_sync(&sma1303->check_fault_work); msleep(55); - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_OFF); - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_OFF); - ret += sma1303_regmap_update_bits(sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_8E_PLL_CTRL, PLL_PD2_MASK, PLL_PD2); sma1303->amp_power_status = false; @@ -1059,14 +1092,12 @@ static int sma1303_dac_feedback_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMU: dev_info(component->dev, "%s : DAC feedback ON\n", __func__); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, PORT_CONFIG_MASK|PORT_OUT_SEL_MASK, OUTPUT_PORT_ENABLE|SPEAKER_PATH); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, SDO_OUTPUT_MASK, NORMAL_OUT); break; @@ -1074,13 +1105,11 @@ static int sma1303_dac_feedback_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: dev_info(component->dev, "%s : DAC feedback OFF\n", __func__); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, PORT_OUT_SEL_MASK, OUT_SEL_DISABLE); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, SDO_OUTPUT_MASK, HIGH_Z_OUT); break; @@ -1138,26 +1167,25 @@ static int sma1303_setup_pll(struct snd_soc_component *component, return -EINVAL; } - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A2_TOP_MAN1, PLL_PD_MASK|PLL_REF_CLK_MASK, PLL_OPERATION|PLL_SCK); } - ret += sma1303_regmap_write(sma1303->regmap, component->dev, + ret += sma1303_regmap_write(sma1303, SMA1303_8B_PLL_POST_N, sma1303->pll_matches[i].post_n); - ret += sma1303_regmap_write(sma1303->regmap, component->dev, + ret += sma1303_regmap_write(sma1303, SMA1303_8C_PLL_N, sma1303->pll_matches[i].n); - ret += sma1303_regmap_write(sma1303->regmap, component->dev, + ret += sma1303_regmap_write(sma1303, SMA1303_8D_PLL_A_SETTING, sma1303->pll_matches[i].vco); - ret += sma1303_regmap_write(sma1303->regmap, component->dev, + ret += sma1303_regmap_write(sma1303, SMA1303_8F_PLL_P_CP, sma1303->pll_matches[i].p_cp); @@ -1211,25 +1239,21 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, case 44100: case 48000: case 96000: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A2_TOP_MAN1, DAC_DN_CONV_MASK, DAC_DN_CONV_DISABLE); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, LEFTPOL_MASK, LOW_FIRST_CH); break; case 192000: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A2_TOP_MAN1, DAC_DN_CONV_MASK, DAC_DN_CONV_ENABLE); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, LEFTPOL_MASK, HIGH_FIRST_CH); break; @@ -1249,8 +1273,7 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, dev_info(component->dev, "%s set format SNDRV_PCM_FORMAT_S16_LE\n", __func__); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, SCK_RATE_MASK, SCK_32FS); break; @@ -1259,8 +1282,7 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, dev_info(component->dev, "%s set format SNDRV_PCM_FORMAT_S24_LE\n", __func__); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, SCK_RATE_MASK, SCK_64FS); break; @@ -1268,8 +1290,7 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, dev_info(component->dev, "%s set format SNDRV_PCM_FORMAT_S32_LE\n", __func__); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, SCK_RATE_MASK, SCK_64FS); break; @@ -1317,8 +1338,7 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, return -EINVAL; } - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, I2S_MODE_MASK, input_format); return ret; @@ -1365,15 +1385,13 @@ static int sma1303_dai_mute(struct snd_soc_dai *dai, int mute, int stream) if (mute) { dev_info(component->dev, "%s : %s\n", __func__, "MUTE"); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_MUTE); } else { dev_info(component->dev, "%s : %s\n", __func__, "UNMUTE"); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_UNMUTE); } @@ -1393,8 +1411,7 @@ static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, case SND_SOC_DAIFMT_CBS_CFS: dev_info(component->dev, "%s : %s\n", __func__, "I2S/TDM Device mode"); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, CONTROLLER_DEVICE_MASK, DEVICE_MODE); break; @@ -1402,8 +1419,7 @@ static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, case SND_SOC_DAIFMT_CBM_CFM: dev_info(component->dev, "%s : %s\n", __func__, "I2S/TDM Controller mode"); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, CONTROLLER_DEVICE_MASK, CONTROLLER_MODE); break; @@ -1434,16 +1450,14 @@ static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, case SND_SOC_DAIFMT_IB_NF: dev_info(component->dev, "%s : %s\n", __func__, "Invert BCLK + Normal Frame"); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, SCK_RISING_MASK, SCK_RISING_EDGE); break; case SND_SOC_DAIFMT_IB_IF: dev_info(component->dev, "%s : %s\n", __func__, "Invert BCLK + Invert Frame"); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, LEFTPOL_MASK|SCK_RISING_MASK, HIGH_FIRST_CH|SCK_RISING_EDGE); @@ -1451,8 +1465,7 @@ static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, case SND_SOC_DAIFMT_NB_IF: dev_info(component->dev, "%s : %s\n", __func__, "Normal BCLK + Invert Frame"); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, LEFTPOL_MASK, HIGH_FIRST_CH); break; @@ -1482,21 +1495,18 @@ static int sma1303_dai_set_tdm_slot(struct snd_soc_dai *dai, sma1303->frame_size = slot_width * slots; - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, O_FORMAT_MASK, O_FMT_TDM); switch (slot_width) { case 16: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A6_TDM2, TDM_DL_MASK, TDM_DL_16); break; case 32: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A6_TDM2, TDM_DL_MASK, TDM_DL_32); break; @@ -1507,14 +1517,12 @@ static int sma1303_dai_set_tdm_slot(struct snd_soc_dai *dai, switch (slots) { case 4: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A6_TDM2, TDM_N_SLOT_MASK, TDM_N_SLOT_4); break; case 8: - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A6_TDM2, TDM_N_SLOT_MASK, TDM_N_SLOT_8); break; @@ -1524,27 +1532,23 @@ static int sma1303_dai_set_tdm_slot(struct snd_soc_dai *dai, } if (sma1303->tdm_slot_rx < slots) - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A5_TDM1, TDM_SLOT1_RX_POS_MASK, (sma1303->tdm_slot_rx) << 3); else dev_err(component->dev, "%s Incorrect tdm-slot-rx %d set\n", __func__, sma1303->tdm_slot_rx); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A5_TDM1, TDM_CLK_POL_MASK, TDM_CLK_POL_RISE); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A5_TDM1, TDM_TX_MODE_MASK, TDM_TX_MONO); if (sma1303->tdm_slot_tx < slots) - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_A6_TDM2, TDM_SLOT1_TX_POS_MASK, (sma1303->tdm_slot_tx) << 3); else @@ -1598,10 +1602,10 @@ static void sma1303_check_fault_worker(struct work_struct *work) mutex_lock(&sma1303->lock); if (sma1303->tsdw_cnt) - ret = regmap_read(sma1303->regmap, + ret = sma1303_regmap_read(sma1303, SMA1303_0A_SPK_VOL, &sma1303->cur_vol); else - ret = regmap_read(sma1303->regmap, + ret = sma1303_regmap_read(sma1303, SMA1303_0A_SPK_VOL, &sma1303->init_vol); if (ret != 0) { @@ -1611,7 +1615,7 @@ static void sma1303_check_fault_worker(struct work_struct *work) return; } - ret = regmap_read(sma1303->regmap, SMA1303_FA_STATUS1, &over_temp); + ret = sma1303_regmap_read(sma1303, SMA1303_FA_STATUS1, &over_temp); if (ret != 0) { dev_err(sma1303->dev, "failed to read SMA1303_FA_STATUS1 : %d\n", ret); @@ -1619,7 +1623,7 @@ static void sma1303_check_fault_worker(struct work_struct *work) return; } - ret = regmap_read(sma1303->regmap, SMA1303_FB_STATUS2, &ocp_val); + ret = sma1303_regmap_read(sma1303, SMA1303_FB_STATUS2, &ocp_val); if (ret != 0) { dev_err(sma1303->dev, "failed to read SMA1303_FB_STATUS2 : %d\n", ret); @@ -1627,7 +1631,7 @@ static void sma1303_check_fault_worker(struct work_struct *work) return; } - ret = regmap_read(sma1303->regmap, SMA1303_FF_DEVICE_INDEX, &uvlo_val); + ret = sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &uvlo_val); if (ret != 0) { dev_err(sma1303->dev, "failed to read SMA1303_FF_DEVICE_INDEX : %d\n", ret); @@ -1640,14 +1644,12 @@ static void sma1303_check_fault_worker(struct work_struct *work) "%s : OT1(Over Temperature Level 1)\n", __func__); if ((sma1303->cur_vol + 6) <= 0xFF) - sma1303_regmap_write( - sma1303->regmap, sma1303->dev, + sma1303_regmap_write(sma1303, SMA1303_0A_SPK_VOL, sma1303->cur_vol + 6); sma1303->tsdw_cnt++; } else if (sma1303->tsdw_cnt) { - sma1303_regmap_write( - sma1303->regmap, sma1303->dev, + sma1303_regmap_write(sma1303, SMA1303_0A_SPK_VOL, sma1303->init_vol); sma1303->tsdw_cnt = 0; sma1303->cur_vol = sma1303->init_vol; @@ -1761,12 +1763,11 @@ static int sma1303_probe(struct snd_soc_component *component) snd_soc_dapm_sync(dapm); - ret += sma1303_regmap_update_bits( - sma1303->regmap, component->dev, + ret += sma1303_regmap_update_bits(sma1303, SMA1303_00_SYSTEM_CTRL, RESETBYI2C_MASK, RESETBYI2C_RESET); - ret += regmap_read(sma1303->regmap, SMA1303_FF_DEVICE_INDEX, &status); + ret += sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &status); if (ret < 0) { dev_err(sma1303->dev, "failed to read, register: %02X, ret: %d\n", @@ -1779,7 +1780,7 @@ static int sma1303_probe(struct snd_soc_component *component) else if (sma1303->rev_num == REV_NUM_TV1) dev_info(component->dev, "SMA1303 Trimming Version 1\n"); - ret += regmap_read(sma1303->regmap, SMA1303_FB_STATUS2, &otp_stat); + ret += sma1303_regmap_read(sma1303, SMA1303_FB_STATUS2, &otp_stat); if (ret < 0) dev_err(sma1303->dev, "failed to read, register: %02X, ret: %d\n", @@ -1794,12 +1795,11 @@ static int sma1303_probe(struct snd_soc_component *component) dev_info(component->dev, "SMA1303 OTP Status Fail\n"); for (i = 0; i < (unsigned int)ARRAY_SIZE(sma1303_reg_def); i++) - ret += sma1303_regmap_write( - sma1303->regmap, component->dev, + ret += sma1303_regmap_write(sma1303, sma1303_reg_def[i].reg, sma1303_reg_def[i].def); - ret += sma1303_regmap_write(sma1303->regmap, component->dev, + ret += sma1303_regmap_write(sma1303, SMA1303_0A_SPK_VOL, sma1303->init_vol); dev_info(component->dev, @@ -1949,6 +1949,21 @@ static int sma1303_i2c_probe(struct i2c_client *client, } if (np) { + if (!of_property_read_u32(np, "i2c-retry", &value)) { + if (value > 50 || value < 0) { + sma1303->retry_cnt = SMA1303_I2C_RETRY_COUNT; + dev_info(&client->dev, "%s : %s\n", __func__, + "i2c-retry out of range (up to 50)"); + } else { + sma1303->retry_cnt = value; + dev_info(&client->dev, "%s : %s = %d\n", + __func__, "i2c-retry count", value); + } + } else { + dev_info(&client->dev, "%s : %s = %d\n", __func__, + "i2c-retry count", SMA1303_I2C_RETRY_COUNT); + sma1303->retry_cnt = SMA1303_I2C_RETRY_COUNT; + } if (!of_property_read_u32(np, "tdm-slot-rx", &value)) { dev_info(&client->dev, "tdm slot rx is '%d' from DT\n", value); @@ -1995,8 +2010,8 @@ static int sma1303_i2c_probe(struct i2c_client *client, return -ENODEV; } - ret = regmap_read(sma1303->regmap, - SMA1303_FF_DEVICE_INDEX, &device_info); + ret = sma1303_regmap_read(sma1303, + SMA1303_FF_DEVICE_INDEX, &device_info); if ((ret != 0) || ((device_info & 0xF8) != DEVICE_ID)) { dev_err(&client->dev, "device initialization error (%d 0x%02X)", diff --git a/sound/soc/codecs/sma1303.h b/sound/soc/codecs/sma1303.h index d1fa2acaba85..186af18188e9 100644 --- a/sound/soc/codecs/sma1303.h +++ b/sound/soc/codecs/sma1303.h @@ -11,6 +11,13 @@ #ifndef _SMA1303_H #define _SMA1303_H +typedef void (*callback_fptr) (void *device, int err); +struct callback_ops { + callback_fptr set_i2c_err; +}; + +void sma1303_set_callback_func(struct callback_ops ops); + #define SMA1303_I2C_ADDR_00 0x1e #define SMA1303_I2C_ADDR_01 0x3e #define SMA1303_I2C_ADDR_10 0x5e @@ -26,6 +33,8 @@ #define LEFT_TWO_CHIP_SOLUTION 0x02 #define RIGHT_TWO_CHIP_SOLUTION 0x03 +#define SMA1303_I2C_RETRY_COUNT 3 + /* * SMA1303 Register Definition */ From patchwork Fri Jan 6 09:15:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 640109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 299F0C54E76 for ; Fri, 6 Jan 2023 09:17:33 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AE3A1F38C; Fri, 6 Jan 2023 10:16:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AE3A1F38C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996650; bh=Uixe9OdB48jor3pV5yP4khlJ1UERWXyO5SWOsYMnLZE=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=N+Z3SBAUPwJMqjeZ1abhny49chObD19EuSPFyYlBRZXiQoWzwjAz1A3W66MSKxVD4 2iYrZYI0zprZASTHSkw7MK8L/KWuh4T5cBBAyUTHFQuOb53o56rgzJ7yleii3x1Sa5 sbY5bT5fV/vg0xOV/TLieLjSah7m+xR5jHmrqQn8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B9D5AF80543; Fri, 6 Jan 2023 10:16:08 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6F88FF80520; Fri, 6 Jan 2023 10:16:07 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2059.outbound.protection.outlook.com [40.107.129.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6FC5AF80238 for ; Fri, 6 Jan 2023 10:16:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6FC5AF80238 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IUI3oT3vunw/Ob2nKjSQk1nt7bxdIKI/IAjDw0PWpghlqR1g0cJnIp20Xs5SeL3/99HOA6IS1x3fE2YAw/Uuiza/ra+qhwVNYDVexjZ+UN6TVcUwC/+BruNa6/7sz5oMQ0TMKZCeNcdHeqICrfAohw/mqxUFFvRX2NxNDfoXREq2IWg8ArKKGhb6VOYhesBVLw1eH/oIdp1PECtvNMC85dF5SacigSa6DisLo3v1Ak8brUeYthfFUJkB347NhrzPl6OgwFL5lcgiqo0HC6+osNXGCCjPLqPPeMsxYiPLFNiBaoYw3bzqLwp9/hiWbUG4yRRkvOCy50F9Zr9Y20fJRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A2ktlz7U4or0UFT99RBslw1vl1GOrk3t25gcHIXATMM=; b=bShh81Zw/rL6Cau6bqd1MB/XD7BJP1s530pdueYJ5NHwsPYU5t+yC9GdyAx9RpBaX5TFQka1DcDes411C4pQstPw/9F5wLZ7IyblxRTCZu0stqt7ZPSNfZn4uv+H/fHRyKangIABqEWGb8BazIEUIjE/n9lXRfSm04thMHPMNORuAppLWay7KFP5w3Y96HFdxEZ/86wjm681N2Ju6HK7jm/4icAq4kXKRsC3fEvku2ep7URK5ZVMWCfbc/oaiexkHCQXrCbQ9pJgeGyq/ujh8GixHhio/mzx7n0OR5Q7nhYASTzZWd7ls3FbenY/MlBslSAMi5C4r5vnRlSztFRNjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:57 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:57 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 04/14] Removed the usage control and add the power switch on DAPM route. Date: Fri, 6 Jan 2023 18:15:33 +0900 Message-Id: <20230106091543.2440-5-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: d4276e91-9c9f-451d-cdd5-08daefc69e66 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UB9a/qMCtEXKIr2Jm2aNE5ksJ3AI1St+PpwrTCgBqhSl0XarINbZbFmc6Cb1H2jgfHH3nJPTGPPsybHa0jCejSvdMyIOs0gzwnSzDojK1rbMXww7G9cic0z5MqPRReq2LDVPAv1HhEUO42d1l1p+GRB6H15o5uDcU+khuypw217DkQgO8EkSmU9WTZmyzGnkiiBvpK0zfET4+A9HU3eJNuRt31WPvyUFtJCwYc4kYayXsCxMMEIsWFTM2vQB0Obc/xlrMzyDdKWhixQH/xGZdyAzb+Ol4IM3xbseOi3zlOxZejRby9UmCBkuLdjXlNaAfZH/13k/Ut+vGwVzx+SqPTEDsLpg7grqZ+pTcjlBPDf4Xgs47/n/YJmU2Q+Cqq5hkAbCcOWPfAWCUVfZYYK+wz8T2jRmsKTgvO9G9Q5c8ts/jLjawrYPRgN3kMZjlhyBuKOtSRqISZBXplAYVt7l0POojyDofTIJsbSCIIt7THtv3ytOoEarJD3iqY7fQYCIZoEcLRjXPISl88a4nJ6l+4izhZNV4x+evkTLaUTMjlYLXtmpvjHsdpjqI1aEbnL9lRgA/7hwidCFvzH0ji8k7wnQAFpOJRiwSTqxYoPjPT03eQzuCMTEeFTgN98rTXz/z6/sudwKBLieLcgaEkGw9t9zfRGVnRYMgmWeQgyaQ8vUhRAf1QyOHW/8CwSMj9d3 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aiYbnOKx3NF1P1hmu1WjMlFwsABp0tEXAorfaU11wkXE4o+8gWlFzqJn/XtYAnIBg4MezhxKcdpwuru0fcs88I+ajbGW6zI0RmDUwegI2cNvb6+ox6N+YXZc4mGOCR+hv92lCyjJLPOj7bVHiwqzPq4GEO5F2gBOLG+Vbe8WT7MJFvmvD8E1Lx+XGH/CNVLQX/5Ub9VySntb4cTdwQUx7V20E33hywc1NYBXp7ccR7KrrmKu70t22Y15MKz1iDm1Bea5X7MioCJxAP8jUPuUB1Ij8gO6qj2I/2UuKsCXVMiCHq0TeyTxHLGfj2a5x1jKA56/+St6+1GZtoxXeReHtKe3bObLz4YhmIpsYEwdOR324g6xp+2Z9ejsHvs5nOGz5E33noBBPWvwMqnpFxnSyst0EYERdHcQedW+z9mOwXfB1lTc3U9hqHABaYKtSV0XdD5Rvv8Fh3XulB+/5zEquupMgip+vvTd5i8AMx8qyo1gYWkNvtHx0WF0HxdFbklRecJpXvl67URKlzOtOlrTDAgr0hnv6ZOarCj5ngRTTabJnQLI2x6trKP2G6IJ5DxtPp+hhBUdnrvAwE8tQxB+fk34ilGKv68fOqozSzO7jTZ9rGV3H19QS7RJnKxGl1LklRJ5L1MPItYGCyuFHR/cS9vSJ8Oyw0EQA5UTJ34a7LTwhzRPp1mLgNVp6pGcUub+gAJCeYe52E4bIie/6gZ6iubYfSJD09yUVNbxsC5lzp0MI2v2mhV25mmhWmPOYjlH6hDTs4hyFOWXfX2vqjC2mP+csXheBsPsAthqKnj6zUBMBXLgHnPnmqYb+kJIpQJzF0CITdiIj9lQ6qBuZ6D+iOKQSczDaeBVb6hoE2oopThOY+OHOil3iWg3xXr2aHhjcNINfze2jpLTrhg8xUsbLSCrKiNtx7wZfu7fH1+0Cyww+kTnn/pm/pNqYE1PuyK/1H/EJvPmcdCVATr0Tp062DUjby6yWbm9s0/BmxUgNXiFmzmmYGeL9x/ub6CsXqSE+Ic1xddnvJbn87Rg6ap0nXTa7r8ZPwiSTn5KMptJtMPB5zNx7D7BA9Y+MbIguiSl1gnHGpiUoyt/X9+AVjZF9Fgs1kGLGpI9OcxHSHH1ZRZU1iLVnvt7zA2JV32kBB8bqKY+XIMdEbwMkPPYAf3UeRfdfPeblRhVF2XwOs+T2pYbaiEW4KYFxl2c1yaLLtPfOec2/4ajsOunPsWDSuwqGoakQgjggXpgIXh3sIuEW4K8YAioPLIlCP7PutU5mGoyx3pNOJeV28N+4fe6afV0hGfOHqgfzUUIDnB8QYkBBZ6rNsgOPsBvV4HFWPEMZtjbYWGnukk02EaFztrN4ukyugySJ2kY9lhwNYCurMwZrq2QhZ2+GMDf2lhmCIfR1UXXnFxGza360QiFGufGQCwuR9rPYJn3eeiR6fsZ6vQPrJNXQf+F9y7nrZqZNupZ4ao4q9dfn8djvIUU/i0jQlCpqrIyBWrjvtjqb1Kl3kIhTtuzBzipXs8pWY0SvAHahWe/iikgTVlX0AQWUVJsOvZLOE0NwdB7R6YAsnQEb20B8R5Gl3HYcMJZrez2i71VvcRj X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4276e91-9c9f-451d-cdd5-08daefc69e66 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:56.9728 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WtU67FK9xMOtgUW3XfQ9ChdALygNgwFLqwucIadEecEIztRA6p2uRwAwtti4OCexpFh4BgsXrOQ6D7QyshCpi3naahoLfrnPZaWtMMSwuVY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Kiseok Jo Reported-by: Mark Brown --- sound/soc/codecs/sma1303.c | 79 ++++---------------------------------- 1 file changed, 8 insertions(+), 71 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 8bd59a481f2d..f78cd2daad61 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -69,7 +69,6 @@ struct sma1303_priv { struct mutex lock; struct delayed_work check_fault_work; bool amp_power_status; - bool usage_status; int num_of_pll_matches; int retry_cnt; unsigned int sys_clk_id; @@ -375,66 +374,6 @@ static int bytes_ext_put(struct snd_kcontrol *kcontrol, return 0; } -static int amp_usage_status_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } - ucontrol->value.integer.value[0] = sma1303->usage_status; - - if (sma1303->usage_status) - dev_info(component->dev, "Amplifier Power Control Enabled\n"); - else - dev_info(component->dev, "Amplifier Power Control Disabled\n"); - - return 0; -} - -static int amp_usage_status_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } - - if ((sma1303->usage_status - != ucontrol->value.integer.value[0]) - && (!ucontrol->value.integer.value[0])) { - dev_info(component->dev, "%s\n", "Force AMP Power Down"); - ret = sma1303_shutdown(component); - if (ret < 0) { - ucontrol->value.integer.value[0] - = sma1303->usage_status; - return ret; - } - - } - sma1303->usage_status = ucontrol->value.integer.value[0]; - - return 0; -} - static const char * const sma1303_amp_mode_text[] = { "1 Chip", "Mono on 2 chips", "Left in 2 chips", "Right in 2chips"}; @@ -928,10 +867,10 @@ static SOC_VALUE_ENUM_SINGLE_DECL(sma1303_sdo_source_enum, sma1303_sdo_source_values); static const struct snd_kcontrol_new sma1303_sdo_source_mux = SOC_DAPM_ENUM("SDO Source", sma1303_sdo_source_enum); +static const struct snd_kcontrol_new sma1303_enable_control = + SOC_DAPM_SINGLE_VIRT("Switch", 1); static const struct snd_kcontrol_new sma1303_snd_controls[] = { -SOC_SINGLE_EXT("Amplifier Usage", SND_SOC_NOPM, 0, 1, 0, - amp_usage_status_get, amp_usage_status_put), SOC_ENUM_EXT("Amplifier Mode", sma1303_amp_mode_enum, sma1303_amp_mode_get, sma1303_amp_mode_put), SOC_ENUM_EXT("Outport config", sma1303_outport_config_enum, @@ -1048,14 +987,12 @@ static int sma1303_dac_event(struct snd_soc_dapm_widget *w, { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: dev_info(component->dev, "%s : PRE_PMU\n", __func__); - if (sma1303->usage_status) - sma1303_startup(component); + sma1303_startup(component); break; @@ -1130,11 +1067,13 @@ SND_SOC_DAPM_ADC_E("DAC_FEEDBACK", "Capture", SND_SOC_NOPM, 0, 0, SND_SOC_DAPM_OUTPUT("SPK"), SND_SOC_DAPM_INPUT("SDO"), SND_SOC_DAPM_MUX("SDO Source", SND_SOC_NOPM, 0, 0, &sma1303_sdo_source_mux), +SND_SOC_DAPM_SWITCH("AMP Enable", SND_SOC_NOPM, 0, 1, &sma1303_enable_control), }; static const struct snd_soc_dapm_route sma1303_audio_map[] = { {"DAC", NULL, "CLK_SUPPLY"}, -{"SPK", NULL, "DAC"}, +{"AMP Enable", "Switch", "DAC"}, +{"SPK", NULL, "AMP Enable"}, {"SDO Source", "Disable", "SDO"}, {"SDO Source", "Format_C", "SDO"}, {"SDO Source", "Mixer_Out", "SDO"}, @@ -1214,9 +1153,8 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (sma1303->usage_status && - (sma1303->sys_clk_id == SMA1303_PLL_CLKIN_MCLK - || sma1303->sys_clk_id == SMA1303_PLL_CLKIN_BCLK)) { + if (sma1303->sys_clk_id == SMA1303_PLL_CLKIN_MCLK + || sma1303->sys_clk_id == SMA1303_PLL_CLKIN_BCLK) { if (sma1303->last_bclk != bclk) { if (sma1303->amp_power_status) { @@ -2039,7 +1977,6 @@ static int sma1303_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, sma1303); sma1303->amp_mode = ONE_CHIP_SOLUTION; - sma1303->usage_status = true; sma1303->amp_power_status = false; sma1303->check_fault_status = true; sma1303->pll_matches = sma1303_pll_matches; From patchwork Fri Jan 6 09:15:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 640108 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3760C3DA7A for ; Fri, 6 Jan 2023 09:18:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CA22BA2A6; Fri, 6 Jan 2023 10:17:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CA22BA2A6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996696; bh=QHZxwF0mVVrUqe4TokdvDgehbwetzR51FC52Y6/w5BI=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=kcjvlvXBTTOTyYhqf0kVR2gMP+yigy67lHarstNhBO3/RHIhx2ySDmLHGh+2/GuE4 ywCMYuFHoY7wv6PHg/rvsb8jo/TQSU6VM6KaW+EcOGcd3xG+UXUrdRtFrnUDkodVFs EpnK08KTriJK60iI+d2UyEdfDa3eGjDVvEvXGVIU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3241CF80579; Fri, 6 Jan 2023 10:16:12 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 07646F8055C; Fri, 6 Jan 2023 10:16:10 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2059.outbound.protection.outlook.com [40.107.129.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3404FF80549 for ; Fri, 6 Jan 2023 10:16:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3404FF80549 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jgbsB5R4YHFOMF3mzebu/1gzLwxXNo/PQFdkbXMx6PCWlOdX7ltBVpQNzauEmq3qoLr5j9hLi7Tx6aMF3fMJqZx2uLEg46qrrnWLWYL/BkWGNVcAj851DuU1TBVdIRoUj9NxeA2pfKwIMY8YesKYLNzKDMRy6hD0Gh7OVSqv1xp272w8BghLDA6jShf4y3hHcYLRHfU0hKKz2WUpw8pR1xBaQ5hyrrpYerNkNdbImJ/eIXExqrC3yCgeosWSmGxWLIhD0JW0wPJFgVztRfE0rCBm7BEH54JfFaWB0tabwQPc/+Wj5c/4YubWv1m9GFWo5rpkGl0FKl2Q57Iam99c8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Va+v5mkjsJfDKO23AXIsMwUF9gsFy3rLjlNX4KjDg9A=; b=S5xAR4uNe/lUfKfXNpdvgWMzoFeekzuMiGWqVdQGmKbQi9zre8vHlbbXj4TX6VC1DKR9jICzqhhzHkfoHi8fKxy8DP1xdNgMekyD6mA1ryNxdPl0JfvT+At6Q07RNanjmPaQ29dKaX6maBh62N6IlMWFuv6w3Jq8+3e3TC4WuIZD3nWHhVTaaPELeeVLeFByTdzzS0vGTncoAjmDZNJoDVmzcEteHHNzfRUf6Y78lgOSRqj54gO6jA9IbM92AJLFT4oz68DpwL7uXCa0z3srvwtBoCjRHAJapG72X8WF81HGhFYIAQRy2m/rjSfcTzasbN19oq91HsgoUne6E9bolA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:57 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:57 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 05/14] Change the DAPM route and widgets Date: Fri, 6 Jan 2023 18:15:34 +0900 Message-Id: <20230106091543.2440-6-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 13009c5b-0301-45c0-531b-08daefc69eae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wrj8gONE5uz8o+Yo0Af3Po/erDrXimAtauz7hSdiYya9zWLHyW3GhgJT1g7o3SSbhsACreTBwp8ZZsKlw/SKxy/k8qd2WkAckhcHtDdrFJSOv/pKZjIno4ryVe96xuZnOg4iXOnKSdDuaIBK+IPIUQHIJ6RheNPIDZrv+wpo084BSfpXxr+IR37XHf7NqjB/KrYgaOCSRewCKpu+gCG8fp2xUYKq1cvJa2kAPRtb3//qanmboxEa18vbvyxdrIC42hbxJxFC8LJ1D96EvHvKoIaASr9apHOhyQwQpE3SpqwgYOC53ZBsVK2Qa6kNDUtw4y3Wul3x7COzAShUDKVCuxG3RkmJItIs6TlwW9Qh+odgYwRoCViIQ37M27mXu5lgGfklir2ifzSQtma3r0h5DXICCq8Dc+GbhsH32PEOcSqKjIdD77DRm0C9xC5oCUHma5ITpMM79N3h4UFMX+9Wowssu1MgNhRvlmKUYHj37ZMvAkXnxkU6NGGZrBcS2a1VEAwHtU7ueszYJyDJD6WPvJElFkBzEsCmW2v2l8FlCIn7TD9M7uWkYI8wYXtRtyw62/IAWtZm2qZg8ht3dPq9qn1bYZ7htvVMWYZcMDYtkEpK/gjgcihqpYATom2cDmX9+OhiQx/KER4wYcQSugpvIOS8P7jB3qIf3qm6tpXVaagRR8igQmCTR3Qn/nBfXenYw4bxiM8FPKkqal55o1ZmtQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(30864003)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iqLNZzaCkv+Oyp6TxdTPnMUxWqksWTDSOvpew8xS9wmaKOik9PZ85mdn+HvwnW4HSQzHu1BwJ3rSdpjDBrkUGPeSIjo88I/xkc3J0s36DCQKe88oHN1deAUSs17WSTiMBC6RJlCwxhPux/OVGsgsW6tsBG0HSkqLESZPXVf0iCBR1MgdfQ/NKb3fxgoAz2vQqsTYBZkiJEYFyeFpeAXycwzYFRSXLcp3K1FRQ2Brx46pxGvxW5gR54Y/f0Nfj0UdN5j/L7xuW3TPNxj2DXNYqZwrtOLmvQnrBFyqIottZ0Zsof8ctLiau1EBPr7kpy3exhQ7RFS1+rmlc6ur38h9O8FEQa54sL/a1/RAmIo0gtbn3fAu+X0+pSV6o/EI0gtb+kzfZpkHDixOXpQVRMopr3jadJhentA4fD00hrwoMNnOiYWYZ2K0voSbVTe9niRJ7LLGibM+WxuB4zG4FBEmf5XUZuEQ6cj7F76y4r1iJyam2a2eYIalSMcqKlXf8GiXOhbLwhwShfq4HNeABgnEOLYyZg+6ShLZfHUfqnm/5Zn41feoxIp1jcTvaTM+F4GHDIVlJ2+xq53+nJXvdx0w1iRMy6z/OvHkw5HgwHilPI8WHPJ28v6bd3y1pVZ1DnbRR1KpXVt254FrSsd9ZK98VOz93oKUcpjGZagfmYosmVnwdigiM/dMT6V4PQynQhExb4zqw7iHq3smIWJcll4RSG/hoDUrNq5gugSM5t5f+FyGJ9wCzSbv1ibXnrqBx4ZpIT+EjIGZS8NuoX/0iSpTTj7Ev9enr5t8efsuFnZF+gyQYZvqkA+vKQ0oykuY6DeM/zeM8280b1LfUG7KIaIgo8+13tz7mjTEtyOcJ6q1GxBhFjYHplxm96XcRLkMvI2ryWc4974B2imjhUTLu0UA8iMx1g2LpEd61qRau5Is1SLChO6Le0CGj4sHCJdKLHWw8eFtMNUGdUL+Pz5cWSFHHBMLhSHi09zklKEhHTb7fkswOrdhk8BwPQgjbvy2lDOY1VLl3sd26e6AKBkCkjlw60jztM3sqFEk9cC+lDMGKnJbZX0iTrS+Kuv3e9n/1R/7ckXZYKeFdGYLeBomdjYs2bk3+KKCUr1hMn1MA77n/LSTGKTo4A5/dYA+dwb57cEMwIkb3vmTbb6uRKs3GBDNxlMzyUrGhutixifpTs3GAqpaBTXIlBtYlPDTtNE07ACgb8ankMdUCURtrs1f+67YqzN4SWGd+oMWMLvmF2Su7BO8pEpygGdIFZ29AUABB6drqVZSeh+8wBDm8zhjTqltuXgS4GNiHRAwiUQOlT9mH1dqBFjMkpKhtMgGJHiyBRuUIcvgx3afIXc3fV0JscSrzINxoVhf0NnQa+ed+aByNqwj3pkKxMfnTuBYZ5rV7DLbZ4+rG9ghaNhjcqPp02liOm3yv5EvptRcTdd33G++zvc5O/FM506XqMwIfTrKWtZXGDVRh3AjVO+HMJVQCC0Al9JebD2VJi4koHzcIG2/Yj0Hb+3Agr1++vqxrIgfBHNx3G+piwQZWdnYjYZtlakfGJnCTjaoaX7E4zM+SVAkRaJTsKLEFtoe+hkT1FjO3W2O X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13009c5b-0301-45c0-531b-08daefc69eae X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:57.5196 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MMgz430QBkBF/D48cHKXVp0hSJpWJc81e/FJmIwn5zDqkjyQ0I/pruEd+XrApdaA6iJxYv1zghOCeyr2Ly5nAsANJoQ01Ps0qbnKCilRMOc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Remove the control of 'amp_mode', and add the 'AIF IN' in DAPM. Remove the outport and add SDO Enable event in DAPM. In DAPM, instead of DAC and ADC, AIF IN & OUT were used, and AMP power control was added. Signed-off-by: Kiseok Jo Reported-by: Mark Brown --- sound/soc/codecs/sma1303.c | 644 ++++++++++++++----------------------- sound/soc/codecs/sma1303.h | 8 +- 2 files changed, 253 insertions(+), 399 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index f78cd2daad61..1ef0b145f5ba 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -374,190 +374,6 @@ static int bytes_ext_put(struct snd_kcontrol *kcontrol, return 0; } -static const char * const sma1303_amp_mode_text[] = { - "1 Chip", "Mono on 2 chips", "Left in 2 chips", "Right in 2chips"}; - -static const struct soc_enum sma1303_amp_mode_enum = - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_amp_mode_text), - sma1303_amp_mode_text); -static int sma1303_amp_mode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } - ucontrol->value.integer.value[0] = sma1303->amp_mode; - - switch (sma1303->amp_mode) { - case ONE_CHIP_SOLUTION: - dev_info(component->dev, "Amplifier 1 Chip Solution\n"); - break; - case MONO_TWO_CHIP_SOLUTION: - dev_info(component->dev, "Amplifier Mono 2 Chips Solution\n"); - break; - case LEFT_TWO_CHIP_SOLUTION: - dev_info(component->dev, "Amplifier Stereo(Left) 2 Chips Solution\n"); - break; - case RIGHT_TWO_CHIP_SOLUTION: - dev_info(component->dev, "Amplifier Stereo(Right) 2 Chips Solution\n"); - break; - default: - dev_err(component->dev, "Invalid Value"); - return ret; - } - return 0; - -} - -static int sma1303_amp_mode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int ret = 0; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return -1; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return -1; - } - - sma1303->amp_mode = ucontrol->value.integer.value[0]; - - switch (sma1303->amp_mode) { - case ONE_CHIP_SOLUTION: - case MONO_TWO_CHIP_SOLUTION: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_11_SYSTEM_CTRL2, - MONOMIX_MASK, MONOMIX_ON); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_11_SYSTEM_CTRL2, - LR_DATA_SW_MASK, LR_DATA_SW_NORMAL); - break; - case LEFT_TWO_CHIP_SOLUTION: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_11_SYSTEM_CTRL2, - MONOMIX_MASK, MONOMIX_OFF); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_11_SYSTEM_CTRL2, - LR_DATA_SW_MASK, LR_DATA_SW_NORMAL); - break; - case RIGHT_TWO_CHIP_SOLUTION: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_11_SYSTEM_CTRL2, - MONOMIX_MASK, MONOMIX_OFF); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_11_SYSTEM_CTRL2, - LR_DATA_SW_MASK, LR_DATA_SW_SWAP); - break; - default: - dev_err(component->dev, "Invalid Value"); - ret += -1; - } - - return ret; -} - -static const char * const sma1303_outport_config_text[] = { - "Enable", "Disable"}; - -static const struct soc_enum sma1303_outport_config_enum = - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_outport_config_text), - sma1303_outport_config_text); - -static int sma1303_outport_config_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int ret = -1, data, val; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } - - ret = sma1303_regmap_read(sma1303, SMA1303_09_OUTPUT_CTRL, &data); - if (ret < 0) { - dev_err(component->dev, - "Failed to read, register: %x ret: %d\n", - SMA1303_09_OUTPUT_CTRL, ret); - return ret; - } - - val = data & PORT_CONFIG_MASK; - switch (val) { - case INPUT_PORT_ONLY: - ucontrol->value.integer.value[0] = 1; - break; - case OUTPUT_PORT_ENABLE: - ucontrol->value.integer.value[0] = 0; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x value: %d\n", - SMA1303_09_OUTPUT_CTRL, val); - return ret; - } - - return 0; -} - -static int sma1303_outport_config_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int sel = (int)ucontrol->value.integer.value[0]; - int val, ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } - - switch (sel) { - case 0: - val = OUTPUT_PORT_ENABLE; - break; - case 1: - val = INPUT_PORT_ONLY; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x\n", - SMA1303_09_OUTPUT_CTRL); - return ret; - } - - return sma1303_regmap_update_bits(sma1303, - SMA1303_09_OUTPUT_CTRL, PORT_CONFIG_MASK, val); -} - static const char * const sma1303_spkmute_text[] = { "Unmute", "Mute"}; @@ -566,111 +382,6 @@ static const struct soc_enum sma1303_spkmute_enum = ARRAY_SIZE(sma1303_spkmute_text), sma1303_spkmute_text); -static const char * const sma1303_spkmode_text[] = { - "Off", "On"}; - -static const struct soc_enum sma1303_spkmode_enum = - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_spkmode_text), - sma1303_spkmode_text); - -static int sma1303_spkmode_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int val, data, ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } - - ret = sma1303_regmap_read(sma1303, SMA1303_10_SYSTEM_CTRL1, &data); - if (ret < 0) { - dev_err(component->dev, - "Failed to read, register: %x ret: %d\n", - SMA1303_10_SYSTEM_CTRL1, ret); - return ret; - } - - val = data & SPK_MODE_MASK; - if (sma1303->amp_mode == ONE_CHIP_SOLUTION) { - switch (val) { - case SPK_OFF: - ucontrol->value.integer.value[0] = 0; - break; - case SPK_MONO: - ucontrol->value.integer.value[0] = 1; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x\n", - SMA1303_10_SYSTEM_CTRL1); - return ret; - } - } else { - switch (val) { - case SPK_OFF: - ucontrol->value.integer.value[0] = 0; - break; - case SPK_STEREO: - ucontrol->value.integer.value[0] = 1; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x\n", - SMA1303_10_SYSTEM_CTRL1); - return ret; - } - } - - return 0; -} - -static int sma1303_spkmode_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int sel = (int)ucontrol->value.integer.value[0]; - int val, ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } - - switch (sel) { - case 0: - val = SPK_OFF; - break; - case 1: - if (sma1303->amp_mode == ONE_CHIP_SOLUTION) - val = SPK_MONO; - else - val = SPK_STEREO; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x\n", - SMA1303_10_SYSTEM_CTRL1); - return ret; - } - - return sma1303_regmap_update_bits(sma1303, - SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, val); -} - static int postscaler_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -852,41 +563,18 @@ static int sma1303_o_format_put(struct snd_kcontrol *kcontrol, SMA1303_A4_TOP_MAN3, O_FORMAT_MASK, val); } -static const char * const sma1303_sdo_source_texts[] = { - "Disable", "Format_C", "Mixer_Out", "After_DSP", "After_Post"}; -static const unsigned int sma1303_sdo_source_values[] = { - OUT_SEL_DISABLE, - FORMAT_CONVERTER, - MIXER_OUTPUT, - SPEAKER_PATH, - POSTSCALER_OUTPUT}; -static SOC_VALUE_ENUM_SINGLE_DECL(sma1303_sdo_source_enum, - SMA1303_09_OUTPUT_CTRL, - 0, PORT_OUT_SEL_MASK, - sma1303_sdo_source_texts, - sma1303_sdo_source_values); -static const struct snd_kcontrol_new sma1303_sdo_source_mux = - SOC_DAPM_ENUM("SDO Source", sma1303_sdo_source_enum); -static const struct snd_kcontrol_new sma1303_enable_control = - SOC_DAPM_SINGLE_VIRT("Switch", 1); +static const char * const sma1303_aif_in_source_text[] = { + "Mono", "Left", "Right"}; +static const char * const sma1303_aif_out_source_text[] = { + "Disable", "After_FmtC", "After_Mixer", "After_DSP", "After_Post", + "Clk_PLL", "Clk_OSC"}; -static const struct snd_kcontrol_new sma1303_snd_controls[] = { -SOC_ENUM_EXT("Amplifier Mode", sma1303_amp_mode_enum, - sma1303_amp_mode_get, sma1303_amp_mode_put), -SOC_ENUM_EXT("Outport config", sma1303_outport_config_enum, - sma1303_outport_config_get, sma1303_outport_config_put), -SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL, - 0, 167, 1, sma1303_spk_tlv), -SOC_ENUM("Speaker Mute Switch", sma1303_spkmute_enum), -SOC_ENUM_EXT("Speaker Output", sma1303_spkmode_enum, - sma1303_spkmode_get, sma1303_spkmode_put), -SND_SOC_BYTES_EXT("Postscaler Set", 1, - postscaler_get, postscaler_put), -SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum, - sma1303_postscaler_config_get, sma1303_postscaler_config_put), -SOC_ENUM_EXT("Output Format", sma1303_o_format_enum, - sma1303_o_format_get, sma1303_o_format_put), -}; +static const struct soc_enum sma1303_aif_in_source_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_aif_in_source_text), + sma1303_aif_in_source_text); +static const struct soc_enum sma1303_aif_out_source_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_aif_out_source_text), + sma1303_aif_out_source_text); static int sma1303_startup(struct snd_soc_component *component) { @@ -905,7 +593,7 @@ static int sma1303_startup(struct snd_soc_component *component) ret += sma1303_regmap_update_bits(sma1303, SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_ON); - if (sma1303->amp_mode == ONE_CHIP_SOLUTION) + if (sma1303->amp_mode == SMA1303_MONO) ret += sma1303_regmap_update_bits(sma1303, SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_MONO); else @@ -963,62 +651,157 @@ static int sma1303_shutdown(struct snd_soc_component *component) return ret; } -static int sma1303_clk_supply_event(struct snd_soc_dapm_widget *w, +static int sma1303_aif_in_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = - snd_soc_dapm_to_component(w->dapm); + snd_soc_dapm_to_component(w->dapm); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + int ret = 0; switch (event) { case SND_SOC_DAPM_PRE_PMU: - dev_info(component->dev, "%s : PRE_PMU\n", __func__); - break; + switch (mux) { + case 0: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_11_SYSTEM_CTRL2, + MONOMIX_MASK, + MONOMIX_ON); + ret += sma1303->amp_mode = SMA1303_MONO; + break; + case 1: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_11_SYSTEM_CTRL2, + MONOMIX_MASK, + MONOMIX_OFF); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_11_SYSTEM_CTRL2, + LR_DATA_SW_MASK, + LR_DATA_SW_NORMAL); + ret += sma1303->amp_mode = SMA1303_STEREO; + break; + case 2: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_11_SYSTEM_CTRL2, + MONOMIX_MASK, + MONOMIX_OFF); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_11_SYSTEM_CTRL2, + LR_DATA_SW_MASK, + LR_DATA_SW_NORMAL); + sma1303->amp_mode = SMA1303_STEREO; + break; + default: + dev_err(sma1303->dev, "%s : Invald value (%d)\n", + __func__, mux); + return -EINVAL; + } - case SND_SOC_DAPM_POST_PMD: - dev_info(component->dev, "%s : POST_PMD\n", __func__); - break; + dev_info(sma1303->dev, "%s : Source : %s\n", __func__, + sma1303_aif_in_source_text[mux]); + break; } - - return 0; + return ret; } -static int sma1303_dac_event(struct snd_soc_dapm_widget *w, +static int sma1303_aif_out_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = - snd_soc_dapm_to_component(w->dapm); + snd_soc_dapm_to_component(w->dapm); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); + int ret = 0; switch (event) { case SND_SOC_DAPM_PRE_PMU: - dev_info(component->dev, "%s : PRE_PMU\n", __func__); - - sma1303_startup(component); - - break; - - case SND_SOC_DAPM_POST_PMU: - dev_info(component->dev, "%s : POST_PMU\n", __func__); - - break; - - case SND_SOC_DAPM_PRE_PMD: - dev_info(component->dev, "%s : PRE_PMD\n", __func__); - - sma1303_shutdown(component); - - break; - - case SND_SOC_DAPM_POST_PMD: - dev_info(component->dev, "%s : POST_PMD\n", __func__); + switch (mux) { + case 0: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + TEST_CLKO_EN_MASK, + NORMAL_SDO); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_09_OUTPUT_CTRL, + PORT_OUT_SEL_MASK, + OUT_SEL_DISABLE); + break; + case 1: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + TEST_CLKO_EN_MASK, + NORMAL_SDO); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_09_OUTPUT_CTRL, + PORT_OUT_SEL_MASK, + FORMAT_CONVERTER); + break; + case 2: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + TEST_CLKO_EN_MASK, + NORMAL_SDO); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_09_OUTPUT_CTRL, + PORT_OUT_SEL_MASK, + MIXER_OUTPUT); + break; + case 3: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + TEST_CLKO_EN_MASK, + NORMAL_SDO); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_09_OUTPUT_CTRL, + PORT_OUT_SEL_MASK, + SPEAKER_PATH); + break; + case 4: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + TEST_CLKO_EN_MASK, + NORMAL_SDO); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_09_OUTPUT_CTRL, + PORT_OUT_SEL_MASK, + POSTSCALER_OUTPUT); + break; + case 5: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + TEST_CLKO_EN_MASK, + CLK_OUT_SDO); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + MON_OSC_PLL_MASK, + PLL_SDO); + break; + case 6: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + TEST_CLKO_EN_MASK, + CLK_OUT_SDO); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A3_TOP_MAN2, + MON_OSC_PLL_MASK, + PLL_OSC); + break; + default: + dev_err(sma1303->dev, "%s : Invald value (%d)\n", + __func__, mux); + return -EINVAL; + } + dev_info(sma1303->dev, "%s : Source : %s\n", __func__, + sma1303_aif_out_source_text[mux]); break; } - - return 0; + return ret; } -static int sma1303_dac_feedback_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) +static int sma1303_sdo_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); @@ -1027,59 +810,132 @@ static int sma1303_dac_feedback_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - dev_info(component->dev, - "%s : DAC feedback ON\n", __func__); + dev_info(sma1303->dev, + "%s : SND_SOC_DAPM_PRE_PMU\n", __func__); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_CONFIG_MASK|PORT_OUT_SEL_MASK, - OUTPUT_PORT_ENABLE|SPEAKER_PATH); - + PORT_CONFIG_MASK, + OUTPUT_PORT_ENABLE); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - SDO_OUTPUT_MASK, NORMAL_OUT); + SDO_OUTPUT_MASK, + NORMAL_OUT); break; - - case SND_SOC_DAPM_PRE_PMD: - dev_info(component->dev, - "%s : DAC feedback OFF\n", __func__); + case SND_SOC_DAPM_POST_PMD: + dev_info(sma1303->dev, + "%s : SND_SOC_DAPM_POST_PMD\n", __func__); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_OUT_SEL_MASK, OUT_SEL_DISABLE); - + PORT_CONFIG_MASK, + INPUT_PORT_ONLY); ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A3_TOP_MAN2, SDO_OUTPUT_MASK, + SMA1303_A3_TOP_MAN2, + SDO_OUTPUT_MASK, HIGH_Z_OUT); break; } + return ret; +} + +static int sma1303_power_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret = 0; + switch (event) { + case SND_SOC_DAPM_POST_PMU: + dev_info(sma1303->dev, + "%s : SND_SOC_DAPM_POST_PMU\n", __func__); + ret = sma1303_startup(component); + break; + case SND_SOC_DAPM_PRE_PMD: + dev_info(sma1303->dev, + "%s : SND_SOC_DAPM_PRE_PMD\n", __func__); + ret = sma1303_shutdown(component); + break; + } return ret; } +static const struct snd_kcontrol_new sma1303_aif_in_source_control = + SOC_DAPM_ENUM("AIF IN Source", sma1303_aif_in_source_enum); +static const struct snd_kcontrol_new sma1303_aif_out_source_control = + SOC_DAPM_ENUM("AIF OUT Source", sma1303_aif_out_source_enum); +static const struct snd_kcontrol_new sma1303_sdo_control = + SOC_DAPM_SINGLE_VIRT("Switch", 1); +static const struct snd_kcontrol_new sma1303_enable_control = + SOC_DAPM_SINGLE_VIRT("Switch", 1); + +static const struct snd_kcontrol_new sma1303_snd_controls[] = { +SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL, + 0, 167, 1, sma1303_spk_tlv), +SOC_ENUM("Speaker Mute Switch", sma1303_spkmute_enum), +SND_SOC_BYTES_EXT("Postscaler Set", 1, + postscaler_get, postscaler_put), +SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum, + sma1303_postscaler_config_get, sma1303_postscaler_config_put), +SOC_ENUM_EXT("Output Format", sma1303_o_format_enum, + sma1303_o_format_get, sma1303_o_format_put), +}; + static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = { -SND_SOC_DAPM_SUPPLY("CLK_SUPPLY", SND_SOC_NOPM, 0, 0, sma1303_clk_supply_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), -SND_SOC_DAPM_DAC_E("DAC", "Playback", SND_SOC_NOPM, 0, 0, sma1303_dac_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD), -SND_SOC_DAPM_ADC_E("DAC_FEEDBACK", "Capture", SND_SOC_NOPM, 0, 0, - sma1303_dac_feedback_event, - SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD), -SND_SOC_DAPM_OUTPUT("SPK"), -SND_SOC_DAPM_INPUT("SDO"), -SND_SOC_DAPM_MUX("SDO Source", SND_SOC_NOPM, 0, 0, &sma1303_sdo_source_mux), -SND_SOC_DAPM_SWITCH("AMP Enable", SND_SOC_NOPM, 0, 1, &sma1303_enable_control), + /* platform domain */ + SND_SOC_DAPM_OUTPUT("SPK"), + SND_SOC_DAPM_INPUT("SDO"), + + /* path domain */ + SND_SOC_DAPM_MUX_E("AIF IN Source", SND_SOC_NOPM, 0, 0, + &sma1303_aif_in_source_control, + sma1303_aif_in_event, + SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_MUX_E("AIF OUT Source", SND_SOC_NOPM, 0, 0, + &sma1303_aif_out_source_control, + sma1303_aif_out_event, + SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_SWITCH_E("SDO Enable", SND_SOC_NOPM, 0, 0, + &sma1303_sdo_control, + sma1303_sdo_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), + SND_SOC_DAPM_MIXER("Entry", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_OUT_DRV_E("AMP Power", SND_SOC_NOPM, 0, 0, NULL, 0, + sma1303_power_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + SND_SOC_DAPM_SWITCH("AMP Enable", SND_SOC_NOPM, 0, 1, + &sma1303_enable_control), + + /* stream domain */ + SND_SOC_DAPM_AIF_IN("AIF IN", "Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0), }; static const struct snd_soc_dapm_route sma1303_audio_map[] = { -{"DAC", NULL, "CLK_SUPPLY"}, -{"AMP Enable", "Switch", "DAC"}, -{"SPK", NULL, "AMP Enable"}, -{"SDO Source", "Disable", "SDO"}, -{"SDO Source", "Format_C", "SDO"}, -{"SDO Source", "Mixer_Out", "SDO"}, -{"SDO Source", "After_DSP", "SDO"}, -{"SDO Source", "After_Post", "SDO"}, -{"DAC_FEEDBACK", NULL, "SDO Source"}, + /* Playback */ + {"AIF IN Source", "Mono", "AIF IN"}, + {"AIF IN Source", "Left", "AIF IN"}, + {"AIF IN Source", "Right", "AIF IN"}, + + {"SDO Enable", "Switch", "AIF IN"}, + {"AIF OUT Source", "Disable", "SDO Enable"}, + {"AIF OUT Source", "After_FmtC", "SDO Enable"}, + {"AIF OUT Source", "After_Mixer", "SDO Enable"}, + {"AIF OUT Source", "After_DSP", "SDO Enable"}, + {"AIF OUT Source", "After_Post", "SDO Enable"}, + {"AIF OUT Source", "Clk_PLL", "SDO Enable"}, + {"AIF OUT Source", "Clk_OSC", "SDO Enable"}, + + {"Entry", NULL, "AIF OUT Source"}, + {"Entry", NULL, "AIF IN Source"}, + + {"AMP Power", NULL, "Entry"}, + + {"AMP Enable", "Switch", "AMP Power"}, + {"SPK", NULL, "AMP Enable"}, + + /* Capture */ + {"AIF OUT", NULL, "AMP Enable"}, }; static int sma1303_setup_pll(struct snd_soc_component *component, @@ -1976,7 +1832,7 @@ static int sma1303_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, sma1303); - sma1303->amp_mode = ONE_CHIP_SOLUTION; + sma1303->amp_mode = SMA1303_MONO; sma1303->amp_power_status = false; sma1303->check_fault_status = true; sma1303->pll_matches = sma1303_pll_matches; diff --git a/sound/soc/codecs/sma1303.h b/sound/soc/codecs/sma1303.h index 186af18188e9..95535546fd73 100644 --- a/sound/soc/codecs/sma1303.h +++ b/sound/soc/codecs/sma1303.h @@ -28,12 +28,10 @@ void sma1303_set_callback_func(struct callback_ops ops); #define SMA1303_PLL_CLKIN_MCLK 0x02 #define SMA1303_PLL_CLKIN_BCLK 0x03 -#define ONE_CHIP_SOLUTION 0x00 -#define MONO_TWO_CHIP_SOLUTION 0x01 -#define LEFT_TWO_CHIP_SOLUTION 0x02 -#define RIGHT_TWO_CHIP_SOLUTION 0x03 +#define SMA1303_MONO 0x00 +#define SMA1303_STEREO 0x01 -#define SMA1303_I2C_RETRY_COUNT 3 +#define SMA1303_I2C_RETRY_COUNT 3 /* * SMA1303 Register Definition From patchwork Fri Jan 6 09:15:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 640106 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC192C3DA7A for ; Fri, 6 Jan 2023 09:19:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5942E14128; Fri, 6 Jan 2023 10:18:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5942E14128 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996758; bh=80/tDextTrqDeTEgIRUNzmKh1Vykbj2Pk/ybzeQ+Ebk=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Ff8E36VA4pvdGbU0+VkSDV2spMsy2A1FhHa21Bx6qQT38Ds8VJ1KDsnf9EpgDynU2 A9pKMbfR3dPMyzmBFGyPMM81jouT0cobbwf9hf4efsLXbsLYztEGN+xDg6/JH72MOR cVwExYyHJHRnkgYQmRxqAGD19+xFLKQI+va94HTQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E1EADF805B2; Fri, 6 Jan 2023 10:16:18 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CE418F805AD; Fri, 6 Jan 2023 10:16:15 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2059.outbound.protection.outlook.com [40.107.129.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DBEB7F8055B for ; Fri, 6 Jan 2023 10:16:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DBEB7F8055B ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AW0rndZGom95Hu/fnsvQizZ5HMkq4HKoZ5iKw1+I50Fyba9J15Hf34fiWgQMy3JViGZqeUCAYJA2F3WG9VuPjOmr6whzNZyrldwIjlV2qA0Sh6Nl8BI8EoW9DB4ZQ/j7ps/eRKTF+45tMzNj8LnqFQ7/dmp+M19Rx4aCxny60EJ/QrkGBEgn7+zeayie81u9eAHARUtOMARZXS6nSgTTV/T9XT0PWQe+xmj4U/Y+63GXwmka4dCxrLn+CDOoSQorjkgg608LE3V4MMWv3UzzvKYdfhBvDoCZeXcKLhQq1N4Q4Ii2FlCVfaWtPkUYY/4sItxF9MLtehCZYcCQQAVUJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y9X6PNsBEn6jTGmw853j7067dblU7AKTUHfuz7jqFAM=; b=VDLejRtxWJ+6L2QcBC58tunDa2a19Nith9AXqNfwf90/uSSz1ekyQhA9g72uxdE+5PByVRNBpcyJn/iN2jCXv403qNahDgH8dlpR5I7rV4aRXla+py0fu/35lYOHaSIV/Yq9qXpgS6tApt0V5ar3nTFkzJfGbAlGHeReDfK4rb+8zhAl3ocqXxHYhQ+G7fK/WZD/0Z7+ki/H2juvqEjHoJd+gMpZrjDxvEb2t71ciOJLk4sroSJLnnkLLIps8rHvDMn+q1vUK+wzdescErzgidzEgJRAfSEhRvWCLgE0llCaEvIPLLpGjjbMBTVEj+43VmSoPQUcjCD2yC74RceTbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:58 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:58 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 06/14] Use the prefixs all definitions Date: Fri, 6 Jan 2023 18:15:35 +0900 Message-Id: <20230106091543.2440-7-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 05acb0e1-87e2-47c8-c3f6-08daefc69f01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +zyaM5c7vqZ86CH9/fHK+h2Xa8s6AsDp6GGnCXqy0AbzEG0MJdv22nt/Jxf/2kxqtzfrxiFcmAgC3CyXe8vN05vg2f9+bH4o8JQrQ9AKViFz/JRvRxZ0WEtdmheXyC7atbLVBWjfR85BXsK7jLuw1LRt2dGMaphgPFguIVMn8aT3KboDOmNgRBVhrkYNSONRE3sqcJSxGfQAOLjejZTPUoGpZwDWS5NTcP/qrivv/Cn3qDRQQVaJOHDjCLBVfii733Vk3l8ybAD+5MtbkSsiGP7HCWLcJ43LlmZ5s4n4fvtNk74XkmjwO2wc6/uX/uluGxM/2A9phqdX2kbHHrUhinJjPDnlXBFhhAHXUHhl0xG8kIO/ET3DBkt/f5nt3APPT01KSNVfDCEQBXgLrm13D7y+avFivYiFU1UaB+uSH/u+5rzZ1BGrJysA9q+amNy/A0i9nBBqIvGefrC5i5LRNHMsQDi2PmlqCmNwo1w6IPUJjYRUvOKc6n8VOgA7PO9WjPXDE10Z7+d2SueSwLJOX0VF+lUo8eXa7z0zB2ZB7iSXjBZfbGxUpfVTFtSv5M0TuTCzsk7hb03+4Mu2cA1utpGtAzT6wGZQ23lfVvsVSTa18lE+7bZ3g/UxXtqR01dD6+35YhTwmNNakfRCgDEZnLNtFeMfq4/wUlaSx2VG1SEm1QLfe+XeHvGqkYquCCUIAMYFg9/l/i6xTfFH4ABPTQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(30864003)(44832011)(8676002)(41300700001)(4326008)(54906003)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003)(2004002)(579004)(559001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wowHWD/dBJTxmeW5vXxoa3fMN0tubCr/Ww2QLioTVFhJhgvAC5EVtSIIpwlz5NEOF7HKA3198braMpiha0ldqIpphl3yhm28vrEs9qmk1LWtDxk7wYCY6u4R+tPJqR9dmNqf7kUS55uzVJdQy9LeWRpgIGzCa30VTK+BBxq7BHMhqdLbJE9iyPujySxc7ageegMa0K+H/5fR9LqBt5p3jqNNipCSL8J6Z5o8ASMBmWCRTbUuVkHFDcNDQymiBDz7Af0fl11irFvTImaHHrsewQfQ68MmqgBEQSVhhf+ZNqcEoTVytF8McX0wmTMcneK2e7TWmrF7F+LeR6CduKLu3GQ67lnkL8rYFh/9MqIl4ibDbqK3SVfUeBniHWPxg+IKwYEPF4lfo7eZNLWU4yyx8Oo8y/3aLPU5t34WcGm8df8BVQyEb0mUF2TgClzxHc0BMEzCNUAaBVDVFDjJiL/yz5v6kfeGHeOcuFfsHIN1R8o0wrSxTgsG3XxR2y/L3pipa0Ll+aksy2rPOHZiKjkiA03QvTSJDmZ7L7uafImBz3HTC+GIL936gOdlA4kkXuvSazvOWzhLabxMubhkuta6H7qY0UE8Qoa5zUiAV9IX0FaeGA8KiJGov2Qr5e5JHal8HHsuQP05tgDg6g09fUqidBIPak2s3ZC3A4+ASV2EFA7LWZn3hYXeNDiiK8+Am41ZzyPXY/FPi7HXw5eEp8OANcz8/S0BaXGOSTQiDH8uhz8hBvSob9/EW5dxwtzJh0Pdui7cwR6Hh0Nf4t4AyXubWy35mrjMhAVwHkuk4KkV1m11Hy6NPgvYWTuChsuVQUWKIFsM9/A5ByVQ1M9ZYXHcYHcnYmBDhnqoMTKjmYT9tO1q0ZNJUcAtiISp0hxxvX23KNRk9bMBRETGn76hdMawJFjj9+V1OS90Uuva1mdefq8UbOCA7Id1halOe0j2E51sqvbuvefNM3Mb7kXsoMJe5WzNq48JqOM6WHLHADDj2Kd1f65bAlDJMUatu+thpg74xsWWIuAT2P5eJWwV4XwkAZEPVSubZ72cKtV2Bo4HavPOpzyV8vU0VQsIMmhWanqOwhYdUmVfx7Vn0g9heUYCMYewSr8XfUvy+f6EYZSuZpBQOUVR+RX1B6KR18a5gU89VVqxdr/rurpnhwXXqSI5jsUgHjPBgZXROHquVjFMJ3BzsUDsuwIAnqxv4DA0PUryyxmWgxDhWgMScBTwPJqTPUcxD4FWrWrxH9dpBto9QySSZQ6nRoKR43wqjS5/DomZmIfJCWJqMSZylyI0HOOWAKarzGgD42ztA5V6FsufrhdpapUk4ISWtuL3UdQwKHnoT95glS78GGeYSJbhhk7zW1p91tHfzfsdktyG6WO6PiwmGoYm/H69clfaHkI3gRYnV2rtE4Z699f8kImy889KKfsI033Bl2gAPjDYqsH6PrMqBLuSNJDniLiU8uX6ZbCNb0mIIoclth+l4xUuobC3K6ahSeZiJujcdnG2fl4/rXa1mKYBFQ6fiRxdcs+q0LrJM6pSVvcO4dv7+eLhw96WU7infl70rs+ZjjHofO7wdDprFdG8Ur+eMZWCLjnn63Ab X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05acb0e1-87e2-47c8-c3f6-08daefc69f01 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:58.1446 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I/fAnQevyKDZtKU5/NSjFe+AQXewgoYAl/8O2MrR8fQOgNSZEQyH9gAMnpqO8VDWw94A+FB8GWaoyTqRa1cgtO5WnZg2vJGfRvHZOVg0YWI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo , Pierre-Louis Bossart Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Modified to the kernel coding style. Signed-off-by: Kiseok Jo Reported-by: Mark Brown Reported-by: Pierre-Louis Bossart --- sound/soc/codecs/sma1303.c | 570 +++++++++++--------------- sound/soc/codecs/sma1303.h | 802 ++++++++++++++++++------------------- 2 files changed, 642 insertions(+), 730 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 1ef0b145f5ba..42352fa6de56 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -1,12 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later -/* sma1303.c -- sma1303 ALSA SoC Audio driver - * - * Copyright 2022 Iron Device Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ +// +// sma1303.c -- sma1303 ALSA SoC Audio driver +// +// Copyright 2023 Iron Device Corporation +// +// Auther: Gyuhwa Park +// Kiseok Jo #include #include @@ -61,29 +60,29 @@ struct sma1303_pll_match { struct sma1303_priv { enum sma1303_type devtype; - struct device *dev; struct attribute_group *attr_grp; + struct delayed_work check_fault_work; + struct device *dev; struct kobject *kobj; + struct mutex lock; struct regmap *regmap; struct sma1303_pll_match *pll_matches; - struct mutex lock; - struct delayed_work check_fault_work; bool amp_power_status; int num_of_pll_matches; int retry_cnt; - unsigned int sys_clk_id; - unsigned int init_vol; + unsigned int amp_mode; unsigned int cur_vol; + unsigned int format; + unsigned int frame_size; + unsigned int init_vol; + unsigned int last_bclk; + unsigned int last_ocp_val; + unsigned int last_over_temp; + unsigned int rev_num; + unsigned int sys_clk_id; unsigned int tdm_slot_rx; unsigned int tdm_slot_tx; unsigned int tsdw_cnt; - unsigned int format; - unsigned int rev_num; - unsigned int last_over_temp; - unsigned int last_ocp_val; - unsigned int last_bclk; - unsigned int frame_size; - unsigned int amp_mode; long check_fault_period; long check_fault_status; }; @@ -245,7 +244,7 @@ EXPORT_SYMBOL(sma1303_set_callback_func); static int sma1303_regmap_write(struct sma1303_priv *sma1303, unsigned int reg, unsigned int val) { - int ret = 0; + int ret; int cnt = sma1303->retry_cnt; while (cnt--) { @@ -264,7 +263,7 @@ static int sma1303_regmap_write(struct sma1303_priv *sma1303, static int sma1303_regmap_update_bits(struct sma1303_priv *sma1303, unsigned int reg, unsigned int mask, unsigned int val) { - int ret = 0; + int ret; int cnt = sma1303->retry_cnt; while (cnt--) { @@ -308,25 +307,11 @@ static int bytes_ext_get(struct snd_kcontrol *kcontrol, struct soc_bytes_ext *params = (void *)kcontrol->private_value; unsigned int i, reg_val; u8 *val; - int ret = -1; + int ret; - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } val = (u8 *)ucontrol->value.bytes.data; for (i = 0; i < params->max; i++) { ret = sma1303_regmap_read(sma1303, reg + i, ®_val); - if (ret < 0) { - dev_err(component->dev, - "Failed to read, register: %x ret: %d\n", - reg + i, ret); - return ret; - } if (sizeof(reg_val) > 2) reg_val = cpu_to_le32(reg_val); else @@ -334,7 +319,7 @@ static int bytes_ext_get(struct snd_kcontrol *kcontrol, memcpy(val + i, ®_val, sizeof(u8)); } - return 0; + return ret; } static int bytes_ext_put(struct snd_kcontrol *kcontrol, @@ -346,16 +331,8 @@ static int bytes_ext_put(struct snd_kcontrol *kcontrol, struct soc_bytes_ext *params = (void *)kcontrol->private_value; void *data; u8 *val; - int i, ret = -1; + int i, ret; - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } data = kmemdup(ucontrol->value.bytes.data, params->max, GFP_KERNEL | GFP_DMA); if (!data) @@ -407,41 +384,25 @@ static int sma1303_postscaler_config_get(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int ret = -1, data, val; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } + int ret, data, val; ret = sma1303_regmap_read(sma1303, SMA1303_90_POSTSCALER, &data); - if (ret < 0) { - dev_err(component->dev, - "Failed to read, register: %x ret: %d\n", - SMA1303_90_POSTSCALER, ret); - return ret; - } - - val = data & BYP_POST_MASK; + val = data & SMA1303_BYP_POST_MASK; switch (val) { - case BYP_POST_SCALER: + case SMA1303_BYP_POST_SCALER: ucontrol->value.integer.value[0] = 1; break; - case EN_POST_SCALER: + case SMA1303_EN_POST_SCALER: ucontrol->value.integer.value[0] = 0; break; default: dev_err(component->dev, "Invalid value, register: %x value: %d\n", SMA1303_90_POSTSCALER, val); - return ret; + return -EINVAL; } - return 0; + return ret; } static int sma1303_postscaler_config_put(struct snd_kcontrol *kcontrol, @@ -451,33 +412,24 @@ static int sma1303_postscaler_config_put(struct snd_kcontrol *kcontrol, snd_soc_kcontrol_component(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int sel = (int)ucontrol->value.integer.value[0]; - int val, ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } + int val; switch (sel) { case 0: - val = EN_POST_SCALER; + val = SMA1303_EN_POST_SCALER; break; case 1: - val = BYP_POST_SCALER; + val = SMA1303_BYP_POST_SCALER; break; default: dev_err(component->dev, "Invalid value, register: %x\n", SMA1303_90_POSTSCALER); - return ret; + return -EINVAL; } return sma1303_regmap_update_bits(sma1303, - SMA1303_90_POSTSCALER, BYP_POST_MASK, val); + SMA1303_90_POSTSCALER, SMA1303_BYP_POST_MASK, val); } static const char * const sma1303_o_format_text[] = { @@ -492,37 +444,28 @@ static int sma1303_o_format_get(struct snd_kcontrol *kcontrol, struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int val, data, ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } + int val, data, ret; ret = sma1303_regmap_read(sma1303, SMA1303_A4_TOP_MAN3, &data); - val = data & O_FORMAT_MASK; + val = data & SMA1303_O_FORMAT_MASK; switch (val) { - case O_FMT_LJ: + case SMA1303_O_FMT_LJ: ucontrol->value.integer.value[0] = 0; break; - case O_FMT_I2S: + case SMA1303_O_FMT_I2S: ucontrol->value.integer.value[0] = 1; break; - case O_FMT_TDM: + case SMA1303_O_FMT_TDM: ucontrol->value.integer.value[0] = 2; break; default: dev_err(component->dev, "Invalid value, register: %x\n", SMA1303_A4_TOP_MAN3); - return ret; + return -EINVAL; } - return 0; + return ret; } static int sma1303_o_format_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -531,36 +474,27 @@ static int sma1303_o_format_put(struct snd_kcontrol *kcontrol, snd_soc_kcontrol_component(kcontrol); struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); int sel = (int)ucontrol->value.integer.value[0]; - int val, ret = -1; - - if (component == NULL) { - pr_err("%s:component is NULL\n", __func__); - return ret; - } - if (sma1303 == NULL) { - pr_err("%s:sma1303 is NULL\n", __func__); - return ret; - } + int val; switch (sel) { case 0: - val = O_FMT_LJ; + val = SMA1303_O_FMT_LJ; break; case 1: - val = O_FMT_I2S; + val = SMA1303_O_FMT_I2S; break; case 2: - val = O_FMT_TDM; + val = SMA1303_O_FMT_TDM; break; default: dev_err(component->dev, "Invalid value, register: %x\n", SMA1303_A4_TOP_MAN3); - return ret; + return -EINVAL; } return sma1303_regmap_update_bits(sma1303, - SMA1303_A4_TOP_MAN3, O_FORMAT_MASK, val); + SMA1303_A4_TOP_MAN3, SMA1303_O_FORMAT_MASK, val); } static const char * const sma1303_aif_in_source_text[] = { @@ -587,18 +521,22 @@ static int sma1303_startup(struct snd_soc_component *component) return ret; } - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_8E_PLL_CTRL, PLL_PD2_MASK, PLL_OPERATION2); + ret += sma1303_regmap_update_bits(sma1303, SMA1303_8E_PLL_CTRL, + SMA1303_PLL_PD2_MASK, SMA1303_PLL_OPERATION2); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_ON); + ret += sma1303_regmap_update_bits(sma1303, SMA1303_00_SYSTEM_CTRL, + SMA1303_POWER_MASK, SMA1303_POWER_ON); if (sma1303->amp_mode == SMA1303_MONO) ret += sma1303_regmap_update_bits(sma1303, - SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_MONO); + SMA1303_10_SYSTEM_CTRL1, + SMA1303_SPK_MODE_MASK, + SMA1303_SPK_MONO); else ret += sma1303_regmap_update_bits(sma1303, - SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_STEREO); + SMA1303_10_SYSTEM_CTRL1, + SMA1303_SPK_MODE_MASK, + SMA1303_SPK_STEREO); if (sma1303->check_fault_status) { if (sma1303->check_fault_period > 0) @@ -611,8 +549,8 @@ static int sma1303_startup(struct snd_soc_component *component) CHECK_PERIOD_TIME * HZ); } - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_UNMUTE); + ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, + SMA1303_SPK_MUTE_MASK, SMA1303_SPK_UNMUTE); sma1303->amp_power_status = true; @@ -630,21 +568,21 @@ static int sma1303_shutdown(struct snd_soc_component *component) return ret; } - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_0E_MUTE_VOL_CTRL, SPK_MUTE_MASK, SPK_MUTE); + ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, + SMA1303_SPK_MUTE_MASK, SMA1303_SPK_MUTE); cancel_delayed_work_sync(&sma1303->check_fault_work); msleep(55); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_10_SYSTEM_CTRL1, SPK_MODE_MASK, SPK_OFF); + ret += sma1303_regmap_update_bits(sma1303, SMA1303_10_SYSTEM_CTRL1, + SMA1303_SPK_MODE_MASK, SMA1303_SPK_OFF); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_00_SYSTEM_CTRL, POWER_MASK, POWER_OFF); + ret += sma1303_regmap_update_bits(sma1303, SMA1303_00_SYSTEM_CTRL, + SMA1303_POWER_MASK, SMA1303_POWER_OFF); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_8E_PLL_CTRL, PLL_PD2_MASK, PLL_PD2); + ret += sma1303_regmap_update_bits(sma1303, SMA1303_8E_PLL_CTRL, + SMA1303_PLL_PD2_MASK, SMA1303_PLL_PD2); sma1303->amp_power_status = false; @@ -666,30 +604,30 @@ static int sma1303_aif_in_event(struct snd_soc_dapm_widget *w, case 0: ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, - MONOMIX_MASK, - MONOMIX_ON); + SMA1303_MONOMIX_MASK, + SMA1303_MONOMIX_ON); ret += sma1303->amp_mode = SMA1303_MONO; break; case 1: ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, - MONOMIX_MASK, - MONOMIX_OFF); + SMA1303_MONOMIX_MASK, + SMA1303_MONOMIX_OFF); ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, - LR_DATA_SW_MASK, - LR_DATA_SW_NORMAL); + SMA1303_LR_DATA_SW_MASK, + SMA1303_LR_DATA_SW_NORMAL); ret += sma1303->amp_mode = SMA1303_STEREO; break; case 2: ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, - MONOMIX_MASK, - MONOMIX_OFF); + SMA1303_MONOMIX_MASK, + SMA1303_MONOMIX_OFF); ret += sma1303_regmap_update_bits(sma1303, SMA1303_11_SYSTEM_CTRL2, - LR_DATA_SW_MASK, - LR_DATA_SW_NORMAL); + SMA1303_LR_DATA_SW_MASK, + SMA1303_LR_DATA_SW_NORMAL); sma1303->amp_mode = SMA1303_STEREO; break; default: @@ -720,72 +658,72 @@ static int sma1303_aif_out_event(struct snd_soc_dapm_widget *w, case 0: ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - TEST_CLKO_EN_MASK, - NORMAL_SDO); + SMA1303_TEST_CLKO_EN_MASK, + SMA1303_NORMAL_SDO); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_OUT_SEL_MASK, - OUT_SEL_DISABLE); + SMA1303_PORT_OUT_SEL_MASK, + SMA1303_OUT_SEL_DISABLE); break; case 1: ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - TEST_CLKO_EN_MASK, - NORMAL_SDO); + SMA1303_TEST_CLKO_EN_MASK, + SMA1303_NORMAL_SDO); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_OUT_SEL_MASK, - FORMAT_CONVERTER); + SMA1303_PORT_OUT_SEL_MASK, + SMA1303_FORMAT_CONVERTER); break; case 2: ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - TEST_CLKO_EN_MASK, - NORMAL_SDO); + SMA1303_TEST_CLKO_EN_MASK, + SMA1303_NORMAL_SDO); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_OUT_SEL_MASK, - MIXER_OUTPUT); + SMA1303_PORT_OUT_SEL_MASK, + SMA1303_MIXER_OUTPUT); break; case 3: ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - TEST_CLKO_EN_MASK, - NORMAL_SDO); + SMA1303_TEST_CLKO_EN_MASK, + SMA1303_NORMAL_SDO); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_OUT_SEL_MASK, - SPEAKER_PATH); + SMA1303_PORT_OUT_SEL_MASK, + SMA1303_SPEAKER_PATH); break; case 4: ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - TEST_CLKO_EN_MASK, - NORMAL_SDO); + SMA1303_TEST_CLKO_EN_MASK, + SMA1303_NORMAL_SDO); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_OUT_SEL_MASK, - POSTSCALER_OUTPUT); + SMA1303_PORT_OUT_SEL_MASK, + SMA1303_POSTSCALER_OUTPUT); break; case 5: ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - TEST_CLKO_EN_MASK, - CLK_OUT_SDO); + SMA1303_TEST_CLKO_EN_MASK, + SMA1303_CLK_OUT_SDO); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - MON_OSC_PLL_MASK, - PLL_SDO); + SMA1303_MON_OSC_PLL_MASK, + SMA1303_PLL_SDO); break; case 6: ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - TEST_CLKO_EN_MASK, - CLK_OUT_SDO); + SMA1303_TEST_CLKO_EN_MASK, + SMA1303_CLK_OUT_SDO); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - MON_OSC_PLL_MASK, - PLL_OSC); + SMA1303_MON_OSC_PLL_MASK, + SMA1303_OSC_SDO); break; default: dev_err(sma1303->dev, "%s : Invald value (%d)\n", @@ -814,24 +752,24 @@ static int sma1303_sdo_event(struct snd_soc_dapm_widget *w, "%s : SND_SOC_DAPM_PRE_PMU\n", __func__); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_CONFIG_MASK, - OUTPUT_PORT_ENABLE); + SMA1303_PORT_CONFIG_MASK, + SMA1303_OUTPUT_PORT_ENABLE); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - SDO_OUTPUT_MASK, - NORMAL_OUT); + SMA1303_SDO_OUTPUT_MASK, + SMA1303_NORMAL_OUT); break; case SND_SOC_DAPM_POST_PMD: dev_info(sma1303->dev, "%s : SND_SOC_DAPM_POST_PMD\n", __func__); ret += sma1303_regmap_update_bits(sma1303, SMA1303_09_OUTPUT_CTRL, - PORT_CONFIG_MASK, - INPUT_PORT_ONLY); + SMA1303_PORT_CONFIG_MASK, + SMA1303_INPUT_PORT_ONLY); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A3_TOP_MAN2, - SDO_OUTPUT_MASK, - HIGH_Z_OUT); + SMA1303_SDO_OUTPUT_MASK, + SMA1303_HIGH_Z_OUT); break; } return ret; @@ -964,8 +902,8 @@ static int sma1303_setup_pll(struct snd_soc_component *component, ret += sma1303_regmap_update_bits(sma1303, SMA1303_A2_TOP_MAN1, - PLL_PD_MASK|PLL_REF_CLK_MASK, - PLL_OPERATION|PLL_SCK); + SMA1303_PLL_PD_MASK|SMA1303_PLL_REF_CLK_MASK, + SMA1303_PLL_OPERATION|SMA1303_PLL_SCK); } ret += sma1303_regmap_write(sma1303, @@ -1033,24 +971,28 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, case 44100: case 48000: case 96000: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A2_TOP_MAN1, - DAC_DN_CONV_MASK, DAC_DN_CONV_DISABLE); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A2_TOP_MAN1, + SMA1303_DAC_DN_CONV_MASK, + SMA1303_DAC_DN_CONV_DISABLE); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_01_INPUT1_CTRL1, - LEFTPOL_MASK, LOW_FIRST_CH); - break; + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_01_INPUT1_CTRL1, + SMA1303_LEFTPOL_MASK, + SMA1303_LOW_FIRST_CH); + break; case 192000: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A2_TOP_MAN1, - DAC_DN_CONV_MASK, DAC_DN_CONV_ENABLE); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A2_TOP_MAN1, + SMA1303_DAC_DN_CONV_MASK, + SMA1303_DAC_DN_CONV_ENABLE); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_01_INPUT1_CTRL1, - LEFTPOL_MASK, HIGH_FIRST_CH); - break; + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_01_INPUT1_CTRL1, + SMA1303_LEFTPOL_MASK, + SMA1303_HIGH_FIRST_CH); + break; default: dev_err(component->dev, "%s not support rate : %d\n", @@ -1069,7 +1011,8 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, __func__); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, - SCK_RATE_MASK, SCK_32FS); + SMA1303_SCK_RATE_MASK, + SMA1303_SCK_32FS); break; case SNDRV_PCM_FORMAT_S24_LE: @@ -1078,7 +1021,8 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, __func__); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, - SCK_RATE_MASK, SCK_64FS); + SMA1303_SCK_RATE_MASK, + SMA1303_SCK_64FS); break; case SNDRV_PCM_FORMAT_S32_LE: dev_info(component->dev, @@ -1086,7 +1030,8 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, __func__); ret += sma1303_regmap_update_bits(sma1303, SMA1303_A4_TOP_MAN3, - SCK_RATE_MASK, SCK_64FS); + SMA1303_SCK_RATE_MASK, + SMA1303_SCK_64FS); break; default: dev_err(component->dev, @@ -1100,13 +1045,13 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, case 16: switch (sma1303->format) { case SND_SOC_DAIFMT_I2S: - input_format |= STANDARD_I2S; + input_format |= SMA1303_STANDARD_I2S; break; case SND_SOC_DAIFMT_LEFT_J: - input_format |= LJ; + input_format |= SMA1303_LJ; break; case SND_SOC_DAIFMT_RIGHT_J: - input_format |= RJ_16BIT; + input_format |= SMA1303_RJ_16BIT; break; } break; @@ -1114,13 +1059,13 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, case 32: switch (sma1303->format) { case SND_SOC_DAIFMT_I2S: - input_format |= STANDARD_I2S; + input_format |= SMA1303_STANDARD_I2S; break; case SND_SOC_DAIFMT_LEFT_J: - input_format |= LJ; + input_format |= SMA1303_LJ; break; case SND_SOC_DAIFMT_RIGHT_J: - input_format |= RJ_24BIT; + input_format |= SMA1303_RJ_24BIT; break; } break; @@ -1134,7 +1079,7 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, - I2S_MODE_MASK, input_format); + SMA1303_I2S_MODE_MASK, input_format); return ret; } @@ -1181,13 +1126,15 @@ static int sma1303_dai_mute(struct snd_soc_dai *dai, int mute, int stream) ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, - SPK_MUTE_MASK, SPK_MUTE); + SMA1303_SPK_MUTE_MASK, + SMA1303_SPK_MUTE); } else { dev_info(component->dev, "%s : %s\n", __func__, "UNMUTE"); ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, - SPK_MUTE_MASK, SPK_UNMUTE); + SMA1303_SPK_MUTE_MASK, + SMA1303_SPK_UNMUTE); } return ret; @@ -1207,7 +1154,8 @@ static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, "%s : %s\n", __func__, "I2S/TDM Device mode"); ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, - CONTROLLER_DEVICE_MASK, DEVICE_MODE); + SMA1303_CONTROLLER_DEVICE_MASK, + SMA1303_DEVICE_MODE); break; case SND_SOC_DAIFMT_CBM_CFM: @@ -1215,7 +1163,8 @@ static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, "%s : %s\n", __func__, "I2S/TDM Controller mode"); ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, - CONTROLLER_DEVICE_MASK, CONTROLLER_MODE); + SMA1303_CONTROLLER_DEVICE_MASK, + SMA1303_CONTROLLER_MODE); break; default: @@ -1246,22 +1195,24 @@ static int sma1303_dai_set_fmt_amp(struct snd_soc_dai *dai, __func__, "Invert BCLK + Normal Frame"); ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, - SCK_RISING_MASK, SCK_RISING_EDGE); + SMA1303_SCK_RISING_MASK, + SMA1303_SCK_RISING_EDGE); break; case SND_SOC_DAIFMT_IB_IF: dev_info(component->dev, "%s : %s\n", __func__, "Invert BCLK + Invert Frame"); ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, - LEFTPOL_MASK|SCK_RISING_MASK, - HIGH_FIRST_CH|SCK_RISING_EDGE); + SMA1303_LEFTPOL_MASK|SMA1303_SCK_RISING_MASK, + SMA1303_HIGH_FIRST_CH|SMA1303_SCK_RISING_EDGE); break; case SND_SOC_DAIFMT_NB_IF: dev_info(component->dev, "%s : %s\n", __func__, "Normal BCLK + Invert Frame"); ret += sma1303_regmap_update_bits(sma1303, SMA1303_01_INPUT1_CTRL1, - LEFTPOL_MASK, HIGH_FIRST_CH); + SMA1303_LEFTPOL_MASK, + SMA1303_HIGH_FIRST_CH); break; case SND_SOC_DAIFMT_NB_NF: dev_info(component->dev, "%s : %s\n", @@ -1290,61 +1241,70 @@ static int sma1303_dai_set_tdm_slot(struct snd_soc_dai *dai, sma1303->frame_size = slot_width * slots; ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A4_TOP_MAN3, - O_FORMAT_MASK, O_FMT_TDM); + SMA1303_A4_TOP_MAN3, + SMA1303_O_FORMAT_MASK, + SMA1303_O_FMT_TDM); switch (slot_width) { case 16: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A6_TDM2, - TDM_DL_MASK, TDM_DL_16); - break; + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A6_TDM2, + SMA1303_TDM_DL_MASK, + SMA1303_TDM_DL_16); + break; case 32: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A6_TDM2, - TDM_DL_MASK, TDM_DL_32); - break; + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A6_TDM2, + SMA1303_TDM_DL_MASK, + SMA1303_TDM_DL_32); + break; default: - dev_err(component->dev, "%s not support TDM %d slot_width\n", - __func__, slot_width); + dev_err(component->dev, "%s not support TDM %d slot_width\n", + __func__, slot_width); } switch (slots) { case 4: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A6_TDM2, - TDM_N_SLOT_MASK, TDM_N_SLOT_4); - break; + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A6_TDM2, + SMA1303_TDM_N_SLOT_MASK, + SMA1303_TDM_N_SLOT_4); + break; case 8: - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A6_TDM2, - TDM_N_SLOT_MASK, TDM_N_SLOT_8); - break; + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A6_TDM2, + SMA1303_TDM_N_SLOT_MASK, + SMA1303_TDM_N_SLOT_8); + break; default: - dev_err(component->dev, "%s not support TDM %d slots\n", + dev_err(component->dev, "%s not support TDM %d slots\n", __func__, slots); } if (sma1303->tdm_slot_rx < slots) ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A5_TDM1, TDM_SLOT1_RX_POS_MASK, - (sma1303->tdm_slot_rx) << 3); + SMA1303_A5_TDM1, + SMA1303_TDM_SLOT1_RX_POS_MASK, + (sma1303->tdm_slot_rx) << 3); else dev_err(component->dev, "%s Incorrect tdm-slot-rx %d set\n", - __func__, sma1303->tdm_slot_rx); + __func__, sma1303->tdm_slot_rx); ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A5_TDM1, - TDM_CLK_POL_MASK, TDM_CLK_POL_RISE); + SMA1303_A5_TDM1, + SMA1303_TDM_CLK_POL_MASK, + SMA1303_TDM_CLK_POL_RISE); ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A5_TDM1, - TDM_TX_MODE_MASK, TDM_TX_MONO); + SMA1303_A5_TDM1, + SMA1303_TDM_TX_MODE_MASK, + SMA1303_TDM_TX_MONO); if (sma1303->tdm_slot_tx < slots) ret += sma1303_regmap_update_bits(sma1303, - SMA1303_A6_TDM2, TDM_SLOT1_TX_POS_MASK, - (sma1303->tdm_slot_tx) << 3); + SMA1303_A6_TDM2, + SMA1303_TDM_SLOT1_TX_POS_MASK, + (sma1303->tdm_slot_tx) << 3); else dev_err(component->dev, "%s Incorrect tdm-slot-tx %d set\n", __func__, sma1303->tdm_slot_tx); @@ -1365,25 +1325,25 @@ static const struct snd_soc_dai_ops sma1303_dai_ops_amp = { SNDRV_PCM_FMTBIT_S32_LE) static struct snd_soc_dai_driver sma1303_dai[] = { -{ - .name = "sma1303-amplifier", - .id = 0, - .playback = { - .stream_name = "Playback", - .channels_min = 1, - .channels_max = 2, - .rates = SMA1303_RATES, - .formats = SMA1303_FORMATS, + { + .name = "sma1303-amplifier", + .id = 0, + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 2, + .rates = SMA1303_RATES, + .formats = SMA1303_FORMATS, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 2, + .rates = SMA1303_RATES, + .formats = SMA1303_FORMATS, + }, + .ops = &sma1303_dai_ops_amp, }, - .capture = { - .stream_name = "Capture", - .channels_min = 1, - .channels_max = 2, - .rates = SMA1303_RATES, - .formats = SMA1303_FORMATS, - }, - .ops = &sma1303_dai_ops_amp, -} }; static void sma1303_check_fault_worker(struct work_struct *work) @@ -1433,7 +1393,7 @@ static void sma1303_check_fault_worker(struct work_struct *work) return; } - if (~over_temp & OT1_OK_STATUS) { + if (~over_temp & SMA1303_OT1_OK_STATUS) { dev_crit(sma1303->dev, "%s : OT1(Over Temperature Level 1)\n", __func__); @@ -1449,23 +1409,23 @@ static void sma1303_check_fault_worker(struct work_struct *work) sma1303->cur_vol = sma1303->init_vol; } - if (~over_temp & OT2_OK_STATUS) { + if (~over_temp & SMA1303_OT2_OK_STATUS) { dev_crit(sma1303->dev, "%s : OT2(Over Temperature Level 2)\n", __func__); } - if (ocp_val & OCP_SPK_STATUS) { + if (ocp_val & SMA1303_OCP_SPK_STATUS) { dev_crit(sma1303->dev, "%s : OCP_SPK(Over Current Protect SPK)\n", __func__); } - if (ocp_val & OCP_BST_STATUS) { + if (ocp_val & SMA1303_OCP_BST_STATUS) { dev_crit(sma1303->dev, "%s : OCP_BST(Over Current Protect Boost)\n", __func__); } - if ((ocp_val & CLK_MON_STATUS) && (sma1303->amp_power_status)) { + if ((ocp_val & SMA1303_CLK_MON_STATUS) && (sma1303->amp_power_status)) { dev_crit(sma1303->dev, "%s : CLK_FAULT(No clock input)\n", __func__); } - if (uvlo_val & UVLO_BST_STATUS) { + if (uvlo_val & SMA1303_UVLO_BST_STATUS) { dev_crit(sma1303->dev, "%s : UVLO(Under Voltage Lock Out)\n", __func__); } @@ -1491,31 +1451,17 @@ static void sma1303_check_fault_worker(struct work_struct *work) CHECK_PERIOD_TIME * HZ); } - if (!(~over_temp & OT1_OK_STATUS) && !(~over_temp & OT2_OK_STATUS) - && !(ocp_val & OCP_SPK_STATUS) - && !(ocp_val & OCP_BST_STATUS) - && !(ocp_val & CLK_MON_STATUS) - && !(uvlo_val & UVLO_BST_STATUS)) { + if (!(~over_temp & SMA1303_OT1_OK_STATUS) + && !(~over_temp & SMA1303_OT2_OK_STATUS) + && !(ocp_val & SMA1303_OCP_SPK_STATUS) + && !(ocp_val & SMA1303_OCP_BST_STATUS) + && !(ocp_val & SMA1303_CLK_MON_STATUS) + && !(uvlo_val & SMA1303_UVLO_BST_STATUS)) { } mutex_unlock(&sma1303->lock); } -#ifdef CONFIG_PM -static int sma1303_suspend(struct snd_soc_component *component) -{ - return 0; -} - -static int sma1303_resume(struct snd_soc_component *component) -{ - return 0; -} -#else -#define sma1303_suspend NULL -#define sma1303_resume NULL -#endif - static int sma1303_probe(struct snd_soc_component *component) { struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); @@ -1559,7 +1505,7 @@ static int sma1303_probe(struct snd_soc_component *component) ret += sma1303_regmap_update_bits(sma1303, SMA1303_00_SYSTEM_CTRL, - RESETBYI2C_MASK, RESETBYI2C_RESET); + SMA1303_RESETBYI2C_MASK, SMA1303_RESETBYI2C_RESET); ret += sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &status); if (ret < 0) { @@ -1568,10 +1514,10 @@ static int sma1303_probe(struct snd_soc_component *component) SMA1303_FF_DEVICE_INDEX, ret); return ret; } - sma1303->rev_num = status & REV_NUM_STATUS; - if (sma1303->rev_num == REV_NUM_TV0) + sma1303->rev_num = status & SMA1303_REV_NUM_STATUS; + if (sma1303->rev_num == SMA1303_REV_NUM_TV0) dev_info(component->dev, "SMA1303 Trimming Version 0\n"); - else if (sma1303->rev_num == REV_NUM_TV1) + else if (sma1303->rev_num == SMA1303_REV_NUM_TV1) dev_info(component->dev, "SMA1303 Trimming Version 1\n"); ret += sma1303_regmap_read(sma1303, SMA1303_FB_STATUS2, &otp_stat); @@ -1580,10 +1526,10 @@ static int sma1303_probe(struct snd_soc_component *component) "failed to read, register: %02X, ret: %d\n", SMA1303_FF_DEVICE_INDEX, ret); - if (((sma1303->rev_num == REV_NUM_TV0) && - ((otp_stat & 0x0E) == OTP_STAT_OK_0)) || - ((sma1303->rev_num != REV_NUM_TV0) && - ((otp_stat & 0x0C) == OTP_STAT_OK_1))) + if (((sma1303->rev_num == SMA1303_REV_NUM_TV0) && + ((otp_stat & 0x0E) == SMA1303_OTP_STAT_OK_0)) || + ((sma1303->rev_num != SMA1303_REV_NUM_TV0) && + ((otp_stat & 0x0C) == SMA1303_OTP_STAT_OK_1))) dev_info(component->dev, "SMA1303 OTP Status Successful\n"); else dev_info(component->dev, "SMA1303 OTP Status Fail\n"); @@ -1612,8 +1558,6 @@ static void sma1303_remove(struct snd_soc_component *component) static const struct snd_soc_component_driver sma1303_component = { .probe = sma1303_probe, .remove = sma1303_remove, - .suspend = sma1303_suspend, - .resume = sma1303_resume, .controls = sma1303_snd_controls, .num_controls = ARRAY_SIZE(sma1303_snd_controls), .dapm_widgets = sma1303_dapm_widgets, @@ -1722,8 +1666,6 @@ static int sma1303_i2c_probe(struct i2c_client *client, u32 value; unsigned int device_info; - dev_info(&client->dev, "%s is here. Driver version REV018\n", __func__); - sma1303 = devm_kzalloc(&client->dev, sizeof(struct sma1303_priv), GFP_KERNEL); @@ -1737,8 +1679,6 @@ static int sma1303_i2c_probe(struct i2c_client *client, dev_err(&client->dev, "Failed to allocate register map: %d\n", ret); - devm_kfree(&client->dev, sma1303); - return ret; } @@ -1807,14 +1747,14 @@ static int sma1303_i2c_probe(struct i2c_client *client, ret = sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &device_info); - if ((ret != 0) || ((device_info & 0xF8) != DEVICE_ID)) { + if ((ret != 0) || ((device_info & 0xF8) != SMA1303_DEVICE_ID)) { dev_err(&client->dev, "device initialization error (%d 0x%02X)", ret, device_info); } dev_info(&client->dev, "chip version 0x%02X\n", device_info); sma1303->last_over_temp = 0xC0; - sma1303->last_ocp_val = 0x0A; + sma1303->last_ocp_val = 0x08; sma1303->tsdw_cnt = 0; sma1303->init_vol = 0x31; sma1303->cur_vol = sma1303->init_vol; @@ -1826,7 +1766,6 @@ static int sma1303_i2c_probe(struct i2c_client *client, mutex_init(&sma1303->lock); sma1303->check_fault_period = CHECK_PERIOD_TIME; - sma1303->devtype = id->driver_data; sma1303->dev = &client->dev; sma1303->kobj = &client->dev.kobj; @@ -1844,10 +1783,6 @@ static int sma1303_i2c_probe(struct i2c_client *client, if (ret) { dev_err(&client->dev, "Failed to register component"); - snd_soc_unregister_component(&client->dev); - - if (sma1303) - devm_kfree(&client->dev, sma1303); return ret; } @@ -1870,11 +1805,6 @@ static void sma1303_i2c_remove(struct i2c_client *client) (struct sma1303_priv *) i2c_get_clientdata(client); cancel_delayed_work_sync(&sma1303->check_fault_work); - - snd_soc_unregister_component(&client->dev); - - if (sma1303) - devm_kfree(&client->dev, sma1303); } static const struct i2c_device_id sma1303_i2c_id[] = { @@ -1899,25 +1829,7 @@ static struct i2c_driver sma1303_i2c_driver = { .id_table = sma1303_i2c_id, }; -static int __init sma1303_init(void) -{ - int ret; - - ret = i2c_add_driver(&sma1303_i2c_driver); - - if (ret) - pr_err("Failed to register sma1303 I2C driver: %d\n", ret); - - return ret; -} - -static void __exit sma1303_exit(void) -{ - i2c_del_driver(&sma1303_i2c_driver); -} - -module_init(sma1303_init); -module_exit(sma1303_exit); +module_i2c_driver(sma1303_i2c_driver); MODULE_DESCRIPTION("ALSA SoC SMA1303 driver"); MODULE_AUTHOR("Gyuhwa Park, "); diff --git a/sound/soc/codecs/sma1303.h b/sound/soc/codecs/sma1303.h index 95535546fd73..a96c3de28d57 100644 --- a/sound/soc/codecs/sma1303.h +++ b/sound/soc/codecs/sma1303.h @@ -1,11 +1,11 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* * sma1303.h -- sma1303 ALSA SoC Audio driver * - * Copyright 2022 Iron Device Corporation + * Copyright 2023 Iron Device Corporation + * + * Author: Kiseok Jo * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #ifndef _SMA1303_H @@ -113,504 +113,504 @@ void sma1303_set_callback_func(struct callback_ops ops); /* SMA1303 Registers Bit Fields */ /* SYSTEM_CTRL : 0x00 */ -#define RESETBYI2C_MASK (1<<1) -#define RESETBYI2C_NORMAL (0<<1) -#define RESETBYI2C_RESET (1<<1) +#define SMA1303_RESETBYI2C_MASK (1<<1) +#define SMA1303_RESETBYI2C_NORMAL (0<<1) +#define SMA1303_RESETBYI2C_RESET (1<<1) -#define POWER_MASK (1<<0) -#define POWER_OFF (0<<0) -#define POWER_ON (1<<0) +#define SMA1303_POWER_MASK (1<<0) +#define SMA1303_POWER_OFF (0<<0) +#define SMA1303_POWER_ON (1<<0) /* INTPUT CTRL1 : 0x01 */ -#define CONTROLLER_DEVICE_MASK (1<<7) -#define DEVICE_MODE (0<<7) -#define CONTROLLER_MODE (1<<7) - -#define I2S_MODE_MASK (7<<4) -#define STANDARD_I2S (0<<4) -#define LJ (1<<4) -#define RJ_16BIT (4<<4) -#define RJ_18BIT (5<<4) -#define RJ_20BIT (6<<4) -#define RJ_24BIT (7<<4) - -#define LEFTPOL_MASK (1<<3) -#define LOW_FIRST_CH (0<<3) -#define HIGH_FIRST_CH (1<<3) - -#define SCK_RISING_MASK (1<<2) -#define SCK_FALLING_EDGE (0<<2) -#define SCK_RISING_EDGE (1<<2) +#define SMA1303_CONTROLLER_DEVICE_MASK (1<<7) +#define SMA1303_DEVICE_MODE (0<<7) +#define SMA1303_CONTROLLER_MODE (1<<7) + +#define SMA1303_I2S_MODE_MASK (7<<4) +#define SMA1303_STANDARD_I2S (0<<4) +#define SMA1303_LJ (1<<4) +#define SMA1303_RJ_16BIT (4<<4) +#define SMA1303_RJ_18BIT (5<<4) +#define SMA1303_RJ_20BIT (6<<4) +#define SMA1303_RJ_24BIT (7<<4) + +#define SMA1303_LEFTPOL_MASK (1<<3) +#define SMA1303_LOW_FIRST_CH (0<<3) +#define SMA1303_HIGH_FIRST_CH (1<<3) + +#define SMA1303_SCK_RISING_MASK (1<<2) +#define SMA1303_SCK_FALLING_EDGE (0<<2) +#define SMA1303_SCK_RISING_EDGE (1<<2) /* INTPUT CTRL2 : 0x02 */ -#define IMODE_MASK (3<<6) -#define I2S (0<<6) -#define PCM_SHORT (1<<6) -#define PCM_LONG (2<<6) +#define SMA1303_IMODE_MASK (3<<6) +#define SMA1303_I2S (0<<6) +#define SMA1303_PCM_SHORT (1<<6) +#define SMA1303_PCM_LONG (2<<6) -#define RIGHT_FIRST_MASK (1<<5) -#define LEFT_NORMAL (0<<5) -#define RIGHT_INVERTED (1<<5) +#define RSMA1303_IGHT_FIRST_MASK (1<<5) +#define SMA1303_LEFT_NORMAL (0<<5) +#define SMA1303_RIGHT_INVERTED (1<<5) -#define PCM_ALAW_MASK (1<<4) -#define PCM_U_DECODING (0<<4) -#define PCM_A_DECODING (1<<4) +#define SMA1303_PCM_ALAW_MASK (1<<4) +#define SMA1303_PCM_U_DECODING (0<<4) +#define SMA1303_PCM_A_DECODING (1<<4) -#define PCM_COMP_MASK (1<<3) -#define PCM_LINEAR (0<<3) -#define PCM_COMPANDING (1<<3) +#define SMA1303_PCM_COMP_MASK (1<<3) +#define SMA1303_PCM_LINEAR (0<<3) +#define SMA1303_PCM_COMPANDING (1<<3) -#define INPUTSEL_MASK (1<<2) -#define PCM_8KHZ (0<<2) -#define PCM_16KHZ (1<<2) +#define SMA1303_INPUTSEL_MASK (1<<2) +#define SMA1303_PCM_8KHZ (0<<2) +#define SMA1303_PCM_16KHZ (1<<2) -#define PCM_STEREO_MASK (1<<1) -#define PCM_MONO (0<<1) -#define PCM_STEREO (1<<1) +#define SMA1303_PCM_STEREO_MASK (1<<1) +#define SMA1303_PCM_MONO (0<<1) +#define SMA1303_PCM_STEREO (1<<1) -#define PCM_DL_MASK (1<<0) -#define PCM_8BIT (0<<0) -#define PCM_16BIT (1<<0) +#define SMA1303_PCM_DL_MASK (1<<0) +#define SMA1303_PCM_8BIT (0<<0) +#define SMA1303_PCM_16BIT (1<<0) /* INTPUT CTRL3 : 0x03 */ -#define PCM_N_SLOT_MASK (15<<0) -#define PCM_N_SLOT1 (0<<0) -#define PCM_N_SLOT2 (1<<0) -#define PCM_N_SLOT3 (2<<0) -#define PCM_N_SLOT4 (3<<0) -#define PCM_N_SLOT5 (4<<0) -#define PCM_N_SLOT6 (5<<0) -#define PCM_N_SLOT7 (6<<0) -#define PCM_N_SLOT8 (7<<0) -#define PCM_N_SLOT9 (8<<0) -#define PCM_N_SLOT10 (9<<0) -#define PCM_N_SLOT11 (10<<0) -#define PCM_N_SLOT12 (11<<0) -#define PCM_N_SLOT13 (12<<0) -#define PCM_N_SLOT14 (13<<0) -#define PCM_N_SLOT15 (14<<0) -#define PCM_N_SLOT16 (15<<0) +#define SMA1303_PCM_N_SLOT_MASK (15<<0) +#define SMA1303_PCM_N_SLOT1 (0<<0) +#define SMA1303_PCM_N_SLOT2 (1<<0) +#define SMA1303_PCM_N_SLOT3 (2<<0) +#define SMA1303_PCM_N_SLOT4 (3<<0) +#define SMA1303_PCM_N_SLOT5 (4<<0) +#define SMA1303_PCM_N_SLOT6 (5<<0) +#define SMA1303_PCM_N_SLOT7 (6<<0) +#define SMA1303_PCM_N_SLOT8 (7<<0) +#define SMA1303_PCM_N_SLOT9 (8<<0) +#define SMA1303_PCM_N_SLOT10 (9<<0) +#define SMA1303_PCM_N_SLOT11 (10<<0) +#define SMA1303_PCM_N_SLOT12 (11<<0) +#define SMA1303_PCM_N_SLOT13 (12<<0) +#define SMA1303_PCM_N_SLOT14 (13<<0) +#define SMA1303_PCM_N_SLOT15 (14<<0) +#define SMA1303_PCM_N_SLOT16 (15<<0) /* INTPUT CTRL4 : 0x04 */ -#define PCM1_SLOT_MASK (15<<4) -#define PCM1_SLOT1 (0<<4) -#define PCM1_SLOT2 (1<<4) -#define PCM1_SLOT3 (2<<4) -#define PCM1_SLOT4 (3<<4) -#define PCM1_SLOT5 (4<<4) -#define PCM1_SLOT6 (5<<4) -#define PCM1_SLOT7 (6<<4) -#define PCM1_SLOT8 (7<<4) -#define PCM1_SLOT9 (8<<4) -#define PCM1_SLOT10 (9<<4) -#define PCM1_SLOT11 (10<<4) -#define PCM1_SLOT12 (11<<4) -#define PCM1_SLOT13 (12<<4) -#define PCM1_SLOT14 (13<<4) -#define PCM1_SLOT15 (14<<4) -#define PCM1_SLOT16 (15<<4) - -#define PCM2_SLOT_MASK (15<<0) -#define PCM2_SLOT1 (0<<0) -#define PCM2_SLOT2 (1<<0) -#define PCM2_SLOT3 (2<<0) -#define PCM2_SLOT4 (3<<0) -#define PCM2_SLOT5 (4<<0) -#define PCM2_SLOT6 (5<<0) -#define PCM2_SLOT7 (6<<0) -#define PCM2_SLOT8 (7<<0) -#define PCM2_SLOT9 (8<<0) -#define PCM2_SLOT10 (9<<0) -#define PCM2_SLOT11 (10<<0) -#define PCM2_SLOT12 (11<<0) -#define PCM2_SLOT13 (12<<0) -#define PCM2_SLOT14 (13<<0) -#define PCM2_SLOT15 (14<<0) -#define PCM2_SLOT16 (15<<0) +#define SMA1303_PCM1_SLOT_MASK (15<<4) +#define SMA1303_PCM1_SLOT1 (0<<4) +#define SMA1303_PCM1_SLOT2 (1<<4) +#define SMA1303_PCM1_SLOT3 (2<<4) +#define SMA1303_PCM1_SLOT4 (3<<4) +#define SMA1303_PCM1_SLOT5 (4<<4) +#define SMA1303_PCM1_SLOT6 (5<<4) +#define SMA1303_PCM1_SLOT7 (6<<4) +#define SMA1303_PCM1_SLOT8 (7<<4) +#define SMA1303_PCM1_SLOT9 (8<<4) +#define SMA1303_PCM1_SLOT10 (9<<4) +#define SMA1303_PCM1_SLOT11 (10<<4) +#define SMA1303_PCM1_SLOT12 (11<<4) +#define SMA1303_PCM1_SLOT13 (12<<4) +#define SMA1303_PCM1_SLOT14 (13<<4) +#define SMA1303_PCM1_SLOT15 (14<<4) +#define SMA1303_PCM1_SLOT16 (15<<4) + +#define SMA1303_PCM2_SLOT_MASK (15<<0) +#define SMA1303_PCM2_SLOT1 (0<<0) +#define SMA1303_PCM2_SLOT2 (1<<0) +#define SMA1303_PCM2_SLOT3 (2<<0) +#define SMA1303_PCM2_SLOT4 (3<<0) +#define SMA1303_PCM2_SLOT5 (4<<0) +#define SMA1303_PCM2_SLOT6 (5<<0) +#define SMA1303_PCM2_SLOT7 (6<<0) +#define SMA1303_PCM2_SLOT8 (7<<0) +#define SMA1303_PCM2_SLOT9 (8<<0) +#define SMA1303_PCM2_SLOT10 (9<<0) +#define SMA1303_PCM2_SLOT11 (10<<0) +#define SMA1303_PCM2_SLOT12 (11<<0) +#define SMA1303_PCM2_SLOT13 (12<<0) +#define SMA1303_PCM2_SLOT14 (13<<0) +#define SMA1303_PCM2_SLOT15 (14<<0) +#define SMA1303_PCM2_SLOT16 (15<<0) /* OUTPUT CTRL : 0x09 */ -#define PORT_CONFIG_MASK (3<<5) -#define INPUT_PORT_ONLY (0<<5) -#define OUTPUT_PORT_ENABLE (2<<5) +#define SMA1303_PORT_CONFIG_MASK (3<<5) +#define SMA1303_INPUT_PORT_ONLY (0<<5) +#define SMA1303_OUTPUT_PORT_ENABLE (2<<5) -#define PORT_OUT_SEL_MASK (7<<0) -#define OUT_SEL_DISABLE (0<<0) -#define FORMAT_CONVERTER (1<<0) -#define MIXER_OUTPUT (2<<0) -#define SPEAKER_PATH (3<<0) -#define POSTSCALER_OUTPUT (4<<0) +#define SMA1303_PORT_OUT_SEL_MASK (7<<0) +#define SMA1303_OUT_SEL_DISABLE (0<<0) +#define SMA1303_FORMAT_CONVERTER (1<<0) +#define SMA1303_MIXER_OUTPUT (2<<0) +#define SMA1303_SPEAKER_PATH (3<<0) +#define SMA1303_POSTSCALER_OUTPUT (4<<0) /* BST_TEST : 0x0B */ -#define BST_OFF_SLOPE_MASK (3<<6) -#define BST_OFF_SLOPE_6_7ns (0<<6) -#define BST_OFF_SLOPE_4_8ns (1<<6) -#define BST_OFF_SLOPE_2_6ns (2<<6) -#define BST_OFF_SLOPE_1_2ns (3<<6) +#define SMA1303_BST_OFF_SLOPE_MASK (3<<6) +#define SMA1303_BST_OFF_SLOPE_6_7ns (0<<6) +#define SMA1303_BST_OFF_SLOPE_4_8ns (1<<6) +#define SMA1303_BST_OFF_SLOPE_2_6ns (2<<6) +#define SMA1303_BST_OFF_SLOPE_1_2ns (3<<6) -#define OCP_TEST_MASK (1<<5) -#define OCP_NORMAL_MODE (0<<5) -#define OCP_TEST_MODE (1<<5) +#define SMA1303_OCP_TEST_MASK (1<<5) +#define SMA1303_OCP_NORMAL_MODE (0<<5) +#define SMA1303_OCP_TEST_MODE (1<<5) -#define BST_FAST_LEBN_MASK (1<<4) -#define BST_SHORT_LEB (0<<4) -#define BST_LONG_LEB (1<<4) +#define SMA1303_BST_FAST_LEBN_MASK (1<<4) +#define SMA1303_BST_SHORT_LEB (0<<4) +#define SMA1303_BST_LONG_LEB (1<<4) -#define HIGH_PGAIN_MASK (1<<3) -#define NORMAL_P_GAIN (0<<3) -#define HIGH_P_GAIN (1<<3) +#define SMA1303_HIGH_PGAIN_MASK (1<<3) +#define SMA1303_NORMAL_P_GAIN (0<<3) +#define SMA1303_HIGH_P_GAIN (1<<3) -#define VCOMP_MASK (1<<2) -#define VCOMP_NORMAL_MODE (0<<2) -#define VCOMP_V_MON_MODE (1<<2) +#define SMA1303_VCOMP_MASK (1<<2) +#define SMA1303_VCOMP_NORMAL_MODE (0<<2) +#define SMA1303_VCOMP_V_MON_MODE (1<<2) -#define PMOS_ON_MASK (1<<1) -#define PMOS_NORMAL_MODE (0<<1) -#define PMOS_TEST_MODE (1<<1) +#define SMA1303_PMOS_ON_MASK (1<<1) +#define SMA1303_PMOS_NORMAL_MODE (0<<1) +#define SMA1303_PMOS_TEST_MODE (1<<1) -#define NMOS_ON_MASK (1<<0) -#define NMOS_NORMAL_MODE (0<<0) -#define NMOS_TEST_MODE (1<<0) +#define SMA1303_NMOS_ON_MASK (1<<0) +#define SMA1303_NMOS_NORMAL_MODE (0<<0) +#define SMA1303_NMOS_TEST_MODE (1<<0) /* BST_TEST1 : 0x0C */ -#define SET_OCP_H_MASK (3<<6) -#define HIGH_OCP_4_5_LVL (0<<6) -#define HIGH_OCP_3_2_LVL (1<<6) -#define HIGH_OCP_2_1_LVL (2<<6) -#define HIGH_OCP_0_9_LVL (3<<6) +#define SMA1303_SET_OCP_H_MASK (3<<6) +#define SMA1303_HIGH_OCP_4_5_LVL (0<<6) +#define SMA1303_HIGH_OCP_3_2_LVL (1<<6) +#define SMA1303_HIGH_OCP_2_1_LVL (2<<6) +#define SMA1303_HIGH_OCP_0_9_LVL (3<<6) -#define OCL_TEST_MASK (1<<5) -#define OCL_NORMAL_MODE (0<<5) -#define OCL_TEST_MODE (1<<5) +#define SMA1303_OCL_TEST_MASK (1<<5) +#define SMA1303_OCL_NORMAL_MODE (0<<5) +#define SMA1303_OCL_TEST_MODE (1<<5) -#define LOOP_CHECK_MASK (1<<4) -#define BST_LOOP_NORMAL_MODE (0<<4) -#define BST_LOOP_CHECK_MODE (1<<4) +#define SMA1303_LOOP_CHECK_MASK (1<<4) +#define SMA1303_BST_LOOP_NORMAL_MODE (0<<4) +#define SMA1303_BST_LOOP_CHECK_MODE (1<<4) -#define EN_SH_PRT_MASK (1<<3) -#define EN_SH_PRT_DISABLE (0<<3) -#define EN_SH_PRT_ENABLE (1<<3) +#define SMA1303_EN_SH_PRT_MASK (1<<3) +#define SMA1303_EN_SH_PRT_DISABLE (0<<3) +#define SMA1303_EN_SH_PRT_ENABLE (1<<3) /* SPK_TEST : 0x0D */ -#define VREF_MON_MASK (1<<3) -#define VREF_NORMAL_MODE (0<<3) -#define VREF_V_MON_MODE (1<<3) +#define SMA1303_VREF_MON_MASK (1<<3) +#define SMA1303_VREF_NORMAL_MODE (0<<3) +#define SMA1303_VREF_V_MON_MODE (1<<3) -#define SPK_OCP_DLYN_MASK (1<<2) -#define SPK_OCP_LONG_DELAY (0<<2) -#define SPK_OCP_NORMAL (1<<2) +#define SMA1303_SPK_OCP_DLYN_MASK (1<<2) +#define SMA1303_SPK_OCP_LONG_DELAY (0<<2) +#define SMA1303_SPK_OCP_NORMAL (1<<2) -#define SPK_OFF_SLOPE_MASK (3<<0) -#define SPK_OFF_SLOPE_SLOW (0<<0) -#define SPK_OFF_SLOPE_FAST (3<<0) +#define SMA1303_SPK_OFF_SLOPE_MASK (3<<0) +#define SMA1303_SPK_OFF_SLOPE_SLOW (0<<0) +#define SMA1303_SPK_OFF_SLOPE_FAST (3<<0) /* MUTE_VOL_CTRL : 0x0E */ -#define VOL_SLOPE_MASK (3<<6) -#define VOL_SLOPE_OFF (0<<6) -#define VOL_SLOPE_SLOW (1<<6) -#define VOL_SLOPE_MID (2<<6) -#define VOL_SLOPE_FAST (3<<6) - -#define MUTE_SLOPE_MASK (3<<4) -#define MUTE_SLOPE_OFF (0<<4) -#define MUTE_SLOPE_SLOW (1<<4) -#define MUTE_SLOPE_MID (2<<4) -#define MUTE_SLOPE_FAST (3<<4) - -#define SPK_MUTE_MASK (1<<0) -#define SPK_UNMUTE (0<<0) -#define SPK_MUTE (1<<0) +#define SMA1303_VOL_SLOPE_MASK (3<<6) +#define SMA1303_VOL_SLOPE_OFF (0<<6) +#define SMA1303_VOL_SLOPE_SLOW (1<<6) +#define SMA1303_VOL_SLOPE_MID (2<<6) +#define SMA1303_VOL_SLOPE_FAST (3<<6) + +#define SMA1303_MUTE_SLOPE_MASK (3<<4) +#define SMA1303_MUTE_SLOPE_OFF (0<<4) +#define SMA1303_MUTE_SLOPE_SLOW (1<<4) +#define SMA1303_MUTE_SLOPE_MID (2<<4) +#define SMA1303_MUTE_SLOPE_FAST (3<<4) + +#define SMA1303_SPK_MUTE_MASK (1<<0) +#define SMA1303_SPK_UNMUTE (0<<0) +#define SMA1303_SPK_MUTE (1<<0) /* SYSTEM_CTRL1 :0x10 */ -#define SPK_MODE_MASK (7<<2) -#define SPK_OFF (0<<2) -#define SPK_MONO (1<<2) -#define SPK_STEREO (4<<2) +#define SMA1303_SPK_MODE_MASK (7<<2) +#define SMA1303_SPK_OFF (0<<2) +#define SMA1303_SPK_MONO (1<<2) +#define SMA1303_SPK_STEREO (4<<2) /* SYSTEM_CTRL2 : 0x11 */ -#define SPK_BS_MASK (1<<6) -#define SPK_BS_BYP (0<<6) -#define SPK_BS_EN (1<<6) -#define SPK_LIM_MASK (1<<5) -#define SPK_LIM_BYP (0<<5) -#define SPK_LIM_EN (1<<5) +#define SMA1303_SPK_BS_MASK (1<<6) +#define SMA1303_SPK_BS_BYP (0<<6) +#define SMA1303_SPK_BS_EN (1<<6) +#define SMA1303_SPK_LIM_MASK (1<<5) +#define SMA1303_SPK_LIM_BYP (0<<5) +#define SMA1303_SPK_LIM_EN (1<<5) -#define LR_DATA_SW_MASK (1<<4) -#define LR_DATA_SW_NORMAL (0<<4) -#define LR_DATA_SW_SWAP (1<<4) +#define SMA1303_LR_DATA_SW_MASK (1<<4) +#define SMA1303_LR_DATA_SW_NORMAL (0<<4) +#define SMA1303_LR_DATA_SW_SWAP (1<<4) -#define MONOMIX_MASK (1<<0) -#define MONOMIX_OFF (0<<0) -#define MONOMIX_ON (1<<0) +#define SMA1303_MONOMIX_MASK (1<<0) +#define SMA1303_MONOMIX_OFF (0<<0) +#define SMA1303_MONOMIX_ON (1<<0) /* SYSTEM_CTRL3 : 0x12 */ -#define INPUT_MASK (3<<6) -#define INPUT_0_DB (0<<6) -#define INPUT_M6_DB (1<<6) -#define INPUT_M12_DB (2<<6) -#define INPUT_INFI_DB (3<<6) -#define INPUT_R_MASK (3<<4) -#define INPUT_R_0_DB (0<<4) -#define INPUT_R_M6_DB (1<<4) -#define INPUT_R_M12_DB (2<<4) -#define INPUT_R_INFI_DB (3<<4) +#define SMA1303_INPUT_MASK (3<<6) +#define SMA1303_INPUT_0_DB (0<<6) +#define SMA1303_INPUT_M6_DB (1<<6) +#define SMA1303_INPUT_M12_DB (2<<6) +#define SMA1303_INPUT_INFI_DB (3<<6) +#define SMA1303_INPUT_R_MASK (3<<4) +#define SMA1303_INPUT_R_0_DB (0<<4) +#define SMA1303_INPUT_R_M6_DB (1<<4) +#define SMA1303_INPUT_R_M12_DB (2<<4) +#define SMA1303_INPUT_R_INFI_DB (3<<4) /* Modulator : 0x14 */ -#define SPK_HYSFB_MASK (3<<6) -#define HYSFB_625K (0<<6) -#define HYSFB_414K (1<<6) -#define HYSFB_297K (2<<6) -#define HYSFB_226K (3<<6) -#define SPK_BDELAY_MASK (63<<0) +#define SMA1303_SPK_HYSFB_MASK (3<<6) +#define SMA1303_HYSFB_625K (0<<6) +#define SMA1303_HYSFB_414K (1<<6) +#define SMA1303_HYSFB_297K (2<<6) +#define SMA1303_HYSFB_226K (3<<6) +#define SMA1303_SPK_BDELAY_MASK (63<<0) /* SDM CONTROL : 0x33 */ -#define SDM_Q_SEL_MASK (1<<2) -#define QUART_SEL_1_DIV_4 (0<<2) -#define QUART_SEL_1_DIV_8 (1<<2) +#define SMA1303_SDM_Q_SEL_MASK (1<<2) +#define SMA1303_QUART_SEL_1_DIV_4 (0<<2) +#define SMA1303_QUART_SEL_1_DIV_8 (1<<2) /* OTP_DATA1 : 0x34 */ -#define OTP_LVL_MASK (1<<5) -#define OTP_LVL_NORMAL (0<<5) -#define OTP_LVL_LOW (1<<5) +#define SMA1303_OTP_LVL_MASK (1<<5) +#define SMA1303_OTP_LVL_NORMAL (0<<5) +#define SMA1303_OTP_LVL_LOW (1<<5) /* PROTECTION : 0x36 */ -#define EDGE_DIS_MASK (1<<7) -#define EDGE_DIS_ENABLE (0<<7) -#define EDGE_DIS_DISABLE (1<<7) +#define SMA1303_EDGE_DIS_MASK (1<<7) +#define SMA1303_EDGE_DIS_ENABLE (0<<7) +#define SMA1303_EDGE_DIS_DISABLE (1<<7) -#define SPK_OCP_DIS_MASK (1<<3) -#define SPK_OCP_ENABLE (0<<3) -#define SPK_OCP_DISABLE (1<<3) +#define SMA1303_SPK_OCP_DIS_MASK (1<<3) +#define SMA1303_SPK_OCP_ENABLE (0<<3) +#define SMA1303_SPK_OCP_DISABLE (1<<3) -#define OCP_MODE_MASK (1<<2) -#define AUTO_RECOVER (0<<2) -#define SHUT_DOWN_PERMANENT (1<<2) +#define SMA1303_OCP_MODE_MASK (1<<2) +#define SMA1303_AUTO_RECOVER (0<<2) +#define SMA1303_SHUT_DOWN_PERMANENT (1<<2) -#define OTP_MODE_MASK (3<<0) -#define OTP_MODE_DISABLE (0<<0) -#define IG_THR1_SHUT_THR2 (1<<0) -#define REC_THR1_SHUT_THR2 (2<<0) -#define SHUT_THR1_SHUT_THR2 (3<<0) +#define SMA1303_OTP_MODE_MASK (3<<0) +#define SMA1303_OTP_MODE_DISABLE (0<<0) +#define SMA1303_IG_THR1_SHUT_THR2 (1<<0) +#define SMA1303_REC_THR1_SHUT_THR2 (2<<0) +#define SMA1303_SHUT_THR1_SHUT_THR2 (3<<0) /* TEST2 : 0x3C */ -#define SPK_HSDM_BP_MASK (1<<4) -#define SPK_HSDM_ENABLE (0<<4) -#define SPK_HSDM_BYPASS (1<<4) +#define SMA1303_SPK_HSDM_BP_MASK (1<<4) +#define SMA1303_SPK_HSDM_ENABLE (0<<4) +#define SMA1303_SPK_HSDM_BYPASS (1<<4) -#define SDM_SYNC_DIS_MASK (1<<5) -#define SDM_SYNC_NORMAL (0<<5) -#define SDM_SYNC_DISABLE (1<<5) +#define SMA1303_SDM_SYNC_DIS_MASK (1<<5) +#define SMA1303_SDM_SYNC_NORMAL (0<<5) +#define SMA1303_SDM_SYNC_DISABLE (1<<5) /* ATEST2 : 0x3F */ -#define SPK_OUT_FREQ_MASK (1<<2) -#define SPK_OUT_FREQ_360K (0<<2) -#define SPK_OUT_FREQ_410K (1<<2) +#define SMA1303_SPK_OUT_FREQ_MASK (1<<2) +#define SMA1303_SPK_OUT_FREQ_360K (0<<2) +#define SMA1303_SPK_OUT_FREQ_410K (1<<2) -#define LOW_POWER_MODE_MASK (1<<3) -#define LOW_POWER_MODE_DISABLE (0<<3) -#define LOW_POWER_MODE_ENABLE (1<<3) +#define SMA1303_LOW_POWER_MODE_MASK (1<<3) +#define SMA1303_LOW_POWER_MODE_DISABLE (0<<3) +#define SMA1303_LOW_POWER_MODE_ENABLE (1<<3) -#define THERMAL_ADJUST_MASK (3<<5) -#define THERMAL_150_110 (0<<5) -#define THERMAL_160_120 (1<<5) -#define THERMAL_140_100 (2<<5) +#define SMA1303_THERMAL_ADJUST_MASK (3<<5) +#define SMA1303_THERMAL_150_110 (0<<5) +#define SMA1303_THERMAL_160_120 (1<<5) +#define SMA1303_THERMAL_140_100 (2<<5) -#define FAST_OFF_DRIVE_SPK_MASK (1<<0) -#define FAST_OFF_DRIVE_SPK_DISABLE (0<<0) -#define FAST_OFF_DRIVE_SPK_ENABLE (1<<0) +#define SMA1303_FAST_OFF_DRIVE_SPK_MASK (1<<0) +#define SMA1303_FAST_OFF_DRIVE_SPK_DISABLE (0<<0) +#define SMA1303_FAST_OFF_DRIVE_SPK_ENABLE (1<<0) /* PLL_CTRL : 0x8E */ -#define TRM_LVL_MASK (1<<4) -#define TRM_LVL_NORMAL (0<<4) -#define TRM_LVL_LOW (1<<4) +#define SMA1303_TRM_LVL_MASK (1<<4) +#define SMA1303_TRM_LVL_NORMAL (0<<4) +#define SMA1303_TRM_LVL_LOW (1<<4) -#define LOW_OCL_MODE_MASK (1<<3) -#define LOW_OCL_MODE (0<<3) -#define NORMAL_OCL_MODE (1<<3) +#define SMA1303_LOW_OCL_MODE_MASK (1<<3) +#define SMA1303_LOW_OCL_MODE (0<<3) +#define SMA1303_NORMAL_OCL_MODE (1<<3) -#define PLL_PD2_MASK (7<<0) -#define PLL_PD2 (7<<0) -#define PLL_OPERATION2 (0<<0) +#define SMA1303_PLL_PD2_MASK (7<<0) +#define SMA1303_PLL_PD2 (7<<0) +#define SMA1303_PLL_OPERATION2 (0<<0) /* POSTSCALER : 0x90 */ -#define BYP_POST_MASK (1<<0) -#define EN_POST_SCALER (0<<0) -#define BYP_POST_SCALER (1<<0) +#define SMA1303_BYP_POST_MASK (1<<0) +#define SMA1303_EN_POST_SCALER (0<<0) +#define SMA1303_BYP_POST_SCALER (1<<0) /* FDPEC CONTROL : 0x92 */ -#define FLT_VDD_GAIN_MASK (15<<4) -#define FLT_VDD_GAIN_2P40 (0<<4) -#define FLT_VDD_GAIN_2P45 (1<<4) -#define FLT_VDD_GAIN_2P50 (2<<4) -#define FLT_VDD_GAIN_2P55 (3<<4) -#define FLT_VDD_GAIN_2P60 (4<<4) -#define FLT_VDD_GAIN_2P65 (5<<4) -#define FLT_VDD_GAIN_2P70 (6<<4) -#define FLT_VDD_GAIN_2P75 (7<<4) -#define FLT_VDD_GAIN_2P80 (8<<4) -#define FLT_VDD_GAIN_2P85 (9<<4) -#define FLT_VDD_GAIN_2P90 (10<<4) -#define FLT_VDD_GAIN_2P95 (11<<4) -#define FLT_VDD_GAIN_3P00 (12<<4) -#define FLT_VDD_GAIN_3P05 (13<<4) -#define FLT_VDD_GAIN_3P10 (14<<4) -#define FLT_VDD_GAIN_3P15 (15<<4) - -#define DIS_FCHG_MASK (1<<2) -#define EN_FAST_CHARGE (0<<2) -#define DIS_FAST_CHARGE (1<<2) +#define SMA1303_FLT_VDD_GAIN_MASK (15<<4) +#define SMA1303_FLT_VDD_GAIN_2P40 (0<<4) +#define SMA1303_FLT_VDD_GAIN_2P45 (1<<4) +#define SMA1303_FLT_VDD_GAIN_2P50 (2<<4) +#define SMA1303_FLT_VDD_GAIN_2P55 (3<<4) +#define SMA1303_FLT_VDD_GAIN_2P60 (4<<4) +#define SMA1303_FLT_VDD_GAIN_2P65 (5<<4) +#define SMA1303_FLT_VDD_GAIN_2P70 (6<<4) +#define SMA1303_FLT_VDD_GAIN_2P75 (7<<4) +#define SMA1303_FLT_VDD_GAIN_2P80 (8<<4) +#define SMA1303_FLT_VDD_GAIN_2P85 (9<<4) +#define SMA1303_FLT_VDD_GAIN_2P90 (10<<4) +#define SMA1303_FLT_VDD_GAIN_2P95 (11<<4) +#define SMA1303_FLT_VDD_GAIN_3P00 (12<<4) +#define SMA1303_FLT_VDD_GAIN_3P05 (13<<4) +#define SMA1303_FLT_VDD_GAIN_3P10 (14<<4) +#define SMA1303_FLT_VDD_GAIN_3P15 (15<<4) + +#define SMA1303_DIS_FCHG_MASK (1<<2) +#define SMA1303_EN_FAST_CHARGE (0<<2) +#define SMA1303_DIS_FAST_CHARGE (1<<2) /* BOOST_CONTROL4 : 0x97 */ -#define TRM_VBST_MASK (7<<2) -#define TRM_VBST_5P5 (0<<2) -#define TRM_VBST_5P6 (1<<2) -#define TRM_VBST_5P7 (2<<2) -#define TRM_VBST_5P8 (3<<2) -#define TRM_VBST_5P9 (4<<2) -#define TRM_VBST_6P0 (5<<2) -#define TRM_VBST_6P1 (6<<2) -#define TRM_VBST_6P2 (7<<2) +#define SMA1303_TRM_VBST_MASK (7<<2) +#define SMA1303_TRM_VBST_5P5 (0<<2) +#define SMA1303_TRM_VBST_5P6 (1<<2) +#define SMA1303_TRM_VBST_5P7 (2<<2) +#define SMA1303_TRM_VBST_5P8 (3<<2) +#define SMA1303_TRM_VBST_5P9 (4<<2) +#define SMA1303_TRM_VBST_6P0 (5<<2) +#define SMA1303_TRM_VBST_6P1 (6<<2) +#define SMA1303_TRM_VBST_6P2 (7<<2) /* TOP_MAN1 : 0xA2 */ -#define PLL_LOCK_SKIP_MASK (1<<7) -#define PLL_LOCK_ENABLE (0<<7) -#define PLL_LOCK_DISABLE (1<<7) +#define SMA1303_PLL_LOCK_SKIP_MASK (1<<7) +#define SMA1303_PLL_LOCK_ENABLE (0<<7) +#define SMA1303_PLL_LOCK_DISABLE (1<<7) -#define PLL_PD_MASK (1<<6) -#define PLL_OPERATION (0<<6) -#define PLL_PD (1<<6) +#define SMA1303_PLL_PD_MASK (1<<6) +#define SMA1303_PLL_OPERATION (0<<6) +#define SMA1303_PLL_PD (1<<6) -#define PLL_DIV_MASK (3<<4) -#define PLL_OUT (0<<4) -#define PLL_OUT_2 (1<<4) -#define PLL_OUT_4 (2<<4) -#define PLL_OUT_8 (3<<4) +#define SMA1303_PLL_DIV_MASK (3<<4) +#define SMA1303_PLL_OUT (0<<4) +#define SMA1303_PLL_OUT_2 (1<<4) +#define SMA1303_PLL_OUT_4 (2<<4) +#define SMA1303_PLL_OUT_8 (3<<4) -#define PLL_REF_CLK_MASK (1<<3) -#define PLL_REF_CLK1 (0<<3) -#define PLL_SCK (1<<3) +#define SMA1303_PLL_REF_CLK_MASK (1<<3) +#define SMA1303_PLL_REF_CLK1 (0<<3) +#define SMA1303_PLL_SCK (1<<3) -#define DAC_DN_CONV_MASK (1<<2) -#define DAC_DN_CONV_DISABLE (0<<2) -#define DAC_DN_CONV_ENABLE (1<<2) +#define SMA1303_DAC_DN_CONV_MASK (1<<2) +#define SMA1303_DAC_DN_CONV_DISABLE (0<<2) +#define SMA1303_DAC_DN_CONV_ENABLE (1<<2) -#define SDO_IO_MASK (1<<1) -#define HIGH_Z_LRCK_H (0<<1) -#define HIGH_Z_LRCK_L (1<<1) +#define SMA1303_SDO_IO_MASK (1<<1) +#define SMA1303_HIGH_Z_LRCK_H (0<<1) +#define SMA1303_HIGH_Z_LRCK_L (1<<1) -#define SDO_OUTPUT2_MASK (1<<0) -#define SDO_NORMAL (0<<0) -#define SDO_OUTPUT_ONLY (1<<0) +#define SMA1303_SDO_OUTPUT2_MASK (1<<0) +#define SMA1303_SDO_NORMAL (0<<0) +#define SMA1303_SDO_OUTPUT_ONLY (1<<0) /* TOP_MAN2 : 0xA3 */ -#define MON_OSC_PLL_MASK (1<<7) -#define PLL_SDO (0<<7) -#define PLL_OSC (1<<7) +#define SMA1303_MON_OSC_PLL_MASK (1<<7) +#define SMA1303_PLL_SDO (0<<7) +#define SMA1303_OSC_SDO (1<<7) -#define TEST_CLKO_EN_MASK (1<<6) -#define NORMAL_SDO (0<<6) -#define CLK_OUT_SDO (1<<6) +#define SMA1303_TEST_CLKO_EN_MASK (1<<6) +#define SMA1303_NORMAL_SDO (0<<6) +#define SMA1303_CLK_OUT_SDO (1<<6) -#define SDO_OUTPUT_MASK (1<<3) -#define NORMAL_OUT (0<<3) -#define HIGH_Z_OUT (1<<3) +#define SMA1303_SDO_OUTPUT_MASK (1<<3) +#define SMA1303_NORMAL_OUT (0<<3) +#define SMA1303_HIGH_Z_OUT (1<<3) -#define CLOCK_MON_MASK (1<<1) -#define CLOCK_MON (0<<1) -#define CLOCK_NOT_MON (1<<1) +#define SMA1303_CLOCK_MON_MASK (1<<1) +#define SMA1303_CLOCK_MON (0<<1) +#define SMA1303_CLOCK_NOT_MON (1<<1) -#define OSC_PD_MASK (1<<0) -#define NORMAL_OPERATION_OSC (0<<0) -#define POWER_DOWN_OSC (1<<0) +#define SMA1303_OSC_PD_MASK (1<<0) +#define SMA1303_NORMAL_OPERATION_OSC (0<<0) +#define SMA1303_POWER_DOWN_OSC (1<<0) /* TOP_MAN3 0xA4 */ -#define O_FORMAT_MASK (7<<5) -#define O_FMT_LJ (1<<5) -#define O_FMT_I2S (2<<5) -#define O_FMT_TDM (4<<5) +#define SMA1303_O_FORMAT_MASK (7<<5) +#define SMA1303_O_FMT_LJ (1<<5) +#define SMA1303_O_FMT_I2S (2<<5) +#define SMA1303_O_FMT_TDM (4<<5) -#define SCK_RATE_MASK (1<<3) -#define SCK_64FS (0<<3) -#define SCK_32FS (2<<3) +#define SMA1303_SCK_RATE_MASK (1<<3) +#define SMA1303_SCK_64FS (0<<3) +#define SMA1303_SCK_32FS (2<<3) -#define LRCK_POL_MASK (1<<0) -#define L_VALID (0<<0) -#define R_VALID (1<<0) +#define SMA1303_LRCK_POL_MASK (1<<0) +#define SMA1303_L_VALID (0<<0) +#define SMA1303_R_VALID (1<<0) /* TDM1 FORMAT : 0xA5 */ -#define TDM_CLK_POL_MASK (1<<7) -#define TDM_CLK_POL_RISE (0<<7) -#define TDM_CLK_POL_FALL (1<<7) - -#define TDM_TX_MODE_MASK (1<<6) -#define TDM_TX_MONO (0<<6) -#define TDM_TX_STEREO (1<<6) - -#define TDM_SLOT1_RX_POS_MASK (7<<3) -#define TDM_SLOT1_RX_POS_0 (0<<3) -#define TDM_SLOT1_RX_POS_1 (1<<3) -#define TDM_SLOT1_RX_POS_2 (2<<3) -#define TDM_SLOT1_RX_POS_3 (3<<3) -#define TDM_SLOT1_RX_POS_4 (4<<3) -#define TDM_SLOT1_RX_POS_5 (5<<3) -#define TDM_SLOT1_RX_POS_6 (6<<3) -#define TDM_SLOT1_RX_POS_7 (7<<3) - -#define TDM_SLOT2_RX_POS_MASK (7<<0) -#define TDM_SLOT2_RX_POS_0 (0<<0) -#define TDM_SLOT2_RX_POS_1 (1<<0) -#define TDM_SLOT2_RX_POS_2 (2<<0) -#define TDM_SLOT2_RX_POS_3 (3<<0) -#define TDM_SLOT2_RX_POS_4 (4<<0) -#define TDM_SLOT2_RX_POS_5 (5<<0) -#define TDM_SLOT2_RX_POS_6 (6<<0) -#define TDM_SLOT2_RX_POS_7 (7<<0) +#define SMA1303_TDM_CLK_POL_MASK (1<<7) +#define SMA1303_TDM_CLK_POL_RISE (0<<7) +#define SMA1303_TDM_CLK_POL_FALL (1<<7) + +#define SMA1303_TDM_TX_MODE_MASK (1<<6) +#define SMA1303_TDM_TX_MONO (0<<6) +#define SMA1303_TDM_TX_STEREO (1<<6) + +#define SMA1303_TDM_SLOT1_RX_POS_MASK (7<<3) +#define SMA1303_TDM_SLOT1_RX_POS_0 (0<<3) +#define SMA1303_TDM_SLOT1_RX_POS_1 (1<<3) +#define SMA1303_TDM_SLOT1_RX_POS_2 (2<<3) +#define SMA1303_TDM_SLOT1_RX_POS_3 (3<<3) +#define SMA1303_TDM_SLOT1_RX_POS_4 (4<<3) +#define SMA1303_TDM_SLOT1_RX_POS_5 (5<<3) +#define SMA1303_TDM_SLOT1_RX_POS_6 (6<<3) +#define SMA1303_TDM_SLOT1_RX_POS_7 (7<<3) + +#define SMA1303_TDM_SLOT2_RX_POS_MASK (7<<0) +#define SMA1303_TDM_SLOT2_RX_POS_0 (0<<0) +#define SMA1303_TDM_SLOT2_RX_POS_1 (1<<0) +#define SMA1303_TDM_SLOT2_RX_POS_2 (2<<0) +#define SMA1303_TDM_SLOT2_RX_POS_3 (3<<0) +#define SMA1303_TDM_SLOT2_RX_POS_4 (4<<0) +#define SMA1303_TDM_SLOT2_RX_POS_5 (5<<0) +#define SMA1303_TDM_SLOT2_RX_POS_6 (6<<0) +#define SMA1303_TDM_SLOT2_RX_POS_7 (7<<0) /* TDM2 FORMAT : 0xA6 */ -#define TDM_DL_MASK (1<<7) -#define TDM_DL_16 (0<<7) -#define TDM_DL_32 (1<<7) - -#define TDM_N_SLOT_MASK (1<<6) -#define TDM_N_SLOT_4 (0<<6) -#define TDM_N_SLOT_8 (1<<6) - -#define TDM_SLOT1_TX_POS_MASK (7<<3) -#define TDM_SLOT1_TX_POS_0 (0<<3) -#define TDM_SLOT1_TX_POS_1 (1<<3) -#define TDM_SLOT1_TX_POS_2 (2<<3) -#define TDM_SLOT1_TX_POS_3 (3<<3) -#define TDM_SLOT1_TX_POS_4 (4<<3) -#define TDM_SLOT1_TX_POS_5 (5<<3) -#define TDM_SLOT1_TX_POS_6 (6<<3) -#define TDM_SLOT1_TX_POS_7 (7<<3) - -#define TDM_SLOT2_TX_POS_MASK (7<<0) -#define TDM_SLOT2_TX_POS_0 (0<<0) -#define TDM_SLOT2_TX_POS_1 (1<<0) -#define TDM_SLOT2_TX_POS_2 (2<<0) -#define TDM_SLOT2_TX_POS_3 (3<<0) -#define TDM_SLOT2_TX_POS_4 (4<<0) -#define TDM_SLOT2_TX_POS_5 (5<<0) -#define TDM_SLOT2_TX_POS_6 (6<<0) -#define TDM_SLOT2_TX_POS_7 (7<<0) +#define SMA1303_TDM_DL_MASK (1<<7) +#define SMA1303_TDM_DL_16 (0<<7) +#define SMA1303_TDM_DL_32 (1<<7) + +#define SMA1303_TDM_N_SLOT_MASK (1<<6) +#define SMA1303_TDM_N_SLOT_4 (0<<6) +#define SMA1303_TDM_N_SLOT_8 (1<<6) + +#define SMA1303_TDM_SLOT1_TX_POS_MASK (7<<3) +#define SMA1303_TDM_SLOT1_TX_POS_0 (0<<3) +#define SMA1303_TDM_SLOT1_TX_POS_1 (1<<3) +#define SMA1303_TDM_SLOT1_TX_POS_2 (2<<3) +#define SMA1303_TDM_SLOT1_TX_POS_3 (3<<3) +#define SMA1303_TDM_SLOT1_TX_POS_4 (4<<3) +#define SMA1303_TDM_SLOT1_TX_POS_5 (5<<3) +#define SMA1303_TDM_SLOT1_TX_POS_6 (6<<3) +#define SMA1303_TDM_SLOT1_TX_POS_7 (7<<3) + +#define SMA1303_TDM_SLOT2_TX_POS_MASK (7<<0) +#define SMA1303_TDM_SLOT2_TX_POS_0 (0<<0) +#define SMA1303_TDM_SLOT2_TX_POS_1 (1<<0) +#define SMA1303_TDM_SLOT2_TX_POS_2 (2<<0) +#define SMA1303_TDM_SLOT2_TX_POS_3 (3<<0) +#define SMA1303_TDM_SLOT2_TX_POS_4 (4<<0) +#define SMA1303_TDM_SLOT2_TX_POS_5 (5<<0) +#define SMA1303_TDM_SLOT2_TX_POS_6 (6<<0) +#define SMA1303_TDM_SLOT2_TX_POS_7 (7<<0) /* STATUS1 : 0xFA */ -#define OT1_OK_STATUS (1<<7) -#define OT2_OK_STATUS (1<<6) +#define SMA1303_OT1_OK_STATUS (1<<7) +#define SMA1303_OT2_OK_STATUS (1<<6) /* STATUS2 : 0xFB */ -#define OCP_SPK_STATUS (1<<5) -#define OCP_BST_STATUS (1<<4) -#define OTP_STAT_OK_0 (5<<1) -#define OTP_STAT_OK_1 (2<<2) +#define SMA1303_OCP_SPK_STATUS (1<<5) +#define SMA1303_OCP_BST_STATUS (1<<4) +#define SMA1303_OTP_STAT_OK_0 (5<<1) +#define SMA1303_OTP_STAT_OK_1 (2<<2) -#define CLK_MON_STATUS (1<<0) +#define SMA1303_CLK_MON_STATUS (1<<0) /* DEVICE_INFO : 0xFF */ -#define DEVICE_ID (2<<3) -#define UVLO_BST_STATUS (1<<2) -#define REV_NUM_STATUS (3<<0) -#define REV_NUM_TV0 (0<<0) -#define REV_NUM_TV1 (1<<0) +#define SMA1303_DEVICE_ID (2<<3) +#define SMA1303_UVLO_BST_STATUS (1<<2) +#define SMA1303_REV_NUM_STATUS (3<<0) +#define SMA1303_REV_NUM_TV0 (0<<0) +#define SMA1303_REV_NUM_TV1 (1<<0) #endif From patchwork Fri Jan 6 09:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 639709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85F37C3DA7A for ; Fri, 6 Jan 2023 09:18:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9284A14123; Fri, 6 Jan 2023 10:17:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9284A14123 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996705; bh=8hSvwR7F10Dti0GCoev+eDLhFjeJbs/HzoOEtb/QgKA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Wv6VS94IOscpGkslNVvABXy6uV8nmXPUWuOSAU1cgB5wrrRaH7tp7jMR2Bxs+GlRo 1XCsA/W5tJGPYZxIHrA73hf0O0VxJQtX91IzdwYMcS1PIx1YocTwefM+tdPInIuZ9B kloUc4djLTHUTPrfcxh8yy0exY8gfy+q3YN06S7I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B9B99F8058C; Fri, 6 Jan 2023 10:16:13 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C4D34F80551; Fri, 6 Jan 2023 10:16:11 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2040.outbound.protection.outlook.com [40.107.129.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CCF79F80551 for ; Fri, 6 Jan 2023 10:16:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CCF79F80551 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYH9fKbBNEI4WBwKJZRTJGxbNqk1UaELWS33v+/EFhz1tdCL9X847GCGi8OgZlZb7hRFvpy/TGJQDEEtQPBbFzgAI6HGYbDB3VVYWrTRFVAg45X9qZ9jTVl6N6/KTaVA1fPzUNEJQrXzmtPnq+yX7uAVfvrHKG6R+5rYGu5Bfifse8GYCpl7GQtjFx8HpmJyRT3yQ9fbF2/W1ZJuD8QRJCGIDzOVuKW/6d/SE/OK0wuOLmnbikhjtoHY0Nlt0AbwPFx9nd78eCJ0KfBh4myko6/B7rphNjCYBuRRaB/6IUqEcU8kEQsQrZ2fLz/8q2pSC3lSaMp8GHhzi34zqcibLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jdjKX6lbmDe4pHB4cptxTdKwkv08k/VoXzofZnpw+aw=; b=g13KgTlchW5OS8y+tSxHd18mPQdAasvl0OrX+xHtW622r9lspv0NgpAqtGokNRe9vxU7jRZ/VAU1mg3Y6luZSCqxIgtPXtrpoEo81zyrzon0Wz64shKwV9TPC0foCKrw/W0520KE2ZYo8y0GG1HbFp7pBLDlrJJRuSq3SUpzoqfBnzAfCe5KgLIs62tFSlgnd/zL8844M2OCuyZR27E0rbG2+3VVFm4m+XnAFufp1Y4mioCxx65bbdtlctlsGI806PXM/15wSXnrLQiWX/PxzpZjGXVBM8g3wb7GuywVwtsdlaDiJAzUiBcsyJYR1EcQwDX4v3bEHzd5lae8i5ltlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:58 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:58 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 07/14] Remove the control of output format Date: Fri, 6 Jan 2023 18:15:36 +0900 Message-Id: <20230106091543.2440-8-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 6b3e4090-9e58-4216-a996-08daefc69f6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O8MDZv/ZsFWoY8Yq7Qi0jyLjjzF+tgXtvSV0XQ+uXIbBhApbYgJ02oYSi2JHdJdQKr4dNaxabYaXXA5+U3wH2gI+179pAbOwd2xmP3IjpRt3e41HI8kST+aXuzfQEBbMKadraJuqfDVLvZB2PXb0OTCxvdJnrawFp09kJWb92cGeT+0Y7eXZtZJQcU0MRwUtvWlCp66LRxqqGxbPGQZgHZoqOS+Xb4HeVwoFlNOaZliNj+ChsM1f1upkV+KsF3QxxEU2UYkoHBQzl7kvjmkDfd/ZX/HV3fleu5STHM5Y1Aj6aNrYaoDEkTK5RIy2pQikVmQv2Amgh3N5Eno2U/3I+UKpJSIERLYN6HRUcPG9LyYT+UDn5vSpAWMEie/TWX+P2Ald03I4XIs8hK4rRdBJ8PDYdfPsZVg4jBULJlTIlZMucqtskboMZl60sWA7+EDcBjmNl8Cx+wOL/ExjUqbA1lC+vXvqea3uIllFb0EOsRVzjOLxcfKsN2KS6YYdzWarKRgaDHFI/848beBU8KPnD76mXm8XrI1rtPaUmLEaDz27lgsGb8njMjxVpNybNhak4rkMQVkcde8E1htjjUFFH9A76wgB//MOtjuXLom4ZUPUXGvlrYEOvJ1yvrK48OrG5wiiXln+TwskX5rbO6O7I45ig8ZKFXPao8dA7JBpzdq/rebzWuVxMyAGUIbCDunW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xLBQlaIqMi601FRoRUZF72HMUlRU01fRLUQtfi+7KnSjKzC9W0zACmgG7MqmN48G2a8ejQQSF2GP9WlIplz/X7Bp6oSuLk9Brvbfz4LAbHBj3j7odrsC4ykZkNFhya/6BE1mUDiWpPK5CmDWhHdYVip285sxH6idRekWmt+xumuVFfNx5oI7TcyaqGwarf1NO4+HTvdrnM9Pl5z7QPtxUrFNfw8VSx4tKCpk2LL0YdJvW/iOMFgudmz15xm/gSTiKWW77jJKK7+1v9CqHYF5iW1gXdjCAEvX+SToF9qX3bZMXHgLZx2oTbJxWJ8Py9i62T02wDWXzQTIo+7N8ptanKnoI/I+bs4IhdlnYtOczel8latOecm1BwG6N4ul7MM6Zedobvv87j9nDCsP1WdvjiSyeYjvWAowuy+HLM1mfoB/6WZbNUyr4OWTR1LZf4CEwSyTE3hDDJS9OJ+oid03zH25iK/P4E9FWdKoCo1TcQ5FSFPFYAM9RJsVBioynCenMVoA7Pbjt2awQoiOIlnfRP6CKnpMotygGRNyMmG5qC02jydzS5ttn38isB1uYLTa6A+AR7ujJgV5C3//zXFhDPcC+EElI7iu9ZqPWoE9GGClqACvJOu5FhuuGXNMkvtkcnBI6Lia0Ju/Dguxz/sqHwhqPdqP5ixR+dApg4NBvjWwcKdRBV0wYCspN4xuIB+G2Ixqp2ZqBRaZafqmXG/bUT/v4rF1oz/1h4UJ6vjp6q0aBol/ZgrsqrKXELPGvcQSiWGv9LbduBKOYo9wbMkUS2Ie5x4lETkuiPwxWPmKGQy/MCWVs83cSGCvihkGx6TW3Q9z3S3NsV6Zw1UFy48oRZDmWthrHH8OVaaI6ZH2KyMRivBhYV+/pLoU9AASvdsEBiRNQWJmSpv9mRw9xyhXuoipRudVchqbs4OCFkpMrvlTas52yc/2l2k7r+cpQm0oQudOLiMucLd3T0UJThB45xLMfPCHocESU+IDDaRGaV281212Ha2AKwwqz0Db+MP0ZWMcBar1e6mMrU2efY3h82CCGQ5wJ05U5vsxge6MKOJvzwKcR9Po7Xp/FSjKZXi9CLbB9tRgk/DPpC100DY073frjNR2o93kvJHWdifLL/nJAWyewUQjbITorYhkHe/EqzV4/1VMXzeiyPgYTs+UKWo3omTkhhfoH13SurL+7/u3LM7uOe0lnH5yebvimc75LtX4aiHUUOLhJwTy2/iN3VSK4Sv7AWbpqencpykSeuTuUzd1bGFzinS8thyDI2wkyL74MrQ97BQTd9M9s/9PmyGzjUWt1BXwNx7y+YkQF6htOxOnDDYxiKidcWqRrREKQqzcXEV317R7uwktx8ZMmDYcCCigireYYm/ibaP/HHQI+0E1m71uWKhC8/Q9Zx52oSMc8nFr6y1XEI8Tx6XOMhe/euxZ2GLBTsoIuhodo9rK8n2Ec9XD03RJ1VxqgDikW4GDu8LYIDqWJBsj6lSGi1sY78X3IUcoEx88RlBYyPrciH5SAVUMRDN+OhqycckxaGvR4NnKNDVa+hKAGmuMORoPT7zbu23dKu50yS88sgiK6P3YgdGKGc8yLN1DTy0S X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b3e4090-9e58-4216-a996-08daefc69f6a X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:58.8789 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: je5aloetQD0VGwFR22jz8yAQHki0Wj7yOBzONrVSOTCZoCtoHZtANMjqecEiBgr8IBkwERb+s4M06gUf+mhkQ0INayIdjSFppIlA200/DWk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Remove output format like I2S, left justifed. And then it add in hw_params. Signed-off-by: Kiseok Jo Reported-by: Mark Brown --- sound/soc/codecs/sma1303.c | 141 +++++++++++++------------------------ 1 file changed, 48 insertions(+), 93 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 42352fa6de56..1199302af01d 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -432,71 +432,6 @@ static int sma1303_postscaler_config_put(struct snd_kcontrol *kcontrol, SMA1303_90_POSTSCALER, SMA1303_BYP_POST_MASK, val); } -static const char * const sma1303_o_format_text[] = { - "LJ", "I2S", "TDM"}; - -static const struct soc_enum sma1303_o_format_enum = -SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_o_format_text), sma1303_o_format_text); - -static int sma1303_o_format_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int val, data, ret; - - ret = sma1303_regmap_read(sma1303, SMA1303_A4_TOP_MAN3, &data); - val = data & SMA1303_O_FORMAT_MASK; - switch (val) { - case SMA1303_O_FMT_LJ: - ucontrol->value.integer.value[0] = 0; - break; - case SMA1303_O_FMT_I2S: - ucontrol->value.integer.value[0] = 1; - break; - case SMA1303_O_FMT_TDM: - ucontrol->value.integer.value[0] = 2; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x\n", - SMA1303_A4_TOP_MAN3); - return -EINVAL; - } - - return ret; -} -static int sma1303_o_format_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int sel = (int)ucontrol->value.integer.value[0]; - int val; - - switch (sel) { - case 0: - val = SMA1303_O_FMT_LJ; - break; - case 1: - val = SMA1303_O_FMT_I2S; - break; - case 2: - val = SMA1303_O_FMT_TDM; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x\n", - SMA1303_A4_TOP_MAN3); - return -EINVAL; - } - - return sma1303_regmap_update_bits(sma1303, - SMA1303_A4_TOP_MAN3, SMA1303_O_FORMAT_MASK, val); -} - static const char * const sma1303_aif_in_source_text[] = { "Mono", "Left", "Right"}; static const char * const sma1303_aif_out_source_text[] = { @@ -815,8 +750,6 @@ SND_SOC_BYTES_EXT("Postscaler Set", 1, postscaler_get, postscaler_put), SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum, sma1303_postscaler_config_get, sma1303_postscaler_config_put), -SOC_ENUM_EXT("Output Format", sma1303_o_format_enum, - sma1303_o_format_get, sma1303_o_format_put), }; static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = { @@ -930,7 +863,6 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - unsigned int input_format = 0; unsigned int bclk = 0; int ret = 0; @@ -1041,35 +973,61 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, } } - switch (params_width(params)) { - case 16: - switch (sma1303->format) { - case SND_SOC_DAIFMT_I2S: - input_format |= SMA1303_STANDARD_I2S; - break; - case SND_SOC_DAIFMT_LEFT_J: - input_format |= SMA1303_LJ; + switch (sma1303->format) { + case SND_SOC_DAIFMT_I2S: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_01_INPUT1_CTRL1, + SMA1303_I2S_MODE_MASK, + SMA1303_STANDARD_I2S); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A4_TOP_MAN3, + SMA1303_O_FORMAT_MASK, + SMA1303_O_FMT_I2S); + break; + case SND_SOC_DAIFMT_LEFT_J: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_01_INPUT1_CTRL1, + SMA1303_I2S_MODE_MASK, + SMA1303_LJ); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A4_TOP_MAN3, + SMA1303_O_FORMAT_MASK, + SMA1303_O_FMT_LJ); + break; + case SND_SOC_DAIFMT_RIGHT_J: + switch (params_width(params)) { + case 16: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_01_INPUT1_CTRL1, + SMA1303_I2S_MODE_MASK, + SMA1303_RJ_16BIT); break; - case SND_SOC_DAIFMT_RIGHT_J: - input_format |= SMA1303_RJ_16BIT; + case 24: + case 32: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_01_INPUT1_CTRL1, + SMA1303_I2S_MODE_MASK, + SMA1303_RJ_24BIT); break; } break; + case SND_SOC_DAIFMT_DSP_A: + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_01_INPUT1_CTRL1, + SMA1303_I2S_MODE_MASK, + SMA1303_STANDARD_I2S); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_A4_TOP_MAN3, + SMA1303_O_FORMAT_MASK, + SMA1303_O_FMT_TDM); + break; + } + + switch (params_width(params)) { + case 16: case 24: case 32: - switch (sma1303->format) { - case SND_SOC_DAIFMT_I2S: - input_format |= SMA1303_STANDARD_I2S; - break; - case SND_SOC_DAIFMT_LEFT_J: - input_format |= SMA1303_LJ; - break; - case SND_SOC_DAIFMT_RIGHT_J: - input_format |= SMA1303_RJ_24BIT; - break; - } break; - default: dev_err(component->dev, "%s not support data bit : %d\n", __func__, @@ -1077,9 +1035,6 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, return -EINVAL; } - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_01_INPUT1_CTRL1, - SMA1303_I2S_MODE_MASK, input_format); return ret; } From patchwork Fri Jan 6 09:15:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 640107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88D02C5479D for ; Fri, 6 Jan 2023 09:18:39 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 67C03D974; Fri, 6 Jan 2023 10:17:47 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 67C03D974 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996717; bh=aFw+YKT94yCYAfiQ0D8+Tr1Z3D0P8PQy1C+3t4w1JFU=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=bDyEYq0lOxsB5Avr/i2uPAgGVbCWQU/rp+AL5DVTjkAWc2kr4jY0+b+GhbugGZjBl DeFk4jvShnBsVsDzhKgNEbOXhuzhw8Qb8hQVVBoH5AsF+FccsYE/gN7p+nbfqejNRj HcR2Q/YQD1yTkS2hmm15bhQZxK+A+OMjdMaqvAEo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D9191F805A1; Fri, 6 Jan 2023 10:16:14 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A7D0AF8057C; Fri, 6 Jan 2023 10:16:12 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2040.outbound.protection.outlook.com [40.107.129.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BDF3AF8056F for ; Fri, 6 Jan 2023 10:16:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BDF3AF8056F ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cBQapV043C2mJs4k5ayE0ENmweF+OL3sCnACaNtrOk4QmvrwRiPx/gK7/65qjiDkL/yWt10SBSkc1U4z4qTQU73AGLJ23EoFuTwKMZOY3BhmYr7JKxYYb5ktE9cle3zWytLnVgmL/rzCuxEPNMmvHI8306K32heN3hbTBG3crT65s0rWuBOW56UoL2Gqkk+xqu7n+ZA/7mPUw6MmQiitgOM2Cj0bKQ/MP7aNcmlIt656utATloIQU6T4biz5gtNJq9JSLdSMoqXhqi3h4MWJsl+80SqFlYXCr54LXjPlxw/UAcaNp2tkWeoRl/DPuge/BTEobBYIWSdz5TEBmU7Q8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TtU6VxcEUvysZz3K2uE5WibOhxzRXuV+DiAEyEB5mxE=; b=UD9AeTOBPf8JFXd3HgbeGOVvFO9wILhp5ZMCWFqG4QsDebT732Occe3TYZBHcCoWayAZwjD8EIvOR1/kHKOkyOf/TfIt1juO27lV3JCQp1huYHM8qivBsHxfFTlvXut6MQ6j/DSpHDmY9xNVioPHDru5L+fOBvSWE4EFR3bnQvKohWHQcS8Q5iQBZANDGbEJv7bwnLG4bHr4dOZjtq9zMrDy78VktlEJ4xFeHuErwad/hhhXC99+xd/gJgom4VGrpYyBA1dwmZpBN2qzTOiI8sOJy7hHttAkf39czMD/+h1PVuOmQfT/urJX4u1zPyGhbugl9v3Uo5DHldHeLVvN9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:15:59 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:15:59 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 08/14] Remove the mute control Date: Fri, 6 Jan 2023 18:15:37 +0900 Message-Id: <20230106091543.2440-9-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: c9da9cbc-8392-4b2f-53cf-08daefc69fd8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SHjHgYB39SFpscJzsK48zLwJw300+kDRiY3gF0UxZE6lJd6p0Sgeun6KoibMEoibTsi0StzWc7PZQDhtC3Tx5/sKgB8niGwXkCdXovvyI5pw5G2+SV/WAnfa8dqZnp4ajd8+D0HC9NPng1L76tpSC0IYaQZBx8nDC7Lk+g4TH9kNdo9K0Vx+KDBhlwJOzJSSPZPgk4o5EBWsuQQ657hkr8Wc7by5OMEjWjK5HOjovtJ29ZExu8xbjbxXpUekYTPfA0I9CDeCFF7wniyhYu/T0ptJgmYqScsG7GuAy7NDn4AbLT6eTx1d0nJI6KFEPPbT2yo493YqSn9N0n6sSEPFQBpWEjy9mL8ybOIYTNxWnifjJ3H2woro7zjFGExiUw2f0LHwLLVKXXhkYEVh2MP8yD/q/3/lcT50rm+a/kkaXte9tqKMSATkpOxRr0uiXHZ29sOcDOr/jhmwZPxOJuRIm9lJ+D6wwmtT7Y1ldpPtKq2ZJoQcFYfUnplzkozZw8p+Q6zlN2udMCB+I35wRxk51irHKSP/Nqr+d6KubWLdLxA/IXmbdE4vOz7tLu9P7I0TZMFvdVCAlH9Xxe8iG5LVlkvc4iseRUBcqMwae6ZsjarAbSUPAZhGKXpr76BY+NujXacGc0Tw1np9gESCAANkS5R8ZuKZzmEtfysq1geQWQM9gBOQkeflKtKEEIpqn3P8xD3+qmEgKnz3sLe1ddQnvA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bI2+UFf+a/P74PY+429AnPTzsgh31RMp6AZ4Oi5KrM9V+jyVK3V/QAMixY0p7AYU1RxKNFzNqE5/gkVEO3mqlF10LoL66nEw+owA4dpcyHVQAyPDIrHvUMEfnohGghgdGWD0eO5fv642dGR/ZRcKVcn87Uv4H7rGKuqJw4E7nfT9wHJHcHR+oRAHZV4qis5dzCJ9BznyROvljM0KF1I+KcyAv7YBMoIEM2d3TejR6eYFUVeIQ8g4e8xMLPJTbQSdkdu8g9LfxLv0E47yu4SuHmo22dc50g4bVQRfs7/izbADBsrwyc9aVmcvhsdy551Mlf6vvi1IHU1fIGKM5nDVNw2y6xTFe6jezlycj5o5Pjoedl3dwXaw3vm+bsYJMON5vkYtI/EksGPa6z3IV53V9daqJIMtMvP28c8pd5c8/Bfq6I5/rKCSngbwPqstswxo+esJMiaEQhaueQgDldLdWUBzj/Y53j84Yk9Hd45Nr/z02njnxh3Wfv7v6gfQed8gwhESCT0rjmYZHQE0lKaFhvQuYEp1S5a2lAKwq6DG6C8zGpMcIgNGRPLYhcs9VPrwGjQdjICn7Jhv89uzgkW0xPoEw6jbfGBBC9uZAmzGTLjIlBqSXxzRxWU4o3ma2TmhPaX9wvY0x8qQ5rOr1UTAplY7iA60T7GNd8hlCaKGD1dJ6P3avB2RwpytNbehVmm83/Ed02Xzssvv7M5AYbH8M9WM0H5itAdEpBKzpNusfeoU545651U6gXwYE9m5FkV362Od9pCelqjS1HtYW3fqHE/2yAGzjXMjosiqnAJL9A3M9eNNzdVnHfWcloeHf8WkwKtbR7+f6TyslaDKYJ0vMgqzxzeJ1o8BkiEEOMZpbGL5/vgm3yKocGVvVwTF/AwcRQEUF/sEVuwfQrHAdyGPRVzAAgW0+rfWZ2YMjHv1+fLcFHdPVKz/CZxa4aHeQJ9dqBPsToU13j/Rk5uH2EHt9Qf+w61A5dXEzy78uhIb1CWA5g1EpCD8mo7ASIZ44R5iRChmDRIlBV9S9MenwM6njpoty9+orLINj5U5tOsPx5MEbytukvsJnxa1Ey1ZFbT0/KJLS4Pu1r+0BbiErkOjNJCbamYJAhB09cqSAVNJkpTtCZIgZmR1OlrwN8xNGtSYxepljyefE3neKcHJ7KgCxqtuki2+02TXGlWeOrPMBzNZ15EKjtolSbmRqiVX8///BuMl4270heh3L630rhUJLIAXuUeXS73wfvyd91JbFkquMLT9EHjWM303V8UZ818QMdx8YFMZUUotR5t3BsozltejmbJp+ceOg0eudf8pPKnmLbZoc0UkJ37VNof3htrPkr6rl6WgjvfGTAmbe4ZxNNHWxlk+D1IFbEq9EbsmRbfDU7cSIg1lOukFtKz2yDvgpo+r5x8k9tm5xDFJw/AZXRQZT+Qs8BSsu+jDQyDUhLDBnB8HvO5UZr3PLbF4daTTqHC2Rc9cuUIXsA3zZ3u7DZ9fuhSzuFgNzNRYq8Gx6JiULXnXfyo+YkjFEWa1Gmxd7n9drGEZGF2+Zrt6scv97AAVQ46yBCD3KWiqNxiStb9P2YA5w9NKDUC1Z8h2GBHu X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9da9cbc-8392-4b2f-53cf-08daefc69fd8 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:59.4726 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: raYFJqCHUyGGNSqjuYbbWggzwq32GSOi5agClMiRU1f7SxXo1SsYy2XYqa+MfQIYj2Op8Q2B9XWHtrOEcxNi13qGJujHd2gR9W0bWbcWW2k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Remove the mute control and add the force mute control instead. Already used the dai mute_stream. Signed-off-by: Kiseok Jo --- sound/soc/codecs/sma1303.c | 72 +++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 1199302af01d..3a60927e20aa 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -68,6 +68,7 @@ struct sma1303_priv { struct regmap *regmap; struct sma1303_pll_match *pll_matches; bool amp_power_status; + bool force_mute_status; int num_of_pll_matches; int retry_cnt; unsigned int amp_mode; @@ -351,14 +352,6 @@ static int bytes_ext_put(struct snd_kcontrol *kcontrol, return 0; } -static const char * const sma1303_spkmute_text[] = { - "Unmute", "Mute"}; - -static const struct soc_enum sma1303_spkmute_enum = - SOC_ENUM_SINGLE(SMA1303_0E_MUTE_VOL_CTRL, 0, - ARRAY_SIZE(sma1303_spkmute_text), - sma1303_spkmute_text); - static int postscaler_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -445,6 +438,34 @@ static const struct soc_enum sma1303_aif_out_source_enum = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_aif_out_source_text), sma1303_aif_out_source_text); +static int sma1303_force_mute_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = (int)sma1303->force_mute_status; + dev_info(sma1303->dev, "%s : Force Mute %s\n", __func__, + sma1303->force_mute_status ? "ON" : "OFF"); + + return 0; +} + +static int sma1303_force_mute_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + + sma1303->force_mute_status = (bool)ucontrol->value.integer.value[0]; + dev_info(sma1303->dev, "%s : Force Mute %s\n", __func__, + sma1303->force_mute_status ? "ON" : "OFF"); + + return 0; +} + static int sma1303_startup(struct snd_soc_component *component) { struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); @@ -484,9 +505,6 @@ static int sma1303_startup(struct snd_soc_component *component) CHECK_PERIOD_TIME * HZ); } - ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, - SMA1303_SPK_MUTE_MASK, SMA1303_SPK_UNMUTE); - sma1303->amp_power_status = true; return ret; @@ -503,9 +521,6 @@ static int sma1303_shutdown(struct snd_soc_component *component) return ret; } - ret += sma1303_regmap_update_bits(sma1303, SMA1303_0E_MUTE_VOL_CTRL, - SMA1303_SPK_MUTE_MASK, SMA1303_SPK_MUTE); - cancel_delayed_work_sync(&sma1303->check_fault_work); msleep(55); @@ -743,13 +758,14 @@ static const struct snd_kcontrol_new sma1303_enable_control = SOC_DAPM_SINGLE_VIRT("Switch", 1); static const struct snd_kcontrol_new sma1303_snd_controls[] = { -SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL, + SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL, 0, 167, 1, sma1303_spk_tlv), -SOC_ENUM("Speaker Mute Switch", sma1303_spkmute_enum), -SND_SOC_BYTES_EXT("Postscaler Set", 1, + SND_SOC_BYTES_EXT("Postscaler Set", 1, postscaler_get, postscaler_put), -SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum, - sma1303_postscaler_config_get, sma1303_postscaler_config_put), + SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum, + sma1303_postscaler_config_get, sma1303_postscaler_config_put), + SOC_SINGLE_BOOL_EXT("Force Mute", 0, + sma1303_force_mute_get, sma1303_force_mute_put), }; static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = { @@ -1084,12 +1100,17 @@ static int sma1303_dai_mute(struct snd_soc_dai *dai, int mute, int stream) SMA1303_SPK_MUTE_MASK, SMA1303_SPK_MUTE); } else { - dev_info(component->dev, "%s : %s\n", __func__, "UNMUTE"); - - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_0E_MUTE_VOL_CTRL, - SMA1303_SPK_MUTE_MASK, - SMA1303_SPK_UNMUTE); + if (!sma1303->force_mute_status) { + dev_info(component->dev, "%s : %s\n", + __func__, "UNMUTE"); + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_0E_MUTE_VOL_CTRL, + SMA1303_SPK_MUTE_MASK, + SMA1303_SPK_UNMUTE); + } else { + dev_info(sma1303->dev, + "%s : FORCE MUTE!!!\n", __func__); + } } return ret; @@ -1728,6 +1749,7 @@ static int sma1303_i2c_probe(struct i2c_client *client, sma1303->amp_mode = SMA1303_MONO; sma1303->amp_power_status = false; + sma1303->force_mute_status = false; sma1303->check_fault_status = true; sma1303->pll_matches = sma1303_pll_matches; sma1303->num_of_pll_matches = From patchwork Fri Jan 6 09:15:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 639708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31392C3DA7A for ; Fri, 6 Jan 2023 09:19:00 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0F0A4730E; Fri, 6 Jan 2023 10:18:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0F0A4730E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996738; bh=DeeAFtXmDT+8oA7kUEV6ABe2auFL5wHwJT7VXp5Ch+k=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Ggly6n8Dkq/gNuPgD6atb0MwrG2l4soe/ufiFHBy6MnFuVHkOeQELYcm5Pc1+Qs9x Lx4otYDK8yz/fjnPH4gOFfi//LWiXcpmtFqu9B9wMbabR5oc1xLlENy+qJ0Zgdcv1a ntKUC5BRP/+zcgB4+fyPN4xI/1JfaK33RZuDSipg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ADE8FF805AD; Fri, 6 Jan 2023 10:16:16 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4FCE1F805A1; Fri, 6 Jan 2023 10:16:14 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2040.outbound.protection.outlook.com [40.107.129.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 5D490F8057F for ; Fri, 6 Jan 2023 10:16:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5D490F8057F ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MLp8ZkHgy2VjUAK2T4OLKdHJ24AFXbu6HDSTZvYX6GrdkiomyzCwIQT4DX/ufBBMOuGnoNIxS2uKETF7SRVeh1pr0FvmfdXj4FPCeitrm4BX2jAJQXvoufGppDTzxllKib7L05XfZeq3U+DsGgJqRGMyLiE0bctuv2W8veLALYgFT3YftZdxbwdKzXmmDEpeDntq19yUOuJwsESZgXo/5z/4dvWnYDsJ0fMcNyu2AuGOX4Y0LJyGtIac3doBbQ+nNwK190zamS/UWtPSh6znjaPzqic8cZalxHsj1l7kt+5iiFxI311cClPuNrHmD0yBfP2Y3Lc83xK/78lya0d8jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cfbqfqzrEtFV+lNjacckbF+nKmj6LXEuD2IPrrMdZWw=; b=UqZJBc49YoRKWFq72EPDgiaC2AElaJQeRw2MPlAaE9v+fwUZruCICm3CYPWsz2oK0pMfTK7H8f7CQQebz8lbN0ii25R+8Vjbn93rlmRVtsloquJecrJnp4Vrm8wO0Mc0mXnrP8yy93tNY6c3oLKv1lLSVy9Y/obn/Qv4gaTeBgXkLeIthmz12SbPnisUo5MkbztaLu3z2fbycbX0ZeyF/Nv/rVnHE6Hgy/oKQ1cvBYoMBgt9bXn2tEXr69/rKF59S6RBNGjNv+Vt1+EAbLogR9K21oiielWUlH5HT56PVOo1s3yJ44pVy8VYhm3a2rbWDV7i//iXBgNsS1bX/942Wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:16:00 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:16:00 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 09/14] Add the prefix for component controls Date: Fri, 6 Jan 2023 18:15:38 +0900 Message-Id: <20230106091543.2440-10-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: dbc9faa0-a1c4-43ea-c4b2-08daefc6a02b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gn7R6IPANU7PFOaSkJY6tm21DgxEQ+64CNUog5F3YYitzCjvPNVEUiZrSyaa+SO5abx+SSe4CYh5gQL691LmKYl2GiCduXFubV6HxtWfLYeHs0EJ9GoH+zkg5/vKCSA+kiXcaa2MXhZYxbNZM0WS39yG00aULhm1iyjDDCvIp2ZRSDrXHbxYzCZcHW3a6uYyrqYHqHiFROc1A41hoPHwC5LWfcqRqt1bDB/Xcxy+SjzUS/O9OOCljYLkjZiR3wHqN7qTHN4EDuS9JyZJQisqk1oyOoPq5aSvPDgJ+NeoUWfcaXGpAk4CzWZKkYPo3QBCNOnyifmmxPKTGf1Z+k3khpxHfmdQvQHhayWK/QpSZCU9nFzLpIz6k7+POOO+6W+TQygyUYmLFuJ9uAk6au8OSisJekJX0lpk8xorzgc30iZ64ZZafyK8jHQjZMsv6jzd8uJRigXoqXUbeFDUrH5S3Us+ikW292BP4x+T49Kj0jzo6Z2PgLgB/lu4IKFu4oUxAC0W2Oxw87ZGFOr+sXWtr318GjdEwARHmT4XpVKRKhUCh/WKrPkSdMb8yqAmib9lZpH29Xhwmw/DyieHOxRlqhOH5wDi9NQBfMlmfDBMb7iHly0poSTfCrS7lWBgCW82PVvJOVm+gEUyOY408H+l/0OZB7XrAFzV62QLW0QN6Ux1UxmbhswZpxDEpDg8Arg4ifo9kZit1EhHoShwDaEVfg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(54906003)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lzZxtqtzk6o+1+2q1OW8ehiQNuufUNa2pswfY2ed5o8eluKxCJpjRQpW8Ca/sVAVOyfgwnQ43vycWdqHZ7XOSksvLc4kzQyvFHRfLqqzsqLSjIZLsl+zaIxm6YGFKa15eglwcXh8pfKJTFGbC0MAKufq89A1Tc8Wu1m5aYdFZUh37KHMfn5pJRL0sxAvTg7s4KGuITxa9ht09t3KCCWNIhT5+B1ZFqWIXMYw/FzpjnpuSjvXULD+1xR2pSL4Bza0s/SMqMu39l8+8DU0TJAbpcQkZmJgXvJldcWC0A6h5ay8TeAEjOUtFCqfp4WtmNtFnJ/kE3fehyHBvBKV1w8ICauip6FMPI7Zz4hmQFKupNLdXpjnq+eaoD2c6EZbm69pDik6tJqkvOjjVvP+755kPLgoB4Bkvx0W2j2m9toEuEQFTvRha4A8ejUyI7HndtVSThPo020tj6gWPHOCSHD0tZqxRq9u6fuDFgzQyXpiQD147kTeUW51U9Z2TrNt4jqE1BJh7hViZbVhFgn8JEDCWfcD5BlvguDWFgyo7wZVrtCgZoojJPUdA0niWrGp4w9mWfROK03FY2Jve3QyrE4B2O5/3RFkOhSO06TieE8CFhv9oKSXv0zp1nOAaCUmY+oQQiJ9U8iTs5KPF+yUAQT+tXrm+xnKnsRT0omAERGcH6JLtzpFwI9RHz6VMNuAzxJZlolg8kd4Qi3eZY/tTUl5gKWC15m5ZaUVNB9ExrYJsqwjFKQ5EheC34GauX5p1lmSKB2vtOsT7V0Nmd2V34EWnekN9NibOV9Q87sdixHQm3/96XZ5yD+1qkitE9YAdYyrGPjUCfWtRtbEThtfC6E++IsAa7qvxKt+n4oMZV34Mr3yIRKcPNgudeuFZU/L2YIg7EmGt6a3K/OnI6TzbgHWjyC9iir3OZ8Y48pFTHS51rTIE2VptS4AIICUxXbmLvSDH3ePwBQODikLXlnP1m1vI6Irsv4qQli5o/suZo8mvzvsfJ6ItfjdtH/VZveqTt+057OUWbF5wjB50AZ5KkUVZKzsuU4UDebogC0DMhe7Un7Q9fb3F7+Qp+27C/B6FkscGBJNVx/TdGdj+EeYBIXpmjbFWmhugpgKWWUiNq/IEQKOdusuks4hRFalJxTlyACwO5VcYKDGlvvtclBRI9i0oeRBwNzAt1ESOYNmzoUAx/cSGTjs7OyjUTM0GeLX8UlqbpqtYIXzeLnRJNp/auNKQCnfFwB+M87VXU3qeg/DHVHsmHig8r335qANnropDrhxwrKSkx1qUhayJr44opOzfJCJAqWkH9fYkpn2JHl/+lyoCXbVxhDYDoi7dcZoxKCOlgQMwH29zT0EFMu9hUgv0+1I0egp3XMrSmJWo7rEpWCudQpukaSVOIkDojO3SkdYNZiRGtVICvVGbHq9ZTQHVPKq72JFuX4qIZFY1llJ3ycgVCBYoTRqbk4a4wA+X79OR8jICj8CZjaZW9naXfpNQk26ATzfbZZKjT6czx8hGozSRmiZyPBR3AlAg7wJ/b1KHDYERCK6Eo8ZRpCzNhyMKjolWONbjuP4eO6Rs7fDWj5BkPx8X1c1uPpV77Tvcqi4 X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: dbc9faa0-a1c4-43ea-c4b2-08daefc6a02b X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:15:59.9726 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uhQYtZX7il5T83BT1qLFT4Ao2kXFB77Nmeth5iZRItDtNmNDfVyH6RreLDSuKjgPzDyCO01MBaSQGyKue9c7JkMGT2MM+n6/W9V61nNpk5Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo , kernel test robot Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add the device name on prefix for component controls. Signed-off-by: Kiseok Jo Reported-by: kernel test robot --- sound/soc/codecs/sma1303.c | 79 ++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 3a60927e20aa..1991c8d21ba3 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -29,6 +29,7 @@ #include "sma1303.h" #define CHECK_PERIOD_TIME 1 /* sec per HZ */ +#define MAX_CONTROL_NAME 48 #define PLL_MATCH(_input_clk_name, _output_clk_name, _input_clk,\ _post_n, _n, _vco, _p_cp)\ @@ -88,6 +89,8 @@ struct sma1303_priv { long check_fault_status; }; +static struct snd_kcontrol_new *sma1303_controls; + static struct sma1303_pll_match sma1303_pll_matches[] = { PLL_MATCH("1.411MHz", "24.595MHz", 1411200, 0x07, 0xF4, 0x8B, 0x03), PLL_MATCH("1.536MHz", "24.576MHz", 1536000, 0x07, 0xE0, 0x8B, 0x03), @@ -825,6 +828,47 @@ static const struct snd_soc_dapm_route sma1303_audio_map[] = { {"AIF OUT", NULL, "AMP Enable"}, }; +static int sma1303_add_component_controls(struct snd_soc_component *component) +{ + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + unsigned char **name; + int index, ret = 0, size, apply = 0; + + sma1303_controls = devm_kzalloc(sma1303->dev, + sizeof(sma1303_snd_controls), GFP_KERNEL); + name = devm_kzalloc(sma1303->dev, + ARRAY_SIZE(sma1303_snd_controls), GFP_KERNEL); + + for (index = 0; index < ARRAY_SIZE(sma1303_snd_controls); index++) { + sma1303_controls[index] = sma1303_snd_controls[index]; + name[index] = devm_kzalloc(sma1303->dev, + MAX_CONTROL_NAME, GFP_KERNEL); + size = strlen(sma1303_snd_controls[index].name) + + strlen(sma1303->dev->driver->name); + if (!name[index] || size > MAX_CONTROL_NAME) { + sma1303_controls[index].name = + sma1303_snd_controls[index].name; + } else { + scnprintf(name[index], MAX_CONTROL_NAME, "%s %s", + sma1303->dev->driver->name, + sma1303_snd_controls[index].name); + sma1303_controls[index].name = name[index]; + apply++; + } + } + + ret = snd_soc_add_component_controls(component, + sma1303_controls, ARRAY_SIZE(sma1303_snd_controls)); + + dev_info(sma1303->dev, + "%s : prefix=\"%s\", total_num=%d, apply_num=%d\n", + __func__, sma1303->dev->driver->name, + (int)ARRAY_SIZE(sma1303_snd_controls), apply); + + return ret; + +} + static int sma1303_setup_pll(struct snd_soc_component *component, unsigned int bclk) { @@ -1443,39 +1487,10 @@ static int sma1303_probe(struct snd_soc_component *component) struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - char *dapm_widget_str = NULL; - int prefix_len = 0, str_max = 30, ret = 0, i = 0; + int ret = 0, i = 0; unsigned int status, otp_stat; - if (component->name_prefix != NULL) { - dev_info(component->dev, "%s : component name prefix - %s\n", - __func__, component->name_prefix); - - prefix_len = strlen(component->name_prefix); - dapm_widget_str = kzalloc(prefix_len + str_max, GFP_KERNEL); - - if (!dapm_widget_str) { - kfree(dapm_widget_str); - return -ENOMEM; - } - - strcpy(dapm_widget_str, component->name_prefix); - strcat(dapm_widget_str, " Playback"); - - snd_soc_dapm_ignore_suspend(dapm, dapm_widget_str); - - memset(dapm_widget_str + prefix_len, 0, str_max); - - strcpy(dapm_widget_str, component->name_prefix); - strcat(dapm_widget_str, " SPK"); - - snd_soc_dapm_ignore_suspend(dapm, dapm_widget_str); - - kfree(dapm_widget_str); - } else { - snd_soc_dapm_ignore_suspend(dapm, "Playback"); - snd_soc_dapm_ignore_suspend(dapm, "SPK"); - } + ret += sma1303_add_component_controls(component); snd_soc_dapm_sync(dapm); @@ -1534,8 +1549,6 @@ static void sma1303_remove(struct snd_soc_component *component) static const struct snd_soc_component_driver sma1303_component = { .probe = sma1303_probe, .remove = sma1303_remove, - .controls = sma1303_snd_controls, - .num_controls = ARRAY_SIZE(sma1303_snd_controls), .dapm_widgets = sma1303_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(sma1303_dapm_widgets), .dapm_routes = sma1303_audio_map, From patchwork Fri Jan 6 09:15:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 640103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 919EDC3DA7A for ; Fri, 6 Jan 2023 09:21:09 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C75D1CB28; Fri, 6 Jan 2023 10:20:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C75D1CB28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996867; bh=nS9gbnxwufmObv6n0JCGQlG4xZiMk9YsU4TFKGc2byA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=lzk7kn4aggwtkwOAW3YW86DPjef5No/imWQtr5PZxffj7dhtXg/FrtETX0B5ryFrV K1fqutOjaPJhPBOem65d3zixfnNlfrdd7MFxHlTlThFtalwAd7yfzabxL+7pRi9ZnA om/Isd3u6kPlobNPB5cgXSUgrUqLxkIMvwEdAnA8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9498FF805E6; Fri, 6 Jan 2023 10:16:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 73A1AF805B1; Fri, 6 Jan 2023 10:16:18 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2059.outbound.protection.outlook.com [40.107.129.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 880B4F8057E for ; Fri, 6 Jan 2023 10:16:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 880B4F8057E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ARdBkP7Kgx+pGPLpINExNM85llX2ck96BYf3poHBfqiYDUGX3rAVNv64zfM8QOE9LxW07YmivxZElzwqcFAtmKU7f6+ubxlcF8oGjPRN04QO4WJAxIrQl97QIXwkf6EIFA4Yqa13DuZyt6yYFyo3CROVfrTjf/FaXfctCYBFvceiPx4exUsGoUtdLmVMOfotHMxMCfwVq6xCJsXh9MmOsNUot6mMVCXeJLLZEsVnTR4w6X0WQWDt7xsjRT0nmifrvj5TNn70mfyKRPO0ZknwKdArFLRAbQ+hnT80mIrm0DIitjSpX/2svvqwOwPnD3pxh7XuhOEFUxpmARlFNi89SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lA+ZO2SQADMxLPUhNfCsUBUr0jRQNbQcQrMQkCAHX+k=; b=IAHecKwYbegLF1een6cQ8IYhLrgFa6zqq8+4wmfnnVSMB/t3hn6dXTLvcZC3FmRGvazVxUkl+QwbjFVLXlWkLpsOF78QeDhCF/B/DS0s7vO/YefhDXI+09O/CaxLDnNtDVH8S7kQjPPFqwRutJVZZx726/TdBXLYrQt81OHDlBweOgpkSV/vH6nFVffGc1LxWTF/dG4RowfRoenC1tmf3ISEQ8YuAOLiAcdjQDcJVCLj6bWEex/oA0bFxtLu5IsknKbF9YeEvJp5uAdqJEwse7IoZ+AYlAtJSE2qaY9E2adNrtL7M/qcO2rz1omcnX70x7g4/YkkPV/1qvhNCd6GaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:16:00 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:16:00 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 10/14] Remove the shutdown and startup when set PLL Date: Fri, 6 Jan 2023 18:15:39 +0900 Message-Id: <20230106091543.2440-11-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 530d975f-61c2-4c1b-ac42-08daefc6a075 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /WR/z1ezy8FNNJh3GnJOTaqEUsAWDE3yU4d500FiqJ8HnFaJLKwFvoSZ4dEzqZ3+TD564ZcinjrJZgNC2ZJhkdviCruL0hxg6guNZGjMAoJaG/q2s8f2/zuTzEnchx79tvKA9I2LNdUlRrdokLdNIIP92iNmnJuBvCSWa953dzXEzBI0tLjvzNp3i4Ivu6it97Z0k7keRzqr2WFCIqmVKz/kXGkkOau6L7j3ExucBVWrFmz1jp00A+8O1zSLGQ2zpw8BTDZI6+P+KizQlTdgsPzNall82OS9OkIp1ABxmWkgUwwmNFZlhzCjwm1qkFQEejqgNFu9parNs/ESgkJF09KhQcLwxuZaJmJyOyE5MJIixnJkxAtWIdSvg2g7+P0/u4xlUxSvpfWkOOvE8tRXGG71QelCbNKg2R9qS/RtCOHjlmRTWV+4lbYTsOKSE4mpnCnH+iJHVBRdLiRotSPw0eB7yLdMPcJHTCy/FpOvKqY9GiARQOJRsfQp4Yvh9blzk46rMz5wfU87Lr1RI/vpihtsXuMgZP82HNbmBZ/cAJHIuLgO6pJ7yFOZlfMUXXQkkWwoT8cOuDCNBsAzdIob1sMMDot9saTyCcpqbPeIkROiyvMA2qj742kgTHy2TA0kJpKeVGUBaB4JFU8I+vRrwqi4PcstKMEBXSVj25GUdGH+KeW6Fvg4xOi5fZ12Evzx6oJ3401G5OUy+dHH6XcyAQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(4744005)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ssKVoy6Fn/LiB0aQrX3ne1Hfs+d7NoO/4FQmqivCLv4pkfPxzdAm+R5dESOa650hpOOenV1EmfL1TG4p++b2xaUgNQ7q5axz+2AYucjyvEfczKUsQGSoon19qPyMRfeZtm3R1JmZ64wirVHj9n+Lrf+RvxrJNgpUuPfrSPD8AF2RAqGcNYynQ5RjEpDDG9kkqMUI9BeNfHCfbwAlkwyMNCXMeav2prqoBod4/0iFY9PGFiz9ej9faGX//pzUbEaPTgWKnOJeqMnso4O4xVYna0ITML6nwhNPiBJNLIFz1IQDi9l7tLCE6Dadws1EmXpo3rpORV/tARDsTgOW56Gpbm+RjzXlIY+puUAvBHxqS/zt4BclMaQTHRp8zwC0CbtQk0NDy8u3C433Mo0sg73NqIvkn7O2o1fdzxedAYJq/tKj7yHTNA+G14DWuyRjR4mRdjZiDdHoXzRu6SrVoGSNddmrs1j9MFwukWGuXcRxCChcTalQOkg1TjAEi6jA0wgY+WMhzYbT10mv0LlTV6NULYvAzTdxCVtLlG9Yd7kqTJ0yrkAKyFCJQWiYxx/vj3Mjpila7YWh/Wo/oxfr5DL9zLj2MlKjm4leMoPCXs6khMsdDhLaLTIRkJEi1fGC0+mbhxTEtZwnU/JtRszWCNysYhitml50AcBNtU/Xqb6IQ/9NqyHHwaSq1RtGKo/qtYp/nJMQ5tcXAjitHFiPFk7CA6mjkU2hGQuT8UoGhwwSmi5phKgS/K724bjYODkffkhROOtMwRp3akNDPfx2JQhNzPYH6IurNIaa+HtNMHh44U33IZg2j4cNMZJtEmNFR2lFE3Y57heIvA1WYqHgmEm2yM8JTuGKBvhDIt+yOPdd6azDHfhZCguc8AUjnLaQax6QCgwgOspiOiknH40em3/d0jV72xnqaa7WnTc+8nzAfzV4MOqzFTrWK6yu9MrOJkbmPs+ScVS1LzEmyTtDl9lpzyP/eTu2Hjvod+u6xPrV54nObTJfaH8oMG17wgMmgt2LrBPScDqaX7aC3esDQ0uVIsl+h8rbzxL5/nti6XcMuM9PLboj0WDyaJCtEyPHd+oOVg2xbfJLucny9LU7sMYTGGuKJ91Vgd1nvcNezOv9SqA4PBGkTUUhXlLGfQCjMePD2Ii3VftYZewejsvRweiIUpcDANffYuTvr6ygXo0a0Our97XyE6DGlfMeg422cnyLdOcnfMIReKZ/guACvIZaRnhFA5KoNblVHoPuYTv4uVK1WJDV85QAXZomVR01fjIT8ZJM7t9VqlBVnX3Rg9R2KDhoRimccMO1489jGV5h0qCnyDfSxGGoduVbln6QxFLRdM4qL/UsW0W3446QkTDqYHP7B6LU4HRGzrsuR4K1WuvfaqNpiO9fN0re7pkOCm9CJUZsLi33bS6eMvTtwlpSIzawvL+0GyN423b/njQh8I5vKdlNbo2iCROhkZBXye+StEyKD/Xv0bhiM5yCxSJyjc0Vt9GA8nv8bGsCs8Fthlh5CW6faSbiN2R6WrBRDMwmq+dO2x6opQqE7AsXmUKN61/hlUH3TQaN+vtCis5aRujPtHo0vKDUwsWjsBXKVT6qlhkmrneGTXUjHtamLdoAow== X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 530d975f-61c2-4c1b-ac42-08daefc6a075 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:16:00.3944 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jBPPbpIkxyfaexNmQVGIV/qXQu3vZNwXLKbUEUW9f/j9KIi1OcrnE+uX8UpFwmiK1kSrlGthkdOiHFaDoJJPtnq7tDv+qC9TKIvRxcRA45A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Kiseok Jo Reported-by: Mark Brown --- sound/soc/codecs/sma1303.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 1991c8d21ba3..0b4ca935ae9f 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -943,13 +943,7 @@ static int sma1303_dai_hw_params_amp(struct snd_pcm_substream *substream, || sma1303->sys_clk_id == SMA1303_PLL_CLKIN_BCLK) { if (sma1303->last_bclk != bclk) { - if (sma1303->amp_power_status) { - sma1303_shutdown(component); - sma1303_setup_pll(component, bclk); - sma1303_startup(component); - } else - sma1303_setup_pll(component, bclk); - + sma1303_setup_pll(component, bclk); sma1303->last_bclk = bclk; } } From patchwork Fri Jan 6 09:15:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 639707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70699C3DA7A for ; Fri, 6 Jan 2023 09:19:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5006B14119; Fri, 6 Jan 2023 10:18:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5006B14119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996769; bh=9jlWhmh4lCwYSsNp/IIkwnAItioUsLXJFYDZplZRWgc=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=LHiIAtB7X8k3t46Cr35+YCxGaZb0cYyHmgBN5ItBkNNPgiQiXo/hWIc5tPmXeEgEC PiGdXSMAhsGRVjKYtmgDmtpD2cSqFDNP/4ODt+xrCF0YTBaT5O0zZor09VHv7IAAiY Vs12pzAcjS9xgaDfpNPyn+sri7LiZhbEFmnXzfds= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8DBA6F805AC; Fri, 6 Jan 2023 10:16:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2A2B6F805AC; Fri, 6 Jan 2023 10:16:16 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2040.outbound.protection.outlook.com [40.107.129.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F10A7F805A8 for ; Fri, 6 Jan 2023 10:16:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F10A7F805A8 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RToJ9lXo4QGrmgkBqDiVQO/wDnNTmaUTpiPDTV/+OUV4O/iY74ZwfcdjBgJ9GIRvLXjdH13EqtQdKPecyhn8l6mwpCuCqcALm7xtfi+jYelF+sRu+CKE0hT/HCpgFudDEfa9q41a9tqA8JZ/LgYYsduKQ9bzhUrlWNB/ld7C7lSNDs7+ghb2dOwiMb1w/56T7iRK6fHbWQWVkIw9TfDFEL0MpV2SjWv0c6sjNpNRPE2CD/Oa+tqbfoiRU/JnVru5OzFDtVTXB7lnmpxrmB5RPVVr2vcSd/3z0uXtBKc4rVdPPYOILLQgpcmxoPYz1oxFyhofjsGWI78HjZmhnzVPFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tt2RT/WM6MW0rGbGkCu3+VPqq8ny/2ZjWvWnsA2HAAg=; b=fELt8ctD8MGi6ZnHI9R4yxP8tiDHVrJMcgjezYNflNC7ktHn7wHWK1r/+M8Q5dyPwKGLNNp0uT20mVvTtTrr2sXN2n/fsCobtwJnIdNZarRDB3hNiH1Rgd4Cx5oW9ud+mAnpR/xDW0h4EBC0x0t5opzgz4eCcEvcdyjBPVBGv3GCc1i00hiJLOR+4c/vo5JBf3KBNQVgOefoyKMM2asFgyaCeJhwV9OQ99UiYx+xABGob3JIzFP9dG7FKc/jISyUjBt3g6mGIANGpPGVoseqjRwZacLs/Drn9oGw2CtlsHRL4kTSsWJFmDbETPbvnNLSu0V3WSXVHEix1UHobVRJVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:16:01 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:16:00 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 11/14] Delete the header file of "linux/version.h" Date: Fri, 6 Jan 2023 18:15:40 +0900 Message-Id: <20230106091543.2440-12-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: b29ab964-d9d6-4d9c-93da-08daefc6a0bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VMu5E6YQmNfNWfaiacn2eF8w5cscme+mAonMuA1O9tQ3IYjzBIWRXtgna0nhJwlsy6poS0ntA6pMDHGSBFTIhZbBbYXwjDb1Q8uQXG11GM3cjfGBiw70/bzGS6C/tt7QovDm63ohrprypgC5mMEJYaNM2pa0oe02IFcJbtFAXFS+2sE52M/EHMgQyyrJUTohLtM64hrA8e9df+cGE6/lSf8BIlBIQjA8twk4X2clxBlA8kW7PLTpQy55jy4f8WECVu9Qh/s0nLLcZI312v2e6lxLDDzZ28NATP22LIPYXx4zvEv596F3105NkGpb56S4A6/Yp9fuA/rFmLNEMvyeCPSkWnVIJaadFwQBGWFYJrQ1NHlrpqjMcwZMFBs2uulCNzk2NSKaUQNkkZ2plrx0WFIz5XD7CFvP6mSlaLe2UOOcaNXgIas6XD+fJLYj+9pLYWBCeJiXOR58pSSRjt+b3gA6xmutKkPQ40Jt+Z2OQ4zO25gMt+YvuvSaT129iW5tntkAXtOzmCWBZRTL/R83/y4FbcBkhW2wdcE40Y1ruY0O52BqM557Rc8RFvEeaCciThyaVC5Jxq0mVkujy5fj/D2lW3OEjxCExQFJfy+PMgedXwbRyw4wbDnoYsxE0sqPIjyN16GgoOIpONq75AUTLsZ+XQterQAEy8qwjT3MipjyC255p28+RwXTE0JZx0Fp X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(4744005)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(54906003)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4++UD6RKBfH4YjzGpASLhRcq+ygrtOwYHjGXaUbR78pZ1EWvQBFb0CMGfPF81SRb9NuaVmXXiR/LkUcuPZa2EEV6i6OR1Ui651mV3aka4+9k0rexKX+0crYydwllqITsCGXkG6bxOeRzTp8VSXFUI3be06aB1ZpZjv0Qja9W4GvZyOpFGR5jmCYFCUF+4d8jsI/SgzaC5niwzDBtLjWJdWWjssbb7aJfSUdV3v+R4iTRXl/b6SeUTTajqEGGmJXUEIn8HEwQ0Ro5jRvrZ8MG1BzYoJ5q6QGf95oLEg3IkvnttUJk+lO612P4wgPRYPuumnx1F4G8j5aAbV7dLfVQfyjzZ9uVNqQLWDyZGKFHPwTq8AhQVnrdENIQPfFn9TK4O/AEd1Z+E/y7MBFzgH982U7Q9pLmhLuILPF/tphFQAPRa3hZkcEww0VjKwB97kco5hzUCZZQXoDA+0G54bigufvilYAUUy5/MfUw+DmnBqaVeTTjbKCfiaINBsCA96spY0Q3sk0m9ufc8eJLYm1FZGQsPowu697wdyVXMSUaZpN/Z5MGE9ZAGat3J/KA6AcfrDmZRPmTCBpG6PEuwfuYzDpZ1AJtikZHPiuZennIW1lO1eLSnmySRwSzJKKoOZi9kHl8T+eBUxYjjDWnEDPTXKy7bhSF6A5bK16AB1SaIAELjUdviz3oEXL9UzM3EQDGKTtLu5XGcSpsK3CRCXJDRkMzeyaOFKaZIKDoiN/Q/kL3AtytefGHVSAu5TjdQT3L2+kbBPzr5xCFic/qR/JY9QrC8yvuuqUmiysXZ9ARfFQCLa6pierDO1b8l06M/sz2k5jE057kzE2G2rfPyYsu8ZO3dM+hCYo9DH05km8GVATKHoBv1mnsbhV+kyd+x227dlapR2Z/fjszj6bLvxTP+in9A4Ol4iZel9spkaY/RYcpbTxD2IC/47yGTXfs602Fiq6/lJZvMiGd3mY/P1cHRb+0V2FIprjOl4+OtW2X+HqPTYBDYcifeFbJnCtTL4HFY+gWRUmNyqdRknjMqjNBE1Cs6ml53g9zPcaebKhLHLfO7ktbELuH3nimYK2pmUG+SDiyDgMcYTA27uFJkxLdpO8eQNrgMhQcpWC946x06sVGcNDsOpru5mSIEkFUOfFbndnb1loM20n1Ln5zv4uvD3sYefbz5Bfwo1TyPpcRXJN+8fo35YPY66UJoU/Oham8bEynj/qRLA3ZYVkopZACmA1NK54hY+FrV925iO7Ofe6vjNvO5yQjbsB0QjHOqlxTF5HG4uBbeUocL7RE6Hj71il61zO/yooK36pI48a1IHp38uz42jILHnyhLGNE4YAAkYnILzfI1U022gCNwkb5IkNNT8Ehs11KHbevfUn/lii9mrjExKDuZHCSF9Ib3YlITERBwl5fvMMBnmmuwu1XIAR2Kz/e34sET4bHorioeAEW5KG8owfP/+/TS0wUSRXwuZLsoreQarBc/Z/gNRK67Q5L2WYv99aE9ISNdUj6kZn8rI7YN+5mlkVvw0rzpGNg3SlTLf0qCMFhRabbJFAOESfZkViGXWuFTj5T2yGLWTiO4PUMpAGKdrwwCiLAXrlqZp7XpNOFHgIdVn+qv2kHXA== X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: b29ab964-d9d6-4d9c-93da-08daefc6a0bf X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:16:00.9256 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BOMXMRA8tuXAjAYOJMA8MnN2WO+IRbZa+oYLDhKpU1XWFr1/MnQZkucDMi/p+9CmwM3aUNH/7LUz+ZWdI3WiUAS1HmhDc8t3hpZVfdGPH4M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo , kernel test robot Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Kiseok Jo Reported-by: kernel test robot --- sound/soc/codecs/sma1303.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 0b4ca935ae9f..ea4356233c2f 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include From patchwork Fri Jan 6 09:15:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 639706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67CF4C3DA7A for ; Fri, 6 Jan 2023 09:20:05 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0F4441412C; Fri, 6 Jan 2023 10:19:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0F4441412C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996803; bh=o04pX3TGsVB93aOnSoaf9/zAG+6cQL/MNgVp5I+lUWA=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=YOPU1JAuEsX/5/KhsaEOiVfMzBLKFhW1dDJGZAwKMFR4rQxz6pSxFO1R9DATjkVaj Mj5XOHa9dSHVjMzxzuQWkUvXnE41767nvWSVJL0O+ufYFr5QUcEivEY0QfLOapaleJ ob0NdjVH2l1teaq8v3328pJq+30vjBDKwnQm1BdQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 91100F805C1; Fri, 6 Jan 2023 10:16:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51327F805AF; Fri, 6 Jan 2023 10:16:17 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2082.outbound.protection.outlook.com [40.107.129.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2041CF805AA for ; Fri, 6 Jan 2023 10:16:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2041CF805AA ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iUxbT0CcEs+a5xfloQIbfdOKWcCzXQfmsBIia7LpJ/0qJn6OwE1D1OGVS0zyYud2wgDGZu/QUJDnn7X4maKnknDPEWUfCW35pC2jJw4fZdIEvpiotHesX6uleRlpjtKsi6KhvWlSGrHvKEeu0UEp/tbFLRNGXMVFXkpC7ZoZztdIETWno0awtKIT1Kf8kisuqHuLMiiq2DJ7v67DiarF1CQdr3SiiWr6zzQo0KjItpTbCaFRfQQGQt+bKSufDVoQsaLCUYbq656upeuzcB/mY1PvD/+hUjY9e1cMpZW6P7OYn2g89NyEctqi7nFAYV0xCQOHKKVfrogC1QQ4/3GwAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ys9mlSw79gkSTaf9AVbduCIMCM8PhB3fTz7OZTMqnb0=; b=meAMk7PSIIHCZhcElCC2XUgvrPZLmQ/mkkkW0WHYnZK65pNG93ENEcr7p86gGJ3XkwUUld7fxxrZTYnaIh9Ew070tWHspxrxlOi8OR4M5ZV7c9XBZAz6sXBJct02cW6+v3oxt2TIqqN779oMwxQWKGcnXgTQTPgdRYlNzVD3k2CcoTitN99msnVX8jSVJWRmqn3ApVpMAygjjc9qaS2ZZp+8rjusaUDs773ULzSZ8Bxgw9ZDcJSXTamHCk2RKeDwa66QZ+sZoucUJVWZbFVx/j6ejJAHpBdApQcD6CnyzjE77/sleiyiks1FCrX1uIC+InQH0LzpRGcs8yZAVWSfVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:16:01 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:16:01 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 12/14] Add the postscaler's switch in DAPM manage. Date: Fri, 6 Jan 2023 18:15:41 +0900 Message-Id: <20230106091543.2440-13-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 2844ff41-e16e-4904-1924-08daefc6a107 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ImrwZXt1D9vG560HerNQLaa8nNAMOprmgkp7ejwyWK5Eax9ecuwQcNlZtK95jpZp+aPTD2fzO+oCHPNnYibfQl8ccGYk7AD1UnaJrCa4TqvZdjk7UgdiK5in8xPnCkTbr56iUQoBUkbF+xhNc4MQKz5AwTxfUJR73V1x4iFywfEHfBj8K6arx+14MMFIZoBC+Z0jFPaPUKxXOTj0JgBk1F0bfIg2po+UDbtoOqqTKcRwlCBIF9p7nqij28rtDyGOR8fWuCIfEpOtf0BeVzCWoGEfjgIoPyy3482ErFMrAWYgWjENNBd5bL6ZtH3wrmxlVHDdF5ajLpe4aNjFNhv4OaHidpR8h+oY8Y7L2tC0IDEIuGsclnfwtg75m5bb2QMjpIx0OgluRQ6AgP1/2s186P51hPMhcFiKbIB+tFrcffJS4l7FJhTW43phCe+MFAoDv0PXoODuyF8CD8YZz9HfE4qBZ49VfFumGj1tCmIqGlx2JGHBxHQ9uCLlWi1f267JVyMkr7ydg0mKpLrSotskXk5fUN5QsQkjH3vcJvwH2r7MS40aD5oZIWfciYiJoADgQhxOURPJFh2jhGM54/vxqpJJ2EkTjzWSQ0hO46Akh58xgc/87Zn2gS4RqQH5QpaFY+e9kD8PU1G8qJT9zNesb36ONAjNxKJprXekK+ebBDnOYN4SNtf6Af/x1ysA3pD9aiASqfAy0XqexgWdHLyN7A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xZvH62feDxtUsT+FBQJhihPqA+eE/kUOrDvtUvzPLKxM3a9OQFF9xJNxyVx0xjD+koxuKV8evrK1xi+NiHHlcYFBPJE6uT8teJtmGI1bgSqpeOMoOtijKfJqbZyy7OBzoV9VF9Q2XGJmMyeZcyHRV0EavQnxk0anYqdVZelBABE7TASYIJc2vtFTY+Ucw/Ss9Zfh6+aYWDrobu1lWNl5ji5Zqoj+DPJpG4i8+fmNlhRPYoxmSXTrbel21+KN5AicNDgKTlNKfNJZcDAJ7E6kCq04fedurlOcOK3Ws1OGy1RzwuAy3tCHQ6VLuxcpWavCOF9OFmuW5SJ1DnXeh6dOJIKU2ACXmnPo9+7rBPUy4gpPDVixxuEt9On1Co5FOZCNd8+d+diVY1Z+mcR0kfHFUbVJGrQGrGlWTY/XtGAHJdVkgWMyHUN7xwN+OX3vDoeVdBFzse+Z1jQn0kHvuKZMRuL9foOMFGbQUBAufbO7+qaExYIfXlIAN+q6gVnef6fjBEkfCJdb27uEy9kG4bjltq7pCxb1YSXo8I38oIsM9JrlC+O10M6hwZmtzOcsb3FHmhgeD0+U6VAjuExoY0XSIfn4+LC6KnbtMrYN0UXgBOO/tqzUWjLdalTykM6urM1FlH2S9KOO/kUQCFW6EcALNMrJ/o5w51fwcZLjgqOO3wu5AWoAXbLQoWf41/JJVvF1E36+wfx+ogj4JoVYFGFG9Qmzk9JthMC8wBWpIjuFGKhoImbGnTDXh8YNcvHKT2wwuXTxBbxXfIkXl5w3GX3O8dKTYDDWMMUGlt4OnSEvxcTWI8KRrf10kU6mVPo85iN6M1oQyjzT+5Bb5WsQtBEuaSLb7gBcz3BI8icMQ/RB+JmNWJIVIK/0epZWKVAjXErGbOVf1Wt5D0eA64yBNZF6UdFmxnJ7WNB44mv6e1blqLT102YQbBL6M+7Vl/0L1Ui/+woBvAo/elicOebzBPWz04gs9KtZOmqBVoGjyl/SU/xlmKt/NGG/zwaG3UurCCQKSMHa337xWhYZx1z2xSEJSmVHszVv/Q18m4sRz8BEoL3KXqzmTpZHAjgZzIaGLD1JMEGTm7AURwSPx6P/hxiz38dJMoBCtALJDu2A4O22+ycikxHHrJFxx2hGappOvy/eZCx1KC/joi5na149gPAbCBx7Y5Wrkr/I6m44UioTOlls5L1D7L4fK4/zh/qe56WE2SPdgfBrEPsxbpvtNIRorrlnaH0a+YoNdg+JZya1LRE340gV5gSc+1i999nUEB60WCs8/Daqx7Zb7oYUivOtQMnH9XGhCat2yF03RnaKgPM/q6XZVLtxKmtIZqzWZ7OPtKiVOrT06I3EO5q3zLSjPGW76okQ0CpWYBRVmGGq2ejQd9CjjAQ6AJ26avIlL24SeSq6d3q/vBWaFd9UHEdTOz6jzIoj0nar1RXp2M9pmDAnVjpP5fmUOAo23gOMsKg+Cvtmmqh/XvI4zRb2B4fJSJSkwkOlX4OW55YppRVsXk8C8tR+yqYRoKQfLkni2cvnLyEg+tLgJRxb2aMiJ4MOMa0SDjBnAonR4RktxiEblz13IKcrV52wr+2r0jOPUIiMBz5Pjp+KO0kjlarW32ggRQ== X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2844ff41-e16e-4904-1924-08daefc6a107 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:16:01.3318 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r528a6N5MHy3fa4tF3Ko7PELmWPDHra4KmkE42FB28Xu9jEj6z4d/iaSRHxCezgYsMtW5EYLRfws4no4jHhMppZZadV6RhQzGyYSukBWvAc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Kiseok Jo --- sound/soc/codecs/sma1303.c | 196 +++++++++++++------------------------ 1 file changed, 66 insertions(+), 130 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index ea4356233c2f..08f5054fde1d 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -301,132 +301,6 @@ static int sma1303_regmap_read(struct sma1303_priv *sma1303, return ret; } -static int bytes_ext_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol, int reg) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - struct soc_bytes_ext *params = (void *)kcontrol->private_value; - unsigned int i, reg_val; - u8 *val; - int ret; - - val = (u8 *)ucontrol->value.bytes.data; - for (i = 0; i < params->max; i++) { - ret = sma1303_regmap_read(sma1303, reg + i, ®_val); - if (sizeof(reg_val) > 2) - reg_val = cpu_to_le32(reg_val); - else - reg_val = cpu_to_le16(reg_val); - memcpy(val + i, ®_val, sizeof(u8)); - } - - return ret; -} - -static int bytes_ext_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol, int reg) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - struct soc_bytes_ext *params = (void *)kcontrol->private_value; - void *data; - u8 *val; - int i, ret; - - data = kmemdup(ucontrol->value.bytes.data, - params->max, GFP_KERNEL | GFP_DMA); - if (!data) - return -ENOMEM; - - val = (u8 *)data; - for (i = 0; i < params->max; i++) { - ret = sma1303_regmap_write(sma1303, reg + i, *(val + i)); - if (ret < 0) { - kfree(data); - return ret; - } - } - kfree(data); - - return 0; -} - -static int postscaler_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - return bytes_ext_get(kcontrol, ucontrol, SMA1303_90_POSTSCALER); -} - -static int postscaler_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - return bytes_ext_put(kcontrol, ucontrol, SMA1303_90_POSTSCALER); -} - -static const char * const sma1303_postscaler_config_text[] = { - "Enable", "Disable"}; - -static const struct soc_enum sma1303_postscaler_config_enum = - SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(sma1303_postscaler_config_text), - sma1303_postscaler_config_text); - -static int sma1303_postscaler_config_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int ret, data, val; - - ret = sma1303_regmap_read(sma1303, SMA1303_90_POSTSCALER, &data); - val = data & SMA1303_BYP_POST_MASK; - switch (val) { - case SMA1303_BYP_POST_SCALER: - ucontrol->value.integer.value[0] = 1; - break; - case SMA1303_EN_POST_SCALER: - ucontrol->value.integer.value[0] = 0; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x value: %d\n", - SMA1303_90_POSTSCALER, val); - return -EINVAL; - } - - return ret; -} - -static int sma1303_postscaler_config_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_soc_component *component = - snd_soc_kcontrol_component(kcontrol); - struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); - int sel = (int)ucontrol->value.integer.value[0]; - int val; - - switch (sel) { - case 0: - val = SMA1303_EN_POST_SCALER; - break; - case 1: - val = SMA1303_BYP_POST_SCALER; - break; - default: - dev_err(component->dev, - "Invalid value, register: %x\n", - SMA1303_90_POSTSCALER); - return -EINVAL; - } - - return sma1303_regmap_update_bits(sma1303, - SMA1303_90_POSTSCALER, SMA1303_BYP_POST_MASK, val); -} - static const char * const sma1303_aif_in_source_text[] = { "Mono", "Left", "Right"}; static const char * const sma1303_aif_out_source_text[] = { @@ -468,6 +342,34 @@ static int sma1303_force_mute_put(struct snd_kcontrol *kcontrol, return 0; } +static int sma1303_postscaler_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int val, ret; + + ret = sma1303_regmap_read(sma1303, SMA1303_90_POSTSCALER, &val); + ucontrol->value.integer.value[0] = (val & 0x7E) >> 1; + + return ret; +} + +static int sma1303_postscaler_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + int ret, sel = (int)ucontrol->value.integer.value[0]; + + ret = sma1303_regmap_update_bits(sma1303, + SMA1303_90_POSTSCALER, 0x70, (sel << 1)); + + return ret; +} + static int sma1303_startup(struct snd_soc_component *component) { struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); @@ -727,6 +629,34 @@ static int sma1303_sdo_event(struct snd_soc_dapm_widget *w, return ret; } +static int sma1303_post_scaler_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + dev_info(sma1303->dev, + "%s : SND_SOC_DAPM_PRE_PMU\n", __func__); + sma1303_regmap_update_bits(sma1303, + SMA1303_90_POSTSCALER, + SMA1303_BYP_POST_MASK, + SMA1303_EN_POST_SCALER); + break; + case SND_SOC_DAPM_POST_PMD: + dev_info(sma1303->dev, + "%s : SND_SOC_DAPM_POST_PMD\n", __func__); + sma1303_regmap_update_bits(sma1303, + SMA1303_90_POSTSCALER, + SMA1303_BYP_POST_MASK, + SMA1303_BYP_POST_SCALER); + break; + } + return 0; +} + static int sma1303_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -756,18 +686,18 @@ static const struct snd_kcontrol_new sma1303_aif_out_source_control = SOC_DAPM_ENUM("AIF OUT Source", sma1303_aif_out_source_enum); static const struct snd_kcontrol_new sma1303_sdo_control = SOC_DAPM_SINGLE_VIRT("Switch", 1); +static const struct snd_kcontrol_new sma1303_post_scaler_control = + SOC_DAPM_SINGLE_VIRT("Switch", 1); static const struct snd_kcontrol_new sma1303_enable_control = SOC_DAPM_SINGLE_VIRT("Switch", 1); static const struct snd_kcontrol_new sma1303_snd_controls[] = { SOC_SINGLE_TLV("Speaker Volume", SMA1303_0A_SPK_VOL, 0, 167, 1, sma1303_spk_tlv), - SND_SOC_BYTES_EXT("Postscaler Set", 1, - postscaler_get, postscaler_put), - SOC_ENUM_EXT("Postscaler Config", sma1303_postscaler_config_enum, - sma1303_postscaler_config_get, sma1303_postscaler_config_put), SOC_SINGLE_BOOL_EXT("Force Mute", 0, sma1303_force_mute_get, sma1303_force_mute_put), + SOC_SINGLE_EXT("Postscaler Gain", SMA1303_90_POSTSCALER, 1, 0x30, 0, + sma1303_postscaler_get, sma1303_postscaler_put), }; static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = { @@ -789,6 +719,10 @@ static const struct snd_soc_dapm_widget sma1303_dapm_widgets[] = { sma1303_sdo_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_MIXER("Entry", SND_SOC_NOPM, 0, 0, NULL, 0), + SND_SOC_DAPM_SWITCH_E("Post Scaler", SND_SOC_NOPM, 0, 1, + &sma1303_post_scaler_control, + sma1303_post_scaler_event, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_OUT_DRV_E("AMP Power", SND_SOC_NOPM, 0, 0, NULL, 0, sma1303_power_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), @@ -818,6 +752,8 @@ static const struct snd_soc_dapm_route sma1303_audio_map[] = { {"Entry", NULL, "AIF OUT Source"}, {"Entry", NULL, "AIF IN Source"}, + {"Post Scaler", "Switch", "Entry"}, + {"AMP Power", NULL, "Entry"}, {"AMP Power", NULL, "Entry"}, {"AMP Enable", "Switch", "AMP Power"}, From patchwork Fri Jan 6 09:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 639705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AA06C5479D for ; Fri, 6 Jan 2023 09:21:14 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A303D14116; Fri, 6 Jan 2023 10:20:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A303D14116 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996872; bh=e2LnDPucXIAz9UG8dv/JMM1/wmxUtrEG5J7Cloc8y9I=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=Gz9Cj+/1PG6y8WXDuOvmweMmGQfKiY6ILkXsjV3yRWlvYRleKbldnKdvur3Hcd0EI Dm/ZJRzRtxn0h6uNRL96o2liFJgzpFGNUz4Z1/fS13mXxRqT4hsRzxfguM2eKPcMYO F+w/dHwGWq5GoQDGWp2ND++P9iyZo8zuS3/aTQ3c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 15E3FF805EA; Fri, 6 Jan 2023 10:16:24 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0018DF805AC; Fri, 6 Jan 2023 10:16:18 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2082.outbound.protection.outlook.com [40.107.129.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CE46BF805AA for ; Fri, 6 Jan 2023 10:16:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CE46BF805AA ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=moW00HfHw1cXZMcLV/CQ2V1jkMM3g6x+GtzwNDn1oQaX2DKMr+XYzszCCD6shgpL85B10TPzOg3n/dfoe0gC1VcLa1PFLw/ekzb38pfvFohNrOeUBvQnBUnQuugcjcTHdeSo1DMztlfs2hC5hgtTwXV0B1sDnq/atY5LS/1WWsQhs+4czb4NP2aW60HoQqBqba5VcONeRmt1yn5UFZkkaVr5h7AGD7coztxePmDdMi2/vi8b/lVDcNPbbde4Lm6Qn7BfEibi1wcwdiWSEkDdnY+zlxc+03RvPy1wOGhxnwyIxmAG9lEOgPgUmf1TtcGken0mhsJ2VNmxhfRdTg50kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y+fRSzAEoaxv5XIxLX8kbHJUDvoxR5QZuWktaypOXTc=; b=gPfQEnr2BeWW1YsiQQ42keDRJOfc95G7dMwhAVuCIZ0sQOkF93RY7umVLfku4L/P32sCKDvOkqekQGWwm5l+5WDqV+tcHHznfru7YUsRseMCyIJjZIrPcgt/KHUSffsbLQWsbQZSLDEmU1Eznyup1N8HLwxOVy0446d9GCjDKPfGTJSz2owoP+VNKCXWW8zCMX3BOzBBcVGWY+BoizrTpWH5rRWKYKb5PQOYzTYYwSjWLu036vj3UTjoBotDTZ+IiU0pBNsCACR1ox6Hqy6fHs/udj1IV2hHPq8qD+cf+WIUIr3WOUq3chEounFhUYZ0fFnT9yRzz3f7D/YvOk2DsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:16:02 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:16:01 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 13/14] Move the initial settings to i2c driver probe Date: Fri, 6 Jan 2023 18:15:42 +0900 Message-Id: <20230106091543.2440-14-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 66da9304-da90-4c70-d9d3-08daefc6a149 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xr+hyP2OscDTqowOLRLYyZy8OIckHoxj2R52OHhKlDm1CuN2etdgmguGzos90ZuKTuIipR9XtCUNmwtPorlf9NS3kpv1BGk99c75FWOI7jtqI5VTE+qakaOZK+R11QURIflAwyHwVyDVH+m9aSpBStZkryhMQMr40E0a6DrKjYi61M5Al2AijrRLMmXbpAqbVns8vSRoUcULZqJHUk6SyeLzCG1qIVqbK7l8EcJBvKTwzaeJwGN5YrwBZm2SJGHZXID67M0wfg7SQzftJrC+eDt3YKvS2ns9eVA1j5AjvRrZKcriZuMu9Z0X0Y7/X0Bn6DeqdP5iposvtmRmsitxs/XVgZtpp0YCMz30bMHdoP8sKJ5/IC86seZFSJWl78xSL6NooxoO9+W+m5ZZqLlDUnB+lk7WQC3Z46iucNKHYMnegA5qMsAZMj8vqS+NngzHq9rH4iK/1bxaE8YaYd1JbhoDXKCdWDCkCenC9gBXg5H2r1U3JYw9V/HjZb7f3wmJv+mL58h0bgaAfZh8Lpl2lGjdByld3LxOouILBiL4XRwk1Uv0ZFjijwIrvycmuwLnluTQm55aVvBA9scZ9p2ed1QkK7GL6KSoQwAiGqhWjHUI8dSXY5wwFDYDDdddMJxy0Gz64t0+EVrc5YhTlZ8PXbgBt5lCzIMb59KAS7Xecu2anCTzIS4KwSt+b1MdoENO2ASA0ElGDgaK9jca2hoKJg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(107886003)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MDpAuFX7uicm7g0KVdweMJ70YEWWKNwgXuU5mErU90h0ZN52s4Keq9l0zbtxF/QXmgTAKppxYRnLp3YczHvH/iG7JInTUAfbf7suaV6VKmFYacqT6tIzoRYd5sOI07XeLOo/cBQ6aZ0v7EEVWjPsSdiGqUe5z89Qj+/nLrlj7c+pXHyuShM61H5iv8/xbBG1/c6kCwJ/ZccHYE3di2Cmb1lI+nPhYRFL0dEu3pEUqYXUMVrVmT9JzMUNaHO/0f91Mskr0opR4Dib93ae9MW4yjNbCVxqgLOcuZLXJQCYdDzsG9HfFTEKRkRqlNXBjJEhCW2YVyZ50sXhA7tkW+BqwQMkvGpsXV5zfZn/gqi1Y8myGeKyqHWuE+UNNxEs+cN3WoY//dTAskZTk6xShKSJRKvmNf0z4mwjzSc3S846scCHqBuMOymbpsxFbIDzrsI368gq+d4o8rmg1ky+NLtCno1nW1+MXXjcu48s9qngFCu/kSZcL+yYGEi/PFu6G3fgxU1TWLd5MCRx05F371RWLomFrnhSMS87FNx49ZgLPk9OoBE56TFII9ucmt8LO6vW8wwm6c35w01BptBqu0ulXPPL/Ku2YJOmMHMNaAvrDsK1RV0bF+zbOfZPqs7xHLd+FXom76XjORLr1vlRJ87PWVF0exXYbpUqTvZ3fI7y9Z3ZuthV7Utq9MCJJxiLsBVTyHlqiEN6EKU+3S+VziGymUdDXK2GzcwObGtEb4NKkt/EM8skhE2VVQ+79K71OSFVb10fWzn4yzP/5XH7jHQvTBSE/z41zrR7sN408Yrn/jbxG7PFY/hVZFdtrqxHUfhXUCWA+1Gru9oV39+XE04VZw8pKRotKe3/SHv0v0YIHAtfHdKdM10bkeOJl2cpJIDDKdBV+4+wEvC1/8LcgxmZbZ1fQxHADX1CVDhQprBWAToFmbXZV8+OEpRtqhO3Uc2ImTMwn21Shys0MPEOaU+ok0WZmlQB3wSn3ie3pEKOzvfHRuAyteWeVi2U51XXtdKMYYvnmXOEcYNcu8SqjnsqjppiqwOwa2Asm5AOhGOGqkcTL1EuKHQURWPw1ieVJs3PM/IQkscMEodu8ctIIBzEgAyvWRqbr2vUNNhpdiwLDhY4MwvJlW3eXcxqH292pGCDZgoTs4yHslimtu3Pq3+KPTnSyoyjognO9MnoZDdJsKoXGhelD5IrgKkBz2wu6h2LgVLY3N9MOxfBB5ELYoMKQjTnQLOzywo4h7BSkeCZL6kTTknLzqxhUrBUOW2VbKF5F2lTzRNAUc9C3RTrcKH7pdT9F0A2swGaMD5uSBn9GPZxF+XPtJmaCXxcAZgDtJXS/xxEXYFaI4oVFRBf7ydtAt2XBXSKEgsLeUzYdJPMNFxvMVYwVNkkkTAsKP/EtaSMO2Jnvtwuops+cHxoT7dPUG6ohcs0Pbqxwz8B6BTO9LizDcUt+35iC2Z6UjlJy4s7Spa+6C9ZFWAld8eKXdBaBfSbP5o2eS2W7dC4Dq3eBPBud0q8FMxFbtnOclFnYQufNpMxCAJd29n+1kgpbrP2lMwLRh9+otdaBRJ0/Te9EKmCD32lUA6NogLxwcXxsDkNKaB2NUp2UdCIrb0YdBYILw== X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66da9304-da90-4c70-d9d3-08daefc6a149 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:16:01.9412 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S1CZjvTudNHewxu7rREElVtlxzigRp06fzRneZuw56GSGONKVyEIKRSxk92FZXtNCNZKzKZZmrqx0EZFDYvFyOdaGEU85eIWrRbhGbbTTt4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, application@irondevice.com, Kiseok Jo Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Kiseok Jo Reported-by: Mark Brown --- sound/soc/codecs/sma1303.c | 106 +++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 58 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 08f5054fde1d..1a5d992bf3db 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -1416,49 +1416,12 @@ static int sma1303_probe(struct snd_soc_component *component) struct sma1303_priv *sma1303 = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - int ret = 0, i = 0; - unsigned int status, otp_stat; + int ret = 0; ret += sma1303_add_component_controls(component); snd_soc_dapm_sync(dapm); - ret += sma1303_regmap_update_bits(sma1303, - SMA1303_00_SYSTEM_CTRL, - SMA1303_RESETBYI2C_MASK, SMA1303_RESETBYI2C_RESET); - - ret += sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &status); - if (ret < 0) { - dev_err(sma1303->dev, - "failed to read, register: %02X, ret: %d\n", - SMA1303_FF_DEVICE_INDEX, ret); - return ret; - } - sma1303->rev_num = status & SMA1303_REV_NUM_STATUS; - if (sma1303->rev_num == SMA1303_REV_NUM_TV0) - dev_info(component->dev, "SMA1303 Trimming Version 0\n"); - else if (sma1303->rev_num == SMA1303_REV_NUM_TV1) - dev_info(component->dev, "SMA1303 Trimming Version 1\n"); - - ret += sma1303_regmap_read(sma1303, SMA1303_FB_STATUS2, &otp_stat); - if (ret < 0) - dev_err(sma1303->dev, - "failed to read, register: %02X, ret: %d\n", - SMA1303_FF_DEVICE_INDEX, ret); - - if (((sma1303->rev_num == SMA1303_REV_NUM_TV0) && - ((otp_stat & 0x0E) == SMA1303_OTP_STAT_OK_0)) || - ((sma1303->rev_num != SMA1303_REV_NUM_TV0) && - ((otp_stat & 0x0C) == SMA1303_OTP_STAT_OK_1))) - dev_info(component->dev, "SMA1303 OTP Status Successful\n"); - else - dev_info(component->dev, "SMA1303 OTP Status Fail\n"); - - for (i = 0; i < (unsigned int)ARRAY_SIZE(sma1303_reg_def); i++) - ret += sma1303_regmap_write(sma1303, - sma1303_reg_def[i].reg, - sma1303_reg_def[i].def); - ret += sma1303_regmap_write(sma1303, SMA1303_0A_SPK_VOL, sma1303->init_vol); @@ -1580,18 +1543,17 @@ static int sma1303_i2c_probe(struct i2c_client *client, { struct sma1303_priv *sma1303; struct device_node *np = client->dev.of_node; - int ret; + int ret, i = 0; u32 value; - unsigned int device_info; - - sma1303 = devm_kzalloc(&client->dev, sizeof(struct sma1303_priv), - GFP_KERNEL); + unsigned int device_info, status, otp_stat; + sma1303 = devm_kzalloc(&client->dev, + sizeof(struct sma1303_priv), GFP_KERNEL); if (!sma1303) return -ENOMEM; + sma1303->dev = &client->dev; sma1303->regmap = devm_regmap_init_i2c(client, &sma_i2c_regmap); - if (IS_ERR(sma1303->regmap)) { ret = PTR_ERR(sma1303->regmap); dev_err(&client->dev, @@ -1671,35 +1633,64 @@ static int sma1303_i2c_probe(struct i2c_client *client, } dev_info(&client->dev, "chip version 0x%02X\n", device_info); - sma1303->last_over_temp = 0xC0; - sma1303->last_ocp_val = 0x08; - sma1303->tsdw_cnt = 0; + ret += sma1303_regmap_update_bits(sma1303, + SMA1303_00_SYSTEM_CTRL, + SMA1303_RESETBYI2C_MASK, SMA1303_RESETBYI2C_RESET); + + ret += sma1303_regmap_read(sma1303, SMA1303_FF_DEVICE_INDEX, &status); + sma1303->rev_num = status & SMA1303_REV_NUM_STATUS; + if (sma1303->rev_num == SMA1303_REV_NUM_TV0) + dev_info(&client->dev, "SMA1303 Trimming Version 0\n"); + else if (sma1303->rev_num == SMA1303_REV_NUM_TV1) + dev_info(&client->dev, "SMA1303 Trimming Version 1\n"); + + ret += sma1303_regmap_read(sma1303, SMA1303_FB_STATUS2, &otp_stat); + if (ret < 0) + dev_err(&client->dev, + "failed to read, register: %02X, ret: %d\n", + SMA1303_FF_DEVICE_INDEX, ret); + + if (((sma1303->rev_num == SMA1303_REV_NUM_TV0) && + ((otp_stat & 0x0E) == SMA1303_OTP_STAT_OK_0)) || + ((sma1303->rev_num != SMA1303_REV_NUM_TV0) && + ((otp_stat & 0x0C) == SMA1303_OTP_STAT_OK_1))) + dev_info(&client->dev, "SMA1303 OTP Status Successful\n"); + else + dev_info(&client->dev, "SMA1303 OTP Status Fail\n"); + + for (i = 0; i < (unsigned int)ARRAY_SIZE(sma1303_reg_def); i++) + ret += sma1303_regmap_write(sma1303, + sma1303_reg_def[i].reg, + sma1303_reg_def[i].def); + + sma1303->amp_mode = SMA1303_MONO; + sma1303->amp_power_status = false; + sma1303->check_fault_period = CHECK_PERIOD_TIME; + sma1303->check_fault_status = true; + sma1303->force_mute_status = false; sma1303->init_vol = 0x31; sma1303->cur_vol = sma1303->init_vol; sma1303->last_bclk = 0; + sma1303->last_ocp_val = 0x08; + sma1303->last_over_temp = 0xC0; + sma1303->tsdw_cnt = 0; - INIT_DELAYED_WORK(&sma1303->check_fault_work, - sma1303_check_fault_worker); + sma1303->dev = &client->dev; + sma1303->kobj = &client->dev.kobj; mutex_init(&sma1303->lock); - sma1303->check_fault_period = CHECK_PERIOD_TIME; - sma1303->dev = &client->dev; - sma1303->kobj = &client->dev.kobj; + INIT_DELAYED_WORK(&sma1303->check_fault_work, + sma1303_check_fault_worker); i2c_set_clientdata(client, sma1303); - sma1303->amp_mode = SMA1303_MONO; - sma1303->amp_power_status = false; - sma1303->force_mute_status = false; - sma1303->check_fault_status = true; sma1303->pll_matches = sma1303_pll_matches; sma1303->num_of_pll_matches = ARRAY_SIZE(sma1303_pll_matches); ret = devm_snd_soc_register_component(&client->dev, &sma1303_component, sma1303_dai, 1); - if (ret) { dev_err(&client->dev, "Failed to register component"); @@ -1708,7 +1699,6 @@ static int sma1303_i2c_probe(struct i2c_client *client, sma1303->attr_grp = &sma1303_attr_group; ret = sysfs_create_group(sma1303->kobj, sma1303->attr_grp); - if (ret) { dev_err(&client->dev, "failed to create attribute group [%d]\n", ret); From patchwork Fri Jan 6 09:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiseok Jo X-Patchwork-Id: 640104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44EA3C5479D for ; Fri, 6 Jan 2023 09:20:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 027591412D; Fri, 6 Jan 2023 10:19:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 027591412D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1672996818; bh=zbfqZTEVmoWiRxl4QzK981QevqrE79UgpYIuwIZOnL4=; h=From:To:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=k13J/K1j0WzLjKs7BAIvqcxt4dOmDkm/4Z5GFt10H6ncHrFElMoVZBUbJN5UO4xbE fLUOu4bj0QN3p9lDdo6Yl0S+8mjmAsFw64mH+gw3KwMqu2rB0zbHJxpkghZzge84qr BrRX6GM5+rfWk76uIGs4NGxwUvgQ/cm0ow6O1vEw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2B5BFF805C5; Fri, 6 Jan 2023 10:16:21 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C89EAF805AC; Fri, 6 Jan 2023 10:16:17 +0100 (CET) Received: from KOR01-SL2-obe.outbound.protection.outlook.com (mail-sl2kor01on2040.outbound.protection.outlook.com [40.107.129.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9A545F805AC for ; Fri, 6 Jan 2023 10:16:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9A545F805AC ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DF0xpFwc60atifLLMGrhb3OnB7XDZGujWO/FJ72Z8u7to5puWXFgmJW4PSx3OpO3P6o9j4Ne+vtwZprAzBw1kjqi8c3Px9MRWW089jjP+DQ1Rt2gQXyfm35J0dLMrNmyWVMfdYSLqNX93oJNR0XOD0j/zLF1SaNW+2iGjifyOWBOp7TKUnadPDKVHQXwC62MpKcbT29/w2FDW2FTIo2NOrkoqv5WfuUG0Z/m9k57fQAL2vekiPfRKjAOarfMHfnxWRpnRBr5EnrRHejcz9Ixs+b5EK5s0Qo4RsF2+tg2RBqfxVMkbRLNVdS3oxkpGZsAhDTSiQsZjmSE/DhLUX/PYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3XKTGBLkjHgnny5QSJtsB+4tYdvlTD4AOZSqOHdGbDc=; b=jlIOqoGcUmYofL/0dyMMQ5KwNmgb0kbrg6CcTmG9E8+Dc5C4Y40K+Qxrgvv/C+9LxE7CjcqbaR3LFYFxfy4fjcJq3G2BEkOiYrTrlS/tOE7vydAaQXnQ/VNb7MdOV0f86Vg3p/bciwQxuJyQ7HsoTam5TrQqA7fZizH7lZYGUsy6Kme3Sg+GNERJnC4mxhM23LjCQFbdhqXNn40ZZ0KCGJ8BotuagcViKZK/IkElivgbYwSgyloxbnzhgtRmznZqwlmMVyDugPpfjAt8c/QCz8ZLn2n/uKCMC7vuUIwr1ogFT/nkFPSsjI5IldbAxTJJfiwv0/u8BudJUHUDXUFxwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=irondevice.com; dmarc=pass action=none header.from=irondevice.com; dkim=pass header.d=irondevice.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=irondevice.com; Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) by PS2P216MB1300.KORP216.PROD.OUTLOOK.COM (2603:1096:301:98::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Fri, 6 Jan 2023 09:16:02 +0000 Received: from SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727]) by SLXP216MB0077.KORP216.PROD.OUTLOOK.COM ([fe80::3d9:7f82:fa73:e727%7]) with mapi id 15.20.5944.019; Fri, 6 Jan 2023 09:16:02 +0000 From: Kiseok Jo To: Mark Brown Subject: [PATCH 14/14] Fixed the retry_cnt bug about being zero Date: Fri, 6 Jan 2023 18:15:43 +0900 Message-Id: <20230106091543.2440-15-kiseok.jo@irondevice.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230106091543.2440-1-kiseok.jo@irondevice.com> References: <20230106091543.2440-1-kiseok.jo@irondevice.com> X-ClientProxiedBy: SL2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:100:41::29) To SLXP216MB0077.KORP216.PROD.OUTLOOK.COM (2603:1096:100:7::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SLXP216MB0077:EE_|PS2P216MB1300:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c131779-4d0e-4236-d3e5-08daefc6a1a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4rSAN80306hVIHwxvWTBlFmCtiEIACVP5XEvjOMYeWw1O5W5qzYiWl3xM4BqvOKaSMRtgUoHd1tTkJLyfHFsFLdeat7niFSDkWffyxJWDVJ4uuzfBnIL+j6634VOWnzutUNUBvUXWKy20xoNR9FDKJKZcyketKWrE4ua8KjyYneUxGMMPsA1k7gkeGDPnfMPJ0dVGAgXG0mRH9xkD7ZmZDYc95jAqv57hB9xu/k50cbMK6Jzvy35kp/azOHyGDjPJ4PKJpKDl6Snj0Z/MPzr5+zvE5XFFjtoPEVYcwXkiLWZ1TkFrV2fFNX4fYKhrnPr6UD6wThId7i/139VfN5QQkVnjE3lpfA/z1R60mqrwdalWeAdcf2vkYavT7GP6sbwfwgcm5lZHFdj81EiJwkbEcYc8ieX8wFqWA8g8o3aPpvS96VkmCnz6hlGytOXcTmV6glkLHS/ZQ69vnCeqcjrIdpGGNnQyAAWfkLmG+lYO5wv0262Xv0LSMmEuHXEuL8WlR4L4XP/PbWZCuMGmNtFPZjpbGojR2RD+SruOLw42ZxhaAlt8Wo5PgPplu7htB/YrPcyklQd+bclj8nseKV/tijiP6PWDNR4dHYty4kj6xJ9eJ7Y6KwCiVy7oK78G23qg3BUelEdt+VB0ctA59qc8p1xYG/57hR5gf5ZPYnQUosMHDGX9Bnf0k/djib2Z/iklZQtBnXAueph7mLF4VdxcQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SLXP216MB0077.KORP216.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230022)(366004)(39840400004)(396003)(376002)(136003)(346002)(451199015)(8936002)(2906002)(5660300002)(44832011)(8676002)(41300700001)(4326008)(54906003)(6916009)(66476007)(66946007)(52116002)(66556008)(316002)(6486002)(478600001)(83380400001)(26005)(186003)(6512007)(6666004)(6506007)(2616005)(38350700002)(1076003)(38100700002)(86362001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sICLrdm3WjNORlPv3KsfNOVHWmBuMTslgwO7jeRJOYHXTrh5+MP9I194tOkXD6S8Bcr2tdM0rGgMxna8eYkVOXInUhk2z7N5rErhDryUyEikHQsIGCr01TOkE6FjPApglpnd5Gn/+3j7cX6diS3P2kE0G0Rz22cXzj6VmYa2c8VUSFybdsSQ4/dGAZx6EIzj5Abn92QK+5DffURGsGc6IYhOH8EnGdat/bIcmJ5ihfjx83n+E5HSRjQpaxXNVvsgCpdu3lHKGnsKbU+x79dvfJ6ngIfJCoTNAbyOCOnVW+bBhuTWILvCWGKKaPlGt/S+RGUrKXx+4MZ7YgftGdic+AYIrq6dD/7uUdRZ6YwqAk4j1gPBLsbiy6NkMD2MC570DApGOhXbYAPEQLXXdHHNXfvo3XTXIXNcwHih0cZ4Jq0NTMJ8LM4h0/i/vt4yUptk1XewQAp7FAXmMUhtVd89lZSKk9P6PyL5tdlBxfVoWSnHmlrJ8GeHrQuoeQ65FPcLjKK6gExNi3gaW/LLD88qNDQFjJj49PhFxCBjGj6tclDyeuC3s30X411Zo3Lt+hTJGUbr6wHgHTLBF9ByyQ/IfJf3ZkgrBlRHRudYdcmqDuruKL+HF7/jcIBJObMGHJx9h38AO4EbwjQb+9RDHQa/TzDNBbNoT5T5yejQ8FsG3zljTir883s54+wlBeMDCEC+XPjulX+6esGdDnoOvrtRJgFdM+3X2VmWzY3G5xc8ZnDPCNzkF6l2xYX3IZGBUOiW/LYfuWqLVtd744gxJ5ZYAaJP+eugSLKAWfksloxKdamkCEW/rYuAD4f5BvmgqI+RMNAnKMCtIrtwvXfD6YTohVyUUKaoyEEj9Zgc4M8Z0sXAdpy1T3spVBURHHOEn3LxUQGSQkYJL9BUlqdO3MXhA29d3eeNQgts9j+z9u83oQ1bgd01ZM4i0Sluo4aqPvJ2GHJUnQMcFHErOBwTGyctMFgDI5ElBB6DXYnnzf3xFlb2ifnPER0UMVjNyZ/Y6/GrW92jnFxZmvWqXuBi1PdeguqgA/41Jl5Tf0bsU3H+Jl5YEG47FMyYiwpY5c+JTHV8pzzwduCbNMANXSOwLUf+tXlygsgjbQGZDw4k9v2T3rJPeUToexqX7Ilb40kEqwaB5o7QkFhR/l6Ye+DcjOTBGk/wFBOHaq1bm8yM7levQvN2+mOIRU80gFLS0kGsDIooBxfplZ3UqCqNmTOFinjDomWqLW55Cm/Eh3mD/nB5WFS5cYxAUQ6tecEvz2pnWKsFVA4EbwSyb6YxP+5XL2TtJSFfBO7XPRLV3BqHoKezOSe0xzhFqqfWjUnfiIAKy1XNs1rA8zbfo73tua2+VwwX42rpvAk93nGD3dKAt9v/Ampfe4qQGAbpI4hE9siVgG2uRyH8zHyHA3cV+g2nYDmrlpyH8Lc5BLAVQjtx+w6Zw/HuetYPzjAsZU5a9MwewxJfnl77yw/8eF5q1nxw5NchBe/LUjW9XbuEdil1EWMDF+ktd0WCBZdfY6+E3DHe+u6ttvGkPkDUXECUoofL0pjFdaMPDoD8FdhcnUoEnRBjrIDt9tEsgohQMGgjresMIeCAIvOgxj/j8TlOPp2PE/w2jQ== X-OriginatorOrg: irondevice.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c131779-4d0e-4236-d3e5-08daefc6a1a6 X-MS-Exchange-CrossTenant-AuthSource: SLXP216MB0077.KORP216.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2023 09:16:02.5505 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b4849faa-3337-494e-a76a-cb25a3b3d7d1 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oSU8TrLuxHsU9rsHT5TlVeeSuo+6mtETlsePzec6clL1NQHKrOrLHNlSnYW8ocvVKN0rDJtjELyBMTFBS+shC5CzqIhdxVHCVTmauT2nn0w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS2P216MB1300 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 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: , Cc: alsa-devel@alsa-project.org, Dan Carpenter , application@irondevice.com, Kiseok Jo , kernel test robot Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Kiseok Jo Reported-by: kernel test robot Reported-by: Dan Carpenter --- sound/soc/codecs/sma1303.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/sma1303.c b/sound/soc/codecs/sma1303.c index 1a5d992bf3db..4f9dab5d1613 100644 --- a/sound/soc/codecs/sma1303.c +++ b/sound/soc/codecs/sma1303.c @@ -247,7 +247,7 @@ EXPORT_SYMBOL(sma1303_set_callback_func); static int sma1303_regmap_write(struct sma1303_priv *sma1303, unsigned int reg, unsigned int val) { - int ret; + int ret = 0; int cnt = sma1303->retry_cnt; while (cnt--) { @@ -266,7 +266,7 @@ static int sma1303_regmap_write(struct sma1303_priv *sma1303, static int sma1303_regmap_update_bits(struct sma1303_priv *sma1303, unsigned int reg, unsigned int mask, unsigned int val) { - int ret; + int ret = 0; int cnt = sma1303->retry_cnt; while (cnt--) { @@ -285,7 +285,7 @@ static int sma1303_regmap_update_bits(struct sma1303_priv *sma1303, static int sma1303_regmap_read(struct sma1303_priv *sma1303, unsigned int reg, unsigned int *val) { - int ret; + int ret = 0; int cnt = sma1303->retry_cnt; while (cnt--) { @@ -772,12 +772,13 @@ static int sma1303_add_component_controls(struct snd_soc_component *component) sma1303_controls = devm_kzalloc(sma1303->dev, sizeof(sma1303_snd_controls), GFP_KERNEL); name = devm_kzalloc(sma1303->dev, - ARRAY_SIZE(sma1303_snd_controls), GFP_KERNEL); + ARRAY_SIZE(sma1303_snd_controls)*sizeof(char *), + GFP_KERNEL); for (index = 0; index < ARRAY_SIZE(sma1303_snd_controls); index++) { sma1303_controls[index] = sma1303_snd_controls[index]; name[index] = devm_kzalloc(sma1303->dev, - MAX_CONTROL_NAME, GFP_KERNEL); + MAX_CONTROL_NAME*sizeof(char), GFP_KERNEL); size = strlen(sma1303_snd_controls[index].name) + strlen(sma1303->dev->driver->name); if (!name[index] || size > MAX_CONTROL_NAME) { @@ -1544,7 +1545,7 @@ static int sma1303_i2c_probe(struct i2c_client *client, struct sma1303_priv *sma1303; struct device_node *np = client->dev.of_node; int ret, i = 0; - u32 value; + u32 value = 0; unsigned int device_info, status, otp_stat; sma1303 = devm_kzalloc(&client->dev, @@ -1564,13 +1565,13 @@ static int sma1303_i2c_probe(struct i2c_client *client, if (np) { if (!of_property_read_u32(np, "i2c-retry", &value)) { - if (value > 50 || value < 0) { + if (value > 50 || value <= 0) { sma1303->retry_cnt = SMA1303_I2C_RETRY_COUNT; dev_info(&client->dev, "%s : %s\n", __func__, "i2c-retry out of range (up to 50)"); } else { sma1303->retry_cnt = value; - dev_info(&client->dev, "%s : %s = %d\n", + dev_info(&client->dev, "%s : %s = %u\n", __func__, "i2c-retry count", value); } } else { @@ -1589,7 +1590,7 @@ static int sma1303_i2c_probe(struct i2c_client *client, } if (!of_property_read_u32(np, "tdm-slot-tx", &value)) { dev_info(&client->dev, - "tdm slot tx is '%d' from DT\n", value); + "tdm slot tx is '%u' from DT\n", value); sma1303->tdm_slot_tx = value; } else { dev_info(&client->dev, @@ -1609,7 +1610,7 @@ static int sma1303_i2c_probe(struct i2c_client *client, break; default: dev_err(&client->dev, - "Invalid sys-clk-id: %d\n", value); + "Invalid sys-clk-id: %u\n", value); return -EINVAL; } sma1303->sys_clk_id = value;