commonlib: Move drivers/storage into commonlib/storage

Move drivers/storage into commonlib/storage to enable access by
libpayload and indirectly by payloads.

* Remove SD/MMC specific include files from include/device
* Remove files from drivers/storage
* Add SD/MMC specific include files to commonlib/include
* Add files to commonlib/storage
* Fix header file references
* Add subdir entry in commonlib/Makefile.inc to build the SD/MMC driver
* Add Kconfig source for commonlib/storage
* Rename *DEVICE* to *COMMONLIB*
* Rename *DRIVERS_STORAGE* to *COMMONLIB_STORAGE*

TEST=Build and run on Galileo Gen2

Change-Id: I4339e4378491db9a0da1f2dc34e1906a5ba31ad6
Signed-off-by: Lee Leahy <Leroy.P.Leahy@intel.com>
Reviewed-on: https://review.coreboot.org/19672
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Lee Leahy 2017-05-08 16:56:03 -07:00
parent f542aca090
commit 48dbc663d7
31 changed files with 88 additions and 86 deletions

View File

@ -353,6 +353,7 @@ source "src/device/Kconfig"
menu "Generic Drivers"
source "src/drivers/*/Kconfig"
source "src/drivers/*/*/Kconfig"
source "src/commonlib/storage/Kconfig"
endmenu
source "src/acpi/Kconfig"

View File

@ -44,7 +44,7 @@
* to reside in the migrated area (between _car_relocatable_data_start
* and _car_relocatable_data_end). */
TIMESTAMP(., 0x100)
#if IS_ENABLED(CONFIG_DRIVERS_STORAGE)
#if IS_ENABLED(CONFIG_COMMONLIB_STORAGE)
_car_drivers_storage_start = .;
. += 256;
_car_drivers_storage_end = .;

View File

@ -1,3 +1,5 @@
subdirs-y += storage
bootblock-y += mem_pool.c
verstage-y += mem_pool.c
romstage-y += mem_pool.c

View File

@ -16,8 +16,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __DEVICE_SD_MMC_CTRLR_H__
#define __DEVICE_SD_MMC_CTRLR_H__
#ifndef __COMMONLIB_SD_MMC_CTRLR_H__
#define __COMMONLIB_SD_MMC_CTRLR_H__
#include <stdint.h>
@ -225,4 +225,4 @@ void sdhc_log_command_issued(void);
void sdhc_log_response(uint32_t entries, uint32_t *response);
void sdhc_log_ret(int ret);
#endif /* __DEVICE_SD_MMC_CTRLR_H__ */
#endif /* __COMMONLIB_SD_MMC_CTRLR_H__ */

View File

@ -16,10 +16,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __DEVICE_SDHCI_H__
#define __DEVICE_SDHCI_H__
#ifndef __COMMONLIB_SDHCI_H__
#define __COMMONLIB_SDHCI_H__
#include <device/sd_mmc_ctrlr.h>
#include <commonlib/sd_mmc_ctrlr.h>
/* Driver specific capabilities */
#define DRVR_CAP_1V8_VDD 0x00010000
@ -73,4 +73,4 @@ struct sd_mmc_ctrlr *new_pci_sdhci_controller(uint32_t dev);
/* Add SDHCI controller with memory address */
struct sd_mmc_ctrlr *new_mem_sdhci_controller(void *ioaddr);
#endif /* __DEVICE_SDHCI_H__ */
#endif /* __COMMONLIB_SDHCI_H__ */

View File

@ -16,10 +16,10 @@
* GNU General Public License for more details.
*/
#ifndef __DEVICE_STORAGE_H__
#define __DEVICE_STORAGE_H__
#ifndef __COMMONLIB_STORAGE_H__
#define __COMMONLIB_STORAGE_H__
#include <device/sd_mmc_ctrlr.h>
#include <commonlib/sd_mmc_ctrlr.h>
/*
* EXT_CSD fields
@ -148,4 +148,4 @@ int storage_set_partition(struct storage_media *media,
void storage_display_setup(struct storage_media *media);
#endif /* __DEVICE_STORAGE_H__ */
#endif /* __COMMONLIB_STORAGE_H__ */

View File

