From patchwork Fri Jul 28 14:19:18 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: 708055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73158C04A6A for ; Fri, 28 Jul 2023 14:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237001AbjG1OTb (ORCPT ); Fri, 28 Jul 2023 10:19:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236473AbjG1OTa (ORCPT ); Fri, 28 Jul 2023 10:19:30 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B54F3ABA for ; Fri, 28 Jul 2023 07:19:28 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3fc04692e20so23479405e9.0 for ; Fri, 28 Jul 2023 07:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1690553967; x=1691158767; 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=KudsjLXhwuLL2d8mNXrF7qeXjTkj4g+r6rSckABUYoI=; b=Z2kDCPjN1LPXmd6+dLzNEdwFl0tm/J1OLyqOgx9lpAsei0DTcOZ9Rm1TDDyeMaVx4Q 3TANE5fPp+7puCmC7KkIkWm8DLldEvX2ymDm6Z3g86nbpRbss9VIUAsUEukjSlLf107L l07dHdPmuGB1D1F6XIuVwYaY4mWWFIc2GEC4tbe4UoB6KPJdJHyPrTjvWZkFocjJMFFh INI30gTj79+BSROU9eSzL7vz5c9j23uYGU+fMqgGmzsmpmPKqyRIc8wCFo9ra4nfADpW AujkGy8Gsl+XROI4Q/lME/cNih96/ktTbwm7FBKcBPack9lbfXjLSlqPdw+pCbBH/j+5 MFcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690553967; x=1691158767; 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=KudsjLXhwuLL2d8mNXrF7qeXjTkj4g+r6rSckABUYoI=; b=YVos6TWTPQI22fnd9KxLoqrU0U/aq2VT3eYMnNeaVkjrQBB584qUWu2Tr6Dt0cB6Zb iryLRYa58YxxIpmewAHyqCCEiHhOjSSnLtU6Pi6UL44I4v4La0j6oBKhG2Qhna5MO+AR IZRegSrhAsTBfSkFl0KwFxSq6JdM7oX1/Qgq9gj++ngnmeULQQFe9Iaa4DblWSDJ3EIL 9VzPoh1cjc+cFACcF15Cc/8MXRAk3K7PdHEOX+WqiEDwW6gSttL2YyVDP4b7yApxLXyB Hhc42rFc3Jcv+qlLz3M/ueG7t4kKf0koIv7Efob+VAsgkfehKI0IMcUyB1VixtP3K5id w3ow== X-Gm-Message-State: ABy/qLYvNUl2n/YeBhuK/13lqApAwsdZeBU5THdcIkckUiGyylP1UZjS /MsU70txpcYcTNW9rNGtWBak4A== X-Google-Smtp-Source: APBJJlFlCbcYPtP9PubsLuQd0EaqWiZsnjn2BGoHiyX0S1ujBgKIIU8F6mzjr6MSr0vf3fYIXplKTw== X-Received: by 2002:a1c:4c12:0:b0:3fd:ad65:ea8b with SMTP id z18-20020a1c4c12000000b003fdad65ea8bmr1857466wmf.12.1690553966984; Fri, 28 Jul 2023 07:19:26 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a246:80e3:766f:be78:d79a:8686]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b0031416362e23sm5013681wrm.3.2023.07.28.07.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 07:19:26 -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 , Krzysztof Kozlowski Subject: [PATCH v4 1/6] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants Date: Fri, 28 Jul 2023 16:19:18 +0200 Message-Id: <20230728141923.162477-2-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230728141923.162477-1-msp@baylibre.com> References: <20230728141923.162477-1-msp@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.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 Fri Jul 28 14:19:19 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: 707656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BAEDC41513 for ; Fri, 28 Jul 2023 14:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237004AbjG1OTc (ORCPT ); Fri, 28 Jul 2023 10:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236992AbjG1OTb (ORCPT ); Fri, 28 Jul 2023 10:19:31 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ADC03ABB for ; Fri, 28 Jul 2023 07:19:29 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fe110de46dso4461755e9.1 for ; Fri, 28 Jul 2023 07:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1690553968; x=1691158768; 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=eCfDNPSl7vSoyBHYmOveE8fuDlgi8ZipveyzGaTlPOC0Q2OpbSPndzkwgMyclgAda/ V6WTHb/DKo1bo2kDoa0OhOJhJ4PL5NQqBFKROAUwm4e9A72r5un/Wtm8JoiZhb4l0DE1 Vs++o1lVFVOTFyUwli6h3oJ+wHe8tIxqaUvdlCDdAphocUK+ygU+y9/PrDVt7fIk7CW7 Ms2GNLTCZO5/X4rTwRGcPHx0MtToecCzRNkrPA7W26gLn5kE3H/GoJhCCBHIbzGQIXn5 Jszk8Jw96jdQ0daJjcTZN11nmfyS6iMVC2HVfmGVY0NLDFC3N9ANmvlVym1ZBAg+pMsx d+pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690553968; x=1691158768; 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=VOnQeJAFb7pqIyY4ZeVN0GrrSnLvA7gjLwMNTjLhA/eyGGt68qrxwFaAeM/hdn9Jeb A6lmw0OBBFh6Tu5zaHH9vwfENLAamYqfwM07yLuOaegCED2lvZdOEJgrzDmKeHgN1bhK hWUPl8uv/lDDA3izBZ4EhCp2NdeVzrjqO/o5utTI8uplaSztPVJo+Ybc3oeuq7pz6GA8 OcY+IZ6f4Z4xFRZU+Na7ZOmhFnG02suEbWKWyiL2CDYQBOx609XCu79N2OUma9Ul2mkT sampBzqhjdSVbp1HZ4NY1EpIwJzLNNYz+BAvBcBksvWWgQXcbcdCUvV0voFibseVLCN3 +B2g== X-Gm-Message-State: ABy/qLZwB7JGjBM06N75y6WCHeCuvZLUxIGT81pFvoGNOi0QWIssjKoI fKXPBNQj9+8UtKd+oD6BXE0ZgQ== X-Google-Smtp-Source: APBJJlFhR9WAI6qiGI8oGXWvZ/UsZ0vbMPJ3iXVMm2YZyySkV1K6NGpHXIsauRuCoGnRq9hod7gT/A== X-Received: by 2002:a5d:5101:0:b0:313:f5f8:a331 with SMTP id s1-20020a5d5101000000b00313f5f8a331mr1763758wrt.34.1690553967911; Fri, 28 Jul 2023 07:19:27 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a246:80e3:766f:be78:d79a:8686]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b0031416362e23sm5013681wrm.3.2023.07.28.07.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 07:19:27 -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 v4 2/6] can: tcan4x5x: Remove reserved register 0x814 from writable table Date: Fri, 28 Jul 2023 16:19:19 +0200 Message-Id: <20230728141923.162477-3-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230728141923.162477-1-msp@baylibre.com> References: <20230728141923.162477-1-msp@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.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 Fri Jul 28 14:19:20 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: 707655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7481FC04E69 for ; Fri, 28 Jul 2023 14:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237012AbjG1OTp (ORCPT ); Fri, 28 Jul 2023 10:19:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237008AbjG1OTd (ORCPT ); Fri, 28 Jul 2023 10:19:33 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AEFB3C06 for ; Fri, 28 Jul 2023 07:19:30 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3141fa31c2bso2018183f8f.2 for ; Fri, 28 Jul 2023 07:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1690553969; x=1691158769; 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=mzaljnOO1Gw4qS38ZHWvBAE06zq5Umr4CoJZWfxvzDg=; b=xUKyFTsSuvcbCo9x7xJzgCo0oi8PFn1TINP4lMKpkxprTf0fSFnKI6CO/S5K6BG4U4 aoSzf21spDOrbbJxqmOzt3E2ezOIXsAIegZZXaBpZ9sTRLPzZnHfC4sH6o6QWLc8Rogr +yXcap8TxO+tUAf6McFVa8Iuk4X2x1lQaF3GXWSpz64Q4LI590V++pfeW+hUbDZ/qbCK FdP4mQBw+v/PRGEN8ni/vSzX4KVKhkasOtgZvmStCpQZ5+cI1dpATaCtFOrMzXBBOSQh 9MVaZXQDFeOApmJTmwVjSyFg6Y6Vt3Z6yE8pIAkRw08w7U+eKNQ/aROZB6Tck/bZQ/SC +Y5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690553969; x=1691158769; 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=mzaljnOO1Gw4qS38ZHWvBAE06zq5Umr4CoJZWfxvzDg=; b=lzz0Tj7ACKRag8EjCZwH0ufnf68awCC6SvZyIaOdEa64JYI836EbvMOBIAICSfX8Sf duq41+WREuhFONhhqJfEAA+192c1S9g7Huvpzw6Dn7mEf7aVwhJSmbQZJUQwWL9TrJ/m Vu8l3nupmScyvFSd5YUhIAI26XRG+wJ51s+pVU2PpoYVvPfcukc/7d7GimVsE+6WCV90 L3btO8bmwXqegPGtrKG2crtrdQA2pzLy2PFgaiH50Ph7LYg8encpkNAHYyElD0UMJ+dE geEKkla5Jxpafm+Rq1D2ieESR85fOYmXlmNMa8/Pfhp4M8pij4UVoheMlGapFp6yBr+Q XoBw== X-Gm-Message-State: ABy/qLYODpDcj+CSbACAceekTcFgulaMrq13QCq+dflyf9LtYal81moc y7I0OT7DmdaB4LrYKKpKQdy81w== X-Google-Smtp-Source: APBJJlFcmt7PAwt3/8ccEaz69Q1c5nt6HSR44F+rbNLEzPLymPTwyiEBTmcnY9kb/BekXh461NYLFw== X-Received: by 2002:adf:d84b:0:b0:317:568d:d69a with SMTP id k11-20020adfd84b000000b00317568dd69amr1991756wrl.11.1690553968837; Fri, 28 Jul 2023 07:19:28 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a246:80e3:766f:be78:d79a:8686]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b0031416362e23sm5013681wrm.3.2023.07.28.07.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 07:19:28 -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 v4 3/6] can: tcan4x5x: Check size of mram configuration Date: Fri, 28 Jul 2023 16:19:20 +0200 Message-Id: <20230728141923.162477-4-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230728141923.162477-1-msp@baylibre.com> References: <20230728141923.162477-1-msp@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.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 c5af92bcc9c9..9210cf0705a1 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 Fri Jul 28 14:19:21 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: 708054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDEEFC001DF for ; Fri, 28 Jul 2023 14:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237042AbjG1OTo (ORCPT ); Fri, 28 Jul 2023 10:19:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237012AbjG1OTe (ORCPT ); Fri, 28 Jul 2023 10:19:34 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 908533C04 for ; Fri, 28 Jul 2023 07:19:31 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fc02a92dcfso22586815e9.0 for ; Fri, 28 Jul 2023 07:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1690553970; x=1691158770; 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=c7iw206NmNGXQD51dyCTfjKcxUDG5tZ5kJQD2+JAaW4M6K4d4qsYEkIRe9WdL7qtmU xJLPDNDokcsQGomwHemsFPimM7eQAPctRh4pOVsJlChdD4ayKSNiBmSQJBEyzJnc3nBL qbJOMF4ro31jIVEvfxr2c1suQK7+xMStzu8Kq5cPkiSBTqFyNHsquGLDbNwsyM3eFne0 YUtZ/LQsQjWolMIoRmkohkvQ1sa112UoCnUGsWavlCW+fQvnFXm7p4kMN7bPNSoQCv6X fZTq3/5CLSNH5tRBuCV9QVzM8VSzVhY2q/3nqZDfapW5IfIRPDRXvVDmOXYCbORy97IU 3u6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690553970; x=1691158770; 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=G7187PqFT9U/Rkha/zSeEt8uVm6PZc1IkSKsiyaDNNYvN+cXsz5bOYSDH1T6jdx53k Y5CB6f5BCD5mdTXddpboH9MlLJdEw81u7vUpBOj4vMRGyAN2RQtMA+U6zchajvVOfEYf Cnq5d0BgXhBcaguc6ONJNpJXgYtuUK4usgk+tquN/EKVc5ajdiQQSO0sBHwogdYjZfU5 OCRCwc5zWpgbiACsZQ3DrnRpk5CgE1dzmqeyzuTkZmuJ1RXhvW+waozER/PSPQcvSVXB qDChYnZOlxVnqBnZdjdsDQQ+R87bPSSao8latUoxRgOl497WnqbcWTuNYWtuRsXIaPfj xFUg== X-Gm-Message-State: ABy/qLasGq1aJ92syQMexwKHOS0UZO6IebMlnvK2BioL7USKNkcQwIo5 hIpg2EvOQ7eYcyD0b9HyUVgSnQ== X-Google-Smtp-Source: APBJJlFs7imRnBEtCs6iYDPuFHgy5C9OPLlOXwI/YIhw8iAEpaIG1yV7BAqgPEz424UL52Nd4O+l1g== X-Received: by 2002:a05:600c:20f:b0:3fe:785:ac0b with SMTP id 15-20020a05600c020f00b003fe0785ac0bmr1757369wmi.5.1690553969966; Fri, 28 Jul 2023 07:19:29 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a246:80e3:766f:be78:d79a:8686]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b0031416362e23sm5013681wrm.3.2023.07.28.07.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 07:19:29 -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 v4 4/6] can: tcan4x5x: Rename ID registers to match datasheet Date: Fri, 28 Jul 2023 16:19:21 +0200 Message-Id: <20230728141923.162477-5-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230728141923.162477-1-msp@baylibre.com> References: <20230728141923.162477-1-msp@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.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 Fri Jul 28 14:19:22 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: 708053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F291C001DE for ; Fri, 28 Jul 2023 14:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236995AbjG1OTq (ORCPT ); Fri, 28 Jul 2023 10:19:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjG1OTg (ORCPT ); Fri, 28 Jul 2023 10:19:36 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C25BC3ABF for ; Fri, 28 Jul 2023 07:19:32 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe110de3b6so3654425e9.1 for ; Fri, 28 Jul 2023 07:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1690553971; x=1691158771; 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=SrC0OKi8JQYuMqsO21AINU5+pXiu6nr1MLw9iKQGNsE=; b=Njf1k3Dw1JnWXqAlS0uxomasFTfTjz8A0pR0+lJt22KaXxeFtfpz6KSOih9jvn3p1S tSMleG2oHnw28yFKwbG9OlMvXdPTby6C1X4HumZn6p5uRoYF5vHZ6/4FfRP5KjHSMnV7 tTbRGpVQ6lP4UjwKIL4Fc/nHQhQX1uvqCt/s2CPL3vrl5jfV0MZ0+WTB4/rtEdPBHDxt 7hqZhXfh9Zqn5gqkBZAGNWRXKEXAn6Wj7uK8yvB/94thAI3tMgPb/c1DTLF83sHk0HGd p8puJwiaYDH+cz5q4EFjXtpnPp2pyvkHCL6UMwHdh30gIJlrcI/UjYr9b+Bv3rHz2nJu aIgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690553971; x=1691158771; 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=SrC0OKi8JQYuMqsO21AINU5+pXiu6nr1MLw9iKQGNsE=; b=NfTILvXoDGXLy7cUZ09SRsd2U9hw/SIar2SW0qeidaMXPCcv7mQu89TuGqvKI9VAxj CXyeLwKxKXNIzinwHRD3u++XQbSOiPvk7FMzii4kWNFMKXahxeYni8VNbvWRjmrpgMvE P47UExaAFUTiseGLkBxDpUX7wuNzPBXNnEWd4hVgegPOIAneCByVBAHkKUbGqAvd9mmG 7UOx12PFNHqvWHl1fJDvpIU1g/WOUXkoj8/etbAQcUnaF02AonDP6Gek7mw+SPJ6GRyX A0l0Tjjj6a27kF2iO1O6Eco+W2DYnTojE98W2AUZyyIjrJapXr9IVGirQTHWx/0WQqxO FwNw== X-Gm-Message-State: ABy/qLZSGn27mLISQGjXRdWwe6yLnndrY7rzD+hdvcy6uTDgV8rxZQyA M2FINE6bptURfLEmxDB7Pkmc1Q== X-Google-Smtp-Source: APBJJlFuLM2DH0+UxviTLjYcp2wsiH3LATToUTFsM92nehZlX3Kl8YHTFG3I9+s+bQf31HtkFTifjw== X-Received: by 2002:a05:600c:b5a:b0:3fb:4064:7e22 with SMTP id k26-20020a05600c0b5a00b003fb40647e22mr2261067wmr.19.1690553970873; Fri, 28 Jul 2023 07:19:30 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a246:80e3:766f:be78:d79a:8686]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b0031416362e23sm5013681wrm.3.2023.07.28.07.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 07:19:30 -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 v4 5/6] can: tcan4x5x: Add support for tcan4552/4553 Date: Fri, 28 Jul 2023 16:19:22 +0200 Message-Id: <20230728141923.162477-6-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230728141923.162477-1-msp@baylibre.com> References: <20230728141923.162477-1-msp@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.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 | 104 ++++++++++++++++++++++---- 1 file changed, 90 insertions(+), 14 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index fb9375fa20ec..2d329b4e4f52 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,37 @@ #define TCAN4X5X_WD_3_S_TIMER BIT(29) #define TCAN4X5X_WD_6_S_TIMER (BIT(28) | BIT(29)) +struct tcan4x5x_version_info { + const char *name; + u32 id2_register; + + bool has_wake_pin; + bool has_state_pin; +}; + +enum { + TCAN4552 = 0, + TCAN4553, + TCAN4X5X, +}; + +static const struct tcan4x5x_version_info tcan4x5x_versions[] = { + [TCAN4552] = { + .name = "4552", + .id2_register = 0x32353534, + }, + [TCAN4553] = { + .name = "4553", + .id2_register = 0x32353534, + }, + /* generic version with no id2_register at the end */ + [TCAN4X5X] = { + .name = "generic", + .has_wake_pin = true, + .has_state_pin = true, + }, +}; + static inline struct tcan4x5x_priv *cdev_to_priv(struct m_can_classdev *cdev) { return container_of(cdev, struct tcan4x5x_priv, cdev); @@ -254,18 +286,53 @@ 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_find_version(struct tcan4x5x_priv *priv) +{ + u32 val; + int ret; + + ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID1, &val); + if (ret) + return ERR_PTR(ret); + + if (val != TCAN4X5X_DEV_ID1_TCAN) { + dev_err(&priv->spi->dev, "Not a tcan device %x\n", val); + return ERR_PTR(-ENODEV); + } + + ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID2, &val); + if (ret) + return ERR_PTR(ret); + + for (int i = 0; i != ARRAY_SIZE(tcan4x5x_versions); ++i) { + const struct tcan4x5x_version_info *vinfo = &tcan4x5x_versions[i]; + + if (!vinfo->id2_register || val == vinfo->id2_register) { + dev_info(&priv->spi->dev, "Detected TCAN device version %s\n", + vinfo->name); + return vinfo; + } + } + + return &tcan4x5x_versions[TCAN4X5X]; +} + +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 +344,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,6 +368,7 @@ 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; @@ -361,7 +431,13 @@ static int tcan4x5x_can_probe(struct spi_device *spi) if (ret) goto out_m_can_class_free_dev; - ret = tcan4x5x_get_gpios(mcan_class); + version_info = tcan4x5x_find_version(priv); + if (IS_ERR(version_info)) { + ret = PTR_ERR(version_info); + goto out_power; + } + + ret = tcan4x5x_get_gpios(mcan_class, version_info); if (ret) goto out_power; From patchwork Fri Jul 28 14:19:23 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: 707654 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BD2FC001E0 for ; Fri, 28 Jul 2023 14:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237066AbjG1OTw (ORCPT ); Fri, 28 Jul 2023 10:19:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236992AbjG1OTg (ORCPT ); Fri, 28 Jul 2023 10:19:36 -0400 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 8B25B3C2A for ; Fri, 28 Jul 2023 07:19:33 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-3175d5ca8dbso2077940f8f.2 for ; Fri, 28 Jul 2023 07:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1690553972; x=1691158772; 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=giuTVJOpvmU1j6SJtXvrs5HolX4CC90ajhkJHQ0pjgw=; b=GrtnL7/fM1SgKRl6fxfIk1pgHVZc0FLNnQTNXNMpxFHXajx2rXR3OjONZAlZAyreCW wS0ZA56RjkbAQzV8dIXlnRLIgoKTDUHRohsAmJAfzMuVkjr5Eksf9+y24egs7pWkz1Lt t6aWo+pYRTaeAVlx7aJyRoDnL18L8ci+c0IkUlTPPt30Grj5WLBSNu/++YOtqK/AV7FR 9AujkEv8QZrtBVNklyS4rjjO33pUWkVGZt9xTwemXM3VcFrc2pmM0EiFIJ173U7bccTe df3kQRxZyHLxaduu/v6G27VyPG8qfOPqqqKdg5koRtkWD54WPU55vPL1pHXtI8X+BVMr W/bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690553972; x=1691158772; 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=giuTVJOpvmU1j6SJtXvrs5HolX4CC90ajhkJHQ0pjgw=; b=ium6YJzraRMYmG7obf7rI0/n738tuXSbTziDDzG9BgrxS3s4vjPP8jVNpZSk93ABJP ihooC+a7/MnMcBCGR2bmaqT+oWPKxC0s4XS/lwh4dDmr13vo+zECpVNNZEkglJe5Yhu3 kQNIYGGQlWoY2hu0u4PhcrYAN/M/Bz2EKi84F56MRAWs+ZjC3WiXHD/vNUOi+baYuEWe H2xZOBoV/eTo4W2O9VaCsAV+zeA81jaMa/pNWqC+8Y03FPO8MMpGdusoahyZwdC9vWct LMuVS43j0gUBsGXmcIyKG92y4WuZUeWjJAa+reN6uCpBpYan0J5NWd6/F6ytN9aHJNYL cLqA== X-Gm-Message-State: ABy/qLaCeZNN4uKhA97eoC7hrZ383FeFWQZdkQOTYtqWHy7YPob5ul7X CN79tfQPJnjPwCOElAlL6EHJjQ== X-Google-Smtp-Source: APBJJlEjiAZn1StP/CczL78boawHSDHTP+/5VlogrBFTZtZZTRb0ONZC3/06apTOOVB9xk0UI4TTYg== X-Received: by 2002:a5d:6849:0:b0:313:f347:eea0 with SMTP id o9-20020a5d6849000000b00313f347eea0mr1951153wrw.60.1690553971785; Fri, 28 Jul 2023 07:19:31 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a246:80e3:766f:be78:d79a:8686]) by smtp.gmail.com with ESMTPSA id l6-20020adfe586000000b0031416362e23sm5013681wrm.3.2023.07.28.07.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 07:19:31 -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 v4 6/6] can: tcan4x5x: Add error messages in probe Date: Fri, 28 Jul 2023 16:19:23 +0200 Message-Id: <20230728141923.162477-7-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230728141923.162477-1-msp@baylibre.com> References: <20230728141923.162477-1-msp@baylibre.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.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 | 29 +++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c index 2d329b4e4f52..8a4143809d33 100644 --- a/drivers/net/can/m_can/tcan4x5x-core.c +++ b/drivers/net/can/m_can/tcan4x5x-core.c @@ -402,6 +402,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; } @@ -420,16 +422,23 @@ 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 %pe\n", ERR_PTR(ret)); goto out_m_can_class_free_dev; + } ret = tcan4x5x_regmap_init(priv); - if (ret) + if (ret) { + dev_err(&spi->dev, "regmap init failed %pe\n", ERR_PTR(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 %pe\n", + ERR_PTR(ret)); goto out_m_can_class_free_dev; + } version_info = tcan4x5x_find_version(priv); if (IS_ERR(version_info)) { @@ -438,16 +447,24 @@ static int tcan4x5x_can_probe(struct spi_device *spi) } ret = tcan4x5x_get_gpios(mcan_class, version_info); - if (ret) + if (ret) { + dev_err(&spi->dev, "Getting gpios failed %pe\n", ERR_PTR(ret)); goto out_power; + } ret = tcan4x5x_init(mcan_class); - if (ret) + if (ret) { + dev_err(&spi->dev, "tcan initialization failed %pe\n", + ERR_PTR(ret)); goto out_power; + } ret = m_can_class_register(mcan_class); - if (ret) + if (ret) { + dev_err(&spi->dev, "Failed registering m_can device %pe\n", + ERR_PTR(ret)); goto out_power; + } netdev_info(mcan_class->net, "TCAN4X5X successfully initialized.\n"); return 0;