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: 1337466 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 4BG1Wr2YNhz9sTk for ; Tue, 28 Jul 2020 12:55:52 +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=qwm4vltx; 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 4BG1Wr28hnzDqnf for ; Tue, 28 Jul 2020 12:55:52 +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::1044; helo=mail-pj1-x1044.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=qwm4vltx; dkim-atps=neutral Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) (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 4BG1Wl1fN3zDqmC for ; Tue, 28 Jul 2020 12:55:47 +1000 (AEST) Received: by mail-pj1-x1044.google.com with SMTP id f9so4543378pju.4 for ; Mon, 27 Jul 2020 19:55:46 -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=sNCvs8JlTKLgYZg7MkXbojmmhkJoGBFa8kwaYCNpoj2xsqi93V5ao9NEaRP4oNmDDm oB9DfgHEZNTcfKJTyM/MslIBs/3CiOFg0BYMA1NsY6KSBzCC7Hx84UYy5AHducPkAf21 5nNfUxgH5njhaPneJcvEbUykAElBdXM1kRwtLSzjcqMlpVAn3tnLht5Q26qNnR37yxOP J7mf5/ADe3K6SAaErlq53e9geCYZ1cMuVHgYqzSU6Yat24c6hL1r+mFsoZKJWTYlEz+x +HAtn6rKY4vZBCbPdzfqLjcDo/VqYUp3LGhAU305j7v1aM5YSTJd9+/7rzx+OnclHnzl 5JxQ== X-Gm-Message-State: AOAM533e7NUHUU/Ka+Tc9B2RP/SWwhQweWtsuiKFxiLPO+koTyj44Un2 CX0wxvskuxGvEqBzjjmlQ3Gt7X89WJc= X-Google-Smtp-Source: ABdhPJzbnK5XuiLz1+hp6r9eBmGOKwKaPDwfwg8x6ABvtWcdMwkEo8lIUImCsZ/cWAs1/wr4FcDBpw== 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 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 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" 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 Reviewed-by: Andrew Jeffery --- drivers/fsi/fsi-master-aspeed.c | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) 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;