@ -13,17 +13,17 @@
## GNU General Public License for more details.
##
config DRIVERS_STORAGE
config COMMONLIB_STORAGE
bool
default n
if DRIVERS_STORAGE
if COMMONLIB_STORAGE
config DRIVERS_STORAGE_MMC
config COMMONLIB_STORAGE_MMC
bool "Enable MultiMediaCard (MMC) and eMMC device support"
default n
config DRIVERS_STORAGE_SD
config COMMONLIB_STORAGE_SD
bool "Enable Secure Digital (SD) memory card support"
default n
@ -102,4 +102,4 @@ config SDHCI_BOUNCE_BUFFER
default n
endif # SDHCI_CONTROLLER
endif # DRIVERS_STORAGE
endif # COMMONLIB_STORAGE

View File

@ -13,7 +13,7 @@
# GNU General Public License for more details.
#
ifeq ($(CONFIG_DRIVERS_STORAGE),y)
ifeq ($(CONFIG_COMMONLIB_STORAGE),y)
bootblock-y += sd_mmc.c
bootblock-y += storage.c
@ -69,22 +69,22 @@ endif # CONFIG_SDHCI_BOUNCE_BUFFER
endif # CONFIG_SDHCI_CONTROLLER
# Determine if MultiMediaCards or embedded MMC devices are supported
ifeq ($(CONFIG_DRIVERS_STORAGE_MMC),y)
ifeq ($(CONFIG_COMMONLIB_STORAGE_MMC),y)
bootblock-y += mmc.c
verstage-y += mmc.c
romstage-y += mmc.c
postcar-y += mmc.c
ramstage-y += mmc.c
endif # CONFIG_DRIVERS_STORAGE_MMC
endif # CONFIG_COMMONLIB_STORAGE_MMC
# Determine if Secure Digital cards are supported
ifeq ($(CONFIG_DRIVERS_STORAGE_SD),y)
ifeq ($(CONFIG_COMMONLIB_STORAGE_SD),y)
bootblock-y += sd.c
verstage-y += sd.c
romstage-y += sd.c
postcar-y += sd.c
ramstage-y += sd.c
endif # CONFIG_DRIVERS_STORAGE_SD
endif # CONFIG_COMMONLIB_STORAGE_SD
# Determine if erase operations are supported
ifeq ($(CONFIG_STORAGE_ERASE),y)
@ -104,4 +104,4 @@ postcar-y += storage_write.c
ramstage-y += storage_write.c
endif # CONFIG_STORAGE_WRITE
endif # CONFIG_DRIVERS_STORAGE
endif # CONFIG_COMMONLIB_STORAGE

View File

@ -15,8 +15,8 @@
* GNU General Public License for more details.
*/
#ifndef __DRIVERS_STORAGE_BOUNCEBUF_H__
#define __DRIVERS_STORAGE_BOUNCEBUF_H__
#ifndef __COMMONLIB_STORAGE_BOUNCEBUF_H__
#define __COMMONLIB_STORAGE_BOUNCEBUF_H__
#include <stddef.h>
#include <stdint.h>
@ -93,4 +93,4 @@ int bounce_buffer_stop(struct bounce_buffer *state);
#define ARCH_DMA_MINALIGN (DMA_MINALIGN)
#endif
#endif // __DRIVERS_STORAGE_BOUNCEBUF_H__
#endif // __COMMONLIB_STORAGE_BOUNCEBUF_H__

View File

@ -19,8 +19,8 @@
* GNU General Public License for more details.
*/
#include <commonlib/storage.h>
#include <console/console.h>
#include <device/storage.h>
#include "sd_mmc.h"
#include "mmc.h"
#include "sd_mmc.h"

View File

@ -16,10 +16,10 @@
* GNU General Public License for more details.
*/
#ifndef __DRIVER_STORAGE_MMC_H__
#define __DRIVER_STORAGE_MMC_H__
#ifndef __COMMONLIB_STORAGE_MMC_H__
#define __COMMONLIB_STORAGE_MMC_H__
#include <device/sd_mmc_ctrlr.h>
#include <commonlib/sd_mmc_ctrlr.h>
#define MMC_HS_TIMING 0x00000100
#define MMC_HS_52MHZ 0x2
@ -51,4 +51,4 @@
int storage_block_setup_media(struct storage_media *media,
struct sd_mmc_ctrlr *ctrlr);
#endif /* __DRIVER_STORAGE_MMC_H__ */
#endif /* __COMMONLIB_STORAGE_MMC_H__ */

