From patchwork Thu Jun 21 13:40:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 139545 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2090163lji; Thu, 21 Jun 2018 06:42:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKytnrZyCx5ldet/5Akl0UVFSxwFFznb6kFSH0OYL/64VFtCMKD40EeMNsogjzQngYS59Q6 X-Received: by 2002:a65:53cc:: with SMTP id z12-v6mr22714985pgr.350.1529588554640; Thu, 21 Jun 2018 06:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529588554; cv=none; d=google.com; s=arc-20160816; b=fOiaPEOWG6S4yekGpPfy21ghKk+7/nMVhs/vyJZBBGrxSENknMIP7TWiCG20jcvxyf TqBY16FgKwamZaaBRqrQ1ek/pkaK23yYl/7cICwpJAQGebMp3ILShy9ASEmdJC84AOoG mOUZC3u+admE3FGwEcBN/HYbT3qsDS/CIpjDtNM5w84Mtqe4S7Fq6mesIdL1GFw5asWF X8Mtz8xp4UlrfsqxkTYTYbIQCS56CynmwAzBlVEzKxNkRGQmV/SUAVychm1MOsjOu/Rh I/b6rIXQDZcbZiOH6/6SQ+q65bIFnTHKLR6mLA3GQmyW/K4Ry7ZwItrEl30n9hhP/keF dP1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=b0XtHaymtfJPBWDPP9vzlIciQBkG4cM6RMPhQhkToHk=; b=MtVqeNB8Fd8Jt8temNNc2O9XG+n+bj8RjdyQNoFIB+4SuSXC12WZxRmkXCkEn9Zc1k owt98kkUJDoADcDLZZ7qojdDLwgvJVBTmd+X5BQgYvEleUlViHTDsA9MfBs3YXTIfX80 P6OaCaiAOt4ExwRTh4YtZg540g4th0hqjlys3MNJT3BJANQRlQwKK6BapcKAmUdScvke R8JJkbR7wUuOqWRJQij5QRkLKe5Iqy+ope0AslCX0rMnN+D3cSFU8+sn39dB2wEUdDTk FNDOpaH/ACm+zp4ovIUQaFaGhCcgRQx3MalIb2qx627Y6QrvE0/gYIEX25vlXZ3bGvA6 E9Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eBnYtZng; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14-v6si3960701pgq.146.2018.06.21.06.42.34; Thu, 21 Jun 2018 06:42:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eBnYtZng; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932944AbeFUNmd (ORCPT + 13 others); Thu, 21 Jun 2018 09:42:33 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35944 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933247AbeFUNmZ (ORCPT ); Thu, 21 Jun 2018 09:42:25 -0400 Received: by mail-wm0-f67.google.com with SMTP id v131-v6so6210098wma.1 for ; Thu, 21 Jun 2018 06:42:24 -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; bh=qXsd+t8b9Dy24QvVjspIYua14NLzhEbPkVr4FzHhvRE=; b=eBnYtZnghM8fD8wGnU7w+7CEVJYr26NcdaQs8/dfqiJU5IYKMsnJvm38xNI4Ucsj0+ DrTXOA9CbSf5q98aNMJOFgzxIxPaNEyBDrfqIPXnK6TfK6Mbk9SonO9iOWZ8XvX7KZA7 tPkW4obLe49TpfWq+skoHqPXla4JYxoACpiIw= 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; bh=qXsd+t8b9Dy24QvVjspIYua14NLzhEbPkVr4FzHhvRE=; b=etxBorvD0V7pkj+lxh+Rx6AznXDKPscAb08NdGCHfw2s9+E5RWG8AOVhByWS8Hc5Wk mC+zUnEJK8K02D0Xtv9GwR3JPZga+n+RbcTCELStHi5ewYeSvvJKFE/3g6H2HGSJJzeT Suf9k2t8780thMR/BwMaWONpFvd+GFs+mwQYo00UvqzF5++LbWh+3ATwc6SBx9TC6Uu8 vr1/ZLvZsjmrqRc0wdS6dWdsvBlS6iwF4gnXj8yKfCSzHXWp8d4OWWUii6I80VXHh8s1 kR5ZeqbXnh559aR36/ZuWOG9+T7Iq2atTmvO0aSSAqKME0gfhDJrvkwbOfiTvlcNNQV6 KTMw== X-Gm-Message-State: APt69E1kmLTXWJBLqVEXO4iAE45A2FrVzFszdXhNb2bWzlxRvfYb2ZAm +dKlm7lvs5b//DJEc1/ofKgUgg== X-Received: by 2002:a1c:f902:: with SMTP id x2-v6mr4933369wmh.116.1529588543654; Thu, 21 Jun 2018 06:42:23 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id r2-v6sm4797513wrq.55.2018.06.21.06.42.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jun 2018 06:42:23 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org, broonie@kernel.org Cc: sdharia@quicinc.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, ctatlor97@gmail.com, vkoul@kernel.org, Srinivas Kandagatla Subject: [PATCH 2/2] slimbus: ngd: add stream support Date: Thu, 21 Jun 2018 14:40:09 +0100 Message-Id: <20180621134009.27116-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180621134009.27116-1-srinivas.kandagatla@linaro.org> References: <20180621134009.27116-1-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This patch adds support to stream support, this involve implementing user specific implementation of Data channel management and channel management SLIMbus messages. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/qcom-ngd-ctrl.c | 144 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) -- 2.16.2 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c index 8554e3f43522..aa597f50f040 100644 --- a/drivers/slimbus/qcom-ngd-ctrl.c +++ b/drivers/slimbus/qcom-ngd-ctrl.c @@ -603,7 +603,9 @@ static void qcom_slim_ngd_rx(struct qcom_slim_ngd_ctrl *ctrl, u8 *buf) if (mc == SLIM_MSG_MC_REPLY_INFORMATION || mc == SLIM_MSG_MC_REPLY_VALUE || (mc == SLIM_USR_MC_ADDR_REPLY && - mt == SLIM_MSG_MT_SRC_REFERRED_USER)) { + mt == SLIM_MSG_MT_SRC_REFERRED_USER) || + (mc == SLIM_USR_MC_GENERIC_ACK && + mt == SLIM_MSG_MT_SRC_REFERRED_USER)) { slim_msg_response(&ctrl->ctrl, &buf[4], buf[3], len - 4); pm_runtime_mark_last_busy(ctrl->dev); } @@ -766,7 +768,10 @@ static int qcom_slim_ngd_xfer_msg(struct slim_controller *sctrl, { struct qcom_slim_ngd_ctrl *ctrl = dev_get_drvdata(sctrl->dev); DECLARE_COMPLETION_ONSTACK(tx_sent); - int ret, timeout; + DECLARE_COMPLETION_ONSTACK(done); + int ret, timeout, i; + u8 wbuf[SLIM_MSGQ_BUF_LEN]; + u8 rbuf[SLIM_MSGQ_BUF_LEN]; u32 *pbuf; u8 *puc; u8 la = txn->la; @@ -794,6 +799,40 @@ static int qcom_slim_ngd_xfer_msg(struct slim_controller *sctrl, return -ENOMEM; } + if (txn->mt == SLIM_MSG_MT_CORE && + (txn->mc == SLIM_MSG_MC_CONNECT_SOURCE || + txn->mc == SLIM_MSG_MC_CONNECT_SINK || + txn->mc == SLIM_MSG_MC_DISCONNECT_PORT)) { + + txn->mt = SLIM_MSG_MT_DEST_REFERRED_USER; + if (txn->mc == SLIM_MSG_MC_CONNECT_SOURCE) + txn->mc = SLIM_USR_MC_CONNECT_SRC; + else if (txn->mc == SLIM_MSG_MC_CONNECT_SINK) + txn->mc = SLIM_USR_MC_CONNECT_SINK; + else if (txn->mc == SLIM_MSG_MC_DISCONNECT_PORT) + txn->mc = SLIM_USR_MC_DISCONNECT_PORT; + i = 0; + wbuf[i++] = txn->la; + la = SLIM_LA_MGR; + wbuf[i++] = txn->msg->wbuf[0]; + if (txn->mc != SLIM_USR_MC_DISCONNECT_PORT) + wbuf[i++] = txn->msg->wbuf[1]; + + txn->comp = &done; + ret = slim_alloc_txn_tid(sctrl, txn); + if (ret) { + dev_err(ctrl->dev, "Unable to allocate TID\n"); + return ret; + } + + wbuf[i++] = txn->tid; + + txn->msg->num_bytes = i; + txn->msg->wbuf = wbuf; + txn->msg->rbuf = rbuf; + txn->rl = txn->msg->num_bytes + 4; + } + /* HW expects length field to be excluded */ txn->rl--; puc = (u8 *)pbuf; @@ -830,6 +869,19 @@ static int qcom_slim_ngd_xfer_msg(struct slim_controller *sctrl, return -ETIMEDOUT; } + if (txn->mt == SLIM_MSG_MT_DEST_REFERRED_USER && + (txn->mc == SLIM_USR_MC_CONNECT_SRC || + txn->mc == SLIM_USR_MC_CONNECT_SINK || + txn->mc == SLIM_USR_MC_DISCONNECT_PORT)) { + timeout = wait_for_completion_timeout(&done, HZ); + if (!timeout) { + dev_err(sctrl->dev, "TX timed out:MC:0x%x,mt:0x%x", + txn->mc, txn->mt); + return -ETIMEDOUT; + } + + } + return 0; } @@ -856,6 +908,93 @@ static int qcom_slim_ngd_xfer_msg_sync(struct slim_controller *ctrl, return 0; } +static int qcom_slim_ngd_enable_stream(struct slim_stream_runtime *rt) +{ + struct slim_device *sdev = rt->dev; + struct slim_controller *ctrl = sdev->ctrl; + struct slim_val_inf msg = {0}; + u8 wbuf[SLIM_MSGQ_BUF_LEN]; + u8 rbuf[SLIM_MSGQ_BUF_LEN]; + struct slim_msg_txn txn = {0,}; + int i, ret; + + txn.mt = SLIM_MSG_MT_DEST_REFERRED_USER; + txn.dt = SLIM_MSG_DEST_LOGICALADDR; + txn.la = SLIM_LA_MGR; + txn.ec = 0; + txn.msg = &msg; + txn.msg->num_bytes = 0; + txn.msg->wbuf = wbuf; + txn.msg->rbuf = rbuf; + + for (i = 0; i < rt->num_ports; i++) { + struct slim_port *port = &rt->ports[i]; + + if (txn.msg->num_bytes == 0) { + int seg_interval = SLIM_SLOTS_PER_SUPERFRAME/rt->ratem; + int exp; + + wbuf[txn.msg->num_bytes++] = sdev->laddr; + wbuf[txn.msg->num_bytes] = rt->bps >> 2 | + (port->ch.aux_fmt << 6); + + /* Data channel segment interval not multiple of 3 */ + exp = seg_interval % 3; + if (exp) + wbuf[txn.msg->num_bytes] |= BIT(5); + + txn.msg->num_bytes++; + wbuf[txn.msg->num_bytes++] = exp << 4 | rt->prot; + + if (rt->prot == SLIM_PROTO_ISO) + wbuf[txn.msg->num_bytes++] = + port->ch.prrate | + SLIM_CHANNEL_CONTENT_FL; + else + wbuf[txn.msg->num_bytes++] = port->ch.prrate; + + ret = slim_alloc_txn_tid(ctrl, &txn); + if (ret) { + dev_err(&sdev->dev, "Fail to allocate TID\n"); + return -ENXIO; + } + wbuf[txn.msg->num_bytes++] = txn.tid; + } + wbuf[txn.msg->num_bytes++] = port->ch.id; + } + + txn.mc = SLIM_USR_MC_DEF_ACT_CHAN; + txn.rl = txn.msg->num_bytes + 4; + ret = qcom_slim_ngd_xfer_msg_sync(ctrl, &txn); + if (ret) { + slim_free_txn_tid(ctrl, &txn); + dev_err(&sdev->dev, "TX timed out:MC:0x%x,mt:0x%x", txn.mc, + txn.mt); + return ret; + } + + txn.mc = SLIM_USR_MC_RECONFIG_NOW; + txn.msg->num_bytes = 2; + wbuf[1] = sdev->laddr; + txn.rl = txn.msg->num_bytes + 4; + + ret = slim_alloc_txn_tid(ctrl, &txn); + if (ret) { + dev_err(ctrl->dev, "Fail to allocate TID\n"); + return ret; + } + + wbuf[0] = txn.tid; + ret = qcom_slim_ngd_xfer_msg_sync(ctrl, &txn); + if (ret) { + slim_free_txn_tid(ctrl, &txn); + dev_err(&sdev->dev, "TX timed out:MC:0x%x,mt:0x%x", txn.mc, + txn.mt); + } + + return ret; +} + static int qcom_slim_ngd_get_laddr(struct slim_controller *ctrl, struct slim_eaddr *ea, u8 *laddr) { @@ -1288,6 +1427,7 @@ static int qcom_slim_ngd_ctrl_probe(struct platform_device *pdev) ctrl->ctrl.a_framer = &ctrl->framer; ctrl->ctrl.clkgear = SLIM_MAX_CLK_GEAR; ctrl->ctrl.get_laddr = qcom_slim_ngd_get_laddr; + ctrl->ctrl.enable_stream = qcom_slim_ngd_enable_stream; ctrl->ctrl.xfer_msg = qcom_slim_ngd_xfer_msg; ctrl->ctrl.wakeup = NULL; ctrl->state = QCOM_SLIM_NGD_CTRL_DOWN;