From patchwork Thu Mar 31 03:51:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keng-Yu Lin X-Patchwork-Id: 89008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id AE7A2B6F74 for ; Thu, 31 Mar 2011 14:52:33 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Q58vt-0002fN-8v; Thu, 31 Mar 2011 03:52:29 +0000 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1Q58vq-0002eU-OM for kernel-team@lists.ubuntu.com; Thu, 31 Mar 2011 03:52:26 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Q58vq-00069n-Kf for ; Thu, 31 Mar 2011 03:52:26 +0000 Received: from 114-45-59-58.dynamic.hinet.net ([114.45.59.58] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Q58vp-00052U-KT for kernel-team@lists.ubuntu.com; Thu, 31 Mar 2011 03:52:26 +0000 From: Keng-Yu Lin To: kernel-team@lists.ubuntu.com Subject: [PATCH 08/11] UBUNTU: SAUCE: (drop after 2.6.39) staging: rts_pstor: fix a bug that a greenhouse sd card can't be recognized Date: Thu, 31 Mar 2011 11:51:10 +0800 Message-Id: <1301543473-11146-9-git-send-email-keng-yu.lin@canonical.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1301543473-11146-1-git-send-email-keng-yu.lin@canonical.com> References: <1301543473-11146-1-git-send-email-keng-yu.lin@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: wwang A greenhouse sd card can't be recognized using rts5209. To fix this bug, these modifications are applied: 1, Move some codes which clear sd internal variables from sd_init_type to sd_prepare_reset. So sd_init_type is useless any more and is removed entirely; 2, If a sd card can't pass sd3.0 mode, the action of tunning phase should be avoided when retrying sd2.0 mode. Signed-off-by: wwang Signed-off-by: Greg Kroah-Hartman BugLink: http://bugs.launchpad.net/bugs/698006 (cherry picked from commit 2d2322b269c2524996a259024f82c7e318719696) Signed-off-by: Keng-Yu Lin --- drivers/staging/rts_pstor/sd.c | 56 ++++++++++++++++++++++----------------- 1 files changed, 32 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rts_pstor/sd.c b/drivers/staging/rts_pstor/sd.c index 80b61e6..21bfa57 100644 --- a/drivers/staging/rts_pstor/sd.c +++ b/drivers/staging/rts_pstor/sd.c @@ -1265,6 +1265,7 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) sd_card->func_group1_mask &= ~(sd_card->sd_switch_fail); + /* Function Group 1: Access Mode */ for (i = 0; i < 4; i++) { switch ((u8)(chip->sd_speed_prior >> (i*8))) { case SDR104_SUPPORT: @@ -1349,6 +1350,14 @@ static int sd_switch_function(struct rtsx_chip *chip, u8 bus_width) } } + if (!func_to_switch || (func_to_switch == HS_SUPPORT)) { + /* Do not try to switch current limit if the card doesn't + * support UHS mode or we don't want it to support UHS mode + */ + return STATUS_SUCCESS; + } + + /* Function Group 4: Current Limit */ func_to_switch = 0xFF; for (i = 0; i < 4; i++) { @@ -2015,6 +2024,17 @@ static int sd_prepare_reset(struct rtsx_chip *chip) sd_card->sd_clock = CLK_30; } + sd_card->sd_type = 0; + sd_card->seq_mode = 0; + sd_card->sd_data_buf_ready = 0; + sd_card->capacity = 0; + +#ifdef SUPPORT_SD_LOCK + sd_card->sd_lock_status = 0; + sd_card->sd_erase_status = 0; +#endif + + chip->capacity[chip->card2lun[SD_CARD]] = 0; chip->sd_io = 0; retval = sd_set_init_para(chip); @@ -2504,6 +2524,15 @@ SD_UNLOCK_ENTRY: sd_dont_switch = 1; if (!sd_dont_switch) { + if (sd20_mode) { + /* Set sd_switch_fail here, because we needn't + * switch to UHS mode + */ + sd_card->sd_switch_fail = SDR104_SUPPORT_MASK | + DDR50_SUPPORT_MASK | SDR50_SUPPORT_MASK; + } + + /* Check the card whether follow SD1.1 spec or higher */ retval = sd_check_spec(chip, switch_bus_width); if (retval == STATUS_SUCCESS) { retval = sd_switch_function(chip, switch_bus_width); @@ -2546,7 +2575,7 @@ SD_UNLOCK_ENTRY: sd_card->sd_lock_status &= ~SD_LOCK_1BIT_MODE; #endif - if (CHK_SD30_SPEED(sd_card)) { + if (!sd20_mode && CHK_SD30_SPEED(sd_card)) { int read_lba0 = 1; RTSX_WRITE_REG(chip, SD30_DRIVE_SEL, 0x07, chip->sd30_drive_sel_1v8); @@ -3040,28 +3069,6 @@ MMC_UNLOCK_ENTRY: return STATUS_SUCCESS; } -static void sd_init_type(struct rtsx_chip *chip) -{ - struct sd_info *sd_card = &(chip->sd_card); - - memset(sd_card, 0, sizeof(struct sd_info)); - - sd_card->sd_type = 0; - sd_card->seq_mode = 0; - sd_card->sd_data_buf_ready = 0; - sd_card->capacity = 0; - sd_card->sd_switch_fail = 0; - sd_card->mmc_dont_switch_bus = 0; - sd_card->need_retune = 0; - -#ifdef SUPPORT_SD_LOCK - sd_card->sd_lock_status = 0; - sd_card->sd_erase_status = 0; -#endif - - chip->capacity[chip->card2lun[SD_CARD]] = sd_card->capacity = 0; -} - int reset_sd_card(struct rtsx_chip *chip) { struct sd_info *sd_card = &(chip->sd_card); @@ -3069,7 +3076,8 @@ int reset_sd_card(struct rtsx_chip *chip) sd_init_reg_addr(chip); - sd_init_type(chip); + memset(sd_card, 0, sizeof(struct sd_info)); + chip->capacity[chip->card2lun[SD_CARD]] = 0; retval = enable_card_clock(chip, SD_CARD); if (retval != STATUS_SUCCESS) {