Lines Matching refs:ctx
194 static int sii9234_writeb(struct sii9234 *ctx, int id, int offset, in sii9234_writeb() argument
198 struct i2c_client *client = ctx->client[id]; in sii9234_writeb()
200 if (ctx->i2c_error) in sii9234_writeb()
201 return ctx->i2c_error; in sii9234_writeb()
205 dev_err(ctx->dev, "writeb: %4s[0x%02x] <- 0x%02x\n", in sii9234_writeb()
207 ctx->i2c_error = ret; in sii9234_writeb()
212 static int sii9234_writebm(struct sii9234 *ctx, int id, int offset, in sii9234_writebm() argument
216 struct i2c_client *client = ctx->client[id]; in sii9234_writebm()
218 if (ctx->i2c_error) in sii9234_writebm()
219 return ctx->i2c_error; in sii9234_writebm()
223 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
225 ctx->i2c_error = ret; in sii9234_writebm()
231 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
233 ctx->i2c_error = ret; in sii9234_writebm()
241 dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n", in sii9234_writebm()
243 ctx->i2c_error = ret; in sii9234_writebm()
249 static int sii9234_readb(struct sii9234 *ctx, int id, int offset) in sii9234_readb() argument
252 struct i2c_client *client = ctx->client[id]; in sii9234_readb()
254 if (ctx->i2c_error) in sii9234_readb()
255 return ctx->i2c_error; in sii9234_readb()
259 dev_err(ctx->dev, "readb: %4s[0x%02x]\n", in sii9234_readb()
261 ctx->i2c_error = ret; in sii9234_readb()
267 dev_err(ctx->dev, "readb: %4s[0x%02x]\n", in sii9234_readb()
269 ctx->i2c_error = ret; in sii9234_readb()
275 static int sii9234_clear_error(struct sii9234 *ctx) in sii9234_clear_error() argument
277 int ret = ctx->i2c_error; in sii9234_clear_error()
279 ctx->i2c_error = 0; in sii9234_clear_error()
309 static u8 sii9234_tmds_control(struct sii9234 *ctx, bool enable) in sii9234_tmds_control() argument
311 mhl_tx_writebm(ctx, MHL_TX_TMDS_CCTRL, enable ? ~0 : 0, in sii9234_tmds_control()
313 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, enable ? ~0 : 0, in sii9234_tmds_control()
315 return sii9234_clear_error(ctx); in sii9234_tmds_control()
318 static int sii9234_cbus_reset(struct sii9234 *ctx) in sii9234_cbus_reset() argument
322 mhl_tx_writebm(ctx, MHL_TX_SRST, ~0, BIT_CBUS_RESET); in sii9234_cbus_reset()
324 mhl_tx_writebm(ctx, MHL_TX_SRST, 0, BIT_CBUS_RESET); in sii9234_cbus_reset()
331 cbus_writeb(ctx, 0xE0 + i, 0xF2); in sii9234_cbus_reset()
336 cbus_writeb(ctx, 0xF0 + i, 0xF2); in sii9234_cbus_reset()
339 return sii9234_clear_error(ctx); in sii9234_cbus_reset()
343 static int sii9234_cbus_init(struct sii9234 *ctx) in sii9234_cbus_init() argument
345 cbus_writeb(ctx, 0x07, 0xF2); in sii9234_cbus_init()
346 cbus_writeb(ctx, 0x40, 0x03); in sii9234_cbus_init()
347 cbus_writeb(ctx, 0x42, 0x06); in sii9234_cbus_init()
348 cbus_writeb(ctx, 0x36, 0x0C); in sii9234_cbus_init()
349 cbus_writeb(ctx, 0x3D, 0xFD); in sii9234_cbus_init()
350 cbus_writeb(ctx, 0x1C, 0x01); in sii9234_cbus_init()
351 cbus_writeb(ctx, 0x1D, 0x0F); in sii9234_cbus_init()
352 cbus_writeb(ctx, 0x44, 0x02); in sii9234_cbus_init()
354 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEV_STATE, 0x00); in sii9234_cbus_init()
355 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_MHL_VERSION, in sii9234_cbus_init()
357 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_CAT, in sii9234_cbus_init()
359 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_ADOPTER_ID_H, 0x01); in sii9234_cbus_init()
360 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_ADOPTER_ID_L, 0x41); in sii9234_cbus_init()
361 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_VID_LINK_MODE, in sii9234_cbus_init()
363 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_VIDEO_TYPE, in sii9234_cbus_init()
365 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_LOG_DEV_MAP, in sii9234_cbus_init()
367 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_BANDWIDTH, 0x0F); in sii9234_cbus_init()
368 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_FEATURE_FLAG, in sii9234_cbus_init()
371 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEVICE_ID_H, 0x0); in sii9234_cbus_init()
372 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_DEVICE_ID_L, 0x0); in sii9234_cbus_init()
373 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_SCRATCHPAD_SIZE, in sii9234_cbus_init()
375 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_INT_STAT_SIZE, in sii9234_cbus_init()
377 cbus_writeb(ctx, CBUS_DEVCAP_OFFSET + MHL_DCAP_RESERVED, 0); in sii9234_cbus_init()
378 cbus_writebm(ctx, 0x31, 0x0C, 0x0C); in sii9234_cbus_init()
379 cbus_writeb(ctx, 0x30, 0x01); in sii9234_cbus_init()
380 cbus_writebm(ctx, 0x3C, 0x30, 0x38); in sii9234_cbus_init()
381 cbus_writebm(ctx, 0x22, 0x0D, 0x0F); in sii9234_cbus_init()
382 cbus_writebm(ctx, 0x2E, 0x15, 0x15); in sii9234_cbus_init()
383 cbus_writeb(ctx, CBUS_INTR1_ENABLE_REG, 0); in sii9234_cbus_init()
384 cbus_writeb(ctx, CBUS_INTR2_ENABLE_REG, 0); in sii9234_cbus_init()
386 return sii9234_clear_error(ctx); in sii9234_cbus_init()
389 static void force_usb_id_switch_open(struct sii9234 *ctx) in force_usb_id_switch_open() argument
392 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, 0, 0x01); in force_usb_id_switch_open()
394 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, USB_ID_OVR); in force_usb_id_switch_open()
395 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL3_REG, ~0, 0x86); in force_usb_id_switch_open()
397 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 0x30); in force_usb_id_switch_open()
400 static void release_usb_id_switch_open(struct sii9234 *ctx) in release_usb_id_switch_open() argument
404 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, 0, USB_ID_OVR); in release_usb_id_switch_open()
406 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, ~0, 0x01); in release_usb_id_switch_open()
409 static int sii9234_power_init(struct sii9234 *ctx) in sii9234_power_init() argument
412 tpi_writeb(ctx, TPI_DPD_REG, 0x3F); in sii9234_power_init()
414 hdmi_writeb(ctx, HDMI_RX_TMDS_CLK_EN_REG, 0x01); in sii9234_power_init()
416 hdmi_writeb(ctx, HDMI_RX_TMDS_CH_EN_REG, 0x15); in sii9234_power_init()
418 mhl_tx_writeb(ctx, 0x08, 0x35); in sii9234_power_init()
419 return sii9234_clear_error(ctx); in sii9234_power_init()
422 static int sii9234_hdmi_init(struct sii9234 *ctx) in sii9234_hdmi_init() argument
424 hdmi_writeb(ctx, HDMI_RX_TMDS0_CCTRL1_REG, 0xC1); in sii9234_hdmi_init()
425 hdmi_writeb(ctx, HDMI_RX_PLL_CALREFSEL_REG, 0x03); in sii9234_hdmi_init()
426 hdmi_writeb(ctx, HDMI_RX_PLL_VCOCAL_REG, 0x20); in sii9234_hdmi_init()
427 hdmi_writeb(ctx, HDMI_RX_EQ_DATA0_REG, 0x8A); in sii9234_hdmi_init()
428 hdmi_writeb(ctx, HDMI_RX_EQ_DATA1_REG, 0x6A); in sii9234_hdmi_init()
429 hdmi_writeb(ctx, HDMI_RX_EQ_DATA2_REG, 0xAA); in sii9234_hdmi_init()
430 hdmi_writeb(ctx, HDMI_RX_EQ_DATA3_REG, 0xCA); in sii9234_hdmi_init()
431 hdmi_writeb(ctx, HDMI_RX_EQ_DATA4_REG, 0xEA); in sii9234_hdmi_init()
432 hdmi_writeb(ctx, HDMI_RX_TMDS_ZONE_CTRL_REG, 0xA0); in sii9234_hdmi_init()
433 hdmi_writeb(ctx, HDMI_RX_TMDS_MODE_CTRL_REG, 0x00); in sii9234_hdmi_init()
434 mhl_tx_writeb(ctx, MHL_TX_TMDS_CCTRL, 0x34); in sii9234_hdmi_init()
435 hdmi_writeb(ctx, 0x45, 0x44); in sii9234_hdmi_init()
436 hdmi_writeb(ctx, 0x31, 0x0A); in sii9234_hdmi_init()
437 hdmi_writeb(ctx, HDMI_RX_TMDS0_CCTRL1_REG, 0xC1); in sii9234_hdmi_init()
439 return sii9234_clear_error(ctx); in sii9234_hdmi_init()
442 static int sii9234_mhl_tx_ctl_int(struct sii9234 *ctx) in sii9234_mhl_tx_ctl_int() argument
444 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL1_REG, 0xD0); in sii9234_mhl_tx_ctl_int()
445 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL2_REG, 0xFC); in sii9234_mhl_tx_ctl_int()
446 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL4_REG, 0xEB); in sii9234_mhl_tx_ctl_int()
447 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL7_REG, 0x0C); in sii9234_mhl_tx_ctl_int()
449 return sii9234_clear_error(ctx); in sii9234_mhl_tx_ctl_int()
452 static int sii9234_reset(struct sii9234 *ctx) in sii9234_reset() argument
456 sii9234_clear_error(ctx); in sii9234_reset()
458 ret = sii9234_power_init(ctx); in sii9234_reset()
461 ret = sii9234_cbus_reset(ctx); in sii9234_reset()
464 ret = sii9234_hdmi_init(ctx); in sii9234_reset()
467 ret = sii9234_mhl_tx_ctl_int(ctx); in sii9234_reset()
472 mhl_tx_writeb(ctx, 0x2B, 0x01); in sii9234_reset()
474 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, 0x04, 0x06); in sii9234_reset()
476 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL2_REG, (1 << 7) /* Reserved */ in sii9234_reset()
483 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL5_REG, 0x77); in sii9234_reset()
484 cbus_writebm(ctx, CBUS_LINK_CONTROL_2_REG, ~0, MHL_INIT_TIMEOUT); in sii9234_reset()
485 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL6_REG, 0xA0); in sii9234_reset()
487 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL6_REG, BLOCK_RGND_INT | in sii9234_reset()
490 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL8_REG, 0); in sii9234_reset()
492 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, USB_ID_OVR); in sii9234_reset()
502 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL3_REG, ~0, 0x86); in sii9234_reset()
507 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, ~0, 0x8C); in sii9234_reset()
509 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 0x06); in sii9234_reset()
514 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, 0, USB_ID_OVR); in sii9234_reset()
515 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL1_REG, 0x27); in sii9234_reset()
517 ret = sii9234_clear_error(ctx); in sii9234_reset()
520 ret = sii9234_cbus_init(ctx); in sii9234_reset()
525 mhl_tx_writeb(ctx, 0x05, 0x04); in sii9234_reset()
527 mhl_tx_writeb(ctx, 0x0D, 0x1C); in sii9234_reset()
528 mhl_tx_writeb(ctx, MHL_TX_INTR4_ENABLE_REG, in sii9234_reset()
531 mhl_tx_writeb(ctx, MHL_TX_INTR1_ENABLE_REG, 0x60); in sii9234_reset()
534 force_usb_id_switch_open(ctx); in sii9234_reset()
535 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, 0, 0xF0); in sii9234_reset()
536 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL5_REG, 0, 0x03); in sii9234_reset()
537 release_usb_id_switch_open(ctx); in sii9234_reset()
540 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, 0, 1 << 5); in sii9234_reset()
541 mhl_tx_writebm(ctx, MHL_TX_INT_CTRL_REG, ~0, 1 << 4); in sii9234_reset()
543 return sii9234_clear_error(ctx); in sii9234_reset()
546 static int sii9234_goto_d3(struct sii9234 *ctx) in sii9234_goto_d3() argument
550 dev_dbg(ctx->dev, "sii9234: detection started d3\n"); in sii9234_goto_d3()
552 ret = sii9234_reset(ctx); in sii9234_goto_d3()
556 hdmi_writeb(ctx, 0x01, 0x03); in sii9234_goto_d3()
557 tpi_writebm(ctx, TPI_DPD_REG, 0, 1); in sii9234_goto_d3()
559 sii9234_clear_error(ctx); in sii9234_goto_d3()
561 ctx->state = ST_D3; in sii9234_goto_d3()
565 dev_err(ctx->dev, "%s failed\n", __func__); in sii9234_goto_d3()
569 static int sii9234_hw_on(struct sii9234 *ctx) in sii9234_hw_on() argument
571 return regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in sii9234_hw_on()
574 static void sii9234_hw_off(struct sii9234 *ctx) in sii9234_hw_off() argument
576 gpiod_set_value(ctx->gpio_reset, 1); in sii9234_hw_off()
578 regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in sii9234_hw_off()
581 static void sii9234_hw_reset(struct sii9234 *ctx) in sii9234_hw_reset() argument
583 gpiod_set_value(ctx->gpio_reset, 1); in sii9234_hw_reset()
585 gpiod_set_value(ctx->gpio_reset, 0); in sii9234_hw_reset()
588 static void sii9234_cable_in(struct sii9234 *ctx) in sii9234_cable_in() argument
592 mutex_lock(&ctx->lock); in sii9234_cable_in()
593 if (ctx->state != ST_OFF) in sii9234_cable_in()
595 ret = sii9234_hw_on(ctx); in sii9234_cable_in()
599 sii9234_hw_reset(ctx); in sii9234_cable_in()
600 sii9234_goto_d3(ctx); in sii9234_cable_in()
602 enable_irq(to_i2c_client(ctx->dev)->irq); in sii9234_cable_in()
605 mutex_unlock(&ctx->lock); in sii9234_cable_in()
608 static void sii9234_cable_out(struct sii9234 *ctx) in sii9234_cable_out() argument
610 mutex_lock(&ctx->lock); in sii9234_cable_out()
612 if (ctx->state == ST_OFF) in sii9234_cable_out()
615 disable_irq(to_i2c_client(ctx->dev)->irq); in sii9234_cable_out()
616 tpi_writeb(ctx, TPI_DPD_REG, 0); in sii9234_cable_out()
618 sii9234_hw_off(ctx); in sii9234_cable_out()
620 ctx->state = ST_OFF; in sii9234_cable_out()
623 mutex_unlock(&ctx->lock); in sii9234_cable_out()
626 static enum sii9234_state sii9234_rgnd_ready_irq(struct sii9234 *ctx) in sii9234_rgnd_ready_irq() argument
630 if (ctx->state == ST_D3) { in sii9234_rgnd_ready_irq()
633 dev_dbg(ctx->dev, "RGND_READY_INT\n"); in sii9234_rgnd_ready_irq()
634 sii9234_hw_reset(ctx); in sii9234_rgnd_ready_irq()
636 ret = sii9234_reset(ctx); in sii9234_rgnd_ready_irq()
638 dev_err(ctx->dev, "sii9234_reset() failed\n"); in sii9234_rgnd_ready_irq()
646 if (ctx->state != ST_RGND_INIT) in sii9234_rgnd_ready_irq()
649 value = mhl_tx_readb(ctx, MHL_TX_STAT2_REG); in sii9234_rgnd_ready_irq()
650 if (sii9234_clear_error(ctx)) in sii9234_rgnd_ready_irq()
654 dev_warn(ctx->dev, "RGND is not 1k\n"); in sii9234_rgnd_ready_irq()
657 dev_dbg(ctx->dev, "RGND 1K!!\n"); in sii9234_rgnd_ready_irq()
658 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL4_REG, ~0, 0x8C); in sii9234_rgnd_ready_irq()
659 mhl_tx_writeb(ctx, MHL_TX_DISC_CTRL5_REG, 0x77); in sii9234_rgnd_ready_irq()
660 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL6_REG, ~0, 0x05); in sii9234_rgnd_ready_irq()
661 if (sii9234_clear_error(ctx)) in sii9234_rgnd_ready_irq()
668 static enum sii9234_state sii9234_mhl_established(struct sii9234 *ctx) in sii9234_mhl_established() argument
670 dev_dbg(ctx->dev, "mhl est interrupt\n"); in sii9234_mhl_established()
673 mhl_tx_writeb(ctx, MHL_TX_MHLTX_CTL1_REG, 0x10); in sii9234_mhl_established()
675 cbus_writeb(ctx, 0x07, 0x32); in sii9234_mhl_established()
676 cbus_writebm(ctx, 0x44, ~0, 1 << 1); in sii9234_mhl_established()
678 mhl_tx_writebm(ctx, MHL_TX_DISC_CTRL1_REG, ~0, 1); in sii9234_mhl_established()
679 mhl_tx_writeb(ctx, MHL_TX_INTR1_ENABLE_REG, in sii9234_mhl_established()
682 if (sii9234_clear_error(ctx)) in sii9234_mhl_established()
688 static enum sii9234_state sii9234_hpd_change(struct sii9234 *ctx) in sii9234_hpd_change() argument
692 value = cbus_readb(ctx, CBUS_MSC_REQ_ABORT_REASON_REG); in sii9234_hpd_change()
693 if (sii9234_clear_error(ctx)) in sii9234_hpd_change()
698 sii9234_tmds_control(ctx, true); in sii9234_hpd_change()
701 sii9234_tmds_control(ctx, false); in sii9234_hpd_change()
704 return ctx->state; in sii9234_hpd_change()
707 static enum sii9234_state sii9234_rsen_change(struct sii9234 *ctx) in sii9234_rsen_change() argument
712 if (ctx->state != ST_RGND_1K) { in sii9234_rsen_change()
713 dev_err(ctx->dev, "RSEN_HIGH without RGND_1K\n"); in sii9234_rsen_change()
716 value = mhl_tx_readb(ctx, MHL_TX_SYSSTAT_REG); in sii9234_rsen_change()
721 dev_dbg(ctx->dev, "MHL cable connected.. RSEN High\n"); in sii9234_rsen_change()
724 dev_dbg(ctx->dev, "RSEN lost\n"); in sii9234_rsen_change()
733 value = mhl_tx_readb(ctx, MHL_TX_SYSSTAT_REG); in sii9234_rsen_change()
736 dev_dbg(ctx->dev, "sys_stat: %x\n", value); in sii9234_rsen_change()
739 dev_dbg(ctx->dev, "RSEN recovery\n"); in sii9234_rsen_change()
742 dev_dbg(ctx->dev, "RSEN Really LOW\n"); in sii9234_rsen_change()
744 sii9234_tmds_control(ctx, false); in sii9234_rsen_change()
745 force_usb_id_switch_open(ctx); in sii9234_rsen_change()
746 release_usb_id_switch_open(ctx); in sii9234_rsen_change()
753 struct sii9234 *ctx = data; in sii9234_irq_thread() local
758 dev_dbg(ctx->dev, "%s\n", __func__); in sii9234_irq_thread()
760 mutex_lock(&ctx->lock); in sii9234_irq_thread()
762 intr1 = mhl_tx_readb(ctx, MHL_TX_INTR1_REG); in sii9234_irq_thread()
763 intr4 = mhl_tx_readb(ctx, MHL_TX_INTR4_REG); in sii9234_irq_thread()
764 intr1_en = mhl_tx_readb(ctx, MHL_TX_INTR1_ENABLE_REG); in sii9234_irq_thread()
765 intr4_en = mhl_tx_readb(ctx, MHL_TX_INTR4_ENABLE_REG); in sii9234_irq_thread()
766 cbus_intr1 = cbus_readb(ctx, CBUS_INT_STATUS_1_REG); in sii9234_irq_thread()
767 cbus_intr2 = cbus_readb(ctx, CBUS_INT_STATUS_2_REG); in sii9234_irq_thread()
769 if (sii9234_clear_error(ctx)) in sii9234_irq_thread()
772 dev_dbg(ctx->dev, "irq %02x/%02x %02x/%02x %02x/%02x\n", in sii9234_irq_thread()
776 ctx->state = sii9234_rgnd_ready_irq(ctx); in sii9234_irq_thread()
778 ctx->state = sii9234_rsen_change(ctx); in sii9234_irq_thread()
780 ctx->state = sii9234_mhl_established(ctx); in sii9234_irq_thread()
782 ctx->state = sii9234_hpd_change(ctx); in sii9234_irq_thread()
784 ctx->state = ST_FAILURE; in sii9234_irq_thread()
786 ctx->state = ST_FAILURE_DISCOVERY; in sii9234_irq_thread()
790 mhl_tx_writeb(ctx, MHL_TX_INTR1_REG, intr1); in sii9234_irq_thread()
791 mhl_tx_writeb(ctx, MHL_TX_INTR4_REG, intr4); in sii9234_irq_thread()
792 cbus_writeb(ctx, CBUS_MHL_STATUS_REG_0, 0xFF); in sii9234_irq_thread()
793 cbus_writeb(ctx, CBUS_MHL_STATUS_REG_1, 0xFF); in sii9234_irq_thread()
794 cbus_writeb(ctx, CBUS_INT_STATUS_1_REG, cbus_intr1); in sii9234_irq_thread()
795 cbus_writeb(ctx, CBUS_INT_STATUS_2_REG, cbus_intr2); in sii9234_irq_thread()
797 sii9234_clear_error(ctx); in sii9234_irq_thread()
799 if (ctx->state == ST_FAILURE) { in sii9234_irq_thread()
800 dev_dbg(ctx->dev, "try to reset after failure\n"); in sii9234_irq_thread()
801 sii9234_hw_reset(ctx); in sii9234_irq_thread()
802 sii9234_goto_d3(ctx); in sii9234_irq_thread()
805 if (ctx->state == ST_FAILURE_DISCOVERY) { in sii9234_irq_thread()
806 dev_err(ctx->dev, "discovery failed, no power for MHL?\n"); in sii9234_irq_thread()
807 tpi_writebm(ctx, TPI_DPD_REG, 0, 1); in sii9234_irq_thread()
808 ctx->state = ST_D3; in sii9234_irq_thread()
811 mutex_unlock(&ctx->lock); in sii9234_irq_thread()
816 static int sii9234_init_resources(struct sii9234 *ctx, in sii9234_init_resources() argument
822 if (!ctx->dev->of_node) { in sii9234_init_resources()
823 dev_err(ctx->dev, "not DT device\n"); in sii9234_init_resources()
827 ctx->gpio_reset = devm_gpiod_get(ctx->dev, "reset", GPIOD_OUT_LOW); in sii9234_init_resources()
828 if (IS_ERR(ctx->gpio_reset)) { in sii9234_init_resources()
829 dev_err(ctx->dev, "failed to get reset gpio from DT\n"); in sii9234_init_resources()
830 return PTR_ERR(ctx->gpio_reset); in sii9234_init_resources()
833 ctx->supplies[0].supply = "avcc12"; in sii9234_init_resources()
834 ctx->supplies[1].supply = "avcc33"; in sii9234_init_resources()
835 ctx->supplies[2].supply = "iovcc18"; in sii9234_init_resources()
836 ctx->supplies[3].supply = "cvcc12"; in sii9234_init_resources()
837 ret = devm_regulator_bulk_get(ctx->dev, 4, ctx->supplies); in sii9234_init_resources()
840 dev_err(ctx->dev, "regulator_bulk failed\n"); in sii9234_init_resources()
844 ctx->client[I2C_MHL] = client; in sii9234_init_resources()
846 ctx->client[I2C_TPI] = devm_i2c_new_dummy_device(&client->dev, adapter, in sii9234_init_resources()
848 if (IS_ERR(ctx->client[I2C_TPI])) { in sii9234_init_resources()
849 dev_err(ctx->dev, "failed to create TPI client\n"); in sii9234_init_resources()
850 return PTR_ERR(ctx->client[I2C_TPI]); in sii9234_init_resources()
853 ctx->client[I2C_HDMI] = devm_i2c_new_dummy_device(&client->dev, adapter, in sii9234_init_resources()
855 if (IS_ERR(ctx->client[I2C_HDMI])) { in sii9234_init_resources()
856 dev_err(ctx->dev, "failed to create HDMI RX client\n"); in sii9234_init_resources()
857 return PTR_ERR(ctx->client[I2C_HDMI]); in sii9234_init_resources()
860 ctx->client[I2C_CBUS] = devm_i2c_new_dummy_device(&client->dev, adapter, in sii9234_init_resources()
862 if (IS_ERR(ctx->client[I2C_CBUS])) { in sii9234_init_resources()
863 dev_err(ctx->dev, "failed to create CBUS client\n"); in sii9234_init_resources()
864 return PTR_ERR(ctx->client[I2C_CBUS]); in sii9234_init_resources()
893 struct sii9234 *ctx; in sii9234_probe() local
897 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); in sii9234_probe()
898 if (!ctx) in sii9234_probe()
901 ctx->dev = dev; in sii9234_probe()
902 mutex_init(&ctx->lock); in sii9234_probe()
918 "sii9234", ctx); in sii9234_probe()
924 ret = sii9234_init_resources(ctx, client); in sii9234_probe()
928 i2c_set_clientdata(client, ctx); in sii9234_probe()
930 ctx->bridge.funcs = &sii9234_bridge_funcs; in sii9234_probe()
931 ctx->bridge.of_node = dev->of_node; in sii9234_probe()
932 drm_bridge_add(&ctx->bridge); in sii9234_probe()
934 sii9234_cable_in(ctx); in sii9234_probe()
941 struct sii9234 *ctx = i2c_get_clientdata(client); in sii9234_remove() local
943 sii9234_cable_out(ctx); in sii9234_remove()
944 drm_bridge_remove(&ctx->bridge); in sii9234_remove()