Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp2107107lqe; Tue, 9 Apr 2024 09:39:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHDF1nPZkgRwovTnYvoiASM4lU6ukEIArJB4NnTAJVy7HlmEh97tSnkKYBdej4HG/aLzXr3azlTGlxA+AdvxbY2Tov5HerFbh47rdCTw== X-Google-Smtp-Source: AGHT+IH3zpCV6TYaFkCwtD59nvKHp+Umgg/qQ+IzNCmGrQYhlWFIOJJ4Qi41lMTs57ezC4farDHV X-Received: by 2002:a05:6a21:3a47:b0:1a7:8828:bca0 with SMTP id zu7-20020a056a213a4700b001a78828bca0mr197857pzb.3.1712680791209; Tue, 09 Apr 2024 09:39:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712680791; cv=pass; d=google.com; s=arc-20160816; b=t7i6+kYDtXmkMm4d+iYFKxlkSBTlANCbAlLU97OWuNa7t6WFt9Vm1a8/1liiD7KW65 Ojr+JCWpDuKTD14Xti/uBBPooslyM2t/glSSDNdW4zJLyU43h2yKZigmzsiWBEXLbOED HNSTl8AFJZZ8P/OB7+1DybzYAItIhml8lS171ATo+oPWZn/eb8flRKpBjcTG+I2vxF6x siiuLfRNmXSlZ/O0sMEjwf/XPWOYzC3UIcdLscykykbCWrZYTHlinp7Q0vwkynoMfovS MM4JPC+B239l30oef9fUu0oTnLe0IFlLIR3kHJflX4MyDD+NJ+lbAwRjE6NWW+/tWuK+ zCnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:cc:to:from :dkim-signature; bh=I6gHj5ulVRplYdlxefeoXkzfjNeS/XzmKLr+AYiBZGc=; fh=+AIgUdv/iyy+8895CCDmgHbIgAfTsb0C4JqGDS+Qp50=; b=YrQLWzeRV0iWfC2whNAArXUTNxWsSZdb80N9blLtd8QtSLHf94fxN7Y4KQrBV7eRFm N8do+fhBZixCeiktIjKDV/V2ozls6hv4uqHr08sIwXQ7VDHVM1OThXyVCDYiwyl8cOMF BOlotf5qOVbj0CTo+DUv6ZQN0dxAj/xPqdvGq5HfwGAGHuUXScN2Rx75YYQggQoqfZKH zy7bSFucekETeE+v6HFX4Mm6OkRCI8axnDMSKfKrKNlYdzZ4YRYf/dWhueY16dm72Ugb yCGWJEjRKrhDhULNpE3jKxBpYSBqHuhzNFRS4NOX/gFuKhD6PM81kSortJILugvMH0/j +FLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=hGq+3KrY; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-137255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137255-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i25-20020a635859000000b005d8e401b4a2si8513329pgm.801.2024.04.09.09.39.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 09:39:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=hGq+3KrY; arc=pass (i=1 spf=pass spfdomain=hugovil.com dkim=pass dkdomain=hugovil.com); spf=pass (google.com: domain of linux-kernel+bounces-137255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137255-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 46247B28C57 for ; Tue, 9 Apr 2024 15:47:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C97613D531; Tue, 9 Apr 2024 15:46:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b="hGq+3KrY" Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B14D013667F; Tue, 9 Apr 2024 15:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.120.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712677587; cv=none; b=EPMaKpP0lav7qrXiT7GiVkO3Q6/1OVzUMmQGPfmUlKnqDgZOoBWJt9r9GJk0b4QXxHZsOMDlKsPQQ8yDLRYpXChaHDMYXzawB8irG+6nEs75kL4QlyacAIi+E6ROGSOdNYWSAtRSejRzzRUPogdCYTjria3Br5ER184NBNimR90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712677587; c=relaxed/simple; bh=xlXn1+20uTqx+W8MEQ4BJ+F8xH03zz0Ii3xHN9DpT3g=; h=From:To:Cc:Date:Message-Id:MIME-Version:Subject; b=eGmbu0wlsU+qYaC9Mk9/8pwQ0G2MwpXG87QTUyUCKkVm8AblDkjy7Iwu4pgNGOqNVgb3zP28WFRzpGTqz5XH+JGGOkrrnNIctXj1/CtSI63Np58Ww0r0nQfOE7Z8I4z+6QKoQ8CW5Wi830UIfIEjmSEDUPBL1o+bM1ajpV+9yOY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.b=hGq+3KrY; arc=none smtp.client-ip=162.243.120.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Cc:To :From:subject:date:message-id:reply-to; bh=I6gHj5ulVRplYdlxefeoXkzfjNeS/XzmKLr+AYiBZGc=; b=hGq+3KrYgOoqjpbO9/HK9WEvuY IJy5438s1SjyptudLQooRozl/aTnkR0MtnhnEscVjxP6hl/PCAx/sWy4iDZi1s/0L2rzowVdiAV6v RtX1Qu942UAbzKkXM6u/L/XNDUuSjjXTN9SJM58GqPQj3FwE2TrJ0HUemmtMlfdt/4Sk=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:44750 helo=pettiford.lan) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1ruDfp-0002NM-14; Tue, 09 Apr 2024 11:46:13 -0400 From: Hugo Villeneuve To: gregkh@linuxfoundation.org, jirislaby@kernel.org, peterz@infradead.org, mingo@kernel.org Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, hugo@hugovil.com, andy.shevchenko@gmail.com, Hugo Villeneuve Date: Tue, 9 Apr 2024 11:42:48 -0400 Message-Id: <20240409154253.3043822-1-hugo@hugovil.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP Subject: [PATCH v4 0/5] serial: sc16is7xx: split into core and I2C/SPI parts X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) From: Hugo Villeneuve Hello, this patch series splits the SPI/I2C parts for the sc16is7xx driver into separate source files (and separate I2C/SPI drivers). These changes are based on suggestions made by Andy Shevchenko following this discussion: Link: https://lore.kernel.org/all/CAHp75VebCZckUrNraYQj9k=Mrn2kbYs1Lx26f5-8rKJ3RXeh-w@mail.gmail.com/ The changes are split into multiple patches to facilitate the review process. In the end, some of them could be merged into a single patch. I have tested the changes on a custom board with two SC16IS752 DUART over a SPI interface using a Variscite IMX8MN NANO SOM. The four UARTs are configured in RS-485 mode. I did not test the changes on a real SC16is7xx using the I2C interface. But I slightly modified the driver to be able to simulate an I2C device using i2c-stub. I was then able to instantiate a virtual I2C device without disturbing existing connection/communication between real SPI devices on /dev/ttySC0 and /dev/ttySC2 (using a loopback cable). Thank you. Link: [v1] https://lore.kernel.org/lkml/20240206214208.2141067-1-hugo@hugovil.com [v2] https://lore.kernel.org/lkml/20240307161828.118495-1-hugo@hugovil.com [v3] https://lore.kernel.org/lkml/20240402174353.256627-1-hugo@hugovil.com Changes for V2: - Move port_registered[] init before the for loop to prevent bug if aborting probe when i = 0 - Since patch f7b487648986 ("lib/find: add atomic find_bit() primitives") has been dropped from linux-next/master, rework patch 2 (sc16is7xx_lines) without find_and_set_bit. Changes for V3: - Simplify sc16is7xx_lines allocation by using the IDA framework Changes for V4: Changes after Andy S. review comments: - Fix commit description - Fix includes for IWYU - Add Reviewed-by tag (Andy) for patches 1 and 5 - Add exported symbols to SERIAL_NXP_SC16IS7XX namespace - Fix Kconfig deps - Keep Kconfig SERIAL_SC16IS7XX_CORE - Convert to a single Kconfig entry and automatically selects I2C and SPI interfaces if available. - Merge patches 2 and 3 - Add NXP and UART keywords to Kconfig description - Remove __maybe_unused from of_device_id - Simplify I2C init/exit with module_i2c_driver() - Simplify SPI init/exit with module_spi_driver() Hugo Villeneuve (5): serial: sc16is7xx: add proper sched.h include for sched_set_fifo() serial: sc16is7xx: unconditionally clear line bit in sc16is7xx_remove() serial: sc16is7xx: split into core and I2C/SPI parts (core) serial: sc16is7xx: split into core and I2C/SPI parts (sc16is7xx_lines) serial: sc16is7xx: split into core and I2C/SPI parts (sc16is7xx_regcfg) drivers/tty/serial/Kconfig | 47 ++---- drivers/tty/serial/Makefile | 2 + drivers/tty/serial/sc16is7xx.c | 261 +++++++---------------------- drivers/tty/serial/sc16is7xx.h | 41 +++++ drivers/tty/serial/sc16is7xx_i2c.c | 67 ++++++++ drivers/tty/serial/sc16is7xx_spi.c | 90 ++++++++++ 6 files changed, 277 insertions(+), 231 deletions(-) create mode 100644 drivers/tty/serial/sc16is7xx.h create mode 100644 drivers/tty/serial/sc16is7xx_i2c.c create mode 100644 drivers/tty/serial/sc16is7xx_spi.c base-commit: fec50db7033ea478773b159e0e2efb135270e3b7 -- 2.39.2