• Home
  • Raw
  • Download

Lines Matching full:cec

3  * STM32 CEC driver
17 #include <media/cec.h>
19 #define CEC_NAME "stm32-cec"
21 /* CEC registers */
73 static void cec_hw_init(struct stm32_cec *cec) in cec_hw_init() argument
75 regmap_update_bits(cec->regmap, CEC_CR, TXEOM | TXSOM | CECEN, 0); in cec_hw_init()
77 regmap_update_bits(cec->regmap, CEC_IER, ALL_TX_IT | ALL_RX_IT, in cec_hw_init()
80 regmap_update_bits(cec->regmap, CEC_CFGR, FULL_CFG, FULL_CFG); in cec_hw_init()
83 static void stm32_tx_done(struct stm32_cec *cec, u32 status) in stm32_tx_done() argument
86 cec_transmit_done(cec->adap, CEC_TX_STATUS_ERROR, in stm32_tx_done()
92 cec_transmit_done(cec->adap, CEC_TX_STATUS_ARB_LOST, in stm32_tx_done()
98 cec_transmit_done(cec->adap, CEC_TX_STATUS_NACK, in stm32_tx_done()
103 if (cec->irq_status & TXBR) { in stm32_tx_done()
105 if (cec->tx_cnt < cec->tx_msg.len) in stm32_tx_done()
106 regmap_write(cec->regmap, CEC_TXDR, in stm32_tx_done()
107 cec->tx_msg.msg[cec->tx_cnt++]); in stm32_tx_done()
110 if (cec->tx_cnt == cec->tx_msg.len) in stm32_tx_done()
111 regmap_update_bits(cec->regmap, CEC_CR, TXEOM, TXEOM); in stm32_tx_done()
114 if (cec->irq_status & TXEND) in stm32_tx_done()
115 cec_transmit_done(cec->adap, CEC_TX_STATUS_OK, 0, 0, 0, 0); in stm32_tx_done()
118 static void stm32_rx_done(struct stm32_cec *cec, u32 status) in stm32_rx_done() argument
120 if (cec->irq_status & (RXACKE | RXOVR)) { in stm32_rx_done()
121 cec->rx_msg.len = 0; in stm32_rx_done()
125 if (cec->irq_status & RXBR) { in stm32_rx_done()
128 regmap_read(cec->regmap, CEC_RXDR, &val); in stm32_rx_done()
129 cec->rx_msg.msg[cec->rx_msg.len++] = val & 0xFF; in stm32_rx_done()
132 if (cec->irq_status & RXEND) { in stm32_rx_done()
133 cec_received_msg(cec->adap, &cec->rx_msg); in stm32_rx_done()
134 cec->rx_msg.len = 0; in stm32_rx_done()
140 struct stm32_cec *cec = arg; in stm32_cec_irq_thread() local
142 if (cec->irq_status & ALL_TX_IT) in stm32_cec_irq_thread()
143 stm32_tx_done(cec, cec->irq_status); in stm32_cec_irq_thread()
145 if (cec->irq_status & ALL_RX_IT) in stm32_cec_irq_thread()
146 stm32_rx_done(cec, cec->irq_status); in stm32_cec_irq_thread()
148 cec->irq_status = 0; in stm32_cec_irq_thread()
155 struct stm32_cec *cec = arg; in stm32_cec_irq_handler() local
157 regmap_read(cec->regmap, CEC_ISR, &cec->irq_status); in stm32_cec_irq_handler()
159 regmap_update_bits(cec->regmap, CEC_ISR, in stm32_cec_irq_handler()
168 struct stm32_cec *cec = adap->priv; in stm32_cec_adap_enable() local
172 ret = clk_enable(cec->clk_cec); in stm32_cec_adap_enable()
174 dev_err(cec->dev, "fail to enable cec clock\n"); in stm32_cec_adap_enable()
176 clk_enable(cec->clk_hdmi_cec); in stm32_cec_adap_enable()
177 regmap_update_bits(cec->regmap, CEC_CR, CECEN, CECEN); in stm32_cec_adap_enable()
179 clk_disable(cec->clk_cec); in stm32_cec_adap_enable()
180 clk_disable(cec->clk_hdmi_cec); in stm32_cec_adap_enable()
181 regmap_update_bits(cec->regmap, CEC_CR, CECEN, 0); in stm32_cec_adap_enable()
189 struct stm32_cec *cec = adap->priv; in stm32_cec_adap_log_addr() local
192 regmap_update_bits(cec->regmap, CEC_CR, CECEN, 0); in stm32_cec_adap_log_addr()
195 regmap_update_bits(cec->regmap, CEC_CFGR, OAR, 0); in stm32_cec_adap_log_addr()
197 regmap_update_bits(cec->regmap, CEC_CFGR, oar, oar); in stm32_cec_adap_log_addr()
199 regmap_update_bits(cec->regmap, CEC_CR, CECEN, CECEN); in stm32_cec_adap_log_addr()
207 struct stm32_cec *cec = adap->priv; in stm32_cec_adap_transmit() local
210 cec->tx_msg = *msg; in stm32_cec_adap_transmit()
211 cec->tx_cnt = 0; in stm32_cec_adap_transmit()
214 * If the CEC message consists of only one byte, in stm32_cec_adap_transmit()
217 if (cec->tx_msg.len == 1) in stm32_cec_adap_transmit()
218 regmap_update_bits(cec->regmap, CEC_CR, TXEOM, TXEOM); in stm32_cec_adap_transmit()
221 regmap_update_bits(cec->regmap, CEC_CR, TXSOM, TXSOM); in stm32_cec_adap_transmit()
224 regmap_write(cec->regmap, CEC_TXDR, cec->tx_msg.msg[0]); in stm32_cec_adap_transmit()
225 cec->tx_cnt++; in stm32_cec_adap_transmit()
248 struct stm32_cec *cec; in stm32_cec_probe() local
252 cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL); in stm32_cec_probe()
253 if (!cec) in stm32_cec_probe()
256 cec->dev = &pdev->dev; in stm32_cec_probe()
263 cec->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "cec", mmio, in stm32_cec_probe()
266 if (IS_ERR(cec->regmap)) in stm32_cec_probe()
267 return PTR_ERR(cec->regmap); in stm32_cec_probe()
269 cec->irq = platform_get_irq(pdev, 0); in stm32_cec_probe()
270 if (cec->irq < 0) in stm32_cec_probe()
271 return cec->irq; in stm32_cec_probe()
273 ret = devm_request_threaded_irq(&pdev->dev, cec->irq, in stm32_cec_probe()
277 pdev->name, cec); in stm32_cec_probe()
281 cec->clk_cec = devm_clk_get(&pdev->dev, "cec"); in stm32_cec_probe()
282 if (IS_ERR(cec->clk_cec)) { in stm32_cec_probe()
283 dev_err(&pdev->dev, "Cannot get cec clock\n"); in stm32_cec_probe()
284 return PTR_ERR(cec->clk_cec); in stm32_cec_probe()
287 ret = clk_prepare(cec->clk_cec); in stm32_cec_probe()
289 dev_err(&pdev->dev, "Unable to prepare cec clock\n"); in stm32_cec_probe()
293 cec->clk_hdmi_cec = devm_clk_get(&pdev->dev, "hdmi-cec"); in stm32_cec_probe()
294 if (!IS_ERR(cec->clk_hdmi_cec)) { in stm32_cec_probe()
295 ret = clk_prepare(cec->clk_hdmi_cec); in stm32_cec_probe()
297 dev_err(&pdev->dev, "Unable to prepare hdmi-cec clock\n"); in stm32_cec_probe()
303 * CEC_CAP_PHYS_ADDR caps should be removed when a cec notifier is in stm32_cec_probe()
306 cec->adap = cec_allocate_adapter(&stm32_cec_adap_ops, cec, in stm32_cec_probe()
308 ret = PTR_ERR_OR_ZERO(cec->adap); in stm32_cec_probe()
312 ret = cec_register_adapter(cec->adap, &pdev->dev); in stm32_cec_probe()
314 cec_delete_adapter(cec->adap); in stm32_cec_probe()
318 cec_hw_init(cec); in stm32_cec_probe()
320 platform_set_drvdata(pdev, cec); in stm32_cec_probe()
327 struct stm32_cec *cec = platform_get_drvdata(pdev); in stm32_cec_remove() local
329 clk_unprepare(cec->clk_cec); in stm32_cec_remove()
330 clk_unprepare(cec->clk_hdmi_cec); in stm32_cec_remove()
332 cec_unregister_adapter(cec->adap); in stm32_cec_remove()
338 { .compatible = "st,stm32-cec" },