soc/marvell/mvmap2315: Add flash driver
Testing: booted successfully. Change-Id: Iaeff9f01dbfad7f313aa237e8c71c36c4ed1e06f Signed-off-by: Hakim Giydan <hgiydan@marvell.com> Reviewed-on: https://review.coreboot.org/15509 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
parent
03d10ea29c
commit
6a1a36f7e9
|
@ -20,6 +20,7 @@ bootblock-y += clock.c
|
||||||
bootblock-y += fiq.S
|
bootblock-y += fiq.S
|
||||||
bootblock-y += gic.c
|
bootblock-y += gic.c
|
||||||
bootblock-y += gpio.c
|
bootblock-y += gpio.c
|
||||||
|
bootblock-y += flash.c
|
||||||
bootblock-y += media.c
|
bootblock-y += media.c
|
||||||
bootblock-y += pinmux.c
|
bootblock-y += pinmux.c
|
||||||
bootblock-y += reset.c
|
bootblock-y += reset.c
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the coreboot project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Marvell, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <arch/io.h>
|
||||||
|
#include <console/console.h>
|
||||||
|
#include <soc/clock.h>
|
||||||
|
#include <soc/flash.h>
|
||||||
|
|
||||||
|
struct flash_ops flash_callbacks = {
|
||||||
|
.init = (void *)MVMAP2315_FLASH_INIT,
|
||||||
|
.read = (void *)MVMAP2315_FLASH_READ,
|
||||||
|
.write = (void *)MVMAP2315_FLASH_WRITE,
|
||||||
|
.shutdown = (void *)MVMAP2315_FLASH_SHUTDOWN,
|
||||||
|
.set_partition = (void *)MVMAP2315_FLASH_SET_PARTITION,
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 flash_init(u32 media, u32 clock_input_mhz)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
clrbits_le32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig,
|
||||||
|
MVMAP2315_SDMMC_CLK_RSTN);
|
||||||
|
setbits_le32(&mvmap2315_apmu_clk->apaonclk_sdmmc_clkgenconfig,
|
||||||
|
MVMAP2315_SDMMC_CLK_RSTN);
|
||||||
|
|
||||||
|
rc = flash_callbacks.init(media, 0, clock_input_mhz);
|
||||||
|
|
||||||
|
if (rc)
|
||||||
|
printk(BIOS_DEBUG, "flash_init failed with rc=%x.\n", rc);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 flash_partition(u32 media, struct flash_params *flash_image_info)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = flash_callbacks.set_partition(media, 0, flash_image_info);
|
||||||
|
|
||||||
|
if (rc)
|
||||||
|
printk(BIOS_DEBUG, "flash_partition failed with rc=%x.\n", rc);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 flash_read(u32 media, struct flash_params *flash_image_info)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = flash_callbacks.read(media, 0, flash_image_info);
|
||||||
|
|
||||||
|
if (rc)
|
||||||
|
printk(BIOS_DEBUG, "flash_read failed with rc=%x.\n", rc);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 flash_write(u32 media, struct flash_params *flash_image_info)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = flash_callbacks.write(media, 0, flash_image_info);
|
||||||
|
|
||||||
|
if (rc)
|
||||||
|
printk(BIOS_DEBUG, "flash_write failed with rc=%x.\n", rc);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 flash_shutdown(u32 media)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = flash_callbacks.shutdown(media, 0, 0);
|
||||||
|
|
||||||
|
if (rc)
|
||||||
|
printk(BIOS_DEBUG, "flash_shutdown failed with rc=%x.\n", rc);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the coreboot project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016 Marvell, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SOC_MARVELL_MVMAP2315_FLASH_H__
|
||||||
|
#define __SOC_MARVELL_MVMAP2315_FLASH_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define MVMAP2315_FLASH_INIT 0xFFE00084
|
||||||
|
#define MVMAP2315_FLASH_READ 0xFFE00088
|
||||||
|
#define MVMAP2315_FLASH_WRITE 0xFFE0008C
|
||||||
|
#define MVMAP2315_FLASH_SHUTDOWN 0xFFE00098
|
||||||
|
#define MVMAP2315_FLASH_SET_PARTITION 0xFFE00094
|
||||||
|
|
||||||
|
#define MVMAP2315_MMC_CLK_MHZ 0x00000019
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MVMAP2315_SD = 7,
|
||||||
|
MVMAP2315_EMMC = 8,
|
||||||
|
MVMAP2315_EEPROM = 27,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct flash_params {
|
||||||
|
u32 offset;
|
||||||
|
u32 buff;
|
||||||
|
u32 size;
|
||||||
|
u32 id;
|
||||||
|
u32 partition;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct flash_ops {
|
||||||
|
u32 (*init)(u32 media, u32 context, u32 clock_input_mhz);
|
||||||
|
u32 (*read)(u32 media, u32 context, struct flash_params *);
|
||||||
|
u32 (*write)(u32 media, u32 context, struct flash_params *);
|
||||||
|
u32 (*shutdown)(u32 media, u32 context, struct flash_params *);
|
||||||
|
u32 (*set_partition)(u32 media, u32 context, struct flash_params *);
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 flash_init(u32 media, u32 clock_input_mhz);
|
||||||
|
u32 flash_read(u32 media, struct flash_params *flash_image_info);
|
||||||
|
u32 flash_write(u32 media, struct flash_params *flash_image_info);
|
||||||
|
u32 flash_shutdown(u32 media);
|
||||||
|
u32 flash_partition(u32 media, struct flash_params *flash_image_info);
|
||||||
|
|
||||||
|
#endif /* __SOC_MARVELL_MVMAP2315_FLASH_H__ */
|
Loading…
Reference in New Issue