From patchwork Fri Apr 25 20:33:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shree Ramamoorthy X-Patchwork-Id: 884620 Received: from lelvem-ot01.ext.ti.com (lelvem-ot01.ext.ti.com [198.47.23.234]) (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 B4B1521FF28; Fri, 25 Apr 2025 20:33:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.23.234 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745613234; cv=none; b=nfZONe0VmuLVChHtEf89T89gF8BD9qYZxC0iKEEFHD29ESTSKEgz3fO2RsHLql3QX445Eem4YHJEUN6kEGB/IJec+2wRlpctCXJ3Xh0l+aCdbKBQPWu5tRvAJD+d9y4tVSyudCivQo9f0dkV7ScWC9V/3pIDpXf9LzWEvrVxYaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745613234; c=relaxed/simple; bh=fpsALeurDplFEDYi6Y4/YldvSEypIcvFuNMmHGuVBSI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=o/Uk2aJisQiZEWui6P829BpLfR2hYAwk4n99K7qbaRNh4iOS7rWi/c02SMh1IMI2f/dQzsNdg3DGa5B96FYAzW2yO3ri79zZ5ou31JiViam4kJwjuC6krgb/ZOXTplAgz+I5hC5NU3KGhtjXpLjofDEFijvozA4Gv7LpebR6UzQ= 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=UcDTxIVs; arc=none smtp.client-ip=198.47.23.234 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="UcDTxIVs" Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelvem-ot01.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53PKXGs22253043 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Apr 2025 15:33:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1745613196; bh=ol88Fhen3dkSnlD6MynWEnaah8tYj6NinLGb/qYvyt0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=UcDTxIVsdC0e//h/CaTOHBC4+hoDPk9EcQSIJpfVtbSCGUdIZEocXMY8kn9TgQlZE T6b4H/U4znCYfnelUez/pr9mdAAI33dR1pGegLDESIxXY/af4Vzag6vi/URe/d3Cdx Qu1ANZ6Lt4xBePKfeWEM/Ge2xaZ66lQEBHWnqlVM= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53PKXGeE048883 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 15:33:16 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) 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; Fri, 25 Apr 2025 15:33:15 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DLEE104.ent.ti.com (157.170.170.34) 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; Fri, 25 Apr 2025 15:33:15 -0500 Received: from DMZ007XYY.dhcp.ti.com (dmz007xyy.dhcp.ti.com [128.247.29.251]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53PKXFbW054212; Fri, 25 Apr 2025 15:33:15 -0500 From: Shree Ramamoorthy To: , , , , , , , , , CC: , Subject: [PATCH v4 1/3] gpio: tps65219: Add TPS65215 to platform_device_id table Date: Fri, 25 Apr 2025 15:33:13 -0500 Message-ID: <20250425203315.71497-2-s-ramamoorthy@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425203315.71497-1-s-ramamoorthy@ti.com> References: <20250425203315.71497-1-s-ramamoorthy@ti.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea 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..996f8deaf03d 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/ */ #include @@ -141,7 +141,6 @@ static int tps65219_gpio_direction_output(struct gpio_chip *gc, unsigned int off } static const struct gpio_chip tps65219_template_chip = { - .label = "tps65219-gpio", .owner = THIS_MODULE, .get_direction = tps65219_gpio_get_direction, .direction_input = tps65219_gpio_direction_input, @@ -164,20 +163,28 @@ static int tps65219_gpio_probe(struct platform_device *pdev) gpio->tps = tps; gpio->gpio_chip = tps65219_template_chip; + gpio->gpio_chip.label = dev_name(&pdev->dev); gpio->gpio_chip.parent = tps->dev; return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio_chip, gpio); } +static const struct platform_device_id tps6521x_gpio_id_table[] = { + { "tps65215-gpio", TPS65215 }, + { "tps65219-gpio", TPS65219 }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, tps6521x_gpio_id_table); + static struct platform_driver tps65219_gpio_driver = { .driver = { .name = "tps65219-gpio", }, .probe = tps65219_gpio_probe, + .id_table = tps6521x_gpio_id_table, }; module_platform_driver(tps65219_gpio_driver); -MODULE_ALIAS("platform:tps65219-gpio"); MODULE_AUTHOR("Jonathan Cormier "); -MODULE_DESCRIPTION("TPS65219 GPIO driver"); +MODULE_DESCRIPTION("TPS65215/TPS65219 GPIO driver"); MODULE_LICENSE("GPL"); From patchwork Fri Apr 25 20:33:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shree Ramamoorthy X-Patchwork-Id: 884621 Received: from fllvem-ot03.ext.ti.com (fllvem-ot03.ext.ti.com [198.47.19.245]) (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 E5D15186E20; Fri, 25 Apr 2025 20:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.245 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745613227; cv=none; b=pRbaeQy9FLzbJKFFXuF/59FWlER4Phfzl3Wz9PIA5gYc384zvxY3MpAsCDXurDO+CTvTt011aTyOU58QWTshT5q66fWbKZJHvyBvzdzNpNQPW9kM0IZ7bJ3A8Fp0kJeKL3tI98skdu87EOkm05F7yZBCExq+Hcg+b+reQyyKxCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745613227; c=relaxed/simple; bh=a2fd/ouzR5gQ0KPu5a9x2xFjwchY9cXrpbjCfSslLlQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QXt8thz+JFkcsTnq86WR5M/CJfEyCvOowvtYqBT/d8JUIohYrxvJ2sDn7G8f7l+Mlgspcs9a5j2muKnNMxACuYZQJV1rFHtgqnWxyXo0KaRbw3sIhq8CXvcg5H0Q8xAOdDNgaQCkWHanIqv8U5Xi5xRK+zAHsD/RwhJ1xLdWxKI= 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=aPSGwDaP; arc=none smtp.client-ip=198.47.19.245 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="aPSGwDaP" Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllvem-ot03.ext.ti.com (8.15.2/8.15.2) with ESMTPS id 53PKXG9x2267843 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Apr 2025 15:33:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1745613196; bh=WVKldgf/yjRpef/BpS7lZTdEVRLPxQjIE5A/hLeZScY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=aPSGwDaPDCxkNvpn9lNszcBI0RzOODuGG3NuErDopzuDIWlGCBYYDrPvBxF1eSUF2 CQxgOxbalTGpRFvdGSnV7BuBQxPkjCFUmEHDrPGBZcq9S5KpaukxKbcSnGio3kqJhk emQHcnHBg7XF04KQguSfTzAhvnv75xKSPaXbhKNw= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 53PKXGHD019855 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Apr 2025 15:33:16 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 25 Apr 2025 15:33:15 -0500 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE115.ent.ti.com (10.64.6.36) 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; Fri, 25 Apr 2025 15:33:15 -0500 Received: from DMZ007XYY.dhcp.ti.com (dmz007xyy.dhcp.ti.com [128.247.29.251]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 53PKXFbY054212; Fri, 25 Apr 2025 15:33:15 -0500 From: Shree Ramamoorthy To: , , , , , , , , , CC: , Subject: [PATCH v4 3/3] gpio: tps65219: Add support for varying gpio/offset values Date: Fri, 25 Apr 2025 15:33:15 -0500 Message-ID: <20250425203315.71497-4-s-ramamoorthy@ti.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425203315.71497-1-s-ramamoorthy@ti.com> References: <20250425203315.71497-1-s-ramamoorthy@ti.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea 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 | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-tps65219.c b/drivers/gpio/gpio-tps65219.c index a5a9dfdb214c..c971deac8619 100644 --- a/drivers/gpio/gpio-tps65219.c +++ b/drivers/gpio/gpio-tps65219.c @@ -13,7 +13,6 @@ #include #define TPS65219_GPIO0_DIR_MASK BIT(3) -#define TPS65219_GPIO0_OFFSET 2 #define TPS6521X_GPIO0_IDX 0 struct tps65219_gpio { @@ -21,6 +20,11 @@ struct tps65219_gpio { struct tps65219 *tps; }; +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 = gpiochip_get_data(gc); @@ -71,7 +75,7 @@ static void tps65219_gpio_set(struct gpio_chip *gc, unsigned int offset, int val struct device *dev = gpio->tps->dev; int v, mask, bit; - bit = (offset == TPS6521X_GPIO0_IDX) ? TPS65219_GPIO0_OFFSET : offset - 1; + bit = (offset == TPS6521X_GPIO0_IDX) ? (gpio->gpio_chip.offset - 1) : offset - 1; mask = BIT(bit); v = value ? mask : 0; @@ -148,14 +152,29 @@ static const struct gpio_chip tps65219_template_chip = { .get = tps65219_gpio_get, .set = tps65219_gpio_set, .base = -1, - .ngpio = 3, .can_sleep = true, }; +static const struct tps65219_chip_data chip_info_table[] = { + [TPS65215] = { + .ngpio = 2, + .offset = 1, + }, + [TPS65219] = { + .ngpio = 3, + .offset = 2, + }, +}; + static int tps65219_gpio_probe(struct platform_device *pdev) { - struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent); struct tps65219_gpio *gpio; + const struct tps65219_chip_data *pmic; + + struct tps65219 *tps = dev_get_drvdata(pdev->dev.parent); + enum pmic_id chip = platform_get_device_id(pdev)->driver_data; + + pmic = &chip_info_table[chip]; gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); if (!gpio) @@ -164,6 +183,8 @@ static int tps65219_gpio_probe(struct platform_device *pdev) gpio->tps = tps; gpio->gpio_chip = tps65219_template_chip; gpio->gpio_chip.label = dev_name(&pdev->dev); + gpio->gpio_chip.ngpio = pmic->ngpio; + gpio->gpio_chip.offset = pmic->offset; gpio->gpio_chip.parent = tps->dev; return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio_chip, gpio);