.. | .. |
---|
27 | 27 | #define MAXBURST_PER_FIFO 8 |
---|
28 | 28 | |
---|
29 | 29 | #define DEFAULT_FS 48000 |
---|
| 30 | +#define TIMEOUT_US 1000 |
---|
| 31 | +#define WAIT_TIME_MS_MAX 10000 |
---|
30 | 32 | #define QUIRK_ALWAYS_ON BIT(0) |
---|
31 | 33 | |
---|
32 | 34 | enum fpw_mode { |
---|
.. | .. |
---|
45 | 47 | struct snd_dmaengine_dai_dma_data capture_dma_data; |
---|
46 | 48 | struct snd_dmaengine_dai_dma_data playback_dma_data; |
---|
47 | 49 | struct snd_pcm_substream *substreams[SNDRV_PCM_STREAM_LAST + 1]; |
---|
| 50 | + unsigned int wait_time[SNDRV_PCM_STREAM_LAST + 1]; |
---|
48 | 51 | unsigned int tx_lanes; |
---|
49 | 52 | unsigned int rx_lanes; |
---|
50 | 53 | unsigned int quirks; |
---|
.. | .. |
---|
54 | 57 | bool has_playback; |
---|
55 | 58 | bool is_master_mode; |
---|
56 | 59 | bool is_tdm; |
---|
| 60 | + bool is_clk_auto; |
---|
57 | 61 | }; |
---|
58 | 62 | |
---|
59 | 63 | static const struct sai_of_quirks { |
---|
.. | .. |
---|
80 | 84 | SAI_XFER_FSS_DIS); |
---|
81 | 85 | |
---|
82 | 86 | ret = regmap_read_poll_timeout_atomic(sai->regmap, SAI_XFER, val, |
---|
83 | | - (val & SAI_XFER_FS_IDLE), 10, 100); |
---|
| 87 | + (val & SAI_XFER_FS_IDLE), 10, TIMEOUT_US); |
---|
84 | 88 | if (ret < 0) |
---|
85 | 89 | dev_warn(sai->dev, "Failed to idle FS\n"); |
---|
86 | 90 | |
---|
87 | 91 | regcache_cache_only(sai->regmap, true); |
---|
| 92 | + /* |
---|
| 93 | + * After FS idle, should wait at least 2 BCLK cycle to make sure |
---|
| 94 | + * the CLK gate operation done, and then disable mclk. |
---|
| 95 | + * |
---|
| 96 | + * Otherwise, the BCLK is still ungated. once the mclk is enabled, |
---|
| 97 | + * there maybe a risk that a few BCLK cycle leak. especially for |
---|
| 98 | + * low speed situation, such as 8k samplerate. |
---|
| 99 | + * |
---|
| 100 | + * The best way is to use delay per samplerate, but, the max time |
---|
| 101 | + * is quite a tiny value, so, let's make it simple to use the max |
---|
| 102 | + * time. |
---|
| 103 | + * |
---|
| 104 | + * The max BCLK cycle time is: 31us @ 8K-8Bit (64K BCLK) |
---|
| 105 | + */ |
---|
| 106 | + udelay(40); |
---|
88 | 107 | clk_disable_unprepare(sai->mclk); |
---|
89 | 108 | clk_disable_unprepare(sai->hclk); |
---|
90 | 109 | |
---|
.. | .. |
---|
110 | 129 | if (ret) |
---|
111 | 130 | goto err_regmap; |
---|
112 | 131 | |
---|
113 | | - if (sai->is_master_mode) |
---|
| 132 | + if (sai->quirks & QUIRK_ALWAYS_ON && sai->is_master_mode) |
---|
114 | 133 | regmap_update_bits(sai->regmap, SAI_XFER, |
---|
115 | 134 | SAI_XFER_CLK_MASK | |
---|
116 | 135 | SAI_XFER_FSS_MASK, |
---|
.. | .. |
---|
203 | 222 | |
---|
204 | 223 | regmap_update_bits(sai->regmap, SAI_CLR, clr, clr); |
---|
205 | 224 | ret = regmap_read_poll_timeout_atomic(sai->regmap, SAI_CLR, val, |
---|
206 | | - !(val & clr), 10, 100); |
---|
| 225 | + !(val & clr), 10, TIMEOUT_US); |
---|
207 | 226 | if (ret < 0) { |
---|
208 | 227 | dev_warn(sai->dev, "Failed to clear %u\n", clr); |
---|
209 | 228 | goto reset; |
---|
.. | .. |
---|
249 | 268 | |
---|
250 | 269 | regmap_update_bits(sai->regmap, SAI_XFER, msk, val); |
---|
251 | 270 | ret = regmap_read_poll_timeout_atomic(sai->regmap, SAI_XFER, val, |
---|
252 | | - (val & idle), 10, 100); |
---|
| 271 | + (val & idle), 10, TIMEOUT_US); |
---|
253 | 272 | if (ret < 0) |
---|
254 | 273 | dev_warn(sai->dev, "Failed to idle stream %d\n", stream); |
---|
255 | 274 | |
---|
.. | .. |
---|
433 | 452 | val = SAI_XCR_VDW(24); |
---|
434 | 453 | break; |
---|
435 | 454 | case SNDRV_PCM_FORMAT_S32_LE: |
---|
| 455 | + case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE: |
---|
436 | 456 | val = SAI_XCR_VDW(32); |
---|
437 | 457 | break; |
---|
438 | 458 | default: |
---|
.. | .. |
---|
473 | 493 | |
---|
474 | 494 | if (sai->is_master_mode) { |
---|
475 | 495 | bclk_rate = sai->fw_ratio * slot_width * ch_per_lane * params_rate(params); |
---|
| 496 | + if (sai->is_clk_auto) |
---|
| 497 | + clk_set_rate(sai->mclk, bclk_rate); |
---|
476 | 498 | mclk_rate = clk_get_rate(sai->mclk); |
---|
477 | 499 | if (mclk_rate < bclk_rate) { |
---|
478 | 500 | dev_err(sai->dev, "Mismatch mclk: %u, expected %u at least\n", |
---|
.. | .. |
---|
484 | 506 | |
---|
485 | 507 | regmap_update_bits(sai->regmap, SAI_CKR, SAI_CKR_MDIV_MASK, |
---|
486 | 508 | SAI_CKR_MDIV(div_bclk)); |
---|
| 509 | + /* |
---|
| 510 | + * Should wait for one BCLK ready after DIV and then ungate |
---|
| 511 | + * output clk to achieve the clean clk. |
---|
| 512 | + * |
---|
| 513 | + * The best way is to use delay per samplerate, but, the max time |
---|
| 514 | + * is quite a tiny value, so, let's make it simple to use the max |
---|
| 515 | + * time. |
---|
| 516 | + * |
---|
| 517 | + * The max BCLK cycle time is: 15.6us @ 8K-8Bit (64K BCLK) |
---|
| 518 | + */ |
---|
| 519 | + udelay(20); |
---|
| 520 | + regmap_update_bits(sai->regmap, SAI_XFER, |
---|
| 521 | + SAI_XFER_CLK_MASK | |
---|
| 522 | + SAI_XFER_FSS_MASK, |
---|
| 523 | + SAI_XFER_CLK_EN | |
---|
| 524 | + SAI_XFER_FSS_EN); |
---|
487 | 525 | } |
---|
488 | 526 | |
---|
489 | 527 | return 0; |
---|
.. | .. |
---|
520 | 558 | struct rk_sai_dev *sai = snd_soc_dai_get_drvdata(dai); |
---|
521 | 559 | int ret; |
---|
522 | 560 | |
---|
523 | | - if (!freq) |
---|
| 561 | + if (!freq || sai->is_clk_auto) |
---|
524 | 562 | return 0; |
---|
525 | 563 | |
---|
526 | 564 | ret = clk_set_rate(sai->mclk, freq); |
---|
.. | .. |
---|
545 | 583 | struct snd_soc_dai *dai) |
---|
546 | 584 | { |
---|
547 | 585 | struct rk_sai_dev *sai = snd_soc_dai_get_drvdata(dai); |
---|
| 586 | + int stream = substream->stream; |
---|
548 | 587 | |
---|
549 | | - if (sai->substreams[substream->stream]) |
---|
| 588 | + if (sai->substreams[stream]) |
---|
550 | 589 | return -EBUSY; |
---|
551 | 590 | |
---|
552 | | - sai->substreams[substream->stream] = substream; |
---|
| 591 | + if (sai->wait_time[stream]) |
---|
| 592 | + substream->wait_time = msecs_to_jiffies(sai->wait_time[stream]); |
---|
| 593 | + |
---|
| 594 | + sai->substreams[stream] = substream; |
---|
553 | 595 | |
---|
554 | 596 | return 0; |
---|
555 | 597 | } |
---|
.. | .. |
---|
746 | 788 | dai->playback.formats = SNDRV_PCM_FMTBIT_S8 | |
---|
747 | 789 | SNDRV_PCM_FMTBIT_S16_LE | |
---|
748 | 790 | SNDRV_PCM_FMTBIT_S24_LE | |
---|
749 | | - SNDRV_PCM_FMTBIT_S32_LE; |
---|
| 791 | + SNDRV_PCM_FMTBIT_S32_LE | |
---|
| 792 | + SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE; |
---|
750 | 793 | |
---|
751 | 794 | sai->playback_dma_data.addr = res->start + SAI_TXDR; |
---|
752 | 795 | sai->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
---|
.. | .. |
---|
761 | 804 | dai->capture.formats = SNDRV_PCM_FMTBIT_S8 | |
---|
762 | 805 | SNDRV_PCM_FMTBIT_S16_LE | |
---|
763 | 806 | SNDRV_PCM_FMTBIT_S24_LE | |
---|
764 | | - SNDRV_PCM_FMTBIT_S32_LE; |
---|
| 807 | + SNDRV_PCM_FMTBIT_S32_LE | |
---|
| 808 | + SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE; |
---|
765 | 809 | |
---|
766 | 810 | sai->capture_dma_data.addr = res->start + SAI_RXDR; |
---|
767 | 811 | sai->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
---|
.. | .. |
---|
794 | 838 | static const char * const vdj_text[] = { "Right J", "Left J" }; |
---|
795 | 839 | |
---|
796 | 840 | static const char * const sbw_text[] = { |
---|
797 | | - " 0", " 0", " 0", " 0", " 0", " 0", " 0", " 8", |
---|
798 | | - " 9", "10", "11", "12", "13", "14", "15", "16", |
---|
| 841 | + "0", "0", "0", "0", "0", "0", "0", "8", |
---|
| 842 | + "9", "10", "11", "12", "13", "14", "15", "16", |
---|
799 | 843 | "17", "18", "19", "20", "21", "22", "23", "24", |
---|
800 | 844 | "25", "26", "27", "28", "29", "30", "31", "32", }; |
---|
801 | 845 | |
---|
.. | .. |
---|
803 | 847 | |
---|
804 | 848 | static DECLARE_TLV_DB_SCALE(rmss_tlv, 0, 128, 0); |
---|
805 | 849 | |
---|
806 | | -static const char * const mss_text[] = { "Master", "Slave" }; |
---|
| 850 | +static const char * const mss_text[] = { "Slave", "Master" }; |
---|
807 | 851 | |
---|
808 | 852 | static const char * const ckp_text[] = { "Normal", "Inverted" }; |
---|
809 | 853 | |
---|
.. | .. |
---|
850 | 894 | static SOC_ENUM_SINGLE_DECL(tmono_switch, SAI_MONO_CR, 0, mono_text); |
---|
851 | 895 | |
---|
852 | 896 | /* CKR */ |
---|
853 | | -static SOC_ENUM_SINGLE_DECL(mss_switch, SAI_CKR, 2, mss_text); |
---|
| 897 | +static const struct soc_enum mss_switch = |
---|
| 898 | + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(mss_text), mss_text); |
---|
854 | 899 | static SOC_ENUM_SINGLE_DECL(sp_switch, SAI_CKR, 1, ckp_text); |
---|
855 | 900 | static SOC_ENUM_SINGLE_DECL(fp_switch, SAI_CKR, 0, ckp_text); |
---|
856 | 901 | |
---|
.. | .. |
---|
981 | 1026 | return 1; |
---|
982 | 1027 | } |
---|
983 | 1028 | |
---|
| 1029 | +static int rockchip_sai_mss_get(struct snd_kcontrol *kcontrol, |
---|
| 1030 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1031 | +{ |
---|
| 1032 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1033 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1034 | + |
---|
| 1035 | + ucontrol->value.enumerated.item[0] = sai->is_master_mode; |
---|
| 1036 | + |
---|
| 1037 | + return 0; |
---|
| 1038 | +} |
---|
| 1039 | + |
---|
| 1040 | +static int rockchip_sai_mss_put(struct snd_kcontrol *kcontrol, |
---|
| 1041 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1042 | +{ |
---|
| 1043 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1044 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1045 | + bool mss; |
---|
| 1046 | + |
---|
| 1047 | + /* MUST: do not update mode while stream is running */ |
---|
| 1048 | + if (snd_soc_component_active(component)) |
---|
| 1049 | + return -EPERM; |
---|
| 1050 | + |
---|
| 1051 | + mss = !!ucontrol->value.enumerated.item[0]; |
---|
| 1052 | + if (mss == sai->is_master_mode) |
---|
| 1053 | + return 0; |
---|
| 1054 | + |
---|
| 1055 | + sai->is_master_mode = mss; |
---|
| 1056 | + |
---|
| 1057 | + pm_runtime_get_sync(sai->dev); |
---|
| 1058 | + if (sai->is_master_mode) { |
---|
| 1059 | + /* Switch from Slave to Master */ |
---|
| 1060 | + regmap_update_bits(sai->regmap, SAI_CKR, |
---|
| 1061 | + SAI_CKR_MSS_MASK, |
---|
| 1062 | + SAI_CKR_MSS_MASTER); |
---|
| 1063 | + regmap_update_bits(sai->regmap, SAI_XFER, |
---|
| 1064 | + SAI_XFER_CLK_MASK | |
---|
| 1065 | + SAI_XFER_FSS_MASK, |
---|
| 1066 | + SAI_XFER_CLK_EN | |
---|
| 1067 | + SAI_XFER_FSS_EN); |
---|
| 1068 | + } else { |
---|
| 1069 | + /* Switch from Master to Slave */ |
---|
| 1070 | + regmap_update_bits(sai->regmap, SAI_CKR, |
---|
| 1071 | + SAI_CKR_MSS_MASK, |
---|
| 1072 | + SAI_CKR_MSS_SLAVE); |
---|
| 1073 | + regmap_update_bits(sai->regmap, SAI_XFER, |
---|
| 1074 | + SAI_XFER_CLK_MASK | |
---|
| 1075 | + SAI_XFER_FSS_MASK, |
---|
| 1076 | + SAI_XFER_CLK_DIS | |
---|
| 1077 | + SAI_XFER_FSS_DIS); |
---|
| 1078 | + } |
---|
| 1079 | + pm_runtime_put(sai->dev); |
---|
| 1080 | + |
---|
| 1081 | + return 1; |
---|
| 1082 | +} |
---|
| 1083 | + |
---|
| 1084 | +static int rockchip_sai_clk_auto_get(struct snd_kcontrol *kcontrol, |
---|
| 1085 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1086 | +{ |
---|
| 1087 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1088 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1089 | + |
---|
| 1090 | + ucontrol->value.integer.value[0] = sai->is_clk_auto; |
---|
| 1091 | + |
---|
| 1092 | + return 0; |
---|
| 1093 | +} |
---|
| 1094 | + |
---|
| 1095 | +static int rockchip_sai_clk_auto_put(struct snd_kcontrol *kcontrol, |
---|
| 1096 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1097 | +{ |
---|
| 1098 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1099 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1100 | + bool clk_auto = ucontrol->value.integer.value[0]; |
---|
| 1101 | + |
---|
| 1102 | + if (clk_auto == sai->is_clk_auto) |
---|
| 1103 | + return 0; |
---|
| 1104 | + |
---|
| 1105 | + sai->is_clk_auto = clk_auto; |
---|
| 1106 | + |
---|
| 1107 | + return 1; |
---|
| 1108 | +} |
---|
| 1109 | + |
---|
| 1110 | +static int rockchip_sai_wait_time_info(struct snd_kcontrol *kcontrol, |
---|
| 1111 | + struct snd_ctl_elem_info *uinfo) |
---|
| 1112 | +{ |
---|
| 1113 | + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
---|
| 1114 | + uinfo->count = 1; |
---|
| 1115 | + uinfo->value.integer.min = 0; |
---|
| 1116 | + uinfo->value.integer.max = WAIT_TIME_MS_MAX; |
---|
| 1117 | + uinfo->value.integer.step = 1; |
---|
| 1118 | + |
---|
| 1119 | + return 0; |
---|
| 1120 | +} |
---|
| 1121 | + |
---|
| 1122 | +static int rockchip_sai_rd_wait_time_get(struct snd_kcontrol *kcontrol, |
---|
| 1123 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1124 | +{ |
---|
| 1125 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1126 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1127 | + |
---|
| 1128 | + ucontrol->value.integer.value[0] = sai->wait_time[SNDRV_PCM_STREAM_CAPTURE]; |
---|
| 1129 | + |
---|
| 1130 | + return 0; |
---|
| 1131 | +} |
---|
| 1132 | + |
---|
| 1133 | +static int rockchip_sai_rd_wait_time_put(struct snd_kcontrol *kcontrol, |
---|
| 1134 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1135 | +{ |
---|
| 1136 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1137 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1138 | + |
---|
| 1139 | + if (ucontrol->value.integer.value[0] > WAIT_TIME_MS_MAX) |
---|
| 1140 | + return -EINVAL; |
---|
| 1141 | + |
---|
| 1142 | + sai->wait_time[SNDRV_PCM_STREAM_CAPTURE] = ucontrol->value.integer.value[0]; |
---|
| 1143 | + |
---|
| 1144 | + return 1; |
---|
| 1145 | +} |
---|
| 1146 | + |
---|
| 1147 | +static int rockchip_sai_wr_wait_time_get(struct snd_kcontrol *kcontrol, |
---|
| 1148 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1149 | +{ |
---|
| 1150 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1151 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1152 | + |
---|
| 1153 | + ucontrol->value.integer.value[0] = sai->wait_time[SNDRV_PCM_STREAM_PLAYBACK]; |
---|
| 1154 | + |
---|
| 1155 | + return 0; |
---|
| 1156 | +} |
---|
| 1157 | + |
---|
| 1158 | +static int rockchip_sai_wr_wait_time_put(struct snd_kcontrol *kcontrol, |
---|
| 1159 | + struct snd_ctl_elem_value *ucontrol) |
---|
| 1160 | +{ |
---|
| 1161 | + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
| 1162 | + struct rk_sai_dev *sai = snd_soc_component_get_drvdata(component); |
---|
| 1163 | + |
---|
| 1164 | + if (ucontrol->value.integer.value[0] > WAIT_TIME_MS_MAX) |
---|
| 1165 | + return -EINVAL; |
---|
| 1166 | + |
---|
| 1167 | + sai->wait_time[SNDRV_PCM_STREAM_PLAYBACK] = ucontrol->value.integer.value[0]; |
---|
| 1168 | + |
---|
| 1169 | + return 1; |
---|
| 1170 | +} |
---|
| 1171 | + |
---|
| 1172 | +#define SAI_PCM_WAIT_TIME(xname, xhandler_get, xhandler_put) \ |
---|
| 1173 | +{ .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = xname, \ |
---|
| 1174 | + .info = rockchip_sai_wait_time_info, \ |
---|
| 1175 | + .get = xhandler_get, .put = xhandler_put } |
---|
| 1176 | + |
---|
984 | 1177 | static DECLARE_TLV_DB_SCALE(fs_shift_tlv, 0, 8192, 0); |
---|
985 | 1178 | |
---|
986 | 1179 | static const struct snd_kcontrol_new rockchip_sai_controls[] = { |
---|
.. | .. |
---|
1012 | 1205 | SOC_ENUM("Receive Mono Switch", rmono_switch), |
---|
1013 | 1206 | SOC_ENUM("Transmit Mono Switch", tmono_switch), |
---|
1014 | 1207 | |
---|
1015 | | - SOC_ENUM("Master / Slave Mode Select", mss_switch), |
---|
| 1208 | + SOC_ENUM_EXT("Master / Slave Mode Select", mss_switch, |
---|
| 1209 | + rockchip_sai_mss_get, rockchip_sai_mss_put), |
---|
1016 | 1210 | SOC_ENUM("Sclk Polarity", sp_switch), |
---|
1017 | 1211 | SOC_ENUM("Frame Sync Polarity", fp_switch), |
---|
1018 | 1212 | |
---|
.. | .. |
---|
1039 | 1233 | 0, 8192, 0, fs_shift_tlv), |
---|
1040 | 1234 | SOC_SINGLE_TLV("Receive Frame Shift Select", SAI_RX_SHIFT, |
---|
1041 | 1235 | 0, 8192, 0, fs_shift_tlv), |
---|
| 1236 | + |
---|
| 1237 | + SOC_SINGLE_BOOL_EXT("Clk Auto Switch", 0, |
---|
| 1238 | + rockchip_sai_clk_auto_get, |
---|
| 1239 | + rockchip_sai_clk_auto_put), |
---|
| 1240 | + |
---|
| 1241 | + SAI_PCM_WAIT_TIME("PCM Read Wait Time MS", |
---|
| 1242 | + rockchip_sai_rd_wait_time_get, |
---|
| 1243 | + rockchip_sai_rd_wait_time_put), |
---|
| 1244 | + SAI_PCM_WAIT_TIME("PCM Write Wait Time MS", |
---|
| 1245 | + rockchip_sai_wr_wait_time_get, |
---|
| 1246 | + rockchip_sai_wr_wait_time_put), |
---|
1042 | 1247 | }; |
---|
1043 | 1248 | |
---|
1044 | 1249 | static const struct snd_soc_component_driver rockchip_sai_component = { |
---|
.. | .. |
---|
1110 | 1315 | int ret = 0, i = 0; |
---|
1111 | 1316 | |
---|
1112 | 1317 | for (i = 0; i < ARRAY_SIZE(of_quirks); i++) |
---|
1113 | | - if (of_property_read_bool(sai->dev->of_node, of_quirks[i].quirk)) |
---|
| 1318 | + if (device_property_read_bool(sai->dev, of_quirks[i].quirk)) |
---|
1114 | 1319 | sai->quirks |= of_quirks[i].id; |
---|
1115 | 1320 | |
---|
1116 | 1321 | if (sai->quirks & QUIRK_ALWAYS_ON) |
---|
.. | .. |
---|
1134 | 1339 | |
---|
1135 | 1340 | sai->dev = &pdev->dev; |
---|
1136 | 1341 | sai->fw_ratio = 1; |
---|
| 1342 | + /* match to register default */ |
---|
| 1343 | + sai->is_master_mode = true; |
---|
1137 | 1344 | dev_set_drvdata(&pdev->dev, sai); |
---|
1138 | 1345 | |
---|
1139 | 1346 | sai->rst_h = devm_reset_control_get_optional_exclusive(&pdev->dev, "h"); |
---|
.. | .. |
---|
1153 | 1360 | if (IS_ERR(sai->regmap)) |
---|
1154 | 1361 | return PTR_ERR(sai->regmap); |
---|
1155 | 1362 | |
---|
1156 | | - irq = platform_get_irq(pdev, 0); |
---|
| 1363 | + irq = platform_get_irq_optional(pdev, 0); |
---|
1157 | 1364 | if (irq > 0) { |
---|
1158 | 1365 | ret = devm_request_irq(&pdev->dev, irq, rockchip_sai_isr, |
---|
1159 | 1366 | IRQF_SHARED, node->name, sai); |
---|
.. | .. |
---|
1196 | 1403 | if (ret) |
---|
1197 | 1404 | goto err_runtime_suspend; |
---|
1198 | 1405 | |
---|
| 1406 | + if (device_property_read_bool(&pdev->dev, "rockchip,no-dmaengine")) { |
---|
| 1407 | + dev_info(&pdev->dev, "Used for Multi-DAI\n"); |
---|
| 1408 | + return 0; |
---|
| 1409 | + } |
---|
| 1410 | + |
---|
1199 | 1411 | ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); |
---|
1200 | 1412 | if (ret) |
---|
1201 | 1413 | goto err_runtime_suspend; |
---|
.. | .. |
---|
1233 | 1445 | static int rockchip_sai_resume(struct device *dev) |
---|
1234 | 1446 | { |
---|
1235 | 1447 | struct rk_sai_dev *sai = dev_get_drvdata(dev); |
---|
1236 | | - int ret = pm_runtime_get_sync(dev); |
---|
| 1448 | + int ret = pm_runtime_resume_and_get(dev); |
---|
1237 | 1449 | |
---|
1238 | | - if (ret < 0) { |
---|
1239 | | - pm_runtime_put_noidle(dev); |
---|
| 1450 | + if (ret < 0) |
---|
1240 | 1451 | return ret; |
---|
1241 | | - } |
---|
1242 | | - |
---|
1243 | 1452 | ret = regcache_sync(sai->regmap); |
---|
1244 | 1453 | pm_runtime_put(dev); |
---|
1245 | 1454 | |
---|