aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2/dss/dsi.c
diff options
context:
space:
mode:
authorTaneja, Archit <archit@ti.com>2011-03-15 00:28:23 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2011-03-15 03:05:38 -0400
commit49641116392ad7522fa0efad53f7ed63f811bd88 (patch)
tree37dec1e9a08d22235e1c53e79387173b342ae860 /drivers/video/omap2/dss/dsi.c
parent31ef82377f1e0f1bc7d308ae4312e6cc5a431885 (diff)
OMAP: DSS2: FEATURES: DSI PLL parameter cleanup
The DSI PLL parameters (regm, regn, regm_dispc, regm_dsi, fint) have different fields and also different Max values on OMAP3 and OMAP4. Use dss features to calculate the register fields and min/max values based on current OMAP revision. Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video/omap2/dss/dsi.c')
-rw-r--r--drivers/video/omap2/dss/dsi.c69
1 files changed, 46 insertions, 23 deletions
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 6e7f46828148..7a4b4404a976 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -185,14 +185,6 @@ struct dsi_reg { u16 idx; };
185#define DSI_DT_RX_SHORT_READ_1 0x21 185#define DSI_DT_RX_SHORT_READ_1 0x21
186#define DSI_DT_RX_SHORT_READ_2 0x22 186#define DSI_DT_RX_SHORT_READ_2 0x22
187 187
188#define FINT_MAX 2100000
189#define FINT_MIN 750000
190#define REGN_MAX (1 << 7)
191#define REGM_MAX ((1 << 11) - 1)
192#define REGM_DISPC_MAX (1 << 4)
193#define REGM_DSI_MAX (1 << 4)
194#define LP_DIV_MAX ((1 << 13) - 1)
195
196enum fifo_size { 188enum fifo_size {
197 DSI_FIFO_SIZE_0 = 0, 189 DSI_FIFO_SIZE_0 = 0,
198 DSI_FIFO_SIZE_32 = 1, 190 DSI_FIFO_SIZE_32 = 1,
@@ -277,6 +269,11 @@ static struct
277 spinlock_t irq_stats_lock; 269 spinlock_t irq_stats_lock;
278 struct dsi_irq_stats irq_stats; 270 struct dsi_irq_stats irq_stats;
279#endif 271#endif
272 /* DSI PLL Parameter Ranges */
273 unsigned long regm_max, regn_max;
274 unsigned long regm_dispc_max, regm_dsi_max;
275 unsigned long fint_min, fint_max;
276 unsigned long lpdiv_max;
280} dsi; 277} dsi;
281 278
282#ifdef DEBUG 279#ifdef DEBUG
@@ -751,7 +748,7 @@ static int dsi_set_lp_clk_divisor(struct omap_dss_device *dssdev)
751 748
752 lp_clk_div = dssdev->phy.dsi.div.lp_clk_div; 749 lp_clk_div = dssdev->phy.dsi.div.lp_clk_div;
753 750
754 if (lp_clk_div == 0 || lp_clk_div > LP_DIV_MAX) 751 if (lp_clk_div == 0 || lp_clk_div > dsi.lpdiv_max)
755 return -EINVAL; 752 return -EINVAL;
756 753
757 dsi_fclk = dsi_fclk_rate(); 754 dsi_fclk = dsi_fclk_rate();
@@ -801,16 +798,16 @@ static int dsi_pll_power(enum dsi_pll_power_state state)
801static int dsi_calc_clock_rates(struct omap_dss_device *dssdev, 798static int dsi_calc_clock_rates(struct omap_dss_device *dssdev,
802 struct dsi_clock_info *cinfo) 799 struct dsi_clock_info *cinfo)
803{ 800{
804 if (cinfo->regn == 0 || cinfo->regn > REGN_MAX) 801 if (cinfo->regn == 0 || cinfo->regn > dsi.regn_max)
805 return -EINVAL; 802 return -EINVAL;
806 803
807 if (cinfo->regm == 0 || cinfo->regm > REGM_MAX) 804 if (cinfo->regm == 0 || cinfo->regm > dsi.regm_max)
808 return -EINVAL; 805 return -EINVAL;
809 806
810 if (cinfo->regm_dispc > REGM_DISPC_MAX) 807 if (cinfo->regm_dispc > dsi.regm_dispc_max)
811 return -EINVAL; 808 return -EINVAL;
812 809
813 if (cinfo->regm_dsi > REGM_DSI_MAX) 810 if (cinfo->regm_dsi > dsi.regm_dsi_max)
814 return -EINVAL; 811 return -EINVAL;
815 812
816 if (cinfo->use_sys_clk) { 813 if (cinfo->use_sys_clk) {
@@ -829,7 +826,7 @@ static int dsi_calc_clock_rates(struct omap_dss_device *dssdev,
829 826
830 cinfo->fint = cinfo->clkin / (cinfo->regn * (cinfo->highfreq ? 2 : 1)); 827 cinfo->fint = cinfo->clkin / (cinfo->regn * (cinfo->highfreq ? 2 : 1));
831 828
832 if (cinfo->fint > FINT_MAX || cinfo->fint < FINT_MIN) 829 if (cinfo->fint > dsi.fint_max || cinfo->fint < dsi.fint_min)
833 return -EINVAL; 830 return -EINVAL;
834 831
835 cinfo->clkin4ddr = 2 * cinfo->regm * cinfo->fint; 832 cinfo->clkin4ddr = 2 * cinfo->regm * cinfo->fint;
@@ -899,17 +896,17 @@ retry:
899 /* no highfreq: 0.75MHz < Fint = clkin / regn < 2.1MHz */ 896 /* no highfreq: 0.75MHz < Fint = clkin / regn < 2.1MHz */
900 /* highfreq: 0.75MHz < Fint = clkin / (2*regn) < 2.1MHz */ 897 /* highfreq: 0.75MHz < Fint = clkin / (2*regn) < 2.1MHz */
901 /* To reduce PLL lock time, keep Fint high (around 2 MHz) */ 898 /* To reduce PLL lock time, keep Fint high (around 2 MHz) */
902 for (cur.regn = 1; cur.regn < REGN_MAX; ++cur.regn) { 899 for (cur.regn = 1; cur.regn < dsi.regn_max; ++cur.regn) {
903 if (cur.highfreq == 0) 900 if (cur.highfreq == 0)
904 cur.fint = cur.clkin / cur.regn; 901 cur.fint = cur.clkin / cur.regn;
905 else 902 else
906 cur.fint = cur.clkin / (2 * cur.regn); 903 cur.fint = cur.clkin / (2 * cur.regn);
907 904
908 if (cur.fint > FINT_MAX || cur.fint < FINT_MIN) 905 if (cur.fint > dsi.fint_max || cur.fint < dsi.fint_min)
909 continue; 906 continue;
910 907
911 /* DSIPHY(MHz) = (2 * regm / regn) * (clkin / (highfreq + 1)) */ 908 /* DSIPHY(MHz) = (2 * regm / regn) * (clkin / (highfreq + 1)) */
912 for (cur.regm = 1; cur.regm < REGM_MAX; ++cur.regm) { 909 for (cur.regm = 1; cur.regm < dsi.regm_max; ++cur.regm) {
913 unsigned long a, b; 910 unsigned long a, b;
914 911
915 a = 2 * cur.regm * (cur.clkin/1000); 912 a = 2 * cur.regm * (cur.clkin/1000);
@@ -921,7 +918,7 @@ retry:
921 918
922 /* dsi_pll_hsdiv_dispc_clk(MHz) = 919 /* dsi_pll_hsdiv_dispc_clk(MHz) =
923 * DSIPHY(MHz) / regm_dispc < 173MHz/186Mhz */ 920 * DSIPHY(MHz) / regm_dispc < 173MHz/186Mhz */
924 for (cur.regm_dispc = 1; cur.regm_dispc < REGM_DISPC_MAX; 921 for (cur.regm_dispc = 1; cur.regm_dispc < dsi.regm_dispc_max;
925 ++cur.regm_dispc) { 922 ++cur.regm_dispc) {
926 struct dispc_clock_info cur_dispc; 923 struct dispc_clock_info cur_dispc;
927 cur.dsi_pll_hsdiv_dispc_clk = 924 cur.dsi_pll_hsdiv_dispc_clk =
@@ -994,6 +991,8 @@ int dsi_pll_set_clock_div(struct dsi_clock_info *cinfo)
994 int r = 0; 991 int r = 0;
995 u32 l; 992 u32 l;
996 int f; 993 int f;
994 u8 regn_start, regn_end, regm_start, regm_end;
995 u8 regm_dispc_start, regm_dispc_end, regm_dsi_start, regm_dsi_end;
997 996
998 DSSDBGF(); 997 DSSDBGF();
999 998
@@ -1038,19 +1037,30 @@ int dsi_pll_set_clock_div(struct dsi_clock_info *cinfo)
1038 dss_feat_get_clk_source_name(DSS_CLK_SRC_DSI_PLL_HSDIV_DSI), 1037 dss_feat_get_clk_source_name(DSS_CLK_SRC_DSI_PLL_HSDIV_DSI),
1039 cinfo->dsi_pll_hsdiv_dsi_clk); 1038 cinfo->dsi_pll_hsdiv_dsi_clk);
1040 1039
1040 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGN, &regn_start, &regn_end);
1041 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM, &regm_start, &regm_end);
1042 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DISPC, &regm_dispc_start,
1043 &regm_dispc_end);
1044 dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DSI, &regm_dsi_start,
1045 &regm_dsi_end);
1046
1041 REG_FLD_MOD(DSI_PLL_CONTROL, 0, 0, 0); /* DSI_PLL_AUTOMODE = manual */ 1047 REG_FLD_MOD(DSI_PLL_CONTROL, 0, 0, 0); /* DSI_PLL_AUTOMODE = manual */
1042 1048
1043 l = dsi_read_reg(DSI_PLL_CONFIGURATION1); 1049 l = dsi_read_reg(DSI_PLL_CONFIGURATION1);
1044 l = FLD_MOD(l, 1, 0, 0); /* DSI_PLL_STOPMODE */ 1050 l = FLD_MOD(l, 1, 0, 0); /* DSI_PLL_STOPMODE */
1045 l = FLD_MOD(l, cinfo->regn - 1, 7, 1); /* DSI_PLL_REGN */ 1051 /* DSI_PLL_REGN */
1046 l = FLD_MOD(l, cinfo->regm, 18, 8); /* DSI_PLL_REGM */ 1052 l = FLD_MOD(l, cinfo->regn - 1, regn_start, regn_end);
1053 /* DSI_PLL_REGM */
1054 l = FLD_MOD(l, cinfo->regm, regm_start, regm_end);
1055 /* DSI_CLOCK_DIV */
1047 l = FLD_MOD(l, cinfo->regm_dispc > 0 ? cinfo->regm_dispc - 1 : 0, 1056 l = FLD_MOD(l, cinfo->regm_dispc > 0 ? cinfo->regm_dispc - 1 : 0,
1048 22, 19); /* DSI_CLOCK_DIV */ 1057 regm_dispc_start, regm_dispc_end);
1058 /* DSIPROTO_CLOCK_DIV */
1049 l = FLD_MOD(l, cinfo->regm_dsi > 0 ? cinfo->regm_dsi - 1 : 0, 1059 l = FLD_MOD(l, cinfo->regm_dsi > 0 ? cinfo->regm_dsi - 1 : 0,
1050 26, 23); /* DSIPROTO_CLOCK_DIV */ 1060 regm_dsi_start, regm_dsi_end);
1051 dsi_write_reg(DSI_PLL_CONFIGURATION1, l); 1061 dsi_write_reg(DSI_PLL_CONFIGURATION1, l);
1052 1062
1053 BUG_ON(cinfo->fint < 750000 || cinfo->fint > 2100000); 1063 BUG_ON(cinfo->fint < dsi.fint_min || cinfo->fint > dsi.fint_max);
1054 if (cinfo->fint < 1000000) 1064 if (cinfo->fint < 1000000)
1055 f = 0x3; 1065 f = 0x3;
1056 else if (cinfo->fint < 1250000) 1066 else if (cinfo->fint < 1250000)
@@ -3333,6 +3343,17 @@ void dsi_wait_pll_hsdiv_dsi_active(void)
3333 dss_feat_get_clk_source_name(DSS_CLK_SRC_DSI_PLL_HSDIV_DSI)); 3343 dss_feat_get_clk_source_name(DSS_CLK_SRC_DSI_PLL_HSDIV_DSI));
3334} 3344}
3335 3345
3346static void dsi_calc_clock_param_ranges(void)
3347{
3348 dsi.regn_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGN);
3349 dsi.regm_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM);
3350 dsi.regm_dispc_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DISPC);
3351 dsi.regm_dsi_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DSI);
3352 dsi.fint_min = dss_feat_get_param_min(FEAT_PARAM_DSIPLL_FINT);
3353 dsi.fint_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_FINT);
3354 dsi.lpdiv_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_LPDIV);
3355}
3356
3336static int dsi_init(struct platform_device *pdev) 3357static int dsi_init(struct platform_device *pdev)
3337{ 3358{
3338 u32 rev; 3359 u32 rev;
@@ -3397,6 +3418,8 @@ static int dsi_init(struct platform_device *pdev)
3397 dsi.vc[i].vc_id = 0; 3418 dsi.vc[i].vc_id = 0;
3398 } 3419 }
3399 3420
3421 dsi_calc_clock_param_ranges();
3422
3400 enable_clocks(1); 3423 enable_clocks(1);
3401 3424
3402 rev = dsi_read_reg(DSI_REVISION); 3425 rev = dsi_read_reg(DSI_REVISION);