From patchwork Tue Jul 28 02:55:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 247203 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp150742ilg; Mon, 27 Jul 2020 19:55:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAgnJMEpMa1M76CZqSuG5nRXGiViLXaBLHHH+r/hTh/ykluFhImubw2fP6pvIx5jjXmLto X-Received: by 2002:a17:906:3b01:: with SMTP id g1mr24657109ejf.353.1595904945844; Mon, 27 Jul 2020 19:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595904945; cv=none; d=google.com; s=arc-20160816; b=tRpqAUNb6lI8TSGvKYgg2OscvpwzBia/a5Jm7I6mf00XVluCbA79SSM0bkanOCdazE B2Ii1xTHe++fiEOxYSwiz+0HRfIHFVh67kH8/XbngCtFRm1LYcV5rig5jkxqkRxMlyRu PkoA1/aEql9Kg4Yo4p4FWwAiUK8DgsPIh3JdViEdKXSynttCYzhb6emwg4nYFs/JsBzE HdIrTQzqeqEJpFTvm5mh2X/vtqb56KCawzvVPjWLbERCPUHdRwSCATLSeifWkDGr/MFR vriqOfk0vM4uO4BMTPBAUUCSTfAwJbigB38HABXawdwZ733xrCtQvSzQ52GJ6NfIYUXs 8KJw== 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=6Ckk/6ewdW9qSUoP0eBZAL2Xbg3NR5wTYMI4LU5aFt4=; b=PzK/r18ztGJOCmlgD6CWUaDLDOhx09d8Q+kS9o2uni1/WVhDh+dUOcMmC+7bTd/XPe dJZuZwfD8WtQCZEasPqE3Yb0hpbJw6l4+aiIKksoWAN5qAuaaLz2B7eKKeVvVgbNe672 PdcOndDbRyyDSzFGJb26yBQ96ccxaOq1aBqZtw0ij+fvRJPoW4dQxBBslQSwZwwKpqo6 o8rdEgqhL5MusvGX/UZPmBlQ3zbEBcqxQpFNZMFbX4nOJ0OineuPok5ipOHr9X2WswyM nwP8tLBN0d3+auWhJRqH3zlZ7TMP0nJfomZVINdZd0APO8WuoLGRi/V5rtQz/6j4nU4c +U1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qwm4vltx; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c26si6714678edy.599.2020.07.27.19.55.45; Mon, 27 Jul 2020 19:55:45 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qwm4vltx; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726760AbgG1Czp (ORCPT + 6 others); Mon, 27 Jul 2020 22:55:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbgG1Czo (ORCPT ); Mon, 27 Jul 2020 22:55:44 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D643AC061794 for ; Mon, 27 Jul 2020 19:55:44 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id il6so4878856pjb.0 for ; Mon, 27 Jul 2020 19:55:44 -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=6Ckk/6ewdW9qSUoP0eBZAL2Xbg3NR5wTYMI4LU5aFt4=; b=qwm4vltxppZrjcwHre2u8XPw/2x/A/ajhqryA4wKKE4Jxxl4xtOYU/PcilF6+6a1KS kQCe3XGO262TWK2MeJaZdKb5NupNdxV9cG+MHUl0Zv948QCe0yd1AK2rk5zrr0AVz39D NYNrXYrLZhzhlDzIscWny3RogwmmAmYeinlHjxO5sPpeLHq1FW/ZmzUo7BuJsfj/w2dP fKO9cFbVZ3RtnJT85YiHMjnTTBJd+WJ/tdS07odx6JEbtNeU7X0xCTw+j8uuxtJQuORy Tiirqcw3lmPkOtES+yzq1Wpo5mLmiJ+cV23g2agFR+BT+lr6B1llmXpcJNrzGO+yTWSp mfLw== 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=6Ckk/6ewdW9qSUoP0eBZAL2Xbg3NR5wTYMI4LU5aFt4=; b=njN3piICTUdKoaoIqcnhaho1CMlswLB+I2nI0OxiRjaLSOeO4qGZAYgEM//uoTbWX+ bkCA8fm6y0JZRCmx4Ff/FXfAXQebiDZ8l7jMRAO50ax3aPqhVr5E9rBW1RfIgbbKsD+y F1V0l9mKawxe8S1xfe9chUvmjJlYavHYNNcUCmrtMshsarKxuEaSTZDdFVnt40QOMQE4 gKUMhXpwoh7qn6N12fp3frP/atPcvnR5FePwf+4FCkwPtQZ/YOm0JWKG4nc8/+Ev3IvN sT+j/8bIZiIwivhMV9LedRPhxguRHXW+i+Ro19jbMkVW7IeoV65natrCD34+MmpfkimK 0mLQ== X-Gm-Message-State: AOAM531QcDl9xp5Bk+c9FJMmCY6TnfBYmFxoaxriYk3yJRpIbZny3Ptl RDS0B41Otz3jSJ1lukqZvkI= X-Received: by 2002:a17:902:6b0c:: with SMTP id o12mr21979221plk.321.1595904944347; Mon, 27 Jul 2020 19:55:44 -0700 (PDT) Received: from localhost.localdomain ([45.124.203.15]) by smtp.gmail.com with ESMTPSA id w9sm15147407pfq.178.2020.07.27.19.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 19:55:43 -0700 (PDT) From: Joel Stanley To: linux-fsi@lists.ozlabs.org, Rob Herring Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Andrew Jeffery , Eddie James Subject: [PATCH 2/5] fsi: aspeed: Support cabled FSI Date: Tue, 28 Jul 2020 12:25:24 +0930 Message-Id: <20200728025527.174503-3-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 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some FSI capable systems have internal FSI signals, and some have external cabled FSI. Software can detect which machine this is by reading a jumper GPIO, and also control which pins the signals are routed to through a mux GPIO. This attempts to find the GPIOs at probe time. If they are not present in the device tree the driver will not error and continue as before. The mux GPIO is owned by the FSI driver to ensure it is not modified at runtime. The routing jumper obtained as non-exclusive to allow other software to inspect it's state. Signed-off-by: Joel Stanley --- drivers/fsi/fsi-master-aspeed.c | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) -- 2.27.0 Reviewed-by: Andrew Jeffery diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index 2b8ca72baeb5..c282de76e6e7 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "fsi-master.h" @@ -417,6 +418,45 @@ static int aspeed_master_init(struct fsi_master_aspeed *aspeed) return 0; } +static int tacoma_cabled_fsi_fixup(struct device *dev) +{ + struct gpio_desc *routing_gpio, *mux_gpio; + int gpio; + + /* + * The routing GPIO is a jumper indicating we should mux for the + * externally connected FSI cable. + */ + routing_gpio = devm_gpiod_get_optional(dev, "fsi-routing", + GPIOD_IN | GPIOD_FLAGS_BIT_NONEXCLUSIVE); + if (IS_ERR(routing_gpio)) + return PTR_ERR(routing_gpio); + if (!routing_gpio) + return 0; + + mux_gpio = devm_gpiod_get_optional(dev, "fsi-mux", GPIOD_ASIS); + if (IS_ERR(mux_gpio)) + return PTR_ERR(mux_gpio); + if (!mux_gpio) + return 0; + + gpio = gpiod_get_value(routing_gpio); + if (gpio < 0) + return gpio; + + /* If the routing GPIO is high we should set the mux to low. */ + if (gpio) { + gpiod_direction_output(mux_gpio, 0); + dev_info(dev, "FSI configured for external cable\n"); + } else { + gpiod_direction_output(mux_gpio, 1); + } + + devm_gpiod_put(dev, routing_gpio); + + return 0; +} + static int fsi_master_aspeed_probe(struct platform_device *pdev) { struct fsi_master_aspeed *aspeed; @@ -424,6 +464,12 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) int rc, links, reg; __be32 raw; + rc = tacoma_cabled_fsi_fixup(&pdev->dev); + if (rc) { + dev_err(&pdev->dev, "Tacoma FSI cable fixup failed\n"); + return rc; + } + aspeed = devm_kzalloc(&pdev->dev, sizeof(*aspeed), GFP_KERNEL); if (!aspeed) return -ENOMEM;