blob: 0fc2f6f1cc979097cf83de13a924c7fb05a105f1 [file] [log] [blame]
Alessandro Rubini63796b72009-07-02 15:29:22 +01001#include <linux/module.h>
2#include <linux/init.h>
3#include <linux/i2c.h>
4#include <linux/i2c-algo-bit.h>
5#include <linux/i2c-gpio.h>
Alessandro Rubini63796b72009-07-02 15:29:22 +01006#include <linux/platform_device.h>
Linus Walleij0f332862011-08-22 08:33:30 +01007#include <plat/gpio-nomadik.h>
Alessandro Rubini63796b72009-07-02 15:29:22 +01008
9/*
10 * There are two busses in the 8815NHK.
11 * They could, in theory, be driven by the hardware component, but we
12 * use bit-bang through GPIO by now, to keep things simple
13 */
14
15static struct i2c_gpio_platform_data nhk8815_i2c_data0 = {
16 /* keep defaults for timeouts; pins are push-pull bidirectional */
17 .scl_pin = 62,
18 .sda_pin = 63,
19};
20
21static struct i2c_gpio_platform_data nhk8815_i2c_data1 = {
22 /* keep defaults for timeouts; pins are push-pull bidirectional */
23 .scl_pin = 53,
24 .sda_pin = 54,
25};
26
27/* first bus: GPIO XX and YY */
28static struct platform_device nhk8815_i2c_dev0 = {
29 .name = "i2c-gpio",
30 .id = 0,
31 .dev = {
32 .platform_data = &nhk8815_i2c_data0,
33 },
34};
35/* second bus: GPIO XX and YY */
36static struct platform_device nhk8815_i2c_dev1 = {
37 .name = "i2c-gpio",
38 .id = 1,
39 .dev = {
40 .platform_data = &nhk8815_i2c_data1,
41 },
42};
43
44static int __init nhk8815_i2c_init(void)
45{
46 nmk_gpio_set_mode(nhk8815_i2c_data0.scl_pin, NMK_GPIO_ALT_GPIO);
47 nmk_gpio_set_mode(nhk8815_i2c_data0.sda_pin, NMK_GPIO_ALT_GPIO);
48 platform_device_register(&nhk8815_i2c_dev0);
49
50 nmk_gpio_set_mode(nhk8815_i2c_data1.scl_pin, NMK_GPIO_ALT_GPIO);
51 nmk_gpio_set_mode(nhk8815_i2c_data1.sda_pin, NMK_GPIO_ALT_GPIO);
52 platform_device_register(&nhk8815_i2c_dev1);
53
54 return 0;
55}
56
57static void __exit nhk8815_i2c_exit(void)
58{
59 platform_device_unregister(&nhk8815_i2c_dev0);
60 platform_device_unregister(&nhk8815_i2c_dev1);
61 return;
62}
63
64module_init(nhk8815_i2c_init);
65module_exit(nhk8815_i2c_exit);