Lines Matching refs:mdp
59 static void mtk_disp_pwm_update_bits(struct mtk_disp_pwm *mdp, u32 offset, in mtk_disp_pwm_update_bits() argument
62 void __iomem *address = mdp->base + offset; in mtk_disp_pwm_update_bits()
74 struct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip); in mtk_disp_pwm_apply() local
83 mtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, mdp->data->enable_mask, in mtk_disp_pwm_apply()
86 if (mdp->enabled) { in mtk_disp_pwm_apply()
87 clk_disable_unprepare(mdp->clk_mm); in mtk_disp_pwm_apply()
88 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_apply()
91 mdp->enabled = false; in mtk_disp_pwm_apply()
95 if (!mdp->enabled) { in mtk_disp_pwm_apply()
96 err = clk_prepare_enable(mdp->clk_main); in mtk_disp_pwm_apply()
103 err = clk_prepare_enable(mdp->clk_mm); in mtk_disp_pwm_apply()
107 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_apply()
122 rate = clk_get_rate(mdp->clk_main); in mtk_disp_pwm_apply()
126 if (!mdp->enabled) { in mtk_disp_pwm_apply()
127 clk_disable_unprepare(mdp->clk_mm); in mtk_disp_pwm_apply()
128 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_apply()
141 mtk_disp_pwm_update_bits(mdp, mdp->data->con0, in mtk_disp_pwm_apply()
144 mtk_disp_pwm_update_bits(mdp, mdp->data->con1, in mtk_disp_pwm_apply()
148 if (mdp->data->has_commit) { in mtk_disp_pwm_apply()
149 mtk_disp_pwm_update_bits(mdp, mdp->data->commit, in mtk_disp_pwm_apply()
150 mdp->data->commit_mask, in mtk_disp_pwm_apply()
151 mdp->data->commit_mask); in mtk_disp_pwm_apply()
152 mtk_disp_pwm_update_bits(mdp, mdp->data->commit, in mtk_disp_pwm_apply()
153 mdp->data->commit_mask, in mtk_disp_pwm_apply()
160 mtk_disp_pwm_update_bits(mdp, mdp->data->bls_debug, in mtk_disp_pwm_apply()
161 mdp->data->bls_debug_mask, in mtk_disp_pwm_apply()
162 mdp->data->bls_debug_mask); in mtk_disp_pwm_apply()
163 mtk_disp_pwm_update_bits(mdp, mdp->data->con0, in mtk_disp_pwm_apply()
164 mdp->data->con0_sel, in mtk_disp_pwm_apply()
165 mdp->data->con0_sel); in mtk_disp_pwm_apply()
168 mtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, mdp->data->enable_mask, in mtk_disp_pwm_apply()
169 mdp->data->enable_mask); in mtk_disp_pwm_apply()
170 mdp->enabled = true; in mtk_disp_pwm_apply()
179 struct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip); in mtk_disp_pwm_get_state() local
184 err = clk_prepare_enable(mdp->clk_main); in mtk_disp_pwm_get_state()
190 err = clk_prepare_enable(mdp->clk_mm); in mtk_disp_pwm_get_state()
193 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_get_state()
197 rate = clk_get_rate(mdp->clk_main); in mtk_disp_pwm_get_state()
198 con0 = readl(mdp->base + mdp->data->con0); in mtk_disp_pwm_get_state()
199 con1 = readl(mdp->base + mdp->data->con1); in mtk_disp_pwm_get_state()
200 pwm_en = readl(mdp->base + DISP_PWM_EN); in mtk_disp_pwm_get_state()
201 state->enabled = !!(pwm_en & mdp->data->enable_mask); in mtk_disp_pwm_get_state()
213 clk_disable_unprepare(mdp->clk_mm); in mtk_disp_pwm_get_state()
214 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_get_state()
227 struct mtk_disp_pwm *mdp; in mtk_disp_pwm_probe() local
230 mdp = devm_kzalloc(&pdev->dev, sizeof(*mdp), GFP_KERNEL); in mtk_disp_pwm_probe()
231 if (!mdp) in mtk_disp_pwm_probe()
234 mdp->data = of_device_get_match_data(&pdev->dev); in mtk_disp_pwm_probe()
236 mdp->base = devm_platform_ioremap_resource(pdev, 0); in mtk_disp_pwm_probe()
237 if (IS_ERR(mdp->base)) in mtk_disp_pwm_probe()
238 return PTR_ERR(mdp->base); in mtk_disp_pwm_probe()
240 mdp->clk_main = devm_clk_get(&pdev->dev, "main"); in mtk_disp_pwm_probe()
241 if (IS_ERR(mdp->clk_main)) in mtk_disp_pwm_probe()
242 return PTR_ERR(mdp->clk_main); in mtk_disp_pwm_probe()
244 mdp->clk_mm = devm_clk_get(&pdev->dev, "mm"); in mtk_disp_pwm_probe()
245 if (IS_ERR(mdp->clk_mm)) in mtk_disp_pwm_probe()
246 return PTR_ERR(mdp->clk_mm); in mtk_disp_pwm_probe()
248 mdp->chip.dev = &pdev->dev; in mtk_disp_pwm_probe()
249 mdp->chip.ops = &mtk_disp_pwm_ops; in mtk_disp_pwm_probe()
250 mdp->chip.npwm = 1; in mtk_disp_pwm_probe()
252 ret = pwmchip_add(&mdp->chip); in mtk_disp_pwm_probe()
258 platform_set_drvdata(pdev, mdp); in mtk_disp_pwm_probe()
265 struct mtk_disp_pwm *mdp = platform_get_drvdata(pdev); in mtk_disp_pwm_remove() local
267 pwmchip_remove(&mdp->chip); in mtk_disp_pwm_remove()