2019-11-19 12:33:35 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/device.h>
|
2019-11-19 12:33:35 +02:00
|
|
|
#include <xtensa/xtruntime.h>
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/irq_nextlevel.h>
|
2019-11-19 12:33:35 +02:00
|
|
|
#include <xtensa/hal.h>
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/init.h>
|
2019-11-19 12:33:35 +02:00
|
|
|
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
#include <cavs-shim.h>
|
2021-08-07 09:44:09 -07:00
|
|
|
#include <cavs-idc.h>
|
2019-11-19 12:33:35 +02:00
|
|
|
#include "soc.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_DYNAMIC_INTERRUPTS
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/sw_isr_table.h>
|
2019-11-19 12:33:35 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
|
2022-05-06 11:11:04 +02:00
|
|
|
#include <zephyr/logging/log.h>
|
2019-11-19 12:33:35 +02:00
|
|
|
LOG_MODULE_REGISTER(soc);
|
|
|
|
|
2021-10-20 11:08:46 -07:00
|
|
|
#ifndef CONFIG_SOC_SERIES_INTEL_CAVS_V15
|
|
|
|
# define SHIM_GPDMA_BASE_OFFSET 0x6500
|
|
|
|
# define SHIM_GPDMA_BASE(x) (SHIM_GPDMA_BASE_OFFSET + (x) * 0x100)
|
|
|
|
# define SHIM_GPDMA_CLKCTL(x) (SHIM_GPDMA_BASE(x) + 0x4)
|
|
|
|
# define SHIM_CLKCTL_LPGPDMAFDCGB BIT(0)
|
|
|
|
|
|
|
|
# define DSP_INIT_LPGPDMA(x) (0x71A60 + (2*x))
|
|
|
|
# define LPGPDMA_CTLOSEL_FLAG BIT(15)
|
|
|
|
# define LPGPDMA_CHOSEL_FLAG 0xFF
|
|
|
|
|
|
|
|
# define DSP_INIT_GENO 0x71A6C
|
|
|
|
# define GENO_MDIVOSEL BIT(1)
|
|
|
|
# define GENO_DIOPTOSEL BIT(2)
|
2022-03-25 14:47:24 +02:00
|
|
|
|
|
|
|
# define DSP_INIT_IOPO 0x71A68
|
|
|
|
# define IOPO_DMIC_FLAG BIT(0)
|
|
|
|
#ifdef CONFIG_SOC_SERIES_INTEL_CAVS_V18
|
|
|
|
/* amount of i2s nodes = amount of bits set in second byte */
|
|
|
|
# define IOPO_I2S_FLAG 7 << 8
|
|
|
|
#else
|
|
|
|
# define IOPO_I2S_FLAG 63 << 8
|
|
|
|
#endif
|
2021-10-20 11:08:46 -07:00
|
|
|
#endif
|
|
|
|
|
2022-01-11 13:47:13 -08:00
|
|
|
#if CONFIG_MP_NUM_CPUS > 1
|
2022-01-03 19:12:34 -08:00
|
|
|
extern void soc_mp_init(void);
|
2022-01-11 13:47:13 -08:00
|
|
|
#endif
|
2022-01-03 19:12:34 -08:00
|
|
|
|
2022-01-28 09:44:59 -08:00
|
|
|
#ifdef CONFIG_INTEL_ADSP_CAVS
|
2021-12-10 17:56:58 -08:00
|
|
|
static __imr void power_init_v15(void)
|
2019-11-19 12:33:35 +02:00
|
|
|
{
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
/* HP domain clocked by PLL
|
2021-08-02 10:09:11 -07:00
|
|
|
* LP domain clocked by PLL
|
2019-11-19 12:33:35 +02:00
|
|
|
* DSP Core 0 PLL Clock Select divide by 1
|
|
|
|
* DSP Core 1 PLL Clock Select divide by 1
|
|
|
|
* High Power Domain PLL Clock Select device by 2
|
2021-08-02 10:09:11 -07:00
|
|
|
* Low Power Domain PLL Clock Select device by 4
|
|
|
|
* Disable Tensilica Core Prevent Audio PLL Shutdown (TCPAPLLS)
|
|
|
|
* Disable Tensilica Core Prevent Local Clock Gating (Core 0)
|
|
|
|
* Disable Tensilica Core Prevent Local Clock Gating (Core 1)
|
|
|
|
* - Disabling "prevent clock gating" means allowing clock gating
|
2019-11-19 12:33:35 +02:00
|
|
|
*/
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
CAVS_SHIM.clkctl = CAVS15_CLKCTL_LMPCS;
|
2019-11-19 12:33:35 +02:00
|
|
|
|
|
|
|
/* Rewrite the low power sequencing control bits */
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
CAVS_SHIM.lpsctl = CAVS_SHIM.lpsctl;
|
2021-09-04 08:15:21 -07:00
|
|
|
}
|
2021-08-02 10:09:11 -07:00
|
|
|
|
2021-12-10 17:56:58 -08:00
|
|
|
static __imr void power_init(void)
|
2021-09-04 08:15:21 -07:00
|
|
|
{
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
/* Request HP ring oscillator and
|
2021-08-02 10:09:11 -07:00
|
|
|
* wait for status to indicate it's ready.
|
|
|
|
*/
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
CAVS_SHIM.clkctl |= CAVS_CLKCTL_RHROSCC;
|
|
|
|
while ((CAVS_SHIM.clkctl & CAVS_CLKCTL_RHROSCC) != CAVS_CLKCTL_RHROSCC) {
|
2021-08-02 10:09:11 -07:00
|
|
|
k_busy_wait(10);
|
|
|
|
}
|
|
|
|
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
/* Request HP Ring Oscillator
|
2021-08-02 10:09:11 -07:00
|
|
|
* Select HP Ring Oscillator
|
|
|
|
* High Power Domain PLL Clock Select device by 2
|
|
|
|
* Low Power Domain PLL Clock Select device by 4
|
|
|
|
* Disable Tensilica Core(s) Prevent Local Clock Gating
|
|
|
|
* - Disabling "prevent clock gating" means allowing clock gating
|
|
|
|
*/
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
CAVS_SHIM.clkctl = (CAVS_CLKCTL_RHROSCC |
|
|
|
|
CAVS_CLKCTL_OCS |
|
|
|
|
CAVS_CLKCTL_LMCS);
|
2021-08-02 10:09:11 -07:00
|
|
|
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
#ifndef CONFIG_SOC_SERIES_INTEL_CAVS_V15
|
2021-08-02 10:09:11 -07:00
|
|
|
/* Prevent LP GPDMA 0 & 1 clock gating */
|
|
|
|
sys_write32(SHIM_CLKCTL_LPGPDMAFDCGB, SHIM_GPDMA_CLKCTL(0));
|
|
|
|
sys_write32(SHIM_CLKCTL_LPGPDMAFDCGB, SHIM_GPDMA_CLKCTL(1));
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
#endif
|
2021-08-02 10:09:11 -07:00
|
|
|
|
|
|
|
/* Disable power gating for first cores */
|
2021-11-22 11:40:29 -08:00
|
|
|
CAVS_SHIM.pwrctl |= CAVS_PWRCTL_TCPDSPPG(0);
|
2021-08-02 10:09:11 -07:00
|
|
|
|
soc: intel_adsp: Clean up shim driver
Each platform was defining its own shim.h header, with slightly
variant field definitions, for a register block that is almost
completely compatible between versions. This is made worse by the
fact that these represent an API imported fairly early from SOF, the
upstream version of which has since diverged.
Move the existing shim struct into a header ("cavs-shim.h") of its
own, remove a bunch of unused symbols, fill in definitions for some
registers that were left out, correct naming to match the hardware
docs in a few places, make sure all hardware dependencies are source
from devicetree only, and modify existing usage to use the new API
exclusively.
Interestingly this leaves the older shim.h header in place, as it
turns out to contain definitions for a bunch of things that were never
part of the shim register block. Those will be unified in separate
patches.
Finally: note that the existing IPM_CAVS_IDC driver (soon to be
removed from all the intel_adsp soc's) is still using the old API, so
redeclare the minimal subset that it needs for the benefit of the
platforms in transition.
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-09-05 15:27:46 -07:00
|
|
|
#ifndef CONFIG_SOC_SERIES_INTEL_CAVS_V15
|
2021-06-24 14:56:37 -07:00
|
|
|
/* On cAVS 1.8+, we must demand ownership of the timestamping
|
|
|
|
* and clock generator registers. Lacking the former will
|
|
|
|
* prevent wall clock timer interrupts from arriving, even
|
|
|
|
* though the device itself is operational.
|
|
|
|
*/
|
|
|
|
sys_write32(GENO_MDIVOSEL | GENO_DIOPTOSEL, DSP_INIT_GENO);
|
|
|
|
sys_write32(LPGPDMA_CHOSEL_FLAG | LPGPDMA_CTLOSEL_FLAG,
|
|
|
|
DSP_INIT_LPGPDMA(0));
|
|
|
|
sys_write32(LPGPDMA_CHOSEL_FLAG | LPGPDMA_CTLOSEL_FLAG,
|
|
|
|
DSP_INIT_LPGPDMA(1));
|
2022-03-25 14:47:24 +02:00
|
|
|
|
|
|
|
sys_write32(IOPO_DMIC_FLAG | IOPO_I2S_FLAG, DSP_INIT_IOPO);
|
2021-06-24 14:56:37 -07:00
|
|
|
#endif
|
2021-09-04 08:15:21 -07:00
|
|
|
}
|
2021-06-24 14:56:37 -07:00
|
|
|
|
2021-12-10 17:56:58 -08:00
|
|
|
static __imr int soc_init(const struct device *dev)
|
2021-09-04 08:15:21 -07:00
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_SOC_SERIES_INTEL_CAVS_V15)) {
|
|
|
|
power_init_v15();
|
|
|
|
} else {
|
|
|
|
power_init();
|
|
|
|
}
|
2021-08-07 09:44:09 -07:00
|
|
|
|
2022-01-11 13:47:13 -08:00
|
|
|
#if CONFIG_MP_NUM_CPUS > 1
|
2022-01-03 19:12:34 -08:00
|
|
|
soc_mp_init();
|
2022-01-11 13:47:13 -08:00
|
|
|
#endif
|
2021-12-14 12:55:32 -08:00
|
|
|
|
2019-11-19 12:33:35 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SYS_INIT(soc_init, PRE_KERNEL_1, 99);
|
2022-01-28 09:44:59 -08:00
|
|
|
#endif /* CONFIG_INTEL_ADSP_CAVS */
|