Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: rcar-csi2: Move PHTW write helpers

Prepare for V4M support by moving the PHTW write helpers to the generic
write helpers. This is needed as adding V4M support will involve
interact with the PHTW register from code that are logically grouped
with similar code in such a way that forward declarations of these
helpers would otherwise be needed.

The functions are moved verbatim.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Niklas Söderlund and committed by
Mauro Carvalho Chehab
a8c916ed e5be5622

+36 -36
+36 -36
drivers/media/platform/renesas/rcar-csi2.c
··· 662 662 iowrite16(data, priv->base + reg); 663 663 } 664 664 665 + static int rcsi2_phtw_write(struct rcar_csi2 *priv, u8 data, u8 code) 666 + { 667 + unsigned int timeout; 668 + 669 + rcsi2_write(priv, priv->info->regs->phtw, 670 + PHTW_DWEN | PHTW_TESTDIN_DATA(data) | 671 + PHTW_CWEN | PHTW_TESTDIN_CODE(code)); 672 + 673 + /* Wait for DWEN and CWEN to be cleared by hardware. */ 674 + for (timeout = 0; timeout <= 20; timeout++) { 675 + if (!(rcsi2_read(priv, priv->info->regs->phtw) & (PHTW_DWEN | PHTW_CWEN))) 676 + return 0; 677 + 678 + usleep_range(1000, 2000); 679 + } 680 + 681 + dev_err(priv->dev, "Timeout waiting for PHTW_DWEN and/or PHTW_CWEN\n"); 682 + 683 + return -ETIMEDOUT; 684 + } 685 + 686 + static int rcsi2_phtw_write_array(struct rcar_csi2 *priv, 687 + const struct phtw_value *values, 688 + unsigned int size) 689 + { 690 + int ret; 691 + 692 + for (unsigned int i = 0; i < size; i++) { 693 + ret = rcsi2_phtw_write(priv, values[i].data, values[i].code); 694 + if (ret) 695 + return ret; 696 + } 697 + 698 + return 0; 699 + } 700 + 665 701 static const struct rcsi2_mbps_info * 666 702 rcsi2_mbps_to_info(struct rcar_csi2 *priv, 667 703 const struct rcsi2_mbps_info *infotable, unsigned int mbps) ··· 1504 1468 * 1505 1469 * NOTE: Magic values are from the datasheet and lack documentation. 1506 1470 */ 1507 - 1508 - static int rcsi2_phtw_write(struct rcar_csi2 *priv, u8 data, u8 code) 1509 - { 1510 - unsigned int timeout; 1511 - 1512 - rcsi2_write(priv, priv->info->regs->phtw, 1513 - PHTW_DWEN | PHTW_TESTDIN_DATA(data) | 1514 - PHTW_CWEN | PHTW_TESTDIN_CODE(code)); 1515 - 1516 - /* Wait for DWEN and CWEN to be cleared by hardware. */ 1517 - for (timeout = 0; timeout <= 20; timeout++) { 1518 - if (!(rcsi2_read(priv, priv->info->regs->phtw) & (PHTW_DWEN | PHTW_CWEN))) 1519 - return 0; 1520 - 1521 - usleep_range(1000, 2000); 1522 - } 1523 - 1524 - dev_err(priv->dev, "Timeout waiting for PHTW_DWEN and/or PHTW_CWEN\n"); 1525 - 1526 - return -ETIMEDOUT; 1527 - } 1528 - 1529 - static int rcsi2_phtw_write_array(struct rcar_csi2 *priv, 1530 - const struct phtw_value *values, 1531 - unsigned int size) 1532 - { 1533 - int ret; 1534 - 1535 - for (unsigned int i = 0; i < size; i++) { 1536 - ret = rcsi2_phtw_write(priv, values[i].data, values[i].code); 1537 - if (ret) 1538 - return ret; 1539 - } 1540 - 1541 - return 0; 1542 - } 1543 1471 1544 1472 static int rcsi2_phtw_write_mbps(struct rcar_csi2 *priv, unsigned int mbps, 1545 1473 const struct rcsi2_mbps_info *values, u8 code)