Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932298AbaDKP72 (ORCPT ); Fri, 11 Apr 2014 11:59:28 -0400 Received: from mail-oa0-f43.google.com ([209.85.219.43]:38489 "EHLO mail-oa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754296AbaDKP7M (ORCPT ); Fri, 11 Apr 2014 11:59:12 -0400 MIME-Version: 1.0 In-Reply-To: References: <1397172708-19735-1-git-send-email-tim.kryger@linaro.org> Date: Fri, 11 Apr 2014 08:59:11 -0700 Message-ID: Subject: Re: [PATCH] mmc: sdhci: Set ocr_avail directly based on vmmc From: Tim Kryger To: Ulf Hansson Cc: Chris Ball , Linux MMC Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 11, 2014 at 1:15 AM, Ulf Hansson wrote: > On 11 April 2014 01:31, Tim Kryger wrote: >> +static unsigned int sdhci_get_ocr_avail_from_vmmc(struct sdhci_host *host) >> +{ >> + unsigned int ocr_avail = 0; >> + struct regulator *vmmc = host->vmmc; >> + >> + if (regulator_is_supported_voltage(vmmc, 1650000, 1950000) > 0) >> + ocr_avail |= MMC_VDD_165_195; >> + >> + if (regulator_is_supported_voltage(vmmc, 2900000, 3000000) > 0) >> + ocr_avail |= MMC_VDD_29_30; >> + >> + if (regulator_is_supported_voltage(vmmc, 3000000, 3100000) > 0) >> + ocr_avail |= MMC_VDD_30_31; >> + >> + if (regulator_is_supported_voltage(vmmc, 3200000, 3300000) > 0) >> + ocr_avail |= MMC_VDD_32_33; >> + >> + if (regulator_is_supported_voltage(vmmc, 3300000, 3400000) > 0) >> + ocr_avail |= MMC_VDD_33_34; >> + >> + return ocr_avail; >> +} >> + > > There is an API called mmc_regulator_get_ocrmask() for this. Great. Thanks for pointing this out. >> + ocr_avail = sdhci_get_ocr_avail_from_vmmc(host); >> + } else { >> + if (caps[0] & SDHCI_CAN_VDD_330) >> + ocr_avail |= MMC_VDD_32_33 | MMC_VDD_33_34; >> + if (caps[0] & SDHCI_CAN_VDD_300) >> + ocr_avail |= MMC_VDD_29_30 | MMC_VDD_30_31; >> + if (caps[0] & SDHCI_CAN_VDD_180) >> + ocr_avail |= MMC_VDD_165_195; >> + } >> + >> + if (host->ocr_mask) >> + ocr_avail = host->ocr_mask; >> + >> + mmc->ocr_avail = ocr_avail; >> + mmc->ocr_avail_sdio = ocr_avail; >> + if (host->ocr_avail_sdio) >> + mmc->ocr_avail_sdio &= host->ocr_avail_sdio; >> + mmc->ocr_avail_sd = ocr_avail; >> + if (host->ocr_avail_sd) >> + mmc->ocr_avail_sd &= host->ocr_avail_sd; >> + else /* normal SD controllers don't support 1.8V */ >> + mmc->ocr_avail_sd &= ~MMC_VDD_165_195; >> + mmc->ocr_avail_mmc = ocr_avail; >> + if (host->ocr_avail_mmc) >> + mmc->ocr_avail_mmc &= host->ocr_avail_mmc; >> + >> + if (mmc->ocr_avail == 0) { >> + pr_err("%s: Hardware doesn't report any support voltages.\n", >> + mmc_hostname(mmc)); >> + return -ENODEV; >> + } > > I have not fully understand why you have different ocr masks depending > on what card you initialize. Is that really supported by the > controller? Would you mind clarifying your question? I'm not sure what you are after. Also this logic is mostly unchanged, I have simply moved it up earlier in the function to keep all the ocr parts together. > I have seen some patches around lately touching the code for handling > the regulators (vcc and vccq) in sdhci. > > A few times I have suggested to switch to use the > mmc_regulator_get_supply() API to simplify and consolidate code. Could > you please have a look at that? Sure, I'll take a look. Thanks for the helpful comments. -Tim -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/