Lines Matching full:mdp

57 static void mtk_disp_pwm_update_bits(struct mtk_disp_pwm *mdp, u32 offset,  in mtk_disp_pwm_update_bits()  argument
60 void __iomem *address = mdp->base + offset; in mtk_disp_pwm_update_bits()
72 struct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip); in mtk_disp_pwm_apply() local
80 if (!state->enabled && mdp->enabled) { in mtk_disp_pwm_apply()
81 mtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, in mtk_disp_pwm_apply()
82 mdp->data->enable_mask, 0x0); in mtk_disp_pwm_apply()
83 clk_disable_unprepare(mdp->clk_mm); in mtk_disp_pwm_apply()
84 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_apply()
86 mdp->enabled = false; in mtk_disp_pwm_apply()
90 if (!mdp->enabled) { in mtk_disp_pwm_apply()
91 err = clk_prepare_enable(mdp->clk_main); in mtk_disp_pwm_apply()
93 dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_main: %pe\n", in mtk_disp_pwm_apply()
98 err = clk_prepare_enable(mdp->clk_mm); in mtk_disp_pwm_apply()
100 dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_mm: %pe\n", in mtk_disp_pwm_apply()
102 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_apply()
117 rate = clk_get_rate(mdp->clk_main); in mtk_disp_pwm_apply()
121 if (!mdp->enabled) { in mtk_disp_pwm_apply()
122 clk_disable_unprepare(mdp->clk_mm); in mtk_disp_pwm_apply()
123 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_apply()
136 if (mdp->data->bls_debug && !mdp->data->has_commit) { in mtk_disp_pwm_apply()
141 mtk_disp_pwm_update_bits(mdp, mdp->data->bls_debug, in mtk_disp_pwm_apply()
142 mdp->data->bls_debug_mask, in mtk_disp_pwm_apply()
143 mdp->data->bls_debug_mask); in mtk_disp_pwm_apply()
144 mtk_disp_pwm_update_bits(mdp, mdp->data->con0, in mtk_disp_pwm_apply()
145 mdp->data->con0_sel, in mtk_disp_pwm_apply()
146 mdp->data->con0_sel); in mtk_disp_pwm_apply()
149 mtk_disp_pwm_update_bits(mdp, mdp->data->con0, in mtk_disp_pwm_apply()
152 mtk_disp_pwm_update_bits(mdp, mdp->data->con1, in mtk_disp_pwm_apply()
156 if (mdp->data->has_commit) { in mtk_disp_pwm_apply()
157 mtk_disp_pwm_update_bits(mdp, mdp->data->commit, in mtk_disp_pwm_apply()
158 mdp->data->commit_mask, in mtk_disp_pwm_apply()
159 mdp->data->commit_mask); in mtk_disp_pwm_apply()
160 mtk_disp_pwm_update_bits(mdp, mdp->data->commit, in mtk_disp_pwm_apply()
161 mdp->data->commit_mask, in mtk_disp_pwm_apply()
165 mtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, mdp->data->enable_mask, in mtk_disp_pwm_apply()
166 mdp->data->enable_mask); in mtk_disp_pwm_apply()
167 mdp->enabled = true; in mtk_disp_pwm_apply()
176 struct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip); in mtk_disp_pwm_get_state() local
181 err = clk_prepare_enable(mdp->clk_main); in mtk_disp_pwm_get_state()
183 dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_main: %pe\n", ERR_PTR(err)); in mtk_disp_pwm_get_state()
187 err = clk_prepare_enable(mdp->clk_mm); in mtk_disp_pwm_get_state()
189 dev_err(pwmchip_parent(chip), "Can't enable mdp->clk_mm: %pe\n", ERR_PTR(err)); in mtk_disp_pwm_get_state()
190 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_get_state()
199 if (mdp->data->bls_debug) in mtk_disp_pwm_get_state()
200 mtk_disp_pwm_update_bits(mdp, mdp->data->bls_debug, in mtk_disp_pwm_get_state()
201 mdp->data->bls_debug_mask, in mtk_disp_pwm_get_state()
202 mdp->data->bls_debug_mask); in mtk_disp_pwm_get_state()
204 rate = clk_get_rate(mdp->clk_main); in mtk_disp_pwm_get_state()
205 con0 = readl(mdp->base + mdp->data->con0); in mtk_disp_pwm_get_state()
206 con1 = readl(mdp->base + mdp->data->con1); in mtk_disp_pwm_get_state()
207 pwm_en = readl(mdp->base + DISP_PWM_EN); in mtk_disp_pwm_get_state()
208 state->enabled = !!(pwm_en & mdp->data->enable_mask); in mtk_disp_pwm_get_state()
220 clk_disable_unprepare(mdp->clk_mm); in mtk_disp_pwm_get_state()
221 clk_disable_unprepare(mdp->clk_main); in mtk_disp_pwm_get_state()
234 struct mtk_disp_pwm *mdp; in mtk_disp_pwm_probe() local
237 chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*mdp)); in mtk_disp_pwm_probe()
240 mdp = to_mtk_disp_pwm(chip); in mtk_disp_pwm_probe()
242 mdp->data = of_device_get_match_data(&pdev->dev); in mtk_disp_pwm_probe()
244 mdp->base = devm_platform_ioremap_resource(pdev, 0); in mtk_disp_pwm_probe()
245 if (IS_ERR(mdp->base)) in mtk_disp_pwm_probe()
246 return PTR_ERR(mdp->base); in mtk_disp_pwm_probe()
248 mdp->clk_main = devm_clk_get(&pdev->dev, "main"); in mtk_disp_pwm_probe()
249 if (IS_ERR(mdp->clk_main)) in mtk_disp_pwm_probe()
250 return dev_err_probe(&pdev->dev, PTR_ERR(mdp->clk_main), in mtk_disp_pwm_probe()
253 mdp->clk_mm = devm_clk_get(&pdev->dev, "mm"); in mtk_disp_pwm_probe()
254 if (IS_ERR(mdp->clk_mm)) in mtk_disp_pwm_probe()
255 return dev_err_probe(&pdev->dev, PTR_ERR(mdp->clk_mm), in mtk_disp_pwm_probe()