Saurabh Satija (saurabh.satija(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15023
-gerrit
commit 249c0b783602d5037bd8e6f9ee59b69df26713c1
Author: Saurabh Satija <saurabh.satija(a)intel.com>
Date: Thu Jun 23 14:46:27 2016 -0700
lib/nhlt: Add common NHLT audio for Intel platforms
The use of a NHLT table is required to make audio work
on the Intel SoCs employing the internal DSP. The table
describes the audio endpoints (render vs capture) along with
their supported formats. These formats are not only dependent
on the audio peripheral but also hardware interfaces. As such
each format has an associated blob of DSP settings to make
the peripheral work. Lastly, each of these settings are provided
by Intel and need to be generated for each device's hardware
connection plus mode/format it supports. This patch does not
include the DSP setting blobs.
Change-Id: I3c75d3537288c47d29e8949ca253ea8c5c1a387d
Signed-off-by: Saurabh Satija <saurabh.satija(a)intel.com>
---
src/include/nhlt.h | 45 +++++++++++++++++++++++++++
src/lib/nhlt.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 134 insertions(+), 2 deletions(-)
diff --git a/src/include/nhlt.h b/src/include/nhlt.h
index f0b3b6f..20d20ed 100644
--- a/src/include/nhlt.h
+++ b/src/include/nhlt.h
@@ -23,6 +23,51 @@ struct nhlt;
struct nhlt_endpoint;
struct nhlt_format;
struct nhlt_format_config;
+struct nhlt_tdm_config;
+
+/*
+ * NHLT device types. These values are used with nhlt_soc_add_endpoint().
+ */
+enum {
+ AUDIO_DEV_I2S,
+ AUDIO_DEV_DMIC,
+ AUDIO_DEV_BT,
+};
+
+/*
+ * Returns corresponding nhlt link type based on hardware link number.
+ * Hardware link number is the SSP port number on which the particular
+ * is present, which is mainboard specfic.
+ * nhlt_soc_get_link_type() is SoC specific.
+ */
+int nhlt_soc_get_link_type(int hwlink, int soc_devtype);
+
+/*
+ * Add a dmic array composed of the provided number of channels.
+ * Returns 0 on success, < 0 on error.
+ */
+int nhlt_add_dmic_array(struct nhlt *nhlt, int num_channels,
+ const struct nhlt_format_config *dmic_ch_config, int num_fmt);
+
+/*
+ * Add audio codec on provided SSP link. Return 0 on succes, < 0 on error.
+ *
+ * The same DSP firmware settings can be used for both the capture and render
+ * endpoints in some cases. Most of the smart amps use different DSP firmware
+ * settings for capture and render endpoints.
+ *
+ * render_cfg, capture_cfg: These are the audio codec configuration defined
+ * in mainboard souce code.
+ * cfg_size: This is the number of configurations defined in codec config.
+ * Each configuration is added as an endpoint.
+ * tdm_config: This is also board specific and defined in mainboard.c
+ * hwlink: This is the SSP hardware port number.
+ * direction: This can be Render only, Capture only or Bi-directional.
+ */
+int nhlt_add_codec_on_ssp(struct nhlt *nhlt, int hwlink,
+ const struct nhlt_format_config *render_cfg, int r_num_fmt,
+ const struct nhlt_format_config *capture_cfg, int c_num_fmt,
+ const struct nhlt_tdm_config *tdm_config, size_t tdm_size);
/*
* Non HD Audio ACPI support. This table is typically used for Intel Smart
diff --git a/src/lib/nhlt.c b/src/lib/nhlt.c
index 11a397c..e31803d 100644
--- a/src/lib/nhlt.c
+++ b/src/lib/nhlt.c
@@ -15,9 +15,12 @@
#include <arch/acpi.h>
#include <cbfs.h>
+#include <cbmem.h>
#include <commonlib/endian.h>
#include <console/console.h>
#include <nhlt.h>
+#include <soc/nvs.h>
+#include <soc/nhlt.h>
#include <stdlib.h>
#include <string.h>
@@ -47,8 +50,7 @@ struct nhlt *nhlt_init(void)
}
struct nhlt_endpoint *nhlt_add_endpoint(struct nhlt *nhlt, int link_type,
- int device_type, int dir,
- uint16_t vid, uint16_t did)
+ int device_type, int dir, uint16_t vid, uint16_t did)
{
struct nhlt_endpoint *endp;
@@ -437,3 +439,88 @@ uintptr_t nhlt_serialize_oem_overrides(struct nhlt *nhlt,
return acpi_addr;
}
+
+int nhlt_add_dmic_array(struct nhlt *nhlt, int num_channels,
+ const struct nhlt_format_config *dmic_ch_cfg, int num_fmt)
+{
+ struct nhlt_endpoint *endp;
+ struct nhlt_dmic_array_config mic_config;
+
+ if (num_channels != 2 && num_channels != 4)
+ return -1;
+
+ endp = nhlt_soc_add_endpoint(nhlt, AUDIO_LINK_DMIC, AUDIO_DEV_DMIC,
+ NHLT_DIR_CAPTURE);
+
+ if (endp == NULL)
+ return -1;
+
+ memset(&mic_config, 0, sizeof(mic_config));
+ mic_config.tdm_config.config_type = NHLT_TDM_MIC_ARRAY;
+
+ switch (num_channels) {
+ case 2:
+ mic_config.array_type = NHLT_MIC_ARRAY_2CH_SMALL;
+ break;
+ case 4:
+ mic_config.array_type = NHLT_MIC_ARRAY_4CH_L_SHAPED;
+ break;
+ }
+
+ if (nhlt_endpoint_append_config(endp, &mic_config, sizeof(mic_config)))
+ return -1;
+
+ return nhlt_endpoint_add_formats(endp, dmic_ch_cfg, num_fmt);
+}
+
+int nhlt_add_codec_on_ssp(struct nhlt *nhlt, int hwlink,
+ const struct nhlt_format_config *render_cfg, int r_num_fmt,
+ const struct nhlt_format_config *capture_cfg, int c_num_fmt,
+ const struct nhlt_tdm_config *tdm_config, size_t tdm_size)
+{
+ struct nhlt_endpoint *endp;
+
+ /* For Bi-directional amplifiers, both capture and render
+ * configuratoins are needed.
+ */
+ if (render_cfg == NULL && capture_cfg == NULL)
+ return -1;
+
+ /* Render Endpoint */
+ if (render_cfg != NULL) {
+ endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+ NHLT_DIR_RENDER);
+ if (endp == NULL)
+ return -1;
+
+ if (tdm_config != NULL) {
+ if (nhlt_endpoint_append_config(endp, tdm_config,
+ tdm_size))
+ return -1;
+ }
+
+ if (nhlt_endpoint_add_formats(endp, render_cfg, r_num_fmt))
+ return -1;
+ }
+
+ /* Capture Endpoint */
+ if (capture_cfg != NULL) {
+ endp = nhlt_soc_add_endpoint(nhlt, hwlink, AUDIO_DEV_I2S,
+ NHLT_DIR_CAPTURE);
+ if (endp == NULL)
+ return -1;
+
+ if (tdm_config != NULL) {
+ if (nhlt_endpoint_append_config(endp, tdm_config,
+ tdm_size))
+ return -1;
+ }
+
+ if (nhlt_endpoint_add_formats(endp, capture_cfg, c_num_fmt))
+ return -1;
+ }
+
+ nhlt_next_instance(nhlt, NHLT_LINK_SSP);
+
+ return 0;
+}
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15463
-gerrit
commit 896cf09b4440fbbc996dd5e7f72effd0fff7a660
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Jun 27 14:50:27 2016 +0300
intel post-car: Consolidate choose_top_of_stack()
Change-Id: I2c49d68ea9a8f52737b6064bc4fa703bdb1af1df
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/cpu/Kconfig | 4 +++
src/cpu/intel/haswell/romstage.c | 16 +----------
src/drivers/intel/fsp1_1/Kconfig | 4 ---
src/drivers/intel/fsp1_1/stack.c | 20 ++------------
src/include/program_loading.h | 4 +++
src/lib/Makefile.inc | 1 +
src/lib/romstage_stack.c | 44 ++++++++++++++++++++++++++++++
src/soc/intel/baytrail/romstage/romstage.c | 16 +----------
src/soc/intel/broadwell/romstage/stack.c | 17 ++----------
9 files changed, 59 insertions(+), 67 deletions(-)
diff --git a/src/cpu/Kconfig b/src/cpu/Kconfig
index a026b28..37d6513 100644
--- a/src/cpu/Kconfig
+++ b/src/cpu/Kconfig
@@ -25,6 +25,10 @@ config DCACHE_BSP_STACK_SLUSH
config DCACHE_AP_STACK_SIZE
hex
+config ROMSTAGE_RAM_STACK_SIZE
+ hex "Size of the romstage RAM stack in bytes"
+ default 0x5000
+
config SMP
bool
default y if MAX_CPUS != 1
diff --git a/src/cpu/intel/haswell/romstage.c b/src/cpu/intel/haswell/romstage.c
index cde9441..8354aeb 100644
--- a/src/cpu/intel/haswell/romstage.c
+++ b/src/cpu/intel/haswell/romstage.c
@@ -65,20 +65,6 @@ static inline u32 *stack_push(u32 *stack, u32 value)
return stack;
}
-/* Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage. */
-#define ROMSTAGE_RAM_STACK_SIZE 0x5000
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- ROMSTAGE_RAM_STACK_SIZE);
- stack_top += ROMSTAGE_RAM_STACK_SIZE;
- return stack_top;
-}
-
/* setup_romstage_stack_after_car() determines the stack to use after
* cache-as-ram is torn down as well as the MTRR settings to use. */
static void *setup_romstage_stack_after_car(void)
@@ -90,7 +76,7 @@ static void *setup_romstage_stack_after_car(void)
u32 top_of_ram;
/* Top of stack needs to be aligned to a 4-byte boundary. */
- top_of_stack = choose_top_of_stack() & ~3;
+ top_of_stack = romstage_ram_stack() & ~3;
slot = (void *)top_of_stack;
num_mtrrs = 0;
diff --git a/src/drivers/intel/fsp1_1/Kconfig b/src/drivers/intel/fsp1_1/Kconfig
index 86f6c7b..59b4797 100644
--- a/src/drivers/intel/fsp1_1/Kconfig
+++ b/src/drivers/intel/fsp1_1/Kconfig
@@ -99,10 +99,6 @@ config GOP_SUPPORT
bool "Enable GOP support"
default n
-config ROMSTAGE_RAM_STACK_SIZE
- hex "Size of the romstage RAM stack in bytes"
- default 0x5000
-
config USE_GENERIC_FSP_CAR_INC
bool
default n
diff --git a/src/drivers/intel/fsp1_1/stack.c b/src/drivers/intel/fsp1_1/stack.c
index 65ba235..b0e4992 100644
--- a/src/drivers/intel/fsp1_1/stack.c
+++ b/src/drivers/intel/fsp1_1/stack.c
@@ -21,23 +21,7 @@
#include <fsp/romstage.h>
#include <fsp/stack.h>
#include <stdlib.h>
-
-const unsigned long romstage_ram_stack_size = CONFIG_ROMSTAGE_RAM_STACK_SIZE;
-
-/*
- * Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage.
- */
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- romstage_ram_stack_size);
- stack_top += romstage_ram_stack_size;
- return stack_top;
-}
+#include <program_loading.h>
/*
* setup_stack_and_mtrrs() determines the stack to use after
@@ -57,7 +41,7 @@ void *setup_stack_and_mtrrs(void)
soc_display_mtrrs();
/* Top of stack needs to be aligned to a 8-byte boundary. */
- top_of_stack = choose_top_of_stack();
+ top_of_stack = romstage_ram_stack();
slot = (void *)top_of_stack;
num_mtrrs = 0;
max_mtrrs = soc_get_variable_mtrr_count(NULL);
diff --git a/src/include/program_loading.h b/src/include/program_loading.h
index 42addb8..f87082d 100644
--- a/src/include/program_loading.h
+++ b/src/include/program_loading.h
@@ -170,6 +170,10 @@ void run_ramstage(void);
/* Called when the stage cache couldn't load ramstage on resume. */
void ramstage_cache_invalid(void);
+/* Determine where stack for ramstage loader is located. */
+unsigned long romstage_ram_stack_maybe_low(int no_cbmem);
+unsigned long romstage_ram_stack(void);
+
/***********************
* PAYLOAD LOADING *
***********************/
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 1028917..0c34b75 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -78,6 +78,7 @@ romstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
ramstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
romstage-$(CONFIG_CACHE_AS_RAM) += ramtest.c
romstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
+romstage-y += romstage_stack.c
romstage-y += stack.c
ramstage-y += rtc.c
diff --git a/src/lib/romstage_stack.c b/src/lib/romstage_stack.c
new file mode 100644
index 0000000..319d354
--- /dev/null
+++ b/src/lib/romstage_stack.c
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google Inc.
+ * Copyright (C) 2015-2016 Intel Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <program_loading.h>
+#include <cbmem.h>
+
+const unsigned long romstage_ram_stack_size = CONFIG_ROMSTAGE_RAM_STACK_SIZE;
+
+/*
+ * Romstage needs quite a bit of stack for decompressing images since the lzma
+ * lib keeps its state on the stack during romstage.
+ */
+unsigned long romstage_ram_stack_maybe_low(int no_cbmem)
+{
+ unsigned long stack_top;
+
+ if (no_cbmem)
+ return CONFIG_RAMTOP;
+
+ /* cbmem_add() does a find() before add(). */
+ stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
+ romstage_ram_stack_size);
+ stack_top += romstage_ram_stack_size;
+ return stack_top;
+}
+
+unsigned long romstage_ram_stack(void)
+{
+ int no_cbmem = IS_ENABLED(CONFIG_LATE_CBMEM_INIT);
+ return romstage_ram_stack_maybe_low(no_cbmem);
+}
diff --git a/src/soc/intel/baytrail/romstage/romstage.c b/src/soc/intel/baytrail/romstage/romstage.c
index a167c90..6cf13bc 100644
--- a/src/soc/intel/baytrail/romstage/romstage.c
+++ b/src/soc/intel/baytrail/romstage/romstage.c
@@ -258,20 +258,6 @@ static inline uint32_t *stack_push(u32 *stack, u32 value)
return stack;
}
-/* Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage. */
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
- const unsigned long romstage_ram_stack_size = 0x5000;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- romstage_ram_stack_size);
- stack_top += romstage_ram_stack_size;
- return stack_top;
-}
-
/* setup_stack_and_mttrs() determines the stack to use after
* cache-as-ram is torn down as well as the MTRR settings to use. */
static void *setup_stack_and_mttrs(void)
@@ -283,7 +269,7 @@ static void *setup_stack_and_mttrs(void)
uint32_t top_of_ram;
/* Top of stack needs to be aligned to a 4-byte boundary. */
- top_of_stack = choose_top_of_stack() & ~3;
+ top_of_stack = romstage_ram_stack() & ~3;
slot = (void *)top_of_stack;
num_mtrrs = 0;
diff --git a/src/soc/intel/broadwell/romstage/stack.c b/src/soc/intel/broadwell/romstage/stack.c
index 6c602a8..87f56ad 100644
--- a/src/soc/intel/broadwell/romstage/stack.c
+++ b/src/soc/intel/broadwell/romstage/stack.c
@@ -21,6 +21,7 @@
#include <cbmem.h>
#include <cpu/x86/mtrr.h>
#include <soc/romstage.h>
+#include <program_loading.h>
static inline uint32_t *stack_push(u32 *stack, u32 value)
{
@@ -29,20 +30,6 @@ static inline uint32_t *stack_push(u32 *stack, u32 value)
return stack;
}
-/* Romstage needs quite a bit of stack for decompressing images since the lzma
- * lib keeps its state on the stack during romstage. */
-static unsigned long choose_top_of_stack(void)
-{
- unsigned long stack_top;
- const unsigned long romstage_ram_stack_size = 0x5000;
-
- /* cbmem_add() does a find() before add(). */
- stack_top = (unsigned long)cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK,
- romstage_ram_stack_size);
- stack_top += romstage_ram_stack_size;
- return stack_top;
-}
-
/* setup_stack_and_mttrs() determines the stack to use after
* cache-as-ram is torn down as well as the MTRR settings to use. */
void *setup_stack_and_mttrs(void)
@@ -54,7 +41,7 @@ void *setup_stack_and_mttrs(void)
uint32_t top_of_ram;
/* Top of stack needs to be aligned to a 4-byte boundary. */
- top_of_stack = choose_top_of_stack() & ~3;
+ top_of_stack = romstage_ram_stack() & ~3;
slot = (void *)top_of_stack;
num_mtrrs = 0;
Shaunak Saha (shaunak.saha(a)intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15460
-gerrit
commit bb446f7568346a6a73c5ca34dd66c01b336227b7
Author: Shaunak Saha <shaunak.saha(a)intel.com>
Date: Mon Jun 27 23:00:15 2016 -0700
soc/apollolake: Expose a function to read pmc bar
This patch exposes a function to read pmc bar.
PMC bar is read in function read_pmc_mmio_bar which
is defined static in file pmutil.c. This patch exposes
that functionality to call it from other files.
BUG=chrome-os-partner:53438
TEST= Read the PMC bar value properly from outside
pmutil file.
Change-Id: I26ee13e6ab95d3a8991c7f8ea4b3856ceb015d10
Signed-off-by: Shaunak Saha <shaunak.saha(a)intel.com>
---
src/soc/intel/apollolake/include/soc/pm.h | 1 +
src/soc/intel/apollolake/pmutil.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/src/soc/intel/apollolake/include/soc/pm.h b/src/soc/intel/apollolake/include/soc/pm.h
index 8838d1c..3da7dd0 100644
--- a/src/soc/intel/apollolake/include/soc/pm.h
+++ b/src/soc/intel/apollolake/include/soc/pm.h
@@ -171,6 +171,7 @@ void disable_pm1_control(uint32_t mask);
void enable_gpe(uint32_t mask);
void disable_gpe(uint32_t mask);
void disable_all_gpe(void);
+uintptr_t get_pmc_mmio_bar(void);
void global_reset_enable(bool enable);
void global_reset_lock(void);
diff --git a/src/soc/intel/apollolake/pmutil.c b/src/soc/intel/apollolake/pmutil.c
index f8b2fdf..f25adfb 100644
--- a/src/soc/intel/apollolake/pmutil.c
+++ b/src/soc/intel/apollolake/pmutil.c
@@ -34,6 +34,11 @@ static uintptr_t read_pmc_mmio_bar(void)
return bar & ~PCI_BASE_ADDRESS_MEM_ATTR_MASK;
}
+uintptr_t get_pmc_mmio_bar(void)
+{
+ return read_pmc_mmio_bar();
+}
+
static void print_num_status_bits(int num_bits, uint32_t status,
const char * const bit_names[])
{