Path: blob/master/arch/arm/mach-nomadik/i2c-8815nhk.c
10817 views
#include <linux/module.h>1#include <linux/init.h>2#include <linux/i2c.h>3#include <linux/i2c-algo-bit.h>4#include <linux/i2c-gpio.h>5#include <linux/gpio.h>6#include <linux/platform_device.h>78/*9* There are two busses in the 8815NHK.10* They could, in theory, be driven by the hardware component, but we11* use bit-bang through GPIO by now, to keep things simple12*/1314static struct i2c_gpio_platform_data nhk8815_i2c_data0 = {15/* keep defaults for timeouts; pins are push-pull bidirectional */16.scl_pin = 62,17.sda_pin = 63,18};1920static struct i2c_gpio_platform_data nhk8815_i2c_data1 = {21/* keep defaults for timeouts; pins are push-pull bidirectional */22.scl_pin = 53,23.sda_pin = 54,24};2526/* first bus: GPIO XX and YY */27static struct platform_device nhk8815_i2c_dev0 = {28.name = "i2c-gpio",29.id = 0,30.dev = {31.platform_data = &nhk8815_i2c_data0,32},33};34/* second bus: GPIO XX and YY */35static struct platform_device nhk8815_i2c_dev1 = {36.name = "i2c-gpio",37.id = 1,38.dev = {39.platform_data = &nhk8815_i2c_data1,40},41};4243static int __init nhk8815_i2c_init(void)44{45nmk_gpio_set_mode(nhk8815_i2c_data0.scl_pin, NMK_GPIO_ALT_GPIO);46nmk_gpio_set_mode(nhk8815_i2c_data0.sda_pin, NMK_GPIO_ALT_GPIO);47platform_device_register(&nhk8815_i2c_dev0);4849nmk_gpio_set_mode(nhk8815_i2c_data1.scl_pin, NMK_GPIO_ALT_GPIO);50nmk_gpio_set_mode(nhk8815_i2c_data1.sda_pin, NMK_GPIO_ALT_GPIO);51platform_device_register(&nhk8815_i2c_dev1);5253return 0;54}5556static void __exit nhk8815_i2c_exit(void)57{58platform_device_unregister(&nhk8815_i2c_dev0);59platform_device_unregister(&nhk8815_i2c_dev1);60return;61}6263module_init(nhk8815_i2c_init);64module_exit(nhk8815_i2c_exit);656667