2 * drivers/gpio/max7300.c
4 * Copyright (C) 2009 Wolfram Sang, Pengutronix
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Check max730x.c for further details.
13 #include <linux/module.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/mutex.h>
17 #include <linux/i2c.h>
18 #include <linux/spi/max7301.h>
20 static int max7300_i2c_write(struct device *dev, unsigned int reg,
23 struct i2c_client *client = to_i2c_client(dev);
25 return i2c_smbus_write_byte_data(client, reg, val);
28 static int max7300_i2c_read(struct device *dev, unsigned int reg)
30 struct i2c_client *client = to_i2c_client(dev);
32 return i2c_smbus_read_byte_data(client, reg);
35 static int __devinit max7300_probe(struct i2c_client *client,
36 const struct i2c_device_id *id)
41 if (!i2c_check_functionality(client->adapter,
42 I2C_FUNC_SMBUS_BYTE_DATA))
45 ts = kzalloc(sizeof(struct max7301), GFP_KERNEL);
49 ts->read = max7300_i2c_read;
50 ts->write = max7300_i2c_write;
51 ts->dev = &client->dev;
53 ret = __max730x_probe(ts);
59 static int __devexit max7300_remove(struct i2c_client *client)
61 return __max730x_remove(&client->dev);
64 static const struct i2c_device_id max7300_id[] = {
68 MODULE_DEVICE_TABLE(i2c, max7300_id);
70 static struct i2c_driver max7300_driver = {
75 .probe = max7300_probe,
76 .remove = __devexit_p(max7300_remove),
77 .id_table = max7300_id,
80 static int __init max7300_init(void)
82 return i2c_add_driver(&max7300_driver);
84 subsys_initcall(max7300_init);
86 static void __exit max7300_exit(void)
88 i2c_del_driver(&max7300_driver);
90 module_exit(max7300_exit);
92 MODULE_AUTHOR("Wolfram Sang");
93 MODULE_LICENSE("GPL v2");
94 MODULE_DESCRIPTION("MAX7300 GPIO-Expander");