2009-07-02 22:29:22 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/i2c-algo-bit.h>
|
|
|
|
#include <linux/i2c-gpio.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There are two busses in the 8815NHK.
|
|
|
|
* They could, in theory, be driven by the hardware component, but we
|
|
|
|
* use bit-bang through GPIO by now, to keep things simple
|
|
|
|
*/
|
|
|
|
|
2012-01-25 21:34:52 +08:00
|
|
|
/* I2C0 connected to the STw4811 power management chip */
|
2009-07-02 22:29:22 +08:00
|
|
|
static struct i2c_gpio_platform_data nhk8815_i2c_data0 = {
|
|
|
|
/* keep defaults for timeouts; pins are push-pull bidirectional */
|
|
|
|
.scl_pin = 62,
|
|
|
|
.sda_pin = 63,
|
|
|
|
};
|
|
|
|
|
2012-01-25 21:34:52 +08:00
|
|
|
/* I2C1 connected to various sensors */
|
2009-07-02 22:29:22 +08:00
|
|
|
static struct i2c_gpio_platform_data nhk8815_i2c_data1 = {
|
|
|
|
/* keep defaults for timeouts; pins are push-pull bidirectional */
|
|
|
|
.scl_pin = 53,
|
|
|
|
.sda_pin = 54,
|
|
|
|
};
|
|
|
|
|
2012-01-25 21:34:52 +08:00
|
|
|
/* I2C2 connected to the USB portions of the STw4811 only */
|
|
|
|
static struct i2c_gpio_platform_data nhk8815_i2c_data2 = {
|
|
|
|
/* keep defaults for timeouts; pins are push-pull bidirectional */
|
|
|
|
.scl_pin = 73,
|
|
|
|
.sda_pin = 74,
|
|
|
|
};
|
|
|
|
|
2009-07-02 22:29:22 +08:00
|
|
|
static struct platform_device nhk8815_i2c_dev0 = {
|
|
|
|
.name = "i2c-gpio",
|
|
|
|
.id = 0,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &nhk8815_i2c_data0,
|
|
|
|
},
|
|
|
|
};
|
2012-01-25 21:34:52 +08:00
|
|
|
|
2009-07-02 22:29:22 +08:00
|
|
|
static struct platform_device nhk8815_i2c_dev1 = {
|
|
|
|
.name = "i2c-gpio",
|
|
|
|
.id = 1,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &nhk8815_i2c_data1,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-01-25 21:34:52 +08:00
|
|
|
static struct platform_device nhk8815_i2c_dev2 = {
|
|
|
|
.name = "i2c-gpio",
|
|
|
|
.id = 2,
|
|
|
|
.dev = {
|
|
|
|
.platform_data = &nhk8815_i2c_data2,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2009-07-02 22:29:22 +08:00
|
|
|
static int __init nhk8815_i2c_init(void)
|
|
|
|
{
|
|
|
|
platform_device_register(&nhk8815_i2c_dev0);
|
|
|
|
platform_device_register(&nhk8815_i2c_dev1);
|
2012-01-25 21:34:52 +08:00
|
|
|
platform_device_register(&nhk8815_i2c_dev2);
|
2009-07-02 22:29:22 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit nhk8815_i2c_exit(void)
|
|
|
|
{
|
|
|
|
platform_device_unregister(&nhk8815_i2c_dev0);
|
|
|
|
platform_device_unregister(&nhk8815_i2c_dev1);
|
2012-01-25 21:34:52 +08:00
|
|
|
platform_device_unregister(&nhk8815_i2c_dev2);
|
2009-07-02 22:29:22 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(nhk8815_i2c_init);
|
|
|
|
module_exit(nhk8815_i2c_exit);
|