From patchwork Tue Dec 19 16:22:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 181075 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2055309dyi; Tue, 19 Dec 2023 08:23:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCPofpp8yM7ppup6F2vupE2sGWSy4qOhCwR12yd6/T0+EmcF5SnVp+OlmPUNGB1qJs9AWv X-Received: by 2002:a05:6214:27e4:b0:67f:e61:7f08 with SMTP id jt4-20020a05621427e400b0067f0e617f08mr11500750qvb.69.1703003020394; Tue, 19 Dec 2023 08:23:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003020; cv=none; d=google.com; s=arc-20160816; b=pwL7yAkYhS3uf16UOfAJNwfwzuE4KXPJNZPtwdmlgiDB+MBjw/qz2IA2pDZHK8XQD7 pMtUOfJkYuU4bwZKHtfCR2qLyJ23kndHSwex5kAr3L4/RyP6X8kVq3giSdXiH8c+IC9b 7fjHDGAlWRDVHqGOwOBpmnZIAhrnj4sFTZfZXw7GNWLK2HQNz4CyFRv6JGJPUSZa9Xok By14xYzgUPSeufrOWHPh0gi2eaq2eMcnSzmSaBHEJSU+ZqJKdC5rcZ0yzolsIKmwT+M+ yPvVK+t+n5rq9Yr99Vl7Af/91oG+7ho+loDegzFVChwAIjpwbwgPjIesTbPXMT4J1vro JfgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=BGIpRw1o/lgYgRYZE8S0poGpmslAlgvEtelYVNqQ+4A=; fh=kl6jwBYwyWQ8UusyU/LVQEf4sbplVtOrtPygnUZLHOM=; b=BkDD4eQcvou5pXNQ/xa0Y3WAx78o5aTijiVA+xJPAvhKIOOA9kjt2un+pyyT6QJJWc B/DyJ8Y5fOD7FzmojJx8aB36fmMTNGs9BGoyk8gXbog1caQvKOFmNxRy30r6TQXNm1h1 Z9xOx4XCOfefY7IyQezVKoVWomSsgNe1oRj0oIvK6RVZEZZuBn88W1tJ9e73G8+Dpu5G Lvp+W7wbzQWu/8+um939R9BfSsNz4bSnSzyrSFtpc6Se8LYnO/r6twL+APJxS+AH0jbe Q9g/MTUetgHbtUrcignmx2YNCdZxwcFcVBA66uhRlaTcbLQ/hSu/1JUEiD4kw1su6UCs LvXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Q9UKXznb; spf=pass (google.com: domain of linux-kernel+bounces-5548-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5548-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x11-20020a05620a448b00b0077f4299af1esi27114560qkp.630.2023.12.19.08.23.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:23:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5548-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=Q9UKXznb; spf=pass (google.com: domain of linux-kernel+bounces-5548-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5548-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 254F21C23C31 for ; Tue, 19 Dec 2023 16:23:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 662282032A; Tue, 19 Dec 2023 16:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Q9UKXznb" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45A501DDF4 for ; Tue, 19 Dec 2023 16:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-42782692142so1261071cf.3 for ; Tue, 19 Dec 2023 08:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703002982; x=1703607782; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=BGIpRw1o/lgYgRYZE8S0poGpmslAlgvEtelYVNqQ+4A=; b=Q9UKXznbnjgbptVaDksp61E4fWnXQgVIiaBg7qQTJhDkjYUm22E+b/d9q/NPTB1Muw tEvkQGpLiWJsf4xGgRqohgoYsGaQpZqj8Apok1y7iM6egkQHYBZ1g2bkXelg8ffy+mJU xusPQyCeDi67DvnEsmltJ2iaIYXcfp4DeZx/8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703002982; x=1703607782; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BGIpRw1o/lgYgRYZE8S0poGpmslAlgvEtelYVNqQ+4A=; b=D/oiPyttnzJAlWQX+OFPdd9lRUhEU1WHBlNGWUgwa+WeJHMlw7J86Tq3ED2mpCXWXm Tdt53vhFvRcxheQOo3MAWJPxJngtfyoKU6J6tLSdXpHX1aGiF2VQ71bKnUZn7djmHNLc +1t3dTofjg9KcHemroIp54KU2HDnF8av03nE3jeff7r2LhmVobJ3cZaMqzFLeH/5iyJW 6i8sa1SOXmm49Sa8/3BFdZRXS9IqRMwGp3YTuJLdtbu8BL7uLppo6PNckf4lVHDH4NmB 81HXU1J5JiipHdBUEeKB33Ja6BisAlbJuR8V8DUM93xsep382nr/Nu3pTWVzm2835hpR ilUg== X-Gm-Message-State: AOJu0Yxq5Uj+tG9SJ296d0c/0+7PsWre6Sgny34B/k67fiQ81NtcSsh/ BaOJOXwga782s44bmPwU59MPrg== X-Received: by 2002:ac8:594a:0:b0:425:4043:96f6 with SMTP id 10-20020ac8594a000000b00425404396f6mr25470252qtz.131.1703002982131; Tue, 19 Dec 2023 08:23:02 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id o15-20020ac8698f000000b0042388bce404sm10363166qtq.57.2023.12.19.08.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:23:01 -0800 (PST) From: Kamal Dasu To: ulf.hansson@linaro.org, linux-kernel@vger.kernel.org, alcooperx@gmail.com, linux-arm-kernel@lists.infradead.org, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, devicetree@vger.kernel.org Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, Kamal Dasu Subject: [PATCH v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Date: Tue, 19 Dec 2023 11:22:35 -0500 Message-Id: <20231219162236.36609-2-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231219162236.36609-1-kamal.dasu@broadcom.com> References: <20231219162236.36609-1-kamal.dasu@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728095319010923 X-GMAIL-MSGID: 1785728095319010923 From: Kamal Dasu With newer sdio controller core used for 74165b0 we need to update the compatibility with "brcm,bcm74165b0-sdhci". Signed-off-by: Kamal Dasu Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml index c028039bc477..cbd3d6c6c77f 100644 --- a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +++ b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml @@ -20,10 +20,8 @@ properties: - const: brcm,sdhci-brcmstb - items: - enum: + - brcm,bcm74165b0-sdhci - brcm,bcm7445-sdhci - - const: brcm,sdhci-brcmstb - - items: - - enum: - brcm,bcm7425-sdhci - const: brcm,sdhci-brcmstb From patchwork Tue Dec 19 16:22:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 181076 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2055798dyi; Tue, 19 Dec 2023 08:24:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4T4IsxvUGSXWMcmP2/Fhmm7QYtiSsHsgC2Sdm0BjExKJrWGH8LlpqB8ipVemeuQ7XEANz X-Received: by 2002:a05:6214:1d28:b0:67f:3d92:e870 with SMTP id f8-20020a0562141d2800b0067f3d92e870mr4140118qvd.79.1703003065892; Tue, 19 Dec 2023 08:24:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703003065; cv=none; d=google.com; s=arc-20160816; b=o+zr0pWiJrH4MAxiwTPRM3ta8QcJbo+wYpXn9QrWVgIVkObJ2dqhmV/7bT93fro1WX UBz2reYcya0XCwn9Xw/04ta5oXJxi2GPIIuU8+jszZ/BYvbWAhO5QFeK25Ws9m/9M0Uy sUUZEg6RDRQpRnd0wOJ/Cw9i3LWTFzXnxO3I9wXJIP9PA7yPNOvD+omWzmqjyiuysh3q f6PHpt8i3ZRSMY1r45pbBXTLwvKCA8HuUGbpW6L/uJpyWvYOz3Rbikg3eC7/VwqCC3xq Z2OMwfe0hJA99q1qw2WYfyjzcMeKh94OIS5A+5paWs/mdwnhmtNjSPgJ3pE1NTPJo59l +Pog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=lewFzn9SrDI+/fbG+W+6O1u8PWoajh2/Xolpgh8p6II=; fh=kl6jwBYwyWQ8UusyU/LVQEf4sbplVtOrtPygnUZLHOM=; b=Xi9L/g5+mSrre2Zgc8kg2v5aIeVJMhG8RQPIK22AadJNfWqhXHhmISvYkWXo9z0pfy af+c30+Aserf5ANjNS1Y/CNffHp4b2WWsnzzLQTZeuvda9f0DbcY0p5Xq3W1fvf5WedG k3WCuLwgv1iD66Y/4SiRbSsnr0uLYZFGf/E0PprccndQ74L/L0hP06afgSDZOTQVDVDT C7LRToI5kIJSpf0rlM3X3z0soAEci1ve+0PFeCrfx3wsLQ7y6vrKbcBrHx5qCSm2j5NT ZP4JEVNdFrzFlHEnISGA5wDPTKjUR2ZLocMZ0rWyKnmVnPzQlDQRDjfWHBWQ30f+zEvh c5ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=fgaOUzZI; spf=pass (google.com: domain of linux-kernel+bounces-5549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5549-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y9-20020a0c8ec9000000b0067abffdfd66si6547710qvb.277.2023.12.19.08.24.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:24:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=fgaOUzZI; spf=pass (google.com: domain of linux-kernel+bounces-5549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5549-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9A0351C23E78 for ; Tue, 19 Dec 2023 16:24:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B984E225D8; Tue, 19 Dec 2023 16:23:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="fgaOUzZI" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62A79200DB for ; Tue, 19 Dec 2023 16:23:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3ba084395d9so3290489b6e.0 for ; Tue, 19 Dec 2023 08:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703002985; x=1703607785; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=lewFzn9SrDI+/fbG+W+6O1u8PWoajh2/Xolpgh8p6II=; b=fgaOUzZI3n/FSz8HwLY6aATLHkLwQ7cF0QIRBE1/07iRlQHbYoW7bxH9wh6fQy74IJ 8Z0vEcGX3kHSm4czJ3c4hS/Tuoak0uueicNlqEto+PbOdQoGKvSegyj0IsOgZY713pQA aftvcLJmzvsrRyBe8w0OzbCiHGEIkgqRq1VlA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703002985; x=1703607785; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lewFzn9SrDI+/fbG+W+6O1u8PWoajh2/Xolpgh8p6II=; b=R+usYR6u5vKydAv5Lr4mSHWHIEEpCUIHVgqODUa0Vs146pAbJwQcJuNxhvDhwmKTh4 tMVX3v2zo8Z3KOVETJWzYz5NZqMCGJBnmQJn0orAov7jV2x0+ZwasBUYGrUMeZxefoJ1 yuW3hp11VV59YYJ3+kZSF9nIJ+kqyy4hN7UPzoI00eo32NX0Cm+RWkVeznOwyThJAO5b p0L5ShaMSKG+y28hi7uxxpD2L8dAqgmu4kZy65B13EgZZl3Tbye3h3BACgrD3kae3843 ZIBAZhN5TzLSmYHKruryWLEcRdSsTt/deQLvu+Mcoe3TBFUjbzk2rRKqMsJ+qDs1+RGf /DnQ== X-Gm-Message-State: AOJu0Yy/yDTRCC7kuKE4gm9erFi5ulVcCZvvU7x2NZOK2KLeEgtAFDsn qbTGPosoO3A33iXrAMMDUgg5yVBe0r5ALru5Ly6RrQ== X-Received: by 2002:a05:6359:6f15:b0:173:24:b27c with SMTP id tk21-20020a0563596f1500b001730024b27cmr360852rwb.32.1703002985239; Tue, 19 Dec 2023 08:23:05 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id o15-20020ac8698f000000b0042388bce404sm10363166qtq.57.2023.12.19.08.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:23:04 -0800 (PST) From: Kamal Dasu To: ulf.hansson@linaro.org, linux-kernel@vger.kernel.org, alcooperx@gmail.com, linux-arm-kernel@lists.infradead.org, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, devicetree@vger.kernel.org Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, Kamal Dasu Subject: [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Date: Tue, 19 Dec 2023 11:22:36 -0500 Message-Id: <20231219162236.36609-3-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231219162236.36609-1-kamal.dasu@broadcom.com> References: <20231219162236.36609-1-kamal.dasu@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785728087937997785 X-GMAIL-MSGID: 1785728143296531279 From: Kamal Dasu 74165b0 shall use a new sdio controller core version which requires a different reset sequence. For core reset we use sdhci_reset. For CMD and/or DATA reset added a new function to also enable SDHCI clocks SDHCI_CLOCK_CARD_EN SDHCI_CLOCK_INT_EN along with the SDHCI_RESET_CMD and/or SDHCI_RESET_DATA fields. Signed-off-by: Kamal Dasu --- drivers/mmc/host/sdhci-brcmstb.c | 67 +++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index c23251bb95f3..7c5d04be93b3 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -44,8 +45,13 @@ struct brcmstb_match_priv { static inline void enable_clock_gating(struct sdhci_host *host) { + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); u32 reg; + if (!(priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK)) + return; + reg = sdhci_readl(host, SDHCI_VENDOR); reg |= SDHCI_VENDOR_GATE_SDCLK_EN; sdhci_writel(host, reg, SDHCI_VENDOR); @@ -53,14 +59,51 @@ static inline void enable_clock_gating(struct sdhci_host *host) static void brcmstb_reset(struct sdhci_host *host, u8 mask) { - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); - sdhci_and_cqhci_reset(host, mask); /* Reset will clear this, so re-enable it */ - if (priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK) - enable_clock_gating(host); + enable_clock_gating(host); +} + +static void brcmstb_sdhci_reset_cmd_data(struct sdhci_host *host, u8 mask) +{ + int ret; + u32 reg; + u32 new_mask = (mask & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) << 24; + + /* + * SDHCI_CLOCK_CONTROL register CARD_EN and CLOCK_INT_EN bits shall + * be set along with SOFTWARE_RESET register RESET_CMD or RESET_DATA + * bits, hence access SDHCI_CLOCK_CONTROL register as 32-bit register + */ + new_mask |= SDHCI_CLOCK_CARD_EN | SDHCI_CLOCK_INT_EN; + reg = sdhci_readl(host, SDHCI_CLOCK_CONTROL); + sdhci_writel(host, reg | new_mask, SDHCI_CLOCK_CONTROL); + + reg = sdhci_readb(host, SDHCI_SOFTWARE_RESET); + ret = readb_poll_timeout(host->ioaddr + SDHCI_SOFTWARE_RESET, + reg, reg & mask, 10, 10000); + + if (ret) { + pr_err("%s: Reset 0x%x never completed.\n", + mmc_hostname(host->mmc), (int)mask); + sdhci_err_stats_inc(host, CTRL_TIMEOUT); + sdhci_dumpregs(host); + } +} + +static void brcmstb_reset_74165b0(struct sdhci_host *host, u8 mask) +{ + /* take care of RESET_ALL as usual */ + if (mask & SDHCI_RESET_ALL) + sdhci_and_cqhci_reset(host, SDHCI_RESET_ALL); + + /* cmd and/or data treated differently on this core */ + if (mask & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) + brcmstb_sdhci_reset_cmd_data(host, mask); + + /* Reset will clear this, so re-enable it */ + enable_clock_gating(host); } static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) @@ -162,6 +205,13 @@ static struct sdhci_ops sdhci_brcmstb_ops_7216 = { .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, }; +static struct sdhci_ops sdhci_brcmstb_ops_74165b0 = { + .set_clock = sdhci_brcmstb_set_clock, + .set_bus_width = sdhci_set_bus_width, + .reset = brcmstb_reset_74165b0, + .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, +}; + static struct brcmstb_match_priv match_priv_7425 = { .flags = BRCMSTB_MATCH_FLAGS_NO_64BIT | BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT, @@ -179,10 +229,17 @@ static const struct brcmstb_match_priv match_priv_7216 = { .ops = &sdhci_brcmstb_ops_7216, }; +static struct brcmstb_match_priv match_priv_74165b0 = { + .flags = BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE, + .hs400es = sdhci_brcmstb_hs400es, + .ops = &sdhci_brcmstb_ops_74165b0, +}; + static const struct of_device_id __maybe_unused sdhci_brcm_of_match[] = { { .compatible = "brcm,bcm7425-sdhci", .data = &match_priv_7425 }, { .compatible = "brcm,bcm7445-sdhci", .data = &match_priv_7445 }, { .compatible = "brcm,bcm7216-sdhci", .data = &match_priv_7216 }, + { .compatible = "brcm,bcm74165b0-sdhci", .data = &match_priv_74165b0 }, {}, };