diff options
Diffstat (limited to 'drivers/spi/spi-efm32.c')
-rw-r--r-- | drivers/spi/spi-efm32.c | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/drivers/spi/spi-efm32.c b/drivers/spi/spi-efm32.c index d4d3cc534792..be44a3eeb5e8 100644 --- a/drivers/spi/spi-efm32.c +++ b/drivers/spi/spi-efm32.c | |||
@@ -198,7 +198,7 @@ static int efm32_spi_txrx_bufs(struct spi_device *spi, struct spi_transfer *t) | |||
198 | 198 | ||
199 | efm32_spi_filltx(ddata); | 199 | efm32_spi_filltx(ddata); |
200 | 200 | ||
201 | init_completion(&ddata->done); | 201 | reinit_completion(&ddata->done); |
202 | 202 | ||
203 | efm32_spi_write32(ddata, REG_IF_TXBL | REG_IF_RXDATAV, REG_IEN); | 203 | efm32_spi_write32(ddata, REG_IF_TXBL | REG_IF_RXDATAV, REG_IEN); |
204 | 204 | ||
@@ -287,17 +287,17 @@ static u32 efm32_spi_get_configured_location(struct efm32_spi_ddata *ddata) | |||
287 | return (reg & REG_ROUTE_LOCATION__MASK) >> __ffs(REG_ROUTE_LOCATION__MASK); | 287 | return (reg & REG_ROUTE_LOCATION__MASK) >> __ffs(REG_ROUTE_LOCATION__MASK); |
288 | } | 288 | } |
289 | 289 | ||
290 | static int efm32_spi_probe_dt(struct platform_device *pdev, | 290 | static void efm32_spi_probe_dt(struct platform_device *pdev, |
291 | struct spi_master *master, struct efm32_spi_ddata *ddata) | 291 | struct spi_master *master, struct efm32_spi_ddata *ddata) |
292 | { | 292 | { |
293 | struct device_node *np = pdev->dev.of_node; | 293 | struct device_node *np = pdev->dev.of_node; |
294 | u32 location; | 294 | u32 location; |
295 | int ret; | 295 | int ret; |
296 | 296 | ||
297 | if (!np) | 297 | ret = of_property_read_u32(np, "efm32,location", &location); |
298 | return 1; | 298 | if (ret) |
299 | 299 | /* fall back to old and (wrongly) generic property "location" */ | |
300 | ret = of_property_read_u32(np, "location", &location); | 300 | ret = of_property_read_u32(np, "location", &location); |
301 | if (!ret) { | 301 | if (!ret) { |
302 | dev_dbg(&pdev->dev, "using location %u\n", location); | 302 | dev_dbg(&pdev->dev, "using location %u\n", location); |
303 | } else { | 303 | } else { |
@@ -308,11 +308,6 @@ static int efm32_spi_probe_dt(struct platform_device *pdev, | |||
308 | } | 308 | } |
309 | 309 | ||
310 | ddata->pdata.location = location; | 310 | ddata->pdata.location = location; |
311 | |||
312 | /* spi core takes care about the bus number using an alias */ | ||
313 | master->bus_num = -1; | ||
314 | |||
315 | return 0; | ||
316 | } | 311 | } |
317 | 312 | ||
318 | static int efm32_spi_probe(struct platform_device *pdev) | 313 | static int efm32_spi_probe(struct platform_device *pdev) |
@@ -322,9 +317,14 @@ static int efm32_spi_probe(struct platform_device *pdev) | |||
322 | int ret; | 317 | int ret; |
323 | struct spi_master *master; | 318 | struct spi_master *master; |
324 | struct device_node *np = pdev->dev.of_node; | 319 | struct device_node *np = pdev->dev.of_node; |
325 | unsigned int num_cs, i; | 320 | int num_cs, i; |
321 | |||
322 | if (!np) | ||
323 | return -EINVAL; | ||
326 | 324 | ||
327 | num_cs = of_gpio_named_count(np, "cs-gpios"); | 325 | num_cs = of_gpio_named_count(np, "cs-gpios"); |
326 | if (num_cs < 0) | ||
327 | return num_cs; | ||
328 | 328 | ||
329 | master = spi_alloc_master(&pdev->dev, | 329 | master = spi_alloc_master(&pdev->dev, |
330 | sizeof(*ddata) + num_cs * sizeof(unsigned)); | 330 | sizeof(*ddata) + num_cs * sizeof(unsigned)); |
@@ -349,6 +349,7 @@ static int efm32_spi_probe(struct platform_device *pdev) | |||
349 | ddata->bitbang.txrx_bufs = efm32_spi_txrx_bufs; | 349 | ddata->bitbang.txrx_bufs = efm32_spi_txrx_bufs; |
350 | 350 | ||
351 | spin_lock_init(&ddata->lock); | 351 | spin_lock_init(&ddata->lock); |
352 | init_completion(&ddata->done); | ||
352 | 353 | ||
353 | ddata->clk = devm_clk_get(&pdev->dev, NULL); | 354 | ddata->clk = devm_clk_get(&pdev->dev, NULL); |
354 | if (IS_ERR(ddata->clk)) { | 355 | if (IS_ERR(ddata->clk)) { |
@@ -415,23 +416,7 @@ static int efm32_spi_probe(struct platform_device *pdev) | |||
415 | goto err; | 416 | goto err; |
416 | } | 417 | } |
417 | 418 | ||
418 | ret = efm32_spi_probe_dt(pdev, master, ddata); | 419 | efm32_spi_probe_dt(pdev, master, ddata); |
419 | if (ret > 0) { | ||
420 | /* not created by device tree */ | ||
421 | const struct efm32_spi_pdata *pdata = | ||
422 | dev_get_platdata(&pdev->dev); | ||
423 | |||
424 | if (pdata) | ||
425 | ddata->pdata = *pdata; | ||
426 | else | ||
427 | ddata->pdata.location = | ||
428 | efm32_spi_get_configured_location(ddata); | ||
429 | |||
430 | master->bus_num = pdev->id; | ||
431 | |||
432 | } else if (ret < 0) { | ||
433 | goto err_disable_clk; | ||
434 | } | ||
435 | 420 | ||
436 | efm32_spi_write32(ddata, 0, REG_IEN); | 421 | efm32_spi_write32(ddata, 0, REG_IEN); |
437 | efm32_spi_write32(ddata, REG_ROUTE_TXPEN | REG_ROUTE_RXPEN | | 422 | efm32_spi_write32(ddata, REG_ROUTE_TXPEN | REG_ROUTE_RXPEN | |
@@ -487,6 +472,9 @@ static int efm32_spi_remove(struct platform_device *pdev) | |||
487 | 472 | ||
488 | static const struct of_device_id efm32_spi_dt_ids[] = { | 473 | static const struct of_device_id efm32_spi_dt_ids[] = { |
489 | { | 474 | { |
475 | .compatible = "energymicro,efm32-spi", | ||
476 | }, { | ||
477 | /* doesn't follow the "vendor,device" scheme, don't use */ | ||
490 | .compatible = "efm32,spi", | 478 | .compatible = "efm32,spi", |
491 | }, { | 479 | }, { |
492 | /* sentinel */ | 480 | /* sentinel */ |