From patchwork Tue Mar 14 15:11:57 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: 69681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1824292wrd; Tue, 14 Mar 2023 08:28:32 -0700 (PDT) X-Google-Smtp-Source: AK7set+5HEkJ8NkgzAvK4rcxHDwtNUNv6BEoUbZ9SHZFF7Xh/vMHCuOboUStCBS/Lu/5j5eYIrIa X-Received: by 2002:a17:902:c411:b0:1a0:50bd:31c0 with SMTP id k17-20020a170902c41100b001a050bd31c0mr7783379plk.24.1678807711987; Tue, 14 Mar 2023 08:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678807711; cv=none; d=google.com; s=arc-20160816; b=RENv+BP0lvFxtPGORl4yDGKsXvXwKtPTvYXYT9X1mvL6xuBuw8iVSIbwSq0JQatYII bXvfDC6ThBBjYKKRoBN7fLtDZDc4iojbAFKm9BKnIZ/78ncLXIti7Vu+Mtp0ydVknKnY iI1/ecCJiNiPJohx445T9Vh9DYJeyvChdLr4dpwTDDcjcYEZSk+FPO7V+MAsmLvTLQOC Q5eicZYSXp6yzmQBg4+avE6y2c133DIXH9iUDuUmR1UGDgGyYovoUdHoLHeyydUO4F26 VeEycnaJisVJtyvlozbQc8bLEl2T7T/YynlmBdIPMb66gIevtkE+aoi2PyDLeKc0EZGJ 5OTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iBdDt0cqpy6mqZcYqnHeD+1brhs0HmWk0OP3dY1LAIs=; b=HlLbI+JUvwdtAcONaC3qEL1DQkHRb4/+6T+YaHUqABZT3wx0WU8Q/cXmf4Gx05UGD5 7TufEXOqABdr6CtP8oYa/z3ogqXNa4RYE0esLiOyJPZPiiEU00Z1+5iStvdTM1ufmPNo jfoYwP/FWLcOQO77ySZGnVji6b3l9nAp7TZwUjOfWQ14Mjs6uCZVXwg/bvcPtcZ5D8n0 bhFbk7gTxnudxWisTtyk5YaArYrXyETsTTihEpGv80f9iV6Dd0zGsuMg34qOLy1VMzBs QeihpYOs8P3z9JvxKkZV31SblBp9InRGT5zoTqNmYH+77oimfu/yfM+4ZFjKfcbzVEj7 1ipQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=GFfmwFW8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a17090302d200b001a05a44093csi2746639plk.58.2023.03.14.08.28.17; Tue, 14 Mar 2023 08:28:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=GFfmwFW8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231528AbjCNPM2 (ORCPT + 99 others); Tue, 14 Mar 2023 11:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231466AbjCNPMW (ORCPT ); Tue, 14 Mar 2023 11:12:22 -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 E9D0864B04 for ; Tue, 14 Mar 2023 08:12:18 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id p4so8484803wre.11 for ; Tue, 14 Mar 2023 08:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678806737; 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=iBdDt0cqpy6mqZcYqnHeD+1brhs0HmWk0OP3dY1LAIs=; b=GFfmwFW8xeMH5Re8QwmK4TF3WQrgLb14J2RNNuffrfGixpc2wJEDemqzYA1xuFrAYQ n26hInC07plbcBftba/DYI8Uc0JuD1Q+FiFljbmQ2tlCLqmdm5Hx1XkwqMQYbbouD5nt pLHbgSADUDrV/ep65O0ceyFvs13IJFpHhIODR5wM0Lx10r7lbWs18irGgQX995MrcjtQ hy9rk6MieRxr/+/v6++iEXl8WUnL/S/1lb/4lfLtXacuJPn3bo38/FEGv7U5UyKcnVNb N4gZqy35fqjuX+Y1t7cUud0mbRDj0NbcePXJpY90lYejri1sLMN7H6xDNXCwvSnCUrYg /eBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678806737; 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=iBdDt0cqpy6mqZcYqnHeD+1brhs0HmWk0OP3dY1LAIs=; b=UJAgqQeC25+3qBCydfOA9HYclG/qna4AXJUG2CF6XuV9mRgd0jQNyUrey/XxLhr85J 8VYLKgfIhE/pgZ93ACU2/wkOQYQXYmBDHZ3Myz1DXVyhf0XrFbQ8nc8PdDlfgcDJB7lr xM8QJZ1ZSfGoov92aif5d2FuQtHIb9+bK7wO485tSNUE7N/SqJZhW0xUJP07q4JN8Lod ToE10+S9L1KTbXUEWatVp9KWpiRQTnSFcXjosS0B5bfTkvekKES1Wmjp38I2MUP5+vWH be5GHc5/sJs9Sd+/CS95V5gn1q8MjCx9FHGGJoWCqW2ilA0DqIArKxb6gyNvce3dhppd yUIA== X-Gm-Message-State: AO0yUKWRqS40jWv6yii8tCMtSPTDeHaC/11MpBjD2aOeX5htmrdm8w7r Hp7Cqs1eTWs3ZPgKE0OhC1Cakw== X-Received: by 2002:adf:f30d:0:b0:2cf:e445:295f with SMTP id i13-20020adff30d000000b002cfe445295fmr3436047wro.61.1678806737399; Tue, 14 Mar 2023 08:12:17 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id d9-20020a5d4f89000000b002c707b336c9sm2320158wru.36.2023.03.14.08.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:12:17 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Rob Herring , Krzysztof Kozlowski Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH 1/5] dt-bindings: can: tcan4x5x: Add tcan4552 and tcan4553 variants Date: Tue, 14 Mar 2023 16:11:57 +0100 Message-Id: <20230314151201.2317134-2-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314151201.2317134-1-msp@baylibre.com> References: <20230314151201.2317134-1-msp@baylibre.com> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760357475666665065?= X-GMAIL-MSGID: =?utf-8?q?1760357475666665065?= 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..38a2b5369b44 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,tcan4x5x" or + "ti,tcan4552" or + "ti,tcan4553" - 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 Tue Mar 14 15:11: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: 69676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1816589wrd; Tue, 14 Mar 2023 08:13:51 -0700 (PDT) X-Google-Smtp-Source: AK7set+yJGsJ0jtdM4heVfebVC4b9Sz7J7VYxXTeBPzUrFcqYUN/gXlR/jif6oe1wwLnw+2BkWI4 X-Received: by 2002:aa7:8bd9:0:b0:625:55e6:e5d6 with SMTP id s25-20020aa78bd9000000b0062555e6e5d6mr3299930pfd.9.1678806831641; Tue, 14 Mar 2023 08:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678806831; cv=none; d=google.com; s=arc-20160816; b=LuJb/XD5lonrhuqxZVGgY9bEtH8FqevXWdXAu/HH3aurb4ZRcvI+EQOJJlEqlXo/rd qluRPQsqyGaDg/RdH6qY2pp7ugadsXGTnGBn169FSkgCamD0c4g6Avy8NT9zqqKb4qiW oiGZuRRFTIsSnDiwNE+pNMN5Tk/WEW3BNXXfDubLP1TToHO4eoHlhXQn8ohXviiJPTyS dFBmTeO9qGFdfXsv5XimtiVup3d01UoL/2hc7NNlxFaAqJD60FqCr8q8hARoVlBkbufl HxtRHFyDoOLacI2N2hZJBTQ0iDPLMTf32pOuRxM6qshcwcW93T71cd5rwMFx7XAJZKHc fu6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VmGIHQCmWWdA9EwE4mVtBEzfVG8pp3/R17fUTMGZ6+A=; b=xsMpIpqX0ELwyz6rQKvhktSrwIHtMc1+Ve+VqaO/qxeQ0SofwvVQyLqWuvvJSJKTC0 KDNS8ApTNPyfzLtx7/zKq3d1gjYWBvXnXt8+8dkOKlwzsqlCr3kYEFlI1eUkHGzGJeyu +4EJ9vsbl5R1jRZNqzDyz/4FpuCwc9yoTdZAD9ZaDi9G4PRLr2uYq6EoDQzhgmziUB8B DUmAK6/p5pCbxwfTAjuJYUFIatCqUYY9G4D7y33fhYlCuhKfIW6BWNlYcEaJ/hk6a9is u6yoaRMEnasaISgCMXUwONWNVcS4LCuupcEzK8wN6FhHeN/I/SmkE8ZyyoMOMbPpzVbO H48Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=wm3utNeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020aa796c8000000b00571a5c5eaa5si2530570pfq.150.2023.03.14.08.13.38; Tue, 14 Mar 2023 08:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=wm3utNeO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231592AbjCNPMg (ORCPT + 99 others); Tue, 14 Mar 2023 11:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231574AbjCNPMW (ORCPT ); Tue, 14 Mar 2023 11:12:22 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0890D9C98A for ; Tue, 14 Mar 2023 08:12:20 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id v16so14730240wrn.0 for ; Tue, 14 Mar 2023 08:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678806738; 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=VmGIHQCmWWdA9EwE4mVtBEzfVG8pp3/R17fUTMGZ6+A=; b=wm3utNeOJHiNjSb3v0zKJI8yUo1ASepqLTO4rJyfMNSbyOL1ayZKciL7n7Nym3iOSo bUQNZxfiK6aHhB4p23vPSr78iJJsfc5QUU+onuZdINfynDMrYFTt3MaDn1vDOjLEXiK2 D/lMEKsbKHcdwt30d8wwqu7BsPqCRL5jpDUD3Gd6g93gnLnbmDccRDaUeWt/v444SyIF 8BoSi53tL6PVh0z5zTzOOvsmowoa+25ze54I9rUqblUyFhXDDHABlKvLXX8HskQpl2Sb VEjf8qDwyF192LHl3WB385ura+pgBnPCbGmsZvL3P3JjAhKGuJuRzmX7c3ifHeIAEMFy g6OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678806738; 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=VmGIHQCmWWdA9EwE4mVtBEzfVG8pp3/R17fUTMGZ6+A=; b=LubI9qwF2GlHLNTYtihN16HWOtc7C+qkgXs7+JvcZG91a2yT0oKpSYzZNqLT6dkQ29 NxQDd39No8MiQX3AO1HaNb+lmGYB1MF6Q+yUtLeptDo5IhT5S/znhfEkBUv+n8PE4QR8 LaimBtlPWiiHGwSP9sj65gS0n25Eo0S6Af/cqxzk7Hf7HIO7E8wYeWNMnp4pk5WXJJ2N PB5u1Z53TEL06IfN0FfVSrYVfjgReWD7heCazeWkrLRA8knr15JcVGheCshJrcEGGAkU Jfw4DlcXIgSLMdr/3byChDnow2NMm9KNMu81zIeVw5BcIf+inFaQEb6xnKIHwg4ukTYl oTdg== X-Gm-Message-State: AO0yUKUdxmapa1r28K/MQvQLs6YjOY43jn3Z1UFQCrUgRFhLV53eezE/ BnndHIpJnmeZoo7WzOLkLNcjsA== X-Received: by 2002:adf:f78e:0:b0:2c8:bf89:39be with SMTP id q14-20020adff78e000000b002c8bf8939bemr28733891wrp.7.1678806738473; Tue, 14 Mar 2023 08:12:18 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id d9-20020a5d4f89000000b002c707b336c9sm2320158wru.36.2023.03.14.08.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:12:17 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Rob Herring , Krzysztof Kozlowski Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH 2/5] can: tcan4x5x: Remove reserved register 0x814 from writable table Date: Tue, 14 Mar 2023 16:11:58 +0100 Message-Id: <20230314151201.2317134-3-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314151201.2317134-1-msp@baylibre.com> References: <20230314151201.2317134-1-msp@baylibre.com> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760356552430576426?= X-GMAIL-MSGID: =?utf-8?q?1760356552430576426?= 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 --- 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 Tue Mar 14 15:11: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: 69683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1824874wrd; Tue, 14 Mar 2023 08:29:49 -0700 (PDT) X-Google-Smtp-Source: AK7set8zayh1gsX7M1jL98C/R18h9zigQFQdT5KBLz+kBs45VaMrGxbdq0iM0F2bi3Bwwn/XE+O4 X-Received: by 2002:a17:902:c101:b0:19f:2dff:21a2 with SMTP id 1-20020a170902c10100b0019f2dff21a2mr9454866pli.64.1678807789110; Tue, 14 Mar 2023 08:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678807789; cv=none; d=google.com; s=arc-20160816; b=sexOl2YV+8tqgwB3mWVgLvjAK6valkqfewvYuc9o9+IJWqRd/HKx0ow5a67+/MiUi1 8x0ZO2UxVxa52XfEpJGwdukZhvjIK9fbAF8Qib13CVjcRHr1Defhnw7ma7fz7pByXyRz 6A3DZzxFXKhuT8aNYBnveTgv3nQm0dXW9rAbTcIl0wCIByLa+gCV5PxGzxVkjZs+PhQD SLxv3B6VfQG3F7u5xsGr9dbifpP6XuadpZanrUvfiDeYVDfcZxMz/jiSRymKijt/k7Op +BTPwJbhAYiKe1mEy5zje/jdsB/9tzQSdWAMWFKam8eZ5fNpkxybo6prfBEVPw8CX7Ya E4NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nf0FCRqxe9mUuT8bqQbLPIB9gEtjE7LcZZoSf7lbVA4=; b=zG4LK1D+GB9B/KZdJKxljcleAlXCs+xlDDIzHjzmsbNG/g7+8MiISXqyGPTDwQdyEs qljlJKHd5IQiOy+PBH7aTkxMjQNIjtVMIaDVprk5td08xeOPjFIcsM1MX0tM0/gf2ce2 EIaDidhoYiTWzFy1yyxm1J9fJh731aKYWMnevB1oCRqK/wgKzlUi/Q/td9u4kPvw63U8 ofedsXD91XVPpnJFLSjYt0IJLXkdRJYCtTMl9kO7HOv+CFyYKoXPdY7hyAGQA+Kh9vts t/RpL19b4ByB4uP/4dUcECXg5tCn3DLfwvEPC+9YMXpqVX0RAAuMCM4yaw2tJRa2L/MK cxag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=yaRKA4uN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k24-20020a63ba18000000b0050bcb3e7584si2300733pgf.334.2023.03.14.08.29.28; Tue, 14 Mar 2023 08:29:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=yaRKA4uN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231657AbjCNPMa (ORCPT + 99 others); Tue, 14 Mar 2023 11:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231582AbjCNPMX (ORCPT ); Tue, 14 Mar 2023 11:12:23 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1778DA103D for ; Tue, 14 Mar 2023 08:12:21 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id v16so14730296wrn.0 for ; Tue, 14 Mar 2023 08:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678806739; 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=nf0FCRqxe9mUuT8bqQbLPIB9gEtjE7LcZZoSf7lbVA4=; b=yaRKA4uN2v5L9uIAwLPb7NpQeJAFI+g0ykjKF9UkFJbLBqz86FR0mBmQtDoIrQJgaE bqnQzKdC0NX48PPGZmgMacf+0c5ZDjkep2cAUmGSyoo90vbk5ylJqUfSv8PQQ1ICa1+l reUBCuaGDebC2aM8f4Lrj9KRacn4vBxcDnusK0ah6+L5IlFR3kD74+Zh/upF2yXB3tJc MwYgwYzPfYRDEP9+A+256LOFj99hDhj2Dg75gEYwwRjy2MP7P/mxeuvwG88lugGp1KlC XCm/UaOb+66IiN5yNAj2pMwAypnc4RFfbgOO+vTF7UU/dO4oE4io7wXRcBHHc7D11mYr 6RTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678806739; 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=nf0FCRqxe9mUuT8bqQbLPIB9gEtjE7LcZZoSf7lbVA4=; b=mq3J/7Z+YxL1rCkmgniXNfjgUBNnmF0Ss9niw5e7PO8ma80SId9U+FewGXh31zTZhN MBbwjBkkL/kfMY0i60x5R0IRErCopfaaGLfuAyQB96K3ojyKkPz4L0CgUsH/8la9wT7B zDIJ1K+Sc/nAOFH6ntyDaz+Xdihcd2RIXDVCk4LkArdwVLoEyWtbmTPoDVGp7SzRKBXB sV8RXXWwolx8Fpv3cKXZEfd0q3qVE9p0/b+qV20UVUjf8jzRDStUJtmP25wCxU/Y+qtL oanwSM9jrEVNlLArOfDE5FSGo6EJNMF+WR7OoUHtsHkGAvrH9tcVp2rW7OrYqhJGNo27 4thw== X-Gm-Message-State: AO0yUKWMHmCjtK+H/bu7jE6zwAv2tusfTHiM6wfzD6heOXd00oHLk9+O emtSom/oiaiSzlo/XnUBBxVSHw== X-Received: by 2002:adf:da44:0:b0:2ce:6f5a:c3b8 with SMTP id r4-20020adfda44000000b002ce6f5ac3b8mr18530977wrl.31.1678806739558; Tue, 14 Mar 2023 08:12:19 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id d9-20020a5d4f89000000b002c707b336c9sm2320158wru.36.2023.03.14.08.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:12:19 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Rob Herring , Krzysztof Kozlowski Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH 3/5] can: tcan4x5x: Check size of mram configuration Date: Tue, 14 Mar 2023 16:11:59 +0100 Message-Id: <20230314151201.2317134-4-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314151201.2317134-1-msp@baylibre.com> References: <20230314151201.2317134-1-msp@baylibre.com> 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760357556284945845?= X-GMAIL-MSGID: =?utf-8?q?1760357556284945845?= 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 --- 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 8e83d6963d85..8ccf20f093f8 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1886,6 +1886,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 Tue Mar 14 15:12: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: 69679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1823575wrd; Tue, 14 Mar 2023 08:26:58 -0700 (PDT) X-Google-Smtp-Source: AK7set+KbxDk/P46g8ERqQFikxbKUjdBc8G333Uj3zmZY6V+xYzqxU8gJ2ZGyGT2H8Euk98gHdEG X-Received: by 2002:aa7:96d3:0:b0:625:290:e303 with SMTP id h19-20020aa796d3000000b006250290e303mr4818086pfq.14.1678807617768; Tue, 14 Mar 2023 08:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678807617; cv=none; d=google.com; s=arc-20160816; b=tlKtwMCmsI7zknuTLbJ8fF1aTjkHx0RWogxGpCwPpHAs9tBnsH2HqYXl0Kzfky/A5X bD5Yf2gt7laKkqoakndP9IrSlWhtlKSVgcTWNHK7czEutZYGfK0r1A18d1EwFJPydQVU VIg9hBHlHPZ5t0L4i9NEw2SFiIv75KoDQzyTvn84IQzlqdSl3MGnFw3cQ+0PRZMLCwXj 1xCQZhRCIg987ZjhFRyTBx/HyUy0U8Z6S7RYK2unZbmgbv27JVtJpDAOXqWMY80kAl86 QZVBQmxTddm31JcGf0qmPgiPX8+lj0+B9gCC8WuChnUBbuTG3KzTNcTvQdQ/cRiD7DVO p8DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8fjPi0++9HsE/g35dDtgt0nVDV0ftpyC2jXqNwiLftg=; b=Qtx5NW+p5dC98B0JxmPO0vpI4fhzgjpD616AbacIjW8Tzq/1xhB9qFy+LvBn60SYXn G5w9a7LfQYfVdPT2LQ4D2FjDo/4+gSLSUKvC04O5Xhm82zHV2h5kSmRyz6X36rawQJFP MXVYe5Fq1bkioDKNiP8O4Y3ass1yywt34uTpLwMSIj/y+hoza76FjJC9GegTnZoRtBL4 otdaVeRRIvmmB7f4ZRfDY9IUYfgLwK6q0KVoBhZEMykedrb6oh7IVm2I3k5g+W93x0bh Gnkc30nIemwsteU4QhkD3BwmeMIexlgbE3O9t3PIV0XvS59f47t2cQS+/7Y0Ev6REUuE DZHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=wWN0v8x3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i126-20020a625484000000b005de484ca9ccsi2539656pfb.149.2023.03.14.08.26.42; Tue, 14 Mar 2023 08:26:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=wWN0v8x3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbjCNPMd (ORCPT + 99 others); Tue, 14 Mar 2023 11:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbjCNPMY (ORCPT ); Tue, 14 Mar 2023 11:12:24 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A8C8A2F2B for ; Tue, 14 Mar 2023 08:12:22 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id r29so6650557wra.13 for ; Tue, 14 Mar 2023 08:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678806740; 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=8fjPi0++9HsE/g35dDtgt0nVDV0ftpyC2jXqNwiLftg=; b=wWN0v8x3ge9+v/J0sUDB316m/AXx/aBfzFM4Br27vN+PgTRTZmSvt6C4sniYj84A6P 3RN72kOYp3ztPUnLaW3dDcV70GpWiwdDKbA9lV2PwQnnTCXRYC1FtttmKpG+WSiRJLTS nWq6Oy6/35vDp0N8Q/OBs1fJ4qP2y/dagc3Key4rlGM8OWzkQ47yNxn96L3IIlgwZpEU aAgD+3uLUAwfRY0gmp2amA3lmHeHGSlwSkO2EDYzJBBL1L3jVu78sTX/jnANP/rSUpk3 ymK4FWCz1twMyF473a1JDqq+CDR4ybHhPIjSFSqk4FRqIl+m7Emurz9gfrpN26VvTXls NB4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678806740; 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=8fjPi0++9HsE/g35dDtgt0nVDV0ftpyC2jXqNwiLftg=; b=kj25DIK2y8z10hQEj+3UKIh/KA5QdarAQEEcXD7sFfwIgg26PSiV4dyUPtzs5NIclo +PRBEnvXfCFI75lVr0Sw8lBVsHTYsBUJkQk13tvW74JKbK20GUGyazqVFFQWXU/lN1D5 CZy//FGQFE49AJNxlKhir+5l0Tyk2/S6WAHRyJe/7/p8AustU29ito5L7xX0zUbk4yze ZYIXHtYZEC1VFKKhNQIIPMPcdiIWnH6j0pvKDsXC5sD6k6IAtjrXQ4YInXgjxQwWRsGv Io2yyoBuc0jURkKtKxChjs2vmauqE0u4V18yo3WMbd/YCgnpGN3XiDCI8/YmJod2YLBy xSQA== X-Gm-Message-State: AO0yUKUMGpLfHj0xJcLf9awbmIRe+iFJ+T3nyNkls89xl+XjZn98GIFc +4hFfBoL2g/aWrXt2B9SM599gA== X-Received: by 2002:a5d:6b87:0:b0:2c7:1c72:69a3 with SMTP id n7-20020a5d6b87000000b002c71c7269a3mr25214914wrx.29.1678806740600; Tue, 14 Mar 2023 08:12:20 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id d9-20020a5d4f89000000b002c707b336c9sm2320158wru.36.2023.03.14.08.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:12:20 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Rob Herring , Krzysztof Kozlowski Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH 4/5] can: tcan4x5x: Rename ID registers to match datasheet Date: Tue, 14 Mar 2023 16:12:00 +0100 Message-Id: <20230314151201.2317134-5-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314151201.2317134-1-msp@baylibre.com> References: <20230314151201.2317134-1-msp@baylibre.com> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760357376560665445?= X-GMAIL-MSGID: =?utf-8?q?1760357376560665445?= The datasheet calls these registers ID1 and ID2. Rename these to avoid confusion. Signed-off-by: Markus Schneider-Pargmann --- 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 Tue Mar 14 15:12: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: 69678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1823246wrd; Tue, 14 Mar 2023 08:26:14 -0700 (PDT) X-Google-Smtp-Source: AK7set9n0u/fatSqcJOZpY36UR0suTIAYRuxCeLRJe2C0wHEmHg5e0uKm/uBOk0Kro2H8qOOz0uF X-Received: by 2002:a17:90b:23c8:b0:23d:1bbd:9fb5 with SMTP id md8-20020a17090b23c800b0023d1bbd9fb5mr5674029pjb.39.1678807574183; Tue, 14 Mar 2023 08:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678807574; cv=none; d=google.com; s=arc-20160816; b=QCR/8QWk2HJeHHWSTG0/lw/0TZ6Iutaslm18vmxEeXUfdQnkU9NfNhluVGSmG9mqNT URQQ6l2pCOUn8s0D40983a+o9Ob5R+CuZFW5ALvHEf3jU7D4FmvpOLsvCv5Bt5LoByKR Y9wnHqpBwK4BNNpBKlozrzIRmQV9h3Nca4T075GK7MuqHapZZwfiVTT4NN2iXFMfBCYw 0GFHImSkQXQdyNbokDoFXHGONRIABcM2NmD0Y3hvqBVHQD1VY6NxBQsp3UYPFwSCj4DS aNbqKM4W+mjYc4FnIMhPbPv2Ja1uJjNuEh0dtaDt0WdYGDEWJeEFCeCUxDL8V8/NIMCa 9dvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PSrec+nBwM+c2dQQeNVjKvZ5AfVGgxg/yYXQBrWPGyQ=; b=jecSgLY1dtbw/420kh9g3aNae502BNmDWByiVWAKVOQcRNhRT4U/TZYnmt6/t+8NBn ngxmKtNrz4CYrY8P+0un4aHxmCKKrPjW/uPbk4ofOspNAZ086Ivi1NUf+Oz9vLdkbWK5 PWL1297OMHwTDUyVfNZChCvPhT6x3fTZldcMOxjYwcdIgX5TDqj/bbHDUUiI9aWwCraJ mOg3EzRylty2M2WGguyaFHSlmIBCDla4Zf79E4iMJYV7xPuJUwcb7uOQN+0feT12XHya DqI0ZECN1mUv9pN7LDrK6M+RBnIcYa4duZGTCFSNTirRwfpw6pSloYzoBwoEi+861R+q pG2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=0PbFTDbB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o96-20020a17090a0a6900b0023d039d1d7csi2735043pjo.36.2023.03.14.08.25.58; Tue, 14 Mar 2023 08:26:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=0PbFTDbB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231701AbjCNPMk (ORCPT + 99 others); Tue, 14 Mar 2023 11:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbjCNPMY (ORCPT ); Tue, 14 Mar 2023 11:12:24 -0400 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 05B5E11EA9 for ; Tue, 14 Mar 2023 08:12:23 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id t15so14673153wrz.7 for ; Tue, 14 Mar 2023 08:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1678806741; 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=PSrec+nBwM+c2dQQeNVjKvZ5AfVGgxg/yYXQBrWPGyQ=; b=0PbFTDbB3iqQ+6B6JXcc9N2aOoYFez/WZp8jLJ+U14nAeRdstbXlrz5nCLrsmu+8vg zrZc9+pn9FlyY7AbhfO6DZ6ZAtMa2BBofJjYjfT3YAZOBfjaLLaSM3GJ82Pr5ypWNVa2 kI+8U7OK7Et9uwE9s1EVsBIEPxuFbcPFhRnyDzXaDmrgTWTUmh7UjHFQz52GNzg04HYT MbwN/mByHaj0BkQK3LrzzXMTKzoDMJCH4fLt/x2TjJowl5N2M8JjUbGj0ZNHLPvGQQ3W kekv73o6UPUG78wFrDRTMQp5yMitEW0p+8uIsMjTwsdPcHPVDe8ldRNV8by6kxRcrdGR uY4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678806741; 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=PSrec+nBwM+c2dQQeNVjKvZ5AfVGgxg/yYXQBrWPGyQ=; b=XXBKcq3JxQ7NjWBhJchXKtIR6coMVC7RyoaTVCFmVkIJHBYUlZhDt7caq5kER/f3oZ pzlLx+uhGxZfWCulDE9NKM0t1pglKYVyFvisGcQuT6rN0ZrRDhME87i4PyW1+b0lXYES tUZbKO4mPigXml7H0TLl67MQTgv+LUhBGCWD8mr+Wr2Hgwf1O5jEVPWeqOokmJrH21ng HWo7xxczld3e3B5MzLtI8sPpjOs563ieXc3eCX9/oOFbNDmdKEsnDj2S7vWKe4YF3rao pVVNQhr13lpyx7+ghZPOHaQtJO43dUUA1QSidkrxPoxRxzF26HJKWlXA2ys4GZI96fhG GITA== X-Gm-Message-State: AO0yUKX9kcxZuKPKS81+1Rk6MxLx36YxRx+ddToCtAw3Ux2CzxOWztoV tt/FPV7QsYJEvo7i1uKdD/08DQ== X-Received: by 2002:a5d:6289:0:b0:2ce:a944:2c6a with SMTP id k9-20020a5d6289000000b002cea9442c6amr6058726wru.70.1678806741490; Tue, 14 Mar 2023 08:12:21 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4090:a247:8056:be7d:83e:a6a5:4659]) by smtp.gmail.com with ESMTPSA id d9-20020a5d4f89000000b002c707b336c9sm2320158wru.36.2023.03.14.08.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:12:21 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , Rob Herring , Krzysztof Kozlowski Cc: Vincent MAILHOL , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Schneider-Pargmann Subject: [PATCH 5/5] can: tcan4x5x: Add support for tcan4552/4553 Date: Tue, 14 Mar 2023 16:12:01 +0100 Message-Id: <20230314151201.2317134-6-msp@baylibre.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314151201.2317134-1-msp@baylibre.com> References: <20230314151201.2317134-1-msp@baylibre.com> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760357330940602924?= X-GMAIL-MSGID: =?utf-8?q?1760357330940602924?= 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 | 113 ++++++++++++++++++++------ 1 file changed, 89 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..e7fa509dacc9 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,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 int tcan4x5x_verify_version( + struct tcan4x5x_priv *priv, + const struct tcan4x5x_version_info *version_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 (!version_info->id2_register) + return 0; + + ret = regmap_read(priv->regmap, TCAN4X5X_DEV_ID2, &val); + if (ret) + return ret; + + if (version_info->id2_register != val) { + dev_err(&priv->spi->dev, "Not the specified TCAN device, id2: %x != %x\n", + version_info->id2_register, val); + return -ENODEV; + } + + 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 +320,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; @@ -301,8 +346,13 @@ static int tcan4x5x_can_probe(struct spi_device *spi) { struct tcan4x5x_priv *priv; struct m_can_classdev *mcan_class; + const struct tcan4x5x_version_info *version_info; 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 +411,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 +448,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,tcan4x5x", .data = &tcan4x5x_generic }, + { .compatible = "ti,tcan4552", .data = &tcan4x5x_tcan4552 }, + { .compatible = "ti,tcan4553", .data = &tcan4x5x_tcan4553 }, + { /* 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);