From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1665FC64E7D for ; Sat, 28 Nov 2020 21:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E45DB20857 for ; Sat, 28 Nov 2020 21:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404232AbgK1VzL (ORCPT ); Sat, 28 Nov 2020 16:55:11 -0500 Received: from foss.arm.com ([217.140.110.172]:37426 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387620AbgK1T5h (ORCPT ); Sat, 28 Nov 2020 14:57:37 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43EFD30E; Sat, 28 Nov 2020 11:56:51 -0800 (PST) Received: from [192.168.2.22] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B0F3A3F23F; Sat, 28 Nov 2020 11:56:49 -0800 (PST) Subject: Re: [RESEND PATCH 17/19] mmc: sunxi: add support for A100 mmc controller To: Frank Lee , tiny.windzz@gmail.com Cc: Marek Vasut , Ulf Hansson , Wolfram Sang , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Ripard , Douglas Anderson , Rui Miguel Silva , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org References: From: =?UTF-8?Q?Andr=c3=a9_Przywara?= Organization: ARM Ltd. Message-ID: <65401815-cb2e-58ec-7653-f09d6a25804c@arm.com> Date: Sat, 28 Nov 2020 19:56:34 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/11/2020 06:46, Frank Lee wrote: Hi, > From: Yangtao Li > > This patch adds support for A100 MMC controller, which use word address > for internal dma. > > Signed-off-by: Yangtao Li > --- > drivers/mmc/host/sunxi-mmc.c | 28 +++++++++++++++++++++++++--- > 1 file changed, 25 insertions(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > index fc62773602ec..1518b64112b7 100644 > --- a/drivers/mmc/host/sunxi-mmc.c > +++ b/drivers/mmc/host/sunxi-mmc.c > @@ -244,6 +244,7 @@ struct sunxi_idma_des { > > struct sunxi_mmc_cfg { > u32 idma_des_size_bits; > + u32 idma_des_shift; > const struct sunxi_mmc_clk_delay *clk_delays; > > /* does the IP block support autocalibration? */ > @@ -343,7 +344,7 @@ static int sunxi_mmc_init_host(struct sunxi_mmc_host *host) > /* Enable CEATA support */ > mmc_writel(host, REG_FUNS, SDXC_CEATA_ON); > /* Set DMA descriptor list base address */ > - mmc_writel(host, REG_DLBA, host->sg_dma); > + mmc_writel(host, REG_DLBA, host->sg_dma >> host->cfg->idma_des_shift); > > rval = mmc_readl(host, REG_GCTRL); > rval |= SDXC_INTERRUPT_ENABLE_BIT; > @@ -373,8 +374,10 @@ static void sunxi_mmc_init_idma_des(struct sunxi_mmc_host *host, > > next_desc += sizeof(struct sunxi_idma_des); > pdes[i].buf_addr_ptr1 = > - cpu_to_le32(sg_dma_address(&data->sg[i])); > - pdes[i].buf_addr_ptr2 = cpu_to_le32((u32)next_desc); > + cpu_to_le32(sg_dma_address(&data->sg[i]) >> > + host->cfg->idma_des_shift); > + pdes[i].buf_addr_ptr2 = cpu_to_le32((u32)next_desc >> > + host->cfg->idma_des_shift); I think you should cast after the shift, otherwise you lose the ability to run above 4 GB. This won't be a problem at the moment, since we still use the default 32-bit DMA mask, but might bite us later. Otherwise this patch looks fine, and works on the H616 as well. Cheers, Andre > } > > pdes[0].config |= cpu_to_le32(SDXC_IDMAC_DES0_FD); > @@ -1178,6 +1181,23 @@ static const struct sunxi_mmc_cfg sun50i_a64_emmc_cfg = { > .needs_new_timings = true, > }; > > +static const struct sunxi_mmc_cfg sun50i_a100_cfg = { > + .idma_des_size_bits = 16, > + .idma_des_shift = 2, > + .clk_delays = NULL, > + .can_calibrate = true, > + .mask_data0 = true, > + .needs_new_timings = true, > +}; > + > +static const struct sunxi_mmc_cfg sun50i_a100_emmc_cfg = { > + .idma_des_size_bits = 13, > + .idma_des_shift = 2, > + .clk_delays = NULL, > + .can_calibrate = true, > + .needs_new_timings = true, > +}; > + > static const struct of_device_id sunxi_mmc_of_match[] = { > { .compatible = "allwinner,sun4i-a10-mmc", .data = &sun4i_a10_cfg }, > { .compatible = "allwinner,sun5i-a13-mmc", .data = &sun5i_a13_cfg }, > @@ -1186,6 +1206,8 @@ static const struct of_device_id sunxi_mmc_of_match[] = { > { .compatible = "allwinner,sun9i-a80-mmc", .data = &sun9i_a80_cfg }, > { .compatible = "allwinner,sun50i-a64-mmc", .data = &sun50i_a64_cfg }, > { .compatible = "allwinner,sun50i-a64-emmc", .data = &sun50i_a64_emmc_cfg }, > + { .compatible = "allwinner,sun50i-a100-mmc", .data = &sun50i_a100_cfg }, > + { .compatible = "allwinner,sun50i-a100-emmc", .data = &sun50i_a100_emmc_cfg }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, sunxi_mmc_of_match); > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 681BFC63777 for ; Sat, 28 Nov 2020 19:58:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 EE55C22210 for ; Sat, 28 Nov 2020 19:58:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OFG4k2N9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE55C22210 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SlPYY7uV7tBmvM2bySedDkpxVeEE06rphLPaHJr6jMs=; b=OFG4k2N9F1Uw0y6xHWdbuzUh5 BaY7Q3GBS9yHkjic5gEqLXqZZKTinYfjkdocuSfSr4lIpjMjJYMFqURkPhGYvkTEQKzSI+834SbHW xmtYrO5BdugnlS6G/5sKIMtb/6824hGzHYGOBiaeQdsLVDURZIvApOhvPr61aqMvHbippcZdsoqcf pO2zHI+62ygjQx+kZk0wuf/GfTqx/k2AAM//gZopZUsra6qIUEfkF6INV8hmvJfFbopD02K40ckgh 0tj36eTaP23e7oLPk9YM9PyN5xxJpYX+pPXrXyZvdPSJgWvTcQnv6wszayzk3j1Z3ZO5ujRYHOaqu kKgLH94Yw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kj6L3-0006Y4-QP; Sat, 28 Nov 2020 19:56:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kj6L0-0006Xi-8s for linux-arm-kernel@lists.infradead.org; Sat, 28 Nov 2020 19:56:55 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 43EFD30E; Sat, 28 Nov 2020 11:56:51 -0800 (PST) Received: from [192.168.2.22] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B0F3A3F23F; Sat, 28 Nov 2020 11:56:49 -0800 (PST) Subject: Re: [RESEND PATCH 17/19] mmc: sunxi: add support for A100 mmc controller To: Frank Lee , tiny.windzz@gmail.com References: From: =?UTF-8?Q?Andr=c3=a9_Przywara?= Organization: ARM Ltd. Message-ID: <65401815-cb2e-58ec-7653-f09d6a25804c@arm.com> Date: Sat, 28 Nov 2020 19:56:34 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201128_145654_521038_2ED42001 X-CRM114-Status: GOOD ( 24.96 ) 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: Marek Vasut , Ulf Hansson , Rui Miguel Silva , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Maxime Ripard , Douglas Anderson , Wolfram Sang , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/11/2020 06:46, Frank Lee wrote: Hi, > From: Yangtao Li > > This patch adds support for A100 MMC controller, which use word address > for internal dma. > > Signed-off-by: Yangtao Li > --- > drivers/mmc/host/sunxi-mmc.c | 28 +++++++++++++++++++++++++--- > 1 file changed, 25 insertions(+), 3 deletions(-) > > diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c > index fc62773602ec..1518b64112b7 100644 > --- a/drivers/mmc/host/sunxi-mmc.c > +++ b/drivers/mmc/host/sunxi-mmc.c > @@ -244,6 +244,7 @@ struct sunxi_idma_des { > > struct sunxi_mmc_cfg { > u32 idma_des_size_bits; > + u32 idma_des_shift; > const struct sunxi_mmc_clk_delay *clk_delays; > > /* does the IP block support autocalibration? */ > @@ -343,7 +344,7 @@ static int sunxi_mmc_init_host(struct sunxi_mmc_host *host) > /* Enable CEATA support */ > mmc_writel(host, REG_FUNS, SDXC_CEATA_ON); > /* Set DMA descriptor list base address */ > - mmc_writel(host, REG_DLBA, host->sg_dma); > + mmc_writel(host, REG_DLBA, host->sg_dma >> host->cfg->idma_des_shift); > > rval = mmc_readl(host, REG_GCTRL); > rval |= SDXC_INTERRUPT_ENABLE_BIT; > @@ -373,8 +374,10 @@ static void sunxi_mmc_init_idma_des(struct sunxi_mmc_host *host, > > next_desc += sizeof(struct sunxi_idma_des); > pdes[i].buf_addr_ptr1 = > - cpu_to_le32(sg_dma_address(&data->sg[i])); > - pdes[i].buf_addr_ptr2 = cpu_to_le32((u32)next_desc); > + cpu_to_le32(sg_dma_address(&data->sg[i]) >> > + host->cfg->idma_des_shift); > + pdes[i].buf_addr_ptr2 = cpu_to_le32((u32)next_desc >> > + host->cfg->idma_des_shift); I think you should cast after the shift, otherwise you lose the ability to run above 4 GB. This won't be a problem at the moment, since we still use the default 32-bit DMA mask, but might bite us later. Otherwise this patch looks fine, and works on the H616 as well. Cheers, Andre > } > > pdes[0].config |= cpu_to_le32(SDXC_IDMAC_DES0_FD); > @@ -1178,6 +1181,23 @@ static const struct sunxi_mmc_cfg sun50i_a64_emmc_cfg = { > .needs_new_timings = true, > }; > > +static const struct sunxi_mmc_cfg sun50i_a100_cfg = { > + .idma_des_size_bits = 16, > + .idma_des_shift = 2, > + .clk_delays = NULL, > + .can_calibrate = true, > + .mask_data0 = true, > + .needs_new_timings = true, > +}; > + > +static const struct sunxi_mmc_cfg sun50i_a100_emmc_cfg = { > + .idma_des_size_bits = 13, > + .idma_des_shift = 2, > + .clk_delays = NULL, > + .can_calibrate = true, > + .needs_new_timings = true, > +}; > + > static const struct of_device_id sunxi_mmc_of_match[] = { > { .compatible = "allwinner,sun4i-a10-mmc", .data = &sun4i_a10_cfg }, > { .compatible = "allwinner,sun5i-a13-mmc", .data = &sun5i_a13_cfg }, > @@ -1186,6 +1206,8 @@ static const struct of_device_id sunxi_mmc_of_match[] = { > { .compatible = "allwinner,sun9i-a80-mmc", .data = &sun9i_a80_cfg }, > { .compatible = "allwinner,sun50i-a64-mmc", .data = &sun50i_a64_cfg }, > { .compatible = "allwinner,sun50i-a64-emmc", .data = &sun50i_a64_emmc_cfg }, > + { .compatible = "allwinner,sun50i-a100-mmc", .data = &sun50i_a100_cfg }, > + { .compatible = "allwinner,sun50i-a100-emmc", .data = &sun50i_a100_emmc_cfg }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, sunxi_mmc_of_match); > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel