mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
Merge branches 'ib-mfd-clk-4.6', 'ib-mfd-input-iio-4.6', 'ib-mfd-regulator-4.6' and 'ib-mfd-regulator-gpio-4.6' into ibs-for-mfd-merged
This commit is contained in:
commit
bab070620e
30 changed files with 2384 additions and 1368 deletions
|
|
@ -91,14 +91,29 @@ config MFD_BCM590XX
|
|||
Support for the BCM590xx PMUs from Broadcom
|
||||
|
||||
config MFD_AXP20X
|
||||
bool "X-Powers AXP20X"
|
||||
tristate
|
||||
select MFD_CORE
|
||||
select REGMAP_I2C
|
||||
select REGMAP_IRQ
|
||||
depends on I2C=y
|
||||
|
||||
config MFD_AXP20X_I2C
|
||||
tristate "X-Powers AXP series PMICs with I2C"
|
||||
select MFD_AXP20X
|
||||
select REGMAP_I2C
|
||||
depends on I2C
|
||||
help
|
||||
If you say Y here you get support for the X-Powers AXP202, AXP209 and
|
||||
AXP288 power management IC (PMIC).
|
||||
If you say Y here you get support for the X-Powers AXP series power
|
||||
management ICs (PMICs) controlled with I2C.
|
||||
This driver include only the core APIs. You have to select individual
|
||||
components like regulators or the PEK (Power Enable Key) under the
|
||||
corresponding menus.
|
||||
|
||||
config MFD_AXP20X_RSB
|
||||
tristate "X-Powers AXP series PMICs with RSB"
|
||||
select MFD_AXP20X
|
||||
depends on SUNXI_RSB
|
||||
help
|
||||
If you say Y here you get support for the X-Powers AXP series power
|
||||
management ICs (PMICs) controlled with RSB.
|
||||
This driver include only the core APIs. You have to select individual
|
||||
components like regulators or the PEK (Power Enable Key) under the
|
||||
corresponding menus.
|
||||
|
|
@ -271,6 +286,15 @@ config MFD_MC13XXX_I2C
|
|||
help
|
||||
Select this if your MC13xxx is connected via an I2C bus.
|
||||
|
||||
config MFD_MX25_TSADC
|
||||
tristate "Freescale i.MX25 integrated Touchscreen and ADC unit"
|
||||
select REGMAP_MMIO
|
||||
depends on (SOC_IMX25 && OF) || COMPILE_TEST
|
||||
help
|
||||
Enable support for the integrated Touchscreen and ADC unit of the
|
||||
i.MX25 processors. They consist of a conversion queue for general
|
||||
purpose ADC and a queue for Touchscreens.
|
||||
|
||||
config MFD_HI6421_PMIC
|
||||
tristate "HiSilicon Hi6421 PMU/Codec IC"
|
||||
depends on OF
|
||||
|
|
@ -1181,27 +1205,25 @@ config MFD_TPS65910
|
|||
Power Management chips.
|
||||
|
||||
config MFD_TPS65912
|
||||
bool "TI TPS65912 Power Management chip"
|
||||
depends on GPIOLIB
|
||||
tristate
|
||||
select MFD_CORE
|
||||
help
|
||||
If you say yes here you get support for the TPS65912 series of
|
||||
PM chips.
|
||||
select REGMAP
|
||||
select REGMAP_IRQ
|
||||
|
||||
config MFD_TPS65912_I2C
|
||||
bool "TI TPS65912 Power Management chip with I2C"
|
||||
select MFD_CORE
|
||||
tristate "TI TPS65912 Power Management chip with I2C"
|
||||
select MFD_TPS65912
|
||||
depends on I2C=y && GPIOLIB
|
||||
select REGMAP_I2C
|
||||
depends on I2C
|
||||
help
|
||||
If you say yes here you get support for the TPS65912 series of
|
||||
PM chips with I2C interface.
|
||||
|
||||
config MFD_TPS65912_SPI
|
||||
bool "TI TPS65912 Power Management chip with SPI"
|
||||
select MFD_CORE
|
||||
tristate "TI TPS65912 Power Management chip with SPI"
|
||||
select MFD_TPS65912
|
||||
depends on SPI_MASTER && GPIOLIB
|
||||
select REGMAP_SPI
|
||||
depends on SPI_MASTER
|
||||
help
|
||||
If you say yes here you get support for the TPS65912 series of
|
||||
PM chips with SPI interface.
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@ obj-$(CONFIG_TPS6507X) += tps6507x.o
|
|||
obj-$(CONFIG_MFD_TPS65217) += tps65217.o
|
||||
obj-$(CONFIG_MFD_TPS65218) += tps65218.o
|
||||
obj-$(CONFIG_MFD_TPS65910) += tps65910.o
|
||||
tps65912-objs := tps65912-core.o tps65912-irq.o
|
||||
obj-$(CONFIG_MFD_TPS65912) += tps65912.o
|
||||
obj-$(CONFIG_MFD_TPS65912) += tps65912-core.o
|
||||
obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o
|
||||
obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o
|
||||
obj-$(CONFIG_MFD_TPS80031) += tps80031.o
|
||||
|
|
@ -85,6 +84,8 @@ obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o
|
|||
obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o
|
||||
obj-$(CONFIG_TWL6040_CORE) += twl6040.o
|
||||
|
||||
obj-$(CONFIG_MFD_MX25_TSADC) += fsl-imx25-tsadc.o
|
||||
|
||||
obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o
|
||||
obj-$(CONFIG_MFD_MC13XXX_SPI) += mc13xxx-spi.o
|
||||
obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o
|
||||
|
|
@ -111,6 +112,8 @@ obj-$(CONFIG_PMIC_DA9052) += da9052-core.o
|
|||
obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o
|
||||
obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o
|
||||
obj-$(CONFIG_MFD_AXP20X) += axp20x.o
|
||||
obj-$(CONFIG_MFD_AXP20X_I2C) += axp20x-i2c.o
|
||||
obj-$(CONFIG_MFD_AXP20X_RSB) += axp20x-rsb.o
|
||||
|
||||
obj-$(CONFIG_MFD_LP3943) += lp3943.o
|
||||
obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o
|
||||
|
|
|
|||
104
drivers/mfd/axp20x-i2c.c
Normal file
104
drivers/mfd/axp20x-i2c.c
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* I2C driver for the X-Powers' Power Management ICs
|
||||
*
|
||||
* AXP20x typically comprises an adaptive USB-Compatible PWM charger, BUCK DC-DC
|
||||
* converters, LDOs, multiple 12-bit ADCs of voltage, current and temperature
|
||||
* as well as configurable GPIOs.
|
||||
*
|
||||
* This driver supports the I2C variants.
|
||||
*
|
||||
* Copyright (C) 2014 Carlo Caione
|
||||
*
|
||||
* Author: Carlo Caione <carlo@caione.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mfd/axp20x.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
static int axp20x_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct axp20x_dev *axp20x;
|
||||
int ret;
|
||||
|
||||
axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
|
||||
if (!axp20x)
|
||||
return -ENOMEM;
|
||||
|
||||
axp20x->dev = &i2c->dev;
|
||||
axp20x->irq = i2c->irq;
|
||||
dev_set_drvdata(axp20x->dev, axp20x);
|
||||
|
||||
ret = axp20x_match_device(axp20x);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
axp20x->regmap = devm_regmap_init_i2c(i2c, axp20x->regmap_cfg);
|
||||
if (IS_ERR(axp20x->regmap)) {
|
||||
ret = PTR_ERR(axp20x->regmap);
|
||||
dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return axp20x_device_probe(axp20x);
|
||||
}
|
||||
|
||||
static int axp20x_i2c_remove(struct i2c_client *i2c)
|
||||
{
|
||||
struct axp20x_dev *axp20x = i2c_get_clientdata(i2c);
|
||||
|
||||
return axp20x_device_remove(axp20x);
|
||||
}
|
||||
|
||||
static const struct of_device_id axp20x_i2c_of_match[] = {
|
||||
{ .compatible = "x-powers,axp152", .data = (void *)AXP152_ID },
|
||||
{ .compatible = "x-powers,axp202", .data = (void *)AXP202_ID },
|
||||
{ .compatible = "x-powers,axp209", .data = (void *)AXP209_ID },
|
||||
{ .compatible = "x-powers,axp221", .data = (void *)AXP221_ID },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, axp20x_i2c_of_match);
|
||||
|
||||
/*
|
||||
* This is useless for OF-enabled devices, but it is needed by I2C subsystem
|
||||
*/
|
||||
static const struct i2c_device_id axp20x_i2c_id[] = {
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);
|
||||
|
||||
static const struct acpi_device_id axp20x_i2c_acpi_match[] = {
|
||||
{
|
||||
.id = "INT33F4",
|
||||
.driver_data = AXP288_ID,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, axp20x_i2c_acpi_match);
|
||||
|
||||
static struct i2c_driver axp20x_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "axp20x-i2c",
|
||||
.of_match_table = of_match_ptr(axp20x_i2c_of_match),
|
||||
.acpi_match_table = ACPI_PTR(axp20x_i2c_acpi_match),
|
||||
},
|
||||
.probe = axp20x_i2c_probe,
|
||||
.remove = axp20x_i2c_remove,
|
||||
.id_table = axp20x_i2c_id,
|
||||
};
|
||||
|
||||
module_i2c_driver(axp20x_i2c_driver);
|
||||
|
||||
MODULE_DESCRIPTION("PMIC MFD I2C driver for AXP20X");
|
||||
MODULE_AUTHOR("Carlo Caione <[email protected]>");
|
||||
MODULE_LICENSE("GPL");
|
||||
80
drivers/mfd/axp20x-rsb.c
Normal file
80
drivers/mfd/axp20x-rsb.c
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* RSB driver for the X-Powers' Power Management ICs
|
||||
*
|
||||
* AXP20x typically comprises an adaptive USB-Compatible PWM charger, BUCK DC-DC
|
||||
* converters, LDOs, multiple 12-bit ADCs of voltage, current and temperature
|
||||
* as well as configurable GPIOs.
|
||||
*
|
||||
* This driver supports the RSB variants.
|
||||
*
|
||||
* Copyright (C) 2015 Chen-Yu Tsai
|
||||
*
|
||||
* Author: Chen-Yu Tsai <wens@csie.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mfd/axp20x.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sunxi-rsb.h>
|
||||
|
||||
static int axp20x_rsb_probe(struct sunxi_rsb_device *rdev)
|
||||
{
|
||||
struct axp20x_dev *axp20x;
|
||||
int ret;
|
||||
|
||||
axp20x = devm_kzalloc(&rdev->dev, sizeof(*axp20x), GFP_KERNEL);
|
||||
if (!axp20x)
|
||||
return -ENOMEM;
|
||||
|
||||
axp20x->dev = &rdev->dev;
|
||||
axp20x->irq = rdev->irq;
|
||||
dev_set_drvdata(&rdev->dev, axp20x);
|
||||
|
||||
ret = axp20x_match_device(axp20x);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
axp20x->regmap = devm_regmap_init_sunxi_rsb(rdev, axp20x->regmap_cfg);
|
||||
if (IS_ERR(axp20x->regmap)) {
|
||||
ret = PTR_ERR(axp20x->regmap);
|
||||
dev_err(&rdev->dev, "regmap init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return axp20x_device_probe(axp20x);
|
||||
}
|
||||
|
||||
static int axp20x_rsb_remove(struct sunxi_rsb_device *rdev)
|
||||
{
|
||||
struct axp20x_dev *axp20x = sunxi_rsb_device_get_drvdata(rdev);
|
||||
|
||||
return axp20x_device_remove(axp20x);
|
||||
}
|
||||
|
||||
static const struct of_device_id axp20x_rsb_of_match[] = {
|
||||
{ .compatible = "x-powers,axp223", .data = (void *)AXP223_ID },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, axp20x_rsb_of_match);
|
||||
|
||||
static struct sunxi_rsb_driver axp20x_rsb_driver = {
|
||||
.driver = {
|
||||
.name = "axp20x-rsb",
|
||||
.of_match_table = of_match_ptr(axp20x_rsb_of_match),
|
||||
},
|
||||
.probe = axp20x_rsb_probe,
|
||||
.remove = axp20x_rsb_remove,
|
||||
};
|
||||
module_sunxi_rsb_driver(axp20x_rsb_driver);
|
||||
|
||||
MODULE_DESCRIPTION("PMIC MFD sunXi RSB driver for AXP20X");
|
||||
MODULE_AUTHOR("Chen-Yu Tsai <[email protected]>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
@ -1,10 +1,14 @@
|
|||
/*
|
||||
* axp20x.c - MFD core driver for the X-Powers' Power Management ICs
|
||||
* MFD core driver for the X-Powers' Power Management ICs
|
||||
*
|
||||
* AXP20x typically comprises an adaptive USB-Compatible PWM charger, BUCK DC-DC
|
||||
* converters, LDOs, multiple 12-bit ADCs of voltage, current and temperature
|
||||
* as well as configurable GPIOs.
|
||||
*
|
||||
* This file contains the interface independent core functions.
|
||||
*
|
||||
* Copyright (C) 2014 Carlo Caione
|
||||
*
|
||||
* Author: Carlo Caione <carlo@caione.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -13,18 +17,15 @@
|
|||
*/
|
||||
|
||||
#include <linux/err.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/mfd/axp20x.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/acpi.h>
|
||||
|
||||
#define AXP20X_OFF 0x80
|
||||
|
|
@ -34,6 +35,7 @@ static const char * const axp20x_model_names[] = {
|
|||
"AXP202",
|
||||
"AXP209",
|
||||
"AXP221",
|
||||
"AXP223",
|
||||
"AXP288",
|
||||
};
|
||||
|
||||
|
|
@ -376,32 +378,6 @@ static const struct regmap_irq axp288_regmap_irqs[] = {
|
|||
INIT_REGMAP_IRQ(AXP288, BC_USB_CHNG, 5, 1),
|
||||
};
|
||||
|
||||
static const struct of_device_id axp20x_of_match[] = {
|
||||
{ .compatible = "x-powers,axp152", .data = (void *) AXP152_ID },
|
||||
{ .compatible = "x-powers,axp202", .data = (void *) AXP202_ID },
|
||||
{ .compatible = "x-powers,axp209", .data = (void *) AXP209_ID },
|
||||
{ .compatible = "x-powers,axp221", .data = (void *) AXP221_ID },
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, axp20x_of_match);
|
||||
|
||||
/*
|
||||
* This is useless for OF-enabled devices, but it is needed by I2C subsystem
|
||||
*/
|
||||
static const struct i2c_device_id axp20x_i2c_id[] = {
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, axp20x_i2c_id);
|
||||
|
||||
static const struct acpi_device_id axp20x_acpi_match[] = {
|
||||
{
|
||||
.id = "INT33F4",
|
||||
.driver_data = AXP288_ID,
|
||||
},
|
||||
{ },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, axp20x_acpi_match);
|
||||
|
||||
static const struct regmap_irq_chip axp152_regmap_irq_chip = {
|
||||
.name = "axp152_irq_chip",
|
||||
.status_base = AXP152_IRQ1_STATE,
|
||||
|
|
@ -606,25 +582,26 @@ static void axp20x_power_off(void)
|
|||
AXP20X_OFF);
|
||||
}
|
||||
|
||||
static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
|
||||
int axp20x_match_device(struct axp20x_dev *axp20x)
|
||||
{
|
||||
struct device *dev = axp20x->dev;
|
||||
const struct acpi_device_id *acpi_id;
|
||||
const struct of_device_id *of_id;
|
||||
|
||||
if (dev->of_node) {
|
||||
of_id = of_match_device(axp20x_of_match, dev);
|
||||
of_id = of_match_device(dev->driver->of_match_table, dev);
|
||||
if (!of_id) {
|
||||
dev_err(dev, "Unable to match OF ID\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
axp20x->variant = (long) of_id->data;
|
||||
axp20x->variant = (long)of_id->data;
|
||||
} else {
|
||||
acpi_id = acpi_match_device(dev->driver->acpi_match_table, dev);
|
||||
if (!acpi_id || !acpi_id->driver_data) {
|
||||
dev_err(dev, "Unable to match ACPI ID and data\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
axp20x->variant = (long) acpi_id->driver_data;
|
||||
axp20x->variant = (long)acpi_id->driver_data;
|
||||
}
|
||||
|
||||
switch (axp20x->variant) {
|
||||
|
|
@ -642,6 +619,7 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
|
|||
axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip;
|
||||
break;
|
||||
case AXP221_ID:
|
||||
case AXP223_ID:
|
||||
axp20x->nr_cells = ARRAY_SIZE(axp22x_cells);
|
||||
axp20x->cells = axp22x_cells;
|
||||
axp20x->regmap_cfg = &axp22x_regmap_config;
|
||||
|
|
@ -658,51 +636,31 @@ static int axp20x_match_device(struct axp20x_dev *axp20x, struct device *dev)
|
|||
return -EINVAL;
|
||||
}
|
||||
dev_info(dev, "AXP20x variant %s found\n",
|
||||
axp20x_model_names[axp20x->variant]);
|
||||
axp20x_model_names[axp20x->variant]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(axp20x_match_device);
|
||||
|
||||
static int axp20x_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
int axp20x_device_probe(struct axp20x_dev *axp20x)
|
||||
{
|
||||
struct axp20x_dev *axp20x;
|
||||
int ret;
|
||||
|
||||
axp20x = devm_kzalloc(&i2c->dev, sizeof(*axp20x), GFP_KERNEL);
|
||||
if (!axp20x)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = axp20x_match_device(axp20x, &i2c->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
axp20x->i2c_client = i2c;
|
||||
axp20x->dev = &i2c->dev;
|
||||
dev_set_drvdata(axp20x->dev, axp20x);
|
||||
|
||||
axp20x->regmap = devm_regmap_init_i2c(i2c, axp20x->regmap_cfg);
|
||||
if (IS_ERR(axp20x->regmap)) {
|
||||
ret = PTR_ERR(axp20x->regmap);
|
||||
dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_add_irq_chip(axp20x->regmap, i2c->irq,
|
||||
ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq,
|
||||
IRQF_ONESHOT | IRQF_SHARED, -1,
|
||||
axp20x->regmap_irq_chip,
|
||||
&axp20x->regmap_irqc);
|
||||
if (ret) {
|
||||
dev_err(&i2c->dev, "failed to add irq chip: %d\n", ret);
|
||||
dev_err(axp20x->dev, "failed to add irq chip: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = mfd_add_devices(axp20x->dev, -1, axp20x->cells,
|
||||
axp20x->nr_cells, NULL, 0, NULL);
|
||||
axp20x->nr_cells, NULL, 0, NULL);
|
||||
|
||||
if (ret) {
|
||||
dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
|
||||
regmap_del_irq_chip(i2c->irq, axp20x->regmap_irqc);
|
||||
dev_err(axp20x->dev, "failed to add MFD devices: %d\n", ret);
|
||||
regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -711,38 +669,25 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
|
|||
pm_power_off = axp20x_power_off;
|
||||
}
|
||||
|
||||
dev_info(&i2c->dev, "AXP20X driver loaded\n");
|
||||
dev_info(axp20x->dev, "AXP20X driver loaded\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(axp20x_device_probe);
|
||||
|
||||
static int axp20x_i2c_remove(struct i2c_client *i2c)
|
||||
int axp20x_device_remove(struct axp20x_dev *axp20x)
|
||||
{
|
||||
struct axp20x_dev *axp20x = i2c_get_clientdata(i2c);
|
||||
|
||||
if (axp20x == axp20x_pm_power_off) {
|
||||
axp20x_pm_power_off = NULL;
|
||||
pm_power_off = NULL;
|
||||
}
|
||||
|
||||
mfd_remove_devices(axp20x->dev);
|
||||
regmap_del_irq_chip(axp20x->i2c_client->irq, axp20x->regmap_irqc);
|
||||
regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct i2c_driver axp20x_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "axp20x",
|
||||
.of_match_table = of_match_ptr(axp20x_of_match),
|
||||
.acpi_match_table = ACPI_PTR(axp20x_acpi_match),
|
||||
},
|
||||
.probe = axp20x_i2c_probe,
|
||||
.remove = axp20x_i2c_remove,
|
||||
.id_table = axp20x_i2c_id,
|
||||
};
|
||||
|
||||
module_i2c_driver(axp20x_i2c_driver);
|
||||
EXPORT_SYMBOL(axp20x_device_remove);
|
||||
|
||||
MODULE_DESCRIPTION("PMIC MFD core driver for AXP20X");
|
||||
MODULE_AUTHOR("Carlo Caione <[email protected]>");
|
||||
|
|
|
|||
203
drivers/mfd/fsl-imx25-tsadc.c
Normal file
203
drivers/mfd/fsl-imx25-tsadc.c
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* Copyright (C) 2014-2015 Pengutronix, Markus Pargmann <mpa@pengutronix.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License version 2 as published by the
|
||||
* Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/clk.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irqchip/chained_irq.h>
|
||||
#include <linux/irqdesc.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/mfd/imx25-tsadc.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
static struct regmap_config mx25_tsadc_regmap_config = {
|
||||
.fast_io = true,
|
||||
.max_register = 8,
|
||||
.reg_bits = 32,
|
||||
.val_bits = 32,
|
||||
.reg_stride = 4,
|
||||
};
|
||||
|
||||
static void mx25_tsadc_irq_handler(struct irq_desc *desc)
|
||||
{
|
||||
struct mx25_tsadc *tsadc = irq_desc_get_handler_data(desc);
|
||||
struct irq_chip *chip = irq_desc_get_chip(desc);
|
||||
u32 status;
|
||||
|
||||
chained_irq_enter(chip, desc);
|
||||
|
||||
regmap_read(tsadc->regs, MX25_TSC_TGSR, &status);
|
||||
|
||||
if (status & MX25_TGSR_GCQ_INT)
|
||||
generic_handle_irq(irq_find_mapping(tsadc->domain, 1));
|
||||
|
||||
if (status & MX25_TGSR_TCQ_INT)
|
||||
generic_handle_irq(irq_find_mapping(tsadc->domain, 0));
|
||||
|
||||
chained_irq_exit(chip, desc);
|
||||
}
|
||||
|
||||
static int mx25_tsadc_domain_map(struct irq_domain *d, unsigned int irq,
|
||||
irq_hw_number_t hwirq)
|
||||
{
|
||||
struct mx25_tsadc *tsadc = d->host_data;
|
||||
|
||||
irq_set_chip_data(irq, tsadc);
|
||||
irq_set_chip_and_handler(irq, &dummy_irq_chip,
|
||||
handle_level_irq);
|
||||
irq_modify_status(irq, IRQ_NOREQUEST, IRQ_NOPROBE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct irq_domain_ops mx25_tsadc_domain_ops = {
|
||||
.map = mx25_tsadc_domain_map,
|
||||
.xlate = irq_domain_xlate_onecell,
|
||||
};
|
||||
|
||||
static int mx25_tsadc_setup_irq(struct platform_device *pdev,
|
||||
struct mx25_tsadc *tsadc)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
int irq;
|
||||
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq <= 0) {
|
||||
dev_err(dev, "Failed to get irq\n");
|
||||
return irq;
|
||||
}
|
||||
|
||||
tsadc->domain = irq_domain_add_simple(np, 2, 0, &mx25_tsadc_domain_ops,
|
||||
tsadc);
|
||||
if (!tsadc->domain) {
|
||||
dev_err(dev, "Failed to add irq domain\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
irq_set_chained_handler(irq, mx25_tsadc_irq_handler);
|
||||
irq_set_handler_data(irq, tsadc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mx25_tsadc_setup_clk(struct platform_device *pdev,
|
||||
struct mx25_tsadc *tsadc)
|
||||
{
|
||||
unsigned clk_div;
|
||||
|
||||
/*
|
||||
* According to the datasheet the ADC clock should never
|
||||
* exceed 1,75 MHz. Base clock is the IPG and the ADC unit uses
|
||||
* a funny clock divider. To keep the ADC conversion time constant
|
||||
* adapt the ADC internal clock divider to the IPG clock rate.
|
||||
*/
|
||||
|
||||
dev_dbg(&pdev->dev, "Found master clock at %lu Hz\n",
|
||||
clk_get_rate(tsadc->clk));
|
||||
|
||||
clk_div = DIV_ROUND_UP(clk_get_rate(tsadc->clk), 1750000);
|
||||
dev_dbg(&pdev->dev, "Setting up ADC clock divider to %u\n", clk_div);
|
||||
|
||||
/* adc clock = IPG clock / (2 * div + 2) */
|
||||
clk_div -= 2;
|
||||
clk_div /= 2;
|
||||
|
||||
/*
|
||||
* the ADC clock divider changes its behaviour when values below 4
|
||||
* are used: it is fixed to "/ 10" in this case
|
||||
*/
|
||||
clk_div = max_t(unsigned, 4, clk_div);
|
||||
|
||||
dev_dbg(&pdev->dev, "Resulting ADC conversion clock at %lu Hz\n",
|
||||
clk_get_rate(tsadc->clk) / (2 * clk_div + 2));
|
||||
|
||||
regmap_update_bits(tsadc->regs, MX25_TSC_TGCR,
|
||||
MX25_TGCR_ADCCLKCFG(0x1f),
|
||||
MX25_TGCR_ADCCLKCFG(clk_div));
|
||||
}
|
||||
|
||||
static int mx25_tsadc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
struct mx25_tsadc *tsadc;
|
||||
struct resource *res;
|
||||
int ret;
|
||||
void __iomem *iomem;
|
||||
|
||||
tsadc = devm_kzalloc(dev, sizeof(*tsadc), GFP_KERNEL);
|
||||
if (!tsadc)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
iomem = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(iomem))
|
||||
return PTR_ERR(iomem);
|
||||
|
||||
tsadc->regs = devm_regmap_init_mmio(dev, iomem,
|
||||
&mx25_tsadc_regmap_config);
|
||||
if (IS_ERR(tsadc->regs)) {
|
||||
dev_err(dev, "Failed to initialize regmap\n");
|
||||
return PTR_ERR(tsadc->regs);
|
||||
}
|
||||
|
||||
tsadc->clk = devm_clk_get(dev, "ipg");
|
||||
if (IS_ERR(tsadc->clk)) {
|
||||
dev_err(dev, "Failed to get ipg clock\n");
|
||||
return PTR_ERR(tsadc->clk);
|
||||
}
|
||||
|
||||
/* setup clock according to the datasheet */
|
||||
mx25_tsadc_setup_clk(pdev, tsadc);
|
||||
|
||||
/* Enable clock and reset the component */
|
||||
regmap_update_bits(tsadc->regs, MX25_TSC_TGCR, MX25_TGCR_CLK_EN,
|
||||
MX25_TGCR_CLK_EN);
|
||||
regmap_update_bits(tsadc->regs, MX25_TSC_TGCR, MX25_TGCR_TSC_RST,
|
||||
MX25_TGCR_TSC_RST);
|
||||
|
||||
/* Setup powersaving mode, but enable internal reference voltage */
|
||||
regmap_update_bits(tsadc->regs, MX25_TSC_TGCR, MX25_TGCR_POWERMODE_MASK,
|
||||
MX25_TGCR_POWERMODE_SAVE);
|
||||
regmap_update_bits(tsadc->regs, MX25_TSC_TGCR, MX25_TGCR_INTREFEN,
|
||||
MX25_TGCR_INTREFEN);
|
||||
|
||||
ret = mx25_tsadc_setup_irq(pdev, tsadc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
platform_set_drvdata(pdev, tsadc);
|
||||
|
||||
of_platform_populate(np, NULL, NULL, dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id mx25_tsadc_ids[] = {
|
||||
{ .compatible = "fsl,imx25-tsadc" },
|
||||
{ /* Sentinel */ }
|
||||
};
|
||||
|
||||
static struct platform_driver mx25_tsadc_driver = {
|
||||
.driver = {
|
||||
.name = "mx25-tsadc",
|
||||
.of_match_table = of_match_ptr(mx25_tsadc_ids),
|
||||
},
|
||||
.probe = mx25_tsadc_probe,
|
||||
};
|
||||
module_platform_driver(mx25_tsadc_driver);
|
||||
|
||||
MODULE_DESCRIPTION("MFD for ADC/TSC for Freescale mx25");
|
||||
MODULE_AUTHOR("Markus Pargmann <[email protected]>");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_ALIAS("platform:mx25-tsadc");
|
||||
|
|
@ -1,175 +1,111 @@
|
|||
/*
|
||||
* tps65912-core.c -- TI TPS65912x
|
||||
* Core functions for TI TPS65912x PMICs
|
||||
*
|
||||
* Copyright 2011 Texas Instruments Inc.
|
||||
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Andrew F. Davis <afd@ti.com>
|
||||
*
|
||||
* Author: Margarita Olaya Cabrera <magi@slimlogic.co.uk>
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
|
||||
* kind, whether expressed or implied; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License version 2 for more details.
|
||||
*
|
||||
* This driver is based on wm8350 implementation.
|
||||
* Based on the TPS65218 driver and the previous TPS65912 driver by
|
||||
* Margarita Olaya Cabrera <magi@slimlogic.co.uk>
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <linux/mfd/tps65912.h>
|
||||
|
||||
static const struct mfd_cell tps65912s[] = {
|
||||
{
|
||||
.name = "tps65912-pmic",
|
||||
},
|
||||
static const struct mfd_cell tps65912_cells[] = {
|
||||
{ .name = "tps65912-regulator", },
|
||||
{ .name = "tps65912-gpio", },
|
||||
};
|
||||
|
||||
int tps65912_set_bits(struct tps65912 *tps65912, u8 reg, u8 mask)
|
||||
static const struct regmap_irq tps65912_irqs[] = {
|
||||
/* INT_STS IRQs */
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PWRHOLD_F, 0, TPS65912_INT_STS_PWRHOLD_F),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_VMON, 0, TPS65912_INT_STS_VMON),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PWRON, 0, TPS65912_INT_STS_PWRON),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PWRON_LP, 0, TPS65912_INT_STS_PWRON_LP),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PWRHOLD_R, 0, TPS65912_INT_STS_PWRHOLD_R),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_HOTDIE, 0, TPS65912_INT_STS_HOTDIE),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO1_R, 0, TPS65912_INT_STS_GPIO1_R),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO1_F, 0, TPS65912_INT_STS_GPIO1_F),
|
||||
/* INT_STS2 IRQs */
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO2_R, 1, TPS65912_INT_STS2_GPIO2_R),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO2_F, 1, TPS65912_INT_STS2_GPIO2_F),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO3_R, 1, TPS65912_INT_STS2_GPIO3_R),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO3_F, 1, TPS65912_INT_STS2_GPIO3_F),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO4_R, 1, TPS65912_INT_STS2_GPIO4_R),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO4_F, 1, TPS65912_INT_STS2_GPIO4_F),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO5_R, 1, TPS65912_INT_STS2_GPIO5_R),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_GPIO5_F, 1, TPS65912_INT_STS2_GPIO5_F),
|
||||
/* INT_STS3 IRQs */
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC1, 2, TPS65912_INT_STS3_PGOOD_DCDC1),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC2, 2, TPS65912_INT_STS3_PGOOD_DCDC2),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC3, 2, TPS65912_INT_STS3_PGOOD_DCDC3),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_DCDC4, 2, TPS65912_INT_STS3_PGOOD_DCDC4),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO1, 2, TPS65912_INT_STS3_PGOOD_LDO1),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO2, 2, TPS65912_INT_STS3_PGOOD_LDO2),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO3, 2, TPS65912_INT_STS3_PGOOD_LDO3),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO4, 2, TPS65912_INT_STS3_PGOOD_LDO4),
|
||||
/* INT_STS4 IRQs */
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO5, 3, TPS65912_INT_STS4_PGOOD_LDO5),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO6, 3, TPS65912_INT_STS4_PGOOD_LDO6),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO7, 3, TPS65912_INT_STS4_PGOOD_LDO7),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO8, 3, TPS65912_INT_STS4_PGOOD_LDO8),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO9, 3, TPS65912_INT_STS4_PGOOD_LDO9),
|
||||
REGMAP_IRQ_REG(TPS65912_IRQ_PGOOD_LDO10, 3, TPS65912_INT_STS4_PGOOD_LDO10),
|
||||
};
|
||||
|
||||
static struct regmap_irq_chip tps65912_irq_chip = {
|
||||
.name = "tps65912",
|
||||
.irqs = tps65912_irqs,
|
||||
.num_irqs = ARRAY_SIZE(tps65912_irqs),
|
||||
.num_regs = 4,
|
||||
.irq_reg_stride = 2,
|
||||
.mask_base = TPS65912_INT_MSK,
|
||||
.status_base = TPS65912_INT_STS,
|
||||
.ack_base = TPS65912_INT_STS,
|
||||
.init_ack_masked = true,
|
||||
};
|
||||
|
||||
int tps65912_device_init(struct tps65912 *tps)
|
||||
{
|
||||
u8 data;
|
||||
int err;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&tps65912->io_mutex);
|
||||
ret = regmap_add_irq_chip(tps->regmap, tps->irq, IRQF_ONESHOT, 0,
|
||||
&tps65912_irq_chip, &tps->irq_data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
err = tps65912->read(tps65912, reg, 1, &data);
|
||||
if (err) {
|
||||
dev_err(tps65912->dev, "Read from reg 0x%x failed\n", reg);
|
||||
goto out;
|
||||
ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65912_cells,
|
||||
ARRAY_SIZE(tps65912_cells), NULL, 0,
|
||||
regmap_irq_get_domain(tps->irq_data));
|
||||
if (ret) {
|
||||
regmap_del_irq_chip(tps->irq, tps->irq_data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
data |= mask;
|
||||
err = tps65912->write(tps65912, reg, 1, &data);
|
||||
if (err)
|
||||
dev_err(tps65912->dev, "Write to reg 0x%x failed\n", reg);
|
||||
|
||||
out:
|
||||
mutex_unlock(&tps65912->io_mutex);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tps65912_set_bits);
|
||||
EXPORT_SYMBOL_GPL(tps65912_device_init);
|
||||
|
||||
int tps65912_clear_bits(struct tps65912 *tps65912, u8 reg, u8 mask)
|
||||
int tps65912_device_exit(struct tps65912 *tps)
|
||||
{
|
||||
u8 data;
|
||||
int err;
|
||||
regmap_del_irq_chip(tps->irq, tps->irq_data);
|
||||
|
||||
mutex_lock(&tps65912->io_mutex);
|
||||
err = tps65912->read(tps65912, reg, 1, &data);
|
||||
if (err) {
|
||||
dev_err(tps65912->dev, "Read from reg 0x%x failed\n", reg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
data &= ~mask;
|
||||
err = tps65912->write(tps65912, reg, 1, &data);
|
||||
if (err)
|
||||
dev_err(tps65912->dev, "Write to reg 0x%x failed\n", reg);
|
||||
|
||||
out:
|
||||
mutex_unlock(&tps65912->io_mutex);
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tps65912_clear_bits);
|
||||
EXPORT_SYMBOL_GPL(tps65912_device_exit);
|
||||
|
||||
static inline int tps65912_read(struct tps65912 *tps65912, u8 reg)
|
||||
{
|
||||
u8 val;
|
||||
int err;
|
||||
|
||||
err = tps65912->read(tps65912, reg, 1, &val);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline int tps65912_write(struct tps65912 *tps65912, u8 reg, u8 val)
|
||||
{
|
||||
return tps65912->write(tps65912, reg, 1, &val);
|
||||
}
|
||||
|
||||
int tps65912_reg_read(struct tps65912 *tps65912, u8 reg)
|
||||
{
|
||||
int data;
|
||||
|
||||
mutex_lock(&tps65912->io_mutex);
|
||||
|
||||
data = tps65912_read(tps65912, reg);
|
||||
if (data < 0)
|
||||
dev_err(tps65912->dev, "Read from reg 0x%x failed\n", reg);
|
||||
|
||||
mutex_unlock(&tps65912->io_mutex);
|
||||
return data;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tps65912_reg_read);
|
||||
|
||||
int tps65912_reg_write(struct tps65912 *tps65912, u8 reg, u8 val)
|
||||
{
|
||||
int err;
|
||||
|
||||
mutex_lock(&tps65912->io_mutex);
|
||||
|
||||
err = tps65912_write(tps65912, reg, val);
|
||||
if (err < 0)
|
||||
dev_err(tps65912->dev, "Write for reg 0x%x failed\n", reg);
|
||||
|
||||
mutex_unlock(&tps65912->io_mutex);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(tps65912_reg_write);
|
||||
|
||||
int tps65912_device_init(struct tps65912 *tps65912)
|
||||
{
|
||||
struct tps65912_board *pmic_plat_data = dev_get_platdata(tps65912->dev);
|
||||
struct tps65912_platform_data *init_data;
|
||||
int ret, dcdc_avs, value;
|
||||
|
||||
init_data = kzalloc(sizeof(struct tps65912_platform_data), GFP_KERNEL);
|
||||
if (init_data == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&tps65912->io_mutex);
|
||||
dev_set_drvdata(tps65912->dev, tps65912);
|
||||
|
||||
dcdc_avs = (pmic_plat_data->is_dcdc1_avs << 0 |
|
||||
pmic_plat_data->is_dcdc2_avs << 1 |
|
||||
pmic_plat_data->is_dcdc3_avs << 2 |
|
||||
pmic_plat_data->is_dcdc4_avs << 3);
|
||||
if (dcdc_avs) {
|
||||
tps65912->read(tps65912, TPS65912_I2C_SPI_CFG, 1, &value);
|
||||
dcdc_avs |= value;
|
||||
tps65912->write(tps65912, TPS65912_I2C_SPI_CFG, 1, &dcdc_avs);
|
||||
}
|
||||
|
||||
ret = mfd_add_devices(tps65912->dev, -1,
|
||||
tps65912s, ARRAY_SIZE(tps65912s),
|
||||
NULL, 0, NULL);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
init_data->irq = pmic_plat_data->irq;
|
||||
init_data->irq_base = pmic_plat_data->irq_base;
|
||||
ret = tps65912_irq_init(tps65912, init_data->irq, init_data);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
kfree(init_data);
|
||||
return ret;
|
||||
|
||||
err:
|
||||
kfree(init_data);
|
||||
mfd_remove_devices(tps65912->dev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void tps65912_device_exit(struct tps65912 *tps65912)
|
||||
{
|
||||
mfd_remove_devices(tps65912->dev);
|
||||
tps65912_irq_exit(tps65912);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Margarita Olaya <[email protected]>");
|
||||
MODULE_DESCRIPTION("TPS65912x chip family multi-function driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Andrew F. Davis <[email protected]>");
|
||||
MODULE_DESCRIPTION("TPS65912x MFD Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
|
|||
|
|
@ -1,139 +1,79 @@
|
|||
/*
|
||||
* tps65912-i2c.c -- I2C access for TI TPS65912x PMIC
|
||||
* I2C access driver for TI TPS65912x PMICs
|
||||
*
|
||||
* Copyright 2011 Texas Instruments Inc.
|
||||
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Andrew F. Davis <afd@ti.com>
|
||||
*
|
||||
* Author: Margarita Olaya Cabrera <magi@slimlogic.co.uk>
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
|
||||
* kind, whether expressed or implied; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License version 2 for more details.
|
||||
*
|
||||
* This driver is based on wm8350 implementation.
|
||||
* Based on the TPS65218 driver and the previous TPS65912 driver by
|
||||
* Margarita Olaya Cabrera <magi@slimlogic.co.uk>
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/regmap.h>
|
||||
|
||||
#include <linux/mfd/tps65912.h>
|
||||
|
||||
static int tps65912_i2c_read(struct tps65912 *tps65912, u8 reg,
|
||||
int bytes, void *dest)
|
||||
static const struct of_device_id tps65912_i2c_of_match_table[] = {
|
||||
{ .compatible = "ti,tps65912", },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static int tps65912_i2c_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *ids)
|
||||
{
|
||||
struct i2c_client *i2c = tps65912->control_data;
|
||||
struct i2c_msg xfer[2];
|
||||
int ret;
|
||||
struct tps65912 *tps;
|
||||
|
||||
/* Write register */
|
||||
xfer[0].addr = i2c->addr;
|
||||
xfer[0].flags = 0;
|
||||
xfer[0].len = 1;
|
||||
xfer[0].buf = ®
|
||||
|
||||
/* Read data */
|
||||
xfer[1].addr = i2c->addr;
|
||||
xfer[1].flags = I2C_M_RD;
|
||||
xfer[1].len = bytes;
|
||||
xfer[1].buf = dest;
|
||||
|
||||
ret = i2c_transfer(i2c->adapter, xfer, 2);
|
||||
if (ret == 2)
|
||||
ret = 0;
|
||||
else if (ret >= 0)
|
||||
ret = -EIO;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tps65912_i2c_write(struct tps65912 *tps65912, u8 reg,
|
||||
int bytes, void *src)
|
||||
{
|
||||
struct i2c_client *i2c = tps65912->control_data;
|
||||
/* we add 1 byte for device register */
|
||||
u8 msg[TPS6591X_MAX_REGISTER + 1];
|
||||
int ret;
|
||||
|
||||
if (bytes > TPS6591X_MAX_REGISTER)
|
||||
return -EINVAL;
|
||||
|
||||
msg[0] = reg;
|
||||
memcpy(&msg[1], src, bytes);
|
||||
|
||||
ret = i2c_master_send(i2c, msg, bytes + 1);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret != bytes + 1)
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tps65912_i2c_probe(struct i2c_client *i2c,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct tps65912 *tps65912;
|
||||
|
||||
tps65912 = devm_kzalloc(&i2c->dev,
|
||||
sizeof(struct tps65912), GFP_KERNEL);
|
||||
if (tps65912 == NULL)
|
||||
tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
|
||||
if (!tps)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(i2c, tps65912);
|
||||
tps65912->dev = &i2c->dev;
|
||||
tps65912->control_data = i2c;
|
||||
tps65912->read = tps65912_i2c_read;
|
||||
tps65912->write = tps65912_i2c_write;
|
||||
i2c_set_clientdata(client, tps);
|
||||
tps->dev = &client->dev;
|
||||
tps->irq = client->irq;
|
||||
|
||||
return tps65912_device_init(tps65912);
|
||||
tps->regmap = devm_regmap_init_i2c(client, &tps65912_regmap_config);
|
||||
if (IS_ERR(tps->regmap)) {
|
||||
dev_err(tps->dev, "Failed to initialize register map\n");
|
||||
return PTR_ERR(tps->regmap);
|
||||
}
|
||||
|
||||
return tps65912_device_init(tps);
|
||||
}
|
||||
|
||||
static int tps65912_i2c_remove(struct i2c_client *i2c)
|
||||
static int tps65912_i2c_remove(struct i2c_client *client)
|
||||
{
|
||||
struct tps65912 *tps65912 = i2c_get_clientdata(i2c);
|
||||
struct tps65912 *tps = i2c_get_clientdata(client);
|
||||
|
||||
tps65912_device_exit(tps65912);
|
||||
|
||||
return 0;
|
||||
return tps65912_device_exit(tps);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id tps65912_i2c_id[] = {
|
||||
{"tps65912", 0 },
|
||||
{ }
|
||||
static const struct i2c_device_id tps65912_i2c_id_table[] = {
|
||||
{ "tps65912", 0 },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, tps65912_i2c_id);
|
||||
MODULE_DEVICE_TABLE(i2c, tps65912_i2c_id_table);
|
||||
|
||||
static struct i2c_driver tps65912_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "tps65912",
|
||||
.driver = {
|
||||
.name = "tps65912",
|
||||
.of_match_table = tps65912_i2c_of_match_table,
|
||||
},
|
||||
.probe = tps65912_i2c_probe,
|
||||
.remove = tps65912_i2c_remove,
|
||||
.id_table = tps65912_i2c_id,
|
||||
.probe = tps65912_i2c_probe,
|
||||
.remove = tps65912_i2c_remove,
|
||||
.id_table = tps65912_i2c_id_table,
|
||||
};
|
||||
module_i2c_driver(tps65912_i2c_driver);
|
||||
|
||||
static int __init tps65912_i2c_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = i2c_add_driver(&tps65912_i2c_driver);
|
||||
if (ret != 0)
|
||||
pr_err("Failed to register TPS65912 I2C driver: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* init early so consumer devices can complete system boot */
|
||||
subsys_initcall(tps65912_i2c_init);
|
||||
|
||||
static void __exit tps65912_i2c_exit(void)
|
||||
{
|
||||
i2c_del_driver(&tps65912_i2c_driver);
|
||||
}
|
||||
module_exit(tps65912_i2c_exit);
|
||||
|
||||
MODULE_AUTHOR("Margarita Olaya <[email protected]>");
|
||||
MODULE_DESCRIPTION("TPS6591x chip family multi-function driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Andrew F. Davis <[email protected]>");
|
||||
MODULE_DESCRIPTION("TPS65912x I2C Interface Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
|
|||
|
|
@ -1,217 +0,0 @@
|
|||
/*
|
||||
* tps65912-irq.c -- TI TPS6591x
|
||||
*
|
||||
* Copyright 2011 Texas Instruments Inc.
|
||||
*
|
||||
* Author: Margarita Olaya <magi@slimlogic.co.uk>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This driver is based on wm8350 implementation.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/mfd/tps65912.h>
|
||||
|
||||
static inline int irq_to_tps65912_irq(struct tps65912 *tps65912,
|
||||
int irq)
|
||||
{
|
||||
return irq - tps65912->irq_base;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a threaded IRQ handler so can access I2C/SPI. Since the
|
||||
* IRQ handler explicitly clears the IRQ it handles the IRQ line
|
||||
* will be reasserted and the physical IRQ will be handled again if
|
||||
* another interrupt is asserted while we run - in the normal course
|
||||
* of events this is a rare occurrence so we save I2C/SPI reads. We're
|
||||
* also assuming that it's rare to get lots of interrupts firing
|
||||
* simultaneously so try to minimise I/O.
|
||||
*/
|
||||
static irqreturn_t tps65912_irq(int irq, void *irq_data)
|
||||
{
|
||||
struct tps65912 *tps65912 = irq_data;
|
||||
u32 irq_sts;
|
||||
u32 irq_mask;
|
||||
u8 reg;
|
||||
int i;
|
||||
|
||||
|
||||
tps65912->read(tps65912, TPS65912_INT_STS, 1, ®);
|
||||
irq_sts = reg;
|
||||
tps65912->read(tps65912, TPS65912_INT_STS2, 1, ®);
|
||||
irq_sts |= reg << 8;
|
||||
tps65912->read(tps65912, TPS65912_INT_STS3, 1, ®);
|
||||
irq_sts |= reg << 16;
|
||||
tps65912->read(tps65912, TPS65912_INT_STS4, 1, ®);
|
||||
irq_sts |= reg << 24;
|
||||
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK, 1, ®);
|
||||
irq_mask = reg;
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK2, 1, ®);
|
||||
irq_mask |= reg << 8;
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK3, 1, ®);
|
||||
irq_mask |= reg << 16;
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK4, 1, ®);
|
||||
irq_mask |= reg << 24;
|
||||
|
||||
irq_sts &= ~irq_mask;
|
||||
if (!irq_sts)
|
||||
return IRQ_NONE;
|
||||
|
||||
for (i = 0; i < tps65912->irq_num; i++) {
|
||||
if (!(irq_sts & (1 << i)))
|
||||
continue;
|
||||
|
||||
handle_nested_irq(tps65912->irq_base + i);
|
||||
}
|
||||
|
||||
/* Write the STS register back to clear IRQs we handled */
|
||||
reg = irq_sts & 0xFF;
|
||||
irq_sts >>= 8;
|
||||
if (reg)
|
||||
tps65912->write(tps65912, TPS65912_INT_STS, 1, ®);
|
||||
reg = irq_sts & 0xFF;
|
||||
irq_sts >>= 8;
|
||||
if (reg)
|
||||
tps65912->write(tps65912, TPS65912_INT_STS2, 1, ®);
|
||||
reg = irq_sts & 0xFF;
|
||||
irq_sts >>= 8;
|
||||
if (reg)
|
||||
tps65912->write(tps65912, TPS65912_INT_STS3, 1, ®);
|
||||
reg = irq_sts & 0xFF;
|
||||
if (reg)
|
||||
tps65912->write(tps65912, TPS65912_INT_STS4, 1, ®);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void tps65912_irq_lock(struct irq_data *data)
|
||||
{
|
||||
struct tps65912 *tps65912 = irq_data_get_irq_chip_data(data);
|
||||
|
||||
mutex_lock(&tps65912->irq_lock);
|
||||
}
|
||||
|
||||
static void tps65912_irq_sync_unlock(struct irq_data *data)
|
||||
{
|
||||
struct tps65912 *tps65912 = irq_data_get_irq_chip_data(data);
|
||||
u32 reg_mask;
|
||||
u8 reg;
|
||||
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK, 1, ®);
|
||||
reg_mask = reg;
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK2, 1, ®);
|
||||
reg_mask |= reg << 8;
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK3, 1, ®);
|
||||
reg_mask |= reg << 16;
|
||||
tps65912->read(tps65912, TPS65912_INT_MSK4, 1, ®);
|
||||
reg_mask |= reg << 24;
|
||||
|
||||
if (tps65912->irq_mask != reg_mask) {
|
||||
reg = tps65912->irq_mask & 0xFF;
|
||||
tps65912->write(tps65912, TPS65912_INT_MSK, 1, ®);
|
||||
reg = tps65912->irq_mask >> 8 & 0xFF;
|
||||
tps65912->write(tps65912, TPS65912_INT_MSK2, 1, ®);
|
||||
reg = tps65912->irq_mask >> 16 & 0xFF;
|
||||
tps65912->write(tps65912, TPS65912_INT_MSK3, 1, ®);
|
||||
reg = tps65912->irq_mask >> 24 & 0xFF;
|
||||
tps65912->write(tps65912, TPS65912_INT_MSK4, 1, ®);
|
||||
}
|
||||
|
||||
mutex_unlock(&tps65912->irq_lock);
|
||||
}
|
||||
|
||||
static void tps65912_irq_enable(struct irq_data *data)
|
||||
{
|
||||
struct tps65912 *tps65912 = irq_data_get_irq_chip_data(data);
|
||||
|
||||
tps65912->irq_mask &= ~(1 << irq_to_tps65912_irq(tps65912, data->irq));
|
||||
}
|
||||
|
||||
static void tps65912_irq_disable(struct irq_data *data)
|
||||
{
|
||||
struct tps65912 *tps65912 = irq_data_get_irq_chip_data(data);
|
||||
|
||||
tps65912->irq_mask |= (1 << irq_to_tps65912_irq(tps65912, data->irq));
|
||||
}
|
||||
|
||||
static struct irq_chip tps65912_irq_chip = {
|
||||
.name = "tps65912",
|
||||
.irq_bus_lock = tps65912_irq_lock,
|
||||
.irq_bus_sync_unlock = tps65912_irq_sync_unlock,
|
||||
.irq_disable = tps65912_irq_disable,
|
||||
.irq_enable = tps65912_irq_enable,
|
||||
};
|
||||
|
||||
int tps65912_irq_init(struct tps65912 *tps65912, int irq,
|
||||
struct tps65912_platform_data *pdata)
|
||||
{
|
||||
int ret, cur_irq;
|
||||
int flags = IRQF_ONESHOT;
|
||||
u8 reg;
|
||||
|
||||
if (!irq) {
|
||||
dev_warn(tps65912->dev, "No interrupt support, no core IRQ\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!pdata || !pdata->irq_base) {
|
||||
dev_warn(tps65912->dev, "No interrupt support, no IRQ base\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Clear unattended interrupts */
|
||||
tps65912->read(tps65912, TPS65912_INT_STS, 1, ®);
|
||||
tps65912->write(tps65912, TPS65912_INT_STS, 1, ®);
|
||||
tps65912->read(tps65912, TPS65912_INT_STS2, 1, ®);
|
||||
tps65912->write(tps65912, TPS65912_INT_STS2, 1, ®);
|
||||
tps65912->read(tps65912, TPS65912_INT_STS3, 1, ®);
|
||||
tps65912->write(tps65912, TPS65912_INT_STS3, 1, ®);
|
||||
tps65912->read(tps65912, TPS65912_INT_STS4, 1, ®);
|
||||
tps65912->write(tps65912, TPS65912_INT_STS4, 1, ®);
|
||||
|
||||
/* Mask top level interrupts */
|
||||
tps65912->irq_mask = 0xFFFFFFFF;
|
||||
|
||||
mutex_init(&tps65912->irq_lock);
|
||||
tps65912->chip_irq = irq;
|
||||
tps65912->irq_base = pdata->irq_base;
|
||||
|
||||
tps65912->irq_num = TPS65912_NUM_IRQ;
|
||||
|
||||
/* Register with genirq */
|
||||
for (cur_irq = tps65912->irq_base;
|
||||
cur_irq < tps65912->irq_num + tps65912->irq_base;
|
||||
cur_irq++) {
|
||||
irq_set_chip_data(cur_irq, tps65912);
|
||||
irq_set_chip_and_handler(cur_irq, &tps65912_irq_chip,
|
||||
handle_edge_irq);
|
||||
irq_set_nested_thread(cur_irq, 1);
|
||||
irq_clear_status_flags(cur_irq, IRQ_NOREQUEST | IRQ_NOPROBE);
|
||||
}
|
||||
|
||||
ret = request_threaded_irq(irq, NULL, tps65912_irq, flags,
|
||||
"tps65912", tps65912);
|
||||
|
||||
irq_set_irq_type(irq, IRQ_TYPE_LEVEL_LOW);
|
||||
if (ret != 0)
|
||||
dev_err(tps65912->dev, "Failed to request IRQ: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int tps65912_irq_exit(struct tps65912 *tps65912)
|
||||
{
|
||||
free_irq(tps65912->chip_irq, tps65912);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,140 +1,78 @@
|
|||
/*
|
||||
* tps65912-spi.c -- SPI access for TI TPS65912x PMIC
|
||||
* SPI access driver for TI TPS65912x PMICs
|
||||
*
|
||||
* Copyright 2011 Texas Instruments Inc.
|
||||
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
|
||||
* Andrew F. Davis <afd@ti.com>
|
||||
*
|
||||
* Author: Margarita Olaya Cabrera <magi@slimlogic.co.uk>
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
|
||||
* kind, whether expressed or implied; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License version 2 for more details.
|
||||
*
|
||||
* This driver is based on wm8350 implementation.
|
||||
* Based on the TPS65218 driver and the previous TPS65912 driver by
|
||||
* Margarita Olaya Cabrera <magi@slimlogic.co.uk>
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/mfd/core.h>
|
||||
|
||||
#include <linux/mfd/tps65912.h>
|
||||
|
||||
static int tps65912_spi_write(struct tps65912 *tps65912, u8 addr,
|
||||
int bytes, void *src)
|
||||
{
|
||||
struct spi_device *spi = tps65912->control_data;
|
||||
u8 *data = (u8 *) src;
|
||||
int ret;
|
||||
/* bit 23 is the read/write bit */
|
||||
unsigned long spi_data = 1 << 23 | addr << 15 | *data;
|
||||
struct spi_transfer xfer;
|
||||
struct spi_message msg;
|
||||
u32 tx_buf;
|
||||
|
||||
tx_buf = spi_data;
|
||||
|
||||
xfer.tx_buf = &tx_buf;
|
||||
xfer.rx_buf = NULL;
|
||||
xfer.len = sizeof(unsigned long);
|
||||
xfer.bits_per_word = 24;
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
|
||||
ret = spi_sync(spi, &msg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int tps65912_spi_read(struct tps65912 *tps65912, u8 addr,
|
||||
int bytes, void *dest)
|
||||
{
|
||||
struct spi_device *spi = tps65912->control_data;
|
||||
/* bit 23 is the read/write bit */
|
||||
unsigned long spi_data = 0 << 23 | addr << 15;
|
||||
struct spi_transfer xfer;
|
||||
struct spi_message msg;
|
||||
int ret;
|
||||
u8 *data = (u8 *) dest;
|
||||
u32 tx_buf, rx_buf;
|
||||
|
||||
tx_buf = spi_data;
|
||||
rx_buf = 0;
|
||||
|
||||
xfer.tx_buf = &tx_buf;
|
||||
xfer.rx_buf = &rx_buf;
|
||||
xfer.len = sizeof(unsigned long);
|
||||
xfer.bits_per_word = 24;
|
||||
|
||||
spi_message_init(&msg);
|
||||
spi_message_add_tail(&xfer, &msg);
|
||||
|
||||
if (spi == NULL)
|
||||
return 0;
|
||||
|
||||
ret = spi_sync(spi, &msg);
|
||||
if (ret == 0)
|
||||
*data = (u8) (rx_buf & 0xFF);
|
||||
return ret;
|
||||
}
|
||||
static const struct of_device_id tps65912_spi_of_match_table[] = {
|
||||
{ .compatible = "ti,tps65912", },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static int tps65912_spi_probe(struct spi_device *spi)
|
||||
{
|
||||
struct tps65912 *tps65912;
|
||||
struct tps65912 *tps;
|
||||
|
||||
tps65912 = devm_kzalloc(&spi->dev,
|
||||
sizeof(struct tps65912), GFP_KERNEL);
|
||||
if (tps65912 == NULL)
|
||||
tps = devm_kzalloc(&spi->dev, sizeof(*tps), GFP_KERNEL);
|
||||
if (!tps)
|
||||
return -ENOMEM;
|
||||
|
||||
tps65912->dev = &spi->dev;
|
||||
tps65912->control_data = spi;
|
||||
tps65912->read = tps65912_spi_read;
|
||||
tps65912->write = tps65912_spi_write;
|
||||
spi_set_drvdata(spi, tps);
|
||||
tps->dev = &spi->dev;
|
||||
tps->irq = spi->irq;
|
||||
|
||||
spi_set_drvdata(spi, tps65912);
|
||||
tps->regmap = devm_regmap_init_spi(spi, &tps65912_regmap_config);
|
||||
if (IS_ERR(tps->regmap)) {
|
||||
dev_err(tps->dev, "Failed to initialize register map\n");
|
||||
return PTR_ERR(tps->regmap);
|
||||
}
|
||||
|
||||
return tps65912_device_init(tps65912);
|
||||
return tps65912_device_init(tps);
|
||||
}
|
||||
|
||||
static int tps65912_spi_remove(struct spi_device *spi)
|
||||
static int tps65912_spi_remove(struct spi_device *client)
|
||||
{
|
||||
struct tps65912 *tps65912 = spi_get_drvdata(spi);
|
||||
struct tps65912 *tps = spi_get_drvdata(client);
|
||||
|
||||
tps65912_device_exit(tps65912);
|
||||
|
||||
return 0;
|
||||
return tps65912_device_exit(tps);
|
||||
}
|
||||
|
||||
static const struct spi_device_id tps65912_spi_id_table[] = {
|
||||
{ "tps65912", 0 },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, tps65912_spi_id_table);
|
||||
|
||||
static struct spi_driver tps65912_spi_driver = {
|
||||
.driver = {
|
||||
.name = "tps65912",
|
||||
.driver = {
|
||||
.name = "tps65912",
|
||||
.of_match_table = tps65912_spi_of_match_table,
|
||||
},
|
||||
.probe = tps65912_spi_probe,
|
||||
.remove = tps65912_spi_remove,
|
||||
.probe = tps65912_spi_probe,
|
||||
.remove = tps65912_spi_remove,
|
||||
.id_table = tps65912_spi_id_table,
|
||||
};
|
||||
module_spi_driver(tps65912_spi_driver);
|
||||
|
||||
static int __init tps65912_spi_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = spi_register_driver(&tps65912_spi_driver);
|
||||
if (ret != 0)
|
||||
pr_err("Failed to register TPS65912 SPI driver: %d\n", ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* init early so consumer devices can complete system boot */
|
||||
subsys_initcall(tps65912_spi_init);
|
||||
|
||||
static void __exit tps65912_spi_exit(void)
|
||||
{
|
||||
spi_unregister_driver(&tps65912_spi_driver);
|
||||
}
|
||||
module_exit(tps65912_spi_exit);
|
||||
|
||||
MODULE_AUTHOR("Margarita Olaya <[email protected]>");
|
||||
MODULE_DESCRIPTION("SPI support for TPS65912 chip family mfd");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Andrew F. Davis <[email protected]>");
|
||||
MODULE_DESCRIPTION("TPS65912x SPI Interface Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
|
|||
Loading…
Reference in a new issue