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>
This commit is contained in:
Vic Yang
2014-08-07 14:58:08 -07:00
committed by chrome-internal-fetch
parent 5d208b9924
commit 0af39b3cff
5 changed files with 32 additions and 17 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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

27
include/crc.h Normal file
View File

@@ -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 */