diff options
Diffstat (limited to 'drivers/serial/mpc52xx_uart.c')
-rw-r--r-- | drivers/serial/mpc52xx_uart.c | 84 |
1 files changed, 8 insertions, 76 deletions
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 02469c31bf0b..84a35f699016 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -397,34 +397,10 @@ static unsigned long mpc512x_getuartclk(void *p) | |||
397 | return mpc5xxx_get_bus_frequency(p); | 397 | return mpc5xxx_get_bus_frequency(p); |
398 | } | 398 | } |
399 | 399 | ||
400 | #define DEFAULT_FIFO_SIZE 16 | ||
401 | |||
402 | static unsigned int __init get_fifo_size(struct device_node *np, | ||
403 | char *fifo_name) | ||
404 | { | ||
405 | const unsigned int *fp; | ||
406 | |||
407 | fp = of_get_property(np, fifo_name, NULL); | ||
408 | if (fp) | ||
409 | return *fp; | ||
410 | |||
411 | pr_warning("no %s property in %s node, defaulting to %d\n", | ||
412 | fifo_name, np->full_name, DEFAULT_FIFO_SIZE); | ||
413 | |||
414 | return DEFAULT_FIFO_SIZE; | ||
415 | } | ||
416 | |||
417 | #define FIFOC(_base) ((struct mpc512x_psc_fifo __iomem *) \ | ||
418 | ((u32)(_base) + sizeof(struct mpc52xx_psc))) | ||
419 | |||
420 | /* Init PSC FIFO Controller */ | 400 | /* Init PSC FIFO Controller */ |
421 | static int __init mpc512x_psc_fifoc_init(void) | 401 | static int __init mpc512x_psc_fifoc_init(void) |
422 | { | 402 | { |
423 | struct device_node *np; | 403 | struct device_node *np; |
424 | void __iomem *psc; | ||
425 | unsigned int tx_fifo_size; | ||
426 | unsigned int rx_fifo_size; | ||
427 | int fifobase = 0; /* current fifo address in 32 bit words */ | ||
428 | 404 | ||
429 | np = of_find_compatible_node(NULL, NULL, | 405 | np = of_find_compatible_node(NULL, NULL, |
430 | "fsl,mpc5121-psc-fifo"); | 406 | "fsl,mpc5121-psc-fifo"); |
@@ -447,51 +423,6 @@ static int __init mpc512x_psc_fifoc_init(void) | |||
447 | return -ENODEV; | 423 | return -ENODEV; |
448 | } | 424 | } |
449 | 425 | ||
450 | for_each_compatible_node(np, NULL, "fsl,mpc5121-psc-uart") { | ||
451 | tx_fifo_size = get_fifo_size(np, "fsl,tx-fifo-size"); | ||
452 | rx_fifo_size = get_fifo_size(np, "fsl,rx-fifo-size"); | ||
453 | |||
454 | /* size in register is in 4 byte units */ | ||
455 | tx_fifo_size /= 4; | ||
456 | rx_fifo_size /= 4; | ||
457 | if (!tx_fifo_size) | ||
458 | tx_fifo_size = 1; | ||
459 | if (!rx_fifo_size) | ||
460 | rx_fifo_size = 1; | ||
461 | |||
462 | psc = of_iomap(np, 0); | ||
463 | if (!psc) { | ||
464 | pr_err("%s: Can't map %s device\n", | ||
465 | __func__, np->full_name); | ||
466 | continue; | ||
467 | } | ||
468 | |||
469 | /* FIFO space is 4KiB, check if requested size is available */ | ||
470 | if ((fifobase + tx_fifo_size + rx_fifo_size) > 0x1000) { | ||
471 | pr_err("%s: no fifo space available for %s\n", | ||
472 | __func__, np->full_name); | ||
473 | iounmap(psc); | ||
474 | /* | ||
475 | * chances are that another device requests less | ||
476 | * fifo space, so we continue. | ||
477 | */ | ||
478 | continue; | ||
479 | } | ||
480 | /* set tx and rx fifo size registers */ | ||
481 | out_be32(&FIFOC(psc)->txsz, (fifobase << 16) | tx_fifo_size); | ||
482 | fifobase += tx_fifo_size; | ||
483 | out_be32(&FIFOC(psc)->rxsz, (fifobase << 16) | rx_fifo_size); | ||
484 | fifobase += rx_fifo_size; | ||
485 | |||
486 | /* reset and enable the slices */ | ||
487 | out_be32(&FIFOC(psc)->txcmd, 0x80); | ||
488 | out_be32(&FIFOC(psc)->txcmd, 0x01); | ||
489 | out_be32(&FIFOC(psc)->rxcmd, 0x80); | ||
490 | out_be32(&FIFOC(psc)->rxcmd, 0x01); | ||
491 | |||
492 | iounmap(psc); | ||
493 | } | ||
494 | |||
495 | return 0; | 426 | return 0; |
496 | } | 427 | } |
497 | 428 | ||
@@ -1295,14 +1226,14 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
1295 | 1226 | ||
1296 | /* Check validity & presence */ | 1227 | /* Check validity & presence */ |
1297 | for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++) | 1228 | for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++) |
1298 | if (mpc52xx_uart_nodes[idx] == op->node) | 1229 | if (mpc52xx_uart_nodes[idx] == op->dev.of_node) |
1299 | break; | 1230 | break; |
1300 | if (idx >= MPC52xx_PSC_MAXNUM) | 1231 | if (idx >= MPC52xx_PSC_MAXNUM) |
1301 | return -EINVAL; | 1232 | return -EINVAL; |
1302 | pr_debug("Found %s assigned to ttyPSC%x\n", | 1233 | pr_debug("Found %s assigned to ttyPSC%x\n", |
1303 | mpc52xx_uart_nodes[idx]->full_name, idx); | 1234 | mpc52xx_uart_nodes[idx]->full_name, idx); |
1304 | 1235 | ||
1305 | uartclk = psc_ops->getuartclk(op->node); | 1236 | uartclk = psc_ops->getuartclk(op->dev.of_node); |
1306 | if (uartclk == 0) { | 1237 | if (uartclk == 0) { |
1307 | dev_dbg(&op->dev, "Could not find uart clock frequency!\n"); | 1238 | dev_dbg(&op->dev, "Could not find uart clock frequency!\n"); |
1308 | return -EINVAL; | 1239 | return -EINVAL; |
@@ -1322,7 +1253,7 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
1322 | port->dev = &op->dev; | 1253 | port->dev = &op->dev; |
1323 | 1254 | ||
1324 | /* Search for IRQ and mapbase */ | 1255 | /* Search for IRQ and mapbase */ |
1325 | ret = of_address_to_resource(op->node, 0, &res); | 1256 | ret = of_address_to_resource(op->dev.of_node, 0, &res); |
1326 | if (ret) | 1257 | if (ret) |
1327 | return ret; | 1258 | return ret; |
1328 | 1259 | ||
@@ -1332,7 +1263,7 @@ mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | |||
1332 | return -EINVAL; | 1263 | return -EINVAL; |
1333 | } | 1264 | } |
1334 | 1265 | ||
1335 | psc_ops->get_irq(port, op->node); | 1266 | psc_ops->get_irq(port, op->dev.of_node); |
1336 | if (port->irq == NO_IRQ) { | 1267 | if (port->irq == NO_IRQ) { |
1337 | dev_dbg(&op->dev, "Could not get irq\n"); | 1268 | dev_dbg(&op->dev, "Could not get irq\n"); |
1338 | return -EINVAL; | 1269 | return -EINVAL; |
@@ -1431,15 +1362,16 @@ mpc52xx_uart_of_enumerate(void) | |||
1431 | MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match); | 1362 | MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match); |
1432 | 1363 | ||
1433 | static struct of_platform_driver mpc52xx_uart_of_driver = { | 1364 | static struct of_platform_driver mpc52xx_uart_of_driver = { |
1434 | .match_table = mpc52xx_uart_of_match, | ||
1435 | .probe = mpc52xx_uart_of_probe, | 1365 | .probe = mpc52xx_uart_of_probe, |
1436 | .remove = mpc52xx_uart_of_remove, | 1366 | .remove = mpc52xx_uart_of_remove, |
1437 | #ifdef CONFIG_PM | 1367 | #ifdef CONFIG_PM |
1438 | .suspend = mpc52xx_uart_of_suspend, | 1368 | .suspend = mpc52xx_uart_of_suspend, |
1439 | .resume = mpc52xx_uart_of_resume, | 1369 | .resume = mpc52xx_uart_of_resume, |
1440 | #endif | 1370 | #endif |
1441 | .driver = { | 1371 | .driver = { |
1442 | .name = "mpc52xx-psc-uart", | 1372 | .name = "mpc52xx-psc-uart", |
1373 | .owner = THIS_MODULE, | ||
1374 | .of_match_table = mpc52xx_uart_of_match, | ||
1443 | }, | 1375 | }, |
1444 | }; | 1376 | }; |
1445 | 1377 | ||