Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp228998rdb; Mon, 18 Sep 2023 13:13:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvDiXCgNjtoJSCdTs7h2EuhKYHCLjK+g1Jh1AFUyDHRAI+wT/2t0GXMSLTzjON0REBQsgp X-Received: by 2002:a17:903:32cd:b0:1c3:6d97:e897 with SMTP id i13-20020a17090332cd00b001c36d97e897mr11757559plr.5.1695067987106; Mon, 18 Sep 2023 13:13:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695067987; cv=none; d=google.com; s=arc-20160816; b=ySVBXkQyEYv8MX8oFnwP9/kOfpOZMyIxLnwOp667W7rY7EfKC5CA0QemR6X1VXh2LX Z4w/8AFAY6gsDQxitmmw8TPsg+aC8L4W/tv9g+vvkfR2qXwcZaleL3OBeQat7XFGpG1G Go4Ms/3O3llnaTQRTAerVicDoz7mcgmpiBtf6A64N6J4DM72Klnqv0adiRsxBz0oEFvi Zctj9wbmP2sFBAgJw4ATEBp0NAGke7PJ0EGOWmBXzvmu9RXh5nx76m2hIvzla6dE01yx 5RYtdR/L8IBxlDHjdaITdFFmFnPBc97MiUAxmfzWDFCAYhz/IY3k3KM0m1CLh4rZeg81 davg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SYhxA4b5M5qtzQkEP8GcAJktsuZaZ2ijMjP2FIezsGY=; fh=mm5GhUzm/JBRmdT/fEYx60eJpGDyNBskrt4GfeHVOSk=; b=J7gv/vQfn+GbGrJ4eosT2SlXWW1GyikeorhkOpl/luQpTo2l5LPvqvTosXKlJYyfRR Lo9/DR5+oPc2LIJ7B99v2A1BNROX7QJwVMVQ2L+lwwTh8rMLClR3FZINcmaSONDVjnJY 9jQYBZjHOy6lprR7mpfHHP+WxVd3I+pxehepPvr0enrvQeCUJFJGL4dmmmot8mRjkQmv Rai7bibEPAyhJ+dWbFr+I0ZLx+BSErgxmGwiObTJz17Fg6zvsKyGzPZ6qUm4XtKXiQ9d 4DpMkL47cl0b6LYkmQ/nOOzNrMkJbl0GBkm3m2gjsKZ/XlNzFPdd0Y+378Bs+kyvrtcy XPIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JWr8KXW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u8-20020a17090341c800b001c320085a71si3968768ple.639.2023.09.18.13.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 13:13:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JWr8KXW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CEBE18063BF9; Mon, 18 Sep 2023 06:00:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241615AbjIRM7j (ORCPT + 99 others); Mon, 18 Sep 2023 08:59:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242030AbjIRM7R (ORCPT ); Mon, 18 Sep 2023 08:59:17 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53FBA10D; Mon, 18 Sep 2023 05:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695041900; x=1726577900; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=MjSCmVJgyfXuq8tj4KIK8MZa0UCrDHb4eV31N5ljfSc=; b=JWr8KXW4i8EpdbGmrxfRQym+AlmIq9wrStcidSZCGZmgNSvjziXc1i1p T2DM24ZibdF+IPV+BqUSFMggaOtyQPjNTv4zKgwJhlB35EHKopEZ5K6jy YFgQGGSJqfzoYjRV+av15lLDk8UWHqMMDE/X5tLsmcpLW5aF/hYAefn62 cSE48DGNI1pRFMfKj+Z/3Y2QlyqcnLOvY9uhODhL1YR8lJqVD1u7m4Cuu OBqCEBTVGYLYJnka/h5+ZY1peCJGk1ef6kYO40HnTaUEY4zyDZAlCdrEh RrsTRmTMHORJcPblh737I+Qn4xy6J+cCenJ8dsKjlpkHDbBO+IOEW5psL Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="359897338" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="359897338" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 05:58:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="889046131" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="889046131" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 18 Sep 2023 05:57:33 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 18 Sep 2023 15:58:15 +0300 Date: Mon, 18 Sep 2023 15:58:15 +0300 From: Heikki Krogerus To: Abdel Alkuor Cc: krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org, gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com Subject: Re: [PATCH v5 10/15] USB: typec: Add port registration for tps25750 Message-ID: References: <20230917152639.21443-1-alkuor@gmail.com> <20230917152639.21443-11-alkuor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230917152639.21443-11-alkuor@gmail.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 18 Sep 2023 06:00:11 -0700 (PDT) On Sun, Sep 17, 2023 at 11:26:34AM -0400, Abdel Alkuor wrote: > From: Abdel Alkuor > > TPS25750 doesn't have system configuration register to get dr/pr of the > current applied binary configuration. > > Get data role from the device node and power role from PD status register. > > Signed-off-by: Abdel Alkuor > --- > drivers/usb/typec/tipd/core.c | 61 ++++++++++++++++++++++++++++++- > drivers/usb/typec/tipd/tps6598x.h | 10 +++++ > 2 files changed, 70 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 8218d88a4a06..a97fda68cb54 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -39,6 +39,7 @@ > #define TPS_REG_CTRL_CONF 0x29 > #define TPS_REG_BOOT_STATUS 0x2D > #define TPS_REG_POWER_STATUS 0x3f > +#define TPS_REG_PD_STATUS 0x40 > #define TPS_REG_RX_IDENTITY_SOP 0x48 > #define TPS_REG_DATA_STATUS 0x5f > > @@ -1028,6 +1029,60 @@ tps6598x_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) > return 0; > } > > +static int > +tps25750_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) > +{ > + struct typec_capability typec_cap = { }; > + const char *data_role; > + u8 pd_status; > + int ret; > + > + ret = tps6598x_read8(tps, TPS_REG_PD_STATUS, &pd_status); > + if (ret) > + return ret; > + > + ret = fwnode_property_read_string(fwnode, "data-role", &data_role); > + if (ret) { > + dev_err(tps->dev, "data-role not found: %d\n", ret); > + return ret; > + } > + > + ret = typec_find_port_data_role(data_role); > + if (ret < 0) { > + dev_err(tps->dev, "unknown data-role: %s\n", data_role); > + return ret; > + } > + > + typec_cap.data = ret; > + typec_cap.revision = USB_TYPEC_REV_1_3; > + typec_cap.pd_revision = 0x300; > + typec_cap.driver_data = tps; > + typec_cap.ops = &tps6598x_ops; > + typec_cap.fwnode = fwnode; > + typec_cap.prefer_role = TYPEC_NO_PREFERRED_ROLE; > + > + switch (TPS_PD_STATUS_PORT_TYPE(pd_status)) { > + case TPS_PD_STATUS_PORT_TYPE_SINK_SOURCE: > + case TPS_PD_STATUS_PORT_TYPE_SOURCE_SINK: > + typec_cap.type = TYPEC_PORT_DRP; > + break; > + case TPS_PD_STATUS_PORT_TYPE_SINK: > + typec_cap.type = TYPEC_PORT_SNK; > + break; > + case TPS_PD_STATUS_PORT_TYPE_SOURCE: > + typec_cap.type = TYPEC_PORT_SRC; > + break; > + default: > + return -ENODEV; > + } > + > + tps->port = typec_register_port(tps->dev, &typec_cap); > + if (IS_ERR(tps->port)) > + return PTR_ERR(tps->port); > + > + return 0; > +} > + > static int tps6598x_probe(struct i2c_client *client) > { > irq_handler_t irq_handler = tps6598x_interrupt; > @@ -1124,7 +1179,11 @@ static int tps6598x_probe(struct i2c_client *client) > if (ret) > goto err_role_put; > > - ret = tps6598x_register_port(tps, fwnode); > + if (np && of_device_is_compatible(np, "ti,tps25750")) Why aren't you using is_tps25750 here? > + ret = tps25750_register_port(tps, fwnode); > + else > + ret = tps6598x_register_port(tps, fwnode); > + > if (ret) > goto err_role_put; thanks, -- heikki