aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/1568-Audio-code-as-per-4-1-0-kernel.patch
blob: fdea4d04fd4b1991df38e4aea73233141323ed08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
From 9392bd8bb11271b1501922ca17f1f944b32589c1 Mon Sep 17 00:00:00 2001
From: Sanjay R Mehta <sanju.mehta@amd.com>
Date: Mon, 25 Apr 2016 00:49:41 +0530
Subject: [PATCH 07/12] Audio code as per 4-1-0 kernel

---
 sound/soc/Kconfig           |   1 +
 sound/soc/Makefile          |   1 +
 sound/soc/amd/Kconfig       |  13 +
 sound/soc/amd/Makefile      |  11 +
 sound/soc/amd/acp-pcm-dma.c | 759 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/amd/acp-rt286.c   | 264 +++++++++++++++
 sound/soc/codecs/rt286.c    |  24 +-
 7 files changed, 1068 insertions(+), 5 deletions(-)
 create mode 100644 sound/soc/amd/Kconfig
 create mode 100644 sound/soc/amd/Makefile
 create mode 100644 sound/soc/amd/acp-pcm-dma.c
 create mode 100644 sound/soc/amd/acp-rt286.c

diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig
index 3ba52da..5932b7a 100644
--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
@@ -57,6 +57,7 @@ source "sound/soc/tegra/Kconfig"
 source "sound/soc/txx9/Kconfig"
 source "sound/soc/ux500/Kconfig"
 source "sound/soc/xtensa/Kconfig"
+source "sound/soc/amd/Kconfig"
 
 # Supported codecs
 source "sound/soc/codecs/Kconfig"
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index 974ba70..9708c055 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -38,3 +38,4 @@ obj-$(CONFIG_SND_SOC)	+= tegra/
 obj-$(CONFIG_SND_SOC)	+= txx9/
 obj-$(CONFIG_SND_SOC)	+= ux500/
 obj-$(CONFIG_SND_SOC)	+= xtensa/
