Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * RSB driver for the X-Powers' Power Management ICs
0004  *
0005  * AXP20x typically comprises an adaptive USB-Compatible PWM charger, BUCK DC-DC
0006  * converters, LDOs, multiple 12-bit ADCs of voltage, current and temperature
0007  * as well as configurable GPIOs.
0008  *
0009  * This driver supports the RSB variants.
0010  *
0011  * Copyright (C) 2015 Chen-Yu Tsai
0012  *
0013  * Author: Chen-Yu Tsai <wens@csie.org>
0014  */
0015 
0016 #include <linux/acpi.h>
0017 #include <linux/err.h>
0018 #include <linux/mfd/axp20x.h>
0019 #include <linux/module.h>
0020 #include <linux/of.h>
0021 #include <linux/regmap.h>
0022 #include <linux/slab.h>
0023 #include <linux/sunxi-rsb.h>
0024 
0025 static int axp20x_rsb_probe(struct sunxi_rsb_device *rdev)
0026 {
0027     struct axp20x_dev *axp20x;
0028     int ret;
0029 
0030     axp20x = devm_kzalloc(&rdev->dev, sizeof(*axp20x), GFP_KERNEL);
0031     if (!axp20x)
0032         return -ENOMEM;
0033 
0034     axp20x->dev = &rdev->dev;
0035     axp20x->irq = rdev->irq;
0036     dev_set_drvdata(&rdev->dev, axp20x);
0037 
0038     ret = axp20x_match_device(axp20x);
0039     if (ret)
0040         return ret;
0041 
0042     axp20x->regmap = devm_regmap_init_sunxi_rsb(rdev, axp20x->regmap_cfg);
0043     if (IS_ERR(axp20x->regmap)) {
0044         ret = PTR_ERR(axp20x->regmap);
0045         dev_err(&rdev->dev, "regmap init failed: %d\n", ret);
0046         return ret;
0047     }
0048 
0049     return axp20x_device_probe(axp20x);
0050 }
0051 
0052 static void axp20x_rsb_remove(struct sunxi_rsb_device *rdev)
0053 {
0054     struct axp20x_dev *axp20x = sunxi_rsb_device_get_drvdata(rdev);
0055 
0056     axp20x_device_remove(axp20x);
0057 }
0058 
0059 static const struct of_device_id axp20x_rsb_of_match[] = {
0060     { .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
0061     { .compatible = "x-powers,axp803", .data = (void *)AXP803_ID },
0062     { .compatible = "x-powers,axp806", .data = (void *)AXP806_ID },
0063     { .compatible = "x-powers,axp809", .data = (void *)AXP809_ID },
0064     { .compatible = "x-powers,axp813", .data = (void *)AXP813_ID },
0065     { },
0066 };
0067 MODULE_DEVICE_TABLE(of, axp20x_rsb_of_match);
0068 
0069 static struct sunxi_rsb_driver axp20x_rsb_driver = {
0070     .driver = {
0071         .name   = "axp20x-rsb",
0072         .of_match_table = of_match_ptr(axp20x_rsb_of_match),
0073     },
0074     .probe  = axp20x_rsb_probe,
0075     .remove = axp20x_rsb_remove,
0076 };
0077 module_sunxi_rsb_driver(axp20x_rsb_driver);
0078 
0079 MODULE_DESCRIPTION("PMIC MFD sunXi RSB driver for AXP20X");
0080 MODULE_AUTHOR("Chen-Yu Tsai <wens@csie.org>");
0081 MODULE_LICENSE("GPL v2");