[Sound-open-firmware] [PATCH] dai: add support for CHT SSP ports
CHT has 6 SSP ports compared to 3 on BYT
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/platform/baytrail/dai.c | 58 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/src/platform/baytrail/dai.c b/src/platform/baytrail/dai.c index 4db91e5..8df13ed 100644 --- a/src/platform/baytrail/dai.c +++ b/src/platform/baytrail/dai.c @@ -39,7 +39,7 @@ #include <stdint.h> #include <string.h>
-static struct dai ssp[3] = { +static struct dai ssp[] = { { .type = COMP_TYPE_DAI_SSP, .index = 0, @@ -90,7 +90,61 @@ static struct dai ssp[3] = { } }, .ops = &ssp_ops, -},}; +}, +#if defined CONFIG_CHERRYTRAIL +{ + .type = COMP_TYPE_DAI_SSP, + .index = 3, + .plat_data = { + .base = SSP3_BASE, + .irq = IRQ_NUM_EXT_SSP0, + .fifo[STREAM_DIRECTION_PLAYBACK] = { + .offset = SSP3_BASE + SSDR, + .handshake = DMA_HANDSHAKE_SSP3_TX, + }, + .fifo[STREAM_DIRECTION_CAPTURE] = { + .offset = SSP0_BASE + SSDR, + .handshake = DMA_HANDSHAKE_SSP3_RX, + } + }, + .ops = &ssp_ops, +}, +{ + .type = COMP_TYPE_DAI_SSP, + .index = 4, + .plat_data = { + .base = SSP4_BASE, + .irq = IRQ_NUM_EXT_SSP1, + .fifo[STREAM_DIRECTION_PLAYBACK] = { + .offset = SSP4_BASE + SSDR, + .handshake = DMA_HANDSHAKE_SSP4_TX, + }, + .fifo[STREAM_DIRECTION_CAPTURE] = { + .offset = SSP4_BASE + SSDR, + .handshake = DMA_HANDSHAKE_SSP4_RX, + } + }, + .ops = &ssp_ops, +}, +{ + .type = COMP_TYPE_DAI_SSP, + .index = 5, + .plat_data = { + .base = SSP5_BASE, + .irq = IRQ_NUM_EXT_SSP2, + .fifo[STREAM_DIRECTION_PLAYBACK] = { + .offset = SSP5_BASE + SSDR, + .handshake = DMA_HANDSHAKE_SSP5_TX, + }, + .fifo[STREAM_DIRECTION_CAPTURE] = { + .offset = SSP5_BASE + SSDR, + .handshake = DMA_HANDSHAKE_SSP5_RX, + } + }, + .ops = &ssp_ops, +}, +#endif +};
struct dai *dai_get(uint32_t type, uint32_t index) {
CHT has 3 DMACs compared to the 2 DMACs on BYT
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/platform/baytrail/dma.c | 51 +++++++++++++++++++++- src/platform/baytrail/include/platform/dma.h | 6 +++ src/platform/baytrail/include/platform/interrupt.h | 2 + 3 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/src/platform/baytrail/dma.c b/src/platform/baytrail/dma.c index 62baadb..6cb1fda 100644 --- a/src/platform/baytrail/dma.c +++ b/src/platform/baytrail/dma.c @@ -106,6 +106,43 @@ static struct dw_drv_plat_data dmac1 = { }, };
+#if defined CONFIG_CHERRYTRAIL +static struct dw_drv_plat_data dmac2 = { + .chan[0] = { + .class = 7, + .weight = 0, + }, + .chan[1] = { + .class = 7, + .weight = 0, + }, + .chan[2] = { + .class = 7, + .weight = 0, + }, + .chan[3] = { + .class = 7, + .weight = 0, + }, + .chan[4] = { + .class = 7, + .weight = 0, + }, + .chan[5] = { + .class = 7, + .weight = 0, + }, + .chan[6] = { + .class = 7, + .weight = 0, + }, + .chan[7] = { + .class = 7, + .weight = 0, + }, +}; +#endif + static struct dma dma[] = { { .plat_data = { @@ -124,7 +161,19 @@ static struct dma dma[] = { .drv_plat_data = &dmac1, }, .ops = &dw_dma_ops, -},}; +}, +#if defined CONFIG_CHERRYTRAIL +{ + .plat_data = { + .id = DMA_ID_DMAC2, + .base = DMA2_BASE, + .irq = IRQ_NUM_EXT_DMAC2, + .drv_plat_data = &dmac2, + }, + .ops = &dw_dma_ops, +}, +#endif +};
struct dma *dma_get(int dmac_id) { diff --git a/src/platform/baytrail/include/platform/dma.h b/src/platform/baytrail/include/platform/dma.h index e880eac..8a1a806 100644 --- a/src/platform/baytrail/include/platform/dma.h +++ b/src/platform/baytrail/include/platform/dma.h @@ -43,5 +43,11 @@ #define DMA_HANDSHAKE_SSP1_TX 3 #define DMA_HANDSHAKE_SSP2_RX 4 #define DMA_HANDSHAKE_SSP2_TX 5 +#define DMA_HANDSHAKE_SSP3_RX 6 +#define DMA_HANDSHAKE_SSP3_TX 7 +#define DMA_HANDSHAKE_SSP4_RX 8 +#define DMA_HANDSHAKE_SSP4_TX 9 +#define DMA_HANDSHAKE_SSP5_RX 10 +#define DMA_HANDSHAKE_SSP6_TX 11
#endif diff --git a/src/platform/baytrail/include/platform/interrupt.h b/src/platform/baytrail/include/platform/interrupt.h index 3d96ba5..8c97122 100644 --- a/src/platform/baytrail/include/platform/interrupt.h +++ b/src/platform/baytrail/include/platform/interrupt.h @@ -53,6 +53,7 @@ #define IRQ_NUM_EXT_SSP0 16 /* Level 5 */ #define IRQ_NUM_EXT_SSP1 17 /* Level 5 */ #define IRQ_NUM_EXT_SSP2 18 /* Level 5 */ +#define IRQ_NUM_EXT_DMAC2 19 /* Level 5 */ #define IRQ_NUM_NMI 20 /* Level 7 */
/* IRQ Masks */ @@ -74,5 +75,6 @@ #define IRQ_MASK_EXT_SSP0 (1 << IRQ_NUM_EXT_SSP0) #define IRQ_MASK_EXT_SSP1 (1 << IRQ_NUM_EXT_SSP1) #define IRQ_MASK_EXT_SSP2 (1 << IRQ_NUM_EXT_SSP2) +#define IRQ_MASK_EXT_DMAC2 (1 << IRQ_NUM_EXT_DMAC2)
#endif
Add some M/N divider entries for 19.2M source clock.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/platform/baytrail/platform.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 814d60d..588530a 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -100,12 +100,17 @@ struct ssp_mn { uint32_t n; };
+/* TODO: move over to the PLL instead of M/N */ static const struct ssp_mn ssp_mn_conf[] = { {25000000, 24, 48000, 1152, 25000}, /* 1.152MHz */ {25000000, 32, 48000, 1536, 25000}, /* 1.536MHz */ {25000000, 64, 48000, 3072, 25000}, /* 3.072MHz */ {25000000, 400, 48000, 96, 125}, /* 19.2MHz */ {25000000, 400, 44100, 441, 625}, /* 17.64MHz */ + {19200000, 24, 48000, 3, 50}, /* 1.152MHz */ + {19200000, 32, 48000, 2, 25}, /* 1.536MHz */ + {19200000, 64, 48000, 4, 25}, /* 3.072MHz */ + {19200000, 400, 44100, 441, 480}, /* 17.64MHz */ };
/* set the SSP M/N clock dividers */
Make sure we initialise the extra SSPs and DMACs for CHT.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com --- src/platform/baytrail/include/platform/shim.h | 7 +++ src/platform/baytrail/platform.c | 83 ++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/src/platform/baytrail/include/platform/shim.h b/src/platform/baytrail/include/platform/shim.h index abb9ac5..b2e9132 100644 --- a/src/platform/baytrail/include/platform/shim.h +++ b/src/platform/baytrail/include/platform/shim.h @@ -36,6 +36,7 @@
#define SHIM_CSR 0x00 #define SHIM_PISR 0x08 +#define SHIM_PISRH 0x0c #define SHIM_PIMR 0x10 #define SHIM_ISRX 0x18 #define SHIM_ISRD 0x20 @@ -66,6 +67,12 @@ #define SHIM_SSP1_DIVH 0xF4 #define SHIM_SSP2_DIVL 0xF8 #define SHIM_SSP2_DIVH 0xFC +#define SHIM_SSP3_DIVL 0x100 +#define SHIM_SSP3_DIVH 0x104 +#define SHIM_SSP4_DIVL 0x108 +#define SHIM_SSP4_DIVH 0x10c +#define SHIM_SSP5_DIVL 0x110 +#define SHIM_SSP5_DIVH 0x114
#define SHIM_SHIM_BEGIN SHIM_CSR #define SHIM_SHIM_END SHIM_HDMC diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 588530a..36d4993 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -46,6 +46,7 @@ #include <reef/ipc.h> #include <reef/trace.h> #include <reef/audio/component.h> +#include <config.h> #include <string.h>
static const struct sst_intel_ipc_fw_ready ready = { @@ -148,6 +149,23 @@ int platform_ssp_set_mn(uint32_t ssp_port, uint32_t source, uint32_t rate, shim_write(SHIM_SSP2_DIVH, SHIM_SSP_DIV_ENA | SHIM_SSP_DIV_UPD | ssp_mn_conf[i].m); break; +#if defined CONFIG_CHERRYTRAIL + case 3: + shim_write(SHIM_SSP3_DIVL, ssp_mn_conf[i].n); + shim_write(SHIM_SSP3_DIVH, SHIM_SSP_DIV_ENA | + SHIM_SSP_DIV_UPD | ssp_mn_conf[i].m); + break; + case 4: + shim_write(SHIM_SSP4_DIVL, ssp_mn_conf[i].n); + shim_write(SHIM_SSP4_DIVH, SHIM_SSP_DIV_ENA | + SHIM_SSP_DIV_UPD | ssp_mn_conf[i].m); + break; + case 5: + shim_write(SHIM_SSP5_DIVL, ssp_mn_conf[i].n); + shim_write(SHIM_SSP5_DIVH, SHIM_SSP_DIV_ENA | + SHIM_SSP_DIV_UPD | ssp_mn_conf[i].m); + break; +#endif default: return -ENODEV; } @@ -173,6 +191,20 @@ void platform_ssp_disable_mn(uint32_t ssp_port) shim_write(SHIM_SSP2_DIVH, SHIM_SSP_DIV_BYP | SHIM_SSP_DIV_UPD); break; +#if defined CONFIG_CHERRYTRAIL + case 3: + shim_write(SHIM_SSP3_DIVH, SHIM_SSP_DIV_BYP | + SHIM_SSP_DIV_UPD); + break; + case 4: + shim_write(SHIM_SSP4_DIVH, SHIM_SSP_DIV_BYP | + SHIM_SSP_DIV_UPD); + break; + case 5: + shim_write(SHIM_SSP5_DIVH, SHIM_SSP_DIV_BYP | + SHIM_SSP_DIV_UPD); + break; +#endif } }
@@ -188,11 +220,18 @@ void platform_interrupt_clear(uint32_t irq, uint32_t mask) shim_write(SHIM_PISR, mask << 24); interrupt_clear(irq); break; +#if defined CONFIG_CHERRYTRAIL + case IRQ_NUM_EXT_DMAC2: + shim_write(SHIM_PISRH, mask << 0); + interrupt_clear(irq); + break; +#endif default: break; } }
+/* TODO: expand this to 64 bit - should we just return mask of IRQ numbers */ uint32_t platform_interrupt_get_enabled(void) { return shim_read(SHIM_PIMR); @@ -215,8 +254,15 @@ static struct timer platform_ext_timer = {
int platform_init(void) { +#if defined CONFIG_BAYTRAIL struct dma *dmac0, *dmac1; struct dai *ssp0, *ssp1, *ssp2; +#elif defined CONFIG_CHERRYTRAIL + struct dma *dmac0, *dmac1, *dmac2; + struct dai *ssp0, *ssp1, *ssp2, *ssp3, *ssp4, *ssp5; +#else +#error Undefined platform +#endif
trace_point(TRACE_BOOT_PLATFORM_MBOX);
@@ -226,7 +272,11 @@ int platform_init(void) trace_point(TRACE_BOOT_PLATFORM_SHIM);
/* configure the shim */ +#if defined CONFIG_BAYTRAIL shim_write(SHIM_MISC, shim_read(SHIM_MISC) | 0x0000000e); +#elif defined CONFIG_CHERRYTRAIL + shim_write(SHIM_MISC, shim_read(SHIM_MISC) | 0x00000e0e); +#endif
trace_point(TRACE_BOOT_PLATFORM_PMC);
@@ -247,9 +297,15 @@ int platform_init(void) trace_point(TRACE_BOOT_SYS_CPU_FREQ); clock_set_freq(CLK_CPU, CLK_MAX_CPU_HZ);
- /* set SSP clock to 25M */ trace_point(TRACE_BOOT_PLATFORM_SSP_FREQ); + +#if defined CONFIG_BAYTRAIL + /* set SSP clock to 25M TODO: make BYT use 19.2M as default */ clock_set_freq(CLK_SSP, 25000000); +#elif defined CONFIG_CHERRYTRAIL + /* set SSP clock to 19.2M */ + clock_set_freq(CLK_SSP, 19200000); +#endif
/* initialise the host IPC mechanisms */ trace_point(TRACE_BOOT_PLATFORM_IPC); @@ -267,6 +323,13 @@ int platform_init(void) return -ENODEV; dma_probe(dmac1);
+#if defined CONFIG_CHERRYTRAIL + dmac2 = dma_get(DMA_ID_DMAC1); + if (dmac2 == NULL) + return -ENODEV; + dma_probe(dmac2); +#endif + /* mask SSP interrupts */ shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) | 0x00000038);
@@ -286,5 +349,23 @@ int platform_init(void) if (ssp2 == NULL) return -ENODEV; dai_probe(ssp2); + +#if defined CONFIG_CHERRYTRAIL + ssp3 = dai_get(COMP_TYPE_DAI_SSP, 3); + if (ssp3 == NULL) + return -ENODEV; + dai_probe(ssp3); + + ssp4 = dai_get(COMP_TYPE_DAI_SSP, 4); + if (ssp4 == NULL) + return -ENODEV; + dai_probe(ssp4); + + ssp5 = dai_get(COMP_TYPE_DAI_SSP, 5); + if (ssp5 == NULL) + return -ENODEV; + dai_probe(ssp5); +#endif + return 0; }
participants (1)
-
Liam Girdwood