View File

@ -19,9 +19,9 @@
#endif
#include <assert.h>
#include <commonlib/sdhci.h>
#include <console/console.h>
#include <device/pci.h>
#include <device/sdhci.h>
#include "sd_mmc.h"
#include "storage.h"
#include <string.h>

View File

@ -20,9 +20,9 @@
*/
#include <assert.h>
#include <commonlib/sd_mmc_ctrlr.h>
#include <commonlib/storage.h>
#include <delay.h>
#include <device/sd_mmc_ctrlr.h>
#include <device/storage.h>
#include <endian.h>
#include "sd_mmc.h"
#include "storage.h"

View File

@ -21,8 +21,8 @@
*/
#include <assert.h>
#include <commonlib/storage.h>
#include <delay.h>
#include <device/storage.h>
#include <endian.h>
#include "mmc.h"
#include "sd_mmc.h"
@ -168,7 +168,7 @@ int sd_mmc_enter_standby(struct storage_media *media)
/* Test for SD version 2 */
err = CARD_TIMEOUT;
if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_SD)) {
if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_SD)) {
err = sd_send_if_cond(media);
/* Get SD card operating condition */
@ -177,7 +177,7 @@ int sd_mmc_enter_standby(struct storage_media *media)
}
/* If the command timed out, we check for an MMC card */
if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_MMC) && (err == CARD_TIMEOUT)) {
if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_MMC) && (err == CARD_TIMEOUT)) {
/* Some cards seem to need this */
sd_mmc_go_idle(media);

View File

@ -12,11 +12,11 @@
* GNU General Public License for more details.
*/
#ifndef __DRIVERS_STORAGE_SD_MMC_H__
#define __DRIVERS_STORAGE_SD_MMC_H__
#ifndef __COMMONLIB_STORAGE_SD_MMC_H__
#define __COMMONLIB_STORAGE_SD_MMC_H__
#include <device/sd_mmc_ctrlr.h>
#include <device/storage.h>
#include <commonlib/sd_mmc_ctrlr.h>
#include <commonlib/storage.h>
#include <stddef.h>
#define SD_MMC_IO_RETRIES 1000
@ -49,11 +49,13 @@ int sd_mmc_send_status(struct storage_media *media, ssize_t tries);
int sd_mmc_set_blocklen(struct sd_mmc_ctrlr *ctrlr, int len);
/* MMC support routines */
int mmc_change_freq(struct storage_media *media);
int mmc_complete_op_cond(struct storage_media *media);
const char *mmc_partition_name(struct storage_media *media,
unsigned int partition_number);
int mmc_send_ext_csd(struct sd_mmc_ctrlr *ctrlr, unsigned char *ext_csd);
int mmc_send_op_cond(struct storage_media *media);
int mmc_set_bus_width(struct storage_media *media);
int mmc_set_partition(struct storage_media *media,
unsigned int partition_number);
int mmc_update_capacity(struct storage_media *media);
@ -64,13 +66,9 @@ const char *sd_partition_name(struct storage_media *media,
unsigned int partition_number);
int sd_send_if_cond(struct storage_media *media);
int sd_send_op_cond(struct storage_media *media);
int sd_set_bus_width(struct storage_media *media);
int sd_set_partition(struct storage_media *media,
unsigned int partition_number);
int sd_set_bus_width(struct storage_media *media);
int mmc_change_freq(struct storage_media *media);
int mmc_send_status(struct storage_media *media, ssize_t tries);
int mmc_set_bus_width(struct storage_media *media);
/* Controller debug functions */
#define sdhc_debug(format...) \
@ -98,4 +96,4 @@ int mmc_set_bus_width(struct storage_media *media);
} while (0)
#define sd_mmc_error(format...) printk(BIOS_ERR, "ERROR: " format)
#endif /* __DRIVERS_STORAGE_SD_MMC_H__ */
#endif /* __COMMONLIB_STORAGE_SD_MMC_H__ */

