diff options
Diffstat (limited to 'drivers/spi/mpc52xx_psc_spi.c')
-rw-r--r-- | drivers/spi/mpc52xx_psc_spi.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c index 1b74d5ca03f3..f50c81df336a 100644 --- a/drivers/spi/mpc52xx_psc_spi.c +++ b/drivers/spi/mpc52xx_psc_spi.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/of_platform.h> | 19 | #include <linux/of_platform.h> |
20 | #include <linux/of_spi.h> | ||
20 | #include <linux/workqueue.h> | 21 | #include <linux/workqueue.h> |
21 | #include <linux/completion.h> | 22 | #include <linux/completion.h> |
22 | #include <linux/io.h> | 23 | #include <linux/io.h> |
@@ -313,11 +314,13 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) | |||
313 | struct mpc52xx_psc __iomem *psc = mps->psc; | 314 | struct mpc52xx_psc __iomem *psc = mps->psc; |
314 | struct mpc52xx_psc_fifo __iomem *fifo = mps->fifo; | 315 | struct mpc52xx_psc_fifo __iomem *fifo = mps->fifo; |
315 | u32 mclken_div; | 316 | u32 mclken_div; |
316 | int ret = 0; | 317 | int ret; |
317 | 318 | ||
318 | /* default sysclk is 512MHz */ | 319 | /* default sysclk is 512MHz */ |
319 | mclken_div = (mps->sysclk ? mps->sysclk : 512000000) / MCLK; | 320 | mclken_div = (mps->sysclk ? mps->sysclk : 512000000) / MCLK; |
320 | mpc52xx_set_psc_clkdiv(psc_id, mclken_div); | 321 | ret = mpc52xx_set_psc_clkdiv(psc_id, mclken_div); |
322 | if (ret) | ||
323 | return ret; | ||
321 | 324 | ||
322 | /* Reset the PSC into a known state */ | 325 | /* Reset the PSC into a known state */ |
323 | out_8(&psc->command, MPC52xx_PSC_RST_RX); | 326 | out_8(&psc->command, MPC52xx_PSC_RST_RX); |
@@ -341,7 +344,7 @@ static int mpc52xx_psc_spi_port_config(int psc_id, struct mpc52xx_psc_spi *mps) | |||
341 | 344 | ||
342 | mps->bits_per_word = 8; | 345 | mps->bits_per_word = 8; |
343 | 346 | ||
344 | return ret; | 347 | return 0; |
345 | } | 348 | } |
346 | 349 | ||
347 | static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) | 350 | static irqreturn_t mpc52xx_psc_spi_isr(int irq, void *dev_id) |
@@ -410,8 +413,10 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr, | |||
410 | goto free_master; | 413 | goto free_master; |
411 | 414 | ||
412 | ret = mpc52xx_psc_spi_port_config(master->bus_num, mps); | 415 | ret = mpc52xx_psc_spi_port_config(master->bus_num, mps); |
413 | if (ret < 0) | 416 | if (ret < 0) { |
417 | dev_err(dev, "can't configure PSC! Is it capable of SPI?\n"); | ||
414 | goto free_irq; | 418 | goto free_irq; |
419 | } | ||
415 | 420 | ||
416 | spin_lock_init(&mps->lock); | 421 | spin_lock_init(&mps->lock); |
417 | init_completion(&mps->done); | 422 | init_completion(&mps->done); |
@@ -464,10 +469,11 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | |||
464 | const u32 *regaddr_p; | 469 | const u32 *regaddr_p; |
465 | u64 regaddr64, size64; | 470 | u64 regaddr64, size64; |
466 | s16 id = -1; | 471 | s16 id = -1; |
472 | int rc; | ||
467 | 473 | ||
468 | regaddr_p = of_get_address(op->node, 0, &size64, NULL); | 474 | regaddr_p = of_get_address(op->node, 0, &size64, NULL); |
469 | if (!regaddr_p) { | 475 | if (!regaddr_p) { |
470 | printk(KERN_ERR "Invalid PSC address\n"); | 476 | dev_err(&op->dev, "Invalid PSC address\n"); |
471 | return -EINVAL; | 477 | return -EINVAL; |
472 | } | 478 | } |
473 | regaddr64 = of_translate_address(op->node, regaddr_p); | 479 | regaddr64 = of_translate_address(op->node, regaddr_p); |
@@ -478,15 +484,18 @@ static int __init mpc52xx_psc_spi_of_probe(struct of_device *op, | |||
478 | 484 | ||
479 | psc_nump = of_get_property(op->node, "cell-index", NULL); | 485 | psc_nump = of_get_property(op->node, "cell-index", NULL); |
480 | if (!psc_nump || *psc_nump > 5) { | 486 | if (!psc_nump || *psc_nump > 5) { |
481 | printk(KERN_ERR "mpc52xx_psc_spi: Device node %s has invalid " | 487 | dev_err(&op->dev, "Invalid cell-index property\n"); |
482 | "cell-index property\n", op->node->full_name); | ||
483 | return -EINVAL; | 488 | return -EINVAL; |
484 | } | 489 | } |
485 | id = *psc_nump + 1; | 490 | id = *psc_nump + 1; |
486 | } | 491 | } |
487 | 492 | ||
488 | return mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, | 493 | rc = mpc52xx_psc_spi_do_probe(&op->dev, (u32)regaddr64, (u32)size64, |
489 | irq_of_parse_and_map(op->node, 0), id); | 494 | irq_of_parse_and_map(op->node, 0), id); |
495 | if (rc == 0) | ||
496 | of_register_spi_devices(dev_get_drvdata(&op->dev), op->node); | ||
497 | |||
498 | return rc; | ||
490 | } | 499 | } |
491 | 500 | ||
492 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) | 501 | static int __exit mpc52xx_psc_spi_of_remove(struct of_device *op) |