From patchwork Mon Nov 21 20:13:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 24009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1814206wrr; Mon, 21 Nov 2022 12:25:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf6JcnWqwtfyQEh1n3xA/IvzxO4mE0Lm6FrA/gUC6cNFhSzEXx0K3+NNl5oMPNsRiGCuM2cb X-Received: by 2002:aa7:9551:0:b0:56b:1fca:18b0 with SMTP id w17-20020aa79551000000b0056b1fca18b0mr9226307pfq.42.1669062299900; Mon, 21 Nov 2022 12:24:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669062299; cv=none; d=google.com; s=arc-20160816; b=kLQUznJ33FLm5simrjMFgcH7kuHttVOcVshMuuPmnzeV9S5dTicllmb4wGxVgS58Fe nBS+/CwTO6uOubrQVOWf5ko12b53DgGzyW2SYGRfmCSTB+iT8UnS7rUF6U5m7s9kiTXX /iUVrDRP19thsMwpTBiY+hLggDrrQTnpmvvtgpba3pu6qem2VAzRkYFajUs5HQRMdosD 7sBfCPSKQeTdRRxoeMI1ip69NO7oCgKrQRy/oZYXDrio/weIahWWkpCBuo3djS3CAFyw PzC053qkmc7yX5t07yklqxbn4/ZosaRziCEQxlHRksGyNEswLgaJdu9fwVjPJtl+nNJu ViXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Louc5ADJT348/nCzYaDBybvP94Rx6fwNzSnISAStWy0=; b=rw+yt3badB8StKlLMrLjbBQTGsGdR0+aLjRb2ccnvJU0ewFYJj0ip856PL6YfUsVSp La/2n/HB6J10iRzhwF1xXSxdbqcRtTREqTs7vnVbosi/BXoK2OHOVTs1JTHh2DHsce3c jfMqHTDQ1WRIZjCfDENZJUuWzHGJle9lTAHmdXCAjpEH16MMtLZM5Rp4UVbBq57PblmE GDkJuqH4a/+6AGQkHIA9OEkLnpjyfpA02ErYGUC6gGTn+nQKbMMgBJaLWb+8/s9wlg90 D1RuESjzSj8chlCAU0LBcu7fixj4kAGrvEVZsfYqzYx3CPiyTwKUlEKpx8EwmJSU3Zfp NleQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TGHF/B4C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a63c151000000b0046fb2a4b57csi11660269pgi.819.2022.11.21.12.24.44; Mon, 21 Nov 2022 12:24:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TGHF/B4C"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231858AbiKUUOA (ORCPT + 99 others); Mon, 21 Nov 2022 15:14:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231861AbiKUUN7 (ORCPT ); Mon, 21 Nov 2022 15:13:59 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80B1053EDB for ; Mon, 21 Nov 2022 12:13:57 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so12357514pjl.3 for ; Mon, 21 Nov 2022 12:13:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=Louc5ADJT348/nCzYaDBybvP94Rx6fwNzSnISAStWy0=; b=TGHF/B4CquhA/lZbHuol0RLDFg6PJB0gRf2Aun3KZ/xka1JqEdr0e61iQx2sOJ+ULu WJYlkRxiP50J7ZlY+iRtqu+ZjJ+FhQMnr4fq8/jeQ++Cwde9vs15gjihEdXE8D6wD9uD q9h7qRmg41GUQQ7THip2b3tHYH6V7rGLhgl+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Louc5ADJT348/nCzYaDBybvP94Rx6fwNzSnISAStWy0=; b=Q/44GS/MWt/o8ywk38XotfaKMNCf8S9W2OnI3EHknfG2tJZd9T+yb1Wx9U4TxHrCJc tsBHevdRVbmZotadiPhVbTRZLEPzhA/z1SYpm81LkkpOhI/j4g8YnrEsLJE5kbb6OHLz W0F7+HQ5t8ihr3tIbGxoHqf1uwa19RY88XbCYyOwarECr4r6wf1JQbxcUn0k29pjn0+R bKKPifrwhUZUCcNID4i+YgmTVgI4JlwLtPrkXxebmXMmdofpF84+P5UBzunOWHLY0uYA hz+drxFRLolKA0CXT1/UkqWnH9fLxA+jG44tKMJG1vQLA+a6dBkc5aTjfGuRX+ZMDndG wkCg== X-Gm-Message-State: ANoB5pljlznZKZEgP4Q4oQw50ycItMFRruoizZ1hvJSqA1mcGlPjKZIs 4LXNbAN9cZ/dMnn9WtBkFQZYLxNTPppKHg== X-Received: by 2002:a17:903:1311:b0:189:1e5:8422 with SMTP id iy17-20020a170903131100b0018901e58422mr461190plb.17.1669061636874; Mon, 21 Nov 2022 12:13:56 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id h8-20020a170902f70800b001822121c45asm10178507plo.28.2022.11.21.12.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 12:13:56 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Cc: Prashant Malani , Benson Leung , Heikki Krogerus , Greg Kroah-Hartman , Guenter Roeck Subject: [PATCH 1/2] usb: typec: Add helper to get partner device struct Date: Mon, 21 Nov 2022 20:13:35 +0000 Message-Id: <20221121201337.2772216-2-pmalani@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221121201337.2772216-1-pmalani@chromium.org> References: <20221121201337.2772216-1-pmalani@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750138670174255085?= X-GMAIL-MSGID: =?utf-8?q?1750138670174255085?= Some port drivers may want to set a Type-C partner as a parent for a USB Power Delivery object, but the Type-C partner struct isn't exposed outside of the Type-C class driver. Add a helper which returns a pointer to the Type-C partner's device struct, so that it can be supplied as the parent to the PD object. Cc: Benson Leung Cc: Heikki Krogerus Signed-off-by: Prashant Malani --- drivers/usb/typec/class.c | 13 +++++++++++++ include/linux/usb/typec.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index bd5e5dd70431..154c70630432 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -821,6 +821,19 @@ void typec_partner_set_svdm_version(struct typec_partner *partner, } EXPORT_SYMBOL_GPL(typec_partner_set_svdm_version); + +/** + * typec_partner_to_dev - Get the device struct of a USB Type-C partner. + * @partner: USB Type-C Partner + * + * Returns a pointer to the device struct or NULL. + */ +struct device *typec_partner_to_dev(struct typec_partner *partner) +{ + return partner ? &partner->dev : NULL; +} +EXPORT_SYMBOL_GPL(typec_partner_to_dev); + /** * typec_register_partner - Register a USB Type-C Partner * @port: The USB Type-C Port the partner is connected to diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 7751bedcae5d..085be3e94ff8 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -327,6 +327,8 @@ void typec_partner_set_svdm_version(struct typec_partner *partner, enum usb_pd_svdm_ver svdm_version); int typec_get_negotiated_svdm_version(struct typec_port *port); +struct device *typec_partner_to_dev(struct typec_partner *partner); + int typec_port_set_usb_power_delivery(struct typec_port *port, struct usb_power_delivery *pd); int typec_partner_set_usb_power_delivery(struct typec_partner *partner, struct usb_power_delivery *pd); From patchwork Mon Nov 21 20:13:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 24010 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1814800wrr; Mon, 21 Nov 2022 12:26:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf65Q6+1EiyV1MVIw4oINQX2houZguz6XQheNI7bVx6TMQlJ5wFRRaxyBYULT59hV2t97DXx X-Received: by 2002:a17:90a:5d0e:b0:202:c5cc:15bd with SMTP id s14-20020a17090a5d0e00b00202c5cc15bdmr28064226pji.235.1669062376659; Mon, 21 Nov 2022 12:26:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669062376; cv=none; d=google.com; s=arc-20160816; b=dn1Gp/f8botzRoUPznzHuXh/rWUBc6QcmoLTDHRCYjgZCBAina9oQCNjp9uh3UqkMk nJ31N9VInSYmxfKhzSdVWQJjkS8YvZOGn2bG5PV0kBublyvthZA45uL8uhVrdE6NW6gk pHPRD9kRbcg/nJLl+OTqLIty3CIOacCOiTVlzvkQ/FTw44Nq6mfxrYAheir8fuiXUrby 9vIbLuy6hZdzyE6uT55T6OCgGKsQayvIiBF/sEH5+tzFqYgkRKb9K0A/w4MiykU4FdZr 0R+kFijV219rConfHCQNzuvvmJgFxwX3qJQSp9V6PMlFpJsr0S/ze7bQjJ51pugzUkTe 7sEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+miEWjJAtnDGZKESGC2K13aQrBJTCpBeMrGNcOOuCUo=; b=SD2HxVddZTsLpBqCkQn4cbJOO09uUjYdvngbH2gaYyMOCw4048o5LT+r3Dj/OVeZ9l cZsgwB5sQ81Dy0ncmjep0DsFipeDXptOsaNgnjexi/96uGQ0R3aqWrnm4t44D9Iq5Q8V f0vzjId62wCdSH/pEqgLGUWQLRG+/AVEFOQCEmRstE3uEfmsiyFLzUdjZnZwhxXgLNDP V6kzWNGGR05KmIt+X8ShvzR/fpRKeKimyTF9M1ZT/5elLdftXoqhpSa0wwItKDvVvBXr gOVAZ441P2yG2PkNwff90iIGpGRGNEiUsdYK2QpiTEKIEqQsP5HL2lighb1grM30uBu0 PZrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="h72e6p/F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a056a000b4f00b0056ce0f64370si9538pfo.108.2022.11.21.12.26.02; Mon, 21 Nov 2022 12:26:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="h72e6p/F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231887AbiKUUOD (ORCPT + 99 others); Mon, 21 Nov 2022 15:14:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231861AbiKUUOB (ORCPT ); Mon, 21 Nov 2022 15:14:01 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7E1651C1A for ; Mon, 21 Nov 2022 12:13:59 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id g5so2888242pjp.4 for ; Mon, 21 Nov 2022 12:13:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; 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=+miEWjJAtnDGZKESGC2K13aQrBJTCpBeMrGNcOOuCUo=; b=h72e6p/FkTIdXBoJPIHLPAwYiX0sUKoIYNfLigO8S8y3c5Hmp3ItR+mjG8pawk/swt 0rYb7PZGEFIBlW4wV8boeOS0y/Tpq1t9tBOauGJCVvcBRUZtsZJm2m7Jbl96APMGvc4b 5XGoN2yZR2a/iKRPfuWT02FW/jZppd6CW53xY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=+miEWjJAtnDGZKESGC2K13aQrBJTCpBeMrGNcOOuCUo=; b=i8v6X/dGs13eUsYlEx/ZWfX2UnqjM0EDAzHjvEHPEsxRcblspm52lUZs6QkFnORXl8 SSPKwz2u5FNCAYUGfP5Xcs3NzlsiVs/VW6PX0UAK71v0UxJDJ15kaVrSQ8qGhIkpMF7e kB02CSSpuw8MK9OhENc+cCIRuF3/0qiTa8PiXEN1iOYd8zTooE9UYgUcN2o8uLhuFWWM 2j1F09xtklEJrliHnfeyB/47FveXdQGGopCfkVv1bx5fZpHyyDeslMjAeGNzSbRW7wn/ cbXDscfJukBrTubk9Ih9zgzDEU2yL2m4cBYdSNRZxxqK1WSQ9ttnmyYyGfIJ4NgWzTEJ qPzw== X-Gm-Message-State: ANoB5pler6brrVxhifeBmgoExhrQyXkCds2XaxUqUVQUzM0F/5s7M0j0 0FB6gS4DtO3IsfkXbpFcxs0fgbZ2zT9WBg== X-Received: by 2002:a17:902:f609:b0:178:2a08:2e7f with SMTP id n9-20020a170902f60900b001782a082e7fmr1199139plg.128.1669061639225; Mon, 21 Nov 2022 12:13:59 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id h8-20020a170902f70800b001822121c45asm10178507plo.28.2022.11.21.12.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 12:13:58 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, chrome-platform@lists.linux.dev Cc: Prashant Malani , Benson Leung , Heikki Krogerus , Greg Kroah-Hartman , Guenter Roeck Subject: [PATCH 2/2] platform/chrome: cros_ec_typec: Set parent of partner PD object Date: Mon, 21 Nov 2022 20:13:36 +0000 Message-Id: <20221121201337.2772216-3-pmalani@chromium.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221121201337.2772216-1-pmalani@chromium.org> References: <20221121201337.2772216-1-pmalani@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750138750761723756?= X-GMAIL-MSGID: =?utf-8?q?1750138750761723756?= In order to tell what Type-C device a PD object belongs to, its parent needs to be set. Set the parent appropriately for PD objects which are created for connected Type-C partners. Cc: Benson Leung Cc: Heikki Krogerus Signed-off-by: Prashant Malani --- 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 2a7ff14dc37e..a1cc23b86f3c 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -968,7 +968,7 @@ static void cros_typec_register_partner_pdos(struct cros_typec_data *typec, if (!resp->source_cap_count && !resp->sink_cap_count) return; - port->partner_pd = usb_power_delivery_register(NULL, &desc); + port->partner_pd = usb_power_delivery_register(typec_partner_to_dev(port->partner), &desc); if (IS_ERR(port->partner_pd)) { dev_warn(typec->dev, "Failed to register partner PD device, port: %d\n", port_num); return;