<p>Simon Glass has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/25966">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">drivers/generic/bayhub: Add driver for BayHub BH720<br><br>Add a driver which puts the device into power-saving mode.<br><br>BUG=b:73726008<br>BRANCH=none<br>TEST=boot and see this message:<br>BayHub BH720: Power-saving enabled 110103<br>From linux:<br>$ iotools pci_read32 2 0 0 0x90<br>0x00110103<br><br>Change-Id: Idbfb114f3782c9386ce9b487c3abdb0afbc4a0d9<br>Signed-off-by: Simon Glass <sjg@chromium.org><br>---<br>A src/drivers/generic/bayhub/Kconfig<br>A src/drivers/generic/bayhub/Makefile.inc<br>A src/drivers/generic/bayhub/bh720.c<br>A src/drivers/generic/bayhub/chip.h<br>M src/include/device/pci_ids.h<br>5 files changed, 107 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/66/25966/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/drivers/generic/bayhub/Kconfig b/src/drivers/generic/bayhub/Kconfig</span><br><span>new file mode 100644</span><br><span>index 0000000..882e8f9</span><br><span>--- /dev/null</span><br><span>+++ b/src/drivers/generic/bayhub/Kconfig</span><br><span>@@ -0,0 +1,2 @@</span><br><span style="color: hsl(120, 100%, 40%);">+config DRIVERS_GENERIC_BH720</span><br><span style="color: hsl(120, 100%, 40%);">+        bool</span><br><span>diff --git a/src/drivers/generic/bayhub/Makefile.inc b/src/drivers/generic/bayhub/Makefile.inc</span><br><span>new file mode 100644</span><br><span>index 0000000..3458815</span><br><span>--- /dev/null</span><br><span>+++ b/src/drivers/generic/bayhub/Makefile.inc</span><br><span>@@ -0,0 +1 @@</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-$(CONFIG_DRIVERS_GENERIC_BH720) += bh720.c</span><br><span>diff --git a/src/drivers/generic/bayhub/bh720.c b/src/drivers/generic/bayhub/bh720.c</span><br><span>new file mode 100644</span><br><span>index 0000000..cd9dd25</span><br><span>--- /dev/null</span><br><span>+++ b/src/drivers/generic/bayhub/bh720.c</span><br><span>@@ -0,0 +1,94 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Driver for BayHub Technology BH720 PCI to eMMC 5.0 HS200 bridge</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2018 Google Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <console/console.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <device/device.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <device/path.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <device/pci.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <device/pci_ids.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include "chip.h"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+enum {</span><br><span style="color: hsl(120, 100%, 40%);">+       BH720_PROTECT                   = 0xd0,</span><br><span style="color: hsl(120, 100%, 40%);">+       BH720_PROTECT_OFF               = 0,</span><br><span style="color: hsl(120, 100%, 40%);">+  BH720_PROTECT_ON                = 1,</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        BH720_RTD3_L1                   = 0x3e0,</span><br><span style="color: hsl(120, 100%, 40%);">+      BH720_RTD3_L1_DISABLE_L1        = BIT(28),</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  BH720_LINK_CTRL                 = 0x90,</span><br><span style="color: hsl(120, 100%, 40%);">+       BH720_LINK_CTRL_L0_ENABLE       = BIT(0),</span><br><span style="color: hsl(120, 100%, 40%);">+     BH720_LINK_CTRL_L1_ENABLE       = BIT(1),</span><br><span style="color: hsl(120, 100%, 40%);">+     BH720_LINK_CTRL_CLKREQ          = BIT(8),</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void bh720_init(struct device *dev)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        struct drivers_generic_bayhub_config *config = dev->chip_info;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   pci_dev_init(dev);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  if (config && config->power_saving) {</span><br><span style="color: hsl(120, 100%, 40%);">+              /*</span><br><span style="color: hsl(120, 100%, 40%);">+             * This procedure for enabling power-saving mode is from the</span><br><span style="color: hsl(120, 100%, 40%);">+           * BayHub BIOS Implementation Guideline document.</span><br><span style="color: hsl(120, 100%, 40%);">+              */</span><br><span style="color: hsl(120, 100%, 40%);">+           pci_write_config32(dev, BH720_PROTECT, BH720_PROTECT_OFF);</span><br><span style="color: hsl(120, 100%, 40%);">+            pci_or_config32(dev, BH720_RTD3_L1, BH720_RTD3_L1_DISABLE_L1);</span><br><span style="color: hsl(120, 100%, 40%);">+                pci_or_config32(dev, BH720_LINK_CTRL,</span><br><span style="color: hsl(120, 100%, 40%);">+                         BH720_LINK_CTRL_L0_ENABLE |</span><br><span style="color: hsl(120, 100%, 40%);">+                           BH720_LINK_CTRL_L1_ENABLE);</span><br><span style="color: hsl(120, 100%, 40%);">+           pci_or_config32(dev, BH720_LINK_CTRL, BH720_LINK_CTRL_CLKREQ);</span><br><span style="color: hsl(120, 100%, 40%);">+                pci_write_config32(dev, BH720_PROTECT, BH720_PROTECT_ON);</span><br><span style="color: hsl(120, 100%, 40%);">+             printk(BIOS_INFO, "BayHub BH720: Power-saving enabled (link_ctrl=%#x)\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                  pci_read_config32(dev, BH720_LINK_CTRL));</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct pci_operations pci_ops = {</span><br><span style="color: hsl(120, 100%, 40%);">+      .set_subsystem = pci_dev_set_subsystem,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct device_operations bh720_ops = {</span><br><span style="color: hsl(120, 100%, 40%);">+  .read_resources         = pci_dev_read_resources,</span><br><span style="color: hsl(120, 100%, 40%);">+     .set_resources          = pci_dev_set_resources,</span><br><span style="color: hsl(120, 100%, 40%);">+      .enable_resources       = pci_dev_enable_resources,</span><br><span style="color: hsl(120, 100%, 40%);">+   .ops_pci                = &pci_ops,</span><br><span style="color: hsl(120, 100%, 40%);">+       .init                   = bh720_init,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static const unsigned short pci_device_ids[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ PCI_DEVICE_ID_O2_BH720,</span><br><span style="color: hsl(120, 100%, 40%);">+       0</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static const struct pci_driver bayhub_bh720 __pci_driver = {</span><br><span style="color: hsl(120, 100%, 40%);">+ .ops            = &bh720_ops,</span><br><span style="color: hsl(120, 100%, 40%);">+     .vendor         = PCI_VENDOR_ID_O2,</span><br><span style="color: hsl(120, 100%, 40%);">+   .devices        = pci_device_ids,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void bh720_enable(struct device *dev)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      dev->ops = &bh720_ops;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct chip_operations bayhub_bh720_ops = {</span><br><span style="color: hsl(120, 100%, 40%);">+       CHIP_NAME("BayHub Technology BH720 PCI to eMMC 5.0 HS200 bridge")</span><br><span style="color: hsl(120, 100%, 40%);">+   .enable_dev = bh720_enable,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span>diff --git a/src/drivers/generic/bayhub/chip.h b/src/drivers/generic/bayhub/chip.h</span><br><span>new file mode 100644</span><br><span>index 0000000..a9254b8</span><br><span>--- /dev/null</span><br><span>+++ b/src/drivers/generic/bayhub/chip.h</span><br><span>@@ -0,0 +1,9 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#include <arch/acpi_device.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bayhub BG720 PCI to eMMC bridge</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct drivers_generic_bayhub_config {</span><br><span style="color: hsl(120, 100%, 40%);">+  /* 1 to enable power-saving mode, 0 to disable */</span><br><span style="color: hsl(120, 100%, 40%);">+     int power_saving;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span>diff --git a/src/include/device/pci_ids.h b/src/include/device/pci_ids.h</span><br><span>index 7dc3e00..a0fcdda 100644</span><br><span>--- a/src/include/device/pci_ids.h</span><br><span>+++ b/src/include/device/pci_ids.h</span><br><span>@@ -1688,6 +1688,7 @@</span><br><span> #define PCI_DEVICE_ID_O2_6730             0x673a</span><br><span> #define PCI_DEVICE_ID_O2_6832         0x6832</span><br><span> #define PCI_DEVICE_ID_O2_6836         0x6836</span><br><span style="color: hsl(120, 100%, 40%);">+#define PCI_DEVICE_ID_O2_BH720          0x8620</span><br><span> </span><br><span> #define PCI_VENDOR_ID_3DFX                0x121a</span><br><span> #define PCI_DEVICE_ID_3DFX_VOODOO     0x0001</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/25966">change 25966</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/25966"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Idbfb114f3782c9386ce9b487c3abdb0afbc4a0d9 </div>
<div style="display:none"> Gerrit-Change-Number: 25966 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Simon Glass <sjg@chromium.org> </div>