Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3294772pxv; Mon, 26 Jul 2021 00:12:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6wZbGb/kVx4QTI3dLctTMsuFs4jXRMw5tQ2keaLq9Vz1OObca0hyH7GHOBMm+spOLGXQq X-Received: by 2002:a05:6e02:1aa2:: with SMTP id l2mr11225150ilv.224.1627283557021; Mon, 26 Jul 2021 00:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627283557; cv=none; d=google.com; s=arc-20160816; b=r5ssoIyveg1oQtgi5KSvOxvB2vS5CSftby0pKWmYs1dCbR+w9XPPnxUHJgl86XWOvl 92cX+aU0+6IoCQO7ip3a1GYYkNVqAs1kFanm8UOPKMmXnKN6bDWurRRL5K0f5zNX6S1j yWP76upx39RDM8BIgowGPmV6Fbzw3q6mcIyqGl5r+NQV7/xkWPmvZpZpkQ0aAeyJZkAU K2/t93iIywsmnlnO3PaGVzRv1na/H7MUbsgGM7BL98LURTCKTEqwOOLM2+IfRBR3nuU8 RVswdP2Gh8M5UcREbdz0y52N/kRsqDMkp+n5OdKu6fXytWGbPN6JqqDIM/jutv1mQaJ8 VoWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+5p8Aei7IrZs3alqaJKEyL3k4NRbSzzZGcPcbzf/ZKM=; b=w7coZHHpNHRgxQGGgTHf1IBUS2ZKZEpDTB3oXy57/W9ZqMt2SKEqpCWLRgdmHHitxK tqK7bZWPcxaebh0bYHTWvfIfn3VVe0K01vzXV/mnT2SrFcyRLaZLvytEF6G1Y27aYbF8 fulrR3ReDmT6NokSfFbLI0L1B0RocPJXouMscwefXxHJuWR6zT5lhrOxm8qmeGSbLdsP afh9e3Qq35U79hLfkZjqQUvVQgGsl1glhmZ5NGNOwJBDaSt6CvuvarYWMafgaG216nHb VNrVc8NqG+8+Lx4CXFXzLvv+YwSsBX8mLp1Md8Kwjp3Rrb1rCeiKLOkYDTUo/R3n+bqn UOyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@beagleboard-org.20150623.gappssmtp.com header.s=20150623 header.b=nsFEEqxu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l20si18319379ion.36.2021.07.26.00.12.24; Mon, 26 Jul 2021 00:12:37 -0700 (PDT) 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=@beagleboard-org.20150623.gappssmtp.com header.s=20150623 header.b=nsFEEqxu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231332AbhGZGbB (ORCPT + 99 others); Mon, 26 Jul 2021 02:31:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231582AbhGZGbA (ORCPT ); Mon, 26 Jul 2021 02:31:00 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7F69C061760 for ; Mon, 26 Jul 2021 00:11:28 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id o44-20020a17090a0a2fb0290176ca3e5a2fso5624395pjo.1 for ; Mon, 26 Jul 2021 00:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beagleboard-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+5p8Aei7IrZs3alqaJKEyL3k4NRbSzzZGcPcbzf/ZKM=; b=nsFEEqxuhHH0w55xR+qWi6/8JTZFD+CjXaMMEmRxPwhw2+t/dxlIOoeHh6BpICM3mq gNT4qD6yRd/mY6jEACPu0YsvzhLNNFAflHc0uWnAC/j7XT9FAhDDBCx7p9j2vtIs0vCd y111+bounbY/WPKSDg7zqY0suEQPOzJntP/Vsa+De7Dkj5L32jI5icyEcWzyEnJAzCq7 aA3xdsgUDt0CbErUbVFasdkp2E1dn6c8e9+j7u0uDTyc57FJVgyU+uLeZDcPrd8Ti2RV /XdKYIyowWMIT/h8pOCMmIrI//hpZnh5WqTho6WOgON21kM/nrs6WNASFxgJQAX9f9zF DaYA== 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=+5p8Aei7IrZs3alqaJKEyL3k4NRbSzzZGcPcbzf/ZKM=; b=fVckV6gU8X+bt9w7rnmbZvT9hFlBdQPKWCRDCUxWXL5qn2o9jg8V22lZnyL/mZAD0Z bXnhXIb+h80v5NNR5ao3KEfdz/88gKok4E1y/9O9RpALT6iscq8ys7PbtYzrHMq43H3c O2X+SKLVI1gi2h9LYys9SSBCS0kCQ9EoC7i/eEkDjDkLAMDRotEaCS0npzj8kGTgFeBP YxXWI6ycsJYKbf7WdfHVJkJtceiYF9YAG9jbWBWDUiO7OEZ4YjGcKwu16ZAaUDbH3Wf3 AzCNDMNEcZgVgDm9tAaEu+2dFswENuIRljoxYo1+6GKK+hkwFYMDw7Pf7cDJ7NVHcHV5 ip9w== X-Gm-Message-State: AOAM532t/JXIThVXlk8jI2GjBJQZWvyRpl8ShtTea5MjduIfTtYO+xIj xFEeX7pMck/XWDs7MSZQDhhAOQ== X-Received: by 2002:a17:90a:6482:: with SMTP id h2mr24182383pjj.24.1627283486888; Mon, 26 Jul 2021 00:11:26 -0700 (PDT) Received: from x1 ([174.127.163.79]) by smtp.gmail.com with ESMTPSA id o134sm43060098pfg.62.2021.07.26.00.11.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 00:11:26 -0700 (PDT) Date: Mon, 26 Jul 2021 00:11:24 -0700 From: Drew Fustini To: Linus Walleij Cc: Michael Walle , Rob Herring , Bartosz Golaszewski , Paul Walmsley , Palmer Dabbelt , Michael Zhu , Geert Uytterhoeven , Fu Wei , linux-kernel , "open list:GPIO SUBSYSTEM" , linux-riscv , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Emil Renner Berthing , Huan Feng Subject: Re: [RFC PATH 2/2] gpio: starfive-jh7100: Add StarFive JH7100 GPIO driver Message-ID: <20210726071124.GA9184@x1> References: <20210701002037.912625-1-drew@beagleboard.org> <20210701002037.912625-3-drew@beagleboard.org> <8c59105d32a9936f8806501ecd20e044@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 11:04:41PM +0200, Linus Walleij wrote: > On Thu, Jul 1, 2021 at 8:39 AM Michael Walle wrote: > > Am 2021-07-01 02:20, schrieb Drew Fustini: > > > Add GPIO driver for the StarFive JH7100 SoC [1] used on the > > > BeagleV Starlight JH7100 board [2]. > > > > > > [1] https://github.com/starfive-tech/beaglev_doc/ > > > [2] https://github.com/beagleboard/beaglev-starlight > > > > > > Signed-off-by: Emil Renner Berthing > > > Signed-off-by: Huan Feng > > > Signed-off-by: Drew Fustini > > > > Could this driver use GPIO_REGMAP and REGMAP_IRQ? See > > drivers/gpio/gpio-sl28cpld.c for an example. > > To me it looks just memory-mapped? > > Good old gpio-mmio.c (select GPIO_GENERIC) should > suffice I think. > > Drew please look at drivers/gpio/gpio-ftgpio010.c for an example > of GPIO_GENERIC calling bgpio_init() in probe(). Thank you for the suggestion. However, I am not sure that will work for this SoC. The GPIO registers are described in section 12 of JH7100 datasheet [1] and I don't think they fit the expectation of gpio-mmio.c because there is a seperate register for each GPIO line for output data value and output enable. There are 64 output data config registers which are 4 bytes wide. There are 64 output enable config registers which are 4 bytes wide too. Output data and output enable registers for a given GPIO pad are contiguous. GPIO0_DOUT_CFG is 0x50 and GPIO0_DOEN_CFG is 0x54 while GPIO1_DOUT_CFG is 0x58 and GPIO1_DOEN_CFG is 0x5C. The stride between GPIO pads is effectively 8, which yields the formula: GPIOn_DOUT_CFG is 0x50+8n. Similarly, GPIO0_DOEN_CFG is 0x54 and thus GPIOn_DOEN_CFG is 0x54+8n. However, GPIO input data does use just one bit for each line. GPIODIN_0 at 0x48 covers GPIO[31:0] and GPIODIN_1 at 0x4c covers GPIO[63:32]. Thus the input could work with gpio-mmio but I am not sure how to reconcile the register-per-gpio for the output value and output enable. Is there way a way to adapt gpio-mmio for this situation? Thanks, Drew [1] https://github.com/starfive-tech/beaglev_doc