.. | .. |
---|
244 | 244 | if (output) |
---|
245 | 245 | return gpiod_direction_output(spi_gpio->mosi, 1); |
---|
246 | 246 | |
---|
247 | | - ret = gpiod_direction_input(spi_gpio->mosi); |
---|
248 | | - if (ret) |
---|
249 | | - return ret; |
---|
| 247 | + /* |
---|
| 248 | + * Only change MOSI to an input if using 3WIRE mode. |
---|
| 249 | + * Otherwise, MOSI could be left floating if there is |
---|
| 250 | + * no pull resistor connected to the I/O pin, or could |
---|
| 251 | + * be left logic high if there is a pull-up. Transmitting |
---|
| 252 | + * logic high when only clocking MISO data in can put some |
---|
| 253 | + * SPI devices in to a bad state. |
---|
| 254 | + */ |
---|
| 255 | + if (spi->mode & SPI_3WIRE) { |
---|
| 256 | + ret = gpiod_direction_input(spi_gpio->mosi); |
---|
| 257 | + if (ret) |
---|
| 258 | + return ret; |
---|
| 259 | + } |
---|
250 | 260 | /* |
---|
251 | 261 | * Send a turnaround high impedance cycle when switching |
---|
252 | 262 | * from output to input. Theoretically there should be |
---|