atc260x-i2c.c (1749B)
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * I2C bus interface for ATC260x PMICs 4 * 5 * Copyright (C) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 6 * Copyright (C) 2020 Cristian Ciocaltea <cristian.ciocaltea@gmail.com> 7 */ 8 9#include <linux/i2c.h> 10#include <linux/mfd/atc260x/core.h> 11#include <linux/module.h> 12#include <linux/of.h> 13#include <linux/regmap.h> 14 15static int atc260x_i2c_probe(struct i2c_client *client, 16 const struct i2c_device_id *id) 17{ 18 struct atc260x *atc260x; 19 struct regmap_config regmap_cfg; 20 int ret; 21 22 atc260x = devm_kzalloc(&client->dev, sizeof(*atc260x), GFP_KERNEL); 23 if (!atc260x) 24 return -ENOMEM; 25 26 atc260x->dev = &client->dev; 27 atc260x->irq = client->irq; 28 29 ret = atc260x_match_device(atc260x, ®map_cfg); 30 if (ret) 31 return ret; 32 33 i2c_set_clientdata(client, atc260x); 34 35 atc260x->regmap = devm_regmap_init_i2c(client, ®map_cfg); 36 if (IS_ERR(atc260x->regmap)) { 37 ret = PTR_ERR(atc260x->regmap); 38 dev_err(&client->dev, "failed to init regmap: %d\n", ret); 39 return ret; 40 } 41 42 return atc260x_device_probe(atc260x); 43} 44 45static const struct of_device_id atc260x_i2c_of_match[] = { 46 { .compatible = "actions,atc2603c", .data = (void *)ATC2603C }, 47 { .compatible = "actions,atc2609a", .data = (void *)ATC2609A }, 48 { } 49}; 50MODULE_DEVICE_TABLE(of, atc260x_i2c_of_match); 51 52static struct i2c_driver atc260x_i2c_driver = { 53 .driver = { 54 .name = "atc260x", 55 .of_match_table = of_match_ptr(atc260x_i2c_of_match), 56 }, 57 .probe = atc260x_i2c_probe, 58}; 59module_i2c_driver(atc260x_i2c_driver); 60 61MODULE_DESCRIPTION("ATC260x PMICs I2C bus interface"); 62MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>"); 63MODULE_AUTHOR("Cristian Ciocaltea <cristian.ciocaltea@gmail.com>"); 64MODULE_LICENSE("GPL");