Lines Matching +full:cec +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0-only
6 #include <linux/clk.h>
54 struct clk *clk; member
62 static void mtk_cec_clear_bits(struct mtk_cec *cec, unsigned int offset, in mtk_cec_clear_bits() argument
65 void __iomem *reg = cec->regs + offset; in mtk_cec_clear_bits()
73 static void mtk_cec_set_bits(struct mtk_cec *cec, unsigned int offset, in mtk_cec_set_bits() argument
76 void __iomem *reg = cec->regs + offset; in mtk_cec_set_bits()
84 static void mtk_cec_mask(struct mtk_cec *cec, unsigned int offset, in mtk_cec_mask() argument
87 u32 tmp = readl(cec->regs + offset) & ~mask; in mtk_cec_mask()
90 writel(tmp, cec->regs + offset); in mtk_cec_mask()
97 struct mtk_cec *cec = dev_get_drvdata(dev); in mtk_cec_set_hpd_event() local
100 spin_lock_irqsave(&cec->lock, flags); in mtk_cec_set_hpd_event()
101 cec->hdmi_dev = hdmi_dev; in mtk_cec_set_hpd_event()
102 cec->hpd_event = hpd_event; in mtk_cec_set_hpd_event()
103 spin_unlock_irqrestore(&cec->lock, flags); in mtk_cec_set_hpd_event()
108 struct mtk_cec *cec = dev_get_drvdata(dev); in mtk_cec_hpd_high() local
111 status = readl(cec->regs + RX_EVENT); in mtk_cec_hpd_high()
116 static void mtk_cec_htplg_irq_init(struct mtk_cec *cec) in mtk_cec_htplg_irq_init() argument
118 mtk_cec_mask(cec, CEC_CKGEN, 0 | CEC_32K_PDN, PDN | CEC_32K_PDN); in mtk_cec_htplg_irq_init()
119 mtk_cec_set_bits(cec, RX_GEN_WD, HDMI_PORD_INT_32K_CLR | in mtk_cec_htplg_irq_init()
121 mtk_cec_mask(cec, RX_GEN_WD, 0, HDMI_PORD_INT_32K_CLR | RX_INT_32K_CLR | in mtk_cec_htplg_irq_init()
126 static void mtk_cec_htplg_irq_enable(struct mtk_cec *cec) in mtk_cec_htplg_irq_enable() argument
128 mtk_cec_set_bits(cec, RX_EVENT, HDMI_PORD_INT_EN | HDMI_HTPLG_INT_EN); in mtk_cec_htplg_irq_enable()
131 static void mtk_cec_htplg_irq_disable(struct mtk_cec *cec) in mtk_cec_htplg_irq_disable() argument
133 mtk_cec_clear_bits(cec, RX_EVENT, HDMI_PORD_INT_EN | HDMI_HTPLG_INT_EN); in mtk_cec_htplg_irq_disable()
136 static void mtk_cec_clear_htplg_irq(struct mtk_cec *cec) in mtk_cec_clear_htplg_irq() argument
138 mtk_cec_set_bits(cec, TR_CONFIG, CLEAR_CEC_IRQ); in mtk_cec_clear_htplg_irq()
139 mtk_cec_set_bits(cec, NORMAL_INT_CTRL, HDMI_HTPLG_INT_CLR | in mtk_cec_clear_htplg_irq()
141 mtk_cec_set_bits(cec, RX_GEN_WD, HDMI_PORD_INT_32K_CLR | in mtk_cec_clear_htplg_irq()
144 mtk_cec_clear_bits(cec, NORMAL_INT_CTRL, HDMI_HTPLG_INT_CLR | in mtk_cec_clear_htplg_irq()
146 mtk_cec_clear_bits(cec, TR_CONFIG, CLEAR_CEC_IRQ); in mtk_cec_clear_htplg_irq()
147 mtk_cec_clear_bits(cec, RX_GEN_WD, HDMI_PORD_INT_32K_CLR | in mtk_cec_clear_htplg_irq()
151 static void mtk_cec_hpd_event(struct mtk_cec *cec, bool hpd) in mtk_cec_hpd_event() argument
157 spin_lock_irqsave(&cec->lock, flags); in mtk_cec_hpd_event()
158 hpd_event = cec->hpd_event; in mtk_cec_hpd_event()
159 hdmi_dev = cec->hdmi_dev; in mtk_cec_hpd_event()
160 spin_unlock_irqrestore(&cec->lock, flags); in mtk_cec_hpd_event()
169 struct mtk_cec *cec = dev_get_drvdata(dev); in mtk_cec_htplg_isr_thread() local
172 mtk_cec_clear_htplg_irq(cec); in mtk_cec_htplg_isr_thread()
175 if (cec->hpd != hpd) { in mtk_cec_htplg_isr_thread()
177 cec->hpd, hpd); in mtk_cec_htplg_isr_thread()
178 cec->hpd = hpd; in mtk_cec_htplg_isr_thread()
179 mtk_cec_hpd_event(cec, hpd); in mtk_cec_htplg_isr_thread()
186 struct device *dev = &pdev->dev; in mtk_cec_probe()
187 struct mtk_cec *cec; in mtk_cec_probe() local
190 cec = devm_kzalloc(dev, sizeof(*cec), GFP_KERNEL); in mtk_cec_probe()
191 if (!cec) in mtk_cec_probe()
192 return -ENOMEM; in mtk_cec_probe()
194 platform_set_drvdata(pdev, cec); in mtk_cec_probe()
195 spin_lock_init(&cec->lock); in mtk_cec_probe()
197 cec->regs = devm_platform_ioremap_resource(pdev, 0); in mtk_cec_probe()
198 if (IS_ERR(cec->regs)) in mtk_cec_probe()
199 return dev_err_probe(dev, PTR_ERR(cec->regs), in mtk_cec_probe()
200 "Failed to ioremap cec\n"); in mtk_cec_probe()
202 cec->clk = devm_clk_get(dev, NULL); in mtk_cec_probe()
203 if (IS_ERR(cec->clk)) in mtk_cec_probe()
204 return dev_err_probe(dev, PTR_ERR(cec->clk), in mtk_cec_probe()
205 "Failed to get cec clock\n"); in mtk_cec_probe()
207 cec->irq = platform_get_irq(pdev, 0); in mtk_cec_probe()
208 if (cec->irq < 0) in mtk_cec_probe()
209 return cec->irq; in mtk_cec_probe()
211 ret = devm_request_threaded_irq(dev, cec->irq, NULL, in mtk_cec_probe()
216 return dev_err_probe(dev, ret, "Failed to register cec irq\n"); in mtk_cec_probe()
218 ret = clk_prepare_enable(cec->clk); in mtk_cec_probe()
220 return dev_err_probe(dev, ret, "Failed to enable cec clock\n"); in mtk_cec_probe()
222 mtk_cec_htplg_irq_init(cec); in mtk_cec_probe()
223 mtk_cec_htplg_irq_enable(cec); in mtk_cec_probe()
230 struct mtk_cec *cec = platform_get_drvdata(pdev); in mtk_cec_remove() local
232 mtk_cec_htplg_irq_disable(cec); in mtk_cec_remove()
233 clk_disable_unprepare(cec->clk); in mtk_cec_remove()
237 { .compatible = "mediatek,mt8173-cec", },
246 .name = "mediatek-cec",