Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10412
-gerrit
commit b158222decea62afcaf6b58db1e153d4cddf0e0c
Author: Patrick Georgi <patrick(a)georgi-clan.de>
Date: Thu Jun 4 00:09:12 2015 +0200
crossgcc: Build gmp compatibly
Normally gmp only links in the assembler routines for the system it's built
on. Worse, its configure script determines the CPU and select -mtune flags for
the compiler.
That's neat when you're building for the current machine, but a real problem
when building portable binaries.
Change-Id: I72d20627270baa082cd02ebb4c9a09cd23f30f8c
Signed-off-by: Patrick Georgi <patrick(a)georgi-clan.de>
---
util/crossgcc/buildgcc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 15bcd92..a1b596e 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -22,8 +22,8 @@
cd `dirname $0`
-CROSSGCC_DATE="March 8th, 2015"
-CROSSGCC_VERSION="1.27"
+CROSSGCC_DATE="June 3th, 2015"
+CROSSGCC_VERSION="1.28"
# default settings
TARGETDIR=`pwd`/xgcc
@@ -418,7 +418,7 @@ printf "Building GMP ${GMP_VERSION} ... "
(
cd ${BUILDDIRPREFIX}-gmp
rm -f .failed
- CC="$CC" ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
+ CC="$CC" CFLAGS="-Os" ../${GMP_DIR}/configure --disable-shared --enable-fat --prefix=$TARGETDIR $OPTIONS \
|| touch .failed
$MAKE $JOBS || touch .failed
$MAKE install DESTDIR=$DESTDIR || touch .failed
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10409
-gerrit
commit 7702b799664dcda9fe51093f221408b57a633449
Author: Patrick Georgi <pgeorgi(a)google.com>
Date: Thu Mar 26 15:17:45 2015 +0100
Remove address from GPLv2 headers
Follow up for commit b890a12, some contributions brought
back a number of FSF addresses, so get rid of them again.
Change-Id: Idcd059f05523916f726b94931c2487ab028b7d72
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
---
src/cpu/intel/fsp_model_206ax/smmrelocate.c | 2 +-
src/cpu/intel/model_2065x/smmrelocate.c | 2 +-
src/cpu/intel/model_206ax/smmrelocate.c | 2 +-
src/drivers/intel/gma/igd.asl | 3 +--
4 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/cpu/intel/fsp_model_206ax/smmrelocate.c b/src/cpu/intel/fsp_model_206ax/smmrelocate.c
index c2f6712..6b954d0 100644
--- a/src/cpu/intel/fsp_model_206ax/smmrelocate.c
+++ b/src/cpu/intel/fsp_model_206ax/smmrelocate.c
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc.
*/
#include <types.h>
diff --git a/src/cpu/intel/model_2065x/smmrelocate.c b/src/cpu/intel/model_2065x/smmrelocate.c
index 94811c3..e357aa5 100644
--- a/src/cpu/intel/model_2065x/smmrelocate.c
+++ b/src/cpu/intel/model_2065x/smmrelocate.c
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc.
*/
#define __SIMPLE_DEVICE__
diff --git a/src/cpu/intel/model_206ax/smmrelocate.c b/src/cpu/intel/model_206ax/smmrelocate.c
index 587fee9..461286f 100644
--- a/src/cpu/intel/model_206ax/smmrelocate.c
+++ b/src/cpu/intel/model_206ax/smmrelocate.c
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * Foundation, Inc.
*/
#include <types.h>
diff --git a/src/drivers/intel/gma/igd.asl b/src/drivers/intel/gma/igd.asl
index 31e8fec..88cc2cd 100644
--- a/src/drivers/intel/gma/igd.asl
+++ b/src/drivers/intel/gma/igd.asl
@@ -15,8 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- * MA 02110-1301 USA
+ * Foundation, Inc.
*/
External(LCD0, DeviceObj)
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10394
-gerrit
commit 494665a31627b3f6f64539cea559f6c8d27d5313
Author: Julius Werner <jwerner(a)chromium.org>
Date: Fri May 22 16:26:40 2015 -0700
lib: Unify log2() and related functions
This patch adds a few bit counting functions that are commonly needed
for certain register calculations. We previously had a log2()
implementation already, but it was awkwardly split between some C code
that's only available in ramstage and an optimized x86-specific
implementation in pre-RAM that prevented other archs from pulling it
into earlier stages.
Using __builtin_clz() as the baseline allows GCC to inline optimized
assembly for most archs (including CLZ on ARM/ARM64 and BSR on x86), and
to perform constant-folding if possible. What was previously named log2f
on pre-RAM x86 is now ffs, since that's the standard name for that
operation and I honestly don't have the slightest idea how it could've
ever ended up being called log2f (which in POSIX is 'binary(2) LOGarithm
with Float result, whereas the Find First Set operation has no direct
correlation to logarithms that I know of). Make ffs result 0-based
instead of the POSIX standard's 1-based since that is consistent with
clz, log2 and the former log2f, and generally closer to what you want
for most applications (a value that can directly be used as a shift to
reach the found bit). Call it __ffs() instead of ffs() to avoid problems
when importing code, since that's what Linux uses for the 0-based
operation.
CQ-DEPEND=CL:273023
BRANCH=None
BUG=None
TEST=Built on Big, Falco, Jerry, Oak and Urara. Compared old and new
log2() and __ffs() results on Falco for a bunch of test values.
Change-Id: I599209b342059e17b3130621edb6b6bbeae26876
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Original-Commit-Id: 3701a16ae944ecff9c54fa9a50d28015690fcb2f
Original-Change-Id: I60f7cf893792508188fa04d088401a8bca4b4af6
Original-Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/273008
Original-Reviewed-by: Patrick Georgi <pgeorgi(a)chromium.org>
---
payloads/libpayload/include/libpayload.h | 7 +++
payloads/libpayload/include/strings.h | 35 --------------
payloads/libpayload/libc/Makefile.inc | 4 +-
payloads/libpayload/libc/libgcc.c | 68 +++++++++++++++++++++++++++
payloads/libpayload/libc/strings.c | 42 -----------------
src/arch/arm/include/utils.h | 55 ----------------------
src/arch/x86/include/arch/io.h | 8 ++--
src/include/lib.h | 18 ++++---
src/lib/Makefile.inc | 6 +--
src/lib/clog2.c | 37 ---------------
src/lib/libgcc.c | 56 ++++++++++++++++++++++
src/northbridge/amd/amdk8/coherent_ht.c | 1 +
src/northbridge/amd/amdk8/raminit.c | 5 +-
src/northbridge/amd/amdk8/raminit_f.c | 1 +
src/northbridge/amd/amdk8/raminit_test.c | 1 +
src/northbridge/intel/e7501/raminit.c | 1 +
src/northbridge/intel/i3100/raminit_ep80579.c | 1 +
src/northbridge/intel/i855/raminit.c | 1 +
src/northbridge/intel/i945/raminit.c | 1 +
src/soc/rockchip/rk3288/clock.c | 17 +------
src/southbridge/via/k8t890/traf_ctrl.c | 3 +-
21 files changed, 163 insertions(+), 205 deletions(-)
diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h
index 781a41d..c3ca123 100644
--- a/payloads/libpayload/include/libpayload.h
+++ b/payloads/libpayload/include/libpayload.h
@@ -311,6 +311,13 @@ u8 bin2hex(u8 b);
u8 hex2bin(u8 h);
void hexdump(const void *memory, size_t length);
void fatal(const char *msg) __attribute__ ((noreturn));
+
+/* Count Leading Zeroes: clz(0) == 32, clz(0xf) == 28, clz(1 << 31) == 0 */
+static inline int clz(u32 x) { return x ? __builtin_clz(x) : sizeof(x) * 8; }
+/* Integer binary logarithm (rounding down): log2(0) == -1, log2(5) == 2 */
+static inline int log2(u32 x) { return sizeof(x) * 8 - clz(x) - 1; }
+/* Find First Set: __ffs(0xf) == 0, __ffs(0) == -1, __ffs(1 << 31) == 31 */
+static inline int __ffs(u32 x) { return log2(x & (u32)(-(s32)x)); }
/** @} */
diff --git a/payloads/libpayload/include/strings.h b/payloads/libpayload/include/strings.h
deleted file mode 100644
index 5beddc6..0000000
--- a/payloads/libpayload/include/strings.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2011 secunet Security Networks AG
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _STRINGS_H
-#define _STRINGS_H
-
-int ffs(int i);
-
-#endif
diff --git a/payloads/libpayload/libc/Makefile.inc b/payloads/libpayload/libc/Makefile.inc
index b4f75a6..272cda9 100644
--- a/payloads/libpayload/libc/Makefile.inc
+++ b/payloads/libpayload/libc/Makefile.inc
@@ -29,10 +29,10 @@
##
libc-$(CONFIG_LP_LIBC) += malloc.c printf.c console.c string.c
-libc-$(CONFIG_LP_LIBC) += memory.c ctype.c ipchecksum.c lib.c
+libc-$(CONFIG_LP_LIBC) += memory.c ctype.c ipchecksum.c lib.c libgcc.c
libc-$(CONFIG_LP_LIBC) += rand.c time.c exec.c
libc-$(CONFIG_LP_LIBC) += readline.c getopt_long.c sysinfo.c
-libc-$(CONFIG_LP_LIBC) += args.c strings.c
+libc-$(CONFIG_LP_LIBC) += args.c
libc-$(CONFIG_LP_LIBC) += strlcpy.c
libc-$(CONFIG_LP_LIBC) += qsort.c
libc-$(CONFIG_LP_LIBC) += hexdump.c
diff --git a/payloads/libpayload/libc/libgcc.c b/payloads/libpayload/libc/libgcc.c
new file mode 100644
index 0000000..86698d8
--- /dev/null
+++ b/payloads/libpayload/libc/libgcc.c
@@ -0,0 +1,68 @@
+/*
+ * This file is part of the libpayload project.
+ *
+ * Copyright 2015 Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <libpayload.h>
+
+/*
+ * Provide platform-independent backend implementation for __builtin_clz() in
+ * <libpayload.h> in case GCC does not have an assembly version for this arch.
+ */
+
+int __clzsi2(u32 a);
+int __clzsi2(u32 a)
+{
+ static const u8 four_bit_table[] = {
+ [0x0] = 4, [0x1] = 3, [0x2] = 2, [0x3] = 2,
+ [0x4] = 1, [0x5] = 1, [0x6] = 1, [0x7] = 1,
+ [0x8] = 0, [0x9] = 0, [0xa] = 0, [0xb] = 0,
+ [0xc] = 0, [0xd] = 0, [0xe] = 0, [0xf] = 0,
+ };
+ int r = 0;
+
+ if (!(a & (0xffff << 16))) {
+ r += 16;
+ a <<= 16;
+ }
+
+ if (!(a & (0xff << 24))) {
+ r += 8;
+ a <<= 8;
+ }
+
+ if (!(a & (0xf << 28))) {
+ r += 4;
+ a <<= 4;
+ }
+
+ return r + four_bit_table[a >> 28];
+}
diff --git a/payloads/libpayload/libc/strings.c b/payloads/libpayload/libc/strings.c
deleted file mode 100644
index 465ae4f..0000000
--- a/payloads/libpayload/libc/strings.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2011 secunet Security Networks AG
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <strings.h>
-
-int ffs(int i)
-{
- int count = 1;
- if (i == 0) return 0;
-
- while ((i & 1) != 1) {
- i>>=1;
- count++;
- }
- return count;
-}
diff --git a/src/arch/arm/include/utils.h b/src/arch/arm/include/utils.h
deleted file mode 100644
index 2482c6b..0000000
--- a/src/arch/arm/include/utils.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * (C) Copyright 2010
- * Texas Instruments, <www.ti.com>
- * Aneesh V <aneesh(a)ti.com>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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; either version 2 of
- * the License, or (at your option) any later version.
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc.
- */
-#ifndef _UTILS_H_
-#define _UTILS_H_
-
-static inline s32 log_2_n_round_up(u32 n)
-{
- s32 log2n = -1;
- u32 temp = n;
-
- while (temp) {
- log2n++;
- temp >>= 1;
- }
-
- if (n & (n - 1))
- return log2n + 1; /* not power of 2 - round up */
- else
- return log2n; /* power of 2 */
-}
-
-static inline s32 log_2_n_round_down(u32 n)
-{
- s32 log2n = -1;
- u32 temp = n;
-
- while (temp) {
- log2n++;
- temp >>= 1;
- }
-
- return log2n;
-}
-
-#endif
diff --git a/src/arch/x86/include/arch/io.h b/src/arch/x86/include/arch/io.h
index ce94773..5c85019 100644
--- a/src/arch/x86/include/arch/io.h
+++ b/src/arch/x86/include/arch/io.h
@@ -174,8 +174,8 @@ static inline __attribute__((always_inline)) void write32(volatile void *addr, u
}
/* Conflicts with definition in lib.h */
-#if defined(__ROMCC__) || defined(__SMM__)
-static inline int log2(int value)
+#if defined(__ROMCC__)
+static inline int log2(u32 value)
{
unsigned int r = 0;
__asm__ volatile (
@@ -187,10 +187,8 @@ static inline int log2(int value)
return r;
}
-#endif
-#if defined(__PRE_RAM__) || defined(__SMM__)
-static inline int log2f(int value)
+static inline int __ffs(u32 value)
{
unsigned int r = 0;
__asm__ volatile (
diff --git a/src/include/lib.h b/src/include/lib.h
index 7ad33dd..b81b1b1 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -24,12 +24,6 @@
#include <stdint.h>
#include <types.h>
-#if !defined(__ROMCC__) /* Conflicts with inline function in arch/io.h */
-/* Defined in src/lib/clog2.c */
-unsigned long log2(unsigned long x);
-#endif
-unsigned long log2_ceil(unsigned long x);
-
/* Defined in src/lib/lzma.c */
unsigned long ulzma(unsigned char *src, unsigned char *dst);
@@ -49,4 +43,16 @@ int checkstack(void *top_of_stack, int core);
void hexdump(const void *memory, size_t length);
void hexdump32(char LEVEL, const void *d, size_t len);
+#if !defined(__ROMCC__)
+/* Count Leading Zeroes: clz(0) == 32, clz(0xf) == 28, clz(1 << 31) == 0 */
+static inline int clz(u32 x) { return x ? __builtin_clz(x) : sizeof(x) * 8; }
+/* Integer binary logarithm (rounding down): log2(0) == -1, log2(5) == 2 */
+static inline int log2(u32 x) { return sizeof(x) * 8 - clz(x) - 1; }
+/* Find First Set: __ffs(1) == 0, __ffs(0) == -1, __ffs(1<<31) == 31 */
+static inline int __ffs(u32 x) { return log2(x & (u32)(-(s32)x)); }
+#endif
+
+/* Integer binary logarithm (rounding up): log2_ceil(0) == -1, log2(5) == 3 */
+static inline int log2_ceil(u32 x) { return (x == 0) ? -1 : log2(x * 2 - 1); }
+
#endif /* __LIB_H__ */
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 557cd66..76c8fd3 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -25,7 +25,7 @@ bootblock-y += cbfs.c
bootblock-y += cbfs_boot_props.c
bootblock-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c
bootblock-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c
-
+bootblock-y += libgcc.c
bootblock-$(CONFIG_GENERIC_UDELAY) += timer.c
bootblock-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
@@ -45,6 +45,7 @@ verstage-y += cbfs.c
verstage-y += halt.c
verstage-y += fmap.c
verstage-y += cbfs_boot_props.c
+verstage-y += libgcc.c
verstage-y += memcmp.c
verstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
verstage-y += region.c
@@ -77,6 +78,7 @@ romstage-y += cbfs.c
romstage-y += cbfs_boot_props.c
romstage-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c
romstage-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c lzmadecode.c
+romstage-y += libgcc.c
romstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
ramstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
romstage-$(CONFIG_CACHE_AS_RAM) += ramtest.c
@@ -115,8 +117,6 @@ ramstage-y += cbfs_boot_props.c
ramstage-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c
ramstage-y += lzma.c lzmadecode.c
ramstage-y += stack.c
-ramstage-y += clog2.c
-romstage-y += clog2.c
ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c
ramstage-$(CONFIG_TRACE) += trace.c
diff --git a/src/lib/clog2.c b/src/lib/clog2.c
deleted file mode 100644
index 5e0d591..0000000
--- a/src/lib/clog2.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <console/console.h>
-#include <lib.h>
-
-/* Assume 8 bits per byte */
-#define CHAR_BIT 8
-
-unsigned long log2(unsigned long x)
-{
- /* assume 8 bits per byte. */
- unsigned long pow = sizeof(x) * CHAR_BIT - 1ULL;
- unsigned long i = 1ULL << pow;
-
- if (!x) {
- printk(BIOS_WARNING, "%s called with invalid parameter of 0\n",
- __func__);
- return -1;
- }
-
- for (; i > x; i >>= 1, pow--);
-
- return pow;
-}
-
-unsigned long log2_ceil(unsigned long x)
-{
- unsigned long pow;
-
- if (!x)
- return -1;
-
- pow = log2(x);
-
- if (x > (1ULL << pow))
- pow++;
-
- return pow;
-}
diff --git a/src/lib/libgcc.c b/src/lib/libgcc.c
new file mode 100644
index 0000000..14685be
--- /dev/null
+++ b/src/lib/libgcc.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2015 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#include <types.h>
+
+/*
+ * Provide platform-independent backend implementation for __builtin_clz() in
+ * <lib.h> in case GCC does not have an assembly version for this arch.
+ */
+
+#if !IS_ENABLED(CONFIG_ARCH_X86) /* work around lack of --gc-sections on x86 */
+int __clzsi2(u32 a);
+int __clzsi2(u32 a)
+{
+ static const u8 four_bit_table[] = {
+ [0x0] = 4, [0x1] = 3, [0x2] = 2, [0x3] = 2,
+ [0x4] = 1, [0x5] = 1, [0x6] = 1, [0x7] = 1,
+ [0x8] = 0, [0x9] = 0, [0xa] = 0, [0xb] = 0,
+ [0xc] = 0, [0xd] = 0, [0xe] = 0, [0xf] = 0,
+ };
+ int r = 0;
+
+ if (!(a & (0xffff << 16))) {
+ r += 16;
+ a <<= 16;
+ }
+
+ if (!(a & (0xff << 24))) {
+ r += 8;
+ a <<= 8;
+ }
+
+ if (!(a & (0xf << 28))) {
+ r += 4;
+ a <<= 4;
+ }
+
+ return r + four_bit_table[a >> 28];
+}
+#endif
diff --git a/src/northbridge/amd/amdk8/coherent_ht.c b/src/northbridge/amd/amdk8/coherent_ht.c
index a8d8700..6554e07 100644
--- a/src/northbridge/amd/amdk8/coherent_ht.c
+++ b/src/northbridge/amd/amdk8/coherent_ht.c
@@ -66,6 +66,7 @@
#include <device/pci_def.h>
#include <device/pci_ids.h>
#include <device/hypertransport_def.h>
+#include <lib.h>
#include <stdlib.h>
#include <arch/io.h>
#include <pc80/mc146818rtc.h>
diff --git a/src/northbridge/amd/amdk8/raminit.c b/src/northbridge/amd/amdk8/raminit.c
index 4213cfb..c58abb1 100644
--- a/src/northbridge/amd/amdk8/raminit.c
+++ b/src/northbridge/amd/amdk8/raminit.c
@@ -7,6 +7,7 @@
#include <cpu/x86/cache.h>
#include <cpu/x86/mtrr.h>
#include <cpu/amd/mtrr.h>
+#include <lib.h>
#include <stdlib.h>
#include <arch/acpi.h>
#include <reset.h>
@@ -1655,7 +1656,7 @@ static struct spd_set_memclk_result spd_set_memclk(const struct mem_controller *
/* if the next lower frequency gives a CL at least one whole cycle
* shorter, select that (see end of BKDG 4.1.1.1) */
if (freq < sizeof(cl_at_freq)-1 && cl_at_freq[freq+1] &&
- log2f(cl_at_freq[freq]) - log2f(cl_at_freq[freq+1]) >= 2)
+ __ffs(cl_at_freq[freq]) - __ffs(cl_at_freq[freq+1]) >= 2)
freq++;
if (freq == sizeof(cl_at_freq))
@@ -1690,7 +1691,7 @@ static struct spd_set_memclk_result spd_set_memclk(const struct mem_controller *
/* Update DRAM Timing Low with our selected cas latency */
value = pci_read_config32(ctrl->f2, DRAM_TIMING_LOW);
value &= ~(DTL_TCL_MASK << DTL_TCL_SHIFT);
- value |= latencies[log2f(cl_at_freq[freq]) - 2] << DTL_TCL_SHIFT;
+ value |= latencies[__ffs(cl_at_freq[freq]) - 2] << DTL_TCL_SHIFT;
pci_write_config32(ctrl->f2, DRAM_TIMING_LOW, value);
result.dimm_mask = dimm_mask;
diff --git a/src/northbridge/amd/amdk8/raminit_f.c b/src/northbridge/amd/amdk8/raminit_f.c
index 1469684..1c1a6ea 100644
--- a/src/northbridge/amd/amdk8/raminit_f.c
+++ b/src/northbridge/amd/amdk8/raminit_f.c
@@ -25,6 +25,7 @@
#include <cpu/x86/tsc.h>
#include <cpu/amd/mtrr.h>
+#include <lib.h>
#include <stdlib.h>
#include <arch/acpi.h>
#include "raminit.h"
diff --git a/src/northbridge/amd/amdk8/raminit_test.c b/src/northbridge/amd/amdk8/raminit_test.c
index be46f27..87e281d 100644
--- a/src/northbridge/amd/amdk8/raminit_test.c
+++ b/src/northbridge/amd/amdk8/raminit_test.c
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <limits.h>
+#include <lib.h>
#include <stdint.h>
#include <string.h>
#include <setjmp.h>
diff --git a/src/northbridge/intel/e7501/raminit.c b/src/northbridge/intel/e7501/raminit.c
index f4fc9a8..93a3a5b 100644
--- a/src/northbridge/intel/e7501/raminit.c
+++ b/src/northbridge/intel/e7501/raminit.c
@@ -12,6 +12,7 @@
/* converted to C 6/2004 yhlu */
#include <assert.h>
+#include <lib.h>
#include <spd.h>
#include <sdram_mode.h>
#include <stdlib.h>
diff --git a/src/northbridge/intel/i3100/raminit_ep80579.c b/src/northbridge/intel/i3100/raminit_ep80579.c
index 85660e9..ee8c4fd 100644
--- a/src/northbridge/intel/i3100/raminit_ep80579.c
+++ b/src/northbridge/intel/i3100/raminit_ep80579.c
@@ -22,6 +22,7 @@
#include <cpu/x86/mtrr.h>
#include <cpu/x86/cache.h>
#include <cpu/intel/speedstep.h>
+#include <lib.h>
#include "raminit_ep80579.h"
#include "ep80579.h"
diff --git a/src/northbridge/intel/i855/raminit.c b/src/northbridge/intel/i855/raminit.c
index 81dcbb5..a43f5be 100644
--- a/src/northbridge/intel/i855/raminit.c
+++ b/src/northbridge/intel/i855/raminit.c
@@ -19,6 +19,7 @@
*/
#include <assert.h>
+#include <lib.h>
#include <spd.h>
#include <sdram_mode.h>
#include <stdlib.h>
diff --git a/src/northbridge/intel/i945/raminit.c b/src/northbridge/intel/i945/raminit.c
index a3be680..7bd6240 100644
--- a/src/northbridge/intel/i945/raminit.c
+++ b/src/northbridge/intel/i945/raminit.c
@@ -20,6 +20,7 @@
#include <console/console.h>
#include <cpu/x86/mtrr.h>
#include <cpu/x86/cache.h>
+#include <lib.h>
#include <pc80/mc146818rtc.h>
#include <spd.h>
#include <string.h>
diff --git a/src/soc/rockchip/rk3288/clock.c b/src/soc/rockchip/rk3288/clock.c
index 2c56376..a2e8d88 100644
--- a/src/soc/rockchip/rk3288/clock.c
+++ b/src/soc/rockchip/rk3288/clock.c
@@ -21,6 +21,7 @@
#include <assert.h>
#include <console/console.h>
#include <delay.h>
+#include <lib.h>
#include <soc/addressmap.h>
#include <soc/clock.h>
#include <soc/grf.h>
@@ -236,22 +237,6 @@ static int rkclk_set_pll(u32 *pll_con, const struct pll_div *div)
return 0;
}
-/*
- TODO:
- it should be replaced by lib.h function
- 'unsigned long log2(unsigned long x)'
-*/
-static unsigned int log2(unsigned int value)
-{
- unsigned int div = 0;
-
- while (value != 1) {
- div++;
- value = ALIGN_UP(value, 2) / 2;
- }
- return div;
-}
-
void rkclk_init(void)
{
u32 aclk_div;
diff --git a/src/southbridge/via/k8t890/traf_ctrl.c b/src/southbridge/via/k8t890/traf_ctrl.c
index b4620da..24c1e65 100644
--- a/src/southbridge/via/k8t890/traf_ctrl.c
+++ b/src/southbridge/via/k8t890/traf_ctrl.c
@@ -24,10 +24,9 @@
#include <arch/acpi.h>
#include <arch/acpigen.h>
#include <cpu/amd/powernow.h>
+#include <lib.h>
#include "k8t890.h"
-extern unsigned long log2(unsigned long x);
-
static void mmconfig_set_resources(device_t dev)
{
struct resource *resource;
the following patch was just integrated into master:
commit d42ee150a0330f22986ad7237c9e70cebd9d995c
Author: Yidi Lin <yidi.lin(a)mediatek.com>
Date: Thu May 7 15:36:04 2015 +0800
libpayload: usb: Support MTK xHCI host controller
1. There is a mis-understanding to calculate the value of TD Size
in Normal TRB. For MTK's xHCI controller it defines a number of
packets that remain to be transferred for a TD after processing
all Max packets in all previous TRBs, that means don't include the
current TRB's.
2. To minimize the scheduling effort for synchronous endpoints in xHC,
the MTK architecture defines some extra SW scheduling parameters for
HW. According to these parameters provided by SW, the xHC can easily
decide whether a synchronous endpoint should be scheduled in a specific
uFrame. The extra SW scheduling parameters are put into reserved DWs
in Slot and Endpoint Context. But in coreboot synchronous transfer can
be ignored, so only two fields are set to a default value 1 to support
bulk and interrupt transfers, and others are set to zero.
3. For control transfer, it is better to read back doorbell register or add
a memory barrier after ringing the doorbell to flush posted write.
Otherwise the first command will be aborted on MTK's xHCI controller.
4. Before send commands to a port, the Port Power in PORTSC register should
be set to 1 on MTK's xHCI so a hook function of enable_port in
generic_hub_ops_t struct is provided.
Change-Id: Ie8878b50c048907ebf939b3f6657535a54877fde
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Original-Commit-Id: 738609c11f16264c6e6429d478b2040cb391fe41
Original-Change-Id: Id9156892699e2e42a166c77fbf6690049abe953b
Original-Signed-off-by: Chunfeng Yun <chunfeng.yun(a)mediatek.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/265362
Original-Reviewed-by: Julius Werner <jwerner(a)chromium.org>
Original-Commit-Queue: Yidi Lin <yidi.lin(a)mediatek.com>
Original-Tested-by: Yidi Lin <yidi.lin(a)mediatek.com>
Reviewed-on: http://review.coreboot.org/10389
Reviewed-by: Patrick Georgi <pgeorgi(a)google.com>
Tested-by: build bot (Jenkins)
See http://review.coreboot.org/10389 for details.
-gerrit
the following patch was just integrated into master:
commit 08e30134900c1c8f169668e8b5b2b90254996c9a
Author: Chunfeng Yun <chunfeng.yun(a)mediatek.com>
Date: Thu May 7 15:28:19 2015 +0800
libpayload: usb: Max packet size of SuperSpeed control EPs should be 512.
BRANCH=none
BUG=none
TEST=none
Change-Id: I563ef65db900d7675aeb5b9123dfb5a8980bf964
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Original-Commit-Id: 9764115d7bcce1d6423464bd81b58211ac728409
Original-Change-Id: Ibac8d3b9e28b4a563079f288901abcfbff6913ee
Original-Signed-off-by: Chunfeng Yun <chunfeng.yun(a)mediatek.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/269863
Original-Reviewed-by: Julius Werner <jwerner(a)chromium.org>
Original-Reviewed-by: Patrick Georgi <pgeorgi(a)chromium.org>
Original-Commit-Queue: Yidi Lin <yidi.lin(a)mediatek.com>
Original-Tested-by: Yidi Lin <yidi.lin(a)mediatek.com>
Reviewed-on: http://review.coreboot.org/10388
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer(a)coreboot.org>
See http://review.coreboot.org/10388 for details.
-gerrit
Patrick Georgi (pgeorgi(a)google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10389
-gerrit
commit 85873b9702026e816b77f0077220bfc70382e1a3
Author: Yidi Lin <yidi.lin(a)mediatek.com>
Date: Thu May 7 15:36:04 2015 +0800
libpayload: usb: Support MTK xHCI host controller
1. There is a mis-understanding to calculate the value of TD Size
in Normal TRB. For MTK's xHCI controller it defines a number of
packets that remain to be transferred for a TD after processing
all Max packets in all previous TRBs, that means don't include the
current TRB's.
2. To minimize the scheduling effort for synchronous endpoints in xHC,
the MTK architecture defines some extra SW scheduling parameters for
HW. According to these parameters provided by SW, the xHC can easily
decide whether a synchronous endpoint should be scheduled in a specific
uFrame. The extra SW scheduling parameters are put into reserved DWs
in Slot and Endpoint Context. But in coreboot synchronous transfer can
be ignored, so only two fields are set to a default value 1 to support
bulk and interrupt transfers, and others are set to zero.
3. For control transfer, it is better to read back doorbell register or add
a memory barrier after ringing the doorbell to flush posted write.
Otherwise the first command will be aborted on MTK's xHCI controller.
4. Before send commands to a port, the Port Power in PORTSC register should
be set to 1 on MTK's xHCI so a hook function of enable_port in
generic_hub_ops_t struct is provided.
Change-Id: Ie8878b50c048907ebf939b3f6657535a54877fde
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Original-Commit-Id: 738609c11f16264c6e6429d478b2040cb391fe41
Original-Change-Id: Id9156892699e2e42a166c77fbf6690049abe953b
Original-Signed-off-by: Chunfeng Yun <chunfeng.yun(a)mediatek.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/265362
Original-Reviewed-by: Julius Werner <jwerner(a)chromium.org>
Original-Commit-Queue: Yidi Lin <yidi.lin(a)mediatek.com>
Original-Tested-by: Yidi Lin <yidi.lin(a)mediatek.com>
---
payloads/libpayload/Config.in | 6 ++++++
payloads/libpayload/drivers/usb/xhci.c | 17 ++++++++++++++++-
payloads/libpayload/drivers/usb/xhci_commands.c | 2 ++
payloads/libpayload/drivers/usb/xhci_devconf.c | 10 ++++++++++
payloads/libpayload/drivers/usb/xhci_private.h | 9 +++++++++
payloads/libpayload/drivers/usb/xhci_rh.c | 20 +++++++++++++++++++-
6 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/payloads/libpayload/Config.in b/payloads/libpayload/Config.in
index 4d48761..92c89ab 100644
--- a/payloads/libpayload/Config.in
+++ b/payloads/libpayload/Config.in
@@ -495,6 +495,12 @@ config USB_XHCI
Select this option if you want to use USB 3.0
NOTE: This option is not (fully) implemented yet
+config USB_XHCI_MTK_QUIRK
+ bool "Support for USB xHCI controllers on MTK SoC"
+ depends on USB_XHCI
+ help
+ Select this option if you want to use USB 3.0 on MTK platform.
+
config USB_DWC2
bool "Support for USB DesignWare HCD controllers"
depends on USB && !USB_HID
diff --git a/payloads/libpayload/drivers/usb/xhci.c b/payloads/libpayload/drivers/usb/xhci.c
index 26dcdbe..89930e0 100644
--- a/payloads/libpayload/drivers/usb/xhci.c
+++ b/payloads/libpayload/drivers/usb/xhci.c
@@ -370,6 +370,8 @@ xhci_reinit (hci_t *controller)
xhci->ev_ring_table[0].seg_base_hi = 0;
xhci->ev_ring_table[0].seg_size = EVENT_RING_SIZE;
+ /* pass event ring table to hardware */
+ wmb();
/* Initialize primary interrupter */
xhci->hcrreg->intrrs[0].erstsz = 1;
xhci_update_event_dq(xhci);
@@ -510,6 +512,7 @@ xhci_enqueue_trb(transfer_ring_t *const tr)
xhci_spew("Handling LINK pointer\n");
const int tc = TRB_GET(TC, tr->cur);
TRB_SET(CH, tr->cur, chain);
+ wmb();
TRB_SET(C, tr->cur, tr->pcs);
tr->cur = phys_to_virt(tr->cur->ptr_low);
if (tc)
@@ -535,7 +538,7 @@ xhci_enqueue_td(transfer_ring_t *const tr, const int ep, const size_t mps,
cur_length = length;
packets = 0;
length = 0;
- } else {
+ } else if (!IS_ENABLED(CONFIG_LP_XHCI_MTK_QUIRK)) {
packets -= (residue + cur_length) / mps;
residue = (residue + cur_length) % mps;
length -= cur_length;
@@ -548,6 +551,18 @@ xhci_enqueue_td(transfer_ring_t *const tr, const int ep, const size_t mps,
TRB_SET(TDS, trb, MIN(TRB_MAX_TD_SIZE, packets));
TRB_SET(CH, trb, 1);
+ if (length && IS_ENABLED(CONFIG_LP_XHCI_MTK_QUIRK)) {
+ /*
+ * For MTK's xHCI controller, TDS defines a number of
+ * packets that remain to be transferred for a TD after
+ * processing all Max packets in all previous TRBs, that
+ * means don't include the current TRB's.
+ */
+ packets -= (residue + cur_length) / mps;
+ residue = (residue + cur_length) % mps;
+ length -= cur_length;
+ }
+
/* Check for first, data stage TRB */
if (!trb_count && ep == 1) {
TRB_SET(DIR, trb, dir);
diff --git a/payloads/libpayload/drivers/usb/xhci_commands.c b/payloads/libpayload/drivers/usb/xhci_commands.c
index 009a69c..845a34d 100644
--- a/payloads/libpayload/drivers/usb/xhci_commands.c
+++ b/payloads/libpayload/drivers/usb/xhci_commands.c
@@ -47,6 +47,8 @@ xhci_post_command(xhci_t *const xhci)
TRB_SET(C, xhci->cr.cur, xhci->cr.pcs);
++xhci->cr.cur;
+ /* pass command trb to hardware */
+ wmb();
/* Ring the doorbell */
xhci->dbreg[0] = 0;
diff --git a/payloads/libpayload/drivers/usb/xhci_devconf.c b/payloads/libpayload/drivers/usb/xhci_devconf.c
index 012f610..5b5bb5e 100644
--- a/payloads/libpayload/drivers/usb/xhci_devconf.c
+++ b/payloads/libpayload/drivers/usb/xhci_devconf.c
@@ -313,6 +313,16 @@ xhci_finish_ep_config(const endpoint_t *const ep, inputctx_t *const ic)
EC_SET(AVRTRB, epctx, avrtrb);
EC_SET(MXESIT, epctx, EC_GET(MPS, epctx) * EC_GET(MBS, epctx));
+ if (IS_ENABLED(CONFIG_LP_USB_XHCI_MTK_QUIRK)) {
+ /* The MTK xHCI defines some extra SW parameters which are
+ * put into reserved DWs in Slot and Endpoint Contexts for
+ * synchronous endpoints. But for non-isochronous transfers,
+ * it is enough to set the following two fields to 1, and others
+ * are set to 0.
+ */
+ EC_SET(BPKTS, epctx, 1);
+ EC_SET(BBM, epctx, 1);
+ }
return 0;
}
diff --git a/payloads/libpayload/drivers/usb/xhci_private.h b/payloads/libpayload/drivers/usb/xhci_private.h
index 3861858..f01a37f 100644
--- a/payloads/libpayload/drivers/usb/xhci_private.h
+++ b/payloads/libpayload/drivers/usb/xhci_private.h
@@ -33,6 +33,8 @@
//#define USB_DEBUG
#include <usb/usb.h>
+#include <arch/barrier.h>
+#include <kconfig.h>
//#define XHCI_DUMPS
#define xhci_debug(fmt, args...) usb_debug("%s: " fmt, __func__, ## args)
@@ -242,6 +244,13 @@ typedef volatile struct slotctx {
#define EC_MXESIT_FIELD f5 /* MXESIT - Max ESIT Payload */
#define EC_MXESIT_START 16
#define EC_MXESIT_LEN 16
+#define EC_BPKTS_FIELD rsvd[0] /* BPKTS - packets tx in scheduled uframe */
+#define EC_BPKTS_START 0
+#define EC_BPKTS_LEN 6
+#define EC_BBM_FIELD rsvd[0] /* BBM - burst mode for scheduling */
+#define EC_BBM_START 11
+#define EC_BBM_LEN 1
+
#define EC_MASK(tok) MASK(EC_##tok##_START, EC_##tok##_LEN)
#define EC_GET(tok, ec) (((ec)->EC_##tok##_FIELD & EC_MASK(tok)) \
>> EC_##tok##_START)
diff --git a/payloads/libpayload/drivers/usb/xhci_rh.c b/payloads/libpayload/drivers/usb/xhci_rh.c
index fa118fe..bcb01ac 100644
--- a/payloads/libpayload/drivers/usb/xhci_rh.c
+++ b/payloads/libpayload/drivers/usb/xhci_rh.c
@@ -119,6 +119,24 @@ xhci_rh_reset_port(usbdev_t *const dev, const int port)
return 0;
}
+static int
+xhci_rh_enable_port(usbdev_t *const dev, int port)
+{
+ if (IS_ENABLED(CONFIG_LP_USB_XHCI_MTK_QUIRK)) {
+ xhci_t *const xhci = XHCI_INST(dev->controller);
+ volatile u32 *const portsc =
+ &xhci->opreg->prs[port - 1].portsc;
+
+ /*
+ * Before sending commands to a port, the Port Power in
+ * PORTSC register should be enabled on MTK's xHCI.
+ */
+ *portsc = (*portsc & PORTSC_RW_MASK) | PORTSC_PP;
+ }
+ return 0;
+}
+
+
static const generic_hub_ops_t xhci_rh_ops = {
.hub_status_changed = xhci_rh_hub_status_changed,
.port_status_changed = xhci_rh_port_status_changed,
@@ -126,7 +144,7 @@ static const generic_hub_ops_t xhci_rh_ops = {
.port_in_reset = xhci_rh_port_in_reset,
.port_enabled = xhci_rh_port_enabled,
.port_speed = xhci_rh_port_speed,
- .enable_port = NULL,
+ .enable_port = xhci_rh_enable_port,
.disable_port = NULL,
.start_port_reset = NULL,
.reset_port = xhci_rh_reset_port,