1 // SPDX-License-Identifier: GPL-2.0-only 2 3 #include <linux/dev_printk.h> 4 #include <linux/err.h> 5 #include <linux/i2c.h> 6 #include <linux/module.h> 7 #include <linux/regmap.h> 8 9 #include "core.h" 10 11 static int zl3073x_i2c_probe(struct i2c_client *client) 12 { 13 struct device *dev = &client->dev; 14 struct zl3073x_dev *zldev; 15 16 zldev = zl3073x_devm_alloc(dev); 17 if (IS_ERR(zldev)) 18 return PTR_ERR(zldev); 19 20 zldev->regmap = devm_regmap_init_i2c(client, &zl3073x_regmap_config); 21 if (IS_ERR(zldev->regmap)) 22 return dev_err_probe(dev, PTR_ERR(zldev->regmap), 23 "Failed to initialize regmap\n"); 24 25 return zl3073x_dev_probe(zldev); 26 } 27 28 static const struct i2c_device_id zl3073x_i2c_id[] = { 29 { "zl30731" }, 30 { "zl30732" }, 31 { "zl30733" }, 32 { "zl30734" }, 33 { "zl30735" }, 34 { /* sentinel */ } 35 }; 36 MODULE_DEVICE_TABLE(i2c, zl3073x_i2c_id); 37 38 static const struct of_device_id zl3073x_i2c_of_match[] = { 39 { .compatible = "microchip,zl30731" }, 40 { .compatible = "microchip,zl30732" }, 41 { .compatible = "microchip,zl30733" }, 42 { .compatible = "microchip,zl30734" }, 43 { .compatible = "microchip,zl30735" }, 44 { /* sentinel */ } 45 }; 46 MODULE_DEVICE_TABLE(of, zl3073x_i2c_of_match); 47 48 static struct i2c_driver zl3073x_i2c_driver = { 49 .driver = { 50 .name = "zl3073x-i2c", 51 .of_match_table = zl3073x_i2c_of_match, 52 }, 53 .probe = zl3073x_i2c_probe, 54 .id_table = zl3073x_i2c_id, 55 }; 56 module_i2c_driver(zl3073x_i2c_driver); 57 58 MODULE_AUTHOR("Ivan Vecera <ivecera@redhat.com>"); 59 MODULE_DESCRIPTION("Microchip ZL3073x I2C driver"); 60 MODULE_IMPORT_NS("ZL3073X"); 61 MODULE_LICENSE("GPL"); 62