dpll: zl3073x: consolidate chip info and add temperature reporting
Subsystems (4)
Ivan Vecera
maintainercover dpll: zl3073x: consolidate chip info and add temperature reporting
This series refactors the ZL3073x chip variant handling and adds die temperature reporting for chips that support it.
Patch 1 replaces the five per-variant chip_info structures and their exported symbols with a single consolidated lookup table. The chip variant is now detected at runtime from the chip ID register rather than being selected at compile time via bus driver match data. This simplifies the I2C/SPI drivers and makes adding new variants a single-line table addition. A flags field replaces the hardcoded chip_id switch in zl3073x_dev_is_ref_phase_comp_32bit().
Patch 2 uses the new flags infrastructure to add die temperature reporting for chip variants that provide a temperature status register. The temp_get callback is conditionally set during device registration based on the ZL3073X_FLAG_DIE_TEMP chip flag.
Ivan Vecera (2):
dpll: zl3073x: detect DPLL channel count from chip ID at runtime
dpll: zl3073x: add die temperature reporting for supported chips
drivers/dpll/zl3073x/core.c | 118 ++++++++++-------------------------- drivers/dpll/zl3073x/core.h | 59 +++++++++--------- drivers/dpll/zl3073x/dpll.c | 28 ++++++++- drivers/dpll/zl3073x/dpll.h | 2 + drivers/dpll/zl3073x/i2c.c | 37 ++++------- drivers/dpll/zl3073x/regs.h | 2 + drivers/dpll/zl3073x/spi.c | 37 ++++------- 7 files changed, 113 insertions(+), 170 deletions(-)
Signature · 1 line
2.52.0
Ivan Vecera
maintainerPATCH 1/2 dpll: zl3073x: detect DPLL channel count from chip ID at runtime
Replace the five per-variant zl3073x_chip_info structures and their exported symbol definitions with a single consolidated chip ID lookup table. The chip variant is now detected at runtime by reading the chip ID register from hardware and looking it up in the table, rather than being selected at compile time via the bus driver match data.
Repurpose struct zl3073x_chip_info to hold a single chip ID, its channel count, and a flags field. Introduce enum zl3073x_flags with ZL3073X_FLAG_REF_PHASE_COMP_32 to replace the chip_id switch statement in zl3073x_dev_is_ref_phase_comp_32bit(). Store a pointer to the detected chip_info entry in struct zl3073x_dev for runtime access.
This simplifies the bus drivers by removing per-variant .data and .driver_data references from the I2C/SPI match tables, and makes adding support for new chip variants a single-line table addition.
--- drivers/dpll/zl3073x/core.c | 118 ++++++++++-------------------------- drivers/dpll/zl3073x/core.h | 57 +++++++++-------- drivers/dpll/zl3073x/i2c.c | 37 ++++------- drivers/dpll/zl3073x/spi.c | 37 ++++------- 4 files changed, 82 insertions(+), 167 deletions(-)
drivers/dpll/zl3073x/core.c +33 -85
@@ -20,79 +20,30 @@#include "dpll.h" #include "regs.h" -/* Chip IDs for zl30731 */ -static const u16 zl30731_ids[] = { -0x0E93 , -0x1E93 , -0x2E93 , +#define ZL_CHIP_INFO (_id, _nchannels, _flags) \ + { .id = (_id), .num_channels = (_nchannels), .flags = (_flags) } + +static const struct zl3073x_chip_info zl3073x_chip_ids[] = { +ZL_CHIP_INFO (0x0E30 ,2 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), +ZL_CHIP_INFO (0x0E93 ,1 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), +ZL_CHIP_INFO (0x0E94 ,2 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), +ZL_CHIP_INFO (0x0E95 ,3 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), +ZL_CHIP_INFO (0x0E96 ,4 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), +ZL_CHIP_INFO (0x0E97 ,5 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), +ZL_CHIP_INFO (0x1E93 ,1 ,0 ), +ZL_CHIP_INFO (0x1E94 ,2 ,0 ), +ZL_CHIP_INFO (0x1E95 ,3 ,0 ), +ZL_CHIP_INFO (0x1E96 ,4 ,0 ), +ZL_CHIP_INFO (0x1E97 ,5 ,0 ), +ZL_CHIP_INFO (0x1F60 ,2 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), +ZL_CHIP_INFO (0x2E93 ,1 ,0 ), +ZL_CHIP_INFO (0x2E94 ,2 ,0 ), +ZL_CHIP_INFO (0x2E95 ,3 ,0 ), +ZL_CHIP_INFO (0x2E96 ,4 ,0 ), +ZL_CHIP_INFO (0x2E97 ,5 ,0 ), +ZL_CHIP_INFO (0x3FC4 ,2 ,0 ), }; -const struct zl3073x_chip_info zl30731_chip_info = { - .ids = zl30731_ids, - .num_ids =ARRAY_SIZE (zl30731_ids), - .num_channels =1 , -}; -EXPORT_SYMBOL_NS_GPL (zl30731_chip_info,"ZL3073X" ); - -/* Chip IDs for zl30732 */ -static const u16 zl30732_ids[] = { -0x0E30 , -0x0E94 , -0x1E94 , -0x1F60 , -0x2E94 , -0x3FC4 , -}; - -const struct zl3073x_chip_info zl30732_chip_info = { - .ids = zl30732_ids, - .num_ids =ARRAY_SIZE (zl30732_ids), - .num_channels =2 , -}; -EXPORT_SYMBOL_NS_GPL (zl30732_chip_info,"ZL3073X" ); - -/* Chip IDs for zl30733 */ -static const u16 zl30733_ids[] = { -0x0E95 , -0x1E95 , -0x2E95 , -}; - -const struct zl3073x_chip_info zl30733_chip_info = { - .ids = zl30733_ids, - .num_ids =ARRAY_SIZE (zl30733_ids), - .num_channels =3 , -}; -EXPORT_SYMBOL_NS_GPL (zl30733_chip_info,"ZL3073X" ); - -/* Chip IDs for zl30734 */ -static const u16 zl30734_ids[] = { -0x0E96 , -0x1E96 , -0x2E96 , -}; - -const struct zl3073x_chip_info zl30734_chip_info = { - .ids = zl30734_ids, - .num_ids =ARRAY_SIZE (zl30734_ids), - .num_channels =4 , -}; -EXPORT_SYMBOL_NS_GPL (zl30734_chip_info,"ZL3073X" ); - -/* Chip IDs for zl30735 */ -static const u16 zl30735_ids[] = { -0x0E97 , -0x1E97 , -0x2E97 , -}; - -const struct zl3073x_chip_info zl30735_chip_info = { - .ids = zl30735_ids, - .num_ids =ARRAY_SIZE (zl30735_ids), - .num_channels =5 , -}; -EXPORT_SYMBOL_NS_GPL (zl30735_chip_info,"ZL3073X" ); -#define ZL_RANGE_OFFSET 0x80#define ZL_PAGE_SIZE 0x80#define ZL_NUM_PAGES 256
@@ -942,7 +893,7 @@ static void zl3073x_dev_dpll_fini(void *ptr) }static int -zl3073x_devm_dpll_init (struct zl3073x_dev *zldev,u8 num_dplls) +zl3073x_devm_dpll_init (struct zl3073x_dev *zldev) {struct kthread_worker *kworker;struct zl3073x_dpll *zldpll;
@@ -952,7 +903,7 @@ zl3073x_devm_dpll_init(struct zl3073x_dev *zldev, u8 num_dplls)INIT_LIST_HEAD (&zldev->dplls);/* Allocate all DPLLs */ -for (i =0 ; i < num_dplls; i++) { +for (i =0 ; i < zldev->info->num_channels; i++) { zldpll =zl3073x_dpll_alloc (zldev, i);if (IS_ERR (zldpll)) { dev_err_probe(zldev->dev, PTR_ERR(zldpll),
@@ -992,14 +943,12 @@ zl3073x_devm_dpll_init(struct zl3073x_dev *zldev, u8 num_dplls)/** * zl3073x_dev_probe - initialize zl3073x device * @zldev: pointer to zl3073x device -* @chip_info: chip info based on compatible * * Common initialization of zl3073x device structure. * * Returns: 0 on success, <0 on error */ -int zl3073x_dev_probe (struct zl3073x_dev *zldev, -const struct zl3073x_chip_info *chip_info) +int zl3073x_dev_probe (struct zl3073x_dev *zldev) {u16 id, revision, fw_ver;unsigned int i;
@@ -1011,18 +960,17 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,if (rc)return rc; -/* Check it matches */ -for (i =0 ; i < chip_info->num_ids; i++) { -if (id == chip_info->ids[i]) +/* Detect chip variant */ +for (i =0 ; i <ARRAY_SIZE (zl3073x_chip_ids); i++) { +if (zl3073x_chip_ids[i].id == id)break ; } -if (i == chip_info->num_ids) { +if (i ==ARRAY_SIZE (zl3073x_chip_ids))return dev_err_probe (zldev->dev, -ENODEV , -"Unknown or non-match chip ID: 0x%0x\n" , - id); - } - zldev->chip_id = id; +"Unknown chip ID: 0x%04x\n" , id); + + zldev->info = &zl3073x_chip_ids[i];/* Read revision, firmware version and custom config version */ rc =zl3073x_read_u16 (zldev,ZL_REG_REVISION , &revision);
@@ -1061,7 +1009,7 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev, "Failed to initialize mutex\n");/* Register DPLL channels */ - rc =zl3073x_devm_dpll_init (zldev, chip_info->num_channels); + rc =zl3073x_devm_dpll_init (zldev);if (rc)return rc;
drivers/dpll/zl3073x/core.h +27 -30
89 lines not on this page · raw message
drivers/dpll/zl3073x/i2c.c +11 -26
@@ -22,40 +22,25 @@ static int zl3073x_i2c_probe(struct i2c_client *client)return dev_err_probe (dev,PTR_ERR (zldev->regmap),"Failed to initialize regmap\n" ); -return zl3073x_dev_probe (zldev,i2c_get_match_data (client)); +return zl3073x_dev_probe (zldev); }static const struct i2c_device_id zl3073x_i2c_id[] = { - { - .name ="zl30731" , - .driver_data = (kernel_ulong_t)&zl30731_chip_info, - }, - { - .name ="zl30732" , - .driver_data = (kernel_ulong_t)&zl30732_chip_info, - }, - { - .name ="zl30733" , - .driver_data = (kernel_ulong_t)&zl30733_chip_info, - }, - { - .name ="zl30734" , - .driver_data = (kernel_ulong_t)&zl30734_chip_info, - }, - { - .name ="zl30735" , - .driver_data = (kernel_ulong_t)&zl30735_chip_info, - }, + {"zl30731" }, + {"zl30732" }, + {"zl30733" }, + {"zl30734" }, + {"zl30735" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (i2c, zl3073x_i2c_id);static const struct of_device_id zl3073x_i2c_of_match[] = { - { .compatible ="microchip,zl30731" , .data = &zl30731_chip_info }, - { .compatible ="microchip,zl30732" , .data = &zl30732_chip_info }, - { .compatible ="microchip,zl30733" , .data = &zl30733_chip_info }, - { .compatible ="microchip,zl30734" , .data = &zl30734_chip_info }, - { .compatible ="microchip,zl30735" , .data = &zl30735_chip_info }, + { .compatible ="microchip,zl30731" }, + { .compatible ="microchip,zl30732" }, + { .compatible ="microchip,zl30733" }, + { .compatible ="microchip,zl30734" }, + { .compatible ="microchip,zl30735" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, zl3073x_i2c_of_match);
drivers/dpll/zl3073x/spi.c +11 -26
@@ -22,40 +22,25 @@ static int zl3073x_spi_probe(struct spi_device *spi)return dev_err_probe (dev,PTR_ERR (zldev->regmap),"Failed to initialize regmap\n" ); -return zl3073x_dev_probe (zldev,spi_get_device_match_data (spi)); +return zl3073x_dev_probe (zldev); }static const struct spi_device_id zl3073x_spi_id[] = { - { - .name ="zl30731" , - .driver_data = (kernel_ulong_t)&zl30731_chip_info - }, - { - .name ="zl30732" , - .driver_data = (kernel_ulong_t)&zl30732_chip_info, - }, - { - .name ="zl30733" , - .driver_data = (kernel_ulong_t)&zl30733_chip_info, - }, - { - .name ="zl30734" , - .driver_data = (kernel_ulong_t)&zl30734_chip_info, - }, - { - .name ="zl30735" , - .driver_data = (kernel_ulong_t)&zl30735_chip_info, - }, + {"zl30731" }, + {"zl30732" }, + {"zl30733" }, + {"zl30734" }, + {"zl30735" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (spi, zl3073x_spi_id);static const struct of_device_id zl3073x_spi_of_match[] = { - { .compatible ="microchip,zl30731" , .data = &zl30731_chip_info }, - { .compatible ="microchip,zl30732" , .data = &zl30732_chip_info }, - { .compatible ="microchip,zl30733" , .data = &zl30733_chip_info }, - { .compatible ="microchip,zl30734" , .data = &zl30734_chip_info }, - { .compatible ="microchip,zl30735" , .data = &zl30735_chip_info }, + { .compatible ="microchip,zl30731" }, + { .compatible ="microchip,zl30732" }, + { .compatible ="microchip,zl30733" }, + { .compatible ="microchip,zl30734" }, + { .compatible ="microchip,zl30735" }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, zl3073x_spi_of_match);
Signature · 1 line
2.52.0
Ivan Vecera
maintainerPATCH 2/2 dpll: zl3073x: add die temperature reporting for supported chips
In reply to Ivan VeceraSome zl3073x chip variants (0x1Exx, 0x2Exx and 0x3FC4) provide a die temperature status register with 0.1 C resolution.
Add a ZL3073X_FLAG_DIE_TEMP chip flag to identify these variants and implement zl3073x_dpll_temp_get() as the dpll_device_ops.temp_get callback. The register value is converted from 0.1 C units to millidegrees as expected by the DPLL subsystem.
To support per-instance ops selection, copy the base dpll_device_ops into struct zl3073x_dpll and conditionally set .temp_get during device registration based on the chip flag.
--- drivers/dpll/zl3073x/core.c | 22 +++++++++++----------- drivers/dpll/zl3073x/core.h | 2 ++ drivers/dpll/zl3073x/dpll.c | 28 +++++++++++++++++++++++++--- drivers/dpll/zl3073x/dpll.h | 2 ++ drivers/dpll/zl3073x/regs.h | 2 ++ 5 files changed, 42 insertions(+), 14 deletions(-)
drivers/dpll/zl3073x/core.c +11 -11
@@ -30,18 +30,18 @@ static const struct zl3073x_chip_info zl3073x_chip_ids[] = {ZL_CHIP_INFO (0x0E95 ,3 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ),ZL_CHIP_INFO (0x0E96 ,4 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ),ZL_CHIP_INFO (0x0E97 ,5 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), -ZL_CHIP_INFO (0x1E93 ,1 ,0 ), -ZL_CHIP_INFO (0x1E94 ,2 ,0 ), -ZL_CHIP_INFO (0x1E95 ,3 ,0 ), -ZL_CHIP_INFO (0x1E96 ,4 ,0 ), -ZL_CHIP_INFO (0x1E97 ,5 ,0 ), +ZL_CHIP_INFO (0x1E93 ,1 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x1E94 ,2 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x1E95 ,3 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x1E96 ,4 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x1E97 ,5 ,ZL3073X_FLAG_DIE_TEMP ),ZL_CHIP_INFO (0x1F60 ,2 ,ZL3073X_FLAG_REF_PHASE_COMP_32 ), -ZL_CHIP_INFO (0x2E93 ,1 ,0 ), -ZL_CHIP_INFO (0x2E94 ,2 ,0 ), -ZL_CHIP_INFO (0x2E95 ,3 ,0 ), -ZL_CHIP_INFO (0x2E96 ,4 ,0 ), -ZL_CHIP_INFO (0x2E97 ,5 ,0 ), - ZL_CHIP_INFO(0x3FC4, 2, 0), +ZL_CHIP_INFO (0x2E93 ,1 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x2E94 ,2 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x2E95 ,3 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x2E96 ,4 ,ZL3073X_FLAG_DIE_TEMP ), +ZL_CHIP_INFO (0x2E97 ,5 ,ZL3073X_FLAG_DIE_TEMP ), + ZL_CHIP_INFO(0x3FC4, 2, ZL3073X_FLAG_DIE_TEMP), };#define ZL_RANGE_OFFSET 0x80
drivers/dpll/zl3073x/core.h +2 -0
@@ -32,11 +32,13 @@ struct zl3073x_dpll;enum zl3073x_flags {ZL3073X_FLAG_REF_PHASE_COMP_32_BIT , +ZL3073X_FLAG_DIE_TEMP_BIT ,ZL3073X_FLAGS_NBITS /* must be last */ };#define __ZL3073X_FLAG (name) BIT(ZL3073X_FLAG_ ## name ## _BIT)#define ZL3073X_FLAG_REF_PHASE_COMP_32 __ZL3073X_FLAG(REF_PHASE_COMP_32) +#define ZL3073X_FLAG_DIE_TEMP __ZL3073X_FLAG(DIE_TEMP)/** * struct zl3073x_chip_info - chip variant identification
drivers/dpll/zl3073x/dpll.c +25 -3
@@ -1065,6 +1065,25 @@ zl3073x_dpll_output_pin_state_on_dpll_get(const struct dpll_pin *dpll_pin,return 0 ; } +static int +zl3073x_dpll_temp_get (const struct dpll_device *dpll,void *dpll_priv, +s32 *temp,struct netlink_ext_ack *extack) +{ +struct zl3073x_dpll *zldpll = dpll_priv; +struct zl3073x_dev *zldev = zldpll->dev; +u16 val; +int rc; + + rc =zl3073x_read_u16 (zldev,ZL_REG_DIE_TEMP_STATUS , &val); +if (rc) +return rc; + +/* Register value is in units of 0.1 C, convert to millidegrees */ + *temp = (s16 )val *100 ; + +return 0 ; +} + static int zl3073x_dpll_lock_status_get(const struct dpll_device *dpll, void *dpll_priv, enum dpll_lock_status *status,
@@ -1671,6 +1690,10 @@ zl3073x_dpll_device_register(struct zl3073x_dpll *zldpll) zldpll->forced_ref =FIELD_GET (ZL_DPLL_MODE_REFSEL_REF , dpll_mode_refsel); + zldpll->ops = zl3073x_dpll_device_ops; +if (zldev->info->flags &ZL3073X_FLAG_DIE_TEMP ) + zldpll->ops.temp_get = zl3073x_dpll_temp_get; + zldpll->dpll_dev =dpll_device_get (zldev->clock_id, zldpll->id,THIS_MODULE , &zldpll->tracker);if (IS_ERR (zldpll->dpll_dev)) {
@@ -1682,7 +1705,7 @@ zl3073x_dpll_device_register(struct zl3073x_dpll *zldpll) rc =dpll_device_register (zldpll->dpll_dev,zl3073x_prop_dpll_type_get (zldev, zldpll->id), - &zl3073x_dpll_device_ops, zldpll); + &zldpll->ops, zldpll);if (rc) {dpll_device_put (zldpll->dpll_dev, &zldpll->tracker); zldpll->dpll_dev =NULL ;
@@ -1705,8 +1728,7 @@ zl3073x_dpll_device_unregister(struct zl3073x_dpll *zldpll)cancel_work_sync (&zldpll->change_work); -dpll_device_unregister (zldpll->dpll_dev, &zl3073x_dpll_device_ops, - zldpll); +dpll_device_unregister (zldpll->dpll_dev, &zldpll->ops, zldpll);dpll_device_put (zldpll->dpll_dev, &zldpll->tracker); zldpll->dpll_dev =NULL ; }
drivers/dpll/zl3073x/dpll.h +2 -0
@@ -17,6 +17,7 @@* @forced_ref: selected reference in forced reference lock mode * @check_count: periodic check counter * @phase_monitor: is phase offset monitor enabled +* @ops: DPLL device operations for this instance * @dpll_dev: pointer to registered DPLL device * @tracker: tracking object for the acquired reference * @lock_status: last saved DPLL lock status
@@ -31,6 +32,7 @@ struct zl3073x_dpll {u8 forced_ref;u8 check_count;bool phase_monitor; +struct dpll_device_ops ops;struct dpll_device *dpll_dev;dpll_tracker tracker;enum dpll_lock_status lock_status;
drivers/dpll/zl3073x/regs.h +2 -0
@@ -78,6 +78,8 @@#define ZL_REG_RESET_STATUS ZL_REG(0, 0x18, 1)#define ZL_REG_RESET_STATUS_RESET BIT(0) +#define ZL_REG_DIE_TEMP_STATUS ZL_REG(0, 0x44, 2) +/************************* * Register Page 2, Status *************************/
Signature · 1 line
2.52.0
Quoted 11 lines · Ivan Vecera
This series refactors the ZL3073x chip variant handling and adds die temperature reporting for chips that support it.
Patch 1 replaces the five per-variant
chip_infostructures and their exported symbols with a single consolidated lookup table. The chip variant is now detected at runtime from the chip ID register rather than being selected at compile time via bus driver match data. This simplifies the I2C/SPI drivers and makes adding new variants a single-line table addition. A flags field replaces the hardcodedchip_idswitch inzl3073x_dev_is_ref_phase_comp_32bit().
Quoted 8 lines
Patch 2 uses the new flags infrastructure to add die temperature reporting for chip variants that provide a temperature status register. The
temp_getcallback is conditionally set during device registration based on theZL3073X_FLAG_DIE_TEMPchip flag.Ivan Vecera (2):
dpll: zl3073x: detect DPLL channel count from chip ID at runtime
dpll: zl3073x: add die temperature reporting for supported chips
For the series,
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Fri, 27 Feb 2026 11:52:58 +0100 you wrote:
This series refactors the ZL3073x chip variant handling and adds die temperature reporting for chips that support it.
Patch 1 replaces the five per-variant
chip_infostructures and their exported symbols with a single consolidated lookup table. The chip variant is now detected at runtime from the chip ID register rather than being selected at compile time via bus driver match data. This simplifies the I2C/SPI drivers and makes adding new variants a single-line table addition. A flags field replaces the hardcodedchip_idswitch inzl3073x_dev_is_ref_phase_comp_32bit().
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,1/2] dpll: zl3073x: detect DPLL channel count from chip ID at runtime
https://git.kernel.org/netdev/net-next/c/4845f2fff730 - [net-next,2/2] dpll: zl3073x: add die temperature reporting for supported chips https://git.kernel.org/netdev/net-next/c/3a97e02b3e91
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html