View File

@ -20,10 +20,10 @@
#include <assert.h>
#include "bouncebuf.h"
#include <console/console.h>
#include <commonlib/sd_mmc_ctrlr.h>
#include <commonlib/sdhci.h>
#include <commonlib/storage.h>
#include <delay.h>
#include <device/sd_mmc_ctrlr.h>
#include <device/sdhci.h>
#include <device/storage.h>
#include <endian.h>
#include <halt.h>
#include "sdhci.h"

View File

@ -14,11 +14,11 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __DRIVERS_STORAGE_SDHCI_H__
#define __DRIVERS_STORAGE_SDHCI_H__
#ifndef __COMMONLIB_STORAGE_SDHCI_H__
#define __COMMONLIB_STORAGE_SDHCI_H__
#include <arch/io.h>
#include <device/sd_mmc_ctrlr.h>
#include <commonlib/sd_mmc_ctrlr.h>
/*
* Controller registers
@ -278,4 +278,4 @@ int sdhci_setup_adma(struct sdhci_ctrlr *sdhci_ctrlr, struct mmc_data *data);
int sdhci_complete_adma(struct sdhci_ctrlr *sdhci_ctrlr,
struct mmc_command *cmd);
#endif /* __DRIVERS_STORAGE_SDHCI_H__ */
#endif /* __COMMONLIB_STORAGE_SDHCI_H__ */

View File

@ -18,9 +18,9 @@
*/
#include <assert.h>
#include <commonlib/sdhci.h>
#include <commonlib/storage.h>
#include <delay.h>
#include <device/sdhci.h>
#include <device/storage.h>
#include <endian.h>
#include "sdhci.h"
#include "sd_mmc.h"

View File

@ -17,10 +17,10 @@
* GNU General Public License for more details.
*/
#include <commonlib/sd_mmc_ctrlr.h>
#include <commonlib/sdhci.h>
#include <commonlib/storage.h>
#include <console/console.h>
#include <device/sd_mmc_ctrlr.h>
#include <device/sdhci.h>
#include <device/storage.h>
#include "sdhci.h"
#include "sd_mmc.h"
#include "storage.h"

View File

@ -22,7 +22,7 @@
*/
#include <assert.h>
#include <device/storage.h>
#include <commonlib/storage.h>
#include "sd_mmc.h"
#include "storage.h"
#include <string.h>
@ -70,7 +70,7 @@ static void display_capacity(struct storage_media *media, int partition_number)
capacity = media->capacity[partition_number];
name = storage_partition_name(media, partition_number);
separator = "";
if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_MMC) && !IS_SD(media))
if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_MMC) && !IS_SD(media))
separator = ": ";
/* Determine the decimal divisor for the capacity */
@ -175,9 +175,9 @@ int storage_startup(struct storage_media *media)
return err;
/* Increase the bus frequency */
if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_SD) && IS_SD(media))
if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_SD) && IS_SD(media))
err = sd_change_freq(media);
else if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_MMC)) {
else if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_MMC)) {
err = mmc_change_freq(media);
if (!err)
mmc_update_capacity(media);
@ -189,9 +189,9 @@ int storage_startup(struct storage_media *media)
media->caps &= ctrlr->caps;
/* Increase the bus width if possible */
if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_SD) && IS_SD(media))
if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_SD) && IS_SD(media))
err = sd_set_bus_width(media);
else if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_MMC))
else if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_MMC))
err = mmc_set_bus_width(media);
if (err)
return err;
@ -329,9 +329,9 @@ int storage_set_partition(struct storage_media *media,
/* Select the partition */
err = -1;
if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_SD) && IS_SD(media))
if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_SD) && IS_SD(media))
err = sd_set_partition(media, partition_number);
else if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_MMC))
else if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_MMC))
err = mmc_set_partition(media, partition_number);
if (err)
sd_mmc_error("Invalid partition number!\n");
@ -345,9 +345,9 @@ const char *storage_partition_name(struct storage_media *media,
/* Get the partition name */
name = NULL;
if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_SD) && IS_SD(media))
if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_SD) && IS_SD(media))
name = sd_partition_name(media, partition_number);
else if (IS_ENABLED(CONFIG_DRIVERS_STORAGE_MMC))
else if (IS_ENABLED(CONFIG_COMMONLIB_STORAGE_MMC))
name = mmc_partition_name(media, partition_number);
return name;
}

