diff options
Diffstat (limited to 'drivers/spi/spi-tegra20-sflash.c')
-rw-r--r-- | drivers/spi/spi-tegra20-sflash.c | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c index 3d6a12b2af04..d65c000efe35 100644 --- a/drivers/spi/spi-tegra20-sflash.c +++ b/drivers/spi/spi-tegra20-sflash.c | |||
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/of.h> | 33 | #include <linux/of.h> |
34 | #include <linux/of_device.h> | 34 | #include <linux/of_device.h> |
35 | #include <linux/spi/spi.h> | 35 | #include <linux/spi/spi.h> |
36 | #include <linux/spi/spi-tegra.h> | ||
37 | #include <linux/clk/tegra.h> | 36 | #include <linux/clk/tegra.h> |
38 | 37 | ||
39 | #define SPI_COMMAND 0x000 | 38 | #define SPI_COMMAND 0x000 |
@@ -439,23 +438,13 @@ static irqreturn_t tegra_sflash_isr(int irq, void *context_data) | |||
439 | return handle_cpu_based_xfer(tsd); | 438 | return handle_cpu_based_xfer(tsd); |
440 | } | 439 | } |
441 | 440 | ||
442 | static struct tegra_spi_platform_data *tegra_sflash_parse_dt( | 441 | static void tegra_sflash_parse_dt(struct tegra_sflash_data *tsd) |
443 | struct platform_device *pdev) | ||
444 | { | 442 | { |
445 | struct tegra_spi_platform_data *pdata; | 443 | struct device_node *np = tsd->dev->of_node; |
446 | struct device_node *np = pdev->dev.of_node; | ||
447 | u32 max_freq; | ||
448 | |||
449 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
450 | if (!pdata) { | ||
451 | dev_err(&pdev->dev, "Memory alloc for pdata failed\n"); | ||
452 | return NULL; | ||
453 | } | ||
454 | |||
455 | if (!of_property_read_u32(np, "spi-max-frequency", &max_freq)) | ||
456 | pdata->spi_max_frequency = max_freq; | ||
457 | 444 | ||
458 | return pdata; | 445 | if (of_property_read_u32(np, "spi-max-frequency", |
446 | &tsd->spi_max_frequency)) | ||
447 | tsd->spi_max_frequency = 25000000; /* 25MHz */ | ||
459 | } | 448 | } |
460 | 449 | ||
461 | static struct of_device_id tegra_sflash_of_match[] = { | 450 | static struct of_device_id tegra_sflash_of_match[] = { |
@@ -469,28 +458,15 @@ static int tegra_sflash_probe(struct platform_device *pdev) | |||
469 | struct spi_master *master; | 458 | struct spi_master *master; |
470 | struct tegra_sflash_data *tsd; | 459 | struct tegra_sflash_data *tsd; |
471 | struct resource *r; | 460 | struct resource *r; |
472 | struct tegra_spi_platform_data *pdata = pdev->dev.platform_data; | ||
473 | int ret; | 461 | int ret; |
474 | const struct of_device_id *match; | 462 | const struct of_device_id *match; |
475 | 463 | ||
476 | match = of_match_device(of_match_ptr(tegra_sflash_of_match), | 464 | match = of_match_device(tegra_sflash_of_match, &pdev->dev); |
477 | &pdev->dev); | ||
478 | if (!match) { | 465 | if (!match) { |
479 | dev_err(&pdev->dev, "Error: No device match found\n"); | 466 | dev_err(&pdev->dev, "Error: No device match found\n"); |
480 | return -ENODEV; | 467 | return -ENODEV; |
481 | } | 468 | } |
482 | 469 | ||
483 | if (!pdata && pdev->dev.of_node) | ||
484 | pdata = tegra_sflash_parse_dt(pdev); | ||
485 | |||
486 | if (!pdata) { | ||
487 | dev_err(&pdev->dev, "No platform data, exiting\n"); | ||
488 | return -ENODEV; | ||
489 | } | ||
490 | |||
491 | if (!pdata->spi_max_frequency) | ||
492 | pdata->spi_max_frequency = 25000000; /* 25MHz */ | ||
493 | |||
494 | master = spi_alloc_master(&pdev->dev, sizeof(*tsd)); | 470 | master = spi_alloc_master(&pdev->dev, sizeof(*tsd)); |
495 | if (!master) { | 471 | if (!master) { |
496 | dev_err(&pdev->dev, "master allocation failed\n"); | 472 | dev_err(&pdev->dev, "master allocation failed\n"); |
@@ -510,6 +486,8 @@ static int tegra_sflash_probe(struct platform_device *pdev) | |||
510 | tsd->dev = &pdev->dev; | 486 | tsd->dev = &pdev->dev; |
511 | spin_lock_init(&tsd->lock); | 487 | spin_lock_init(&tsd->lock); |
512 | 488 | ||
489 | tegra_sflash_parse_dt(tsd); | ||
490 | |||
513 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 491 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
514 | if (!r) { | 492 | if (!r) { |
515 | dev_err(&pdev->dev, "No IO memory resource\n"); | 493 | dev_err(&pdev->dev, "No IO memory resource\n"); |
@@ -538,7 +516,6 @@ static int tegra_sflash_probe(struct platform_device *pdev) | |||
538 | goto exit_free_irq; | 516 | goto exit_free_irq; |
539 | } | 517 | } |
540 | 518 | ||
541 | tsd->spi_max_frequency = pdata->spi_max_frequency; | ||
542 | init_completion(&tsd->xfer_completion); | 519 | init_completion(&tsd->xfer_completion); |
543 | pm_runtime_enable(&pdev->dev); | 520 | pm_runtime_enable(&pdev->dev); |
544 | if (!pm_runtime_enabled(&pdev->dev)) { | 521 | if (!pm_runtime_enabled(&pdev->dev)) { |
@@ -658,7 +635,7 @@ static struct platform_driver tegra_sflash_driver = { | |||
658 | .name = "spi-tegra-sflash", | 635 | .name = "spi-tegra-sflash", |
659 | .owner = THIS_MODULE, | 636 | .owner = THIS_MODULE, |
660 | .pm = &slink_pm_ops, | 637 | .pm = &slink_pm_ops, |
661 | .of_match_table = of_match_ptr(tegra_sflash_of_match), | 638 | .of_match_table = tegra_sflash_of_match, |
662 | }, | 639 | }, |
663 | .probe = tegra_sflash_probe, | 640 | .probe = tegra_sflash_probe, |
664 | .remove = tegra_sflash_remove, | 641 | .remove = tegra_sflash_remove, |