<p>Subrata Banik has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23591">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">soc/intel/cannonlake: Implement Sata SOC override as per CNP-PCH<br><br>This patch ensures soc/sata.c correctly translate pci config<br>offset 0x92 bit 0-2.<br><br>Bit 0-2<br>SATA Port x Present (SPDx)<br>0 = Port x is enabled<br>1 = Port x is disabled<br><br>Change-Id: Ide093dafe33b947ba7845cc0b74a975471353e39<br>Signed-off-by: Subrata Banik <subrata.banik@intel.com><br>---<br>M src/soc/intel/cannonlake/Makefile.inc<br>A src/soc/intel/cannonlake/sata.c<br>2 files changed, 59 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/91/23591/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/soc/intel/cannonlake/Makefile.inc b/src/soc/intel/cannonlake/Makefile.inc</span><br><span>index 47f06aa..76f31b2 100644</span><br><span>--- a/src/soc/intel/cannonlake/Makefile.inc</span><br><span>+++ b/src/soc/intel/cannonlake/Makefile.inc</span><br><span>@@ -47,6 +47,7 @@</span><br><span> ramstage-y += pmc.c</span><br><span> ramstage-y += pmutil.c</span><br><span> ramstage-$(CONFIG_PLATFORM_USES_FSP2_0) += reset.c</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-$(CONFIG_SOC_INTEL_COMMON_BLOCK_SATA) += sata.c</span><br><span> ramstage-y += smmrelocate.c</span><br><span> ramstage-y += spi.c</span><br><span> ramstage-y += systemagent.c</span><br><span>diff --git a/src/soc/intel/cannonlake/sata.c b/src/soc/intel/cannonlake/sata.c</span><br><span>new file mode 100644</span><br><span>index 0000000..324a0d9</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/intel/cannonlake/sata.c</span><br><span>@@ -0,0 +1,58 @@</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 (C) 2018 Intel Corporation.</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 <device/device.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_def.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 <intelblocks/sata.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/pci_devs.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SATA_ABAR_PORT_IMPLEMENTED      0x0c</span><br><span style="color: hsl(120, 100%, 40%);">+#define SATA_PCI_CFG_PORT_CTL_STS 0x92</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static void *get_ahci_bar(device_t dev)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    uintptr_t bar;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      bar = pci_read_config32(dev, PCI_BASE_ADDRESS_5);</span><br><span style="color: hsl(120, 100%, 40%);">+     return (void *)(bar & ~PCI_BASE_ADDRESS_MEM_ATTR_MASK);</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%);">+ * SATA Port control and Status. By default, the SATA ports are set (by HW)</span><br><span style="color: hsl(120, 100%, 40%);">+ * to the disabled state (e.g. bits[3:0] == '0') as a result of an initial</span><br><span style="color: hsl(120, 100%, 40%);">+ * power on reset. When enabled by software as per SATA port mapping,</span><br><span style="color: hsl(120, 100%, 40%);">+ * the ports can transition between the on, partial and slumber states</span><br><span style="color: hsl(120, 100%, 40%);">+ * and can detect devices. When disabled, the port is in the off state and</span><br><span style="color: hsl(120, 100%, 40%);">+ * can't detect any devices.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void sata_soc_final(device_t dev)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ void *ahcibar = get_ahci_bar(dev);</span><br><span style="color: hsl(120, 100%, 40%);">+    u32 port_impl, temp;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Set Bus Master */</span><br><span style="color: hsl(120, 100%, 40%);">+  temp = pci_read_config32(dev, PCI_COMMAND);</span><br><span style="color: hsl(120, 100%, 40%);">+   pci_write_config32(dev, PCI_COMMAND, temp | PCI_COMMAND_MASTER);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    /* Read Ports Implemented (GHC_PI) */</span><br><span style="color: hsl(120, 100%, 40%);">+ port_impl = ~read32(ahcibar + SATA_ABAR_PORT_IMPLEMENTED) & 0x07;</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Port enable */</span><br><span style="color: hsl(120, 100%, 40%);">+     temp = pci_read_config32(dev, SATA_PCI_CFG_PORT_CTL_STS);</span><br><span style="color: hsl(120, 100%, 40%);">+     temp |= port_impl;</span><br><span style="color: hsl(120, 100%, 40%);">+    pci_write_config32(dev, SATA_PCI_CFG_PORT_CTL_STS, temp);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23591">change 23591</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/23591"/><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: Ide093dafe33b947ba7845cc0b74a975471353e39 </div>
<div style="display:none"> Gerrit-Change-Number: 23591 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Subrata Banik <subrata.banik@intel.com> </div>