From patchwork Wed Mar 12 19:59:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jameson Thies X-Patchwork-Id: 14013813 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 148821EC011 for ; Wed, 12 Mar 2025 20:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741809616; cv=none; b=mrSb6cYUUJ/po34OlV8UTC7OTuVxxjrKDUQsOxUqnl0LiO3K3qFRUXUxUM3Jkvs8TTftd70qqQCKtHjD9Oj4wOyVOc2Vt1+dsjZvoOBeOgetz85GwwsXgQdc+bZhg+B0HDVwghfgt5a3JR2LQO+tM5wHNn99/Dl7i9wtWOO+Fic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741809616; c=relaxed/simple; bh=WvRKKyrxPM0AndWhf5s5lTyd+m2bVCqjFHn7YN0dKLs=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nqzeH/v2Da4t3rmV6FeEkFdV+tTFSA8Cg1jvebBhqqqNiZv/uXaAXOanCXAqIMvNNWP6J0ww6iVDjlxrNRoqUvPAsLEbAQvHTc4nh3hHNXrvJDsSohrzyeff8cZdN6lupKFfttx2UDhILzcU6HKEXJ5tdxXSDpVCzS7x9tgoGog= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YkpWyZ6d; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YkpWyZ6d" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3011cfa31f6so389705a91.3 for ; Wed, 12 Mar 2025 13:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741809614; x=1742414414; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=wfELBOAwKsIn4f/h6RBx4PQYztLIiCjc1rnfMpVEC8A=; b=YkpWyZ6d4sIAz8Q71MhhkEIMYhEsZbVa2vGdNjc+Lift/1YfQ0N+DKzRV4HUsJ1uO2 E8wLY56pRkrgJ6SVdPlikdW42MxWkg+3FLo+kw3vDaTNFLHmO/WYSfkSbQW2uCft+o8K 2J2AtEgVE4YqYLVGyP0a3UYutpF/iariCJxyyLPnS5qMhGFGJAT3iztE0JIxJqrUO4qB LYHwfImJPPArq2p0WjOEmUeEXi2NNL+pIXMMVKVV2KNd2n/ZDjVNVWMjtQL3Xfh05oox Ey6o659P2/ZGiTKMz44g0Le2Kjy+rJhJe7luRdi5g318FnqOfDj/rxA8GCP4yJytTfUl t0+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741809614; x=1742414414; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=wfELBOAwKsIn4f/h6RBx4PQYztLIiCjc1rnfMpVEC8A=; b=KshkXWtdUBivdbxd1jrbHqrlWHeFAtaQ+eNeb7wwwUwxqji4zUhapa3HJ/GC250Z9j rpyFBwzdXhFXHsksb9/bpqTE3pQrkZ7HyqjjGSsEsWV8LXjJHDYx4Gv4qI6eDGeXdtnL ZgsbKLM8BZ3d4Mn02smSOzLMbxRK5UiBHn4CcgwgIiumxAJjy+prpuZGrBEycbO8JN6C glgoaGNGaKWljFP3SVu8uSO8X5xiEUJ2xstVuoZGUtrwzdV2NNSAEs4OppcGM2TWe2Ri S4+oKIRpSc1OIlqupDYhAy+7oLh2I/DhavOy4qaQPzXm5CqHTs269BLYoKOrutLAVzvd btog== X-Forwarded-Encrypted: i=1; AJvYcCX7Kan5o5YeyNnUnpQbUj99JiKgtA/neCb8zmWCdh6jhGp9gWEqtzzMh5DjqriTEvF83pfPg2Et1Mk=@vger.kernel.org X-Gm-Message-State: AOJu0YyONVNwObV4LsU9MHHitjmu/QWE5OKPdAvBl/Ycus8TlNONo1vo 24ItKEmOcYFmFbwIcPG3lvdM1kbnypF0jIDgBSJ5CDpwWlsUn06FA0Emlqn+0EIcvEiZ7kxz9ui 7PA== X-Google-Smtp-Source: AGHT+IE+MbUq96ItG8DzcFSeVabSk7TgmT8HCVRXFsqek/lzPUV/vp4+cJRf1j5i4c+BNQLVVm3ovOJuqD0= X-Received: from pgbfm12.prod.google.com ([2002:a05:6a02:498c:b0:ad5:2dcc:552b]) (user=jthies job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:c79a:b0:1f5:8126:8a5d with SMTP id adf61e73a8af0-1f581268cd8mr18624416637.17.1741809614269; Wed, 12 Mar 2025 13:00:14 -0700 (PDT) Date: Wed, 12 Mar 2025 19:59:10 +0000 In-Reply-To: <20250312195951.1579682-1-jthies@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250312195951.1579682-1-jthies@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Message-ID: <20250312195951.1579682-2-jthies@google.com> Subject: [PATCH v1 1/3] dt-bindings: Add cros-ec-ucsi to cros-ec-typec device tree documentation From: Jameson Thies To: tzungbi@kernel.org, ukaszb@chromium.org, bleung@chromium.org, heikki.krogerus@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, groeck@chromium.org, swboyd@chromium.org, akuchynski@chromium.org Cc: devicetree@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Jameson Thies Add documentation for the cros-ec-ucsi device tree definition. Defining this node will load the cros_ec_ucsi driver which is used for USB-C port control on PDC based ChromeOS systems. Additionally, update mantainers list to reflect changes to the ChromeOS USB owners. Signed-off-by: Jameson Thies --- .../bindings/chrome/google,cros-ec-typec.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml b/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml index 9f9816fbecbc..ab39c5280681 100644 --- a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml +++ b/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml @@ -8,17 +8,24 @@ title: Google Chrome OS EC(Embedded Controller) Type C port driver. maintainers: - Benson Leung - - Prashant Malani + - Abhishek Pandit-Subedi + - Ɓukasz Bartosik + - Jameson Thies + - Andrei Kuchynski description: Chrome OS devices have an Embedded Controller(EC) which has access to Type C port state. This node is intended to allow the host to read and control the Type C ports. The node for this device should be under a - cros-ec node like google,cros-ec-spi. + cros-ec node like google,cros-ec-spi. On TCPC systems, ChromeOS should + use cros-ec-typec. On PDC systems, ChromeOS should use cros-ec-ucsi. properties: compatible: - const: google,cros-ec-typec + oneOf: + - items: + - const: google,cros-ec-typec + - const: google,cros-ec-ucsi '#address-cells': const: 1 From patchwork Wed Mar 12 19:59:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jameson Thies X-Patchwork-Id: 14013814 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2542F1EA7C8 for ; Wed, 12 Mar 2025 20:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741809620; cv=none; b=WnmUURpDw8ItYWw8nVIpSNza0+IbT/oQZMgHHk+FNgCeARMiMfonS1Err6Y4mrl1BURcMuJG2RK1yb/XApNQ8YB2J7HiIaPIVuFuU3q0WuJKT/FwxbPWY5PHRyrwdHYaUYJiqtRslJzFPnNrCTAd8KLjhhqP7vcURMSedPs+yKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741809620; c=relaxed/simple; bh=0GWy3rp0F7KpgF0wRntfFfUSkJ3mXo1eZ4Tv31fz+NU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XUUg019aICGJIa09Gb9j3MAFHXBt6+yUj+Esl5ez5dvMkLDisFbLMdCyAQn0B0hPGLI9xvesXaBlxu/8l/DGTnBhq0kblmhtH8i6jkjAeFDWHWPE8dZ5uoXAXvPQqC1LgrtdJphInA9jeVDN8ykuxyyzOTQLLjtriTaJf5++VC4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QAKra6lR; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QAKra6lR" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2242ce15cc3so3312575ad.1 for ; Wed, 12 Mar 2025 13:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741809617; x=1742414417; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=VDEU9Q/7+kilAtJ4k6780hVL8+VoEsG1QL4aEk8tmxQ=; b=QAKra6lRa8Yqut8W4HDU+3znz2V3GW9seMe5fmfLTOUxkqI3JxxKW2mkSGcF+WYrf9 B4NcXCaG0dhTABxWAVM/zB38q+lKSqs8nvfovINd5zsSb4c4LVRC/+2O9nW4EktJ8J15 7p5Q7v8aGdBF0dUgPr16j8cZDqW29CZpXCok6KxUS8cKyDGLy/jGJKgReWQehTEawHz9 FjXNvzkKn3lMiPhn9uZcp7BuIBUzAt9AbmPN41PvRAz/mEPpFEopBE+OjGA4p7Uh6nod 0k5M6x9dAtkxxc/Zaz9zKSOf+ThUTrYQRaym4nHuIToO7hBJbhKp/Z2swzKaQTu3Rfzk pc4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741809617; x=1742414417; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VDEU9Q/7+kilAtJ4k6780hVL8+VoEsG1QL4aEk8tmxQ=; b=RTTkUBu6CZRh0gvcaz5NVdHDEE1h8qPbA79SZaftSBiqh2LiOeO5Q6p/wgUysYVgeJ 3GXEnl/OA/UffYGfocmb7tFkL5WMwQKkdjsOz6065FkSSKgImU9aRvISUggVW3aW92QV Kf+2KJD/9/6vrwkl/axzLHHsLfV2K88F/6FsmM32iUhaNTVkE17tYuIpWwgVFstO3EyH l3g7b6xVskeOW0n9V5J6XbuS1zNQ0Y6TOtDbiURdzYRiiMf8FiARUDC2w6Plr1WV4GS7 ipoLwF9nVHOK3x0LAQChzsgApQi6EOXFu7MCXJm1068nOnNCutRdHZUanqnvFeFhbpa6 UDvg== X-Forwarded-Encrypted: i=1; AJvYcCXsZyuF66VlPKswyDk68crK4ztGSGFWEPqx9R+gzRl2moVoPhQ4WAbrU5jcFqqF44RwD2as8SYKJf4=@vger.kernel.org X-Gm-Message-State: AOJu0Yx00ISp8rUXdVxXKIUnmrJrovrCWlcT4QBzh+pP52z7qXvz1lR8 v9vFsi7KILLTYcKYWouPHXDbxkimOvHqqUxavuIOEE0Z3BsPAPb5dRfS56dJdfknz6iB4ArOXtX I1A== X-Google-Smtp-Source: AGHT+IG+7wN0jLCNhozwudp+CmZ2bIOC2JWCQMC5PPVbBuF1mi37k+/+m0ELnNvF8x64iohsHTAqLd5wRsg= X-Received: from plbjy16.prod.google.com ([2002:a17:903:42d0:b0:223:37b7:2388]) (user=jthies job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:234d:b0:220:c34c:5760 with SMTP id d9443c01a7336-22428c240demr280258275ad.51.1741809617329; Wed, 12 Mar 2025 13:00:17 -0700 (PDT) Date: Wed, 12 Mar 2025 19:59:11 +0000 In-Reply-To: <20250312195951.1579682-1-jthies@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250312195951.1579682-1-jthies@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Message-ID: <20250312195951.1579682-3-jthies@google.com> Subject: [PATCH v1 2/3] usb: typec: cros_ec_ucsi: Load driver from OF and ACPI definitions From: Jameson Thies To: tzungbi@kernel.org, ukaszb@chromium.org, bleung@chromium.org, heikki.krogerus@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, groeck@chromium.org, swboyd@chromium.org, akuchynski@chromium.org Cc: devicetree@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Jameson Thies Add support for cros_ec_ucsi to load based on "google,cros-ec-ucsi" compatible devices and "GOOG0021" ACPI nodes. Signed-off-by: Jameson Thies --- drivers/usb/typec/ucsi/cros_ec_ucsi.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/ucsi/cros_ec_ucsi.c b/drivers/usb/typec/ucsi/cros_ec_ucsi.c index c605c8616726..d916893b8908 100644 --- a/drivers/usb/typec/ucsi/cros_ec_ucsi.c +++ b/drivers/usb/typec/ucsi/cros_ec_ucsi.c @@ -5,11 +5,13 @@ * Copyright 2024 Google LLC. */ +#include #include #include #include #include #include +#include #include #include #include @@ -226,7 +228,6 @@ static void cros_ucsi_destroy(struct cros_ucsi_data *udata) static int cros_ucsi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct cros_ec_dev *ec_data = dev_get_drvdata(dev->parent); struct cros_ucsi_data *udata; int ret; @@ -236,7 +237,14 @@ static int cros_ucsi_probe(struct platform_device *pdev) udata->dev = dev; - udata->ec = ec_data->ec_dev; + if (is_acpi_device_node(dev->fwnode) || is_of_node(dev->fwnode)) { + udata->ec = dev_get_drvdata(pdev->dev.parent); + } else { + struct cros_ec_dev *ec_data = dev_get_drvdata(dev->parent); + + udata->ec = ec_data->ec_dev; + } + if (!udata->ec) return dev_err_probe(dev, -ENODEV, "couldn't find parent EC device\n"); @@ -317,10 +325,24 @@ static const struct platform_device_id cros_ucsi_id[] = { }; MODULE_DEVICE_TABLE(platform, cros_ucsi_id); +static const struct acpi_device_id cros_ec_ucsi_acpi_device_ids[] = { + { "GOOG0021", 0 }, + { } +}; +MODULE_DEVICE_TABLE(acpi, cros_ec_ucsi_acpi_device_ids); + +static const struct of_device_id cros_ucsi_of_match[] = { + { .compatible = "google,cros-ec-ucsi", }, + {} +}; +MODULE_DEVICE_TABLE(of, cros_ucsi_of_match); + static struct platform_driver cros_ucsi_driver = { .driver = { .name = KBUILD_MODNAME, .pm = &cros_ucsi_pm_ops, + .acpi_match_table = cros_ec_ucsi_acpi_device_ids, + .of_match_table = cros_ucsi_of_match, }, .id_table = cros_ucsi_id, .probe = cros_ucsi_probe, From patchwork Wed Mar 12 19:59:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jameson Thies X-Patchwork-Id: 14013815 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BED01EE7D3 for ; Wed, 12 Mar 2025 20:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741809621; cv=none; b=N3th9bVc4Rjvmm9caM9Rxcw/nZkFJCNUjlJYi1hgU4mhd5S/gQwbZ/fo/JPOrIkTNr+/i0/lxoHikTXw1t83SxOdLpXegfcaICI2dMYKcaENUKFqCiQAf6b+EUhWlMxdU80V5CgQ5iXHKY5gXoXaA2awItB+eJufjE7/o5N65CE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741809621; c=relaxed/simple; bh=05+7dVWuOECHdsMMg1bh5t6jzIqyq0QLMWPcZxTVIQY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=UtkMYZ5w6VTjVhsf5hcJP0IJOduDwzCXeNgK5IisL+xKz4ZT2xcxc5S7hZNLT5iH5yaAc0Z4MTZh3mWWUoYCkDdiBTgV5J79hTP4rlHhq1tZBenEXje7+yhJQdqf6fiXJzbAPxfO7XN2SjXL8Ia7/mBZ+FENEomBcvuY72K6lTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pDuNEo9d; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthies.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pDuNEo9d" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2242ade807fso5210815ad.2 for ; Wed, 12 Mar 2025 13:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1741809620; x=1742414420; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=L17RDKhWUu6oMmo9Xalv19pEsxNZy4ncT3jPzEM2UX4=; b=pDuNEo9dU1xeUwAGKpNJjX/5xH6mFHLzgXgg713KpOOW1EEa9PrKi0vgDGNFOGduVs S6udB/on88tOO/1sWiWKA4O3v+JmQyie1VI2SulepMrbG9n34zLxZiRDKwyMOqP/l+bV bnwUdhYXnEbdlT0bIytSyyGEm97s5NX5C25QxC9TsGxsjKHxADKtDAuZ7fMLmHFLVdIk DJvFs4s5nU2WfDfqaALucCjf7oYAj6H423UNvZ4oue1Uqesth5Q3Pwgcyw0tEstI7mOZ Vmjb48JoPrqKPQ5ffphXW0MWdI4+kjD7JbUCUmXJMdHbGnYLYdrMimC5XFYA04PYnVZy PH1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741809620; x=1742414420; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L17RDKhWUu6oMmo9Xalv19pEsxNZy4ncT3jPzEM2UX4=; b=m0J8iIVjqnfebxmOwftf+2EpFwvodH9UWXcq+6k1JnVWln3U9qHjfS8GntUtW+zIVT V90LkGPQiyWgMl5Q0u7PsavvBJEfbuFT9+Iib/H9yeSa0msER63Ku1dZX3CZASWFsp1v d+f8ZSuD1vUb5maXtpDD+voJVXGkL9h5+FFhyLyZhrgouToUs30TEBxL+AE4zXpx97yq G8y90G/XJI040l9UemGbmZg5n8mxvS9k2/HTfa3rSqK3aQKbi1no0KfOxFqvmPpifUXk dovgeEaD6mmmtphJC2mdMKN9LtC4UwxzFoswVhB1QxHaL+8/0ZAWOfrxLcUM4MQF0YG4 j6wQ== X-Forwarded-Encrypted: i=1; AJvYcCUKx64IuzzB9MIJvXPRUZy7XVXkwh2tMCWW4ZWfxDGnJEHL1hx/4uvsuIUGutk1iRdEv3PsxiEBvdY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3zMKmpxJ5/APzyqaV6hSQbQ1DJQ5E3FIuFSPqK6cODEy8ZYUF 8HTqYKnGB9ZoF+8o1xTcFgeYnxQuZR80sytx8l6dizTOKmKomF45L15L5Zv8MpgJ5cmXsXdlT3o kRA== X-Google-Smtp-Source: AGHT+IH4K/47qeRDt1YjBAXcU3FOe5IP5JjThNYGWQevxtIT/iQUAQ0NeIwRHC3jFWJ6xWJBzD8leYYbizE= X-Received: from plbmp13.prod.google.com ([2002:a17:902:fd0d:b0:21f:56e1:c515]) (user=jthies job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2405:b0:224:24d5:f20a with SMTP id d9443c01a7336-22428bfdba7mr411018645ad.48.1741809619744; Wed, 12 Mar 2025 13:00:19 -0700 (PDT) Date: Wed, 12 Mar 2025 19:59:12 +0000 In-Reply-To: <20250312195951.1579682-1-jthies@google.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250312195951.1579682-1-jthies@google.com> X-Mailer: git-send-email 2.49.0.rc0.332.g42c0ae87b1-goog Message-ID: <20250312195951.1579682-4-jthies@google.com> Subject: [PATCH v1 3/3] mfd: cros_ec: Don't add cros_ec_ucsi if it is defined in OF or ACPI From: Jameson Thies To: tzungbi@kernel.org, ukaszb@chromium.org, bleung@chromium.org, heikki.krogerus@linux.intel.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, groeck@chromium.org, swboyd@chromium.org, akuchynski@chromium.org Cc: devicetree@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Jameson Thies Check for cros_ec_ucsi to be defined in the OF device tree or an ACPI node. If it is defined by either OF or ACPI, it does not need to be added as a subdevice of cros_ec_dev. Signed-off-by: Jameson Thies --- drivers/mfd/cros_ec_dev.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 9f84a52b48d6..5fb6cd20c5ec 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c @@ -5,6 +5,7 @@ * Copyright (C) 2014 Google, Inc. */ +#include #include #include #include @@ -128,11 +129,6 @@ static const struct cros_feature_to_cells cros_subdevices[] = { .mfd_cells = cros_ec_rtc_cells, .num_cells = ARRAY_SIZE(cros_ec_rtc_cells), }, - { - .id = EC_FEATURE_UCSI_PPM, - .mfd_cells = cros_ec_ucsi_cells, - .num_cells = ARRAY_SIZE(cros_ec_ucsi_cells), - }, { .id = EC_FEATURE_HANG_DETECT, .mfd_cells = cros_ec_wdt_cells, @@ -169,6 +165,15 @@ static const struct mfd_cell cros_ec_vbc_cells[] = { { .name = "cros-ec-vbc", } }; + +static int ucsi_acpi_match(struct device *dev, void *data) +{ + struct acpi_device_id ucsi_acpi_device_ids[] = { + { "GOOG0021", 0 }, + }; + return !!acpi_match_device(ucsi_acpi_device_ids, dev); +} + static void cros_ec_class_release(struct device *dev) { kfree(to_cros_ec_dev(dev)); @@ -256,6 +261,30 @@ static int ec_device_probe(struct platform_device *pdev) } } + /* + * FW nodes can load cros_ec_ucsi, but early PDC devices did not define + * the required nodes. On PDC systems without FW nodes for cros_ec_ucsi, + * the driver should be added as an mfd subdevice. + */ + if (cros_ec_check_features(ec, EC_FEATURE_USB_PD) && + cros_ec_check_features(ec, EC_FEATURE_UCSI_PPM)) { + struct device *acpi_dev = device_find_child(ec->ec_dev->dev, + NULL, + ucsi_acpi_match); + + if (!!acpi_dev) { + put_device(acpi_dev); + } else if (!of_find_compatible_node(NULL, NULL, "google,cros-ec-ucsi")) { + retval = mfd_add_hotplug_devices(ec->dev, + cros_ec_ucsi_cells, + ARRAY_SIZE(cros_ec_ucsi_cells)); + if (retval) + dev_warn(ec->dev, + "failed to add cros_ec_ucsi: %d\n", + retval); + } + } + /* * UCSI provides power supply information so we don't need to separately * load the cros_usbpd_charger driver.