File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,30 @@ config SPI_FLASH_W25QXXDV_SPI_SLAVE
79
79
This option sets the SPI slave number the SPI controller has to switch
80
80
to when dealing with WinBond SPI flash chip.
81
81
82
+ config SPI_FLASH_W25QXXDV_GPIO_SPI_CS
83
+ bool "Manage SPI CS through a GPIO pin"
84
+ default n
85
+ depends on SPI_FLASH_W25QXXDV
86
+ help
87
+ This option is useful if one needs to manage SPI CS through a GPIO
88
+ pin to by-pass the SPI controller's CS logic.
89
+
90
+ config SPI_FLASH_W25QXXDV_GPIO_SPI_CS_DRV_NAME
91
+ string "GPIO driver's name to use to drive SPI CS through"
92
+ default ""
93
+ depends on SPI_FLASH_W25QXXDV_GPIO_SPI_CS
94
+ help
95
+ This option is mandatory to set which GPIO controller to use in order
96
+ to actually emulate the SPI CS.
97
+
98
+ config SPI_FLASH_W25QXXDV_GPIO_SPI_CS_PIN
99
+ int "GPIO PIN to use to drive SPI CS through"
100
+ default 0
101
+ depends on SPI_FLASH_W25QXXDV_GPIO_SPI_CS
102
+ help
103
+ This option is mandatory to set which GPIO pin to use in order
104
+ to actually emulate the SPI CS.
105
+
82
106
config SPI_FLASH_W25QXXDV_FLASH_SIZE
83
107
int "Flash size in bytes"
84
108
depends on SPI_FLASH_W25QXXDV
Original file line number Diff line number Diff line change @@ -325,6 +325,19 @@ static int spi_flash_wb_configure(struct device *dev)
325
325
data -> spi_cfg .operation = SPI_WORD_SET (8 );
326
326
data -> spi_cfg .slave = CONFIG_SPI_FLASH_W25QXXDV_SPI_SLAVE ;
327
327
328
+ #if defined(CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS )
329
+ data -> cs_ctrl .gpio_dev = device_get_binding (
330
+ CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_DRV_NAME );
331
+ if (!data -> cs_ctrl .gpio_dev ) {
332
+ return - ENODEV ;
333
+ }
334
+
335
+ data -> cs_ctrl .gpio_pin = CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS_PIN ;
336
+ data -> cs_ctrl .delay = 0 ;
337
+
338
+ data -> spi_cfg .cs = & data -> cs_ctrl ;
339
+ #endif /* CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS */
340
+
328
341
return spi_flash_wb_id (dev );
329
342
}
330
343
@@ -336,7 +349,7 @@ static int spi_flash_init(struct device *dev)
336
349
k_sem_init (& data -> sem , 1 , UINT_MAX );
337
350
338
351
ret = spi_flash_wb_configure (dev );
339
- if (ret ) {
352
+ if (! ret ) {
340
353
dev -> driver_api = & spi_flash_api ;
341
354
}
342
355
Original file line number Diff line number Diff line change 16
16
17
17
struct spi_flash_data {
18
18
struct device * spi ;
19
+ #if defined(CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS )
20
+ struct spi_cs_control cs_ctrl ;
21
+ #endif /* CONFIG_SPI_FLASH_W25QXXDV_GPIO_SPI_CS */
19
22
struct spi_config spi_cfg ;
20
23
struct k_sem sem ;
21
24
};
You can’t perform that action at this time.
0 commit comments