From patchwork Wed Sep 10 01:29:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 4873511 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B2B37C0338 for ; Wed, 10 Sep 2014 01:29:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6FB52017D for ; Wed, 10 Sep 2014 01:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A785F200DF for ; Wed, 10 Sep 2014 01:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751379AbaIJB3S (ORCPT ); Tue, 9 Sep 2014 21:29:18 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:43451 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750852AbaIJB3R (ORCPT ); Tue, 9 Sep 2014 21:29:17 -0400 Received: by mail-pd0-f177.google.com with SMTP id y10so2328373pdj.36 for ; Tue, 09 Sep 2014 18:29:16 -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=bfSqobxe6hz65XOl+8wRfSQpTrS97dzGIbvNOsFgp+M=; b=hgJRhPAHibVpA4p9s8tvbphH+XHBwTjxNLsJ7xslkTvcSR2W0wPOEqKfk3eh9xPTVj nAccU0kEtOv49Zp64OAlmbXWUKhkkAX/jkLOMPIBPsD0z0q4lfsBllsYrxtpUorZJ58h f344ec03ynJ5M9RjDdi7k94ztwymfCzVCp0JjCFSv2jb4UgCqKKSStdjp01pAmfJAlTX kK3qEpoK++cTXAOOUCh3czXIEg1fayCJdhP3V372lzyBOhEcw1czAq6GuL7Xk9xj7viO fXLm7DXiNTGrU5LF3AYb70Y9xZysWSAPbFa8B4Y0LWy4bFvBGM8B0hlLKTPXfdK3q28w 1HvA== X-Received: by 10.70.130.138 with SMTP id oe10mr63775308pdb.115.1410312556874; Tue, 09 Sep 2014 18:29:16 -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 zr6sm12734384pbc.50.2014.09.09.18.29.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 09 Sep 2014 18:29:16 -0700 (PDT) Date: Tue, 09 Sep 2014 18:29:16 -0700 (PDT) Message-ID: <8761gwz2jb.wl%kuninori.morimoto.gx@gmail.com> From: Kuninori Morimoto Subject: [PATCH v2] mmc: tmio: enable odd number size access 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 , Shinobu Uehara 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=-9.3 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 --- v1 -> v2 - use u8 pointer only - fix buf offset - remove unneeded -1 drivers/mmc/host/tmio_mmc_pio.c | 46 +++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index ff5ff0f..2ee0e21 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -376,6 +376,47 @@ 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 *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 */ + + buf8 = (u8 *)(buf + (count >> 1)); + + /* + * FIXME + * + * driver and this function are assuming that + * it is used as little endian + */ + if (is_read) { + extra = sd_ctrl_read16(host, CTL_SD_DATA_PORT); + + *buf8 = (u8)(extra & 0xff); + } else { + extra = (u16)(*buf8); + + 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 +449,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;