diff options
author | andrew <andrew@FreeBSD.org> | 2014-05-17 18:52:20 +0000 |
---|---|---|
committer | andrew <andrew@FreeBSD.org> | 2014-05-17 18:52:20 +0000 |
commit | 751a8ed42e079c9fd23a03911fbfd9de423a4487 (patch) | |
tree | 81893ae74dc763e36b9653e80eb1b6f4e1924788 | |
parent | 64874148f80d31991502a35abb87db20a0553dd9 (diff) | |
download | FreeBSD-src-751a8ed42e079c9fd23a03911fbfd9de423a4487.zip FreeBSD-src-751a8ed42e079c9fd23a03911fbfd9de423a4487.tar.gz |
Allow us to compile the Ti iic driver for both OMAP4 and AM335x.
MFC after: 1 week
-rw-r--r-- | sys/arm/ti/ti_i2c.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/sys/arm/ti/ti_i2c.c b/sys/arm/ti/ti_i2c.c index 089c2de..3e583a2 100644 --- a/sys/arm/ti/ti_i2c.c +++ b/sys/arm/ti/ti_i2c.c @@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$"); #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> +#include <arm/ti/ti_cpuid.h> #include <arm/ti/ti_prcm.h> #include <arm/ti/ti_i2c.h> @@ -106,21 +107,23 @@ struct ti_i2c_clock_config uint8_t hssclh; /* High Speed mode SCL high time */ }; -static struct ti_i2c_clock_config ti_i2c_clock_configs[] = { - #if defined(SOC_OMAP4) +static struct ti_i2c_clock_config ti_omap4_i2c_clock_configs[] = { { IIC_SLOW, 100000, 23, 13, 15, 0, 0}, { IIC_FAST, 400000, 9, 5, 7, 0, 0}, { IIC_FASTEST, 3310000, 1, 113, 115, 7, 10}, -#elif defined(SOC_TI_AM335X) + { -1, 0 } +}; +#endif + +#if defined(SOC_TI_AM335X) +static struct ti_i2c_clock_config ti_am335x_i2c_clock_configs[] = { { IIC_SLOW, 100000, 3, 53, 55, 0, 0}, { IIC_FAST, 400000, 3, 8, 10, 0, 0}, { IIC_FASTEST, 400000, 3, 8, 10, 0, 0}, /* This might be higher */ -#else -#error "TI I2C driver is not supported on this SoC" -#endif { -1, 0 } }; +#endif #define TI_I2C_REV1 0x003C /* OMAP3 */ @@ -280,7 +283,20 @@ ti_i2c_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr) struct ti_i2c_clock_config *clkcfg; uint16_t con_reg; - clkcfg = ti_i2c_clock_configs; + switch (ti_chip()) { +#ifdef SOC_OMAP4 + case CHIP_OMAP_4: + clkcfg = ti_omap4_i2c_clock_configs; + break; +#endif +#ifdef SOC_TI_AM335X + case CHIP_AM335X: + clkcfg = ti_am335x_i2c_clock_configs; + break; +#endif + default: + panic("Unknown Ti SoC, unable to reset the i2c"); + } while (clkcfg->speed != -1) { if (clkcfg->speed == speed) break; |