From patchwork Sat Apr 23 03:46:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jonathan Bakker X-Patchwork-Id: 12824406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48AF1C433EF for ; Sat, 23 Apr 2022 03:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232591AbiDWDtw (ORCPT ); Fri, 22 Apr 2022 23:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232563AbiDWDtp (ORCPT ); Fri, 22 Apr 2022 23:49:45 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08olkn2043.outbound.protection.outlook.com [40.92.47.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383BB17E18; Fri, 22 Apr 2022 20:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lx/dffzEIK3vWKwOJxHF67D9F23Mdp2U2niDm4+VFEsUBPFI23d7/Vxf6WqClLWkBRiU/ETTntRQA87i1n9+wBKkGK2A6TeMPffMWcMB/aXqNa7PVRQwRCfgUx3S3vmYud2inPGUX28sif8pHuDjMwYGEjLu4W4NoifnRiYXZxemqq1rjojTbcl1jY0U/ztTxTBbXSiprBRImUm8bW8mqxzwzaHdwaGgL+0dyVlX4lFrcY4ff1Md59GHE0r+ZTuqgYi6vnpHSqbLfrd3wNdjmJ3mjlRAti8kU+CZKNXxovzqAkuoQV2Gg8X+2PPucCU6F8DtjA1Tb35Bv4WZCVQtAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TOCNBNpg8pj5X3kpg0xrEiadcxZZFicj1B2uUAE+IjM=; b=ezLPLWAlYDmpn3y5RwCdCOrn91OIMLr7Uaa/fJ5mQAESHD2SjXMdtgI4ivH05P7meIBo5/T+H43jBoJTEr4CB3ih4SUZ07nW+Rb984Va/k8/ihB3xVOEEEZoV449o4i2BllvZL87rL6oI1j5f5b4zWly1sNj6jD/4XhkgmrlSYbQN/U7CKxhq/ZaLQHhzAJNPYJGge8xiEpRX+dRS15QBWoxoc8RXr/npcYIiefozHztP9Bb1sz+dFvgSRO5CwkHXwwiSKZJ43BwzoYmKHiIJcIb9wOPqLgvGt++Gh/UgWlpiNbC31PTZnnSA2kyzfm06eagt5MykgtGa/9X5F+yNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from CY4PR04MB0567.namprd04.prod.outlook.com (2603:10b6:903:b1::20) by SN6PR04MB4205.namprd04.prod.outlook.com (2603:10b6:805:30::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Sat, 23 Apr 2022 03:46:46 +0000 Received: from CY4PR04MB0567.namprd04.prod.outlook.com ([fe80::8e:6e22:f98c:29d5]) by CY4PR04MB0567.namprd04.prod.outlook.com ([fe80::8e:6e22:f98c:29d5%5]) with mapi id 15.20.5186.015; Sat, 23 Apr 2022 03:46:46 +0000 From: Jonathan Bakker To: Miquel Raynal Cc: Kyungmin Park , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Tomasz Figa , =?utf-8?q?Pawe=C5=82_Chmiel?= , Jonathan Bakker Subject: [PATCH 3/5] mtd: onenand: samsung: Unify resource order for controller variants Date: Fri, 22 Apr 2022 20:46:20 -0700 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220423034622.366696-1-xc-racer2@live.ca> References: <20220423034524.366612-1-xc-racer2@live.ca> <20220423034622.366696-1-xc-racer2@live.ca> X-TMN: [l2FdWO9S3Of0bxkli5/76lPwUFTdTVMeFfFO/wdP6TZtn5RBC1007aa2VLoXy9Gg] X-ClientProxiedBy: MW4PR04CA0210.namprd04.prod.outlook.com (2603:10b6:303:86::35) To CY4PR04MB0567.namprd04.prod.outlook.com (2603:10b6:903:b1::20) X-Microsoft-Original-Message-ID: <20220423034622.366696-2-xc-racer2@live.ca> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea943821-93a8-4df7-d37f-08da24dbe3a1 X-MS-TrafficTypeDiagnostic: SN6PR04MB4205:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d+bJautiTjtFkFFL6Cr5Iaf+oQLj9D718x20bWKhdGH94wuA6A1gz82f7ltmiCS0/6RXb2/wO9n1l6hWZ0fOz9aWZwvk4twIKdFTzkjsiEPZz2DPyoIPvj5QZz/mhTGgPXzvZQz2uNSDWQeWlNQzgK16P6sZc+sf5oDerHbaTLzubO03rEF+H2Alb0BvsYI6inroaPio1uPV1vFHPtgMgucZ6TQg2ShCc15YwHJ9Mbg3Bo7f3u0z7+sD0xYX0MsUwRMjnJONumthtXnNSS3eG4KppIWyrNkq5HSl84sHMWBoO+a/h7AaqZpxuPq39C2rA9bjCzfPMEHrqOxR5xsphtRSWbPP97Kp480GuXus5lO/5wEP2QnCk5DlNN+kEosC8u2zlWZwSdamz8KJp1uONwG9ESC8+Hw14IVZrg11mAUSoEKmdNIGHLZU3YgFzdtCvl5ZeiAx+tyvfvy7lELl85QwQy9V3va/qBmRDFu1wS0QgM8bkczTva+OnE4IX2dDX5J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qbwEdPmJe15ttm+wEo3Zum2uDHvdFu7?= =?utf-8?q?cG8eWnz7SDpCyMoLuJUXAXQbFmNnXPXCfxy24SukqCgYynvyYgubGkFGSY0iSJRCs?= =?utf-8?q?fWNVXceNs9YfTMYbzrSuCe8TlwI/xTTWIJipWy6PaAfLp+mZfl94/G62Va+J9I6Ai?= =?utf-8?q?mrO1SqLeDhNXYejfkhKGPXP8o4UOpirxgLSNpjZj0GKd1esh9CE0FMXB/CUDumLn7?= =?utf-8?q?c5Vss2ZuKgYREsHdIAdC+vi75Mv2G/iXgMJ200lzoSr7NT04335QfApgaWnHxP5Ww?= =?utf-8?q?DVWzwKbb5QDwSrK6julRTaD1mudxxZjB/Q/iKvk9ciNZA3MXP0eSHPbnGhhTSYPih?= =?utf-8?q?ZWIrS4nYVDNm/+ft0Agrm2/fmSsQWeiXeG46GRcBpSTHnycTP52URAZ3L5KeF8yFD?= =?utf-8?q?PWCJ/jny2fCdRHR0GhAasw6P3KukbLwnDcMEcEi8FGd9hxVQkPhNSjv/f+yU18i2e?= =?utf-8?q?cO1Th4OFoL1mpFAVsYXu5XDX4i2L01uPh+7+T84PdHUUTdKIRGkjFOYHBpmto+lzg?= =?utf-8?q?wEb5s4oB4RwqtnMesXJd7jRrMOfA2KFTsWqk9wY18dlgUY1derXpNxQDS8PY0Fuxj?= =?utf-8?q?VsALhUhm9YbBCoyVM67orLuVew37aPoIE1ucSPZD0wBRpllBBYLX6HYwIqGp5Uo54?= =?utf-8?q?bXlda4Eb6An2pLVYJrxHkE+z4+XdibYfoy7oDnWN8rXPGcJ85vcDaN0kw=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-edb50.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: ea943821-93a8-4df7-d37f-08da24dbe3a1 X-MS-Exchange-CrossTenant-AuthSource: CY4PR04MB0567.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2022 03:46:46.5723 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR04MB4205 Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org From: Tomasz Figa Before this patch, the order of memory resources requested by the driver was controller base as first and OneNAND chip base as second for S3C64xx/S5PC100 variant and the opposite for S5PC110/S5PV210 variant. To make this more consistent, this patch swaps the order of resources for the latter and updates platform code accordingly. As a nice side effect there is a slight reduction in line count of probe function. This will make the transition to DT-based probing much easier. Signed-off-by: Tomasz Figa Signed-off-by: Paweł Chmiel Signed-off-by: Jonathan Bakker --- drivers/mtd/nand/onenand/onenand_samsung.c | 48 ++++++++++------------ 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/drivers/mtd/nand/onenand/onenand_samsung.c b/drivers/mtd/nand/onenand/onenand_samsung.c index 924f5ddc9505..a3ef4add865a 100644 --- a/drivers/mtd/nand/onenand/onenand_samsung.c +++ b/drivers/mtd/nand/onenand/onenand_samsung.c @@ -123,14 +123,13 @@ struct s3c_onenand { struct mtd_info *mtd; struct platform_device *pdev; enum soc_type type; - void __iomem *base; - void __iomem *ahb_addr; + void __iomem *ctrl_base; + void __iomem *chip_base; int bootram_command; void *page_buf; void *oob_buf; unsigned int (*mem_addr)(int fba, int fpa, int fsa); unsigned int (*cmd_map)(unsigned int type, unsigned int val); - void __iomem *dma_addr; unsigned long phys_base; struct completion complete; }; @@ -144,22 +143,22 @@ static struct s3c_onenand *onenand; static inline int s3c_read_reg(int offset) { - return readl(onenand->base + offset); + return readl(onenand->ctrl_base + offset); } static inline void s3c_write_reg(int value, int offset) { - writel(value, onenand->base + offset); + writel(value, onenand->ctrl_base + offset); } static inline int s3c_read_cmd(unsigned int cmd) { - return readl(onenand->ahb_addr + cmd); + return readl(onenand->chip_base + cmd); } static inline void s3c_write_cmd(int value, unsigned int cmd) { - writel(value, onenand->ahb_addr + cmd); + writel(value, onenand->chip_base + cmd); } #ifdef SAMSUNG_DEBUG @@ -517,7 +516,7 @@ static int (*s5pc110_dma_ops)(dma_addr_t dst, dma_addr_t src, size_t count, int static int s5pc110_dma_poll(dma_addr_t dst, dma_addr_t src, size_t count, int direction) { - void __iomem *base = onenand->dma_addr; + void __iomem *base = onenand->ctrl_base; int status; unsigned long timeout; @@ -561,7 +560,7 @@ static int s5pc110_dma_poll(dma_addr_t dst, dma_addr_t src, size_t count, int di static irqreturn_t s5pc110_onenand_irq(int irq, void *data) { - void __iomem *base = onenand->dma_addr; + void __iomem *base = onenand->ctrl_base; int status, cmd = 0; status = readl(base + S5PC110_INTC_DMA_STATUS); @@ -583,7 +582,7 @@ static irqreturn_t s5pc110_onenand_irq(int irq, void *data) static int s5pc110_dma_irq(dma_addr_t dst, dma_addr_t src, size_t count, int direction) { - void __iomem *base = onenand->dma_addr; + void __iomem *base = onenand->ctrl_base; int status; status = readl(base + S5PC110_INTC_DMA_MASK); @@ -632,7 +631,7 @@ static int s5pc110_read_bufferram(struct mtd_info *mtd, int area, } if (offset & 3 || (size_t) buf & 3 || - !onenand->dma_addr || count != mtd->writesize) + !onenand->ctrl_base || count != mtd->writesize) goto normal; /* Handle vmalloc address */ @@ -862,23 +861,22 @@ static int s3c_onenand_probe(struct platform_device *pdev) s3c_onenand_setup(mtd); r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - onenand->base = devm_ioremap_resource(&pdev->dev, r); - if (IS_ERR(onenand->base)) - return PTR_ERR(onenand->base); - + onenand->ctrl_base = devm_ioremap_resource(&pdev->dev, r); + if (IS_ERR(onenand->ctrl_base)) + return PTR_ERR(onenand->ctrl_base); + + r = platform_get_resource(pdev, IORESOURCE_MEM, 1); + onenand->chip_base = devm_ioremap_resource(&pdev->dev, r); + if (IS_ERR(onenand->chip_base)) + return PTR_ERR(onenand->chip_base); onenand->phys_base = r->start; - /* Set onenand_chip also */ - this->base = onenand->base; - /* Use runtime badblock check */ this->options |= ONENAND_SKIP_UNLOCK_CHECK; if (onenand->type != TYPE_S5PC110) { - r = platform_get_resource(pdev, IORESOURCE_MEM, 1); - onenand->ahb_addr = devm_ioremap_resource(&pdev->dev, r); - if (IS_ERR(onenand->ahb_addr)) - return PTR_ERR(onenand->ahb_addr); + /* Set onenand_chip also */ + this->base = onenand->ctrl_base; /* Allocate 4KiB BufferRAM */ onenand->page_buf = devm_kzalloc(&pdev->dev, SZ_4K, @@ -896,10 +894,8 @@ static int s3c_onenand_probe(struct platform_device *pdev) this->subpagesize = mtd->writesize; } else { /* S5PC110 */ - r = platform_get_resource(pdev, IORESOURCE_MEM, 1); - onenand->dma_addr = devm_ioremap_resource(&pdev->dev, r); - if (IS_ERR(onenand->dma_addr)) - return PTR_ERR(onenand->dma_addr); + /* Set onenand_chip also */ + this->base = onenand->chip_base; s5pc110_dma_ops = s5pc110_dma_poll; /* Interrupt support */