Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5676532pxb; Sun, 7 Nov 2021 17:46:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdDUViNygpxe/7Smz0tcmegylkZs5x1axIBkTIfuexwE1UP2XrOoGvMhVnyk/sMB9uo7sA X-Received: by 2002:a05:6e02:174d:: with SMTP id y13mr21325910ill.183.1636335977319; Sun, 07 Nov 2021 17:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636335977; cv=none; d=google.com; s=arc-20160816; b=NHIBTewkbBz4B+7Zmz9KF67ZTJFfsCtAUa9pIZWHfvkyVnBmKbGMDwAKTcMVJB9PGv g7WtjWIFI0erxsLxWXlivPJPeaqK5LPa7CNw2/MLpe6JnN//1yblo0ajHjbgvGpXgKKE oNoF0aBQReCTPsXeUrXtG3V0roNaFr3stpnCZ8aWhQpsV+syN0LZBlQXjGaEVLPdanPZ L562HiobyfBQZYYDS7H11W9oZfFzM9fvqP+JoWc9qAwh3wc9iv3cyDVccPlTE6U6WIj6 ug8guPJTfJV38dfVz78brynY94cIld4NRxXfS3cZWI7Kle4qoR6zv7qDIKvwP383uoWO d0DQ== 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=eMHkjPc5rIa5X9zRJiGLsZ3MoAtpjiPyEbEU/3emZIY=; b=zc48VAnHUPZvwHPuK2gjevIm92q2shbgPN9uX9PqrW9MnYwSlHkQtm2czIhAsp982v +EnAPXUr0D2vgOXCSdcCWUrVCGq6PUnE5HL25sgvfLAEnn1BdfbkxuyFG0yxSMu+vEHV hX8RAa1qoMAc3P4BYllv214mlEc0oyhrH4XiFqvSV6OCSfm6SwdimTo4zceLZr279llX 0bt5DKMJBda1v/FgaN0rI71YkboZQdh+wZgO3VFJqQPfMYQA9Kwy5bI90D4qYQWs1QH1 rgm5Spam/0ouIS05AP6cvqVVeuPxC1vYpqykV0F21Xz+jcpDPEr2on16DMfkKeBG3VKK agYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jUhmHlGi; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si25680112jaj.121.2021.11.07.17.46.03; Sun, 07 Nov 2021 17:46:17 -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=@gmail.com header.s=20210112 header.b=jUhmHlGi; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236242AbhKGTKS (ORCPT + 99 others); Sun, 7 Nov 2021 14:10:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbhKGTKO (ORCPT ); Sun, 7 Nov 2021 14:10:14 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC36C061570; Sun, 7 Nov 2021 11:07:30 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id p16so31311558lfa.2; Sun, 07 Nov 2021 11:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=eMHkjPc5rIa5X9zRJiGLsZ3MoAtpjiPyEbEU/3emZIY=; b=jUhmHlGin5sEj5r9B3duWZRYeZfWXFTNWh3fjVMDJalE4cgJbKUOBCVy+HI8gCwirs 3XvxuZH5zrrIMShFl0fwn1DIUJPx1G+MhjL0TS/jL7T8SH1Qn8CyBZq+c1INVx9qxC6/ chCfa/fERQRXgAgzBM0eamEQGzO/tnPEFLzfJmcJzPJsMtZX3GjVHaPSMJSthYahkzvw +0K/IAndgglgZqZDAVZEsLjOzaV+FmxOQ7p+zmmct6v7RRXkdU3bOfSZ+y+d+zBVf6MA DCeY9cKiZpeNf5XniqAHn4Z8HJAxoTbjxIox7i+HDLfH2gHhP/fUW2qx/dsV3oKKooQt eC3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eMHkjPc5rIa5X9zRJiGLsZ3MoAtpjiPyEbEU/3emZIY=; b=z84M3HiLN0SKCcTzt8D/lcHKaNwKDrX7s5rDhyM7SoHITG3Ltct3yR/w74YfV8ioPO 4TkTGGXBGDrnVVGLy0WjNQqiLCi4nPePFtRUBcLEVpMdmSgJryPt5ggGkWHjJlQ66kAg tyfY0ZJJtVwXTeUrsYJwGXfG3IbSr0FIro6NunXpzdBzqJRxwPMNja8Iketx+pHgoVbF Ck3iiHfmn1YqFk+doEmZAYT8/y83KVsFfrTQCl9yoNSLwbi41lMWBBMaOmoNZKVMMvao JqLtWx1j1YlreCO0Z+J/9e/YhIGApC/H+2gwhgc5cXnOv3ySMpKyjV0GTHqP3fJFquGC 1t5w== X-Gm-Message-State: AOAM531jHSqQP5zybn1RN4E302m772SO99t0C0IvaX+dg6eSb8L7CAeA T3tgRLzNQsAf2icnRnnh11c= X-Received: by 2002:ac2:5df4:: with SMTP id z20mr57205513lfq.97.1636312048924; Sun, 07 Nov 2021 11:07:28 -0800 (PST) Received: from localhost.localdomain ([37.45.143.17]) by smtp.gmail.com with ESMTPSA id b22sm251387lfv.20.2021.11.07.11.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Nov 2021 11:07:28 -0800 (PST) Received: from jek by localhost.localdomain with local (Exim 4.95) (envelope-from ) id 1mjnVn-000Dnk-DT; Sun, 07 Nov 2021 22:07:27 +0300 Date: Sun, 7 Nov 2021 22:07:27 +0300 From: Yauhen Kharuzhy To: Hans de Goede 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 Subject: Re: [PATCH 11/13] i2c: cht-wc: Add support for devices using a bq25890 charger Message-ID: References: <20211030182813.116672-1-hdegoede@redhat.com> <20211030182813.116672-12-hdegoede@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211030182813.116672-12-hdegoede@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + > +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 > -- Yauhen Kharuzhy