From patchwork Thu Nov 7 23:02:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13867271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D2F0D5D699 for ; Thu, 7 Nov 2024 23:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=l4jpQRHA2wXLqR7H/sC/XWgVEchK+V9PTWhYv9dnidY=; b=yL9EBShyKf5n71TSf0Qqm8+FGM c3FQ5uKCvKIRYPAEbIXITIi8P6g/EkSWWWZxk+RsAPhqxXVCZS5cmMfVsbiOmQYD3QfIx4HCOVdWx SM9VBc2EvicE2mbY9bEU+llPh5hmKHKGpYuqaHdwhevzo1imtMqLwVS1pLYK7vyVPFvMZl46Ulktd v4qxGHnS5t3cfbmOoioaOJPNsMsHy/UN21kj1JkH1r6oMQEY2/miPcqB27NwP132xP0cOc4IIJBdJ /xC1tyBJgW5btEUiFVs+8Go9RCGpEuGXvZvHAz7pl2UqaF+pmtUXY0/3EwHpRD1Vo8p5NOFbd9B+B 8rAARv2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t9BcF-00000008eYQ-0NZY; Thu, 07 Nov 2024 23:08:39 +0000 Received: from mail-vi1eur02on20620.outbound.protection.outlook.com ([2a01:111:f403:2607::620] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t9BXD-00000008dNe-0AHi for linux-arm-kernel@lists.infradead.org; Thu, 07 Nov 2024 23:03:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i4jkRzhMOL48P4zKJlB/CNM+7k8Do9JtDFJyStTwuzBQYj7Rs6ZuEqQuJhLlmTkrvKBSuIr98w/tDWuDhlcqRs5kyn5JV+ep94jbXNr3E9CrpTogeR4Om0h4vWa9skcaWk5FtlgL6qV4dhTc8Cp+MntggR980Y5tA593XL6EY7bF5N4NhLHpQ+waZuIlnl1VXg43BJQNPondku2WGOe+RXCpXHitjYrfKoNpM5P0Xxs4NZjSakgATvsPFWiQtTqYqNKFATr+H4cwn2k1ol+qFp7SbaBlznX+J5OOYAZ82NF/PZBjNFVYA9mRPf5GE/lzFgb7uYDd3WOvokzvCHT8tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l4jpQRHA2wXLqR7H/sC/XWgVEchK+V9PTWhYv9dnidY=; b=gTT9On9BVeaRStE2q/VW7hWQ1iTvzx3hn3zv0ww2gG52JAm0WdQhp9iqPd48D0Yy6CR1AgcXZeT99AaAFioO/y5/kILG/hnjPIDLpEJzlAiW79+UahDA4WGSekZ4dC1d79Wog42QHIeF0S4iAzpty/fUTl0dBxqbptESExD5VWAnwj3ARKxIZ+bfUfcbm9ct4V7ET5olEdi+pB2x3BWp5hL7HmY+baBa0EGH4hoKfsdDZ4VCCHA3pdigeFiksM//Z646HGCbrfNKjts34IZGjCqw70XroPYQSIaV5kgNIGqhgCGYPZcDsE4Ym+YcORMZ7ZxQsXf5BXMTq7PGvFWtlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l4jpQRHA2wXLqR7H/sC/XWgVEchK+V9PTWhYv9dnidY=; b=S6PrkWjGJk2sXr3fmjM6iFCyS/tyC/ZNIrcYxXYgpy2IHI9s9Y0QXsI18D3b9gm9kZxMVc81yYjZb6ZYCerwnZofPz/V9idC/fcPDCrtRGumYvmxFgRglpW9n8uMQ0Enyocx8/3lBnZptxLcjcyGIPBOQceyilnDZUHa52dqExG/Yjw7j9UEQeWzTVp3i177xGC/ueWXddC/RyB8sPuQiTdkyzg3yzpGgYe9O6+NLCV9oTt3S8i5FvnI1IksEaLJuWqoPzioeqFm2XcIVyzcUQJWO89jGD1x/jvUt5yY/fp098mjdlIPfHmPRNrkVvear98Sci7w9wkhW8t7qgwjDg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM0PR04MB6851.eurprd04.prod.outlook.com (2603:10a6:208:182::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.18; Thu, 7 Nov 2024 23:03:22 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8137.018; Thu, 7 Nov 2024 23:03:22 +0000 From: Frank Li Date: Thu, 07 Nov 2024 18:02:28 -0500 Subject: [PATCH 2/3] iio: temperature: Add support for P3T1085 Message-Id: <20241107-p3t1085-v1-2-9a76cb85673f@nxp.com> References: <20241107-p3t1085-v1-0-9a76cb85673f@nxp.com> In-Reply-To: <20241107-p3t1085-v1-0-9a76cb85673f@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Cameron , Lars-Peter Clausen , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Frank Li , Carlos Song , Clark Wang X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1731020590; l=10073; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Sz9Q+6YHuWSvSb3gpsYVOO4SXJ4eqmHsQQa4pS5GzUk=; b=lsoTv4hN1Ve8RM+YdWsugsKlVV4t11d86e/xmDqtTx/XXjnpB0MZPuIdogPoVshikHUZSBvVk kPTnK070/emAOCCNRMnqdl1DQSn8oBwpJCvHEWk+WJmd6L7h5UyHImV X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0094.namprd05.prod.outlook.com (2603:10b6:a03:334::9) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM0PR04MB6851:EE_ X-MS-Office365-Filtering-Correlation-Id: c2739906-3d82-42e0-3cb6-08dcff80607b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|7416014|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?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+qK8pODtUFG0RlhPtnar1cUkkGyLkF4q?= =?utf-8?q?JD2zmrw9ucO46XsGQ8zu/1mroeyHpc3ixRrffFd1ae0bT+hySiFgZiXBujLi4yown?= =?utf-8?q?T3FwJbBKdr9MJxuvn+PGXk9AySo/hfcUksgaPAT8yg1r76ZDL+zcYzlUH+bt6Kbhl?= =?utf-8?q?n5epzvm274Ss5Afvyi3d09/45X+G/nsk5p5MrB9aQ/8ej5AxA/HW2I/4v7jDJ1i4/?= =?utf-8?q?5/TAAM+a4tLzrY7RgJD47/w9fcB46OUfqHk67IgkOmyuIrjL5KGh6elFpXCS6i9dD?= =?utf-8?q?xP/hRGvHiBDoTsHuqwAHEURNHLjMq6AdUYstoUkTgQ3C1yXsoascdrxPVaz5mMJ4t?= =?utf-8?q?eAldMdqS+XJ42P7HYUUfpMrrb1p2ayWL0WyF7uZbXdG+Nj+6ZSbURwdezB5PfExfH?= =?utf-8?q?j+Af2/C4MBrFF7+durG1+DjxyzlBd2eu+1qyBqTiWFyErfOE6LOCq92A=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(7416014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5rfUQwytbbseIOSjmzvKoGh1mE7V?= =?utf-8?q?l5/FZvylzZdLqpxGvDnGAUwwOfAejP0AQG6afIUui2PIeJ6o3s7JbwDYXsZkQ4LT7?= =?utf-8?q?4qLdNaIbN8bfhkSt0ggI36IxN+N7/2wzsuh+8BvUJ2cdH8Zc2UFLtLqI1SvChQN8L?= =?utf-8?q?r0Q7UA/LPvJl8k0xPFTuo+ZK5tcLPSasRSFKutCHJ0lg+H32N1cmvIIh/OrMUdfVI?= =?utf-8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4sN9DjoQKLGnBDIuo1nlxR/+EL5OkR4fpqeLkklubHO37mfg/wp1np?= =?utf-8?q?rZLRDr7U67hhoAhAw0Cm+rJUou8XrR2g4GPW8FHfFySXurinDMZLrR0JpRIht/NNb?= =?utf-8?q?4p4NsoMUhK1lGJgxes0LcZ58k+zqgexF7fzZji8IL9Z2JHHdjFYa6DHJ3I2lUQiKo?= =?utf-8?q?0/He3DKkM7VFBbnrXUWjUQQf8nVNsyOscKTJdAJglzjoCSMZMQ7mJ6zbfzqOv1lZ6?= =?utf-8?q?DGt98iLIPYlIOrw/XiPFtaV0de1wlqA8tImdynOF+I7KJb3vIUD26sG//h/+YhlKH?= =?utf-8?q?X5tU9ciAomepQGejj680LFlRECRbFIN+PQZKNTGfHmhWcJGJvJe+eJ6ogayGOsiRd?= =?utf-8?q?cmD65nyPAbuXf+qQYr8GMqgUkVjwSkXUduGSDz0tetzKsAvAVAiRkC57UdmuLjMrt?= =?utf-8?q?PiY0b7h8DQNb?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2739906-3d82-42e0-3cb6-08dcff80607b X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2024 23:03:22.0396 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iRVPMWvdlKcQ9n88JbbK4CHqeu2weYlzlkvBxSnMPdfXa1BdQHMRDIfQmbSCoy2eEvZpbQD/Nhe7Rp896hrFZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6851 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241107_150327_225895_DAB400EB X-CRM114-Status: GOOD ( 20.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Carlos Song Add basic function support for P3T1085 temperature sensor. P3T1085UK is a temperature-to-digital converter with a -40 °C to +125 °C range. The device can be communicated by a controller via the 2-wire serial I3C (up to 12.5 MHz) and I2C (up to 3.4 MHz) interface. Signed-off-by: Clark Wang Signed-off-by: Carlos Song Signed-off-by: Frank Li --- drivers/iio/temperature/Kconfig | 1 + drivers/iio/temperature/Makefile | 2 + drivers/iio/temperature/p3t/Kconfig | 29 +++++++++++ drivers/iio/temperature/p3t/Makefile | 5 ++ drivers/iio/temperature/p3t/p3t1085.h | 31 ++++++++++++ drivers/iio/temperature/p3t/p3t1085_core.c | 79 ++++++++++++++++++++++++++++++ drivers/iio/temperature/p3t/p3t1085_i2c.c | 68 +++++++++++++++++++++++++ drivers/iio/temperature/p3t/p3t1085_i3c.c | 59 ++++++++++++++++++++++ 8 files changed, 274 insertions(+) diff --git a/drivers/iio/temperature/Kconfig b/drivers/iio/temperature/Kconfig index 1244d8e17d504..7cdd49279aba2 100644 --- a/drivers/iio/temperature/Kconfig +++ b/drivers/iio/temperature/Kconfig @@ -182,4 +182,5 @@ config MCP9600 This driver can also be built as a module. If so, the module will be called mcp9600. +source "drivers/iio/temperature/p3t/Kconfig" endmenu diff --git a/drivers/iio/temperature/Makefile b/drivers/iio/temperature/Makefile index 07d6e65709f7f..d5e89c20d58b6 100644 --- a/drivers/iio/temperature/Makefile +++ b/drivers/iio/temperature/Makefile @@ -19,3 +19,5 @@ obj-$(CONFIG_TMP007) += tmp007.o obj-$(CONFIG_TMP117) += tmp117.o obj-$(CONFIG_TSYS01) += tsys01.o obj-$(CONFIG_TSYS02D) += tsys02d.o + +obj-y += p3t/ diff --git a/drivers/iio/temperature/p3t/Kconfig b/drivers/iio/temperature/p3t/Kconfig new file mode 100644 index 0000000000000..09e925024b66f --- /dev/null +++ b/drivers/iio/temperature/p3t/Kconfig @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config IIO_P3T1085 + tristate + depends on (I2C || I3C) + +config IIO_P3T1085_I2C + tristate "NXP P3T1085 temperature sensor I2C driver" + depends on I2C + select IIO_P3T1085 + select REGMAP_I2C + help + Say yes here to build support for NXP P3T1085 I2C temperature + sensor. + + To compile this driver as a module, choose M here: the module + will be called p3t1085_i2c + +config IIO_P3T1085_I3C + tristate "NXP P3T1085 temperature sensor I3C driver" + depends on I3C + select IIO_P3T1085 + select REGMAP_I3C + help + Say yes here to build support for NXP P3T1085 I3C temperature + sensor. + + To compile this driver as a module, choose M here: the module + will be called p3t1085_i3c diff --git a/drivers/iio/temperature/p3t/Makefile b/drivers/iio/temperature/p3t/Makefile new file mode 100644 index 0000000000000..21aaeb51e044d --- /dev/null +++ b/drivers/iio/temperature/p3t/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_IIO_P3T1085) += p3t1085_core.o +obj-$(CONFIG_IIO_P3T1085_I2C) += p3t1085_i2c.o +obj-$(CONFIG_IIO_P3T1085_I3C) += p3t1085_i3c.o diff --git a/drivers/iio/temperature/p3t/p3t1085.h b/drivers/iio/temperature/p3t/p3t1085.h new file mode 100644 index 0000000000000..b018a04e4aee4 --- /dev/null +++ b/drivers/iio/temperature/p3t/p3t1085.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * NXP P3T1085 Temperature Sensor Driver + * + * Copyright 2024 NXP + */ +#ifndef P3T1085_H +#define P3T1085_H + +#include +#include + +#define P3T1085_REG_TEMP 0x0 +#define P3T1085_REG_CFGR 0x1 +#define P3T1085_REG_HIGH_LIM 0x2 +#define P3T1085_REG_LOW_LIM 0x3 + +#define P3T1085_RESOLUTION_10UC 62500 + +enum p3t1085_hw_id { + P3T1085_ID, +}; + +struct p3t1085_data { + struct device *dev; + struct regmap *regmap; +}; + +int p3t1085_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap); + +#endif /* P3T1085_H */ diff --git a/drivers/iio/temperature/p3t/p3t1085_core.c b/drivers/iio/temperature/p3t/p3t1085_core.c new file mode 100644 index 0000000000000..4b00e606a6d04 --- /dev/null +++ b/drivers/iio/temperature/p3t/p3t1085_core.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * NXP P3T1085 Temperature Sensor Driver + * + * Copyright 2024 NXP + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "p3t1085.h" + +static int p3t1085_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *channel, int *val, + int *val2, long mask) +{ + struct p3t1085_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = regmap_read(data->regmap, P3T1085_REG_TEMP, val); + if (ret < 0) { + dev_err(data->dev, "failed to read temperature register\n"); + return ret; + } + *val = *val >> 4; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + +static const struct iio_chan_spec p3t1085_channels[] = { + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, +}; + +static const struct iio_info p3t1085_info = { + .read_raw = p3t1085_read_raw, +}; + +int p3t1085_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap) +{ + struct p3t1085_data *data; + struct iio_dev *iio_dev; + + iio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!iio_dev) + return -ENOMEM; + + data = iio_priv(iio_dev); + data->dev = dev; + data->regmap = regmap; + + iio_dev->name = "p3t1085"; + iio_dev->modes = INDIO_DIRECT_MODE; + iio_dev->info = &p3t1085_info; + + iio_dev->channels = p3t1085_channels; + iio_dev->num_channels = ARRAY_SIZE(p3t1085_channels); + + return devm_iio_device_register(dev, iio_dev); +} +EXPORT_SYMBOL_NS(p3t1085_probe, IIO_P3T1085); + +MODULE_AUTHOR("Xiaoning Wang "); +MODULE_DESCRIPTION("NXP P3T1085 driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/iio/temperature/p3t/p3t1085_i2c.c b/drivers/iio/temperature/p3t/p3t1085_i2c.c new file mode 100644 index 0000000000000..20e5f7a68dd9e --- /dev/null +++ b/drivers/iio/temperature/p3t/p3t1085_i2c.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * NXP P3T1085 Temperature Sensor Driver + * + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include + +#include "p3t1085.h" + +static const struct regmap_config p3t1085_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 16, +}; + +static int p3t1085_i2c_probe(struct i2c_client *client) +{ + const struct i2c_device_id *id; + struct regmap *regmap; + int ret; + + id = i2c_client_get_device_id(client); + if (!id) + return -EINVAL; + + regmap = devm_regmap_init_i2c(client, &p3t1085_i2c_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(&client->dev, PTR_ERR(regmap), + "Failed to register i2c regmap %ld\n", PTR_ERR(regmap)); + + ret = p3t1085_probe(&client->dev, client->irq, id->driver_data, regmap); + if (ret) + return dev_err_probe(&client->dev, ret, "Failed to probe\n"); + + return 0; +} + +static const struct of_device_id p3t1085_i2c_of_match[] = { + { .compatible = "nxp,p3t1085", }, + { } +}; +MODULE_DEVICE_TABLE(of, p3t1085_i2c_of_match); + +static const struct i2c_device_id p3t1085_i2c_id_table[] = { + { "p3t1085", P3T1085_ID }, + { } +}; +MODULE_DEVICE_TABLE(i2c, p3t1085_i2c_id_table); + +static struct i2c_driver p3t1085_driver = { + .driver = { + .name = "p3t1085_i2c", + .of_match_table = p3t1085_i2c_of_match, + }, + .probe = p3t1085_i2c_probe, + .id_table = p3t1085_i2c_id_table, +}; +module_i2c_driver(p3t1085_driver); + +MODULE_AUTHOR("Xiaoning Wang "); +MODULE_DESCRIPTION("NXP P3T1085 i2c driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(IIO_P3T1085); diff --git a/drivers/iio/temperature/p3t/p3t1085_i3c.c b/drivers/iio/temperature/p3t/p3t1085_i3c.c new file mode 100644 index 0000000000000..0007d79aa0a6d --- /dev/null +++ b/drivers/iio/temperature/p3t/p3t1085_i3c.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * NXP P3T1085 Temperature Sensor Driver + * + * Copyright 2024 NXP + */ +#include +#include +#include +#include +#include +#include +#include + +#include "p3t1085.h" + +static const struct i3c_device_id p3t1085_i3c_ids[] = { + I3C_DEVICE(0x011B, 0x1529, (void *)P3T1085_ID), + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(i3c, p3t1085_i3c_ids); + +static int p3t1085_i3c_probe(struct i3c_device *i3cdev) +{ + const struct regmap_config p3t1085_i3c_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + }; + int ret; + + const struct i3c_device_id *id = i3c_device_match_id(i3cdev, + p3t1085_i3c_ids); + struct regmap *regmap; + + regmap = devm_regmap_init_i3c(i3cdev, &p3t1085_i3c_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(&i3cdev->dev, PTR_ERR(regmap), + "Failed to register i3c regmap\n"); + + ret = p3t1085_probe(&i3cdev->dev, 0, (uintptr_t)id->data, regmap); + if (ret) + return dev_err_probe(&i3cdev->dev, ret, "Failed to probe\n"); + + return 0; +} + +static struct i3c_driver p3t1085_driver = { + .driver = { + .name = "p3t1085_i3c", + }, + .probe = p3t1085_i3c_probe, + .id_table = p3t1085_i3c_ids, +}; +module_i3c_driver(p3t1085_driver); + +MODULE_AUTHOR("Xiaoning Wang "); +MODULE_DESCRIPTION("NXP p3t1085 i3c driver"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(IIO_P3T1085);