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
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/abx500/ab8500.h>
14
#include <linux/mfd/dbx500-prcmu.h>
16
static int ab8500_i2c_write(struct ab8500 *ab8500, u16 addr, u8 data)
20
ret = prcmu_abb_write((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1);
22
dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
26
static int ab8500_i2c_write_masked(struct ab8500 *ab8500, u16 addr, u8 mask,
31
ret = prcmu_abb_write_masked((u8)(addr >> 8), (u8)(addr & 0xFF), &data,
34
dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
38
static int ab8500_i2c_read(struct ab8500 *ab8500, u16 addr)
43
ret = prcmu_abb_read((u8)(addr >> 8), (u8)(addr & 0xFF), &data, 1);
45
dev_err(ab8500->dev, "prcmu i2c error %d\n", ret);
51
static int __devinit ab8500_i2c_probe(struct platform_device *plf)
53
const struct platform_device_id *platid = platform_get_device_id(plf);
54
struct ab8500 *ab8500;
55
struct resource *resource;
58
ab8500 = kzalloc(sizeof *ab8500, GFP_KERNEL);
62
ab8500->dev = &plf->dev;
64
resource = platform_get_resource(plf, IORESOURCE_IRQ, 0);
70
ab8500->irq = resource->start;
72
ab8500->read = ab8500_i2c_read;
73
ab8500->write = ab8500_i2c_write;
74
ab8500->write_masked = ab8500_i2c_write_masked;
76
platform_set_drvdata(plf, ab8500);
78
ret = ab8500_init(ab8500, platid->driver_data);
86
static int __devexit ab8500_i2c_remove(struct platform_device *plf)
88
struct ab8500 *ab8500 = platform_get_drvdata(plf);
96
static const struct platform_device_id ab8500_id[] = {
97
{ "ab8500-i2c", AB8500_VERSION_AB8500 },
98
{ "ab8505-i2c", AB8500_VERSION_AB8505 },
99
{ "ab9540-i2c", AB8500_VERSION_AB9540 },
100
{ "ab8540-i2c", AB8500_VERSION_AB8540 },
104
static struct platform_driver ab8500_i2c_driver = {
106
.name = "ab8500-i2c",
107
.owner = THIS_MODULE,
109
.probe = ab8500_i2c_probe,
110
.remove = __devexit_p(ab8500_i2c_remove),
111
.id_table = ab8500_id,
114
static int __init ab8500_i2c_init(void)
116
return platform_driver_register(&ab8500_i2c_driver);
119
static void __exit ab8500_i2c_exit(void)
121
platform_driver_unregister(&ab8500_i2c_driver);
123
arch_initcall(ab8500_i2c_init);
124
module_exit(ab8500_i2c_exit);
126
MODULE_AUTHOR("Mattias WALLIN <mattias.wallin@stericsson.com");
127
MODULE_DESCRIPTION("AB8500 Core access via PRCMU I2C");
128
MODULE_LICENSE("GPL v2");