From 7a0de86b74fff46d9c441d78ad49a32e6eb74c62 Mon Sep 17 00:00:00 2001 From: FrankBuss Date: Tue, 8 May 2012 01:10:11 -0400 Subject: [PATCH 1/6] I2C-GPIO driver enabled --- arch/arm/mach-bcm2708/bcm2708.c | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index 54476fcf92d74f..12a657029c8041 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -374,6 +375,37 @@ static struct platform_device bcm2708_gpio_device = { .coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON), }, }; + +/* I2C at the pin header */ +static struct i2c_gpio_platform_data bcm2708_i2c_gpio_data0 = { + .sda_pin = 0, /* GPIO 0, SDA0 */ + .sda_is_open_drain = 0, + .scl_pin = 1, /* GPIO 1, SCL0 */ + .scl_is_open_drain = 0, + .udelay = 0, /* default to 100 kHz */ + .timeout = 0, /* default to 100 ms */ +}; +static struct platform_device bcm2708_i2c_device0 = { + .name = "i2c-gpio", + .id = 0, + .dev.platform_data = &bcm2708_i2c_gpio_data0, +}; + +/* I2C at the camera connector */ +static struct i2c_gpio_platform_data bcm2708_i2c_gpio_data1 = { + .sda_pin = 2, /* GPIO 2, SDA1 */ + .sda_is_open_drain = 0, + .scl_pin = 3, /* GPIO 3, SCL1 */ + .scl_is_open_drain = 0, + .udelay = 0, /* default to 100 kHz */ + .timeout = 0, /* default to 100 ms */ +}; +static struct platform_device bcm2708_i2c_device1 = { + .name = "i2c-gpio", + .id = 1, + .dev.platform_data = &bcm2708_i2c_gpio_data1, +}; + #endif static struct resource bcm2708_systemtimer_resources[] = { @@ -496,6 +528,10 @@ void __init bcm2708_init(void) bcm_register_device(&bcm2708_emmc_device); #endif bcm2708_init_led(); +#ifdef CONFIG_I2C_GPIO + bcm_register_device(&bcm2708_i2c_device0); + bcm_register_device(&bcm2708_i2c_device1); +#endif for (i = 0; i < ARRAY_SIZE(bcm2708_alsa_devices); i++) bcm_register_device(&bcm2708_alsa_devices[i]); From 04985ff7d0704ad8e79a505cd785aef679e8a77e Mon Sep 17 00:00:00 2001 From: FrankBuss Date: Tue, 8 May 2012 21:50:54 -0400 Subject: [PATCH 2/6] changed driver init order, because GPIO is architecture level and should be loaded before all other modules --- arch/arm/mach-bcm2708/bcm2708_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-bcm2708/bcm2708_gpio.c b/arch/arm/mach-bcm2708/bcm2708_gpio.c index 59df912fc84d70..2c9c530605cad5 100644 --- a/arch/arm/mach-bcm2708/bcm2708_gpio.c +++ b/arch/arm/mach-bcm2708/bcm2708_gpio.c @@ -315,7 +315,7 @@ static void __exit bcm2708_gpio_exit(void) platform_driver_unregister(&bcm2708_gpio_driver); } -module_init(bcm2708_gpio_init); +arch_initcall(bcm2708_gpio_init); module_exit(bcm2708_gpio_exit); MODULE_DESCRIPTION("Broadcom BCM2708 GPIO driver"); From b51c6a3f26aa3a5222fb3ad98d0c1ff1d7b92324 Mon Sep 17 00:00:00 2001 From: FrankBuss Date: Tue, 8 May 2012 21:53:09 -0400 Subject: [PATCH 3/6] structure only needed whe I2C_GPIO ins enabled --- arch/arm/mach-bcm2708/bcm2708.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index 12a657029c8041..1f92c7386a6e78 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -376,6 +376,10 @@ static struct platform_device bcm2708_gpio_device = { }, }; +#endif + +#ifdef CONFIG_I2C_GPIO + /* I2C at the pin header */ static struct i2c_gpio_platform_data bcm2708_i2c_gpio_data0 = { .sda_pin = 0, /* GPIO 0, SDA0 */ From 28e096c43a711f1f7f833b4c51afbe82cfa21584 Mon Sep 17 00:00:00 2001 From: Stuart Poulton Date: Thu, 10 May 2012 08:15:44 +0000 Subject: [PATCH 4/6] bcm2708: Fix i2c platform device registration when CONFIG_I2C_GPIO=m --- arch/arm/mach-bcm2708/bcm2708.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index 1f92c7386a6e78..f1134959e05796 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -378,7 +378,7 @@ static struct platform_device bcm2708_gpio_device = { #endif -#ifdef CONFIG_I2C_GPIO +#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) /* I2C at the pin header */ static struct i2c_gpio_platform_data bcm2708_i2c_gpio_data0 = { @@ -532,7 +532,7 @@ void __init bcm2708_init(void) bcm_register_device(&bcm2708_emmc_device); #endif bcm2708_init_led(); -#ifdef CONFIG_I2C_GPIO +#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) bcm_register_device(&bcm2708_i2c_device0); bcm_register_device(&bcm2708_i2c_device1); #endif From 891b6288fa4ea29d99b24f426b034cae2044c758 Mon Sep 17 00:00:00 2001 From: FrankBuss Date: Thu, 10 May 2012 19:57:20 -0400 Subject: [PATCH 5/6] fine tuning for 100 kHz I2C bus speed --- arch/arm/mach-bcm2708/bcm2708.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index f1134959e05796..6385544a0a8376 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -380,13 +380,15 @@ static struct platform_device bcm2708_gpio_device = { #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) +#define I2C_UDELAY 4 + /* I2C at the pin header */ static struct i2c_gpio_platform_data bcm2708_i2c_gpio_data0 = { .sda_pin = 0, /* GPIO 0, SDA0 */ .sda_is_open_drain = 0, .scl_pin = 1, /* GPIO 1, SCL0 */ .scl_is_open_drain = 0, - .udelay = 0, /* default to 100 kHz */ + .udelay = I2C_UDELAY, /* 100 kHz */ .timeout = 0, /* default to 100 ms */ }; static struct platform_device bcm2708_i2c_device0 = { @@ -401,7 +403,7 @@ static struct i2c_gpio_platform_data bcm2708_i2c_gpio_data1 = { .sda_is_open_drain = 0, .scl_pin = 3, /* GPIO 3, SCL1 */ .scl_is_open_drain = 0, - .udelay = 0, /* default to 100 kHz */ + .udelay = I2C_UDELAY, /* 100 kHz */ .timeout = 0, /* default to 100 ms */ }; static struct platform_device bcm2708_i2c_device1 = { From ec7d9a4f66b55ce21d6fcdef3592154e45ec02bf Mon Sep 17 00:00:00 2001 From: FrankBuss Date: Thu, 10 May 2012 19:58:06 -0400 Subject: [PATCH 6/6] enabling I2C-GPIO as a module --- arch/arm/configs/bcmrpi_cutdown_defconfig | 7 +++++++ arch/arm/configs/bcmrpi_defconfig | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/arch/arm/configs/bcmrpi_cutdown_defconfig b/arch/arm/configs/bcmrpi_cutdown_defconfig index 6732014acf13ee..a3da4f0fc620df 100644 --- a/arch/arm/configs/bcmrpi_cutdown_defconfig +++ b/arch/arm/configs/bcmrpi_cutdown_defconfig @@ -492,3 +492,10 @@ CONFIG_CRYPTO_DEFLATE=m # CONFIG_CRYPTO_HW is not set CONFIG_CRC_ITU_T=y CONFIG_LIBCRC32C=y +CONFIG_I2C=y +CONFIG_I2C_ALGOBIT=m +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_GPIO=m +CONFIG_I2C_HELPER_AUTO=y diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig index fcbf8a5b836108..ad9c95618a8811 100644 --- a/arch/arm/configs/bcmrpi_defconfig +++ b/arch/arm/configs/bcmrpi_defconfig @@ -528,3 +528,10 @@ CONFIG_CRYPTO_DEFLATE=m # CONFIG_CRYPTO_HW is not set CONFIG_CRC_ITU_T=y CONFIG_LIBCRC32C=y +CONFIG_I2C=y +CONFIG_I2C_ALGOBIT=m +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_COMPAT=y +CONFIG_I2C_GPIO=m +CONFIG_I2C_HELPER_AUTO=y