1 /* 2 * Freescale MPL115A2 pressure/temperature sensor 3 * 4 * Copyright (c) 2014 Peter Meerwald <pmeerw@pmeerw.net> 5 * 6 * This file is subject to the terms and conditions of version 2 of 7 * the GNU General Public License. See the file COPYING in the main 8 * directory of this archive for more details. 9 * 10 * (7-bit I2C slave address 0x60) 11 * 12 * Datasheet: http://www.nxp.com/files/sensors/doc/data_sheet/MPL115A2.pdf 13 */ 14 15 #include <linux/module.h> 16 #include <linux/i2c.h> 17 18 #include "mpl115.h" 19 20 static int mpl115_i2c_init(struct device *dev) 21 { 22 return 0; 23 } 24 25 static int mpl115_i2c_read(struct device *dev, u8 address) 26 { 27 return i2c_smbus_read_word_swapped(to_i2c_client(dev), address); 28 } 29 30 static int mpl115_i2c_write(struct device *dev, u8 address, u8 value) 31 { 32 return i2c_smbus_write_byte_data(to_i2c_client(dev), address, value); 33 } 34 35 static const struct mpl115_ops mpl115_i2c_ops = { 36 .init = mpl115_i2c_init, 37 .read = mpl115_i2c_read, 38 .write = mpl115_i2c_write, 39 }; 40 41 static int mpl115_i2c_probe(struct i2c_client *client, 42 const struct i2c_device_id *id) 43 { 44 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) 45 return -EOPNOTSUPP; 46 47 return mpl115_probe(&client->dev, id->name, &mpl115_i2c_ops); 48 } 49 50 static const struct i2c_device_id mpl115_i2c_id[] = { 51 { "mpl115", 0 }, 52 { } 53 }; 54 MODULE_DEVICE_TABLE(i2c, mpl115_i2c_id); 55 56 static struct i2c_driver mpl115_i2c_driver = { 57 .driver = { 58 .name = "mpl115", 59 }, 60 .probe = mpl115_i2c_probe, 61 .id_table = mpl115_i2c_id, 62 }; 63 module_i2c_driver(mpl115_i2c_driver); 64 65 MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>"); 66 MODULE_DESCRIPTION("Freescale MPL115A2 pressure/temperature driver"); 67 MODULE_LICENSE("GPL"); 68