Lines Matching full:dsi

25 /* DSI digital registers & bit definitions */
29 /* DSI wrapper registers & bit definitions */
32 #define WCFGR_DSIM BIT(0) /* DSI Mode */
36 #define WCR_DSIEN BIT(3) /* DSI ENable */
60 /* dsi color format coding according to the datasheet */
80 struct dw_mipi_dsi *dsi; member
87 static inline void dsi_write(struct dw_mipi_dsi_stm *dsi, u32 reg, u32 val) in dsi_write() argument
89 writel(val, dsi->base + reg); in dsi_write()
92 static inline u32 dsi_read(struct dw_mipi_dsi_stm *dsi, u32 reg) in dsi_read() argument
94 return readl(dsi->base + reg); in dsi_read()
97 static inline void dsi_set(struct dw_mipi_dsi_stm *dsi, u32 reg, u32 mask) in dsi_set() argument
99 dsi_write(dsi, reg, dsi_read(dsi, reg) | mask); in dsi_set()
102 static inline void dsi_clear(struct dw_mipi_dsi_stm *dsi, u32 reg, u32 mask) in dsi_clear() argument
104 dsi_write(dsi, reg, dsi_read(dsi, reg) & ~mask); in dsi_clear()
107 static inline void dsi_update_bits(struct dw_mipi_dsi_stm *dsi, u32 reg, in dsi_update_bits() argument
110 dsi_write(dsi, reg, (dsi_read(dsi, reg) & ~mask) | val); in dsi_update_bits()
141 static int dsi_pll_get_params(struct dw_mipi_dsi_stm *dsi, in dsi_pll_get_params() argument
152 fvco_min = dsi->lane_min_kbps * 2 * ODF_MAX; in dsi_pll_get_params()
153 fvco_max = dsi->lane_max_kbps * 2 * ODF_MIN; in dsi_pll_get_params()
199 struct dw_mipi_dsi_stm *dsi = priv_data; in dw_mipi_dsi_phy_init() local
204 dsi_set(dsi, DSI_WRPCR, WRPCR_REGEN | WRPCR_BGREN); in dw_mipi_dsi_phy_init()
205 ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_RRS, in dw_mipi_dsi_phy_init()
210 /* Enable the DSI PLL & wait for its lock */ in dw_mipi_dsi_phy_init()
211 dsi_set(dsi, DSI_WRPCR, WRPCR_PLLEN); in dw_mipi_dsi_phy_init()
212 ret = readl_poll_timeout(dsi->base + DSI_WISR, val, val & WISR_PLLLS, in dw_mipi_dsi_phy_init()
222 struct dw_mipi_dsi_stm *dsi = priv_data; in dw_mipi_dsi_phy_power_on() local
226 /* Enable the DSI wrapper */ in dw_mipi_dsi_phy_power_on()
227 dsi_set(dsi, DSI_WCR, WCR_DSIEN); in dw_mipi_dsi_phy_power_on()
232 struct dw_mipi_dsi_stm *dsi = priv_data; in dw_mipi_dsi_phy_power_off() local
236 /* Disable the DSI wrapper */ in dw_mipi_dsi_phy_power_off()
237 dsi_clear(dsi, DSI_WCR, WCR_DSIEN); in dw_mipi_dsi_phy_power_off()
245 struct dw_mipi_dsi_stm *dsi = priv_data; in dw_mipi_dsi_get_lane_mbps() local
251 dsi->lane_min_kbps = LANE_MIN_KBPS; in dw_mipi_dsi_get_lane_mbps()
252 dsi->lane_max_kbps = LANE_MAX_KBPS; in dw_mipi_dsi_get_lane_mbps()
253 if (dsi->hw_version == HWVER_131) { in dw_mipi_dsi_get_lane_mbps()
254 dsi->lane_min_kbps *= 2; in dw_mipi_dsi_get_lane_mbps()
255 dsi->lane_max_kbps *= 2; in dw_mipi_dsi_get_lane_mbps()
258 pll_in_khz = (unsigned int)(clk_get_rate(dsi->pllref_clk) / 1000); in dw_mipi_dsi_get_lane_mbps()
268 if (pll_out_khz > dsi->lane_max_kbps) { in dw_mipi_dsi_get_lane_mbps()
269 pll_out_khz = dsi->lane_max_kbps; in dw_mipi_dsi_get_lane_mbps()
272 if (pll_out_khz < dsi->lane_min_kbps) { in dw_mipi_dsi_get_lane_mbps()
273 pll_out_khz = dsi->lane_min_kbps; in dw_mipi_dsi_get_lane_mbps()
281 ret = dsi_pll_get_params(dsi, pll_in_khz, pll_out_khz, in dw_mipi_dsi_get_lane_mbps()
290 dsi_update_bits(dsi, DSI_WRPCR, WRPCR_NDIV | WRPCR_IDF | WRPCR_ODF, in dw_mipi_dsi_get_lane_mbps()
295 dsi_update_bits(dsi, DSI_WPCR0, WPCR0_UIX4, val); in dw_mipi_dsi_get_lane_mbps()
298 dsi_clear(dsi, DSI_WCFGR, WCFGR_DSIM); in dw_mipi_dsi_get_lane_mbps()
301 dsi_update_bits(dsi, DSI_WCFGR, WCFGR_COLMUX, in dw_mipi_dsi_get_lane_mbps()
338 { .compatible = "st,stm32-dsi", .data = &dw_mipi_dsi_stm_plat_data, },
346 struct dw_mipi_dsi_stm *dsi; in dw_mipi_dsi_stm_probe() local
351 dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); in dw_mipi_dsi_stm_probe()
352 if (!dsi) in dw_mipi_dsi_stm_probe()
356 dsi->base = devm_ioremap_resource(dev, res); in dw_mipi_dsi_stm_probe()
357 if (IS_ERR(dsi->base)) { in dw_mipi_dsi_stm_probe()
358 ret = PTR_ERR(dsi->base); in dw_mipi_dsi_stm_probe()
359 DRM_ERROR("Unable to get dsi registers %d\n", ret); in dw_mipi_dsi_stm_probe()
363 dsi->vdd_supply = devm_regulator_get(dev, "phy-dsi"); in dw_mipi_dsi_stm_probe()
364 if (IS_ERR(dsi->vdd_supply)) { in dw_mipi_dsi_stm_probe()
365 ret = PTR_ERR(dsi->vdd_supply); in dw_mipi_dsi_stm_probe()
371 ret = regulator_enable(dsi->vdd_supply); in dw_mipi_dsi_stm_probe()
377 dsi->pllref_clk = devm_clk_get(dev, "ref"); in dw_mipi_dsi_stm_probe()
378 if (IS_ERR(dsi->pllref_clk)) { in dw_mipi_dsi_stm_probe()
379 ret = PTR_ERR(dsi->pllref_clk); in dw_mipi_dsi_stm_probe()
386 ret = clk_prepare_enable(dsi->pllref_clk); in dw_mipi_dsi_stm_probe()
405 dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION; in dw_mipi_dsi_stm_probe()
408 if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) { in dw_mipi_dsi_stm_probe()
410 DRM_ERROR("bad dsi hardware version\n"); in dw_mipi_dsi_stm_probe()
414 dw_mipi_dsi_stm_plat_data.base = dsi->base; in dw_mipi_dsi_stm_probe()
415 dw_mipi_dsi_stm_plat_data.priv_data = dsi; in dw_mipi_dsi_stm_probe()
417 platform_set_drvdata(pdev, dsi); in dw_mipi_dsi_stm_probe()
419 dsi->dsi = dw_mipi_dsi_probe(pdev, &dw_mipi_dsi_stm_plat_data); in dw_mipi_dsi_stm_probe()
420 if (IS_ERR(dsi->dsi)) { in dw_mipi_dsi_stm_probe()
421 ret = PTR_ERR(dsi->dsi); in dw_mipi_dsi_stm_probe()
422 DRM_ERROR("Failed to initialize mipi dsi host: %d\n", ret); in dw_mipi_dsi_stm_probe()
429 clk_disable_unprepare(dsi->pllref_clk); in dw_mipi_dsi_stm_probe()
431 regulator_disable(dsi->vdd_supply); in dw_mipi_dsi_stm_probe()
438 struct dw_mipi_dsi_stm *dsi = platform_get_drvdata(pdev); in dw_mipi_dsi_stm_remove() local
440 dw_mipi_dsi_remove(dsi->dsi); in dw_mipi_dsi_stm_remove()
441 clk_disable_unprepare(dsi->pllref_clk); in dw_mipi_dsi_stm_remove()
442 regulator_disable(dsi->vdd_supply); in dw_mipi_dsi_stm_remove()
449 struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data; in dw_mipi_dsi_stm_suspend() local
453 clk_disable_unprepare(dsi->pllref_clk); in dw_mipi_dsi_stm_suspend()
454 regulator_disable(dsi->vdd_supply); in dw_mipi_dsi_stm_suspend()
461 struct dw_mipi_dsi_stm *dsi = dw_mipi_dsi_stm_plat_data.priv_data; in dw_mipi_dsi_stm_resume() local
466 ret = regulator_enable(dsi->vdd_supply); in dw_mipi_dsi_stm_resume()
472 ret = clk_prepare_enable(dsi->pllref_clk); in dw_mipi_dsi_stm_resume()
474 regulator_disable(dsi->vdd_supply); in dw_mipi_dsi_stm_resume()
492 .name = "stm32-display-dsi",
501 MODULE_DESCRIPTION("STMicroelectronics DW MIPI DSI host controller driver");