From patchwork Tue Jul 28 02:55:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 11687939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CAE561392 for ; Tue, 28 Jul 2020 02:57:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A2F3F20825 for ; Tue, 28 Jul 2020 02:57:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RzCAocCE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IUASXs1v" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2F3F20825 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1nkhwGJo39eQ0/ojoNVmitZ+n8eR2EJv5VOiX5h56UM=; b=RzCAocCEuPo93u69vfu6E5AFI gmJPsCIK9oqu7Qx9rwvC+omx4vXs0g156iF2ufitsn4t93bVrqE8P6FdYKkrv9CfwGBtPJGq3283M E0N42YAxn50Kilzk3L8/XTGLPUxsLHwWXZdQQsxFWGWVXxlnre+j6SGW7QHW1MJtMeYjYeQwHW4k5 rf8TTy9jjsq/O1hrGxnBM7Ig0lSVYMIutswgIK0bn9Gv5J/rOUIfBXgx2X8jCEId4aQxT0Cm3Qz6x FQun9+3CLFXNe0IogETpxkKlOhzzDPMk/uJ+21dT4pOCcrRiHQuaX6QRAR5GgJ05I/aQrWW2Meopu jA/c/s+sg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0Fmr-0003ua-0m; Tue, 28 Jul 2020 02:56:17 +0000 Received: from mail-pj1-x1041.google.com ([2607:f8b0:4864:20::1041]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0FmY-0003ob-Jd for linux-arm-kernel@lists.infradead.org; Tue, 28 Jul 2020 02:55:59 +0000 Received: by mail-pj1-x1041.google.com with SMTP id gc9so10725642pjb.2 for ; Mon, 27 Jul 2020 19:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xHSue0CpQdznRDxP9HpcUml2ldWS2kI8QAiHMjwZsXk=; b=IUASXs1vJ1qA+xjSALYyZt+BdzR4rFVXPkh++rAUOBtW4OALDpHw7FcO3xHVgYiCZi /YC0T0Q0QLAJEIuYlDEdC1B/0lHyq08IcxsTpffEYRgOHUp9eokDwJOdobX6OdNzBHWC gGcYXpgJsy8sknso3kDuoeJs6DXH8C14Ig2m2/U9A0WirUen7R0UEmzCcRSwFy9C3O6y uT1Psxj5VOB05ySDtvIJD0K7WY0C16kRQvrosHcpWR9tO52rvSAp66ctAIUgqGXmj6ld TjtuqaiXR2CRNGWf58N1Bkqc8KG77MsTq5894zZ+AanQ/gD0JZ1MuBQZexHCIGFfiDy9 xipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xHSue0CpQdznRDxP9HpcUml2ldWS2kI8QAiHMjwZsXk=; b=hPt/j9IpihpC8FNHtgbHfxBN86Gi5fqK9tK3aKbamZ+1sA0c8DI7vzJERepn07BxM/ dn7o7LK3nyqju4uy1N0626GBmwqdOLIXuk9z1X8tK9cXnvrSw+mm+AZ5CdEC0Tp6C4fz p15ZGfT5s1AY7gBytl9QMwyD+uwG5YS6iIBOHrKGTAprE+kfixj8D7GKqTMoXwrC1Y1I o5udkg2z6BPgTftnDJXLqEEm7rE+YlHnz3NspJOdk7T6wPA9XPt5R4ds3i9V0E0DXM5S ec/QmHFYJumR43CWlg/gAH4UZRnciJU63scLXfefagaXkOq/ok9H/X0g+pPQtHCZxxA9 Umtw== X-Gm-Message-State: AOAM532GMzd3au5yXxnchAghhyF1CeA+g978IIud5qbn4k04whMwqfLt uVPbTiwc13aMjIBjCwvBUZ4= X-Google-Smtp-Source: ABdhPJwjK0HYoPAp5SbegcVvL9vysGStO3XCD+1r9RziUs8rO+gT/2vi8u418QOHBxw3jN5+WNU4uQ== X-Received: by 2002:a17:902:d704:: with SMTP id w4mr21994938ply.278.1595904956348; Mon, 27 Jul 2020 19:55:56 -0700 (PDT) Received: from localhost.localdomain ([45.124.203.15]) by smtp.gmail.com with ESMTPSA id w9sm15147407pfq.178.2020.07.27.19.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 19:55:55 -0700 (PDT) From: Joel Stanley To: linux-fsi@lists.ozlabs.org, Rob Herring Subject: [PATCH 5/5] fsi: aspeed: Support CFAM reset GPIO Date: Tue, 28 Jul 2020 12:25:27 +0930 Message-Id: <20200728025527.174503-6-joel@jms.id.au> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200728025527.174503-1-joel@jms.id.au> References: <20200728025527.174503-1-joel@jms.id.au> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200727_225558_703707_B1EF7AE5 X-CRM114-Status: GOOD ( 18.52 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1041 listed in] [list.dnswl.org] 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [joel.stan[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Jeffery , devicetree@vger.kernel.org, Eddie James , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Systems have a line for restting the remote CFAM. This is not part of the FSI master, but is associated with it, so it makes sense to include it in the master driver. This exposes a sysfs interface to reset the cfam, abstracting away the direction and polarity of the GPIO, as well as the timing of the reset pulse. Userspace will be blocked until the reset pulse is finished. The reset is hard coded to be in the range of (900, 1000) us. It was observed with a scope to regularly be just over 1ms. If the device tree property is not preset the driver will silently continue. Reviewed-by: Andrew Jeffery Signed-off-by: Joel Stanley --- drivers/fsi/fsi-master-aspeed.c | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 2531e826ba8b..c006ec008a1a 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -22,6 +22,7 @@ struct fsi_master_aspeed { struct device *dev; void __iomem *base; struct clk *clk; + struct gpio_desc *cfam_reset_gpio; }; #define to_fsi_master_aspeed(m) \ @@ -425,6 +426,43 @@ static int aspeed_master_init(struct fsi_master_aspeed *aspeed) return 0; } +static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct fsi_master_aspeed *aspeed = dev_get_drvdata(dev); + + gpiod_set_value(aspeed->cfam_reset_gpio, 1); + usleep_range(900, 1000); + gpiod_set_value(aspeed->cfam_reset_gpio, 0); + + return count; +} + +static DEVICE_ATTR(cfam_reset, 0200, NULL, cfam_reset_store); + +static int setup_cfam_reset(struct fsi_master_aspeed *aspeed) +{ + struct device *dev = aspeed->dev; + struct gpio_desc *gpio; + int rc; + + gpio = devm_gpiod_get_optional(dev, "cfam-reset", GPIOD_OUT_LOW); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); + if (!gpio) + return 0; + + aspeed->cfam_reset_gpio = gpio; + + rc = device_create_file(dev, &dev_attr_cfam_reset); + if (rc) { + devm_gpiod_put(dev, gpio); + return rc; + } + + return 0; +} + static int tacoma_cabled_fsi_fixup(struct device *dev) { struct gpio_desc *routing_gpio, *mux_gpio; @@ -507,6 +545,11 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) return rc; } + rc = setup_cfam_reset(aspeed); + if (rc) { + dev_err(&pdev->dev, "CFAM reset GPIO setup failed\n"); + } + writel(0x1, aspeed->base + OPB_CLK_SYNC); writel(OPB1_XFER_ACK_EN | OPB0_XFER_ACK_EN, aspeed->base + OPB_IRQ_MASK);