From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E351C433E0 for ; Thu, 4 Mar 2021 09:13:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6ACC564EED for ; Thu, 4 Mar 2021 09:13:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ACC564EED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uPabu04XZQCCijx16oOD4PfmgAFr4GvKS9ZGAgTAhQU=; b=egG25y2K4z3LxIdAOtuyJ8Va1 qbGsh/tC4WGTeY9dAdNsItLloerlpm1mO6t2nfnoCgr9/1rJlHwrELcwZ+Idux7LT1JWTa9KX4ufN vkZK27s82P7++GTMdGq20tKINQBPhktDygHousStZFBOwJvagsYuW8+YjdM+NJBL0+MU6etCDLH/P TEaDPhkreQwZe0+iuzE2aKyi0o1aOpZG7o1rg2JIZAXWjQ7emmKCFxTSFHQTCGN/kNtbugObBZIdG pzNh4hupuPUoq8N6q2s/aAWJgiobrmvHOQnrbP3zsh8T90GQ7JUWxXUywpVK+GEjWQGaUX/YyOD4p F+B7urpMg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHk0O-008FGv-Ke; Thu, 04 Mar 2021 09:10:55 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHk05-008FDC-DQ for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 09:10:38 +0000 Received: by mail-lf1-x129.google.com with SMTP id z11so41894838lfb.9 for ; Thu, 04 Mar 2021 01:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lYt7mYpM9/m04UA7Mdu92MabZprxTpAcM5FOuDuthS4=; b=fmPBN3OVw4OwkdjJx8DpFvbIIja2mK2GdJqOtQW1Ioet6C2AJbxyHtAZ43/5yCOrfX YIhF1TjFDL94mY63OlkM7Tq6ADqjKKprw16c8Rsl1jpf2nBbSqTnFGk2RXPVonxnt9mT fptNyLQvpVUQ/TG+NGemc2z47SIYdWwdjRXzM17FTZhE5A031EofI372xV0+oqP5UZVq nIyNDc0PwajjCfDf0tRpSuO0P0eR5eXRnz3KYdEiM2KwNi0pRoBf5K7MFlmaXIvBjzBt Fbr9yiWSaoKtGJwoFQbveoUS5IWzzmBgTS0OU1XKvhO64UA+q/yHFcctocMAHLsJSuZB DG+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lYt7mYpM9/m04UA7Mdu92MabZprxTpAcM5FOuDuthS4=; b=f2kz+MmoBKXUy4L80OSQ2ztOu5HE9wIDsNKzMo2FEejOO0fADakzMc90DC5PHKFy64 RNqRKvLT2RVz1RtnjafsZr7G08vGXCeFkhTp6z4kM9I4zyBaoy5kC99Vpwgh+lwmoamd XAjUwpbMaZhevhIMZnOL88SHWgqvWzjvmYT0ut1eGow2GQsaXHcVCt+x/Qy0uB4fLp9I KjqkzZnLBNuQmJ1PoyMxwoKpiuBUGrEHShBM6VMX79O3kxeo3k1hW65qgTVcJw/v04ls nS3Wmbu/rLUZf0/V2OSDljjb4q8Xl+ZTfSeCPgq4RPeWzpafQl9VCw9MdYhntQ2RWEwm BwTA== X-Gm-Message-State: AOAM530bQqzTP0HIEQTIGoQvwewOF0Xj1Oh9G7+gfwQTxXLJqwV4mnBJ l1JcnSDE6f/H+LYHcO9K7JA= X-Google-Smtp-Source: ABdhPJwlzUi5evrB7tfs/CevoAu3N1l1PJFqqId94eiMubcRbH8Dlr2a1CzIcdo2ScMeyBt/EDehfA== X-Received: by 2002:ac2:5232:: with SMTP id i18mr1839362lfl.30.1614849028522; Thu, 04 Mar 2021 01:10:28 -0800 (PST) Received: from mobilestation ([95.79.88.254]) by smtp.gmail.com with ESMTPSA id e24sm2536883lfn.62.2021.03.04.01.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 01:10:28 -0800 (PST) Date: Thu, 4 Mar 2021 12:10:25 +0300 From: Serge Semin To: Linus Walleij Cc: Brad Larson , Linux ARM , Arnd Bergmann , Bartosz Golaszewski , Mark Brown , Adrian Hunter , Ulf Hansson , Olof Johansson , "open list:GPIO SUBSYSTEM" , linux-spi , linux-mmc , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/8] gpio: Add Elba SoC gpio driver for spi cs control Message-ID: <20210304091025.ny52qjm7wbfvmjgl@mobilestation> References: <20210304034141.7062-1-brad@pensando.io> <20210304034141.7062-2-brad@pensando.io> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello Linus, I started reviewing from the DW APB SPI driver part of this series, that's why I suggested to remove the CS callback from there seeing it doesn't really differ much from the generic one. But after looking at the dts file and in this driver I think that the alterations layout needs to be a bit different. This module looks more like being a part of a SoC System Controller seeing it's just a single register. Corresponding pins seem like being multiplexed between SPI controller and GPO (being directly driven by setting a bit in the corresponding register). See the next comment. On Thu, Mar 04, 2021 at 09:29:33AM +0100, Linus Walleij wrote: > Hi Brad, > > thanks for your patch! > > On Thu, Mar 4, 2021 at 4:42 AM Brad Larson wrote: > > > This GPIO driver is for the Pensando Elba SoC which > > provides control of four chip selects on two SPI busses. > > > > Signed-off-by: Brad Larson > (...) > > > +#include > > Use this in new drivers: > #include > > > + * pin: 3 2 | 1 0 > > + * bit: 7------6------5------4----|---3------2------1------0 > > + * cs1 cs1_ovr cs0 cs0_ovr | cs1 cs1_ovr cs0 cs0_ovr > > + * ssi1 | ssi0 > > + */ > > +#define SPICS_PIN_SHIFT(pin) (2 * (pin)) > > +#define SPICS_MASK(pin) (0x3 << SPICS_PIN_SHIFT(pin)) > > +#define SPICS_SET(pin, val) ((((val) << 1) | 0x1) << SPICS_PIN_SHIFT(pin)) > > So 2 bits per GPIO line in one register? (Nice doc!) I suppose the first bit is the CS-pin-override flag. So when it's set the output is directly driven by the second bit, otherwise the corresponding DW APB SPI controller drives it. That's how the multiplexing is implemented here. > > > +struct elba_spics_priv { > > + void __iomem *base; > > + spinlock_t lock; > > + struct gpio_chip chip; > > +}; > > + > > +static int elba_spics_get_value(struct gpio_chip *chip, unsigned int pin) > > +{ > > + return -ENXIO; > > +} > > Write a comment that the chip only supports output mode, > because it repurposes SPI CS pins as generic GPIO out, > maybe at the top of the file? > > I suppose these systems also actually (ab)use the SPI cs > for things that are not really SPI CS? I haven't noticed that in the dts file submitted by Brad. So most likely these are just CS pins, which can be either automatically driven by the DW APB SPI controller (yeah, DW APB SPI controller doesn't provide a way to directly set he native CS value, it sets the CS value low automatically when starts SPI xfers) or can be manually set low/high by means of that SPI-CS register. > Because otherwise > this could just be part of the SPI driver (native chip select). That's what I suggested in my comment to the patch [PATCH 7/8] arm64: dts: Add Pensando Elba SoC support in this series. Although imho it's better to be done by means of a System Controller. -Sergey > > > +static const struct of_device_id ebla_spics_of_match[] = { > > + { .compatible = "pensando,elba-spics" }, > > Have you documented this? > > Other than that this is a nice and complete driver. > > Yours, > Linus Walleij _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel