^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2020 Rockchip Electronics Co. Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Author: Algea Cao <algea.cao@rock-chips.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mfd/rk630.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) rk630_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct device *dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct rk630 *rk630;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) rk630 = devm_kzalloc(dev, sizeof(*rk630), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) if (!rk630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) rk630->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) rk630->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) i2c_set_clientdata(client, rk630);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) rk630->grf = devm_regmap_init_i2c(client, &rk630_grf_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) if (IS_ERR(rk630->grf)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ret = PTR_ERR(rk630->grf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) dev_err(dev, "failed to allocate grf register map: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) rk630->cru = devm_regmap_init_i2c(client, &rk630_cru_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if (IS_ERR(rk630->cru)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) ret = PTR_ERR(rk630->cru);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) dev_err(dev, "failed to allocate cru register map: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) rk630->tve = devm_regmap_init_i2c(client, &rk630_tve_regmap_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (IS_ERR(rk630->tve)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) ret = PTR_ERR(rk630->tve);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) dev_err(rk630->dev, "Failed to initialize tve regmap: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return rk630_core_probe(rk630);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static const struct of_device_id rk630_i2c_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) { .compatible = "rockchip,rk630", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) MODULE_DEVICE_TABLE(of, rk630_i2c_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) static const struct i2c_device_id rk630_i2c_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) { "rk630", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) MODULE_DEVICE_TABLE(i2c, rk630_i2c_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) static struct i2c_driver rk630_i2c_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) .name = "rk630",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) .of_match_table = of_match_ptr(rk630_i2c_of_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) .probe = rk630_i2c_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) .id_table = rk630_i2c_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) module_i2c_driver(rk630_i2c_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) MODULE_AUTHOR("Algea Cao <Algea.cao@rock-chips.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) MODULE_DESCRIPTION("Rockchip rk630 MFD I2C driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) MODULE_LICENSE("GPL v2");