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: Abstract PHTW and PHYPLL register offsets

Most of the registers used on the R-Car V4M CSI-2 IP are shared with the
devices already supported by the rcar-csi2 driver. Two registers which
function and layout are the same are however found on different offsets.

Prepare for adding support for R-Car V4M by storing the offset to these
two registers offsets in the device information structured. This way the
code, which is shared between the devices, can be reused when V4M
support is added.

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
28a034da b230ddd8

+24 -3
+24 -3
drivers/media/platform/renesas/rcar-csi2.c
··· 584 584 NR_OF_RCAR_CSI2_PAD, 585 585 }; 586 586 587 + struct rcsi2_register_layout { 588 + unsigned int phtw; 589 + unsigned int phypll; 590 + }; 591 + 587 592 struct rcar_csi2_info { 593 + const struct rcsi2_register_layout *regs; 588 594 int (*init_phtw)(struct rcar_csi2 *priv, unsigned int mbps); 589 595 int (*phy_post_init)(struct rcar_csi2 *priv); 590 596 int (*start_receiver)(struct rcar_csi2 *priv, ··· 736 730 ((mbps - hsfreq_prev->mbps) <= (hsfreq->mbps - mbps))) 737 731 hsfreq = hsfreq_prev; 738 732 739 - rcsi2_write(priv, PHYPLL_REG, PHYPLL_HSFREQRANGE(hsfreq->reg)); 733 + rcsi2_write(priv, priv->info->regs->phypll, PHYPLL_HSFREQRANGE(hsfreq->reg)); 740 734 741 735 return 0; 742 736 } ··· 1461 1455 { 1462 1456 unsigned int timeout; 1463 1457 1464 - rcsi2_write(priv, PHTW_REG, 1458 + rcsi2_write(priv, priv->info->regs->phtw, 1465 1459 PHTW_DWEN | PHTW_TESTDIN_DATA(data) | 1466 1460 PHTW_CWEN | PHTW_TESTDIN_CODE(code)); 1467 1461 1468 1462 /* Wait for DWEN and CWEN to be cleared by hardware. */ 1469 1463 for (timeout = 0; timeout <= 20; timeout++) { 1470 - if (!(rcsi2_read(priv, PHTW_REG) & (PHTW_DWEN | PHTW_CWEN))) 1464 + if (!(rcsi2_read(priv, priv->info->regs->phtw) & (PHTW_DWEN | PHTW_CWEN))) 1471 1465 return 0; 1472 1466 1473 1467 usleep_range(1000, 2000); ··· 1713 1707 return PTR_ERR_OR_ZERO(priv->rstc); 1714 1708 } 1715 1709 1710 + static const struct rcsi2_register_layout rcsi2_registers_gen3 = { 1711 + .phtw = PHTW_REG, 1712 + .phypll = PHYPLL_REG, 1713 + }; 1714 + 1716 1715 static const struct rcar_csi2_info rcar_csi2_info_r8a7795 = { 1716 + .regs = &rcsi2_registers_gen3, 1717 1717 .init_phtw = rcsi2_init_phtw_h3_v3h_m3n, 1718 1718 .start_receiver = rcsi2_start_receiver_gen3, 1719 1719 .enter_standby = rcsi2_enter_standby_gen3, ··· 1731 1719 }; 1732 1720 1733 1721 static const struct rcar_csi2_info rcar_csi2_info_r8a7795es2 = { 1722 + .regs = &rcsi2_registers_gen3, 1734 1723 .init_phtw = rcsi2_init_phtw_h3es2, 1735 1724 .start_receiver = rcsi2_start_receiver_gen3, 1736 1725 .enter_standby = rcsi2_enter_standby_gen3, ··· 1743 1730 }; 1744 1731 1745 1732 static const struct rcar_csi2_info rcar_csi2_info_r8a7796 = { 1733 + .regs = &rcsi2_registers_gen3, 1746 1734 .start_receiver = rcsi2_start_receiver_gen3, 1747 1735 .enter_standby = rcsi2_enter_standby_gen3, 1748 1736 .hsfreqrange = hsfreqrange_m3w, ··· 1752 1738 }; 1753 1739 1754 1740 static const struct rcar_csi2_info rcar_csi2_info_r8a77961 = { 1741 + .regs = &rcsi2_registers_gen3, 1755 1742 .start_receiver = rcsi2_start_receiver_gen3, 1756 1743 .enter_standby = rcsi2_enter_standby_gen3, 1757 1744 .hsfreqrange = hsfreqrange_m3w, ··· 1761 1746 }; 1762 1747 1763 1748 static const struct rcar_csi2_info rcar_csi2_info_r8a77965 = { 1749 + .regs = &rcsi2_registers_gen3, 1764 1750 .init_phtw = rcsi2_init_phtw_h3_v3h_m3n, 1765 1751 .start_receiver = rcsi2_start_receiver_gen3, 1766 1752 .enter_standby = rcsi2_enter_standby_gen3, ··· 1773 1757 }; 1774 1758 1775 1759 static const struct rcar_csi2_info rcar_csi2_info_r8a77970 = { 1760 + .regs = &rcsi2_registers_gen3, 1776 1761 .init_phtw = rcsi2_init_phtw_v3m_e3, 1777 1762 .phy_post_init = rcsi2_phy_post_init_v3m_e3, 1778 1763 .start_receiver = rcsi2_start_receiver_gen3, ··· 1783 1766 }; 1784 1767 1785 1768 static const struct rcar_csi2_info rcar_csi2_info_r8a77980 = { 1769 + .regs = &rcsi2_registers_gen3, 1786 1770 .init_phtw = rcsi2_init_phtw_h3_v3h_m3n, 1787 1771 .start_receiver = rcsi2_start_receiver_gen3, 1788 1772 .enter_standby = rcsi2_enter_standby_gen3, ··· 1794 1776 }; 1795 1777 1796 1778 static const struct rcar_csi2_info rcar_csi2_info_r8a77990 = { 1779 + .regs = &rcsi2_registers_gen3, 1797 1780 .init_phtw = rcsi2_init_phtw_v3m_e3, 1798 1781 .phy_post_init = rcsi2_phy_post_init_v3m_e3, 1799 1782 .start_receiver = rcsi2_start_receiver_gen3, ··· 1804 1785 }; 1805 1786 1806 1787 static const struct rcar_csi2_info rcar_csi2_info_r8a779a0 = { 1788 + .regs = &rcsi2_registers_gen3, 1807 1789 .init_phtw = rcsi2_init_phtw_v3u, 1808 1790 .start_receiver = rcsi2_start_receiver_gen3, 1809 1791 .enter_standby = rcsi2_enter_standby_gen3, ··· 1816 1796 }; 1817 1797 1818 1798 static const struct rcar_csi2_info rcar_csi2_info_r8a779g0 = { 1799 + .regs = &rcsi2_registers_gen3, 1819 1800 .start_receiver = rcsi2_start_receiver_v4h, 1820 1801 .use_isp = true, 1821 1802 .support_cphy = true,