Release 4.7 drivers/mfd/pcf50633-core.c
/* NXP PCF50633 Power Management Unit (PMU) driver
*
* (C) 2006-2008 by Openmoko, Inc.
* Author: Harald Welte <laforge@openmoko.org>
* Balaji Rao <balajirrao@openmoko.org>
* 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 as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/sysfs.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/regmap.h>
#include <linux/err.h>
#include <linux/mfd/pcf50633/core.h>
/* Read a block of up to 32 regs */
int pcf50633_read_block(struct pcf50633 *pcf, u8 reg,
int nr_regs, u8 *data)
{
int ret;
ret = regmap_raw_read(pcf->regmap, reg, data, nr_regs);
if (ret != 0)
return ret;
return nr_regs;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 43 | 86.00% | 1 | 50.00% |
mark brown | mark brown | 7 | 14.00% | 1 | 50.00% |
| Total | 50 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(pcf50633_read_block);
/* Write a block of up to 32 regs */
int pcf50633_write_block(struct pcf50633 *pcf , u8 reg,
int nr_regs, u8 *data)
{
return regmap_raw_write(pcf->regmap, reg, data, nr_regs);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 27 | 79.41% | 1 | 33.33% |
mark brown | mark brown | 6 | 17.65% | 1 | 33.33% |
axel lin | axel lin | 1 | 2.94% | 1 | 33.33% |
| Total | 34 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(pcf50633_write_block);
u8 pcf50633_reg_read(struct pcf50633 *pcf, u8 reg)
{
unsigned int val;
int ret;
ret = regmap_read(pcf->regmap, reg, &val);
if (ret < 0)
return -1;
return val;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 28 | 59.57% | 1 | 50.00% |
mark brown | mark brown | 19 | 40.43% | 1 | 50.00% |
| Total | 47 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(pcf50633_reg_read);
int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val)
{
return regmap_write(pcf->regmap, reg, val);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 25 | 89.29% | 1 | 50.00% |
mark brown | mark brown | 3 | 10.71% | 1 | 50.00% |
| Total | 28 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(pcf50633_reg_write);
int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val)
{
return regmap_update_bits(pcf->regmap, reg, mask, val);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 29 | 87.88% | 1 | 50.00% |
mark brown | mark brown | 4 | 12.12% | 1 | 50.00% |
| Total | 33 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(pcf50633_reg_set_bit_mask);
int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 val)
{
return regmap_update_bits(pcf->regmap, reg, val, 0);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 26 | 86.67% | 1 | 50.00% |
mark brown | mark brown | 4 | 13.33% | 1 | 50.00% |
| Total | 30 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(pcf50633_reg_clear_bits);
/* sysfs attributes */
static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct pcf50633 *pcf = dev_get_drvdata(dev);
u8 dump[16];
int n, n1, idx = 0;
char *buf1 = buf;
static u8 address_no_read[] = { /* must be ascending */
PCF50633_REG_INT1,
PCF50633_REG_INT2,
PCF50633_REG_INT3,
PCF50633_REG_INT4,
PCF50633_REG_INT5,
0 /* terminator */
};
for (n = 0; n < 256; n += sizeof(dump)) {
for (n1 = 0; n1 < sizeof(dump); n1++)
if (n == address_no_read[idx]) {
idx++;
dump[n1] = 0x00;
} else
dump[n1] = pcf50633_reg_read(pcf, n + n1);
buf1 += sprintf(buf1, "%*ph\n", (int)sizeof(dump), dump);
}
return buf1 - buf;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 157 | 94.01% | 1 | 50.00% |
andy shevchenko | andy shevchenko | 10 | 5.99% | 1 | 50.00% |
| Total | 167 | 100.00% | 2 | 100.00% |
static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL);
static ssize_t show_resume_reason(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct pcf50633 *pcf = dev_get_drvdata(dev);
int n;
n = sprintf(buf, "%02x%02x%02x%02x%02x\n",
pcf->resume_reason[0],
pcf->resume_reason[1],
pcf->resume_reason[2],
pcf->resume_reason[3],
pcf->resume_reason[4]);
return n;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 80 | 100.00% | 1 | 100.00% |
| Total | 80 | 100.00% | 1 | 100.00% |
static DEVICE_ATTR(resume_reason, 0400, show_resume_reason, NULL);
static struct attribute *pcf_sysfs_entries[] = {
&dev_attr_dump_regs.attr,
&dev_attr_resume_reason.attr,
NULL,
};
static struct attribute_group pcf_attr_group = {
.name = NULL, /* put in device directory */
.attrs = pcf_sysfs_entries,
};
static void
pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
struct platform_device **pdev)
{
int ret;
*pdev = platform_device_alloc(name, -1);
if (!*pdev) {
dev_err(pcf->dev, "Falied to allocate %s\n", name);
return;
}
(*pdev)->dev.parent = pcf->dev;
ret = platform_device_add(*pdev);
if (ret) {
dev_err(pcf->dev, "Failed to register %s: %d\n", name, ret);
platform_device_put(*pdev);
*pdev = NULL;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
lars-peter clausen | lars-peter clausen | 71 | 66.36% | 1 | 50.00% |
balaji rao | balaji rao | 36 | 33.64% | 1 | 50.00% |
| Total | 107 | 100.00% | 2 | 100.00% |
#ifdef CONFIG_PM_SLEEP
static int pcf50633_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct pcf50633 *pcf = i2c_get_clientdata(client);
return pcf50633_irq_suspend(pcf);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mark brown | mark brown | 14 | 37.84% | 1 | 33.33% |
balaji rao | balaji rao | 12 | 32.43% | 1 | 33.33% |
lars-peter clausen | lars-peter clausen | 11 | 29.73% | 1 | 33.33% |
| Total | 37 | 100.00% | 3 | 100.00% |
static int pcf50633_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct pcf50633 *pcf = i2c_get_clientdata(client);
return pcf50633_irq_resume(pcf);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 19 | 51.35% | 1 | 25.00% |
mark brown | mark brown | 14 | 37.84% | 1 | 25.00% |
lars-peter clausen | lars-peter clausen | 4 | 10.81% | 2 | 50.00% |
| Total | 37 | 100.00% | 4 | 100.00% |
#endif
static SIMPLE_DEV_PM_OPS(pcf50633_pm, pcf50633_suspend, pcf50633_resume);
static const struct regmap_config pcf50633_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};
static int pcf50633_probe(struct i2c_client *client,
const struct i2c_device_id *ids)
{
struct pcf50633 *pcf;
struct platform_device *pdev;
struct pcf50633_platform_data *pdata = dev_get_platdata(&client->dev);
int i, j, ret;
int version, variant;
if (!client->irq) {
dev_err(&client->dev, "Missing IRQ\n");
return -ENOENT;
}
pcf = devm_kzalloc(&client->dev, sizeof(*pcf), GFP_KERNEL);
if (!pcf)
return -ENOMEM;
i2c_set_clientdata(client, pcf);
pcf->dev = &client->dev;
pcf->pdata = pdata;
mutex_init(&pcf->lock);
pcf->regmap = devm_regmap_init_i2c(client, &pcf50633_regmap_config);
if (IS_ERR(pcf->regmap)) {
ret = PTR_ERR(pcf->regmap);
dev_err(pcf->dev, "Failed to allocate register map: %d\n", ret);
return ret;
}
version = pcf50633_reg_read(pcf, 0);
variant = pcf50633_reg_read(pcf, 1);
if (version < 0 || variant < 0) {
dev_err(pcf->dev, "Unable to probe pcf50633\n");
ret = -ENODEV;
return ret;
}
dev_info(pcf->dev, "Probed device version %d variant %d\n",
version, variant);
pcf50633_irq_init(pcf, client->irq);
/* Create sub devices */
pcf50633_client_dev_register(pcf, "pcf50633-input", &pcf->input_pdev);
pcf50633_client_dev_register(pcf, "pcf50633-rtc", &pcf->rtc_pdev);
pcf50633_client_dev_register(pcf, "pcf50633-mbc", &pcf->mbc_pdev);
pcf50633_client_dev_register(pcf, "pcf50633-adc", &pcf->adc_pdev);
pcf50633_client_dev_register(pcf, "pcf50633-backlight", &pcf->bl_pdev);
for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
pdev = platform_device_alloc("pcf50633-regulator", i);
if (!pdev)
return -ENOMEM;
pdev->dev.parent = pcf->dev;
ret = platform_device_add_data(pdev, &pdata->reg_init_data[i],
sizeof(pdata->reg_init_data[i]));
if (ret)
goto err;
ret = platform_device_add(pdev);
if (ret)
goto err;
pcf->regulator_pdev[i] = pdev;
}
ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group);
if (ret)
dev_warn(pcf->dev, "error creating sysfs entries\n");
if (pdata->probe_done)
pdata->probe_done(pcf);
return 0;
err:
platform_device_put(pdev);
for (j = 0; j < i; j++)
platform_device_put(pcf->regulator_pdev[j]);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 294 | 60.87% | 1 | 7.69% |
lee jones | lee jones | 65 | 13.46% | 2 | 15.38% |
lars-peter clausen | lars-peter clausen | 55 | 11.39% | 4 | 30.77% |
mark brown | mark brown | 32 | 6.63% | 1 | 7.69% |
axel lin | axel lin | 30 | 6.21% | 3 | 23.08% |
jingoo han | jingoo han | 4 | 0.83% | 1 | 7.69% |
alan cox | alan cox | 3 | 0.62% | 1 | 7.69% |
| Total | 483 | 100.00% | 13 | 100.00% |
static int pcf50633_remove(struct i2c_client *client)
{
struct pcf50633 *pcf = i2c_get_clientdata(client);
int i;
sysfs_remove_group(&client->dev.kobj, &pcf_attr_group);
pcf50633_irq_free(pcf);
platform_device_unregister(pcf->input_pdev);
platform_device_unregister(pcf->rtc_pdev);
platform_device_unregister(pcf->mbc_pdev);
platform_device_unregister(pcf->adc_pdev);
platform_device_unregister(pcf->bl_pdev);
for (i = 0; i < PCF50633_NUM_REGULATORS; i++)
platform_device_unregister(pcf->regulator_pdev[i]);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 82 | 79.61% | 1 | 33.33% |
axel lin | axel lin | 20 | 19.42% | 1 | 33.33% |
lars-peter clausen | lars-peter clausen | 1 | 0.97% | 1 | 33.33% |
| Total | 103 | 100.00% | 3 | 100.00% |
static const struct i2c_device_id pcf50633_id_table[] = {
{"pcf50633", 0x73},
{/* end of list */}
};
MODULE_DEVICE_TABLE(i2c, pcf50633_id_table);
static struct i2c_driver pcf50633_driver = {
.driver = {
.name = "pcf50633",
.pm = &pcf50633_pm,
},
.id_table = pcf50633_id_table,
.probe = pcf50633_probe,
.remove = pcf50633_remove,
};
static int __init pcf50633_init(void)
{
return i2c_add_driver(&pcf50633_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 16 | 100.00% | 1 | 100.00% |
| Total | 16 | 100.00% | 1 | 100.00% |
static void __exit pcf50633_exit(void)
{
i2c_del_driver(&pcf50633_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 15 | 100.00% | 1 | 100.00% |
| Total | 15 | 100.00% | 1 | 100.00% |
MODULE_DESCRIPTION("I2C chip driver for NXP PCF50633 PMU");
MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>");
MODULE_LICENSE("GPL");
subsys_initcall(pcf50633_init);
module_exit(pcf50633_exit);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
balaji rao | balaji rao | 1085 | 71.01% | 1 | 4.00% |
mark brown | mark brown | 147 | 9.62% | 2 | 8.00% |
lars-peter clausen | lars-peter clausen | 144 | 9.42% | 5 | 20.00% |
lee jones | lee jones | 65 | 4.25% | 2 | 8.00% |
axel lin | axel lin | 59 | 3.86% | 7 | 28.00% |
andy shevchenko | andy shevchenko | 10 | 0.65% | 1 | 4.00% |
jean delvare | jean delvare | 5 | 0.33% | 1 | 4.00% |
jingoo han | jingoo han | 4 | 0.26% | 1 | 4.00% |
alan cox | alan cox | 3 | 0.20% | 1 | 4.00% |
tejun heo | tejun heo | 3 | 0.20% | 1 | 4.00% |
lucas de marchi | lucas de marchi | 1 | 0.07% | 1 | 4.00% |
samuel ortiz | samuel ortiz | 1 | 0.07% | 1 | 4.00% |
krzysztof kozlowski | krzysztof kozlowski | 1 | 0.07% | 1 | 4.00% |
| Total | 1528 | 100.00% | 25 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.