From patchwork Sun Aug 28 13:33:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2313 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 1FB9940F47 for ; Sun, 28 Aug 2022 15:33:39 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id p4-20020a056402500400b00447e8b6f62bsf4058980eda.17 for ; Sun, 28 Aug 2022 06:33:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661693618; cv=pass; d=google.com; s=arc-20160816; b=IGOyfNdNEViIAIEC29lifBDrWojLBlO5T8RkfyTR0IfccgsmHU9HJ+SiDEAnpoJ5Th JDkZS1JC0/e+qm+VIjWsG6urt95hsxI5PdhfgF1imMCWNAcFDLDeijreWSOIIUVkZw8V 0eZdjkXcEn6XcfCfBmt+PDE92vuYMkezSyrety59JkkxnAH8Q9QxhohDX9jOWFJ801sS 8PnwhWYVAdXNZ7OR/8h4HINnpqZnfIs9JYt2IJVQVfCkidasDEK7+saaIwPp549B/9iF KLGSgP/BXeLq2oZsMaB1BMaAi87iLuFIfkEkqs0TDerO1UWop3CwzXNwX4LdCcqCsvDw eyog== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=pMUsGilgOt2iydT/w49Tlmrul6d51jtQpenwmtBIEqs=; b=HNRVWE3ic6Z3QT1UOCgUZht/gMIZLkd3dLVCZ532GyPlmXldvu518WGywzSY/Ijfqs 6NgohFpMQj3K4UWuNhtGtDV4fw1f1mn0pgk+LwPVRoZZGFWdjBwy/v/w8FQKohQRDOhD /QwOuVQ269sFCUQ5COjSVob5hPIy2F8KisHIsQ6fomXd8t+1zAYiQZfxsGX8FlWlN2og Aw9ZKYmxs8o0lTOSokOlTIEzdDb1JDLysoIPN4hiVu1p43HEbLB2rBa0FD7AESrErhN/ rms1i9JOSaZ/H04wFh8w2YvU2vqD//W2QriFNnuQuFhp7PBW6cZg13cpIyDbGZH71dRo +obw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RwRoWd9A; 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; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc; bh=pMUsGilgOt2iydT/w49Tlmrul6d51jtQpenwmtBIEqs=; b=BpBRRYaisqjFSDWs1ajrXnh7cZr5ExSSaUEMvJexw0/bwTXZfuCGkNn7ikwy/dsuJR +PUsQyDIoqNHX/2nZQHR/cbL8uz36XNMbqsjtQNN2VmB0fWT/aTUFJCspGiJgnjhPZSU RW17MznXwuiB1J8XHntoZ51fzyv6S4km//XCE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=pMUsGilgOt2iydT/w49Tlmrul6d51jtQpenwmtBIEqs=; b=rdMCtBgX+VgT3ncj/A41WL1GsmtfmNMSK4nIit+6FsIfPlcltKfT3Hrn7owwz3VO2j KNDUxrqRC6bHjzpp4ywx5twLZ5efJSYDBPhSPXsnTbvumrUbHWOjPd0OrAQFoVqD51BA 6x0HJuzw2Z2vCDysIZ7o/iBfw1+AtIfE7ao4Tt5UbLYX9P0fuIhxLXeDfYPcBDoP3mWb vEJxUsIksrPluOKeVWwMRa0V25mqakM0l0ezb8rlDnM+6DnyCA99JwwZArIqubjPBWbG Io4OikYPRZEiS4/e+L9uiSIHnE+qnK91UuSI1xI4BoMWfycT8cZZgcFbtFJYLd1B1sN5 B+Og== X-Gm-Message-State: ACgBeo0CCgX6OVxeMBLobaTGMVJdbxs6D9pqGh7VrTuDeo1mTNCOuWWO e7eGqpw4pjp1LrY2Qyh0xlH1A5fF X-Google-Smtp-Source: AA6agR7pEskKW0ua2YlHDTWj79TCN32zN5kr04oWiFQtzTs4e4Lh1Gqt5PCYcZTQldxzOSyKebAc9g== X-Received: by 2002:a05:6402:538f:b0:444:c17b:1665 with SMTP id ew15-20020a056402538f00b00444c17b1665mr13451350edb.98.1661693618626; Sun, 28 Aug 2022 06:33:38 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:76ad:b0:73c:b61c:65e3 with SMTP id jw13-20020a17090776ad00b0073cb61c65e3ls3894554ejc.11.-pod-prod-gmail; Sun, 28 Aug 2022 06:33:37 -0700 (PDT) X-Received: by 2002:a17:906:da86:b0:740:7120:c6e6 with SMTP id xh6-20020a170906da8600b007407120c6e6mr6630615ejb.44.1661693617408; Sun, 28 Aug 2022 06:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661693617; cv=none; d=google.com; s=arc-20160816; b=CSkhEzFPW9JazHIch8w3AIby0M49eQjC9GGMlnkZd8ON//VZGNT9iPCUowBxlafCaJ BEbp8jw3MrpmsKlkSsOLVpO8BQn471gXwVnZT1HemCLctADxTpOcICbTV9lLU/gcv5h6 L9o7XwfhGyIpf1x2gVqZ9wIpa1tq5HLiD6RFjdhzekcrdH7xNKwkIBGcgG1W0Yj0YykD julr6PAbA67dwtrwwLiQiYoocED+dZNzxkHtkYFWhOUxS7MuUa4UqMI0DbBMv8s/8NYe x5kAtT01Cr80nadBBHKooMOKl1Wbqk5S7N8xmgRGAhy/ue7ZxH+cemvOe4mOnF3tA2gn pqDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=DNUvT1ZZ3fFrLVQIyi9us/iFYLs4Qz0Ypyc3D33P4jw=; b=VNAQX40Fl2IqTGqWjkL0CUtDY62v40tFNg7LGTWvLMqR/B6CV9SrqaSSSMj0FbSQnr KAhFS0Li26Ly/8EBiqaAgCtDfsHnLcbaAnKU0OxAiNCpKo0tqYSKkIh30ZSPPwfY7zxy QPur27y36XJgkIqU1aNLQBbmKN+WqXtbVMfyvEvkC5FNKYbjzydNKWkrAB+AEB9Ri3xx /QxN4XUS0p9cLYvMG8H3h6KHFgx7RSbpogfjXXT5QYGnOVXLHFLQ5IYYnej0boj2ibPY 4EUlnyh0tswSfiadNWmvOkoxhYFi3ppkK/FmUa+7n5bgpFekU9uD5oI6df85N25ax8bK 98Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=RwRoWd9A; 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-20020a1709064c4f00b0073d9592c35esor2417353ejw.30.2022.08.28.06.33.37 for (Google Transport Security); Sun, 28 Aug 2022 06:33: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:a17:907:6d24:b0:731:7720:bb9b with SMTP id sa36-20020a1709076d2400b007317720bb9bmr10836381ejc.717.1661693617054; Sun, 28 Aug 2022 06:33:37 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-79-31-31-9.retail.telecomitalia.it. [79.31.31.9]) by smtp.gmail.com with ESMTPSA id u26-20020a1709064ada00b007313a25e56esm3247669ejt.29.2022.08.28.06.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 06:33:36 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Marc Kleine-Budde , Alexandre Torgue , michael@amarulasolutions.com, Amarula patchwork , Vincent Mailhol , Krzysztof Kozlowski , Rob Herring , 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: [RFC PATCH v3 0/4] can: bxcan: add support for ST bxCAN controller Date: Sun, 28 Aug 2022 15:33:25 +0200 Message-Id: <20220828133329.793324-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 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=RwRoWd9A; 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: , The series adds support for the basic extended CAN controller (bxCAN) found in many low- to middle-end STM32 SoCs. The driver design (one core module and one driver module) was inspired by other ST drivers (e. g. drivers/iio/adc/stm32-adc.c, drivers/iio/adc/stm32-adc-core.c) where device instances share resources. The shared resources functions are implemented in the core module, the device driver in a separate module. The driver has been tested on the stm32f469i-discovery board with a kernel version 5.19.0-rc2 in loopback + silent mode: ip link set can0 type can bitrate 125000 loopback on listen-only on ip link set up can0 candump can0 -L & cansend can0 300#AC.AB.AD.AE.75.49.AD.D1 For uboot and kernel compilation, as well as for rootfs creation I used buildroot: make stm32f469_disco_sd_defconfig make but I had to patch can-utils and busybox as can-utils and iproute are not compiled for MMU-less microcotrollers. In the case of can-utils, replacing the calls to fork() with vfork(), I was able to compile the package with working candump and cansend applications, while in the case of iproute, I ran into more than one problem and finally I decided to extend busybox's ip link command for CAN-type devices. I'm still wondering if it was really necessary, but this way I was able to test the driver. 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. - Remove 'Dario Binacchi ' SOB. - Add "clocks" to can@0 node. - Remove 'Dario Binacchi ' SOB. - Remove a blank line. - 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: - 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. - Remove a blank line. - 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. Dario Binacchi (4): dt-bindings: net: can: add STM32 bxcan DT bindings ARM: dts: stm32: add CAN support on stm32f429 ARM: dts: stm32: add pin map for CAN controller on stm32f4 can: bxcan: add support for ST bxCAN controller .../bindings/net/can/st,stm32-bxcan.yaml | 142 +++ MAINTAINERS | 7 + arch/arm/boot/dts/stm32f4-pinctrl.dtsi | 30 + arch/arm/boot/dts/stm32f429.dtsi | 31 + drivers/net/can/Kconfig | 1 + drivers/net/can/Makefile | 1 + drivers/net/can/bxcan/Kconfig | 34 + drivers/net/can/bxcan/Makefile | 4 + drivers/net/can/bxcan/bxcan-core.c | 200 ++++ drivers/net/can/bxcan/bxcan-core.h | 31 + drivers/net/can/bxcan/bxcan-drv.c | 1045 +++++++++++++++++ 11 files changed, 1526 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/can/st,stm32-bxcan.yaml create mode 100644 drivers/net/can/bxcan/Kconfig create mode 100644 drivers/net/can/bxcan/Makefile create mode 100644 drivers/net/can/bxcan/bxcan-core.c create mode 100644 drivers/net/can/bxcan/bxcan-core.h create mode 100644 drivers/net/can/bxcan/bxcan-drv.c