6
6
#include <linux/io.h>
7
7
#include <linux/spi/spi.h>
8
8
#include <linux/spi/spi_bitbang.h>
9
- #include <linux/gpio.h>
10
9
#include <linux/interrupt.h>
11
10
#include <linux/platform_device.h>
12
11
#include <linux/clk.h>
13
12
#include <linux/err.h>
14
13
#include <linux/module.h>
15
- #include <linux/of_gpio.h>
16
14
#include <linux/platform_data/efm32-spi.h>
15
+ #include <linux/of.h>
17
16
18
17
#define DRIVER_NAME "efm32-spi"
19
18
@@ -82,9 +81,6 @@ struct efm32_spi_ddata {
82
81
const u8 * tx_buf ;
83
82
u8 * rx_buf ;
84
83
unsigned tx_len , rx_len ;
85
-
86
- /* chip selects */
87
- unsigned csgpio [];
88
84
};
89
85
90
86
#define ddata_to_dev (ddata ) (&(ddata->bitbang.master->dev))
@@ -102,14 +98,6 @@ static u32 efm32_spi_read32(struct efm32_spi_ddata *ddata, unsigned offset)
102
98
return readl_relaxed (ddata -> base + offset );
103
99
}
104
100
105
- static void efm32_spi_chipselect (struct spi_device * spi , int is_on )
106
- {
107
- struct efm32_spi_ddata * ddata = spi_master_get_devdata (spi -> master );
108
- int value = !(spi -> mode & SPI_CS_HIGH ) == !(is_on == BITBANG_CS_ACTIVE );
109
-
110
- gpio_set_value (ddata -> csgpio [spi -> chip_select ], value );
111
- }
112
-
113
101
static int efm32_spi_setup_transfer (struct spi_device * spi ,
114
102
struct spi_transfer * t )
115
103
{
@@ -320,17 +308,11 @@ static int efm32_spi_probe(struct platform_device *pdev)
320
308
int ret ;
321
309
struct spi_master * master ;
322
310
struct device_node * np = pdev -> dev .of_node ;
323
- int num_cs , i ;
324
311
325
312
if (!np )
326
313
return - EINVAL ;
327
314
328
- num_cs = of_gpio_named_count (np , "cs-gpios" );
329
- if (num_cs < 0 )
330
- return num_cs ;
331
-
332
- master = spi_alloc_master (& pdev -> dev ,
333
- sizeof (* ddata ) + num_cs * sizeof (unsigned ));
315
+ master = spi_alloc_master (& pdev -> dev , sizeof (* ddata ));
334
316
if (!master ) {
335
317
dev_dbg (& pdev -> dev ,
336
318
"failed to allocate spi master controller\n" );
@@ -340,14 +322,13 @@ static int efm32_spi_probe(struct platform_device *pdev)
340
322
341
323
master -> dev .of_node = pdev -> dev .of_node ;
342
324
343
- master -> num_chipselect = num_cs ;
344
325
master -> mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH ;
345
326
master -> bits_per_word_mask = SPI_BPW_RANGE_MASK (4 , 16 );
327
+ master -> use_gpio_descriptors = true;
346
328
347
329
ddata = spi_master_get_devdata (master );
348
330
349
331
ddata -> bitbang .master = master ;
350
- ddata -> bitbang .chipselect = efm32_spi_chipselect ;
351
332
ddata -> bitbang .setup_transfer = efm32_spi_setup_transfer ;
352
333
ddata -> bitbang .txrx_bufs = efm32_spi_txrx_bufs ;
353
334
@@ -361,25 +342,6 @@ static int efm32_spi_probe(struct platform_device *pdev)
361
342
goto err ;
362
343
}
363
344
364
- for (i = 0 ; i < num_cs ; ++ i ) {
365
- ret = of_get_named_gpio (np , "cs-gpios" , i );
366
- if (ret < 0 ) {
367
- dev_err (& pdev -> dev , "failed to get csgpio#%u (%d)\n" ,
368
- i , ret );
369
- goto err ;
370
- }
371
- ddata -> csgpio [i ] = ret ;
372
- dev_dbg (& pdev -> dev , "csgpio#%u = %u\n" , i , ddata -> csgpio [i ]);
373
- ret = devm_gpio_request_one (& pdev -> dev , ddata -> csgpio [i ],
374
- GPIOF_OUT_INIT_LOW , DRIVER_NAME );
375
- if (ret < 0 ) {
376
- dev_err (& pdev -> dev ,
377
- "failed to configure csgpio#%u (%d)\n" ,
378
- i , ret );
379
- goto err ;
380
- }
381
- }
382
-
383
345
res = platform_get_resource (pdev , IORESOURCE_MEM , 0 );
384
346
if (!res ) {
385
347
ret = - ENODEV ;
0 commit comments