From patchwork Mon Sep 8 04:29:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4859941 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 BDD1A9F35F for ; Mon, 8 Sep 2014 04:29:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDEAB2012F for ; Mon, 8 Sep 2014 04:29:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6385200D4 for ; Mon, 8 Sep 2014 04:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483AbaIHE3h (ORCPT ); Mon, 8 Sep 2014 00:29:37 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:60649 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751401AbaIHE3g (ORCPT ); Mon, 8 Sep 2014 00:29:36 -0400 Received: by mail-pa0-f52.google.com with SMTP id eu11so26573141pac.11 for ; Sun, 07 Sep 2014 21:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:subject:user-agent:to:cc:mime-version :content-type; bh=uQea39Wj7XCVt3AFpd+ELGPK040FyGngQb3VsU73Q4k=; b=iIg6zBmYWZfF30b4hyOVY3PfKK5+FuysK0n7tqwvCNox7D6CLNiDeKxY5iXh7TEBAt 8w6aBTM9O7zZSNQSgzKG3eeT31qCSH/SQYb+NcupjCDSpIX92AcHgBIS2E3gVI3U4jow iBjPcHVxuekEeJq9Fv/QwCIqQNN89EkZC2/WF+VRsotq9LjDUcs7xfDsm2I0T7dTceBV UH++yRUMrogbtje/psvdh0Z8QVNhE8RRetNY99vlZL87M7b24d0yCm6ZBjCygoOxLA+w KgynIpi7QFOzk6iHNDpsS/gjHZJnTN2QoAt3R7+n8IBQ37Z27mfynRYbuOSvwYS6wZ/Q e4qw== X-Received: by 10.66.102.7 with SMTP id fk7mr42375856pab.127.1410150575643; Sun, 07 Sep 2014 21:29:35 -0700 (PDT) Received: from remon.gmail.com (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id qa2sm7718986pdb.38.2014.09.07.21.29.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 07 Sep 2014 21:29:34 -0700 (PDT) Date: Sun, 07 Sep 2014 21:29:34 -0700 (PDT) Message-ID: <87wq9eohuc.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto Subject: [PATCH] mmc: tmio: enable odd number size transfer User-Agent: Wanderlust/2.14.0 Emacs/23.3 Mule/6.0 To: Ulf Hansson , Chris Ball Cc: Simon , Kuninori Morimoto , Linux-SH , linux-mmc MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Current tmio is using sd_ctrl_read16/write16_rep() for data transfer. It works if transfer size was even number, but, last 1 byte will be ignored if transfer size was odd number. This patch adds new tmio_mmc_transfer_data() and solve this issue. Tested-by: Shinobu Uehara Signed-off-by: Kuninori Morimoto --- drivers/mmc/host/tmio_mmc_pio.c | 42 +++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index ba45413..817ec7d 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -376,6 +376,43 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command return 0; } +static void tmio_mmc_transfer_data(struct tmio_mmc_host *host, + unsigned short *buf, + unsigned int count) +{ + int is_read = host->data->flags & MMC_DATA_READ; + u16 extra; + u8 *extra8; + u8 *buf8; + + /* + * Transfer the data + */ + if (is_read) + sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1); + else + sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1); + + /* count was even number */ + if (!(count & 0x1)) + return; + + /* count was odd number */ + + extra8 = (u8 *)&extra; + buf8 = (u8 *)(buf + ((count - 1) >> 1)); + + if (is_read) { + extra = sd_ctrl_read16(host, CTL_SD_DATA_PORT); + + buf8[1] = extra8[1]; + } else { + extra = buf8[1] << 8; + + sd_ctrl_write16(host, CTL_SD_DATA_PORT, extra); + } +} + /* * This chip always returns (at least?) as much data as you ask for. * I'm unsure what happens if you ask for less than a block. This should be @@ -408,10 +445,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host) count, host->sg_off, data->flags); /* Transfer the data */ - if (data->flags & MMC_DATA_READ) - sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1); - else - sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1); + tmio_mmc_transfer_data(host, buf, count); host->sg_off += count;