+obj-$(CONFIG_SND_SOC)	+= amd/
diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig
new file mode 100644
index 0000000..07677de
--- /dev/null
+++ b/sound/soc/amd/Kconfig
@@ -0,0 +1,13 @@
+ config SND_SOC_AMD_CZ_RT286_MACH
+        tristate "AMD ASoC Audio driver for Carrizo with rt286 codec"
+	select SND_SOC_RT286
+	select SND_SOC_AMD_ACP
+        depends on I2C_DESIGNWARE_PLATFORM
+        help
+           This option enables AMD I2S Audio support on Carrizo
+	   with ALC288 codec.
+ config SND_SOC_AMD_ACP
+        tristate "AMD Audio Coprocessor support"
+        depends on DRM_AMD_GNB_BUS
+        help
+          This option enables ACP support (DMA,I2S) on AMD platforms.
diff --git a/sound/soc/amd/Makefile b/sound/soc/amd/Makefile
new file mode 100644
index 0000000..63b6f83
--- /dev/null
+++ b/sound/soc/amd/Makefile
@@ -0,0 +1,11 @@
+ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/amdsoc/
+ccflags-y += -Idrivers/gpu/drm/amdsoc/include/
+ccflags-y += -Idrivers/gpu/drm/amd/include/bus/
+ccflags-y += -Idrivers/gpu/drm/amd/acp/include
+ccflags-y += -Idrivers/gpu/drm/amd/include/
+ccflags-y += -Idrivers/gpu/drm/amd/include/asic_reg/acp
+snd-soc-acp-pcm-objs	:= acp-pcm-dma.o
+snd-soc-acp-rt286-mach-objs := acp-rt286.o
+
+obj-$(CONFIG_SND_SOC_AMD_ACP) += snd-soc-acp-pcm.o
+obj-$(CONFIG_SND_SOC_AMD_CZ_RT286_MACH) += snd-soc-acp-rt286-mach.o
diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c
new file mode 100644
index 0000000..7e0e5cb
--- /dev/null
+++ b/sound/soc/amd/acp-pcm-dma.c
@@ -0,0 +1,759 @@
+/*
+ * AMD ALSA SoC PCM Driver
+ *
+ * Copyright 2014-2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ */
+
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/pci.h>
+#include <linux/pm_runtime.h>
+
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
+#include "amd_acp.h"
+#include "amd_gnb_bus.h"
+
+#define PLAYBACK_MIN_NUM_PERIODS    2
+#define PLAYBACK_MAX_NUM_PERIODS    2
+#define PLAYBACK_MAX_PERIOD_SIZE    16384
+#define PLAYBACK_MIN_PERIOD_SIZE    1024
+#define CAPTURE_MIN_NUM_PERIODS     2
+#define CAPTURE_MAX_NUM_PERIODS     2
+#define CAPTURE_MAX_PERIOD_SIZE     16384
+#define CAPTURE_MIN_PERIOD_SIZE     1024
+
+#define NUM_DSCRS_PER_CHANNEL 2
+
+#define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS)
+#define MIN_BUFFER MAX_BUFFER
+
+#define TWO_CHANNEL_SUPPORT     2	/* up to 2.0 */
+#define FOUR_CHANNEL_SUPPORT    4	/* up to 3.1 */
+#define SIX_CHANNEL_SUPPORT     6	/* up to 5.1 */
+#define EIGHT_CHANNEL_SUPPORT   8	/* up to 7.1 */
+
+
+static const struct snd_pcm_hardware acp_pcm_hardware_playback = {
+	.info = SNDRV_PCM_INFO_INTERLEAVED |
+		SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
+		SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BATCH |
+		SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME,
+	/* formats,rates,channels  based on i2s doc. */
+	.formats = SNDRV_PCM_FMTBIT_S16_LE |
+		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
+	.channels_min = 1,
+	.channels_max = 8,
+	.rates = SNDRV_PCM_RATE_8000_96000,
+	.rate_min = 8000,
+	.rate_max = 96000,
+	.buffer_bytes_max = PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE,
+	.period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE,
+	.period_bytes_max = PLAYBACK_MAX_PERIOD_SIZE,
+	.periods_min = PLAYBACK_MIN_NUM_PERIODS,
+	.periods_max = PLAYBACK_MAX_NUM_PERIODS,
+	.fifo_size = 0,
+};
+
+static const struct snd_pcm_hardware acp_pcm_hardware_capture = {
+	.info = SNDRV_PCM_INFO_INTERLEAVED |
+		SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
+		SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BATCH |
+	    SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME,
+	/* formats,rates,channels  based on i2s doc. */
+	.formats = SNDRV_PCM_FMTBIT_S16_LE |
+		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
+	.channels_min = 1,
+	.channels_max = 2,
+	.rates = SNDRV_PCM_RATE_8000_48000,
+	.rate_min = 8000,
+	.rate_max = 48000,
+	.buffer_bytes_max = CAPTURE_MAX_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE,
+	.period_bytes_min = CAPTURE_MIN_PERIOD_SIZE,
+	.period_bytes_max = CAPTURE_MAX_PERIOD_SIZE,
+	.periods_min = CAPTURE_MIN_NUM_PERIODS,
+	.periods_max = CAPTURE_MAX_NUM_PERIODS,
+	.fifo_size = 0,
+};
+
+struct audio_drv_data {
+	struct snd_pcm_substream *play_stream;
+	struct snd_pcm_substream *capture_stream;
+	struct amd_acp_device *acp_dev;
+	struct acp_irq_prv *iprv;
+};
+
+struct audio_substream_data {
+	struct amd_acp_device *acp_dev;
+	struct page *pg;
+	struct acp_dma_config *dma_config;
+	struct acp_i2s_config  *i2s_config;
+	unsigned int order;
+};
+
+static const struct snd_soc_component_driver dw_i2s_component = {
+	.name = "dw-i2s.0",
+};
+
+static void acp_pcm_period_elapsed(struct device *dev, u16 play_intr,
+							u16 capture_intr)
+{
+	struct snd_pcm_substream *substream;
+	struct audio_drv_data *irq_data =
+	    (struct audio_drv_data *)dev_get_drvdata(dev);
+
+	/* Inform ALSA about the period elapsed (one out of two periods) */
+	if (play_intr)
+		substream = irq_data->play_stream;
+	else if (capture_intr)
+		substream = irq_data->capture_stream;
+
+	if (substream->runtime && snd_pcm_running(substream))
+		snd_pcm_period_elapsed(substream);
+}
+
+static int acp_dma_open(struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct snd_soc_pcm_runtime *prtd = substream->private_data;
+	struct audio_drv_data *intr_data =
+	    (struct audio_drv_data *)dev_get_drvdata(prtd->platform->dev);
+
+	struct audio_substream_data *adata =
+		kzalloc(sizeof(struct audio_substream_data), GFP_KERNEL);
+	if (adata == NULL)
+		return -ENOMEM;
+
+	adata->dma_config =
+			kzalloc(sizeof(struct acp_dma_config), GFP_KERNEL);
+	if (adata->dma_config == NULL) {
+		kfree(adata);
+		return -ENOMEM;
+	}
+
+	adata->i2s_config =
+			kzalloc(sizeof(struct acp_i2s_config), GFP_KERNEL);
+	if (adata->i2s_config == NULL) {
+		kfree(adata->dma_config);
+		kfree(adata);
+		return -ENOMEM;
+	}
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		runtime->hw = acp_pcm_hardware_playback;
+	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+		runtime->hw = acp_pcm_hardware_capture;
+	else {
+		pr_err("Error in stream type\n");
+		return -EINVAL;
+	}
+
+	ret = snd_pcm_hw_constraint_integer(runtime,
+					    SNDRV_PCM_HW_PARAM_PERIODS);
+	if (ret < 0) {
+		pr_err("snd_pcm_hw_constraint_integer failed\n");
+		return ret;
+	}
+
+	adata->acp_dev = intr_data->acp_dev;
+	runtime->private_data = adata;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+		intr_data->play_stream = substream;
+	else
+		intr_data->capture_stream = substream;
+
+	return 0;
+}
+
+static int acp_dma_hw_params(struct snd_pcm_substream *substream,
+			     struct snd_pcm_hw_params *params)
+{
+	int status;
+	uint64_t size;
+	struct snd_dma_buffer *dma_buffer;
+	struct page *pg;
+	u16 num_of_pages;
+
+	struct snd_pcm_runtime *runtime;
+	struct audio_substream_data *rtd;
+	struct amd_acp_device *acp_dev;
+
+	if (WARN_ON(!substream))
+		return -EINVAL;
+
+	dma_buffer = &substream->dma_buffer;
+
+	runtime = substream->runtime;
+	rtd = runtime->private_data;
+
+	if (WARN_ON(!rtd))
+		return -EINVAL;
+	acp_dev = rtd->acp_dev;
+
+	size = params_buffer_bytes(params);
+	status = snd_pcm_lib_malloc_pages(substream, size);
+	if (status < 0)
+		return status;
+
+	memset(substream->runtime->dma_area, 0, params_buffer_bytes(params));
+	pg = virt_to_page(substream->dma_buffer.area);
+
+	if (NULL != pg) {
+		/* Save for runtime private data */
+		rtd->pg = pg;
+		rtd->order = get_order(size);
+
+		/*Let ACP know the Allocated memory */
+		num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
+
+		/* Fill the page table entries in ACP SRAM */
+
+		rtd->dma_config->pg = pg;
+		rtd->dma_config->size = size;
+		rtd->dma_config->num_of_pages = num_of_pages;
+		rtd->dma_config->direction = substream->stream;
+
+		acp_dev->config_dma(acp_dev, rtd->dma_config);
+
+		status = 0;
+	} else {
+		status = -ENOMEM;
+	}
+	return status;
+}
+
+static int acp_dma_hw_free(struct snd_pcm_substream *substream)
+{
+	return snd_pcm_lib_free_pages(substream);
+}
+
+static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream)
+{
+	u32 pos = 0;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct audio_substream_data *rtd = runtime->private_data;
+	struct amd_acp_device *acp_dev = rtd->acp_dev;
+
+	pos = acp_dev->update_dma_pointer(acp_dev, substream->stream,
+				frames_to_bytes(runtime, runtime->period_size));
+	return bytes_to_frames(runtime, pos);
+
+}
+
+static int acp_dma_mmap(struct snd_pcm_substream *substream,
+			struct vm_area_struct *vma)
+{
+	return snd_pcm_lib_default_mmap(substream, vma);
+}
+
+static int acp_dma_prepare(struct snd_pcm_substream *substream)
+{
+	int ret;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct audio_substream_data *rtd = runtime->private_data;
+	struct amd_acp_device *acp_dev = rtd->acp_dev;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+
+		acp_dev->config_dma_channel(acp_dev, SYSRAM_TO_ACP_CH_NUM,
+					PLAYBACK_START_DMA_DESCR_CH12,
+					NUM_DSCRS_PER_CHANNEL, 0);
+		acp_dev->config_dma_channel(acp_dev, ACP_TO_I2S_DMA_CH_NUM,
+					PLAYBACK_START_DMA_DESCR_CH13,
+					NUM_DSCRS_PER_CHANNEL, 0);
+		/* Fill ACP SRAM with zeros from System RAM which is zero-ed
+		 * in hw_params */
+		ret = acp_dev->dma_start(rtd->acp_dev,
+						SYSRAM_TO_ACP_CH_NUM, false);
+		if (ret < 0)
+			ret = -EFAULT;
+
+		/* Now configure DMA to transfer only first half of System RAM
+		 * buffer before playback is triggered. This will overwrite
+		 * zero-ed second half of SRAM buffer */
+		acp_dev->config_dma_channel(acp_dev, SYSRAM_TO_ACP_CH_NUM,
+					PLAYBACK_START_DMA_DESCR_CH12,
+					1, 0);
+	} else {
+		acp_dev->config_dma_channel(acp_dev, ACP_TO_SYSRAM_CH_NUM,
+					CAPTURE_START_DMA_DESCR_CH14,
+					NUM_DSCRS_PER_CHANNEL, 0);
+		acp_dev->config_dma_channel(acp_dev, I2S_TO_ACP_DMA_CH_NUM,
+					CAPTURE_START_DMA_DESCR_CH15,
+					NUM_DSCRS_PER_CHANNEL, 0);
+	}
+	return 0;
+}
+
+static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct audio_substream_data *rtd = runtime->private_data;
+	struct amd_acp_device *acp_dev = rtd->acp_dev;
+
+	int ret = -EIO;
+
+	if (!rtd)
+		return -EINVAL;
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+			ret = acp_dev->dma_start(rtd->acp_dev,
+						SYSRAM_TO_ACP_CH_NUM, false);
+			if (ret < 0)
+				ret = -EFAULT;
+			else
+				acp_dev->prebuffer_audio(rtd->acp_dev);
+
+			ret = acp_dev->dma_start(acp_dev,
+					    ACP_TO_I2S_DMA_CH_NUM, true);
+		} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+			ret = acp_dev->dma_start(acp_dev,
+					    I2S_TO_ACP_DMA_CH_NUM, true);
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+			ret = acp_dev->dma_stop(acp_dev, SYSRAM_TO_ACP_CH_NUM);
+			if (0 == ret)
+				ret = acp_dev->dma_stop(acp_dev,
+						   ACP_TO_I2S_DMA_CH_NUM);
+		} else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+			ret = acp_dev->dma_stop(acp_dev, I2S_TO_ACP_DMA_CH_NUM);
+			if (0 == ret)
+				ret = acp_dev->dma_stop(acp_dev,
+						ACP_TO_SYSRAM_CH_NUM);
+		}
+		break;
+	default:
+		ret = -EINVAL;
+
+	}
+	return ret;
+}
+
+static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)
+{
+	int ret;
+	struct snd_pcm *pcm;
+
+	pcm = rtd->pcm;
+	ret = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
+					NULL, MIN_BUFFER, MAX_BUFFER);
+	return ret;
+}
+
+static int acp_dma_close(struct snd_pcm_substream *substream)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct audio_substream_data *rtd = runtime->private_data;
+
+	struct snd_soc_pcm_runtime *prtd = substream->private_data;
+	kfree(rtd->dma_config);
+	kfree(rtd->i2s_config);
+	kfree(rtd);
+
+	pm_runtime_mark_last_busy(prtd->platform->dev);
+	return 0;
+}
+
+static int acp_dai_i2s_hwparams(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params,
+				struct snd_soc_dai *dai)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct snd_soc_pcm_runtime *prtd = substream->private_data;
+
+	struct audio_substream_data *rtd = runtime->private_data;
+	struct amd_acp_device *acp_dev = rtd->acp_dev;
+	struct device *dev = prtd->platform->dev;
+
+	u32 chan_nr;
+
+	switch (params_format(params)) {
+	case SNDRV_PCM_FORMAT_S16_LE:
+		rtd->i2s_config->xfer_resolution = 0x02;
+		break;
+
+	case SNDRV_PCM_FORMAT_S24_LE:
+		rtd->i2s_config->xfer_resolution = 0x04;
+		break;
+
+	case SNDRV_PCM_FORMAT_S32_LE:
+		rtd->i2s_config->xfer_resolution = 0x05;
+		break;
+
+	default:
+		dev_err(dev, "designware-i2s: unsuppted PCM fmt");
+		return -EINVAL;
+	}
+
+	chan_nr = params_channels(params);
+
+	switch (chan_nr) {
+	case EIGHT_CHANNEL_SUPPORT:
+		rtd->i2s_config->ch_reg = 3;
+		break;
+	case SIX_CHANNEL_SUPPORT:
+		rtd->i2s_config->ch_reg = 2;
+		break;
+	case FOUR_CHANNEL_SUPPORT:
+		rtd->i2s_config->ch_reg = 1;
+		break;
+	case TWO_CHANNEL_SUPPORT:
+		rtd->i2s_config->ch_reg = 0;
+		break;
+	default:
+		dev_err(dev, "channel not supported\n");
+		return -EINVAL;
+	}
+
+	rtd->i2s_config->direction = substream->stream;
+
+	acp_dev->config_i2s(acp_dev, rtd->i2s_config);
+
+	return 0;
+}
+
+static int acp_dai_i2s_trigger(struct snd_pcm_substream *substream,
+			       int cmd, struct snd_soc_dai *dai)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct audio_substream_data *rtd = runtime->private_data;
+	struct amd_acp_device *acp_dev = rtd->acp_dev;
+
+	int ret = 0;
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+		acp_dev->i2s_start(acp_dev, substream->stream);
+		break;
+
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		acp_dev->i2s_stop(acp_dev, substream->stream);
+		break;
+	default:
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+static int acp_dai_i2s_prepare(struct snd_pcm_substream *substream,
+			       struct snd_soc_dai *dai)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct audio_substream_data *rtd = runtime->private_data;
+	struct amd_acp_device *acp_dev = rtd->acp_dev;
+
+	acp_dev->i2s_reset(acp_dev, substream->stream);
+	return 0;
+}
+
+static struct snd_pcm_ops acp_dma_ops = {
+	.open = acp_dma_open,
+	.close = acp_dma_close,
+	.ioctl = snd_pcm_lib_ioctl,
+	.hw_params = acp_dma_hw_params,
+	.hw_free = acp_dma_hw_free,
+	.trigger = acp_dma_trigger,
+	.pointer = acp_dma_pointer,
+	.mmap = acp_dma_mmap,
+	.prepare = acp_dma_prepare,
+};
+
+struct snd_soc_dai_ops acp_dai_i2s_ops = {
+	.prepare = acp_dai_i2s_prepare,
+	.hw_params = acp_dai_i2s_hwparams,
+	.trigger = acp_dai_i2s_trigger,
+};
+
+/* CZ i2s configuration */
+static struct snd_soc_dai_driver i2s_dai_driver_cz = {
+	.playback = {
+		     .stream_name = "I2S Playback",
+		     .channels_min = 2,
+		     .channels_max = 2,
+		     .rates = SNDRV_PCM_RATE_8000_96000,
+		     .formats = SNDRV_PCM_FMTBIT_S24_LE |
+				SNDRV_PCM_FMTBIT_S32_LE,
+
+		     .rate_min = 8000,
+		     .rate_max = 96000,
+		     },
+	.capture = {
+		    .stream_name = "I2S Capture",
+		    .channels_min = 2,
+		    .channels_max = 2,
+		    .rates = SNDRV_PCM_RATE_8000_48000,
+		    .formats = SNDRV_PCM_FMTBIT_S24_LE |
+				SNDRV_PCM_FMTBIT_S32_LE,
+		    .rate_min = 8000,
+		    .rate_max = 48000,
+		    },
+	.ops = &acp_dai_i2s_ops,
+};
+
+static struct snd_soc_platform_driver acp_asoc_platform = {
+	.ops = &acp_dma_ops,
+	.pcm_new = acp_dma_new,
+};
+
+static int acp_alsa_register(struct device *dev, struct amd_acp_device *acp_dev,
+				struct amd_gnb_bus_dev *adev)
+{
+	int status;
+
+	status = snd_soc_register_platform(dev, &acp_asoc_platform);
+	if (STATUS_SUCCESS != status) {
+		dev_err(dev, "Unable to register ALSA platform device\n");
+		goto exit_platform;
+	} else {
+		 /* SNDRV_PCM_FMTBIT_S16_LE is not supported in CZ */
+		status = snd_soc_register_component(dev,
+					&dw_i2s_component,
+					&i2s_dai_driver_cz, 1);
+
+		if (STATUS_SUCCESS != status) {
+			dev_err(dev, "Unable to register i2s dai\n");
+			goto exit_dai;
+		} else {
+			dev_info(dev, "ACP device registered with ALSA\n");
+			return status;
+		}
+	}
+
+exit_dai:
+	snd_soc_unregister_platform(dev);
+exit_platform:
+	acp_dev->fini(acp_dev);
+	return status;
+}
+
+static int acp_amdsoc_probe(struct amd_gnb_bus_dev *adev)
+{
+	int status;
+	struct audio_drv_data *audio_drv_data;
+	struct amd_acp_device *acp_dev = adev->private_data;
+
+	if (AMD_GNB_IP_ACP_PCM != adev->ip) {
+		dev_err(&adev->dev, "Not an ACP Device on AMD GNB bus\n");
+		return -ENODEV;
+	}
+
+	audio_drv_data = devm_kzalloc(&adev->dev,
+						sizeof(struct audio_drv_data),
+						GFP_KERNEL);
+	if (audio_drv_data == NULL)
+		return -ENOMEM;
+
+	audio_drv_data->iprv = devm_kzalloc(&adev->dev,
+						sizeof(struct acp_irq_prv),
+						GFP_KERNEL);
+	if (audio_drv_data->iprv == NULL)
+		return -ENOMEM;
+
+	/* The following members gets populated in device 'open'
+	 * function. Till then interrupts are disabled in 'acp_hw_init'
+	 * and device doesn't generate any interrupts.
+	 */
+
+	audio_drv_data->play_stream = NULL;
+	audio_drv_data->capture_stream = NULL;
+	audio_drv_data->acp_dev = acp_dev;
+
+	audio_drv_data->iprv->dev = &adev->dev;
+	audio_drv_data->iprv->acp_dev = acp_dev;
+	audio_drv_data->iprv->set_elapsed = acp_pcm_period_elapsed;
+
+	dev_set_drvdata(&adev->dev, audio_drv_data);
+
+	/* Initialize the ACP */
+	status = acp_dev->init(acp_dev, audio_drv_data->iprv);
+
+	if (STATUS_SUCCESS == status)
+		status = acp_alsa_register(&adev->dev, acp_dev, adev);
+	else
+		pr_err("ACP initialization Failed\n");
+
+	pm_runtime_set_autosuspend_delay(&adev->dev, 10000);
+	pm_runtime_use_autosuspend(&adev->dev);
+	pm_runtime_enable(&adev->dev);
+
+	return status;
+}
+
+static int acp_amdsoc_remove(struct amd_gnb_bus_dev *adev)
+{
+	struct amd_acp_device *acp_dev = adev->private_data;
+
+	snd_soc_unregister_component(&adev->dev);
+	snd_soc_unregister_platform(&adev->dev);
+
+	acp_dev->fini(acp_dev);
+	pm_runtime_disable(&adev->dev);
+	return 0;
+}
+
+static int acp_pcm_suspend(struct device *dev)
+{
+	bool pm_rts;
+	struct audio_drv_data *adata =
+	    (struct audio_drv_data *)dev_get_drvdata(dev);
+
+	pm_rts = pm_runtime_status_suspended(dev);
+	if (pm_rts == false)
+		adata->acp_dev->fini(adata->acp_dev);
+
+	return 0;
+}
+
+static int acp_pcm_resume(struct device *dev)
+{
+	bool pm_rts;
+	struct snd_pcm_substream *pstream, *cstream;
+	struct snd_pcm_runtime *prtd, *crtd;
+	struct audio_substream_data *rtd;
+
+	struct audio_drv_data *adata =
+	    (struct audio_drv_data *)dev_get_drvdata(dev);
+
+	pm_rts = pm_runtime_status_suspended(dev);
+	if (pm_rts == true) {
+		/* Resumed from system wide suspend and there is
+		 * no pending audio activity to resume. */
+		pm_runtime_disable(dev);
+		pm_runtime_set_active(dev);
+		pm_runtime_enable(dev);
+
+		goto out;
+	}
+
+	pstream = adata->play_stream;
+	prtd = pstream ? pstream->runtime : NULL;
+	if (prtd != NULL) {
+		/* Resume playback stream from a suspended state */
+		rtd = prtd->private_data;
+
+		adata->acp_dev->config_dma(adata->acp_dev, rtd->dma_config);
+		adata->acp_dev->config_i2s(adata->acp_dev, rtd->i2s_config);
+	}
+
+	cstream = adata->capture_stream;
+	crtd =  cstream ? cstream->runtime : NULL;
+	if (crtd != NULL) {
+		/* Resume capture stream from a suspended state */
+		rtd = crtd->private_data;
+
+		adata->acp_dev->config_dma(adata->acp_dev, rtd->dma_config);
+		adata->acp_dev->config_i2s(adata->acp_dev, rtd->i2s_config);
+	}
+out:
+	return 0;
+}
+
+int acp_pcm_runtime_suspend(struct device *dev)
+{
+	struct audio_drv_data *adata =
+	    (struct audio_drv_data *)dev_get_drvdata(dev);
+
+	adata->acp_dev->acp_suspend(adata->acp_dev);
+	return 0;
+}
+
+int acp_pcm_runtime_resume(struct device *dev)
+{
+	struct audio_drv_data *adata =
+	    (struct audio_drv_data *)dev_get_drvdata(dev);
+
+	adata->acp_dev->acp_resume(adata->acp_dev);
+	return 0;
+}
+
+int acp_pcm_runtime_idle(struct device *dev)
+{
+	return 0;
+}
+
+static const struct dev_pm_ops acp_pm_ops = {
+	.suspend = acp_pcm_suspend,
+	.resume = acp_pcm_resume,
+	.runtime_suspend = acp_pcm_runtime_suspend,
+	.runtime_resume = acp_pcm_runtime_resume,
+	.runtime_idle = acp_pcm_runtime_idle
+};
+
+static struct amd_gnb_bus_driver acp_dma_driver = {
+	.name = "acp-pcm-driver",
+	.ip = AMD_GNB_IP_ACP_PCM,
+	.probe = acp_amdsoc_probe,
+	.remove = acp_amdsoc_remove,
+	.driver = {
+		.pm = &acp_pm_ops,
+	},
+};
+
+static int __init amdsoc_bus_acp_dma_driver_init(void)
+{
+	int ret = 0;
+
+	ret = amd_gnb_bus_register_driver(&acp_dma_driver,
+					 THIS_MODULE, "acp-pcm-driver");
+	if (ret) {
+		pr_err("ACP: Unable to register with AMD GNB BUS!\n");
+		return ret;
+	}
+
+	return 0;
+
+}
+
+static void __exit amdsoc_bus_acp_dma_driver_exit(void)
+{
+	pr_info("ACP: PCM driver exit\n");
+	amd_gnb_bus_unregister_driver(&acp_dma_driver);
+}
+
+module_init(amdsoc_bus_acp_dma_driver_init);
+module_exit(amdsoc_bus_acp_dma_driver_exit);
+
+MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com");
+MODULE_DESCRIPTION("AMD ACP PCM Driver");
+MODULE_LICENSE("GPL and additional rights");
diff --git a/sound/soc/amd/acp-rt286.c b/sound/soc/amd/acp-rt286.c
new file mode 100644
index 0000000..8be9236
--- /dev/null
+++ b/sound/soc/amd/acp-rt286.c
@@ -0,0 +1,264 @@
+/*
+ * Machine driver for AMD ACP Audio engine using Realtek RT286 codec
+ *
+ * Copyright 2014-2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ */
+
+#include <sound/core.h>
+#include <sound/soc.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc-dapm.h>
+#include <sound/jack.h>
+#include <linux/gpio.h>
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/acpi.h>
+
+#include "../codecs/rt286.h"
+
+#ifdef CONFIG_PINCTRL_AMD
+
+#define CZ_HPJACK_GPIO  7
+#define CZ_HPJACK_DEBOUNCE 150
+
+#endif
+
+#define CZ_CODEC_I2C_ADDR 0x1c
+#define CZ_CODEC_I2C_ADAPTER_ID 3
+
+struct i2c_client *i2c_client;
+
+struct acp_rt286 {
+	int gpio_hp_det;
+};
+
+static struct snd_soc_jack cz_jack;
+static struct snd_soc_jack_pin cz_pins[] = {
+	{
+		.pin = "Analog Mic",
+		.mask = SND_JACK_MICROPHONE,
+	},
+	{
+		.pin = "Headphones",
+		.mask = SND_JACK_HEADPHONE,
+	},
+};
+
+static int carrizo_hw_params(struct snd_pcm_substream *substream,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_card *card = rtd->card;
+	int sample_rate;
+	int err;
+
+	err = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+				SND_SOC_DAIFMT_NB_NF |
+				SND_SOC_DAIFMT_CBM_CFM);
+	if (err < 0) {
+		dev_err(card->dev, "unable to set codec dai format\n");
+		return err;
+	}
+
+	sample_rate = params_rate(params);
+
+	err = snd_soc_dai_set_sysclk(codec_dai, RT286_SCLK_S_PLL, 24000000,
+					SND_SOC_CLOCK_OUT);
+	if (err < 0) {
+		dev_err(card->dev, "unable to set codec dai clock\n");
+		return err;
+	}
+
+	return 0;
+
+}
+
+static struct snd_soc_ops carrizo_rt286_ops = {
+	.hw_params = carrizo_hw_params,
+};
+
+static int carrizo_init(struct snd_soc_pcm_runtime *rtd)
+{
+	/* TODO: check whether dapm widgets needs to be
+	 * dsiconnected initially. */
+	int ret;
+	struct snd_soc_card *card;
+	struct snd_soc_codec *codec;
+
+	codec = rtd->codec;
+	card = rtd->card;
+	ret = snd_soc_card_jack_new(card, "Headset",
+		SND_JACK_HEADSET, &cz_jack, cz_pins, ARRAY_SIZE(cz_pins));
+
+	if (ret)
+		return ret;
+
+	rt286_mic_detect(codec, &cz_jack);
+	return 0;
+}
+
+
+static struct snd_soc_dai_link carrizo_dai_rt286 = {
+	.name = "amd-rt286",
+	.stream_name = "RT286_AIF1",
+	.platform_name = "acp_pcm_dev",
+	.cpu_dai_name = "acp_pcm_dev",
+	.codec_dai_name = "rt286-aif1",
+	.codec_name = "rt286.3-001c",
+	.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
+			| SND_SOC_DAIFMT_CBM_CFM,
+	.ops = &carrizo_rt286_ops,
+	.init = carrizo_init,
+};
+
+static const struct snd_soc_dapm_widget cz_widgets[] = {
+	SND_SOC_DAPM_HP("Headphones", NULL),
+	SND_SOC_DAPM_MIC("Analog Mic", NULL),
+};
+
+static const struct snd_soc_dapm_route cz_audio_route[] = {
+	{"Headphones", NULL, "HPO L"},
+	{"Headphones", NULL, "HPO R"},
+	{"MIC1", NULL, "Analog Mic"},
+};
+
+static struct snd_soc_card carrizo_card = {
+	.name = "acp-rt286",
+	.owner = THIS_MODULE,
+	.dai_link = &carrizo_dai_rt286,
+	.num_links = 1,
+
+	.dapm_widgets = cz_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(cz_widgets),
+	.dapm_routes = cz_audio_route,
+	.num_dapm_routes = ARRAY_SIZE(cz_audio_route),
+};
+
+static int carrizo_probe(struct platform_device *pdev)
+{
+	int ret;
+	struct acp_rt286 *machine;
+	struct snd_soc_card *card;
+
+	machine = devm_kzalloc(&pdev->dev, sizeof(struct acp_rt286),
+				GFP_KERNEL);
+	if (!machine)
+		return -ENOMEM;
+
+	card = &carrizo_card;
+	carrizo_card.dev = &pdev->dev;
+
+	platform_set_drvdata(pdev, card);
+	snd_soc_card_set_drvdata(card, machine);
+
+	ret = snd_soc_register_card(card);
+	if (ret) {
+		dev_err(&pdev->dev,
+				"snd_soc_register_card(%s) failed: %d\n",
+				carrizo_card.name, ret);
+		return ret;
+	}
+	return 0;
+}
+
+static int carrizo_remove(struct platform_device *pdev)
+{
+	struct snd_soc_card *card;
+
+	card = platform_get_drvdata(pdev);
+	snd_soc_unregister_card(card);
+
+	return 0;
+}
+
+static const struct acpi_device_id cz_audio_acpi_match[] = {
+	{ "I2SC1002", 0 },
+	{},
+};
+
+static struct platform_driver carrizo_pcm_driver = {
+	.driver = {
+		.name = "carrizo_i2s_audio",
+		.acpi_match_table = ACPI_PTR(cz_audio_acpi_match),
+		.owner = THIS_MODULE,
+		.pm = &snd_soc_pm_ops,
+	},
+	.probe = carrizo_probe,
+	.remove = carrizo_remove,
+};
+
+static int __init cz_audio_init(void)
+{
+	int ret;
+	struct i2c_adapter *adapter;
+	struct i2c_board_info cz_board_info;
+	const char *codec_acpi_name = "rt288";
+
+	adapter = i2c_get_adapter(CZ_CODEC_I2C_ADAPTER_ID);
+	if (!adapter)
+		return -ENODEV;
+
+	memset(&cz_board_info, 0, sizeof(struct i2c_board_info));
+	cz_board_info.addr = CZ_CODEC_I2C_ADDR;
+	strlcpy(cz_board_info.type, codec_acpi_name, I2C_NAME_SIZE);
+
+#ifdef CONFIG_PINCTRL_AMD
+	if (gpio_is_valid(CZ_HPJACK_GPIO)) {
+		ret = gpio_request_one(CZ_HPJACK_GPIO, GPIOF_DIR_IN |
+						GPIOF_EXPORT, "hp-gpio");
+		if (ret != 0)
+			pr_err("gpio_request_one failed : err %d\n", ret);
+
+		cz_board_info.irq = gpio_to_irq(CZ_HPJACK_GPIO);
+
+		gpio_set_debounce(CZ_HPJACK_GPIO, CZ_HPJACK_DEBOUNCE);
+	}
+#endif
+	i2c_client = i2c_new_device(adapter, &cz_board_info);
+	i2c_put_adapter(adapter);
+	if (!i2c_client)
+		return -ENODEV;
+
+	platform_driver_register(&carrizo_pcm_driver);
+	return 0;
+}
+
+static void __exit cz_audio_exit(void)
+{
+#ifdef CONFIG_PINCTRL_AMD
+	if (gpio_is_valid(CZ_HPJACK_GPIO))
+		gpio_free(CZ_HPJACK_GPIO);
+#endif
+	i2c_unregister_device(i2c_client);
+
+	platform_driver_unregister(&carrizo_pcm_driver);
+}
+
+module_init(cz_audio_init);
+module_exit(cz_audio_exit);
+
+MODULE_AUTHOR("Maruthi.Bayyavarapu@amd.com");
+MODULE_DESCRIPTION("CZ-rt288 Audio Support");
+MODULE_LICENSE("GPL and additional rights");
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index 0fcda35..56ae984 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -358,6 +358,15 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic)
 		*hp = buf & 0x80000000;
 		regmap_read(rt286->regmap, RT286_GET_MIC1_SENSE, &buf);
 		*mic = buf & 0x80000000;
