From patchwork Thu Jun 20 22:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13706463 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 98650C2BA18 for ; Thu, 20 Jun 2024 22:55:39 +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=J93Wdu3UHX/SH5BNBWL2XcVx8HcjEhvK9ORDAnvlEtw=; b=nSlDwMGZZOb7ZA ULNl4k17UZX1lNK45OjX48pvtvqn2tmI7m/SZxgMtsPbRZ2Fq2sNBnDygjQ35eHGBcZctGiPOPlzD CEvfdcsOPEBr2t2dIhHrAHE/2OTbflDub0AglwIYDmHJiLR37PZCTVcq+qWBTFRgnKE7uUwBhBG96 DzzhdZTifsAs0YaBm3iCg2VrlIKgUlmYuBi20Vqk6VoIdpDG7Uumc2AJGIfoGkF/00v4Id46pFJAh SF5ETWrNsU7lvHwOEzzgJ8EqieDwK+hCSTCJyF0c6Rs7rL3q+oFfHDUyochWcagzWqhBfiai+NhG3 OEjht5P9OdK/HRUemHlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKQgj-000000070ko-2Zhy; Thu, 20 Jun 2024 22:55:29 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKQgf-000000070h2-0xb8 for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 22:55:27 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ec3f875e68so16710691fa.0 for ; Thu, 20 Jun 2024 15:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718924123; x=1719528923; 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=J93Wdu3UHX/SH5BNBWL2XcVx8HcjEhvK9ORDAnvlEtw=; b=pHoODeyXgQGlYF3Kn4V4p3FZ5l4xA7piuA2ejYNIa4qIAZQbTiAyy+i+RlsuegnxMd +y716o2lJN0M+b7oe7AwSk2Rgaohkz//EfheXlNAl5lfrXL8zOonDItt20x2VY5fpgQd b/IpXjWYb70na/+Cj2elIiN0tXlveDPJ+YL3CC+hUDlTZKb5/TG+hjit37K0EkYnCzIP lGh+3K/Fx2+2ij+/wCPa6WW/o81StSJAs0E6qmicwhD78YAOF7xTrQIRNQFbCPQm2YE5 7DUxhxsw4KMDtRqLSRf0FZCeEGhghqB39iEfj/ByIJH6+nkLy2KW8QjteRqFczwL+mAA yNng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718924123; x=1719528923; 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=J93Wdu3UHX/SH5BNBWL2XcVx8HcjEhvK9ORDAnvlEtw=; b=L9tjX+eSIlQ6UIvDMXVufzYahMZ0ZvKAY6TIqvojVpW83TiqTAJNlW1KsxNYuEDyDM 6DngFZnHhVSgWy1n0sYJlJzfT34sH+04JydbgO7VxxmAArCFU4GIypBW6Doo0bGhsXDZ DtuPBxgSAYMbO0+ZeOFH9sLeAs15qDqZnyGcXvqIP9DI0RgHilco0k6kOwbb1o/x1bdY nQMzyn9q6RNBewKuGv//YmaE6Uc84gcmZAHzn4Lay+wZ3JX5UBRnMl4e4dX3FPpw4ui7 bt94Et256wVFimrtqjRjk1ejIKy+RlAErGrEWzstQppATn4g8ZWrAKij/c1UhUSYhBat Pqqw== X-Forwarded-Encrypted: i=1; AJvYcCUdeSq8IRpSRrRAKFUTkKCELPCbMFiCtInuNtfHeJ5lZjgNyONM92o4da6wM9bXic41xx047bkpbskHlMedFyspsrHg7EUlmUY1UVo3DKXeBO/X+CA= X-Gm-Message-State: AOJu0Yzj3lRu6BU2LknAXJIF/qxx0lDYFiZ9a03+IazE8o1lDcFlaX8a e8pvg8WR31rY1UlGrxTblph5Y9UCwY3OtaUuRi2u06pZ595gOiNpCE5suO1ImlM= X-Google-Smtp-Source: AGHT+IFQN2Bt5zqFFKMUGCJsgkrAaABWB+x6UZRmiYHHZjBZGwfUjSSQ4U5Pk9vdJM+yd1sxDvObTg== X-Received: by 2002:a2e:9d4d:0:b0:2ec:4d89:795e with SMTP id 38308e7fff4ca-2ec4d897aebmr1580681fa.17.1718924123126; Thu, 20 Jun 2024 15:55:23 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec4d60126fsm510461fa.20.2024.06.20.15.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 15:55:22 -0700 (PDT) From: Dmitry Baryshkov Subject: [PATCH v2 0/7] usb: typec: ucsi: rework glue driver interface Date: Fri, 21 Jun 2024 01:55:19 +0300 Message-Id: <20240621-ucsi-rework-interface-v2-0-a399ff96bf88@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAFezdGYC/3WNQQ7CIBBFr9LMWgxFINaV9zBdEDq0Ew2YoVZNw 93Funb5XvLfXyEjE2Y4NSswLpQpxQpq14CfXBxR0FAZlFRaGmXEw2cSjM/EV0FxRg7OozAhKGV 1sA491O2dMdBr6176yhPlOfF7u1nar/0VrTz8KS6tkKLrnB2M1h798Xyj6DjtE4/Ql1I+KdSRW 7sAAAA= 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=2727; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=NGDUIv34hYFZN854eluh2DVe78KwRqnWAHRvdoMY1uA=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ1rJ5sgVx7PFb4ZH8FW6nmSoUlXRFZdQykv9LNKyS2nzd In+nXqdjMYsDIxcDLJiiiw+BS1TYzYlh33YMbUeZhArE8gUBi5OAZiI/G72vyLrNm+y3WNfvX+J yH0Hv1Jm72qJtYxG+9z8b7P4zXMPCN1ifTS9V7vhWs05oSV7FT4pi5x8tSTLxNuFuWnGUc3P8X5 f+O53/Nm8K9v9yMdzEV1tsvsFxXeUnXgoeUxH9ayX95sdhnzfFngsf7Enl1+xa/HPWNOQY0+88m /ZdvVXPSxgXJnWvy3F19gsQGZjOJPO5+4bgoeaAzI/hGd6f79333f6o+rL8vb17QFiPfPj/RTSf 3u88Fp+70iRv+jX+b90uU8usWlWOfGPTUNv17t6VeuT0lufb+o3tfzpf/ljVdKCjhn7fTS5JSzW nM/6No37w5cTb1n6Snbw2U1+ZTrdcPEepakWcyW1ck3yAA== 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-20240620_155525_485106_83D84C02 X-CRM114-Status: GOOD ( 11.46 ) 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 --- 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 | 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 ++++-------- drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 104 +++++---------- 7 files changed, 309 insertions(+), 392 deletions(-) --- base-commit: f0dbf09a40c8100a895f675d619db5ed1f58f7ac change-id: 20240525-ucsi-rework-interface-5ff2264f6aec Best regards,