From patchwork Fri Oct 4 11:59:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 11174329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F58716B1 for ; Fri, 4 Oct 2019 12:07:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36CF3215EA for ; Fri, 4 Oct 2019 12:07:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MrOtPH7S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36CF3215EA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kaod.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eZ8CL8m5TqCbDvlARLJIaha9TTmmaFsaOTIumZYY0Ug=; b=MrOtPH7SSHx83g BsCFUGHisGbXrqFwi1IHp9mDidjgTiCpnFb46n8whxDkwQbywvVbCaqRm9CrrQQ+cvDyeE0StspJ7 3UcH3LYzMQm8eO0WvIGKeoEgB2dfgwGd+3rlGWxdtOhJ0WYzlEPuAwsDoBMavOeWXtn15+aH2mkJD ZOWUMVEXE7dzhAkq2vPyrcP4+qakDcykkQM1Fw7wbVs01ix/+VtY2tOyJQulhwaafFe70gF8JAx2O ASE0LJ/ig7O9/X6zssFl0Yq8X7iPj/hY9UA9yaYa/9AW5Zoxcnp43EXNGVz7JhtaOr6Z/qHrUS8aY DUWXSpHtBgGDhrd55IGA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iGMMs-0005Kd-Tk; Fri, 04 Oct 2019 12:07:30 +0000 Received: from 4.mo177.mail-out.ovh.net ([46.105.37.72]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iGMIf-0000NT-OJ for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2019 12:03:12 +0000 Received: from player792.ha.ovh.net (unknown [10.108.54.74]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id EF3C310D10B for ; Fri, 4 Oct 2019 14:03:06 +0200 (CEST) Received: from kaod.org (lfbn-1-2229-223.w90-76.abo.wanadoo.fr [90.76.50.223]) (Authenticated sender: clg@kaod.org) by player792.ha.ovh.net (Postfix) with ESMTPSA id 188B1AA663E2; Fri, 4 Oct 2019 12:02:50 +0000 (UTC) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: linux-mtd@lists.infradead.org, Tudor Ambarus Subject: [PATCH 12/16] mtd: spi-nor: aspeed: Add initial support for the AST2600 Date: Fri, 4 Oct 2019 13:59:15 +0200 Message-Id: <20191004115919.20788-13-clg@kaod.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191004115919.20788-1-clg@kaod.org> References: <20191004115919.20788-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 3817363635969362867 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrhedugdegudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191004_050309_986600_A1A2A701 X-CRM114-Status: GOOD ( 16.00 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.105.37.72 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [46.105.37.72 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Vignesh Raghavendra , linux-aspeed@lists.ozlabs.org, Andrew Jeffery , Richard Weinberger , Marek Vasut , Joel Stanley , Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The HW interface of AST2600 SoC SMC controllers is very similar to the the AST2500. The AST2600 Firmware Memory Controller is now SPI only. The Segment Registers also have a different encoding. A 1MB unit is used and the address range of a flash SPI device is encoded with offsets in the overall controller window. The previous SoC AST2400 and AST2500 used absolute addresses. Only bits [27:20] are relevant and the end address is an upper bound limit. Read training yet to come. Signed-off-by: Cédric Le Goater Reviewed-by: Andrew Jeffery --- drivers/mtd/spi-nor/aspeed-smc.c | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c index 7cdd84a2ca82..c977f8f28aef 100644 --- a/drivers/mtd/spi-nor/aspeed-smc.c +++ b/drivers/mtd/spi-nor/aspeed-smc.c @@ -116,6 +116,39 @@ static const struct aspeed_smc_info spi_2500_info = { .segment_reg = aspeed_smc_segment_reg, }; +static u32 aspeed_smc_segment_start_ast2600(struct aspeed_smc_controller *ctrl, + u32 reg); +static u32 aspeed_smc_segment_end_ast2600(struct aspeed_smc_controller *ctrl, + u32 reg); +static u32 aspeed_smc_segment_reg_ast2600(struct aspeed_smc_controller *ctrl, + u32 start, u32 end); + +static const struct aspeed_smc_info fmc_2600_info = { + .maxsize = 256 * 1024 * 1024, + .nce = 3, + .hastype = false, /* SPI Only */ + .we0 = 16, + .ctl0 = 0x10, + .timing = 0x94, + .set_4b = aspeed_smc_chip_set_4b, + .segment_start = aspeed_smc_segment_start_ast2600, + .segment_end = aspeed_smc_segment_end_ast2600, + .segment_reg = aspeed_smc_segment_reg_ast2600, +}; + +static const struct aspeed_smc_info spi_2600_info = { + .maxsize = 256 * 1024 * 1024, + .nce = 2, + .hastype = false, + .we0 = 16, + .ctl0 = 0x10, + .timing = 0x94, + .set_4b = aspeed_smc_chip_set_4b, + .segment_start = aspeed_smc_segment_start_ast2600, + .segment_end = aspeed_smc_segment_end_ast2600, + .segment_reg = aspeed_smc_segment_reg_ast2600, +}; + enum aspeed_smc_ctl_reg_value { smc_base, /* base value without mode for other commands */ smc_read, /* command reg for (maybe fast) reads */ @@ -251,6 +284,39 @@ static u32 aspeed_smc_segment_reg(struct aspeed_smc_controller *controller, return (((start >> 23) & 0xFF) << 16) | (((end >> 23) & 0xFF) << 24); } +/* + * The Segment Registers of the AST2600 have a 1MB unit. The address + * range of a flash SPI slave is encoded with offsets in the overall + * controller window. The previous SoC AST2400 and AST2500 used + * absolute addresses. Only bits [27:20] are relevant and the end + * address is an upper bound limit. + */ + +#define AST2600_SEG_ADDR_MASK 0x0ff00000 + +static u32 aspeed_smc_segment_start_ast2600(struct aspeed_smc_controller *ctlr, + u32 reg) +{ + u32 start_offset = (reg << 16) & AST2600_SEG_ADDR_MASK; + + return ctlr->ahb_base_phy + start_offset; +} + +static u32 aspeed_smc_segment_end_ast2600(struct aspeed_smc_controller *ctlr, + u32 reg) +{ + u32 end_offset = reg & AST2600_SEG_ADDR_MASK; + + return ctlr->ahb_base_phy + end_offset + 0x100000; +} + +static u32 aspeed_smc_segment_reg_ast2600(struct aspeed_smc_controller *ctlr, + u32 start, u32 end) +{ + return ((start & AST2600_SEG_ADDR_MASK) >> 16) | + ((end - 1) & AST2600_SEG_ADDR_MASK); +} + /* * Switch to turn off read optimisation if needed */ @@ -538,6 +604,8 @@ static const struct of_device_id aspeed_smc_matches[] = { { .compatible = "aspeed,ast2400-spi", .data = &spi_2400_info }, { .compatible = "aspeed,ast2500-fmc", .data = &fmc_2500_info }, { .compatible = "aspeed,ast2500-spi", .data = &spi_2500_info }, + { .compatible = "aspeed,ast2600-fmc", .data = &fmc_2600_info }, + { .compatible = "aspeed,ast2600-spi", .data = &spi_2600_info }, { } }; MODULE_DEVICE_TABLE(of, aspeed_smc_matches);