From patchwork Thu Jun 27 14:44:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13714506 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 3504EC2BD09 for ; Thu, 27 Jun 2024 14:45:18 +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=OU3mOlwnB7yXdNX3pzXS01pB5G7EZpP4xG1jI/1t+1k=; b=UlmWqjhdvCIaKQ dsLxediA5DEJp2weDewLwmUMR5AMx0y87Ybj1td5uCBJkiQltHjQ4J6WBoHS6TiGZng7KI8jX3mMf 4rskQ9q6cBpxb9YIviTIYFsUyaQ4D9KCgL2kSQToncQKbIvpxc+PvKEsGETG2ltAvJ+wjCW73xl4L uJnZQh+zpOuSAMU0IinHgcGR8giENPgAUyfz7GKPLRyUafDHwpU3CAT4v7qnEGCn4dsGz0zujnJKr pGqvSAPAhCIt35UAxYp/Rqvpvdt0SDP3ifldhsNKNtgC0E6D9NeXKe6c4rVG9myhdqic7uXj4Xm0+ q7Yw7JBnc+A+L2Sx2HCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMqMx-0000000AgQT-1cFj; Thu, 27 Jun 2024 14:45:03 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMqMn-0000000AgLf-2qDA for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 14:44:55 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2ec408c6d94so90109331fa.3 for ; Thu, 27 Jun 2024 07:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719499483; x=1720104283; 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=OU3mOlwnB7yXdNX3pzXS01pB5G7EZpP4xG1jI/1t+1k=; b=s4YA1na8v9f6le1tsUrOB+FVUQZaxNIIuIF2qfsqa0dUkXDs4lu+/ZZtC3LZLwK8fi Y3MRiC1ZL5+7FwziHAhx8GdiBeVoruD436PyIrDcdr5ipJZrzOcztny9zEbYz2nBTzUa 5UWmUVoCQViZdSqaQQ6UfVk+TATNpFO8XZJbY3lShqiUYPm40NJY0g+SaCJ+rCm9jkSX rWsxV2d9OiebXiqibJFlIN+Ndl0bR3tQPa4RZseP6UOJZIunMUjvVr8v7pVvr9AQCxEV +W2CxAJXVurDkvj8/LXsbrnTb9xmpO66+VZYz8Jo9Wc3ZSgW15q20h8sX8AVwUXl1Ktg cG9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719499483; x=1720104283; 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=OU3mOlwnB7yXdNX3pzXS01pB5G7EZpP4xG1jI/1t+1k=; b=T6KYC9W2mUqJwQyl6pmDwsjlMHVeS72/qY8JTQ4saQYrjBwxsbTn6vmmU+dClJ41tE 1VfPJz+LRTJmKbsySWffP8YCpNMcnVRFoVvWjMr29/TQJUIQ0qyPLsr7jcC2zfZ/o8xY I1hBiD2Zt2FJufF59Yfz6MbvN4ePK2BKjOv+8wpvjhYt8BMA4qwRzrtimd2NkJvLj/8X scc/rdkeP59i8cGOFgcu465t59bIoNRzU7Y8Q4/+GIK3edFVYPuprEUbZJXrWpqpL1f7 buBLpxx+L/jrX7dhN5q7ykWhhngFPq/ThaVGskn+uktna1XhiwriffVsI1Dfl/ZgfRYy L9dA== X-Forwarded-Encrypted: i=1; AJvYcCU7SVLPgC+9kaVwwlMTLo56jY1kkZIZTttt+b14xVUU/ewAdxOoOQZQDj5nRplbtq6hrteqwjmUV/hWdzenHjag+gWR1AytlwJkJiaEYVJY70/jCus= X-Gm-Message-State: AOJu0Yx3F7x4K5gjLaIpoG+z3SpxmxesPhMKY8ct4ie3kFueja7YSx+Y 1TWAWsvcryZruft9dD4ccI775W/vqzfYAadNfa6Fv6pdY2rKgFYtDbRIZ55hpC0= X-Google-Smtp-Source: AGHT+IEawBNGQyhMDfZk05i3TKpcNT+YhEEzV5vSCXQFMuu8PQZieFyGjjzkLFDHqSWQ0x8moGwfKQ== X-Received: by 2002:a2e:b6ca:0:b0:2ec:4de9:733c with SMTP id 38308e7fff4ca-2ec59310257mr100015781fa.9.1719499482923; Thu, 27 Jun 2024 07:44:42 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ee4a34447fsm2775911fa.11.2024.06.27.07.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 07:44:42 -0700 (PDT) From: Dmitry Baryshkov Subject: [PATCH v4 0/7] usb: typec: ucsi: rework glue driver interface Date: Thu, 27 Jun 2024 17:44:39 +0300 Message-Id: <20240627-ucsi-rework-interface-v4-0-289ddc6874c7@linaro.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIANh6fWYC/3XPwQ7CIAyA4VcxnMVswHB48j2MB8bKbDTDFEWN2 bvL5mXG7Pg36df0zSIQQmS71ZsRJIwY+hxqvWLuZPsOOLa5mSiEKipR8buLyAkegc4c+xuQtw5 45b0QWnltwbG8eyXw+JzcwzH3CeMt0Gs6k8px+hV1IRfEVPKCG2N1WynlwNX7C/aWwiZQx0Yyi RkjyiVGZMZKY7w3uvH1PyPnzNJ/SWZma7Wrodw2IO0PMwzDB3y8vXxJAQAA 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=3115; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=bV6pMkV0+VB/9V9ogB8UlgFP7o3YnKPH33jLb5wU5ts=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmfXrYk+USNOvo5MKGxj+al1QwKFMYgN/fC0KdH AL11aqxH5SJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZn162AAKCRCLPIo+Aiko 1RDFB/9T7NQaaf13GsUbtwV5QVP8vJXFzfmwMieA4x3a3gV+YOuz/RPy7+T557w6o9XTQjAOdSj nRRJABvhYU7BCY9Jghy3/RAHQEZxiQJjIEAWSqJQwi6+4Qy4PJ9wZvAIO+k6Yp46wfSSJMrhhc0 roNYrd9usq58bxfFuh7a0oEd2FEMpmATUYt7SlkMN0FAAsUmYiTUZNiWLDLVfKboH9ap3oCVtHS OVfqGTw7bZYnnK2am/90mDSRq0mDc41LITRKiTjtTaFefr4wVJ5mYAoPSPQ3dxIQaTwQL3ROapQ TKRt8EcmMSdJCgPghifjuqlOC/SmXEfuVjjQY6DIZPeiI4rS 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-20240627_074453_784998_AD381835 X-CRM114-Status: GOOD ( 12.31 ) 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 v4: - Rebased on top of Greg's tree to resolve conflicts. - Link to v3: https://lore.kernel.org/r/20240625-ucsi-rework-interface-v3-0-7a6c8e17be3a@linaro.org 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 | 221 +++++++++++++++++--------------- 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, 325 insertions(+), 409 deletions(-) --- base-commit: 878bae2ba39bdd581cbe77d8210b9a03ae172adf change-id: 20240525-ucsi-rework-interface-5ff2264f6aec Best regards,