Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C with the Linux bitbanging interface activated #19

Closed
wants to merge 9 commits into from
7 changes: 7 additions & 0 deletions arch/arm/configs/bcmrpi_cutdown_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions arch/arm/configs/bcmrpi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
42 changes: 42 additions & 0 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/dma-mapping.h>
#include <linux/serial_8250.h>
#include <linux/platform_device.h>
#include <linux/i2c-gpio.h>
#include <linux/sysdev.h>
#include <linux/interrupt.h>
#include <linux/amba/bus.h>
Expand Down Expand Up @@ -374,6 +375,43 @@ static struct platform_device bcm2708_gpio_device = {
.coherent_dma_mask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON),
},
};

#endif

#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 = I2C_UDELAY, /* 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 = I2C_UDELAY, /* 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[] = {
Expand Down Expand Up @@ -496,6 +534,10 @@ void __init bcm2708_init(void)
bcm_register_device(&bcm2708_emmc_device);
#endif
bcm2708_init_led();
#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
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]);

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-bcm2708/bcm2708_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down