linux/drivers/dpll/zl3073x/spi.c
Ivan Vecera 4845f2fff7 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.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Link: https://patch.msgid.link/20260227105300.710272-2-ivecera@redhat.com
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-03-03 12:15:30 +01:00

62 lines
1.5 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/spi/spi.h>
#include "core.h"
static int zl3073x_spi_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
struct zl3073x_dev *zldev;
zldev = zl3073x_devm_alloc(dev);
if (IS_ERR(zldev))
return PTR_ERR(zldev);
zldev->regmap = devm_regmap_init_spi(spi, &zl3073x_regmap_config);
if (IS_ERR(zldev->regmap))
return dev_err_probe(dev, PTR_ERR(zldev->regmap),
"Failed to initialize regmap\n");
return zl3073x_dev_probe(zldev);
}
static const struct spi_device_id zl3073x_spi_id[] = {
{ "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" },
{ .compatible = "microchip,zl30732" },
{ .compatible = "microchip,zl30733" },
{ .compatible = "microchip,zl30734" },
{ .compatible = "microchip,zl30735" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, zl3073x_spi_of_match);
static struct spi_driver zl3073x_spi_driver = {
.driver = {
.name = "zl3073x-spi",
.of_match_table = zl3073x_spi_of_match,
},
.probe = zl3073x_spi_probe,
.id_table = zl3073x_spi_id,
};
module_spi_driver(zl3073x_spi_driver);
MODULE_AUTHOR("Ivan Vecera <ivecera@redhat.com>");
MODULE_DESCRIPTION("Microchip ZL3073x SPI driver");
MODULE_IMPORT_NS("ZL3073X");
MODULE_LICENSE("GPL");