From patchwork Tue Jun 15 14:59:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 460519 Delivered-To: patch@linaro.org Received: by 2002:a17:907:7409:0:0:0:0 with SMTP id gj9csp3792105ejc; Tue, 15 Jun 2021 08:01:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcsZ1NmGX77QU0NbV6/hCZKA2/NZ/c9Q1is49GkHQ0Lv+EuyHndnfJWj12MXHcrZrjJB5T X-Received: by 2002:a05:6638:1382:: with SMTP id w2mr21947618jad.36.1623769277471; Tue, 15 Jun 2021 08:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623769277; cv=none; d=google.com; s=arc-20160816; b=fgTasONhdGg/pAJT8G669nXAAK4yC+LNkaH7iAuvZZyuYgfWJhT4bSqg6tI1kcz9Xl p7nWnQuEjI9H4wnCEgLGzgLYoS8ZEVvhJRMBbuQyYeviOloKYJm4z+W6vncA0aHSgu/P IuTDioiBDKuazUhNPaMCTx8LVf+MhoZOKTYdUOlRW0sA53kBaumMmksTmGgT00upEq9F cZoRZW3W3mzyx7N7qTguK64LEn8ZucUMdyNe6qmL3MOXwOKxycMzE/3txfRViUXCvmv+ 8tSk92qAG3YbWwXj4Wupd+iWfY0m+TSHJCfWBEF/l67qfIdy3jr44ckVlP741UV0K8a6 gX8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cJ3E6xz1GtHO5ssuzNBSjmKl0fJUbXbXi3ZsWAUHOk0=; b=t/dNHnG0/QVg4DS+JdcAbxJo1YFAjnlsTd8OWDyl/io2GoQJQVCEAFIiN2wlR2QeIx QKlPUlBl/5DdAmKtAx6BhZzqOt4homXnLANqgnkf791bOY4KSzCCBjUuYGnt20HXjAQa m3aRZGHPsZ9i54CAsm6nhZK9e2Bx4i0r8S599nm/RRbTZMf+MTDUtCEfP3LqgBq/CtPs v+tO+coX6cZyOBnJcJkBLQ/9mssgW3gkGj8AXwX/RNUs6jYURKaeynnRDbSGoNiumt5D /SFUnkJSZp0bk91e5FPPTUx+I9SR/79s8RNoCCk7GJiDncZSPEr+rXbTlQNkdJBdDxxP hS1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TFRBCQYr; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-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 h2si20136003ile.35.2021.06.15.08.01.17; Tue, 15 Jun 2021 08:01:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-gpio-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=TFRBCQYr; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-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 S231398AbhFOPDU (ORCPT + 3 others); Tue, 15 Jun 2021 11:03:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231389AbhFOPDU (ORCPT ); Tue, 15 Jun 2021 11:03:20 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23EC1C061574 for ; Tue, 15 Jun 2021 08:01:15 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id r16so25458715ljk.9 for ; Tue, 15 Jun 2021 08:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cJ3E6xz1GtHO5ssuzNBSjmKl0fJUbXbXi3ZsWAUHOk0=; b=TFRBCQYrClIJos2Bez2gAp3xfty8ROT++L/cj0GEl8zFVd+2qXYMW7MfEZ/RTbX7X8 ynUk6KnsxaSZw5zfVWP3sUUhIZCZrvW5Xt0COoAYvroRAguETHaqzYTr0EQoThdS3GIG SiUlQUttAOtFnJg/xAvQakrJwfbfne+bnc5/cJlLv3lFMKoKcPfnn4ImvFHcyWEYAkbA 6v9alzB6m3Uh4Alsnch1S/Ko9Ky0kP3xetjSQ1IYVO6LdzntNaVEkDE2NgiMVO5tOd3A dVDRFHQDM4BjaWVfU17GsNejkj/SfPKxvQFgLHL481P+Cez2Xoty6K7uU4Omd+glDS7t hwpw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=cJ3E6xz1GtHO5ssuzNBSjmKl0fJUbXbXi3ZsWAUHOk0=; b=UatUqXlAqJYup+IHp5QuBrtJdsTzTDOnkw1C1ex0ZAGtEwdcng9n9+ATnsbyiwDkWI V/9HeYtFHojFjHRsliRIX6JptbGPVrxxIVEcabAQBZCZpkF3seE54WlTfIh9gy0YziJe 72J/0owMF375D4f/LcWvVbVv0BOUaLKJ+6u5V/Tvt2K6uiySpQpRZo9RiaQ3gBDcwdIv UvP3wtmfGerh6+GihFkXUedSZZyok3VeXSsPbnNFd2uoFIyxUXr6KZU5za6wI8BkLWdb y96y0huVO1KMTMmkWxQaaZrlsJByFounbcPQYmtOByMP+vWEt8lKU21KgIMkMUjMa8vQ BQ4A== X-Gm-Message-State: AOAM5310PW9KLgJ7gB1udYKlHuS23gu1/dsPKoiv1DZg+R1vzUNavMcP n7A75LCrV8gK7bzK0hSXAwRL4qKCppXKZg== X-Received: by 2002:a2e:89d9:: with SMTP id c25mr22628ljk.63.1623769271832; Tue, 15 Jun 2021 08:01:11 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id c18sm788914lfd.51.2021.06.15.08.01.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 08:01:11 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Linus Walleij , Sekhar Nori Subject: [PATCH 3/3 v5] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table Date: Tue, 15 Jun 2021 16:59:03 +0200 Message-Id: <20210615145903.634565-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210615145903.634565-1-linus.walleij@linaro.org> References: <20210615145903.634565-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This converts the DaVinci DM646x LEDs to use GPIO descriptor look-ups. Cc: Sekhar Nori Cc: Bartosz Golaszewski Reviewed-by: Bartosz Golaszewski Signed-off-by: Linus Walleij --- ChangeLog v4->v5: - Name each I2C expander instance explicitly as "u2" etc. - Tie the LEDs to the generated "i2c-u2" device name. ChangeLog v3->v4: - Rebase on v5.13-rc1 - Resend - LED maintainers: please apply this patch, it is ACKed by a DaVinci maintainer ChangeLog v2->v3: - Rebase on v5.10-rc1 - Resend ChangeLog v1->v2: - Collect Bartosz' review tag - Rebase on v5.9-rc1 - Resend --- arch/arm/mach-davinci/board-dm646x-evm.c | 34 +++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) -- 2.31.1 diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index ee91d81ebbfd..00c074fddce6 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -202,10 +203,10 @@ static struct i2c_driver dm6467evm_cpld_driver = { /* LEDS */ static struct gpio_led evm_leds[] = { - { .name = "DS1", .active_low = 1, }, - { .name = "DS2", .active_low = 1, }, - { .name = "DS3", .active_low = 1, }, - { .name = "DS4", .active_low = 1, }, + { .name = "DS1" }, + { .name = "DS2" }, + { .name = "DS3" }, + { .name = "DS4" }, }; static const struct gpio_led_platform_data evm_led_data = { @@ -213,18 +214,32 @@ static const struct gpio_led_platform_data evm_led_data = { .leds = evm_leds, }; +static struct gpiod_lookup_table evm_leds_gpio_table = { + .dev_id = "leds-gpio.0", + .table = { + /* + * These GPIOs are on a PCF8574a GPIO expander, which + * is in turn named after the I2C device name. This is + * device "u2" on I2C bus 1 with address 0x38. These + * leds are at offset 4, 5, 6, 7. + */ + GPIO_LOOKUP_IDX("i2c-u2", 4, NULL, 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("i2c-u2", 5, NULL, 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("i2c-u2", 6, NULL, 2, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("i2c-u2", 7, NULL, 3, GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct platform_device *evm_led_dev; static int evm_led_setup(struct i2c_client *client, int gpio, unsigned int ngpio, void *c) { - struct gpio_led *leds = evm_leds; int status; - while (ngpio--) { - leds->gpio = gpio++; - leds++; - } + /* Add the lookup table */ + gpiod_add_lookup_table(&evm_leds_gpio_table); evm_led_dev = platform_device_alloc("leds-gpio", 0); platform_device_add_data(evm_led_dev, &evm_led_data, @@ -438,6 +453,7 @@ static struct i2c_board_info __initdata i2c_info[] = { }, { I2C_BOARD_INFO("pcf8574a", 0x38), + .dev_name = "u2", .platform_data = &pcf_data, }, {