Received: by 10.192.165.148 with SMTP id m20csp1855230imm; Thu, 26 Apr 2018 03:19:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx48X7LtQO64+GDf6x5XXQDcJMXLpqRamQZgpBbzoOEA8ookivseA3Homg1cJPkQpDoVqTLOz X-Received: by 10.99.117.22 with SMTP id q22mr26732612pgc.68.1524737988762; Thu, 26 Apr 2018 03:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524737988; cv=none; d=google.com; s=arc-20160816; b=Tzek/ccwphZ1IFo1mtgXKHzq8FuLUzISxtmN3FHRd2Mu7rRX3H2iE/4jWLmyvvOMJG MAwcxvLqLHxHSSD6LxZe+D12MNMUaBfnjuHOx6ubziSiG4pEiNUy8xSArsrXPGMNqBrk IkPdsKfP1WHU2T/W0IebBzDi+SoBfoAC1FPDnwhus3ykKaenG5GiEVZrmLuOoMCSt+qz JKSu5rHShpqXj+cgUuO/LY/VpIk9YV2vv/j4urYE19Kw22qVHlwKzCLar2MEZRrU6Z5W LDuyaEC0DxKmKxJA1/tO1q/8z8P5AE/z6iSp/YGD4hiLkeIw0bzmSCOaLK/VRgrR71bE z8yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=FWrCf4gJOemraCIXP4/29YnqaQm1l5FBetTg8xpyDLs=; b=mifzS9rvjCzepGt5bjesKJ+30m0i/QVdwOzCPV5ePA52RVV5U3NMExQQbJ1tHwu5OZ XIUEpGMD0boIOubl3ulX1GIyfebJkwglYCpQt/Bh/Yw8WnAZcuhigZfCVOXqbzWKxfMt iL9JaSUTyiK2Y7OhIebYriyGOLhM4i9mpN3/4HPGBwRZVz2k4jOCvzRG7JnkB2PSFR1u gGKOtJSnRx8f/M/IEA1+DcFbz5mUUu7A4MBzFBBCVTWUQ5f8073SZTA969+1mgBeHLSE kApt3S1Cpa1D2/krTM9zwWMYtzUFUa4SC2IqhH+kJfocKb7W8xuDmtFjKwJ9UaSNzcDW K+PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@goldelico.com header.s=strato-dkim-0002 header.b=HXSuLmCc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15-v6si20013170pln.526.2018.04.26.03.19.34; Thu, 26 Apr 2018 03:19:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@goldelico.com header.s=strato-dkim-0002 header.b=HXSuLmCc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755252AbeDZKR6 (ORCPT + 99 others); Thu, 26 Apr 2018 06:17:58 -0400 Received: from mo4-p02-ob.smtp.rzone.de ([81.169.146.170]:14249 "EHLO mo4-p02-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754842AbeDZKRm (ORCPT ); Thu, 26 Apr 2018 06:17:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1524737858; s=strato-dkim-0002; d=goldelico.com; h=To:References:Message-Id:Content-Transfer-Encoding:Cc:Date: In-Reply-To:From:Subject:Content-Type:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=FWrCf4gJOemraCIXP4/29YnqaQm1l5FBetTg8xpyDLs=; b=HXSuLmCcSkP0Sj145zfu/4ZNYTH9KyeecEnZB5ogdzbGHFj+StCeuq+oaABh1Q8bE8 LdajDwzvnv+Wm6lEIrl9d2Sr1N7354LVFu+3GsHn5Bu814CIB/cV1bZ6Ualch0NjhzeM PUosWKjX+At6P+Fav4lHFCkczlwFQEtuY8jKn2BjX9ZsLPV4nR6ldAH/djycwzpVbebn zmJyBP/xo7kYLbiehUR7yVeS7tVLntNbt/4/MI1uJFJLPdTo5MNeed3aeHBo8u8QiVqH UeSnw/EeaWIlMwjcLDshnvULndPk2m+PgsLQahC4AAz3Cvo5SwaMaZDbWt+gYj1lgkCE Smlg== X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcJeFKiMgPgp8VKxflSZ1P34KBj4Qpw87WisdN1GTaY X-RZG-CLASS-ID: mo00 Received: from [192.168.2.107] by smtp.strato.de (RZmta 43.5 DYNA|AUTH) with ESMTPSA id z0512cu3QAHO3JA (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 26 Apr 2018 12:17:24 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: [Letux-kernel] [PATCH v3 2/4] gpio: pca953x: add register definitions for pcal6524 and fix address calculation From: "H. Nikolaus Schaller" In-Reply-To: Date: Thu, 26 Apr 2018 12:17:23 +0200 Cc: Mark Rutland , Alexandre Courbot , Pawel Moll , Ian Campbell , Linus Walleij , kernel@pyra-handheld.com, Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , devicetree , Rob Herring , Kumar Gala , Discussions about the Letux Kernel Content-Transfer-Encoding: quoted-printable Message-Id: References: <0e9bea79eae7504e61fabdb4a0311f8fdc2f6b25.1523376423.git.hns@goldelico.com> <65085C47-CDA8-4F8C-8307-C145F21F7D19@goldelico.com> To: Andy Shevchenko X-Mailer: Apple Mail (2.3124) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, > Am 26.04.2018 um 12:06 schrieb Andy Shevchenko = : >=20 > On Wed, Apr 25, 2018 at 9:05 PM, H. Nikolaus Schaller = wrote: >>> Am 11.04.2018 um 07:00 schrieb H. Nikolaus Schaller = : >>>> Am 10.04.2018 um 20:06 schrieb Andy Shevchenko = : >>>> On Tue, Apr 10, 2018 at 7:07 PM, H. Nikolaus Schaller = wrote: >=20 >>>>> PCAL chips ("L" seems to stand for "latched") have additional >>>>> registers starting at address 0x40 to control the latches, >>>>> interrupt mask, pull-up and pull down etc. >>>>>=20 >>>>> The constants are so far defined in a way that they fit for >>>>> the pcal9555a when shifted by the number of banks, i.e. multiplied >>>>> by 2. >>>>>=20 >>>>> Now the pcal6524 has 3 banks which means the relative offset >>>>> must be multiplied by 4 which gives a wrong result if not done >>>>> carefully, since the base offset is already included in the = offset. >>>>>=20 >>>>> For the basic registers shared with all pca93xx/tca64xx chips >>>>> there is no such offset. >>>>>=20 >>>>> Therefore, we add code to adjust the register number for exended >>>>> registers to the 24 bit accessor functions. >>>>>=20 >>>>> And we add additional register offset constants (not yet used by >>>>> the driver code) which are specific to the pcal6524. >=20 >>>> First of all, as I said, please split this to two patches. Don't = mix the things. >>> Ok. Queued for v4. >=20 > I actually think it would be even more patches: > - move to hex from dec > - add new definitions for PCAL953x > - append new code for registers (see below) > - add definitions for PCAL6524 It is already done in my local git, just waiting for the address thing... >=20 >>>>> + /* adjust register address for pcal6524 */ >>>>> + if (reg >=3D PCAL953X_OUT_STRENGTH) >>>>> + reg -=3D PCAL953X_OUT_STRENGTH >> 1; >>>>> + >>>>=20 >>>> Give me some days to think about it. >=20 > So, what about something like: >=20 > --- 8< --- 8< --- > #define PCAL953X_GPIO_MASK GENMASK(5,0) // this makes sense even for > your initial solution >=20 > int bank_shift =3D fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); > int addr =3D (reg & PCAL953X_GPIO_MASK) << bank_shift; > int pinctrl =3D (reg & ~PCAL953X_GPIO_MASK) << 1; Ok! Intersting idea. Basically decomposes register bank number (pinctrl) and register offset = (addr) and shifts them differently. >=20 > return i2c_smbus_write_i2c_block_data(chip->client, > pinctrl | addr | = REG_ADDR_AI, > NBANK(chip), val); >=20 > // similar for read. Looks good. I'll test asap. BR and thanks, Nikolaus >=20 > --- 8< --- 8< --- >=20 > Keep in mind your solution has a bug for registers starting from 0x30. >=20 > --=20 > With Best Regards, > Andy Shevchenko