Lines Matching refs:ctx
206 static int sii9234_writeb(struct sii9234 *ctx, int id, int offset, in sii9234_writeb() argument
210 struct i2c_client *client = ctx->client[id]; in sii9234_writeb()
212 if (ctx->i2c_error) in sii9234_writeb()
213 return ctx->i2c_error; in sii9234_writeb()
217 dev_err(ctx->dev, "writeb: %4s[0x%02x] <- 0x%02x\n", in sii9234_writeb()
219 ctx->i2c_error = ret; in sii9234_writeb()
224 static int sii9234_writebm(struct sii9234 *ctx, int id, int offset, in sii9234_writebm() argument
228 struct i2c_client *client = ctx->client[id]; in sii9234_writebm()
230 if (ctx->i2c_error) in sii9234_writebm()
231 return ctx->i2c_error; in sii9234_writebm()
235 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
237 ctx->i2c_error = ret; in sii9234_writebm()
243 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
245 ctx->i2c_error = ret; in sii9234_writebm()
253 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
255 ctx->i2c_error = ret; in sii9234_writebm()
261 static int sii9234_readb(struct sii9234 *ctx, int id, int offset) in sii9234_readb() argument
264 struct i2c_client *client = ctx->client[id]; in sii9234_readb()
266 if (ctx->i2c_error) in sii9234_readb()
267 return ctx->i2c_error; in sii9234_readb()
271 dev_err(ctx->dev, "readb: %4s[0x%02x]\n", in sii9234_readb()
273 ctx->i2c_error = ret; in sii9234_readb()
279 dev_err(ctx->dev, "readb: %4s[0x%02x]\n", in sii9234_readb()
281 ctx->i2c_error = ret; in sii9234_readb()
287 static int sii9234_clear_error(struct sii9234 *ctx) in sii9234_clear_error() argument
289 int ret = ctx->i2c_error; in sii9234_clear_error()
291 ctx->i2c_error = 0; in sii9234_clear_error()
321 static u8 sii9234_tmds_control(struct sii9234 *ctx, bool enable) in sii9234_tmds_control() argument
323 mhl_tx_writebm(ctx, MHL_TX_TMDS_CCTRL, enable ? ~0 : 0, in sii9234_tmds_control()
325 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, enable ? ~0 : 0, in sii9234_tmds_control()
327 return sii9234_clear_error(ctx); in sii9234_tmds_control()
330 static int sii9234_cbus_reset(struct sii9234 *ctx) in sii9234_cbus_reset() argument
334 mhl_tx_writebm(ctx, MHL_TX_SRST, ~0, BIT_CBUS_RESET); in sii9234_cbus_reset()
336 mhl_tx_writebm(ctx, MHL_TX_SRST, 0, BIT_CBUS_RESET); in sii9234_cbus_reset()
343 cbus_writeb(ctx, 0xE0 + i, 0xF2); in sii9234_cbus_reset()
348 cbus_writeb(ctx, 0xF0 + i, 0xF2); in sii9234_cbus_reset()
351 return sii9234_clear_error(ctx); in sii9234_cbus_reset()
355 static int sii9234_cbus_init(struct sii9234 *ctx) in sii9234_cbus_init() argument
357 cbus_writeb(ctx, 0x07, 0xF2); in sii9234_cbus_init()
358 cbus_writeb(ctx, 0x40, 0x03); in sii9234_cbus_init()
359 cbus_writeb(ctx, 0x42, 0x06); in sii9234_cbus_init()
360 cbus_writeb(ctx, 0x36, 0x0C); in sii9234_cbus_init()
361 cbus_writeb(ctx, 0x3D, 0xFD); in sii9234_cbus_init()
362 cbus_writeb(ctx, 0x1C, 0x01); in sii9234_cbus_init()
363 cbus_writeb(ctx, 0x1D, 0x0F); in sii9234_cbus_init()
364 cbus_writeb(ctx, 0x44, 0x02); in sii9234_cbus_init()
366 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEV_STATE, 0x00); in sii9234_cbus_init()
367 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_MHL_VERSION, in sii9234_cbus_init()
369 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_CAT, in sii9234_cbus_init()
371 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_ADOPTER_ID_H, 0x01); in sii9234_cbus_init()
372 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_ADOPTER_ID_L, 0x41); in sii9234_cbus_init()
373 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_VID_LINK_MODE, in sii9234_cbus_init()
375 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_VIDEO_TYPE, in sii9234_cbus_init()
377 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_LOG_DEV_MAP, in sii9234_cbus_init()
379 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_BANDWIDTH, 0x0F); in sii9234_cbus_init()
380 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_FEATURE_FLAG, in sii9234_cbus_init()
383 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEVICE_ID_H, 0x0); in sii9234_cbus_init()
384 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEVICE_ID_L, 0x0); in sii9234_cbus_init()
385 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_SCRATCHPAD_SIZE, in sii9234_cbus_init()
387 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_INT_STAT_SIZE, in sii9234_cbus_init()
389 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_RESERVED, 0); in sii9234_cbus_init()
390 cbus_writebm(ctx, 0x31, 0x0C, 0x0C); in sii9234_cbus_init()
391 cbus_writeb(ctx, 0x30, 0x01); in sii9234_cbus_init()
392 cbus_writebm(ctx, 0x3C, 0x30, 0x38); in sii9234_cbus_init()
393 cbus_writebm(ctx, 0x22, 0x0D, 0x0F); in sii9234_cbus_init()
394 cbus_writebm(ctx, 0x2E, 0x15, 0x15); in sii9234_cbus_init()
395 cbus_writeb(ctx, CBUS_INTR1_ENABLE_REG, 0); in sii9234_cbus_init()
396 cbus_writeb(ctx, CBUS_INTR2_ENABLE_REG, 0); in sii9234_cbus_init()
398 return sii9234_clear_error(ctx); in sii9234_cbus_init()
401 static void force_usb_id_switch_open(struct sii9234 *ctx) in force_usb_id_switch_open() argument
404 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, 0, 0x01); in force_usb_id_switch_open()
406 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, USB_ID_OVR); in force_usb_id_switch_open()
407 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL3_REG, ~0, 0x86); in force_usb_id_switch_open()
409 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 0x30); in force_usb_id_switch_open()
412 static void release_usb_id_switch_open(struct sii9234 *ctx) in release_usb_id_switch_open() argument
416 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, 0, USB_ID_OVR); in release_usb_id_switch_open()
418 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, ~0, 0x01); in release_usb_id_switch_open()
421 static int sii9234_power_init(struct sii9234 *ctx) in sii9234_power_init() argument
424 tpi_writeb(ctx, TPI_DPD_REG, 0x3F); in sii9234_power_init()
426 hdmi_writeb(ctx, HDMI_RX_TMDS_CLK_EN_REG, 0x01); in sii9234_power_init()
428 hdmi_writeb(ctx, HDMI_RX_TMDS_CH_EN_REG, 0x15); in sii9234_power_init()
430 mhl_tx_writeb(ctx, 0x08, 0x35); in sii9234_power_init()
431 return sii9234_clear_error(ctx); in sii9234_power_init()
434 static int sii9234_hdmi_init(struct sii9234 *ctx) in sii9234_hdmi_init() argument
436 hdmi_writeb(ctx, HDMI_RX_TMDS0_CCTRL1_REG, 0xC1); in sii9234_hdmi_init()
437 hdmi_writeb(ctx, HDMI_RX_PLL_CALREFSEL_REG, 0x03); in sii9234_hdmi_init()
438 hdmi_writeb(ctx, HDMI_RX_PLL_VCOCAL_REG, 0x20); in sii9234_hdmi_init()
439 hdmi_writeb(ctx, HDMI_RX_EQ_DATA0_REG, 0x8A); in sii9234_hdmi_init()
440 hdmi_writeb(ctx, HDMI_RX_EQ_DATA1_REG, 0x6A); in sii9234_hdmi_init()
441 hdmi_writeb(ctx, HDMI_RX_EQ_DATA2_REG, 0xAA); in sii9234_hdmi_init()
442 hdmi_writeb(ctx, HDMI_RX_EQ_DATA3_REG, 0xCA); in sii9234_hdmi_init()
443 hdmi_writeb(ctx, HDMI_RX_EQ_DATA4_REG, 0xEA); in sii9234_hdmi_init()
444 hdmi_writeb(ctx, HDMI_RX_TMDS_ZONE_CTRL_REG, 0xA0); in sii9234_hdmi_init()
445 hdmi_writeb(ctx, HDMI_RX_TMDS_MODE_CTRL_REG, 0x00); in sii9234_hdmi_init()
446 mhl_tx_writeb(ctx, MHL_TX_TMDS_CCTRL, 0x34); in sii9234_hdmi_init()
447 hdmi_writeb(ctx, 0x45, 0x44); in sii9234_hdmi_init()
448 hdmi_writeb(ctx, 0x31, 0x0A); in sii9234_hdmi_init()
449 hdmi_writeb(ctx, HDMI_RX_TMDS0_CCTRL1_REG, 0xC1); in sii9234_hdmi_init()
451 return sii9234_clear_error(ctx); in sii9234_hdmi_init()
454 static int sii9234_mhl_tx_ctl_int(struct sii9234 *ctx) in sii9234_mhl_tx_ctl_int() argument
456 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL1_REG, 0xD0); in sii9234_mhl_tx_ctl_int()
457 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL2_REG, 0xFC); in sii9234_mhl_tx_ctl_int()
458 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL4_REG, 0xEB); in sii9234_mhl_tx_ctl_int()
459 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL7_REG, 0x0C); in sii9234_mhl_tx_ctl_int()
461 return sii9234_clear_error(ctx); in sii9234_mhl_tx_ctl_int()
464 static int sii9234_reset(struct sii9234 *ctx) in sii9234_reset() argument
468 sii9234_clear_error(ctx); in sii9234_reset()
470 ret = sii9234_power_init(ctx); in sii9234_reset()
473 ret = sii9234_cbus_reset(ctx); in sii9234_reset()
476 ret = sii9234_hdmi_init(ctx); in sii9234_reset()
479 ret = sii9234_mhl_tx_ctl_int(ctx); in sii9234_reset()
484 mhl_tx_writeb(ctx, 0x2B, 0x01); in sii9234_reset()
486 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, 0x04, 0x06); in sii9234_reset()
488 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL2_REG, (1 << 7) /* Reserved */ in sii9234_reset()
495 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL5_REG, 0x77); in sii9234_reset()
496 cbus_writebm(ctx, CBUS_LINK_CONTROL_2_REG, ~0, MHL_INIT_TIMEOUT); in sii9234_reset()
497 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL6_REG, 0xA0); in sii9234_reset()
499 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL6_REG, BLOCK_RGND_INT | in sii9234_reset()
502 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL8_REG, 0); in sii9234_reset()
504 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, USB_ID_OVR); in sii9234_reset()
514 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL3_REG, ~0, 0x86); in sii9234_reset()
519 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, ~0, 0x8C); in sii9234_reset()
521 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 0x06); in sii9234_reset()
526 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, 0, USB_ID_OVR); in sii9234_reset()
527 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL1_REG, 0x27); in sii9234_reset()
529 ret = sii9234_clear_error(ctx); in sii9234_reset()
532 ret = sii9234_cbus_init(ctx); in sii9234_reset()
537 mhl_tx_writeb(ctx, 0x05, 0x04); in sii9234_reset()
539 mhl_tx_writeb(ctx, 0x0D, 0x1C); in sii9234_reset()
540 mhl_tx_writeb(ctx, MHL_TX_INTR4_ENABLE_REG, in sii9234_reset()
543 mhl_tx_writeb(ctx, MHL_TX_INTR1_ENABLE_REG, 0x60); in sii9234_reset()
546 force_usb_id_switch_open(ctx); in sii9234_reset()
547 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, 0, 0xF0); in sii9234_reset()
548 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL5_REG, 0, 0x03); in sii9234_reset()
549 release_usb_id_switch_open(ctx); in sii9234_reset()
552 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 1 << 5); in sii9234_reset()
553 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, ~0, 1 << 4); in sii9234_reset()
555 return sii9234_clear_error(ctx); in sii9234_reset()
558 static int sii9234_goto_d3(struct sii9234 *ctx) in sii9234_goto_d3() argument
562 dev_dbg(ctx->dev, "sii9234: detection started d3\n"); in sii9234_goto_d3()
564 ret = sii9234_reset(ctx); in sii9234_goto_d3()
568 hdmi_writeb(ctx, 0x01, 0x03); in sii9234_goto_d3()
569 tpi_writebm(ctx, TPI_DPD_REG, 0, 1); in sii9234_goto_d3()
571 sii9234_clear_error(ctx); in sii9234_goto_d3()
573 ctx->state = ST_D3; in sii9234_goto_d3()
577 dev_err(ctx->dev, "%s failed\n", __func__); in sii9234_goto_d3()
581 static int sii9234_hw_on(struct sii9234 *ctx) in sii9234_hw_on() argument
583 return regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in sii9234_hw_on()
586 static void sii9234_hw_off(struct sii9234 *ctx) in sii9234_hw_off() argument
588 gpiod_set_value(ctx->gpio_reset, 1); in sii9234_hw_off()
590 regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in sii9234_hw_off()
593 static void sii9234_hw_reset(struct sii9234 *ctx) in sii9234_hw_reset() argument
595 gpiod_set_value(ctx->gpio_reset, 1); in sii9234_hw_reset()
597 gpiod_set_value(ctx->gpio_reset, 0); in sii9234_hw_reset()
600 static void sii9234_cable_in(struct sii9234 *ctx) in sii9234_cable_in() argument
604 mutex_lock(&ctx->lock); in sii9234_cable_in()
605 if (ctx->state != ST_OFF) in sii9234_cable_in()
607 ret = sii9234_hw_on(ctx); in sii9234_cable_in()
611 sii9234_hw_reset(ctx); in sii9234_cable_in()
612 sii9234_goto_d3(ctx); in sii9234_cable_in()
614 enable_irq(to_i2c_client(ctx->dev)->irq); in sii9234_cable_in()
617 mutex_unlock(&ctx->lock); in sii9234_cable_in()
620 static void sii9234_cable_out(struct sii9234 *ctx) in sii9234_cable_out() argument
622 mutex_lock(&ctx->lock); in sii9234_cable_out()
624 if (ctx->state == ST_OFF) in sii9234_cable_out()
627 disable_irq(to_i2c_client(ctx->dev)->irq); in sii9234_cable_out()
628 tpi_writeb(ctx, TPI_DPD_REG, 0); in sii9234_cable_out()
630 sii9234_hw_off(ctx); in sii9234_cable_out()
632 ctx->state = ST_OFF; in sii9234_cable_out()
635 mutex_unlock(&ctx->lock); in sii9234_cable_out()
638 static enum sii9234_state sii9234_rgnd_ready_irq(struct sii9234 *ctx) in sii9234_rgnd_ready_irq() argument
642 if (ctx->state == ST_D3) { in sii9234_rgnd_ready_irq()
645 dev_dbg(ctx->dev, "RGND_READY_INT\n"); in sii9234_rgnd_ready_irq()
646 sii9234_hw_reset(ctx); in sii9234_rgnd_ready_irq()
648 ret = sii9234_reset(ctx); in sii9234_rgnd_ready_irq()
650 dev_err(ctx->dev, "sii9234_reset() failed\n"); in sii9234_rgnd_ready_irq()
658 if (ctx->state != ST_RGND_INIT) in sii9234_rgnd_ready_irq()
661 value = mhl_tx_readb(ctx, MHL_TX_STAT2_REG); in sii9234_rgnd_ready_irq()
662 if (sii9234_clear_error(ctx)) in sii9234_rgnd_ready_irq()
666 dev_warn(ctx->dev, "RGND is not 1k\n"); in sii9234_rgnd_ready_irq()
669 dev_dbg(ctx->dev, "RGND 1K!!\n"); in sii9234_rgnd_ready_irq()
670 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, ~0, 0x8C); in sii9234_rgnd_ready_irq()
671 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL5_REG, 0x77); in sii9234_rgnd_ready_irq()
672 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, 0x05); in sii9234_rgnd_ready_irq()
673 if (sii9234_clear_error(ctx)) in sii9234_rgnd_ready_irq()
680 static enum sii9234_state sii9234_mhl_established(struct sii9234 *ctx) in sii9234_mhl_established() argument
682 dev_dbg(ctx->dev, "mhl est interrupt\n"); in sii9234_mhl_established()
685 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL1_REG, 0x10); in sii9234_mhl_established()
687 cbus_writeb(ctx, 0x07, 0x32); in sii9234_mhl_established()
688 cbus_writebm(ctx, 0x44, ~0, 1 << 1); in sii9234_mhl_established()
690 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, ~0, 1); in sii9234_mhl_established()
691 mhl_tx_writeb(ctx, MHL_TX_INTR1_ENABLE_REG, in sii9234_mhl_established()
694 if (sii9234_clear_error(ctx)) in sii9234_mhl_established()
700 static enum sii9234_state sii9234_hpd_change(struct sii9234 *ctx) in sii9234_hpd_change() argument
704 value = cbus_readb(ctx, CBUS_MSC_REQ_ABORT_REASON_REG); in sii9234_hpd_change()
705 if (sii9234_clear_error(ctx)) in sii9234_hpd_change()
710 sii9234_tmds_control(ctx, true); in sii9234_hpd_change()
713 sii9234_tmds_control(ctx, false); in sii9234_hpd_change()
716 return ctx->state; in sii9234_hpd_change()
719 static enum sii9234_state sii9234_rsen_change(struct sii9234 *ctx) in sii9234_rsen_change() argument
724 if (ctx->state != ST_RGND_1K) { in sii9234_rsen_change()
725 dev_err(ctx->dev, "RSEN_HIGH without RGND_1K\n"); in sii9234_rsen_change()
728 value = mhl_tx_readb(ctx, MHL_TX_SYSSTAT_REG); in sii9234_rsen_change()
733 dev_dbg(ctx->dev, "MHL cable connected.. RSEN High\n"); in sii9234_rsen_change()
736 dev_dbg(ctx->dev, "RSEN lost\n"); in sii9234_rsen_change()
745 value = mhl_tx_readb(ctx, MHL_TX_SYSSTAT_REG); in sii9234_rsen_change()
748 dev_dbg(ctx->dev, "sys_stat: %x\n", value); in sii9234_rsen_change()
751 dev_dbg(ctx->dev, "RSEN recovery\n"); in sii9234_rsen_change()
754 dev_dbg(ctx->dev, "RSEN Really LOW\n"); in sii9234_rsen_change()
756 sii9234_tmds_control(ctx, false); in sii9234_rsen_change()
757 force_usb_id_switch_open(ctx); in sii9234_rsen_change()
758 release_usb_id_switch_open(ctx); in sii9234_rsen_change()
765 struct sii9234 *ctx = data; in sii9234_irq_thread() local
770 dev_dbg(ctx->dev, "%s\n", __func__); in sii9234_irq_thread()
772 mutex_lock(&ctx->lock); in sii9234_irq_thread()
774 intr1 = mhl_tx_readb(ctx, MHL_TX_INTR1_REG); in sii9234_irq_thread()
775 intr4 = mhl_tx_readb(ctx, MHL_TX_INTR4_REG); in sii9234_irq_thread()
776 intr1_en = mhl_tx_readb(ctx, MHL_TX_INTR1_ENABLE_REG); in sii9234_irq_thread()
777 intr4_en = mhl_tx_readb(ctx, MHL_TX_INTR4_ENABLE_REG); in sii9234_irq_thread()
778 cbus_intr1 = cbus_readb(ctx, CBUS_INT_STATUS_1_REG); in sii9234_irq_thread()
779 cbus_intr2 = cbus_readb(ctx, CBUS_INT_STATUS_2_REG); in sii9234_irq_thread()
781 if (sii9234_clear_error(ctx)) in sii9234_irq_thread()
784 dev_dbg(ctx->dev, "irq %02x/%02x %02x/%02x %02x/%02x\n", in sii9234_irq_thread()
788 ctx->state = sii9234_rgnd_ready_irq(ctx); in sii9234_irq_thread()
790 ctx->state = sii9234_rsen_change(ctx); in sii9234_irq_thread()
792 ctx->state = sii9234_mhl_established(ctx); in sii9234_irq_thread()
794 ctx->state = sii9234_hpd_change(ctx); in sii9234_irq_thread()
796 ctx->state = ST_FAILURE; in sii9234_irq_thread()
798 ctx->state = ST_FAILURE_DISCOVERY; in sii9234_irq_thread()
802 mhl_tx_writeb(ctx, MHL_TX_INTR1_REG, intr1); in sii9234_irq_thread()
803 mhl_tx_writeb(ctx, MHL_TX_INTR4_REG, intr4); in sii9234_irq_thread()
804 cbus_writeb(ctx, CBUS_MHL_STATUS_REG_0, 0xFF); in sii9234_irq_thread()
805 cbus_writeb(ctx, CBUS_MHL_STATUS_REG_1, 0xFF); in sii9234_irq_thread()
806 cbus_writeb(ctx, CBUS_INT_STATUS_1_REG, cbus_intr1); in sii9234_irq_thread()
807 cbus_writeb(ctx, CBUS_INT_STATUS_2_REG, cbus_intr2); in sii9234_irq_thread()
809 sii9234_clear_error(ctx); in sii9234_irq_thread()
811 if (ctx->state == ST_FAILURE) { in sii9234_irq_thread()
812 dev_dbg(ctx->dev, "try to reset after failure\n"); in sii9234_irq_thread()
813 sii9234_hw_reset(ctx); in sii9234_irq_thread()
814 sii9234_goto_d3(ctx); in sii9234_irq_thread()
817 if (ctx->state == ST_FAILURE_DISCOVERY) { in sii9234_irq_thread()
818 dev_err(ctx->dev, "discovery failed, no power for MHL?\n"); in sii9234_irq_thread()
819 tpi_writebm(ctx, TPI_DPD_REG, 0, 1); in sii9234_irq_thread()
820 ctx->state = ST_D3; in sii9234_irq_thread()
823 mutex_unlock(&ctx->lock); in sii9234_irq_thread()
828 static int sii9234_init_resources(struct sii9234 *ctx, in sii9234_init_resources() argument
834 if (!ctx->dev->of_node) { in sii9234_init_resources()
835 dev_err(ctx->dev, "not DT device\n"); in sii9234_init_resources()
839 ctx->gpio_reset = devm_gpiod_get(ctx->dev, "reset", GPIOD_OUT_LOW); in sii9234_init_resources()
840 if (IS_ERR(ctx->gpio_reset)) { in sii9234_init_resources()
841 dev_err(ctx->dev, "failed to get reset gpio from DT\n"); in sii9234_init_resources()
842 return PTR_ERR(ctx->gpio_reset); in sii9234_init_resources()
845 ctx->supplies[0].supply = "avcc12"; in sii9234_init_resources()
846 ctx->supplies[1].supply = "avcc33"; in sii9234_init_resources()
847 ctx->supplies[2].supply = "iovcc18"; in sii9234_init_resources()
848 ctx->supplies[3].supply = "cvcc12"; in sii9234_init_resources()
849 ret = devm_regulator_bulk_get(ctx->dev, 4, ctx->supplies); in sii9234_init_resources()
851 dev_err(ctx->dev, "regulator_bulk failed\n"); in sii9234_init_resources()
855 ctx->client[I2C_MHL] = client; in sii9234_init_resources()
857 ctx->client[I2C_TPI] = i2c_new_dummy(adapter, I2C_TPI_ADDR); in sii9234_init_resources()
858 if (!ctx->client[I2C_TPI]) { in sii9234_init_resources()
859 dev_err(ctx->dev, "failed to create TPI client\n"); in sii9234_init_resources()
863 ctx->client[I2C_HDMI] = i2c_new_dummy(adapter, I2C_HDMI_ADDR); in sii9234_init_resources()
864 if (!ctx->client[I2C_HDMI]) { in sii9234_init_resources()
865 dev_err(ctx->dev, "failed to create HDMI RX client\n"); in sii9234_init_resources()
869 ctx->client[I2C_CBUS] = i2c_new_dummy(adapter, I2C_CBUS_ADDR); in sii9234_init_resources()
870 if (!ctx->client[I2C_CBUS]) { in sii9234_init_resources()
871 dev_err(ctx->dev, "failed to create CBUS client\n"); in sii9234_init_resources()
878 i2c_unregister_device(ctx->client[I2C_HDMI]); in sii9234_init_resources()
880 i2c_unregister_device(ctx->client[I2C_TPI]); in sii9234_init_resources()
885 static void sii9234_deinit_resources(struct sii9234 *ctx) in sii9234_deinit_resources() argument
887 i2c_unregister_device(ctx->client[I2C_CBUS]); in sii9234_deinit_resources()
888 i2c_unregister_device(ctx->client[I2C_HDMI]); in sii9234_deinit_resources()
889 i2c_unregister_device(ctx->client[I2C_TPI]); in sii9234_deinit_resources()
914 struct sii9234 *ctx; in sii9234_probe() local
918 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); in sii9234_probe()
919 if (!ctx) in sii9234_probe()
922 ctx->dev = dev; in sii9234_probe()
923 mutex_init(&ctx->lock); in sii9234_probe()
939 "sii9234", ctx); in sii9234_probe()
945 ret = sii9234_init_resources(ctx, client); in sii9234_probe()
949 i2c_set_clientdata(client, ctx); in sii9234_probe()
951 ctx->bridge.funcs = &sii9234_bridge_funcs; in sii9234_probe()
952 ctx->bridge.of_node = dev->of_node; in sii9234_probe()
953 drm_bridge_add(&ctx->bridge); in sii9234_probe()
955 sii9234_cable_in(ctx); in sii9234_probe()
962 struct sii9234 *ctx = i2c_get_clientdata(client); in sii9234_remove() local
964 sii9234_cable_out(ctx); in sii9234_remove()
965 drm_bridge_remove(&ctx->bridge); in sii9234_remove()
966 sii9234_deinit_resources(ctx); in sii9234_remove()