From patchwork Sun Jun 2 23:24:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13683129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 426BBC27C44 for ; Sun, 2 Jun 2024 23:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:MIME-Version:Message-Id:Date: Subject:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=qYCS096PiGUFSxphCMuktdAcMwp7AFt3HVR+5jkJqLo=; b=KOZqyIqgQnQlrK B5/Lj8b0aKJg7T5a6wuvSfuRVr87XeRrhbX7D8wR44zeJhlGrOC09R47QDOfVwfUJwdn9Akvhc+T2 C2CAlzLhtFHEzcv4hRsOMDU/o29psoCtMZe083Qsl4h6mS/4EmzVJfslIoIUQ94nMrt3ZeKYSYT7I c6tEg3Y8bLH2zJrO4B51N6SaZrETnKr/eEQx+1NDEljA1iMHYhedUcReIltgItmUzj3iThvCgwBE7 DWrmvtKpHbtz7bCDRCIq0FvivWFoaT4wTzg6nBx79DOEc6rIldUrW8ZRtbcBdwHbnKrdA1WlsG7qN Qp8a3Ew4dKBPPaNBeEBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDuZU-0000000F65z-1PLJ; Sun, 02 Jun 2024 23:25:04 +0000 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDuZP-0000000F63B-2tZq for linux-arm-kernel@lists.infradead.org; Sun, 02 Jun 2024 23:25:01 +0000 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-52b7e693b8aso3091132e87.1 for ; Sun, 02 Jun 2024 16:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717370697; x=1717975497; darn=lists.infradead.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=9GW/P8HNtUj4gAsXICqtNm+UsqGq0aT7yVz6HhJrHSA=; b=C0Ni3Li2oUvEwkvxG/LDGd4TtyBSFoS0i0ixA+JoZFgoYmghMMHcjxShJ/kdcwrAM7 x6i6K+mlAcTEc3pxh5FNrw5S2n0BWw3oKQ4NX7eHR9YUz5v18spOS9Tcgq8dfN6g2mxt dJCs/uAM1l5Ojh8cNgMKE01Md4f72PggzNZy5OpfpBG2UV8zVMqtrE3xQRlIOx9mi2O5 2EBZd5yfw963DT4n1IQWaGTtcVG3x62JTMo3ckTpV1mrf9M29GHaiFTJFrk7LF+kzMCL 1PlnOi6ASkN4ShSCBDyt5Bq8v+YKDxLpM2QY+69TNxR8ydRn/dZHYDUW5ePCLl963a2l PGtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717370697; x=1717975497; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9GW/P8HNtUj4gAsXICqtNm+UsqGq0aT7yVz6HhJrHSA=; b=k3XMhWYw4ROJjhDpgcvEpGzEes2AwFea9eIhv5nuLb/cTa1OKPPCttKuEkV80q2vtc AHnknVtQ1+royBkhgNZ4aErOB6alhXkyb6b+BRMr0KHJdyLwnt7LD0GdUpYh/DN9hXA1 GwAmNqg+KjK2khguZf2+CveIRtY/wlnFBWR4v5HezRTw+Wyx+KTfACCQLfd+jbVb1CSB 0MlhPfhAlo/4YfhOaeVuO1LS5N1e/19jpqf1zuahcTNpORgYhcw7+BSZtNiF6BfDhDo9 6QGClEfbtS46EO6X8B/LikS0qgcseolavzuogt+nrx7zPFWpx4X8lT3QVU/pLPsJGX5Z I1KA== X-Forwarded-Encrypted: i=1; AJvYcCVzFdT6az291qNq3o+e5hZYvsUJWUVRboNX9AT9c0in1ethb/q8d/3iJMlaygQt1YNK+y+raumuJRq+D+fc6AMdLbt/+RBe2reM3VK4utRxEcjDZ+0= X-Gm-Message-State: AOJu0YyT5SHHSOVXCUsw+dWHpsxw1OMk+oEmYePPkRxBVPIYLACQkN9d KrcnVfjkiyofGBAlGYo1lYX5lw/7hvZOUwwYuBmbsXSGV1+jQSEDg2T4ueMNc6U= X-Google-Smtp-Source: AGHT+IFObhCSI9ATwzqYvUqFHXDu4y0kBGo1nJVdLLy4L1+PoQcx3K73d/nUhKyCvcqieX4Kw6RrLw== X-Received: by 2002:ac2:4889:0:b0:51f:8df0:fbf1 with SMTP id 2adb3069b0e04-52b7e350b53mr2917997e87.30.1717370696998; Sun, 02 Jun 2024 16:24:56 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b959008aasm392369e87.269.2024.06.02.16.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 16:24:56 -0700 (PDT) From: Dmitry Baryshkov Subject: [PATCH RFC 0/7] usb: typec: ucsi: rework glue driver interface Date: Mon, 03 Jun 2024 02:24:53 +0300 Message-Id: <20240603-ucsi-rework-interface-v1-0-99a6d544cec8@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAEX/XGYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDUyNT3dLk4kzdotTy/KJs3cy8ktSitMTkVF3TtDQjIzOTNLPE1GQloN6 CotS0zAqwudFKQW7OSrG1tQAdoJOsbAAAAA== To: Heikki Krogerus , Greg Kroah-Hartman , Maxime Coquelin , Alexandre Torgue Cc: Nikita Travkin , Neil Armstrong , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2404; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=gBMQdnHYBqt0Cz6vbwrln0vxA5FTa/0tj8FaEe/b0zs=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmXP9GP5gxL64nLA9ixHwOAFBfXBDUwb3IytFr9 MzqXPncK2KJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlz/RgAKCRCLPIo+Aiko 1QMtB/9Ey2KOkOoXQtrK3z40/JUfDsmj8HhHIM+2tx5HLtM3vh51/enSM0NG8/7joFYK3odgHCr Qog87gI4VxOkkiZ2uolgr+BS+iYg9qCg9l5KwpUqE3pDu3mYNHlId+ZWojI23jfAAffFI0VHuRQ jbehKAnAkH+8sY9knuzynaOHFpu4qwJO5dHUcEIrfEUP/rSaiL4z/1jJopD3q1uajUH1SBAOwLG OXf4RS3IsMDMVGMa0s0X+u3vuhy2itfvTF5Njhb47z4yvz4IAe8xFlq7k9d5y/G85oy70S6Clwp ozyuGd4VH5nNmhlUka6xJw3tBeUIsue8TLMONydFvPfh1hL9 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240602_162459_800934_F2B0ADB5 X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The interface between UCSI and the glue driver is very low-level. It allows reading the UCSI data from any offset (but in reality the UCSI driver reads only VERSION, CCI an MESSAGE_IN data). All event handling is to be done by the glue driver (which already resulted in several similar-but-slightly different implementations). It leaves no place to optimize the write-read-read sequence for the command execution (which might be beneficial for some of the drivers), etc. The patchseries attempts to restructure the UCSI glue driver interface in order to provide sensible operations instead of a low-level read / write calls. If this approach is found to be acceptable, I plan to further rework the command interface, moving reading CCI and MESSAGE_IN to the common control code, which should simplify driver's implementation and remove necessity to split quirks between sync_control and read_message_in e.g. as implemented in the ucsi_ccg.c. Note, the series was tested only on the ucsi_glink platforms. Further testing is appreciated. Depends: [1], [2] [1] https://lore.kernel.org/linux-usb/20240521151109.3078775-1-fabrice.gasnier@foss.st.com/ [2] https://lore.kernel.org/linux-usb/20240531104653.1303519-1-heikki.krogerus@linux.intel.com/ Signed-off-by: Dmitry Baryshkov --- Dmitry Baryshkov (7): usb: typec: ucsi: move ucsi_acknowledge() from ucsi_read_error() usb: typec: ucsi: simplify command sending API usb: typec: ucsi: split read operation usb: typec: ucsi: rework command execution functions usb: typec: ucsi: inline ucsi_read_message_in usb: typec: ucsi: extract common code for command handling usb: typec: ucsi: reorder operations in ucsi_run_command() drivers/usb/typec/ucsi/ucsi.c | 215 ++++++++++++++++++---------------- drivers/usb/typec/ucsi/ucsi.h | 26 ++-- drivers/usb/typec/ucsi/ucsi_acpi.c | 100 ++++++++-------- drivers/usb/typec/ucsi/ucsi_ccg.c | 103 +++++++--------- drivers/usb/typec/ucsi/ucsi_glink.c | 74 ++++-------- drivers/usb/typec/ucsi/ucsi_stm32g0.c | 79 +++++-------- 6 files changed, 277 insertions(+), 320 deletions(-) --- base-commit: 975aa2136eebb8c7c716ac2d24d9bfdb002f87fd change-id: 20240525-ucsi-rework-interface-5ff2264f6aec Best regards,