cregit-Linux how code gets into the kernel

Release 4.11 drivers/mfd/intel_soc_pmic_core.c

Directory: drivers/mfd
/*
 * intel_soc_pmic_core.c - Intel SoC PMIC MFD Driver
 *
 * Copyright (C) 2013, 2014 Intel Corporation. All rights reserved.
 *
 * 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 distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Author: Yang, Bin <bin.yang@intel.com>
 * Author: Zhu, Lejun <lejun.zhu@linux.intel.com>
 */

#include <linux/module.h>
#include <linux/mfd/core.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/gpio/consumer.h>
#include <linux/acpi.h>
#include <linux/regmap.h>
#include <linux/mfd/intel_soc_pmic.h>
#include <linux/gpio/machine.h>
#include <linux/pwm.h>
#include "intel_soc_pmic_core.h"

/* Lookup table for the Panel Enable/Disable line as GPIO signals */

static struct gpiod_lookup_table panel_gpio_table = {
	/* Intel GFX is consumer */
	.dev_id = "0000:00:02.0",
	.table = {
		/* Panel EN/DISABLE */
		GPIO_LOOKUP("gpio_crystalcove", 94, "panel", GPIO_ACTIVE_HIGH),
		{ },
        },
};

/* PWM consumed by the Intel GFX */

static struct pwm_lookup crc_pwm_lookup[] = {
	PWM_LOOKUP("crystal_cove_pwm", 0, "0000:00:02.0", "pwm_backlight", 0, PWM_POLARITY_NORMAL),
};


static int intel_soc_pmic_find_gpio_irq(struct device *dev) { struct gpio_desc *desc; int irq; desc = devm_gpiod_get_index(dev, "intel_soc_pmic", 0, GPIOD_IN); if (IS_ERR(desc)) return PTR_ERR(desc); irq = gpiod_to_irq(desc); if (irq < 0) dev_warn(dev, "Can't get irq: %d\n", irq); return irq; }

Contributors

PersonTokensPropCommitsCommitProp
Lejun Zhu6491.43%133.33%
Jarkko Nikula68.57%266.67%
Total70100.00%3100.00%


static int intel_soc_pmic_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *i2c_id) { struct device *dev = &i2c->dev; const struct acpi_device_id *id; struct intel_soc_pmic_config *config; struct intel_soc_pmic *pmic; int ret; int irq; id = acpi_match_device(dev->driver->acpi_match_table, dev); if (!id || !id->driver_data) return -ENODEV; config = (struct intel_soc_pmic_config *)id->driver_data; 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); /* * On some boards the PMIC interrupt may come from a GPIO line. Try to * lookup the ACPI table for a such connection and setup a GPIO * interrupt if it exists. Otherwise use the IRQ provided by I2C */ irq = intel_soc_pmic_find_gpio_irq(dev); pmic->irq = (irq < 0) ? i2c->irq : 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 binding for Panel Control to the GPIO Chip */ gpiod_add_lookup_table(&panel_gpio_table); /* Add lookup table for crc-pwm */ pwm_add_table(crc_pwm_lookup, ARRAY_SIZE(crc_pwm_lookup)); 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; }

Contributors

PersonTokensPropCommitsCommitProp
Lejun Zhu25990.24%120.00%
Shobhit Kumar186.27%240.00%
Kiran Padwal93.14%120.00%
Jarkko Nikula10.35%120.00%
Total287100.00%5100.00%


static int 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 lookup table for Panel Control from the GPIO Chip */ gpiod_remove_lookup_table(&panel_gpio_table); /* remove crc-pwm lookup table */ pwm_remove_table(crc_pwm_lookup, ARRAY_SIZE(crc_pwm_lookup)); mfd_remove_devices(&i2c->dev); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Lejun Zhu4671.88%133.33%
Shobhit Kumar1828.12%266.67%
Total64100.00%3100.00%


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; }

Contributors

PersonTokensPropCommitsCommitProp
Lejun Zhu32100.00%1100.00%
Total32100.00%1100.00%

#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; }

Contributors

PersonTokensPropCommitsCommitProp
Lejun Zhu31100.00%1100.00%
Total31100.00%1100.00%


static int intel_soc_pmic_resume(struct device *dev) { struct intel_soc_pmic *pmic = dev_get_drvdata(dev); enable_irq(pmic->irq); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Lejun Zhu31100.00%1100.00%
Total31100.00%1100.00%

#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", (kernel_ulong_t)&intel_soc_pmic_config_crc}, { }, }; 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>");

Overall Contributors

PersonTokensPropCommitsCommitProp
Lejun Zhu62282.49%19.09%
Shobhit Kumar9712.86%218.18%
Kiran Padwal91.19%19.09%
Lee Jones81.06%19.09%
Jaewon Kim81.06%19.09%
Jarkko Nikula70.93%327.27%
Ville Syrjälä20.27%19.09%
Mathias Krause10.13%19.09%
Total754100.00%11100.00%
Directory: drivers/mfd
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.