summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-08-07 14:58:08 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-08 03:11:38 +0000
commit0af39b3cffe139e18267422e985bdf9aca19dcbe (patch)
treef52f7150c9bc7393e03230c26a1b994c640c8861
parent5d208b992494ae4cdeffc0efdf4f341c6ada64e5 (diff)
downloadchrome-ec-0af39b3cffe139e18267422e985bdf9aca19dcbe.tar.gz
Move software CRC implementation to common
There is nothing chip-specific in the software CRC implementation. Let's move it to common so that we can reuse it for other chips and unit tests. BUG=chrome-os-partner:31200 TEST=Define CONFIG_SW_CRC for host. Check crc.c compiles fine. BRANCH=None Change-Id: Icdc1d105c55c38ff07410cb5d733a31dbac53aea Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/211494 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/stm32/build.mk1
-rw-r--r--chip/stm32/crc_hw.h (renamed from chip/stm32/crc.h)20
-rw-r--r--common/build.mk1
-rw-r--r--common/crc.c (renamed from chip/stm32/crc.c)0
-rw-r--r--include/crc.h27
5 files changed, 32 insertions, 17 deletions
diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk
index d141fa2f60..65fdb58876 100644
--- a/chip/stm32/build.mk
+++ b/chip/stm32/build.mk
@@ -27,7 +27,6 @@ chip-y=dma.o system.o
chip-y+=jtag-$(CHIP_FAMILY).o clock-$(CHIP_FAMILY).o
chip-$(CONFIG_SPI)+=spi.o
chip-$(CONFIG_SPI_MASTER_PORT)+=spi_master.o
-chip-$(CONFIG_SW_CRC)+=crc.o
chip-$(CONFIG_COMMON_GPIO)+=gpio.o gpio-$(CHIP_FAMILY).o
chip-$(CONFIG_COMMON_TIMER)+=hwtimer$(TIMER_TYPE).o
chip-$(CONFIG_I2C)+=i2c-$(CHIP_FAMILY).o
diff --git a/chip/stm32/crc.h b/chip/stm32/crc_hw.h
index df98c35d3b..c1a97da842 100644
--- a/chip/stm32/crc.h
+++ b/chip/stm32/crc_hw.h
@@ -3,13 +3,9 @@
* found in the LICENSE file.
*/
-#ifndef _CRC_H
-#define _CRC_H
-/* CRC-32 implementation with USB constants */
-
-/* Note: it's a stateful CRC-32 to match the hardware block interface */
-
-#ifdef CONFIG_HW_CRC
+#ifndef _CRC_HW_H
+#define _CRC_HW_H
+/* CRC-32 hardware implementation with USB constants */
#include "registers.h"
@@ -39,12 +35,4 @@ static inline uint32_t crc32_result(void)
return STM32_CRC_DR ^ 0xFFFFFFFF;
}
-#else /* !CONFIG_HW_CRC */
-/* Use software implementation */
-void crc32_init(void);
-void crc32_hash32(uint32_t val);
-void crc32_hash16(uint16_t val);
-uint32_t crc32_result(void);
-#endif /* CONFIG_HW_CRC */
-
-#endif /* _CRC_H */
+#endif /* _CRC_HW_H */
diff --git a/common/build.mk b/common/build.mk
index 6b2dd5dbfb..4401c570aa 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -62,6 +62,7 @@ common-$(CONFIG_SHA1)+=sha1.o
common-$(CONFIG_SOFTWARE_CLZ)+=clz.o
common-$(CONFIG_SPI_FLASH)+=spi_flash.o
common-$(CONFIG_SWITCH)+=switch.o
+common-$(CONFIG_SW_CRC)+=crc.o
common-$(CONFIG_TEMP_SENSOR)+=temp_sensor.o thermal.o
common-$(CONFIG_USB_PORT_POWER_DUMB)+=usb_port_power_dumb.o
common-$(CONFIG_USB_PORT_POWER_SMART)+=usb_port_power_smart.o
diff --git a/chip/stm32/crc.c b/common/crc.c
index 31054ad732..31054ad732 100644
--- a/chip/stm32/crc.c
+++ b/common/crc.c
diff --git a/include/crc.h b/include/crc.h
new file mode 100644
index 0000000000..73289ae213
--- /dev/null
+++ b/include/crc.h
@@ -0,0 +1,27 @@
+/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef _CRC_H
+#define _CRC_H
+/* CRC-32 implementation with USB constants */
+/* Note: it's a stateful CRC-32 to match the hardware block interface */
+
+#ifdef CONFIG_HW_CRC
+#include "crc_hw.h"
+#else
+
+/* Use software implementation */
+
+void crc32_init(void);
+
+void crc32_hash32(uint32_t val);
+
+void crc32_hash16(uint16_t val);
+
+uint32_t crc32_result(void);
+
+#endif /* CONFIG_HW_CRC */
+
+#endif /* _CRC_H */