From patchwork Tue Jun 25 14:54:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13711299 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 615EAC3064D for ; Tue, 25 Jun 2024 14:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To: Content-Transfer-Encoding:Content-Type: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=NSweAIPoKXuI7H4LOqoZzWikrFkReHajx8tj+okt9I0=; b=W04Lb4MX52OIZU VbeI36F03jlQF0bMEs3stFu14DXfA6DLndn3aytsA+H5PlZ9XjhnO0mfNLstttIajWkHS5Nz3RV6G 4WUAjvppY4oWb7tU/ax0G2EmZCPCyrwwlPlpxelVUzduVt0f6RlPtC4m7UfttcjGnFa/vl/zfr2sD T4aT7JVE7XnmuXtMuh+4UxoU8tj2rjF+p/pj4BxPWRdNrwrAdOzzdTt9LKSMZY0D2ae+9aExTSmX9 9tyZEMQxj0IFmu8f2WEHUv5WuJ9tWRu9+B+utTerLuhTmWDayjhB3WCRHsGmZ+iTGXmGuvNvUemUZ sJsxGOvS3glPVnDISJdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM7ZD-00000003H1G-1SUT; Tue, 25 Jun 2024 14:54:43 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM7Z2-00000003GvP-2REg for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 14:54:35 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52caebc6137so5321617e87.0 for ; Tue, 25 Jun 2024 07:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719327269; x=1719932069; 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=NSweAIPoKXuI7H4LOqoZzWikrFkReHajx8tj+okt9I0=; b=i1ffagvTdu6+Q+gtOVDY6k0kT8FVuqvOOSaIWiqAGtfvFEjiQKOJSzukrdXI9JgtFn eI6GaSe7YVox/BH/OPGtkudwztodaEdxyCxjPSpQxS+h1xEUyArGYBR/G250kVkJkU7N 4rIR/Y1DqGI21TunePhdj2qM8G6GNTBb9wf9TP+/iW9fknT+pJSmI6/Sn5TnfYTNb5Hk 9XyDxzqmlGrFWYvpnwopzz0CCHsgwac4mi4PKCf+2xj4Nc+IrxTs4g6UjM4NcfP/elCN qqLNGV7LhnOhniDxzWLIYp1hlGamnlTT8vYuTRolpkwMF0pnjGNxKGAvYJ3mIwBqqJOA YRTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719327269; x=1719932069; 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=NSweAIPoKXuI7H4LOqoZzWikrFkReHajx8tj+okt9I0=; b=tFY5RT5Jfa1WaV892EXQC4jj7ozLRdgXrcGYas/Pk23pV3RMFyo9UNnI+kuK+/WOU3 CKY6x/jacWpZPcQ2gKCIaGDaSq3A2E9g9eV/LSR5Gn1ihaFC308McrtA0CXQzhDn7BO/ vLey0ZjA2nDedyUqnk5xnuKIj6sLsjnIL6BTTwAu8qqa5z/FfdGno/Ia+cZFSt1GkbfD Et1ObYH8ZmTi5l4rmyUU6F05E8c0iQYgZKZIJE+lRFg6pR9GBJ55XN6TYSlnr9WDzhcW n6za557PUM0fCW7/vUcx87yAKAu7jKg7BcmtRNwV9cmVBmBY2osDNgH7VikZcafSuQNZ 6pUw== X-Forwarded-Encrypted: i=1; AJvYcCVO9h1DsOTVOB+rpsjdWQWL80igbMTZF3m4W5MOj/W+3/2vxTm9rwOqlYPZf/WdljWYnJSAf17Cav1ojJ8+FdzAnUtUQA7SEblsXXNksSFYhaf2nus= X-Gm-Message-State: AOJu0YzVNDPu4lDNzk4CY1lnng0/BvbEGu6d/Sz49Dhkn7Ub2WHXZoPC cUjqNUBRpc/6HyRC1/dV8I38mreBsVdtTHkhMfYPFl7/2MJ5XAB9eAdjdfUszdE= X-Google-Smtp-Source: AGHT+IGeR7Mb8mzSff+xkx/yZpp3fQkqTztpSXyNBdXwUXBi7RBdm5R0F5OHiVIGXyAdCOnfrcQq1Q== X-Received: by 2002:a05:6512:281:b0:52c:e10b:cb36 with SMTP id 2adb3069b0e04-52ce183add6mr4527968e87.33.1719327269161; Tue, 25 Jun 2024 07:54:29 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd64328b7sm1251877e87.221.2024.06.25.07.54.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 07:54:28 -0700 (PDT) From: Dmitry Baryshkov Subject: [PATCH v3 0/7] usb: typec: ucsi: rework glue driver interface Date: Tue, 25 Jun 2024 17:54:25 +0300 Message-Id: <20240625-ucsi-rework-interface-v3-0-7a6c8e17be3a@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIACHaemYC/3XNQQ6CMBCF4auQrq0pBRrqynsYF7VMYaJpzRSrh nB3C250wfJ/yXwzsQiEENmhmBhBwojB56h2BbOD8T1w7HIzKWQtGtnwh43ICZ6Brhz9COSMBd4 4J6WqnTJgWb69Ezh8re7pnHvAOAZ6r29SuaxfUYlqQ0wlF1xro7qmri3Y9nhDbyjsA/VsIZP8Y WS5xcjMmEpr57S6uPafmef5A6rCgBcCAQAA 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=2942; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=zRKg6mWitu11c42NN2MnOy4OSiuaKeH1XVqNTKR3lj0=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmetojbLrVWL1KxL/3+AbHhHJv1YRcYzQQRHB/+ h1vtmKVpkeJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZnraIwAKCRCLPIo+Aiko 1RgDB/4gKJx8pOyKonR8hoAZs8N6uQfaS0m6ZS8C12DOGIsOmj8EhMwqGRG/WlU+e2o7/zwV5b7 JQVzIQ/4Z73v39NBv26Ayj6nvXRYxtcg825wgzqHUTON9txQ/3IKYyTNEudMPmRxI+licVGwe+9 ARjxOQTAEqZZepY5jQwusAlcE8pKIm+jKgw911/xi4Ary9atBJRvrU4pKt1rrtp3EhCmIrQAtJq 6ymbchcfeBhgIh0TUjk40TeY80bihzj8L2GROdqmK3b5TIsxTYifm8nANyFI/DuBe7DQ/ZghnIq f9iCqUcHT4ovuC4pPPFm/y/uvRbEExcisxCsGYnGWRA0xx8x 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-20240625_075432_706572_54E7C809 X-CRM114-Status: GOOD ( 12.57 ) 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/20240612124656.2305603-1-fabrice.gasnier@foss.st.com/ [2] https://lore.kernel.org/linux-usb/20240621-ucsi-yoga-ec-driver-v8-1-e03f3536b8c6@linaro.org/ Signed-off-by: Dmitry Baryshkov Tested-by: Heikki Krogerus Reviewed-by: Heikki Krogerus --- Changes in v3: - Rebased on top of the next to resolve conflicts with the merge LG Gram patch (Heikki) - Link to v2: https://lore.kernel.org/r/20240621-ucsi-rework-interface-v2-0-a399ff96bf88@linaro.org Changes in v2: - Dropped the RFC prefix - Rebased on top of the fixed STM32 patch - Included the pending Yoga C630 driver into the cleanup. - Link to v1: https://lore.kernel.org/r/20240603-ucsi-rework-interface-v1-0-99a6d544cec8@linaro.org --- 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 | 127 ++++++++++--------- drivers/usb/typec/ucsi/ucsi_ccg.c | 103 +++++++-------- drivers/usb/typec/ucsi/ucsi_glink.c | 74 ++++------- drivers/usb/typec/ucsi/ucsi_stm32g0.c | 79 ++++-------- drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 104 +++++---------- 7 files changed, 322 insertions(+), 406 deletions(-) --- base-commit: c0068dfdd1aaf0fa9d60367b0f392ce145ee27c3 change-id: 20240525-ucsi-rework-interface-5ff2264f6aec Best regards,