From 488b02ff6c4c145bd96dcf02aa52e3a5fb289be1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 21 Dec 2014 17:20:16 -0600 Subject: [PATCH] Tiva: Add support for I2C6-9 --- arch/arm/src/tiva/Kconfig | 57 +++++++++ arch/arm/src/tiva/tiva_i2c.c | 230 ++++++++++++++++++++++++++++++++++- 2 files changed, 285 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/tiva/Kconfig b/arch/arm/src/tiva/Kconfig index c87c637629..8022b9d032 100644 --- a/arch/arm/src/tiva/Kconfig +++ b/arch/arm/src/tiva/Kconfig @@ -15,6 +15,7 @@ config ARCH_CHIP_LM3S6918 depends on ARCH_CHIP_LM select ARCH_CORTEXM3 select ARCH_CHIP_LM3S + select TIVA_HAVE_I2C1 select TIVA_HAVE_SSI1 config ARCH_CHIP_LM3S9B96 @@ -23,6 +24,7 @@ config ARCH_CHIP_LM3S9B96 select ARCH_CORTEXM3 select ARCH_CHIP_LM3S select TIVA_HAVE_UART3 + select TIVA_HAVE_I2C1 select TIVA_HAVE_SSI1 select TIVA_HAVE_GPIOH_IRQS @@ -38,6 +40,7 @@ config ARCH_CHIP_LM3S6965 select ARCH_CORTEXM3 select ARCH_CHIP_LM3S select TIVA_HAVE_UART3 + select TIVA_HAVE_I2C1 select TIVA_HAVE_GPIOH_IRQS config ARCH_CHIP_LM3S8962 @@ -46,6 +49,7 @@ config ARCH_CHIP_LM3S8962 select ARCH_CORTEXM3 select ARCH_CHIP_LM3S select TIVA_HAVE_UART3 + select TIVA_HAVE_I2C1 select TIVA_HAVE_GPIOH_IRQS config ARCH_CHIP_LM4F120 @@ -86,6 +90,7 @@ config ARCH_CHIP_CC3200 bool "CC3200" depends on ARCH_CHIP_TIVA select ARCH_CORTEXM4 + select TIVA_HAVE_I2C1 endchoice @@ -112,6 +117,7 @@ config ARCH_CHIP_LM4F select TIVA_HAVE_GPIOF_IRQS select TIVA_HAVE_GPIOG_IRQS select TIVA_HAVE_GPIOH_IRQS + select TIVA_HAVE_I2C1 select TIVA_HAVE_I2C2 select TIVA_HAVE_I2C3 select TIVA_HAVE_UART3 @@ -130,12 +136,19 @@ config ARCH_CHIP_TM4C123 config ARCH_CHIP_TM4C129 bool select TIVA_HAVE_GPIOQ_IRQS + select TIVA_HAVE_I2C4 + select TIVA_HAVE_I2C5 + select TIVA_HAVE_I2C6 + select TIVA_HAVE_I2C7 + select TIVA_HAVE_I2C8 + select TIVA_HAVE_I2C9 config ARCH_CHIP_TM4C bool select ARCH_CORTEXM4 select ARCH_HAVE_FPU select TIVA_HAVE_GPIOP_IRQS + select TIVA_HAVE_I2C1 select TIVA_HAVE_I2C2 select TIVA_HAVE_I2C3 select TIVA_HAVE_UART3 @@ -166,6 +179,10 @@ config TIVA_I2C bool default n +config TIVA_HAVE_I2C1 + bool + default n + config TIVA_HAVE_I2C2 bool default n @@ -182,6 +199,22 @@ config TIVA_HAVE_I2C5 bool default n +config TIVA_HAVE_I2C6 + bool + default n + +config TIVA_HAVE_I2C7 + bool + default n + +config TIVA_HAVE_I2C8 + bool + default n + +config TIVA_HAVE_I2C9 + bool + default n + config TIVA_HAVE_UART3 bool default n @@ -256,6 +289,30 @@ config TIVA_I2C5 depends on TIVA_HAVE_I2C5 select TIVA_I2C +config TIVA_I2C6 + bool "I2C6" + default n + depends on TIVA_HAVE_I2C6 + select TIVA_I2C + +config TIVA_I2C7 + bool "I2C7" + default n + depends on TIVA_HAVE_I2C7 + select TIVA_I2C + +config TIVA_I2C8 + bool "I2C8" + default n + depends on TIVA_HAVE_I2C8 + select TIVA_I2C + +config TIVA_I2C9 + bool "I2C9" + default n + depends on TIVA_HAVE_I2C9 + select TIVA_I2C + config TIVA_UART0 bool "UART0" select ARCH_HAVE_UART0 diff --git a/arch/arm/src/tiva/tiva_i2c.c b/arch/arm/src/tiva/tiva_i2c.c index bab0e32ea6..1779e7e2de 100644 --- a/arch/arm/src/tiva/tiva_i2c.c +++ b/arch/arm/src/tiva/tiva_i2c.c @@ -76,7 +76,9 @@ #if defined(CONFIG_TIVA_I2C0) || defined(CONFIG_TIVA_I2C1) || \ defined(CONFIG_TIVA_I2C2) || defined(CONFIG_TIVA_I2C3) || \ - defined(CONFIG_TIVA_I2C4) || defined(CONFIG_TIVA_I2C5) + defined(CONFIG_TIVA_I2C4) || defined(CONFIG_TIVA_I2C5) || \ + defined(CONFIG_TIVA_I2C6) || defined(CONFIG_TIVA_I2C7) || \ + defined(CONFIG_TIVA_I2C8) || defined(CONFIG_TIVA_I2C9) /************************************************************************************ * Pre-processor Definitions @@ -320,6 +322,18 @@ static int tiva_i2c4_interrupt(int irq, void *context); #ifdef CONFIG_TIVA_I2C5 static int tiva_i2c5_interrupt(int irq, void *context); #endif +#ifdef CONFIG_TIVA_I2C6 +static int tiva_i2c6_interrupt(int irq, void *context); +#endif +#ifdef CONFIG_TIVA_I2C7 +static int tiva_i2c7_interrupt(int irq, void *context); +#endif +#ifdef CONFIG_TIVA_I2C8 +static int tiva_i2c8_interrupt(int irq, void *context); +#endif +#ifdef CONFIG_TIVA_I2C9 +static int tiva_i2c9_interrupt(int irq, void *context); +#endif #endif /* !CONFIG_I2C_POLLED */ static int tiva_i2c_initialize(struct tiva_i2c_priv_s *priv, uint32_t frequency); @@ -482,6 +496,94 @@ static const struct tiva_i2c_config_s tiva_i2c5_config = static struct tiva_i2c_priv_s tiva_i2c5_priv; #endif +#ifdef CONFIG_TIVA_I2C6 +static const struct tiva_i2c_config_s tiva_i2c6_config = +{ + .base = TIVA_I2C6_BASE, +#ifndef TIVA_SYSCON_RCGCI2C + .rcgbit = SYSCON_RCGC1_I2C6, +#endif +#ifndef TIVA_SYSCON_SRI2C + .rstbit = SYSCON_SRCR1_I2C6, +#endif + .scl_pin = GPIO_I2C6_SCL, + .sda_pin = GPIO_I2C6_SDA, +#ifndef CONFIG_I2C_POLLED + .isr = tiva_i2c6_interrupt, + .irq = TIVA_IRQ_I2C6, +#endif + .devno = 6, +}; + +static struct tiva_i2c_priv_s tiva_i2c7_priv; +#endif + +#ifdef CONFIG_TIVA_I2C7 +static const struct tiva_i2c_config_s tiva_i2c7_config = +{ + .base = TIVA_I2C7_BASE, +#ifndef TIVA_SYSCON_RCGCI2C + .rcgbit = SYSCON_RCGC1_I2C7, +#endif +#ifndef TIVA_SYSCON_SRI2C + .rstbit = SYSCON_SRCR1_I2C7, +#endif + .scl_pin = GPIO_I2C7_SCL, + .sda_pin = GPIO_I2C7_SDA, +#ifndef CONFIG_I2C_POLLED + .isr = tiva_i2c7_interrupt, + .irq = TIVA_IRQ_I2C7, +#endif + .devno = 7, +}; + +static struct tiva_i2c_priv_s tiva_i2c8_priv; +#endif + +#ifdef CONFIG_TIVA_I2C8 +static const struct tiva_i2c_config_s tiva_i2c8_config = +{ + .base = TIVA_I2C8_BASE, +#ifndef TIVA_SYSCON_RCGCI2C + .rcgbit = SYSCON_RCGC1_I2C8, +#endif +#ifndef TIVA_SYSCON_SRI2C + .rstbit = SYSCON_SRCR1_I2C8, +#endif + .scl_pin = GPIO_I2C8_SCL, + .sda_pin = GPIO_I2C8_SDA, +#ifndef CONFIG_I2C_POLLED + .isr = tiva_i2c8_interrupt, + .irq = TIVA_IRQ_I2C8, +#endif + .devno = 8, +}; + +static struct tiva_i2c_priv_s tiva_i2c9_priv; +#endif + +#ifdef CONFIG_TIVA_I2C9 +static const struct tiva_i2c_config_s tiva_i2c9_config = +{ + .base = TIVA_I2C9_BASE, +#ifndef TIVA_SYSCON_RCGCI2C + .rcgbit = SYSCON_RCGC1_I2C9, +#endif +#ifndef TIVA_SYSCON_SRI2C + .rstbit = SYSCON_SRCR1_I2C9, +#endif + .scl_pin = GPIO_I2C9_SCL, + .sda_pin = GPIO_I2C9_SDA, +#ifndef CONFIG_I2C_POLLED + .isr = tiva_i2c9_interrupt, + .irq = TIVA_IRQ_I2C9, +#endif + .devno = 9, +}; + +static struct tiva_i2c_priv_s tiva_i2c0_priv; +#endif + /* Device Structures, Instantiation */ static const struct i2c_ops_s tiva_i2c_ops = @@ -1504,6 +1606,106 @@ static int tiva_i2c5_interrupt(int irq, void *context) } #endif +/************************************************************************************ + * Name: tiva_i2c6_interrupt + * + * Description: + * I2C6 interrupt service routine + * + ************************************************************************************/ + +#if !defined(CONFIG_I2C_POLLED) && defined(CONFIG_TIVA_I2C6) +static int tiva_i2c6_interrupt(int irq, void *context) +{ + struct tiva_i2c_priv_s *priv; + uint32_t status; + + /* Read the masked interrupt status */ + + priv = &tiva_i2c6_priv; + status = tiva_i2c_getreg(priv, TIVA_I2CM_MIS_OFFSET); + + /* Let the common interrupt handler do the rest of the work */ + + return tiva_i2c_interrupt(priv, status); +} +#endif + +/************************************************************************************ + * Name: tiva_i2c7_interrupt + * + * Description: + * I2C7 interrupt service routine + * + ************************************************************************************/ + +#if !defined(CONFIG_I2C_POLLED) && defined(CONFIG_TIVA_I2C7) +static int tiva_i2c7_interrupt(int irq, void *context) +{ + struct tiva_i2c_priv_s *priv; + uint32_t status; + + /* Read the masked interrupt status */ + + priv = &tiva_i2c7_priv; + status = tiva_i2c_getreg(priv, TIVA_I2CM_MIS_OFFSET); + + /* Let the common interrupt handler do the rest of the work */ + + return tiva_i2c_interrupt(priv, status); +} +#endif + +/************************************************************************************ + * Name: tiva_i2c8_interrupt + * + * Description: + * I2C8 interrupt service routine + * + ************************************************************************************/ + +#if !defined(CONFIG_I2C_POLLED) && defined(CONFIG_TIVA_I2C8) +static int tiva_i2c8_interrupt(int irq, void *context) +{ + struct tiva_i2c_priv_s *priv; + uint32_t status; + + /* Read the masked interrupt status */ + + priv = &tiva_i2c8_priv; + status = tiva_i2c_getreg(priv, TIVA_I2CM_MIS_OFFSET); + + /* Let the common interrupt handler do the rest of the work */ + + return tiva_i2c_interrupt(priv, status); +} +#endif + +/************************************************************************************ + * Name: tiva_i2c9_interrupt + * + * Description: + * I2C9 interrupt service routine + * + ************************************************************************************/ + +#if !defined(CONFIG_I2C_POLLED) && defined(CONFIG_TIVA_I2C9) +static int tiva_i2c9_interrupt(int irq, void *context) +{ + struct tiva_i2c_priv_s *priv; + uint32_t status; + + /* Read the masked interrupt status */ + + priv = &tiva_i2c9_priv; + status = tiva_i2c_getreg(priv, TIVA_I2CM_MIS_OFFSET); + + /* Let the common interrupt handler do the rest of the work */ + + return tiva_i2c_interrupt(priv, status); +} +#endif + /************************************************************************************ * Name: tiva_i2c_initialize * @@ -2048,6 +2250,30 @@ struct i2c_dev_s *up_i2cinitialize(int port) priv = &tiva_i2c5_priv; config = &tiva_i2c5_config; break; +#endif +#ifdef CONFIG_TIVA_I2C6 + case 6: + priv = &tiva_i2c6_priv; + config = &tiva_i2c6_config; + break; +#endif +#ifdef CONFIG_TIVA_I2C7 + case 7: + priv = &tiva_i2c7_priv; + config = &tiva_i2c7_config; + break; +#endif +#ifdef CONFIG_TIVA_I2C8 + case 7: + priv = &tiva_i2c8_priv; + config = &tiva_i2c8_config; + break; +#endif +#ifdef CONFIG_TIVA_I2C9 + case 0: + priv = &tiva_i2c9_priv; + config = &tiva_i2c9_config; + break; #endif default: i2cdbg("I2C%d: ERROR: Not supported\n", port); @@ -2267,4 +2493,4 @@ out: } #endif /* CONFIG_I2C_RESET */ -#endif /* CONFIG_TIVA_I2C0 ... CONFIG_TIVA_I2C5 */ +#endif /* CONFIG_TIVA_I2C0 ... CONFIG_TIVA_I2C9 */