From patchwork Wed Apr 16 00:02:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 881681 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 1E96F2C9D for ; Wed, 16 Apr 2025 00:02:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761736; cv=none; b=BSfKgUIateUwY1J6NDNoQq4kABI19/IWbaBK7hK/zWqQVDf3oSTkt8o6BFB/utNSOppTuFg0x9QTM9bvHU7QDCjDc3ikaxSLqrvvBsIG0+4YhQZtwLabCWCnTk87MifgmSh8hfBCVB/hG1OaFEotONvz2QdCbD3X6KHAWBi/VQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761736; c=relaxed/simple; bh=9LdBVOezi3+S4+ZxOQ8+mmTVUoo6eXOCdNB3fmZA2G8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GtYmazsMQhG9YdzERFfDbYbyKryXYVRFogAJaE7h72XbNH5KRhxRmiwlNWzV2Zk58mSD6JW/cQI/PzhTvqQumFnEecYWWmiCrDhUuXl6NFvj7CpPuL5OwIemoJefcKVBbDrds0CPhUbxNx/gZeIvj96kvM6NkSSJHZQsOuzLCkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Lqr89/Fs; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Lqr89/Fs" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-225477548e1so60110305ad.0 for ; Tue, 15 Apr 2025 17:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1744761733; x=1745366533; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ETD26CH6iD+0uFy4hgKYmRwgyWbV2LZsUcS2ttgEWQs=; b=Lqr89/Fsvp9NHUE4Uw36V/1U0Goynt73cR0htAdOnjj4iRTVvqaQPzMsRPdMYBKeco gNmQlEKTvWHbfeGMdTDJLboFW9Cepkzzsm1GVlOCvH9n0s2W2MW2JwTP4c/Z3rL4AuaU izMc6BLTeMcGRBpO9dKBFugSD7Sg0oGA40no8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744761733; x=1745366533; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ETD26CH6iD+0uFy4hgKYmRwgyWbV2LZsUcS2ttgEWQs=; b=xJ8gYpmtZ7qwMJOcO000bTvnn53m6QTlhcGHd2KLu4IPRZfsGXdi+7FD466jc4vaiN 2LtkWRt3LfXiMRWLkrt0vv/g2jay8A5iatxyCK0MrP2dDHVXJ61dzo4hQX/qA2VzBupx FVriz5VOgXpEPlmpOk+yKSoL1a1yibau+cEpX6tC1tw4Yo2QOndGoazb9NJVAFziLzzS WY5IQIY6gs1EblfzLmelWKqW4tXkIdZCpkfytJx0mIBmV5AhNubVdNrmhmU6mwzp/2K1 uuAShh9s1noSg21xoftiiGoIMJoLXaG0HqLsJoxsl3KSw25ElE14WZzGaEPrm8VB6+KF Z7tA== X-Forwarded-Encrypted: i=1; AJvYcCVGJMgpNRddsWI3XB//Jr4Jpm6Bb+xpOuj8Q5PQlP00r2Dwf1SgSqAkxNLK5wZNzP9/6kzt45g29ebBj6oA@vger.kernel.org X-Gm-Message-State: AOJu0YzCdywIjMSjZXT+N2qyt94NACs8Vkggrf+r4Zm+Ge0fQEsLdcPi 3AOpEjqf6KsYpMy+r6YTuVfVLPXxXT5/Zxj8nWPXaKD9y7/npNvqkRFaVMG75A== X-Gm-Gg: ASbGncuM4Fv5sKM7zZkj+ZMUYUBwLRkLl+PHyOSWSFy7PW+aDW9+jPQaYel6qMDMkfm JaWb6ADJ8EJXGN/BwVu2q5AXtRv54L8Nu3RYKVuyE6pc3x15Sny6zbSNTOYjMkfkd+cQGqtr8QF iKpr8gQP/t4qPJmuw+mu40K2Xco7AOTPKcbU0I0Z+XwI2n72lpHEcgks9Wsr4r4yTiTyjjlphei IDjZdvo746mx+HrGw5Ety8ChNt2uO3UcuGe9UiK/p/Zc6yFYVSGlvSIUA7We34rgssIRX4Y9Cjj Qi525G4ZpgoWkRHiFUZbbhkpyTf7RJdhVOADshUFdu2dJpOtgpDNqBABdwqxYzl+fBo+1ZXdSPv MLQ== X-Google-Smtp-Source: AGHT+IGTNhPFIcDKlL3bF0SzfSJ7SIXjnXhh0YeuCFsofT603F8bPtE9D2lDaA650EUHL4OU3b5nnQ== X-Received: by 2002:a17:903:2a85:b0:220:e63c:5aff with SMTP id d9443c01a7336-22c31ae8e3emr14464865ad.47.1744761733360; Tue, 15 Apr 2025 17:02:13 -0700 (PDT) Received: from localhost (199.24.125.34.bc.googleusercontent.com. [34.125.24.199]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-22c33fc47e0sm1235925ad.167.2025.04.15.17.02.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 17:02:13 -0700 (PDT) From: Stephen Boyd To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Bjorn Andersson , Konrad Dybcio , devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Conor Dooley , Benson Leung , chrome-platform@lists.linux.dev, Pin-yen Lin , Abhishek Pandit-Subedi , =?utf-8?q?=C5=81ukasz?= =?utf-8?q?_Bartosik?= , Jameson Thies , Andrei Kuchynski Subject: [PATCH 1/7] platform/chrome: cros_ec_typec: No pending status means attention Date: Tue, 15 Apr 2025 17:02:01 -0700 Message-ID: <20250416000208.3568635-2-swboyd@chromium.org> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog In-Reply-To: <20250416000208.3568635-1-swboyd@chromium.org> References: <20250416000208.3568635-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If we aren't expecting a status update when cros_typec_displayport_status_update() is called then we're handling an attention message, like HPD high/low or IRQ. Call typec_altmode_attention() in this case so that HPD signaling works in the DP altmode driver. Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Abhishek Pandit-Subedi Cc: Łukasz Bartosik Cc: Jameson Thies Cc: Andrei Kuchynski Signed-off-by: Stephen Boyd --- drivers/platform/chrome/cros_typec_altmode.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/platform/chrome/cros_typec_altmode.c b/drivers/platform/chrome/cros_typec_altmode.c index 557340b53af0..c2d9c548b5e8 100644 --- a/drivers/platform/chrome/cros_typec_altmode.c +++ b/drivers/platform/chrome/cros_typec_altmode.c @@ -280,11 +280,8 @@ int cros_typec_displayport_status_update(struct typec_altmode *altmode, typec_altmode_get_drvdata(altmode); struct cros_typec_altmode_data *adata = &dp_data->adata; - if (!dp_data->pending_status_update) { - dev_dbg(&altmode->dev, - "Got DPStatus without a pending request\n"); - return 0; - } + if (!dp_data->pending_status_update) + return typec_altmode_attention(altmode, data->status); if (dp_data->configured && dp_data->data.conf != data->conf) dev_dbg(&altmode->dev, From patchwork Wed Apr 16 00:02:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 881945 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 D67FA38FA6 for ; Wed, 16 Apr 2025 00:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761739; cv=none; b=dE2xCBFmQ3mMUu3Jiw9xaiUoVyMpIuViCWGQ4ZyBKb/63mxWT/ahU+9etAiKBtu2dmLUO9S+2Ts+0BL6sp4zDvjJuS0jUfliJn+hmu4mlZzP3RQgZLThecq/HGeXZ38W8c0iY7VZKazL1dsuBn22jtyiF1h5MoERwouu1Reht/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761739; c=relaxed/simple; bh=X73kg4tdW06GAOX2zu95FNoOmd3sHwKiCictodfiuao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cbCVBjYCgVsSoAQLrPdet0LKjirQ7tRDBb4wnpLa0K2drf3TDea3CE6tknCcgPXCsjmbD0dUvVFwBS03mXtuuby/oEgWh++UHMGmTDXfwT8U1ywXp+Ww0tt2iAlpfl2wx5x+OSHh7DSWfl49p+Wnkef7FEz+kONaAqhhG/WM/dI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Iip1LbTe; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Iip1LbTe" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-736b34a71a1so7162205b3a.0 for ; Tue, 15 Apr 2025 17:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1744761735; x=1745366535; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ztpfrrq65RboKoVCNPKCaSBonp9V4OT02BBtVtoD/uU=; b=Iip1LbTelo/dFDgaCB7aH39IJa2T0r6QRpjefrchYJ2GLfppOm6HEMBe/MCpIQBe7t sgs7w01FbVfctXxeqzUhERu4j5c/EzQl2TTMIMQ0C0ddjZj/mtVZrO+ICFyDhPyDUWjT fNT1AxGGmQtyzC6AGcMUt87HtO004pxKLkcFw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744761735; x=1745366535; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ztpfrrq65RboKoVCNPKCaSBonp9V4OT02BBtVtoD/uU=; b=LjMzxvb44lg7NYPWqVPFwNDSzrywWc6IZUt8nxo+8o1J1la2HaNIElu8LD0jzJb/qK 3/Z68ROOxzahPZ2foqPDlD3xRx0pWAI/+Sp17xBbnqGGmws+Ou8BDy3sL+SKgRm/SclL FmhU3VyiAQTWpwix78xoj73xCWSGoo7sKDyHI9UfDPtGX2U5it+CED1GDNvBNcsuZL5b 14VQZkmpo4264B1CO32BlfC77mde1RF5grXRKatiiT4ZwkLsI9rXPftQEboHdnKLAgeb Otwpr0aAzR+tLJeCGqSG+x/L9vHjMyBMnVR24qCBnxVLqbI0LOE12AcwE62sen0U0f6p U2NQ== X-Forwarded-Encrypted: i=1; AJvYcCUofh1aRuOlH9YNxaWtUVO8XtCyP7E1d34ZuAObydrKWhnHktcJtGhOelMEp4AqvCu/3Fo6fBSsD4hl4K67@vger.kernel.org X-Gm-Message-State: AOJu0YyICxlnV8SLunyHIpC7UprjS8f86DZctSrcX1q00nTBrltsNIr/ +6EYxmFt0W9g/IOdYv9ij0nC62wOhQsq/WaYYyn0PY5LCItF9Xm4sT2eZfGFZQ== X-Gm-Gg: ASbGncuBetapjOSy15A1URDQ6z8Txt4+/MM9DI/fnNzgf90a1r4gkMyWZq5iQ1j6O83 o5qSsXxS7KyXh/y+iOusjmwuHsbfyk92P1vA2n6QiYz8qGA9m9GNhoBoPRoZgokt8KWHdjViLSa Xugh6UzjickPvLuY8UYQzUv3zHRjTi8fkEDF/nHbonu0wyGw6r4gI3TaYMMgJCHUlgJOf/L2ph/ 5YN1ah5p/RDVRY+fQT41axaG+Cd99kxTiRRwalfxZrN8YgV7ReiDkUdAteCJDdSr1hIz7Gvs43M AmT2KR0NJZoK2lpSJSLtDExD7RV1YvkSXcN768vNnhgmSHvWxCyAIZVVhhLwLgmxY1ZiCYM7Chl Vpg== X-Google-Smtp-Source: AGHT+IHkUQNhj55ArcxMsqdZ9goNzK1iX/oCF1gdLXwsnONXGZV+o45RA+2MeBctZXHEWSSuaXlJnA== X-Received: by 2002:a05:6a00:2e29:b0:736:48d1:57f7 with SMTP id d2e1a72fcca58-73c1f90d688mr1947843b3a.7.1744761735002; Tue, 15 Apr 2025 17:02:15 -0700 (PDT) Received: from localhost (199.24.125.34.bc.googleusercontent.com. [34.125.24.199]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-73bd21c3216sm9157830b3a.49.2025.04.15.17.02.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 17:02:14 -0700 (PDT) From: Stephen Boyd To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Bjorn Andersson , Konrad Dybcio , devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Conor Dooley , Benson Leung , chrome-platform@lists.linux.dev, Pin-yen Lin , Abhishek Pandit-Subedi , =?utf-8?q?=C5=81ukasz?= =?utf-8?q?_Bartosik?= , Jameson Thies , Andrei Kuchynski Subject: [PATCH 2/7] platform/chrome: cros_ec_typec: Allow DP configure to work Date: Tue, 15 Apr 2025 17:02:02 -0700 Message-ID: <20250416000208.3568635-3-swboyd@chromium.org> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog In-Reply-To: <20250416000208.3568635-1-swboyd@chromium.org> References: <20250416000208.3568635-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The DP altmode driver fails the configure stage because the status VDO that is spoofed in cros_typec_enable_dp() is missing a couple flags. Add them so that the configure succeeds. This has the nice side effect of properly reflecting the pin assignment and configuration of the DP altmode in sysfs. Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Abhishek Pandit-Subedi Cc: Łukasz Bartosik Cc: Jameson Thies Cc: Andrei Kuchynski Signed-off-by: Stephen Boyd --- drivers/platform/chrome/cros_ec_typec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 6ee182101bc9..2cbe29f08064 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -531,7 +531,7 @@ static int cros_typec_enable_dp(struct cros_typec_data *typec, } /* Status VDO. */ - dp_data.status = DP_STATUS_ENABLED; + dp_data.status = DP_STATUS_ENABLED | DP_STATUS_CON_UFP_D | DP_STATUS_PREFER_MULTI_FUNC; if (port->mux_flags & USB_PD_MUX_HPD_IRQ) dp_data.status |= DP_STATUS_IRQ_HPD; if (port->mux_flags & USB_PD_MUX_HPD_LVL) From patchwork Wed Apr 16 00:02:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 881944 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 7B12A18C02E for ; Wed, 16 Apr 2025 00:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761741; cv=none; b=EU4fKKR+iO9jUdNlgNSS21sCOKfBSJCohv6zo6oYBJKtD9ShV0Am37rVCeDd3yqqvUk6zxuVszYOXiKk6cQ5plfJ9nQWKJYc+KAn7SoPYlxF75HIF+fsfYEE73G5YtnAbPa4OJTv4ti41x+kWqPcqVj7C33bkrt5m3/OZJ20zCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761741; c=relaxed/simple; bh=GwnkAZU+uW9fAkCDWWme3oB1O6PxoBs+pYMPoHkdFMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VdkcApHlqiuPQ0NnQZpGmubM5OtkWLrWjEGjflLc1mpxRCdREM6h4N+Ey2lN7fdEIzgvNvU2++eWOemTj85ch/ekoW+3+DuHVDAbGw3uO20GjC1BDGIw4lkQ5lY+ngg5wskbfzO8HJj1LYrxh9PL5/eUbqM4pfpYziuE2jpfi40= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=jDxg0ZmW; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jDxg0ZmW" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2254e0b4b79so84045105ad.2 for ; Tue, 15 Apr 2025 17:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1744761737; x=1745366537; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pLpTjFW7p6ghiYRblP02dy0kbs1t/nRG9KfdA64BMng=; b=jDxg0ZmWXkY7/crCU4dh2s0ImdvGa3j7mKy8npK2BmZp6SxxErN+YJw5TL8PoSxTc6 9G5uulvzJU1bR9eFHsBjgU2rEnJAtHWJb+7b+QmwwZqZ0JTBhAlU/34sZDLC6DnJjlNo J3DrfSpyMsN9ZDzq2VZpjr4riVdV+FqZlWbLQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744761737; x=1745366537; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pLpTjFW7p6ghiYRblP02dy0kbs1t/nRG9KfdA64BMng=; b=HrjGdH0kv7yKZ6V+K7S25cq6+sQ+VeMaumpioTl8Z7R0ldajP5wpvKecmc2v5miZBP jNiJQT6y1qCkZ5O6glDZ2aU+EpSAivQXx8Mep8xiL4XDwdfrw9Bjo/3d+FYEEPcXkkiD kmVwLMIMZlZEb8cFDfeIiW+uACkC4eV7/Qxna0KIkmwe7m64E1Y5vbqSmeO3KGrHuxVi UKirxZJthI9MH++CT2vzg8PxYu+EyZPPB1I65/e9ATkwbk8EZOZG/VUhZy2nCFQWLY+e R+6JxF7krxGWFOcNvte1bsKyphtf9RyC93PjIGaHTcQ6nsLUGgooaED5J4+j9ZIaMCjP ptmw== X-Forwarded-Encrypted: i=1; AJvYcCWdXgHkQDD6ttkoTto3jkDTHaPqgXSiOEeJ61v4kHMB35hJTOjYaiwqUt1l97olHM8QVirsZiss8ZXfrsrJ@vger.kernel.org X-Gm-Message-State: AOJu0YxRbOQqdOjx1+L4UQeuoLwJrVmX7sOWYU16x23QES6cpxgXHKhB WRYEKAk8VO+a0ZGnyzVYd8QWVbb61/3hxpqS58AI2hVMtmXVCSoxyaTpAhtMwQ== X-Gm-Gg: ASbGncu/+0CO4+gYZ7XnYTjnkwxOZTGeSQ9RQG8KMC+olYyjqo5NeoKmqBpA8WQfGh8 cKHKLKfu7HV8NDoLGITaz899vjR2DpyfQZAGVXdHOQPleT7OwvlkQBr6NjWLE4jjXipdHEcTKlm SnfP00yRG1etZ5PDDozz/HIHym2/RP9jNxC6XnGNQcat8/N39HZpBOrOiSLOucuJL99DfQXWlFr 7Mnh2DQwOjez6LsyX5JxXPc2bMc3XgnFYrNUGKNfDw79o+5EPYJZImb/vzVT4TIhL2iTlkL+556 RIjYN5x3LIUauDwyEp68n3DPkPs1Y69u4mHnRfzLOgILozD955WqN6FC0fERbg+4jkIqqElYckR wxQ== X-Google-Smtp-Source: AGHT+IFgDSfSzHJQGblYKtBgX+uGjROsnXUma1oaTnVLcJEUU+QM71Xipmk/uC+evcJTJfTYjoWWzQ== X-Received: by 2002:a17:902:d585:b0:223:536d:f67b with SMTP id d9443c01a7336-22c31a86b22mr19203715ad.38.1744761736701; Tue, 15 Apr 2025 17:02:16 -0700 (PDT) Received: from localhost (199.24.125.34.bc.googleusercontent.com. [34.125.24.199]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-308613b3849sm196331a91.38.2025.04.15.17.02.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 17:02:16 -0700 (PDT) From: Stephen Boyd To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Bjorn Andersson , Konrad Dybcio , devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Conor Dooley , Benson Leung , chrome-platform@lists.linux.dev, Pin-yen Lin , Abhishek Pandit-Subedi , =?utf-8?q?=C5=81ukasz?= =?utf-8?q?_Bartosik?= , Jameson Thies , Andrei Kuchynski Subject: [PATCH 3/7] platform/chrome: cros_ec_typec: Support EC mode entry Date: Tue, 15 Apr 2025 17:02:03 -0700 Message-ID: <20250416000208.3568635-4-swboyd@chromium.org> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog In-Reply-To: <20250416000208.3568635-1-swboyd@chromium.org> References: <20250416000208.3568635-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Support ChromeOS EC firmwares that don't support AP mode entry. Check that the mode has been entered by querying the EC and reject mode entry attempts if the EC hasn't already entered the mode requested. This allows us to bind the DP altmode driver on devices that don't support AP mode entry, i.e. most ChromeOS devices where the EC controls mode entry. Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Abhishek Pandit-Subedi Cc: Łukasz Bartosik Cc: Jameson Thies Cc: Andrei Kuchynski Signed-off-by: Stephen Boyd --- drivers/platform/chrome/cros_typec_altmode.c | 112 +++++++++++++------ 1 file changed, 75 insertions(+), 37 deletions(-) diff --git a/drivers/platform/chrome/cros_typec_altmode.c b/drivers/platform/chrome/cros_typec_altmode.c index c2d9c548b5e8..97ca4cfabbc0 100644 --- a/drivers/platform/chrome/cros_typec_altmode.c +++ b/drivers/platform/chrome/cros_typec_altmode.c @@ -58,31 +58,50 @@ static void cros_typec_altmode_work(struct work_struct *work) static int cros_typec_altmode_enter(struct typec_altmode *alt, u32 *vdo) { struct cros_typec_altmode_data *adata = typec_altmode_get_drvdata(alt); - struct ec_params_typec_control req = { - .port = adata->port->port_num, - .command = TYPEC_CONTROL_COMMAND_ENTER_MODE, - }; + struct cros_ec_device *ec = adata->port->typec_data->ec; + unsigned int port = adata->port->port_num; int svdm_version; int ret; if (!adata->ap_mode_entry) { - dev_warn(&alt->dev, - "EC does not support AP driven mode entry\n"); - return -EOPNOTSUPP; + struct ec_response_usb_pd_mux_info resp; + struct ec_params_usb_pd_mux_info req = { + .port = port, + }; + uint8_t flags; + + if (adata->sid == USB_TYPEC_DP_SID) + flags = USB_PD_MUX_DP_ENABLED; + else if (adata->sid == USB_TYPEC_TBT_SID) + flags = USB_PD_MUX_TBT_COMPAT_ENABLED; + else + return -EOPNOTSUPP; + + ret = cros_ec_cmd(ec, 0, EC_CMD_USB_PD_MUX_INFO, + &req, sizeof(req), &resp, sizeof(resp)); + if (ret < 0) + return ret; + + if (!(resp.flags & flags)) + return -EINVAL; + } else { + struct ec_params_typec_control req = { + .port = port, + .command = TYPEC_CONTROL_COMMAND_ENTER_MODE, + }; + + if (adata->sid == USB_TYPEC_DP_SID) + req.mode_to_enter = CROS_EC_ALTMODE_DP; + else if (adata->sid == USB_TYPEC_TBT_SID) + req.mode_to_enter = CROS_EC_ALTMODE_TBT; + else + return -EOPNOTSUPP; + + ret = cros_ec_cmd(ec, 0, EC_CMD_TYPEC_CONTROL, &req, sizeof(req), NULL, 0); + if (ret < 0) + return ret; } - if (adata->sid == USB_TYPEC_DP_SID) - req.mode_to_enter = CROS_EC_ALTMODE_DP; - else if (adata->sid == USB_TYPEC_TBT_SID) - req.mode_to_enter = CROS_EC_ALTMODE_TBT; - else - return -EOPNOTSUPP; - - ret = cros_ec_cmd(adata->port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, - &req, sizeof(req), NULL, 0); - if (ret < 0) - return ret; - svdm_version = typec_altmode_get_svdm_version(alt); if (svdm_version < 0) return svdm_version; @@ -97,31 +116,52 @@ static int cros_typec_altmode_enter(struct typec_altmode *alt, u32 *vdo) schedule_work(&adata->work); mutex_unlock(&adata->lock); - return ret; + + return 0; } static int cros_typec_altmode_exit(struct typec_altmode *alt) { struct cros_typec_altmode_data *adata = typec_altmode_get_drvdata(alt); - struct ec_params_typec_control req = { - .port = adata->port->port_num, - .command = TYPEC_CONTROL_COMMAND_EXIT_MODES, - }; + struct cros_ec_device *ec = adata->port->typec_data->ec; + unsigned int port = adata->port->port_num; int svdm_version; int ret; if (!adata->ap_mode_entry) { - dev_warn(&alt->dev, - "EC does not support AP driven mode exit\n"); - return -EOPNOTSUPP; + struct ec_response_usb_pd_mux_info resp; + struct ec_params_usb_pd_mux_info req = { + .port = port, + }; + uint8_t flags; + + if (adata->sid == USB_TYPEC_DP_SID) + flags = USB_PD_MUX_DP_ENABLED; + else if (adata->sid == USB_TYPEC_TBT_SID) + flags = USB_PD_MUX_TBT_COMPAT_ENABLED; + else + return -EOPNOTSUPP; + + ret = cros_ec_cmd(ec, 0, EC_CMD_USB_PD_MUX_INFO, + &req, sizeof(req), &resp, sizeof(resp)); + if (ret < 0) + return ret; + + if (resp.flags & flags) + return -EINVAL; + } else { + struct ec_params_typec_control req = { + .port = port, + .command = TYPEC_CONTROL_COMMAND_EXIT_MODES, + }; + + ret = cros_ec_cmd(adata->port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, + &req, sizeof(req), NULL, 0); + + if (ret < 0) + return ret; } - ret = cros_ec_cmd(adata->port->typec_data->ec, 0, EC_CMD_TYPEC_CONTROL, - &req, sizeof(req), NULL, 0); - - if (ret < 0) - return ret; - svdm_version = typec_altmode_get_svdm_version(alt); if (svdm_version < 0) return svdm_version; @@ -136,7 +176,8 @@ static int cros_typec_altmode_exit(struct typec_altmode *alt) schedule_work(&adata->work); mutex_unlock(&adata->lock); - return ret; + + return 0; } static int cros_typec_displayport_vdm(struct typec_altmode *alt, u32 header, @@ -254,9 +295,6 @@ static int cros_typec_altmode_vdm(struct typec_altmode *alt, u32 header, { struct cros_typec_altmode_data *adata = typec_altmode_get_drvdata(alt); - if (!adata->ap_mode_entry) - return -EOPNOTSUPP; - if (adata->sid == USB_TYPEC_DP_SID) return cros_typec_displayport_vdm(alt, header, data, count); From patchwork Wed Apr 16 00:02:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 881680 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 376FEC8CE for ; Wed, 16 Apr 2025 00:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761740; cv=none; b=r7xKGzmuiYfcjktDdiS6QA1GB1GBL0RfTF1wVMBQwqNxqstxV/ErY/k7nTa1nDAA4LsIA9oXRIC3KdtgAT6NTwdUbC2I68MN2G+IgVt5tD5l3QTa0SY92zGZt6VYZ1qZilrhIy1V2cJ7S9nFwGeaIHmKvz340bFb7u56Qy3JpcQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761740; c=relaxed/simple; bh=prSaVLEnAK+vncf8usI+ZxASfQG4nPOuCBOY+Y2RjLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cCD/A5l6R9y2ZPoUjutWJcyN84a/DTEv9JUx1EnqbI2bAJ7rIE/3ODOfzNwcWqtJ8gzMirEiKaiWdfpQHmAhh6XgEkWSrQRpmq3u6bu7INcQfosu0izxZ7xYK5fFRwQmBKboXbU0IbOg4A1p7svx/AOs+OvNltEvxikQk6/WnLs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=B/JuoPLD; arc=none smtp.client-ip=209.85.215.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="B/JuoPLD" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-af908bb32fdso149081a12.1 for ; Tue, 15 Apr 2025 17:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1744761738; x=1745366538; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KYGM0h7RhBS79sRo31i/Eh5uWT+nxNBuyvsqtZ/CclU=; b=B/JuoPLDOMx7rAfk9+hA3BlnShh+QrRj8Jpix+yacFS6f5rHYwLb4mpGY9SHSLBpFe X5xC7ha84pf5voc6G7LgxR63tczdVxUl6ik/htyp6LoBqHE5Z6u1qpM1cP6mI9D2A8Cc 1pLVGO8tcgkBsZOP0Jq+ZFAS3jipW6yHhURgU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744761738; x=1745366538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KYGM0h7RhBS79sRo31i/Eh5uWT+nxNBuyvsqtZ/CclU=; b=j2EdaMmgwRkcp1fYapztNVEQWv76CgkQzNJvGecWRwa9BbCcGVBGq849PHLwUr7qpE q2LcXIdGhj82gYKFV+giWFsaywICzVF7Ir6OHfG4yK+eICP+8cI6v1s4+nT7/SzBkB4e A02QPOkgElr9mfBg6EIO17CECaT9VNhRZI4O6AqXVJ8605C5iWapb9YtpaFZKMFZO+ia rGN5Truyz+NF7wtgR2wf69+UONVRdEi64oEqXpixkk3yES3Pv6Z9c0WBjT0aSfpQkt3y Msbn1nVEecGwoSftoMpoVsAVaBzCgVJGkJ1L4sjgs9m+E/bZ6IQW8RrNEPoqPEHhlrqt Xd9Q== X-Forwarded-Encrypted: i=1; AJvYcCU0cV0wALUHZA+auQ1h8eG1gb7rDlBsGiD2NDxw2xeZ63yG5wJ03wZ488IYm4cR6yS06Wq4SEEIC3BBVwfv@vger.kernel.org X-Gm-Message-State: AOJu0Yyq0LayIDkRh6vj9gek2kIBobFogIDCHn03y2Jze75TXid6P2Ve aXpRTNotxLgQroisUJlqtQIpdpfIjpwar42gi9LW0FvhJCpmfpDjxkdLag9i0Q== X-Gm-Gg: ASbGnct6vABknE6y85qMeMwh/80iTuSiLrD2aEgD+c685wsSHqmQTeRBuYRuiMIi6+T WBknbkK6RWyQLtulaOYONHpyP+up0iLrot+z2dDenC33G2/sOWknzaSbCv7YA9lasxA1O7yHb27 1CjZR4CesFrZIYu6GHzQYxsgAOGeCZhQaBpfliMENuewclpeRw47E1vJlX8J+WHz0u4W6zVjL8I Z/Ukp9vLMXACsBvsbSPZSQKWbYXwPQ6+7sBMyHjXhDmygogM6JxfCNdCiHUeiV0YGOPDlikydFN cuJaJzI5TLzJE5D05G4sH5GweSLTZgH9WAikiUrv8QZSMqaX9+0dnDHsN3l/1i7SBaqC1MinDgg DCg== X-Google-Smtp-Source: AGHT+IEOM8kY/Swx09k+WNyJ/f38PKBMBA/O7hhf0bPsaN2iBD0xvwXHaD7iBXxxmNY494s22DK7cg== X-Received: by 2002:a17:90b:2e41:b0:2ee:9661:eafb with SMTP id 98e67ed59e1d1-3085dfaceecmr2050851a91.12.1744761738388; Tue, 15 Apr 2025 17:02:18 -0700 (PDT) Received: from localhost (199.24.125.34.bc.googleusercontent.com. [34.125.24.199]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-22c33fe4de0sm1234335ad.212.2025.04.15.17.02.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 17:02:17 -0700 (PDT) From: Stephen Boyd To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Bjorn Andersson , Konrad Dybcio , devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Conor Dooley , Krzysztof Kozlowski , Lee Jones , Benson Leung , Guenter Roeck , chrome-platform@lists.linux.dev, Pin-yen Lin , Abhishek Pandit-Subedi , =?utf-8?q?=C5=81ukasz?= =?utf-8?q?_Bartosik?= , Jameson Thies , Andrei Kuchynski , Krzysztof Kozlowski Subject: [PATCH 4/7] dt-bindings: Move google,cros-ec-typec binding to usb Date: Tue, 15 Apr 2025 17:02:04 -0700 Message-ID: <20250416000208.3568635-5-swboyd@chromium.org> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog In-Reply-To: <20250416000208.3568635-1-swboyd@chromium.org> References: <20250416000208.3568635-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This binding is about USB type-c control. Move the binding to the usb directory as it's a better home than chrome. Reviewed-by: Rob Herring (Arm) Cc: Krzysztof Kozlowski Cc: Conor Dooley Cc: Lee Jones Cc: Benson Leung Cc: Guenter Roeck Cc: Tzung-Bi Shih Cc: Cc: Cc: Pin-yen Lin Cc: Abhishek Pandit-Subedi Cc: Łukasz Bartosik Cc: Jameson Thies Cc: Andrei Kuchynski Suggested-by: Krzysztof Kozlowski Signed-off-by: Stephen Boyd Acked-by: Lee Jones --- .../devicetree/bindings/mfd/google,cros-ec.yaml | 2 +- .../{chrome => usb}/google,cros-ec-typec.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename Documentation/devicetree/bindings/{chrome => usb}/google,cros-ec-typec.yaml (72%) diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml index 50f457090066..ac89696fa649 100644 --- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml @@ -99,7 +99,7 @@ properties: gpio-controller: true typec: - $ref: /schemas/chrome/google,cros-ec-typec.yaml# + $ref: /schemas/usb/google,cros-ec-typec.yaml# ec-pwm: $ref: /schemas/pwm/google,cros-ec-pwm.yaml# diff --git a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml b/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml similarity index 72% rename from Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml rename to Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml index 9f9816fbecbc..3272d0e01f7e 100644 --- a/Documentation/devicetree/bindings/chrome/google,cros-ec-typec.yaml +++ b/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml @@ -1,20 +1,20 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/chrome/google,cros-ec-typec.yaml# +$id: http://devicetree.org/schemas/usb/google,cros-ec-typec.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Google Chrome OS EC(Embedded Controller) Type C port driver. +title: Google ChromeOS EC (Embedded Controller) USB Type-C Port Manager maintainers: - Benson Leung - Prashant Malani 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. + Chrome OS devices have an Embedded Controller (EC) which has access to + USB 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 with a compatible like "google,cros-ec-spi". properties: compatible: From patchwork Wed Apr 16 00:02:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 881679 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 EF2C01A23B0 for ; Wed, 16 Apr 2025 00:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761742; cv=none; b=vBmIPmFHXTXhOd9PysZHfcpuT1o+E8BuFHAjxxgp3gwYtcIGpxgr29Ti1JweSXywV8dIR34npeZyXkXm/LwVTnny93XAv3XQ8jq4l3G5UP/Po/t9UqHq0by5ajYeP1dCvthxzci0twHiyOlFjeJ7W8G09RUVDw65gD8+j8lUDbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761742; c=relaxed/simple; bh=tZfWDcOQ8bgRqRi+NW+GjNxPj8wZOgOCyGs7+vqornI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gSDbuKdkgqqC/jzue15A8AY4L5PS0ubu6/bufjekukXFBY7tloZOgUAoHcGQOMWgzCbLaS2yY25bUf8PbGbcDVnJrcEUyCe4vWjkOdwXrprOga1XymSzCRFZ9iif6lnwYyNxEzKqjBYmxX/BGyGvZV5kmuMX5k4pq+Bd1h3W3r0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=MXQrSpEf; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MXQrSpEf" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-225477548e1so60111115ad.0 for ; Tue, 15 Apr 2025 17:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1744761740; x=1745366540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Nrlq2rYfgBLmHuWsTGNtsJ7KxYne7Xpu0dSG8i28Zdk=; b=MXQrSpEfvIdcZKmISuhZn1wVVkt7lIHjTSlN6X8x7YCkBZIRnLHz6TCJHw0lWH8389 s0coEQcAP3BVIdBnV0h9hywdNi5LzcOBo0vRoP4xA5ZO2BKnTD5Mb6UF5HPLZVA9IuQV 1AVu+jK/f29jv3zqnHqGHuDIQljwA0oHG1XIk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744761740; x=1745366540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nrlq2rYfgBLmHuWsTGNtsJ7KxYne7Xpu0dSG8i28Zdk=; b=CHVVLpuHA6EDEaFSAeDGM27RSQOmDiQZD5XxkpxK2GBS37kqc4KJyQKbx3irLEOJQf q9afm7YMtSoG0rgNZFLLkzvoMtJywQU6tr0AQiNmgbpkobaBJrAsS8RTTyaMZfzYiCxQ TiCqu+rfivi63RoOA30T+AF4DFPvhJ6OZ8RBpA+Ry8AJaPaClbfT1lN4fjEQc3GQLr0Z 6E8dJfbaG/vR3zZRBvOIxXQCxpA27BglvpKhmtc5gpW1enXlYgPidw6tbTCLasI1hvJW eWw6GkhTS/md9mjN9r3r21H+aN/RqW3nVd6QN6/7emEe+XnNl5t23UXgTOMM/bV4lSuo jTaw== X-Forwarded-Encrypted: i=1; AJvYcCXx88SYVR2dNbpaI+6cx4FCOreG7JidS9dpCXKEzthWHgJjsLBi3LTHQt4QZA7TEWcEW+6qAU9XceRb/0KF@vger.kernel.org X-Gm-Message-State: AOJu0YxuzzDUS64yHc9NpgrSwSIOqh5AbzQqUT+EHKLQLDK4AxURaHfM 2rF3qCgAiRJ7VNH/QYRVaEDRfYMu0HXvxnooD2XytiUZUfzLAy/Hb8waSnGubA== X-Gm-Gg: ASbGncvWyrtBhtdOtoG5Hopyv0hzn8kMywib7dVvrjkwBdJ/R9UUfJ0f/a4GDurE9Ap QwvRWOOh3N2+vQvgjpOQZ3ijBm6u9J9MXZJPbk0YQybdFbgNs3S58jOFKOC9gownwwvleeGpvRL SuS7T0iVVHymB4+y0UKJbVyW5L2SgOB3rUMTP5h4MFkyL5AKL9L+7l6XW7u0J86T1rc5Udczkai asSfQfx4CrQoZ6kMeNV7LrG4oqQk5zYGcoB/covMOwkvSzkOY3TW0zYd3+Tjpq1CZpqSMEONTe1 e6+A4kSrExCUuaZyIJKfjpkaeaKPU48yGhPlBlK99h+s7WoR+V6fZFgGTX/UNKNu65e/mJSw4Pt iMAWW/9qX4LZh X-Google-Smtp-Source: AGHT+IF1TOXiHYmZ5Jg3EXQSDRIROqzmWiXyNsBmBpcbZ0pKroNPtY+R3VjCmcQUVeHmUyzQagE5Vg== X-Received: by 2002:a17:902:e545:b0:224:e33:8896 with SMTP id d9443c01a7336-22c31a0aca5mr15114425ad.11.1744761740162; Tue, 15 Apr 2025 17:02:20 -0700 (PDT) Received: from localhost (199.24.125.34.bc.googleusercontent.com. [34.125.24.199]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-22c33f1d392sm1327015ad.99.2025.04.15.17.02.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 17:02:19 -0700 (PDT) From: Stephen Boyd To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Bjorn Andersson , Konrad Dybcio , devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Conor Dooley , Krzysztof Kozlowski , Lee Jones , Benson Leung , Guenter Roeck , chrome-platform@lists.linux.dev, Pin-yen Lin , Abhishek Pandit-Subedi , =?utf-8?q?=C5=81ukasz?= =?utf-8?q?_Bartosik?= , Jameson Thies , Andrei Kuchynski Subject: [PATCH 5/7] dt-bindings: usb: google, cros-ec-typec: Add ports for DP altmode Date: Tue, 15 Apr 2025 17:02:05 -0700 Message-ID: <20250416000208.3568635-6-swboyd@chromium.org> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog In-Reply-To: <20250416000208.3568635-1-swboyd@chromium.org> References: <20250416000208.3568635-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a DT graph binding to google,cros-ec-typec so that it can combine DisplayPort (DP) and USB SuperSpeed (SS) data into a USB type-c endpoint that is connected to the usb-c-connector node's SS endpoint. Allow there to be multiple 'typec' nodes underneath the EC node so that one DT graph exists per DP bridge. The EC is actually controlling TCPCs and redrivers that combine the DP and USB signals together so this more accurately reflects the hardware design without introducing yet another DT node underneath the EC for USB type-c "stuff". If the type-c ports are being shared between a single DP controller then the ports need to know about each other and determine a policy to drive DP to one type-c port or the other. If the type-c ports each have their own dedicated DP controller then they're able to operate independently and enter/exit DP altmode independently as well. We can't connect the DP controller's endpoint to one usb-c-connector port@1 endpoint and the USB controller's endpoint to another usb-c-connector port@1 endpoint either because the DP muxing case would have DP connected to two usb-c-connector endpoints which the graph binding doesn't support. Therefore, one typec node is required per the capabilities of the type-c port(s) being managed. Add a port to the DisplayPort altmode as well, so that we can show the connection between the DP controller and the DP altmode. This lets us indicate which type-c ports the DP controller is wired to. For example, if DP was connected to ports 0 and 2, while port 1 was connected to another DP controller we wouldn't be able to implement that without having some other DT property to indicate which output ports are connected to the DP endpoint. Furthermore, this supports ChromeOS designs like Corsola where a DP controller/PHY is split with two lanes going to one connector and the other two lanes going to another connector. In this case, we wouldn't have the graph binding under the cros-ec-typec node, but we would have the graph binding in the DP altmode directly connected to the DP controller's two output endpoints. Cc: Rob Herring (Arm) Cc: Krzysztof Kozlowski Cc: Conor Dooley Acked-by: Lee Jones Cc: Benson Leung Cc: Guenter Roeck Cc: Tzung-Bi Shih Cc: Cc: Cc: Pin-yen Lin Cc: Abhishek Pandit-Subedi Cc: Łukasz Bartosik Cc: Jameson Thies Cc: Andrei Kuchynski Signed-off-by: Stephen Boyd --- .../bindings/connector/usb-connector.yaml | 6 + .../bindings/mfd/google,cros-ec.yaml | 7 +- .../bindings/usb/google,cros-ec-typec.yaml | 165 ++++++++++++++++++ 3 files changed, 175 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.yaml b/Documentation/devicetree/bindings/connector/usb-connector.yaml index 11e40d225b9f..e3d60997c03e 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.yaml +++ b/Documentation/devicetree/bindings/connector/usb-connector.yaml @@ -179,6 +179,12 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 description: VDO returned by Discover Modes USB PD command. + port: + $ref: /schemas/graph.yaml#/properties/port + description: OF graph bindings modeling a data bus to the + DisplayPort altmode from the DisplayPort controller. Used when + the altmode switch is part of the port manager. + port: $ref: /schemas/graph.yaml#/properties/port description: OF graph bindings modeling a data bus to the connector, e.g. diff --git a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml index ac89696fa649..63d506e88abb 100644 --- a/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml +++ b/Documentation/devicetree/bindings/mfd/google,cros-ec.yaml @@ -98,9 +98,6 @@ properties: gpio-controller: true - typec: - $ref: /schemas/usb/google,cros-ec-typec.yaml# - ec-pwm: $ref: /schemas/pwm/google,cros-ec-pwm.yaml# deprecated: true @@ -163,6 +160,10 @@ patternProperties: type: object $ref: /schemas/extcon/extcon-usbc-cros-ec.yaml# + "^typec(-[0-9])*$": + type: object + $ref: /schemas/usb/google,cros-ec-typec.yaml# + required: - compatible diff --git a/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml b/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml index 3272d0e01f7e..611345bbe884 100644 --- a/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml +++ b/Documentation/devicetree/bindings/usb/google,cros-ec-typec.yaml @@ -26,6 +26,55 @@ properties: '#size-cells': const: 0 + mux-gpios: + description: GPIOs indicating which way the DisplayPort mux is steered + minItems: 1 + maxItems: 3 + + no-hpd: + description: Indicates this device doesn't signal HPD for DisplayPort + type: boolean + + ports: + $ref: /schemas/graph.yaml#/properties/ports + + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: + Port for DisplayPort (DP) data + + properties: + endpoint@0: + $ref: /schemas/graph.yaml#/properties/endpoint + description: Input DP port + + patternProperties: + '^endpoint@[1-8]$': + $ref: /schemas/graph.yaml#/properties/endpoint + description: Output to the usb-c connector's DP altmode + + required: + - endpoint@0 + + anyOf: + - required: + - endpoint@1 + - required: + - endpoint@2 + - required: + - endpoint@3 + - required: + - endpoint@4 + - required: + - endpoint@5 + - required: + - endpoint@6 + - required: + - endpoint@7 + - required: + - endpoint@8 + patternProperties: '^connector@[0-9a-f]+$': $ref: /schemas/connector/usb-connector.yaml# @@ -35,10 +84,30 @@ patternProperties: required: - compatible +allOf: + - if: + required: + - no-hpd + then: + properties: + ports: + required: + - port@0 + - if: + required: + - mux-gpios + then: + properties: + ports: + required: + - port@0 + additionalProperties: false examples: - |+ + #include + spi { #address-cells = <1>; #size-cells = <0>; @@ -47,6 +116,8 @@ examples: compatible = "google,cros-ec-spi"; reg = <0>; interrupts = <35 0>; + #gpio-cells = <2>; + gpio-controller; typec { compatible = "google,cros-ec-typec"; @@ -54,12 +125,106 @@ examples: #address-cells = <1>; #size-cells = <0>; + mux-gpios = <&cros_ec 42 GPIO_ACTIVE_HIGH>, <&cros_ec 3 GPIO_ACTIVE_HIGH>; + connector@0 { compatible = "usb-c-connector"; reg = <0>; power-role = "dual"; data-role = "dual"; try-power-role = "source"; + + altmodes { + displayport { + port { + usbc0_dp: endpoint { + remote-endpoint = <&dp_out0>; + }; + }; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + usb_c0_hs: endpoint { + remote-endpoint = <&usb_hub_dfp3_hs>; + }; + }; + + port@1 { + reg = <1>; + usb_c0_ss: endpoint { + remote-endpoint = <&usb_hub_dfp3_ss>; + }; + }; + }; + }; + + connector@1 { + compatible = "usb-c-connector"; + reg = <1>; + power-role = "dual"; + data-role = "dual"; + try-power-role = "source"; + + altmodes { + displayport { + port { + usbc1_dp: endpoint { + remote-endpoint = <&dp_out1>; + }; + }; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + usb_c1_hs: endpoint { + remote-endpoint = <&usb_hub_dfp2_hs>; + }; + }; + + port@1 { + reg = <1>; + usb_c1_ss: endpoint { + remote-endpoint = <&usb_hub_dfp2_ss>; + }; + }; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + #address-cells = <1>; + #size-cells = <0>; + + dp_in: endpoint@0 { + reg = <0>; + remote-endpoint = <&dp_phy>; + }; + + dp_out0: endpoint@1 { + reg = <1>; + remote-endpoint = <&usbc0_dp>; + }; + + dp_out1: endpoint@2 { + reg = <2>; + remote-endpoint = <&usbc1_dp>; + }; + }; }; }; }; From patchwork Wed Apr 16 00:02:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 881943 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 8EE5B1B6D06 for ; Wed, 16 Apr 2025 00:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761744; cv=none; b=FTUMhX/+vaESI55zEFVdOxa0FsE3S7DUE5H1yNw7/y0e8yDfbdUczIpM8mZQGMkdL/yms7qD0zIQWnAZtR+SRpKzACZCByAYdU1d5LPaF84YXaGIqjSSFEOPYGqIa3g0Q1chrQTeOfZaVgX8iPZYJX8qJ8tA2Cgr0i06id5vZ6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761744; c=relaxed/simple; bh=zOmVc3lsujHVGR9M+6Irw8HkDbw5tSV2x/aMh4olbVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p4Z83Y8s+VpqDBS7tpkDAwx+dVvBOcuyEPsK7GyP93yTPdfPt8HDWsFOF/wBU07X3GQzDSTpaWTA6ZZ3jT1KN+11Z7vjMAv5dicI/AQEi6u42rqfw60xcOS3NEd8tXcjCukjJmTR9o4/CbXzXVvSVaQGr6WWVEFKOfQ3wljT6K8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=HnKg+mkB; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HnKg+mkB" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-225477548e1so60111255ad.0 for ; Tue, 15 Apr 2025 17:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1744761742; x=1745366542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HHYpHK7kt8aJgnApA+GCQEa2iHMXOWfKlfQqVLhW5Rk=; b=HnKg+mkBbHrgIIyQFIbRnLvSVHEDaLRtzQQ0c1D9HTvhmM/YesNo4HqUnTZt5yIBgO AE9Na1KLyVyZ7gXvF/5gPubHHd/cktGbeGIzEL3D9hxMrhjLWg5Ffq2/nilux6/jhC/L romY3FzDK3qkNhqgG6zYBQ5+2GKvvoqhAucB0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744761742; x=1745366542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HHYpHK7kt8aJgnApA+GCQEa2iHMXOWfKlfQqVLhW5Rk=; b=fOgOSHPCqjz03vCTMEACG05Xg4MnPDbdbBycYNeSROPmv95Qs8qF7uXj+83j4QnhfX UyHlDVrcDcQoTWk62PPJyanrnLgJMRNPSOfeqDhoHo8UUnYRGZpd27ubjgD+9P5Lw9XY A3tG2NxU7kZjhDe7IUc9K5Eeg85Pzl2lFsmcOenD9K4/XpRnT1nDlCeITD4sRerIh8pT gYkd8KdmSLJrQfO/Yvvf0PpAcWxje7lALlPCQhAphbtRdvZQfjHNxcWRKN1PrEoslu2y noa7LEIl5Y+fLpuor3s4YOEZyYWnz67nS7qWgrywk9dHd4RJ8AZaznpb0MscMQqeHKTq bMjg== X-Forwarded-Encrypted: i=1; AJvYcCVXQjhsmDBIuYzErHPii3b3EHaP81fBFLyp44slCApncX1vnoeNz7ROydljeP+J9J0enLfq2CaPd+gdce64@vger.kernel.org X-Gm-Message-State: AOJu0YwL+zhSMcxvq2c7NtLVAzfve2vN7bssDrV4nifnvHp3jRSddb5i 5+79R2gz06PkXkAcskxIvI65nk35KaUZJhLEcL0cY1Hbd3QT6kH/8WCt2D+swQ== X-Gm-Gg: ASbGnctTy2PhpwczITvnQU9HUvO5J2Z5i4CEcWzmHmUT8rbu++hjnHvkRhMVyLS9sqV lG2dXdLoJ7KL6SRiL6EwszhxwLZumXf2+uPQC+RNjhobJA3+2nwc7v17vaGJ4JYUiP+9GT9RcY2 g2w0XwXMlbaD4Cau0uVlPphmS20LHxkXysAon8PT2eMXnKeiIKrrfcrDhB22ir6QfDyxNmoqIB2 hvhQPWRe+JaWMlYu7k0a4hoF3FRP5NImUDNdX41GoxEsNnTTfQeXy5hbAm3aSGtJEV/cw7qX5ba ih2c4crSyeTGwpIrFGK+kjz0+Ya7VjUKDPUfBIgqF0JFj51I7HmCkyT0hmC0Uvu1PsYxti6U+ex GJw== X-Google-Smtp-Source: AGHT+IEiQFpTS4vI0noyDuSs6VYTT9MkaGL0pVH3GJ7yVUmMdtuB7YMvp/PXxT4BTHtGtAfI5QsF6w== X-Received: by 2002:a17:902:a5c7:b0:223:5525:6239 with SMTP id d9443c01a7336-22c31ace733mr15386845ad.38.1744761741951; Tue, 15 Apr 2025 17:02:21 -0700 (PDT) Received: from localhost (199.24.125.34.bc.googleusercontent.com. [34.125.24.199]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-22c33f1d091sm1324475ad.61.2025.04.15.17.02.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 17:02:21 -0700 (PDT) From: Stephen Boyd To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Bjorn Andersson , Konrad Dybcio , devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Conor Dooley , Benson Leung , chrome-platform@lists.linux.dev, Pin-yen Lin , Abhishek Pandit-Subedi , =?utf-8?q?=C5=81ukasz?= =?utf-8?q?_Bartosik?= , Jameson Thies , Andrei Kuchynski Subject: [PATCH 6/7] platform/chrome: cros_ec_typec: Add support for DP altmode via drm_bridge Date: Tue, 15 Apr 2025 17:02:06 -0700 Message-ID: <20250416000208.3568635-7-swboyd@chromium.org> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog In-Reply-To: <20250416000208.3568635-1-swboyd@chromium.org> References: <20250416000208.3568635-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Trogdor platforms, the USB DP altmode is entered and exited by the EC depending on if DP altmode is possible and if HPD is asserted for a port. Trogdor has two USB-C connectors but the AP only supports one DP controller, so the first USB-C connector to assert HPD "wins". The DP controller on the AP is fixed to output two lanes DP that goes to an analog mux that steers the DP lanes to one of the two USB-C connectors. The HPD state in the DP altmode is "captured" by the EC and redriven from a GPIO on the EC to the AP's GPIO that is muxed to the DisplayPort controller inside the AP SoC. This allows both HPD high/low and HPD IRQ to be signaled from the EC as well as making DP altmode possible on either USB-C connector except at the same time. Add a drm_bridge to the ChromeOS EC driver to represent this analog mux on Trogdor and teach the kernel that DP altmode is using this DP controller on the AP. When the DT node has a graph binding, we assume that we're muxing DP to one of many USB-C connectors and we terminate the bridge chain here. In almost all cases we want this bridge to be the one that signals HPD because the EC is the one managing HPD and redriving the GPIO, except for in the case that the DP altmode driver is enabled in which case HPD will be signaled with drm_bridge_connector_oob_hotplug_event(). Unfortunately Trogdor EC firmwares have a bug where HPD state isn't discoverable properly, so we skip signaling HPD in that case if the "no-hpd" property exists in the node. Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Abhishek Pandit-Subedi Cc: Łukasz Bartosik Cc: Jameson Thies Cc: Andrei Kuchynski Signed-off-by: Stephen Boyd --- drivers/platform/chrome/Kconfig | 1 + drivers/platform/chrome/cros_ec_typec.c | 50 +++++++++++++++++++++++++ drivers/platform/chrome/cros_ec_typec.h | 7 ++++ 3 files changed, 58 insertions(+) diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig index 1b2f2bd09662..0ed8637b8853 100644 --- a/drivers/platform/chrome/Kconfig +++ b/drivers/platform/chrome/Kconfig @@ -247,6 +247,7 @@ config CROS_EC_TYPEC depends on MFD_CROS_EC_DEV && TYPEC depends on CROS_USBPD_NOTIFY depends on USB_ROLE_SWITCH + depends on DRM_BRIDGE default MFD_CROS_EC_DEV select CROS_EC_TYPEC_ALTMODES if TYPEC_DP_ALTMODE select CROS_EC_TYPEC_ALTMODES if TYPEC_TBT_ALTMODE diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 2cbe29f08064..27324cf0c0c6 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -16,6 +17,8 @@ #include #include +#include + #include "cros_ec_typec.h" #include "cros_typec_vdm.h" #include "cros_typec_altmode.h" @@ -337,6 +340,9 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) u32 port_num = 0; nports = device_get_child_node_count(dev); + /* Don't count any 'ports' child node */ + if (of_graph_is_present(dev->of_node)) + nports--; if (nports == 0) { dev_err(dev, "No port entries found.\n"); return -ENODEV; @@ -350,6 +356,10 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) /* DT uses "reg" to specify port number. */ port_prop = dev->of_node ? "reg" : "port-number"; device_for_each_child_node(dev, fwnode) { + /* An OF graph isn't a connector */ + if (fwnode_name_eq(fwnode, "ports")) + continue; + if (fwnode_property_read_u32(fwnode, port_prop, &port_num)) { ret = -EINVAL; dev_err(dev, "No port-number for port, aborting.\n"); @@ -417,6 +427,42 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) return ret; } +static int cros_typec_dp_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + return flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR ? 0 : -EINVAL; +} + +static const struct drm_bridge_funcs cros_typec_dp_bridge_funcs = { + .attach = cros_typec_dp_bridge_attach, +}; + +static int cros_typec_init_dp_bridge(struct cros_typec_data *typec) +{ + struct device *dev = typec->dev; + struct cros_typec_dp_bridge *dp_bridge; + struct drm_bridge *bridge; + struct device_node *np = dev->of_node; + + /* Not capable of DP altmode switching. Ignore. */ + if (!of_graph_is_present(np)) + return 0; + + dp_bridge = devm_kzalloc(dev, sizeof(*dp_bridge), GFP_KERNEL); + if (!dp_bridge) + return -ENOMEM; + typec->dp_bridge = dp_bridge; + + bridge = &dp_bridge->bridge; + bridge->funcs = &cros_typec_dp_bridge_funcs; + bridge->of_node = np; + bridge->type = DRM_MODE_CONNECTOR_DisplayPort; + if (!device_property_read_bool(dev, "no-hpd")) + bridge->ops |= DRM_BRIDGE_OP_HPD; + + return devm_drm_bridge_add(dev, bridge); +} + static int cros_typec_usb_safe_state(struct cros_typec_port *port) { int ret; @@ -1276,6 +1322,10 @@ static int cros_typec_probe(struct platform_device *pdev) typec->num_ports = EC_USB_PD_MAX_PORTS; } + ret = cros_typec_init_dp_bridge(typec); + if (ret < 0) + return ret; + ret = cros_typec_init_ports(typec); if (ret < 0) return ret; diff --git a/drivers/platform/chrome/cros_ec_typec.h b/drivers/platform/chrome/cros_ec_typec.h index 9fd5342bb0ad..090f8f5c0492 100644 --- a/drivers/platform/chrome/cros_ec_typec.h +++ b/drivers/platform/chrome/cros_ec_typec.h @@ -14,6 +14,8 @@ #include #include +#include + /* Supported alt modes. */ enum { CROS_EC_ALTMODE_DP = 0, @@ -35,6 +37,7 @@ struct cros_typec_data { unsigned int pd_ctrl_ver; /* Array of ports, indexed by port number. */ struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS]; + struct cros_typec_dp_bridge *dp_bridge; struct notifier_block nb; struct work_struct port_work; bool typec_cmd_supported; @@ -83,4 +86,8 @@ struct cros_typec_port { struct cros_typec_data *typec_data; }; +struct cros_typec_dp_bridge { + struct drm_bridge bridge; +}; + #endif /* __CROS_EC_TYPEC__ */ From patchwork Wed Apr 16 00:02:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 881678 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 54F051E1DF2 for ; Wed, 16 Apr 2025 00:02:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761746; cv=none; b=erXODJXWU/Q/YNtlI+MdIh6fR1/Z63mE63zQsUSpnRhSK3QXSkIylaTwB2xzYYH8tW6FmhnW+V8loLe9zYpsnEkQ8Qyvf4sEPJLTHbvJC8cbXoLJZ9kAqRtZxfXakp+zraGC7TFzN4gOFXRyCtn8oNj8MRajspeMxYTLvWbnd6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744761746; c=relaxed/simple; bh=eDLBVrgnGdyoJQ79t80ww+yTdagNVGC7c/Zmd+hN+sM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=idqAgvpvMmXr8O8rXZXYFPVuNsJoSQKsCrs9cFZb51rKi5VeYtWzvtK9wwRJOjdlp/kdbhW5526QzkKqdqjCAieOvHJmBigTyVxjvo3QDzo6Wm3372IzhH95We6N4EPS9ryLIQrN/7yZuKj9QBmL3dijV6DuDdMxQ6LLdqkqSbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=hOFs+dE7; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hOFs+dE7" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-306b78ae2d1so5775432a91.3 for ; Tue, 15 Apr 2025 17:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1744761744; x=1745366544; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GPPbtqsuzK5NYYNdc0zpLwLBjiWgWtV76EEhJ0f/yC8=; b=hOFs+dE7qbldjczDg5jaBppniUhUyhdGxQk8sC5969Yoh2DXbfBTep+PUklVDEdcNn ivmv/uIAz69Dv+V749MmIVZECSRIve4vSvJ3sanF7hQabeWaZqEosPMZCjSXkh+mCJre MOULjY0ewSQ9/qCvNPQLuXe8tNoeUGBO1K+6U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744761744; x=1745366544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GPPbtqsuzK5NYYNdc0zpLwLBjiWgWtV76EEhJ0f/yC8=; b=fv87x3j4Vre5KmzPPDjEZdH0dMRkLrydxDd2iOF8bWtO50yz++IA1exfHTLa4WSmR+ kOPKUd06naGOdSTjSvz5VplOwCvpwPF/r8Y3klAcapRD9jPK4mysDjmC+tYlTRHN10Ar HZsxwnwCEjKVogoK98H6e8Qe3Q5q5hkvT3ay1xhgDdd8V00nxJldJv477sMsRb9mlvfw OTHdttPKnrBBNluj7Q2ntKNKAT8gsb/oE3ei4xE/Mf47hS6e27ZFmjhur+xWk70WBwl6 K9tYp4JdQ3qoizhkWT6dlL2QofG74lYX8CXNxb47ledhqSR6gu6xopiNmCZPsR/loEZ1 x30A== X-Forwarded-Encrypted: i=1; AJvYcCXRL5D3VH+dN+nXz2hX20Gj6t8DZkwfmX1Yl0OCyzKJvJelmNA0vsi3ljSjHYoFfDGckJTyYPWY6ZphB6oj@vger.kernel.org X-Gm-Message-State: AOJu0YyrQMJi29dESx7uq+AiEqSp7LNyF2Sigo+JXG9n5EDmHZpbDgjM khecNgRRL83j3dC0E5AIYkRkPYiWQW9Qt+u0XMGhAtrVdq2/enOos9hPy9bNEg== X-Gm-Gg: ASbGnctEXauxSJLl8Lv0MNSnBvx94r460CTKnyN1/AfvqnkgRFh6wkx2GmtMBnxQ6xF G0mwAIS0EgcFVQ2ZJnJvba+td5a4edoSMp+Fnwnn6AgMinRhX/zH62R9cckUSxQPuX7wTkMRbCT WOLi6Ph+1XZzwTHDP8iS8hfDvd5j0nTGwXpayfKvEsQVHEpnE/X6HFR1mKgCCuSUAnHP/qPJxaU a/k8Kf3pbzjLgQLgFYGmltIjYFKA59YRzLywkEtmt3XylZeCZd3xbwZTAg+On+KYjlWaGwEKVFI Nn6VrLbuLl3pVCfDOs5GNY9XSaFyERZNHC33ihHOAxV73xIpWWalkSb+tc/rh4DbuLYI2mZpGMH ABg== X-Google-Smtp-Source: AGHT+IErLrf4vSn8BQ0x8FQOElvg38uwkXskYXgtvXn9GTzRRW4rhFc/IJBl//1/RAJQqDgW15Gcyw== X-Received: by 2002:a17:90b:5108:b0:2ee:9b09:7d3d with SMTP id 98e67ed59e1d1-3085ef36625mr1741934a91.19.1744761743673; Tue, 15 Apr 2025 17:02:23 -0700 (PDT) Received: from localhost (199.24.125.34.bc.googleusercontent.com. [34.125.24.199]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-b0b22217eebsm117742a12.67.2025.04.15.17.02.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Apr 2025 17:02:23 -0700 (PDT) From: Stephen Boyd To: Tzung-Bi Shih Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Bjorn Andersson , Konrad Dybcio , devicetree@vger.kernel.org, Dmitry Baryshkov , Krzysztof Kozlowski , Rob Herring , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Conor Dooley , Benson Leung , chrome-platform@lists.linux.dev, Pin-yen Lin , Abhishek Pandit-Subedi , =?utf-8?q?=C5=81ukasz?= =?utf-8?q?_Bartosik?= , Jameson Thies , Andrei Kuchynski Subject: [PATCH 7/7] platform/chrome: cros_ec_typec: Support DP muxing Date: Tue, 15 Apr 2025 17:02:07 -0700 Message-ID: <20250416000208.3568635-8-swboyd@chromium.org> X-Mailer: git-send-email 2.49.0.604.gff1f9ca942-goog In-Reply-To: <20250416000208.3568635-1-swboyd@chromium.org> References: <20250416000208.3568635-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Most ARM based chromebooks with two usb-c-connector nodes and one DP controller are muxing the DP lanes between the two USB ports. This is done so that the type-c ports are at least equal in capability if not functionality. Either an analog mux is used to steer the DP signal to one or the other port, or a DP bridge chip has two lanes (e.g. DP ML0/ML1) wired to one type-c port while the other two (e.g. DP ML2/ML3) are wired to another type-c port. If a user connects a DP capable cable to both usb-c-connectors the EC likes to inform the AP that both ports have entered DP altmode, even though one of those ports can't actually display anything because the DP lanes aren't steered there. The answer to this problem is to look at the HPD bit in the EC messages. The port that isn't steered for DP won't ever see HPD be asserted, because the EC hides HPD state for the other port. This isn't a great solution though, because some EC firmwares don't even signal HPD state in the message at all. Oops! And it really does throw the whole type-c subsystem for a loop when the port has DP altmode present but it can't be entered properly. Let's fix these problems by doing two things. First, we'll only allow the port that's steered for DP to enter DP mode. Do that by checking the mux-gpios whenever we see that the EC tells us DP mode has been entered. If the mux isn't selecting this port, remove the flag from the message so that DP mode doesn't look to be entered. Second, inject HPD into the EC message when the EC has busted firmware. In this case, DT authors add 'no-hpd' to the typec node (essentially only on Trogdor). Listen for HPD events from the drm_bridge and read the mux when HPD is asserted to figure out which port actually had HPD asserted on it. When the port state is processed, check the bit against the port and if DP mode is entered, i.e. the mux is still steering toward that port, check if HPD is asserted on that port and inject HPD. This is necessary so that the typec framework can update the HPD state in sysfs, and eventually call drm_connector_oob_hotplug_event() from the DP altmode driver. Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Abhishek Pandit-Subedi Cc: Łukasz Bartosik Cc: Jameson Thies Cc: Andrei Kuchynski Signed-off-by: Stephen Boyd --- drivers/platform/chrome/cros_ec_typec.c | 115 +++++++++++++++++++ drivers/platform/chrome/cros_ec_typec.h | 14 +++ drivers/platform/chrome/cros_typec_altmode.c | 2 + 3 files changed, 131 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 27324cf0c0c6..10079129645d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -427,6 +428,41 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) return ret; } +static void cros_typec_dp_bridge_hpd_notify(struct drm_bridge *bridge, enum drm_connector_status status) +{ + struct cros_typec_dp_bridge *dp_bridge = bridge_to_cros_typec_dp_bridge(bridge); + struct cros_typec_data *typec = dp_bridge->typec_data; + struct gpio_desc *mux_gpio = dp_bridge->mux_gpio; + int val; + DECLARE_BITMAP(orig, EC_USB_PD_MAX_PORTS); + DECLARE_BITMAP(changed, EC_USB_PD_MAX_PORTS); + + if (!mux_gpio) + return; + + /* This bridge signals HPD so it must be able to detect HPD properly */ + if (dp_bridge->bridge.ops & DRM_BRIDGE_OP_HPD) + return; + + bitmap_copy(orig, dp_bridge->hpd_asserted, EC_USB_PD_MAX_PORTS); + bitmap_zero(changed, EC_USB_PD_MAX_PORTS); + + if (status == connector_status_connected) { + val = gpiod_get_value_cansleep(mux_gpio); + if (val < 0) { + dev_err(typec->dev, "Failed to read mux gpio\n"); + return; + } + __set_bit(val, changed); + } + + bitmap_copy(dp_bridge->hpd_asserted, changed, EC_USB_PD_MAX_PORTS); + + /* Refresh port state. */ + if (!bitmap_equal(orig, changed, EC_USB_PD_MAX_PORTS)) + schedule_work(&typec->port_work); +} + static int cros_typec_dp_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) { @@ -435,6 +471,7 @@ static int cros_typec_dp_bridge_attach(struct drm_bridge *bridge, static const struct drm_bridge_funcs cros_typec_dp_bridge_funcs = { .attach = cros_typec_dp_bridge_attach, + .hpd_notify = cros_typec_dp_bridge_hpd_notify, }; static int cros_typec_init_dp_bridge(struct cros_typec_data *typec) @@ -452,6 +489,11 @@ static int cros_typec_init_dp_bridge(struct cros_typec_data *typec) if (!dp_bridge) return -ENOMEM; typec->dp_bridge = dp_bridge; + dp_bridge->typec_data = typec; + + dp_bridge->mux_gpio = devm_gpiod_get_optional(dev, "mux", GPIOD_ASIS); + if (IS_ERR(dp_bridge->mux_gpio)) + return dev_err_probe(dev, PTR_ERR(dp_bridge->mux_gpio), "failed to get mux gpio\n"); bridge = &dp_bridge->bridge; bridge->funcs = &cros_typec_dp_bridge_funcs; @@ -662,6 +704,77 @@ static int cros_typec_enable_usb4(struct cros_typec_data *typec, return typec_mux_set(port->mux, &port->state); } +/* + * Some ECs like to tell AP that both ports have DP enabled when that's + * impossible because the EC is muxing DP to one or the other port. Check the + * mux on the EC in this case and ignore what the EC tells us about DP on the + * port that isn't actually muxed for DP. + */ +void cros_typec_check_dp(struct cros_typec_data *typec, + struct ec_response_usb_pd_mux_info *resp, + struct cros_typec_port *port) +{ + struct cros_typec_dp_bridge *dp_bridge = typec->dp_bridge; + struct gpio_desc *mux_gpio; + int val; + + /* Never registered a drm_bridge. Skip. */ + if (!dp_bridge) + return; + + /* Don't need to override DP enabled when DP isn't enabled. */ + if (!(resp->flags & USB_PD_MUX_DP_ENABLED)) + return; + + mux_gpio = dp_bridge->mux_gpio; + /* EC mux is required to determine which port actually has DP on it. */ + if (!mux_gpio) + return; + + val = gpiod_get_value_cansleep(mux_gpio); + if (val < 0) { + dev_err(typec->dev, "Failed to read mux gpio\n"); + return; + } + + /* Only the muxed port can have DP enabled. Ignore. */ + if (val != port->port_num) + resp->flags &= ~USB_PD_MUX_DP_ENABLED; +} + +/* + * Some ECs don't notify AP when HPD goes high or low because their firmware is + * broken. Capture the state of HPD in cros_typec_dp_bridge_hpd_notify() and + * inject the asserted state into the EC's response (deasserted is the + * default). + */ +static void cros_typec_inject_hpd(struct cros_typec_data *typec, + struct ec_response_usb_pd_mux_info *resp, + struct cros_typec_port *port) +{ + struct cros_typec_dp_bridge *dp_bridge = typec->dp_bridge; + + /* Never registered a drm_bridge. Skip. */ + if (!dp_bridge) + return; + + /* Don't need to inject HPD level when DP isn't enabled. */ + if (!(resp->flags & USB_PD_MUX_DP_ENABLED)) + return; + + /* This bridge signals HPD so it doesn't need to be reinjected */ + if (dp_bridge->bridge.ops & DRM_BRIDGE_OP_HPD) + return; + + /* + * The default setting is HPD deasserted. Ignore if nothing to inject. + */ + if (!test_bit(port->port_num, dp_bridge->hpd_asserted)) + return; + + resp->flags |= USB_PD_MUX_HPD_LVL; +} + static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, struct ec_response_usb_pd_control_v2 *pd_ctrl) { @@ -682,6 +795,8 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, port_num, ret); return ret; } + cros_typec_check_dp(typec, &resp, port); + cros_typec_inject_hpd(typec, &resp, port); /* No change needs to be made, let's exit early. */ if (port->mux_flags == resp.flags && port->role == pd_ctrl->role) diff --git a/drivers/platform/chrome/cros_ec_typec.h b/drivers/platform/chrome/cros_ec_typec.h index 090f8f5c0492..b4b331aa5dc7 100644 --- a/drivers/platform/chrome/cros_ec_typec.h +++ b/drivers/platform/chrome/cros_ec_typec.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,19 @@ struct cros_typec_port { struct cros_typec_dp_bridge { struct drm_bridge bridge; + struct cros_typec_data *typec_data; + struct gpio_desc *mux_gpio; + DECLARE_BITMAP(hpd_asserted, EC_USB_PD_MAX_PORTS); }; +static inline struct cros_typec_dp_bridge * +bridge_to_cros_typec_dp_bridge(struct drm_bridge *bridge) +{ + return container_of(bridge, struct cros_typec_dp_bridge, bridge); +} + +void cros_typec_check_dp(struct cros_typec_data *typec, + struct ec_response_usb_pd_mux_info *resp, + struct cros_typec_port *port); + #endif /* __CROS_EC_TYPEC__ */ diff --git a/drivers/platform/chrome/cros_typec_altmode.c b/drivers/platform/chrome/cros_typec_altmode.c index 97ca4cfabbc0..10d21da592f1 100644 --- a/drivers/platform/chrome/cros_typec_altmode.c +++ b/drivers/platform/chrome/cros_typec_altmode.c @@ -82,6 +82,7 @@ static int cros_typec_altmode_enter(struct typec_altmode *alt, u32 *vdo) if (ret < 0) return ret; + cros_typec_check_dp(adata->port->typec_data, &resp, adata->port); if (!(resp.flags & flags)) return -EINVAL; } else { @@ -147,6 +148,7 @@ static int cros_typec_altmode_exit(struct typec_altmode *alt) if (ret < 0) return ret; + cros_typec_check_dp(adata->port->typec_data, &resp, adata->port); if (resp.flags & flags) return -EINVAL; } else {