From patchwork Sun Feb 14 20:48:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 582602 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 8BBCE14031F for ; Mon, 15 Feb 2016 08:00:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E6E8539BA; Sun, 14 Feb 2016 21:55:41 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NaQc_xWiCURw; Sun, 14 Feb 2016 21:55:41 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A095A770F; Sun, 14 Feb 2016 21:54:35 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C6424A777F for ; Sun, 14 Feb 2016 21:54:29 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QchPfP7H-tdV for ; Sun, 14 Feb 2016 21:54:29 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) by theia.denx.de (Postfix) with ESMTPS id 6B5B8A762D for ; Sun, 14 Feb 2016 21:53:28 +0100 (CET) Received: by mail-pf0-f179.google.com with SMTP id x65so75935985pfb.1 for ; Sun, 14 Feb 2016 12:53:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uT8f5RMpK4w/y3RupeV0r5tjX4g5iZFFkRYU5oKQ3SI=; b=CQ0aXoyMwelLN3EgqQPb2iskCjPTl72I7GjfqJ9TjwcMXo2PdDroonn34jvdpXgpsa MdOdy8zhia8uzCSlv3/kasnAVYuwxjIYmdrWnDSJKtavvgUjSkAWJiFnD5B2bjhVSlNW ZVBi0Q6fvtWfRnkZ6o+nh0vZcrqfvfAioNe4UJfP5ErWD0kdyyvnQlc4tNRwgMpv0glr jZSexAlZaabihlaehx5R0/zC/jII9eyJE1FADpdYNHQNhxwHuUSfxUwEcIwkNp+SglFW O00mBziFG1LnI6asdtRPiqtv4Vsjbqhbgrgbr9bsBIKQkjwZK5RRuSewyeERCf69ylQm Qh1g== X-Gm-Message-State: AG10YOTDRWmkHWS17hYwQNtWmCyIhTvHscsel+rWZ6xfHa9jeMQXt7jYb4Mvfp1Mhsn84Q== X-Received: by 10.98.70.80 with SMTP id t77mr18388002pfa.107.1455483207134; Sun, 14 Feb 2016 12:53:27 -0800 (PST) Received: from localhost.localdomain ([123.236.183.254]) by smtp.gmail.com with ESMTPSA id cq9sm11423890pac.26.2016.02.14.12.53.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Feb 2016 12:53:26 -0800 (PST) From: Jagan Teki To: u-boot@lists.denx.de Date: Mon, 15 Feb 2016 02:18:50 +0530 Message-Id: <1455482955-19053-51-git-send-email-jteki@openedev.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455482955-19053-1-git-send-email-jteki@openedev.com> References: <1455482955-19053-1-git-send-email-jteki@openedev.com> Cc: Jagan Teki Subject: [U-Boot] [PATCH v6 51/76] mtd: spi-nor: sandbox: Use spi-nor header X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Since sandbox moved to use spi-nor layer, this patch replaced the header changes from sf_internal.h to mtd/spi-nor.h Cc: Simon Glass Cc: Bin Meng Signed-off-by: Jagan Teki --- drivers/mtd/spi-nor/sandbox.c | 49 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/mtd/spi-nor/sandbox.c b/drivers/mtd/spi-nor/sandbox.c index 895604d..3cfb47c 100644 --- a/drivers/mtd/spi-nor/sandbox.c +++ b/drivers/mtd/spi-nor/sandbox.c @@ -12,10 +12,8 @@ #include #include #include -#include - #include -#include "sf_internal.h" +#include #include #include @@ -24,6 +22,8 @@ #include #include +#include + DECLARE_GLOBAL_DATA_PTR; /* @@ -88,7 +88,7 @@ struct sandbox_spi_flash { /* The current flash status (see STAT_XXX defines above) */ u16 status; /* Data describing the flash we're emulating */ - const struct spi_flash_params *data; + const struct spi_nor_info *data; /* The file on disk to serv up data from */ int fd; }; @@ -112,7 +112,7 @@ static int sandbox_sf_probe(struct udevice *dev) struct sandbox_spi_flash *sbsf = dev_get_priv(dev); const char *file; size_t len, idname_len; - const struct spi_flash_params *data; + const struct spi_nor_info *data; struct sandbox_spi_flash_plat_data *pdata = dev_get_platdata(dev); struct sandbox_state *state = state_get_current(); struct udevice *bus = dev->parent; @@ -166,7 +166,7 @@ static int sandbox_sf_probe(struct udevice *dev) } debug("%s: device='%s'\n", __func__, spec); - for (data = spi_flash_params_table; data->name; data++) { + for (data = spi_nor_ids; data->name; data++) { len = strlen(data->name); if (idname_len != len) continue; @@ -255,45 +255,45 @@ static int sandbox_sf_process_cmd(struct sandbox_spi_flash *sbsf, const u8 *rx, sbsf->cmd = rx[0]; switch (sbsf->cmd) { - case CMD_READ_ID: + case SNOR_OP_RDID: sbsf->state = SF_ID; sbsf->cmd = SF_ID; break; - case CMD_READ_ARRAY_FAST: + case SNOR_OP_READ_FAST: sbsf->pad_addr_bytes = 1; - case CMD_READ_ARRAY_SLOW: - case CMD_PAGE_PROGRAM: + case SNOR_OP_READ: + case SNOR_OP_PP: sbsf->state = SF_ADDR; break; - case CMD_WRITE_DISABLE: + case SNOR_OP_WRDI: debug(" write disabled\n"); sbsf->status &= ~STAT_WEL; break; - case CMD_READ_STATUS: + case SNOR_OP_RDSR: sbsf->state = SF_READ_STATUS; break; - case CMD_READ_STATUS1: + case SNOR_OP_RDCR: sbsf->state = SF_READ_STATUS1; break; - case CMD_WRITE_ENABLE: + case SNOR_OP_WREN: debug(" write enabled\n"); sbsf->status |= STAT_WEL; break; - case CMD_WRITE_STATUS: + case SNOR_OP_WRSR: sbsf->state = SF_WRITE_STATUS; break; default: { int flags = sbsf->data->flags; /* we only support erase here */ - if (sbsf->cmd == CMD_ERASE_CHIP) { + if (sbsf->cmd == SPINOR_OP_CHIP_ERASE) { sbsf->erase_size = sbsf->data->sector_size * - sbsf->data->nr_sectors; - } else if (sbsf->cmd == CMD_ERASE_4K && (flags & SECT_4K)) { + sbsf->data->n_sectors; + } else if (sbsf->cmd == SNOR_OP_BE_4K && (flags & SECT_4K)) { sbsf->erase_size = 4 << 10; - } else if (sbsf->cmd == CMD_ERASE_32K && (flags & SECT_32K)) { + } else if (sbsf->cmd == SNOR_OP_BE_32K && (flags & SECT_32K)) { sbsf->erase_size = 32 << 10; - } else if (sbsf->cmd == CMD_ERASE_64K && + } else if (sbsf->cmd == SNOR_OP_SE && !(flags & (SECT_4K | SECT_32K))) { sbsf->erase_size = 64 << 10; } else { @@ -361,8 +361,7 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen, debug(" id: off:%u tx:", sbsf->off); if (sbsf->off < IDCODE_LEN) { /* Extract correct byte from ID 0x00aabbcc */ - id = sbsf->data->jedec >> - (8 * (IDCODE_LEN - 1 - sbsf->off)); + id = JEDEC_ID(sbsf->data) >> (8 * (IDCODE_LEN - 1 - sbsf->off)); } else { id = 0; } @@ -394,11 +393,11 @@ static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen, return -EIO; } switch (sbsf->cmd) { - case CMD_READ_ARRAY_FAST: - case CMD_READ_ARRAY_SLOW: + case SNOR_OP_READ_FAST: + case SNOR_OP_READ: sbsf->state = SF_READ; break; - case CMD_PAGE_PROGRAM: + case SNOR_OP_PP: sbsf->state = SF_WRITE; break; default: