Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp522090rdb; Thu, 21 Dec 2023 17:28:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4Qm/msYAr7/biTfEDAq35bI70E3jcILQ7FO8vnVEd7BLca8+PvOLh310/vOF2wYt+Mqsm X-Received: by 2002:a05:6214:5287:b0:67f:3d0e:783e with SMTP id kj7-20020a056214528700b0067f3d0e783emr636132qvb.93.1703208482815; Thu, 21 Dec 2023 17:28:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703208482; cv=none; d=google.com; s=arc-20160816; b=H9oiUDWyODjI/9mg6NhUSaDYbKp+L7JTvkZPWpzM94lYu/kOOTPK1nkUV6KLhO2pX0 FzQA+/0dfZQiWQk0jkQ45V83naCdlYEQ+zsnzM2JlSaA/STX0m52NztTwfWu+LciKJuE aTNp14K3uLuMHnfnHbGSoEho8yJ0fuIZCm/Ljg4KcjLU8jANqN/0M2cFxH2U7oJjD5yY DNU1auT6c0SY9dC7ercCE9ZQ3eKp6oim1aqfT9cax3fdCR516k0reBl/rRqkFtd+YqfY vLlzFKySp/oThVvcJ6oDy2i0sJuLKKx6Wq9wWZcsNR6R2x4s2r9bGyPF4cBl4DaSwZ6w ilnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=cbiwt6IU8kOI0izJYNgyXRRGilmtjvoO7sPIgNCgD0Y=; fh=DsXVqLCcXu/qXHnTjg2pPKLTD2WDt+XEzEw7e46pA/s=; b=mClax7c1WuPmO5EXn4c0I5JmS9kIaUF+SIhtozVunz9yueYgpt8KMMjsBKzEcjyfAy L6+8mLmwQVa6dEkmAMiK+uptkBhbPPe2PcCFEgJVxoWeYmb0A4/7BuXs92rjDLD4IEaD SlzD9+DH24T7sQpiD4hE9Sy8xBNSnsYCXL6Fu9n3K/eHc1qTXH8PLRpKrUHqb8m72ExC fXLRR+3XHjlNOpdSxFcikIOCWvqFd7aQBGGQr8GD/LWiYmHAcFNLFt+56C72V1oZrCsj OdrBDp+yCgWZoRUxuB6WUvj1+7DdyFGoyIsedDq/FlC/3CYKk6oepSfx+/16v7sYf27E hL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="a3OLoF/l"; spf=pass (google.com: domain of linux-kernel+bounces-9238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y12-20020a0cf14c000000b0067f84b32003si2298950qvl.85.2023.12.21.17.28.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 17:28:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="a3OLoF/l"; spf=pass (google.com: domain of linux-kernel+bounces-9238-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9238-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D9731C2477B for ; Fri, 22 Dec 2023 01:28:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAE7563A7; Fri, 22 Dec 2023 01:27:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a3OLoF/l" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A228E612E; Fri, 22 Dec 2023 01:27:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2cc95f1102eso15022171fa.1; Thu, 21 Dec 2023 17:27:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703208470; x=1703813270; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cbiwt6IU8kOI0izJYNgyXRRGilmtjvoO7sPIgNCgD0Y=; b=a3OLoF/lLCOsSO9XfNOud1fXQf1Pe7zLVEyUIEOlaA9TJEUC9wOV2NcT96rBC7HvyT AjTDsQZsR4Gytp4LS0w4IdRJoVTrjjCyUXvLuHs7ZVsdVz7kviI1ZrnImPjqI8OmrVvP hnFSLNkeSdFLQ/0vwiwcd/6i2HMRWWjlIvqvLiqyLCvFcvVcf9VaKXoYsym6b7PU9ZMd Wwb/HnQWfW1/yq66iRw0vyUVplbRgQyGqnicLh1/XRV0cwOff8RJlOJeIQTK+b1jKb5a WC8b/ZbpCpFodlYPUAo+w25NxnHX9jKfs8y/bicPppjNYus3phHd+o+A4ILVBUZAx92S KOaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703208470; x=1703813270; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cbiwt6IU8kOI0izJYNgyXRRGilmtjvoO7sPIgNCgD0Y=; b=nO8iovgTYhYT8Codcj/YPSADVJHBEBO11epiFbkem7PZRVV4JPpATQcLBEW/cRL9Nx VgX8qLPy4lIN7JWgWPv3GsrMWxDal66WXYXTsvmb4mW7jZEGqX5YdZrXCxafiLqyeAqw qaJqwrZlkrW6B5I/0lDQJK6/TbWtx5ohMu5QhXiJfvG6fItCUQmSffy/OnCX5MVTfXMC 5tHuhg2YRMiH8T4Q4821k1/a9a+4DvynRhk5pSErLVj32Gie2h9O5U+Ukcu4J6ymp7XU Q98NWHL1t7+zfwTZ03MybrO3CluX5UsFAhXBJPrgjz4PTWAV7x/1JU67ZnfF8sipNXBe EJpA== X-Gm-Message-State: AOJu0Yw1Q09/EFTnfagZB7BoBthlKmA6GPo3LjBWQ36eWVsHKpCp7Brv yhGVstz6g93oT8gW1YOqboeCShLoe7/uFWXW+ao= X-Received: by 2002:a2e:6e04:0:b0:2cc:89ef:23f9 with SMTP id j4-20020a2e6e04000000b002cc89ef23f9mr142991ljc.17.1703208470239; Thu, 21 Dec 2023 17:27:50 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231212065147.3475413-1-jim.t90615@gmail.com> <20231212065147.3475413-4-jim.t90615@gmail.com> In-Reply-To: From: Jim Liu Date: Fri, 22 Dec 2023 09:27:39 +0800 Message-ID: Subject: Re: [PATCH v9 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver To: Andy Shevchenko Cc: JJLIU0@nuvoton.com, KWLIU@nuvoton.com, linus.walleij@linaro.org, brgl@bgdev.pl, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Content-Type: text/plain; charset="UTF-8" Hi Andy Thanks for your reply. The description as below > > > + in_port = GPIO_BANK(gpio->nin_sgpio); > > > + if (GPIO_BIT(gpio->nin_sgpio) > 0) > > > + in_port += 1; > > > > This is strange... So, you are telling that offsets start from 1 and not 0? > > > > > + out_port = GPIO_BANK(gpio->nout_sgpio); > > > + if (GPIO_BIT(gpio->nout_sgpio) > 0) > > > + out_port += 1; > > > > Ditto. > > > Yes, if the customer has defined the in/out pins the offsets start from 1. >Why? The NPCM_IOXCFG2_PORT default setting is to enable 0 input port and 0 output port. The register default value is 0x0. Each port can support 8 pins. If the register value is 0x31 means enable 3 output ports and 1 input port. If customer has define nuvoton,input-ngpios or nuvoton,output-ngpios dts property For example , nuvoton,output-ngpios = <9> > > > + out_port = GPIO_BANK(gpio->nout_sgpio); The out_port value is 1 but one port only supports 8 pins. > > > + if (GPIO_BIT(gpio->nout_sgpio) > 0) > > > + out_port += 1; This out_port value is 2, the driver will enable two port to support 9 pins. Maybe it is my expression error , the out_port and in_port default value is 0. > The NPCM_IOXCFG2_PORT register is the set number of in/out ports. > NPCM_IOXCFG2_PORT register define as below: > 0~3 bit is the number of input ports > 4~7 bit is the number of output ports > Each module can support 8 input ports and 8 output ports. Best regards, Jim