Lines Matching refs:idt821034

25 struct idt821034 {
51 static int idt821034_8bit_write(struct idt821034 *idt821034, u8 val)
55 .tx_buf = &idt821034->spi_tx_buf,
59 .tx_buf = &idt821034->spi_tx_buf,
64 idt821034->spi_tx_buf = val;
66 dev_vdbg(&idt821034->spi->dev, "spi xfer wr 0x%x\n", val);
68 return spi_sync_transfer(idt821034->spi, xfer, 2);
71 static int idt821034_2x8bit_write(struct idt821034 *idt821034, u8 val1, u8 val2)
75 ret = idt821034_8bit_write(idt821034, val1);
78 return idt821034_8bit_write(idt821034, val2);
81 static int idt821034_8bit_read(struct idt821034 *idt821034, u8 valw, u8 *valr)
85 .tx_buf = &idt821034->spi_tx_buf,
86 .rx_buf = &idt821034->spi_rx_buf,
90 .tx_buf = &idt821034->spi_tx_buf,
96 idt821034->spi_tx_buf = valw;
98 ret = spi_sync_transfer(idt821034->spi, xfer, 2);
102 *valr = idt821034->spi_rx_buf;
104 dev_vdbg(&idt821034->spi->dev, "spi xfer wr 0x%x, rd 0x%x\n",
119 static int idt821034_set_channel_power(struct idt821034 *idt821034, u8 ch, u8 power)
124 dev_dbg(&idt821034->spi->dev, "set_channel_power(%u, 0x%x)\n", ch, power);
126 conf = IDT821034_MODE_CODEC(ch) | idt821034->cache.codec_conf;
129 ret = idt821034_2x8bit_write(idt821034,
131 idt821034->cache.ch[ch].rx_slot);
136 ret = idt821034_2x8bit_write(idt821034,
138 idt821034->cache.ch[ch].tx_slot);
143 ret = idt821034_2x8bit_write(idt821034, conf, 0);
148 idt821034->cache.ch[ch].power = power;
153 static u8 idt821034_get_channel_power(struct idt821034 *idt821034, u8 ch)
155 return idt821034->cache.ch[ch].power;
162 static int idt821034_set_codec_conf(struct idt821034 *idt821034, u8 codec_conf)
168 dev_dbg(&idt821034->spi->dev, "set_codec_conf(0x%x)\n", codec_conf);
180 if (idt821034->cache.ch[0].power & IDT821034_CONF_PWRUP_RX) {
182 ts = idt821034->cache.ch[0].rx_slot;
183 } else if (idt821034->cache.ch[0].power & IDT821034_CONF_PWRUP_TX) {
185 ts = idt821034->cache.ch[0].tx_slot;
191 ret = idt821034_2x8bit_write(idt821034, conf, ts);
195 idt821034->cache.codec_conf = codec_conf;
199 static u8 idt821034_get_codec_conf(struct idt821034 *idt821034)
201 return idt821034->cache.codec_conf;
208 static int idt821034_set_channel_ts(struct idt821034 *idt821034, u8 ch, u8 ch_dir, u8 ts_num)
213 dev_dbg(&idt821034->spi->dev, "set_channel_ts(%u, 0x%x, %d)\n", ch, ch_dir, ts_num);
215 conf = IDT821034_MODE_CODEC(ch) | idt821034->cache.codec_conf;
218 if (idt821034->cache.ch[ch].power & IDT821034_CONF_PWRUP_RX) {
219 ret = idt821034_2x8bit_write(idt821034,
225 idt821034->cache.ch[ch].rx_slot = ts_num;
228 if (idt821034->cache.ch[ch].power & IDT821034_CONF_PWRUP_TX) {
229 ret = idt821034_2x8bit_write(idt821034,
235 idt821034->cache.ch[ch].tx_slot = ts_num;
245 static int idt821034_set_slic_conf(struct idt821034 *idt821034, u8 ch, u8 slic_dir)
250 dev_dbg(&idt821034->spi->dev, "set_slic_conf(%u, 0x%x)\n", ch, slic_dir);
253 ret = idt821034_2x8bit_write(idt821034, conf, idt821034->cache.ch[ch].slic_control);
257 idt821034->cache.ch[ch].slic_conf = slic_dir;
262 static u8 idt821034_get_slic_conf(struct idt821034 *idt821034, u8 ch)
264 return idt821034->cache.ch[ch].slic_conf;
267 static int idt821034_write_slic_raw(struct idt821034 *idt821034, u8 ch, u8 slic_raw)
272 dev_dbg(&idt821034->spi->dev, "write_slic_raw(%u, 0x%x)\n", ch, slic_raw);
283 conf = IDT821034_MODE_SLIC(ch) | idt821034->cache.ch[ch].slic_conf;
284 ret = idt821034_2x8bit_write(idt821034, conf, slic_raw);
288 idt821034->cache.ch[ch].slic_control = slic_raw;
292 static u8 idt821034_get_written_slic_raw(struct idt821034 *idt821034, u8 ch)
294 return idt821034->cache.ch[ch].slic_control;
297 static int idt821034_read_slic_raw(struct idt821034 *idt821034, u8 ch, u8 *slic_raw)
314 val = IDT821034_MODE_SLIC(ch) | idt821034->cache.ch[ch].slic_conf;
315 ret = idt821034_8bit_write(idt821034, val);
319 ret = idt821034_8bit_read(idt821034, idt821034->cache.ch[ch].slic_control, slic_raw);
323 dev_dbg(&idt821034->spi->dev, "read_slic_raw(%i) 0x%x\n", ch, *slic_raw);
332 static int idt821034_set_gain_channel(struct idt821034 *idt821034, u8 ch,
338 dev_dbg(&idt821034->spi->dev, "set_gain_channel(%u, 0x%x, 0x%x-%d)\n",
379 ret = idt821034_2x8bit_write(idt821034, conf | 0x00, gain_val & 0x007F);
383 ret = idt821034_2x8bit_write(idt821034, conf | 0x01, (gain_val >> 7) & 0x7F);
406 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component);
416 mutex_lock(&idt821034->mutex);
418 val = idt821034->amps.ch[ch].amp_out.gain;
420 val = idt821034->amps.ch[ch].amp_in.gain;
421 mutex_unlock(&idt821034->mutex);
437 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component);
459 mutex_lock(&idt821034->mutex);
462 amp = &idt821034->amps.ch[ch].amp_out;
465 amp = &idt821034->amps.ch[ch].amp_in;
475 ret = idt821034_set_gain_channel(idt821034, ch, gain_type, val);
483 mutex_unlock(&idt821034->mutex);
491 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component);
498 mutex_lock(&idt821034->mutex);
500 idt821034->amps.ch[ch].amp_out.is_muted :
501 idt821034->amps.ch[ch].amp_in.is_muted;
502 mutex_unlock(&idt821034->mutex);
513 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component);
524 mutex_lock(&idt821034->mutex);
527 amp = &idt821034->amps.ch[ch].amp_out;
530 amp = &idt821034->amps.ch[ch].amp_in;
539 ret = idt821034_set_gain_channel(idt821034, ch, gain_type,
547 mutex_unlock(&idt821034->mutex);
623 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component);
632 mutex_lock(&idt821034->mutex);
634 power = idt821034_get_channel_power(idt821034, ch);
639 ret = idt821034_set_channel_power(idt821034, ch, power);
641 mutex_unlock(&idt821034->mutex);
700 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(dai->component);
720 mutex_lock(&idt821034->mutex);
721 ret = idt821034_set_channel_ts(idt821034, ch, IDT821034_CH_RX, slot);
722 mutex_unlock(&idt821034->mutex);
738 idt821034->max_ch_playback = ch;
745 mutex_lock(&idt821034->mutex);
746 ret = idt821034_set_channel_ts(idt821034, ch, IDT821034_CH_TX, slot);
747 mutex_unlock(&idt821034->mutex);
763 idt821034->max_ch_capture = ch;
770 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(dai->component);
774 mutex_lock(&idt821034->mutex);
776 conf = idt821034_get_codec_conf(idt821034);
791 ret = idt821034_set_codec_conf(idt821034, conf);
793 mutex_unlock(&idt821034->mutex);
801 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(dai->component);
805 mutex_lock(&idt821034->mutex);
807 conf = idt821034_get_codec_conf(idt821034);
822 ret = idt821034_set_codec_conf(idt821034, conf);
824 mutex_unlock(&idt821034->mutex);
838 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(dai->component);
843 idt821034->max_ch_playback : idt821034->max_ch_capture;
878 .name = "idt821034",
896 static int idt821034_reset_audio(struct idt821034 *idt821034)
901 mutex_lock(&idt821034->mutex);
903 ret = idt821034_set_codec_conf(idt821034, 0);
908 idt821034->amps.ch[i].amp_out.gain = IDT821034_GAIN_OUT_INIT_RAW;
909 idt821034->amps.ch[i].amp_out.is_muted = false;
910 ret = idt821034_set_gain_channel(idt821034, i, IDT821034_GAIN_RX,
911 idt821034->amps.ch[i].amp_out.gain);
915 idt821034->amps.ch[i].amp_in.gain = IDT821034_GAIN_IN_INIT_RAW;
916 idt821034->amps.ch[i].amp_in.is_muted = false;
917 ret = idt821034_set_gain_channel(idt821034, i, IDT821034_GAIN_TX,
918 idt821034->amps.ch[i].amp_in.gain);
922 ret = idt821034_set_channel_power(idt821034, i, 0);
929 mutex_unlock(&idt821034->mutex);
935 struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component);
938 /* reset idt821034 audio part*/
939 ret = idt821034_reset_audio(idt821034);
964 struct idt821034 *idt821034 = gpiochip_get_data(c);
968 mutex_lock(&idt821034->mutex);
970 slic_raw = idt821034_get_written_slic_raw(idt821034, ch);
975 ret = idt821034_write_slic_raw(idt821034, ch, slic_raw);
977 dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n",
981 mutex_unlock(&idt821034->mutex);
988 struct idt821034 *idt821034 = gpiochip_get_data(c);
992 mutex_lock(&idt821034->mutex);
993 ret = idt821034_read_slic_raw(idt821034, ch, &slic_raw);
994 mutex_unlock(&idt821034->mutex);
996 dev_err(&idt821034->spi->dev, "get gpio %d (%u, 0x%x) failed (%d)\n",
1013 struct idt821034 *idt821034 = gpiochip_get_data(c);
1016 mutex_lock(&idt821034->mutex);
1017 slic_dir = idt821034_get_slic_conf(idt821034, ch);
1018 mutex_unlock(&idt821034->mutex);
1027 struct idt821034 *idt821034 = gpiochip_get_data(c);
1035 mutex_lock(&idt821034->mutex);
1037 slic_conf = idt821034_get_slic_conf(idt821034, ch) | mask;
1039 ret = idt821034_set_slic_conf(idt821034, ch, slic_conf);
1041 dev_err(&idt821034->spi->dev, "dir in gpio %d (%u, 0x%x) failed (%d)\n",
1045 mutex_unlock(&idt821034->mutex);
1053 struct idt821034 *idt821034 = gpiochip_get_data(c);
1059 mutex_lock(&idt821034->mutex);
1061 slic_conf = idt821034_get_slic_conf(idt821034, ch) & ~mask;
1063 ret = idt821034_set_slic_conf(idt821034, ch, slic_conf);
1065 dev_err(&idt821034->spi->dev, "dir in gpio %d (%u, 0x%x) failed (%d)\n",
1069 mutex_unlock(&idt821034->mutex);
1073 static int idt821034_reset_gpio(struct idt821034 *idt821034)
1078 mutex_lock(&idt821034->mutex);
1082 ret = idt821034_set_slic_conf(idt821034, i,
1087 ret = idt821034_write_slic_raw(idt821034, i, 0);
1094 mutex_unlock(&idt821034->mutex);
1098 static int idt821034_gpio_init(struct idt821034 *idt821034)
1102 ret = idt821034_reset_gpio(idt821034);
1106 idt821034->gpio_chip.owner = THIS_MODULE;
1107 idt821034->gpio_chip.label = dev_name(&idt821034->spi->dev);
1108 idt821034->gpio_chip.parent = &idt821034->spi->dev;
1109 idt821034->gpio_chip.base = -1;
1110 idt821034->gpio_chip.ngpio = 5 * 4; /* 5 GPIOs on 4 channels */
1111 idt821034->gpio_chip.get_direction = idt821034_chip_get_direction;
1112 idt821034->gpio_chip.direction_input = idt821034_chip_direction_input;
1113 idt821034->gpio_chip.direction_output = idt821034_chip_direction_output;
1114 idt821034->gpio_chip.get = idt821034_chip_gpio_get;
1115 idt821034->gpio_chip.set = idt821034_chip_gpio_set;
1116 idt821034->gpio_chip.can_sleep = true;
1118 return devm_gpiochip_add_data(&idt821034->spi->dev, &idt821034->gpio_chip,
1119 idt821034);
1124 struct idt821034 *idt821034;
1132 idt821034 = devm_kzalloc(&spi->dev, sizeof(*idt821034), GFP_KERNEL);
1133 if (!idt821034)
1136 idt821034->spi = spi;
1138 mutex_init(&idt821034->mutex);
1140 spi_set_drvdata(spi, idt821034);
1148 return idt821034_gpio_init(idt821034);
1154 { .compatible = "renesas,idt821034", },
1160 { "idt821034", 0 },
1167 .name = "idt821034",