From b5a3546834137237bdc46d92b5b6b08e02045ea7 Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Wed, 22 Aug 2018 14:13:46 +0200 Subject: [PATCH 01/10] drivers: refactor: create / filetree Split files into appropriate folders. Added makefiles to not break build. Fixed checkpatch errors in dw-dma and baytrail/ssp. Signed-off-by: Janusz Jankowski --- configure.ac | 3 ++ src/arch/xtensa/Makefile.am | 2 +- src/drivers/Makefile.am | 46 ++++-------------- src/drivers/intel/Makefile.am | 17 +++++++ src/drivers/intel/cavs/Makefile.am | 12 +++++ src/drivers/{ => intel/cavs}/dmic.c | 0 src/drivers/{ => intel/cavs}/hda-dma.c | 0 src/drivers/{apl-ssp.c => intel/cavs/ssp.c} | 0 src/drivers/{ => intel}/dw-dma.c | 47 +++++++++++-------- src/drivers/intel/legacy/Makefile.am | 25 ++++++++++ .../legacy/baytrail/ssp.c} | 4 +- .../{hsw-ssp.c => intel/legacy/haswell/ssp.c} | 0 12 files changed, 97 insertions(+), 59 deletions(-) create mode 100644 src/drivers/intel/Makefile.am create mode 100644 src/drivers/intel/cavs/Makefile.am rename src/drivers/{ => intel/cavs}/dmic.c (100%) rename src/drivers/{ => intel/cavs}/hda-dma.c (100%) rename src/drivers/{apl-ssp.c => intel/cavs/ssp.c} (100%) rename src/drivers/{ => intel}/dw-dma.c (97%) create mode 100644 src/drivers/intel/legacy/Makefile.am rename src/drivers/{byt-ssp.c => intel/legacy/baytrail/ssp.c} (99%) rename src/drivers/{hsw-ssp.c => intel/legacy/haswell/ssp.c} (100%) diff --git a/configure.ac b/configure.ac index 43e26c5362b3..b91d74e7131c 100644 --- a/configure.ac +++ b/configure.ac @@ -448,6 +448,9 @@ AC_CONFIG_FILES([ src/audio/Makefile src/math/Makefile src/drivers/Makefile + src/drivers/intel/Makefile + src/drivers/intel/cavs/Makefile + src/drivers/intel/legacy/Makefile src/include/Makefile src/include/sof/Makefile src/include/sof/audio/Makefile diff --git a/src/arch/xtensa/Makefile.am b/src/arch/xtensa/Makefile.am index 0c3474e699c8..7727ecd9b9d9 100644 --- a/src/arch/xtensa/Makefile.am +++ b/src/arch/xtensa/Makefile.am @@ -93,7 +93,7 @@ sof_LDADD = \ ../../ipc/libsof_ipc.a \ ../../lib/libdma.a \ ../../audio/libaudio.a \ - ../../drivers/libdrivers.a \ + ../../drivers/libdrivers.la \ ../../math/libsof_math.a \ -lgcc diff --git a/src/drivers/Makefile.am b/src/drivers/Makefile.am index f6b8dd8d5adc..55c3ca99c577 100644 --- a/src/drivers/Makefile.am +++ b/src/drivers/Makefile.am @@ -1,44 +1,14 @@ -noinst_LIBRARIES = libdrivers.a +SUBDIRS = intel -libdrivers_a_SOURCES = \ - dw-dma.c +noinst_LTLIBRARIES = libdrivers.la -if BUILD_BAYTRAIL -libdrivers_a_SOURCES += \ - byt-ssp.c -endif - -if BUILD_CHERRYTRAIL -libdrivers_a_SOURCES += \ - byt-ssp.c -endif - -if BUILD_HASWELL -libdrivers_a_SOURCES += \ - hsw-ssp.c -endif - -if BUILD_BROADWELL -libdrivers_a_SOURCES += \ - hsw-ssp.c -endif - -if BUILD_APOLLOLAKE -libdrivers_a_SOURCES += \ - apl-ssp.c \ - hda-dma.c \ - dmic.c -endif - -if BUILD_CANNONLAKE -libdrivers_a_SOURCES += \ - apl-ssp.c \ - hda-dma.c \ - dmic.c -endif - -libdrivers_a_CFLAGS = \ +libdrivers_la_CFLAGS = \ $(ARCH_CFLAGS) \ $(PLATFORM_INCDIR) \ $(SOF_INCDIR) \ $(ARCH_INCDIR) + +# This lib is just composition of convenience libraries +libdrivers_la_SOURCES = + +libdrivers_la_LIBADD = intel/libdrivers.la diff --git a/src/drivers/intel/Makefile.am b/src/drivers/intel/Makefile.am new file mode 100644 index 000000000000..6968be83dc65 --- /dev/null +++ b/src/drivers/intel/Makefile.am @@ -0,0 +1,17 @@ +noinst_LTLIBRARIES = libdrivers.la + +libdrivers_la_CFLAGS = \ + $(ARCH_CFLAGS) \ + $(PLATFORM_INCDIR) \ + $(SOF_INCDIR) \ + $(ARCH_INCDIR) + +libdrivers_la_SOURCES = dw-dma.c + +if BUILD_CAVS +SUBDIRS = cavs +libdrivers_la_LIBADD = cavs/libdrivers.la +else +SUBDIRS = legacy +libdrivers_la_LIBADD = legacy/libdrivers.la +endif diff --git a/src/drivers/intel/cavs/Makefile.am b/src/drivers/intel/cavs/Makefile.am new file mode 100644 index 000000000000..7056d77dd375 --- /dev/null +++ b/src/drivers/intel/cavs/Makefile.am @@ -0,0 +1,12 @@ +noinst_LTLIBRARIES = libdrivers.la + +libdrivers_la_SOURCES = \ + dmic.c \ + hda-dma.c \ + ssp.c + +libdrivers_la_CFLAGS = \ + $(ARCH_CFLAGS) \ + $(PLATFORM_INCDIR) \ + $(SOF_INCDIR) \ + $(ARCH_INCDIR) diff --git a/src/drivers/dmic.c b/src/drivers/intel/cavs/dmic.c similarity index 100% rename from src/drivers/dmic.c rename to src/drivers/intel/cavs/dmic.c diff --git a/src/drivers/hda-dma.c b/src/drivers/intel/cavs/hda-dma.c similarity index 100% rename from src/drivers/hda-dma.c rename to src/drivers/intel/cavs/hda-dma.c diff --git a/src/drivers/apl-ssp.c b/src/drivers/intel/cavs/ssp.c similarity index 100% rename from src/drivers/apl-ssp.c rename to src/drivers/intel/cavs/ssp.c diff --git a/src/drivers/dw-dma.c b/src/drivers/intel/dw-dma.c similarity index 97% rename from src/drivers/dw-dma.c rename to src/drivers/intel/dw-dma.c index 07c48180cc58..971c7b7ffb8a 100644 --- a/src/drivers/dw-dma.c +++ b/src/drivers/intel/dw-dma.c @@ -149,7 +149,7 @@ #define DW_CTLL_RELOAD_DST (1 << 31) /* Haswell / Broadwell specific registers */ -#if defined (CONFIG_HASWELL) || defined (CONFIG_BROADWELL) +#if defined(CONFIG_HASWELL) || defined(CONFIG_BROADWELL) /* CTL_HI */ #define DW_CTLH_DONE 0x00001000 @@ -166,7 +166,7 @@ #define DW_CFG_LOW_DEF 0x0 #define DW_CFG_HIGH_DEF 0x4 -#elif defined (CONFIG_BAYTRAIL) || defined (CONFIG_CHERRYTRAIL) +#elif defined(CONFIG_BAYTRAIL) || defined(CONFIG_CHERRYTRAIL) /* baytrail specific registers */ /* CTL_LO */ @@ -198,7 +198,7 @@ #define DW_CFG_LOW_DEF 0x00000003 #define DW_CFG_HIGH_DEF 0x0 -#elif defined (CONFIG_APOLLOLAKE) || defined (CONFIG_CANNONLAKE) +#elif defined(CONFIG_APOLLOLAKE) || defined(CONFIG_CANNONLAKE) /* CTL_LO */ #define DW_CTLL_S_GATH_EN (1 << 17) @@ -264,9 +264,12 @@ struct dma_chan_data { uint32_t cfg_hi; struct dma_id id; - void (*cb)(void *data, uint32_t type, struct dma_sg_elem *next); /* client callback function */ - void *cb_data; /* client callback data */ - int cb_type; /* callback type */ + /* client callback function */ + void (*cb)(void *data, uint32_t type, struct dma_sg_elem *next); + /* client callback data */ + void *cb_data; + /* callback type */ + int cb_type; }; /* private data for DW DMA engine */ @@ -400,7 +403,8 @@ static int dw_dma_start(struct dma *dma, int channel) } /* write interrupt clear registers for the channel: - ClearTfr, ClearBlock, ClearSrcTran, ClearDstTran, ClearErr*/ + * ClearTfr, ClearBlock, ClearSrcTran, ClearDstTran, ClearErr + */ dw_write(dma, DW_CLEAR_TFR, 0x1 << channel); dw_write(dma, DW_CLEAR_BLOCK, 0x1 << channel); dw_write(dma, DW_CLEAR_SRC_TRAN, 0x1 << channel); @@ -664,7 +668,9 @@ static int dw_dma_set_config(struct dma *dma, int channel, lli_desc->ctrl_lo |= DW_CTLL_DST_MSIZE(msize); lli_desc->ctrl_lo |= DW_CTLL_INT_EN; /* enable interrupt */ - /* config the SINC and DINC field of CTL_LOn, SRC/DST_PER filed of CFGn */ + /* config the SINC and DINC field of CTL_LOn, + * SRC/DST_PER filed of CFGn + */ switch (config->direction) { case DMA_DIR_LMEM_TO_HMEM: lli_desc->ctrl_lo |= DW_CTLL_FC_M2M; @@ -676,22 +682,25 @@ static int dw_dma_set_config(struct dma *dma, int channel, case DMA_DIR_HMEM_TO_LMEM: lli_desc->ctrl_lo |= DW_CTLL_FC_M2M; lli_desc->ctrl_lo |= DW_CTLL_SRC_INC | DW_CTLL_DST_INC; - lli_desc->dar = - (uint32_t)sg_elem->dest | PLATFORM_HOST_DMA_MASK; + lli_desc->dar = (uint32_t)sg_elem->dest + | PLATFORM_HOST_DMA_MASK; lli_desc->sar = (uint32_t)sg_elem->src; break; case DMA_DIR_MEM_TO_MEM: lli_desc->ctrl_lo |= DW_CTLL_FC_M2M; lli_desc->ctrl_lo |= DW_CTLL_SRC_INC | DW_CTLL_DST_INC; - lli_desc->sar = (uint32_t)sg_elem->src | PLATFORM_HOST_DMA_MASK; - lli_desc->dar = (uint32_t)sg_elem->dest | PLATFORM_HOST_DMA_MASK; + lli_desc->sar = (uint32_t)sg_elem->src + | PLATFORM_HOST_DMA_MASK; + lli_desc->dar = (uint32_t)sg_elem->dest + | PLATFORM_HOST_DMA_MASK; break; case DMA_DIR_MEM_TO_DEV: lli_desc->ctrl_lo |= DW_CTLL_FC_M2P; lli_desc->ctrl_lo |= DW_CTLL_SRC_INC | DW_CTLL_DST_FIX; p->chan[channel].cfg_hi |= DW_CFGH_DST_PER(config->dest_dev); - lli_desc->sar = (uint32_t)sg_elem->src | PLATFORM_HOST_DMA_MASK; + lli_desc->sar = (uint32_t)sg_elem->src + | PLATFORM_HOST_DMA_MASK; lli_desc->dar = (uint32_t)sg_elem->dest; break; case DMA_DIR_DEV_TO_MEM: @@ -700,7 +709,8 @@ static int dw_dma_set_config(struct dma *dma, int channel, p->chan[channel].cfg_hi |= DW_CFGH_SRC_PER(config->src_dev); lli_desc->sar = (uint32_t)sg_elem->src; - lli_desc->dar = (uint32_t)sg_elem->dest | PLATFORM_HOST_DMA_MASK; + lli_desc->dar = (uint32_t)sg_elem->dest + | PLATFORM_HOST_DMA_MASK; break; case DMA_DIR_DEV_TO_DEV: lli_desc->ctrl_lo |= DW_CTLL_FC_P2P; @@ -730,7 +740,8 @@ static int dw_dma_set_config(struct dma *dma, int channel, (sg_elem->size & DW_CTLH_BLOCK_TS_MASK); #elif defined CONFIG_BROADWELL || defined CONFIG_HASWELL /* for bdw, the unit is transaction--TR_WIDTH. */ - lli_desc->ctrl_hi = (sg_elem->size / (1 << (lli_desc->ctrl_lo >> 4 & 0x7))) + lli_desc->ctrl_hi = (sg_elem->size / + (1 << (lli_desc->ctrl_lo >> 4 & 0x7))) & DW_CTLH_BLOCK_TS_MASK; #endif @@ -1080,9 +1091,8 @@ static void dw_dma_irq_handler(void *data) int i; status_intr = dw_read(dma, DW_INTR_STATUS); - if (!status_intr) { + if (!status_intr) return; - } tracev_dma("DIr"); @@ -1097,9 +1107,8 @@ static void dw_dma_irq_handler(void *data) /* TODO: handle errors, just clear them atm */ status_err = dw_read(dma, DW_STATUS_ERR); dw_write(dma, DW_CLEAR_ERR, status_err); - if (status_err) { + if (status_err) trace_dma_error("eI1"); - } /* clear platform and DSP interrupt */ pmask = status_block | status_tfr | status_err; diff --git a/src/drivers/intel/legacy/Makefile.am b/src/drivers/intel/legacy/Makefile.am new file mode 100644 index 000000000000..4e10f866b398 --- /dev/null +++ b/src/drivers/intel/legacy/Makefile.am @@ -0,0 +1,25 @@ +noinst_LTLIBRARIES = libdrivers.la + +libdrivers_la_CFLAGS = \ + $(ARCH_CFLAGS) \ + $(PLATFORM_INCDIR) \ + $(SOF_INCDIR) \ + $(ARCH_INCDIR) + +libdrivers_la_SOURCES = + +if BUILD_BAYTRAIL +libdrivers_la_SOURCES += baytrail/ssp.c +endif + +if BUILD_CHERRYTRAIL +libdrivers_la_SOURCES += baytrail/ssp.c +endif + +if BUILD_HASWELL +libdrivers_la_SOURCES += haswell/ssp.c +endif + +if BUILD_BROADWELL +libdrivers_la_SOURCES += haswell/ssp.c +endif diff --git a/src/drivers/byt-ssp.c b/src/drivers/intel/legacy/baytrail/ssp.c similarity index 99% rename from src/drivers/byt-ssp.c rename to src/drivers/intel/legacy/baytrail/ssp.c index a940ff98e2f8..669c639e13f0 100644 --- a/src/drivers/byt-ssp.c +++ b/src/drivers/intel/legacy/baytrail/ssp.c @@ -585,7 +585,9 @@ static int ssp_probe(struct dai *dai) ssp->state[DAI_DIR_CAPTURE] = COMP_STATE_READY; #if defined CONFIG_CHERRYTRAIL - /* register our IRQ handler - CHT shares SSP 0,1,2 IRQs with SSP 3,4,5 */ + /* register our IRQ handler + * - CHT shares SSP 0,1,2 IRQs with SSP 3,4,5 + */ if (ssp_irq(dai) >= IRQ_CHT_SSP_OFFSET) interrupt_register(ssp_irq(dai) - IRQ_CHT_SSP_OFFSET, ssp_irq_handler, dai); diff --git a/src/drivers/hsw-ssp.c b/src/drivers/intel/legacy/haswell/ssp.c similarity index 100% rename from src/drivers/hsw-ssp.c rename to src/drivers/intel/legacy/haswell/ssp.c From 08614a8759e4cbb2ac2ae96b5539510a72830fc1 Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Wed, 22 Aug 2018 14:35:50 +0200 Subject: [PATCH 02/10] platform: refactor: move interrupt functions from platform.c Moved platform_interrupt_* functions from platform.c to interrupt.c to match CNL&APL. Updated headers for BYT&HSW to have the same functions declarations as CNL&APL. Signed-off-by: Janusz Jankowski --- src/platform/baytrail/Makefile.am | 1 + .../baytrail/include/platform/interrupt.h | 8 +- src/platform/baytrail/interrupt.c | 174 ++++++++++++++++++ src/platform/baytrail/platform.c | 127 ------------- src/platform/haswell/Makefile.am | 1 + .../haswell/include/platform/interrupt.h | 9 +- src/platform/haswell/interrupt.c | 109 +++++++++++ src/platform/haswell/platform.c | 66 ------- 8 files changed, 289 insertions(+), 206 deletions(-) create mode 100644 src/platform/baytrail/interrupt.c create mode 100644 src/platform/haswell/interrupt.c diff --git a/src/platform/baytrail/Makefile.am b/src/platform/baytrail/Makefile.am index f07860960479..71b4d0892cef 100644 --- a/src/platform/baytrail/Makefile.am +++ b/src/platform/baytrail/Makefile.am @@ -5,6 +5,7 @@ EXTRA_DIST = baytrail.x.in noinst_LTLIBRARIES = libplatform.la libplatform_la_SOURCES = \ + interrupt.c \ platform.c \ dai.c \ dma.c \ diff --git a/src/platform/baytrail/include/platform/interrupt.h b/src/platform/baytrail/include/platform/interrupt.h index d0cd17b6b807..9a2afa573ea1 100644 --- a/src/platform/baytrail/include/platform/interrupt.h +++ b/src/platform/baytrail/include/platform/interrupt.h @@ -88,13 +88,9 @@ /* no nested interrupts */ #define PLATFORM_IRQ_CHILDREN 0 -static inline void platform_interrupt_init(void) {} - -static inline struct irq_desc *platform_irq_get_parent(uint32_t irq) -{ - return NULL; -} +void platform_interrupt_init(void); +struct irq_desc *platform_irq_get_parent(uint32_t irq); void platform_interrupt_set(int irq); void platform_interrupt_clear(uint32_t irq, uint32_t mask); uint32_t platform_interrupt_get_enabled(void); diff --git a/src/platform/baytrail/interrupt.c b/src/platform/baytrail/interrupt.c new file mode 100644 index 000000000000..56c185684425 --- /dev/null +++ b/src/platform/baytrail/interrupt.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2018, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Liam Girdwood + * Keyon Jie + * Janusz Jankowski + * + */ + +#include +#include + +void platform_interrupt_init(void) {} + +struct irq_desc *platform_irq_get_parent(uint32_t irq) +{ + return NULL; +} + +void platform_interrupt_set(int irq) +{ + arch_interrupt_set(irq); +} + +/* clear mask in PISR, bits are W1C in docs but some bits need preserved ?? */ +void platform_interrupt_clear(uint32_t irq, uint32_t mask) +{ + switch (irq) { + case IRQ_NUM_EXT_SSP0: + shim_write(SHIM_PISR, mask << 3); + interrupt_clear(irq); + break; + case IRQ_NUM_EXT_SSP1: + shim_write(SHIM_PISR, mask << 4); + interrupt_clear(irq); + break; + case IRQ_NUM_EXT_SSP2: + shim_write(SHIM_PISR, mask << 5); + interrupt_clear(irq); + break; + case IRQ_NUM_EXT_DMAC0: + shim_write(SHIM_PISR, mask << 16); + interrupt_clear(irq); + break; + case IRQ_NUM_EXT_DMAC1: + 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; + case IRQ_NUM_EXT_SSP3: + shim_write(SHIM_PISRH, mask << 8); + interrupt_clear(irq); + break; + case IRQ_NUM_EXT_SSP4: + shim_write(SHIM_PISRH, mask << 9); + interrupt_clear(irq); + break; + case IRQ_NUM_EXT_SSP5: + shim_write(SHIM_PISRH, mask << 10); + 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); +} + +void platform_interrupt_mask(uint32_t irq, uint32_t mask) +{ + switch (irq) { + case IRQ_NUM_EXT_SSP0: + shim_write(SHIM_PIMR, mask << 3); + break; + case IRQ_NUM_EXT_SSP1: + shim_write(SHIM_PIMR, mask << 4); + break; + case IRQ_NUM_EXT_SSP2: + shim_write(SHIM_PIMR, mask << 5); + break; + case IRQ_NUM_EXT_DMAC0: + shim_write(SHIM_PIMR, mask << 16); + break; + case IRQ_NUM_EXT_DMAC1: + shim_write(SHIM_PIMR, mask << 24); + break; +#if defined CONFIG_CHERRYTRAIL + case IRQ_NUM_EXT_DMAC2: + shim_write(SHIM_PIMRH, mask << 8); + break; + case IRQ_NUM_EXT_SSP3: + shim_write(SHIM_PIMRH, mask << 0); + break; + case IRQ_NUM_EXT_SSP4: + shim_write(SHIM_PIMRH, mask << 1); + break; + case IRQ_NUM_EXT_SSP5: + shim_write(SHIM_PIMRH, mask << 2); + break; +#endif + default: + break; + } +} + +void platform_interrupt_unmask(uint32_t irq, uint32_t mask) +{ + switch (irq) { + case IRQ_NUM_EXT_SSP0: + shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 3)); + break; + case IRQ_NUM_EXT_SSP1: + shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 4)); + break; + case IRQ_NUM_EXT_SSP2: + shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 5)); + break; + case IRQ_NUM_EXT_DMAC0: + shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 16)); + break; + case IRQ_NUM_EXT_DMAC1: + shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 24)); + break; +#if defined CONFIG_CHERRYTRAIL + case IRQ_NUM_EXT_DMAC2: + shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 8)); + break; + case IRQ_NUM_EXT_SSP3: + shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 0)); + break; + case IRQ_NUM_EXT_SSP4: + shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 1)); + break; + case IRQ_NUM_EXT_SSP5: + shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 2)); + break; +#endif + default: + break; + } +} diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 7906cb4fc14d..01b3e6ef6c9f 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -164,133 +164,6 @@ int platform_boot_complete(uint32_t boot_message) return 0; } -/* clear mask in PISR, bits are W1C in docs but some bits need preserved ?? */ -void platform_interrupt_clear(uint32_t irq, uint32_t mask) -{ - switch (irq) { - case IRQ_NUM_EXT_SSP0: - shim_write(SHIM_PISR, mask << 3); - interrupt_clear(irq); - break; - case IRQ_NUM_EXT_SSP1: - shim_write(SHIM_PISR, mask << 4); - interrupt_clear(irq); - break; - case IRQ_NUM_EXT_SSP2: - shim_write(SHIM_PISR, mask << 5); - interrupt_clear(irq); - break; - case IRQ_NUM_EXT_DMAC0: - shim_write(SHIM_PISR, mask << 16); - interrupt_clear(irq); - break; - case IRQ_NUM_EXT_DMAC1: - 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; - case IRQ_NUM_EXT_SSP3: - shim_write(SHIM_PISRH, mask << 8); - interrupt_clear(irq); - break; - case IRQ_NUM_EXT_SSP4: - shim_write(SHIM_PISRH, mask << 9); - interrupt_clear(irq); - break; - case IRQ_NUM_EXT_SSP5: - shim_write(SHIM_PISRH, mask << 10); - 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); -} - -void platform_interrupt_mask(uint32_t irq, uint32_t mask) -{ - switch (irq) { - case IRQ_NUM_EXT_SSP0: - shim_write(SHIM_PIMR, mask << 3); - break; - case IRQ_NUM_EXT_SSP1: - shim_write(SHIM_PIMR, mask << 4); - break; - case IRQ_NUM_EXT_SSP2: - shim_write(SHIM_PIMR, mask << 5); - break; - case IRQ_NUM_EXT_DMAC0: - shim_write(SHIM_PIMR, mask << 16); - break; - case IRQ_NUM_EXT_DMAC1: - shim_write(SHIM_PIMR, mask << 24); - break; -#if defined CONFIG_CHERRYTRAIL - case IRQ_NUM_EXT_DMAC2: - shim_write(SHIM_PIMRH, mask << 8); - break; - case IRQ_NUM_EXT_SSP3: - shim_write(SHIM_PIMRH, mask << 0); - break; - case IRQ_NUM_EXT_SSP4: - shim_write(SHIM_PIMRH, mask << 1); - break; - case IRQ_NUM_EXT_SSP5: - shim_write(SHIM_PIMRH, mask << 2); - break; -#endif - default: - break; - } -} - -void platform_interrupt_unmask(uint32_t irq, uint32_t mask) -{ - switch (irq) { - case IRQ_NUM_EXT_SSP0: - shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 3)); - break; - case IRQ_NUM_EXT_SSP1: - shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 4)); - break; - case IRQ_NUM_EXT_SSP2: - shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 5)); - break; - case IRQ_NUM_EXT_DMAC0: - shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 16)); - break; - case IRQ_NUM_EXT_DMAC1: - shim_write(SHIM_PIMR, shim_read(SHIM_PIMR) & ~(mask << 24)); - break; -#if defined CONFIG_CHERRYTRAIL - case IRQ_NUM_EXT_DMAC2: - shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 8)); - break; - case IRQ_NUM_EXT_SSP3: - shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 0)); - break; - case IRQ_NUM_EXT_SSP4: - shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 1)); - break; - case IRQ_NUM_EXT_SSP5: - shim_write(SHIM_PIMRH, shim_read(SHIM_PIMRH) & ~(mask << 2)); - break; -#endif - default: - break; - } -} - int platform_init(struct sof *sof) { #if defined CONFIG_BAYTRAIL diff --git a/src/platform/haswell/Makefile.am b/src/platform/haswell/Makefile.am index 8e0f221da128..71921ae76af2 100644 --- a/src/platform/haswell/Makefile.am +++ b/src/platform/haswell/Makefile.am @@ -5,6 +5,7 @@ EXTRA_DIST = haswell.x.in noinst_LTLIBRARIES = libplatform.la libplatform_la_SOURCES = \ + interrupt.c \ platform.c \ dai.c \ dma.c \ diff --git a/src/platform/haswell/include/platform/interrupt.h b/src/platform/haswell/include/platform/interrupt.h index 14d0e30c9db6..c9f4c0548bb5 100644 --- a/src/platform/haswell/include/platform/interrupt.h +++ b/src/platform/haswell/include/platform/interrupt.h @@ -66,14 +66,9 @@ #define IRQ_MASK_EXT_PARITY (1 << IRQ_NUM_EXT_PARITY) #define IRQ_MASK_TIMER3 (1 << IRQ_NUM_TIMER3) -static inline void platform_interrupt_init(void) {} - -/* haswell does not support child IRQs */ -static inline struct irq_desc *platform_irq_get_parent(uint32_t irq) -{ - return NULL; -} +void platform_interrupt_init(void); +struct irq_desc *platform_irq_get_parent(uint32_t irq); void platform_interrupt_set(int irq); void platform_interrupt_clear(uint32_t irq, uint32_t mask); uint32_t platform_interrupt_get_enabled(void); diff --git a/src/platform/haswell/interrupt.c b/src/platform/haswell/interrupt.c new file mode 100644 index 000000000000..70645666fe55 --- /dev/null +++ b/src/platform/haswell/interrupt.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2018, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Liam Girdwood + * Keyon Jie + * Janusz Jankowski + * + */ + +#include +#include + +void platform_interrupt_init(void) {} + +/* haswell does not support child IRQs */ +struct irq_desc *platform_irq_get_parent(uint32_t irq) +{ + return NULL; +} + +void platform_interrupt_set(int irq) +{ + arch_interrupt_set(irq); +} + +/* clear mask in PISR, bits are W1C in docs but some bits need preserved ?? */ +void platform_interrupt_clear(uint32_t irq, uint32_t mask) +{ + switch (irq) { + case IRQ_NUM_EXT_DMAC0: + case IRQ_NUM_EXT_DMAC1: + case IRQ_NUM_EXT_SSP0: + case IRQ_NUM_EXT_SSP1: + interrupt_clear(irq); + break; + 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_IMRD); +} + +void platform_interrupt_mask(uint32_t irq, uint32_t mask) +{ + switch (irq) { + case IRQ_NUM_EXT_SSP0: + shim_write(SHIM_IMRD, SHIM_IMRD_SSP0); + break; + case IRQ_NUM_EXT_SSP1: + shim_write(SHIM_IMRD, SHIM_IMRD_SSP1); + break; + case IRQ_NUM_EXT_DMAC0: + shim_write(SHIM_IMRD, SHIM_IMRD_DMAC0); + break; + case IRQ_NUM_EXT_DMAC1: + shim_write(SHIM_IMRD, SHIM_IMRD_DMAC1); + break; + default: + break; + } +} + +void platform_interrupt_unmask(uint32_t irq, uint32_t mask) +{ + switch (irq) { + case IRQ_NUM_EXT_SSP0: + shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_SSP0); + break; + case IRQ_NUM_EXT_SSP1: + shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_SSP1); + break; + case IRQ_NUM_EXT_DMAC0: + shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_DMAC0); + break; + case IRQ_NUM_EXT_DMAC1: + shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_DMAC1); + break; + default: + break; + } +} diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c index 5c9358108f70..24b56520d512 100644 --- a/src/platform/haswell/platform.c +++ b/src/platform/haswell/platform.c @@ -159,72 +159,6 @@ int platform_boot_complete(uint32_t boot_message) return 0; } -void platform_interrupt_set(int irq) -{ - arch_interrupt_set(irq); -} - -/* clear mask in PISR, bits are W1C in docs but some bits need preserved ?? */ -void platform_interrupt_clear(uint32_t irq, uint32_t mask) -{ - switch (irq) { - case IRQ_NUM_EXT_DMAC0: - case IRQ_NUM_EXT_DMAC1: - case IRQ_NUM_EXT_SSP0: - case IRQ_NUM_EXT_SSP1: - interrupt_clear(irq); - break; - 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_IMRD); -} - -void platform_interrupt_mask(uint32_t irq, uint32_t mask) -{ - switch (irq) { - case IRQ_NUM_EXT_SSP0: - shim_write(SHIM_IMRD, SHIM_IMRD_SSP0); - break; - case IRQ_NUM_EXT_SSP1: - shim_write(SHIM_IMRD, SHIM_IMRD_SSP1); - break; - case IRQ_NUM_EXT_DMAC0: - shim_write(SHIM_IMRD, SHIM_IMRD_DMAC0); - break; - case IRQ_NUM_EXT_DMAC1: - shim_write(SHIM_IMRD, SHIM_IMRD_DMAC1); - break; - default: - break; - } -} - -void platform_interrupt_unmask(uint32_t irq, uint32_t mask) -{ - switch (irq) { - case IRQ_NUM_EXT_SSP0: - shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_SSP0); - break; - case IRQ_NUM_EXT_SSP1: - shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_SSP1); - break; - case IRQ_NUM_EXT_DMAC0: - shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_DMAC0); - break; - case IRQ_NUM_EXT_DMAC1: - shim_write(SHIM_IMRD, shim_read(SHIM_IMRD) & ~SHIM_IMRD_DMAC1); - break; - default: - break; - } -} - /* init shim registers */ static void platform_init_shim(void) { From f6ef5bca5cf17894fd27c8749bd1f6f2953a605e Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Wed, 22 Aug 2018 14:52:48 +0200 Subject: [PATCH 03/10] drivers: refactor: add per-platform makefile for legacy Signed-off-by: Janusz Jankowski --- configure.ac | 2 ++ src/drivers/intel/legacy/Makefile.am | 13 +++++++++---- src/drivers/intel/legacy/baytrail/Makefile.am | 10 ++++++++++ src/drivers/intel/legacy/haswell/Makefile.am | 10 ++++++++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/drivers/intel/legacy/baytrail/Makefile.am create mode 100644 src/drivers/intel/legacy/haswell/Makefile.am diff --git a/configure.ac b/configure.ac index b91d74e7131c..8635066954d2 100644 --- a/configure.ac +++ b/configure.ac @@ -451,6 +451,8 @@ AC_CONFIG_FILES([ src/drivers/intel/Makefile src/drivers/intel/cavs/Makefile src/drivers/intel/legacy/Makefile + src/drivers/intel/legacy/baytrail/Makefile + src/drivers/intel/legacy/haswell/Makefile src/include/Makefile src/include/sof/Makefile src/include/sof/audio/Makefile diff --git a/src/drivers/intel/legacy/Makefile.am b/src/drivers/intel/legacy/Makefile.am index 4e10f866b398..b96301cc4703 100644 --- a/src/drivers/intel/legacy/Makefile.am +++ b/src/drivers/intel/legacy/Makefile.am @@ -6,20 +6,25 @@ libdrivers_la_CFLAGS = \ $(SOF_INCDIR) \ $(ARCH_INCDIR) +# This lib just includes lib for specific platform libdrivers_la_SOURCES = if BUILD_BAYTRAIL -libdrivers_la_SOURCES += baytrail/ssp.c +SUBDIRS = baytrail +libdrivers_la_LIBADD = baytrail/libdrivers.la endif if BUILD_CHERRYTRAIL -libdrivers_la_SOURCES += baytrail/ssp.c +SUBDIRS = baytrail +libdrivers_la_LIBADD = baytrail/libdrivers.la endif if BUILD_HASWELL -libdrivers_la_SOURCES += haswell/ssp.c +SUBDIRS = haswell +libdrivers_la_LIBADD = haswell/libdrivers.la endif if BUILD_BROADWELL -libdrivers_la_SOURCES += haswell/ssp.c +SUBDIRS = haswell +libdrivers_la_LIBADD = haswell/libdrivers.la endif diff --git a/src/drivers/intel/legacy/baytrail/Makefile.am b/src/drivers/intel/legacy/baytrail/Makefile.am new file mode 100644 index 000000000000..4a9cfb588d66 --- /dev/null +++ b/src/drivers/intel/legacy/baytrail/Makefile.am @@ -0,0 +1,10 @@ +noinst_LTLIBRARIES = libdrivers.la + +libdrivers_la_SOURCES = \ + ssp.c + +libdrivers_la_CFLAGS = \ + $(ARCH_CFLAGS) \ + $(PLATFORM_INCDIR) \ + $(SOF_INCDIR) \ + $(ARCH_INCDIR) diff --git a/src/drivers/intel/legacy/haswell/Makefile.am b/src/drivers/intel/legacy/haswell/Makefile.am new file mode 100644 index 000000000000..4a9cfb588d66 --- /dev/null +++ b/src/drivers/intel/legacy/haswell/Makefile.am @@ -0,0 +1,10 @@ +noinst_LTLIBRARIES = libdrivers.la + +libdrivers_la_SOURCES = \ + ssp.c + +libdrivers_la_CFLAGS = \ + $(ARCH_CFLAGS) \ + $(PLATFORM_INCDIR) \ + $(SOF_INCDIR) \ + $(ARCH_INCDIR) From a738cb2eeb6ff1205a72bf0c375e4980f3ea721d Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Wed, 22 Aug 2018 15:17:19 +0200 Subject: [PATCH 04/10] drivers: refactor: move interrupt from platform to drivers Signed-off-by: Janusz Jankowski --- configure.ac | 1 + src/drivers/intel/cavs/Makefile.am | 1 + .../intel/cavs/interrupt.c | 3 -- src/drivers/intel/legacy/baytrail/Makefile.am | 1 + .../intel/legacy}/baytrail/interrupt.c | 0 src/drivers/intel/legacy/haswell/Makefile.am | 1 + .../intel/legacy}/haswell/interrupt.c | 0 src/include/sof/drivers/Makefile.am | 2 + src/include/sof/drivers/interrupt.h | 45 +++++++++++++++++++ src/include/sof/interrupt.h | 1 + .../apollolake/include/platform/interrupt.h | 9 ---- src/platform/baytrail/Makefile.am | 1 - .../baytrail/include/platform/interrupt.h | 9 ---- .../cannonlake/include/platform/interrupt.h | 9 ---- src/platform/haswell/Makefile.am | 1 - .../haswell/include/platform/interrupt.h | 9 ---- src/platform/intel/cavs/Makefile.am | 1 - 17 files changed, 52 insertions(+), 42 deletions(-) rename src/{platform => drivers}/intel/cavs/interrupt.c (99%) rename src/{platform => drivers/intel/legacy}/baytrail/interrupt.c (100%) rename src/{platform => drivers/intel/legacy}/haswell/interrupt.c (100%) create mode 100644 src/include/sof/drivers/Makefile.am create mode 100644 src/include/sof/drivers/interrupt.h diff --git a/configure.ac b/configure.ac index 8635066954d2..618b36fb7640 100644 --- a/configure.ac +++ b/configure.ac @@ -458,6 +458,7 @@ AC_CONFIG_FILES([ src/include/sof/audio/Makefile src/include/sof/audio/coefficients/Makefile src/include/sof/audio/coefficients/src/Makefile + src/include/sof/drivers/Makefile src/include/sof/math/Makefile src/include/uapi/Makefile src/ipc/Makefile diff --git a/src/drivers/intel/cavs/Makefile.am b/src/drivers/intel/cavs/Makefile.am index 7056d77dd375..98b113108835 100644 --- a/src/drivers/intel/cavs/Makefile.am +++ b/src/drivers/intel/cavs/Makefile.am @@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ dmic.c \ hda-dma.c \ + interrupt.c \ ssp.c libdrivers_la_CFLAGS = \ diff --git a/src/platform/intel/cavs/interrupt.c b/src/drivers/intel/cavs/interrupt.c similarity index 99% rename from src/platform/intel/cavs/interrupt.c rename to src/drivers/intel/cavs/interrupt.c index c01eb3b70118..2c171db7499f 100644 --- a/src/platform/intel/cavs/interrupt.c +++ b/src/drivers/intel/cavs/interrupt.c @@ -65,7 +65,6 @@ static inline void irq_lvl2_handler(void *data, /* handle each child */ while (status) { - /* any IRQ for this child bit ? */ if ((status & 0x1) == 0) goto next; @@ -193,7 +192,6 @@ void platform_interrupt_mask(uint32_t irq, uint32_t mask) default: break; } - } void platform_interrupt_unmask(uint32_t irq, uint32_t mask) @@ -217,7 +215,6 @@ void platform_interrupt_unmask(uint32_t irq, uint32_t mask) default: break; } - } void platform_interrupt_clear(uint32_t irq, uint32_t mask) diff --git a/src/drivers/intel/legacy/baytrail/Makefile.am b/src/drivers/intel/legacy/baytrail/Makefile.am index 4a9cfb588d66..fe6c4c8cb972 100644 --- a/src/drivers/intel/legacy/baytrail/Makefile.am +++ b/src/drivers/intel/legacy/baytrail/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ + interrupt.c \ ssp.c libdrivers_la_CFLAGS = \ diff --git a/src/platform/baytrail/interrupt.c b/src/drivers/intel/legacy/baytrail/interrupt.c similarity index 100% rename from src/platform/baytrail/interrupt.c rename to src/drivers/intel/legacy/baytrail/interrupt.c diff --git a/src/drivers/intel/legacy/haswell/Makefile.am b/src/drivers/intel/legacy/haswell/Makefile.am index 4a9cfb588d66..fe6c4c8cb972 100644 --- a/src/drivers/intel/legacy/haswell/Makefile.am +++ b/src/drivers/intel/legacy/haswell/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ + interrupt.c \ ssp.c libdrivers_la_CFLAGS = \ diff --git a/src/platform/haswell/interrupt.c b/src/drivers/intel/legacy/haswell/interrupt.c similarity index 100% rename from src/platform/haswell/interrupt.c rename to src/drivers/intel/legacy/haswell/interrupt.c diff --git a/src/include/sof/drivers/Makefile.am b/src/include/sof/drivers/Makefile.am new file mode 100644 index 000000000000..53ecb792d073 --- /dev/null +++ b/src/include/sof/drivers/Makefile.am @@ -0,0 +1,2 @@ +noinst_HEADERS = \ + interrupt.h diff --git a/src/include/sof/drivers/interrupt.h b/src/include/sof/drivers/interrupt.h new file mode 100644 index 000000000000..615c6179927d --- /dev/null +++ b/src/include/sof/drivers/interrupt.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Janusz Jankowski + */ + +#ifndef __INCLUDE_DRIVERS_INTERRUPT__ +#define __INCLUDE_DRIVERS_INTERRUPT__ + +#include + +void platform_interrupt_init(void); + +struct irq_desc *platform_irq_get_parent(uint32_t irq); +void platform_interrupt_set(int irq); +void platform_interrupt_clear(uint32_t irq, uint32_t mask); +uint32_t platform_interrupt_get_enabled(void); +void platform_interrupt_mask(uint32_t irq, uint32_t mask); +void platform_interrupt_unmask(uint32_t irq, uint32_t mask); + +#endif diff --git a/src/include/sof/interrupt.h b/src/include/sof/interrupt.h index bbda635fc7b5..082299534314 100644 --- a/src/include/sof/interrupt.h +++ b/src/include/sof/interrupt.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/src/platform/apollolake/include/platform/interrupt.h b/src/platform/apollolake/include/platform/interrupt.h index 677866194ce0..e60a04b7828d 100644 --- a/src/platform/apollolake/include/platform/interrupt.h +++ b/src/platform/apollolake/include/platform/interrupt.h @@ -162,13 +162,4 @@ #define IRQ_MASK_EXT_LEVEL7 (1 << IRQ_NUM_EXT_LEVEL7) #define IRQ_MASK_SOFTWARE9 (1 << IRQ_NUM_SOFTWARE9) -void platform_interrupt_init(void); - -struct irq_desc *platform_irq_get_parent(uint32_t irq); -void platform_interrupt_set(int irq); -void platform_interrupt_clear(uint32_t irq, uint32_t mask); -uint32_t platform_interrupt_get_enabled(void); -void platform_interrupt_mask(uint32_t irq, uint32_t mask); -void platform_interrupt_unmask(uint32_t irq, uint32_t mask); - #endif diff --git a/src/platform/baytrail/Makefile.am b/src/platform/baytrail/Makefile.am index 71b4d0892cef..f07860960479 100644 --- a/src/platform/baytrail/Makefile.am +++ b/src/platform/baytrail/Makefile.am @@ -5,7 +5,6 @@ EXTRA_DIST = baytrail.x.in noinst_LTLIBRARIES = libplatform.la libplatform_la_SOURCES = \ - interrupt.c \ platform.c \ dai.c \ dma.c \ diff --git a/src/platform/baytrail/include/platform/interrupt.h b/src/platform/baytrail/include/platform/interrupt.h index 9a2afa573ea1..5cf9e96c2690 100644 --- a/src/platform/baytrail/include/platform/interrupt.h +++ b/src/platform/baytrail/include/platform/interrupt.h @@ -88,13 +88,4 @@ /* no nested interrupts */ #define PLATFORM_IRQ_CHILDREN 0 -void platform_interrupt_init(void); - -struct irq_desc *platform_irq_get_parent(uint32_t irq); -void platform_interrupt_set(int irq); -void platform_interrupt_clear(uint32_t irq, uint32_t mask); -uint32_t platform_interrupt_get_enabled(void); -void platform_interrupt_mask(uint32_t irq, uint32_t mask); -void platform_interrupt_unmask(uint32_t irq, uint32_t mask); - #endif diff --git a/src/platform/cannonlake/include/platform/interrupt.h b/src/platform/cannonlake/include/platform/interrupt.h index b14cfdfd5237..63ffd0cae789 100644 --- a/src/platform/cannonlake/include/platform/interrupt.h +++ b/src/platform/cannonlake/include/platform/interrupt.h @@ -159,13 +159,4 @@ #define IRQ_MASK_EXT_LEVEL7 (1 << IRQ_NUM_EXT_LEVEL7) #define IRQ_MASK_SOFTWARE9 (1 << IRQ_NUM_SOFTWARE9) -void platform_interrupt_init(void); - -struct irq_desc *platform_irq_get_parent(uint32_t irq); -void platform_interrupt_set(int irq); -void platform_interrupt_clear(uint32_t irq, uint32_t mask); -uint32_t platform_interrupt_get_enabled(void); -void platform_interrupt_mask(uint32_t irq, uint32_t mask); -void platform_interrupt_unmask(uint32_t irq, uint32_t mask); - #endif diff --git a/src/platform/haswell/Makefile.am b/src/platform/haswell/Makefile.am index 71921ae76af2..8e0f221da128 100644 --- a/src/platform/haswell/Makefile.am +++ b/src/platform/haswell/Makefile.am @@ -5,7 +5,6 @@ EXTRA_DIST = haswell.x.in noinst_LTLIBRARIES = libplatform.la libplatform_la_SOURCES = \ - interrupt.c \ platform.c \ dai.c \ dma.c \ diff --git a/src/platform/haswell/include/platform/interrupt.h b/src/platform/haswell/include/platform/interrupt.h index c9f4c0548bb5..f09778653a3f 100644 --- a/src/platform/haswell/include/platform/interrupt.h +++ b/src/platform/haswell/include/platform/interrupt.h @@ -66,13 +66,4 @@ #define IRQ_MASK_EXT_PARITY (1 << IRQ_NUM_EXT_PARITY) #define IRQ_MASK_TIMER3 (1 << IRQ_NUM_TIMER3) -void platform_interrupt_init(void); - -struct irq_desc *platform_irq_get_parent(uint32_t irq); -void platform_interrupt_set(int irq); -void platform_interrupt_clear(uint32_t irq, uint32_t mask); -uint32_t platform_interrupt_get_enabled(void); -void platform_interrupt_mask(uint32_t irq, uint32_t mask); -void platform_interrupt_unmask(uint32_t irq, uint32_t mask); - #endif diff --git a/src/platform/intel/cavs/Makefile.am b/src/platform/intel/cavs/Makefile.am index 503d604237a5..f048e4eae229 100644 --- a/src/platform/intel/cavs/Makefile.am +++ b/src/platform/intel/cavs/Makefile.am @@ -6,7 +6,6 @@ libcavsplatform_la_SOURCES = \ dma.c \ clk.c \ timer.c \ - interrupt.c \ memory.c \ pm_runtime.c From 950fba87598af748c22a1f02a5689ba4706a6dad Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Wed, 22 Aug 2018 15:29:04 +0200 Subject: [PATCH 05/10] drivers: rename platform_interrupt_* function to drivers_interrupt_* Signed-off-by: Janusz Jankowski --- src/arch/xtensa/smp/include/arch/idc.h | 2 +- src/drivers/intel/cavs/dmic.c | 4 ++-- src/drivers/intel/cavs/interrupt.c | 12 ++++++------ src/drivers/intel/cavs/ssp.c | 4 ++-- src/drivers/intel/dw-dma.c | 4 ++-- src/drivers/intel/legacy/baytrail/interrupt.c | 14 +++++++------- src/drivers/intel/legacy/baytrail/ssp.c | 4 ++-- src/drivers/intel/legacy/haswell/interrupt.c | 14 +++++++------- src/drivers/intel/legacy/haswell/ssp.c | 4 ++-- src/include/sof/drivers/interrupt.h | 14 +++++++------- src/init/init.c | 2 +- src/lib/interrupt.c | 12 ++++++------ src/platform/intel/cavs/platform.c | 2 +- 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/arch/xtensa/smp/include/arch/idc.h b/src/arch/xtensa/smp/include/arch/idc.h index 6992c69c6c67..075ae81722f4 100644 --- a/src/arch/xtensa/smp/include/arch/idc.h +++ b/src/arch/xtensa/smp/include/arch/idc.h @@ -64,7 +64,7 @@ static inline void idc_enable_interrupts(int target_core, int source_core) { idc_write(IPC_IDCCTL, target_core, IPC_IDCCTL_IDCTBIE(source_core)); - platform_interrupt_unmask(PLATFORM_IDC_INTERRUPT(target_core), 0); + drivers_interrupt_unmask(PLATFORM_IDC_INTERRUPT(target_core), 0); } /** diff --git a/src/drivers/intel/cavs/dmic.c b/src/drivers/intel/cavs/dmic.c index 47c966d263ef..8064bea6e4ff 100644 --- a/src/drivers/intel/cavs/dmic.c +++ b/src/drivers/intel/cavs/dmic.c @@ -1421,7 +1421,7 @@ static void dmic_irq_handler(void *data) trace_value(val); /* clear IRQ */ - platform_interrupt_clear(dmic_irq(dai), 1); + drivers_interrupt_clear(dmic_irq(dai), 1); } static int dmic_probe(struct dai *dai) @@ -1442,7 +1442,7 @@ static int dmic_probe(struct dai *dai) /* register our IRQ handler */ interrupt_register(dmic_irq(dai), dmic_irq_handler, dai); - platform_interrupt_unmask(dmic_irq(dai), 1); + drivers_interrupt_unmask(dmic_irq(dai), 1); interrupt_enable(dmic_irq(dai)); return 0; diff --git a/src/drivers/intel/cavs/interrupt.c b/src/drivers/intel/cavs/interrupt.c index 2c171db7499f..c33e37cb476c 100644 --- a/src/drivers/intel/cavs/interrupt.c +++ b/src/drivers/intel/cavs/interrupt.c @@ -148,7 +148,7 @@ static struct irq_desc dsp_irq[PLATFORM_CORE_COUNT][4] = { {IRQ_NUM_EXT_LEVEL5, irq_lvl2_level5_handler, } }, }; -struct irq_desc *platform_irq_get_parent(uint32_t irq) +struct irq_desc *drivers_interrupt_irq_get_parent(uint32_t irq) { int core = SOF_IRQ_CPU(irq); @@ -166,12 +166,12 @@ struct irq_desc *platform_irq_get_parent(uint32_t irq) } } -uint32_t platform_interrupt_get_enabled(void) +uint32_t drivers_interrupt_get_enabled(void) { return 0; } -void platform_interrupt_mask(uint32_t irq, uint32_t mask) +void drivers_interrupt_mask(uint32_t irq, uint32_t mask) { int core = SOF_IRQ_CPU(irq); @@ -194,7 +194,7 @@ void platform_interrupt_mask(uint32_t irq, uint32_t mask) } } -void platform_interrupt_unmask(uint32_t irq, uint32_t mask) +void drivers_interrupt_unmask(uint32_t irq, uint32_t mask) { int core = SOF_IRQ_CPU(irq); @@ -217,11 +217,11 @@ void platform_interrupt_unmask(uint32_t irq, uint32_t mask) } } -void platform_interrupt_clear(uint32_t irq, uint32_t mask) +void drivers_interrupt_clear(uint32_t irq, uint32_t mask) { } -void platform_interrupt_init(void) +void drivers_interrupt_init(void) { int i, j; int core = cpu_get_id(); diff --git a/src/drivers/intel/cavs/ssp.c b/src/drivers/intel/cavs/ssp.c index 21065c3a89b7..581ae1ee617b 100644 --- a/src/drivers/intel/cavs/ssp.c +++ b/src/drivers/intel/cavs/ssp.c @@ -726,7 +726,7 @@ static void ssp_irq_handler(void *data) /* clear IRQ */ ssp_write(dai, SSSR, ssp_read(dai, SSSR)); - platform_interrupt_clear(ssp_irq(dai), 1); + drivers_interrupt_clear(ssp_irq(dai), 1); } static int ssp_probe(struct dai *dai) @@ -744,7 +744,7 @@ static int ssp_probe(struct dai *dai) /* register our IRQ handler */ interrupt_register(ssp_irq(dai), ssp_irq_handler, dai); - platform_interrupt_unmask(ssp_irq(dai), 1); + drivers_interrupt_unmask(ssp_irq(dai), 1); interrupt_enable(ssp_irq(dai)); return 0; diff --git a/src/drivers/intel/dw-dma.c b/src/drivers/intel/dw-dma.c index 971c7b7ffb8a..f29f2f43df22 100644 --- a/src/drivers/intel/dw-dma.c +++ b/src/drivers/intel/dw-dma.c @@ -412,7 +412,7 @@ static int dw_dma_start(struct dma *dma, int channel) dw_write(dma, DW_CLEAR_ERR, 0x1 << channel); /* clear platform interrupt */ - platform_interrupt_clear(dma_irq(dma, cpu_get_id()), 1 << channel); + drivers_interrupt_clear(dma_irq(dma, cpu_get_id()), 1 << channel); #if DW_USE_HW_LLI /* TODO: Revisit: are we using LLP mode or single transfer ? */ @@ -1112,7 +1112,7 @@ static void dw_dma_irq_handler(void *data) /* clear platform and DSP interrupt */ pmask = status_block | status_tfr | status_err; - platform_interrupt_clear(dma_irq(dma, cpu_get_id()), pmask); + drivers_interrupt_clear(dma_irq(dma, cpu_get_id()), pmask); /* confirm IRQ cleared */ status_block_new = dw_read(dma, DW_STATUS_BLOCK); diff --git a/src/drivers/intel/legacy/baytrail/interrupt.c b/src/drivers/intel/legacy/baytrail/interrupt.c index 56c185684425..2c869ae4eed1 100644 --- a/src/drivers/intel/legacy/baytrail/interrupt.c +++ b/src/drivers/intel/legacy/baytrail/interrupt.c @@ -34,20 +34,20 @@ #include #include -void platform_interrupt_init(void) {} +void drivers_interrupt_init(void) {} -struct irq_desc *platform_irq_get_parent(uint32_t irq) +struct irq_desc *drivers_interrupt_irq_get_parent(uint32_t irq) { return NULL; } -void platform_interrupt_set(int irq) +void drivers_interrupt_set(int irq) { arch_interrupt_set(irq); } /* clear mask in PISR, bits are W1C in docs but some bits need preserved ?? */ -void platform_interrupt_clear(uint32_t irq, uint32_t mask) +void drivers_interrupt_clear(uint32_t irq, uint32_t mask) { switch (irq) { case IRQ_NUM_EXT_SSP0: @@ -94,12 +94,12 @@ void platform_interrupt_clear(uint32_t irq, uint32_t mask) } /* TODO: expand this to 64 bit - should we just return mask of IRQ numbers */ -uint32_t platform_interrupt_get_enabled(void) +uint32_t drivers_interrupt_get_enabled(void) { return shim_read(SHIM_PIMR); } -void platform_interrupt_mask(uint32_t irq, uint32_t mask) +void drivers_interrupt_mask(uint32_t irq, uint32_t mask) { switch (irq) { case IRQ_NUM_EXT_SSP0: @@ -136,7 +136,7 @@ void platform_interrupt_mask(uint32_t irq, uint32_t mask) } } -void platform_interrupt_unmask(uint32_t irq, uint32_t mask) +void drivers_interrupt_unmask(uint32_t irq, uint32_t mask) { switch (irq) { case IRQ_NUM_EXT_SSP0: diff --git a/src/drivers/intel/legacy/baytrail/ssp.c b/src/drivers/intel/legacy/baytrail/ssp.c index 669c639e13f0..2200abd3b627 100644 --- a/src/drivers/intel/legacy/baytrail/ssp.c +++ b/src/drivers/intel/legacy/baytrail/ssp.c @@ -568,7 +568,7 @@ static void ssp_irq_handler(void *data) /* clear IRQ */ ssp_write(dai, SSSR, ssp_read(dai, SSSR)); - platform_interrupt_clear(ssp_irq(dai), 1); + drivers_interrupt_clear(ssp_irq(dai), 1); } static int ssp_probe(struct dai *dai) @@ -597,7 +597,7 @@ static int ssp_probe(struct dai *dai) /* register our IRQ handler */ interrupt_register(ssp_irq(dai), ssp_irq_handler, dai); #endif - platform_interrupt_unmask(ssp_irq(dai), 1); + drivers_interrupt_unmask(ssp_irq(dai), 1); interrupt_enable(ssp_irq(dai)); return 0; diff --git a/src/drivers/intel/legacy/haswell/interrupt.c b/src/drivers/intel/legacy/haswell/interrupt.c index 70645666fe55..09b6d049670a 100644 --- a/src/drivers/intel/legacy/haswell/interrupt.c +++ b/src/drivers/intel/legacy/haswell/interrupt.c @@ -34,21 +34,21 @@ #include #include -void platform_interrupt_init(void) {} +void drivers_interrupt_init(void) {} /* haswell does not support child IRQs */ -struct irq_desc *platform_irq_get_parent(uint32_t irq) +struct irq_desc *drivers_interrupt_irq_get_parent(uint32_t irq) { return NULL; } -void platform_interrupt_set(int irq) +void drivers_interrupt_set(int irq) { arch_interrupt_set(irq); } /* clear mask in PISR, bits are W1C in docs but some bits need preserved ?? */ -void platform_interrupt_clear(uint32_t irq, uint32_t mask) +void drivers_interrupt_clear(uint32_t irq, uint32_t mask) { switch (irq) { case IRQ_NUM_EXT_DMAC0: @@ -63,12 +63,12 @@ void platform_interrupt_clear(uint32_t irq, uint32_t mask) } /* TODO: expand this to 64 bit - should we just return mask of IRQ numbers */ -uint32_t platform_interrupt_get_enabled(void) +uint32_t drivers_interrupt_get_enabled(void) { return shim_read(SHIM_IMRD); } -void platform_interrupt_mask(uint32_t irq, uint32_t mask) +void drivers_interrupt_mask(uint32_t irq, uint32_t mask) { switch (irq) { case IRQ_NUM_EXT_SSP0: @@ -88,7 +88,7 @@ void platform_interrupt_mask(uint32_t irq, uint32_t mask) } } -void platform_interrupt_unmask(uint32_t irq, uint32_t mask) +void drivers_interrupt_unmask(uint32_t irq, uint32_t mask) { switch (irq) { case IRQ_NUM_EXT_SSP0: diff --git a/src/drivers/intel/legacy/haswell/ssp.c b/src/drivers/intel/legacy/haswell/ssp.c index 479ae27f05bb..a787ba017c30 100644 --- a/src/drivers/intel/legacy/haswell/ssp.c +++ b/src/drivers/intel/legacy/haswell/ssp.c @@ -492,7 +492,7 @@ static void ssp_irq_handler(void *data) /* clear IRQ */ ssp_write(dai, SSSR, ssp_read(dai, SSSR)); - platform_interrupt_clear(ssp_irq(dai), 1); + drivers_interrupt_clear(ssp_irq(dai), 1); } static int ssp_probe(struct dai *dai) @@ -512,7 +512,7 @@ static int ssp_probe(struct dai *dai) /* register our IRQ handler */ interrupt_register(ssp_irq(dai), ssp_irq_handler, dai); - platform_interrupt_unmask(ssp_irq(dai), 1); + drivers_interrupt_unmask(ssp_irq(dai), 1); interrupt_enable(ssp_irq(dai)); return 0; diff --git a/src/include/sof/drivers/interrupt.h b/src/include/sof/drivers/interrupt.h index 615c6179927d..c8c9185ac309 100644 --- a/src/include/sof/drivers/interrupt.h +++ b/src/include/sof/drivers/interrupt.h @@ -33,13 +33,13 @@ #include -void platform_interrupt_init(void); +void drivers_interrupt_init(void); -struct irq_desc *platform_irq_get_parent(uint32_t irq); -void platform_interrupt_set(int irq); -void platform_interrupt_clear(uint32_t irq, uint32_t mask); -uint32_t platform_interrupt_get_enabled(void); -void platform_interrupt_mask(uint32_t irq, uint32_t mask); -void platform_interrupt_unmask(uint32_t irq, uint32_t mask); +struct irq_desc *drivers_interrupt_irq_get_parent(uint32_t irq); +void drivers_interrupt_set(int irq); +void drivers_interrupt_clear(uint32_t irq, uint32_t mask); +uint32_t drivers_interrupt_get_enabled(void); +void drivers_interrupt_mask(uint32_t irq, uint32_t mask); +void drivers_interrupt_unmask(uint32_t irq, uint32_t mask); #endif diff --git a/src/init/init.c b/src/init/init.c index a1501c53383b..28d99fd5079d 100644 --- a/src/init/init.c +++ b/src/init/init.c @@ -101,7 +101,7 @@ int slave_core_init(struct sof *sof) trace_point(TRACE_BOOT_SYS_SCHED); scheduler_init(sof); - platform_interrupt_init(); + drivers_interrupt_init(); trace_point(TRACE_BOOT_SYS_WORK); init_system_workq(&platform_generic_queue[cpu_get_id()]); diff --git a/src/lib/interrupt.c b/src/lib/interrupt.c index e059c6c2bfc6..9e6190e3f6ce 100644 --- a/src/lib/interrupt.c +++ b/src/lib/interrupt.c @@ -135,7 +135,7 @@ static uint32_t irq_enable_child(struct irq_desc *parent, int irq) parent->enabled_count++; /* enable the child interrupt */ - platform_interrupt_unmask(irq, 0); + drivers_interrupt_unmask(irq, 0); } } @@ -163,7 +163,7 @@ static uint32_t irq_disable_child(struct irq_desc *parent, int irq) if (parent->enabled_count == 0) { /* disable the child interrupt */ - platform_interrupt_mask(irq, 0); + drivers_interrupt_mask(irq, 0); arch_interrupt_disable_mask(1 << SOF_IRQ_NUMBER(irq)); } @@ -177,7 +177,7 @@ int interrupt_register(uint32_t irq, struct irq_desc *parent; /* no parent means we are registering DSP internal IRQ */ - parent = platform_irq_get_parent(irq); + parent = drivers_interrupt_irq_get_parent(irq); if (parent == NULL) return arch_interrupt_register(irq, handler, arg); else @@ -189,7 +189,7 @@ void interrupt_unregister(uint32_t irq) struct irq_desc *parent; /* no parent means we are unregistering DSP internal IRQ */ - parent = platform_irq_get_parent(irq); + parent = drivers_interrupt_irq_get_parent(irq); if (parent == NULL) arch_interrupt_unregister(irq); else @@ -201,7 +201,7 @@ uint32_t interrupt_enable(uint32_t irq) struct irq_desc *parent; /* no parent means we are enabling DSP internal IRQ */ - parent = platform_irq_get_parent(irq); + parent = drivers_interrupt_irq_get_parent(irq); if (parent == NULL) return arch_interrupt_enable_mask(1 << irq); else @@ -213,7 +213,7 @@ uint32_t interrupt_disable(uint32_t irq) struct irq_desc *parent; /* no parent means we are disabling DSP internal IRQ */ - parent = platform_irq_get_parent(irq); + parent = drivers_interrupt_irq_get_parent(irq); if (parent == NULL) return arch_interrupt_disable_mask(1 << irq); else diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index eab1680cffba..8c2a75110571 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -281,7 +281,7 @@ int platform_init(struct sof *sof) platform_init_hw(); #endif - platform_interrupt_init(); + drivers_interrupt_init(); trace_point(TRACE_BOOT_PLATFORM_MBOX); platform_memory_windows_init(); From 9aaf4ce358768e7adda5b468644ca9ac05656f38 Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Wed, 22 Aug 2018 15:50:57 +0200 Subject: [PATCH 06/10] drivers: refactor: move clk from platform to drivers Signed-off-by: Janusz Jankowski --- src/drivers/intel/cavs/Makefile.am | 1 + src/{platform => drivers}/intel/cavs/clk.c | 1 + src/drivers/intel/legacy/baytrail/Makefile.am | 1 + .../intel/legacy}/baytrail/clk.c | 1 + src/drivers/intel/legacy/haswell/Makefile.am | 1 + .../intel/legacy}/haswell/clk.c | 5 +-- src/include/sof/drivers/Makefile.am | 1 + src/include/sof/drivers/clk.h | 36 +++++++++++++++++++ src/library/include/platform/clk.h | 2 -- .../apollolake/include/platform/clk.h | 2 -- src/platform/baytrail/Makefile.am | 1 - src/platform/baytrail/include/platform/clk.h | 2 -- src/platform/baytrail/platform.c | 1 + .../cannonlake/include/platform/clk.h | 2 -- src/platform/haswell/Makefile.am | 1 - src/platform/haswell/include/platform/clk.h | 2 -- src/platform/haswell/platform.c | 1 + src/platform/intel/cavs/Makefile.am | 1 - src/platform/intel/cavs/platform.c | 1 + 19 files changed, 48 insertions(+), 15 deletions(-) rename src/{platform => drivers}/intel/cavs/clk.c (99%) rename src/{platform => drivers/intel/legacy}/baytrail/clk.c (99%) rename src/{platform => drivers/intel/legacy}/haswell/clk.c (98%) create mode 100644 src/include/sof/drivers/clk.h diff --git a/src/drivers/intel/cavs/Makefile.am b/src/drivers/intel/cavs/Makefile.am index 98b113108835..60d9526428f5 100644 --- a/src/drivers/intel/cavs/Makefile.am +++ b/src/drivers/intel/cavs/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ + clk.c \ dmic.c \ hda-dma.c \ interrupt.c \ diff --git a/src/platform/intel/cavs/clk.c b/src/drivers/intel/cavs/clk.c similarity index 99% rename from src/platform/intel/cavs/clk.c rename to src/drivers/intel/cavs/clk.c index 25abeaad6452..42b5b8f42c90 100644 --- a/src/platform/intel/cavs/clk.c +++ b/src/drivers/intel/cavs/clk.c @@ -31,6 +31,7 @@ * Janusz Jankowski */ +#include #include #include #include diff --git a/src/drivers/intel/legacy/baytrail/Makefile.am b/src/drivers/intel/legacy/baytrail/Makefile.am index fe6c4c8cb972..765b075612c6 100644 --- a/src/drivers/intel/legacy/baytrail/Makefile.am +++ b/src/drivers/intel/legacy/baytrail/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ + clk.c \ interrupt.c \ ssp.c diff --git a/src/platform/baytrail/clk.c b/src/drivers/intel/legacy/baytrail/clk.c similarity index 99% rename from src/platform/baytrail/clk.c rename to src/drivers/intel/legacy/baytrail/clk.c index 170aea831681..9b9a537538ca 100644 --- a/src/platform/baytrail/clk.c +++ b/src/drivers/intel/legacy/baytrail/clk.c @@ -29,6 +29,7 @@ * Keyon Jie */ +#include #include #include #include diff --git a/src/drivers/intel/legacy/haswell/Makefile.am b/src/drivers/intel/legacy/haswell/Makefile.am index fe6c4c8cb972..765b075612c6 100644 --- a/src/drivers/intel/legacy/haswell/Makefile.am +++ b/src/drivers/intel/legacy/haswell/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ + clk.c \ interrupt.c \ ssp.c diff --git a/src/platform/haswell/clk.c b/src/drivers/intel/legacy/haswell/clk.c similarity index 98% rename from src/platform/haswell/clk.c rename to src/drivers/intel/legacy/haswell/clk.c index d784347fbf13..4c54c2e842cf 100644 --- a/src/platform/haswell/clk.c +++ b/src/drivers/intel/legacy/haswell/clk.c @@ -28,6 +28,7 @@ * Author: Liam Girdwood */ +#include #include #include #include @@ -142,8 +143,8 @@ uint32_t clock_set_freq(int clock, uint32_t hz) /* set CPU frequency request for CCU */ io_reg_update_bits(SHIM_BASE + SHIM_CSR, - SHIM_CSR_DCS_MASK, - SHIM_CSR_DCS(cpu_freq[idx].enc)); + SHIM_CSR_DCS_MASK, + SHIM_CSR_DCS(cpu_freq[idx].enc)); /* tell anyone interested we have now changed CPU freq */ notifier_event(NOTIFIER_ID_CPU_FREQ, CLOCK_NOTIFY_POST, diff --git a/src/include/sof/drivers/Makefile.am b/src/include/sof/drivers/Makefile.am index 53ecb792d073..e0a684f1d8ed 100644 --- a/src/include/sof/drivers/Makefile.am +++ b/src/include/sof/drivers/Makefile.am @@ -1,2 +1,3 @@ noinst_HEADERS = \ + clk.h \ interrupt.h diff --git a/src/include/sof/drivers/clk.h b/src/include/sof/drivers/clk.h new file mode 100644 index 000000000000..38eaa9c5d1d2 --- /dev/null +++ b/src/include/sof/drivers/clk.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Janusz Jankowski + */ + +#ifndef __INCLUDE_DRIVERS_CLK__ +#define __INCLUDE_DRIVERS_CLK__ + +void init_platform_clocks(void); + +#endif diff --git a/src/library/include/platform/clk.h b/src/library/include/platform/clk.h index 0dd11e6b68b3..97bd8351a2f1 100644 --- a/src/library/include/platform/clk.h +++ b/src/library/include/platform/clk.h @@ -37,6 +37,4 @@ #define CLK_DEFAULT_CPU_HZ 50000000 #define CLK_MAX_CPU_HZ 343000000 -void init_platform_clocks(void); - #endif diff --git a/src/platform/apollolake/include/platform/clk.h b/src/platform/apollolake/include/platform/clk.h index 5a15b8a4a6a0..6ca9ed37e685 100644 --- a/src/platform/apollolake/include/platform/clk.h +++ b/src/platform/apollolake/include/platform/clk.h @@ -38,6 +38,4 @@ #define CLK_DEFAULT_CPU_HZ 400000000 #define CLK_MAX_CPU_HZ 400000000 -void init_platform_clocks(void); - #endif diff --git a/src/platform/baytrail/Makefile.am b/src/platform/baytrail/Makefile.am index f07860960479..ac6c07783d05 100644 --- a/src/platform/baytrail/Makefile.am +++ b/src/platform/baytrail/Makefile.am @@ -8,7 +8,6 @@ libplatform_la_SOURCES = \ platform.c \ dai.c \ dma.c \ - clk.c \ timer.c \ memory.c diff --git a/src/platform/baytrail/include/platform/clk.h b/src/platform/baytrail/include/platform/clk.h index 7292b00348f7..ce424a487420 100644 --- a/src/platform/baytrail/include/platform/clk.h +++ b/src/platform/baytrail/include/platform/clk.h @@ -37,6 +37,4 @@ #define CLK_DEFAULT_CPU_HZ 50000000 #define CLK_MAX_CPU_HZ 343000000 -void init_platform_clocks(void); - #endif diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 01b3e6ef6c9f..0cf1ee3a701a 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/src/platform/cannonlake/include/platform/clk.h b/src/platform/cannonlake/include/platform/clk.h index d6ccd6c5698b..8b5ee82f883e 100644 --- a/src/platform/cannonlake/include/platform/clk.h +++ b/src/platform/cannonlake/include/platform/clk.h @@ -39,6 +39,4 @@ #define CLK_DEFAULT_CPU_HZ 120000000 #define CLK_MAX_CPU_HZ 400000000 -void init_platform_clocks(void); - #endif diff --git a/src/platform/haswell/Makefile.am b/src/platform/haswell/Makefile.am index 8e0f221da128..2c36856a46ef 100644 --- a/src/platform/haswell/Makefile.am +++ b/src/platform/haswell/Makefile.am @@ -8,7 +8,6 @@ libplatform_la_SOURCES = \ platform.c \ dai.c \ dma.c \ - clk.c \ timer.c \ memory.c diff --git a/src/platform/haswell/include/platform/clk.h b/src/platform/haswell/include/platform/clk.h index 010396df45a2..ceb692312126 100644 --- a/src/platform/haswell/include/platform/clk.h +++ b/src/platform/haswell/include/platform/clk.h @@ -37,6 +37,4 @@ #define CLK_DEFAULT_CPU_HZ 320000000 #define CLK_MAX_CPU_HZ 320000000 -void init_platform_clocks(void); - #endif diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c index 24b56520d512..58cb89fe453d 100644 --- a/src/platform/haswell/platform.c +++ b/src/platform/haswell/platform.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/src/platform/intel/cavs/Makefile.am b/src/platform/intel/cavs/Makefile.am index f048e4eae229..ab6c8253fbf2 100644 --- a/src/platform/intel/cavs/Makefile.am +++ b/src/platform/intel/cavs/Makefile.am @@ -4,7 +4,6 @@ libcavsplatform_la_SOURCES = \ platform.c \ dai.c \ dma.c \ - clk.c \ timer.c \ memory.c \ pm_runtime.c diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index 8c2a75110571..73fbae8d5a8d 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include From 1d447e29e8a6c807afffda838420c2ff13ecb7ac Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Wed, 22 Aug 2018 15:53:57 +0200 Subject: [PATCH 07/10] drivers: refactor: rename init_platform_clocks Signed-off-by: Janusz Jankowski --- src/drivers/intel/cavs/clk.c | 2 +- src/drivers/intel/legacy/baytrail/clk.c | 2 +- src/drivers/intel/legacy/haswell/clk.c | 2 +- src/include/sof/drivers/clk.h | 2 +- src/platform/baytrail/platform.c | 2 +- src/platform/haswell/platform.c | 2 +- src/platform/intel/cavs/platform.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/drivers/intel/cavs/clk.c b/src/drivers/intel/cavs/clk.c index 42b5b8f42c90..7ba73b2bfc0f 100644 --- a/src/drivers/intel/cavs/clk.c +++ b/src/drivers/intel/cavs/clk.c @@ -220,7 +220,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current) clk_pdata->clk[clock].ticks_per_usec; } -void init_platform_clocks(void) +void drivers_clock_init(void) { clk_pdata = rmalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*clk_pdata)); diff --git a/src/drivers/intel/legacy/baytrail/clk.c b/src/drivers/intel/legacy/baytrail/clk.c index 9b9a537538ca..4380d2d91edf 100644 --- a/src/drivers/intel/legacy/baytrail/clk.c +++ b/src/drivers/intel/legacy/baytrail/clk.c @@ -260,7 +260,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current) clk_pdata->clk[clock].ticks_per_usec; } -void init_platform_clocks(void) +void drivers_clock_init(void) { clk_pdata = rmalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*clk_pdata)); diff --git a/src/drivers/intel/legacy/haswell/clk.c b/src/drivers/intel/legacy/haswell/clk.c index 4c54c2e842cf..83f9e902dae2 100644 --- a/src/drivers/intel/legacy/haswell/clk.c +++ b/src/drivers/intel/legacy/haswell/clk.c @@ -194,7 +194,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current) clk_pdata->clk[clock].ticks_per_usec; } -void init_platform_clocks(void) +void drivers_clock_init(void) { clk_pdata = rzalloc(RZONE_SYS, SOF_MEM_CAPS_RAM, sizeof(*clk_pdata)); diff --git a/src/include/sof/drivers/clk.h b/src/include/sof/drivers/clk.h index 38eaa9c5d1d2..83a5cbb8b4bf 100644 --- a/src/include/sof/drivers/clk.h +++ b/src/include/sof/drivers/clk.h @@ -31,6 +31,6 @@ #ifndef __INCLUDE_DRIVERS_CLK__ #define __INCLUDE_DRIVERS_CLK__ -void init_platform_clocks(void); +void drivers_clock_init(void); #endif diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 0cf1ee3a701a..7669744a8d05 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -203,7 +203,7 @@ int platform_init(struct sof *sof) platform_ipc_pmc_init(); trace_point(TRACE_BOOT_PLATFORM_CLOCK); - init_platform_clocks(); + drivers_clock_init(); /* init work queues and clocks */ trace_point(TRACE_BOOT_SYS_WORK); diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c index 58cb89fe453d..38813ac006cd 100644 --- a/src/platform/haswell/platform.c +++ b/src/platform/haswell/platform.c @@ -192,7 +192,7 @@ int platform_init(struct sof *sof) platform_init_shim(); trace_point(TRACE_BOOT_PLATFORM_CLOCK); - init_platform_clocks(); + drivers_clock_init(); /* init work queues and clocks */ trace_point(TRACE_BOOT_SYS_WORK); diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index 73fbae8d5a8d..c807d1c89516 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -294,7 +294,7 @@ int platform_init(struct sof *sof) platform_timer_start(platform_timer); trace_point(TRACE_BOOT_PLATFORM_CLOCK); - init_platform_clocks(); + drivers_clock_init(); trace_point(TRACE_BOOT_SYS_WORK); init_system_workq(&platform_generic_queue[PLATFORM_MASTER_CORE_ID]); From 7769abcd265fde767493acee21b4c1d751a840ce Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Thu, 23 Aug 2018 10:22:51 +0200 Subject: [PATCH 08/10] platform: refactor: unify */platform/timer.h functions and variables For cnl&apl removed platform_timer_register from public api and made it static. For byt&hsw moved platform_timer to platform.h (just like it is for cnl&apl). Signed-off-by: Janusz Jankowski --- src/platform/apollolake/include/platform/timer.h | 2 -- src/platform/baytrail/include/platform/platform.h | 3 +++ src/platform/baytrail/include/platform/timer.h | 2 -- src/platform/cannonlake/include/platform/timer.h | 2 -- src/platform/haswell/include/platform/platform.h | 3 +++ src/platform/haswell/include/platform/timer.h | 2 -- src/platform/intel/cavs/timer.c | 4 ++-- 7 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/platform/apollolake/include/platform/timer.h b/src/platform/apollolake/include/platform/timer.h index e4977e4d4279..347ddc5d8eb4 100644 --- a/src/platform/apollolake/include/platform/timer.h +++ b/src/platform/apollolake/include/platform/timer.h @@ -53,8 +53,6 @@ void platform_timer_clear(struct timer *timer); uint64_t platform_timer_get(struct timer *timer); void platform_timer_start(struct timer *timer); void platform_timer_stop(struct timer *timer); -int platform_timer_register(struct timer *timer, - void (*handler)(void *arg), void *arg); /* get timestamp for host stream DMA position */ void platform_host_timestamp(struct comp_dev *host, diff --git a/src/platform/baytrail/include/platform/platform.h b/src/platform/baytrail/include/platform/platform.h index c859cd5f3eca..7b028794bfe3 100644 --- a/src/platform/baytrail/include/platform/platform.h +++ b/src/platform/baytrail/include/platform/platform.h @@ -112,4 +112,7 @@ static inline void platform_panic(uint32_t p) /* Platform defined trace code */ #define platform_trace_point(__x) \ shim_write(SHIM_IPCXL, (__x & 0x3fffffff)) + +extern struct timer *platform_timer; + #endif diff --git a/src/platform/baytrail/include/platform/timer.h b/src/platform/baytrail/include/platform/timer.h index 2801bb5b5c80..38c04609303d 100644 --- a/src/platform/baytrail/include/platform/timer.h +++ b/src/platform/baytrail/include/platform/timer.h @@ -47,8 +47,6 @@ struct comp_dev; struct sof_ipc_stream_posn; -extern struct timer *platform_timer; - int platform_timer_set(struct timer *timer, uint64_t ticks); void platform_timer_clear(struct timer *timer); uint64_t platform_timer_get(struct timer *timer); diff --git a/src/platform/cannonlake/include/platform/timer.h b/src/platform/cannonlake/include/platform/timer.h index 02b7c6e0d8b5..25043b9fdb3a 100644 --- a/src/platform/cannonlake/include/platform/timer.h +++ b/src/platform/cannonlake/include/platform/timer.h @@ -54,8 +54,6 @@ void platform_timer_clear(struct timer *timer); uint64_t platform_timer_get(struct timer *timer); void platform_timer_start(struct timer *timer); void platform_timer_stop(struct timer *timer); -int platform_timer_register(struct timer *timer, - void (*handler)(void *arg), void *arg); /* get timestamp for host stream DMA position */ void platform_host_timestamp(struct comp_dev *host, diff --git a/src/platform/haswell/include/platform/platform.h b/src/platform/haswell/include/platform/platform.h index da5fdcf9b797..d7f771f4dba7 100644 --- a/src/platform/haswell/include/platform/platform.h +++ b/src/platform/haswell/include/platform/platform.h @@ -111,4 +111,7 @@ static inline void platform_panic(uint32_t p) /* Platform defined trace code */ #define platform_trace_point(__x) \ shim_write(SHIM_IPCX, ((__x) & 0x3fffffff)) + +extern struct timer *platform_timer; + #endif diff --git a/src/platform/haswell/include/platform/timer.h b/src/platform/haswell/include/platform/timer.h index c51e0e6d5f56..91627cb1061b 100644 --- a/src/platform/haswell/include/platform/timer.h +++ b/src/platform/haswell/include/platform/timer.h @@ -46,8 +46,6 @@ struct comp_dev; struct sof_ipc_stream_posn; -extern struct timer *platform_timer; - int platform_timer_set(struct timer *timer, uint64_t ticks); void platform_timer_clear(struct timer *timer); uint64_t platform_timer_get(struct timer *timer); diff --git a/src/platform/intel/cavs/timer.c b/src/platform/intel/cavs/timer.c index de745c4f72b7..f6e721508dab 100644 --- a/src/platform/intel/cavs/timer.c +++ b/src/platform/intel/cavs/timer.c @@ -114,8 +114,8 @@ void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) *wallclock = shim_read64(SHIM_DSPWC); } -int platform_timer_register(struct timer *timer, - void (*handler)(void *arg), void *arg) +static int platform_timer_register(struct timer *timer, + void (*handler)(void *arg), void *arg) { return interrupt_register(timer->irq, handler, arg); } From 67d2f57be4243dbe63bbe8079ceff633127d8f05 Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Thu, 23 Aug 2018 10:50:51 +0200 Subject: [PATCH 09/10] drivers: refactor: move timer from platform to drivers + Indents for 'CHECK: Alignment should match open parenthesis' Signed-off-by: Janusz Jankowski --- src/drivers/intel/cavs/Makefile.am | 3 +- src/{platform => drivers}/intel/cavs/timer.c | 13 +++-- src/drivers/intel/legacy/baytrail/Makefile.am | 3 +- .../intel/legacy}/baytrail/timer.c | 22 ++++---- src/drivers/intel/legacy/haswell/Makefile.am | 3 +- .../intel/legacy}/haswell/timer.c | 5 +- src/include/sof/drivers/Makefile.am | 3 +- src/include/sof/drivers/timer.h | 56 +++++++++++++++++++ src/include/sof/wait.h | 1 + .../apollolake/include/platform/timer.h | 19 ------- src/platform/baytrail/Makefile.am | 1 - .../baytrail/include/platform/timer.h | 20 ------- .../cannonlake/include/platform/timer.h | 19 ------- src/platform/haswell/Makefile.am | 1 - src/platform/haswell/include/platform/timer.h | 20 ------- src/platform/intel/cavs/Makefile.am | 1 - 16 files changed, 87 insertions(+), 103 deletions(-) rename src/{platform => drivers}/intel/cavs/timer.c (92%) rename src/{platform => drivers/intel/legacy}/baytrail/timer.c (93%) rename src/{platform => drivers/intel/legacy}/haswell/timer.c (96%) create mode 100644 src/include/sof/drivers/timer.h diff --git a/src/drivers/intel/cavs/Makefile.am b/src/drivers/intel/cavs/Makefile.am index 60d9526428f5..2ef317940868 100644 --- a/src/drivers/intel/cavs/Makefile.am +++ b/src/drivers/intel/cavs/Makefile.am @@ -5,7 +5,8 @@ libdrivers_la_SOURCES = \ dmic.c \ hda-dma.c \ interrupt.c \ - ssp.c + ssp.c \ + timer.c libdrivers_la_CFLAGS = \ $(ARCH_CFLAGS) \ diff --git a/src/platform/intel/cavs/timer.c b/src/drivers/intel/cavs/timer.c similarity index 92% rename from src/platform/intel/cavs/timer.c rename to src/drivers/intel/cavs/timer.c index f6e721508dab..89ab4f669443 100644 --- a/src/platform/intel/cavs/timer.c +++ b/src/drivers/intel/cavs/timer.c @@ -35,6 +35,7 @@ #include #include #include +#include #include void platform_timer_start(struct timer *timer) @@ -42,7 +43,7 @@ void platform_timer_start(struct timer *timer) /* run timer */ shim_write64(SHIM_DSPWCT0C, 0); shim_write(SHIM_DSPWCTCS, - shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0A); + shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0A); } void platform_timer_stop(struct timer *timer) @@ -50,7 +51,7 @@ void platform_timer_stop(struct timer *timer) /* stop timer */ shim_write64(SHIM_DSPWCT0C, 0); shim_write(SHIM_DSPWCTCS, - shim_read(SHIM_DSPWCTCS) & ~SHIM_DSPWCTCS_T0A); + shim_read(SHIM_DSPWCTCS) & ~SHIM_DSPWCTCS_T0A); } int platform_timer_set(struct timer *timer, uint64_t ticks) @@ -62,7 +63,7 @@ int platform_timer_set(struct timer *timer, uint64_t ticks) /* set new value and run */ shim_write64(SHIM_DSPWCT0C, ticks); shim_write(SHIM_DSPWCTCS, - shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0A); + shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0A); return 0; } @@ -71,7 +72,7 @@ void platform_timer_clear(struct timer *timer) { /* write 1 to clear the timer interrupt */ shim_write(SHIM_DSPWCTCS, - shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0T); + shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0T); } uint64_t platform_timer_get(struct timer *timer) @@ -82,7 +83,7 @@ uint64_t platform_timer_get(struct timer *timer) /* get timestamp for host stream DMA position */ void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn) + struct sof_ipc_stream_posn *posn) { int err; @@ -94,7 +95,7 @@ void platform_host_timestamp(struct comp_dev *host, /* get timestamp for DAI stream DMA position */ void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn) + struct sof_ipc_stream_posn *posn) { int err; diff --git a/src/drivers/intel/legacy/baytrail/Makefile.am b/src/drivers/intel/legacy/baytrail/Makefile.am index 765b075612c6..5ffd56af8427 100644 --- a/src/drivers/intel/legacy/baytrail/Makefile.am +++ b/src/drivers/intel/legacy/baytrail/Makefile.am @@ -3,7 +3,8 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ clk.c \ interrupt.c \ - ssp.c + ssp.c \ + timer.c libdrivers_la_CFLAGS = \ $(ARCH_CFLAGS) \ diff --git a/src/platform/baytrail/timer.c b/src/drivers/intel/legacy/baytrail/timer.c similarity index 93% rename from src/platform/baytrail/timer.c rename to src/drivers/intel/legacy/baytrail/timer.c index 835b2eee3b80..d001eb1dd3d7 100644 --- a/src/platform/baytrail/timer.c +++ b/src/drivers/intel/legacy/baytrail/timer.c @@ -35,6 +35,7 @@ #include #include #include +#include #include struct timer_data { @@ -112,13 +113,13 @@ int platform_timer_set(struct timer *timer, uint64_t ticks) /* cant be in the past */ arch_interrupt_global_enable(flags); return -EINVAL; - } else { - /* set for checking at next timeout */ - time = ticks; - timer->hitimeout = hitimeout; - timer->lowtimeout = ticks; } + /* set for checking at next timeout */ + time = ticks; + timer->hitimeout = hitimeout; + timer->lowtimeout = ticks; + /* set new value and run */ shim_write(SHIM_EXT_TIMER_CNTLH, SHIM_EXT_TIMER_RUN); shim_write(SHIM_EXT_TIMER_CNTLL, time); @@ -148,7 +149,7 @@ uint64_t platform_timer_get(struct timer *timer) /* check and see whether 32bit IRQ is pending for timer */ if (arch_interrupt_get_status() & IRQ_MASK_EXT_TIMER && - shim_read(SHIM_EXT_TIMER_CNTLL) == 1) { + shim_read(SHIM_EXT_TIMER_CNTLL) == 1) { /* yes, overflow has occurred but handler has not run */ high = timer->hitime + 1; } else { @@ -165,7 +166,7 @@ uint64_t platform_timer_get(struct timer *timer) /* get timestamp for host stream DMA position */ void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn) + struct sof_ipc_stream_posn *posn) { int err; @@ -177,7 +178,7 @@ void platform_host_timestamp(struct comp_dev *host, /* get timestamp for DAI stream DMA position */ void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn) + struct sof_ipc_stream_posn *posn) { int err; @@ -199,7 +200,7 @@ void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) } static int platform_timer_register(struct timer *timer, - void(*handler)(void *arg), void *arg) + void (*handler)(void *arg), void *arg) { struct timer_data *tdata = &xtimer[0]; uint32_t flags; @@ -211,7 +212,8 @@ static int platform_timer_register(struct timer *timer, timer->timer_data = tdata; timer->hitime = 0; timer->hitimeout = 0; - ret = arch_interrupt_register(timer->id, platform_timer_64_handler, timer); + ret = arch_interrupt_register(timer->id, + platform_timer_64_handler, timer); arch_interrupt_global_enable(flags); return ret; diff --git a/src/drivers/intel/legacy/haswell/Makefile.am b/src/drivers/intel/legacy/haswell/Makefile.am index 765b075612c6..5ffd56af8427 100644 --- a/src/drivers/intel/legacy/haswell/Makefile.am +++ b/src/drivers/intel/legacy/haswell/Makefile.am @@ -3,7 +3,8 @@ noinst_LTLIBRARIES = libdrivers.la libdrivers_la_SOURCES = \ clk.c \ interrupt.c \ - ssp.c + ssp.c \ + timer.c libdrivers_la_CFLAGS = \ $(ARCH_CFLAGS) \ diff --git a/src/platform/haswell/timer.c b/src/drivers/intel/legacy/haswell/timer.c similarity index 96% rename from src/platform/haswell/timer.c rename to src/drivers/intel/legacy/haswell/timer.c index ebdbd0796cd2..ed365e2d6e70 100644 --- a/src/platform/haswell/timer.c +++ b/src/drivers/intel/legacy/haswell/timer.c @@ -33,6 +33,7 @@ #include #include #include +#include #include void platform_timer_start(struct timer *timer) @@ -62,7 +63,7 @@ uint64_t platform_timer_get(struct timer *timer) /* get timestamp for host stream DMA position */ void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn) + struct sof_ipc_stream_posn *posn) { int err; @@ -74,7 +75,7 @@ void platform_host_timestamp(struct comp_dev *host, /* get timestamp for DAI stream DMA position */ void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn) + struct sof_ipc_stream_posn *posn) { int err; diff --git a/src/include/sof/drivers/Makefile.am b/src/include/sof/drivers/Makefile.am index e0a684f1d8ed..fbb4611acb67 100644 --- a/src/include/sof/drivers/Makefile.am +++ b/src/include/sof/drivers/Makefile.am @@ -1,3 +1,4 @@ noinst_HEADERS = \ clk.h \ - interrupt.h + interrupt.h \ + timer.h diff --git a/src/include/sof/drivers/timer.h b/src/include/sof/drivers/timer.h new file mode 100644 index 000000000000..20c55e654f09 --- /dev/null +++ b/src/include/sof/drivers/timer.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Janusz Jankowski + */ + +#ifndef __INCLUDE_DRIVERS_TIMER__ +#define __INCLUDE_DRIVERS_TIMER__ + +#include + +struct comp_dev; +struct sof_ipc_stream_posn; + +int platform_timer_set(struct timer *timer, uint64_t ticks); +void platform_timer_clear(struct timer *timer); +uint64_t platform_timer_get(struct timer *timer); +void platform_timer_start(struct timer *timer); +void platform_timer_stop(struct timer *timer); + +/* get timestamp for host stream DMA position */ +void platform_host_timestamp(struct comp_dev *host, + struct sof_ipc_stream_posn *posn); + +/* get timestamp for DAI stream DMA position */ +void platform_dai_timestamp(struct comp_dev *dai, + struct sof_ipc_stream_posn *posn); + +/* get current wallclock for componnent */ +void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock); + +#endif diff --git a/src/include/sof/wait.h b/src/include/sof/wait.h index feb8b29b3149..9016da8aa730 100644 --- a/src/include/sof/wait.h +++ b/src/include/sof/wait.h @@ -43,6 +43,7 @@ #include #include #include +#include #if DEBUG_LOCKS #define wait_atomic_check \ diff --git a/src/platform/apollolake/include/platform/timer.h b/src/platform/apollolake/include/platform/timer.h index 347ddc5d8eb4..9f1a0fa7b4b2 100644 --- a/src/platform/apollolake/include/platform/timer.h +++ b/src/platform/apollolake/include/platform/timer.h @@ -45,23 +45,4 @@ #define TIMER3 IRQ_EXT_TSTAMP0_LVL2(0) #define TIMER4 IRQ_EXT_TSTAMP1_LVL2(0) -struct comp_dev; -struct sof_ipc_stream_posn; - -int platform_timer_set(struct timer *timer, uint64_t ticks); -void platform_timer_clear(struct timer *timer); -uint64_t platform_timer_get(struct timer *timer); -void platform_timer_start(struct timer *timer); -void platform_timer_stop(struct timer *timer); - -/* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn); - -/* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn); - -/* get current wallclock for componnent */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock); #endif diff --git a/src/platform/baytrail/Makefile.am b/src/platform/baytrail/Makefile.am index ac6c07783d05..dddfbfd7842e 100644 --- a/src/platform/baytrail/Makefile.am +++ b/src/platform/baytrail/Makefile.am @@ -8,7 +8,6 @@ libplatform_la_SOURCES = \ platform.c \ dai.c \ dma.c \ - timer.c \ memory.c libplatform_la_CFLAGS = \ diff --git a/src/platform/baytrail/include/platform/timer.h b/src/platform/baytrail/include/platform/timer.h index 38c04609303d..a11620ac43cd 100644 --- a/src/platform/baytrail/include/platform/timer.h +++ b/src/platform/baytrail/include/platform/timer.h @@ -44,24 +44,4 @@ #define TIMER2 IRQ_NUM_TIMER3 #define TIMER3 IRQ_NUM_EXT_TIMER -struct comp_dev; -struct sof_ipc_stream_posn; - -int platform_timer_set(struct timer *timer, uint64_t ticks); -void platform_timer_clear(struct timer *timer); -uint64_t platform_timer_get(struct timer *timer); -void platform_timer_start(struct timer *timer); -void platform_timer_stop(struct timer *timer); - -/* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn); - -/* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn); - -/* get current wallclock for componnent */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock); - #endif diff --git a/src/platform/cannonlake/include/platform/timer.h b/src/platform/cannonlake/include/platform/timer.h index 25043b9fdb3a..7586c4f52ab1 100644 --- a/src/platform/cannonlake/include/platform/timer.h +++ b/src/platform/cannonlake/include/platform/timer.h @@ -46,23 +46,4 @@ #define TIMER3 IRQ_EXT_TSTAMP0_LVL2(0) #define TIMER4 IRQ_EXT_TSTAMP1_LVL2(0) -struct comp_dev; -struct sof_ipc_stream_posn; - -int platform_timer_set(struct timer *timer, uint64_t ticks); -void platform_timer_clear(struct timer *timer); -uint64_t platform_timer_get(struct timer *timer); -void platform_timer_start(struct timer *timer); -void platform_timer_stop(struct timer *timer); - -/* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn); - -/* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn); - -/* get current wallclock for componnent */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock); #endif diff --git a/src/platform/haswell/Makefile.am b/src/platform/haswell/Makefile.am index 2c36856a46ef..d6ce05e2ed4c 100644 --- a/src/platform/haswell/Makefile.am +++ b/src/platform/haswell/Makefile.am @@ -8,7 +8,6 @@ libplatform_la_SOURCES = \ platform.c \ dai.c \ dma.c \ - timer.c \ memory.c libplatform_la_CFLAGS = \ diff --git a/src/platform/haswell/include/platform/timer.h b/src/platform/haswell/include/platform/timer.h index 91627cb1061b..a09f3125d4f2 100644 --- a/src/platform/haswell/include/platform/timer.h +++ b/src/platform/haswell/include/platform/timer.h @@ -43,24 +43,4 @@ #define TIMER1 IRQ_NUM_TIMER2 #define TIMER2 IRQ_NUM_TIMER3 -struct comp_dev; -struct sof_ipc_stream_posn; - -int platform_timer_set(struct timer *timer, uint64_t ticks); -void platform_timer_clear(struct timer *timer); -uint64_t platform_timer_get(struct timer *timer); -void platform_timer_start(struct timer *timer); -void platform_timer_stop(struct timer *timer); - -/* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn); - -/* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn); - -/* get current wallclock for componnent */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock); - #endif diff --git a/src/platform/intel/cavs/Makefile.am b/src/platform/intel/cavs/Makefile.am index ab6c8253fbf2..f2eaa62716f0 100644 --- a/src/platform/intel/cavs/Makefile.am +++ b/src/platform/intel/cavs/Makefile.am @@ -4,7 +4,6 @@ libcavsplatform_la_SOURCES = \ platform.c \ dai.c \ dma.c \ - timer.c \ memory.c \ pm_runtime.c From bd49c27b8dd3fc32214520ba702387bfc0778bb8 Mon Sep 17 00:00:00 2001 From: Janusz Jankowski Date: Thu, 23 Aug 2018 11:15:06 +0200 Subject: [PATCH 10/10] drivers: refactor: rename platform_timer functions to drivers_timer Signed-off-by: Janusz Jankowski --- src/audio/dai.c | 4 ++-- src/audio/pipeline.c | 8 +++---- src/drivers/intel/cavs/clk.c | 2 +- src/drivers/intel/cavs/timer.c | 20 ++++++++--------- src/drivers/intel/legacy/baytrail/clk.c | 2 +- src/drivers/intel/legacy/baytrail/timer.c | 24 ++++++++++----------- src/drivers/intel/legacy/haswell/clk.c | 2 +- src/drivers/intel/legacy/haswell/timer.c | 20 ++++++++--------- src/include/sof/drivers/timer.h | 20 ++++++++--------- src/include/sof/wait.h | 4 ++-- src/ipc/handler.c | 2 +- src/lib/agent.c | 6 +++--- src/lib/schedule.c | 4 ++-- src/lib/trace.c | 8 +++---- src/library/include/platform/timer.h | 17 +++++++++------ src/platform/baytrail/platform.c | 8 +++---- src/platform/haswell/platform.c | 2 +- src/platform/intel/cavs/platform.c | 26 +++++++++++------------ 18 files changed, 92 insertions(+), 87 deletions(-) diff --git a/src/audio/dai.c b/src/audio/dai.c index e98e40c2ccd8..0cb689995b7b 100644 --- a/src/audio/dai.c +++ b/src/audio/dai.c @@ -559,7 +559,7 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd) } /* update starting wallclock */ - platform_dai_wallclock(dev, &dd->wallclock); + drivers_timer_dai_wallclock(dev, &dd->wallclock); break; case COMP_TRIGGER_RELEASE: /* only start the DAI if we are not XRUN handling */ @@ -578,7 +578,7 @@ static int dai_comp_trigger(struct comp_dev *dev, int cmd) } /* update starting wallclock */ - platform_dai_wallclock(dev, &dd->wallclock); + drivers_timer_dai_wallclock(dev, &dd->wallclock); break; case COMP_TRIGGER_XRUN: dd->xrun = 1; diff --git a/src/audio/pipeline.c b/src/audio/pipeline.c index 9e4acef0644a..471034ddecd2 100644 --- a/src/audio/pipeline.c +++ b/src/audio/pipeline.c @@ -1007,7 +1007,7 @@ static int timestamp_downstream(struct comp_dev *start, if (current->comp.type == SOF_COMP_DAI || current->comp.type == SOF_COMP_SG_DAI) { - platform_dai_timestamp(current, posn); + drivers_timer_dai_timestamp(current, posn); return 1; } } @@ -1052,7 +1052,7 @@ static int timestamp_upstream(struct comp_dev *start, if (current->comp.type == SOF_COMP_DAI || current->comp.type == SOF_COMP_SG_DAI) { - platform_dai_timestamp(current, posn); + drivers_timer_dai_timestamp(current, posn); return 1; } } @@ -1085,7 +1085,7 @@ static int timestamp_upstream(struct comp_dev *start, void pipeline_get_timestamp(struct pipeline *p, struct comp_dev *host, struct sof_ipc_stream_posn *posn) { - platform_host_timestamp(host, posn); + drivers_timer_host_timestamp(host, posn); if (host->params.direction == SOF_IPC_STREAM_PLAYBACK) { timestamp_downstream(host, host, posn); @@ -1099,7 +1099,7 @@ static void xrun(struct comp_dev *dev, void *data) struct sof_ipc_stream_posn *posn = data; /* get host timestamps */ - platform_host_timestamp(dev, posn); + drivers_timer_host_timestamp(dev, posn); /* send XRUN to host */ ipc_stream_send_xrun(dev, posn); diff --git a/src/drivers/intel/cavs/clk.c b/src/drivers/intel/cavs/clk.c index 7ba73b2bfc0f..6157b61522e8 100644 --- a/src/drivers/intel/cavs/clk.c +++ b/src/drivers/intel/cavs/clk.c @@ -205,7 +205,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current) _current = arch_timer_get_system(NULL); break; case CLK_SSP: - _current = platform_timer_get(platform_timer); + _current = drivers_timer_get(platform_timer); break; default: return 0; diff --git a/src/drivers/intel/cavs/timer.c b/src/drivers/intel/cavs/timer.c index 89ab4f669443..706fa2ddbc30 100644 --- a/src/drivers/intel/cavs/timer.c +++ b/src/drivers/intel/cavs/timer.c @@ -38,7 +38,7 @@ #include #include -void platform_timer_start(struct timer *timer) +void drivers_timer_start(struct timer *timer) { /* run timer */ shim_write64(SHIM_DSPWCT0C, 0); @@ -46,7 +46,7 @@ void platform_timer_start(struct timer *timer) shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0A); } -void platform_timer_stop(struct timer *timer) +void drivers_timer_stop(struct timer *timer) { /* stop timer */ shim_write64(SHIM_DSPWCT0C, 0); @@ -54,7 +54,7 @@ void platform_timer_stop(struct timer *timer) shim_read(SHIM_DSPWCTCS) & ~SHIM_DSPWCTCS_T0A); } -int platform_timer_set(struct timer *timer, uint64_t ticks) +int drivers_timer_set(struct timer *timer, uint64_t ticks) { /* a tick value of 0 will not generate an IRQ */ if (ticks == 0) @@ -68,22 +68,22 @@ int platform_timer_set(struct timer *timer, uint64_t ticks) return 0; } -void platform_timer_clear(struct timer *timer) +void drivers_timer_clear(struct timer *timer) { /* write 1 to clear the timer interrupt */ shim_write(SHIM_DSPWCTCS, shim_read(SHIM_DSPWCTCS) | SHIM_DSPWCTCS_T0T); } -uint64_t platform_timer_get(struct timer *timer) +uint64_t drivers_timer_get(struct timer *timer) { // return arch_timer_get_system(timer); return (uint64_t)shim_read64(SHIM_DSPWC); } /* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn) +void drivers_timer_host_timestamp(struct comp_dev *host, + struct sof_ipc_stream_posn *posn) { int err; @@ -94,8 +94,8 @@ void platform_host_timestamp(struct comp_dev *host, } /* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn) +void drivers_timer_dai_timestamp(struct comp_dev *dai, + struct sof_ipc_stream_posn *posn) { int err; @@ -110,7 +110,7 @@ void platform_dai_timestamp(struct comp_dev *dai, } /* get current wallclock for componnent */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) +void drivers_timer_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) { *wallclock = shim_read64(SHIM_DSPWC); } diff --git a/src/drivers/intel/legacy/baytrail/clk.c b/src/drivers/intel/legacy/baytrail/clk.c index 4380d2d91edf..ff7d80afdbad 100644 --- a/src/drivers/intel/legacy/baytrail/clk.c +++ b/src/drivers/intel/legacy/baytrail/clk.c @@ -245,7 +245,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current) _current = arch_timer_get_system(NULL); break; case CLK_SSP: - _current = platform_timer_get(platform_timer); + _current = drivers_timer_get(platform_timer); break; default: return 0; diff --git a/src/drivers/intel/legacy/baytrail/timer.c b/src/drivers/intel/legacy/baytrail/timer.c index d001eb1dd3d7..61a15db51b00 100644 --- a/src/drivers/intel/legacy/baytrail/timer.c +++ b/src/drivers/intel/legacy/baytrail/timer.c @@ -80,7 +80,7 @@ static void platform_timer_64_handler(void *arg) shim_write(SHIM_EXT_TIMER_CNTLL, timeout); } -void platform_timer_start(struct timer *timer) +void drivers_timer_start(struct timer *timer) { /* run timer */ shim_write(SHIM_EXT_TIMER_CNTLH, SHIM_EXT_TIMER_RUN); @@ -88,14 +88,14 @@ void platform_timer_start(struct timer *timer) } /* this seems to stop rebooting with RTD3 ???? */ -void platform_timer_stop(struct timer *timer) +void drivers_timer_stop(struct timer *timer) { /* run timer */ shim_write(SHIM_EXT_TIMER_CNTLL, 0); shim_write(SHIM_EXT_TIMER_CNTLH, SHIM_EXT_TIMER_CLEAR); } -int platform_timer_set(struct timer *timer, uint64_t ticks) +int drivers_timer_set(struct timer *timer, uint64_t ticks) { uint32_t time = 1; uint32_t hitimeout = ticks >> 32; @@ -129,13 +129,13 @@ int platform_timer_set(struct timer *timer, uint64_t ticks) return 0; } -void platform_timer_clear(struct timer *timer) +void drivers_timer_clear(struct timer *timer) { /* we don't use the timer clear bit as we only need to clear the ISR */ shim_write(SHIM_PISR, SHIM_PISR_EXT_TIMER); } -uint64_t platform_timer_get(struct timer *timer) +uint64_t drivers_timer_get(struct timer *timer) { uint64_t time; uint32_t flags; @@ -165,8 +165,8 @@ uint64_t platform_timer_get(struct timer *timer) } /* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn) +void drivers_timer_host_timestamp(struct comp_dev *host, + struct sof_ipc_stream_posn *posn) { int err; @@ -177,8 +177,8 @@ void platform_host_timestamp(struct comp_dev *host, } /* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn) +void drivers_timer_dai_timestamp(struct comp_dev *dai, + struct sof_ipc_stream_posn *posn) { int err; @@ -188,15 +188,15 @@ void platform_dai_timestamp(struct comp_dev *dai, posn->flags |= SOF_TIME_DAI_VALID; /* get SSP wallclock - DAI sets this to stream start value */ - posn->wallclock = platform_timer_get(platform_timer) - posn->wallclock; + posn->wallclock = drivers_timer_get(platform_timer) - posn->wallclock; posn->flags |= SOF_TIME_WALL_VALID | SOF_TIME_WALL_64; } /* get current wallclock for component */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) +void drivers_timer_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) { /* only 1 wallclock on BYT */ - *wallclock = platform_timer_get(platform_timer); + *wallclock = drivers_timer_get(platform_timer); } static int platform_timer_register(struct timer *timer, diff --git a/src/drivers/intel/legacy/haswell/clk.c b/src/drivers/intel/legacy/haswell/clk.c index 83f9e902dae2..ff79e375d3f6 100644 --- a/src/drivers/intel/legacy/haswell/clk.c +++ b/src/drivers/intel/legacy/haswell/clk.c @@ -179,7 +179,7 @@ uint64_t clock_time_elapsed(int clock, uint64_t previous, uint64_t *current) _current = arch_timer_get_system(NULL); break; case CLK_SSP: - _current = platform_timer_get(platform_timer); + _current = drivers_timer_get(platform_timer); break; default: return 0; diff --git a/src/drivers/intel/legacy/haswell/timer.c b/src/drivers/intel/legacy/haswell/timer.c index ed365e2d6e70..e89b3a1d2812 100644 --- a/src/drivers/intel/legacy/haswell/timer.c +++ b/src/drivers/intel/legacy/haswell/timer.c @@ -36,34 +36,34 @@ #include #include -void platform_timer_start(struct timer *timer) +void drivers_timer_start(struct timer *timer) { arch_timer_enable(timer); } -void platform_timer_stop(struct timer *timer) +void drivers_timer_stop(struct timer *timer) { arch_timer_disable(timer); } -int platform_timer_set(struct timer *timer, uint64_t ticks) +int drivers_timer_set(struct timer *timer, uint64_t ticks) { return arch_timer_set(timer, ticks); } -void platform_timer_clear(struct timer *timer) +void drivers_timer_clear(struct timer *timer) { arch_timer_clear(timer); } -uint64_t platform_timer_get(struct timer *timer) +uint64_t drivers_timer_get(struct timer *timer) { return arch_timer_get_system(timer); } /* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn) +void drivers_timer_host_timestamp(struct comp_dev *host, + struct sof_ipc_stream_posn *posn) { int err; @@ -74,8 +74,8 @@ void platform_host_timestamp(struct comp_dev *host, } /* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn) +void drivers_timer_dai_timestamp(struct comp_dev *dai, + struct sof_ipc_stream_posn *posn) { int err; @@ -90,7 +90,7 @@ void platform_dai_timestamp(struct comp_dev *dai, } /* get current wallclock for componnent */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) +void drivers_timer_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock) { /* only 1 wallclock on HSW */ *wallclock = timer_get_system(platform_timer); diff --git a/src/include/sof/drivers/timer.h b/src/include/sof/drivers/timer.h index 20c55e654f09..22eb06b5a0b7 100644 --- a/src/include/sof/drivers/timer.h +++ b/src/include/sof/drivers/timer.h @@ -36,21 +36,21 @@ struct comp_dev; struct sof_ipc_stream_posn; -int platform_timer_set(struct timer *timer, uint64_t ticks); -void platform_timer_clear(struct timer *timer); -uint64_t platform_timer_get(struct timer *timer); -void platform_timer_start(struct timer *timer); -void platform_timer_stop(struct timer *timer); +int drivers_timer_set(struct timer *timer, uint64_t ticks); +void drivers_timer_clear(struct timer *timer); +uint64_t drivers_timer_get(struct timer *timer); +void drivers_timer_start(struct timer *timer); +void drivers_timer_stop(struct timer *timer); /* get timestamp for host stream DMA position */ -void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn); +void drivers_timer_host_timestamp(struct comp_dev *host, + struct sof_ipc_stream_posn *posn); /* get timestamp for DAI stream DMA position */ -void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn); +void drivers_timer_dai_timestamp(struct comp_dev *dai, + struct sof_ipc_stream_posn *posn); /* get current wallclock for componnent */ -void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock); +void drivers_timer_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock); #endif diff --git a/src/include/sof/wait.h b/src/include/sof/wait.h index 9016da8aa730..4242a891f8ef 100644 --- a/src/include/sof/wait.h +++ b/src/include/sof/wait.h @@ -152,9 +152,9 @@ static inline int wait_for_completion_timeout(completion_t *comp) */ static inline void wait_delay(uint64_t number_of_clks) { - uint64_t current = platform_timer_get(platform_timer); + uint64_t current = drivers_timer_get(platform_timer); - while ((platform_timer_get(platform_timer) - current) < number_of_clks) + while ((drivers_timer_get(platform_timer) - current) < number_of_clks) idelay(PLATFORM_DEFAULT_DELAY); } diff --git a/src/ipc/handler.c b/src/ipc/handler.c index ce8c3305b478..41075ba439bb 100644 --- a/src/ipc/handler.c +++ b/src/ipc/handler.c @@ -553,7 +553,7 @@ static int ipc_pm_context_save(uint32_t header) /* TODO: clear any outstanding platform IRQs - TODO refine */ /* TODO: stop ALL timers */ - platform_timer_stop(platform_timer); + drivers_timer_stop(platform_timer); /* TODO: disable SSP and DMA HW */ diff --git a/src/lib/agent.c b/src/lib/agent.c index b672f235563c..152108a4b88e 100644 --- a/src/lib/agent.c +++ b/src/lib/agent.c @@ -55,7 +55,7 @@ void sa_enter_idle(struct sof *sof) { struct sa *sa = sof->sa; - sa->last_idle = platform_timer_get(platform_timer); + sa->last_idle = drivers_timer_get(platform_timer); } static uint64_t validate(void *data, uint64_t delay) @@ -64,7 +64,7 @@ static uint64_t validate(void *data, uint64_t delay) uint64_t current; uint64_t delta; - current = platform_timer_get(platform_timer); + current = drivers_timer_get(platform_timer); delta = current - sa->last_idle; /* were we last idle longer than timeout */ @@ -91,7 +91,7 @@ void sa_init(struct sof *sof) trace_sa_value(sa->ticks); /* set lst idle time to now to give time for boot completion */ - sa->last_idle = platform_timer_get(platform_timer) + sa->ticks; + sa->last_idle = drivers_timer_get(platform_timer) + sa->ticks; work_init(&sa->work, validate, sa, WORK_ASYNC); work_schedule_default(&sa->work, PLATFORM_IDLE_TIME); } diff --git a/src/lib/schedule.c b/src/lib/schedule.c index 22296854e00f..f0f2d63cb5bd 100644 --- a/src/lib/schedule.c +++ b/src/lib/schedule.c @@ -177,7 +177,7 @@ static struct task *schedule_edf(void) tracev_pipe("edf"); /* get the current time */ - current = platform_timer_get(platform_timer); + current = drivers_timer_get(platform_timer); /* get next task to be scheduled */ task = edf_get_next(current, NULL); @@ -250,7 +250,7 @@ static int _schedule_task(struct task *task, uint64_t start, uint64_t deadline) } /* get the current time */ - current = platform_timer_get(platform_timer); + current = drivers_timer_get(platform_timer); /* calculate start time - TODO: include MIPS */ if (start == 0) diff --git a/src/lib/trace.c b/src/lib/trace.c index 0c378588e5b0..16b28c8740c2 100644 --- a/src/lib/trace.c +++ b/src/lib/trace.c @@ -53,7 +53,7 @@ void _trace_event(uint32_t event) if (!trace.enable) return; - dt[0] = platform_timer_get(platform_timer); + dt[0] = drivers_timer_get(platform_timer); dt[1] = event; dtrace_event((const char *)dt, sizeof(uint64_t) * 2); } @@ -65,7 +65,7 @@ void _trace_event_atomic(uint32_t event) if (!trace.enable) return; - dt[0] = platform_timer_get(platform_timer); + dt[0] = drivers_timer_get(platform_timer); dt[1] = event; dtrace_event_atomic((const char *)dt, sizeof(uint64_t) * 2); } @@ -82,7 +82,7 @@ void _trace_event_mbox(uint32_t event) if (!trace.enable) return; - time = platform_timer_get(platform_timer); + time = drivers_timer_get(platform_timer); dt[0] = time; dt[1] = event; @@ -116,7 +116,7 @@ void _trace_event_mbox_atomic(uint32_t event) if (!trace.enable) return; - time = platform_timer_get(platform_timer); + time = drivers_timer_get(platform_timer); dt[0] = time; dt[1] = event; diff --git a/src/library/include/platform/timer.h b/src/library/include/platform/timer.h index 9c6a513eb352..8310ce8af9b9 100644 --- a/src/library/include/platform/timer.h +++ b/src/library/include/platform/timer.h @@ -39,16 +39,21 @@ struct comp_dev; struct sof_ipc_stream_posn; +// TODO: functions below should go to some drivers mocks else for host library + /* get timestamp for host stream DMA position */ -static inline void platform_host_timestamp(struct comp_dev *host, - struct sof_ipc_stream_posn *posn) {} +static inline void drivers_timer_host_timestamp(struct comp_dev *host, + struct sof_ipc_stream_posn *pos) +{} /* get timestamp for DAI stream DMA position */ -static inline void platform_dai_timestamp(struct comp_dev *dai, - struct sof_ipc_stream_posn *posn) {} +static inline void drivers_timer_dai_timestamp(struct comp_dev *dai, + struct sof_ipc_stream_posn *pos) +{} /* get current wallclock for componnent */ -static inline void platform_dai_wallclock(struct comp_dev *dai, - uint64_t *wallclock) {} +static inline void drivers_timer_dai_wallclock(struct comp_dev *dai, + uint64_t *wallclock) +{} #endif diff --git a/src/platform/baytrail/platform.c b/src/platform/baytrail/platform.c index 7669744a8d05..c58b3f226df9 100644 --- a/src/platform/baytrail/platform.c +++ b/src/platform/baytrail/platform.c @@ -135,9 +135,9 @@ struct work_queue_timesource platform_generic_queue[] = { }, .clk = PLATFORM_WORKQ_CLOCK, .notifier = NOTIFIER_ID_SSP_FREQ, - .timer_set = platform_timer_set, - .timer_clear = platform_timer_clear, - .timer_get = platform_timer_get, + .timer_set = drivers_timer_set, + .timer_clear = drivers_timer_clear, + .timer_get = drivers_timer_get, }, }; @@ -210,7 +210,7 @@ int platform_init(struct sof *sof) init_system_workq(&platform_generic_queue[PLATFORM_MASTER_CORE_ID]); trace_point(TRACE_BOOT_PLATFORM_TIMER); - platform_timer_start(platform_timer); + drivers_timer_start(platform_timer); /* init the system agent */ sa_init(sof); diff --git a/src/platform/haswell/platform.c b/src/platform/haswell/platform.c index 38813ac006cd..40a0956b973d 100644 --- a/src/platform/haswell/platform.c +++ b/src/platform/haswell/platform.c @@ -199,7 +199,7 @@ int platform_init(struct sof *sof) init_system_workq(&platform_generic_queue[PLATFORM_MASTER_CORE_ID]); trace_point(TRACE_BOOT_PLATFORM_TIMER); - platform_timer_start(platform_timer); + drivers_timer_start(platform_timer); /* init the system agent */ sa_init(sof); diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index c807d1c89516..8e65483709a4 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -152,9 +152,9 @@ struct work_queue_timesource platform_generic_queue[] = { }, .clk = CLK_SSP, .notifier = NOTIFIER_ID_SSP_FREQ, - .timer_set = platform_timer_set, - .timer_clear = platform_timer_clear, - .timer_get = platform_timer_get, + .timer_set = drivers_timer_set, + .timer_clear = drivers_timer_clear, + .timer_get = drivers_timer_get, }, { .timer = { @@ -163,9 +163,9 @@ struct work_queue_timesource platform_generic_queue[] = { }, .clk = CLK_SSP, .notifier = NOTIFIER_ID_SSP_FREQ, - .timer_set = platform_timer_set, - .timer_clear = platform_timer_clear, - .timer_get = platform_timer_get, + .timer_set = drivers_timer_set, + .timer_clear = drivers_timer_clear, + .timer_get = drivers_timer_get, }, #if defined(CONFIG_CANNONLAKE) { @@ -175,9 +175,9 @@ struct work_queue_timesource platform_generic_queue[] = { }, .clk = CLK_SSP, .notifier = NOTIFIER_ID_SSP_FREQ, - .timer_set = platform_timer_set, - .timer_clear = platform_timer_clear, - .timer_get = platform_timer_get, + .timer_set = drivers_timer_set, + .timer_clear = drivers_timer_clear, + .timer_get = drivers_timer_get, }, { .timer = { @@ -186,9 +186,9 @@ struct work_queue_timesource platform_generic_queue[] = { }, .clk = CLK_SSP, .notifier = NOTIFIER_ID_SSP_FREQ, - .timer_set = platform_timer_set, - .timer_clear = platform_timer_clear, - .timer_get = platform_timer_get, + .timer_set = drivers_timer_set, + .timer_clear = drivers_timer_clear, + .timer_get = drivers_timer_get, }, #endif }; @@ -291,7 +291,7 @@ int platform_init(struct sof *sof) /* init work queues and clocks */ trace_point(TRACE_BOOT_PLATFORM_TIMER); - platform_timer_start(platform_timer); + drivers_timer_start(platform_timer); trace_point(TRACE_BOOT_PLATFORM_CLOCK); drivers_clock_init();