Lines Matching refs:sii902x
166 struct sii902x { struct
227 static inline struct sii902x *bridge_to_sii902x(struct drm_bridge *bridge) in bridge_to_sii902x()
229 return container_of(bridge, struct sii902x, bridge); in bridge_to_sii902x()
232 static inline struct sii902x *connector_to_sii902x(struct drm_connector *con) in connector_to_sii902x()
234 return container_of(con, struct sii902x, connector); in connector_to_sii902x()
237 static void sii902x_reset(struct sii902x *sii902x) in sii902x_reset() argument
239 if (!sii902x->reset_gpio) in sii902x_reset()
242 gpiod_set_value_cansleep(sii902x->reset_gpio, 1); in sii902x_reset()
247 gpiod_set_value_cansleep(sii902x->reset_gpio, 0); in sii902x_reset()
250 static enum drm_connector_status sii902x_detect(struct sii902x *sii902x) in sii902x_detect() argument
254 mutex_lock(&sii902x->mutex); in sii902x_detect()
256 regmap_read(sii902x->regmap, SII902X_INT_STATUS, &status); in sii902x_detect()
258 mutex_unlock(&sii902x->mutex); in sii902x_detect()
267 struct sii902x *sii902x = connector_to_sii902x(connector); in sii902x_connector_detect() local
269 return sii902x_detect(sii902x); in sii902x_connector_detect()
281 static struct edid *sii902x_get_edid(struct sii902x *sii902x, in sii902x_get_edid() argument
286 mutex_lock(&sii902x->mutex); in sii902x_get_edid()
288 edid = drm_get_edid(connector, sii902x->i2cmux->adapter[0]); in sii902x_get_edid()
291 sii902x->sink_is_hdmi = true; in sii902x_get_edid()
293 sii902x->sink_is_hdmi = false; in sii902x_get_edid()
296 mutex_unlock(&sii902x->mutex); in sii902x_get_edid()
303 struct sii902x *sii902x = connector_to_sii902x(connector); in sii902x_get_modes() local
307 edid = sii902x_get_edid(sii902x, connector); in sii902x_get_modes()
332 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_disable() local
334 mutex_lock(&sii902x->mutex); in sii902x_bridge_disable()
336 regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, in sii902x_bridge_disable()
340 mutex_unlock(&sii902x->mutex); in sii902x_bridge_disable()
345 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_enable() local
347 mutex_lock(&sii902x->mutex); in sii902x_bridge_enable()
349 regmap_update_bits(sii902x->regmap, SII902X_PWR_STATE_CTRL, in sii902x_bridge_enable()
352 regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, in sii902x_bridge_enable()
355 mutex_unlock(&sii902x->mutex); in sii902x_bridge_enable()
362 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_mode_set() local
364 struct regmap *regmap = sii902x->regmap; in sii902x_bridge_mode_set()
370 if (sii902x->sink_is_hdmi) in sii902x_bridge_mode_set()
386 mutex_lock(&sii902x->mutex); in sii902x_bridge_mode_set()
388 ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, in sii902x_bridge_mode_set()
398 &sii902x->connector, adj); in sii902x_bridge_mode_set()
416 mutex_unlock(&sii902x->mutex); in sii902x_bridge_mode_set()
422 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_attach() local
428 return drm_bridge_attach(bridge->encoder, sii902x->next_bridge, in sii902x_bridge_attach()
431 drm_connector_helper_add(&sii902x->connector, in sii902x_bridge_attach()
435 dev_err(&sii902x->i2c->dev, in sii902x_bridge_attach()
440 ret = drm_connector_init(drm, &sii902x->connector, in sii902x_bridge_attach()
446 if (sii902x->i2c->irq > 0) in sii902x_bridge_attach()
447 sii902x->connector.polled = DRM_CONNECTOR_POLL_HPD; in sii902x_bridge_attach()
449 sii902x->connector.polled = DRM_CONNECTOR_POLL_CONNECT; in sii902x_bridge_attach()
451 ret = drm_display_info_set_bus_formats(&sii902x->connector.display_info, in sii902x_bridge_attach()
456 drm_connector_attach_encoder(&sii902x->connector, bridge->encoder); in sii902x_bridge_attach()
463 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_detect() local
465 return sii902x_detect(sii902x); in sii902x_bridge_detect()
471 struct sii902x *sii902x = bridge_to_sii902x(bridge); in sii902x_bridge_get_edid() local
473 return sii902x_get_edid(sii902x, connector); in sii902x_bridge_get_edid()
525 static int sii902x_mute(struct sii902x *sii902x, bool mute) in sii902x_mute() argument
527 struct device *dev = &sii902x->i2c->dev; in sii902x_mute()
533 return regmap_update_bits(sii902x->regmap, in sii902x_mute()
582 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_hw_params() local
654 ret = clk_prepare_enable(sii902x->audio.mclk); in sii902x_audio_hw_params()
660 if (sii902x->audio.mclk) { in sii902x_audio_hw_params()
661 mclk_rate = clk_get_rate(sii902x->audio.mclk); in sii902x_audio_hw_params()
669 mutex_lock(&sii902x->mutex); in sii902x_audio_hw_params()
671 ret = regmap_write(sii902x->regmap, in sii902x_audio_hw_params()
677 ret = regmap_write(sii902x->regmap, SII902X_TPI_I2S_INPUT_CONFIG_REG, in sii902x_audio_hw_params()
682 for (i = 0; i < ARRAY_SIZE(sii902x->audio.i2s_fifo_sequence) && in sii902x_audio_hw_params()
683 sii902x->audio.i2s_fifo_sequence[i]; i++) in sii902x_audio_hw_params()
684 regmap_write(sii902x->regmap, in sii902x_audio_hw_params()
686 sii902x->audio.i2s_fifo_sequence[i]); in sii902x_audio_hw_params()
688 ret = regmap_write(sii902x->regmap, SII902X_TPI_AUDIO_CONFIG_BYTE3_REG, in sii902x_audio_hw_params()
693 ret = regmap_bulk_write(sii902x->regmap, SII902X_TPI_I2S_STRM_HDR_BASE, in sii902x_audio_hw_params()
708 ret = regmap_bulk_write(sii902x->regmap, in sii902x_audio_hw_params()
716 ret = regmap_write(sii902x->regmap, SII902X_IND_SET_PAGE, 0x02); in sii902x_audio_hw_params()
720 ret = regmap_write(sii902x->regmap, SII902X_IND_OFFSET, 0x24); in sii902x_audio_hw_params()
724 ret = regmap_write(sii902x->regmap, SII902X_IND_VALUE, 0x02); in sii902x_audio_hw_params()
730 mutex_unlock(&sii902x->mutex); in sii902x_audio_hw_params()
733 clk_disable_unprepare(sii902x->audio.mclk); in sii902x_audio_hw_params()
743 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_shutdown() local
745 mutex_lock(&sii902x->mutex); in sii902x_audio_shutdown()
747 regmap_write(sii902x->regmap, SII902X_TPI_AUDIO_CONFIG_BYTE2_REG, in sii902x_audio_shutdown()
750 mutex_unlock(&sii902x->mutex); in sii902x_audio_shutdown()
752 clk_disable_unprepare(sii902x->audio.mclk); in sii902x_audio_shutdown()
758 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_mute() local
760 mutex_lock(&sii902x->mutex); in sii902x_audio_mute()
762 sii902x_mute(sii902x, enable); in sii902x_audio_mute()
764 mutex_unlock(&sii902x->mutex); in sii902x_audio_mute()
772 struct sii902x *sii902x = dev_get_drvdata(dev); in sii902x_audio_get_eld() local
774 mutex_lock(&sii902x->mutex); in sii902x_audio_get_eld()
776 memcpy(buf, sii902x->connector.eld, in sii902x_audio_get_eld()
777 min(sizeof(sii902x->connector.eld), len)); in sii902x_audio_get_eld()
779 mutex_unlock(&sii902x->mutex); in sii902x_audio_get_eld()
813 static int sii902x_audio_codec_init(struct sii902x *sii902x, in sii902x_audio_codec_init() argument
863 sii902x->audio.i2s_fifo_sequence[i] |= audio_fifo_id[i] | in sii902x_audio_codec_init()
866 sii902x->audio.mclk = devm_clk_get_optional(dev, "mclk"); in sii902x_audio_codec_init()
867 if (IS_ERR(sii902x->audio.mclk)) { in sii902x_audio_codec_init()
869 __func__, PTR_ERR(sii902x->audio.mclk)); in sii902x_audio_codec_init()
870 return PTR_ERR(sii902x->audio.mclk); in sii902x_audio_codec_init()
873 sii902x->audio.pdev = platform_device_register_data( in sii902x_audio_codec_init()
877 return PTR_ERR_OR_ZERO(sii902x->audio.pdev); in sii902x_audio_codec_init()
900 struct sii902x *sii902x = data; in sii902x_interrupt() local
903 mutex_lock(&sii902x->mutex); in sii902x_interrupt()
905 regmap_read(sii902x->regmap, SII902X_INT_STATUS, &status); in sii902x_interrupt()
906 regmap_write(sii902x->regmap, SII902X_INT_STATUS, status); in sii902x_interrupt()
908 mutex_unlock(&sii902x->mutex); in sii902x_interrupt()
910 if ((status & SII902X_HOTPLUG_EVENT) && sii902x->bridge.dev) { in sii902x_interrupt()
911 drm_helper_hpd_irq_event(sii902x->bridge.dev); in sii902x_interrupt()
912 drm_bridge_hpd_notify(&sii902x->bridge, (status & SII902X_PLUGGED_STATUS) in sii902x_interrupt()
934 struct sii902x *sii902x = i2c_mux_priv(mux); in sii902x_i2c_bypass_select() local
935 struct device *dev = &sii902x->i2c->dev; in sii902x_i2c_bypass_select()
940 ret = sii902x_update_bits_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_select()
949 ret = sii902x_read_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_select()
961 return sii902x_write_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_select()
979 struct sii902x *sii902x = i2c_mux_priv(mux); in sii902x_i2c_bypass_deselect() local
980 struct device *dev = &sii902x->i2c->dev; in sii902x_i2c_bypass_deselect()
1000 ret = sii902x_read_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_deselect()
1009 ret = sii902x_update_bits_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_deselect()
1018 ret = sii902x_read_unlocked(sii902x->i2c, SII902X_SYS_CTRL_DATA, in sii902x_i2c_bypass_deselect()
1041 static int sii902x_init(struct sii902x *sii902x) in sii902x_init() argument
1043 struct device *dev = &sii902x->i2c->dev; in sii902x_init()
1048 sii902x_reset(sii902x); in sii902x_init()
1050 ret = regmap_write(sii902x->regmap, SII902X_REG_TPI_RQB, 0x0); in sii902x_init()
1054 ret = regmap_bulk_read(sii902x->regmap, SII902X_REG_CHIPID(0), in sii902x_init()
1068 regmap_read(sii902x->regmap, SII902X_INT_STATUS, &status); in sii902x_init()
1069 regmap_write(sii902x->regmap, SII902X_INT_STATUS, status); in sii902x_init()
1071 if (sii902x->i2c->irq > 0) { in sii902x_init()
1072 regmap_write(sii902x->regmap, SII902X_INT_ENABLE, in sii902x_init()
1075 ret = devm_request_threaded_irq(dev, sii902x->i2c->irq, NULL, in sii902x_init()
1078 sii902x); in sii902x_init()
1083 ret = sii902x_audio_codec_init(sii902x, dev); in sii902x_init()
1087 i2c_set_clientdata(sii902x->i2c, sii902x); in sii902x_init()
1089 sii902x->i2cmux = i2c_mux_alloc(sii902x->i2c->adapter, dev, in sii902x_init()
1093 if (!sii902x->i2cmux) { in sii902x_init()
1098 sii902x->i2cmux->priv = sii902x; in sii902x_init()
1099 ret = i2c_mux_add_adapter(sii902x->i2cmux, 0, 0, 0); in sii902x_init()
1103 sii902x->bridge.funcs = &sii902x_bridge_funcs; in sii902x_init()
1104 sii902x->bridge.of_node = dev->of_node; in sii902x_init()
1105 sii902x->bridge.timings = &default_sii902x_timings; in sii902x_init()
1106 sii902x->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID; in sii902x_init()
1108 if (sii902x->i2c->irq > 0) in sii902x_init()
1109 sii902x->bridge.ops |= DRM_BRIDGE_OP_HPD; in sii902x_init()
1111 drm_bridge_add(&sii902x->bridge); in sii902x_init()
1116 if (!PTR_ERR_OR_ZERO(sii902x->audio.pdev)) in sii902x_init()
1117 platform_device_unregister(sii902x->audio.pdev); in sii902x_init()
1126 struct sii902x *sii902x; in sii902x_probe() local
1137 sii902x = devm_kzalloc(dev, sizeof(*sii902x), GFP_KERNEL); in sii902x_probe()
1138 if (!sii902x) in sii902x_probe()
1141 sii902x->i2c = client; in sii902x_probe()
1142 sii902x->regmap = devm_regmap_init_i2c(client, &sii902x_regmap_config); in sii902x_probe()
1143 if (IS_ERR(sii902x->regmap)) in sii902x_probe()
1144 return PTR_ERR(sii902x->regmap); in sii902x_probe()
1146 sii902x->reset_gpio = devm_gpiod_get_optional(dev, "reset", in sii902x_probe()
1148 if (IS_ERR(sii902x->reset_gpio)) { in sii902x_probe()
1150 PTR_ERR(sii902x->reset_gpio)); in sii902x_probe()
1151 return PTR_ERR(sii902x->reset_gpio); in sii902x_probe()
1170 sii902x->next_bridge = of_drm_find_bridge(remote); in sii902x_probe()
1172 if (!sii902x->next_bridge) in sii902x_probe()
1177 mutex_init(&sii902x->mutex); in sii902x_probe()
1183 return sii902x_init(sii902x); in sii902x_probe()
1188 struct sii902x *sii902x = i2c_get_clientdata(client); in sii902x_remove() local
1190 drm_bridge_remove(&sii902x->bridge); in sii902x_remove()
1191 i2c_mux_del_adapters(sii902x->i2cmux); in sii902x_remove()
1193 if (!PTR_ERR_OR_ZERO(sii902x->audio.pdev)) in sii902x_remove()
1194 platform_device_unregister(sii902x->audio.pdev); in sii902x_remove()