diff --git a/arch b/arch index 244343293fc..32ca4e6150e 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit 244343293fcfa82e03e002fa792a4e09d238b9f2 +Subproject commit 32ca4e6150e8369dfa9f84f62863774cea6dc736 diff --git a/configs b/configs index 66325b8ab4f..dd88ee499c9 160000 --- a/configs +++ b/configs @@ -1 +1 @@ -Subproject commit 66325b8ab4f012c1261e88ae262d5cd2e3d54fd1 +Subproject commit dd88ee499c9fc77884091a48cad9d6fc3ba451a9 diff --git a/drivers/analog/pga11x.c b/drivers/analog/pga11x.c index 143b897bc9b..915cfca0553 100644 --- a/drivers/analog/pga11x.c +++ b/drivers/analog/pga11x.c @@ -170,7 +170,6 @@ static void pga11x_configure(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void pga11x_lock(FAR struct spi_dev_s *spi) { spivdbg("Locking\n"); @@ -193,9 +192,6 @@ static void pga11x_lock(FAR struct spi_dev_s *spi) pga11x_configure(spi); } -#else -# define pga11x_lock(spi) -#endif /**************************************************************************** * Name: pga11x_unlock @@ -208,16 +204,12 @@ static void pga11x_lock(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void pga11x_unlock(FAR struct spi_dev_s *spi) { spivdbg("Unlocking\n"); SPI_LOCK(spi, false); } -#else -# define pga11x_unlock(spi) -#endif /**************************************************************************** * Name: pga11x_send16 @@ -361,16 +353,8 @@ PGA11X_HANDLE pga11x_initialize(FAR struct spi_dev_s *spi) { spivdbg("Entry\n"); - /* Configure the SPI us for the device. Do this now only if the PGA11X is - * the only device on the bus. - */ - -#ifdef CONFIG_SPI_OWNBUS - pga11x_configure(spi); -#endif - - /* No other special state is required, just return the SPI driver instance - * as the handle. This gives us a place to extend functionality in the + /* No Special state is required, just return the SPI driver instance as + * the handle. This gives us a place to extend functionality in the * future if neccessary. */ diff --git a/drivers/input/ads7843e.c b/drivers/input/ads7843e.c index d09afce3125..1648b7fddf5 100644 --- a/drivers/input/ads7843e.c +++ b/drivers/input/ads7843e.c @@ -94,15 +94,8 @@ ****************************************************************************/ /* Low-level SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS -static inline void ads7843e_configspi(FAR struct spi_dev_s *spi); -# define ads7843e_lock(spi) -# define ads7843e_unlock(spi) -#else -# define ads7843e_configspi(spi); static void ads7843e_lock(FAR struct spi_dev_s *spi); static void ads7843e_unlock(FAR struct spi_dev_s *spi); -#endif static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, uint8_t cmd); @@ -180,7 +173,6 @@ static struct ads7843e_dev_s *g_ads7843elist; * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void ads7843e_lock(FAR struct spi_dev_s *spi) { /* Lock the SPI bus because there are multiple devices competing for the @@ -201,15 +193,13 @@ static void ads7843e_lock(FAR struct spi_dev_s *spi) (void)SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY); SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false); } -#endif /**************************************************************************** * Function: ads7843e_unlock * * Description: - * If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS - * undefined) then we need to un-lock the SPI bus for each transfer, - * possibly losing the current configuration. + * Un-lock the SPI bus after each transfer, possibly losing the current + * configuration if we are sharing the bus with other devices. * * Parameters: * spi - Reference to the SPI driver structure @@ -221,49 +211,12 @@ static void ads7843e_lock(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void ads7843e_unlock(FAR struct spi_dev_s *spi) { /* Relinquish the SPI bus. */ (void)SPI_LOCK(spi, false); } -#endif - -/**************************************************************************** - * Function: ads7843e_configspi - * - * Description: - * Configure the SPI for use with the ADS7843E. This function should be - * called once during touchscreen initialization to configure the SPI - * bus. Note that if CONFIG_SPI_OWNBUS is not defined, then this function - * does nothing. - * - * Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -#ifdef CONFIG_SPI_OWNBUS -static inline void ads7843e_configspi(FAR struct spi_dev_s *spi) -{ - /* Configure SPI for the ADS7843. But only if we own the SPI bus. - * Otherwise, don't bother because it might change. - */ - - SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true); - SPI_SETMODE(spi, CONFIG_ADS7843E_SPIMODE); - SPI_SETBITS(spi, 8); - (void)SPI_HWFEATURES(spi, 0); - (void)SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY); - SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false); -} -#endif /**************************************************************************** * Name: ads7843e_sendcmd @@ -1254,10 +1207,6 @@ int ads7843e_register(FAR struct spi_dev_s *spi, ads7843e_lock(spi); - /* Configure the SPI interface */ - - ads7843e_configspi(spi); - /* Enable the PEN IRQ */ ads7843e_sendcmd(priv, ADS7843_CMD_ENABPENIRQ); diff --git a/drivers/input/max11802.c b/drivers/input/max11802.c index 85a5b77347a..25698427b93 100644 --- a/drivers/input/max11802.c +++ b/drivers/input/max11802.c @@ -88,16 +88,8 @@ ****************************************************************************/ /* Low-level SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS -static inline void max11802_configspi(FAR struct spi_dev_s *spi); -# define max11802_lock(spi) -# define max11802_unlock(spi) -#else -# define max11802_configspi(spi); static void max11802_lock(FAR struct spi_dev_s *spi); static void max11802_unlock(FAR struct spi_dev_s *spi); -#endif - static uint16_t max11802_sendcmd(FAR struct max11802_dev_s *priv, uint8_t cmd, int *tags); @@ -181,7 +173,6 @@ static struct max11802_dev_s *g_max11802list; * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void max11802_lock(FAR struct spi_dev_s *spi) { /* Lock the SPI bus because there are multiple devices competing for the @@ -200,15 +191,13 @@ static void max11802_lock(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_MAX11802_FREQUENCY); } -#endif /**************************************************************************** * Function: max11802_unlock * * Description: - * If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS - * undefined) then we need to un-lock the SPI bus for each transfer, - * possibly losing the current configuration. + * Un-lock the SPI bus after each transfer, possibly losing the current + * configuration if we are sharing the SPI bus with other devices * * Parameters: * spi - Reference to the SPI driver structure @@ -220,47 +209,12 @@ static void max11802_lock(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void max11802_unlock(FAR struct spi_dev_s *spi) { /* Relinquish the SPI bus. */ (void)SPI_LOCK(spi, false); } -#endif - -/**************************************************************************** - * Function: max11802_configspi - * - * Description: - * Configure the SPI for use with the MAX11802. This function should be - * called once during touchscreen initialization to configure the SPI - * bus. Note that if CONFIG_SPI_OWNBUS is not defined, then this function - * does nothing. - * - * Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -#ifdef CONFIG_SPI_OWNBUS -static inline void max11802_configspi(FAR struct spi_dev_s *spi) -{ - /* Configure SPI for the MAX11802. But only if we own the SPI bus. - * Otherwise, don't bother because it might change. - */ - - SPI_SETMODE(spi, CONFIG_MAX11802_SPIMODE); - SPI_SETBITS(spi, 8); - (void)SPI_HWFEATURES(spi, 0); - (void)SPI_SETFREQUENCY(spi, CONFIG_MAX11802_FREQUENCY); -} -#endif /**************************************************************************** * Name: max11802_sendcmd @@ -1256,11 +1210,8 @@ int max11802_register(FAR struct spi_dev_s *spi, max11802_lock(spi); - /* Configure the SPI interface */ - - max11802_configspi(spi); - /* Configure MAX11802 registers */ + SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true); (void)SPI_SEND(priv->spi, MAX11802_CMD_MODE_WR); (void)SPI_SEND(priv->spi, MAX11802_MODE); diff --git a/drivers/lcd/memlcd.c b/drivers/lcd/memlcd.c index c4a8a6e10fb..e960e27612a 100644 --- a/drivers/lcd/memlcd.c +++ b/drivers/lcd/memlcd.c @@ -150,14 +150,8 @@ struct memlcd_dev_s /* Low-level spi helpers */ -static inline void memlcd_configspi(FAR struct spi_dev_s *spi); -#ifdef CONFIG_SPI_OWNBUS -static inline void memlcd_select(FAR struct spi_dev_s *spi); -static inline void memlcd_deselect(FAR struct spi_dev_s *spi); -#else static void memlcd_select(FAR struct spi_dev_s *spi); static void memlcd_deselect(FAR struct spi_dev_s *spi); -#endif /* lcd data transfer methods */ @@ -266,48 +260,6 @@ static inline int __test_bit(int nr, const volatile uint8_t * addr) return 1 & (addr[BIT_BYTE(nr)] >> (nr & (BITS_PER_BYTE - 1))); } -/**************************************************************************** - * Name: memlcd_configspi - * - * Description: - * Configure the SPI for use with the Sharp Memory LCD - * - * Input Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -static inline void memlcd_configspi(FAR struct spi_dev_s *spi) -{ -#ifdef CONFIG_MEMLCD_SPI_FREQUENCY - lcddbg("Mode: %d Bits: %d Frequency: %d\n", - MEMLCD_SPI_MODE, MEMLCD_SPI_BITS, CONFIG_MEMLCD_SPI_FREQUENCY); -#else - lcddbg("Mode: %d Bits: %d Frequency: %d\n", - MEMLCD_SPI_MODE, MEMLCD_SPI_BITS, MEMLCD_SPI_FREQUENCY); -#endif - - /* Configure SPI for the Memory LCD. But only if we own the SPI bus. - * Otherwise, don't bother because it might change. - */ - -#ifdef CONFIG_SPI_OWNBUS - SPI_SETMODE(spi, MEMLCD_SPI_MODE); - SPI_SETBITS(spi, MEMLCD_SPI_BITS); - (void)SPI_HWFEATURES(spi, 0); -# ifdef CONFIG_MEMLCD_SPI_FREQUENCY - (void)SPI_SETFREQUENCY(spi, CONFIG_MEMLCD_SPI_FREQUENCY); -# else - (void)SPI_SETFREQUENCY(spi, MEMLCD_SPI_FREQUENCY); -# endif -#endif -} - /**************************************************************************** * Name: memlcd_select * @@ -324,25 +276,19 @@ static inline void memlcd_configspi(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void memlcd_select(FAR struct spi_dev_s *spi) -{ - /* we own the spi bus, so just select the chip */ - SPI_SELECT(spi, SPIDEV_DISPLAY, true); -} - -#else static void memlcd_select(FAR struct spi_dev_s *spi) { /* Select memlcd (locking the SPI bus in case there are multiple * devices competing for the SPI bus */ + SPI_LOCK(spi, true); SPI_SELECT(spi, SPIDEV_DISPLAY, true); /* Now make sure that the SPI bus is configured for the memlcd (it * might have gotten configured for a different device while unlocked) */ + SPI_SETMODE(spi, MEMLCD_SPI_MODE); SPI_SETBITS(spi, MEMLCD_SPI_BITS); (void)SPI_HWFEATURES(spi, 0); @@ -352,7 +298,6 @@ static void memlcd_select(FAR struct spi_dev_s *spi) (void)SPI_SETFREQUENCY(spi, MEMLCD_SPI_FREQUENCY); # endif } -#endif /**************************************************************************** * Name: memlcd_deselect @@ -370,20 +315,13 @@ static void memlcd_select(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void memlcd_deselect(FAR struct spi_dev_s *spi) -{ - /* we own the spi bus, so just de-select the chip */ - SPI_SELECT(spi, SPIDEV_DISPLAY, false); -} -#else static void memlcd_deselect(FAR struct spi_dev_s *spi) { - /* de-select memlcd and relinquish the spi bus. */ + /* De-select memlcd and relinquish the spi bus. */ + SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_LOCK(spi, false); } -#endif /**************************************************************************** * Name: memlcd_clear @@ -765,11 +703,10 @@ FAR struct lcd_dev_s *memlcd_initialize(FAR struct spi_dev_s *spi, DEBUGASSERT(spi && priv && devno == 0); - /* register board specific functions */ - mlcd->priv = priv; + /* Register board specific functions */ + mlcd->priv = priv; mlcd->spi = spi; - memlcd_configspi(spi); mlcd->priv->attachirq(memlcd_extcominisr); diff --git a/drivers/lcd/nokia6100.c b/drivers/lcd/nokia6100.c index d6f71590e98..d3a765a812b 100644 --- a/drivers/lcd/nokia6100.c +++ b/drivers/lcd/nokia6100.c @@ -338,14 +338,8 @@ struct nokia_dev_s /* SPI support */ -static inline void nokia_configspi(FAR struct spi_dev_s *spi); -#ifdef CONFIG_SPI_OWNBUS -static inline void nokia_select(FAR struct spi_dev_s *spi); -static inline void nokia_deselect(FAR struct spi_dev_s *spi); -#else static void nokia_select(FAR struct spi_dev_s *spi); static void nokia_deselect(FAR struct spi_dev_s *spi); -#endif static void nokia_sndcmd(FAR struct spi_dev_s *spi, const uint8_t cmd); static void nokia_cmdarray(FAR struct spi_dev_s *spi, int len, const uint8_t *cmddata); static void nokia_clrram(FAR struct spi_dev_s *spi); @@ -650,39 +644,6 @@ static const uint8_t g_setcon[] = * Private Functions **************************************************************************************/ -/************************************************************************************** - * Function: nokia_configspi - * - * Description: - * Configure the SPI for use with the Nokia 6100 - * - * Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - **************************************************************************************/ - -static inline void nokia_configspi(FAR struct spi_dev_s *spi) -{ - lcddbg("Mode: %d Bits: %d Frequency: %d\n", - CONFIG_NOKIA6100_SPIMODE, CONFIG_NOKIA6100_WORDWIDTH, CONFIG_NOKIA6100_FREQUENCY); - - /* Configure SPI for the Nokia 6100. But only if we own the SPI bus. Otherwise, don't - * bother because it might change. - */ - -#ifdef CONFIG_SPI_OWNBUS - SPI_SETMODE(spi, CONFIG_NOKIA6100_SPIMODE); - SPI_SETBITS(spi, CONFIG_NOKIA6100_WORDWIDTH); - (void)SPI_HWFEATURES(spi, 0); - (void)SPI_SETFREQUENCY(spi, CONFIG_NOKIA6100_FREQUENCY) -#endif -} - /************************************************************************************** * Function: nokia_select * @@ -699,15 +660,6 @@ static inline void nokia_configspi(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void nokia_select(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just select the chip */ - - lcddbg("SELECTED\n"); - SPI_SELECT(spi, SPIDEV_DISPLAY, true); -} -#else static void nokia_select(FAR struct spi_dev_s *spi) { /* Select Nokia 6100 chip (locking the SPI bus in case there are multiple @@ -727,7 +679,6 @@ static void nokia_select(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_NOKIA6100_FREQUENCY); } -#endif /************************************************************************************** * Function: nokia_deselect @@ -745,15 +696,6 @@ static void nokia_select(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void nokia_deselect(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just de-select the chip */ - - lcddbg("DE-SELECTED\n"); - SPI_SELECT(spi, SPIDEV_DISPLAY, false); -} -#else static void nokia_deselect(FAR struct spi_dev_s *spi) { /* De-select Nokia 6100 chip and relinquish the SPI bus. */ @@ -762,7 +704,6 @@ static void nokia_deselect(FAR struct spi_dev_s *spi) SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_LOCK(spi, false); } -#endif /************************************************************************************** * Name: nokia_sndcmd @@ -1218,9 +1159,8 @@ FAR struct lcd_dev_s *nokia_lcdinitialize(FAR struct spi_dev_s *spi, unsigned in priv->spi = spi; /* Save the SPI instance */ priv->contrast = NOKIA_DEFAULT_CONTRAST; /* Initial contrast setting */ - /* Configure and enable the LCD controller */ + /* Enable the LCD controller */ - nokia_configspi(spi); if (nokia_initialize(priv) == OK) { /* Turn on the backlight */ @@ -1228,5 +1168,6 @@ FAR struct lcd_dev_s *nokia_lcdinitialize(FAR struct spi_dev_s *spi, unsigned in nokia_backlight(CONFIG_NOKIA6100_BLINIT); return &priv->dev; } + return NULL; } diff --git a/drivers/lcd/p14201.c b/drivers/lcd/p14201.c index b79e036aed2..a1df779364a 100644 --- a/drivers/lcd/p14201.c +++ b/drivers/lcd/p14201.c @@ -206,13 +206,8 @@ struct rit_dev_s /* Low-level SPI helpers */ static inline void rit_configspi(FAR struct spi_dev_s *spi); -#ifdef CONFIG_SPI_OWNBUS -static inline void rit_select(FAR struct spi_dev_s *spi); -static inline void rit_deselect(FAR struct spi_dev_s *spi); -#else static void rit_select(FAR struct spi_dev_s *spi); static void rit_deselect(FAR struct spi_dev_s *spi); -#endif static void rit_sndbytes(FAR struct rit_dev_s *priv, FAR const uint8_t *buffer, size_t buflen, bool cmd); static void rit_sndcmds(FAR struct rit_dev_s *priv, FAR const uint8_t *table); @@ -457,14 +452,12 @@ static inline void rit_configspi(FAR struct spi_dev_s *spi) * bother because it might change. */ -#ifdef CONFIG_SPI_OWNBUS SPI_SETMODE(spi, CONFIG_P14201_SPIMODE); SPI_SETBITS(spi, 8); (void)SPI_HWFEATURES(spi, 0); #ifdef CONFIG_P14201_FREQUENCY (void)SPI_SETFREQUENCY(spi, CONFIG_P14201_FREQUENCY) #endif -#endif } /************************************************************************************** @@ -483,14 +476,6 @@ static inline void rit_configspi(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void rit_select(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just select the chip */ - - SPI_SELECT(spi, SPIDEV_DISPLAY, true); -} -#else static void rit_select(FAR struct spi_dev_s *spi) { /* Select P14201 chip (locking the SPI bus in case there are multiple @@ -511,7 +496,6 @@ static void rit_select(FAR struct spi_dev_s *spi) (void)SPI_SETFREQUENCY(spi, CONFIG_P14201_FREQUENCY); #endif } -#endif /************************************************************************************** * Name: rit_deselect @@ -529,14 +513,6 @@ static void rit_select(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void rit_deselect(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just de-select the chip */ - - SPI_SELECT(spi, SPIDEV_DISPLAY, false); -} -#else static void rit_deselect(FAR struct spi_dev_s *spi) { /* De-select P14201 chip and relinquish the SPI bus. */ @@ -544,7 +520,6 @@ static void rit_deselect(FAR struct spi_dev_s *spi) SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_LOCK(spi, false); } -#endif /************************************************************************************** * Name: rit_sndbytes diff --git a/drivers/lcd/ssd1306.h b/drivers/lcd/ssd1306.h index 8dbb4f1a831..b75672936e6 100644 --- a/drivers/lcd/ssd1306.h +++ b/drivers/lcd/ssd1306.h @@ -258,10 +258,7 @@ void ssd1306_sendblk(FAR struct ssd1306_dev_s *priv, uint8_t *data, uint8_t len) #ifdef CONFIG_LCD_SSD1306_SPI void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs); void ssd1306_cmddata(FAR struct ssd1306_dev_s *priv, bool cmd); - -#ifndef CONFIG_SPI_OWNBUS static inline void ssd1306_configspi(FAR struct spi_dev_s *spi) -#endif #else # define ssd1306_select(priv, cs) diff --git a/drivers/lcd/ssd1306_base.c b/drivers/lcd/ssd1306_base.c index 13d0a7195d5..2ac7bbeca1c 100644 --- a/drivers/lcd/ssd1306_base.c +++ b/drivers/lcd/ssd1306_base.c @@ -818,23 +818,9 @@ FAR struct lcd_dev_s *ssd1306_initialize(FAR struct i2c_dev_s *dev, unsigned int #ifdef CONFIG_LCD_SSD1306_SPI priv->spi = dev; - /* If this SPI bus is not shared, then we can config it now. - * If it is shared, then other device could change our config, - * then just configure before sending data. - */ - -# ifdef CONFIG_SPI_OWNBUS - /* Configure SPI */ - - SPI_SETMODE(priv->spi, CONFIG_SSD1306_SPIMODE); - SPI_SETBITS(priv->spi, 8); - (void)SPI_HWFEATURES(priv->spi, 0); - (void)SPI_SETFREQUENCY(priv->spi, CONFIG_SSD1306_FREQUENCY); -# else /* Configure the SPI */ ssd1306_configspi(priv->spi); -# endif #else /* Remember the I2C configuration */ diff --git a/drivers/lcd/ssd1306_spi.c b/drivers/lcd/ssd1306_spi.c index fedc3eae9d1..b17466c40ea 100644 --- a/drivers/lcd/ssd1306_spi.c +++ b/drivers/lcd/ssd1306_spi.c @@ -61,7 +61,6 @@ * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void ssd1306_configspi(FAR struct spi_dev_s *spi) { lcdvdbg("Mode: %d Bits: 8 Frequency: %d\n", @@ -74,7 +73,6 @@ static inline void ssd1306_configspi(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_SSD1306_FREQUENCY); } -#endif /**************************************************************************** * Public Functions @@ -124,7 +122,6 @@ void ssd1306_sendblk(FAR struct ssd1306_dev_s *priv, uint8_t *data, uint8_t len) void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs) { -#ifndef CONFIG_SPI_OWNBUS /* If we are selecting the device */ if (cs == true) @@ -134,13 +131,11 @@ void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs) (void)SPI_LOCK(priv->spi, true); ssd1306_configspi(priv->spi); } -#endif /* Select/deselect SPI device */ SPI_SELECT(priv->spi, SPIDEV_DISPLAY, cs); -#ifndef CONFIG_SPI_OWNBUS /* If we are deselecting the device */ if (cs == false) @@ -149,7 +144,6 @@ void ssd1306_select(FAR struct ssd1306_dev_s *priv, bool cs) (void)SPI_LOCK(priv->spi, false); } -#endif } /**************************************************************************** diff --git a/drivers/lcd/ssd1351.c b/drivers/lcd/ssd1351.c index 30178930a26..c56cc2b6823 100644 --- a/drivers/lcd/ssd1351.c +++ b/drivers/lcd/ssd1351.c @@ -507,12 +507,10 @@ static void ssd1351_select(FAR struct ssd1351_dev_s *priv) * have gotten configured for a different device while unlocked) */ -#ifndef CONFIG_SPI_OWNBUS SPI_SETMODE(spi, CONFIG_SSD1351_SPIMODE); SPI_SETBITS(spi, SSD1351_SPIBITS); (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_SSD1351_SPIFREQ); -#endif } #endif @@ -1189,19 +1187,6 @@ FAR struct lcd_dev_s *ssd1351_initialize(FAR struct spi_dev_s *spi, #endif priv->power = LCD_FULL_OFF; - /* Configure the SPI bus if we own it. Otherwise, don't bother because - * it might change. - */ - -#if defined(CONFIG_SSD1351_SPI3WIRE) || defined(CONFIG_SSD1351_SPI4WIRE) -#ifdef CONFIG_SPI_OWNBUS - SPI_SETMODE(spi, CONFIG_SSD1351_SPIMODE); - SPI_SETBITS(spi, SSD1351_SPIBITS); - (void)SPI_HWFEATURES(spi, 0); - (void)SPI_SETFREQUENCY(spi, CONFIG_SSD1351_SPIFREQ); -#endif -#endif - /* Configure the device */ ssd1351_hwinitialize(priv); diff --git a/drivers/lcd/st7567.c b/drivers/lcd/st7567.c index 1a597f22e48..77ba1bbc1dd 100644 --- a/drivers/lcd/st7567.c +++ b/drivers/lcd/st7567.c @@ -246,13 +246,8 @@ struct st7567_dev_s /* SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS -static inline void st7567_select(FAR struct spi_dev_s *spi); -static inline void st7567_deselect(FAR struct spi_dev_s *spi); -#else static void st7567_select(FAR struct spi_dev_s *spi); static void st7567_deselect(FAR struct spi_dev_s *spi); -#endif /* LCD Data Transfer Methods */ @@ -371,14 +366,6 @@ static struct st7567_dev_s g_st7567dev = * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void st7567_select(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just select the chip */ - - SPI_SELECT(spi, SPIDEV_DISPLAY, true); -} -#else static void st7567_select(FAR struct spi_dev_s *spi) { /* Select ST7567 chip (locking the SPI bus in case there are multiple @@ -399,7 +386,6 @@ static void st7567_select(FAR struct spi_dev_s *spi) (void)SPI_SETFREQUENCY(spi, CONFIG_ST7567_FREQUENCY); #endif } -#endif /************************************************************************************** * Function: st7567_deselect @@ -417,14 +403,6 @@ static void st7567_select(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void st7567_deselect(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just de-select the chip */ - - SPI_SELECT(spi, SPIDEV_DISPLAY, false); -} -#else static void st7567_deselect(FAR struct spi_dev_s *spi) { /* De-select ST7567 chip and relinquish the SPI bus. */ @@ -432,7 +410,6 @@ static void st7567_deselect(FAR struct spi_dev_s *spi) SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_LOCK(spi, false); } -#endif /************************************************************************************** * Name: st7567_putrun diff --git a/drivers/lcd/ug-2864ambag01.c b/drivers/lcd/ug-2864ambag01.c index 1d1b773316a..ab53fbc0247 100644 --- a/drivers/lcd/ug-2864ambag01.c +++ b/drivers/lcd/ug-2864ambag01.c @@ -301,15 +301,8 @@ struct ug2864ambag01_dev_s /* Low-level SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS -static inline void ug2864ambag01_configspi(FAR struct spi_dev_s *spi); -# define ug2864ambag01_lock(spi) -# define ug2864ambag01_unlock(spi) -#else -# define ug2864ambag01_configspi(spi) static void ug2864ambag01_lock(FAR struct spi_dev_s *spi); static void ug2864ambag01_unlock(FAR struct spi_dev_s *spi); -#endif /* LCD Data Transfer Methods */ @@ -408,39 +401,6 @@ static struct ug2864ambag01_dev_s g_oleddev = * Private Functions **************************************************************************************/ -/************************************************************************************** - * Name: ug2864ambag01_configspi - * - * Description: - * Configure the SPI for use with the UG-2864AMBAG01 - * - * Input Parameters: - * spi - Reference to the SPI driver structure - * - * Returned Value: - * None - * - * Assumptions: - * - **************************************************************************************/ - -#ifdef CONFIG_SPI_OWNBUS -static inline void ug2864ambag01_configspi(FAR struct spi_dev_s *spi) -{ - lcdvdbg("Mode: %d Bits: 8 Frequency: %d\n", - CONFIG_UG2864AMBAG01_SPIMODE, CONFIG_UG2864AMBAG01_FREQUENCY); - - /* Configure SPI for the UG-2864AMBAG01. But only if we own the SPI bus. Otherwise, - * don't bother because it might change. - */ - - SPI_SETMODE(spi, CONFIG_UG2864AMBAG01_SPIMODE); - SPI_SETBITS(spi, 8); - (void)SPI_HWFEATURES(spi, 0); - (void)SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY); -} -#endif - /************************************************************************************** * Name: ug2864ambag01_lock * @@ -457,7 +417,6 @@ static inline void ug2864ambag01_configspi(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi) { /* Lock the SPI bus if there are multiple devices competing for the SPI bus. */ @@ -473,7 +432,6 @@ static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY); } -#endif /************************************************************************************** * Name: ug2864ambag01_unlock @@ -491,14 +449,12 @@ static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void ug2864ambag01_unlock(FAR struct spi_dev_s *spi) { /* De-select UG-2864AMBAG01 chip and relinquish the SPI bus. */ SPI_LOCK(spi, false); } -#endif /************************************************************************************** * Name: ug2864ambag01_putrun @@ -1080,10 +1036,6 @@ FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi, unsign priv->spi = spi; - /* Configure the SPI */ - - ug2864ambag01_configspi(spi); - /* Lock and select device */ ug2864ambag01_lock(priv->spi); diff --git a/drivers/lcd/ug-9664hswag01.c b/drivers/lcd/ug-9664hswag01.c index be97d551b0e..e9053a7218e 100644 --- a/drivers/lcd/ug-9664hswag01.c +++ b/drivers/lcd/ug-9664hswag01.c @@ -261,13 +261,8 @@ struct ug_dev_s /* SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS -static inline void ug_select(FAR struct spi_dev_s *spi); -static inline void ug_deselect(FAR struct spi_dev_s *spi); -#else static void ug_select(FAR struct spi_dev_s *spi); static void ug_deselect(FAR struct spi_dev_s *spi); -#endif /* LCD Data Transfer Methods */ @@ -415,14 +410,6 @@ static inline FAR const char *ug_powerstring(uint8_t power) * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void ug_select(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just select the chip */ - - SPI_SELECT(spi, SPIDEV_DISPLAY, true); -} -#else static void ug_select(FAR struct spi_dev_s *spi) { /* Select UG-9664HSWAG01 chip (locking the SPI bus in case there are multiple @@ -443,7 +430,6 @@ static void ug_select(FAR struct spi_dev_s *spi) (void)SPI_SETFREQUENCY(spi, CONFIG_UG9664HSWAG01_FREQUENCY); #endif } -#endif /************************************************************************************** * Function: ug_deselect @@ -461,14 +447,6 @@ static void ug_select(FAR struct spi_dev_s *spi) * **************************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void ug_deselect(FAR struct spi_dev_s *spi) -{ - /* We own the SPI bus, so just de-select the chip */ - - SPI_SELECT(spi, SPIDEV_DISPLAY, false); -} -#else static void ug_deselect(FAR struct spi_dev_s *spi) { /* De-select UG-9664HSWAG01 chip and relinquish the SPI bus. */ @@ -476,7 +454,6 @@ static void ug_deselect(FAR struct spi_dev_s *spi) SPI_SELECT(spi, SPIDEV_DISPLAY, false); SPI_LOCK(spi, false); } -#endif /************************************************************************************** * Name: ug_putrun diff --git a/drivers/mmcsd/mmcsd_spi.c b/drivers/mmcsd/mmcsd_spi.c index e4cfc4ecda6..b9101fe1b18 100644 --- a/drivers/mmcsd/mmcsd_spi.c +++ b/drivers/mmcsd/mmcsd_spi.c @@ -158,9 +158,7 @@ struct mmcsd_slot_s uint32_t twrite; /* Card write time */ uint32_t ocr; /* Last 4 bytes of OCR (R3) */ uint32_t r7; /* Last 4 bytes of R7 */ -#ifndef CONFIG_SPI_OWNBUS uint32_t spispeed; /* Speed to use for SPI in data mode */ -#endif }; struct mmcsd_cmdinfo_s @@ -181,12 +179,6 @@ static void mmcsd_semgive(FAR struct mmcsd_slot_s *slot); /* Card SPI interface *******************************************************/ -#ifdef CONFIG_SPI_OWNBUS -static inline void mmcsd_spiinit(FAR struct mmcsd_slot_s *slot); -#else -# define mmcsd_spiinit(slot) -#endif - static int mmcsd_waitready(FAR struct mmcsd_slot_s *slot); static uint32_t mmcsd_sendcmd(FAR struct mmcsd_slot_s *slot, const struct mmcsd_cmdinfo_s *cmd, uint32_t arg); @@ -358,7 +350,6 @@ static void mmcsd_semtake(FAR struct mmcsd_slot_s *slot) { /* Get exclusive access to the SPI bus (if necessary) */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(slot->spi, true); /* Set the frequency, bit width and mode, as some other driver could have @@ -369,7 +360,6 @@ static void mmcsd_semtake(FAR struct mmcsd_slot_s *slot) SPI_SETBITS(slot->spi, 8); (void)SPI_HWFEATURES(slot->spi, 0); (void)SPI_SETFREQUENCY(slot->spi, slot->spispeed); -#endif /* Get exclusive access to the MMC/SD device (possibly unnecessary if * SPI_LOCK is also implemented as a semaphore). @@ -397,7 +387,6 @@ static void mmcsd_semgive(FAR struct mmcsd_slot_s *slot) /* Relinquish the lock on the SPI bus */ -#ifndef CONFIG_SPI_OWNBUS /* The card may need up to 8 SCLK cycles to sample the CS status * and release the MISO line. */ @@ -407,29 +396,8 @@ static void mmcsd_semgive(FAR struct mmcsd_slot_s *slot) /* Relinquish exclusive access to the SPI bus */ (void)SPI_LOCK(slot->spi, false); -#endif } -/**************************************************************************** - * Name: mmcsd_spiinit - * - * Description: - * Set SPI mode and data width. - * - * Assumptions: - * MMC/SD card already selected - * - ****************************************************************************/ - -#ifdef CONFIG_SPI_OWNBUS -static inline void mmcsd_spiinit(FAR struct mmcsd_slot_s *slot) -{ - SPI_SETMODE(slot->spi, CONFIG_MMCSD_SPIMODE); - SPI_SETBITS(slot->spi, 8); - (void)SPI_HWFEATURES(slot->spi, 0); -} -#endif - /**************************************************************************** * Name: mmcsd_waitready * @@ -738,9 +706,7 @@ static void mmcsd_decodecsd(FAR struct mmcsd_slot_s *slot, uint8_t *csd) /* Set the actual SPI frequency as close as possible to the max frequency */ -#ifndef CONFIG_SPI_OWNBUS slot->spispeed = frequency; -#endif frequency = SPI_SETFREQUENCY(spi, frequency); /* Now determine the delay to access data */ @@ -1607,9 +1573,7 @@ static int mmcsd_mediainitialize(FAR struct mmcsd_slot_s *slot) /* Clock Freq. Identification Mode < 400kHz */ -#ifndef CONFIG_SPI_OWNBUS slot->spispeed = MMCSD_IDMODE_CLOCK; -#endif (void)SPI_SETFREQUENCY(spi, MMCSD_IDMODE_CLOCK); /* Set the maximum access time out */ @@ -1974,17 +1938,14 @@ int mmcsd_spislotinitialize(int minor, int slotno, FAR struct spi_dev_s *spi) /* Bind the SPI port to the slot */ - slot->spi = spi; -#ifndef CONFIG_SPI_OWNBUS + slot->spi = spi; slot->spispeed = MMCSD_IDMODE_CLOCK; -#endif /* Get exclusive access to the SPI bus and make sure that SPI is properly * configured for the MMC/SD card */ mmcsd_semtake(slot); - mmcsd_spiinit(slot); /* Initialize for the media in the slot (if any) */ diff --git a/drivers/mtd/at25.c b/drivers/mtd/at25.c index 8ab7c1728cb..e085ca8b89b 100644 --- a/drivers/mtd/at25.c +++ b/drivers/mtd/at25.c @@ -256,34 +256,6 @@ static void at25_waitwritecomplete(struct at25_dev_s *priv) { uint8_t status; - /* Are we the only device on the bus? */ - -#ifdef CONFIG_SPI_OWNBUS - - /* Select this FLASH part */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, true); - - /* Send "Read Status Register (RDSR)" command */ - - (void)SPI_SEND(priv->dev, AT25_RDSR); - - /* Loop as long as the memory is busy with a write cycle */ - - do - { - /* Send a dummy byte to generate the clock needed to shift out the status */ - - status = SPI_SEND(priv->dev, AT25_DUMMY); - } - while ((status & AT25_SR_BUSY) != 0); - - /* Deselect the FLASH */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, false); - -#else - /* Loop as long as the memory is busy with a write cycle */ do @@ -317,7 +289,6 @@ static void at25_waitwritecomplete(struct at25_dev_s *priv) } } while ((status & AT25_SR_BUSY) != 0); -#endif if (status & AT25_SR_EPE) { diff --git a/drivers/mtd/m25px.c b/drivers/mtd/m25px.c index f1b71dfc11f..3a9bda2c9da 100644 --- a/drivers/mtd/m25px.c +++ b/drivers/mtd/m25px.c @@ -418,34 +418,6 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv) { uint8_t status; - /* Are we the only device on the bus? */ - -#ifdef CONFIG_SPI_OWNBUS - - /* Select this FLASH part */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, true); - - /* Send "Read Status Register (RDSR)" command */ - - (void)SPI_SEND(priv->dev, M25P_RDSR); - - /* Loop as long as the memory is busy with a write cycle */ - - do - { - /* Send a dummy byte to generate the clock needed to shift out the status */ - - status = SPI_SEND(priv->dev, M25P_DUMMY); - } - while ((status & M25P_SR_WIP) != 0); - - /* Deselect the FLASH */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, false); - -#else - /* Loop as long as the memory is busy with a write cycle */ do @@ -479,7 +451,6 @@ static void m25p_waitwritecomplete(struct m25p_dev_s *priv) } } while ((status & M25P_SR_WIP) != 0); -#endif fvdbg("Complete\n"); } diff --git a/drivers/mtd/sst25.c b/drivers/mtd/sst25.c index 2a9b3e50f01..61a79a63b5e 100644 --- a/drivers/mtd/sst25.c +++ b/drivers/mtd/sst25.c @@ -396,34 +396,6 @@ static uint8_t sst25_waitwritecomplete(struct sst25_dev_s *priv) { uint8_t status; - /* Are we the only device on the bus? */ - -#ifdef CONFIG_SPI_OWNBUS - - /* Select this FLASH part */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, true); - - /* Send "Read Status Register (RDSR)" command */ - - (void)SPI_SEND(priv->dev, SST25_RDSR); - - /* Loop as long as the memory is busy with a write cycle */ - - do - { - /* Send a dummy byte to generate the clock needed to shift out the status */ - - status = SPI_SEND(priv->dev, SST25_DUMMY); - } - while ((status & SST25_SR_BUSY) != 0); - - /* Deselect the FLASH */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, false); - -#else - /* Loop as long as the memory is busy with a write cycle */ do @@ -459,7 +431,6 @@ static uint8_t sst25_waitwritecomplete(struct sst25_dev_s *priv) #endif } while ((status & SST25_SR_BUSY) != 0); -#endif return status; } diff --git a/drivers/mtd/sst25xx.c b/drivers/mtd/sst25xx.c index 3a1c086c250..ebbcfd33f2f 100644 --- a/drivers/mtd/sst25xx.c +++ b/drivers/mtd/sst25xx.c @@ -315,36 +315,10 @@ static void sst25xx_waitwritecomplete(struct sst25xx_dev_s *priv) #if 0 if (!priv->lastwaswrite) - return; -#endif - - /* Are we the only device on the bus? */ - -#ifdef CONFIG_SPI_OWNBUS - - /* Select this FLASH part */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, true); - - /* Send "Read Status Register (RDSR)" command */ - - (void)SPI_SEND(priv->dev, SST25_RDSR); - - /* Loop as long as the memory is busy with a write cycle */ - - do { - /* Send a dummy byte to generate the clock needed to shift out the status */ - - status = SPI_SEND(priv->dev, SST25_DUMMY); + return; } - while ((status & SST25_SR_WIP) != 0); - - /* Deselect the FLASH */ - - SPI_SELECT(priv->dev, SPIDEV_FLASH, false); - -#else +#endif /* Loop as long as the memory is busy with a write cycle */ @@ -380,8 +354,6 @@ static void sst25xx_waitwritecomplete(struct sst25xx_dev_s *priv) } while ((status & SST25_SR_WIP) != 0); -#endif - priv->lastwaswrite = false; fvdbg("Complete\n"); diff --git a/drivers/mtd/w25.c b/drivers/mtd/w25.c index 1ea22d5bc3c..09a7c015d25 100644 --- a/drivers/mtd/w25.c +++ b/drivers/mtd/w25.c @@ -472,34 +472,6 @@ static uint8_t w25_waitwritecomplete(struct w25_dev_s *priv) { uint8_t status; - /* Are we the only device on the bus? */ - -#ifdef CONFIG_SPI_OWNBUS - - /* Select this FLASH part */ - - SPI_SELECT(priv->spi, SPIDEV_FLASH, true); - - /* Send "Read Status Register (RDSR)" command */ - - (void)SPI_SEND(priv->spi, W25_RDSR); - - /* Loop as long as the memory is busy with a write cycle */ - - do - { - /* Send a dummy byte to generate the clock needed to shift out the status */ - - status = SPI_SEND(priv->spi, W25_DUMMY); - } - while ((status & W25_SR_BUSY) != 0); - - /* Deselect the FLASH */ - - SPI_SELECT(priv->spi, SPIDEV_FLASH, false); - -#else - /* Loop as long as the memory is busy with a write cycle */ do @@ -535,7 +507,6 @@ static uint8_t w25_waitwritecomplete(struct w25_dev_s *priv) #endif } while ((status & W25_SR_BUSY) != 0); -#endif return status; } diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index 43d0e6c6859..842d18cc2aa 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c @@ -270,15 +270,9 @@ static struct enc_driver_s g_enc28j60[CONFIG_ENC28J60_NINTERFACES]; /* Low-level SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS static inline void enc_configspi(FAR struct spi_dev_s *spi); -# define enc_lock(priv); -# define enc_unlock(priv); -#else -# define enc_configspi(spi) static void enc_lock(FAR struct enc_driver_s *priv); static inline void enc_unlock(FAR struct enc_driver_s *priv); -#endif /* SPI control register access */ @@ -372,19 +366,15 @@ static int enc_reset(FAR struct enc_driver_s *priv); * ****************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS static inline void enc_configspi(FAR struct spi_dev_s *spi) { - /* Configure SPI for the ENC28J60. But only if we own the SPI bus. - * Otherwise, don't bother because it might change. - */ + /* Configure SPI for the ENC28J60. */ SPI_SETMODE(spi, CONFIG_ENC28J60_SPIMODE); SPI_SETBITS(spi, 8); (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_ENC28J60_FREQUENCY); } -#endif /**************************************************************************** * Function: enc_lock @@ -402,7 +392,6 @@ static inline void enc_configspi(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void enc_lock(FAR struct enc_driver_s *priv) { /* Lock the SPI bus in case there are multiple devices competing for the SPI @@ -420,7 +409,6 @@ static void enc_lock(FAR struct enc_driver_s *priv) (void)SPI_HWFEATURES(priv->spi, 0); (void)SPI_SETFREQUENCY(priv->spi, CONFIG_ENC28J60_FREQUENCY); } -#endif /**************************************************************************** * Function: enc_unlock @@ -438,14 +426,12 @@ static void enc_lock(FAR struct enc_driver_s *priv) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void enc_unlock(FAR struct enc_driver_s *priv) { /* Relinquish the lock on the bus. */ SPI_LOCK(priv->spi, false); } -#endif /**************************************************************************** * Function: enc_rdgreg2 diff --git a/drivers/net/encx24j600.c b/drivers/net/encx24j600.c index 8c5e57e2559..4eeb85f2e6b 100644 --- a/drivers/net/encx24j600.c +++ b/drivers/net/encx24j600.c @@ -285,15 +285,9 @@ static struct enc_driver_s g_encx24j600[CONFIG_ENCX24J600_NINTERFACES]; /* Low-level SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS static inline void enc_configspi(FAR struct spi_dev_s *spi); -# define enc_lock(priv); -# define enc_unlock(priv); -#else -# define enc_configspi(spi) static void enc_lock(FAR struct enc_driver_s *priv); static inline void enc_unlock(FAR struct enc_driver_s *priv); -#endif /* SPI control register access */ @@ -395,19 +389,15 @@ static int enc_reset(FAR struct enc_driver_s *priv); * ****************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS static inline void enc_configspi(FAR struct spi_dev_s *spi) { - /* Configure SPI for the ENCX24J600. But only if we own the SPI bus. - * Otherwise, don't bother because it might change. - */ + /* Configure SPI for the ENCX24J600. */ SPI_SETMODE(spi, CONFIG_ENCX24J600_SPIMODE); SPI_SETBITS(spi, 8); (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_ENCX24J600_FREQUENCY); } -#endif /**************************************************************************** * Function: enc_lock @@ -425,7 +415,6 @@ static inline void enc_configspi(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void enc_lock(FAR struct enc_driver_s *priv) { /* Lock the SPI bus in case there are multiple devices competing for the SPI @@ -443,7 +432,6 @@ static void enc_lock(FAR struct enc_driver_s *priv) (void)SPI_HWFEATURES(priv->spi, 0); (void)SPI_SETFREQUENCY(priv->spi, CONFIG_ENCX24J600_FREQUENCY); } -#endif /**************************************************************************** * Function: enc_unlock @@ -461,14 +449,12 @@ static void enc_lock(FAR struct enc_driver_s *priv) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void enc_unlock(FAR struct enc_driver_s *priv) { /* Relinquish the lock on the bus. */ SPI_LOCK(priv->spi, false); } -#endif /**************************************************************************** * Function: enc_cmd diff --git a/drivers/sensors/adxl345_base.c b/drivers/sensors/adxl345_base.c index dfca4e30d0f..4b2f95fbde0 100644 --- a/drivers/sensors/adxl345_base.c +++ b/drivers/sensors/adxl345_base.c @@ -409,20 +409,6 @@ ADXL345_HANDLE adxl345_instantiate(FAR struct i2c_dev_s *dev, #ifdef CONFIG_ADXL345_SPI priv->spi = dev; - /* If this SPI bus is not shared, then we can config it now. - * If it is shared, then other device could change our config, - * then just configure before sending data. - */ - -#ifdef CONFIG_SPI_OWNBUS - /* Configure SPI for the ADXL345 */ - - SPI_SETMODE(priv->spi, SPIDEV_MODE3); - SPI_SETBITS(priv->spi, 8); - (void)SPI_HWFEATURES(priv->spi, 0); - (void)SPI_SETFREQUENCY(priv->spi, ADXL345_SPI_MAXFREQUENCY); -#endif - #else priv->i2c = dev; diff --git a/drivers/sensors/adxl345_spi.c b/drivers/sensors/adxl345_spi.c index 381eec64b75..1e837132af1 100644 --- a/drivers/sensors/adxl345_spi.c +++ b/drivers/sensors/adxl345_spi.c @@ -64,7 +64,6 @@ * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void adxl345_configspi(FAR struct spi_dev_s *spi) { /* Configure SPI for the ADXL345 */ @@ -74,7 +73,6 @@ static inline void adxl345_configspi(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, ADXL345_SPI_MAXFREQUENCY); } -#endif /**************************************************************************** * Public Functions @@ -94,10 +92,8 @@ uint8_t adxl345_getreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr) /* If SPI bus is shared then lock and configure it */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(priv->spi, true); adxl345_configspi(priv->spi); -#endif /* Select the ADXL345 */ @@ -114,9 +110,7 @@ uint8_t adxl345_getreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr) /* Unlock bus */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(priv->spi, false); -#endif #ifdef CONFIG_ADXL345_REGDEBUG dbg("%02x->%02x\n", regaddr, regval); @@ -141,10 +135,8 @@ void adxl345_putreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr, /* If SPI bus is shared then lock and configure it */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(priv->spi, true); adxl345_configspi(priv->spi); -#endif /* Select the ADXL345 */ @@ -160,9 +152,8 @@ void adxl345_putreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr, SPI_SELECT(priv->spi, SPIDEV_ACCELEROMETER, false); /* Unlock bus */ -#ifndef CONFIG_SPI_OWNBUS + (void)SPI_LOCK(priv->spi, false); -#endif } /**************************************************************************** @@ -179,10 +170,8 @@ uint16_t adxl345_getreg16(FAR struct adxl345_dev_s *priv, uint8_t regaddr) /* If SPI bus is shared then lock and configure it */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(priv->spi, true); adxl345_configspi(priv->spi); -#endif /* Select the ADXL345 */ @@ -199,9 +188,7 @@ uint16_t adxl345_getreg16(FAR struct adxl345_dev_s *priv, uint8_t regaddr) /* Unlock bus */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(priv->spi, false); -#endif #ifdef CONFIG_ADXL345_REGDEBUG dbg("%02x->%04x\n", regaddr, regval); diff --git a/drivers/sensors/max31855.c b/drivers/sensors/max31855.c index 7fc21f43563..c239d9688d8 100644 --- a/drivers/sensors/max31855.c +++ b/drivers/sensors/max31855.c @@ -279,15 +279,6 @@ int max31855_register(FAR const char *devpath, FAR struct spi_dev_s *spi) priv->spi = spi; priv->temp = 0; -#ifdef CONFIG_SPI_OWNBUS - /* Configure SPI for the MAX31855 */ - - SPI_SETMODE(priv->spi, SPIDEV_MODE1); - SPI_SETBITS(priv->spi, 8); - (void)SPI_HWFEATURES(priv->spi, 0); - (void)SPI_SETFREQUENCY(priv->spi, MAX31855_SPI_MAXFREQ); -#endif - /* Register the character driver */ ret = register_driver(devpath, &g_max31855fops, 0666, priv); diff --git a/drivers/sensors/max6675.c b/drivers/sensors/max6675.c index 7c2404d1766..38aa6c18a7f 100644 --- a/drivers/sensors/max6675.c +++ b/drivers/sensors/max6675.c @@ -256,15 +256,6 @@ int max6675_register(FAR const char *devpath, FAR struct spi_dev_s *spi) priv->spi = spi; priv->temp = 0; -#ifdef CONFIG_SPI_OWNBUS - /* Configure SPI for the MAX6675 */ - - SPI_SETMODE(priv->spi, SPIDEV_MODE1); - SPI_SETBITS(priv->spi, 8); - (void)SPI_HWFEATURES(priv->spi, 0); - (void)SPI_SETFREQUENCY(priv->spi, MAX6675_SPI_MAXFREQ); -#endif - /* Register the character driver */ ret = register_driver(devpath, &g_max6675fops, 0666, priv); diff --git a/drivers/sensors/mpl115a.c b/drivers/sensors/mpl115a.c index ba43af3aa84..0c4e87414c3 100644 --- a/drivers/sensors/mpl115a.c +++ b/drivers/sensors/mpl115a.c @@ -112,7 +112,6 @@ static const struct file_operations g_mpl115afops = * Private Functions ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static inline void mpl115a_configspi(FAR struct spi_dev_s *spi) { /* Configure SPI for the MPL115A */ @@ -122,7 +121,6 @@ static inline void mpl115a_configspi(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, MPL115A_SPI_MAXFREQUENCY); } -#endif /**************************************************************************** * Name: mpl115a_getreg8 @@ -138,10 +136,8 @@ static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv, uint8_t regaddr) /* If SPI bus is shared then lock and configure it */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(priv->spi, true); mpl115a_configspi(priv->spi); -#endif /* Select the MPL115A */ @@ -158,9 +154,7 @@ static uint8_t mpl115a_getreg8(FAR struct mpl115a_dev_s *priv, uint8_t regaddr) /* Unlock bus */ -#ifndef CONFIG_SPI_OWNBUS (void)SPI_LOCK(priv->spi, false); -#endif #ifdef CONFIG_MPL115A_REGDEBUG dbg("%02x->%02x\n", regaddr, regval); diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index c416b67b562..4d0b72741c8 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -22,14 +22,6 @@ config SPI_SLAVE_DMA endif -config SPI_OWNBUS - bool "SPI single device" - default n - ---help--- - Set if there is only one active device on the SPI bus. No locking or - SPI configuration will be performed. It is not necessary for clients to - lock, re-configure, etc. - config SPI_EXCHANGE bool "SPI exchange" default y diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c index 7f3a41c5496..823b330982f 100644 --- a/drivers/spi/spi_bitbang.c +++ b/drivers/spi/spi_bitbang.c @@ -110,9 +110,7 @@ /* SPI methods */ -#ifndef CONFIG_SPI_OWNBUS static int spi_lock(FAR struct spi_dev_s *dev, bool lock); -#endif static void spi_select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, @@ -144,9 +142,7 @@ static int spi_cmddata(FAR struct spi_dev_s *dev, enum spi_dev_e devid, static const struct spi_ops_s g_spiops = { -#ifndef CONFIG_SPI_OWNBUS spi_lock, /* lock */ -#endif spi_select, /* select */ spi_setfrequency, /* setfrequency */ spi_setmode, /* setmode */ @@ -193,7 +189,6 @@ static const struct spi_ops_s g_spiops = * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static int spi_lock(FAR struct spi_dev_s *dev, bool lock) { FAR struct spi_bitbang_s *priv = (FAR struct spi_bitbang_s *)dev; @@ -219,7 +214,6 @@ static int spi_lock(FAR struct spi_dev_s *dev, bool lock) return OK; } -#endif /**************************************************************************** * Name: spi_select diff --git a/drivers/wireless/cc3000/cc3000.c b/drivers/wireless/cc3000/cc3000.c index 9e7e9d2c0c5..29b6ad84b1f 100644 --- a/drivers/wireless/cc3000/cc3000.c +++ b/drivers/wireless/cc3000/cc3000.c @@ -283,15 +283,9 @@ static inline void cc3000_configspi(FAR struct spi_dev_s *spi) static void cc3000_lock_and_select(FAR struct spi_dev_s *spi) { -#ifndef CONFIG_SPI_OWNBUS - /* Lock the SPI bus because there are multiple devices competing for the - * SPI bus - */ - /* Lock the SPI bus so that we have exclusive access */ (void)SPI_LOCK(spi, true); -#endif /* We have the lock. Now make sure that the SPI bus is configured for the * CC3000 (it might have gotten configured for a different device while @@ -306,9 +300,8 @@ static void cc3000_lock_and_select(FAR struct spi_dev_s *spi) * Function: cc3000_unlock * * Description: - * If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS - * undefined) then we need to un-lock the SPI bus for each transfer, - * possibly losing the current configuration. + * Un-lock the SPI bus after each transfer, possibly losing the current + * configuration if we are sharing the SPI bus with other devices. * * Parameters: * spi - Reference to the SPI driver structure @@ -326,11 +319,9 @@ static void cc3000_deselect_and_unlock(FAR struct spi_dev_s *spi) SPI_SELECT(spi, SPIDEV_WIRELESS, false); -#ifndef CONFIG_SPI_OWNBUS /* Relinquish the SPI bus. */ (void)SPI_LOCK(spi, false); -#endif } /**************************************************************************** diff --git a/drivers/wireless/nrf24l01.c b/drivers/wireless/nrf24l01.c index 430c0b5b7af..0d83651cee5 100644 --- a/drivers/wireless/nrf24l01.c +++ b/drivers/wireless/nrf24l01.c @@ -158,21 +158,13 @@ struct nrf24l01_dev_s ****************************************************************************/ /* Low-level SPI helpers */ -#ifdef CONFIG_SPI_OWNBUS static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi); -# define nrf24l01_lock(spi) -# define nrf24l01_unlock(spi) -#else -# define nrf24l01_configspi(spi); static void nrf24l01_lock(FAR struct spi_dev_s *spi); static void nrf24l01_unlock(FAR struct spi_dev_s *spi); -#endif static uint8_t nrf24l01_access(FAR struct nrf24l01_dev_s *dev, nrf24l01_access_mode_t mode, uint8_t cmd, uint8_t *buf, int length); - static uint8_t nrf24l01_flush_rx(FAR struct nrf24l01_dev_s *dev); - static uint8_t nrf24l01_flush_tx(FAR struct nrf24l01_dev_s *dev); /* Read register from nrf24 */ @@ -250,7 +242,6 @@ static const struct file_operations nrf24l01_fops = * Private Functions ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void nrf24l01_lock(FAR struct spi_dev_s *spi) { /* Lock the SPI bus because there are multiple devices competing for the @@ -271,15 +262,13 @@ static void nrf24l01_lock(FAR struct spi_dev_s *spi) (void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ); SPI_SELECT(spi, SPIDEV_WIRELESS, false); } -#endif /**************************************************************************** * Function: nrf24l01_unlock * * Description: - * If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS - * undefined) then we need to un-lock the SPI bus for each transfer, - * possibly losing the current configuration. + * Un-lock the SPI bus after each transfer, possibly losing the current + * configuration if we are sharing the SPI bus with other devices. * * Parameters: * spi - Reference to the SPI driver structure @@ -291,23 +280,18 @@ static void nrf24l01_lock(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void nrf24l01_unlock(FAR struct spi_dev_s *spi) { /* Relinquish the SPI bus. */ (void)SPI_LOCK(spi, false); } -#endif /**************************************************************************** * Function: nrf24l01_configspi * * Description: - * Configure the SPI for use with the NRF24L01. This function should be - * called once during touchscreen initialization to configure the SPI - * bus. Note that if CONFIG_SPI_OWNBUS is not defined, then this function - * does nothing. + * Configure the SPI for use with the NRF24L01. * * Parameters: * spi - Reference to the SPI driver structure @@ -319,12 +303,9 @@ static void nrf24l01_unlock(FAR struct spi_dev_s *spi) * ****************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi) { - /* Configure SPI for the NRF24L01 module. - * As we own the SPI bus this method is called just once. - */ + /* Configure SPI for the NRF24L01 module. */ SPI_SELECT(spi, SPIDEV_WIRELESS, true); /* Useful ? */ SPI_SETMODE(spi, SPIDEV_MODE0); @@ -333,7 +314,6 @@ static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi) (void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ); SPI_SELECT(spi, SPIDEV_WIRELESS, false); } -#endif static inline void nrf24l01_select(struct nrf24l01_dev_s * dev) { diff --git a/drivers/wireless/pn532.c b/drivers/wireless/pn532.c index 1596db3a6e9..f0a51be5afc 100644 --- a/drivers/wireless/pn532.c +++ b/drivers/wireless/pn532.c @@ -85,15 +85,9 @@ * Private Function Prototypes ****************************************************************************/ -#ifdef CONFIG_SPI_OWNBUS static inline void pn532_configspi(FAR struct spi_dev_s *spi); -# define pn532_lock(spi) -# define pn532_unlock(spi) -#else -# define pn532_configspi(spi); static void pn532_lock(FAR struct spi_dev_s *spi); static void pn532_unlock(FAR struct spi_dev_s *spi); -#endif /* Character driver methods */ @@ -143,7 +137,6 @@ static const uint8_t pn532ack[] = * Private Functions ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS static void pn532_lock(FAR struct spi_dev_s *spi) { (void)SPI_LOCK(spi, true); @@ -153,16 +146,12 @@ static void pn532_lock(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ); } -#endif -#ifndef CONFIG_SPI_OWNBUS static void pn532_unlock(FAR struct spi_dev_s *spi) { (void)SPI_LOCK(spi, false); } -#endif -#ifdef CONFIG_SPI_OWNBUS static inline void pn532_configspi(FAR struct spi_dev_s *spi) { /* Configure SPI for the PN532 module. @@ -174,7 +163,6 @@ static inline void pn532_configspi(FAR struct spi_dev_s *spi) (void)SPI_HWFEATURES(spi, 0); (void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ); } -#endif static inline void pn532_select(struct pn532_dev_s *dev) { diff --git a/include/nuttx/analog/pga11x.h b/include/nuttx/analog/pga11x.h index 9a74e09f0ee..7b6cf7881c3 100644 --- a/include/nuttx/analog/pga11x.h +++ b/include/nuttx/analog/pga11x.h @@ -73,8 +73,6 @@ * When SPI_SELECT is called with devid=SPIDEV_MUX. * * Other settings that effect the driver: - * CONFIG_SPI_OWNBUS -- If the PGA117 is enabled, this must be set to 'y' - * if the PGA117 is the only device on the SPI bus; * CONFIG_DEBUG_SPI -- With CONFIG_DEBUG and CONFIG_DEBUG_VERBOSE, * this will enable debug output from the PGA117 driver. */ diff --git a/include/nuttx/spi/spi.h b/include/nuttx/spi/spi.h index fb2b012c973..b7ba3eac1bb 100644 --- a/include/nuttx/spi/spi.h +++ b/include/nuttx/spi/spi.h @@ -51,11 +51,9 @@ * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ -/* CONFIG_SPI_OWNBUS - Set if there is only one active device on the SPI bus. - * No locking or SPI configuration will be performed. It is not necessary - * for clients to lock, re-configure, etc.. - * CONFIG_SPI_EXCHANGE - Driver supports a single exchange method +/* CONFIG_SPI_EXCHANGE - Driver supports a single exchange method * (vs a recvblock() and sndblock ()methods). + * CONFIG_SPI_HWFEATURES - Support special, hardware-specific SPI features. * CONFIG_SPI_CMDDATA - Devices on the SPI bus require out-of-band support * to distinguish command transfers from data transfers. Such devices * will often support either 9-bit SPI (yech) or 8-bit SPI and a GPIO @@ -85,11 +83,7 @@ * ****************************************************************************/ -#ifndef CONFIG_SPI_OWNBUS -# define SPI_LOCK(d,l) (d)->ops->lock(d,l) -#else -# define SPI_LOCK(d,l) 0 -#endif +#define SPI_LOCK(d,l) (d)->ops->lock(d,l) /**************************************************************************** * Name: SPI_SELECT @@ -428,9 +422,7 @@ typedef uint8_t spi_hwfeatures_t; struct spi_dev_s; struct spi_ops_s { -#ifndef CONFIG_SPI_OWNBUS CODE int (*lock)(FAR struct spi_dev_s *dev, bool lock); -#endif CODE void (*select)(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected); CODE uint32_t (*setfrequency)(FAR struct spi_dev_s *dev, uint32_t frequency); diff --git a/include/nuttx/spi/spi_bitbang.h b/include/nuttx/spi/spi_bitbang.h index b54a3b3d1a8..fee6a9f1fca 100644 --- a/include/nuttx/spi/spi_bitbang.h +++ b/include/nuttx/spi/spi_bitbang.h @@ -127,9 +127,7 @@ struct spi_bitbang_s FAR const struct spi_bitbang_ops_s *low; /* Low-level operations */ uint32_t holdtime; /* SCK hold time to achieve requested frequency */ bitexchange_t exchange; /* The select bit exchange function */ -#ifndef CONFIG_SPI_OWNBUS sem_t exclsem; /* Supports mutually exclusive access to SPI */ -#endif #ifdef CONFIG_SPI_BITBANG_VARWIDTH uint8_t nbits; /* Number of bits in the transfer */ #endif