Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp182770imp; Tue, 19 Feb 2019 21:19:32 -0800 (PST) X-Google-Smtp-Source: AHgI3IYv81HUEr1dBlrGYCUHiVvtzyWKudZJtVVchm05L3dobRpO5l6JBE3JAimjvMusc5Vzs4mG X-Received: by 2002:a63:ce:: with SMTP id 197mr27108074pga.212.1550639972002; Tue, 19 Feb 2019 21:19:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550639971; cv=none; d=google.com; s=arc-20160816; b=l3VQZ5DP+cDIdDL1L2WWcY7i/GlgM0kaf/OEggdm5e/+ZjXnPOiCLHC8GiizSibNoA pkwah1o5ULQHNQdXEwLbxXAV1ZdFbJ0AXShEAC36Fnm/tKzqlU1aCI3AnIKS5agGEGLB CvoUwrLqqs1wWpGYNagSgAeLgYn1NsTi/cTl7GqNqEHcdwn86NxyQvZbK0z4i/cIYiEd zPqqRG8KeZt/MhVcFrgpsPsAS0hl87ZetolGQtBDSKR9w632rt9/tDV0xqCM+iE+JRzu r+2YBXgIRVaMoHOCW+uuQs3BDLa35+yw28nb0Wcn/3JpqZepVM5gJ9/jYnc9WI7koTUf BMPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dpQnCqYK8zQeRAaUTV8LjE1UVmbI8+tnujnQmz5gcr8=; b=s+k99xOrkwFNMLCbhloqtfkp29zVM3sUzwIuKi3/jxtZQ1SRAGBDh5CpNuTtPEuLcg B6fVVeepDKtza71hYsMe/38DDiZgskzvWLF6dugUbxGhdeolqAGGOk4aNEShJeSvBr1t Qm0JZFyG5mb+VxWXnLT53Lv0NDl3doN4WOIQBIOAxn5uiESJ/4rD0blxw4OzNZwIvgHO QqGmEKW1940cYMaxrHru7F7FtBwSkyttopV9txifpPlbz0fw7DuOWbJDhsQ7QNvpFl/0 +wcPN2C8j03aurOqsBi3sqzq1Fhi6w5QyEKgLKp6tyoDRwDmCUdG9/yU65t9Y7H6cmvt yMEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Br2Z+EZj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 43si15093573plb.299.2019.02.19.21.19.17; Tue, 19 Feb 2019 21:19:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Br2Z+EZj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbfBTFSO (ORCPT + 99 others); Wed, 20 Feb 2019 00:18:14 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:51840 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbfBTFSM (ORCPT ); Wed, 20 Feb 2019 00:18:12 -0500 Received: by mail-it1-f193.google.com with SMTP id y184so12455511itc.1 for ; Tue, 19 Feb 2019 21:18:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dpQnCqYK8zQeRAaUTV8LjE1UVmbI8+tnujnQmz5gcr8=; b=Br2Z+EZjM1fBYP5AaRzSQRwuIiAYydfoVFnAOTyb0sZ3rnjLysp6rDBJp691H/cv/g 7j3nHRyAO/h4P33RdOmJz+Um8NIj2Lon0S/YUcs6zuIetuIL8YXNatU2MgQoLGxFy8Fs HF3TreY9dSJeVcaR9b3VoBRWvTyII7Hp1PtrhhbLXXQXpTrlYh8I/ngXEs9c0StVwUH+ fO2XkZS5SsB/AL+IJtlHZzFarjFKUhCwr3akIOFbDMuuFEwIntgxMhjHDGWDuNPtinAq 5GhaCCZkziZgEfhlhXMGb5RMkJE9z7qTvPzG9N+dI+1enDxQNb11PDhMKRDaeBoRLg4k 84+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dpQnCqYK8zQeRAaUTV8LjE1UVmbI8+tnujnQmz5gcr8=; b=cji7RNgjgDZ5YxXJSPrE64yzOb3JS0S7R0eumtitdgln2XciPMyeWLZhUR0lGoNDqA CcJavLNzU/WHkBezhosEXYxGBz5Z764Nwp7SBRLUjl2O5XsTfo0RQCUhAATOwO56pxL+ 0/jURiVY3ZF8c9cHxPxOuki5cXL4M3r9AYZdyule3y0ivEqmnkUIVtQLs4R8N2uncjjv htFiWonTLqVRSJClcewZa4wVnYnJ6/jPyJHOtZ/1TdN9gg3V/oBr7vxYPcOuQJvK+hTq HVEuY0NpFdt3UM5DXW/ydCzLHTP8ieGfd0EkgkuHfG7wGGR40sMFGK5D0SsH/4rh/Yav BIBA== X-Gm-Message-State: AHQUAuamskgLiCYCiHxc97blmWx8jBBFglnabmFtIBsuNMGz62NBDCFR ol40RtRq6ifbdn7cFqmdHrc= X-Received: by 2002:a6b:c544:: with SMTP id v65mr16636993iof.222.1550639891392; Tue, 19 Feb 2019 21:18:11 -0800 (PST) Received: from localhost.localdomain (c-73-242-244-99.hsd1.nm.comcast.net. [73.242.244.99]) by smtp.gmail.com with ESMTPSA id k64sm2297550itb.7.2019.02.19.21.18.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 21:18:10 -0800 (PST) From: George Hilliard To: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org, Neil Brown , George Hilliard Subject: [PATCH 05/10] staging: mt7621-mmc: Use pinctrl subsystem to select SDXC pin mode Date: Tue, 19 Feb 2019 22:17:49 -0700 Message-Id: <20190220051754.12195-6-thirtythreeforty@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220051754.12195-1-thirtythreeforty@gmail.com> References: <20190220051754.12195-1-thirtythreeforty@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver previously grabbed the SD pins for itself, ignoring the pin controller. Replace this direct register access with appropriate calls to the pinctrl subsystem. This also allows this driver to work on related devices that have a different pin controller mapping, such as the MT7688. The hardcoded bit index was incorrect on that device. This change could break SD controller functionality on existing devices whose device trees do not specify a pin controller and state for the SD node. Signed-off-by: George Hilliard --- drivers/staging/mt7621-mmc/sd.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index a7c7ec0d7bbb..97ed7510e96d 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -1599,6 +1600,8 @@ static int msdc_drv_probe(struct platform_device *pdev) struct msdc_host *host; struct msdc_hw *hw; int ret; + struct pinctrl *pctrl; + struct pinctrl_state *pins_default; hw = &msdc0_hw; @@ -1671,6 +1674,25 @@ static int msdc_drv_probe(struct platform_device *pdev) host->mrq = NULL; + /* Read pin control settings from device tree */ + pctrl = devm_pinctrl_get(&pdev->dev); + if (IS_ERR(pctrl)) { + ret = PTR_ERR(pctrl); + dev_err(&pdev->dev, "Cannot find pinctrl in device tree\n"); + goto host_free; + } + + pins_default = pinctrl_lookup_state(pctrl, PINCTRL_STATE_DEFAULT); + if (IS_ERR(pins_default)) { + ret = PTR_ERR(pins_default); + dev_err(&pdev->dev, "Cannot find pinctrl state default\n"); + goto host_free; + } + + ret = pinctrl_select_state(pctrl, pins_default); + if (ret < 0) + dev_warn(&pdev->dev, "Cannot select pinctrl state\n"); + dma_coerce_mask_and_coherent(mmc_dev(mmc), DMA_BIT_MASK(32)); /* using dma_alloc_coherent*/ /* todo: using 1, for all 4 slots */ @@ -1822,12 +1844,6 @@ static struct platform_driver mt_msdc_driver = { static int __init mt_msdc_init(void) { int ret; - u32 reg; - - // Set the pins for sdxc to sdxc mode - //FIXME: this should be done by pinctl and not by the sd driver - reg = readl((void __iomem *)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3 << 18); - writel(reg, (void __iomem *)(RALINK_SYSCTL_BASE + 0x60)); ret = platform_driver_register(&mt_msdc_driver); if (ret) { -- 2.20.1