Lines Matching +full:11 +full:- +full:7

1 // SPDX-License-Identifier: GPL-2.0+
5 * Guochun Huang <hero.huang@rock-chips.com>
8 #include <dt-bindings/phy/phy.h>
39 #define I_RES_120_8UA I_RES_CNTL(7)
69 #define I_LADDER_0_72V I_LADDER_SEL(7)
73 * The selection between the 400-based or 200-based values for REG_400M
86 #define REG_325M_365MV REG_325M(7)
96 #define REG_LP_400M_450MV REG_LP_400M(7)
106 #define REG_400M_450MV REG_400M(7)
114 #define REG_400M_160MV REG_400M(7)
124 #define REG_645M_725MV REG_645M(7)
146 #define MFR_MASK GENMASK(7, 0)
149 #define SSCG_EN BIT(11)
170 #define RES_UP(x) FIELD_PREP(GENMASK(7, 4), x)
177 #define T_LPX(x) FIELD_PREP(GENMASK(11, 4), x)
180 #define T_CLK_PREPARE(x) FIELD_PREP(GENMASK(7, 0), x)
183 #define T_CLK_TRAIL(x) FIELD_PREP(GENMASK(7, 0), x)
185 #define T_CLK_POST(x) FIELD_PREP(GENMASK(7, 0), x)
191 #define SKEW_CAL_INIT_RUN_TIME(x) FIELD_PREP(GENMASK(11, 8), x)
192 #define SKEW_CAL_INIT_WAIT_TIME(x) FIELD_PREP(GENMASK(7, 4), x)
247 #define T_HS_PREPARE(x) FIELD_PREP(GENMASK(7, 0), x)
249 #define T_HS_TRAIL(x) FIELD_PREP(GENMASK(7, 0), x)
250 #define T_TA_GET(x) FIELD_PREP(GENMASK(7, 4), x)
667 {3200, 15, 56, 14, 14, 15, 26, 13, 11, 21, 17},
668 {3190, 15, 56, 14, 14, 15, 26, 13, 11, 21, 17},
669 {3180, 15, 56, 14, 14, 15, 26, 13, 11, 21, 17},
670 {3170, 15, 56, 14, 14, 15, 25, 13, 11, 21, 17},
671 {3160, 15, 55, 14, 14, 14, 26, 13, 11, 21, 17},
672 {3150, 15, 55, 14, 14, 14, 26, 13, 11, 21, 17},
673 {3140, 15, 55, 14, 14, 14, 26, 13, 11, 21, 17},
674 {3130, 15, 55, 14, 14, 14, 26, 13, 11, 21, 17},
675 {3120, 15, 54, 14, 13, 14, 26, 13, 11, 21, 17},
676 {3110, 15, 54, 14, 13, 14, 26, 13, 11, 21, 17},
677 {3100, 15, 54, 14, 13, 14, 26, 13, 11, 21, 17},
678 {3090, 15, 54, 14, 13, 14, 25, 12, 11, 21, 17},
679 {3080, 15, 53, 14, 13, 14, 25, 12, 11, 21, 17},
680 {3070, 14, 54, 14, 13, 14, 25, 12, 11, 21, 16},
681 {3060, 14, 54, 14, 13, 14, 25, 12, 11, 21, 16},
682 {3050, 14, 54, 14, 13, 14, 25, 12, 11, 20, 16},
683 {3040, 14, 53, 14, 13, 14, 25, 12, 11, 20, 16},
684 {3030, 14, 53, 14, 13, 14, 25, 12, 11, 20, 16},
685 {3020, 14, 53, 14, 13, 14, 24, 12, 11, 20, 16},
686 {3010, 14, 53, 14, 13, 14, 24, 12, 11, 20, 16},
687 {3000, 14, 53, 13, 13, 14, 24, 12, 11, 20, 16},
688 {2990, 14, 52, 13, 13, 14, 24, 12, 11, 20, 16},
689 {2980, 14, 52, 13, 13, 14, 24, 12, 11, 20, 16},
690 {2970, 14, 52, 13, 13, 14, 24, 12, 11, 20, 16},
691 {2960, 14, 52, 13, 13, 14, 24, 12, 11, 20, 16},
692 {2950, 14, 51, 13, 13, 13, 24, 12, 11, 20, 16},
693 {2940, 14, 51, 13, 13, 13, 24, 12, 11, 20, 16},
702 {2850, 13, 50, 13, 12, 13, 23, 11, 10, 19, 15},
703 {2840, 13, 50, 13, 12, 13, 23, 11, 10, 19, 15},
704 {2830, 13, 50, 13, 12, 13, 23, 11, 10, 19, 15},
705 {2820, 13, 49, 13, 12, 13, 23, 11, 10, 19, 15},
706 {2810, 13, 49, 13, 12, 13, 23, 11, 10, 19, 15},
707 {2800, 13, 49, 12, 12, 13, 22, 11, 10, 19, 15},
708 {2790, 13, 49, 12, 12, 13, 22, 11, 10, 19, 15},
709 {2780, 13, 48, 12, 12, 13, 22, 11, 10, 19, 15},
710 {2770, 13, 48, 12, 12, 13, 22, 11, 10, 19, 15},
711 {2760, 13, 48, 12, 12, 13, 22, 11, 10, 18, 15},
712 {2750, 13, 48, 12, 12, 13, 22, 11, 10, 18, 15},
713 {2740, 13, 47, 12, 12, 12, 23, 11, 10, 18, 14},
714 {2730, 13, 47, 12, 12, 12, 22, 11, 10, 18, 14},
715 {2720, 13, 47, 12, 12, 12, 22, 11, 10, 18, 14},
716 {2710, 13, 47, 12, 12, 12, 22, 11, 10, 18, 14},
717 {2700, 13, 47, 12, 12, 12, 22, 11, 10, 18, 14},
718 {2690, 13, 46, 12, 12, 12, 22, 11, 10, 18, 14},
719 {2680, 13, 46, 12, 12, 12, 22, 11, 10, 18, 14},
720 {2670, 12, 47, 12, 12, 12, 22, 11, 10, 18, 14},
721 {2660, 12, 47, 12, 12, 12, 21, 11, 9, 18, 14},
722 {2650, 12, 46, 12, 11, 12, 21, 11, 9, 18, 14},
723 {2640, 12, 46, 12, 11, 12, 21, 11, 9, 18, 14},
724 {2630, 12, 46, 12, 11, 12, 21, 11, 9, 18, 14},
725 {2620, 12, 46, 12, 11, 12, 21, 10, 9, 18, 14},
726 {2610, 12, 45, 12, 11, 12, 21, 10, 9, 17, 14},
727 {2600, 12, 45, 11, 11, 12, 21, 10, 9, 17, 14},
728 {2590, 12, 45, 11, 11, 12, 20, 10, 9, 17, 14},
729 {2580, 12, 45, 11, 11, 12, 20, 10, 9, 17, 14},
730 {2570, 12, 44, 11, 11, 12, 20, 10, 9, 17, 13},
731 {2560, 12, 44, 11, 11, 12, 20, 10, 9, 17, 13},
732 {2550, 12, 44, 11, 11, 12, 20, 10, 9, 17, 13},
733 {2540, 12, 44, 11, 11, 11, 21, 10, 9, 17, 13},
734 {2530, 12, 44, 11, 11, 11, 21, 10, 9, 17, 13},
735 {2520, 12, 43, 11, 11, 11, 21, 10, 9, 17, 13},
736 {2510, 12, 43, 11, 11, 11, 20, 10, 9, 17, 13},
737 {2500, 12, 43, 11, 11, 11, 20, 10, 9, 17, 13},
738 {2490, 12, 43, 11, 11, 11, 20, 10, 9, 17, 13},
739 {2480, 12, 42, 11, 11, 11, 20, 10, 9, 17, 13},
740 {2470, 11, 43, 11, 11, 11, 20, 10, 9, 16, 13},
741 {2460, 11, 43, 11, 11, 11, 20, 10, 9, 16, 13},
742 {2450, 11, 43, 11, 11, 11, 20, 10, 9, 16, 13},
743 {2440, 11, 42, 11, 11, 11, 19, 10, 9, 16, 13},
744 {2430, 11, 42, 11, 11, 11, 19, 10, 9, 16, 13},
745 {2420, 11, 42, 11, 10, 11, 19, 10, 9, 16, 13},
746 {2410, 11, 42, 11, 10, 11, 19, 10, 9, 16, 12},
747 {2400, 11, 41, 10, 10, 11, 19, 10, 8, 16, 12},
748 {2390, 11, 41, 10, 10, 11, 19, 10, 8, 16, 12},
749 {2380, 11, 41, 10, 10, 11, 19, 9, 8, 16, 12},
750 {2370, 11, 41, 10, 10, 11, 18, 9, 8, 16, 12},
751 {2360, 11, 41, 10, 10, 11, 18, 9, 8, 16, 12},
752 {2350, 11, 40, 10, 10, 11, 18, 9, 8, 16, 12},
753 {2340, 11, 40, 10, 10, 11, 18, 9, 8, 16, 12},
754 {2330, 11, 40, 10, 10, 10, 19, 9, 8, 16, 12},
755 {2320, 11, 40, 10, 10, 10, 19, 9, 8, 15, 12},
756 {2310, 11, 39, 10, 10, 10, 19, 9, 8, 15, 12},
757 {2300, 11, 39, 10, 10, 10, 18, 9, 8, 15, 12},
758 {2290, 11, 39, 10, 10, 10, 18, 9, 8, 15, 12},
759 {2280, 11, 39, 10, 10, 10, 18, 9, 8, 15, 12},
763 {2240, 10, 39, 10, 10, 10, 18, 9, 8, 15, 11},
764 {2230, 10, 38, 10, 10, 10, 18, 9, 8, 15, 11},
765 {2220, 10, 38, 10, 10, 10, 17, 9, 8, 15, 11},
766 {2210, 10, 38, 10, 10, 10, 17, 9, 8, 15, 11},
767 {2200, 10, 38, 9, 10, 10, 17, 9, 8, 15, 11},
768 {2190, 10, 38, 9, 9, 10, 17, 9, 8, 15, 11},
769 {2180, 10, 37, 9, 9, 10, 17, 9, 8, 14, 11},
770 {2170, 10, 37, 9, 9, 10, 17, 9, 8, 14, 11},
771 {2160, 10, 37, 9, 9, 10, 17, 9, 8, 14, 11},
772 {2150, 10, 37, 9, 9, 10, 16, 8, 8, 14, 11},
773 {2140, 10, 36, 9, 9, 10, 16, 8, 8, 14, 11},
774 {2130, 10, 36, 9, 9, 10, 16, 8, 7, 14, 11},
775 {2120, 10, 36, 9, 9, 9, 17, 8, 7, 14, 11},
776 {2110, 10, 36, 9, 9, 9, 17, 8, 7, 14, 11},
777 {2100, 10, 35, 9, 9, 9, 17, 8, 7, 14, 11},
778 {2090, 10, 35, 9, 9, 9, 17, 8, 7, 14, 11},
779 {2080, 9, 36, 9, 9, 9, 16, 8, 7, 14, 11},
780 {2070, 9, 36, 9, 9, 9, 16, 8, 7, 14, 10},
781 {2060, 9, 35, 9, 9, 9, 16, 8, 7, 14, 10},
782 {2050, 9, 35, 9, 9, 9, 16, 8, 7, 14, 10},
783 {2040, 9, 35, 9, 9, 9, 16, 8, 7, 14, 10},
784 {2030, 9, 35, 9, 9, 9, 16, 8, 7, 13, 10},
785 {2020, 9, 35, 9, 9, 9, 16, 8, 7, 13, 10},
786 {2010, 9, 34, 9, 9, 9, 15, 8, 7, 13, 10},
787 {2000, 9, 34, 8, 9, 9, 15, 8, 7, 13, 10},
788 {1990, 9, 34, 8, 9, 9, 15, 8, 7, 13, 10},
789 {1980, 9, 34, 8, 9, 9, 15, 8, 7, 13, 10},
790 {1970, 9, 33, 8, 9, 9, 15, 8, 7, 13, 10},
791 {1960, 9, 33, 8, 9, 9, 15, 8, 7, 13, 10},
792 {1950, 9, 33, 8, 8, 9, 15, 8, 7, 13, 10},
793 {1940, 9, 33, 8, 8, 9, 15, 8, 7, 13, 10},
794 {1930, 9, 32, 8, 8, 9, 14, 8, 7, 13, 10},
795 {1920, 9, 32, 8, 8, 9, 14, 8, 7, 13, 10},
796 {1910, 9, 32, 8, 8, 8, 15, 7, 7, 13, 9},
797 {1900, 9, 32, 8, 8, 8, 15, 7, 7, 13, 9},
798 {1890, 9, 31, 8, 8, 8, 15, 7, 7, 12, 9},
799 {1880, 8, 32, 8, 8, 8, 15, 7, 7, 12, 9},
800 {1870, 8, 32, 8, 8, 8, 15, 7, 7, 12, 9},
801 {1860, 8, 32, 8, 8, 8, 14, 7, 6, 12, 9},
802 {1850, 8, 32, 8, 8, 8, 14, 7, 6, 12, 9},
803 {1840, 8, 31, 8, 8, 8, 14, 7, 6, 12, 9},
804 {1830, 8, 31, 8, 8, 8, 14, 7, 6, 12, 9},
805 {1820, 8, 31, 8, 8, 8, 14, 7, 6, 12, 9},
806 {1810, 8, 31, 8, 8, 8, 14, 7, 6, 12, 9},
807 {1800, 8, 30, 7, 8, 8, 14, 7, 6, 12, 9},
808 {1790, 8, 30, 7, 8, 8, 13, 7, 6, 12, 9},
809 {1780, 8, 30, 7, 8, 8, 13, 7, 6, 12, 9},
810 {1770, 8, 30, 7, 8, 8, 13, 7, 6, 12, 9},
811 {1760, 8, 29, 7, 8, 8, 13, 7, 6, 12, 9},
812 {1750, 8, 29, 7, 8, 8, 13, 7, 6, 12, 9},
813 {1740, 8, 29, 7, 8, 8, 13, 7, 6, 11, 8},
814 {1730, 8, 29, 7, 8, 8, 13, 7, 6, 11, 8},
815 {1720, 8, 29, 7, 7, 8, 13, 7, 6, 11, 8},
816 {1710, 8, 28, 7, 7, 8, 12, 7, 6, 11, 8},
817 {1700, 8, 28, 7, 7, 7, 13, 7, 6, 11, 8},
818 {1690, 8, 28, 7, 7, 7, 13, 7, 6, 11, 8},
819 {1680, 7, 29, 7, 7, 7, 13, 6, 6, 11, 8},
820 {1670, 7, 28, 7, 7, 7, 13, 6, 6, 11, 8},
821 {1660, 7, 28, 7, 7, 7, 13, 6, 6, 11, 8},
822 {1650, 7, 28, 7, 7, 7, 13, 6, 6, 11, 8},
823 {1640, 7, 28, 7, 7, 7, 12, 6, 6, 11, 8},
824 {1630, 7, 27, 7, 7, 7, 12, 6, 6, 11, 8},
825 {1620, 7, 27, 7, 7, 7, 12, 6, 6, 11, 8},
826 {1610, 7, 27, 7, 7, 7, 12, 6, 6, 11, 8},
827 {1600, 7, 27, 6, 7, 7, 12, 6, 5, 10, 8},
828 {1590, 7, 26, 6, 7, 7, 12, 6, 5, 10, 8},
829 {1580, 7, 26, 6, 7, 7, 12, 6, 5, 10, 7},
830 {1570, 7, 26, 6, 7, 7, 11, 6, 5, 10, 7},
831 {1560, 7, 26, 6, 7, 7, 11, 6, 5, 10, 7},
832 {1550, 7, 26, 6, 7, 7, 11, 6, 5, 10, 7},
833 {1540, 7, 25, 6, 7, 7, 11, 6, 5, 10, 7},
834 {1530, 7, 25, 6, 7, 7, 11, 6, 5, 10, 7},
835 {1520, 7, 25, 6, 7, 7, 11, 6, 5, 10, 7},
836 {1510, 7, 25, 6, 7, 7, 11, 6, 5, 10, 7},
837 {1500, 7, 24, 6, 7, 7, 10, 6, 5, 10, 7},
858 {1290, 51, 21, 5, 70, 51, 8, 63, 38, 7, 64},
859 {1280, 51, 21, 5, 69, 51, 8, 63, 38, 7, 63},
860 {1270, 50, 21, 5, 69, 50, 8, 62, 38, 7, 63},
861 {1260, 50, 20, 5, 69, 50, 8, 62, 37, 7, 62},
862 {1250, 49, 20, 5, 68, 49, 8, 62, 37, 7, 62},
863 {1240, 49, 20, 5, 68, 49, 8, 61, 37, 7, 61},
864 {1230, 49, 20, 5, 68, 49, 8, 61, 36, 7, 61},
865 {1220, 48, 20, 5, 67, 48, 8, 61, 36, 7, 60},
866 {1210, 48, 19, 5, 67, 48, 7, 60, 36, 7, 60},
867 {1200, 49, 19, 4, 67, 49, 7, 60, 36, 7, 59},
868 {1190, 48, 19, 4, 66, 48, 7, 60, 36, 7, 59},
869 {1180, 48, 19, 4, 66, 48, 7, 59, 36, 7, 58},
870 {1170, 46, 19, 4, 66, 46, 7, 59, 35, 7, 58},
871 {1160, 46, 18, 4, 65, 46, 7, 59, 34, 7, 57},
872 {1150, 45, 18, 4, 65, 46, 7, 58, 34, 7, 57},
873 {1140, 45, 18, 4, 65, 45, 7, 58, 34, 6, 56},
874 {1130, 45, 18, 4, 64, 45, 7, 58, 33, 6, 56},
875 {1120, 44, 18, 4, 64, 44, 7, 57, 33, 6, 55},
876 {1110, 44, 18, 4, 64, 44, 7, 57, 33, 6, 55},
910 { 770, 30, 11, 2, 52, 31, 4, 45, 23, 4, 39},
911 { 760, 30, 11, 2, 52, 31, 3, 45, 22, 4, 38},
912 { 750, 29, 11, 2, 51, 30, 3, 45, 22, 4, 38},
913 { 740, 29, 11, 2, 51, 30, 3, 44, 22, 4, 37},
914 { 730, 28, 11, 2, 51, 31, 3, 44, 22, 4, 37},
931 { 560, 22, 7, 1, 45, 23, 2, 38, 16, 2, 28},
932 { 550, 21, 7, 1, 45, 23, 2, 38, 16, 2, 28},
933 { 540, 21, 7, 1, 44, 22, 2, 37, 16, 2, 27},
934 { 530, 20, 7, 1, 44, 22, 1, 37, 15, 2, 27},
935 { 520, 20, 7, 1, 43, 21, 1, 37, 15, 2, 27},
947 { 400, 15, 5, 0, 39, 17, 0, 33, 11, 1, 21},
957 { 300, 11, 3, 0, 36, 13, 0, 29, 8, 1, 16},
958 { 290, 11, 2, 0, 36, 13, 0, 29, 8, 1, 15},
966 { 210, 7, 1, 0, 33, 10, 0, 26, 6, 0, 12},
967 { 200, 7, 1, 0, 33, 9, 0, 26, 5, 0, 11},
968 { 190, 7, 1, 0, 32, 9, 0, 25, 5, 0, 11},
975 { 120, 4, 0, 0, 30, 6, 0, 23, 3, 0, 7},
976 { 110, 3, 0, 0, 30, 6, 0, 23, 3, 0, 7},
984 regmap_write(samsung->regmap, BIAS_CON0, I_DEV_DIV_6 | I_RES_100_2UA); in samsung_mipi_dcphy_bias_block_enable()
985 regmap_write(samsung->regmap, BIAS_CON1, I_VBG_SEL_820MV | I_BGR_VREF_820MV | in samsung_mipi_dcphy_bias_block_enable()
987 regmap_write(samsung->regmap, BIAS_CON2, REG_325M_325MV | REG_LP_400M_400MV | in samsung_mipi_dcphy_bias_block_enable()
994 regmap_update_bits(samsung->regmap, BIAS_CON4, in samsung_mipi_dcphy_bias_block_enable()
1000 regmap_write(samsung->regmap, DPHY_MC_GNR_CON1, T_PHY_READY(0x2000)); in samsung_mipi_dphy_lane_enable()
1001 regmap_update_bits(samsung->regmap, DPHY_MC_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1004 switch (samsung->lanes) { in samsung_mipi_dphy_lane_enable()
1006 regmap_write(samsung->regmap, DPHY_MD3_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1008 regmap_update_bits(samsung->regmap, DPHY_MD3_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1012 regmap_write(samsung->regmap, COMBO_MD2_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1014 regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1018 regmap_write(samsung->regmap, COMBO_MD1_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1020 regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1025 regmap_write(samsung->regmap, COMBO_MD0_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1027 regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1035 switch (samsung->lanes) { in samsung_mipi_dphy_lane_disable()
1037 regmap_update_bits(samsung->regmap, DPHY_MD3_GNR_CON0, in samsung_mipi_dphy_lane_disable()
1041 regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, in samsung_mipi_dphy_lane_disable()
1045 regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, in samsung_mipi_dphy_lane_disable()
1050 regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, in samsung_mipi_dphy_lane_disable()
1055 regmap_update_bits(samsung->regmap, DPHY_MC_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_dphy_lane_disable()
1060 regmap_update_bits(samsung->regmap, PLL_CON0, S_MASK | P_MASK, in samsung_mipi_dcphy_pll_configure()
1061 S(samsung->pll.scaler) | P(samsung->pll.prediv)); in samsung_mipi_dcphy_pll_configure()
1063 if (samsung->pll.dsm < 0) { in samsung_mipi_dcphy_pll_configure()
1067 dsm_tmp = abs(samsung->pll.dsm); in samsung_mipi_dcphy_pll_configure()
1068 dsm_tmp = dsm_tmp - 1; in samsung_mipi_dcphy_pll_configure()
1070 regmap_write(samsung->regmap, PLL_CON1, dsm_tmp); in samsung_mipi_dcphy_pll_configure()
1072 regmap_write(samsung->regmap, PLL_CON1, samsung->pll.dsm); in samsung_mipi_dcphy_pll_configure()
1075 regmap_update_bits(samsung->regmap, PLL_CON2, in samsung_mipi_dcphy_pll_configure()
1076 M_MASK, M(samsung->pll.fbdiv)); in samsung_mipi_dcphy_pll_configure()
1078 if (samsung->pll.ssc_en) { in samsung_mipi_dcphy_pll_configure()
1079 regmap_write(samsung->regmap, PLL_CON3, in samsung_mipi_dcphy_pll_configure()
1080 MRR(samsung->pll.mrr) | MFR(samsung->pll.mfr)); in samsung_mipi_dcphy_pll_configure()
1081 regmap_update_bits(samsung->regmap, PLL_CON4, SSCG_EN, SSCG_EN); in samsung_mipi_dcphy_pll_configure()
1084 regmap_write(samsung->regmap, PLL_CON5, RESET_N_SEL | PLL_ENABLE_SEL); in samsung_mipi_dcphy_pll_configure()
1085 regmap_write(samsung->regmap, PLL_CON7, PLL_LOCK_CNT(0xf000)); in samsung_mipi_dcphy_pll_configure()
1086 regmap_write(samsung->regmap, PLL_CON8, PLL_STB_CNT(0xf000)); in samsung_mipi_dcphy_pll_configure()
1094 regmap_update_bits(samsung->regmap, PLL_CON0, PLL_EN, PLL_EN); in samsung_mipi_dcphy_pll_enable()
1096 ret = regmap_read_poll_timeout(samsung->regmap, PLL_STAT0, in samsung_mipi_dcphy_pll_enable()
1099 dev_err(samsung->dev, "DC-PHY pll failed to lock\n"); in samsung_mipi_dcphy_pll_enable()
1106 regmap_update_bits(samsung->regmap, PLL_CON0, PLL_EN, 0); in samsung_mipi_dcphy_pll_disable()
1114 unsigned int lane_mbps = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_dphy_get_timing()
1120 for (i = num_timings; i > 1; i--) in samsung_mipi_dphy_get_timing()
1121 if (lane_mbps <= timings[i - 1].max_lane_mbps) in samsung_mipi_dphy_get_timing()
1124 return &timings[i - 1]; in samsung_mipi_dphy_get_timing()
1132 u32 max_fout = samsung->pdata->dphy_tx_max_lane_kbps; in samsung_mipi_dcphy_pll_round_rate()
1143 dev_err(samsung->dev, "parent rate of PLL can not be zero\n"); in samsung_mipi_dcphy_pll_round_rate()
1160 for (_scaler = 0; _scaler < 7; _scaler++) { in samsung_mipi_dcphy_pll_round_rate()
1182 /* -32767 ≤ K[15:0] ≤ 32767 */ in samsung_mipi_dcphy_pll_round_rate()
1183 _dsm = ((_prediv * fvco) - (2 * _fbdiv * fin)); in samsung_mipi_dcphy_pll_round_rate()
1191 delta = abs(fvco * MSEC_PER_SEC - tmp); in samsung_mipi_dcphy_pll_round_rate()
1210 dev_dbg(samsung->dev, "p: %d, m: %d, dsm:%ld, scaler: %d\n", in samsung_mipi_dcphy_pll_round_rate()
1220 unsigned int lane_hs_rate = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_dphy_clk_lane_timing_init()
1224 regmap_write(samsung->regmap, DPHY_MC_GNR_CON0, 0xf000); in samsung_mipi_dphy_clk_lane_timing_init()
1227 * The Drive-Strength / Voltage-Amplitude is adjusted by setting in samsung_mipi_dphy_clk_lane_timing_init()
1228 * the Driver-Up Resistor and Driver-Down Resistor. in samsung_mipi_dphy_clk_lane_timing_init()
1230 res_up = samsung->pdata->dphy_hs_drv_res_cfg->clk_hs_drv_up_ohm; in samsung_mipi_dphy_clk_lane_timing_init()
1231 res_down = samsung->pdata->dphy_hs_drv_res_cfg->clk_hs_drv_down_ohm; in samsung_mipi_dphy_clk_lane_timing_init()
1232 val = EDGE_CON(7) | EDGE_CON_DIR(0) | EDGE_CON_EN | in samsung_mipi_dphy_clk_lane_timing_init()
1234 regmap_write(samsung->regmap, DPHY_MC_ANA_CON0, val); in samsung_mipi_dphy_clk_lane_timing_init()
1237 regmap_write(samsung->regmap, DPHY_MC_ANA_CON1, 0x0001); in samsung_mipi_dphy_clk_lane_timing_init()
1241 * Divide-by-2 Clock from Serial Clock. Use this when data rate is under in samsung_mipi_dphy_clk_lane_timing_init()
1242 * 1500Mbps, otherwise divide-by-16 Clock from Serial Clock in samsung_mipi_dphy_clk_lane_timing_init()
1247 val |= T_LPX(timing->lpx); in samsung_mipi_dphy_clk_lane_timing_init()
1249 regmap_write(samsung->regmap, DPHY_MC_TIME_CON0, val); in samsung_mipi_dphy_clk_lane_timing_init()
1251 val = T_CLK_ZERO(timing->clk_zero) | T_CLK_PREPARE(timing->clk_prepare); in samsung_mipi_dphy_clk_lane_timing_init()
1252 regmap_write(samsung->regmap, DPHY_MC_TIME_CON1, val); in samsung_mipi_dphy_clk_lane_timing_init()
1254 val = T_HS_EXIT(timing->hs_exit) | T_CLK_TRAIL(timing->clk_trail_eot); in samsung_mipi_dphy_clk_lane_timing_init()
1255 regmap_write(samsung->regmap, DPHY_MC_TIME_CON2, val); in samsung_mipi_dphy_clk_lane_timing_init()
1257 val = T_CLK_POST(timing->clk_post); in samsung_mipi_dphy_clk_lane_timing_init()
1258 regmap_write(samsung->regmap, DPHY_MC_TIME_CON3, val); in samsung_mipi_dphy_clk_lane_timing_init()
1261 regmap_write(samsung->regmap, DPHY_MC_TIME_CON4, 0x1f4); in samsung_mipi_dphy_clk_lane_timing_init()
1268 regmap_write(samsung->regmap, DPHY_MC_DESKEW_CON0, 0x9cb1); in samsung_mipi_dphy_clk_lane_timing_init()
1275 unsigned int lane_hs_rate = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_dphy_data_lane_timing_init()
1281 * The Drive-Strength / Voltage-Amplitude is adjusted by adjusting the in samsung_mipi_dphy_data_lane_timing_init()
1282 * Driver-Up Resistor and Driver-Down Resistor. in samsung_mipi_dphy_data_lane_timing_init()
1284 res_up = samsung->pdata->dphy_hs_drv_res_cfg->data_hs_drv_up_ohm; in samsung_mipi_dphy_data_lane_timing_init()
1285 res_down = samsung->pdata->dphy_hs_drv_res_cfg->data_hs_drv_down_ohm; in samsung_mipi_dphy_data_lane_timing_init()
1286 val = EDGE_CON(7) | EDGE_CON_DIR(0) | EDGE_CON_EN | in samsung_mipi_dphy_data_lane_timing_init()
1288 regmap_write(samsung->regmap, COMBO_MD0_ANA_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1289 regmap_write(samsung->regmap, COMBO_MD1_ANA_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1290 regmap_write(samsung->regmap, COMBO_MD2_ANA_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1291 regmap_write(samsung->regmap, DPHY_MD3_ANA_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1294 regmap_write(samsung->regmap, COMBO_MD0_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1295 regmap_write(samsung->regmap, COMBO_MD1_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1296 regmap_write(samsung->regmap, COMBO_MD2_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1297 regmap_write(samsung->regmap, DPHY_MD3_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1302 * Divide-by-2 Clock from Serial Clock. Use this when data rate is under in samsung_mipi_dphy_data_lane_timing_init()
1303 * 1500Mbps, otherwise divide-by-16 Clock from Serial Clock in samsung_mipi_dphy_data_lane_timing_init()
1308 val |= T_LPX(timing->lpx); in samsung_mipi_dphy_data_lane_timing_init()
1310 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1311 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1312 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1313 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1315 val = T_HS_ZERO(timing->hs_zero) | T_HS_PREPARE(timing->hs_prepare); in samsung_mipi_dphy_data_lane_timing_init()
1316 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1317 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1318 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1319 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1321 val = T_HS_EXIT(timing->hs_exit) | T_HS_TRAIL(timing->hs_trail_eot); in samsung_mipi_dphy_data_lane_timing_init()
1322 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1323 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1324 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1325 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1327 /* TTA-GET/TTA-GO Timing Counter register use default value */ in samsung_mipi_dphy_data_lane_timing_init()
1329 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1330 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1331 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1332 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1335 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1336 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1337 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1338 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1345 reset_control_assert(samsung->m_phy_rst); in samsung_mipi_dphy_power_on()
1357 reset_control_deassert(samsung->m_phy_rst); in samsung_mipi_dphy_power_on()
1371 reset_control_assert(samsung->apb_rst); in samsung_mipi_dcphy_power_on()
1373 reset_control_deassert(samsung->apb_rst); in samsung_mipi_dcphy_power_on()
1375 switch (samsung->type) { in samsung_mipi_dcphy_power_on()
1380 return -EOPNOTSUPP; in samsung_mipi_dcphy_power_on()
1390 switch (samsung->type) { in samsung_mipi_dcphy_power_off()
1396 return -EOPNOTSUPP; in samsung_mipi_dcphy_power_off()
1408 unsigned long fin = div64_ul(clk_get_rate(samsung->ref_clk), MSEC_PER_SEC); in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1409 u16 prediv = samsung->pll.prediv; in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1410 u16 fbdiv = samsung->pll.fbdiv; in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1442 dev_err(samsung->dev, "failed to calc ssc parameter mfr and mrr\n"); in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1443 return -EINVAL; in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1453 unsigned long prate = clk_get_rate(samsung->ref_clk); in samsung_mipi_dcphy_pll_calc_rate()
1465 dev_dbg(samsung->dev, "%s: fin=%lu, req_rate=%llu\n", in samsung_mipi_dcphy_pll_calc_rate()
1467 dev_dbg(samsung->dev, "%s: fout=%lu, prediv=%u, fbdiv=%u\n", in samsung_mipi_dcphy_pll_calc_rate()
1470 samsung->pll.prediv = prediv; in samsung_mipi_dcphy_pll_calc_rate()
1471 samsung->pll.fbdiv = fbdiv; in samsung_mipi_dcphy_pll_calc_rate()
1472 samsung->pll.dsm = dsm; in samsung_mipi_dcphy_pll_calc_rate()
1473 samsung->pll.scaler = scaler; in samsung_mipi_dcphy_pll_calc_rate()
1474 samsung->pll.rate = fout; in samsung_mipi_dcphy_pll_calc_rate()
1484 samsung->pll.ssc_en = true; in samsung_mipi_dcphy_pll_calc_rate()
1485 samsung->pll.mfr = mfr; in samsung_mipi_dcphy_pll_calc_rate()
1486 samsung->pll.mrr = mrr; in samsung_mipi_dcphy_pll_calc_rate()
1495 unsigned long long target_rate = opts->mipi_dphy.hs_clk_rate; in samsung_mipi_dcphy_configure()
1497 samsung->lanes = opts->mipi_dphy.lanes > 4 ? 4 : opts->mipi_dphy.lanes; in samsung_mipi_dcphy_configure()
1500 opts->mipi_dphy.hs_clk_rate = samsung->pll.rate; in samsung_mipi_dcphy_configure()
1509 return pm_runtime_resume_and_get(samsung->dev); in samsung_mipi_dcphy_init()
1516 return pm_runtime_put(samsung->dev); in samsung_mipi_dcphy_exit()
1541 if (args->args_count != 1) { in samsung_mipi_dcphy_xlate()
1543 return ERR_PTR(-EINVAL); in samsung_mipi_dcphy_xlate()
1546 if (samsung->type != PHY_NONE && samsung->type != args->args[0]) in samsung_mipi_dcphy_xlate()
1548 args->args[0], samsung->type); in samsung_mipi_dcphy_xlate()
1550 samsung->type = args->args[0]; in samsung_mipi_dcphy_xlate()
1552 return samsung->phy; in samsung_mipi_dcphy_xlate()
1557 struct device *dev = &pdev->dev; in samsung_mipi_dcphy_probe()
1558 struct device_node *np = dev->of_node; in samsung_mipi_dcphy_probe()
1567 return -ENOMEM; in samsung_mipi_dcphy_probe()
1569 samsung->dev = dev; in samsung_mipi_dcphy_probe()
1570 samsung->pdata = device_get_match_data(dev); in samsung_mipi_dcphy_probe()
1578 samsung->regmap = devm_regmap_init_mmio(dev, regs, in samsung_mipi_dcphy_probe()
1580 if (IS_ERR(samsung->regmap)) in samsung_mipi_dcphy_probe()
1581 return dev_err_probe(dev, PTR_ERR(samsung->regmap), "Failed to init regmap\n"); in samsung_mipi_dcphy_probe()
1583 samsung->grf_regmap = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in samsung_mipi_dcphy_probe()
1584 if (IS_ERR(samsung->grf_regmap)) in samsung_mipi_dcphy_probe()
1585 return dev_err_probe(dev, PTR_ERR(samsung->grf_regmap), in samsung_mipi_dcphy_probe()
1588 samsung->ref_clk = devm_clk_get(dev, "ref"); in samsung_mipi_dcphy_probe()
1589 if (IS_ERR(samsung->ref_clk)) in samsung_mipi_dcphy_probe()
1590 return dev_err_probe(dev, PTR_ERR(samsung->ref_clk), in samsung_mipi_dcphy_probe()
1593 samsung->pclk = devm_clk_get(dev, "pclk"); in samsung_mipi_dcphy_probe()
1594 if (IS_ERR(samsung->pclk)) in samsung_mipi_dcphy_probe()
1595 return dev_err_probe(dev, PTR_ERR(samsung->pclk), "Failed to get pclk\n"); in samsung_mipi_dcphy_probe()
1597 samsung->m_phy_rst = devm_reset_control_get(dev, "m_phy"); in samsung_mipi_dcphy_probe()
1598 if (IS_ERR(samsung->m_phy_rst)) in samsung_mipi_dcphy_probe()
1599 return dev_err_probe(dev, PTR_ERR(samsung->m_phy_rst), in samsung_mipi_dcphy_probe()
1602 samsung->s_phy_rst = devm_reset_control_get(dev, "s_phy"); in samsung_mipi_dcphy_probe()
1603 if (IS_ERR(samsung->s_phy_rst)) in samsung_mipi_dcphy_probe()
1604 return dev_err_probe(dev, PTR_ERR(samsung->s_phy_rst), in samsung_mipi_dcphy_probe()
1607 samsung->apb_rst = devm_reset_control_get(dev, "apb"); in samsung_mipi_dcphy_probe()
1608 if (IS_ERR(samsung->apb_rst)) in samsung_mipi_dcphy_probe()
1609 return dev_err_probe(dev, PTR_ERR(samsung->apb_rst), in samsung_mipi_dcphy_probe()
1612 samsung->grf_apb_rst = devm_reset_control_get(dev, "grf"); in samsung_mipi_dcphy_probe()
1613 if (IS_ERR(samsung->grf_apb_rst)) in samsung_mipi_dcphy_probe()
1614 return dev_err_probe(dev, PTR_ERR(samsung->grf_apb_rst), in samsung_mipi_dcphy_probe()
1617 samsung->phy = devm_phy_create(dev, NULL, &samsung_mipi_dcphy_ops); in samsung_mipi_dcphy_probe()
1618 if (IS_ERR(samsung->phy)) in samsung_mipi_dcphy_probe()
1619 return dev_err_probe(dev, PTR_ERR(samsung->phy), "Failed to create MIPI DC-PHY\n"); in samsung_mipi_dcphy_probe()
1621 phy_set_drvdata(samsung->phy, samsung); in samsung_mipi_dcphy_probe()
1639 clk_disable_unprepare(samsung->ref_clk); in samsung_mipi_dcphy_runtime_suspend()
1640 clk_disable_unprepare(samsung->pclk); in samsung_mipi_dcphy_runtime_suspend()
1650 ret = clk_prepare_enable(samsung->pclk); in samsung_mipi_dcphy_runtime_resume()
1652 dev_err(samsung->dev, "Failed to enable pclk, %d\n", ret); in samsung_mipi_dcphy_runtime_resume()
1656 ret = clk_prepare_enable(samsung->ref_clk); in samsung_mipi_dcphy_runtime_resume()
1658 dev_err(samsung->dev, "Failed to enable reference clock, %d\n", ret); in samsung_mipi_dcphy_runtime_resume()
1659 clk_disable_unprepare(samsung->pclk); in samsung_mipi_dcphy_runtime_resume()
1697 .compatible = "rockchip,rk3576-mipi-dcphy",
1700 .compatible = "rockchip,rk3588-mipi-dcphy",
1709 .name = "samsung-mipi-dcphy",
1717 MODULE_AUTHOR("Guochun Huang <hero.huang@rock-chips.com>");