[coreboot-gerrit] Change in coreboot[master]: WIP: generic: Add generic DMIC driver
Sathyanarayana Nujella (Code Review)
gerrit at coreboot.org
Fri Sep 28 03:01:44 CEST 2018
Hello Jairaj Arava, HARSHAPRIYA N,
I'd like you to do a code review. Please visit
https://review.coreboot.org/28778
to review the following change.
Change subject: WIP: generic: Add generic DMIC driver
......................................................................
WIP: generic: Add generic DMIC driver
DMIC driver in Kernel needs configurations like modeswitch_delay_ms
which is used to adust the minimum clock ON time, etc.
DMIC is not an I2S or I2C slave, so adding as a generic driver.
BUG=b:112888584
TEST=build coreboot and cross check DUT boots
Change-Id: Ic8c8be1aa04e8d35ad4827d81a37ee54c25dfc63
Signed-off-by: Sathyanarayana Nujella <sathyanarayana.nujella at intel.com>
Signed-off-by: Jairaj Arava <jairaj.arava at intel.com>
Signed-off-by: Harsha Priya <harshapriya.n at intel.com>
---
A src/drivers/generic/dmic/Kconfig
A src/drivers/generic/dmic/Makefile.inc
A src/drivers/generic/dmic/chip.h
A src/drivers/generic/dmic/dmic.c
4 files changed, 97 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/78/28778/1
diff --git a/src/drivers/generic/dmic/Kconfig b/src/drivers/generic/dmic/Kconfig
new file mode 100644
index 0000000..5234eeb
--- /dev/null
+++ b/src/drivers/generic/dmic/Kconfig
@@ -0,0 +1,2 @@
+config DRIVERS_GENERIC_DMIC
+ bool
diff --git a/src/drivers/generic/dmic/Makefile.inc b/src/drivers/generic/dmic/Makefile.inc
new file mode 100644
index 0000000..52bb984
--- /dev/null
+++ b/src/drivers/generic/dmic/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_GENERIC_DMIC) += dmic.c
diff --git a/src/drivers/generic/dmic/chip.h b/src/drivers/generic/dmic/chip.h
new file mode 100644
index 0000000..6cb19bd
--- /dev/null
+++ b/src/drivers/generic/dmic/chip.h
@@ -0,0 +1,11 @@
+#ifndef __DRIVERS_GENERIC_DMIC__
+#define __DRIVERS_GENERIC_DMIC__
+
+#include <arch/acpi_device.h>
+
+struct drivers_generic_dmic_config {
+ /* SDMODE Delay */
+ unsigned modeswitch_delay_ms;
+};
+
+#endif
diff --git a/src/drivers/generic/dmic/dmic.c b/src/drivers/generic/dmic/dmic.c
new file mode 100644
index 0000000..e90f475
--- /dev/null
+++ b/src/drivers/generic/dmic/dmic.c
@@ -0,0 +1,83 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2016 Google Inc.
+ *
+ * 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 <arch/acpi_device.h>
+#include <arch/acpigen.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/path.h>
+#include <gpio.h>
+#include <stdint.h>
+#include <string.h>
+#include "chip.h"
+
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+
+#define DMIC_ACPI_NAME "DMIC"
+#define DMIC_ACPI_HID "DMIC"
+
+
+static void dmic_fill_ssdt(struct device *dev)
+{
+ struct drivers_generic_dmic_config *config = dev->chip_info;
+ const char *path;
+ struct acpi_dp *dp;
+ if (!config)
+ return;
+
+ /* Device */
+ acpigen_write_scope(acpi_device_scope(dev));
+ acpigen_write_device(acpi_device_name(dev));
+ acpigen_write_name_string("_HID", DMIC_ACPI_HID);
+ acpigen_write_name_integer("_UID", 0);
+ acpigen_write_name_string("_DDN", dev->chip_ops->name);
+ acpigen_write_STA(ACPI_STATUS_DEVICE_ALL_ON);
+
+ /* _DSD for devicetree properties */
+ /* This points to the first pin in the first gpio entry in _CRS */
+ path = acpi_device_path(dev);
+ dp = acpi_dp_new_table("_DSD");
+ acpi_dp_add_integer(dp, "modeswitch_delay_ms", config->modeswitch_delay_ms);
+ acpi_dp_write(dp);
+
+ acpigen_pop_len(); /* Device */
+ acpigen_pop_len(); /* Scope */
+}
+
+static const char *dmic_acpi_name(const struct device *dev)
+{
+ return DMIC_ACPI_NAME;
+}
+#endif
+
+static struct device_operations dmic_ops = {
+ .read_resources = DEVICE_NOOP,
+ .set_resources = DEVICE_NOOP,
+ .enable_resources = DEVICE_NOOP,
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+ .acpi_name = &dmic_acpi_name,
+ .acpi_fill_ssdt_generator = &dmic_fill_ssdt,
+#endif
+};
+
+static void dmic_enable(struct device *dev)
+{
+ dev->ops = &dmic_ops;
+}
+
+struct chip_operations drivers_generic_dmic_ops = {
+ CHIP_NAME("DMIC")
+ .enable_dev = &dmic_enable
+};
--
To view, visit https://review.coreboot.org/28778
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8c8be1aa04e8d35ad4827d81a37ee54c25dfc63
Gerrit-Change-Number: 28778
Gerrit-PatchSet: 1
Gerrit-Owner: Sathyanarayana Nujella <sathyanarayana.nujella at intel.com>
Gerrit-Reviewer: HARSHAPRIYA N <harshapriya.n at intel.com>
Gerrit-Reviewer: Jairaj Arava <jairaj.arava at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180928/2960ab47/attachment-0001.html>
More information about the coreboot-gerrit
mailing list