From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752833AbdJFTW4 (ORCPT ); Fri, 6 Oct 2017 15:22:56 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:40102 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752594AbdJFTWE (ORCPT ); Fri, 6 Oct 2017 15:22:04 -0400 From: Liming Sun To: Jaehoon Chung , Ulf Hansson Cc: Liming Sun , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 9/9] mmc: dw_mmc: Parse slot-specific configuration Date: Fri, 6 Oct 2017 15:21:32 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit adds code to parse the child-nodes for slot specific configuration in the dw_mmc host driver according to linux/Documentation/devicetree/bindings/mmc/synopsys-dw-mshc.txt This change is needed when the cards have different configuration like the 'bus-width'. Signed-off-by: Liming Sun Reviewed-by: Chris Metcalf --- drivers/mmc/host/dw_mmc.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index a3188c2..9d870db 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2766,6 +2766,39 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +static void mmc_parse_slot_cfg(struct mmc_host *mmc) +{ + struct dw_mci_slot *slot = mmc_priv(mmc); + struct fwnode_handle *child; + u32 bus_width, id; + + /* Find the node for this card. */ + device_for_each_child_node(mmc->parent, child) { + if (!fwnode_property_read_u32(child, "reg", &id) && + id == slot->id) + break; + } + + if (!child) + return; + + if (!fwnode_property_read_u32(child, "bus-width", &bus_width)) { + switch (bus_width) { + case 8: + mmc->caps |= MMC_CAP_8_BIT_DATA; + /* Hosts capable of 8-bit can also do 4 bits. */ + case 4: + mmc->caps |= MMC_CAP_4_BIT_DATA; + break; + default: + break; + } + } + + if (fwnode_property_read_bool(child, "disable-wp")) + mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; +} + static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) { struct mmc_host *mmc; @@ -2830,10 +2863,14 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) if (host->pdata->caps2) mmc->caps2 = host->pdata->caps2; + /* Parse common configuration. */ ret = mmc_of_parse(mmc); if (ret) goto err_host_allocated; + /* Check per-slot configuration. */ + mmc_parse_slot_cfg(mmc); + /* Process SDIO IRQs through the sdio_irq_work. */ if (mmc->caps & MMC_CAP_SDIO_IRQ) mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD; -- 1.8.3.1