From 69ce24c70ca303713d54d86da172f2a2f8b07bee Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 1 Feb 2016 16:31:13 -0600 Subject: [PATCH] I2C: Remove the setfrequency method from the interface --- Documentation | 2 +- arch | 2 +- drivers/audio/wm8904.c | 5 ----- drivers/i2c/i2c_read.c | 1 - drivers/i2c/i2c_write.c | 1 - drivers/i2c/i2c_writeread.c | 1 - drivers/input/mxt.c | 2 -- drivers/input/stmpe811_base.c | 7 ------- drivers/input/stmpe811_tsc.c | 2 +- drivers/input/tsc2007.c | 5 ----- drivers/ioexpander/pca9555.c | 7 ------- drivers/lcd/ssd1306_base.c | 7 ------- drivers/leds/pca9635pw.c | 4 ---- drivers/mtd/at24xx.c | 4 ---- drivers/power/bq2425x.c | 4 ---- drivers/power/max1704x.c | 4 ---- drivers/sensors/adxl345_base.c | 7 ------- drivers/sensors/bmp180.c | 4 ---- drivers/timers/ds3231.c | 8 -------- drivers/timers/pcf85263.c | 8 -------- drivers/video/ov2640.c | 4 ---- include/nuttx/i2c/i2c_master.h | 23 ++--------------------- 22 files changed, 5 insertions(+), 107 deletions(-) diff --git a/Documentation b/Documentation index 7d40326c7f..527fb2f925 160000 --- a/Documentation +++ b/Documentation @@ -1 +1 @@ -Subproject commit 7d40326c7f8ca77993caaa7bb940e3ae2a631f9d +Subproject commit 527fb2f92536a8dad7dee60da49281049dc545bb diff --git a/arch b/arch index 18c2083af2..867f8d6f49 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 18c2083af2a73f710e2777c42ccd7ca8ae4096bf +Subproject commit 867f8d6f49f9bec687e98bfb2bedba81e017e90a diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c index cfc04a3ddc..6f1694fbe6 100644 --- a/drivers/audio/wm8904.c +++ b/drivers/audio/wm8904.c @@ -2501,11 +2501,6 @@ FAR struct audio_lowerhalf_s * dq_init(&priv->pendq); dq_init(&priv->doneq); - /* Initialize I2C */ - - auddbg("address=%02x frequency=%d\n", lower->address, lower->frequency); - I2C_SETFREQUENCY(i2c, lower->frequency); - /* Software reset. This puts all WM8904 registers back in their * default state. */ diff --git a/drivers/i2c/i2c_read.c b/drivers/i2c/i2c_read.c index 72134c2c50..54291dc1aa 100644 --- a/drivers/i2c/i2c_read.c +++ b/drivers/i2c/i2c_read.c @@ -87,7 +87,6 @@ int i2c_read(FAR struct i2c_master_s *dev, /* Then perform the transfer. */ - I2C_SETFREQUENCY(dev, config->frequency); return I2C_TRANSFER(dev, &msg, 1); } diff --git a/drivers/i2c/i2c_write.c b/drivers/i2c/i2c_write.c index 11eb25cc7d..f72bc97a33 100644 --- a/drivers/i2c/i2c_write.c +++ b/drivers/i2c/i2c_write.c @@ -82,7 +82,6 @@ int i2c_write(FAR struct i2c_master_s *dev, /* Then perform the transfer. */ - I2C_SETFREQUENCY(dev, config->frequency); return I2C_TRANSFER(dev, &msg, 1); } diff --git a/drivers/i2c/i2c_writeread.c b/drivers/i2c/i2c_writeread.c index 265f272d1d..1b5c2060c5 100644 --- a/drivers/i2c/i2c_writeread.c +++ b/drivers/i2c/i2c_writeread.c @@ -109,7 +109,6 @@ int i2c_writeread(FAR struct i2c_master_s *dev, /* Then perform the transfer. */ - I2C_SETFREQUENCY(dev, config->frequency); return I2C_TRANSFER(dev, msg, 2); } diff --git a/drivers/input/mxt.c b/drivers/input/mxt.c index 768ebe095b..d7444a5522 100644 --- a/drivers/input/mxt.c +++ b/drivers/input/mxt.c @@ -1517,7 +1517,6 @@ static int mxt_ioctl(FAR struct file *filep, int cmd, unsigned long arg) DEBUGASSERT(priv->lower != NULL && ptr != NULL); priv->frequency = *ptr; - (void)I2C_SETFREQUENCY(priv->i2c, *ptr); } break; @@ -1741,7 +1740,6 @@ static int mxt_hwinitialize(FAR struct mxt_dev_s *priv) /* Set the selected I2C frequency */ priv->frequency = priv->lower->frequency; - (void)I2C_SETFREQUENCY(priv->i2c, priv->lower->frequency); /* Read the info registers from the device */ diff --git a/drivers/input/stmpe811_base.c b/drivers/input/stmpe811_base.c index c115d985fe..224b9eaefc 100644 --- a/drivers/input/stmpe811_base.c +++ b/drivers/input/stmpe811_base.c @@ -324,13 +324,6 @@ STMPE811_HANDLE stmpe811_instantiate(FAR struct i2c_master_s *dev, priv->spi = dev; #else priv->i2c = dev; - - /* Set the I2C address and frequency. REVISIT: This logic would be - * insufficient if we share the I2C bus with any other devices that also - * modify the address and frequency. - */ - - I2C_SETFREQUENCY(dev, config->frequency); #endif /* Read and verify the STMPE811 chip ID */ diff --git a/drivers/input/stmpe811_tsc.c b/drivers/input/stmpe811_tsc.c index fa701e0710..55dce44272 100644 --- a/drivers/input/stmpe811_tsc.c +++ b/drivers/input/stmpe811_tsc.c @@ -615,7 +615,7 @@ static int stmpe811_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { FAR uint32_t *ptr = (FAR uint32_t *)((uintptr_t)arg); DEBUGASSERT(priv->config != NULL && ptr != NULL); - priv->config->frequency = I2C_SETFREQUENCY(priv->i2c, *ptr); + priv->config->frequency = *ptr; } break; diff --git a/drivers/input/tsc2007.c b/drivers/input/tsc2007.c index e3ae851688..0c1991b351 100644 --- a/drivers/input/tsc2007.c +++ b/drivers/input/tsc2007.c @@ -1073,7 +1073,6 @@ static int tsc2007_ioctl(FAR struct file *filep, int cmd, unsigned long arg) FAR uint32_t *ptr = (FAR uint32_t *)((uintptr_t)arg); DEBUGASSERT(priv->config != NULL && ptr != NULL); priv->config->frequency = *ptr; - (void)I2C_SETFREQUENCY(priv->i2c, *ptr); } break; @@ -1255,10 +1254,6 @@ int tsc2007_register(FAR struct i2c_master_s *dev, sem_init(&priv->devsem, 0, 1); /* Initialize device structure semaphore */ sem_init(&priv->waitsem, 0, 0); /* Initialize pen event wait semaphore */ - /* Set the I2C frequency (saving the actual frequency) */ - - config->frequency = I2C_SETFREQUENCY(dev, config->frequency); - /* Make sure that interrupts are disabled */ config->clear(config); diff --git a/drivers/ioexpander/pca9555.c b/drivers/ioexpander/pca9555.c index 0348ca7ade..2d9f213304 100644 --- a/drivers/ioexpander/pca9555.c +++ b/drivers/ioexpander/pca9555.c @@ -618,13 +618,6 @@ FAR struct ioexpander_dev_s *pca9555_initialize(FAR struct i2c_master_s *i2cdev, pcadev->dev.ops = &g_pca9555_ops; pcadev->config = config; - /* Set the I2C frequency. REVISIT: This logic would be - * insufficient if we share the I2C bus with any other devices that also - * modify the address and frequency. - */ - - I2C_SETFREQUENCY(i2cdev, config->frequency); - #ifdef CONFIG_PCA9555_INT_ENABLE pcadev->config->attach(pcadev->config, pca9555_interrupt); pcadev->config->enable(pcadev->config, TRUE); diff --git a/drivers/lcd/ssd1306_base.c b/drivers/lcd/ssd1306_base.c index 8bb511ee83..db94d9ea83 100644 --- a/drivers/lcd/ssd1306_base.c +++ b/drivers/lcd/ssd1306_base.c @@ -827,13 +827,6 @@ FAR struct lcd_dev_s *ssd1306_initialize(FAR struct i2c_master_s *dev, unsigned priv->i2c = dev; priv->addr = CONFIG_SSD1306_I2CADDR; - - /* Set the I2C frequency. REVISIT: This logic would be - * insufficient if we share the I2C bus with any other devices that also - * modify the address and frequency. - */ - - I2C_SETFREQUENCY(priv->i2c, CONFIG_SSD1306_I2CFREQ); #endif /* Lock and select device */ diff --git a/drivers/leds/pca9635pw.c b/drivers/leds/pca9635pw.c index b4a8419061..452891555a 100644 --- a/drivers/leds/pca9635pw.c +++ b/drivers/leds/pca9635pw.c @@ -381,10 +381,6 @@ int pca9635pw_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, return ret; } - /* setup i2c frequency */ - - I2C_SETFREQUENCY(priv->i2c, I2C_BUS_FREQ_HZ); - return OK; } diff --git a/drivers/mtd/at24xx.c b/drivers/mtd/at24xx.c index aa235c346a..85299baada 100644 --- a/drivers/mtd/at24xx.c +++ b/drivers/mtd/at24xx.c @@ -246,7 +246,6 @@ static int at24c_eraseall(FAR struct at24c_dev_s *priv) int startblock = 0; memset(&buf[AT24XX_ADDRSIZE], 0xff, priv->pagesize); - I2C_SETFREQUENCY(priv->dev, CONFIG_AT24XX_FREQUENCY); for (startblock = 0; startblock < priv->npages; startblock++) { @@ -298,8 +297,6 @@ static ssize_t at24c_read_internal(FAR struct at24c_dev_s *priv, off_t offset, fvdbg("offset: %lu nbytes: %lu address: %02x\n", (unsigned long)offset, (unsigned long)nbytes, address); - I2C_SETFREQUENCY(priv->dev, CONFIG_AT24XX_FREQUENCY); - /* "Random Read: A Random Read requires a dummy byte write sequence to load in the * data word address. Once the device address word and data word address are clocked * in and acknowledged by the EEPROM, the microcontroller must generate another @@ -422,7 +419,6 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t } fvdbg("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks); - I2C_SETFREQUENCY(priv->dev, CONFIG_AT24XX_FREQUENCY); while (blocksleft-- > 0) { diff --git a/drivers/power/bq2425x.c b/drivers/power/bq2425x.c index 3927ce27d4..073c3ce379 100644 --- a/drivers/power/bq2425x.c +++ b/drivers/power/bq2425x.c @@ -744,10 +744,6 @@ FAR struct battery_charger_dev_s * priv->addr = addr; priv->frequency = frequency; - /* Set the I2C frequency (ignoring the returned, actual frequency) */ - - (void)I2C_SETFREQUENCY(i2c, priv->frequency); - /* Reset the BQ2425x */ ret = bq2425x_reset(priv); diff --git a/drivers/power/max1704x.c b/drivers/power/max1704x.c index 8228413409..7fa3f85060 100644 --- a/drivers/power/max1704x.c +++ b/drivers/power/max1704x.c @@ -548,10 +548,6 @@ FAR struct battery_gauge_dev_s *max1704x_initialize(FAR struct i2c_master_s *i2c priv->addr = addr; priv->frequency = frequency; - /* Set the I2C frequency (ignoring the returned, actual frequency) */ - - (void)I2C_SETFREQUENCY(i2c, priv->frequency); - /* Reset the MAX1704x (mostly just to make sure that we can talk to it) */ #if 0 diff --git a/drivers/sensors/adxl345_base.c b/drivers/sensors/adxl345_base.c index d2c9362314..4cf667807d 100644 --- a/drivers/sensors/adxl345_base.c +++ b/drivers/sensors/adxl345_base.c @@ -411,13 +411,6 @@ ADXL345_HANDLE adxl345_instantiate(FAR struct i2c_master_s *dev, #else priv->i2c = dev; - - /* Set the I2C address and frequency. REVISIT: This logic would be - * insufficient if we share the I2C bus with any other devices that also - * modify the address and frequency. - */ - - I2C_SETFREQUENCY(dev, config->frequency); #endif /* Read and verify the ADXL345 device ID */ diff --git a/drivers/sensors/bmp180.c b/drivers/sensors/bmp180.c index 3279647ef9..2124066fe9 100644 --- a/drivers/sensors/bmp180.c +++ b/drivers/sensors/bmp180.c @@ -610,10 +610,6 @@ int bmp180_register(FAR const char *devpath, FAR struct i2c_master_s *i2c) priv->addr = BMP180_ADDR; priv->freq = BMP180_FREQ; - /* Configure I2C before using it */ - - I2C_SETFREQUENCY(priv->i2c, priv->freq); - /* Check Device ID */ ret = bmp180_checkid(priv); diff --git a/drivers/timers/ds3231.c b/drivers/timers/ds3231.c index 60292c4fed..7efaaecb03 100644 --- a/drivers/timers/ds3231.c +++ b/drivers/timers/ds3231.c @@ -330,10 +330,6 @@ int up_rtc_getdatetime(FAR struct tm *tp) msg[3].buffer = &seconds; msg[3].length = 1; - /* Configure I2C before using it */ - - I2C_SETFREQUENCY(g_ds3231.i2c, CONFIG_DS3231_I2C_FREQUENCY); - /* Perform the transfer. The transfer may be performed repeatedly of the * seconds values decreases, meaning that that was a rollover in the seconds. */ @@ -549,10 +545,6 @@ int up_rtc_settime(FAR const struct timespec *tp) msg[2].buffer = &seconds; msg[2].length = 1; - /* Configure I2C before using it */ - - I2C_SETFREQUENCY(g_ds3231.i2c, CONFIG_DS3231_I2C_FREQUENCY); - /* Perform the transfer. This transfer will be repeated if the seconds * count rolls over to a smaller value while writing. */ diff --git a/drivers/timers/pcf85263.c b/drivers/timers/pcf85263.c index c8b85f1162..0128e354f2 100644 --- a/drivers/timers/pcf85263.c +++ b/drivers/timers/pcf85263.c @@ -329,10 +329,6 @@ int up_rtc_getdatetime(FAR struct tm *tp) msg[3].buffer = &seconds; msg[3].length = 1; - /* Configure I2C before using it */ - - I2C_SETFREQUENCY(g_pcf85263.i2c, CONFIG_PCF85263_I2C_FREQUENCY); - /* Perform the transfer. The transfer may be performed repeatedly of the * seconds values decreases, meaning that that was a rollover in the seconds. */ @@ -513,10 +509,6 @@ int up_rtc_settime(FAR const struct timespec *tp) msg[2].buffer = &seconds; msg[2].length = 1; - /* Configure I2C before using it */ - - I2C_SETFREQUENCY(g_pcf85263.i2c, CONFIG_PCF85263_I2C_FREQUENCY); - /* Perform the transfer. This transfer will be repeated if the seconds * count rolls over to a smaller value while writing. */ diff --git a/drivers/video/ov2640.c b/drivers/video/ov2640.c index 19812e3224..ebf37f002c 100644 --- a/drivers/video/ov2640.c +++ b/drivers/video/ov2640.c @@ -922,10 +922,6 @@ int ov2640_initialize(FAR struct i2c_master_s *i2c) { int ret; - /* Configure I2C bus for the OV2640 */ - - I2C_SETFREQUENCY(i2c, CONFIG_OV2640_FREQUENCY); - /* Reset the OVR2640 */ ret = ov2640_reset(i2c); diff --git a/include/nuttx/i2c/i2c_master.h b/include/nuttx/i2c/i2c_master.h index 4040efa24e..2b9271dced 100644 --- a/include/nuttx/i2c/i2c_master.h +++ b/include/nuttx/i2c/i2c_master.h @@ -80,24 +80,6 @@ /* Access macros ************************************************************/ -/**************************************************************************** - * Name: I2C_SETFREQUENCY - * - * Description: - * Set the I2C frequency. This frequency will be retained in the struct - * i2c_master_s instance and will be used with all transfers. Required. - * - * Input Parameters: - * dev - Device-specific state data - * frequency - The I2C frequency requested - * - * Returned Value: - * Returns the actual frequency selected - * - ****************************************************************************/ - -#define I2C_SETFREQUENCY(d,f) ((d)->ops->setfrequency(d,f)) - /**************************************************************************** * Name: I2C_TRANSFER * @@ -131,9 +113,8 @@ struct i2c_master_s; struct i2c_msg_s; struct i2c_ops_s { - uint32_t (*setfrequency)(FAR struct i2c_master_s *dev, uint32_t frequency); - int (*transfer)(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, - int count); + int (*transfer)(FAR struct i2c_master_s *dev, FAR struct i2c_msg_s *msgs, + int count); }; /* This structure contains the full state of I2C as needed for a specific