From patchwork Sun Mar 26 16:03:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2804 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 8A2D240FE7 for ; Sun, 26 Mar 2023 18:03:34 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id y24-20020aa7ccd8000000b004be3955a42esf9180439edt.22 for ; Sun, 26 Mar 2023 09:03:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679846614; cv=pass; d=google.com; s=arc-20160816; b=AAzEzI7MSx6ij/J/+bzl7hEjmyilUilQJnIrKlD79jTRY/bPEvh+i7gd4ZXm6kWJKj tcln6S5Z9LI0Wu1TJFzol0gqbmS+cb4xUERJDX4TwCQw/DRSI2klvMCZHM9EmojMrybr AUh4DGX2xZTCbtP3rLeHm74R/0AXL/nZsGMlGv7UlThxp2DEazbVpPIeFeAHslwxKdR9 FK68JR/YP2x8jNJmxrNq3oB+iFIXBkrFTb4DA0IX1P2fg5OgIe0cbrxiOX4rBkVtbYxQ 0QmboCY2+CIyLTX7Hz5H4GluBPUgmPiCUcD6XnWK2vLKCspgbVow0vq14X2Ydfr6U4Tj lVJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=utiGXJPpdcCa/75j/RvzBwnSWaRyED1povyCuzJioA0=; b=HEo9v89xoKHQSsMayrG6ZmvdYh1tjoUotLJo/xANMK/GCRHKKA7WRMolUtr1bXN0ns 3hRX1TOuy966m+l4qyNJ6RQLZeMQ7Da5pLI1basMqey4BB9X7ykqQoNBd7tBjBcxr2h/ NniepDvNlSVKmAv4dgPksLQTXhs6/O8MmiJCMws9US2GFY9kIrnEmQdHV9vA5dbJ6W5H 7mAPz1O+WC6QVeNPUUppnJ6Ii31mohgQPbl5TS6bOUp19aL0Hudgrkqi2bqgB8UbSv0t 79acizA2xuuhOiCWl69mZYNitOIdD0iXXfcUeHuQNkyAeGFKotdwaEN37msIOBWqEnei Ly7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=lm3usrJk; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1679846614; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=utiGXJPpdcCa/75j/RvzBwnSWaRyED1povyCuzJioA0=; b=bwq9GYGUa9vbtbCFFRYSOOKEI+zdq7hNCAURO8F3CGSpVtpgYz7kpV+6MOEgzbKB4D 0O5zm0UNjN1gEQAiT/I5fVEjlZVGw/C6b6kJxGtCLrnhDUIc4O2FlOi4270tBvatULPu wMFz9exBrlHMqpNKvkyC634yjSx6w453kMNck= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679846614; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=utiGXJPpdcCa/75j/RvzBwnSWaRyED1povyCuzJioA0=; b=mIJteMuKcgbW8El5GyTqVRNRHuPBI+IO4A9QSjMyt7gQLErbN18xaU2Z7aLILBY0iy p64rIMs97t3Q1wcY7d54vkrrkrkYHN4aejR3eZc4MC59C52oDuiGsd0t8XTUrtGaZ8n+ h/LUSS4I/i9+DJGsxRyy6XKXqR/+oLjfg5G0WXaXWeoAgwvmieoCdkveAfFNJ4cS4bbT jfz0QMSQMukLtyIrKefTcle/yn75EO7pVdENmD7KlySpZMaJr1c2iXv7DDyA6Ci71yvL fHSioGhTCE136sy7Mg43sAUh/8GoPjIBnrKrsbhfmdNEC/uZ6yQlAhcUfL5yX4wtwecC hBqw== X-Gm-Message-State: AAQBX9eyT0ED7qqckx3yy3MFkKfzd1AFNjyTZKnw1KGG680WTdnN8w7U eI+p6ZQM4+Pu51W6o716bOO2pJ8ZM40OJ+rW X-Google-Smtp-Source: AKy350Z1ye0asylbT94vp5zIls6plBUevLNBg/fs0uRDQK2bq7yqMc8NqVJer0z48HY1XJ4TINjqag== X-Received: by 2002:a17:906:9619:b0:932:446:b2f7 with SMTP id s25-20020a170906961900b009320446b2f7mr3859316ejx.6.1679846614035; Sun, 26 Mar 2023 09:03:34 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:7d8c:b0:93f:74ba:81b with SMTP id oz12-20020a1709077d8c00b0093f74ba081bls1633609ejc.5.-pod-prod-gmail; Sun, 26 Mar 2023 09:03:32 -0700 (PDT) X-Received: by 2002:a17:906:5849:b0:931:4b0b:73e3 with SMTP id h9-20020a170906584900b009314b0b73e3mr8804175ejs.65.1679846612415; Sun, 26 Mar 2023 09:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679846612; cv=none; d=google.com; s=arc-20160816; b=jsMgi7iOiEADlDNfdjNf3U8IFLyt0/LqPkOrDUzgBl1B8ccBsRAtErDwAdGoGAJrT4 yfJ31+lbzBthdFuyZssZuzXnoxVNJscM9KFuCWA3nxsx74nos77qpT3HLXAwqecPnUD5 mLk/+HD/G6GbVojbJ0kWhiWZqu6n53uy0CfFryCHOLLxSxM9cRhweQVmh113OOZ5eyud L9jaMqi1I8KaLxuz1ZRQHUlECLW6wI+BXuTa3/4I0o7+4pvkNK0uYb1A2U2tVHVvotpf 1FtO9rTxUDEY0nvbCsXOBOpMV4Mi1UGb2B2LcRO5BJ9jHQpX/0G9IigXe9Zb5Z0eYV02 ns0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=WuawNslRJtsC33cN3DASsrMzq8m1GQBJdWGYFmYOzJw=; b=ZqbvKLesMqTKo5DOgYQXE0rjOUkfkMGJAW/AwZCHKU0WX6KKu6YbU/5KXhslaqrkGY 3m2pC4YYV3PHQd5S9FpocJA32ih9OF7ANtbqbUDHWai5JessLUf4/VcxfiT5ONZgUG01 NcUeNzNn44yMLDplwzQB/nLcsc3xPmS5yH5IMl+enDkN4JUG9dU/Uud58dDGKRDN5pn8 OpJfEbG1GHlBn8lfvyXZ4esHpWSDNEuJXemyReyPaT7VS05wmmelvdZWpZdz/ue8Rwkm Bm+fzao50VwwvK0VOh6d9R2pwR3I1VPXlQKchs1HAUKVzjQCP7B1oshHMJR/sGoaaj+p 4rSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=lm3usrJk; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id l13-20020a1709065a8d00b00943fa400d55sor599866ejq.92.2023.03.26.09.03.32 for (Google Transport Security); Sun, 26 Mar 2023 09:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:1c09:b0:930:f953:9608 with SMTP id nc9-20020a1709071c0900b00930f9539608mr13785177ejc.0.1679846612122; Sun, 26 Mar 2023 09:03:32 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id m2-20020a50d7c2000000b00501fc87352fsm6869333edj.13.2023.03.26.09.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 09:03:31 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , michael@amarulasolutions.com, Vincent Mailhol , Alexandre Torgue , Dario Binacchi , Alexandre Belloni , Christophe Roullier , Hans Verkuil , Krzysztof Kozlowski , Matti Vaittinen , Maxime Coquelin , Rob Herring , Stephen Boyd , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v8 1/5] dt-bindings: arm: stm32: add compatible for syscon gcan node Date: Sun, 26 Mar 2023 18:03:21 +0200 Message-Id: <20230326160325.3771891-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> References: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=lm3usrJk; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Since commit ad440432d1f9 ("dt-bindings: mfd: Ensure 'syscon' has a more specific compatible") It is required to provide at least 2 compatibles string for syscon node. This patch documents the new compatible for stm32f4 SoC to support global/shared CAN registers access for bxCAN controllers. Signed-off-by: Dario Binacchi Acked-by: Rob Herring --- (no changes since v5) Changes in v5: - Add Rob Herring's Acked-by tag. .../devicetree/bindings/arm/stm32/st,stm32-syscon.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml b/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml index b2b156cc160a..ad8e51aa01b0 100644 --- a/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml +++ b/Documentation/devicetree/bindings/arm/stm32/st,stm32-syscon.yaml @@ -20,6 +20,7 @@ properties: - st,stm32-syscfg - st,stm32-power-config - st,stm32-tamp + - st,stm32f4-gcan - const: syscon - items: - const: st,stm32-tamp @@ -42,6 +43,7 @@ if: contains: enum: - st,stm32mp157-syscfg + - st,stm32f4-gcan then: required: - clocks From patchwork Sun Mar 26 16:03:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2805 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 246663F25A for ; Sun, 26 Mar 2023 18:03:36 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id i22-20020a05640242d600b004f5962985f4sf9206054edc.12 for ; Sun, 26 Mar 2023 09:03:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679846616; cv=pass; d=google.com; s=arc-20160816; b=zUAXJ9sNiPQ4plggdHuRCLBLPmcIbPWVoONKIQjVvVDWy0iOSiRVhk9o8FBg5TCCtA iK2CGtOSD99xz3Lfpft0wCG3lsKCkipEsFQpcYNr/013ea/TXjBZgGh1/kLqxTNNhJOR FVEvni0bgZiDOIsGcVBrU4p1wLFAZhrlVSGm9wPbG6uMSFvKkcdr7rGwfEzoxwjwQekS IIKmxxcMpKqQKFo7knpHHrO9zaUolaieY8AzRkTXBqpKEhMjVYfwS9WT5+YRR0o47ihM abI4hqxI0GBK1kXpR/bRM8PCDe6o36hxjpajQARjLWyiCUr5acR9sqNe8vENV8Y1RwOC ec+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=c3keGljZK9pMIYlHCDcD5dMBkG59atWfPB7XJXGLOBM=; b=Rts1zjYxtS97kybPG4M+tNG8t2A8uqZUEeCQ3D+TdSU8Awe2BVe5Di8bh3HiSuZcZf VBYkJDVmj0hoFVQqUt5yv8JjYVcd5P3viS+NhExmObOv74yX76re9EiI89ZjyjGPgJlA BEntzYYtt798JR6tsWFYhILfM0oqp2nOLIo8FBZOrPbZsBChjMDa9+y1yZiwU/PQhEHB R1IuQb0IwnHQ1A/MnpTRmpYClXj8ayZwvhFO6x1LBUyy+mKIoGs8HNYqdrYRxHDvxyVJ Gp96RYwYQO/DdhWrhUeT3CqBYKTEuYQKi3E4S/Ykd4/QMaf6fiZUeWlkcNn7bfAT1Sut b+NQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Gye0T3mS; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1679846616; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=c3keGljZK9pMIYlHCDcD5dMBkG59atWfPB7XJXGLOBM=; b=G6SKun7l13nNelBmy1yAvqUM59SwuRMFvfyB0kdMg8qEA1rPKqfIkhjRkJ+qk5IX6/ o0RcJ2AQI7ZE+ylpJffbTUyTc0644Dj8ZXHid3kxyFP2P0ajgXfWhC+yUuyzHK6UoaEr DxnJqHtBJSTMqHPlWIGhLap6pj6YVsVB92v9w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679846616; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=c3keGljZK9pMIYlHCDcD5dMBkG59atWfPB7XJXGLOBM=; b=KnkBzhZBuXGRcqzuRPBLHqXfHjEUTtOqx2p2ohagFJizepGQMaQHFHk4njuy0sDyx5 9Ho3UR07Q2RTPTCvcBEflTmSBNHbG69sKOdBTyDbztMvABNSs4YVeh2yEsW0R6kQPBpL FgzA3jFmSEznOXQSCzDQTueFcDXCQJ4CVQ8xTOwzY2MJNeLdI2NRPo+e/CWmDzY6Z7r8 fA8pa/XbT/mxVwAFynn1CnExBu7SzyRtQ8HOBNhwCTzn5skKx5NDdLuzPFjydnchsf4q TL5+DFKDEoE5T2aXM0PdZUiNecdPhqT2g4t7djApcTOdk8dEfZWjWhTkpvkAuP44Nu4g 8zqw== X-Gm-Message-State: AAQBX9erN2K29l1I0tyEEUsIkGZB7xyQCmdWHtqUTCy4qfk2fCZ8oYCZ qoyKMc6dIR3p/KI6wioOjfUq//s7uCDui+wP X-Google-Smtp-Source: AKy350ZxQZ+Gr7tUgS/GyGzaAHL+dZmRAo4U9Kq7Ejl4M39gRzgDh1vBMuyGuJJp6PyDQmDm5id7XA== X-Received: by 2002:a17:906:8315:b0:93d:6382:d5b with SMTP id j21-20020a170906831500b0093d63820d5bmr3772091ejx.9.1679846615642; Sun, 26 Mar 2023 09:03:35 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:608c:b0:92a:da3e:a6b2 with SMTP id ht12-20020a170907608c00b0092ada3ea6b2ls3896195ejc.4.-pod-prod-gmail; Sun, 26 Mar 2023 09:03:34 -0700 (PDT) X-Received: by 2002:a17:907:7787:b0:939:90ee:e086 with SMTP id ky7-20020a170907778700b0093990eee086mr9213541ejc.28.1679846613925; Sun, 26 Mar 2023 09:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679846613; cv=none; d=google.com; s=arc-20160816; b=CNoO5565WpdEkL69FOO49Z+Ah21uAhFGzywnn5bUbPMkLTrQbOWapQoqvww6gx2l50 V6EBc5F48FyYvnMi9gdrMyLS8AXZgR6wOwu7AvdtJqFZtq3b+blc1yCFd6tCuYXViXQC rCV5LvIfJOc90VePpihIF+JsSKJdl3nhm7JBbsDu1ZGzFCjieMNwIjSQv0eyagM3JQWo wwh0oBgzoNygjN4LqVVuOwLW2F8cyy/4amdkS2e30hoQ8fMaDq6LLssa3tJwzz2Aw6ZB 3UXyURmDZLhLhtMHizjaapqdkh7Qv8KkQF7i6I8LggDwW2VQMLcVJIyjY3j537hc0uAZ b2yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Kod5siM2bcM+dDVpz/GqL4BGUBIqfHoecSZkZ5xWujI=; b=zLNt8iJTSK2F6K5wgrFxdyWcGbDJtvR54nKolUYAiLFVCwrn2eW4SHlwpNBaPyjbKI 1oHxEFsYGQu/pFivgdGaUKFLGzpxwHzLsIrmTVhdM/qlt/btx5B+Hz6lmyo8PZ+QkRRl Iebqt9AZz6bSOWoC574M4iBMM+brESBju158Qgd/uchWP/kIqoJipISFbiy3JjaMpLKJ jr4JuA/SvpuXiDeLehYhYBXeFfUOPDVBiYZ/Mwlol1C2MSt1LbtAVz7fY0wYEmvXL1jS JLTQkwiA7a6pTAWa7giyz5XG0cutbF86iAUDs7Bsa0jJU5f3eqW4DnYaVYRnv0pPOFJv /tdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Gye0T3mS; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d15-20020a50f68f000000b004fc7879582csor12898066edn.47.2023.03.26.09.03.33 for (Google Transport Security); Sun, 26 Mar 2023 09:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:aa7:cd8d:0:b0:4fe:1b62:4741 with SMTP id x13-20020aa7cd8d000000b004fe1b624741mr8976237edv.28.1679846613613; Sun, 26 Mar 2023 09:03:33 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id m2-20020a50d7c2000000b00501fc87352fsm6869333edj.13.2023.03.26.09.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 09:03:33 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , michael@amarulasolutions.com, Vincent Mailhol , Alexandre Torgue , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Krzysztof Kozlowski , Maxime Coquelin , Paolo Abeni , Rob Herring , Wolfgang Grandegger , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, netdev@vger.kernel.org Subject: [PATCH v8 2/5] dt-bindings: net: can: add STM32 bxcan DT bindings Date: Sun, 26 Mar 2023 18:03:22 +0200 Message-Id: <20230326160325.3771891-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> References: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Gye0T3mS; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add documentation of device tree bindings for the STM32 basic extended CAN (bxcan) controller. Signed-off-by: Dario Binacchi Reviewed-by: Rob Herring --- (no changes since v5) Changes in v5: - Add Rob Herring's Reviewed-by tag. Changes in v4: - Remove "st,stm32f4-bxcan-core" compatible. In this way the can nodes (compatible "st,stm32f4-bxcan") are no longer children of a parent node with compatible "st,stm32f4-bxcan-core". - Add the "st,gcan" property (global can memory) to can nodes which references a "syscon" node containing the shared clock and memory addresses. Changes in v3: - Remove 'Dario Binacchi ' SOB. - Add description to the parent of the two child nodes. - Move "patterProperties:" after "properties: in top level before "required". - Add "clocks" to the "required:" list of the child nodes. Changes in v2: - Change the file name into 'st,stm32-bxcan-core.yaml'. - Rename compatibles: - st,stm32-bxcan-core -> st,stm32f4-bxcan-core - st,stm32-bxcan -> st,stm32f4-bxcan - Rename master property to st,can-master. - Remove the status property from the example. - Put the node child properties as required. .../bindings/net/can/st,stm32-bxcan.yaml | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml diff --git a/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml b/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml new file mode 100644 index 000000000000..c9194345d202 --- /dev/null +++ b/Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/can/st,stm32-bxcan.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics bxCAN controller + +description: STMicroelectronics BxCAN controller for CAN bus + +maintainers: + - Dario Binacchi + +allOf: + - $ref: can-controller.yaml# + +properties: + compatible: + enum: + - st,stm32f4-bxcan + + st,can-master: + description: + Master and slave mode of the bxCAN peripheral is only relevant + if the chip has two CAN peripherals. In that case they share + some of the required logic. + type: boolean + + reg: + maxItems: 1 + + interrupts: + items: + - description: transmit interrupt + - description: FIFO 0 receive interrupt + - description: FIFO 1 receive interrupt + - description: status change error interrupt + + interrupt-names: + items: + - const: tx + - const: rx0 + - const: rx1 + - const: sce + + resets: + maxItems: 1 + + clocks: + maxItems: 1 + + st,gcan: + $ref: "/schemas/types.yaml#/definitions/phandle-array" + description: + The phandle to the gcan node which allows to access the 512-bytes + SRAM memory shared by the two bxCAN cells (CAN1 master and CAN2 + slave) in dual CAN peripheral configuration. + +required: + - compatible + - reg + - interrupts + - resets + - clocks + - st,gcan + +additionalProperties: false + +examples: + - | + #include + #include + + can1: can@40006400 { + compatible = "st,stm32f4-bxcan"; + reg = <0x40006400 0x200>; + interrupts = <19>, <20>, <21>, <22>; + interrupt-names = "tx", "rx0", "rx1", "sce"; + resets = <&rcc STM32F4_APB1_RESET(CAN1)>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN1)>; + st,can-master; + st,gcan = <&gcan>; + }; From patchwork Sun Mar 26 16:03:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2806 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 5B35240FE7 for ; Sun, 26 Mar 2023 18:03:37 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id ev6-20020a056402540600b004bc2358ac04sf9167140edb.21 for ; Sun, 26 Mar 2023 09:03:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679846617; cv=pass; d=google.com; s=arc-20160816; b=s9nM5+Y3aRa5lpSzVY+zoFt/ZBgSlKLIdYZSaZcVKMcg07jAl9/SIjnjfEmOJ4pGsn QKdxRJpn6ANoPh95yCa0aYaAALb7QSqAoe5gbEzHuzyzS2/xNGZ0lxRTxMlk3IlrzX6T 5m4zmdoOpm0vb1IHFOcAQmiKeUjwj5A/pcQp+oNwJth/330WJU73IMQavQL8Gk+8bhII N3WFUC9Nf1StnZun+nSU3TNbjxVUxpatI4Vv2GR1iuwLtkEjgW9bkahdOTqo2g4Zn617 N2+nSD5a+sb5Gd5nCk+x6bwY/jIKiti5p5cCNSaVOWDaBrTZmGOORjW6ZCH5LlBXi46T H07A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=f3cSV/Slt9kPATVc/BNcmtDo8rY0Fe4nvudWjA356B0=; b=hBXi8g2B9pfulE614HxxUKrWxhUjwsV5zaHtY/ddjgwIGFZaoymzxTQb+SGAqmdVhM x+APnlOIprNg97dgt6MhzY2lrMYHVanuWg4wDgd1hqGzEsjJ7CEFgXAb4a/JX2bL1vB3 jFIK1EscgtTimjDT67/Ac5nkUQpgN3Mtvc26TprXalR5QVA5/TAbc0Aqzd6w9xMx7IuG hgOr2XPQVEG6Jv9Xsd/awSBc/0JOoQoC8BvDKmgsc5PgqupIllsvgPk5PXC2wYBQl0iA W+yRuTJhDRwhurqwuhpcMGKFwaVgKUUz++MCmbLpNOVoFycD7DFfDGOQdh7nYttNPy1E UeEw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IGpkTrSY; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1679846617; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=f3cSV/Slt9kPATVc/BNcmtDo8rY0Fe4nvudWjA356B0=; b=Q0EtvpT+HRX9JrZMRqQKOw/R2KxTtq0g87c4PwF+44nReuEAh+bgWoBI0FT7cTpIbq WxrcX7q6sbvZqaYk1sD6NoNNICEXa5K9Mgpq/X8WPEsUFivIvRaOOuucrPDXXJfXiOK8 w0IOY8l2apVd72gmBlrS3gIfHiieJdoLzaV4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679846617; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=f3cSV/Slt9kPATVc/BNcmtDo8rY0Fe4nvudWjA356B0=; b=ksNyYti+gh4oTp70T083OWYPdfAughCBFM9SfEVkKGKKcSXTuN4BIABeBWbH5f5icF acqF71AlRYKY2QfmdH8JJv865ehafeYs8/+A/RX4EJa8IcRJC/JIIeapORDhjJpHjqUX a5ljcqZJBTeQjGEoisBUH8BWBsx31hQx9PgwZ/kVLQdi+5z5/S/vEz8ji6GaEr11xapk c/yoqm0jVAHnA3kIMsAZxPlzdDcWrHb9rJfpCDUAuVr9GtkmiCPoeaxKajVqG5EnDhUi 7qpyXXBe78lfeOmoXe0uwtIoUilvNZb6Z1CdVR18EwRRRvb9fD05J+G86u8BTwbQbzHf HTQg== X-Gm-Message-State: AAQBX9fzWR3QT3igF3rFrdvjTVcHGHU1NfQdObob2ZmDr2xC2CYkhzXF WZUbetc/TLFgxyWAiJAf62BRiJLN X-Google-Smtp-Source: AKy350bU1MHL2stFqRCJhScRzbJnK2ykANMdmotJ4NYDy4lN3LQiYQhhUl2FD7Fz4ezXLrtolg8b6w== X-Received: by 2002:a50:d49e:0:b0:502:148d:9e1e with SMTP id s30-20020a50d49e000000b00502148d9e1emr4368360edi.3.1679846616925; Sun, 26 Mar 2023 09:03:36 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:510b:b0:4ad:73cb:b525 with SMTP id m11-20020a056402510b00b004ad73cbb525ls2567697edd.3.-pod-prod-gmail; Sun, 26 Mar 2023 09:03:35 -0700 (PDT) X-Received: by 2002:a05:6402:1:b0:4fc:c7c8:e78d with SMTP id d1-20020a056402000100b004fcc7c8e78dmr9259475edu.31.1679846615247; Sun, 26 Mar 2023 09:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679846615; cv=none; d=google.com; s=arc-20160816; b=WGaM8+bbb5g8PEra7WPS23ERPznk+cUc/9YK2QfY3osdnpUR3NNkN+zyynxdKT3I4c NCqRbyAP0CNis+LZEU6yMs/jRCS+QvC82tU4qiKhBt5tuRtl4URgvQ917/V9KxJWhSTE PLRLZVkwYDRr2Ue4/ToInpfNMpDWzlMsomRr4b9cIen3CAXb+t6cI+cTrCxa8jcXkl5z Im5SFNy9eNlnbFvB8VSB3uyhbyA5qW+UgJUCLMimUnFICxWwPX9q3PICjKgjqg3EXwET v4df+2BcvTP3+cQNFmK7PEf00IFnv2qQLy3NsYKgY4b7iI/ataTJRydbUsp9DXgwJgCa dvZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=90w47meUN1AAVQio6KlRg3XgdW53vJW4u/H89twTllI=; b=c9pR4rf1RtsJx2/4AplPLSf8rI7f06xYEfA+4OsiqYT/OQS5jEnQvElCxAG7jDIwPc 7U/wqDpiYUor55xpmh9Cb9uPFFAByU+zhR/SA+CqKEePtORpy3XjfJsIF1P6yOv87mAs h7to6AXa5nkAnyBJY67ZniwPPO2I+42W+hFN74jFvnP82cfv4szwBRUO68A0H0oGObZ6 VDofHnchqZb3NJ2buMOlnOrFT6LnK83AtuwbeRb6bih/Sv9bhhwEABB4UCyazsQWrj+1 cXa9E/LlYUam9ZRSHDrtA60z0xPcC7FHgry7A4Z3nMFzdLzwTz4KxPTw6rJv2goHEeq8 WAvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IGpkTrSY; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id v12-20020a50954c000000b004fa2744e25esor13563597eda.59.2023.03.26.09.03.35 for (Google Transport Security); Sun, 26 Mar 2023 09:03:35 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:aa7:d14e:0:b0:500:58cb:3b05 with SMTP id r14-20020aa7d14e000000b0050058cb3b05mr8961649edo.27.1679846614987; Sun, 26 Mar 2023 09:03:34 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id m2-20020a50d7c2000000b00501fc87352fsm6869333edj.13.2023.03.26.09.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 09:03:34 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , michael@amarulasolutions.com, Vincent Mailhol , Alexandre Torgue , Dario Binacchi , Krzysztof Kozlowski , Maxime Coquelin , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v8 3/5] ARM: dts: stm32: add CAN support on stm32f429 Date: Sun, 26 Mar 2023 18:03:23 +0200 Message-Id: <20230326160325.3771891-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> References: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IGpkTrSY; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add support for bxcan (Basic eXtended CAN controller) to STM32F429. The chip contains two CAN peripherals, CAN1 the master and CAN2 the slave, that share some of the required logic like clock and filters. This means that the slave CAN can't be used without the master CAN. Signed-off-by: Dario Binacchi --- (no changes since v6) Changes in v6: - move can1 node before gcan to keep ordering by address. Changes in v4: - Replace the node can@40006400 (compatible "st,stm32f4-bxcan-core") with the gcan@40006600 node ("sysnode" compatible). The gcan node contains clocks and memory addresses shared by the two can nodes of which it's no longer the parent. - Add to can nodes the "st,gcan" property (global can memory) which references the gcan@40006600 node ("sysnode compatibble). Changes in v3: - Remove 'Dario Binacchi ' SOB. - Add "clocks" to can@0 node. arch/arm/boot/dts/stm32f429.dtsi | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi index c31ceb821231..809b2842ded9 100644 --- a/arch/arm/boot/dts/stm32f429.dtsi +++ b/arch/arm/boot/dts/stm32f429.dtsi @@ -362,6 +362,35 @@ i2c3: i2c@40005c00 { status = "disabled"; }; + can1: can@40006400 { + compatible = "st,stm32f4-bxcan"; + reg = <0x40006400 0x200>; + interrupts = <19>, <20>, <21>, <22>; + interrupt-names = "tx", "rx0", "rx1", "sce"; + resets = <&rcc STM32F4_APB1_RESET(CAN1)>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN1)>; + st,can-master; + st,gcan = <&gcan>; + status = "disabled"; + }; + + gcan: gcan@40006600 { + compatible = "st,stm32f4-gcan", "syscon"; + reg = <0x40006600 0x200>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN1)>; + }; + + can2: can@40006800 { + compatible = "st,stm32f4-bxcan"; + reg = <0x40006800 0x200>; + interrupts = <63>, <64>, <65>, <66>; + interrupt-names = "tx", "rx0", "rx1", "sce"; + resets = <&rcc STM32F4_APB1_RESET(CAN2)>; + clocks = <&rcc 0 STM32F4_APB1_CLOCK(CAN2)>; + st,gcan = <&gcan>; + status = "disabled"; + }; + dac: dac@40007400 { compatible = "st,stm32f4-dac-core"; reg = <0x40007400 0x400>; From patchwork Sun Mar 26 16:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2807 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1E71F3F25A for ; Sun, 26 Mar 2023 18:03:38 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id i42-20020a0564020f2a00b004fd23c238besf9142197eda.0 for ; Sun, 26 Mar 2023 09:03:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679846618; cv=pass; d=google.com; s=arc-20160816; b=mQBYcXZS2JgyBh+viZoWTaWUEiiA5lHYePYIFpgSP/a2Y/KB4svz8TqAwqyXVvZgbZ BrB8iVnY1OXJIX3hNPpqbf1AAlDsRMKsZD4pulPGoeZGbd4JW2lqIPBtztxYVOWmjLRh EcUmTeUvtdNY6pFIysMdi7v8Y8C9d6FAmZL7I32LG937wfF96zECsgwKPS/ZZ/gEmTbP dHW6WLs8aHB7y9ix2tiRZIv6RKw0oAXUbQqAWjczcnqHBRYCqT1oZYctPSt69oRGlSO4 upDV7xPjRxNlDGZV3XnY9IGUFiDK/04Y27Wkdbyh3Vq74XZ28e7J2/tnKpb1gqv4PZBY EbDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=SfdrfT03OSwzGLgYfJRpTJI75xsr8u1PQr9DsxijOMI=; b=HxSXve4yAdhHtoHMKKfmb1xHFFIGSIo+L1xhD05I6IpdAVeqgoj8inD4Y1NFwW7iiR kZPxlQvc70N3I/SGHSIFscPULViA93MgjfrKmkuybsg3p/V/LAMh44gHAKtakHvvnsCR pUM5o5MJNNjo1bVG/cRNbrDTJ9fdwif8L2UxEvFutANqyiuEnJTpAUuT/5SlWd1aBVB7 cIr/YRlRlNTGnHaW7vMQCc4xqHG9dm0fi3IIevl4koSvUzJA5rH5Mnb5BRdaWTO+fhYv AfV8eGgJsFgmAAoubtBWvfGsWwAPwvrOIgAGzpakc7GAxVIkrS2gd1pSR/D2EA+2pu1y RRsg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rq5dyFnU; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1679846618; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=SfdrfT03OSwzGLgYfJRpTJI75xsr8u1PQr9DsxijOMI=; b=UBqMDK2UUPxMWniP5onE2lOUjV2Hmea9AV2KFccglr5wh8tpL8Rco7POVm8q8VPXLq kUA2YWarU1X+TsXO517iyGFQ1i2mGjwcJVuQeMAA6ngAe0A6kuE4kIkA+oAjbLcJgDmz 50L4XbvqR4/ptgd8I2gF6oSbgrscFfM5mrCEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679846618; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=SfdrfT03OSwzGLgYfJRpTJI75xsr8u1PQr9DsxijOMI=; b=o+vZ8K+UyR6QROKYXsBJJyd+wcZEZKDQTT6OaOjv1RtxThLXd3n4slEWOjE9+3iMZX m2WP9KDv72A4U+4k9HQc0rNQvsKvG0FISijswN12kR+86phEzp6JGTrMmA3wc6nfDpYT czTVWT4UOetNAaA0gT2XjQ6D776PNZgr9aF80ni4nX84sfoBmRq+FP7ifF1o70W1saSs FB097FINHdhlG7V1a5UvsIPZHxLrHdcgUC08hRKt6Yj3SO9yEEDOuSc+pkKSL6Z7wC0s lEi18IPCLanAbFgf3R9kk9LwyR7pQ0eXi7uHHaydF1xwya0vZvAtpvbhs+aZesf4FmF9 Mk0g== X-Gm-Message-State: AAQBX9dYv62uKY+MbkLFGSUMxiXiT0nTCeeIFjq9jjxRG7OvdN/ivEcZ I1b3levUFrhXOXTCVLVYai0g9CLTb6ULoylT X-Google-Smtp-Source: AKy350ZHWuv8iSvYE2+wEbCsa7oDjjEswF2sUxt1OQBhGv7kc7fPUXKgcwgiqxSdcU9F4RBwUMWiyw== X-Received: by 2002:a50:9f6f:0:b0:4fb:2593:846 with SMTP id b102-20020a509f6f000000b004fb25930846mr4103109edf.3.1679846617910; Sun, 26 Mar 2023 09:03:37 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:4311:b0:4ac:d2bc:e0cb with SMTP id m17-20020a056402431100b004acd2bce0cbls2566874edc.0.-pod-prod-gmail; Sun, 26 Mar 2023 09:03:36 -0700 (PDT) X-Received: by 2002:aa7:d14e:0:b0:500:58cb:3b05 with SMTP id r14-20020aa7d14e000000b0050058cb3b05mr8961708edo.27.1679846616421; Sun, 26 Mar 2023 09:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679846616; cv=none; d=google.com; s=arc-20160816; b=IvJ1gnE6+nSB6omPMtyqmOIrEEARcZwbbU2digllV7aJwmLwisT9ay3BO1zIeGpcxV O5yqJ1Z0vEheY+LOS3yWo4Wt13pfkW0953Jk3OX8uWobNXHms0NoEyc1z711xJ1I8wIv PCB+i6W+G67d6Lp6IFIyXK1+P7b+YbFoj1toTJfUUTY9j3Rfn+5mr2s7Ui0snVmOOqqF ueLUnlvD5SafLKyM2QotHSJI5NF8wPEWr+9On0Ortlz9lPBoas0zpvCBbhwnFvr/otR1 n+d/jV/ge/oCP4653F2Z62ui+BDJbm/fnmZEAfspLA5WJVa0BvOFDkDG0yssMuGeUWv9 WbXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=QV3iGa8KiUlr1LClhXl1D1BGw0maVF3hcUmABXx2qKM=; b=zv/Bgyr6pSGBQ4vGkPEaAt7IkSZgvgccQVXSMJr26NQ1lUkwsCfwqCzUdkbINGacPl T71wk63YfTNwrqHrzQ4gaFUJL+H57LeT41ALMH9pJzHNjv5Vhju+Mx1ADpKN5RJsKPfY /P8a/hQXqFqbsyDfUXIdAb2VNgxoyUcHBcPLa78hXQCz1SwXe5WBymKtb7/5261DxMVJ EjYNqvSz81htmelhFPXSq+ROqTHDSWg77uO3ARKZYZbT+LygxqVUvhTsJ3hxUfMtibT9 20ZbOkqJtTDwGOD5QTuH4U5jK/GawDUcFU47mwqVsZgWiPp+UwdOApF7b/eQrR+5JDDO Hq1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rq5dyFnU; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id c9-20020a509f89000000b004ac8e642725sor13010214edf.84.2023.03.26.09.03.36 for (Google Transport Security); Sun, 26 Mar 2023 09:03:36 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:70a:b0:4fb:9b54:ccb8 with SMTP id w10-20020a056402070a00b004fb9b54ccb8mr9305209edx.21.1679846616252; Sun, 26 Mar 2023 09:03:36 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id m2-20020a50d7c2000000b00501fc87352fsm6869333edj.13.2023.03.26.09.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 09:03:36 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , michael@amarulasolutions.com, Vincent Mailhol , Alexandre Torgue , Dario Binacchi , Krzysztof Kozlowski , Maxime Coquelin , Rob Herring , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v8 4/5] ARM: dts: stm32: add pin map for CAN controller on stm32f4 Date: Sun, 26 Mar 2023 18:03:24 +0200 Message-Id: <20230326160325.3771891-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> References: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rq5dyFnU; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add pin configurations for using CAN controller on stm32f469-disco board. They are located on the Arduino compatible connector CN5 (CAN1) and on the extension connector CN12 (CAN2). Signed-off-by: Dario Binacchi --- (no changes since v3) Changes in v3: - Remove 'Dario Binacchi ' SOB. - Remove a blank line. Changes in v2: - Remove a blank line. arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi index 4523c63475e4..3bb812d6399e 100644 --- a/arch/arm/boot/dts/stm32f4-pinctrl.dtsi +++ b/arch/arm/boot/dts/stm32f4-pinctrl.dtsi @@ -447,6 +447,36 @@ pins2 { slew-rate = <2>; }; }; + + can1_pins_a: can1-0 { + pins1 { + pinmux = ; /* CAN1_TX */ + }; + pins2 { + pinmux = ; /* CAN1_RX */ + bias-pull-up; + }; + }; + + can2_pins_a: can2-0 { + pins1 { + pinmux = ; /* CAN2_TX */ + }; + pins2 { + pinmux = ; /* CAN2_RX */ + bias-pull-up; + }; + }; + + can2_pins_b: can2-1 { + pins1 { + pinmux = ; /* CAN2_TX */ + }; + pins2 { + pinmux = ; /* CAN2_RX */ + bias-pull-up; + }; + }; }; }; }; From patchwork Sun Mar 26 16:03:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2808 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1AE813F25A for ; Sun, 26 Mar 2023 18:03:40 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id p36-20020a056402502400b004bb926a3d54sf9043129eda.2 for ; Sun, 26 Mar 2023 09:03:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679846619; cv=pass; d=google.com; s=arc-20160816; b=PxC+kL14AQNXPVWC/rpeihCuO6bmbDQ0soOR0FOx4wbdmP52sZfbSX/QnlWmC9rwGT Epec1UbrNGFdhhT3lBTlOTdUeHen5ThAq9wtH2bjmDMgFasry8jHRX+UD4/z6MFh5TtF 0rVyGd0QgGRTisjTinJPm3wyuE0k+6241o4TL8SbPj8jUawrgWuWwyhppAhQ2icvPQkD hgpk5WUFzCVYisadXeXb4ktuCLMw9ejWVx7qdTfq0VwAm4+7dL/4aXJ8TF/u6fiKAiwN SV0My/fqUTE4B4Mz71oOrutszWjOhGggccNn62wNsZhN5gGysJLIbLvx6IAdmfMd+TZz rmIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=aTGk2jYx1wt8QnDWL5MTsTVdFQZyroNWSwenjT6v/2E=; b=YNAYyx0fE1qcMmG/B7tne/MDk5O20uFIWjRrvOmESiRusJldWfSwNv5Tk/VRCYpl+n Ld60tqI6XgWdLzXr+195tBd7loiOn/lWsy85r+HOlCd63IDTTp6aULu9OB90Q873CnI8 Rmfi3mx+ZZFtBICoUvETL0xp/9tc48HPaeyYJlghvBkK+NYgnOxZ0drW0NWk/Q3UZ6fH nmtwcS8XAsxTgbSQF1Ici3cjeb44klBIMrS3i16lqc7dP/FiFnRr4BQHwU+XLxQNKmRp 4aLxUNsYTpNnSZaurObIV4zgb+LESaGkEzy5CR8bx4PN2+yOsP2FbACGxNK/icM7kXQv f3ZQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=itZzClcb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1679846619; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=aTGk2jYx1wt8QnDWL5MTsTVdFQZyroNWSwenjT6v/2E=; b=nPwDD9XFWYoUKhjPU4WUQZaswNGfoXLVKhRatw1DSAYEgqxqKi/c/PKjaX99xtXK5w BBhcqHt4uFPSQ7eqaK/WmNed0WkWKrYGIUP6y7a72mdoWtZZeV3v8Q6rBIL60KmKl1xe jXyE3EIj339iZtzwMlThdiUYvOfpuPfVCXBSE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679846619; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=aTGk2jYx1wt8QnDWL5MTsTVdFQZyroNWSwenjT6v/2E=; b=HGQ4xnu+Aekg/EybL+GMpCZLg8Z5kRp3HanpHeOVr5qklzHXWijBfa6QDXYxo7Dl88 IYb15/qwaFnO3dswJaU15f8c8uVh1rWZy9eGg8O7etr31tXem1X3v3SBzgZv2xUuJHZ2 65KuQSPBhMl1fq5Fuhz3k+/ZJ+Y10OuvVoQHFTzUmaoXr0mNA46yNpr98N06WNdQbUM5 qYEv+/caeE63K3f9uK5/pJXxVmu5W7T5p0nbTFniaBGj+7sLBxrD9CiH/LitGJGiY0My DYcPJtbpiM08fakCZjTPTIPhLT5RcBWOdxkHIj8BSvfGjuD33E13H/na/2FPPsOQSTER 8FGg== X-Gm-Message-State: AAQBX9eze6VqXESzQtg1PvG1S9EA60hSzJD+I1clXOseWal3/5IiOJHM 15L+LYbnjfq0gYHLcTvnXgSYD9ES X-Google-Smtp-Source: AKy350ZsW6g21ysQO6fafo7XFPhVJDJ2KbJK86/FVVgaB6fvjIr3BKBJ+rf3r2iDHz3Pq9ftSWYUmw== X-Received: by 2002:a17:906:6a2a:b0:929:ac47:f0ad with SMTP id qw42-20020a1709066a2a00b00929ac47f0admr4000755ejc.1.1679846619575; Sun, 26 Mar 2023 09:03:39 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:2049:b0:931:f9f8:d13e with SMTP id pg9-20020a170907204900b00931f9f8d13els3886829ejb.8.-pod-prod-gmail; Sun, 26 Mar 2023 09:03:38 -0700 (PDT) X-Received: by 2002:a17:906:3193:b0:932:1af9:7386 with SMTP id 19-20020a170906319300b009321af97386mr8589580ejy.27.1679846617964; Sun, 26 Mar 2023 09:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679846617; cv=none; d=google.com; s=arc-20160816; b=zgo3BccL0+2sc6+CgwbI0P23ly7HIIaQZeqDs+nIwt4FXa2guAWWBVCyiNiPECGo9o BsGtvbrd/E4D60uIXAZuwKMc8DBVhd8ZcXsNZaWtMHRb+5WWe1qpK6cPfHEc5kRdec5s SodU+LGt9Q3EPbRtGLIyVUyCSXLBWyjGiI+edVUJm7oW73sPZ2ZMAy/ZMOa0AkamTvTi tQPeo6T4zIuZmYcVAtlp1yTLzTcWrPXqZl6VxN4suzcNjGW8ngwIJz93I4uzFcB6Us4S VmBO6Cs5l9L8k/Fglv+e6imaAenymFLijt7d5R2RSHaYHEgMcf9pMISqIAGO41tkF8uY b6Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=La/g6ZdFP5xb5dwFf1l6Fzpc7W8BmURXmNe6fGtjuLE=; b=czLQjwjs+2RQqTFwvuoDo1cOst6XhG1w6KE7Tc9zz84qLTk6zNDVLYl3vA1d+Rd0un Myo+le3s9WEJpRHrklDvhXmYoCbUSpXZoyCdv87PtgA0r+/bXDOieZ6LcmLEfkzskdf2 ahCHgCtwfyaXMLYB9+7inwXSTlex9W4KtpWlz373AWj+fo6OXCY3CtBQLmU3P7cOI+ES fsdrwcF4GV2v/ru2kUJczyPvwNMwAqNaxQgokHNwu8HJDpfONairZ0TzHZ/InTPMj6o4 MCmSSaRiZSCYrqG+eTyXXsO1QH3C18vJRcy5Iham8GpRo3zlPk4QRYsy3tZMiqJRtmE1 mCvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=itZzClcb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id q18-20020a50aa92000000b004fd204abe33sor13227824edc.34.2023.03.26.09.03.37 for (Google Transport Security); Sun, 26 Mar 2023 09:03:37 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:708:b0:502:4182:963e with SMTP id w8-20020a056402070800b005024182963emr1931015edx.26.1679846617626; Sun, 26 Mar 2023 09:03:37 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-87-0-102-254.retail.telecomitalia.it. [87.0.102.254]) by smtp.gmail.com with ESMTPSA id m2-20020a50d7c2000000b00501fc87352fsm6869333edj.13.2023.03.26.09.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Mar 2023 09:03:37 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , Rob Herring , Krzysztof Kozlowski , Marc Kleine-Budde , michael@amarulasolutions.com, Vincent Mailhol , Alexandre Torgue , Dario Binacchi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v8 5/5] can: bxcan: add support for ST bxCAN controller Date: Sun, 26 Mar 2023 18:03:25 +0200 Message-Id: <20230326160325.3771891-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> References: <20230326160325.3771891-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=itZzClcb; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add support for the basic extended CAN controller (bxCAN) found in many low- to middle-end STM32 SoCs. It supports the Basic Extended CAN protocol versions 2.0A and B with a maximum bit rate of 1 Mbit/s. The controller supports two channels (CAN1 as master and CAN2 as slave) and the driver can enable either or both of the channels. They share some of the required logic (e. g. clocks and filters), and that means you cannot use the slave CAN without enabling some hardware resources managed by the master CAN. Each channel has 3 transmit mailboxes, 2 receive FIFOs with 3 stages and 28 scalable filter banks. It also manages 4 dedicated interrupt vectors: - transmit interrupt - FIFO 0 receive interrupt - FIFO 1 receive interrupt - status change error interrupt Driver uses all 3 available mailboxes for transmission and FIFO 0 for reception. Rx filter rules are configured to the minimum. They accept all messages and assign filter 0 to CAN1 and filter 14 to CAN2 in identifier mask mode with 32 bits width. It enables and uses transmit, receive buffers for FIFO 0 and error and status change interrupts. Signed-off-by: Dario Binacchi Reviewed-by: Vincent Mailhol --- Changes in v8: - Do not enable the clock in probe and enable/disable it in open/close. - Return IRQ_NONE if no IRQ is active. Changes in v7: - Add Vincent Mailhol's Reviewed-by tag. - Remove all unused macros for reading/writing the controller registers. - Add CAN_ERR_CNT flag to notify availability of error counter. - Move the "break" before the newline in the switch/case statements. - Print the mnemotechnic instead of the error value in each netdev_err(). - Remove the debug print for timings parameter. - Do not copy the data if CAN_RTR_FLAG is set in bxcan_start_xmit(). - Populate ndev->ethtool_ops with the default timestamp info. Changes in v5: - Put static in front of bxcan_enable_filters() definition. Changes in v4: - Add "dt-bindings: arm: stm32: add compatible for syscon gcan node" patch. - Drop the core driver. Thus bxcan-drv.c has been renamed to bxcan.c and moved to the drivers/net/can folder. The drivers/net/can/bxcan directory has therefore been removed. - Use the regmap_*() functions to access the shared memory registers. - Use spinlock to protect bxcan_rmw(). - Use 1 space, instead of tabs, in the macros definition. - Drop clock ref-counting. - Drop unused code. - Drop the _SHIFT macros and use FIELD_GET()/FIELD_PREP() directly. - Add BXCAN_ prefix to lec error codes. - Add the macro BXCAN_RX_MB_NUM. - Enable time triggered mode and use can_rx_offload(). - Use readx_poll_timeout() in function with timeouts. - Loop from tail to head in bxcan_tx_isr(). - Check bits of tsr register instead of pkts variable in bxcan_tx_isr(). - Don't return from bxcan_handle_state_change() if skb/cf are NULL. - Enable/disable the generation of the bus error interrupt depending on can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING. - Don't return from bxcan_handle_bus_err() if skb is NULL. - Drop statistics updating from bxcan_handle_bus_err(). - Add an empty line in front of 'return IRQ_HANDLED;' - Rename bxcan_start() to bxcan_chip_start(). - Rename bxcan_stop() to bxcan_chip_stop(). - Disable all IRQs in bxcan_chip_stop(). - Rename bxcan_close() to bxcan_ndo_stop(). - Use writel instead of bxcan_rmw() to update the dlc register. Changes in v3: - Remove 'Dario Binacchi ' SOB. - Fix the documentation file path in the MAINTAINERS entry. - Do not increment the "stats->rx_bytes" if the frame is remote. - Remove pr_debug() call from bxcan_rmw(). Changes in v2: - Fix sparse errors. - Create a MAINTAINERS entry. - Remove the print of the registers address. - Remove the volatile keyword from bxcan_rmw(). - Use tx ring algorithm to manage tx mailboxes. - Use can_{get|put}_echo_skb(). - Update DT properties. MAINTAINERS | 7 + drivers/net/can/Kconfig | 12 + drivers/net/can/Makefile | 1 + drivers/net/can/bxcan.c | 1096 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 1116 insertions(+) create mode 100644 drivers/net/can/bxcan.c diff --git a/MAINTAINERS b/MAINTAINERS index d8ebab595b2a..74b519501378 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4431,6 +4431,13 @@ S: Maintained F: drivers/scsi/BusLogic.* F: drivers/scsi/FlashPoint.* +BXCAN CAN NETWORK DRIVER +M: Dario Binacchi +L: linux-can@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml +F: drivers/net/can/bxcan.c + C-MEDIA CMI8788 DRIVER M: Clemens Ladisch L: alsa-devel@alsa-project.org (moderated for non-subscribers) diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index cd34e8dc9394..3ceccafd701b 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig @@ -93,6 +93,18 @@ config CAN_AT91 This is a driver for the SoC CAN controller in Atmel's AT91SAM9263 and AT91SAM9X5 processors. +config CAN_BXCAN + tristate "STM32 Basic Extended CAN (bxCAN) devices" + depends on OF || ARCH_STM32 || COMPILE_TEST + depends on HAS_IOMEM + select CAN_RX_OFFLOAD + help + Say yes here to build support for the STMicroelectronics STM32 basic + extended CAN Controller (bxCAN). + + This driver can also be built as a module. If so, the module + will be called bxcan. + config CAN_CAN327 tristate "Serial / USB serial ELM327 based OBD-II Interfaces (can327)" depends on TTY diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile index 52b0f6e10668..ff8f76295d13 100644 --- a/drivers/net/can/Makefile +++ b/drivers/net/can/Makefile @@ -14,6 +14,7 @@ obj-y += usb/ obj-y += softing/ obj-$(CONFIG_CAN_AT91) += at91_can.o +obj-$(CONFIG_CAN_BXCAN) += bxcan.o obj-$(CONFIG_CAN_CAN327) += can327.o obj-$(CONFIG_CAN_CC770) += cc770/ obj-$(CONFIG_CAN_C_CAN) += c_can/ diff --git a/drivers/net/can/bxcan.c b/drivers/net/can/bxcan.c new file mode 100644 index 000000000000..7ce372907f70 --- /dev/null +++ b/drivers/net/can/bxcan.c @@ -0,0 +1,1096 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// bxcan.c - STM32 Basic Extended CAN controller driver +// +// Copyright (c) 2022 Dario Binacchi +// + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BXCAN_NAPI_WEIGHT 3 +#define BXCAN_TIMEOUT_US 10000 + +#define BXCAN_RX_MB_NUM 2 +#define BXCAN_TX_MB_NUM 3 + +/* Master control register (MCR) bits */ +#define BXCAN_MCR_RESET BIT(15) +#define BXCAN_MCR_TTCM BIT(7) +#define BXCAN_MCR_ABOM BIT(6) +#define BXCAN_MCR_AWUM BIT(5) +#define BXCAN_MCR_NART BIT(4) +#define BXCAN_MCR_RFLM BIT(3) +#define BXCAN_MCR_TXFP BIT(2) +#define BXCAN_MCR_SLEEP BIT(1) +#define BXCAN_MCR_INRQ BIT(0) + +/* Master status register (MSR) bits */ +#define BXCAN_MSR_ERRI BIT(2) +#define BXCAN_MSR_SLAK BIT(1) +#define BXCAN_MSR_INAK BIT(0) + +/* Transmit status register (TSR) bits */ +#define BXCAN_TSR_RQCP2 BIT(16) +#define BXCAN_TSR_RQCP1 BIT(8) +#define BXCAN_TSR_RQCP0 BIT(0) + +/* Receive FIFO 0 register (RF0R) bits */ +#define BXCAN_RF0R_RFOM0 BIT(5) +#define BXCAN_RF0R_FMP0_MASK GENMASK(1, 0) + +/* Interrupt enable register (IER) bits */ +#define BXCAN_IER_SLKIE BIT(17) +#define BXCAN_IER_WKUIE BIT(16) +#define BXCAN_IER_ERRIE BIT(15) +#define BXCAN_IER_LECIE BIT(11) +#define BXCAN_IER_BOFIE BIT(10) +#define BXCAN_IER_EPVIE BIT(9) +#define BXCAN_IER_EWGIE BIT(8) +#define BXCAN_IER_FOVIE1 BIT(6) +#define BXCAN_IER_FFIE1 BIT(5) +#define BXCAN_IER_FMPIE1 BIT(4) +#define BXCAN_IER_FOVIE0 BIT(3) +#define BXCAN_IER_FFIE0 BIT(2) +#define BXCAN_IER_FMPIE0 BIT(1) +#define BXCAN_IER_TMEIE BIT(0) + +/* Error status register (ESR) bits */ +#define BXCAN_ESR_REC_MASK GENMASK(31, 24) +#define BXCAN_ESR_TEC_MASK GENMASK(23, 16) +#define BXCAN_ESR_LEC_MASK GENMASK(6, 4) +#define BXCAN_ESR_BOFF BIT(2) +#define BXCAN_ESR_EPVF BIT(1) +#define BXCAN_ESR_EWGF BIT(0) + +/* Bit timing register (BTR) bits */ +#define BXCAN_BTR_SILM BIT(31) +#define BXCAN_BTR_LBKM BIT(30) +#define BXCAN_BTR_SJW_MASK GENMASK(25, 24) +#define BXCAN_BTR_TS2_MASK GENMASK(22, 20) +#define BXCAN_BTR_TS1_MASK GENMASK(19, 16) +#define BXCAN_BTR_BRP_MASK GENMASK(9, 0) + +/* TX mailbox identifier register (TIxR, x = 0..2) bits */ +#define BXCAN_TIxR_STID_MASK GENMASK(31, 21) +#define BXCAN_TIxR_EXID_MASK GENMASK(31, 3) +#define BXCAN_TIxR_IDE BIT(2) +#define BXCAN_TIxR_RTR BIT(1) +#define BXCAN_TIxR_TXRQ BIT(0) + +/* TX mailbox data length and time stamp register (TDTxR, x = 0..2 bits */ +#define BXCAN_TDTxR_DLC_MASK GENMASK(3, 0) + +/* RX FIFO mailbox identifier register (RIxR, x = 0..1 */ +#define BXCAN_RIxR_STID_MASK GENMASK(31, 21) +#define BXCAN_RIxR_EXID_MASK GENMASK(31, 3) +#define BXCAN_RIxR_IDE BIT(2) +#define BXCAN_RIxR_RTR BIT(1) + +/* RX FIFO mailbox data length and timestamp register (RDTxR, x = 0..1) bits */ +#define BXCAN_RDTxR_TIME_MASK GENMASK(31, 16) +#define BXCAN_RDTxR_DLC_MASK GENMASK(3, 0) + +#define BXCAN_FMR_REG 0x00 +#define BXCAN_FM1R_REG 0x04 +#define BXCAN_FS1R_REG 0x0c +#define BXCAN_FFA1R_REG 0x14 +#define BXCAN_FA1R_REG 0x1c +#define BXCAN_FiR1_REG(b) (0x40 + (b) * 8) +#define BXCAN_FiR2_REG(b) (0x44 + (b) * 8) + +#define BXCAN_FILTER_ID(master) (master ? 0 : 14) + +/* Filter master register (FMR) bits */ +#define BXCAN_FMR_CANSB_MASK GENMASK(13, 8) +#define BXCAN_FMR_FINIT BIT(0) + +enum bxcan_lec_code { + BXCAN_LEC_NO_ERROR = 0, + BXCAN_LEC_STUFF_ERROR, + BXCAN_LEC_FORM_ERROR, + BXCAN_LEC_ACK_ERROR, + BXCAN_LEC_BIT1_ERROR, + BXCAN_LEC_BIT0_ERROR, + BXCAN_LEC_CRC_ERROR, + BXCAN_LEC_UNUSED +}; + +/* Structure of the message buffer */ +struct bxcan_mb { + u32 id; /* can identifier */ + u32 dlc; /* data length control and timestamp */ + u32 data[2]; /* data */ +}; + +/* Structure of the hardware registers */ +struct bxcan_regs { + u32 mcr; /* 0x00 - master control */ + u32 msr; /* 0x04 - master status */ + u32 tsr; /* 0x08 - transmit status */ + u32 rf0r; /* 0x0c - FIFO 0 */ + u32 rf1r; /* 0x10 - FIFO 1 */ + u32 ier; /* 0x14 - interrupt enable */ + u32 esr; /* 0x18 - error status */ + u32 btr; /* 0x1c - bit timing*/ + u32 reserved0[88]; /* 0x20 */ + struct bxcan_mb tx_mb[BXCAN_TX_MB_NUM]; /* 0x180 - tx mailbox */ + struct bxcan_mb rx_mb[BXCAN_RX_MB_NUM]; /* 0x1b0 - rx mailbox */ +}; + +struct bxcan_priv { + struct can_priv can; + struct can_rx_offload offload; + struct device *dev; + struct net_device *ndev; + + struct bxcan_regs __iomem *regs; + struct regmap *gcan; + int tx_irq; + int sce_irq; + bool master; + struct clk *clk; + spinlock_t rmw_lock; /* lock for read-modify-write operations */ + unsigned int tx_head; + unsigned int tx_tail; + u32 timestamp; +}; + +static const struct can_bittiming_const bxcan_bittiming_const = { + .name = KBUILD_MODNAME, + .tseg1_min = 1, + .tseg1_max = 16, + .tseg2_min = 1, + .tseg2_max = 8, + .sjw_max = 4, + .brp_min = 1, + .brp_max = 1024, + .brp_inc = 1, +}; + +static inline void bxcan_rmw(struct bxcan_priv *priv, void __iomem *addr, + u32 clear, u32 set) +{ + unsigned long flags; + u32 old, val; + + spin_lock_irqsave(&priv->rmw_lock, flags); + old = readl(addr); + val = (old & ~clear) | set; + if (val != old) + writel(val, addr); + + spin_unlock_irqrestore(&priv->rmw_lock, flags); +} + +static void bxcan_disable_filters(struct bxcan_priv *priv, bool master) +{ + unsigned int fid = BXCAN_FILTER_ID(master); + u32 fmask = BIT(fid); + + regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, 0); +} + +static void bxcan_enable_filters(struct bxcan_priv *priv, bool master) +{ + unsigned int fid = BXCAN_FILTER_ID(master); + u32 fmask = BIT(fid); + + /* Filter settings: + * + * Accept all messages. + * Assign filter 0 to CAN1 and filter 14 to CAN2 in identifier + * mask mode with 32 bits width. + */ + + /* Enter filter initialization mode and assing filters to CAN + * controllers. + */ + regmap_update_bits(priv->gcan, BXCAN_FMR_REG, + BXCAN_FMR_CANSB_MASK | BXCAN_FMR_FINIT, + FIELD_PREP(BXCAN_FMR_CANSB_MASK, 14) | + BXCAN_FMR_FINIT); + + /* Deactivate filter */ + regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, 0); + + /* Two 32-bit registers in identifier mask mode */ + regmap_update_bits(priv->gcan, BXCAN_FM1R_REG, fmask, 0); + + /* Single 32-bit scale configuration */ + regmap_update_bits(priv->gcan, BXCAN_FS1R_REG, fmask, fmask); + + /* Assign filter to FIFO 0 */ + regmap_update_bits(priv->gcan, BXCAN_FFA1R_REG, fmask, 0); + + /* Accept all messages */ + regmap_write(priv->gcan, BXCAN_FiR1_REG(fid), 0); + regmap_write(priv->gcan, BXCAN_FiR2_REG(fid), 0); + + /* Activate filter */ + regmap_update_bits(priv->gcan, BXCAN_FA1R_REG, fmask, fmask); + + /* Exit filter initialization mode */ + regmap_update_bits(priv->gcan, BXCAN_FMR_REG, BXCAN_FMR_FINIT, 0); +} + +static inline u8 bxcan_get_tx_head(const struct bxcan_priv *priv) +{ + return priv->tx_head % BXCAN_TX_MB_NUM; +} + +static inline u8 bxcan_get_tx_tail(const struct bxcan_priv *priv) +{ + return priv->tx_tail % BXCAN_TX_MB_NUM; +} + +static inline u8 bxcan_get_tx_free(const struct bxcan_priv *priv) +{ + return BXCAN_TX_MB_NUM - (priv->tx_head - priv->tx_tail); +} + +static bool bxcan_tx_busy(const struct bxcan_priv *priv) +{ + if (bxcan_get_tx_free(priv) > 0) + return false; + + netif_stop_queue(priv->ndev); + + /* Memory barrier before checking tx_free (head and tail) */ + smp_mb(); + + if (bxcan_get_tx_free(priv) == 0) { + netdev_dbg(priv->ndev, + "Stopping tx-queue (tx_head=0x%08x, tx_tail=0x%08x, len=%d).\n", + priv->tx_head, priv->tx_tail, + priv->tx_head - priv->tx_tail); + + return true; + } + + netif_start_queue(priv->ndev); + + return false; +} + +static int bxcan_chip_softreset(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, 0, BXCAN_MCR_RESET); + return readx_poll_timeout(readl, ®s->msr, value, + value & BXCAN_MSR_SLAK, BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_enter_init_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, 0, BXCAN_MCR_INRQ); + return readx_poll_timeout(readl, ®s->msr, value, + value & BXCAN_MSR_INAK, BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_leave_init_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, BXCAN_MCR_INRQ, 0); + return readx_poll_timeout(readl, ®s->msr, value, + !(value & BXCAN_MSR_INAK), BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_enter_sleep_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, 0, BXCAN_MCR_SLEEP); + return readx_poll_timeout(readl, ®s->msr, value, + value & BXCAN_MSR_SLAK, BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static int bxcan_leave_sleep_mode(struct bxcan_priv *priv) +{ + struct bxcan_regs __iomem *regs = priv->regs; + u32 value; + + bxcan_rmw(priv, ®s->mcr, BXCAN_MCR_SLEEP, 0); + return readx_poll_timeout(readl, ®s->msr, value, + !(value & BXCAN_MSR_SLAK), BXCAN_TIMEOUT_US, + USEC_PER_SEC); +} + +static inline +struct bxcan_priv *rx_offload_to_priv(struct can_rx_offload *offload) +{ + return container_of(offload, struct bxcan_priv, offload); +} + +static struct sk_buff *bxcan_mailbox_read(struct can_rx_offload *offload, + unsigned int mbxno, u32 *timestamp, + bool drop) +{ + struct bxcan_priv *priv = rx_offload_to_priv(offload); + struct bxcan_regs __iomem *regs = priv->regs; + struct bxcan_mb __iomem *mb_regs = ®s->rx_mb[0]; + struct sk_buff *skb = NULL; + struct can_frame *cf; + u32 rf0r, id, dlc; + + rf0r = readl(®s->rf0r); + if (unlikely(drop)) { + skb = ERR_PTR(-ENOBUFS); + goto mark_as_read; + } + + if (!(rf0r & BXCAN_RF0R_FMP0_MASK)) + goto mark_as_read; + + skb = alloc_can_skb(offload->dev, &cf); + if (unlikely(!skb)) { + skb = ERR_PTR(-ENOMEM); + goto mark_as_read; + } + + id = readl(&mb_regs->id); + if (id & BXCAN_RIxR_IDE) + cf->can_id = FIELD_GET(BXCAN_RIxR_EXID_MASK, id) | CAN_EFF_FLAG; + else + cf->can_id = FIELD_GET(BXCAN_RIxR_STID_MASK, id) & CAN_SFF_MASK; + + dlc = readl(&mb_regs->dlc); + priv->timestamp = FIELD_GET(BXCAN_RDTxR_TIME_MASK, dlc); + cf->len = can_cc_dlc2len(FIELD_GET(BXCAN_RDTxR_DLC_MASK, dlc)); + + if (id & BXCAN_RIxR_RTR) { + cf->can_id |= CAN_RTR_FLAG; + } else { + int i, j; + + for (i = 0, j = 0; i < cf->len; i += 4, j++) + *(u32 *)(cf->data + i) = readl(&mb_regs->data[j]); + } + + mark_as_read: + rf0r |= BXCAN_RF0R_RFOM0; + writel(rf0r, ®s->rf0r); + return skb; +} + +static irqreturn_t bxcan_rx_isr(int irq, void *dev_id) +{ + struct net_device *ndev = dev_id; + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + u32 rf0r; + + rf0r = readl(®s->rf0r); + if (!(rf0r & BXCAN_RF0R_FMP0_MASK)) + return IRQ_NONE; + + can_rx_offload_irq_offload_fifo(&priv->offload); + can_rx_offload_irq_finish(&priv->offload); + + return IRQ_HANDLED; +} + +static irqreturn_t bxcan_tx_isr(int irq, void *dev_id) +{ + struct net_device *ndev = dev_id; + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + struct net_device_stats *stats = &ndev->stats; + u32 tsr, rqcp_bit; + int idx; + + tsr = readl(®s->tsr); + if (!(tsr & (BXCAN_TSR_RQCP0 | BXCAN_TSR_RQCP1 | BXCAN_TSR_RQCP2))) + return IRQ_NONE; + + while (priv->tx_head - priv->tx_tail > 0) { + idx = bxcan_get_tx_tail(priv); + rqcp_bit = BXCAN_TSR_RQCP0 << (idx << 3); + if (!(tsr & rqcp_bit)) + break; + + stats->tx_packets++; + stats->tx_bytes += can_get_echo_skb(ndev, idx, NULL); + priv->tx_tail++; + } + + writel(tsr, ®s->tsr); + + if (bxcan_get_tx_free(priv)) { + /* Make sure that anybody stopping the queue after + * this sees the new tx_ring->tail. + */ + smp_mb(); + netif_wake_queue(ndev); + } + + return IRQ_HANDLED; +} + +static void bxcan_handle_state_change(struct net_device *ndev, u32 esr) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + enum can_state new_state = priv->can.state; + struct can_berr_counter bec; + enum can_state rx_state, tx_state; + struct sk_buff *skb; + struct can_frame *cf; + + /* Early exit if no error flag is set */ + if (!(esr & (BXCAN_ESR_EWGF | BXCAN_ESR_EPVF | BXCAN_ESR_BOFF))) + return; + + bec.txerr = FIELD_GET(BXCAN_ESR_TEC_MASK, esr); + bec.rxerr = FIELD_GET(BXCAN_ESR_REC_MASK, esr); + + if (esr & BXCAN_ESR_BOFF) + new_state = CAN_STATE_BUS_OFF; + else if (esr & BXCAN_ESR_EPVF) + new_state = CAN_STATE_ERROR_PASSIVE; + else if (esr & BXCAN_ESR_EWGF) + new_state = CAN_STATE_ERROR_WARNING; + + /* state hasn't changed */ + if (unlikely(new_state == priv->can.state)) + return; + + skb = alloc_can_err_skb(ndev, &cf); + + tx_state = bec.txerr >= bec.rxerr ? new_state : 0; + rx_state = bec.txerr <= bec.rxerr ? new_state : 0; + can_change_state(ndev, cf, tx_state, rx_state); + + if (new_state == CAN_STATE_BUS_OFF) { + can_bus_off(ndev); + } else if (skb) { + cf->can_id |= CAN_ERR_CNT; + cf->data[6] = bec.txerr; + cf->data[7] = bec.rxerr; + } + + if (skb) { + int err; + + err = can_rx_offload_queue_timestamp(&priv->offload, skb, + priv->timestamp); + if (err) + ndev->stats.rx_fifo_errors++; + } +} + +static void bxcan_handle_bus_err(struct net_device *ndev, u32 esr) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + enum bxcan_lec_code lec_code; + struct can_frame *cf; + struct sk_buff *skb; + + lec_code = FIELD_GET(BXCAN_ESR_LEC_MASK, esr); + + /* Early exit if no lec update or no error. + * No lec update means that no CAN bus event has been detected + * since CPU wrote BXCAN_LEC_UNUSED value to status reg. + */ + if (lec_code == BXCAN_LEC_UNUSED || lec_code == BXCAN_LEC_NO_ERROR) + return; + + /* Common for all type of bus errors */ + priv->can.can_stats.bus_error++; + + /* Propagate the error condition to the CAN stack */ + skb = alloc_can_err_skb(ndev, &cf); + if (skb) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; + + switch (lec_code) { + case BXCAN_LEC_STUFF_ERROR: + netdev_dbg(ndev, "Stuff error\n"); + ndev->stats.rx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_STUFF; + break; + + case BXCAN_LEC_FORM_ERROR: + netdev_dbg(ndev, "Form error\n"); + ndev->stats.rx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_FORM; + break; + + case BXCAN_LEC_ACK_ERROR: + netdev_dbg(ndev, "Ack error\n"); + ndev->stats.tx_errors++; + if (skb) { + cf->can_id |= CAN_ERR_ACK; + cf->data[3] = CAN_ERR_PROT_LOC_ACK; + } + break; + + case BXCAN_LEC_BIT1_ERROR: + netdev_dbg(ndev, "Bit error (recessive)\n"); + ndev->stats.tx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_BIT1; + break; + + case BXCAN_LEC_BIT0_ERROR: + netdev_dbg(ndev, "Bit error (dominant)\n"); + ndev->stats.tx_errors++; + if (skb) + cf->data[2] |= CAN_ERR_PROT_BIT0; + break; + + case BXCAN_LEC_CRC_ERROR: + netdev_dbg(ndev, "CRC error\n"); + ndev->stats.rx_errors++; + if (skb) { + cf->data[2] |= CAN_ERR_PROT_BIT; + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + } + break; + + default: + break; + } + + if (skb) { + int err; + + err = can_rx_offload_queue_timestamp(&priv->offload, skb, + priv->timestamp); + if (err) + ndev->stats.rx_fifo_errors++; + } +} + +static irqreturn_t bxcan_state_change_isr(int irq, void *dev_id) +{ + struct net_device *ndev = dev_id; + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + u32 msr, esr; + + msr = readl(®s->msr); + if (!(msr & BXCAN_MSR_ERRI)) + return IRQ_NONE; + + esr = readl(®s->esr); + bxcan_handle_state_change(ndev, esr); + + if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) + bxcan_handle_bus_err(ndev, esr); + + msr |= BXCAN_MSR_ERRI; + writel(msr, ®s->msr); + can_rx_offload_irq_finish(&priv->offload); + + return IRQ_HANDLED; +} + +static int bxcan_chip_start(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + struct can_bittiming *bt = &priv->can.bittiming; + u32 clr, set; + int err; + + err = bxcan_chip_softreset(priv); + if (err) { + netdev_err(ndev, "failed to reset chip, error %pe\n", + ERR_PTR(err)); + return err; + } + + err = bxcan_leave_sleep_mode(priv); + if (err) { + netdev_err(ndev, "failed to leave sleep mode, error %pe\n", + ERR_PTR(err)); + goto failed_leave_sleep; + } + + err = bxcan_enter_init_mode(priv); + if (err) { + netdev_err(ndev, "failed to enter init mode, error %pe\n", + ERR_PTR(err)); + goto failed_enter_init; + } + + /* MCR + * + * select request order priority + * enable time triggered mode + * bus-off state left on sw request + * sleep mode left on sw request + * retransmit automatically on error + * do not lock RX FIFO on overrun + */ + bxcan_rmw(priv, ®s->mcr, + BXCAN_MCR_ABOM | BXCAN_MCR_AWUM | BXCAN_MCR_NART | + BXCAN_MCR_RFLM, BXCAN_MCR_TTCM | BXCAN_MCR_TXFP); + + /* Bit timing register settings */ + set = FIELD_PREP(BXCAN_BTR_BRP_MASK, bt->brp - 1) | + FIELD_PREP(BXCAN_BTR_TS1_MASK, bt->phase_seg1 + + bt->prop_seg - 1) | + FIELD_PREP(BXCAN_BTR_TS2_MASK, bt->phase_seg2 - 1) | + FIELD_PREP(BXCAN_BTR_SJW_MASK, bt->sjw - 1); + + /* loopback + silent mode put the controller in test mode, + * useful for hot self-test + */ + if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) + set |= BXCAN_BTR_LBKM; + + if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) + set |= BXCAN_BTR_SILM; + + bxcan_rmw(priv, ®s->btr, BXCAN_BTR_SILM | BXCAN_BTR_LBKM | + BXCAN_BTR_BRP_MASK | BXCAN_BTR_TS1_MASK | BXCAN_BTR_TS2_MASK | + BXCAN_BTR_SJW_MASK, set); + + bxcan_enable_filters(priv, priv->master); + + /* Clear all internal status */ + priv->tx_head = 0; + priv->tx_tail = 0; + + err = bxcan_leave_init_mode(priv); + if (err) { + netdev_err(ndev, "failed to leave init mode, error %pe\n", + ERR_PTR(err)); + goto failed_leave_init; + } + + /* Set a `lec` value so that we can check for updates later */ + bxcan_rmw(priv, ®s->esr, BXCAN_ESR_LEC_MASK, + FIELD_PREP(BXCAN_ESR_LEC_MASK, BXCAN_LEC_UNUSED)); + + /* IER + * + * Enable interrupt for: + * bus-off + * passive error + * warning error + * last error code + * RX FIFO pending message + * TX mailbox empty + */ + clr = BXCAN_IER_WKUIE | BXCAN_IER_SLKIE | BXCAN_IER_FOVIE1 | + BXCAN_IER_FFIE1 | BXCAN_IER_FMPIE1 | BXCAN_IER_FOVIE0 | + BXCAN_IER_FFIE0; + set = BXCAN_IER_ERRIE | BXCAN_IER_BOFIE | BXCAN_IER_EPVIE | + BXCAN_IER_EWGIE | BXCAN_IER_FMPIE0 | BXCAN_IER_TMEIE; + + if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) + set |= BXCAN_IER_LECIE; + else + clr |= BXCAN_IER_LECIE; + + bxcan_rmw(priv, ®s->ier, clr, set); + + priv->can.state = CAN_STATE_ERROR_ACTIVE; + return 0; + +failed_leave_init: +failed_enter_init: +failed_leave_sleep: + bxcan_chip_softreset(priv); + return err; +} + +static int bxcan_open(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + int err; + + err = clk_prepare_enable(priv->clk); + if (err) { + netdev_err(ndev, "failed to enable clock, error %pe\n", + ERR_PTR(err)); + return err; + } + + err = open_candev(ndev); + if (err) { + netdev_err(ndev, "open_candev() failed, error %pe\n", + ERR_PTR(err)); + goto out_disable_clock; + } + + can_rx_offload_enable(&priv->offload); + err = request_irq(ndev->irq, bxcan_rx_isr, IRQF_SHARED, ndev->name, + ndev); + if (err) { + netdev_err(ndev, "failed to register rx irq(%d), error %pe\n", + ndev->irq, ERR_PTR(err)); + goto out_close_candev; + } + + err = request_irq(priv->tx_irq, bxcan_tx_isr, IRQF_SHARED, ndev->name, + ndev); + if (err) { + netdev_err(ndev, "failed to register tx irq(%d), error %pe\n", + priv->tx_irq, ERR_PTR(err)); + goto out_free_rx_irq; + } + + err = request_irq(priv->sce_irq, bxcan_state_change_isr, IRQF_SHARED, + ndev->name, ndev); + if (err) { + netdev_err(ndev, "failed to register sce irq(%d), error %pe\n", + priv->sce_irq, ERR_PTR(err)); + goto out_free_tx_irq; + } + + err = bxcan_chip_start(ndev); + if (err) + goto out_free_sce_irq; + + netif_start_queue(ndev); + return 0; + +out_free_sce_irq: + free_irq(priv->sce_irq, ndev); +out_free_tx_irq: + free_irq(priv->tx_irq, ndev); +out_free_rx_irq: + free_irq(ndev->irq, ndev); +out_close_candev: + can_rx_offload_disable(&priv->offload); + close_candev(ndev); +out_disable_clock: + clk_disable_unprepare(priv->clk); + return err; +} + +static void bxcan_chip_stop(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + + /* disable all interrupts */ + bxcan_rmw(priv, ®s->ier, BXCAN_IER_SLKIE | BXCAN_IER_WKUIE | + BXCAN_IER_ERRIE | BXCAN_IER_LECIE | BXCAN_IER_BOFIE | + BXCAN_IER_EPVIE | BXCAN_IER_EWGIE | BXCAN_IER_FOVIE1 | + BXCAN_IER_FFIE1 | BXCAN_IER_FMPIE1 | BXCAN_IER_FOVIE0 | + BXCAN_IER_FFIE0 | BXCAN_IER_FMPIE0 | BXCAN_IER_TMEIE, 0); + bxcan_disable_filters(priv, priv->master); + bxcan_enter_sleep_mode(priv); + priv->can.state = CAN_STATE_STOPPED; +} + +static int bxcan_stop(struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + + netif_stop_queue(ndev); + bxcan_chip_stop(ndev); + free_irq(ndev->irq, ndev); + free_irq(priv->tx_irq, ndev); + free_irq(priv->sce_irq, ndev); + can_rx_offload_disable(&priv->offload); + close_candev(ndev); + clk_disable_unprepare(priv->clk); + return 0; +} + +static netdev_tx_t bxcan_start_xmit(struct sk_buff *skb, + struct net_device *ndev) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct can_frame *cf = (struct can_frame *)skb->data; + struct bxcan_regs __iomem *regs = priv->regs; + struct bxcan_mb __iomem *mb_regs; + unsigned int idx; + u32 id; + int i, j; + + if (can_dropped_invalid_skb(ndev, skb)) + return NETDEV_TX_OK; + + if (bxcan_tx_busy(priv)) + return NETDEV_TX_BUSY; + + idx = bxcan_get_tx_head(priv); + priv->tx_head++; + if (bxcan_get_tx_free(priv) == 0) + netif_stop_queue(ndev); + + mb_regs = ®s->tx_mb[idx]; + if (cf->can_id & CAN_EFF_FLAG) + id = FIELD_PREP(BXCAN_TIxR_EXID_MASK, cf->can_id) | + BXCAN_TIxR_IDE; + else + id = FIELD_PREP(BXCAN_TIxR_STID_MASK, cf->can_id); + + if (cf->can_id & CAN_RTR_FLAG) { /* Remote transmission request */ + id |= BXCAN_TIxR_RTR; + } else { + for (i = 0, j = 0; i < cf->len; i += 4, j++) + writel(*(u32 *)(cf->data + i), &mb_regs->data[j]); + } + + writel(FIELD_PREP(BXCAN_TDTxR_DLC_MASK, cf->len), &mb_regs->dlc); + + can_put_echo_skb(skb, ndev, idx, 0); + + /* Start transmission */ + writel(id | BXCAN_TIxR_TXRQ, &mb_regs->id); + + return NETDEV_TX_OK; +} + +static const struct net_device_ops bxcan_netdev_ops = { + .ndo_open = bxcan_open, + .ndo_stop = bxcan_stop, + .ndo_start_xmit = bxcan_start_xmit, + .ndo_change_mtu = can_change_mtu, +}; + +static const struct ethtool_ops bxcan_ethtool_ops = { + .get_ts_info = ethtool_op_get_ts_info, +}; + +static int bxcan_do_set_mode(struct net_device *ndev, enum can_mode mode) +{ + int err; + + switch (mode) { + case CAN_MODE_START: + err = bxcan_chip_start(ndev); + if (err) + return err; + + netif_wake_queue(ndev); + break; + + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static int bxcan_get_berr_counter(const struct net_device *ndev, + struct can_berr_counter *bec) +{ + struct bxcan_priv *priv = netdev_priv(ndev); + struct bxcan_regs __iomem *regs = priv->regs; + u32 esr; + int err; + + err = clk_prepare_enable(priv->clk); + if (err) + return err; + + esr = readl(®s->esr); + bec->txerr = FIELD_GET(BXCAN_ESR_TEC_MASK, esr); + bec->rxerr = FIELD_GET(BXCAN_ESR_REC_MASK, esr); + clk_disable_unprepare(priv->clk); + return 0; +} + +static int bxcan_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct net_device *ndev; + struct bxcan_priv *priv; + struct clk *clk = NULL; + void __iomem *regs; + struct regmap *gcan; + bool master; + int err, rx_irq, tx_irq, sce_irq; + + regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regs)) { + dev_err(dev, "failed to get base address\n"); + return PTR_ERR(regs); + } + + gcan = syscon_regmap_lookup_by_phandle(np, "st,gcan"); + if (IS_ERR(gcan)) { + dev_err(dev, "failed to get shared memory base address\n"); + return PTR_ERR(gcan); + } + + master = of_property_read_bool(np, "st,can-master"); + clk = devm_clk_get(dev, NULL); + if (IS_ERR(clk)) { + dev_err(dev, "failed to get clock\n"); + return PTR_ERR(clk); + } + + rx_irq = platform_get_irq_byname(pdev, "rx0"); + if (rx_irq < 0) { + dev_err(dev, "failed to get rx0 irq\n"); + return rx_irq; + } + + tx_irq = platform_get_irq_byname(pdev, "tx"); + if (tx_irq < 0) { + dev_err(dev, "failed to get tx irq\n"); + return tx_irq; + } + + sce_irq = platform_get_irq_byname(pdev, "sce"); + if (sce_irq < 0) { + dev_err(dev, "failed to get sce irq\n"); + return sce_irq; + } + + ndev = alloc_candev(sizeof(struct bxcan_priv), BXCAN_TX_MB_NUM); + if (!ndev) { + dev_err(dev, "alloc_candev() failed\n"); + return -ENOMEM; + } + + priv = netdev_priv(ndev); + platform_set_drvdata(pdev, ndev); + SET_NETDEV_DEV(ndev, dev); + ndev->netdev_ops = &bxcan_netdev_ops; + ndev->ethtool_ops = &bxcan_ethtool_ops; + ndev->irq = rx_irq; + ndev->flags |= IFF_ECHO; + + priv->dev = dev; + priv->ndev = ndev; + priv->regs = regs; + priv->gcan = gcan; + priv->clk = clk; + priv->tx_irq = tx_irq; + priv->sce_irq = sce_irq; + priv->master = master; + priv->can.clock.freq = clk_get_rate(clk); + spin_lock_init(&priv->rmw_lock); + priv->tx_head = 0; + priv->tx_tail = 0; + priv->can.bittiming_const = &bxcan_bittiming_const; + priv->can.do_set_mode = bxcan_do_set_mode; + priv->can.do_get_berr_counter = bxcan_get_berr_counter; + priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | + CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_BERR_REPORTING; + + priv->offload.mailbox_read = bxcan_mailbox_read; + err = can_rx_offload_add_fifo(ndev, &priv->offload, BXCAN_NAPI_WEIGHT); + if (err) { + dev_err(dev, "failed to add FIFO rx_offload\n"); + goto out_free_candev; + } + + err = register_candev(ndev); + if (err) { + dev_err(dev, "failed to register netdev\n"); + goto out_can_rx_offload_del; + } + + dev_info(dev, "clk: %d Hz, IRQs: %d, %d, %d\n", priv->can.clock.freq, + tx_irq, rx_irq, sce_irq); + return 0; + +out_can_rx_offload_del: + can_rx_offload_del(&priv->offload); +out_free_candev: + free_candev(ndev); + return err; +} + +static int bxcan_remove(struct platform_device *pdev) +{ + struct net_device *ndev = platform_get_drvdata(pdev); + struct bxcan_priv *priv = netdev_priv(ndev); + + unregister_candev(ndev); + clk_disable_unprepare(priv->clk); + can_rx_offload_del(&priv->offload); + free_candev(ndev); + return 0; +} + +static int __maybe_unused bxcan_suspend(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct bxcan_priv *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return 0; + + netif_stop_queue(ndev); + netif_device_detach(ndev); + + bxcan_enter_sleep_mode(priv); + priv->can.state = CAN_STATE_SLEEPING; + clk_disable_unprepare(priv->clk); + return 0; +} + +static int __maybe_unused bxcan_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct bxcan_priv *priv = netdev_priv(ndev); + + if (!netif_running(ndev)) + return 0; + + clk_prepare_enable(priv->clk); + bxcan_leave_sleep_mode(priv); + priv->can.state = CAN_STATE_ERROR_ACTIVE; + + netif_device_attach(ndev); + netif_start_queue(ndev); + return 0; +} + +static SIMPLE_DEV_PM_OPS(bxcan_pm_ops, bxcan_suspend, bxcan_resume); + +static const struct of_device_id bxcan_of_match[] = { + {.compatible = "st,stm32f4-bxcan"}, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, bxcan_of_match); + +static struct platform_driver bxcan_driver = { + .driver = { + .name = KBUILD_MODNAME, + .pm = &bxcan_pm_ops, + .of_match_table = bxcan_of_match, + }, + .probe = bxcan_probe, + .remove = bxcan_remove, +}; + +module_platform_driver(bxcan_driver); + +MODULE_AUTHOR("Dario Binacchi "); +MODULE_DESCRIPTION("STMicroelectronics Basic Extended CAN controller driver"); +MODULE_LICENSE("GPL");