mirror of
https://github.com/torvalds/linux.git
synced 2024-12-04 10:01:41 +00:00
ed5c2f5fd1
The value returned by an i2c driver's remove function is mostly ignored. (Only an error message is printed if the value is non-zero that the error is ignored.) So change the prototype of the remove function to return no value. This way driver authors are not tempted to assume that passing an error to the upper layer is a good idea. All drivers are adapted accordingly. There is no intended change of behaviour, all callbacks were prepared to return 0 before. Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com> Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au> Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Crt Mori <cmo@melexis.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013 Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/* Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5 Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860 Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power Acked-by: Krzysztof Hałasa <khalasa@piap.pl> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <wsa@kernel.org>
159 lines
3.8 KiB
C
159 lines
3.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Intel SoC PMIC MFD Driver
|
|
*
|
|
* Copyright (C) 2013, 2014 Intel Corporation. All rights reserved.
|
|
*
|
|
* Author: Yang, Bin <bin.yang@intel.com>
|
|
* Author: Zhu, Lejun <lejun.zhu@linux.intel.com>
|
|
*/
|
|
|
|
#include <linux/acpi.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/module.h>
|
|
#include <linux/mfd/core.h>
|
|
#include <linux/mfd/intel_soc_pmic.h>
|
|
#include <linux/platform_data/x86/soc.h>
|
|
#include <linux/pwm.h>
|
|
#include <linux/regmap.h>
|
|
|
|
#include "intel_soc_pmic_core.h"
|
|
|
|
/* PWM consumed by the Intel GFX */
|
|
static struct pwm_lookup crc_pwm_lookup[] = {
|
|
PWM_LOOKUP("crystal_cove_pwm", 0, "0000:00:02.0", "pwm_pmic_backlight", 0, PWM_POLARITY_NORMAL),
|
|
};
|
|
|
|
static int intel_soc_pmic_i2c_probe(struct i2c_client *i2c,
|
|
const struct i2c_device_id *i2c_id)
|
|
{
|
|
struct device *dev = &i2c->dev;
|
|
struct intel_soc_pmic_config *config;
|
|
struct intel_soc_pmic *pmic;
|
|
int ret;
|
|
|
|
if (soc_intel_is_byt())
|
|
config = &intel_soc_pmic_config_byt_crc;
|
|
else
|
|
config = &intel_soc_pmic_config_cht_crc;
|
|
|
|
pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
|
|
if (!pmic)
|
|
return -ENOMEM;
|
|
|
|
dev_set_drvdata(dev, pmic);
|
|
|
|
pmic->regmap = devm_regmap_init_i2c(i2c, config->regmap_config);
|
|
if (IS_ERR(pmic->regmap))
|
|
return PTR_ERR(pmic->regmap);
|
|
|
|
pmic->irq = i2c->irq;
|
|
|
|
ret = regmap_add_irq_chip(pmic->regmap, pmic->irq,
|
|
config->irq_flags | IRQF_ONESHOT,
|
|
0, config->irq_chip,
|
|
&pmic->irq_chip_data);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = enable_irq_wake(pmic->irq);
|
|
if (ret)
|
|
dev_warn(dev, "Can't enable IRQ as wake source: %d\n", ret);
|
|
|
|
/* Add lookup table for crc-pwm */
|
|
pwm_add_table(crc_pwm_lookup, ARRAY_SIZE(crc_pwm_lookup));
|
|
|
|
/* To distuingish this domain from the GPIO/charger's irqchip domains */
|
|
irq_domain_update_bus_token(regmap_irq_get_domain(pmic->irq_chip_data),
|
|
DOMAIN_BUS_NEXUS);
|
|
|
|
ret = mfd_add_devices(dev, -1, config->cell_dev,
|
|
config->n_cell_devs, NULL, 0,
|
|
regmap_irq_get_domain(pmic->irq_chip_data));
|
|
if (ret)
|
|
goto err_del_irq_chip;
|
|
|
|
return 0;
|
|
|
|
err_del_irq_chip:
|
|
regmap_del_irq_chip(pmic->irq, pmic->irq_chip_data);
|
|
return ret;
|
|
}
|
|
|
|
static void intel_soc_pmic_i2c_remove(struct i2c_client *i2c)
|
|
{
|
|
struct intel_soc_pmic *pmic = dev_get_drvdata(&i2c->dev);
|
|
|
|
regmap_del_irq_chip(pmic->irq, pmic->irq_chip_data);
|
|
|
|
/* remove crc-pwm lookup table */
|
|
pwm_remove_table(crc_pwm_lookup, ARRAY_SIZE(crc_pwm_lookup));
|
|
|
|
mfd_remove_devices(&i2c->dev);
|
|
}
|
|
|
|
static void intel_soc_pmic_shutdown(struct i2c_client *i2c)
|
|
{
|
|
struct intel_soc_pmic *pmic = dev_get_drvdata(&i2c->dev);
|
|
|
|
disable_irq(pmic->irq);
|
|
|
|
return;
|
|
}
|
|
|
|
#if defined(CONFIG_PM_SLEEP)
|
|
static int intel_soc_pmic_suspend(struct device *dev)
|
|
{
|
|
struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
|
|
|
|
disable_irq(pmic->irq);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int intel_soc_pmic_resume(struct device *dev)
|
|
{
|
|
struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
|
|
|
|
enable_irq(pmic->irq);
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
static SIMPLE_DEV_PM_OPS(intel_soc_pmic_pm_ops, intel_soc_pmic_suspend,
|
|
intel_soc_pmic_resume);
|
|
|
|
static const struct i2c_device_id intel_soc_pmic_i2c_id[] = {
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(i2c, intel_soc_pmic_i2c_id);
|
|
|
|
#if defined(CONFIG_ACPI)
|
|
static const struct acpi_device_id intel_soc_pmic_acpi_match[] = {
|
|
{ "INT33FD" },
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE(acpi, intel_soc_pmic_acpi_match);
|
|
#endif
|
|
|
|
static struct i2c_driver intel_soc_pmic_i2c_driver = {
|
|
.driver = {
|
|
.name = "intel_soc_pmic_i2c",
|
|
.pm = &intel_soc_pmic_pm_ops,
|
|
.acpi_match_table = ACPI_PTR(intel_soc_pmic_acpi_match),
|
|
},
|
|
.probe = intel_soc_pmic_i2c_probe,
|
|
.remove = intel_soc_pmic_i2c_remove,
|
|
.id_table = intel_soc_pmic_i2c_id,
|
|
.shutdown = intel_soc_pmic_shutdown,
|
|
};
|
|
|
|
module_i2c_driver(intel_soc_pmic_i2c_driver);
|
|
|
|
MODULE_DESCRIPTION("I2C driver for Intel SoC PMIC");
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_AUTHOR("Yang, Bin <bin.yang@intel.com>");
|
|
MODULE_AUTHOR("Zhu, Lejun <lejun.zhu@linux.intel.com>");
|