Received: by 2002:a05:6520:3645:b029:c0:f950:43e0 with SMTP id l5csp6296658lki; Thu, 4 Mar 2021 09:29:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKTU26gRwXRhg3HyGCJ8fKH6WFpEzc8kNxd1Q6eMoH6PLrDnH3zRxziu/PMpDteWW2PUYy X-Received: by 2002:aa7:cb4d:: with SMTP id w13mr5591943edt.249.1614878980974; Thu, 04 Mar 2021 09:29:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614878980; cv=none; d=google.com; s=arc-20160816; b=KPyPSwzJJcAyZuDgrDhm+LGDeKiwT1Ndpi91qINywamloZ+qf4ZkJW4M6GrTlDktK0 BDK3PHfBhsHzsMoOdXhGGuyNzuyFmwdxJZ3h1NUTp/wkXe3JygxGh/7lYZPea+17oc/D tgD3jloxlB6WLn4jzPz7pFVst2FOaqVuqVCDeFiTdokByVgYSw++CD9e4+RUPBjr8lqD RqwQ8DsBKIWRPjcJtc9vZqb5c161aLLt2ha9V29vp+oqpshEdCQUp0P8mYax+XSeWNp0 XsU83dOrPDYchuTRTZz7tP9fgaOoBGjQui3hX9yGe55gGPkiecowdO2yA8EKodolPMZ2 nS+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Sy4nEQi288EJ0M7NsP9fNgE7Qbg6ZfSce++n7QC7VuE=; b=mifbiaerQnT6RashlGDcs1RVLruon7S7R0q+cs0WCtUNwAZodOEwnRrkqE1xNLjZz0 MgxtWE8Q1ZjICSNIB8zBE3SmdqMPg0HkTn1mm/GljbCdSfmetjASxbpT87tcWh7pHA8v O+tNFYpOidh9NVv8jfOvBaSPJk5b7MWh7TobeNrgY1h0TK5mhtW4wLwfjnX69MyOE+q3 7R00KaD3WXTvw/rDRghztIokHl8WsatyhipWFo2zQl3+eRzfsg6rXtOmwRzZl9tYMuzm UddA5jaUn1hVIQfBxH3vm9acxu4s+ksUSpJ6xdJR4Q85anhF5Wb7jP0AvE5M7HeCFs2O qbBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDEyZwrE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j16si18505621ejm.573.2021.03.04.09.29.17; Thu, 04 Mar 2021 09:29:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDEyZwrE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241363AbhCDNjA (ORCPT + 99 others); Thu, 4 Mar 2021 08:39:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241373AbhCDNiy (ORCPT ); Thu, 4 Mar 2021 08:38:54 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F2BC061756 for ; Thu, 4 Mar 2021 05:38:14 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id b1so32460221lfb.7 for ; Thu, 04 Mar 2021 05:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Sy4nEQi288EJ0M7NsP9fNgE7Qbg6ZfSce++n7QC7VuE=; b=HDEyZwrEB46msqvh9yZL6EIpSxJmqDcC7gwO0qmA5ppFeUZZynGA6jUe7EyfCmsk8Q rcBnKK1vNt9y/wlSP7cHt9bjTpe55w38EsfRix7wkpzfpiWxwAsFdAyMlNpRS2Vvh6w3 fawXFbtO/97KGmx+9feW42Ya5GUueAsIb/TRpTlmNJ5s6egRp9BtUOyo0gqFaq+xdPEV T1zZT8nF1Ni3+X79Dae5i7HiscmcOz6U3D2PZKXsvPFXricPI9lr/5a9b1eetyEuexsL QYuoLhT95aAs2djBuEz3/JU7g7CqeaarcznXmDsFvDWyfCEJvHFKCp3bOPwouJhVFNPf XRfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Sy4nEQi288EJ0M7NsP9fNgE7Qbg6ZfSce++n7QC7VuE=; b=cHJ5SpANOxwRQ3SOJJ6yidvpViZEvsTKbYWutCWMpN6PLiXBOoSujKhBygH1HeK2GA DT/ScNI+S+3eZlGz+qOQ/JL7bCyEva1ti8ieYVlRyNiqV+4ttgMKENy/4n8S0sA9MaL4 KqrNKyomIQIiuox/uY0r7B7X0SvpUCwxFQolawE69QiCXy84OQcpzDqemBVXYlAgGaW4 4E46WNtIfzWa25lIxltvqMvx5YFVlsXkYuanMaCIwn4C9cq9GNBVFZS7XjmPGWysUaD1 P+6lkKCbQRAtUQiMuR2QAhyDozvc+9wL4bnOripMT1SpaUBZ7A4WOgIrDYQzv+jpr44P TWew== X-Gm-Message-State: AOAM531jhP1e/Zjz9VkTx6V+UwgUHetPIghs6vhRqq9aB1Ufh+0nDXSF fR+hfJSwQyyIQfyslCbTkASQlRs5qqlykb3rJwjWQg== X-Received: by 2002:a19:548:: with SMTP id 69mr2287824lff.465.1614865092582; Thu, 04 Mar 2021 05:38:12 -0800 (PST) MIME-Version: 1.0 References: <20210304034141.7062-1-brad@pensando.io> <20210304034141.7062-2-brad@pensando.io> <20210304091025.ny52qjm7wbfvmjgl@mobilestation> In-Reply-To: <20210304091025.ny52qjm7wbfvmjgl@mobilestation> From: Linus Walleij Date: Thu, 4 Mar 2021 14:38:01 +0100 Message-ID: Subject: Re: [PATCH 1/8] gpio: Add Elba SoC gpio driver for spi cs control To: Serge Semin 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" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 4, 2021 at 10:10 AM Serge Semin wrote: > On Thu, Mar 04, 2021 at 09:29:33AM +0100, Linus Walleij wrote: > > > + * 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. If these output lines are so tightly coupled to the SPI block and will not be used for any other GPO (general purpose output) I think it makes more sense to bundle the handling into the DW SPI driver, and activate it based on the Elba compatible string (if of_is_compatible(...)). I am a bit cautious because it has happened in the past that people repurpose CS lines who were originally for SPI CS to all kind of other purposes, such as a power-on LED and in that case it needs to be a separate GPIO driver. So the author needs to have a good idea about what is a realistic use case here. Yours, Linus Walleij