mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
ae9559594c
- Fix 'mfd_of_node_list' OF node entry resource leak - New Drivers - Add support for Ocelot VSC7512 Networking Chip - Add support for MediaTek MT6370 subPMIC - Add support for Richtek RT5120 (I2C) PMIC - New Device Support - Add support for Rockchip RV1126 and RK3588 to Syscon - Add support for Rockchip RK817 Battery Charger to RK808 - Add support for Silergy SY7636a Voltage Regulator to Simple MFD - Add support for Qualcomm PMP8074 PMIC to QCOM SPMI - Add support for Secure Update to Intel M10 BMC - New Functionality - Provide SSP type to Intel's LPSS (PCI) SPI driver - Fix-ups - Remove legacy / unused code; stmpe, intel_soc_pmic_crc, syscon - Unify / simplify; intel_soc_pmic_crc - Trivial reordering / spelling, etc; Makefile, twl-core - Convert to managed resources; intel_soc_pmic_crc - Use appropriate APIs; intel_soc_pmic_crc - strscpy() conversion; htc-i2cpld, lpc_ich, mfd-core - GPIOD conversion; htc-i2cpld, stmpe - Add missing header file includes; twl4030-irq - DT goodies; stmpe, mediatek,mt6370, x-powers,axp152, aspeed,ast2x00-scu, mediatek,mt8195-scpsys, qcom,spmi-pmic, syscon, qcom,tcsr, rockchip,rk817, sprd,ums512-glbreg, dlg,da9063 - Bug Fixes - Properly check return values; sm501, htc-i2cpld - Repair Two-Wire Bus Mode; da9062-core - Fix error handling; intel_soc_pmic_core, fsl-imx25-tsadc, lp8788, lp8788-irq -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmM9e3IACgkQUa+KL4f8 d2EGYRAArUG1tPdUWYzZweXCbojG+Q8nz0+yLQ/64tfNXRPTovUdwNDwP/l3i+46 5K74gAsVONQQwORhDPM0QNZH5enFVKz6UcBnjM8hDDk4Ip8GEgbmPQjxrY4RpQq8 CL3IXzPHX6LnmGUhxdm1GvKrKt+bATdYZUnAN865afxpXUQMKJt1dZcVWFHSmMco 7EGVUfyEER/w3RehXSsqlEjEfiBsdCNoPigql1Kwb4Vdaf26hXlMvQ4Iw92yOXeC vaFuWaTDlzH+aQAGn4r56OjB+kIxAXvz/yUcuOZKHSKVQYj78QjBOG4KV94B3sVQ 6j9WIZ1kNeHVOcI/sNflvN2xQOe2dT87ZxpnZpp11tYFJQE+ZuQX2c5RQC/uSqmV NRmYrpgDgJl/J7RUWcqBO0FV26FdcB0AQVRobgSR1Q8ii8LPifKq8w8XzOvrYwQF eGfmAZOTFwxFDrJrR9eHxfBLBTewVTCwtfq7FQkTQLWOqMCDDSdczsQUyMh6kQSx FVW/HJAdiohnafJgoD0noPrAulmsT2+WQX1EP4JDcpIEAoZAq+Z96yRqSWV/8q0i KlJlAD+mAvZAEjHlkuVXlGTsOl6k7wZL5ICrd8I8b77wcn1FKIbu9lwKTIjVrL1K r++Egr/ABXlMMX4lzka6+49Ua2PpRrN5Ln4ALmKhRBZVjjazA8A= =GgPZ -----END PGP SIGNATURE----- Merge tag 'mfd-next-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd Pull MFD updates from Lee Jones: "Core Frameworks: - Fix 'mfd_of_node_list' OF node entry resource leak New Drivers: - Add support for Ocelot VSC7512 Networking Chip - Add support for MediaTek MT6370 subPMIC - Add support for Richtek RT5120 (I2C) PMIC New Device Support: - Add support for Rockchip RV1126 and RK3588 to Syscon - Add support for Rockchip RK817 Battery Charger to RK808 - Add support for Silergy SY7636a Voltage Regulator to Simple MFD - Add support for Qualcomm PMP8074 PMIC to QCOM SPMI - Add support for Secure Update to Intel M10 BMC New Functionality: - Provide SSP type to Intel's LPSS (PCI) SPI driver Fix-ups: - Remove legacy / unused code; stmpe, intel_soc_pmic_crc, syscon - Unify / simplify; intel_soc_pmic_crc - Trivial reordering / spelling, etc; Makefile, twl-core - Convert to managed resources; intel_soc_pmic_crc - Use appropriate APIs; intel_soc_pmic_crc - strscpy() conversion; htc-i2cpld, lpc_ich, mfd-core - GPIOD conversion; htc-i2cpld, stmpe - Add missing header file includes; twl4030-irq - DT goodies; stmpe, mediatek,mt6370, x-powers,axp152, aspeed,ast2x00-scu, mediatek,mt8195-scpsys, qcom,spmi-pmic, syscon, qcom,tcsr, rockchip,rk817, sprd,ums512-glbreg, dlg,da9063 Bug Fixes: - Properly check return values; sm501, htc-i2cpld - Repair Two-Wire Bus Mode; da9062-core - Fix error handling; intel_soc_pmic_core, fsl-imx25-tsadc, lp8788, lp8788-irq" * tag 'mfd-next-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (60 commits) mfd: syscon: Remove repetition of the regmap_get_val_endian() mfd: ocelot-spi: Add missing MODULE_DEVICE_TABLE power: supply: Add charger driver for Rockchip RK817 dt-bindings: mfd: mt6370: Fix the indentation in the example mfd: da9061: Fix Failed to set Two-Wire Bus Mode. mfd: htc-i2cpld: Fix an IS_ERR() vs NULL bug in htcpld_core_probe() dt-bindings: mfd: qcom,tcsr: Drop simple-mfd from IPQ6018 mfd: sm501: Add check for platform_driver_register() dt-bindings: mfd: mediatek: Add scpsys compatible for mt8186 mfd: twl4030: Add missed linux/device.h header dt-bindings: mfd: dlg,da9063: Add missing regulator patterns dt-bindings: mfd: sprd: Add bindings for ums512 global registers mfd: intel_soc_pmic_chtdc_ti: Switch from __maybe_unused to pm_sleep_ptr() etc dt-bindings: mfd: syscon: Add rk3588 QoS register compatible mfd: stmpe: Switch to using gpiod API mfd: qcom-spmi-pmic: Add pm7250b compatible dt-bindings: mfd: Add missing (unevaluated|additional)Properties on child nodes mfd/omap1: htc-i2cpld: Convert to a pure GPIO driver mfd: intel-m10-bmc: Add d5005 bmc secure update driver dt-bindings: mfd: syscon: Drop ref from reg-io-width ...
247 lines
5.2 KiB
C
247 lines
5.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* TI LP8788 MFD - core interface
|
|
*
|
|
* Copyright 2012 Texas Instruments
|
|
*
|
|
* Author: Milo(Woogyom) Kim <milo.kim@ti.com>
|
|
*/
|
|
|
|
#include <linux/err.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/mfd/core.h>
|
|
#include <linux/mfd/lp8788.h>
|
|
#include <linux/module.h>
|
|
#include <linux/slab.h>
|
|
|
|
#define MAX_LP8788_REGISTERS 0xA2
|
|
|
|
#define MFD_DEV_SIMPLE(_name) \
|
|
{ \
|
|
.name = LP8788_DEV_##_name, \
|
|
}
|
|
|
|
#define MFD_DEV_WITH_ID(_name, _id) \
|
|
{ \
|
|
.name = LP8788_DEV_##_name, \
|
|
.id = _id, \
|
|
}
|
|
|
|
#define MFD_DEV_WITH_RESOURCE(_name, _resource, num_resource) \
|
|
{ \
|
|
.name = LP8788_DEV_##_name, \
|
|
.resources = _resource, \
|
|
.num_resources = num_resource, \
|
|
}
|
|
|
|
static const struct resource chg_irqs[] = {
|
|
/* Charger Interrupts */
|
|
{
|
|
.start = LP8788_INT_CHG_INPUT_STATE,
|
|
.end = LP8788_INT_PRECHG_TIMEOUT,
|
|
.name = LP8788_CHG_IRQ,
|
|
.flags = IORESOURCE_IRQ,
|
|
},
|
|
/* Power Routing Switch Interrupts */
|
|
{
|
|
.start = LP8788_INT_ENTER_SYS_SUPPORT,
|
|
.end = LP8788_INT_EXIT_SYS_SUPPORT,
|
|
.name = LP8788_PRSW_IRQ,
|
|
.flags = IORESOURCE_IRQ,
|
|
},
|
|
/* Battery Interrupts */
|
|
{
|
|
.start = LP8788_INT_BATT_LOW,
|
|
.end = LP8788_INT_NO_BATT,
|
|
.name = LP8788_BATT_IRQ,
|
|
.flags = IORESOURCE_IRQ,
|
|
},
|
|
};
|
|
|
|
static const struct resource rtc_irqs[] = {
|
|
{
|
|
.start = LP8788_INT_RTC_ALARM1,
|
|
.end = LP8788_INT_RTC_ALARM2,
|
|
.name = LP8788_ALM_IRQ,
|
|
.flags = IORESOURCE_IRQ,
|
|
},
|
|
};
|
|
|
|
static const struct mfd_cell lp8788_devs[] = {
|
|
/* 4 bucks */
|
|
MFD_DEV_WITH_ID(BUCK, 1),
|
|
MFD_DEV_WITH_ID(BUCK, 2),
|
|
MFD_DEV_WITH_ID(BUCK, 3),
|
|
MFD_DEV_WITH_ID(BUCK, 4),
|
|
|
|
/* 12 digital ldos */
|
|
MFD_DEV_WITH_ID(DLDO, 1),
|
|
MFD_DEV_WITH_ID(DLDO, 2),
|
|
MFD_DEV_WITH_ID(DLDO, 3),
|
|
MFD_DEV_WITH_ID(DLDO, 4),
|
|
MFD_DEV_WITH_ID(DLDO, 5),
|
|
MFD_DEV_WITH_ID(DLDO, 6),
|
|
MFD_DEV_WITH_ID(DLDO, 7),
|
|
MFD_DEV_WITH_ID(DLDO, 8),
|
|
MFD_DEV_WITH_ID(DLDO, 9),
|
|
MFD_DEV_WITH_ID(DLDO, 10),
|
|
MFD_DEV_WITH_ID(DLDO, 11),
|
|
MFD_DEV_WITH_ID(DLDO, 12),
|
|
|
|
/* 10 analog ldos */
|
|
MFD_DEV_WITH_ID(ALDO, 1),
|
|
MFD_DEV_WITH_ID(ALDO, 2),
|
|
MFD_DEV_WITH_ID(ALDO, 3),
|
|
MFD_DEV_WITH_ID(ALDO, 4),
|
|
MFD_DEV_WITH_ID(ALDO, 5),
|
|
MFD_DEV_WITH_ID(ALDO, 6),
|
|
MFD_DEV_WITH_ID(ALDO, 7),
|
|
MFD_DEV_WITH_ID(ALDO, 8),
|
|
MFD_DEV_WITH_ID(ALDO, 9),
|
|
MFD_DEV_WITH_ID(ALDO, 10),
|
|
|
|
/* ADC */
|
|
MFD_DEV_SIMPLE(ADC),
|
|
|
|
/* battery charger */
|
|
MFD_DEV_WITH_RESOURCE(CHARGER, chg_irqs, ARRAY_SIZE(chg_irqs)),
|
|
|
|
/* rtc */
|
|
MFD_DEV_WITH_RESOURCE(RTC, rtc_irqs, ARRAY_SIZE(rtc_irqs)),
|
|
|
|
/* backlight */
|
|
MFD_DEV_SIMPLE(BACKLIGHT),
|
|
|
|
/* current sink for vibrator */
|
|
MFD_DEV_SIMPLE(VIBRATOR),
|
|
|
|
/* current sink for keypad LED */
|
|
MFD_DEV_SIMPLE(KEYLED),
|
|
};
|
|
|
|
int lp8788_read_byte(struct lp8788 *lp, u8 reg, u8 *data)
|
|
{
|
|
int ret;
|
|
unsigned int val;
|
|
|
|
ret = regmap_read(lp->regmap, reg, &val);
|
|
if (ret < 0) {
|
|
dev_err(lp->dev, "failed to read 0x%.2x\n", reg);
|
|
return ret;
|
|
}
|
|
|
|
*data = (u8)val;
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL_GPL(lp8788_read_byte);
|
|
|
|
int lp8788_read_multi_bytes(struct lp8788 *lp, u8 reg, u8 *data, size_t count)
|
|
{
|
|
return regmap_bulk_read(lp->regmap, reg, data, count);
|
|
}
|
|
EXPORT_SYMBOL_GPL(lp8788_read_multi_bytes);
|
|
|
|
int lp8788_write_byte(struct lp8788 *lp, u8 reg, u8 data)
|
|
{
|
|
return regmap_write(lp->regmap, reg, data);
|
|
}
|
|
EXPORT_SYMBOL_GPL(lp8788_write_byte);
|
|
|
|
int lp8788_update_bits(struct lp8788 *lp, u8 reg, u8 mask, u8 data)
|
|
{
|
|
return regmap_update_bits(lp->regmap, reg, mask, data);
|
|
}
|
|
EXPORT_SYMBOL_GPL(lp8788_update_bits);
|
|
|
|
static int lp8788_platform_init(struct lp8788 *lp)
|
|
{
|
|
struct lp8788_platform_data *pdata = lp->pdata;
|
|
|
|
return (pdata && pdata->init_func) ? pdata->init_func(lp) : 0;
|
|
}
|
|
|
|
static const struct regmap_config lp8788_regmap_config = {
|
|
.reg_bits = 8,
|
|
.val_bits = 8,
|
|
.max_register = MAX_LP8788_REGISTERS,
|
|
};
|
|
|
|
static int lp8788_probe(struct i2c_client *cl, const struct i2c_device_id *id)
|
|
{
|
|
struct lp8788 *lp;
|
|
struct lp8788_platform_data *pdata = dev_get_platdata(&cl->dev);
|
|
int ret;
|
|
|
|
lp = devm_kzalloc(&cl->dev, sizeof(struct lp8788), GFP_KERNEL);
|
|
if (!lp)
|
|
return -ENOMEM;
|
|
|
|
lp->regmap = devm_regmap_init_i2c(cl, &lp8788_regmap_config);
|
|
if (IS_ERR(lp->regmap)) {
|
|
ret = PTR_ERR(lp->regmap);
|
|
dev_err(&cl->dev, "regmap init i2c err: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
lp->pdata = pdata;
|
|
lp->dev = &cl->dev;
|
|
i2c_set_clientdata(cl, lp);
|
|
|
|
ret = lp8788_platform_init(lp);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = lp8788_irq_init(lp, cl->irq);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = mfd_add_devices(lp->dev, -1, lp8788_devs,
|
|
ARRAY_SIZE(lp8788_devs), NULL, 0, NULL);
|
|
if (ret)
|
|
goto err_exit_irq;
|
|
|
|
return 0;
|
|
|
|
err_exit_irq:
|
|
lp8788_irq_exit(lp);
|
|
return ret;
|
|
}
|
|
|
|
static void lp8788_remove(struct i2c_client *cl)
|
|
{
|
|
struct lp8788 *lp = i2c_get_clientdata(cl);
|
|
|
|
mfd_remove_devices(lp->dev);
|
|
lp8788_irq_exit(lp);
|
|
}
|
|
|
|
static const struct i2c_device_id lp8788_ids[] = {
|
|
{"lp8788", 0},
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(i2c, lp8788_ids);
|
|
|
|
static struct i2c_driver lp8788_driver = {
|
|
.driver = {
|
|
.name = "lp8788",
|
|
},
|
|
.probe = lp8788_probe,
|
|
.remove = lp8788_remove,
|
|
.id_table = lp8788_ids,
|
|
};
|
|
|
|
static int __init lp8788_init(void)
|
|
{
|
|
return i2c_add_driver(&lp8788_driver);
|
|
}
|
|
subsys_initcall(lp8788_init);
|
|
|
|
static void __exit lp8788_exit(void)
|
|
{
|
|
i2c_del_driver(&lp8788_driver);
|
|
}
|
|
module_exit(lp8788_exit);
|
|
|
|
MODULE_DESCRIPTION("TI LP8788 MFD Driver");
|
|
MODULE_AUTHOR("Milo Kim");
|
|
MODULE_LICENSE("GPL");
|