~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/tty/serial/ucc_uart.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1194
1194
        release_firmware(fw);
1195
1195
}
1196
1196
 
1197
 
static int ucc_uart_probe(struct platform_device *ofdev,
1198
 
        const struct of_device_id *match)
 
1197
static int ucc_uart_probe(struct platform_device *ofdev)
1199
1198
{
1200
1199
        struct device_node *np = ofdev->dev.of_node;
1201
1200
        const unsigned int *iprop;      /* Integer OF properties */
1270
1269
        ret = of_address_to_resource(np, 0, &res);
1271
1270
        if (ret) {
1272
1271
                dev_err(&ofdev->dev, "missing 'reg' property in device tree\n");
1273
 
                kfree(qe_port);
1274
 
                return ret;
 
1272
                goto out_free;
1275
1273
        }
1276
1274
        if (!res.start) {
1277
1275
                dev_err(&ofdev->dev, "invalid 'reg' property in device tree\n");
1278
 
                kfree(qe_port);
1279
 
                return -EINVAL;
 
1276
                ret = -EINVAL;
 
1277
                goto out_free;
1280
1278
        }
1281
1279
        qe_port->port.mapbase = res.start;
1282
1280
 
1286
1284
        if (!iprop) {
1287
1285
                iprop = of_get_property(np, "device-id", NULL);
1288
1286
                if (!iprop) {
1289
 
                        kfree(qe_port);
1290
1287
                        dev_err(&ofdev->dev, "UCC is unspecified in "
1291
1288
                                "device tree\n");
1292
 
                        return -EINVAL;
 
1289
                        ret = -EINVAL;
 
1290
                        goto out_free;
1293
1291
                }
1294
1292
        }
1295
1293
 
1296
1294
        if ((*iprop < 1) || (*iprop > UCC_MAX_NUM)) {
1297
1295
                dev_err(&ofdev->dev, "no support for UCC%u\n", *iprop);
1298
 
                kfree(qe_port);
1299
 
                return -ENODEV;
 
1296
                ret = -ENODEV;
 
1297
                goto out_free;
1300
1298
        }
1301
1299
        qe_port->ucc_num = *iprop - 1;
1302
1300
 
1310
1308
        sprop = of_get_property(np, "rx-clock-name", NULL);
1311
1309
        if (!sprop) {
1312
1310
                dev_err(&ofdev->dev, "missing rx-clock-name in device tree\n");
1313
 
                kfree(qe_port);
1314
 
                return -ENODEV;
 
1311
                ret = -ENODEV;
 
1312
                goto out_free;
1315
1313
        }
1316
1314
 
1317
1315
        qe_port->us_info.rx_clock = qe_clock_source(sprop);
1318
1316
        if ((qe_port->us_info.rx_clock < QE_BRG1) ||
1319
1317
            (qe_port->us_info.rx_clock > QE_BRG16)) {
1320
1318
                dev_err(&ofdev->dev, "rx-clock-name must be a BRG for UART\n");
1321
 
                kfree(qe_port);
1322
 
                return -ENODEV;
 
1319
                ret = -ENODEV;
 
1320
                goto out_free;
1323
1321
        }
1324
1322
 
1325
1323
#ifdef LOOPBACK
1329
1327
        sprop = of_get_property(np, "tx-clock-name", NULL);
1330
1328
        if (!sprop) {
1331
1329
                dev_err(&ofdev->dev, "missing tx-clock-name in device tree\n");
1332
 
                kfree(qe_port);
1333
 
                return -ENODEV;
 
1330
                ret = -ENODEV;
 
1331
                goto out_free;
1334
1332
        }
1335
1333
        qe_port->us_info.tx_clock = qe_clock_source(sprop);
1336
1334
#endif
1337
1335
        if ((qe_port->us_info.tx_clock < QE_BRG1) ||
1338
1336
            (qe_port->us_info.tx_clock > QE_BRG16)) {
1339
1337
                dev_err(&ofdev->dev, "tx-clock-name must be a BRG for UART\n");
1340
 
                kfree(qe_port);
1341
 
                return -ENODEV;
 
1338
                ret = -ENODEV;
 
1339
                goto out_free;
1342
1340
        }
1343
1341
 
1344
1342
        /* Get the port number, numbered 0-3 */
1345
1343
        iprop = of_get_property(np, "port-number", NULL);
1346
1344
        if (!iprop) {
1347
1345
                dev_err(&ofdev->dev, "missing port-number in device tree\n");
1348
 
                kfree(qe_port);
1349
 
                return -EINVAL;
 
1346
                ret = -EINVAL;
 
1347
                goto out_free;
1350
1348
        }
1351
1349
        qe_port->port.line = *iprop;
1352
1350
        if (qe_port->port.line >= UCC_MAX_UART) {
1353
1351
                dev_err(&ofdev->dev, "port-number must be 0-%u\n",
1354
1352
                        UCC_MAX_UART - 1);
1355
 
                kfree(qe_port);
1356
 
                return -EINVAL;
 
1353
                ret = -EINVAL;
 
1354
                goto out_free;
1357
1355
        }
1358
1356
 
1359
1357
        qe_port->port.irq = irq_of_parse_and_map(np, 0);
1360
1358
        if (qe_port->port.irq == NO_IRQ) {
1361
1359
                dev_err(&ofdev->dev, "could not map IRQ for UCC%u\n",
1362
1360
                       qe_port->ucc_num + 1);
1363
 
                kfree(qe_port);
1364
 
                return -EINVAL;
 
1361
                ret = -EINVAL;
 
1362
                goto out_free;
1365
1363
        }
1366
1364
 
1367
1365
        /*
1373
1371
                np = of_find_node_by_type(NULL, "qe");
1374
1372
                if (!np) {
1375
1373
                        dev_err(&ofdev->dev, "could not find 'qe' node\n");
1376
 
                        kfree(qe_port);
1377
 
                        return -EINVAL;
 
1374
                        ret = -EINVAL;
 
1375
                        goto out_free;
1378
1376
                }
1379
1377
        }
1380
1378
 
1382
1380
        if (!iprop) {
1383
1381
                dev_err(&ofdev->dev,
1384
1382
                       "missing brg-frequency in device tree\n");
1385
 
                kfree(qe_port);
1386
 
                return -EINVAL;
 
1383
                ret = -EINVAL;
 
1384
                goto out_np;
1387
1385
        }
1388
1386
 
1389
1387
        if (*iprop)
1398
1396
                if (!iprop) {
1399
1397
                        dev_err(&ofdev->dev,
1400
1398
                                "missing QE bus-frequency in device tree\n");
1401
 
                        kfree(qe_port);
1402
 
                        return -EINVAL;
 
1399
                        ret = -EINVAL;
 
1400
                        goto out_np;
1403
1401
                }
1404
1402
                if (*iprop)
1405
1403
                        qe_port->port.uartclk = *iprop / 2;
1406
1404
                else {
1407
1405
                        dev_err(&ofdev->dev,
1408
1406
                                "invalid QE bus-frequency in device tree\n");
1409
 
                        kfree(qe_port);
1410
 
                        return -EINVAL;
 
1407
                        ret = -EINVAL;
 
1408
                        goto out_np;
1411
1409
                }
1412
1410
        }
1413
1411
 
1445
1443
        if (ret) {
1446
1444
                dev_err(&ofdev->dev, "could not add /dev/ttyQE%u\n",
1447
1445
                       qe_port->port.line);
1448
 
                kfree(qe_port);
1449
 
                return ret;
 
1446
                goto out_np;
1450
1447
        }
1451
1448
 
1452
1449
        dev_set_drvdata(&ofdev->dev, qe_port);
1460
1457
               SERIAL_QE_MINOR + qe_port->port.line);
1461
1458
 
1462
1459
        return 0;
 
1460
out_np:
 
1461
        of_node_put(np);
 
1462
out_free:
 
1463
        kfree(qe_port);
 
1464
        return ret;
1463
1465
}
1464
1466
 
1465
1467
static int ucc_uart_remove(struct platform_device *ofdev)
1485
1487
};
1486
1488
MODULE_DEVICE_TABLE(of, ucc_uart_match);
1487
1489
 
1488
 
static struct of_platform_driver ucc_uart_of_driver = {
 
1490
static struct platform_driver ucc_uart_of_driver = {
1489
1491
        .driver = {
1490
1492
                .name = "ucc_uart",
1491
1493
                .owner = THIS_MODULE,
1510
1512
                return ret;
1511
1513
        }
1512
1514
 
1513
 
        ret = of_register_platform_driver(&ucc_uart_of_driver);
 
1515
        ret = platform_driver_register(&ucc_uart_of_driver);
1514
1516
        if (ret)
1515
1517
                printk(KERN_ERR
1516
1518
                       "ucc-uart: could not register platform driver\n");
1523
1525
        printk(KERN_INFO
1524
1526
               "Freescale QUICC Engine UART device driver unloading\n");
1525
1527
 
1526
 
        of_unregister_platform_driver(&ucc_uart_of_driver);
 
1528
        platform_driver_unregister(&ucc_uart_of_driver);
1527
1529
        uart_unregister_driver(&ucc_uart_driver);
1528
1530
}
1529
1531