Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3492302ybi; Mon, 29 Jul 2019 07:29:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOwWXnA/PISFWp6u0T1tShxBi/ejYcPzSRSJyoT4VhB/zOTbp2/am1BacxD4txhQ++DqAv X-Received: by 2002:a65:52c5:: with SMTP id z5mr90580912pgp.118.1564410570920; Mon, 29 Jul 2019 07:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564410570; cv=none; d=google.com; s=arc-20160816; b=QX5t2uzufLYyeZK9arFxr8iGADOv//9XNZEb535+GqtC6vRh/MlOELHEKx/mDNSyCW lzTz2vlNX7kjNOuYC4XwLFEMFSVds8rcPj6OJSpDiRhOEr1DJpCldC/IS5pfwhzd1FNC 2uDPLZ1iqHNDMJxuVMKCsQwSrC9bazThkih92bHuWVKHIK1x9Q1f/He18+Oty2isXoP/ Yj+y1STYyfJuhvrDOPiZDVL0hlnUkFd9wY3AnwQMok3XMh2E4L/nnyKjLwJHCEbRESnG KQUfogWTogvwUvzJtUgPj920dpSEPn9tHfXFNUbbbGrvB877dNzDQbGamVXl78AJEh4X Rk3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=owNWQOd/2H0FCiTpZ4jqUS3s4pbGEfup+TU4saXXw6w=; b=meUMkC3S+ZB8wVLMYJ/P7wUbj1r0YgETjIvzRlytwgcrpun1mvPT3/3qAcGTkib2yd 1sAV7SeGVFvoA0dI439Zyqr+pberCDrJATcJ0cY+/W3EHGiFTjm8sz1zrGSrn5Br6HQs t8Hy/tXPZAEnRzkakNKGIQxAItfnURlej+Dx4DoDBoUZl8fpeNxuT8pe8YYjDwyafYkj zP9+rxOUv4GPIB5dbgAFJpQUo61qUEkW9j/pyUwf6fP1Z0+BNrOaJpf2GtD0dkc4eiSi SH6+xaIgwwyfZ69WR8deD/TwaUN7oaQ3oqaoMzQY8iI1O/yyOc1OjTPfmsN0U2wXt77T 4iRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6si27864882pgt.13.2019.07.29.07.29.14; Mon, 29 Jul 2019 07:29:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727631AbfG2O0b (ORCPT + 99 others); Mon, 29 Jul 2019 10:26:31 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:40073 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726167AbfG2O0a (ORCPT ); Mon, 29 Jul 2019 10:26:30 -0400 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id x6TEP5TO025571; Mon, 29 Jul 2019 17:25:06 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id D6FB761FD3; Mon, 29 Jul 2019 17:25:05 +0300 (IDT) From: Tomer Maimon To: broonie@kernel.org, dwmw2@infradead.org, computersforpeace@gmail.com, marek.vasut@gmail.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, bbrezillon@kernel.org, yogeshnarayan.gaur@nxp.com, tudor.ambarus@microchip.com, gregkh@linuxfoundation.org, frieder.schrempf@exceet.de, tglx@linutronix.de Cc: linux-spi@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Tomer Maimon Subject: [RFC v1 0/3] *spi-mem: adding setup and callback function Date: Mon, 29 Jul 2019 17:25:01 +0300 Message-Id: <20190729142504.188336-1-tmaimon77@gmail.com> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lately we have working on Flash interface unit (FIU) SPI driver that using spi-mem interface, Our FIU HW module support direct Flash Rd//Wr. In our SOC (32 bit dual core ARM) we have 3 FIU's that using memory mapping as follow: FIU0 - have 2 chip select and each one have 128MB memory mapping (total 256MB memory mapping) FIU1 - have 4 chip select and each one have 128MB memory mapping (total 512MB memory mapping) FIU2 - have 4 chip select and each one have 16MB memory mapping (total 32MB memory mapping) Totally 800MB memory mapping. When the FIU driver probe it don't know the size of each Flash that connected to the FIU, so the entire memory mapping is allocated for each FIU according the FIU device tree memory map parameters. It means, if we enable all three FIU's the drivers will try to allocate totally 800MB. In 32bit system it is problematic because the kernel have only 1GB of memory allocation so the vmalloc cannot take 800MB. When implementing the FIU driver in the mtd/spi-nor we allocating memory address only for detected Flash with exact size (usually we are not using 128MB Flash), and in that case usually we allocating much less memory. To solve this issue we needed to overcome two things: 1. Get argument from the upper layer (spi-mem layer) 2. Calling the get argument function after SPI_NOR_SCAN function. (the MTD Flash size filled in SPI_NOR_SCAN function) The attach patch set solving the describe issue by: 1. Add spi-mem callback function and value to the SPI device for passing an argument from the spi-mem layer to the spi layer 2. Add spi-mem setup function to the spi-memory operation that running after the spi-mem probe finished. 3. Implement function callback in the m25p80 driver that execute get Flash size. The patch set tested on NPCM750 EVB with FIU driver (implemented with SPI-MEM interface). Thanks for your attention. Tomer Tomer Maimon (3): spi: spi-mem: add spi-mem setup function spi: spi-mem: add callback function to spi-mem device mtd: m25p80: add get Flash size callback support drivers/mtd/devices/m25p80.c | 12 ++++++++++++ drivers/spi/spi-mem.c | 27 ++++++++++++++++++++++++++- include/linux/spi/spi-mem.h | 11 +++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) -- 2.18.0