From patchwork Thu Jan 4 00:04:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1882249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T56L74SnRz1ydb for ; Thu, 4 Jan 2024 11:05:35 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rLBEm-00054y-Af; Thu, 04 Jan 2024 00:05:28 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rLBEA-0004rR-RP for kernel-team@lists.ubuntu.com; Thu, 04 Jan 2024 00:04:52 +0000 Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 8F7F13F74A for ; Thu, 4 Jan 2024 00:04:47 +0000 (UTC) Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-204e4adcf72so9867700fac.1 for ; Wed, 03 Jan 2024 16:04:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704326685; x=1704931485; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XUctszYT1uOSLQsJr4B50Ce0Oo9BNhUcIa2R4gUgHQc=; b=BuxhfXafyXkMsO4LIUOMvC+vYp7XbrotRLlrCDB34NelhSWHa0gNFh+bx88lQmEifu TWCYE8gzuw3zG/q1KHIlWNMOf6FSPXV6mRqSKJdhE6Jkxk8/qXrV6Sc4eJch3LDO+n5d b7bTVmu9V0S2Zy0R5r6vbrtocbmG4FZVS1JwEGAC21DNEoP+cPHiJ7qloY3DWEO/skbM AMUzX3orQYNqb1HDE4qqogwYfywmtEEcO5TcLokl2D7SRmG8aThlwnF6lNJ+syT9OChM U1HJID24VFqLGX+1Ud0FBmVmDJNpxxwPBuE8F2acmBGKrXlY07m0upd2elKi7R16sS7I bUag== X-Gm-Message-State: AOJu0YxOajdLydx8tYLIWPqYoqhhz2/ZigrQvT9yD1WHfjp2y4EaGokP ovDUThf36F9H5I2QogAe3dAcgPV7J6xrCMA8Qm+r8x/NhakegY0pU1OyHfx9oE6Ma1I+mVVqZR8 YX5j7f+UZ+8srFaad0OhS7CQRfClGb/ZTGtRLRghAaFuoWheHM4+326x4 X-Received: by 2002:a05:6870:b69c:b0:203:a983:c7b with SMTP id cy28-20020a056870b69c00b00203a9830c7bmr26981254oab.60.1704326684709; Wed, 03 Jan 2024 16:04:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPznmMYErIKqYv7x9Av42s5qzeuYwRnkeDdyB+kj1YJG6ORV44jLm/ZArYRb+OKe8V1IBwsg== X-Received: by 2002:a05:6870:b69c:b0:203:a983:c7b with SMTP id cy28-20020a056870b69c00b00203a9830c7bmr26981226oab.60.1704326683825; Wed, 03 Jan 2024 16:04:43 -0800 (PST) Received: from portia-desktop.alistair23.me ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id t13-20020a62ea0d000000b006d638fd230bsm24040651pfh.93.2024.01.03.16.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 16:04:41 -0800 (PST) From: Portia Stephens To: portia.stephens@canonical.com, kernel-team@lists.ubuntu.com Subject: [jammy xilinx-zynqmp 2/2] can: xilinx_can: Add support for controller reset Date: Thu, 4 Jan 2024 10:04:30 +1000 Message-Id: <20240104000430.39141-3-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240104000430.39141-1-portia.stephens@canonical.com> References: <20240104000430.39141-1-portia.stephens@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Srinivas Neeli Add support for an optional reset for the CAN controller using the reset driver. If the CAN node contains the "resets" property, then this logic will perform CAN controller reset. BugLink: https://bugs.launchpad.net/bugs/2046280 Signed-off-by: Srinivas Neeli State: pending (cherry-picked from commit 433d2843762819d2601f44bfef02e72c9f710063 https://github.com/Xilinx/linux-xlnx.git) Signed-off-by: Portia Stephens --- drivers/net/can/xilinx_can.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c index 622d71058fc9..5ce99fb7ef22 100644 --- a/drivers/net/can/xilinx_can.c +++ b/drivers/net/can/xilinx_can.c @@ -28,6 +28,7 @@ #include #include #include +#include #define DRIVER_NAME "xilinx_can" @@ -225,6 +226,7 @@ struct xcan_priv { struct clk *bus_clk; struct clk *can_clk; struct xcan_devtype_data devtype; + struct reset_control *rstc; }; /* CAN Bittiming constants as per Xilinx CAN specs */ @@ -1762,6 +1764,17 @@ static int xcan_probe(struct platform_device *pdev) priv->can.do_get_berr_counter = xcan_get_berr_counter; priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_BERR_REPORTING; + priv->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + if (IS_ERR(priv->rstc)) { + dev_err(&pdev->dev, "Cannot get CAN reset.\n"); + ret = PTR_ERR(priv->rstc); + goto err_free; + } + + ret = reset_control_reset(priv->rstc); + if (ret) + goto err_free; + if (devtype->cantype == XAXI_CANFD) priv->can.data_bittiming_const = @@ -1783,7 +1796,7 @@ static int xcan_probe(struct platform_device *pdev) /* Get IRQ for the device */ ret = platform_get_irq(pdev, 0); if (ret < 0) - goto err_free; + goto err_reset; ndev->irq = ret; @@ -1798,14 +1811,14 @@ static int xcan_probe(struct platform_device *pdev) if (IS_ERR(priv->can_clk)) { ret = dev_err_probe(&pdev->dev, PTR_ERR(priv->can_clk), "device clock not found\n"); - goto err_free; + goto err_reset; } priv->bus_clk = devm_clk_get(&pdev->dev, devtype->bus_clk_name); if (IS_ERR(priv->bus_clk)) { ret = dev_err_probe(&pdev->dev, PTR_ERR(priv->bus_clk), "bus clock not found\n"); - goto err_free; + goto err_reset; } priv->write_reg = xcan_write_reg_le; @@ -1854,6 +1867,8 @@ static int xcan_probe(struct platform_device *pdev) err_disableclks: pm_runtime_put(priv->dev); pm_runtime_disable(&pdev->dev); +err_reset: + reset_control_assert(priv->rstc); err_free: free_candev(ndev); err: @@ -1876,6 +1891,7 @@ static int xcan_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); netif_napi_del(&priv->napi); free_candev(ndev); + reset_control_assert(priv->rstc); return 0; }