blob: 0c2f6628299aa6bc2a7c95b567ff56344dd7df87 [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 Walleijbb16bd92012-10-10 14:27:58 +02007#include <linux/platform_data/pinctrl-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
Linus Walleij661d4142012-01-25 14:34:52 +010015/* I2C0 connected to the STw4811 power management chip */
Alessandro Rubini63796b72009-07-02 15:29:22 +010016static struct i2c_gpio_platform_data nhk8815_i2c_data0 = {
17 /* keep defaults for timeouts; pins are push-pull bidirectional */
18 .scl_pin = 62,
19 .sda_pin = 63,
20};
21
Linus Walleij661d4142012-01-25 14:34:52 +010022/* I2C1 connected to various sensors */
Alessandro Rubini63796b72009-07-02 15:29:22 +010023static struct i2c_gpio_platform_data nhk8815_i2c_data1 = {
24 /* keep defaults for timeouts; pins are push-pull bidirectional */
25 .scl_pin = 53,
26 .sda_pin = 54,
27};
28
Linus Walleij661d4142012-01-25 14:34:52 +010029/* I2C2 connected to the USB portions of the STw4811 only */
30static struct i2c_gpio_platform_data nhk8815_i2c_data2 = {
31 /* keep defaults for timeouts; pins are push-pull bidirectional */
32 .scl_pin = 73,
33 .sda_pin = 74,
34};
35
Alessandro Rubini63796b72009-07-02 15:29:22 +010036static struct platform_device nhk8815_i2c_dev0 = {
37 .name = "i2c-gpio",
38 .id = 0,
39 .dev = {
40 .platform_data = &nhk8815_i2c_data0,
41 },
42};
Linus Walleij661d4142012-01-25 14:34:52 +010043
Alessandro Rubini63796b72009-07-02 15:29:22 +010044static struct platform_device nhk8815_i2c_dev1 = {
45 .name = "i2c-gpio",
46 .id = 1,
47 .dev = {
48 .platform_data = &nhk8815_i2c_data1,
49 },
50};
51
Linus Walleij661d4142012-01-25 14:34:52 +010052static struct platform_device nhk8815_i2c_dev2 = {
53 .name = "i2c-gpio",
54 .id = 2,
55 .dev = {
56 .platform_data = &nhk8815_i2c_data2,
57 },
58};
59
60static pin_cfg_t cpu8815_pins_i2c[] = {
61 PIN_CFG_INPUT(62, GPIO, PULLUP),
62 PIN_CFG_INPUT(63, GPIO, PULLUP),
63 PIN_CFG_INPUT(53, GPIO, PULLUP),
64 PIN_CFG_INPUT(54, GPIO, PULLUP),
65 PIN_CFG_INPUT(73, GPIO, PULLUP),
66 PIN_CFG_INPUT(74, GPIO, PULLUP),
67};
68
Alessandro Rubini63796b72009-07-02 15:29:22 +010069static int __init nhk8815_i2c_init(void)
70{
Linus Walleij661d4142012-01-25 14:34:52 +010071 nmk_config_pins(cpu8815_pins_i2c, ARRAY_SIZE(cpu8815_pins_i2c));
Alessandro Rubini63796b72009-07-02 15:29:22 +010072 platform_device_register(&nhk8815_i2c_dev0);
Alessandro Rubini63796b72009-07-02 15:29:22 +010073 platform_device_register(&nhk8815_i2c_dev1);
Linus Walleij661d4142012-01-25 14:34:52 +010074 platform_device_register(&nhk8815_i2c_dev2);
Alessandro Rubini63796b72009-07-02 15:29:22 +010075
76 return 0;
77}
78
79static void __exit nhk8815_i2c_exit(void)
80{
81 platform_device_unregister(&nhk8815_i2c_dev0);
82 platform_device_unregister(&nhk8815_i2c_dev1);
Linus Walleij661d4142012-01-25 14:34:52 +010083 platform_device_unregister(&nhk8815_i2c_dev2);
Alessandro Rubini63796b72009-07-02 15:29:22 +010084 return;
85}
86
87module_init(nhk8815_i2c_init);
88module_exit(nhk8815_i2c_exit);