summaryrefslogtreecommitdiffstats
path: root/drivers/mfd/twl4030.c
blob: 3b4c661a870ccdeded1662d403a8c5d016cdbd80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Copyright (C) 2010 Michael Grzeschik <mgr@pengutronix.de>
 *
 * This file is released under the GPLv2
 *
 */

#include <common.h>
#include <init.h>
#include <driver.h>
#include <xfuncs.h>
#include <errno.h>

#include <i2c/i2c.h>
#include <mfd/twl4030.h>

#define DRIVERNAME		"twl4030"

#define to_twl4030(a)		container_of(a, struct twl4030, cdev)

static struct twl4030 *twl_dev;

struct twl4030 *twl4030_get(void)
{
	if (!twl_dev)
		return NULL;

	return twl_dev;
}
EXPORT_SYMBOL(twl4030_get);

static int twl_probe(struct device_d *dev)
{
	if (twl_dev)
		return -EBUSY;

	twl_dev = xzalloc(sizeof(struct twl4030));
	twl_dev->core.cdev.name = DRIVERNAME;
	twl_dev->core.client = to_i2c_client(dev);
	twl_dev->core.cdev.size = 1024;
	twl_dev->core.cdev.dev = dev;
	twl_dev->core.cdev.ops = &twl_fops;

	devfs_create(&(twl_dev->core.cdev));

	return 0;
}

static struct driver_d twl_driver = {
	.name  = DRIVERNAME,
	.probe = twl_probe,
};

static int twl_init(void)
{
	i2c_driver_register(&twl_driver);
	return 0;
}

device_initcall(twl_init);