Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / mfd / stmpe-i2c.c
blob373f423b118164dbe1058fcba74694d4122c1527
1 /*
2 * ST Microelectronics MFD: stmpe's i2c client specific driver
4 * Copyright (C) ST-Ericsson SA 2010
5 * Copyright (C) ST Microelectronics SA 2011
7 * License Terms: GNU General Public License, version 2
8 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
9 * Author: Viresh Kumar <viresh.kumar@st.com> for ST Microelectronics
12 #include <linux/i2c.h>
13 #include <linux/interrupt.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include "stmpe.h"
19 static int i2c_reg_read(struct stmpe *stmpe, u8 reg)
21 struct i2c_client *i2c = stmpe->client;
23 return i2c_smbus_read_byte_data(i2c, reg);
26 static int i2c_reg_write(struct stmpe *stmpe, u8 reg, u8 val)
28 struct i2c_client *i2c = stmpe->client;
30 return i2c_smbus_write_byte_data(i2c, reg, val);
33 static int i2c_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values)
35 struct i2c_client *i2c = stmpe->client;
37 return i2c_smbus_read_i2c_block_data(i2c, reg, length, values);
40 static int i2c_block_write(struct stmpe *stmpe, u8 reg, u8 length,
41 const u8 *values)
43 struct i2c_client *i2c = stmpe->client;
45 return i2c_smbus_write_i2c_block_data(i2c, reg, length, values);
48 static struct stmpe_client_info i2c_ci = {
49 .read_byte = i2c_reg_read,
50 .write_byte = i2c_reg_write,
51 .read_block = i2c_block_read,
52 .write_block = i2c_block_write,
55 static int __devinit
56 stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
58 i2c_ci.data = (void *)id;
59 i2c_ci.irq = i2c->irq;
60 i2c_ci.client = i2c;
61 i2c_ci.dev = &i2c->dev;
63 return stmpe_probe(&i2c_ci, id->driver_data);
66 static int __devexit stmpe_i2c_remove(struct i2c_client *i2c)
68 struct stmpe *stmpe = dev_get_drvdata(&i2c->dev);
70 return stmpe_remove(stmpe);
73 static const struct i2c_device_id stmpe_i2c_id[] = {
74 { "stmpe610", STMPE610 },
75 { "stmpe801", STMPE801 },
76 { "stmpe811", STMPE811 },
77 { "stmpe1601", STMPE1601 },
78 { "stmpe2401", STMPE2401 },
79 { "stmpe2403", STMPE2403 },
80 { }
82 MODULE_DEVICE_TABLE(i2c, stmpe_id);
84 static struct i2c_driver stmpe_i2c_driver = {
85 .driver.name = "stmpe-i2c",
86 .driver.owner = THIS_MODULE,
87 #ifdef CONFIG_PM
88 .driver.pm = &stmpe_dev_pm_ops,
89 #endif
90 .probe = stmpe_i2c_probe,
91 .remove = __devexit_p(stmpe_i2c_remove),
92 .id_table = stmpe_i2c_id,
95 static int __init stmpe_init(void)
97 return i2c_add_driver(&stmpe_i2c_driver);
99 subsys_initcall(stmpe_init);
101 static void __exit stmpe_exit(void)
103 i2c_del_driver(&stmpe_i2c_driver);
105 module_exit(stmpe_exit);
107 MODULE_LICENSE("GPL v2");
108 MODULE_DESCRIPTION("STMPE MFD I2C Interface Driver");
109 MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>");