um: remove SIGHUP handler
[linux/fpc-iii.git] / drivers / mfd / ab8500-i2c.c
blob821e6b86afd2a82a73811f65176fca1b3e835110
1 /*
2 * Copyright (C) ST-Ericsson SA 2010
3 * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson.
4 * License Terms: GNU General Public License v2
5 * This file was based on drivers/mfd/ab8500-spi.c
6 */
8 #include <linux/kernel.h>
9 #include <linux/slab.h>
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/platform_device.h>
13 #include <linux/mfd/ab8500.h>
15 #include <mach/prcmu.h>
17 static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data)
19 int ret;
21 ret = prcmu_abb_write((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1);
22 if (ret < 0)
23 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
24 return ret;
27 static int ab8500_i2c_read(struct ab8500 *ab8500, u16 addr)
29 int ret;
30 u8 data;
32 ret = prcmu_abb_read((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1);
33 if (ret < 0) {
34 dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
35 return ret;
37 return (int)data;
40 static int __devinit ab8500_i2c_probe(struct platform_device *plf)
42 struct ab8500 *ab8500;
43 struct resource *resource;
44 int ret;
46 ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL);
47 if (!ab8500)
48 return -ENOMEM;
50 ab8500->dev = &plf->dev;
52 resource = platform_get_resource(plf, IORESOURCE_IRQ, 0);
53 if (!resource) {
54 kfree(ab8500);
55 return -ENODEV;
58 ab8500->irq = resource->start;
60 ab8500->read = ab8500_i2c_read;
61 ab8500->write = ab8500_i2c_write;
63 platform_set_drvdata(plf, ab8500);
65 ret = ab8500_init(ab8500);
66 if (ret)
67 kfree(ab8500);
69 return ret;
72 static int __devexit ab8500_i2c_remove(struct platform_device *plf)
74 struct ab8500 *ab8500 = platform_get_drvdata(plf);
76 ab8500_exit(ab8500);
77 kfree(ab8500);
79 return 0;
82 static struct platform_driver ab8500_i2c_driver = {
83 .driver = {
84 .name = "ab8500-i2c",
85 .owner = THIS_MODULE,
87 .probe = ab8500_i2c_probe,
88 .remove = __devexit_p(ab8500_i2c_remove)
91 static int __init ab8500_i2c_init(void)
93 return platform_driver_register(&ab8500_i2c_driver);
96 static void __exit ab8500_i2c_exit(void)
98 platform_driver_unregister(&ab8500_i2c_driver);
100 arch_initcall(ab8500_i2c_init);
101 module_exit(ab8500_i2c_exit);
103 MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
104 MODULE_DESCRIPTION("AB8500 Core access via PRCMU I2C");
105 MODULE_LICENSE("GPL v2");