From patchwork Mon Dec 15 02:28:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 5489931 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CE48A9F1D4 for ; Mon, 15 Dec 2014 02:28:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E32D120A03 for ; Mon, 15 Dec 2014 02:28:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E61C8209BF for ; Mon, 15 Dec 2014 02:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751199AbaLOC2v (ORCPT ); Sun, 14 Dec 2014 21:28:51 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:60810 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751055AbaLOC2u (ORCPT ); Sun, 14 Dec 2014 21:28:50 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 15 Dec 2014 11:28:49 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id C89D43B33B; Mon, 15 Dec 2014 11:28:49 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id BC9281806F; Mon, 15 Dec 2014 11:28:49 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id B4F0C1800A; Mon, 15 Dec 2014 11:28:49 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id MAE00975; Mon, 15 Dec 2014 11:28:49 +0900 X-IronPort-AV: E=Sophos;i="5.07,577,1413212400"; d="scan'208";a="175701662" Received: from mail-hk1lp0121.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.121]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 15 Dec 2014 11:28:49 +0900 Received: from remon.renesas.com (211.11.155.132) by HKNPR06MB161.apcprd06.prod.outlook.com (10.242.104.16) with Microsoft SMTP Server (TLS) id 15.1.31.17; Mon, 15 Dec 2014 02:28:47 +0000 Message-ID: <8761ddve6l.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 6/7] mmc: sh_mobile: enable 32bit DMA access User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Ulf Hansson , Chris Ball CC: Simon , Linux-SH , linux-mmc In-Reply-To: <87egs1ve96.wl%kuninori.morimoto.gx@renesas.com> References: <87egs1ve96.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Date: Mon, 15 Dec 2014 02:28:47 +0000 X-Originating-IP: [211.11.155.132] X-ClientProxiedBy: HKNPR06CA0037.apcprd06.prod.outlook.com (10.141.16.27) To HKNPR06MB161.apcprd06.prod.outlook.com (10.242.104.16) Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB161; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601003); SRVR:HKNPR06MB161; X-Forefront-PRVS: 04267075BD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(199003)(189002)(54356999)(107046002)(99396003)(64706001)(47776003)(20776003)(19580395003)(66066001)(62966003)(92566001)(86362001)(77156002)(575784001)(87976001)(42186005)(46406003)(36756003)(122386002)(40100003)(76176999)(77096005)(229853001)(105586002)(120916001)(106356001)(23726002)(46102003)(68736005)(50986999)(21056001)(50466002)(97736003)(33646002)(19580405001)(69596002)(101416001)(81156004)(53416004)(4396001)(31966008)(83506001); DIR:OUT; SFP:1102; SCL:1; SRVR:HKNPR06MB161; H:remon.renesas.com; FPR:; SPF:None; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB161; X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@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=ham 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 | 44 +++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 0bec741..9d65fae 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,31 @@ struct sh_mobile_sdhi { struct tmio_mmc_dma dma_priv; }; +static void rcar_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: + /* + * SH-Mobile. 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 +123,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 */ + rcar_sdhi_sdbuf_width(host, 16); + return 0; } @@ -161,6 +192,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 */ + rcar_sdhi_sdbuf_width(host, enable ? 32 : 16); } static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev) @@ -184,7 +218,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) @@ -276,6 +309,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) mmc_data->flags |= of_data->tmio_flags; mmc_data->capabilities |= of_data->capabilities; mmc_data->capabilities2 |= of_data->capabilities2; + mmc_data->dma_buswidth = of_data->dma_buswidth; dma_priv->dma_rx_offset = of_data->dma_rx_offset; } @@ -290,14 +324,6 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) goto eprobe; /* - * 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. */