From nobody Thu Dec 18 10:01:39 2025 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7B651D5CCC; Mon, 13 Jan 2025 22:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.249 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736808962; cv=none; b=efU3dRor0Amf+38B8JMjAqdbnUKmFh0GdO29kUcxL2cDVVY7SBpH7xLvDXIgMkMbAOEuNx/H2eNI8T7ycKIY2/AKHeQrU4G2mIpa3Tkax/pdafmLq3wLuGErKuFVvAGebX3RPdn/hKDIQkwEpraTNNj0OLedQjy8WdkW/GKQlLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736808962; c=relaxed/simple; bh=eLgWbwr+HdznEx+mPYR8aItzP0MmG4feZT8c4voRN78=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=chGZM1JK1c/hkooTjPy6aPGNeSFnqVFwQ7xv/PUva7eugYAbVOgEBy8uddZ5TTxH7vOgx8lQEVx/1EfKE709wlKFRhpypGSjLFvUGa0bdrg7iGrj5zIpuUWpZVB4zAws8RZ4Zvx84oHRoysB7CpR3ZPnpIZGsSs8Zo9L/6xi/dI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=kF3TgaVi; arc=none smtp.client-ip=198.47.23.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="kF3TgaVi" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 50DMtUZE103651; Mon, 13 Jan 2025 16:55:30 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1736808930; bh=gLmMXGTfUb8j5ddv6kcDeHTlf8WPsi4njchz9eZjtf8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=kF3TgaVio8Ma8eG05F7dYwGLf5TVm9lNvx9SuJwwvOo9rgcBBzl4yEF2jD6THKpBa mnjWTuXjA8t88Hju3cNX5fBkTHJnvSAKp5tA2YCElakM0VwDUJbM2XJC9D1jPqd+8r VKR44ueSvIFf6ekSokQegTgr+FXMsw6ZwXqdbjhw= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 50DMtUwC086496 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 13 Jan 2025 16:55:30 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 13 Jan 2025 16:55:30 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 13 Jan 2025 16:55:30 -0600 Received: from DMZ007XYY.dhcp.ti.com (dmz007xyy.dhcp.ti.com [128.247.29.11]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 50DMtU55047817; Mon, 13 Jan 2025 16:55:30 -0600 From: Shree Ramamoorthy To: , , , , , , , , , CC: , , Subject: [PATCH v3 1/3] gpio: tps65215: Add TPS65215 to platform_device_id table Date: Mon, 13 Jan 2025 16:55:28 -0600 Message-ID: <20250113225530.124213-2-s-ramamoorthy@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113225530.124213-1-s-ramamoorthy@ti.com> References: <20250113225530.124213-1-s-ramamoorthy@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Add platform_device_id struct and use the platform_get_device_id() output to match which PMIC device is in use. With new name options, the gpio_chip .label field is now assigned to the platform_device name match. Remove MODULE_ALIAS since it is now generated by MODULE_DEVICE_TABLE. Signed-off-by: Shree Ramamoorthy --- drivers/gpio/gpio-tps65219.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c index 526640c39a11..7e03be0c7c92 100644 --- a/drivers/gpio/gpio-tps65219.c +++ b/drivers/gpio/gpio-tps65219.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* - * GPIO driver for TI TPS65219 PMICs + * GPIO driver for TI TPS65215/TPS65219 PMICs * - * Copyright (C) 2022 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com/ */ =20 #include @@ -141,7 +141,6 @@ static int tps65219_gpio_direction_output(struct gpio_c= hip *gc, unsigned int off } =20 static const struct gpio_chip tps65219_template_chip =3D { - .label =3D "tps65219-gpio", .owner =3D THIS_MODULE, .get_direction =3D tps65219_gpio_get_direction, .direction_input =3D tps65219_gpio_direction_input, @@ -164,20 +163,28 @@ static int tps65219_gpio_probe(struct platform_device= *pdev) =20 gpio->tps =3D tps; gpio->gpio_chip =3D tps65219_template_chip; + gpio->gpio_chip.label =3D dev_name(&pdev->dev); gpio->gpio_chip.parent =3D tps->dev; =20 return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio_chip, gpio); } =20 +static const struct platform_device_id tps6521x_gpio_id_table[] =3D { + { "tps65215-gpio", TPS65215 }, + { "tps65219-gpio", TPS65219 }, + { } +}; +MODULE_DEVICE_TABLE(platform, tps6521x_gpio_id_table); + static struct platform_driver tps65219_gpio_driver =3D { .driver =3D { .name =3D "tps65219-gpio", }, .probe =3D tps65219_gpio_probe, + .id_table =3D tps6521x_gpio_id_table, }; module_platform_driver(tps65219_gpio_driver); =20 -MODULE_ALIAS("platform:tps65219-gpio"); MODULE_AUTHOR("Jonathan Cormier "); -MODULE_DESCRIPTION("TPS65219 GPIO driver"); +MODULE_DESCRIPTION("TPS65215/TPS65219 GPIO driver"); MODULE_LICENSE("GPL"); --=20 2.43.0 From nobody Thu Dec 18 10:01:39 2025 Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A59A01F9F78; Mon, 13 Jan 2025 22:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.235 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736808967; cv=none; b=n3LBdZ4kIngr9om0Cs1E4TLy44uFXt6cFSgxzZrM7cEaUA2ub8zyaKuVELn9EmIbuNRy4JxNJauh9tsu9EUd3zajzR4ZGrzOhh7suMfW0+oHNuHkRpr/ztru2YlVkdRuFbjOhAtmMq4YF2iDntj1+Iuu8LDoIymIw9ZmhUWB9yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736808967; c=relaxed/simple; bh=M0Lu9nzsBwZ8zrdo6QtSe3xZr6xQn4q8rTZSoxWH+hA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SFWAQ4PGFhGHL/zHOzODsLH1DhteXONOrZzTeQE3FtRIL8iQ/SWPbNcBo0roZd2FZav9p6dIioK1otF2mz9T6KFRnu4XZw1t0qzECRuxFaAkMOiGWOvNUUSdT1xtkdzPxJKTbud8t9qLUEvFHdpzOFvD2YRDiB5fFTPqsLEGqDc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=ii8AVSor; arc=none smtp.client-ip=198.47.23.235 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="ii8AVSor" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 50DMtU9X3881631 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jan 2025 16:55:30 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1736808930; bh=kL/SJcfgV3QjRqYYg0mlBQ5Mo829P8bsgPsREmi4k9w=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ii8AVSor2rbGpSFuxUBpcH5ShqnjhS1eMZEXruWi1Ikpj4wjweYRtLg8AmL7v9I4w fZk38LgMLVHRbbmyk7DIorz2Ts+S9FLP9NucP781gOBRikCXC5bnU2R3b1IyHi2LXW MvzLbHxt52IJVZ2+XjBHTx6IM5wxzI77nK1PzdCY= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 50DMtUdK003265 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 13 Jan 2025 16:55:30 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 13 Jan 2025 16:55:30 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 13 Jan 2025 16:55:30 -0600 Received: from DMZ007XYY.dhcp.ti.com (dmz007xyy.dhcp.ti.com [128.247.29.11]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 50DMtU56047817; Mon, 13 Jan 2025 16:55:30 -0600 From: Shree Ramamoorthy To: , , , , , , , , , CC: , , Subject: [PATCH v3 2/3] gpio: tps65215: Update GPIO0_IDX macro prefix Date: Mon, 13 Jan 2025 16:55:29 -0600 Message-ID: <20250113225530.124213-3-s-ramamoorthy@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113225530.124213-1-s-ramamoorthy@ti.com> References: <20250113225530.124213-1-s-ramamoorthy@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Updating the macro name to TPS6521X_GPIO0_IDX is meant to indicate this macro applies to both PMIC devices. Signed-off-by: Shree Ramamoorthy Acked-by: Linus Walleij --- drivers/gpio/gpio-tps65219.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c index 7e03be0c7c92..70a4410c473a 100644 --- a/drivers/gpio/gpio-tps65219.c +++ b/drivers/gpio/gpio-tps65219.c @@ -14,7 +14,7 @@ =20 #define TPS65219_GPIO0_DIR_MASK BIT(3) #define TPS65219_GPIO0_OFFSET 2 -#define TPS65219_GPIO0_IDX 0 +#define TPS6521X_GPIO0_IDX 0 =20 struct tps65219_gpio { struct gpio_chip gpio_chip; @@ -26,7 +26,7 @@ static int tps65219_gpio_get_direction(struct gpio_chip *= gc, unsigned int offset struct tps65219_gpio *gpio =3D gpiochip_get_data(gc); int ret, val; =20 - if (offset !=3D TPS65219_GPIO0_IDX) + if (offset !=3D TPS6521X_GPIO0_IDX) return GPIO_LINE_DIRECTION_OUT; =20 ret =3D regmap_read(gpio->tps->regmap, TPS65219_REG_MFP_1_CONFIG, &val); @@ -42,7 +42,7 @@ static int tps65219_gpio_get(struct gpio_chip *gc, unsign= ed int offset) struct device *dev =3D gpio->tps->dev; int ret, val; =20 - if (offset !=3D TPS65219_GPIO0_IDX) { + if (offset !=3D TPS6521X_GPIO0_IDX) { dev_err(dev, "GPIO%d is output only, cannot get\n", offset); return -ENOTSUPP; } @@ -71,7 +71,7 @@ static void tps65219_gpio_set(struct gpio_chip *gc, unsig= ned int offset, int val struct device *dev =3D gpio->tps->dev; int v, mask, bit; =20 - bit =3D (offset =3D=3D TPS65219_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offs= et - 1; + bit =3D (offset =3D=3D TPS6521X_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offs= et - 1; =20 mask =3D BIT(bit); v =3D value ? mask : 0; @@ -117,7 +117,7 @@ static int tps65219_gpio_direction_input(struct gpio_ch= ip *gc, unsigned int offs struct tps65219_gpio *gpio =3D gpiochip_get_data(gc); struct device *dev =3D gpio->tps->dev; =20 - if (offset !=3D TPS65219_GPIO0_IDX) { + if (offset !=3D TPS6521X_GPIO0_IDX) { dev_err(dev, "GPIO%d is output only, cannot change to input\n", offset); return -ENOTSUPP; } @@ -131,7 +131,7 @@ static int tps65219_gpio_direction_input(struct gpio_ch= ip *gc, unsigned int offs static int tps65219_gpio_direction_output(struct gpio_chip *gc, unsigned i= nt offset, int value) { tps65219_gpio_set(gc, offset, value); - if (offset !=3D TPS65219_GPIO0_IDX) + if (offset !=3D TPS6521X_GPIO0_IDX) return 0; =20 if (tps65219_gpio_get_direction(gc, offset) =3D=3D GPIO_LINE_DIRECTION_OU= T) --=20 2.43.0 From nobody Thu Dec 18 10:01:39 2025 Received: from fllvem-ot04.ext.ti.com (fllvem-ot04.ext.ti.com [198.47.19.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 469E61D5CCC; Mon, 13 Jan 2025 22:55:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.246 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736808951; cv=none; b=ntwhhEY2EZNVKk9UlxsAFMBG3dWVK7lMCQ9/SouChTZtsq673ws7gIH70BiU1FJ6erGUMuO+o11RGBIFVKNlh3F2ubL+6a+WtxDAefHcLPCNyPWaPzAtzb6YDpsjdPl5tHAUPZNd/MQzl6//HzJb0eTxXnlPFlv4+MdSevBhoiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736808951; c=relaxed/simple; bh=Fmb/nG+uD0XTG4I2Ot3fwepT/zZC/OX2GMKcSIhtlwQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tOS0uu/ZFCpCV3d11P0mIAhVj7/lK61x6DOOQgu2Jlu3Qe7nsPpsu6F9mPOruNMQVuFfbl/m3mLtbT/YuKByD4F+Ng1DAJWtOV8hA6tkGf6O3DdiG++z1MOBBvITrtz3w2uKREWk7h17FZCoTYGBEJsPTJxSjuNH4ECKYR/6qQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=gHkHqXHr; arc=none smtp.client-ip=198.47.19.246 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="gHkHqXHr" Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllvem-ot04.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 50DMtVto3760652 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jan 2025 16:55:31 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1736808931; bh=ojOuWESO9FkVlOtfgnqTVX+eAvMKTt16l2Utsyj+/EM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=gHkHqXHropckwdylTndJLGnd6lh+ulVwgg7/kd6RPhre1cwbAp3hoFbskzh5aTTp4 Jx3ObbXariSKS6+6nXw3KZJATPkHmtYIPPvkFW2iJ95xp/cL0yKc0AA7kMjvC43Q24 yv5fmAeYOkUFDNT3Vlbz5CyhX0uouNSp5apfzXoo= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 50DMtVJq037814 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 13 Jan 2025 16:55:31 -0600 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 13 Jan 2025 16:55:30 -0600 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 13 Jan 2025 16:55:30 -0600 Received: from DMZ007XYY.dhcp.ti.com (dmz007xyy.dhcp.ti.com [128.247.29.11]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 50DMtU57047817; Mon, 13 Jan 2025 16:55:30 -0600 From: Shree Ramamoorthy To: , , , , , , , , , CC: , , Subject: [PATCH v3 3/3] gpio tps65215: Add support for varying gpio/offset values Date: Mon, 13 Jan 2025 16:55:30 -0600 Message-ID: <20250113225530.124213-4-s-ramamoorthy@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250113225530.124213-1-s-ramamoorthy@ti.com> References: <20250113225530.124213-1-s-ramamoorthy@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea Content-Type: text/plain; charset="utf-8" Add device-specific structs to select the different PMIC .npgio and .offset values. With the chip_data struct values selected based on the match data, having a separate GPIO0_OFFSET macro is no longer needed. Signed-off-by: Shree Ramamoorthy --- drivers/gpio/gpio-tps65219.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c index 70a4410c473a..f2d8fd65d422 100644 --- a/drivers/gpio/gpio-tps65219.c +++ b/drivers/gpio/gpio-tps65219.c @@ -13,7 +13,6 @@ #include =20 #define TPS65219_GPIO0_DIR_MASK BIT(3) -#define TPS65219_GPIO0_OFFSET 2 #define TPS6521X_GPIO0_IDX 0 =20 struct tps65219_gpio { @@ -21,6 +20,11 @@ struct tps65219_gpio { struct tps65219 *tps; }; =20 +struct tps65219_chip_data { + int ngpio; + int offset; +}; + static int tps65219_gpio_get_direction(struct gpio_chip *gc, unsigned int = offset) { struct tps65219_gpio *gpio =3D gpiochip_get_data(gc); @@ -71,7 +75,7 @@ static void tps65219_gpio_set(struct gpio_chip *gc, unsig= ned int offset, int val struct device *dev =3D gpio->tps->dev; int v, mask, bit; =20 - bit =3D (offset =3D=3D TPS6521X_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offs= et - 1; + bit =3D (offset =3D=3D TPS6521X_GPIO0_IDX) ? (gpio->gpio_chip.offset - 1)= : offset - 1; =20 mask =3D BIT(bit); v =3D value ? mask : 0; @@ -148,14 +152,28 @@ static const struct gpio_chip tps65219_template_chip = =3D { .get =3D tps65219_gpio_get, .set =3D tps65219_gpio_set, .base =3D -1, - .ngpio =3D 3, .can_sleep =3D true, }; =20 +static const struct tps65219_chip_data chip_info_table[] =3D { + [TPS65215] =3D { + .ngpio =3D 2, + .offset =3D 1, + }, + [TPS65219] =3D { + .ngpio =3D 3, + .offset =3D 2, + }, +}; + static int tps65219_gpio_probe(struct platform_device *pdev) { - struct tps65219 *tps =3D dev_get_drvdata(pdev->dev.parent); struct tps65219_gpio *gpio; + const struct tps65219_chip_data *pmic; + + struct tps65219 *tps =3D dev_get_drvdata(pdev->dev.parent); + enum pmic_id chip =3D platform_get_device_id(pdev)->driver_data; + pmic =3D &chip_info_table[chip]; =20 gpio =3D devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); if (!gpio) @@ -164,6 +182,8 @@ static int tps65219_gpio_probe(struct platform_device *= pdev) gpio->tps =3D tps; gpio->gpio_chip =3D tps65219_template_chip; gpio->gpio_chip.label =3D dev_name(&pdev->dev); + gpio->gpio_chip.ngpio =3D pmic->ngpio; + gpio->gpio_chip.offset =3D pmic->offset; gpio->gpio_chip.parent =3D tps->dev; =20 return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio_chip, gpio); --=20 2.43.0