+		if (*mic) {
+			regmap_write(rt286->regmap, RT286_SET_MIC1, 0x24);
+			msleep(50);
+
+			regmap_update_bits(rt286->regmap,
+						RT286_CBJ_CTRL1,
+						0xfcc0, 0xd400);
+			msleep(300);
+		}
 	}
 
 	snd_soc_dapm_disable_pin(&rt286->codec->dapm, "HV");
@@ -1078,7 +1087,6 @@ static int rt286_suspend(struct snd_soc_codec *codec)
 
 	regcache_cache_only(rt286->regmap, true);
 	regcache_mark_dirty(rt286->regmap);
-
 	return 0;
 }
 
@@ -1089,7 +1097,6 @@ static int rt286_resume(struct snd_soc_codec *codec)
 	regcache_cache_only(rt286->regmap, false);
 	rt286_index_sync(codec);
 	regcache_sync(rt286->regmap);
-
 	return 0;
 }
 #else
@@ -1099,7 +1106,8 @@ static int rt286_resume(struct snd_soc_codec *codec)
 
 #define RT286_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000)
 #define RT286_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
-			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
+			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) | \
+			SNDRV_PCM_FMTBIT_S32_LE
 
 static const struct snd_soc_dai_ops rt286_aif_dai_ops = {
 	.hw_params = rt286_hw_params,
@@ -1189,6 +1197,7 @@ MODULE_DEVICE_TABLE(i2c, rt286_i2c_id);
 
 static const struct acpi_device_id rt286_acpi_match[] = {
 	{ "INT343A", 0 },
+	{ "RTK0000", 0 },
 	{},
 };
 MODULE_DEVICE_TABLE(acpi, rt286_acpi_match);
@@ -1214,10 +1223,15 @@ static struct dmi_system_id dmi_dell_dino[] = {
 	{ }
 };
 
+static struct rt286_platform_data rt286_acpi_data = {
+	.cbj_en = false,
+	.gpio2_en = false,
+};
+
 static int rt286_i2c_probe(struct i2c_client *i2c,
 			   const struct i2c_device_id *id)
 {
-	struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
+	struct rt286_platform_data *pdata = &rt286_acpi_data;
 	struct rt286_priv *rt286;
 	int i, ret, val;
 
@@ -1314,7 +1328,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
 
 	if (rt286->i2c->irq) {
 		ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq,
-			IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286);
+			IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt286", rt286);
 		if (ret != 0) {
 			dev_err(&i2c->dev,
 				"Failed to reguest IRQ: %d\n", ret);
-- 
1.9.1