View File

@ -12,11 +12,11 @@
* GNU General Public License for more details.
*/
#ifndef __DRIVERS_STORAGE_STORAGE_H__
#define __DRIVERS_STORAGE_STORAGE_H__
#ifndef __COMMONLIB_STORAGE_STORAGE_H__
#define __COMMONLIB_STORAGE_STORAGE_H__
#include <stdint.h>
#include <device/storage.h>
#include <commonlib/storage.h>
#define DMA_MINALIGN (64)
#define ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1))
@ -34,4 +34,4 @@ int storage_startup(struct storage_media *media);
int storage_block_setup(struct storage_media *media, uint64_t start,
uint64_t count, int is_read);
#endif /* __DRIVERS_STORAGE_STORAGE_H__ */
#endif /* __COMMONLIB_STORAGE_STORAGE_H__ */

View File

@ -182,7 +182,7 @@ config FMDFILE
config ENABLE_SD_TESTING
bool "Enable SD card testing"
default y
select DRIVERS_STORAGE_SD
select COMMONLIB_STORAGE_SD
select SDHC_DEBUG
select STORAGE_LOG
select STORAGE_TEST

View File

@ -26,7 +26,7 @@ verstage-$(CONFIG_VBOOT) += vboot.c
romstage-y += gpio.c
romstage-y += reg_access.c
romstage-$(CONFIG_DRIVERS_STORAGE_SD) += sd.c
romstage-$(CONFIG_COMMONLIB_STORAGE_SD) += sd.c
romstage-$(CONFIG_VBOOT) += vboot.c
postcar-y += gpio.c
@ -34,4 +34,4 @@ postcar-y += reg_access.c
ramstage-y += gpio.c
ramstage-y += reg_access.c
ramstage-$(CONFIG_DRIVERS_STORAGE_SD) += sd.c
ramstage-$(CONFIG_COMMONLIB_STORAGE_SD) += sd.c

View File

@ -13,9 +13,9 @@
* GNU General Public License for more details.
*/
#include <commonlib/sdhci.h>
#include <commonlib/storage.h>
#include <console/console.h>
#include <device/sdhci.h>
#include <device/storage.h>
void soc_sd_mmc_controller_quirks(struct sd_mmc_ctrlr *ctrlr)
{

View File

@ -311,11 +311,12 @@ config C_ENV_BOOTBLOCK_SIZE
config STORAGE_TEST
bool "Test SD/MMC/eMMC card or device access"
default n
select DRIVERS_STORAGE
select COMMONLIB_STORAGE
select SDHCI_CONTROLLER
help
Read block 0 from each parition of the storage device. User must
also enable one or both of DRIVERS_STORAGE_SD or DRIVERS_STORAGE_MMC.
Read block 0 from each parition of the storage device. User
must also enable one or both of COMMONLIB_STORAGE_SD or
COMMONLIB_STORAGE_MMC.
config STORAGE_LOG
bool "Log and display SD/MMC commands"

View File

@ -16,9 +16,9 @@
#ifndef __STORAGE_TEST_H__
#define __STORAGE_TEST_H__
#include <commonlib/sd_mmc_ctrlr.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/sd_mmc_ctrlr.h>
#include <timer.h>
#ifdef __SIMPLE_DEVICE__

View File

@ -14,12 +14,12 @@
*/
#include <arch/io.h>
#include <commonlib/sdhci.h>
#include <commonlib/storage.h>
#include <console/console.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/sdhci.h>
#include <device/storage.h>
#include <soc/storage_test.h>
static void init(struct device *dev)

View File

@ -18,9 +18,9 @@
#include <assert.h>
#include <cbmem.h>
#include <commonlib/cbmem_id.h>
#include <commonlib/sdhci.h>
#include <commonlib/storage.h>
#include <console/console.h>
#include <device/sdhci.h>
#include <device/storage.h>
#include <lib.h>
#include <soc/iomap.h>
#include <soc/pci_devs.h>