From patchwork Tue Jan 13 05:00:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 5617911 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 92649C058E for ; Tue, 13 Jan 2015 05:00:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AAE40205F7 for ; Tue, 13 Jan 2015 05:00:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5B7F20605 for ; Tue, 13 Jan 2015 05:00:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750845AbbAMFAM (ORCPT ); Tue, 13 Jan 2015 00:00:12 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:44823 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750728AbbAMFAK (ORCPT ); Tue, 13 Jan 2015 00:00:10 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 13 Jan 2015 14:00:09 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id A41333E5A6; Tue, 13 Jan 2015 14:00:09 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 84CAE8002E; Tue, 13 Jan 2015 14:00:09 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 7F9148002D; Tue, 13 Jan 2015 14:00:09 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id QAH09135; Tue, 13 Jan 2015 14:00:09 +0900 X-IronPort-AV: E=Sophos;i="5.07,747,1413212400"; d="scan'208";a="178567731" Received: from mail-hk1lp0121.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.121]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 13 Jan 2015 14:00:08 +0900 Received: from SINPR06MB170.apcprd06.prod.outlook.com (10.242.57.16) by SINPR06MB076.apcprd06.prod.outlook.com (10.242.54.21) with Microsoft SMTP Server (TLS) id 15.1.53.17; Tue, 13 Jan 2015 05:00:08 +0000 Received: from remon.renesas.com (211.11.155.132) by SINPR06MB170.apcprd06.prod.outlook.com (10.242.57.16) with Microsoft SMTP Server (TLS) id 15.1.53.17; Tue, 13 Jan 2015 05:00:07 +0000 Message-ID: <877fwruven.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 16/17] mmc: sh_mobile_sdhi: enable 32bit DMA access User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Ulf Hansson CC: Arnd Bergmann , Chris Ball , Simon , Linux-SH , linux-mmc In-Reply-To: <87twzvuvl1.wl%kuninori.morimoto.gx@renesas.com> References: <87twzvuvl1.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Date: Tue, 13 Jan 2015 05:00:07 +0000 X-Originating-IP: [211.11.155.132] X-ClientProxiedBy: SIXPR06CA0061.apcprd06.prod.outlook.com (25.160.171.179) To SINPR06MB170.apcprd06.prod.outlook.com (10.242.57.16) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-DmarcAction-Test: None X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(3005003);SRVR:SINPR06MB170; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:SINPR06MB170; X-Forefront-PRVS: 045584D28C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(62966003)(81156004)(40100003)(106356001)(54356999)(66066001)(105586002)(33646002)(53416004)(19580395003)(92566002)(69596002)(83506001)(2950100001)(19580405001)(46406003)(46102003)(110136001)(50986999)(76176999)(50466002)(47776003)(64706001)(97736003)(101416001)(122386002)(42186005)(77096005)(23726002)(229853001)(68736005)(86362001)(77156002)(36756003)(87976001)(575784001); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB170; H:remon.renesas.com; FPR:; SPF:None; MLV:sfv; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB170; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2015 05:00:07.3183 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SINPR06MB170 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB076; X-OriginatorOrg: renesas.com Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Now, sh_mobile_sdhi can use 32bit DMA access in R-Cer Gen2. Let's use it. Signed-off-by: Kuninori Morimoto --- drivers/mmc/host/sh_mobile_sdhi.c | 42 +++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 4091329..7dbcb57 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -41,6 +41,7 @@ struct sh_mobile_sdhi_of_data { unsigned long tmio_flags; unsigned long capabilities; unsigned long capabilities2; + enum dma_slave_buswidth dma_buswidth; dma_addr_t dma_rx_offset; }; @@ -60,6 +61,7 @@ static const struct sh_mobile_sdhi_of_data of_rcar_gen2_compatible = { .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_CLK_ACTUAL, .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, + .dma_buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES, .dma_rx_offset = 0x2000, }; @@ -86,6 +88,29 @@ struct sh_mobile_sdhi { struct tmio_mmc_dma dma_priv; }; +static void sh_mobile_sdhi_sdbuf_width(struct tmio_mmc_host *host, int width) +{ + u32 val; + + /* + * see also + * sh_mobile_sdhi_of_data :: dma_buswidth + */ + switch (sd_ctrl_read16(host, CTL_VERSION)) { + case 0x490C: + val = (width == 32) ? 0x0001 : 0x0000; + break; + case 0xCB0D: + val = (width == 32) ? 0x0000 : 0x0001; + break; + default: + /* nothing to do */ + return; + } + + sd_ctrl_write16(host, EXT_ACC, val); +} + static int sh_mobile_sdhi_clk_enable(struct platform_device *pdev, unsigned int *f) { struct mmc_host *mmc = platform_get_drvdata(pdev); @@ -96,6 +121,10 @@ static int sh_mobile_sdhi_clk_enable(struct platform_device *pdev, unsigned int return ret; *f = clk_get_rate(priv->clk); + + /* enable 16bit data access on SDBUF as default */ + sh_mobile_sdhi_sdbuf_width(host, 16); + return 0; } @@ -161,6 +190,9 @@ static int sh_mobile_sdhi_multi_io_quirk(struct mmc_card *card, static void sh_mobile_sdhi_enable_dma(struct tmio_mmc_host *host, bool enable) { sd_ctrl_write16(host, CTL_DMA_ENABLE, enable ? 2 : 0); + + /* enable 32bit access if DMA mode if possibile */ + sh_mobile_sdhi_sdbuf_width(host, enable ? 32 : 16); } static int sh_mobile_sdhi_probe(struct platform_device *pdev) @@ -175,7 +207,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) int irq, ret, i = 0; bool multiplexed_isr = true; struct tmio_mmc_dma *dma_priv; - u16 ver; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) @@ -271,6 +302,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) mmc_data->capabilities |= of_data->capabilities; mmc_data->capabilities2 |= of_data->capabilities2; mmc_data->dma_rx_offset = of_data->dma_rx_offset; + dma_priv->dma_buswidth = of_data->dma_buswidth; } ret = tmio_mmc_host_probe(host, mmc_data); @@ -278,14 +310,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) goto efree; /* - * FIXME: - * this Workaround can be more clever method - */ - ver = sd_ctrl_read16(host, CTL_VERSION); - if (ver == 0xCB0D) - sd_ctrl_write16(host, EXT_ACC, 1); - - /* * Allow one or more specific (named) ISRs or * one or more multiplexed (un-named) ISRs. */