From patchwork Thu Sep 10 10:17:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 249604 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6011:0:0:0:0 with SMTP id o17csp1246463ejj; Thu, 10 Sep 2020 03:20:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0i3CJJM9ACpR07MlxyO/72nG8GY0s9ElmnEq6HwdH/5Fa78hkdToLt/TvhlPt5pt8EB6X X-Received: by 2002:a17:906:5490:: with SMTP id r16mr7713840ejo.222.1599733239812; Thu, 10 Sep 2020 03:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599733239; cv=none; d=google.com; s=arc-20160816; b=gpYU8I8G67q8GB52tdfOVY0f5BIyYpytjpQPplXRNy8ii0i3rxzIglAbHS8CRS5clN I8ZbYYesb2UQubWmiYEfv8dTAaT/auvOQzsAIYDkglOKZjpvrLL2pfNQzocWg/TCxVtT KPmKA4d/DEQEV9OvKR+1V7fECiXGj7iS4r+08c1BJoapZLo0kYBF9vKgkEJLOXV7L69W CSP1pf3867TwdeP/nZ3FOfqm4uXdB6kP8bsF/lZeS1IYPvbV3hi76UGHA7foVFioEzP2 Gg1aLcTTTLsVAIbiR5DqH4ncNPuiFRFFQGivyPU4iBV/7kA8TGKdcdX6oHazJowjxvL+ AwIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=22LyqQo6HEx0we5PVT6YvtjB0CtK+JfHvXfl6GB7W6M=; b=SPVhIxTQJ86mOgDUSu96irrWbjGCnZADKPk7RCZWYzGra1dFjZ29xxM/xFbaZPT4os WUkIE8Xhou9QjcveahgVdXy43vcDlN/fMyrjEfW8gib1zOQE8BVjJDh3Cy9q1uN/Vdg+ 9u3r1AToa6jVOYqjK+mzNXLHEEcFhgDyadhw90Equi+dKg/pmgZE6pUciPQP8eDIDwOi AIWwVdrdqDgjEeqaGxkrCzI15rFfLzR5ZINgSRAwoyrZPtxReqRMfCMkfmskyLq2UsoW 69A4iAlRnTrybNo5H7vxDMFpgzOzY48C2RHP2nl+ECcnbr7FfNn2h6hunuvLdd+3sR30 6haQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKyzkPao; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si3177689edr.13.2020.09.10.03.20.39; Thu, 10 Sep 2020 03:20:39 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xKyzkPao; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730652AbgIJKUF (ORCPT + 6 others); Thu, 10 Sep 2020 06:20:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730619AbgIJKSC (ORCPT ); Thu, 10 Sep 2020 06:18:02 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 202B7C06179B for ; Thu, 10 Sep 2020 03:17:55 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id m6so6107559wrn.0 for ; Thu, 10 Sep 2020 03:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=22LyqQo6HEx0we5PVT6YvtjB0CtK+JfHvXfl6GB7W6M=; b=xKyzkPaoXGrnZ90y19H11Ynf+0/C89moDoqMnGvpgHj1SIoacvU3QQzuR018Oq9sh+ JW8mnCIYkOd05NpgBvxxNqLIV4J9ewS5fXUKw8KUPuJ3G66f5qHg72Dho7OkPaSbIRIe TEE81/brWsk8O34vpIQzVyUaPecx5PqvcUTxdkSiKkFkHIAZYRoRmMz9CPdr0ctL49V+ FIcC9cJzdn8tzzSAKe3Hd43vkqOYBA2zlKMg2/m1u4OEBri2Rs7JEnjwgJ609tonp/g0 D/rc5eN+jzOBbKgHzr1HLaXLq1K1vKrOWyjjx84EY/5QVMqRTawwO4JFhCZlqcU6/jzA USzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=22LyqQo6HEx0we5PVT6YvtjB0CtK+JfHvXfl6GB7W6M=; b=qSfFjj8v0vYQjAkRcCncFsjf2+S14ovt8hzVM1FJPhX2M+GBA/2aXBy6fXL9ytBzZE M3Dj4np+Ej8s8psq4wMP1OnmDhuQw1DbUiLnWj2NG8m3c3DO1Oi3LURDWHuHSTlNCeSq DI0iULZWESoWaT1ZEEEgsLd3Gy22xo4yICWFG6ULjj2HfoZHCWNvMwj4YnMtgkzMzVgB DCSkG1PfDdMhYaE6l/U3s336YpPZnXa6aOqhP7YUVMTInLX/HnArG9DDq3zl/wc4WGcn NBHORbGqbltO3Xo1vFw/SRSsS1TnQ9HDtGgefMd85vuUG6oF5kjbaGHqxAC8ioiDaSjh PFgQ== X-Gm-Message-State: AOAM530ffVjLPhJ6aqijudzlq7/PLXUwztZ0fx8SSKjcBoEHiYbOk5l9 RKc5TRqDTw0CWPF/qIDy0FHCxg== X-Received: by 2002:adf:81c6:: with SMTP id 64mr8024531wra.176.1599733073707; Thu, 10 Sep 2020 03:17:53 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id m4sm8851731wro.18.2020.09.10.03.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 03:17:53 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, robh+dt@kernel.org, plai@codeaurora.org, bgoswami@codeaurora.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 5/8] ASoC: q6dsp: q6afe: add lpass hw voting support Date: Thu, 10 Sep 2020 11:17:29 +0100 Message-Id: <20200910101732.23484-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200910101732.23484-1-srinivas.kandagatla@linaro.org> References: <20200910101732.23484-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/q6afe.c | 99 ++++++++++++++++++++++++++++++++++++ sound/soc/qcom/qdsp6/q6afe.h | 8 +++ 2 files changed, 107 insertions(+) -- 2.21.0 diff --git a/sound/soc/qcom/qdsp6/q6afe.c b/sound/soc/qcom/qdsp6/q6afe.c index 2a8e3c3acb10..51c94dd9998d 100644 --- a/sound/soc/qcom/qdsp6/q6afe.c +++ b/sound/soc/qcom/qdsp6/q6afe.c @@ -43,6 +43,9 @@ #define AFE_PARAM_ID_TDM_CONFIG 0x0001029D #define AFE_PARAM_ID_PORT_SLOT_MAPPING_CONFIG 0x00010297 #define AFE_PARAM_ID_CODEC_DMA_CONFIG 0x000102B8 +#define AFE_CMD_REMOTE_LPASS_CORE_HW_VOTE_REQUEST 0x000100f4 +#define AFE_CMD_RSP_REMOTE_LPASS_CORE_HW_VOTE_REQUEST 0x000100f5 +#define AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST 0x000100f6 /* I2S config specific */ #define AFE_API_VERSION_I2S_CONFIG 0x1 @@ -545,6 +548,18 @@ struct q6afe_port { struct list_head node; }; +struct afe_cmd_remote_lpass_core_hw_vote_request { + uint32_t hw_block_id; + char client_name[8]; +} __packed; + +struct afe_cmd_remote_lpass_core_hw_devote_request { + uint32_t hw_block_id; + uint32_t client_handle; +} __packed; + + + struct afe_port_map { int port_id; int token; @@ -880,6 +895,11 @@ static int q6afe_callback(struct apr_device *adev, struct apr_resp_pkt *data) } } break; + case AFE_CMD_RSP_REMOTE_LPASS_CORE_HW_VOTE_REQUEST: + afe->result.opcode = hdr->opcode; + afe->result.status = res->status; + wake_up(&afe->wait); + break; default: break; } @@ -1593,6 +1613,85 @@ void q6afe_port_put(struct q6afe_port *port) } EXPORT_SYMBOL_GPL(q6afe_port_put); +int q6afe_unvote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, + uint32_t client_handle) +{ + struct q6afe *afe = dev_get_drvdata(dev->parent); + struct afe_cmd_remote_lpass_core_hw_devote_request *vote_cfg; + struct apr_pkt *pkt; + int ret = 0; + int pkt_size; + void *p; + + pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg); + p = kzalloc(pkt_size, GFP_KERNEL); + if (!p) + return -ENOMEM; + + pkt = p; + vote_cfg = p + APR_HDR_SIZE; + + pkt->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, + APR_HDR_LEN(APR_HDR_SIZE), + APR_PKT_VER); + pkt->hdr.pkt_size = pkt_size; + pkt->hdr.src_port = 0; + pkt->hdr.dest_port = 0; + pkt->hdr.token = hw_block_id; + pkt->hdr.opcode = AFE_CMD_REMOTE_LPASS_CORE_HW_DEVOTE_REQUEST; + vote_cfg->hw_block_id = hw_block_id; + vote_cfg->client_handle = client_handle; + + ret = apr_send_pkt(afe->apr, pkt); + if (ret < 0) + dev_err(afe->dev, "AFE failed to unvote (%d)\n", hw_block_id); + + kfree(pkt); + return ret; +} +EXPORT_SYMBOL(q6afe_unvote_lpass_core_hw); + +int q6afe_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, + char *client_name, uint32_t *client_handle) +{ + struct q6afe *afe = dev_get_drvdata(dev->parent); + struct afe_cmd_remote_lpass_core_hw_vote_request *vote_cfg; + struct apr_pkt *pkt; + int ret = 0; + int pkt_size; + void *p; + + pkt_size = APR_HDR_SIZE + sizeof(*vote_cfg); + p = kzalloc(pkt_size, GFP_KERNEL); + if (!p) + return -ENOMEM; + + pkt = p; + vote_cfg = p + APR_HDR_SIZE; + + pkt->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, + APR_HDR_LEN(APR_HDR_SIZE), + APR_PKT_VER); + pkt->hdr.pkt_size = pkt_size; + pkt->hdr.src_port = 0; + pkt->hdr.dest_port = 0; + pkt->hdr.token = hw_block_id; + pkt->hdr.opcode = AFE_CMD_REMOTE_LPASS_CORE_HW_VOTE_REQUEST; + vote_cfg->hw_block_id = hw_block_id; + strlcpy(vote_cfg->client_name, client_name, + sizeof(vote_cfg->client_name)); + + ret = afe_apr_send_pkt(afe, pkt, NULL, + AFE_CMD_RSP_REMOTE_LPASS_CORE_HW_VOTE_REQUEST); + if (ret) + dev_err(afe->dev, "AFE failed to vote (%d)\n", hw_block_id); + + + kfree(pkt); + return ret; +} +EXPORT_SYMBOL(q6afe_vote_lpass_core_hw); + static int q6afe_probe(struct apr_device *adev) { struct q6afe *afe; diff --git a/sound/soc/qcom/qdsp6/q6afe.h b/sound/soc/qcom/qdsp6/q6afe.h index 1f7cbed9335d..93592670ef0b 100644 --- a/sound/soc/qcom/qdsp6/q6afe.h +++ b/sound/soc/qcom/qdsp6/q6afe.h @@ -133,6 +133,10 @@ /* Clock ID for INT MCLK1 */ #define Q6AFE_LPASS_CLK_ID_INT_MCLK_1 0x306 +#define Q6AFE_LPASS_CORE_AVTIMER_BLOCK 0x2 +#define Q6AFE_LPASS_CORE_HW_MACRO_BLOCK 0x3 +#define Q6AFE_LPASS_CORE_HW_DCODEC_BLOCK 0x4 + /* Clock attribute for invalid use (reserved for internal usage) */ #define Q6AFE_LPASS_CLK_ATTRIBUTE_INVALID 0x0 /* Clock attribute for no couple case */ @@ -220,4 +224,8 @@ void q6afe_cdc_dma_port_prepare(struct q6afe_port *port, int q6afe_port_set_sysclk(struct q6afe_port *port, int clk_id, int clk_src, int clk_root, unsigned int freq, int dir); +int q6afe_vote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, + char *client_name, uint32_t *client_handle); +int q6afe_unvote_lpass_core_hw(struct device *dev, uint32_t hw_block_id, + uint32_t client_handle); #endif /* __Q6AFE_H__ */