From patchwork Wed Jan 3 23:56:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Portia Stephens X-Patchwork-Id: 1882246 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 4T568d4F2Zz1yQ5 for ; Thu, 4 Jan 2024 10:57:21 +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 1rLB6o-0003bz-U4; Wed, 03 Jan 2024 23:57:15 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rLB6e-0003Ys-9F for kernel-team@lists.ubuntu.com; Wed, 03 Jan 2024 23:57:04 +0000 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (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-0.canonical.com (Postfix) with ESMTPS id 091763F2C4 for ; Wed, 3 Jan 2024 23:57:04 +0000 (UTC) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-6d9e845c0fbso3508574b3a.2 for ; Wed, 03 Jan 2024 15:57:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704326221; x=1704931021; 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=QQAvqJDwxCA89PKJP6w7Pexo919Xb84BR8NgEbf8zFc1/wF3glq7cF9spdJUw9Ow/Q vUKZFYmn4vX0a+dBSk17+hxMLHBUcNG5C1IZmBctnB/GYw87jxMDh3HJg29D32ncTtA/ aXYnw42+fGCRZInV4BDAduYmHlvJrdkqN8kLnSE5bF2JeVdyAJziCub3WlfCE3AZbhGr 81Hv7jMljF5qR3tjCoGT4xevA2C1kZ3i7hzJAqxNSz8VHPd9ynu7aX24Zc3tVi2WicC8 uj/00TCXGHZgU3o47tnxxECKOuP6KxMv4xwBq7YpUYrwXd7cacdHYY1uTt/ETKQLY2Pq FuoA== X-Gm-Message-State: AOJu0YyMI3myM9ianWz1JglsZ1Ymqfg5MPpN3LkhZQH3aFFUHTRoK+Au vsz08kCNsPg2/lXl/FmZ1XhwTjwurwV/x3TBDM6xSbmVv9yR6xnrbo6WsOOsskeOTDz6Mt/UE16 maXtq6ryPDhi3JP+G1JvYNE1TiBu4EePpG8/NAFGFbaUCdkN1zXBXByCL X-Received: by 2002:a05:6a20:2444:b0:197:4911:7723 with SMTP id t4-20020a056a20244400b0019749117723mr2691763pzc.111.1704326221701; Wed, 03 Jan 2024 15:57:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEc8DR/Rwgv0r8RABm/Z3vfffdJ0/ij0elxbQO/4YAt/jF8mHlFlG0iHk8vfMtWwiSUqpmcbw== X-Received: by 2002:a05:6a20:2444:b0:197:4911:7723 with SMTP id t4-20020a056a20244400b0019749117723mr2691759pzc.111.1704326221429; Wed, 03 Jan 2024 15:57:01 -0800 (PST) Received: from portia-desktop.alistair23.me ([159.196.41.205]) by smtp.gmail.com with ESMTPSA id 4-20020a17090a1a0400b0028cec396567sm2136011pjk.44.2024.01.03.15.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:56:59 -0800 (PST) From: Portia Stephens To: kernel-team@lists.ubuntu.com, portia.stephens@canonical.com Subject: [jammy xilinx-zynqmp v2 2/2] can: xilinx_can: Add support for controller reset Date: Thu, 4 Jan 2024 09:56:46 +1000 Message-Id: <20240103235646.36605-3-portia.stephens@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240103235646.36605-1-portia.stephens@canonical.com> References: <20240103235646.36605-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; }