Lines Matching defs:ch7322

150 struct ch7322 {
165 static int ch7322_send_message(struct ch7322 *ch7322, const struct cec_msg *msg)
172 WARN_ON(!mutex_is_locked(&ch7322->mutex));
177 ret = regmap_read(ch7322->regmap, CH7322_WRITE, &val);
187 ch7322->tx_flags = CH7322_TX_FLAG_NACK | CH7322_TX_FLAG_RETRY;
189 ch7322->tx_flags = CH7322_TX_FLAG_NACK;
191 ch7322->tx_flags = CH7322_TX_FLAG_RETRY;
194 ret = regmap_write(ch7322->regmap, CH7322_WRITE, len - 1);
199 ret = regmap_write(ch7322->regmap,
208 static int ch7322_receive_message(struct ch7322 *ch7322, struct cec_msg *msg)
214 WARN_ON(!mutex_is_locked(&ch7322->mutex));
216 ret = regmap_read(ch7322->regmap, CH7322_READ, &val);
228 ret = regmap_read(ch7322->regmap, CH7322_RDBUF + i, &val);
237 static void ch7322_tx_done(struct ch7322 *ch7322)
243 mutex_lock(&ch7322->mutex);
244 ret = regmap_read(ch7322->regmap, CH7322_WRITE, &val);
245 flags = ch7322->tx_flags;
246 mutex_unlock(&ch7322->mutex);
267 cec_transmit_attempt_done(ch7322->cec, status);
270 static void ch7322_rx_done(struct ch7322 *ch7322)
275 mutex_lock(&ch7322->mutex);
276 ret = ch7322_receive_message(ch7322, &msg);
277 mutex_unlock(&ch7322->mutex);
280 dev_err(&ch7322->i2c->dev, "cec receive error: %d\n", ret);
282 cec_received_msg(ch7322->cec, &msg);
290 static void ch7322_phys_addr(struct ch7322 *ch7322)
295 mutex_lock(&ch7322->mutex);
296 ret |= regmap_read(ch7322->regmap, CH7322_PARH, &pah);
297 ret |= regmap_read(ch7322->regmap, CH7322_PARL, &pal);
298 mutex_unlock(&ch7322->mutex);
301 dev_err(&ch7322->i2c->dev, "phys addr error\n");
303 cec_s_phys_addr(ch7322->cec, pal | (pah << 8), false);
308 struct ch7322 *ch7322 = dev;
311 mutex_lock(&ch7322->mutex);
312 regmap_read(ch7322->regmap, CH7322_INTDATA, &data);
313 regmap_write(ch7322->regmap, CH7322_INTDATA, data);
314 mutex_unlock(&ch7322->mutex);
317 cec_phys_addr_invalidate(ch7322->cec);
320 ch7322_tx_done(ch7322);
323 ch7322_rx_done(ch7322);
326 ch7322_phys_addr(ch7322);
329 dev_dbg(&ch7322->i2c->dev, "unknown error\n");
342 struct ch7322 *ch7322 = cec_get_drvdata(adap);
345 mutex_lock(&ch7322->mutex);
346 ret = regmap_update_bits(ch7322->regmap, CH7322_ADDLW,
348 mutex_unlock(&ch7322->mutex);
356 struct ch7322 *ch7322 = cec_get_drvdata(adap);
359 mutex_lock(&ch7322->mutex);
360 ret = ch7322_send_message(ch7322, msg);
361 mutex_unlock(&ch7322->mutex);
451 struct ch7322 *ch7322;
464 ch7322 = devm_kzalloc(&client->dev, sizeof(*ch7322), GFP_KERNEL);
465 if (!ch7322)
468 ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);
469 if (IS_ERR(ch7322->regmap))
470 return PTR_ERR(ch7322->regmap);
472 ret = regmap_read(ch7322->regmap, CH7322_DID, &val);
479 mutex_init(&ch7322->mutex);
480 ch7322->i2c = client;
481 ch7322->tx_flags = 0;
483 i2c_set_clientdata(client, ch7322);
486 ret = regmap_write(ch7322->regmap, CH7322_MODE, CH7322_MODE_SW);
491 ret = regmap_update_bits(ch7322->regmap, CH7322_CTL,
496 ch7322->cec = cec_allocate_adapter(&ch7322_cec_adap_ops, ch7322,
500 if (IS_ERR(ch7322->cec)) {
501 ret = PTR_ERR(ch7322->cec);
505 ch7322->cec->adap_controls_phys_addr = true;
510 ch7322->cec);
518 ret = regmap_write(ch7322->regmap, CH7322_CFG1, 0);
521 ret = regmap_write(ch7322->regmap, CH7322_INTCTL, CH7322_INTCTL_INTPB);
524 ret = regmap_write(ch7322->regmap, CH7322_INTDATA, 0xff);
529 ret = regmap_read(ch7322->regmap, CH7322_ADDLR, &val);
533 ch7322_phys_addr(ch7322);
538 client->name, ch7322);
543 mutex_lock(&ch7322->mutex);
544 ret = regmap_write(ch7322->regmap, CH7322_INTCTL, 0xff);
545 mutex_unlock(&ch7322->mutex);
550 ret = cec_register_adapter(ch7322->cec, &client->dev);
560 cec_notifier_cec_adap_unregister(notifier, ch7322->cec);
562 cec_delete_adapter(ch7322->cec);
564 mutex_destroy(&ch7322->mutex);
570 struct ch7322 *ch7322 = i2c_get_clientdata(client);
573 mutex_lock(&ch7322->mutex);
574 regmap_write(ch7322->regmap, CH7322_INTCTL, CH7322_INTCTL_INTPB);
575 mutex_unlock(&ch7322->mutex);
577 cec_unregister_adapter(ch7322->cec);
578 mutex_destroy(&ch7322->mutex);
584 { .compatible = "chrontel,ch7322", },
591 .name = "ch7322",