From patchwork Thu May 14 12:50:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1206 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 8FD503F03F for ; Thu, 14 May 2020 14:51:16 +0200 (CEST) Received: by mail-pg1-f198.google.com with SMTP id l7sf2206807pgb.2 for ; Thu, 14 May 2020 05:51:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1589460674; cv=pass; d=google.com; s=arc-20160816; b=VeL4XKvGxDxXj57ekwyga0rp75WKwdjGiSaLP0DSzCCuXMGcfV6rx8G/dYwASkZpzV JT1+sNSGFN8y4RMltymg8UnAMFRDA9JXoW0KW4VsLbVvJL4wJvwopZa+tQSZvpQdfq1q RwbSObINkYG1GrFA2Ux0nQDv0+r1U2FyLkupzGM3fLL8ii2Jgy9iCfm3vrlQWD8RuF5a TH+Ebv6bb2rymFtp+7T+u96t/M4T6SedVEACZslCU5Ls0lqhFapNLghnNzsdsdM8UMbg xiL2NhZLWAKhzJPEa81YxX6a2ZYIMCX+jmH4N9dUrNZ0u/V35HNUc994iL6iZsgSVha+ orvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=+XuxQDBcP9sn6qd0offhhjGVccZMEoxF7pQ+dQwodz8=; b=ARleUARSiqh7gZFIRSjAxHNlDTiCBSHAkrCjcJs3Fmm9PCaU64FgkwqoVWqLJcOnI6 griQ+bQbgH5LFaodurnMdYBG6VNPX3PtI3w88Xaj72uhC7JlVXN/nSCS/5ecFXjBY/qQ VCj0dcbCW6R20YzFD3CTT+pU0D6mRnAeTnsupDg6OidDD6effxJO2Qb7YRrC91DZf9Gn r/vi7Q72x53yCur/ltRoVi6VWGBNZs08wdwI48YYspy3+MJ3mG4mso5SpnUxht+cesLX vjKlKvYlmIJy5vnWWDm174iAu4+nDgHSWh5x+y2MvqUD0o9ka9Pw5D06ItpyKKIGpn5O mqiw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=QivAu2aS; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=+XuxQDBcP9sn6qd0offhhjGVccZMEoxF7pQ+dQwodz8=; b=Yn5y2Y0Y0WgTy9ckTf1PXsVrfvyE2NHI3EIwwcmj3frdnLhwMDIEhh/KuHrgXqgW8M W9IVpSUGWxbE7hlJs//5u1bqEMJFgF7PF5Vh7BziRi8QE/a72V6+xsB5b6GuD5ilH3RG 7KgrFZFvGQxhkTaAxG6ig4yBYIyfA6DaaxaQA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-unsubscribe; bh=+XuxQDBcP9sn6qd0offhhjGVccZMEoxF7pQ+dQwodz8=; b=RApgXI2afbAz8pECdYYv5H7ZToWJZWDdsNDD2/vhj4+9hFvypL4ruInmyl1WENXpoX GgA2VPjNpm1NDnFsSI7DdDQuMAjgmW9ypg+YfhB3/p/6xG6BcJeC01p9/VJXRr8Gktpz 6HBPvtZItmrDpbFmrOL6PVA4/QCq15LvMpL6fkbPF21gEdZnuC7llrJp6YZZcPUcQbJl Wgoc0pkCEfU0cR8uPtqxvbEw8HWWM6g6tJf8Yq6OeS3W6IVZDTByMBE7LPEaTl9uyseN RxMRHWFa3AjXKL4t3W/w4TKkv6r1zzRaL/aLkvtvPuGUQ8L10wSfrqaje4ARYbOZVcIj 9siQ== X-Gm-Message-State: AGi0PuZyxC6NNsWdjTzyeiVDcfwWljfl+2KIKixy1UZ1ZRxnr7bQ6ruB xx3KT6kMZHsm3JAMoQBv+XjYx9fa X-Google-Smtp-Source: APiQypIf/vRNXxjIdrPFT4IUBMCSdQEeNRhgC3kOHGN0uEEz79gqI+81CIDmiqosyWd8xuAoR+OaSA== X-Received: by 2002:a17:90a:b00d:: with SMTP id x13mr40732818pjq.227.1589460674282; Thu, 14 May 2020 05:51:14 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:55c3:: with SMTP id j186ls965619pfb.6.gmail; Thu, 14 May 2020 05:51:14 -0700 (PDT) X-Received: by 2002:aa7:9096:: with SMTP id i22mr4355891pfa.250.1589460673744; Thu, 14 May 2020 05:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589460673; cv=none; d=google.com; s=arc-20160816; b=AIT+HOnbb8u0zfzrkK1ZY/8qSre/9zhlb+2oiObgp6HEogUBfnE1CXC9ms+hSzHQWo xdgNistTI4Gj2BauyAQzBcB401DKMQQGR7wIFgIB22OLkDG3zzILSfuj1Xw14uDcC4E9 XOfvY+LwHHDIpoMxTRxIpqu8kGek7Cnde0x6owKCis9oj1/4PYXYKZ8LfbXf971I3p+3 xb2wp/FF3SpdXW/ZK4TuU1cfD3bZESPM1hko4slTgWbHPIjcLy5Ui1mLbp5nDaT8kJsg tVlPVHCBgFdopHhGztpgE3JE5Hmekkxs4blwZ8YCMqsCaipEzncjypUXsGkHZnHbuXMr ijNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=BdG7eWB3YsogSjXyFhbVxpZloUO+tCtnq0t7yAxk4Uo=; b=vUXwYexf+9dKcvTsU5TUIpw35IHSgOB3OVisiUr2uQUykx6ZCuL0hoBtePo9G9uW/M H6E802rg5Li0iiUdmpb9GfDgpaoWY0yLeoiyLtJVdpmmibj6rRzeURqCEILondlRYaGn RYdTgNkPTxw8hKRvs35UzLTJ1P9BAgmG4lePGPaFndqTNLO1KEqgm25xo6g6OI8t/oxo xEa9D2FHIDj+rX5YVh/uoLCV2jR7XiGfxbtY598CB2UgTfKk5+D3e1kxWnnwMCMhcfOY q1bXdCj8CEQh7uzAKX72IDid6WjHz19sO+BvUjHmjlAxPCAxKHfobe3B4D4Ub8RywAcV 0Sxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=QivAu2aS; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a12sor3534776pgk.70.2020.05.14.05.51.12 for (Google Transport Security); Thu, 14 May 2020 05:51:12 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:2166:: with SMTP id s38mr3779049pgm.369.1589460672456; Thu, 14 May 2020 05:51:12 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:713c:4a0a:47eb:ffcd]) by smtp.gmail.com with ESMTPSA id kr1sm14628710pjb.26.2020.05.14.05.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 05:51:11 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Jagan Teki , Simon Glass , Vignesh R Subject: [PATCH] sf: Drop spl_flash_get_sw_write_prot Date: Thu, 14 May 2020 18:20:56 +0530 Message-Id: <20200514125056.30931-1-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=QivAu2aS; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The get_sw_write_prot API is used to get the write-protected bits of flash by reading the status register and other wards it's API for reading register bits. 1) This kind of requirement can be achieved using existing flash operations and flash locking API calls instead of making a separate flash API. 2) Technically there is no real hardware user for this API to use in the source tree. 3) Having a flash operations API for simple register read bits also make difficult to extend the flash operations. 4) Instead of touching generic code, it is possible to have this functionality inside spinor operations in the form of flash hooks or fixups for associated flash chips. Considering all these points, this patch drops the get_sw_write_prot and associated code bases. Cc: Simon Glass Cc: Vignesh R Signed-off-by: Jagan Teki --- drivers/mtd/spi/sf-uclass.c | 9 --------- drivers/mtd/spi/sf_internal.h | 4 ---- drivers/mtd/spi/sf_probe.c | 8 -------- drivers/mtd/spi/spi-nor-core.c | 11 ----------- drivers/mtd/spi/spi-nor-tiny.c | 6 ------ include/spi_flash.h | 27 --------------------------- test/dm/sf.c | 8 -------- 7 files changed, 73 deletions(-) diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c index 5ebcca590a..5a42ab83c8 100644 --- a/drivers/mtd/spi/sf-uclass.c +++ b/drivers/mtd/spi/sf-uclass.c @@ -29,15 +29,6 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len) return log_ret(sf_get_ops(dev)->erase(dev, offset, len)); } -int spl_flash_get_sw_write_prot(struct udevice *dev) -{ - struct dm_spi_flash_ops *ops = sf_get_ops(dev); - - if (!ops->get_sw_write_prot) - return -ENOSYS; - return log_ret(ops->get_sw_write_prot(dev)); -} - /* * TODO(sjg@chromium.org): This is an old-style function. We should remove * it when all SPI flash drivers use dm diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 544ed74a5f..5fc662875e 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -74,10 +74,6 @@ extern const struct flash_info spi_nor_ids[]; #define JEDEC_MFR(info) ((info)->id[0]) #define JEDEC_ID(info) (((info)->id[1]) << 8 | ((info)->id[2])) -/* Get software write-protect value (BP bits) */ -int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash); - - #if CONFIG_IS_ENABLED(SPI_FLASH_MTD) int spi_flash_mtd_register(struct spi_flash *flash); void spi_flash_mtd_unregister(void); diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c index 1e8744896c..f167bfab8a 100644 --- a/drivers/mtd/spi/sf_probe.c +++ b/drivers/mtd/spi/sf_probe.c @@ -129,13 +129,6 @@ static int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len) return mtd->_erase(mtd, &instr); } -static int spi_flash_std_get_sw_write_prot(struct udevice *dev) -{ - struct spi_flash *flash = dev_get_uclass_priv(dev); - - return spi_flash_cmd_get_sw_write_prot(flash); -} - int spi_flash_std_probe(struct udevice *dev) { struct spi_slave *slave = dev_get_parent_priv(dev); @@ -159,7 +152,6 @@ static const struct dm_spi_flash_ops spi_flash_std_ops = { .read = spi_flash_std_read, .write = spi_flash_std_write, .erase = spi_flash_std_erase, - .get_sw_write_prot = spi_flash_std_get_sw_write_prot, }; static const struct udevice_id spi_flash_std_ids[] = { diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 984cece0b0..c5aff6f5c6 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -2639,14 +2639,3 @@ int spi_nor_scan(struct spi_nor *nor) return 0; } - -/* U-Boot specific functions, need to extend MTD to support these */ -int spi_flash_cmd_get_sw_write_prot(struct spi_nor *nor) -{ - int sr = read_sr(nor); - - if (sr < 0) - return sr; - - return (sr >> 2) & 7; -} diff --git a/drivers/mtd/spi/spi-nor-tiny.c b/drivers/mtd/spi/spi-nor-tiny.c index ccc0ab07af..06e3dad8c4 100644 --- a/drivers/mtd/spi/spi-nor-tiny.c +++ b/drivers/mtd/spi/spi-nor-tiny.c @@ -797,9 +797,3 @@ int spi_nor_scan(struct spi_nor *nor) return 0; } - -/* U-Boot specific functions, need to extend MTD to support these */ -int spi_flash_cmd_get_sw_write_prot(struct spi_nor *nor) -{ - return -ENOTSUPP; -} diff --git a/include/spi_flash.h b/include/spi_flash.h index 0b23f57a71..d9b2af856c 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -34,19 +34,6 @@ struct dm_spi_flash_ops { int (*write)(struct udevice *dev, u32 offset, size_t len, const void *buf); int (*erase)(struct udevice *dev, u32 offset, size_t len); - /** - * get_sw_write_prot() - Check state of software write-protect feature - * - * SPI flash chips can lock a region of the flash defined by a - * 'protected area'. This function checks if this protected area is - * defined. - * - * @dev: SPI flash device - * @return 0 if no region is write-protected, 1 if a region is - * write-protected, -ENOSYS if the driver does not implement this, - * other -ve value on error - */ - int (*get_sw_write_prot)(struct udevice *dev); }; /* Access the serial operations for a device */ @@ -88,20 +75,6 @@ int spi_flash_write_dm(struct udevice *dev, u32 offset, size_t len, */ int spi_flash_erase_dm(struct udevice *dev, u32 offset, size_t len); -/** - * spl_flash_get_sw_write_prot() - Check state of software write-protect feature - * - * SPI flash chips can lock a region of the flash defined by a - * 'protected area'. This function checks if this protected area is - * defined. - * - * @dev: SPI flash device - * @return 0 if no region is write-protected, 1 if a region is - * write-protected, -ENOSYS if the driver does not implement this, - * other -ve value on error - */ -int spl_flash_get_sw_write_prot(struct udevice *dev); - /** * spi_flash_std_probe() - Probe a SPI flash device * diff --git a/test/dm/sf.c b/test/dm/sf.c index 7805af740e..0c3f6c3bb7 100644 --- a/test/dm/sf.c +++ b/test/dm/sf.c @@ -50,14 +50,6 @@ static int dm_test_spi_flash(struct unit_test_state *uts) ut_assertok(spi_flash_read_dm(dev, 0, size, dst)); ut_assertok(memcmp(src, dst, size)); - /* Try the write-protect stuff */ - ut_assertok(uclass_first_device_err(UCLASS_SPI_EMUL, &emul)); - ut_asserteq(0, spl_flash_get_sw_write_prot(dev)); - sandbox_sf_set_block_protect(emul, 1); - ut_asserteq(1, spl_flash_get_sw_write_prot(dev)); - sandbox_sf_set_block_protect(emul, 0); - ut_asserteq(0, spl_flash_get_sw_write_prot(dev)); - /* Check mapping */ ut_assertok(dm_spi_get_mmap(dev, &map_base, &map_size, &offset)); ut_asserteq(0x1000, map_base);