Lines Matching refs:ctx
193 static int sii9234_writeb(struct sii9234 *ctx, int id, int offset, in sii9234_writeb() argument
197 struct i2c_client *client = ctx->client[id]; in sii9234_writeb()
199 if (ctx->i2c_error) in sii9234_writeb()
200 return ctx->i2c_error; in sii9234_writeb()
204 dev_err(ctx->dev, "writeb: %4s[0x%02x] <- 0x%02x\n", in sii9234_writeb()
206 ctx->i2c_error = ret; in sii9234_writeb()
211 static int sii9234_writebm(struct sii9234 *ctx, int id, int offset, in sii9234_writebm() argument
215 struct i2c_client *client = ctx->client[id]; in sii9234_writebm()
217 if (ctx->i2c_error) in sii9234_writebm()
218 return ctx->i2c_error; in sii9234_writebm()
222 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
224 ctx->i2c_error = ret; in sii9234_writebm()
230 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
232 ctx->i2c_error = ret; in sii9234_writebm()
240 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
242 ctx->i2c_error = ret; in sii9234_writebm()
248 static int sii9234_readb(struct sii9234 *ctx, int id, int offset) in sii9234_readb() argument
251 struct i2c_client *client = ctx->client[id]; in sii9234_readb()
253 if (ctx->i2c_error) in sii9234_readb()
254 return ctx->i2c_error; in sii9234_readb()
258 dev_err(ctx->dev, "readb: %4s[0x%02x]\n", in sii9234_readb()
260 ctx->i2c_error = ret; in sii9234_readb()
266 dev_err(ctx->dev, "readb: %4s[0x%02x]\n", in sii9234_readb()
268 ctx->i2c_error = ret; in sii9234_readb()
274 static int sii9234_clear_error(struct sii9234 *ctx) in sii9234_clear_error() argument
276 int ret = ctx->i2c_error; in sii9234_clear_error()
278 ctx->i2c_error = 0; in sii9234_clear_error()
308 static u8 sii9234_tmds_control(struct sii9234 *ctx, bool enable) in sii9234_tmds_control() argument
310 mhl_tx_writebm(ctx, MHL_TX_TMDS_CCTRL, enable ? ~0 : 0, in sii9234_tmds_control()
312 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, enable ? ~0 : 0, in sii9234_tmds_control()
314 return sii9234_clear_error(ctx); in sii9234_tmds_control()
317 static int sii9234_cbus_reset(struct sii9234 *ctx) in sii9234_cbus_reset() argument
321 mhl_tx_writebm(ctx, MHL_TX_SRST, ~0, BIT_CBUS_RESET); in sii9234_cbus_reset()
323 mhl_tx_writebm(ctx, MHL_TX_SRST, 0, BIT_CBUS_RESET); in sii9234_cbus_reset()
330 cbus_writeb(ctx, 0xE0 + i, 0xF2); in sii9234_cbus_reset()
335 cbus_writeb(ctx, 0xF0 + i, 0xF2); in sii9234_cbus_reset()
338 return sii9234_clear_error(ctx); in sii9234_cbus_reset()
342 static int sii9234_cbus_init(struct sii9234 *ctx) in sii9234_cbus_init() argument
344 cbus_writeb(ctx, 0x07, 0xF2); in sii9234_cbus_init()
345 cbus_writeb(ctx, 0x40, 0x03); in sii9234_cbus_init()
346 cbus_writeb(ctx, 0x42, 0x06); in sii9234_cbus_init()
347 cbus_writeb(ctx, 0x36, 0x0C); in sii9234_cbus_init()
348 cbus_writeb(ctx, 0x3D, 0xFD); in sii9234_cbus_init()
349 cbus_writeb(ctx, 0x1C, 0x01); in sii9234_cbus_init()
350 cbus_writeb(ctx, 0x1D, 0x0F); in sii9234_cbus_init()
351 cbus_writeb(ctx, 0x44, 0x02); in sii9234_cbus_init()
353 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEV_STATE, 0x00); in sii9234_cbus_init()
354 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_MHL_VERSION, in sii9234_cbus_init()
356 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_CAT, in sii9234_cbus_init()
358 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_ADOPTER_ID_H, 0x01); in sii9234_cbus_init()
359 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_ADOPTER_ID_L, 0x41); in sii9234_cbus_init()
360 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_VID_LINK_MODE, in sii9234_cbus_init()
362 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_VIDEO_TYPE, in sii9234_cbus_init()
364 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_LOG_DEV_MAP, in sii9234_cbus_init()
366 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_BANDWIDTH, 0x0F); in sii9234_cbus_init()
367 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_FEATURE_FLAG, in sii9234_cbus_init()
370 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEVICE_ID_H, 0x0); in sii9234_cbus_init()
371 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEVICE_ID_L, 0x0); in sii9234_cbus_init()
372 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_SCRATCHPAD_SIZE, in sii9234_cbus_init()
374 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_INT_STAT_SIZE, in sii9234_cbus_init()
376 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_RESERVED, 0); in sii9234_cbus_init()
377 cbus_writebm(ctx, 0x31, 0x0C, 0x0C); in sii9234_cbus_init()
378 cbus_writeb(ctx, 0x30, 0x01); in sii9234_cbus_init()
379 cbus_writebm(ctx, 0x3C, 0x30, 0x38); in sii9234_cbus_init()
380 cbus_writebm(ctx, 0x22, 0x0D, 0x0F); in sii9234_cbus_init()
381 cbus_writebm(ctx, 0x2E, 0x15, 0x15); in sii9234_cbus_init()
382 cbus_writeb(ctx, CBUS_INTR1_ENABLE_REG, 0); in sii9234_cbus_init()
383 cbus_writeb(ctx, CBUS_INTR2_ENABLE_REG, 0); in sii9234_cbus_init()
385 return sii9234_clear_error(ctx); in sii9234_cbus_init()
388 static void force_usb_id_switch_open(struct sii9234 *ctx) in force_usb_id_switch_open() argument
391 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, 0, 0x01); in force_usb_id_switch_open()
393 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, USB_ID_OVR); in force_usb_id_switch_open()
394 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL3_REG, ~0, 0x86); in force_usb_id_switch_open()
396 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 0x30); in force_usb_id_switch_open()
399 static void release_usb_id_switch_open(struct sii9234 *ctx) in release_usb_id_switch_open() argument
403 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, 0, USB_ID_OVR); in release_usb_id_switch_open()
405 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, ~0, 0x01); in release_usb_id_switch_open()
408 static int sii9234_power_init(struct sii9234 *ctx) in sii9234_power_init() argument
411 tpi_writeb(ctx, TPI_DPD_REG, 0x3F); in sii9234_power_init()
413 hdmi_writeb(ctx, HDMI_RX_TMDS_CLK_EN_REG, 0x01); in sii9234_power_init()
415 hdmi_writeb(ctx, HDMI_RX_TMDS_CH_EN_REG, 0x15); in sii9234_power_init()
417 mhl_tx_writeb(ctx, 0x08, 0x35); in sii9234_power_init()
418 return sii9234_clear_error(ctx); in sii9234_power_init()
421 static int sii9234_hdmi_init(struct sii9234 *ctx) in sii9234_hdmi_init() argument
423 hdmi_writeb(ctx, HDMI_RX_TMDS0_CCTRL1_REG, 0xC1); in sii9234_hdmi_init()
424 hdmi_writeb(ctx, HDMI_RX_PLL_CALREFSEL_REG, 0x03); in sii9234_hdmi_init()
425 hdmi_writeb(ctx, HDMI_RX_PLL_VCOCAL_REG, 0x20); in sii9234_hdmi_init()
426 hdmi_writeb(ctx, HDMI_RX_EQ_DATA0_REG, 0x8A); in sii9234_hdmi_init()
427 hdmi_writeb(ctx, HDMI_RX_EQ_DATA1_REG, 0x6A); in sii9234_hdmi_init()
428 hdmi_writeb(ctx, HDMI_RX_EQ_DATA2_REG, 0xAA); in sii9234_hdmi_init()
429 hdmi_writeb(ctx, HDMI_RX_EQ_DATA3_REG, 0xCA); in sii9234_hdmi_init()
430 hdmi_writeb(ctx, HDMI_RX_EQ_DATA4_REG, 0xEA); in sii9234_hdmi_init()
431 hdmi_writeb(ctx, HDMI_RX_TMDS_ZONE_CTRL_REG, 0xA0); in sii9234_hdmi_init()
432 hdmi_writeb(ctx, HDMI_RX_TMDS_MODE_CTRL_REG, 0x00); in sii9234_hdmi_init()
433 mhl_tx_writeb(ctx, MHL_TX_TMDS_CCTRL, 0x34); in sii9234_hdmi_init()
434 hdmi_writeb(ctx, 0x45, 0x44); in sii9234_hdmi_init()
435 hdmi_writeb(ctx, 0x31, 0x0A); in sii9234_hdmi_init()
436 hdmi_writeb(ctx, HDMI_RX_TMDS0_CCTRL1_REG, 0xC1); in sii9234_hdmi_init()
438 return sii9234_clear_error(ctx); in sii9234_hdmi_init()
441 static int sii9234_mhl_tx_ctl_int(struct sii9234 *ctx) in sii9234_mhl_tx_ctl_int() argument
443 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL1_REG, 0xD0); in sii9234_mhl_tx_ctl_int()
444 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL2_REG, 0xFC); in sii9234_mhl_tx_ctl_int()
445 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL4_REG, 0xEB); in sii9234_mhl_tx_ctl_int()
446 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL7_REG, 0x0C); in sii9234_mhl_tx_ctl_int()
448 return sii9234_clear_error(ctx); in sii9234_mhl_tx_ctl_int()
451 static int sii9234_reset(struct sii9234 *ctx) in sii9234_reset() argument
455 sii9234_clear_error(ctx); in sii9234_reset()
457 ret = sii9234_power_init(ctx); in sii9234_reset()
460 ret = sii9234_cbus_reset(ctx); in sii9234_reset()
463 ret = sii9234_hdmi_init(ctx); in sii9234_reset()
466 ret = sii9234_mhl_tx_ctl_int(ctx); in sii9234_reset()
471 mhl_tx_writeb(ctx, 0x2B, 0x01); in sii9234_reset()
473 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, 0x04, 0x06); in sii9234_reset()
475 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL2_REG, (1 << 7) /* Reserved */ in sii9234_reset()
482 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL5_REG, 0x77); in sii9234_reset()
483 cbus_writebm(ctx, CBUS_LINK_CONTROL_2_REG, ~0, MHL_INIT_TIMEOUT); in sii9234_reset()
484 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL6_REG, 0xA0); in sii9234_reset()
486 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL6_REG, BLOCK_RGND_INT | in sii9234_reset()
489 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL8_REG, 0); in sii9234_reset()
491 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, USB_ID_OVR); in sii9234_reset()
501 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL3_REG, ~0, 0x86); in sii9234_reset()
506 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, ~0, 0x8C); in sii9234_reset()
508 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 0x06); in sii9234_reset()
513 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, 0, USB_ID_OVR); in sii9234_reset()
514 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL1_REG, 0x27); in sii9234_reset()
516 ret = sii9234_clear_error(ctx); in sii9234_reset()
519 ret = sii9234_cbus_init(ctx); in sii9234_reset()
524 mhl_tx_writeb(ctx, 0x05, 0x04); in sii9234_reset()
526 mhl_tx_writeb(ctx, 0x0D, 0x1C); in sii9234_reset()
527 mhl_tx_writeb(ctx, MHL_TX_INTR4_ENABLE_REG, in sii9234_reset()
530 mhl_tx_writeb(ctx, MHL_TX_INTR1_ENABLE_REG, 0x60); in sii9234_reset()
533 force_usb_id_switch_open(ctx); in sii9234_reset()
534 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, 0, 0xF0); in sii9234_reset()
535 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL5_REG, 0, 0x03); in sii9234_reset()
536 release_usb_id_switch_open(ctx); in sii9234_reset()
539 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 1 << 5); in sii9234_reset()
540 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, ~0, 1 << 4); in sii9234_reset()
542 return sii9234_clear_error(ctx); in sii9234_reset()
545 static int sii9234_goto_d3(struct sii9234 *ctx) in sii9234_goto_d3() argument
549 dev_dbg(ctx->dev, "sii9234: detection started d3\n"); in sii9234_goto_d3()
551 ret = sii9234_reset(ctx); in sii9234_goto_d3()
555 hdmi_writeb(ctx, 0x01, 0x03); in sii9234_goto_d3()
556 tpi_writebm(ctx, TPI_DPD_REG, 0, 1); in sii9234_goto_d3()
558 sii9234_clear_error(ctx); in sii9234_goto_d3()
560 ctx->state = ST_D3; in sii9234_goto_d3()
564 dev_err(ctx->dev, "%s failed\n", __func__); in sii9234_goto_d3()
568 static int sii9234_hw_on(struct sii9234 *ctx) in sii9234_hw_on() argument
570 return regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in sii9234_hw_on()
573 static void sii9234_hw_off(struct sii9234 *ctx) in sii9234_hw_off() argument
575 gpiod_set_value(ctx->gpio_reset, 1); in sii9234_hw_off()
577 regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in sii9234_hw_off()
580 static void sii9234_hw_reset(struct sii9234 *ctx) in sii9234_hw_reset() argument
582 gpiod_set_value(ctx->gpio_reset, 1); in sii9234_hw_reset()
584 gpiod_set_value(ctx->gpio_reset, 0); in sii9234_hw_reset()
587 static void sii9234_cable_in(struct sii9234 *ctx) in sii9234_cable_in() argument
591 mutex_lock(&ctx->lock); in sii9234_cable_in()
592 if (ctx->state != ST_OFF) in sii9234_cable_in()
594 ret = sii9234_hw_on(ctx); in sii9234_cable_in()
598 sii9234_hw_reset(ctx); in sii9234_cable_in()
599 sii9234_goto_d3(ctx); in sii9234_cable_in()
601 enable_irq(to_i2c_client(ctx->dev)->irq); in sii9234_cable_in()
604 mutex_unlock(&ctx->lock); in sii9234_cable_in()
607 static void sii9234_cable_out(struct sii9234 *ctx) in sii9234_cable_out() argument
609 mutex_lock(&ctx->lock); in sii9234_cable_out()
611 if (ctx->state == ST_OFF) in sii9234_cable_out()
614 disable_irq(to_i2c_client(ctx->dev)->irq); in sii9234_cable_out()
615 tpi_writeb(ctx, TPI_DPD_REG, 0); in sii9234_cable_out()
617 sii9234_hw_off(ctx); in sii9234_cable_out()
619 ctx->state = ST_OFF; in sii9234_cable_out()
622 mutex_unlock(&ctx->lock); in sii9234_cable_out()
625 static enum sii9234_state sii9234_rgnd_ready_irq(struct sii9234 *ctx) in sii9234_rgnd_ready_irq() argument
629 if (ctx->state == ST_D3) { in sii9234_rgnd_ready_irq()
632 dev_dbg(ctx->dev, "RGND_READY_INT\n"); in sii9234_rgnd_ready_irq()
633 sii9234_hw_reset(ctx); in sii9234_rgnd_ready_irq()
635 ret = sii9234_reset(ctx); in sii9234_rgnd_ready_irq()
637 dev_err(ctx->dev, "sii9234_reset() failed\n"); in sii9234_rgnd_ready_irq()
645 if (ctx->state != ST_RGND_INIT) in sii9234_rgnd_ready_irq()
648 value = mhl_tx_readb(ctx, MHL_TX_STAT2_REG); in sii9234_rgnd_ready_irq()
649 if (sii9234_clear_error(ctx)) in sii9234_rgnd_ready_irq()
653 dev_warn(ctx->dev, "RGND is not 1k\n"); in sii9234_rgnd_ready_irq()
656 dev_dbg(ctx->dev, "RGND 1K!!\n"); in sii9234_rgnd_ready_irq()
657 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, ~0, 0x8C); in sii9234_rgnd_ready_irq()
658 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL5_REG, 0x77); in sii9234_rgnd_ready_irq()
659 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, 0x05); in sii9234_rgnd_ready_irq()
660 if (sii9234_clear_error(ctx)) in sii9234_rgnd_ready_irq()
667 static enum sii9234_state sii9234_mhl_established(struct sii9234 *ctx) in sii9234_mhl_established() argument
669 dev_dbg(ctx->dev, "mhl est interrupt\n"); in sii9234_mhl_established()
672 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL1_REG, 0x10); in sii9234_mhl_established()
674 cbus_writeb(ctx, 0x07, 0x32); in sii9234_mhl_established()
675 cbus_writebm(ctx, 0x44, ~0, 1 << 1); in sii9234_mhl_established()
677 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, ~0, 1); in sii9234_mhl_established()
678 mhl_tx_writeb(ctx, MHL_TX_INTR1_ENABLE_REG, in sii9234_mhl_established()
681 if (sii9234_clear_error(ctx)) in sii9234_mhl_established()
687 static enum sii9234_state sii9234_hpd_change(struct sii9234 *ctx) in sii9234_hpd_change() argument
691 value = cbus_readb(ctx, CBUS_MSC_REQ_ABORT_REASON_REG); in sii9234_hpd_change()
692 if (sii9234_clear_error(ctx)) in sii9234_hpd_change()
697 sii9234_tmds_control(ctx, true); in sii9234_hpd_change()
700 sii9234_tmds_control(ctx, false); in sii9234_hpd_change()
703 return ctx->state; in sii9234_hpd_change()
706 static enum sii9234_state sii9234_rsen_change(struct sii9234 *ctx) in sii9234_rsen_change() argument
711 if (ctx->state != ST_RGND_1K) { in sii9234_rsen_change()
712 dev_err(ctx->dev, "RSEN_HIGH without RGND_1K\n"); in sii9234_rsen_change()
715 value = mhl_tx_readb(ctx, MHL_TX_SYSSTAT_REG); in sii9234_rsen_change()
720 dev_dbg(ctx->dev, "MHL cable connected.. RSEN High\n"); in sii9234_rsen_change()
723 dev_dbg(ctx->dev, "RSEN lost\n"); in sii9234_rsen_change()
732 value = mhl_tx_readb(ctx, MHL_TX_SYSSTAT_REG); in sii9234_rsen_change()
735 dev_dbg(ctx->dev, "sys_stat: %x\n", value); in sii9234_rsen_change()
738 dev_dbg(ctx->dev, "RSEN recovery\n"); in sii9234_rsen_change()
741 dev_dbg(ctx->dev, "RSEN Really LOW\n"); in sii9234_rsen_change()
743 sii9234_tmds_control(ctx, false); in sii9234_rsen_change()
744 force_usb_id_switch_open(ctx); in sii9234_rsen_change()
745 release_usb_id_switch_open(ctx); in sii9234_rsen_change()
752 struct sii9234 *ctx = data; in sii9234_irq_thread() local
757 dev_dbg(ctx->dev, "%s\n", __func__); in sii9234_irq_thread()
759 mutex_lock(&ctx->lock); in sii9234_irq_thread()
761 intr1 = mhl_tx_readb(ctx, MHL_TX_INTR1_REG); in sii9234_irq_thread()
762 intr4 = mhl_tx_readb(ctx, MHL_TX_INTR4_REG); in sii9234_irq_thread()
763 intr1_en = mhl_tx_readb(ctx, MHL_TX_INTR1_ENABLE_REG); in sii9234_irq_thread()
764 intr4_en = mhl_tx_readb(ctx, MHL_TX_INTR4_ENABLE_REG); in sii9234_irq_thread()
765 cbus_intr1 = cbus_readb(ctx, CBUS_INT_STATUS_1_REG); in sii9234_irq_thread()
766 cbus_intr2 = cbus_readb(ctx, CBUS_INT_STATUS_2_REG); in sii9234_irq_thread()
768 if (sii9234_clear_error(ctx)) in sii9234_irq_thread()
771 dev_dbg(ctx->dev, "irq %02x/%02x %02x/%02x %02x/%02x\n", in sii9234_irq_thread()
775 ctx->state = sii9234_rgnd_ready_irq(ctx); in sii9234_irq_thread()
777 ctx->state = sii9234_rsen_change(ctx); in sii9234_irq_thread()
779 ctx->state = sii9234_mhl_established(ctx); in sii9234_irq_thread()
781 ctx->state = sii9234_hpd_change(ctx); in sii9234_irq_thread()
783 ctx->state = ST_FAILURE; in sii9234_irq_thread()
785 ctx->state = ST_FAILURE_DISCOVERY; in sii9234_irq_thread()
789 mhl_tx_writeb(ctx, MHL_TX_INTR1_REG, intr1); in sii9234_irq_thread()
790 mhl_tx_writeb(ctx, MHL_TX_INTR4_REG, intr4); in sii9234_irq_thread()
791 cbus_writeb(ctx, CBUS_MHL_STATUS_REG_0, 0xFF); in sii9234_irq_thread()
792 cbus_writeb(ctx, CBUS_MHL_STATUS_REG_1, 0xFF); in sii9234_irq_thread()
793 cbus_writeb(ctx, CBUS_INT_STATUS_1_REG, cbus_intr1); in sii9234_irq_thread()
794 cbus_writeb(ctx, CBUS_INT_STATUS_2_REG, cbus_intr2); in sii9234_irq_thread()
796 sii9234_clear_error(ctx); in sii9234_irq_thread()
798 if (ctx->state == ST_FAILURE) { in sii9234_irq_thread()
799 dev_dbg(ctx->dev, "try to reset after failure\n"); in sii9234_irq_thread()
800 sii9234_hw_reset(ctx); in sii9234_irq_thread()
801 sii9234_goto_d3(ctx); in sii9234_irq_thread()
804 if (ctx->state == ST_FAILURE_DISCOVERY) { in sii9234_irq_thread()
805 dev_err(ctx->dev, "discovery failed, no power for MHL?\n"); in sii9234_irq_thread()
806 tpi_writebm(ctx, TPI_DPD_REG, 0, 1); in sii9234_irq_thread()
807 ctx->state = ST_D3; in sii9234_irq_thread()
810 mutex_unlock(&ctx->lock); in sii9234_irq_thread()
815 static int sii9234_init_resources(struct sii9234 *ctx, in sii9234_init_resources() argument
821 if (!ctx->dev->of_node) { in sii9234_init_resources()
822 dev_err(ctx->dev, "not DT device\n"); in sii9234_init_resources()
826 ctx->gpio_reset = devm_gpiod_get(ctx->dev, "reset", GPIOD_OUT_LOW); in sii9234_init_resources()
827 if (IS_ERR(ctx->gpio_reset)) { in sii9234_init_resources()
828 dev_err(ctx->dev, "failed to get reset gpio from DT\n"); in sii9234_init_resources()
829 return PTR_ERR(ctx->gpio_reset); in sii9234_init_resources()
832 ctx->supplies[0].supply = "avcc12"; in sii9234_init_resources()
833 ctx->supplies[1].supply = "avcc33"; in sii9234_init_resources()
834 ctx->supplies[2].supply = "iovcc18"; in sii9234_init_resources()
835 ctx->supplies[3].supply = "cvcc12"; in sii9234_init_resources()
836 ret = devm_regulator_bulk_get(ctx->dev, 4, ctx->supplies); in sii9234_init_resources()
838 dev_err(ctx->dev, "regulator_bulk failed\n"); in sii9234_init_resources()
842 ctx->client[I2C_MHL] = client; in sii9234_init_resources()
844 ctx->client[I2C_TPI] = i2c_new_dummy(adapter, I2C_TPI_ADDR); in sii9234_init_resources()
845 if (!ctx->client[I2C_TPI]) { in sii9234_init_resources()
846 dev_err(ctx->dev, "failed to create TPI client\n"); in sii9234_init_resources()
850 ctx->client[I2C_HDMI] = i2c_new_dummy(adapter, I2C_HDMI_ADDR); in sii9234_init_resources()
851 if (!ctx->client[I2C_HDMI]) { in sii9234_init_resources()
852 dev_err(ctx->dev, "failed to create HDMI RX client\n"); in sii9234_init_resources()
856 ctx->client[I2C_CBUS] = i2c_new_dummy(adapter, I2C_CBUS_ADDR); in sii9234_init_resources()
857 if (!ctx->client[I2C_CBUS]) { in sii9234_init_resources()
858 dev_err(ctx->dev, "failed to create CBUS client\n"); in sii9234_init_resources()
865 i2c_unregister_device(ctx->client[I2C_HDMI]); in sii9234_init_resources()
867 i2c_unregister_device(ctx->client[I2C_TPI]); in sii9234_init_resources()
872 static void sii9234_deinit_resources(struct sii9234 *ctx) in sii9234_deinit_resources() argument
874 i2c_unregister_device(ctx->client[I2C_CBUS]); in sii9234_deinit_resources()
875 i2c_unregister_device(ctx->client[I2C_HDMI]); in sii9234_deinit_resources()
876 i2c_unregister_device(ctx->client[I2C_TPI]); in sii9234_deinit_resources()
901 struct sii9234 *ctx; in sii9234_probe() local
905 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); in sii9234_probe()
906 if (!ctx) in sii9234_probe()
909 ctx->dev = dev; in sii9234_probe()
910 mutex_init(&ctx->lock); in sii9234_probe()
926 "sii9234", ctx); in sii9234_probe()
932 ret = sii9234_init_resources(ctx, client); in sii9234_probe()
936 i2c_set_clientdata(client, ctx); in sii9234_probe()
938 ctx->bridge.funcs = &sii9234_bridge_funcs; in sii9234_probe()
939 ctx->bridge.of_node = dev->of_node; in sii9234_probe()
940 drm_bridge_add(&ctx->bridge); in sii9234_probe()
942 sii9234_cable_in(ctx); in sii9234_probe()
949 struct sii9234 *ctx = i2c_get_clientdata(client); in sii9234_remove() local
951 sii9234_cable_out(ctx); in sii9234_remove()
952 drm_bridge_remove(&ctx->bridge); in sii9234_remove()
953 sii9234_deinit_resources(ctx); in sii9234_remove()