From patchwork Mon Oct 15 13:15:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 12231 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9D15423DE2 for ; Mon, 15 Oct 2012 13:16:10 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id CA2B9A1908E for ; Mon, 15 Oct 2012 13:16:09 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so7548963iej.11 for ; Mon, 15 Oct 2012 06:16:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=y2yshqvioJAkJh97TFyBHCjBrmAwOM9LbReqd4EotLY=; b=dlZ2NVZU5wFiFExFkoaDnsApNEY43UIdMme0Dx+HcLGJyib6rG9wSLBGYE7VxcYQrI miVd26T5kwaStUbKEADtHkegmCS4YClJ+3acbyVSD/uiXrQ4bc9vw0Ym3s9nS7Q5Jh/8 Yhp1mwxRGjXu9SQ6hHLYb+HufEQWbb5g8jD5EggJGyXGLjUhUCSEnKsy8rDInqPhohO9 kmWrCl/eMnb/mgksaTbYmmzAZMxuWzdnFzCd6Cr6DrayvmacPSAQ9xhjl3Ivy04fw5sJ kQbLDnvU5kak9mDGn0DhdsUuNGsXcNH6XDVbh4SVpAsF+me2wiNC+bV7Pcs+PfJoR1IY 2tUw== Received: by 10.50.236.72 with SMTP id us8mr8458174igc.70.1350306969195; Mon, 15 Oct 2012 06:16:09 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp572788igt; Mon, 15 Oct 2012 06:16:08 -0700 (PDT) Received: by 10.180.87.230 with SMTP id bb6mr23809525wib.6.1350306967445; Mon, 15 Oct 2012 06:16:07 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id t20si16720845wei.153.2012.10.15.06.16.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 06:16:07 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f50.google.com with SMTP id 16so4138774wgi.31 for ; Mon, 15 Oct 2012 06:16:06 -0700 (PDT) Received: by 10.216.212.225 with SMTP id y75mr7124573weo.39.1350306966658; Mon, 15 Oct 2012 06:16:06 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id p4sm15828402wix.0.2012.10.15.06.16.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Oct 2012 06:16:05 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Chris Ball , Russell King , linux-mmc@vger.kernel.org Subject: [PATCH 1/2] mmc: core: Support all MMC capabilities when booting from Device Tree Date: Mon, 15 Oct 2012 14:15:58 +0100 Message-Id: <1350306959-5843-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQk6NWf0zhzeJh75KN0ev0TzsGwIz6BSdm9hbIXPaUYAsA7IWwAvmXaNixI1d7hL/ojTo+i6 Capabilities are an important part of the MMC subsystem. Much supported functionality would be lost if we didn't provide the same level of support when booting Device Tree as we currently do when the subsystem is passed capabilities via platform data. This patch supplies this support with one simple call to a DT parsing function. Cc: Chris Ball Cc: Russell King Cc: linux-mmc@vger.kernel.org Acked-by: Linus Walleij Acked-by: Ulf Hansson Signed-off-by: Lee Jones --- drivers/mmc/core/host.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/host.h | 3 +- 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index ee2e16b..61a02db 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -436,3 +437,95 @@ void mmc_free_host(struct mmc_host *host) } EXPORT_SYMBOL(mmc_free_host); + +/** + * mmc_of_populate_caps - support all MMC capabilities from Device Tree + * @np: MMC OF device node + * @caps: Host capabilities - as per linux/mmc/host.h + * @caps2: More host cabibilies - as per linux/mmc/host.h + * + * Read capability string from the device node provided and populate + * the capability container accordingly. + */ +void mmc_of_populate_caps(struct device_node *np, + unsigned long *caps, + unsigned int *caps2) +{ + if(of_property_read_bool(np, "mmc-cap-4-bit-data")) + *caps |= MMC_CAP_4_BIT_DATA; + if(of_property_read_bool(np, "mmc-cap-mmc-highspeed")) + *caps |= MMC_CAP_MMC_HIGHSPEED; + if(of_property_read_bool(np, "mmc-cap-sd-highspeed")) + *caps |= MMC_CAP_SD_HIGHSPEED; + if(of_property_read_bool(np, "mmc-cap-sdio-irq")) + *caps |= MMC_CAP_SDIO_IRQ; + if(of_property_read_bool(np, "mmc-cap-spi")) + *caps |= MMC_CAP_SPI; + if(of_property_read_bool(np, "mmc-cap-needs-poll")) + *caps |= MMC_CAP_NEEDS_POLL; + if(of_property_read_bool(np, "mmc-cap-8-bit-data")) + *caps |= MMC_CAP_8_BIT_DATA; + if(of_property_read_bool(np, "mmc-cap-nonremovable")) + *caps |= MMC_CAP_NONREMOVABLE; + if(of_property_read_bool(np, "mmc-cap-wait-while-busy")) + *caps |= MMC_CAP_WAIT_WHILE_BUSY; + if(of_property_read_bool(np, "mmc-cap-erase")) + *caps |= MMC_CAP_ERASE; + if(of_property_read_bool(np, "mmc-cap-1-8v-ddr")) + *caps |= MMC_CAP_1_8V_DDR; + if(of_property_read_bool(np, "mmc-cap-1-2v-ddr")) + *caps |= MMC_CAP_1_2V_DDR; + if(of_property_read_bool(np, "mmc-cap-power-off-card")) + *caps |= MMC_CAP_POWER_OFF_CARD; + if(of_property_read_bool(np, "mmc-cap-bus-width-test")) + *caps |= MMC_CAP_BUS_WIDTH_TEST; + if(of_property_read_bool(np, "mmc-cap-uhs-sdr12")) + *caps |= MMC_CAP_UHS_SDR12; + if(of_property_read_bool(np, "mmc-cap-uhs-sdr25")) + *caps |= MMC_CAP_UHS_SDR25; + if(of_property_read_bool(np, "mmc-cap-uhs-sdr50")) + *caps |= MMC_CAP_UHS_SDR50; + if(of_property_read_bool(np, "mmc-cap-uhs-sdr104")) + *caps |= MMC_CAP_UHS_SDR104; + if(of_property_read_bool(np, "mmc-cap-uhs-ddr50")) + *caps |= MMC_CAP_UHS_DDR50; + if(of_property_read_bool(np, "mmc-cap-driver-type-a")) + *caps |= MMC_CAP_DRIVER_TYPE_A; + if(of_property_read_bool(np, "mmc-cap-driver-type-c")) + *caps |= MMC_CAP_DRIVER_TYPE_C; + if(of_property_read_bool(np, "mmc-cap-driver-type-d")) + *caps |= MMC_CAP_DRIVER_TYPE_D; + if(of_property_read_bool(np, "mmc-cap-cmd23")) + *caps |= MMC_CAP_CMD23; + if(of_property_read_bool(np, "mmc-cap-hw-reset")) + *caps |= MMC_CAP_HW_RESET; + + if(of_property_read_bool(np, "mmc-cap2-bootpart-noacc")) + *caps2 |= MMC_CAP2_BOOTPART_NOACC; + if(of_property_read_bool(np, "mmc-cap2-cache-ctrl")) + *caps2 |= MMC_CAP2_CACHE_CTRL; + if(of_property_read_bool(np, "mmc-cap2-poweroff-notify")) + *caps2 |= MMC_CAP2_POWEROFF_NOTIFY; + if(of_property_read_bool(np, "mmc-cap2-no-multi-read")) + *caps2 |= MMC_CAP2_NO_MULTI_READ; + if(of_property_read_bool(np, "mmc-cap2-no-sleep-cmd")) + *caps2 |= MMC_CAP2_NO_SLEEP_CMD; + if(of_property_read_bool(np, "mmc-cap2-hs200-1-8v-sdr")) + *caps2 |= MMC_CAP2_HS200_1_8V_SDR; + if(of_property_read_bool(np, "mmc-cap2-hs200-1-2v-sdr")) + *caps2 |= MMC_CAP2_HS200_1_2V_SDR; + if(of_property_read_bool(np, "mmc-cap2-hs200")) + *caps2 |= MMC_CAP2_HS200; + if(of_property_read_bool(np, "mmc-cap2-broken-voltage")) + *caps2 |= MMC_CAP2_BROKEN_VOLTAGE; + if(of_property_read_bool(np, "mmc-cap2-detect-on-err")) + *caps2 |= MMC_CAP2_DETECT_ON_ERR; + if(of_property_read_bool(np, "mmc-cap2-hc-erase-sz")) + *caps2 |= MMC_CAP2_HC_ERASE_SZ; + if(of_property_read_bool(np, "mmc-cap2-cd-active-high")) + *caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; + if(of_property_read_bool(np, "mmc-cap2-ro-active-high")) + *caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; +} + +EXPORT_SYMBOL(mmc_of_populate_caps); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 7abb0e1..612cf0e 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -344,7 +344,8 @@ extern struct mmc_host *mmc_alloc_host(int extra, struct device *); extern int mmc_add_host(struct mmc_host *); extern void mmc_remove_host(struct mmc_host *); extern void mmc_free_host(struct mmc_host *); - +extern void mmc_of_populate_caps(struct device_node *, + unsigned long *, unsigned int *); static inline void *mmc_priv(struct mmc_host *host) { return (void *)host->private;