uboot 添加W25Q64

这篇博客介绍了如何在UBoot中为Winbond的W25Q64闪存设备添加驱动支持。内容包括定义的SPI闪存命令、Winbond特定的ID以及对应的闪存参数结构体,以及读写和擦除操作的实现函数。
摘要由CSDN通过智能技术生成
/*
 * Copyright 2008, Network Appliance Inc.
 * Author: Jason McMullan <mcmullan <at> netapp.com>
 * Licensed under the GPL-2 or later.
 */
#include <common.h>
#include <malloc.h>
#include <spi_flash.h>
#include "spi_flash_internal.h"
/* M25Pxx-specific commands */
#define CMD_W25_WREN        0x06    /* Write Enable */
#define CMD_W25_WRDI        0x04    /* Write Disable */
#define CMD_W25_RDSR        0x05    /* Read Status Register */
#define CMD_W25_WRSR        0x01    /* Write Status Register */
#define CMD_W25_READ        0x03    /* Read Data Bytes */
#define CMD_W25_FAST_READ    0x0b    /* Read Data Bytes at Higher Speed */
#define CMD_W25_PP        0x02    /* Page Program */
#define CMD_W25_SE        0x20    /* Sector (4K) Erase */
#define CMD_W25_BE        0xd8    /* Block (64K) Erase */
#define CMD_W25_CE        0xc7    /* Chip Erase */
#define CMD_W25_DP        0xb9    /* Deep Power-down */
#define CMD_W25_RES        0xab    /* Release from DP, and Read Signature */

#define WINBOND_ID_W25X10A        0x3011
#define WINBOND_ID_W25X20A        0x3012
#define WINBOND_ID_W25X40A        0x3013
#define WINBOND_ID_W25X80A        0x3014
#define WINBOND_ID_W25X16        0x3015
#define WINBOND_ID_W25X32        0x3016
#define WINBOND_ID_W25X64        0x3017
#define WINBOND_ID_W25Q16B        0x4015
#define WINBOND_ID_W25Q32B        0x4016
#define WINBOND_ID_W25Q64        0x4017
#define WINBOND_ID_W25Q128        0x4018

#define WINBOND_SR_WIP        (1 << 0)    /* Write-in-Progress */

struct winbond_spi_flash_params {
    uint16_t    id;
    /* Log2 of page size in power-of-two mode */
    uint8_t        l2_page_size;
    uint16_t    pages_per_sector;
    uint16_t    sectors_per_block;
//    uint8_t        nr_blocks;
    uint16_t    nr_blocks;
    const char    *name;
};
/* spi_flash needs to be first so upper layers can free() it */
struct winbond_spi_flash {
    struct spi_flash flash;
    const struct winbond_spi_flash_params *params;
};
static inline struct winbond_spi_flash *
to_winbond_spi_flash(struct spi_flash *flash)
{
    return container_of(flash, struct winbond_spi_flash, flash);
}
static const struct winbond_spi_flash_params winbond_spi_flash_table[] = {
    {
        .id            = WINBOND_ID_W25X10A,
        .l2_page_size        = 8,
        .pages_per_sector    = 16,
        .sectors_per_block    = 16,
        .nr_blocks        = 2,
        .name            = "W25X10A",
    },
    {
        .id            = WINBOND_ID_W25X20A,
        .l2_page_size        = 8,
        .pages_per_sector    = 16,
        .sectors_per_block    = 16,
        .nr_blocks        = 4,
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值