@@ -126,6 +126,19 @@ const u8 clk_alpha_pll_regs[][PLL_OFF_MAX_REGS] = {
126
126
[PLL_OFF_TEST_CTL_U ] = 0x1c ,
127
127
[PLL_OFF_STATUS ] = 0x2c ,
128
128
},
129
+ [CLK_ALPHA_PLL_TYPE_ZONDA ] = {
130
+ [PLL_OFF_L_VAL ] = 0x04 ,
131
+ [PLL_OFF_ALPHA_VAL ] = 0x08 ,
132
+ [PLL_OFF_USER_CTL ] = 0x0c ,
133
+ [PLL_OFF_CONFIG_CTL ] = 0x10 ,
134
+ [PLL_OFF_CONFIG_CTL_U ] = 0x14 ,
135
+ [PLL_OFF_CONFIG_CTL_U1 ] = 0x18 ,
136
+ [PLL_OFF_TEST_CTL ] = 0x1c ,
137
+ [PLL_OFF_TEST_CTL_U ] = 0x20 ,
138
+ [PLL_OFF_TEST_CTL_U1 ] = 0x24 ,
139
+ [PLL_OFF_OPMODE ] = 0x28 ,
140
+ [PLL_OFF_STATUS ] = 0x38 ,
141
+ },
129
142
};
130
143
EXPORT_SYMBOL_GPL (clk_alpha_pll_regs );
131
144
@@ -162,6 +175,11 @@ EXPORT_SYMBOL_GPL(clk_alpha_pll_regs);
162
175
#define LUCID_5LPE_PLL_LATCH_INPUT BIT(14)
163
176
#define LUCID_5LPE_ENABLE_VOTE_RUN BIT(21)
164
177
178
+ /* ZONDA PLL specific */
179
+ #define ZONDA_PLL_OUT_MASK 0xf
180
+ #define ZONDA_STAY_IN_CFA BIT(16)
181
+ #define ZONDA_PLL_FREQ_LOCK_DET BIT(29)
182
+
165
183
#define pll_alpha_width (p ) \
166
184
((PLL_ALPHA_VAL_U(p) - PLL_ALPHA_VAL(p) == 4) ? \
167
185
ALPHA_REG_BITWIDTH : ALPHA_REG_16BIT_WIDTH)
@@ -208,6 +226,9 @@ static int wait_for_pll(struct clk_alpha_pll *pll, u32 mask, bool inverse,
208
226
#define wait_for_pll_enable_lock (pll ) \
209
227
wait_for_pll(pll, PLL_LOCK_DET, 0, "enable")
210
228
229
+ #define wait_for_zonda_pll_freq_lock (pll ) \
230
+ wait_for_pll(pll, ZONDA_PLL_FREQ_LOCK_DET, 0, "freq enable")
231
+
211
232
#define wait_for_pll_disable (pll ) \
212
233
wait_for_pll(pll, PLL_ACTIVE_FLAG, 1, "disable")
213
234
@@ -1777,3 +1798,156 @@ const struct clk_ops clk_alpha_pll_postdiv_lucid_5lpe_ops = {
1777
1798
.set_rate = clk_lucid_5lpe_pll_postdiv_set_rate ,
1778
1799
};
1779
1800
EXPORT_SYMBOL (clk_alpha_pll_postdiv_lucid_5lpe_ops );
1801
+
1802
+ void clk_zonda_pll_configure (struct clk_alpha_pll * pll , struct regmap * regmap ,
1803
+ const struct alpha_pll_config * config )
1804
+ {
1805
+ clk_alpha_pll_write_config (regmap , PLL_L_VAL (pll ), config -> l );
1806
+ clk_alpha_pll_write_config (regmap , PLL_ALPHA_VAL (pll ), config -> alpha );
1807
+ clk_alpha_pll_write_config (regmap , PLL_CONFIG_CTL (pll ), config -> config_ctl_val );
1808
+ clk_alpha_pll_write_config (regmap , PLL_CONFIG_CTL_U (pll ), config -> config_ctl_hi_val );
1809
+ clk_alpha_pll_write_config (regmap , PLL_CONFIG_CTL_U1 (pll ), config -> config_ctl_hi1_val );
1810
+ clk_alpha_pll_write_config (regmap , PLL_USER_CTL (pll ), config -> user_ctl_val );
1811
+ clk_alpha_pll_write_config (regmap , PLL_USER_CTL_U (pll ), config -> user_ctl_hi_val );
1812
+ clk_alpha_pll_write_config (regmap , PLL_USER_CTL_U1 (pll ), config -> user_ctl_hi1_val );
1813
+ clk_alpha_pll_write_config (regmap , PLL_TEST_CTL (pll ), config -> test_ctl_val );
1814
+ clk_alpha_pll_write_config (regmap , PLL_TEST_CTL_U (pll ), config -> test_ctl_hi_val );
1815
+ clk_alpha_pll_write_config (regmap , PLL_TEST_CTL_U1 (pll ), config -> test_ctl_hi1_val );
1816
+
1817
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_BYPASSNL , 0 );
1818
+
1819
+ /* Disable PLL output */
1820
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_OUTCTRL , 0 );
1821
+
1822
+ /* Set operation mode to OFF */
1823
+ regmap_write (regmap , PLL_OPMODE (pll ), PLL_STANDBY );
1824
+
1825
+ /* Place the PLL in STANDBY mode */
1826
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_RESET_N , PLL_RESET_N );
1827
+ }
1828
+ EXPORT_SYMBOL_GPL (clk_zonda_pll_configure );
1829
+
1830
+ static int clk_zonda_pll_enable (struct clk_hw * hw )
1831
+ {
1832
+ struct clk_alpha_pll * pll = to_clk_alpha_pll (hw );
1833
+ struct regmap * regmap = pll -> clkr .regmap ;
1834
+ u32 val ;
1835
+ int ret ;
1836
+
1837
+ regmap_read (regmap , PLL_MODE (pll ), & val );
1838
+
1839
+ /* If in FSM mode, just vote for it */
1840
+ if (val & PLL_VOTE_FSM_ENA ) {
1841
+ ret = clk_enable_regmap (hw );
1842
+ if (ret )
1843
+ return ret ;
1844
+ return wait_for_pll_enable_active (pll );
1845
+ }
1846
+
1847
+ /* Get the PLL out of bypass mode */
1848
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_BYPASSNL , PLL_BYPASSNL );
1849
+
1850
+ /*
1851
+ * H/W requires a 1us delay between disabling the bypass and
1852
+ * de-asserting the reset.
1853
+ */
1854
+ udelay (1 );
1855
+
1856
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_RESET_N , PLL_RESET_N );
1857
+
1858
+ /* Set operation mode to RUN */
1859
+ regmap_write (regmap , PLL_OPMODE (pll ), PLL_RUN );
1860
+
1861
+ regmap_read (regmap , PLL_TEST_CTL (pll ), & val );
1862
+
1863
+ /* If cfa mode then poll for freq lock */
1864
+ if (val & ZONDA_STAY_IN_CFA )
1865
+ ret = wait_for_zonda_pll_freq_lock (pll );
1866
+ else
1867
+ ret = wait_for_pll_enable_lock (pll );
1868
+ if (ret )
1869
+ return ret ;
1870
+
1871
+ /* Enable the PLL outputs */
1872
+ regmap_update_bits (regmap , PLL_USER_CTL (pll ), ZONDA_PLL_OUT_MASK , ZONDA_PLL_OUT_MASK );
1873
+
1874
+ /* Enable the global PLL outputs */
1875
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_OUTCTRL , PLL_OUTCTRL );
1876
+
1877
+ return 0 ;
1878
+ }
1879
+
1880
+ static void clk_zonda_pll_disable (struct clk_hw * hw )
1881
+ {
1882
+ struct clk_alpha_pll * pll = to_clk_alpha_pll (hw );
1883
+ struct regmap * regmap = pll -> clkr .regmap ;
1884
+ u32 val ;
1885
+
1886
+ regmap_read (regmap , PLL_MODE (pll ), & val );
1887
+
1888
+ /* If in FSM mode, just unvote it */
1889
+ if (val & PLL_VOTE_FSM_ENA ) {
1890
+ clk_disable_regmap (hw );
1891
+ return ;
1892
+ }
1893
+
1894
+ /* Disable the global PLL output */
1895
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_OUTCTRL , 0 );
1896
+
1897
+ /* Disable the PLL outputs */
1898
+ regmap_update_bits (regmap , PLL_USER_CTL (pll ), ZONDA_PLL_OUT_MASK , 0 );
1899
+
1900
+ /* Put the PLL in bypass and reset */
1901
+ regmap_update_bits (regmap , PLL_MODE (pll ), PLL_RESET_N | PLL_BYPASSNL , 0 );
1902
+
1903
+ /* Place the PLL mode in OFF state */
1904
+ regmap_write (regmap , PLL_OPMODE (pll ), 0x0 );
1905
+ }
1906
+
1907
+ static int clk_zonda_pll_set_rate (struct clk_hw * hw , unsigned long rate ,
1908
+ unsigned long prate )
1909
+ {
1910
+ struct clk_alpha_pll * pll = to_clk_alpha_pll (hw );
1911
+ unsigned long rrate ;
1912
+ u32 test_ctl_val ;
1913
+ u32 l , alpha_width = pll_alpha_width (pll );
1914
+ u64 a ;
1915
+ int ret ;
1916
+
1917
+ rrate = alpha_pll_round_rate (rate , prate , & l , & a , alpha_width );
1918
+
1919
+ ret = alpha_pll_check_rate_margin (hw , rrate , rate );
1920
+ if (ret < 0 )
1921
+ return ret ;
1922
+
1923
+ regmap_write (pll -> clkr .regmap , PLL_ALPHA_VAL (pll ), a );
1924
+ regmap_write (pll -> clkr .regmap , PLL_L_VAL (pll ), l );
1925
+
1926
+ /* Wait before polling for the frequency latch */
1927
+ udelay (5 );
1928
+
1929
+ /* Read stay in cfa mode */
1930
+ regmap_read (pll -> clkr .regmap , PLL_TEST_CTL (pll ), & test_ctl_val );
1931
+
1932
+ /* If cfa mode then poll for freq lock */
1933
+ if (test_ctl_val & ZONDA_STAY_IN_CFA )
1934
+ ret = wait_for_zonda_pll_freq_lock (pll );
1935
+ else
1936
+ ret = wait_for_pll_enable_lock (pll );
1937
+ if (ret )
1938
+ return ret ;
1939
+
1940
+ /* Wait for PLL output to stabilize */
1941
+ udelay (100 );
1942
+ return 0 ;
1943
+ }
1944
+
1945
+ const struct clk_ops clk_alpha_pll_zonda_ops = {
1946
+ .enable = clk_zonda_pll_enable ,
1947
+ .disable = clk_zonda_pll_disable ,
1948
+ .is_enabled = clk_trion_pll_is_enabled ,
1949
+ .recalc_rate = clk_trion_pll_recalc_rate ,
1950
+ .round_rate = clk_alpha_pll_round_rate ,
1951
+ .set_rate = clk_zonda_pll_set_rate ,
1952
+ };
1953
+ EXPORT_SYMBOL (clk_alpha_pll_zonda_ops );
0 commit comments