Message ID | 20230917152639.21443-1-alkuor@gmail.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2254946vqi; Sun, 17 Sep 2023 11:37:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHQgMKbd5aTAfMEYF14zG8bEV5lWjZcKDNUeEefCq0WeRz8gSDXfqrYrhWBmgQORwDvEeD0 X-Received: by 2002:a05:6a21:3299:b0:159:f39a:54e1 with SMTP id yt25-20020a056a21329900b00159f39a54e1mr6976067pzb.51.1694975845990; Sun, 17 Sep 2023 11:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694975845; cv=none; d=google.com; s=arc-20160816; b=k7W7EkHB+CZYk+VSxbvgEOrP13+PMZ+t9tm86MikhnCL3jlVtSNUs1/vQDwLfxMKWP aFs4nwQfy1hBi8t4Hpu2g4hHJiXD9S6cshDqx4TN5ve8ioVeWaFScDY+e9Od8EOAZpQI 53zV1sDwbpAkbVTKVwJ32jahgEQnibVLoLQlxOG3BkLuh55Oh6rWHJIHqf9tiNC7Jqfb SVG2dHko5Sj+pLW+OILXVI2bnBVazAVukpP6FBshBhlAgcbJNdY59EoVzIh3l9i33gnd fYjc5Yektk6CmsallfQtD9e+YOK9xqvNyfyHF9GFL9Ex+fOZR+RTUnzWTQyaGhpvE1Ag NWnw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=itAnQtUK0esq7xPW/PIltIlBTpoKhniXVdlB9pgFqig=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=EL2o/3RflrfGcIermDjZygIw6y0dO5osyx0Xu22J+EF6LeZ2T04EgWU4+j5Lja0qII rlSJBEwjNgf48CUsRQ3T1loqMZXgqnVltnbN63drUi0vuBM+L9f3gWUFU0ZRs2/w86xZ Cg2q8bk/GeNbyvB42DvUcmwgWZlpsIv1ODPGqyf+ayeOvqW6lWKjjLeH7CGRHyPb5Ddr dnoZnYqD0hF9iWkW+sR1nQy3mmSmIuQ/BnbXIP05MyDQRrChYAy9qAxDZs2uVDK0nr77 SR3N4ItquUKW/1TYy3L+H758zFZDjONcpcyDEpJjx6LSUqU62TIU1uAlYbf95TJ1tChc 76ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fpcmbzio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id le11-20020a170902fb0b00b001c38abae9b6si6778449plb.258.2023.09.17.11.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fpcmbzio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C20B4804B29B; Sun, 17 Sep 2023 08:28:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbjIQP11 (ORCPT <rfc822;toshivichauhan@gmail.com> + 29 others); Sun, 17 Sep 2023 11:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbjIQP1I (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 17 Sep 2023 11:27:08 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F3911F; Sun, 17 Sep 2023 08:27:03 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3214de9cd8bso230129f8f.2; Sun, 17 Sep 2023 08:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964421; x=1695569221; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=itAnQtUK0esq7xPW/PIltIlBTpoKhniXVdlB9pgFqig=; b=fpcmbzioRagxHtRRBJqwPgMcM5eEUjASlnE4sGUhQKLKouuNeMEJe6jVKLb36Yw+3c Pnb03qaFZE343cTmm5WgnuvNWJhq6EwxCoI74pUcKUldEiyCaoX26lfPvN41JZjan6Jc P7H80jFNdsvHpD9kRND3HN+4b/2iIvg2GxIrNfr9r/vbSRszfj7NCvKja9vrNnCARb/s rdP6gSaEA6QV9qvIivjpopByu+zgcf81h9OnUH+tDccKmuITDQx4ywZSJ7RmXs+VlpeR 8BdpfIYj0Kja5D7tvsAPMvKkjPM/q5xcq2/yul79//1uDoGhi58gt2Kq/B0OsWu16+DV +rDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964421; x=1695569221; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=itAnQtUK0esq7xPW/PIltIlBTpoKhniXVdlB9pgFqig=; b=r4MjzYvzib8d5YPD4pge/uqEew1YnWqjLqXrGPLsklFtHmdSwA48uuzqRVRgAeEyVy owCnCcyTXr3W3FqWZ9BAIdZylnUnExSor79NzYD/KbZvuxUHz7WjaQQd3QSdGRUlZKb8 ftxTz6iOWiyHc/4/GJug0WIqN0iCSZnK8OO1XFzA1ixByuTy4TopG+rCGlk4JAciTLbW LLaof8LKi8jY/2ElhOSk0w3is0kX9bkDi66RFnnrLyRpkZNRuNDMapKzFg9qbD5QmoBB DZlnqGbefOZ+maNBlifvdVNUSrldufQ/O1Z7Doqu7NOHPYr5nWD5WpF2bPHrnlDWLxJE xaZw== X-Gm-Message-State: AOJu0Yye9jt9A08lcMULo3+zgXLlFU2SKnZ+zBu1tilaL0hfIo6K2uAd XNo14HqMtlJuyX2/YnNsf80= X-Received: by 2002:a05:6000:118d:b0:316:efb9:101d with SMTP id g13-20020a056000118d00b00316efb9101dmr6956862wrx.25.1694964421068; Sun, 17 Sep 2023 08:27:01 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:00 -0700 (PDT) From: Abdel Alkuor <alkuor@gmail.com> To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: 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: [PATCH v5 00/15] Add TPS25750 USB type-C PD controller support Date: Sun, 17 Sep 2023 11:26:24 -0400 Message-Id: <20230917152639.21443-1-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:28:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777310993110241942 X-GMAIL-MSGID: 1777310993110241942 |
Series |
Add TPS25750 USB type-C PD controller support
|
|
Message
Abdel Alkuor
Sept. 17, 2023, 3:26 p.m. UTC
From: Abdel Alkuor <abdelalkuor@geotab.com>
TPS25750 USB type-C PD controller has the same register offsets as
tps6598x. The following is a summary of incorporating TPS25750 into
TPS6598x driver:
- Only Check VID register (0x00) for TPS6598x and cd321x, as TPS25750 doesn't
have VID register.
- TypeC port registration will be registered differently for each PD
controller. TPS6598x uses system configuration register (0x28) to get
pr/dr capabilities. On the other hand, TPS25750 will use data role property
and PD status register (0x40) to get pr/dr capabilities as TPS25750 doesn't
have register 0x28 supported.
- TPS25750 requires writing a binary configuration to switch PD
controller from PTCH mode to APP mode which needs the following changes:
- Add PTCH mode to the modes list.
- Add an argument to tps6598x_check_mode to return the current mode.
- Currently, tps6598x_exec_cmd has cmd timeout hardcoded to 1 second,
and doesn't wait before checking DATA_OUT response. In TPS25750, patch 4CCs
take longer than 1 second to execute and some requires a delay before
checking DATA_OUT. To accommodate that, cmd_timeout and response_delay will
be added as arguments to tps6598x_exec_cmd.
- Implement applying patch sequence for TPS25750.
- In pm suspend callback, patch mode needs to be checked and the binary
configuration should be applied if needed.
- For interrupt, TPS25750 has only one event register (0x14) and one mask
register (0x16) of 11 bytes each, where TPS6598x has two event
and two mask registers of 8 bytes each. Both TPS25750 and TPS65986x
shares the same bit field offsets for events/masks/clear but many of
there fields are reserved in TPS25750, the following needs to be done in
tps6598x_interrupt:
- Read EVENT1 register as a block of 11 bytes when tps25750 is present
- Write CLEAR1 register as a block of 11 bytes when tps25750 is present
- Add trace_tps25750_irq
- During testing, I noticed that when a cable is plugged into the PD
controller and before PD controller switches to APP mode, there is a
lag between dr/pr updates and PlugInsertOrRemoval Event, so a check
for dr/pr change needs to be added along TPS_REG_INT_PLUG_EVENT check
- Add TPS25750 traces for status and power status registers. Trace for
data register won't be added as it doesn't exist in the device.
- Configure sleep mode for TPS25750.
v5:
- PATCH 1: Add tps25750 bindings to tps6598x
- PATCH 2: Remove tps25750 driver and incorperate tps25750
into tps6598x driver
v4:
- PATCH 1: No change
- PATCH 2: Fix comments style and drop of_match_ptr
v3:
- PATCH 1: Fix node name
- PATCH 2: Upload tps25750 driver patch
v2:
- PATCH 1: General properties clean up
Abdel Alkuor (15):
dt-bindings: usb: tps6598x: Add tps25750
USB: typec: Add cmd timeout and response delay
USB: typec: Add patch mode to tps6598x
USB: typec: Load TPS25750 patch bundle
USB: typec: Check for EEPROM present
USB: typec: Clear dead battery flag
USB: typec: Apply patch again after power resume
USB: typec: Add interrupt support for TPS25750
USB: typec: Refactor tps6598x port registration
USB: typec: Add port registration for tps25750
USB: typec: Enable sleep mode for tps25750
USB: typec: Add trace for tps25750 irq
USB: typec: Add power status trace for tps25750
USB: typec: Add status trace for tps25750
USB: typec: Do not check VID for tps25750
.../devicetree/bindings/usb/ti,tps6598x.yaml | 70 +++
drivers/usb/typec/tipd/core.c | 570 +++++++++++++++---
drivers/usb/typec/tipd/tps6598x.h | 36 ++
drivers/usb/typec/tipd/trace.h | 84 +++
4 files changed, 683 insertions(+), 77 deletions(-)
Comments
On 17/09/2023 17:26, Abdel Alkuor wrote: > From: Abdel Alkuor <abdelalkuor@geotab.com> > > TPS25750 is USB TypeC PD controller which is a subset of TPS6598x. > > Signed-off-by: Abdel Alkuor <abdelalkuor@geotab.com> > --- > .../devicetree/bindings/usb/ti,tps6598x.yaml | 70 +++++++++++++++++++ > 1 file changed, 70 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml > index 5497a60cddbc..e49bd92b5276 100644 > --- a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml > +++ b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml > @@ -20,6 +20,8 @@ properties: > enum: > - ti,tps6598x > - apple,cd321x > + - ti,tps25750 > + > reg: > maxItems: 1 > > @@ -32,10 +34,45 @@ properties: > items: > - const: irq > > + firmware-name: > + description: | > + Should contain the name of the default patch binary > + file located on the firmware search path which is > + used to switch the controller into APP mode. > + This is used when tps25750 doesn't have an EEPROM > + connected to it. > + maxItems: 1 > + > + ti,patch-address: > + description: | > + One of PBMs command data field is I2C slave address > + which is used when writing the patch for TPS25750. > + The slave address can be any value except 0x00, 0x20, > + 0x21, 0x22, and 0x23 Why this cannot be another entry in the reg? > + $ref: /schemas/types.yaml#/definitions/uint8 > + minimum: 1 > + maximum: 0x7e > + > required: > - compatible > - reg > > +allOf: > + - if: > + properties: > + compatible: > + contains: > + const: ti,tps25750 > + then: > + required: > + - ti,patch-address > + - connector Why? Connector should be required or not required for both devices. What is different between them? Best regards, Krzysztof
On Sun, Sep 17, 2023 at 07:30:52PM +0200, Krzysztof Kozlowski wrote: > On 17/09/2023 17:26, Abdel Alkuor wrote: > > From: Abdel Alkuor <abdelalkuor@geotab.com> > > > > TPS25750 is USB TypeC PD controller which is a subset of TPS6598x. > > > > Signed-off-by: Abdel Alkuor <abdelalkuor@geotab.com> > > --- > > .../devicetree/bindings/usb/ti,tps6598x.yaml | 70 +++++++++++++++++++ > > 1 file changed, 70 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml > > index 5497a60cddbc..e49bd92b5276 100644 > > --- a/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml > > +++ b/Documentation/devicetree/bindings/usb/ti,tps6598x.yaml > > @@ -20,6 +20,8 @@ properties: > > enum: > > - ti,tps6598x > > - apple,cd321x > > + - ti,tps25750 > > + > > reg: > > maxItems: 1 > > > > @@ -32,10 +34,45 @@ properties: > > items: > > - const: irq > > > > + firmware-name: > > + description: | > > + Should contain the name of the default patch binary > > + file located on the firmware search path which is > > + used to switch the controller into APP mode. > > + This is used when tps25750 doesn't have an EEPROM > > + connected to it. > > + maxItems: 1 > > + > > + ti,patch-address: > > + description: | > > + One of PBMs command data field is I2C slave address > > + which is used when writing the patch for TPS25750. > > + The slave address can be any value except 0x00, 0x20, > > + 0x21, 0x22, and 0x23 > > Why this cannot be another entry in the reg? > This address is different than the physical address of PD controller. The patch address will be used instead of PD controller address when writing the patch. I thought reg proprity is only for a device physical address, should I add another entry in the reg property in this case? > > + $ref: /schemas/types.yaml#/definitions/uint8 > > + minimum: 1 > > + maximum: 0x7e > > + > > required: > > - compatible > > - reg > > > > +allOf: > > + - if: > > + properties: > > + compatible: > > + contains: > > + const: ti,tps25750 > > + then: > > + required: > > + - ti,patch-address > > + - connector > > > Why? Connector should be required or not required for both devices. What > is different between them? > The data-role for tps6598x can be extracted from system config register which it doesn't exist in tps25750, so the only way to extract this information is by using data-role property from the Connector for tps25750, hence Connector and data-role are set as required for tps25750. > > Best regards, > Krzysztof > Thanks, Abdel
Hi, On Sun, Sep 17, 2023 at 11:26:39AM -0400, Abdel Alkuor wrote: > From: Abdel Alkuor <abdelalkuor@geotab.com> > > tps25750 doesn't have VID register, check VID for PD controllers > other than tps25750 > > Signed-off-by: Abdel Alkuor <abdelalkuor@geotab.com> > --- > drivers/usb/typec/tipd/core.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 326c23bfa8e6..c1399e12a170 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -1142,10 +1142,6 @@ static int tps6598x_probe(struct i2c_client *client) > if (IS_ERR(tps->regmap)) > return PTR_ERR(tps->regmap); > > - ret = tps6598x_read32(tps, TPS_REG_VID, &vid); > - if (ret < 0 || !vid) > - return -ENODEV; > - > /* > * Checking can the adapter handle SMBus protocol. If it can not, the > * driver needs to take care of block reads separately. > @@ -1176,6 +1172,12 @@ static int tps6598x_probe(struct i2c_client *client) > > tps->irq_handler = irq_handler; > > + if (!tps->is_tps25750) { > + ret = tps6598x_read32(tps, TPS_REG_VID, &vid); > + if (ret < 0 || !vid) > + return -ENODEV; > + } You need to do this at the same time you enable tps25750, so I'm guessing in patch 4. You are also changing the execution order just because of that is_tps25750. Instead you need to make sure you have that flag set as soon as possible in the first place, so right after "tps" is allocated: mutex_init(&tps->lock); tps->dev = &client->dev; + tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750"); tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config); if (IS_ERR(tps->regmap)) thanks,
On Sun, Sep 17, 2023 at 11:26:24AM -0400, Abdel Alkuor wrote: > From: Abdel Alkuor <abdelalkuor@geotab.com> > > TPS25750 USB type-C PD controller has the same register offsets as > tps6598x. The following is a summary of incorporating TPS25750 into > TPS6598x driver: > > - Only Check VID register (0x00) for TPS6598x and cd321x, as TPS25750 doesn't > have VID register. > > - TypeC port registration will be registered differently for each PD > controller. TPS6598x uses system configuration register (0x28) to get > pr/dr capabilities. On the other hand, TPS25750 will use data role property > and PD status register (0x40) to get pr/dr capabilities as TPS25750 doesn't > have register 0x28 supported. > > - TPS25750 requires writing a binary configuration to switch PD > controller from PTCH mode to APP mode which needs the following changes: > - Add PTCH mode to the modes list. > - Add an argument to tps6598x_check_mode to return the current mode. > - Currently, tps6598x_exec_cmd has cmd timeout hardcoded to 1 second, > and doesn't wait before checking DATA_OUT response. In TPS25750, patch 4CCs > take longer than 1 second to execute and some requires a delay before > checking DATA_OUT. To accommodate that, cmd_timeout and response_delay will > be added as arguments to tps6598x_exec_cmd. > - Implement applying patch sequence for TPS25750. > > - In pm suspend callback, patch mode needs to be checked and the binary > configuration should be applied if needed. > > - For interrupt, TPS25750 has only one event register (0x14) and one mask > register (0x16) of 11 bytes each, where TPS6598x has two event > and two mask registers of 8 bytes each. Both TPS25750 and TPS65986x > shares the same bit field offsets for events/masks/clear but many of > there fields are reserved in TPS25750, the following needs to be done in > tps6598x_interrupt: > - Read EVENT1 register as a block of 11 bytes when tps25750 is present > - Write CLEAR1 register as a block of 11 bytes when tps25750 is present > - Add trace_tps25750_irq > - During testing, I noticed that when a cable is plugged into the PD > controller and before PD controller switches to APP mode, there is a > lag between dr/pr updates and PlugInsertOrRemoval Event, so a check > for dr/pr change needs to be added along TPS_REG_INT_PLUG_EVENT check > > - Add TPS25750 traces for status and power status registers. Trace for > data register won't be added as it doesn't exist in the device. > > - Configure sleep mode for TPS25750. This looks mostly okay, but I'm a bit uncomfortable with flags like is_tps25750. I think a better way would be to supply driver data. In it you would have a callback for everything that needs to be customised. struct tipd_data { int (*interrupt)(int irq, void *data); ... }; ... static const struct tipd_data tps25750_data = { .interrupt = tps25750_interrupt, ... Something like that. You can on top of that still check device_is_compatible(dev, "...") in some places. thanks,
On Mon, Sep 18, 2023 at 04:29:43PM +0300, Heikki Krogerus wrote: > Hi, > > On Sun, Sep 17, 2023 at 11:26:39AM -0400, Abdel Alkuor wrote: > > From: Abdel Alkuor <abdelalkuor@geotab.com> > > > > tps25750 doesn't have VID register, check VID for PD controllers > > other than tps25750 > > > > Signed-off-by: Abdel Alkuor <abdelalkuor@geotab.com> > > --- > > drivers/usb/typec/tipd/core.c | 10 ++++++---- > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > > index 326c23bfa8e6..c1399e12a170 100644 > > --- a/drivers/usb/typec/tipd/core.c > > +++ b/drivers/usb/typec/tipd/core.c > > @@ -1142,10 +1142,6 @@ static int tps6598x_probe(struct i2c_client *client) > > if (IS_ERR(tps->regmap)) > > return PTR_ERR(tps->regmap); > > > > - ret = tps6598x_read32(tps, TPS_REG_VID, &vid); > > - if (ret < 0 || !vid) > > - return -ENODEV; > > - > > /* > > * Checking can the adapter handle SMBus protocol. If it can not, the > > * driver needs to take care of block reads separately. > > @@ -1176,6 +1172,12 @@ static int tps6598x_probe(struct i2c_client *client) > > > > tps->irq_handler = irq_handler; > > > > + if (!tps->is_tps25750) { > > + ret = tps6598x_read32(tps, TPS_REG_VID, &vid); > > + if (ret < 0 || !vid) > > + return -ENODEV; > > + } > > You need to do this at the same time you enable tps25750, so I'm > guessing in patch 4. > > You are also changing the execution order just because of that > is_tps25750. Instead you need to make sure you have that flag set as > soon as possible in the first place, so right after "tps" is > allocated: > Good point. I will move the check in patch 4 and check it after allocating tps. > mutex_init(&tps->lock); > tps->dev = &client->dev; > + tps->is_tps25750 = of_device_is_compatible(np, "ti,tps25750"); > > tps->regmap = devm_regmap_init_i2c(client, &tps6598x_regmap_config); > if (IS_ERR(tps->regmap)) > > > thanks, > > -- > heikki Thanks, Abdel
On Mon, Sep 18, 2023 at 04:57:49PM +0300, Heikki Krogerus wrote: > On Sun, Sep 17, 2023 at 11:26:24AM -0400, Abdel Alkuor wrote: > > From: Abdel Alkuor <abdelalkuor@geotab.com> > > > > TPS25750 USB type-C PD controller has the same register offsets as > > tps6598x. The following is a summary of incorporating TPS25750 into > > TPS6598x driver: > > > > - Only Check VID register (0x00) for TPS6598x and cd321x, as TPS25750 doesn't > > have VID register. > > > > - TypeC port registration will be registered differently for each PD > > controller. TPS6598x uses system configuration register (0x28) to get > > pr/dr capabilities. On the other hand, TPS25750 will use data role property > > and PD status register (0x40) to get pr/dr capabilities as TPS25750 doesn't > > have register 0x28 supported. > > > > - TPS25750 requires writing a binary configuration to switch PD > > controller from PTCH mode to APP mode which needs the following changes: > > - Add PTCH mode to the modes list. > > - Add an argument to tps6598x_check_mode to return the current mode. > > - Currently, tps6598x_exec_cmd has cmd timeout hardcoded to 1 second, > > and doesn't wait before checking DATA_OUT response. In TPS25750, patch 4CCs > > take longer than 1 second to execute and some requires a delay before > > checking DATA_OUT. To accommodate that, cmd_timeout and response_delay will > > be added as arguments to tps6598x_exec_cmd. > > - Implement applying patch sequence for TPS25750. > > > > - In pm suspend callback, patch mode needs to be checked and the binary > > configuration should be applied if needed. > > > > - For interrupt, TPS25750 has only one event register (0x14) and one mask > > register (0x16) of 11 bytes each, where TPS6598x has two event > > and two mask registers of 8 bytes each. Both TPS25750 and TPS65986x > > shares the same bit field offsets for events/masks/clear but many of > > there fields are reserved in TPS25750, the following needs to be done in > > tps6598x_interrupt: > > - Read EVENT1 register as a block of 11 bytes when tps25750 is present > > - Write CLEAR1 register as a block of 11 bytes when tps25750 is present > > - Add trace_tps25750_irq > > - During testing, I noticed that when a cable is plugged into the PD > > controller and before PD controller switches to APP mode, there is a > > lag between dr/pr updates and PlugInsertOrRemoval Event, so a check > > for dr/pr change needs to be added along TPS_REG_INT_PLUG_EVENT check > > > > - Add TPS25750 traces for status and power status registers. Trace for > > data register won't be added as it doesn't exist in the device. > > > > - Configure sleep mode for TPS25750. > > This looks mostly okay, but I'm a bit uncomfortable with flags like > is_tps25750. > > I think a better way would be to supply driver data. In it you would > have a callback for everything that needs to be customised. > > struct tipd_data { > int (*interrupt)(int irq, void *data); > ... > }; > ... > static const struct tipd_data tps25750_data = { > .interrupt = tps25750_interrupt, > ... > > Something like that. You can on top of that still check > device_is_compatible(dev, "...") in some places. > Sounds good. I will create callbacks factory struct as you suggested and remove the flag. > > thanks, > > -- > heikki Thanks, Abdel