Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5714888pxb; Sun, 7 Nov 2021 18:38:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUrXs3XrpRyqffGxHcD/ckbp0t5eIsFm2DTPjf1Itr6nd9JrpuZ95Gj/W2WiXIhAhRHINY X-Received: by 2002:a05:6e02:170a:: with SMTP id u10mr23678989ill.251.1636339124208; Sun, 07 Nov 2021 18:38:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636339124; cv=none; d=google.com; s=arc-20160816; b=YGqButHEeaTJHPd7et3I07iQTRJHilsTsHDmM8rEREjJUJ2K/2Nm/LYLMnW4703IHg A2UeiMb1L/wop/fArfz5XPkfH2ciRq7Cv9y0zH5sfjsVxs0/Wg7C26m3k+hEB6VMNKzL hJxVX/EYkFxXCMp+Lal6WTvwj5ASM6faTa36R5s5X4sZJeT7vKhSMxirc9AdqRgl13Dq K4dNtz2Pgj89hfCbMSCOAtp7/Zno2T75P9iaorpY0vYg7uRIKrJGJ6oMLq7RfIAc+0mY NFiaI0wvXTq29Cg0JU8jSs4OSIWlab1wsBu/m9vJUxtF63fHkgFIY7riyTPxgUEAEeqn cEvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ISQHp33JZv+veOlWG7UsO8OxcF62yPS/55R+u1kO5uM=; b=hz0bSQAM4LzoEzAMa2Banivah/sEf4I/NF+VNsiVBkt++g2Xt38rwlPnBDoUgXnPYK gNZM6kEIwXfh0ElaeeZee+94NG1Jibc47ENy4LMf1ldvoq9HlGBJdHgJ/CPdHKNO8Oya zXwLmuxSEPYYCQWiFqsKArLerzU3nRDMzKnjgO7RoHxIVZKDsOr47xlRST/R8RWtDC+H Iks38k3HjB9H7lsDB0rd48I+fr/QSkyYuJZDOcUbUpcFtJJdFftBPDwVXbvq/6k47/7e jcKu3PdY+/2A+KpjHG3arPAlESlOMU8nEu0wS7d/QBX4LzHb8U33TJOqOHIz9Ctrud82 grtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejZyfYQr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m2si28429261ilu.157.2021.11.07.18.38.20; Sun, 07 Nov 2021 18:38:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejZyfYQr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236344AbhKGTx5 (ORCPT + 99 others); Sun, 7 Nov 2021 14:53:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34397 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235432AbhKGTx4 (ORCPT ); Sun, 7 Nov 2021 14:53:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636314673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ISQHp33JZv+veOlWG7UsO8OxcF62yPS/55R+u1kO5uM=; b=ejZyfYQrdAo/wsJgpJvAQ3BoUsneutWYeFcPJLZ9FPSWFzlP/J2+aCBeQ9NLARDj4tJ61V DIMSKWNSufr3I1X1kOAynpULMkeZrl2lWgE9W3eFDcod01j76RFpilJq62q8mk+qCbT+gP PICoOQ/9ZkVp2WKv5ymidvXlxuTUNtY= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-7-aoxHEqnkPu21G3P5izRMyw-1; Sun, 07 Nov 2021 14:51:11 -0500 X-MC-Unique: aoxHEqnkPu21G3P5izRMyw-1 Received: by mail-ed1-f69.google.com with SMTP id w12-20020a056402268c00b003e2ab5a3370so13133471edd.0 for ; Sun, 07 Nov 2021 11:51:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=ISQHp33JZv+veOlWG7UsO8OxcF62yPS/55R+u1kO5uM=; b=yV3OCLlQJR4Y6kqegcF8lEjkIYUrZDG7HfKWI39inG8SG74Ryd+PMNp4NA8a0cBda7 mBCVjqWOFXAoX1s/9ftF4OplOcisDGh0lZym9VEwJ/x8gAeNl4mjoPKJ0vXRfrTZYFxx pMFE06NuKTLO3Sf9hHyI7za9MCH85ZTxfev5vgi68sR/kWYScw50BtxGF7M8PExFuem1 skkt32DV31w+2Ic5ixeNl2KXxRye/7Xne8J+6g7KrS2NtNTFDg96KQgkkgkYSXbbzj+9 7bsUWk6/IdFaM1f79ka1T9kttrCzcjR5gINHeqxB6OAuip7LxOMrH/D1FpoVg5PHzNA3 mSUg== X-Gm-Message-State: AOAM5320L5DDZx/ZkpZkW9nQY2/xUcUYkcMt3ldue4Tx11JyaYpPU5HB Moqy7Jc7mGHHPE92IqtCMgpSmZwGERNt3eM20V3WjEZVlqzapNjNix35QwIWbCqQwDx4fC93U34 4gg9Ii8lYFtWfAHJXgfHeNnMA X-Received: by 2002:a17:907:7d94:: with SMTP id oz20mr69029186ejc.410.1636314670519; Sun, 07 Nov 2021 11:51:10 -0800 (PST) X-Received: by 2002:a17:907:7d94:: with SMTP id oz20mr69029153ejc.410.1636314670260; Sun, 07 Nov 2021 11:51:10 -0800 (PST) Received: from ?IPV6:2001:1c00:c1e:bf00:1054:9d19:e0f0:8214? (2001-1c00-0c1e-bf00-1054-9d19-e0f0-8214.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:1054:9d19:e0f0:8214]) by smtp.gmail.com with ESMTPSA id o5sm8765113edc.25.2021.11.07.11.51.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Nov 2021 11:51:09 -0800 (PST) Message-ID: <8a5935b2-880e-eca0-265d-13b8538caefe@redhat.com> Date: Sun, 7 Nov 2021 20:51:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH 11/13] i2c: cht-wc: Add support for devices using a bq25890 charger Content-Language: en-US To: Yauhen Kharuzhy Cc: Mark Gross , Andy Shevchenko , Wolfram Sang , Sebastian Reichel , MyungJoo Ham , Chanwoo Choi , Ard Biesheuvel , Tsuchiya Yuto , platform-driver-x86@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org References: <20211030182813.116672-1-hdegoede@redhat.com> <20211030182813.116672-12-hdegoede@redhat.com> From: Hans de Goede In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 11/7/21 20:07, Yauhen Kharuzhy wrote: > On Sat, Oct 30, 2021 at 08:28:11PM +0200, Hans de Goede wrote: >> The i2c-controller on the Cherry Trail - Whiskey Cove PMIC is special >> in that it is always connected to the I2C charger IC of the board on >> which the PMIC is used; and the charger IC is not described in ACPI, >> so the i2c-cht-wc code needs to instantiate an i2c-client for it itself. >> >> So far there has been a rudimentary check to make sure the ACPI tables >> are at least somewhat as expected by checking for the presence of an >> INT33FE device and sofar the code has assumed that if this INT33FE >> device is present that the used charger then is a bq24290i. >> >> But some boards with an INT33FE device in their ACPI tables use a >> different charger IC and some boards don't have an INT33FE device at all. >> >> Since the information about the used charger + fuel-gauge + other chips is >> necessary in other places too, the kernel now adds a "intel,cht-wc-setup" >> string property to the Whiskey Cove PMIC i2c-client based on DMI matching, >> which reliably describes the board's setup of the PMIC. >> >> Switch to using the "intel,cht-wc-setup" property and add support for >> instantiating an i2c-client for either a bq24292i or a bq25890 charger. >> >> This has been tested on a GPD pocket (which uses the old bq24292i setup) >> and on a Xiaomi Mi Pad 2 with a bq25890 charger. >> >> Signed-off-by: Hans de Goede >> --- >> drivers/i2c/busses/i2c-cht-wc.c | 77 +++++++++++++++++++++++++-------- >> 1 file changed, 59 insertions(+), 18 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c >> index 1cf68f85b2e1..e7d62af6c39d 100644 >> --- a/drivers/i2c/busses/i2c-cht-wc.c >> +++ b/drivers/i2c/busses/i2c-cht-wc.c >> @@ -18,6 +18,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #define CHT_WC_I2C_CTRL 0x5e24 >> @@ -304,18 +305,55 @@ static struct bq24190_platform_data bq24190_pdata = { >> .regulator_init_data = &bq24190_vbus_init_data, >> }; >> >> +static struct i2c_board_info bq24190_board_info = { >> + .type = "bq24190", >> + .addr = 0x6b, >> + .dev_name = "bq24190", >> + .swnode = &bq24190_node, >> + .platform_data = &bq24190_pdata, >> +}; >> + >> +static struct regulator_consumer_supply bq25890_vbus_consumer = { >> + .supply = "vbus", >> + .dev_name = "cht_wcove_pwrsrc", >> +}; >> + >> +static const struct regulator_init_data bq25890_vbus_init_data = { >> + .constraints = { >> + .valid_ops_mask = REGULATOR_CHANGE_STATUS, >> + }, >> + .consumer_supplies = &bq25890_vbus_consumer, >> + .num_consumer_supplies = 1, >> +}; >> + >> +static struct bq25890_platform_data bq25890_pdata = { >> + .regulator_init_data = &bq25890_vbus_init_data, >> +}; >> + >> +static const struct property_entry bq25890_props[] = { >> + PROPERTY_ENTRY_BOOL("ti,skip-init"), >> + { } >> +}; > > The Lenovo Yoga Book firmware set the IINLIM field to 500 mA at > initialization, we need a way to pass maximum allowed current in the fast > charging mode to driver. I have added 'ti,input-max-current' in my port, for > example. 500 mA is fine, we will run BC1.2 spec charger-type detection in the PMIC extcon code and then pass the result of that to the charger-IC. This is not present in this version of the patch-set because I did not have a yogabook yet when I wrote this, v2 will take care of this. I hope to post a v2 sometime the coming 2 weeks. Regards, Hans > >> + >> +static const struct software_node bq25890_node = { >> + .properties = bq25890_props, >> +}; >> + >> +static struct i2c_board_info bq25890_board_info = { >> + .type = "bq25890", >> + .addr = 0x6a, >> + .dev_name = "bq25890", >> + .swnode = &bq25890_node, >> + .platform_data = &bq25890_pdata, >> +}; >> + >> static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) >> { >> struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); >> + struct i2c_board_info *board_info = NULL; >> struct cht_wc_i2c_adap *adap; >> - struct i2c_board_info board_info = { >> - .type = "bq24190", >> - .addr = 0x6b, >> - .dev_name = "bq24190", >> - .swnode = &bq24190_node, >> - .platform_data = &bq24190_pdata, >> - }; >> int ret, reg, irq; >> + const char *str; >> >> irq = platform_get_irq(pdev, 0); >> if (irq < 0) >> @@ -379,17 +417,20 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) >> if (ret) >> goto remove_irq_domain; >> >> - /* >> - * Normally the Whiskey Cove PMIC is paired with a TI bq24292i charger, >> - * connected to this i2c bus, and a max17047 fuel-gauge and a fusb302 >> - * USB Type-C controller connected to another i2c bus. In this setup >> - * the max17047 and fusb302 devices are enumerated through an INT33FE >> - * ACPI device. If this device is present register an i2c-client for >> - * the TI bq24292i charger. >> - */ >> - if (acpi_dev_present("INT33FE", NULL, -1)) { >> - board_info.irq = adap->client_irq; >> - adap->client = i2c_new_client_device(&adap->adapter, &board_info); >> + ret = device_property_read_string(pdev->dev.parent, "intel,cht-wc-setup", &str); >> + if (ret) >> + dev_warn(&pdev->dev, "intel,cht-wc-setup not set, not instantiating charger device\n"); >> + else if (!strcmp(str, "bq24292i,max17047,fusb302,pi3usb30532")) >> + board_info = &bq24190_board_info; >> + else if (!strcmp(str, "bq25890,bq27520")) >> + board_info = &bq25890_board_info; >> + else >> + dev_warn(&pdev->dev, "Unknown intel,cht-wc-setup value: '%s', not instantiating charger device\n", >> + str); >> + >> + if (board_info) { >> + board_info->irq = adap->client_irq; >> + adap->client = i2c_new_client_device(&adap->adapter, board_info); >> if (IS_ERR(adap->client)) { >> ret = PTR_ERR(adap->client); >> goto del_adapter; >> -- >> 2.31.1 >> >