From patchwork Wed Jun 21 09:30:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13286977 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27DE0D51E for ; Wed, 21 Jun 2023 09:31:12 +0000 (UTC) Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56AFC1997 for ; Wed, 21 Jun 2023 02:31:11 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f766777605so7522136e87.1 for ; Wed, 21 Jun 2023 02:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339869; x=1689931869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iUVZalfP6V27NAYz5kQTxrxcxQh7F8OqnR+1IuXKgno=; b=1NSCmre2p7CtkNBkBJvdszJkRwwGaioXWZdO9EoPmJnoKNEGXXEu6EFvU6OgprI5xc tNLkv1dB9ERCHrEUpnTmLZDBzjMzhSVv4UdIs49WCyTKl8Kh/tuD9bFDYntp0pq77pkh rAo12jFi/yvwkjV6rGqstr6iqTzJgJ65dZl8q2XnC53Duoonqw3IhHvngOffXYqqEG3N Xm0SbOk8kbFQCK3y7GZwC8TlYnRblyaNUE2ptaLDzkOoXlopaD4qC8VTiVYh/iUbrdSJ Fp3M3vuvPtPIWQV/Hz+KWNLxB8jMJSZf0+6FxPzEv16pO8LfN7RRV2bpfV9JQl2eBTws 2q/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339869; x=1689931869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iUVZalfP6V27NAYz5kQTxrxcxQh7F8OqnR+1IuXKgno=; b=Hr9T0XCv0WuSRFso2T3JYCdLTSHq9n4CUtBDTqFVvb5v8sfmi3TuBDIuSqyUHQ686D ELR63qWjkPTtIpiJPJv0SU8sjEgvyshHZMrvqSAtrHO/27226+OhLgbVl+cJ+X72fXRx bc2MSGSKw9F6NftcTI1gEkUfu47QwY5iEe+uJd4rK8Xx0/aj07RkHdeikk5u9tSXdPjp DDCbVJz7KReGPRZUYYcPgX1G+qrdzMapJW6+hFTWcZUF/kRemV+Bc1vL+lgwCm6XJRSY itRg1VX/xj/R1++X+Bhm+v1oRktqLn+7L+8oNK24Mks+xA4oHRBE/nurYc0aC7HKudIw Sr6g== X-Gm-Message-State: AC+VfDxUUdMdi2mTPUT5OPneW+pbHSEUgytLZVSwnGFvtsUNy3vSxKgc +fZZ5OOKoOFvht9JQuDDzHppuw== X-Google-Smtp-Source: ACHHUZ5niONPbfuy2pOl3UdRueK/q4eJCqkzPPKmPZ8iuLpRxdjpzGVdHt5BRKAlNXSVVVJQYSq+HQ== X-Received: by 2002:a19:5053:0:b0:4f9:5519:78b8 with SMTP id z19-20020a195053000000b004f9551978b8mr2520136lfj.63.1687339869403; Wed, 21 Jun 2023 02:31:09 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:b762:4f68:e1ed:5041]) by smtp.gmail.com with ESMTPSA id t10-20020a5d49ca000000b002fe96f0b3acsm3977344wrs.63.2023.06.21.02.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:31:08 -0700 (PDT) From: Markus Schneider-Pargmann To: Wolfgang Grandegger , Marc Kleine-Budde , Rob Herring , Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Conor Dooley , Chandrasekar Ramakrishnan , Michal Kubiak , Vivek Yadav , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Markus Schneider-Pargmann Subject: [PATCH v2 1/6] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants Date: Wed, 21 Jun 2023 11:30:58 +0200 Message-Id: <20230621093103.3134655-2-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230621093103.3134655-1-msp@baylibre.com> References: <20230621093103.3134655-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org These two new chips do not have state or wake pins. Signed-off-by: Markus Schneider-Pargmann Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/net/can/tcan4x5x.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/net/can/tcan4x5x.txt b/Documentation/devicetree/bindings/net/can/tcan4x5x.txt index e3501bfa22e9..170e23f0610d 100644 --- a/Documentation/devicetree/bindings/net/can/tcan4x5x.txt +++ b/Documentation/devicetree/bindings/net/can/tcan4x5x.txt @@ -4,7 +4,10 @@ Texas Instruments TCAN4x5x CAN Controller This file provides device node information for the TCAN4x5x interface contains. Required properties: - - compatible: "ti,tcan4x5x" + - compatible: + "ti,tcan4552", "ti,tcan4x5x" + "ti,tcan4553", "ti,tcan4x5x" or + "ti,tcan4x5x" - reg: 0 - #address-cells: 1 - #size-cells: 0 @@ -21,8 +24,10 @@ Optional properties: - reset-gpios: Hardwired output GPIO. If not defined then software reset. - device-state-gpios: Input GPIO that indicates if the device is in - a sleep state or if the device is active. - - device-wake-gpios: Wake up GPIO to wake up the TCAN device. + a sleep state or if the device is active. Not + available with tcan4552/4553. + - device-wake-gpios: Wake up GPIO to wake up the TCAN device. Not + available with tcan4552/4553. Example: tcan4x5x: tcan4x5x@0 { From patchwork Wed Jun 21 09:30:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13286978 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D958DDB0 for ; Wed, 21 Jun 2023 09:31:14 +0000 (UTC) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73FA1170C for ; Wed, 21 Jun 2023 02:31:12 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3111547c8f9so6627350f8f.1 for ; Wed, 21 Jun 2023 02:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339871; x=1689931871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aOPR69iAQ16PRI3TWa1E2gZcgSDBVpUe2mB3Tg7XdFY=; b=p6VfhCsZ1XQVk+UFLTJRo9cf3iTipfn7+MBuZGX/3xu99DkZWmG8tzt/4QEiu0vdoP SwlKwJZpil8SEzBGic9Sdgl41L2ROAyA7fjHmwCysGNFyiJ2HXeo4xDhFyiizQzpbGAb pFEwDePat4OO5iNIvyfT6kCa1Y1wwPfNVqWTUay+XSTDaay8iLXaiNAWpNJosnHvR002 85B6egNdHCN4pFH1hnrVd2eyXbxaTHobsIy0GYO0HIrF0qrfTKXUZWMqa3bWv6qy4XO8 Fmtgt9r0knq3H5Xf8bnbXgXrDmp7C2UqP5JkHSCkA99CZSH22vhgwzEkEOE5iahxQgJf FIAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339871; x=1689931871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aOPR69iAQ16PRI3TWa1E2gZcgSDBVpUe2mB3Tg7XdFY=; b=Rms+y5bhKU6GdDJCNKubwU8Z4lpESJb5Cw9XDBWnuGZActfQJ3NOCkmobARqe1dWr6 JD0VD8+7sMYi1dmN3Eywa4OS2SwsHMQ1ZipA4J92/I4PRPhWnecTL8MzApOT/rgHc4m5 3jRU28x2Owd2YUR5uzBCEGPtWoHe9WtefjuEwCovjak+qNJnP7nEIzKp3SRuyF9hk5IM Y1OlE48IMR+DKLb7ZJM8Y3SdAQhZf5Db218QtK/GdOftsHuBxTfw7MkMwqDJGx5dHIxq 63/VGtgTFGIsZiUDwQ7okQpk61gSrvHQAes/oyhV6odu3nYYsNRxuldPS/k3AiIlS2tl 052w== X-Gm-Message-State: AC+VfDxdh8CzjcMBxkAVlf24xPnEIpa4/I9aEV1Y9a9t3pLhnyrbO9d5 u/P+TAw0jPWVtbzaPIUVcURPIw== X-Google-Smtp-Source: ACHHUZ7h1oBelfPdJ7hS0YJrsBMI7+8RNi0jGbeXTETw7BrgmXNO4eGVgr+m/lxb6bEa7Izo9X0Sqw== X-Received: by 2002:adf:f287:0:b0:311:13e6:650a with SMTP id k7-20020adff287000000b0031113e6650amr12500326wro.28.1687339870910; Wed, 21 Jun 2023 02:31:10 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:b762:4f68:e1ed:5041]) by smtp.gmail.com with ESMTPSA id t10-20020a5d49ca000000b002fe96f0b3acsm3977344wrs.63.2023.06.21.02.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:31:10 -0700 (PDT) From: Markus Schneider-Pargmann To: Wolfgang Grandegger , Marc Kleine-Budde , Rob Herring , Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Conor Dooley , Chandrasekar Ramakrishnan , Michal Kubiak , Vivek Yadav , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Markus Schneider-Pargmann Subject: [PATCH v2 2/6] can: tcan4x5x: Remove reserved register 0x814 from writable table Date: Wed, 21 Jun 2023 11:30:59 +0200 Message-Id: <20230621093103.3134655-3-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230621093103.3134655-1-msp@baylibre.com> References: <20230621093103.3134655-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The mentioned register is not writable. It is reserved and should not be written. Fixes: 39dbb21b6a29 ("can: tcan4x5x: Specify separate read/write ranges") Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Michal Kubiak --- drivers/net/can/m_can/tcan4x5x-regmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/can/m_can/tcan4x5x-regmap.c b/drivers/net/can/m_can/tcan4x5x-regmap.c index 2b218ce04e9f..fafa6daa67e6 100644 --- a/drivers/net/can/m_can/tcan4x5x-regmap.c +++ b/drivers/net/can/m_can/tcan4x5x-regmap.c @@ -95,7 +95,6 @@ static const struct regmap_range tcan4x5x_reg_table_wr_range[] = { regmap_reg_range(0x000c, 0x0010), /* Device configuration registers and Interrupt Flags*/ regmap_reg_range(0x0800, 0x080c), - regmap_reg_range(0x0814, 0x0814), regmap_reg_range(0x0820, 0x0820), regmap_reg_range(0x0830, 0x0830), /* M_CAN */ From patchwork Wed Jun 21 09:31:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13286979 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7916DF57 for ; Wed, 21 Jun 2023 09:31:15 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A30291989 for ; Wed, 21 Jun 2023 02:31:13 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-30fbf253dc7so4561748f8f.0 for ; Wed, 21 Jun 2023 02:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339872; x=1689931872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ybtO4Wog7AXA+LuJ7ppZ2BwN9dyYZ5NmmDbgKQHeLHM=; b=GbEYPR52b9eyHWmMfQU9tvxe081wY8nIF6gJ+LgJ2SlgFQ61zD+2NzGNljuXKeWy24 LICZ2j4cIUIqB4M9uHH9OBqCAf81admdZooSMEzGnVTZlENGAJArH+OU0feZq4wZJOIJ Vvmyp1jnZUar0x3VDO97AP/HdoH9AoCKcyIa/32nekVLkhrKozliSJQmm6MdckAS7A1d 43G5aKpBfnpfF8e4HGgwvkwzwk0ERyZ/t+jxxVJGFEiSAhKR7nkVegtGqXe0vJySt9CZ Z0BZB4msJpteWeG4DHueVVr5CfwIUnYQExTnPDUsxSv8vYpYVsW6e2jl8xXbVPL4Qhu4 tNWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339872; x=1689931872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ybtO4Wog7AXA+LuJ7ppZ2BwN9dyYZ5NmmDbgKQHeLHM=; b=ECUwiyezT+xjjEG6yX3h5rfg5eik2rwfPM8LPPltQYpzvlKzQX5BKJj0J6xArvzdrx TC8PLgXdXTmffV5vNK3ZBXBGB9tDpxT27SAladswu1e0RmrdDpRE+pJRAafLQerR3FT2 RFsLlvt4Bfc4Opt6aTFOP3JqQvwv0Jue2aOiwETLexvwIpQi9L9iQdnCCnlxP/YxzfU8 mF/UJ/n/w1XGTFj+b88n40yQ3sSdM/YS3DlIeda3ZxOp60Eqw9p5/47ffBl9LrCJlPBS h+Y0gGrnYxT97PnVSv6QbpX3oX5SsCXY3ANRX1tiHOiRmj6udAhFEBI+GeOLtJdnPVS4 wqGA== X-Gm-Message-State: AC+VfDw2K1j+9mguDP2PlYKv16rD1HOtLT7fOtR9JH9YgJO67V1h7zqL FLoM98Cp1GnH6iBSzPxSh3W0Tg== X-Google-Smtp-Source: ACHHUZ6N4ShxDPmm0lHjPVsFzQjzdixQQokpJC6Xp7OpddAHkKElZIycIIwE8vb2xIbBKwges4fvGg== X-Received: by 2002:a5d:6501:0:b0:30f:c420:1743 with SMTP id x1-20020a5d6501000000b0030fc4201743mr12562307wru.26.1687339872182; Wed, 21 Jun 2023 02:31:12 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:b762:4f68:e1ed:5041]) by smtp.gmail.com with ESMTPSA id t10-20020a5d49ca000000b002fe96f0b3acsm3977344wrs.63.2023.06.21.02.31.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:31:11 -0700 (PDT) From: Markus Schneider-Pargmann To: Wolfgang Grandegger , Marc Kleine-Budde , Rob Herring , Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Conor Dooley , Chandrasekar Ramakrishnan , Michal Kubiak , Vivek Yadav , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Markus Schneider-Pargmann Subject: [PATCH v2 3/6] can: tcan4x5x: Check size of mram configuration Date: Wed, 21 Jun 2023 11:31:00 +0200 Message-Id: <20230621093103.3134655-4-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230621093103.3134655-1-msp@baylibre.com> References: <20230621093103.3134655-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org To reduce debugging effort in case the mram is misconfigured, add this size check of the DT configuration. Currently if the mram configuration doesn't fit into the available MRAM it just overwrites other areas of the MRAM. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Michal Kubiak --- drivers/net/can/m_can/m_can.c | 16 ++++++++++++++++ drivers/net/can/m_can/m_can.h | 1 + drivers/net/can/m_can/tcan4x5x-core.c | 5 +++++ 3 files changed, 22 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index a5003435802b..1cdd2675f022 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1887,6 +1887,22 @@ static int register_m_can_dev(struct net_device *dev) return register_candev(dev); } +int m_can_check_mram_cfg(struct m_can_classdev *cdev, u32 mram_max_size) +{ + u32 total_size; + + total_size = cdev->mcfg[MRAM_TXB].off - cdev->mcfg[MRAM_SIDF].off + + cdev->mcfg[MRAM_TXB].num * TXB_ELEMENT_SIZE; + if (total_size > mram_max_size) { + dev_err(cdev->dev, "Total size of mram config(%u) exceeds mram(%u)\n", + total_size, mram_max_size); + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_GPL(m_can_check_mram_cfg); + static void m_can_of_parse_mram(struct m_can_classdev *cdev, const u32 *mram_config_vals) { diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index a839dc71dc9b..d8150d8128e7 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -101,6 +101,7 @@ int m_can_class_register(struct m_can_classdev *cdev); void m_can_class_unregister(struct m_can_classdev *cdev); int m_can_class_get_clocks(struct m_can_classdev *cdev); int m_can_init_ram(struct m_can_classdev *priv); +int m_can_check_mram_cfg(struct m_can_classdev *cdev, u32 mram_max_size); int m_can_class_suspend(struct device *dev); int m_can_class_resume(struct device *dev); diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index 2342aa011647..e706518176e4 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -80,6 +80,7 @@ TCAN4X5X_MCAN_IR_RF1F) #define TCAN4X5X_MRAM_START 0x8000 +#define TCAN4X5X_MRAM_SIZE 0x800 #define TCAN4X5X_MCAN_OFFSET 0x1000 #define TCAN4X5X_CLEAR_ALL_INT 0xffffffff @@ -307,6 +308,10 @@ static int tcan4x5x_can_probe(struct spi_device *spi) if (!mcan_class) return -ENOMEM; + ret = m_can_check_mram_cfg(mcan_class, TCAN4X5X_MRAM_SIZE); + if (ret) + goto out_m_can_class_free_dev; + priv = cdev_to_priv(mcan_class); priv->power = devm_regulator_get_optional(&spi->dev, "vsup"); From patchwork Wed Jun 21 09:31:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13286980 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29394F9C0 for ; Wed, 21 Jun 2023 09:31:16 +0000 (UTC) Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCBA5170C for ; Wed, 21 Jun 2023 02:31:14 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3f9c0abc8b1so3383435e9.1 for ; Wed, 21 Jun 2023 02:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339873; x=1689931873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tK3XW9CvIKNotY0VMKRibuYSfqNfjSdewyrI1jRS2zM=; b=vvdnouFDr5rb5PrRGsiwpdR9r3jMNwu2DJKvMiB+TZcBK9nVZqtjy4UYTSQ4p9v/VP AquDpYPH11jrF5fDASMF0QD9sJEtSrMVtpn4yTrfXcrzYRXBVSUfh2j8cqsfBFxl6wTQ LmmUZA3e3tI2GkjWfMnNEG3XGt5EgaGGOhZA6bzTEwgGegB/VylAiRHrvVfHS0fVbHuQ bfIUDZN+XP5AHAn0UFS+tCcSTpqsif6XY8g0v6JNt3OixPHVV2E/2if5qputFSnY8AkV w5dl7UPoPIRGpkOn5p4VxIO1FmgwCj7Lu+5VB0Ymn7gcjmTddwZD9HzLFJBnZ0KPr8G8 dL7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339873; x=1689931873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tK3XW9CvIKNotY0VMKRibuYSfqNfjSdewyrI1jRS2zM=; b=UafpFUynV9kg2fZREMXGe+0riU+Sr22x8y8MpktJKTtglGFN7qL8qgCPiv+JX/qQEV Ajc32oegjZDWKMBKbxoQy3L3VIdTp7cGsPM0HF9eVqWMXz4GamWMUDXDIQ1DuPBbhmde QLOaWVfJNj0becxKDxVhDU+qBtTLzc41JADcIlGr19dZ0meYIJQnS279W2HiMnJDuZuv aMv7N7I8gsFB9wHghHTf+eS/CY0PD5fZ7nXtooQMylX0Sne39sY68wIDHkv3/w8GXL3E 2TC7RV14g9foYih0zpyEji+C42bfK75pyBh4cxSFoYsVWfuKCQzf7sR6/pJYHV+tmfSL wl0A== X-Gm-Message-State: AC+VfDwljYWwHAY/1a57g8WztQt1WYu0ZgFoXNUeOJHGP8l0XQGGPYnD ldq+Mc/TXt/4d47o8bddo45Rhg== X-Google-Smtp-Source: ACHHUZ7COqfi5t5n61Ie+ILJw3861GrMcUy4TqaeUI4JHKNwaDVVPooLUubzz7WmMReSJ+T8lRhG0A== X-Received: by 2002:a05:600c:2051:b0:3f7:3545:4630 with SMTP id p17-20020a05600c205100b003f735454630mr15189344wmg.20.1687339873364; Wed, 21 Jun 2023 02:31:13 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:b762:4f68:e1ed:5041]) by smtp.gmail.com with ESMTPSA id t10-20020a5d49ca000000b002fe96f0b3acsm3977344wrs.63.2023.06.21.02.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:31:12 -0700 (PDT) From: Markus Schneider-Pargmann To: Wolfgang Grandegger , Marc Kleine-Budde , Rob Herring , Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Conor Dooley , Chandrasekar Ramakrishnan , Michal Kubiak , Vivek Yadav , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Markus Schneider-Pargmann Subject: [PATCH v2 4/6] can: tcan4x5x: Rename ID registers to match datasheet Date: Wed, 21 Jun 2023 11:31:01 +0200 Message-Id: <20230621093103.3134655-5-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230621093103.3134655-1-msp@baylibre.com> References: <20230621093103.3134655-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The datasheet calls these registers ID1 and ID2. Rename these to avoid confusion. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Michal Kubiak --- drivers/net/can/m_can/tcan4x5x-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index e706518176e4..fb9375fa20ec 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -6,8 +6,8 @@ #define TCAN4X5X_EXT_CLK_DEF 40000000 -#define TCAN4X5X_DEV_ID0 0x00 -#define TCAN4X5X_DEV_ID1 0x04 +#define TCAN4X5X_DEV_ID1 0x00 +#define TCAN4X5X_DEV_ID2 0x04 #define TCAN4X5X_REV 0x08 #define TCAN4X5X_STATUS 0x0C #define TCAN4X5X_ERROR_STATUS_MASK 0x10 From patchwork Wed Jun 21 09:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13286981 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E551BFBEC for ; Wed, 21 Jun 2023 09:31:18 +0000 (UTC) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21D1419AC for ; Wed, 21 Jun 2023 02:31:16 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-307d20548adso4598970f8f.0 for ; Wed, 21 Jun 2023 02:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339874; x=1689931874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r9i7Uk9aCK3lESxenmpxDJxkyZ2pr8k/0UfT23fdTCU=; b=HMgfcToT+99atd0bEiOKT3uanwqjHO/q5VjUGAtCm8HErnMups9azwMX8fcFcKdIQl 6lyWoxMdiAxsrjuZTTGn98YG1dCeeQRiGOqr6gcjASDjukONjjHPxvtsQfhUiVcBIDcY EhtHaUF0BIw8TWhppvIrNxdkl48e7fD9VY+rn6oEwpktSkLwEeiq5G3B+KIle89b2Q8+ UTI0aXxydtrWn6JMb2tGM/tdzMRShsIpVFgravjjptsWm3WaWZxCU1BvlU75zWFr2llR vNltpYb/766oVwx5ICst7gjtM02ZNO79qA822hHN0W0MyEPHUzfKsTiIWeX3RXkHxh+8 wmxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339874; x=1689931874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r9i7Uk9aCK3lESxenmpxDJxkyZ2pr8k/0UfT23fdTCU=; b=jmbsLsIlIXxGC6uM4jyUQ3aL6Zx7/6+cPiVwkdFtWRxKscUkeyNB6QIasuXshAFQCT dgIFd3Qo96LcLhr1daBU87J5VYY/y98XI9Qv4AWDYJlRkLhwLOlwzrz0GG8eeX7ajQ3f J51/HTY0wyJ/9QbVdXAid9j5d5ERaawy8UUP4iYdAZAAcSjdy5FBbyyslQiLUXPZO6HZ Hf8smgt85WhwJ1VUC2KgPxnomtdnMTK3ew0S2PrRgKNEaGRU6Yb97p47XrrPghocZV6P XkjparTJKUnTn2eYUqjcYLZOckDafSpPvi5oUWvCq+ZCzOdyQauVmLXd85CElOBCZzyn nITg== X-Gm-Message-State: AC+VfDzYe7YNEOeLH/xVFI6VqxI4hD43Yvx+fZi7xzoOtpjinADHSg9d ipSBIPLVMdnilTslwA7q2WUyYw== X-Google-Smtp-Source: ACHHUZ7Pu7OaqYZZMO9Cjox1GAG9gZTMhbuui5bdyWhgpv6HpGu/DrL+U5iPrc3XAkpwSKqppaw1rw== X-Received: by 2002:adf:e489:0:b0:311:d3c:df0 with SMTP id i9-20020adfe489000000b003110d3c0df0mr9514734wrm.43.1687339874666; Wed, 21 Jun 2023 02:31:14 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:b762:4f68:e1ed:5041]) by smtp.gmail.com with ESMTPSA id t10-20020a5d49ca000000b002fe96f0b3acsm3977344wrs.63.2023.06.21.02.31.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:31:14 -0700 (PDT) From: Markus Schneider-Pargmann To: Wolfgang Grandegger , Marc Kleine-Budde , Rob Herring , Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Conor Dooley , Chandrasekar Ramakrishnan , Michal Kubiak , Vivek Yadav , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Markus Schneider-Pargmann Subject: [PATCH v2 5/6] can: tcan4x5x: Add support for tcan4552/4553 Date: Wed, 21 Jun 2023 11:31:02 +0200 Message-Id: <20230621093103.3134655-6-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230621093103.3134655-1-msp@baylibre.com> References: <20230621093103.3134655-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org tcan4552 and tcan4553 do not have wake or state pins, so they are currently not compatible with the generic driver. The generic driver uses tcan4x5x_disable_state() and tcan4x5x_disable_wake() if the gpios are not defined. These functions use register bits that are not available in tcan4552/4553. This patch adds support by introducing version information to reflect if the chip has wake and state pins. Also the version is now checked. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/tcan4x5x-core.c | 128 +++++++++++++++++++++----- 1 file changed, 104 insertions(+), 24 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index fb9375fa20ec..756acd122075 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -7,6 +7,7 @@ #define TCAN4X5X_EXT_CLK_DEF 40000000 #define TCAN4X5X_DEV_ID1 0x00 +#define TCAN4X5X_DEV_ID1_TCAN 0x4e414354 /* ASCII TCAN */ #define TCAN4X5X_DEV_ID2 0x04 #define TCAN4X5X_REV 0x08 #define TCAN4X5X_STATUS 0x0C @@ -103,6 +104,13 @@ #define TCAN4X5X_WD_3_S_TIMER BIT(29) #define TCAN4X5X_WD_6_S_TIMER (BIT(28) | BIT(29)) +struct tcan4x5x_version_info { + u32 id2_register; + + bool has_wake_pin; + bool has_state_pin; +}; + static inline struct tcan4x5x_priv *cdev_to_priv(struct m_can_classdev *cdev) { return container_of(cdev, struct tcan4x5x_priv, cdev); @@ -254,18 +262,68 @@ static int tcan4x5x_disable_state(struct m_can_classdev *cdev) TCAN4X5X_DISABLE_INH_MSK, 0x01); } -static int tcan4x5x_get_gpios(struct m_can_classdev *cdev) +static const struct tcan4x5x_version_info tcan4x5x_generic; +static const struct of_device_id tcan4x5x_of_match[]; + +static const struct tcan4x5x_version_info +*tcan4x5x_find_version_info(struct tcan4x5x_priv *priv, u32 id2_value) +{ + for (int i = 0; tcan4x5x_of_match[i].data; ++i) { + const struct tcan4x5x_version_info *vinfo = + tcan4x5x_of_match[i].data; + if (!vinfo->id2_register || id2_value == vinfo->id2_register) { + dev_warn(&priv->spi->dev, "TCAN device is %s, please use it in DT\n", + tcan4x5x_of_match[i].compatible); + return vinfo; + } + } + + return &tcan4x5x_generic; +} + +static int tcan4x5x_verify_version(struct tcan4x5x_priv *priv, + const struct tcan4x5x_version_info **info) +{ + u32 val; + int ret; + + ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID1, &val); + if (ret) + return ret; + + if (val != TCAN4X5X_DEV_ID1_TCAN) { + dev_err(&priv->spi->dev, "Not a tcan device %x\n", val); + return -ENODEV; + } + + if (!(*info)->id2_register) + return 0; + + ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID2, &val); + if (ret) + return ret; + + if ((*info)->id2_register != val) + *info = tcan4x5x_find_version_info(priv, val); + + return 0; +} + +static int tcan4x5x_get_gpios(struct m_can_classdev *cdev, + const struct tcan4x5x_version_info *version_info) { struct tcan4x5x_priv *tcan4x5x = cdev_to_priv(cdev); int ret; - tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake", - GPIOD_OUT_HIGH); - if (IS_ERR(tcan4x5x->device_wake_gpio)) { - if (PTR_ERR(tcan4x5x->device_wake_gpio) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (version_info->has_wake_pin) { + tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake", + GPIOD_OUT_HIGH); + if (IS_ERR(tcan4x5x->device_wake_gpio)) { + if (PTR_ERR(tcan4x5x->device_wake_gpio) == -EPROBE_DEFER) + return -EPROBE_DEFER; - tcan4x5x_disable_wake(cdev); + tcan4x5x_disable_wake(cdev); + } } tcan4x5x->reset_gpio = devm_gpiod_get_optional(cdev->dev, "reset", @@ -277,12 +335,14 @@ static int tcan4x5x_get_gpios(struct m_can_classdev *cdev) if (ret) return ret; - tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev, - "device-state", - GPIOD_IN); - if (IS_ERR(tcan4x5x->device_state_gpio)) { - tcan4x5x->device_state_gpio = NULL; - tcan4x5x_disable_state(cdev); + if (version_info->has_state_pin) { + tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev, + "device-state", + GPIOD_IN); + if (IS_ERR(tcan4x5x->device_state_gpio)) { + tcan4x5x->device_state_gpio = NULL; + tcan4x5x_disable_state(cdev); + } } return 0; @@ -299,10 +359,15 @@ static struct m_can_ops tcan4x5x_ops = { static int tcan4x5x_can_probe(struct spi_device *spi) { + const struct tcan4x5x_version_info *version_info; struct tcan4x5x_priv *priv; struct m_can_classdev *mcan_class; int freq, ret; + version_info = of_device_get_match_data(&spi->dev); + if (!version_info) + version_info = (void *)spi_get_device_id(spi)->driver_data; + mcan_class = m_can_class_allocate_dev(&spi->dev, sizeof(struct tcan4x5x_priv)); if (!mcan_class) @@ -361,7 +426,11 @@ static int tcan4x5x_can_probe(struct spi_device *spi) if (ret) goto out_m_can_class_free_dev; - ret = tcan4x5x_get_gpios(mcan_class); + ret = tcan4x5x_verify_version(priv, &version_info); + if (ret) + goto out_power; + + ret = tcan4x5x_get_gpios(mcan_class, version_info); if (ret) goto out_power; @@ -394,21 +463,32 @@ static void tcan4x5x_can_remove(struct spi_device *spi) m_can_class_free_dev(priv->cdev.net); } +static const struct tcan4x5x_version_info tcan4x5x_generic = { + .has_state_pin = true, + .has_wake_pin = true, +}; + +static const struct tcan4x5x_version_info tcan4x5x_tcan4552 = { + .id2_register = 0x32353534, /* ASCII = 4552 */ +}; + +static const struct tcan4x5x_version_info tcan4x5x_tcan4553 = { + .id2_register = 0x33353534, /* ASCII = 4553 */ +}; + static const struct of_device_id tcan4x5x_of_match[] = { - { - .compatible = "ti,tcan4x5x", - }, { - /* sentinel */ - }, + { .compatible = "ti,tcan4552", .data = &tcan4x5x_tcan4552 }, + { .compatible = "ti,tcan4553", .data = &tcan4x5x_tcan4553 }, + { .compatible = "ti,tcan4x5x", .data = &tcan4x5x_generic }, + { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, tcan4x5x_of_match); static const struct spi_device_id tcan4x5x_id_table[] = { - { - .name = "tcan4x5x", - }, { - /* sentinel */ - }, + { .name = "tcan4x5x", .driver_data = (unsigned long)&tcan4x5x_generic, }, + { .name = "tcan4552", .driver_data = (unsigned long)&tcan4x5x_tcan4552, }, + { .name = "tcan4553", .driver_data = (unsigned long)&tcan4x5x_tcan4553, }, + { /* sentinel */ } }; MODULE_DEVICE_TABLE(spi, tcan4x5x_id_table); From patchwork Wed Jun 21 09:31:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13286982 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89367FBEC for ; Wed, 21 Jun 2023 09:31:19 +0000 (UTC) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44AFC19B5 for ; Wed, 21 Jun 2023 02:31:17 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f900cd3f96so44918895e9.2 for ; Wed, 21 Jun 2023 02:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1687339876; x=1689931876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iCNYj/86/5sdpI0dqVl7psoKKhFSLSkxZDdeHiB+vfs=; b=zKBvUDeuh/AFGKGg1KW0cPS/Z+YJwgyTetO5WMcCNXlsdpA6DjdA+JCVw45yfuzOQ7 +ggePlPV3BBZnFVirubbyFlazU9n8ZAQj0zkNJ/DD+8+2atf/UTfto6Um/z+4M4Zq6B9 EjBubPtKj/umzTqO5cGA7NrHohxZE4BCTl1MBpXkc8BnPRZwr9YUtV/s4CYuyxjCbokc P5vyN9h0L5kRalzYsd99rB177VmsDdNE8fI4EFcRb8+b6tJOlJ8DZiTvy3pnH0pRaWcZ tHRdrkMTSwHYtYfyih96fQ+/L8iuf0mZH0mZ5GaI7ysumftvk8TaZMPd5kO9ke+Ysz0U X8aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687339876; x=1689931876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iCNYj/86/5sdpI0dqVl7psoKKhFSLSkxZDdeHiB+vfs=; b=BOQICw4iiATEmnokc17oeU63Em0tyolNeYIDwjo90ARNwOD9dAHj6T4C34e/XHlI9u IO+YJIa5Ml6p3ZGAaqTARbkDFqX2CTQk/pFUxqysYERLbDqT5nvod19euA9Uaqo6F2Nr PT2N+aFOjOl7KO73Fjyo6lCg25+PXpKcifDzFc7MF4v7kGt8DVaXbfbMDqbEgTR6ve45 0Tt/GdisYmDTUWXvotQ/NziBWT+HEvou/eVXEMTIWv4NTCgwr56/CIySoUUk/ylVarwu oW9lOV57Z2ULMPozRKStaErj92zD4FknINhkwYSG6OjuHWaYTMDxM7dmE+oDIB4eb9uM X0Gg== X-Gm-Message-State: AC+VfDyvBcL6lZVcWEjcx2z7rW+71OasYKUZLD4o+AGaiK94gh7CQa9+ zYGNRfnx6mbUfKBwLNQxwMJn4Q== X-Google-Smtp-Source: ACHHUZ7UtUgNUTqAfGOg4L/0CMP4+0xc+qarTvVyytZqEa5kddJf6P2sJTX0FK96SnjlHw6+Bk3Cpg== X-Received: by 2002:a05:600c:248:b0:3f9:b3b4:4367 with SMTP id 8-20020a05600c024800b003f9b3b44367mr5036089wmj.15.1687339875812; Wed, 21 Jun 2023 02:31:15 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a247:82fa:b762:4f68:e1ed:5041]) by smtp.gmail.com with ESMTPSA id t10-20020a5d49ca000000b002fe96f0b3acsm3977344wrs.63.2023.06.21.02.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 02:31:15 -0700 (PDT) From: Markus Schneider-Pargmann To: Wolfgang Grandegger , Marc Kleine-Budde , Rob Herring , Krzysztof Kozlowski Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Conor Dooley , Chandrasekar Ramakrishnan , Michal Kubiak , Vivek Yadav , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Markus Schneider-Pargmann Subject: [PATCH v2 6/6] can: tcan4x5x: Add error messages in probe Date: Wed, 21 Jun 2023 11:31:03 +0200 Message-Id: <20230621093103.3134655-7-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230621093103.3134655-1-msp@baylibre.com> References: <20230621093103.3134655-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org To be able to understand issues during probe easier, add error messages if something fails. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/tcan4x5x-core.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index 756acd122075..e30faa1cf893 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -397,6 +397,8 @@ static int tcan4x5x_can_probe(struct spi_device *spi) /* Sanity check */ if (freq < 20000000 || freq > TCAN4X5X_EXT_CLK_DEF) { + dev_err(&spi->dev, "Clock frequency is out of supported range %d\n", + freq); ret = -ERANGE; goto out_m_can_class_free_dev; } @@ -415,32 +417,44 @@ static int tcan4x5x_can_probe(struct spi_device *spi) /* Configure the SPI bus */ spi->bits_per_word = 8; ret = spi_setup(spi); - if (ret) + if (ret) { + dev_err(&spi->dev, "SPI setup failed %d\n", ret); goto out_m_can_class_free_dev; + } ret = tcan4x5x_regmap_init(priv); - if (ret) + if (ret) { + dev_err(&spi->dev, "regmap init failed %d\n", ret); goto out_m_can_class_free_dev; + } ret = tcan4x5x_power_enable(priv->power, 1); - if (ret) + if (ret) { + dev_err(&spi->dev, "Enabling regulator failed %d\n", ret); goto out_m_can_class_free_dev; + } ret = tcan4x5x_verify_version(priv, &version_info); if (ret) goto out_power; ret = tcan4x5x_get_gpios(mcan_class, version_info); - if (ret) + if (ret) { + dev_err(&spi->dev, "Getting gpios failed %d\n", ret); goto out_power; + } ret = tcan4x5x_init(mcan_class); - if (ret) + if (ret) { + dev_err(&spi->dev, "tcan initialization failed %d\n", ret); goto out_power; + } ret = m_can_class_register(mcan_class); - if (ret) + if (ret) { + dev_err(&spi->dev, "Failed registering m_can device %d\n", ret); goto out_power; + } netdev_info(mcan_class->net, "TCAN4X5X successfully initialized.\n"); return 0;