From patchwork Tue Nov 7 15:17:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 118192 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4104431qgn; Tue, 7 Nov 2017 07:19:19 -0800 (PST) X-Google-Smtp-Source: ABhQp+RKmmastshaAUzLv+I+x2WxMH3HYIy+UXYMCKNQbbEjGOE1qKwiv1XsBx8ul5WAC7USPSsP X-Received: by 10.99.105.71 with SMTP id e68mr18933563pgc.55.1510067959357; Tue, 07 Nov 2017 07:19:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510067959; cv=none; d=google.com; s=arc-20160816; b=jUNA+QR1rAFu2cLyUrjJ4bLBxDXk0fcrDTuU+JI126chzvCU+HjNO45Qv/ioQHfaXk 9Yq48l7WjVfdZw2uRY01pvgiNoB9nUWCFA22Q/8VeViqsMLA/nYT5f1czUew0WOxHdM0 qlEPaZnlNuy01HSiKc91Eq3Fylng+Dzo3XoP4dBByZt8UhPJwjqCGnR3341SWcsW17EW 0/WAU7GMJDpmbff2EznR0ed0CJgSBkCpVnzsh/wFebYPE0+yeHwXs8egmzFhuRPuzHG/ DbBcx7HvurP1fUyoBKwjznM8qsObkmTt0DumBbG/dVzMiVqRF8AU9jAg9QtWrhFwRN8+ i1Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=QFaF05zvlmH8VXqhqDrfNzKdljGwPc7FS0smtsATLHY=; b=jYVeHdscX8DU1GRouEr0l7ViZfnUIPqypxked0Ailcfke1+5IP6iF4D5Bze1mp7G6f urjf4GmcChzo7WeVOJ3R9iLR+4AqIY/BTf+aIThohLnP5G7ltzSfx+rzFzy9YtYb0TNf lARrK7eLRSXASGdX0cTXPZK7IBOiFzPOPxDGx2gHbPk2DXRXm1YbOxEa/30avyHMbSdy RcCWE0EIFU2SPR8xBXhYD18EnK6GwV0bddyaULIaYlOiFhRg+gUSTlESe5Fv1qrdKqE1 2RZQzrqed2emRu/I+c9P09lxuAmA72XmrcC6PHjnbyiecP+QRfaPnh01A1tp8XSbMJZa 11Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HvEcAxEf; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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. [209.132.180.67]) by mx.google.com with ESMTP id g13si1423286plk.466.2017.11.07.07.19.19; Tue, 07 Nov 2017 07:19:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HvEcAxEf; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-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 S1752732AbdKGPTS (ORCPT + 3 others); Tue, 7 Nov 2017 10:19:18 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:49011 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751844AbdKGPTR (ORCPT ); Tue, 7 Nov 2017 10:19:17 -0500 Received: by mail-lf0-f65.google.com with SMTP id r135so14923334lfe.5 for ; Tue, 07 Nov 2017 07:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=QFaF05zvlmH8VXqhqDrfNzKdljGwPc7FS0smtsATLHY=; b=HvEcAxEf5GwbIeFCsxFi7ML/ciHmsVNVdAy8puJnH12q7tU4sFVozXxT0G6ptHw9v0 qHLl7H735rd0sPl7PcNjrVzmh5ajucZCMZLjRXH4PzFZugJBV2GlNKWUIwobhSuWpd8T RURDC1HgvYOuCNnAoMd0hpXQ6E7dFvVgdeei4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QFaF05zvlmH8VXqhqDrfNzKdljGwPc7FS0smtsATLHY=; b=EDQKHICUs/qvpOoZ0kHXZPftqLHLXIKdepBI3/aqUQPp+QV8EplN9ia01SRUNmrFMp siLT7U1BYBJmbZzG8N0QGg/iFBQknSoWdvVvu4ho3lwnuOSxgvCrfiLlW0yVFFHyIxx0 ZwtLqNJ5EM0uZM7Ls8Wr64LLQONiUVtEfTt+5YrPPO57Nojgf+b/JnQjd062AzSzx38E EyVhVKpso/nYrQV2ki6k0kbwO7I6og8IqBUlVe23Yi7b6OwxR+K1s9NLPieg7G2N/+AH vx8MoKUJb2YeHDJZkdwHGkwQf9y5HW8SK6Obf4KCiZYuukUiVCalV1MUmHJxXQwpBSbi aRLg== X-Gm-Message-State: AMCzsaV2wHPQ4XKdEENcSuwi4jf01Af6fbJYl+zqtZZhu1Uwnd695ENU ez02aFcUEU+aMf4A7HbA+F0OZIuzY/g= X-Received: by 10.46.95.82 with SMTP id t79mr7111052ljb.63.1510067955894; Tue, 07 Nov 2017 07:19:15 -0800 (PST) Received: from localhost.localdomain (c-567171d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.113.86]) by smtp.gmail.com with ESMTPSA id 18sm295675ljo.29.2017.11.07.07.19.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2017 07:19:14 -0800 (PST) From: Linus Walleij To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Linus Walleij , Wolfram Sang , Jochen Friedrich , linux-arm-kernel@lists.infradead.org, Russell King Subject: [PATCH] ARM: sa1100: simpad: Correct I2C GPIO offsets Date: Tue, 7 Nov 2017 16:17:03 +0100 Message-Id: <20171107151703.3847-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.6 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Arnd reported the following build bug bug: In file included from arch/arm/mach-sa1100/simpad.c:20:0: arch/arm/mach-sa1100/include/mach/SA-1100.h:1118:18: error: large integer implicitly truncated to unsigned type [-Werror=overflow] (0x00000001 << (Nb)) ^ include/linux/gpio/machine.h:56:16: note: in definition of macro 'GPIO_LOOKUP_IDX' .chip_hwnum = _chip_hwnum, ^~~~~~~~~~~ arch/arm/mach-sa1100/include/mach/SA-1100.h:1140:21: note: in expansion of macro 'GPIO_GPIO' ^~~~~~~~~ arch/arm/mach-sa1100/simpad.c:331:27: note: in expansion of macro 'GPIO_GPIO21' GPIO_LOOKUP_IDX("gpio", GPIO_GPIO21, NULL, 0, This is what happened: commit b2e63555592f81331c8da3afaa607d8cf83e8138 "i2c: gpio: Convert to use descriptors" commit 4d0ce62c0a02e41a65cfdcfe277f5be430edc371 "i2c: gpio: Augment all boardfiles to use open drain" together uncovered an old bug in the Simpad board file: as theGPIO_LOOKUP_IDX() encodes GPIO offsets on gpiochips in an u16 (see ) these GPIO "numbers" does not fit, since in arch/arm/mach-sa1100/include/mach/SA-1100.h it is defined as: This is however provably wrong, since the i2c-gpio driver uses proper GPIO numbers, albeit earlier from the global number space, whereas this GPIO_GPIO21 is the local line offset in the GPIO register, which is used in other code but certainly not in the gpiolib GPIO driver in drivers/gpio/gpio-sa1100.c, which has code like this: static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { int reg = value ? R_GPSR : R_GPCR; writel_relaxed(BIT(offset), sa1100_gpio_chip(chip)->membase + reg); } So far everything however compiled fine as an unsigned int was used to pass the GPIO numbers in struct i2c_gpio_platform_data. We can trace the actual error back to commit dbd406f9d0a1d33a1303eb75cbe3f9435513d339 "ARM: 7025/1: simpad: add GPIO based device definitions." This added the i2c_gpio with the wrong offsets. This commit was before the SA1100 was converted to use the gpiolib, but as can be seen from the contemporary gpio.c in mach-sa1100, it was already using: static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) { return GPLR & GPIO_GPIO(offset); } And GPIO_GPIO() is essentially the BIT() macro. Cc: Wolfram Sang Cc: Jochen Friedrich Cc: linux-arm-kernel@lists.infradead.org Cc: Russell King Reported-by: Arnd Bergmann Signed-off-by: Linus Walleij --- Wolfram: this is in the i2c GPIO refactoring in your tree, please apply it directly as a fix for v4.15 if there are no protests. Jochen: did this ever work? I suspect the patch was simply developed on top of a different kernel. --- arch/arm/mach-sa1100/simpad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c index 9db483a42826..7d4feb8a49ac 100644 --- a/arch/arm/mach-sa1100/simpad.c +++ b/arch/arm/mach-sa1100/simpad.c @@ -328,9 +328,9 @@ static struct platform_device simpad_gpio_leds = { static struct gpiod_lookup_table simpad_i2c_gpiod_table = { .dev_id = "i2c-gpio", .table = { - GPIO_LOOKUP_IDX("gpio", GPIO_GPIO21, NULL, 0, + GPIO_LOOKUP_IDX("gpio", 21, NULL, 0, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), - GPIO_LOOKUP_IDX("gpio", GPIO_GPIO25, NULL, 1, + GPIO_LOOKUP_IDX("gpio", 25, NULL, 1, GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN), }, };