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: 1337470 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BG1X268S3z9sTm for ; Tue, 28 Jul 2020 12:56:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=IUASXs1v; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BG1X256kzzDr1G for ; Tue, 28 Jul 2020 12:56:02 +1000 (AEST) X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=jms.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=IUASXs1v; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4BG1Wz2Rz0zDqwl for ; Tue, 28 Jul 2020 12:55:59 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id l6so9146980plt.7 for ; Mon, 27 Jul 2020 19:55:59 -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=jCJI9cHnRn8bOKREkI3+k5vJV4yFRZ7//aOKSJ+ZGAEyJ+VMkGyqjmKjv/jNYlIyk/ Z1iR82Pmt66J26h03NKXcJQz6GRWo/4y0dN+DlSi1pg3n/ZpiVCt6KUr25bhwTO0wYGd OrPUQmXNGFPM3qnpFGhip/2HMCUeRAril3CuVv4KHuFFWQ0XjmcRxlqAu6hJtIBj7b66 Av8mUgYQ0QKToy3eyaph4qnguOgh4UMGokzRw5xeK3T5A1smV36d09xMNlkecGvzcS3q /7S44yqfo2OVU3tHYNg3t4Y+ge0toYMLgcpVH+aCgV3Tu00iA0pC1AgbtOXnuWvIg0mk d6Mg== X-Gm-Message-State: AOAM531coPNLx4/UABSwHgkMorGL1X6lz5uxwJS85HvW4R1SRF6fFmNr ggeaanAt/SB4GEamdyqCGBqp96TSlFs= 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-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" 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);