From patchwork Thu Sep 10 13:38:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manivannan Sadhasivam X-Patchwork-Id: 249619 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp753159ilk; Thu, 10 Sep 2020 06:47:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7s3mZnWZZq7XbccQAU4SvWMn0PjMymIPOEJI/jWLIL5DEa/Oi61G6tDOOBDTvSQMNqeX8 X-Received: by 2002:a05:6402:1558:: with SMTP id p24mr9130226edx.194.1599745670784; Thu, 10 Sep 2020 06:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599745670; cv=none; d=google.com; s=arc-20160816; b=ntOjc5oYa1NCNCD42whSjR/GQ3PSduKMyngVa1yy3kUeXqB7bSj/nIH15DQrlQJyX1 q4lx6EBXtEUUR2WIvDoNRidz7o/vHJ6F58i3LpOoZllAY5jhxENjBe88VUpv/Qr8VE3g ChH4pXlD5qPJowwaWRLJplPeoX6xNkLdeDdbJjXg+cTw/xijeHX/BVlaM+zg89TxAjCr VlQHk10BJKKgm0o3G0qYmnGKJd/8WYPtwopQnWfDt0g4w/2iz2MG4R7N66EOXHkRNC37 34dbXAwgKyy5O6b+HnS9ZzB+SIpsK8kgTPdto0eFVMx2C1S/fU2WiADlqTZSWfVlvrsQ 36kQ== 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; bh=/0UJlMMYS97ZEd1pzZy1E70sLlZzGqr7O+AUirQ/jf8=; b=I9fOs3YgZZUPzjs5f9m2tZjTcrnOfxeIR26NoPySddzcyReyzS2ZwYaGB6VmcXKzO5 K89ByPZ/If6aCBD/Zl8QdRW32d8Dfs0jv82EVurTKtyAD2p2l2Qpq1SimXa1trobPCkm 88QicYvx/fvWpdsu2aPZ/uNB33ZJULVhIx2AOBuPg5bBZHeKWvYtbaQR4fKq5aexYwkf gcN5d+8oM1IOS1jkt5OJhtHL/tgJiU7e16E5eBB2a85elmZDltWcuyXe/7XOD7y2RYly w+t0yDj+ATQ2aNCVWBdv2z9EccQRp8DDKase9+Bsxj5rSpT5TcgcfnNc+CdK+koMfUBx lijg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JWLt/K0Q"; 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 f27si3611945ejt.420.2020.09.10.06.47.50; Thu, 10 Sep 2020 06:47:50 -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="JWLt/K0Q"; 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 S1730940AbgIJNrb (ORCPT + 6 others); Thu, 10 Sep 2020 09:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730957AbgIJNlY (ORCPT ); Thu, 10 Sep 2020 09:41:24 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBD1AC0617A4 for ; Thu, 10 Sep 2020 06:38:36 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id l191so4261836pgd.5 for ; Thu, 10 Sep 2020 06:38:36 -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=/0UJlMMYS97ZEd1pzZy1E70sLlZzGqr7O+AUirQ/jf8=; b=JWLt/K0QwNvzoj6nxqKPcWAMMXsRyj3oN5+4omDOjxwKh6VeMqT0tOggHi3F5AYIbt hyxo5lP35yLC+r5RRZWsGyW9UD6G6hm5mW+ADILi1Dx59pSfOnkl9/xG79xybquIlCoH DyvTbrQzw43bvNGC6PdmN3nZHYQSm/Xd0bIqyFoCceAhDa5mfOugjvUD8i8vrGipBWg+ lrW5SQU3A/CUOJncDK5n26xHziFS7caOipKAve2w4lQ5me4Pe3f0dwnvCJTbfJyXp414 AhmAVU5GTrcKuNrA3ZaUk+yiBVryOa4cmozrqoePAqtkn7dyg53KoTrqedbYX86jouPV yNoQ== 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=/0UJlMMYS97ZEd1pzZy1E70sLlZzGqr7O+AUirQ/jf8=; b=SUK1e/5iotVny1Ej+SN4Tog+jWM5Vt6YH0yt3M16vxNZDbA439zgK+8y1rtchgsDoB mSZasw4RSPDrNiwiAY2Pj/4CBERB0D1n2wPFi9FzVNG3HO30oSCy4IX2vWYaAz2TeaqB ACEfIlfMF/Mpf0J9NjpuZzNkiAcCv7mkbM1H4PxsG2iNm0a1Gj2HDD8/SRfezAvBPAcC 9ZCQ+R73QtPPLrboPFIiq45vzBiF5XveSxpTw+t59GAWGy6yKUaWQKsQWZGR5+0GVXb5 sG5FujV5GsFQPaIFIq/5GUNN+3cqlIdbwG2sXouGxbP9OvbVdXBVsOOEP6jwBA/tvgcu 8CBw== X-Gm-Message-State: AOAM533k610118G1HJgfXdIO9Xr5+FHgHW1g0vgmRy0HPboahHxfM4iV fWqa4SYhXFQnHJH/DBAJOD7JVQTlseUnc+M= X-Received: by 2002:a62:19c2:: with SMTP id 185mr5497347pfz.1.1599745115588; Thu, 10 Sep 2020 06:38:35 -0700 (PDT) Received: from localhost.localdomain ([103.59.133.81]) by smtp.googlemail.com with ESMTPSA id o30sm5603801pgc.45.2020.09.10.06.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 06:38:35 -0700 (PDT) From: Manivannan Sadhasivam To: wg@grandegger.com, mkl@pengutronix.de, robh+dt@kernel.org Cc: linux-can@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dev.kurt@vandijck-laurijssen.be, o.rempel@pengutronix.de, Manivannan Sadhasivam Subject: [PATCH 5/6] can: mcp25xxfd: add listen-only mode Date: Thu, 10 Sep 2020 19:08:05 +0530 Message-Id: <20200910133806.25077-6-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200910133806.25077-1-manivannan.sadhasivam@linaro.org> References: <20200910133806.25077-1-manivannan.sadhasivam@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Kurt Van Dijck This commit enables listen-only mode, which works internally like CANFD mode. Signed-off-by: Kurt Van Dijck Signed-off-by: Marc Kleine-Budde Signed-off-by: Manivannan Sadhasivam --- drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c b/drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c index eea3ef69f585..905ea98448cd 100644 --- a/drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c +++ b/drivers/net/can/spi/mcp25xxfd/mcp25xxfd-core.c @@ -392,7 +392,8 @@ static int mcp25xxfd_ring_alloc(struct mcp25xxfd_priv *priv) int ram_free, i; tef_obj_size = sizeof(struct mcp25xxfd_hw_tef_obj); - if (priv->can.ctrlmode & CAN_CTRLMODE_FD) { + /* listen-only mode works like FD mode */ + if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_FD)) { tx_obj_num = MCP25XXFD_TX_OBJ_NUM_CANFD; tx_obj_size = sizeof(struct mcp25xxfd_hw_tx_obj_canfd); rx_obj_size = sizeof(struct mcp25xxfd_hw_rx_obj_canfd); @@ -807,7 +808,7 @@ mcp25xxfd_chip_rx_fifo_init_one(const struct mcp25xxfd_priv *priv, MCP25XXFD_REG_FIFOCON_RXOVIE | MCP25XXFD_REG_FIFOCON_TFNRFNIE; - if (priv->can.ctrlmode & CAN_CTRLMODE_FD) + if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_FD)) fifo_con |= FIELD_PREP(MCP25XXFD_REG_FIFOCON_PLSIZE_MASK, MCP25XXFD_REG_FIFOCON_PLSIZE_64); else @@ -857,7 +858,7 @@ static int mcp25xxfd_chip_fifo_init(const struct mcp25xxfd_priv *priv) MCP25XXFD_REG_FIFOCON_TXEN | MCP25XXFD_REG_FIFOCON_TXATIE; - if (priv->can.ctrlmode & CAN_CTRLMODE_FD) + if (priv->can.ctrlmode & (CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_FD)) val |= FIELD_PREP(MCP25XXFD_REG_FIFOCON_PLSIZE_MASK, MCP25XXFD_REG_FIFOCON_PLSIZE_64); else @@ -930,7 +931,9 @@ static u8 mcp25xxfd_get_normal_mode(const struct mcp25xxfd_priv *priv) { u8 mode; - if (priv->can.ctrlmode & CAN_CTRLMODE_FD) + if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) + mode = MCP25XXFD_REG_CON_MODE_LISTENONLY; + else if (priv->can.ctrlmode & CAN_CTRLMODE_FD) mode = MCP25XXFD_REG_CON_MODE_MIXED; else mode = MCP25XXFD_REG_CON_MODE_CAN2_0; @@ -2767,8 +2770,9 @@ static int mcp25xxfd_probe(struct spi_device *spi) priv->can.do_get_berr_counter = mcp25xxfd_get_berr_counter; priv->can.bittiming_const = &mcp25xxfd_bittiming_const; priv->can.data_bittiming_const = &mcp25xxfd_data_bittiming_const; - priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING | - CAN_CTRLMODE_FD | CAN_CTRLMODE_FD_NON_ISO; + priv->can.ctrlmode_supported = CAN_CTRLMODE_LISTENONLY | + CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_FD | + CAN_CTRLMODE_FD_NON_ISO; priv->ndev = ndev; priv->spi = spi; priv->rx_int = rx_int;