From patchwork Sun Jun 13 00:03:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 459358 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp2139044jae; Sat, 12 Jun 2021 17:07:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl745L62HODTpXPEQuOaw76X4MUpVzNcvhsjAVcCKDd5c1EvrZx1S5hkJZC1MS+Nq4B5UO X-Received: by 2002:aa7:ccc1:: with SMTP id y1mr10443366edt.333.1623542837574; Sat, 12 Jun 2021 17:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623542837; cv=none; d=google.com; s=arc-20160816; b=v2YD0K6fdKqAMTpdjMZ/yCl5KLnGu3Jury5MPRSvt0N8wLFyTgzuItvSnU3dMR9e/X Lh5GJoTJwIrcH/1TGeiBJD54jDhjXeHE5HXHTBILP2xQaPJijI48JQcUcB4IOBYIF38n mmFrKxw/mTQijjKpfGA3RHCoo8uegKMdJcixH9XOn1DSaHDr1LGVfAZOy3+aLw9lrCp8 aoxRkCvfriWwdh9Z27aBKdMrJkoyp4UBDPEesN72MD0t4P5z8Cq/Ej9uc8m2GjmQBW/y jHOeAsLHBRSBb2XIOOjRe3DCXNTyabwOmhA8zdEBlzUhtrLBxZfL5q+nzeOUipkbFnyn UdRg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=g/mSZoqPlWK6T+TfBIdgoZ0pB815FYg1CJaot/oFpRU=; b=AbFj6dLzZjJDskVCf+9MINpNjjSZRgO23Rxi+ynRs720isYT7zNMMpDSB1EvV1lhls 9w4iflojEM8QKsm7D5Z/7VxZP0snKEe+I+3vExxwyFYG5O0mDc39KmbObCNCmnID40BZ gmJvqzLGry0YEdtVVR70zLAJskuu86aKUlKIiQeWFbnAuzHj8qVzsTHM9LDuaF7/A66y 0pwT2zU/f1vFw28/sBldwgg6C9Ypi9yQ3jTAw8FF4UNnZOuwWhIiqruChlz6ZZgR7TmY F4/5+FZRM2AOP2NesUEISuIiIsTfnkUrvjLAvP+exoFEWRh1O88b56pghF4VyxO7ath8 lE/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gt/BexTN"; spf=pass (google.com: domain of linux-leds-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-leds-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 5si7534839ejh.625.2021.06.12.17.07.17 for ; Sat, 12 Jun 2021 17:07:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-leds-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="gt/BexTN"; spf=pass (google.com: domain of linux-leds-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-leds-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 S229777AbhFMAIK (ORCPT ); Sat, 12 Jun 2021 20:08:10 -0400 Received: from mail-lj1-f178.google.com ([209.85.208.178]:42717 "EHLO mail-lj1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbhFMAIK (ORCPT ); Sat, 12 Jun 2021 20:08:10 -0400 Received: by mail-lj1-f178.google.com with SMTP id r16so14728085ljk.9 for ; Sat, 12 Jun 2021 17:06:09 -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:mime-version :content-transfer-encoding; bh=g/mSZoqPlWK6T+TfBIdgoZ0pB815FYg1CJaot/oFpRU=; b=gt/BexTNBowuvEBy9eSTww3uDf31/AEcH0FrTLIYwKuZlEGRUSgAHYRbehCbiJd0Ow 7gelQwEwXAWlqLqOvQzzEMj4AOpvqvsyLswFb9Ed3en4+5yFMNyQjS69WmUz5O0oYgYZ sCU2P/p6dxpBteDu+qd2+w9kdh/xDtbklh2bZe3ORvbxjaFOPZTA9wlKoFB/mGhD0ZZO fwh/MU0Ply0693NRXgn/Tv9LJ7gm1HHf8Mg5BNOTpLonxIdW84pWlPl2FY/I7/lfvDM6 UyJnUoI6qrLJmMoqJ144R+GHEKKbZ94yMVcjrsF9Xdd9lRbaQtu2h0hrMZTGRhluem+8 GM4g== 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:mime-version :content-transfer-encoding; bh=g/mSZoqPlWK6T+TfBIdgoZ0pB815FYg1CJaot/oFpRU=; b=fwNlqGzwkKc28hQPhgLhUfNoZ9SAfReefzzRRVgGn6wNIgpig12bVgvBdttGq5exfG BdkmI3kfTUZD/uFnTHYVreP4HTPUmfciCp66A/hFWkmeJy3vHwpqeBJo962RPPVwL62r veLXH5eTtCLGW8+ytwScaGgkd2WTaAzO1M4wQmwGTQA9WF0+Q0VDSMu9al6wWKbVVf0A qDoA9T0ZiJkH2sOQqDi8XDKp6LIFZYOuU/lnruKZj3k82KV0BP5l2SVqb8gNsYsThhNP jowgbHI/288sidYpfEqAyKQLYAHZtDLVwWFUJA13lPQXc3eI4f0kOFcdUNsO2mwSFXOO 2M/Q== X-Gm-Message-State: AOAM530SO4c5ZY0rSDGNF9cW2oXoB7htlSfX6+mNM0N63TPTIRnVPQNx S44Sob6lGW4dDTnIDoWK+M5BnQ== X-Received: by 2002:a05:651c:96:: with SMTP id 22mr8242236ljq.254.1623542708919; Sat, 12 Jun 2021 17:05:08 -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 n10sm1022702lfl.104.2021.06.12.17.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 17:05:08 -0700 (PDT) From: Linus Walleij To: Pavel Machek Cc: linux-leds@vger.kernel.org, Linus Walleij , Sekhar Nori , Bartosz Golaszewski Subject: [PATCH 1/2] ARM: davinci: dm644x: Convert LEDs to GPIO descriptor table Date: Sun, 13 Jun 2021 02:03:01 +0200 Message-Id: <20210613000302.421268-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org This converts the DaVinci DM644x LEDs to use GPIO descriptor look-ups. Cc: Sekhar Nori Cc: Bartosz Golaszewski Reviewed-by: Bartosz Golaszewski Signed-off-by: Linus Walleij --- 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-dm644x-evm.c | 46 +++++++++++++++--------- 1 file changed, 30 insertions(+), 16 deletions(-) -- 2.31.1 diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index cce3a621eb20..d875c0e5d53d 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c @@ -319,17 +319,14 @@ static struct platform_device rtc_dev = { /* U2 -- LEDs */ static struct gpio_led evm_leds[] = { - { .name = "DS8", .active_low = 1, - .default_trigger = "heartbeat", }, - { .name = "DS7", .active_low = 1, }, - { .name = "DS6", .active_low = 1, }, - { .name = "DS5", .active_low = 1, }, - { .name = "DS4", .active_low = 1, }, - { .name = "DS3", .active_low = 1, }, - { .name = "DS2", .active_low = 1, - .default_trigger = "mmc0", }, - { .name = "DS1", .active_low = 1, - .default_trigger = "disk-activity", }, + { .name = "DS8", .default_trigger = "heartbeat", }, + { .name = "DS7", }, + { .name = "DS6", }, + { .name = "DS5", }, + { .name = "DS4", }, + { .name = "DS3", }, + { .name = "DS2", .default_trigger = "mmc0", }, + { .name = "DS1", .default_trigger = "disk-activity", }, }; static const struct gpio_led_platform_data evm_led_data = { @@ -337,18 +334,35 @@ 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 PCF8574 GPIO expander, which + * is in turn named after the I2C device name. This is + * device "u2" on I2C bus 1 with address 0x38. + */ + GPIO_LOOKUP_IDX("1-0038", 0, NULL, 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 1, NULL, 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 2, NULL, 2, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 3, NULL, 3, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 4, NULL, 4, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 5, NULL, 5, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 6, NULL, 6, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 7, NULL, 7, GPIO_ACTIVE_LOW), + { }, + }, +}; + static struct platform_device *evm_led_dev; static int evm_led_setup(struct i2c_client *client, int gpio, unsigned 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); /* what an extremely annoying way to be forced to handle * device unregistration ... From patchwork Sun Jun 13 00:03:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 459352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6476EC48BCF for ; Sun, 13 Jun 2021 00:06:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39AAB60C3D for ; Sun, 13 Jun 2021 00:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbhFMAIk (ORCPT ); Sat, 12 Jun 2021 20:08:40 -0400 Received: from mail-lj1-f182.google.com ([209.85.208.182]:35642 "EHLO mail-lj1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbhFMAIk (ORCPT ); Sat, 12 Jun 2021 20:08:40 -0400 Received: by mail-lj1-f182.google.com with SMTP id n17so14774925ljg.2 for ; Sat, 12 Jun 2021 17:06:28 -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=ZFYKxf7UW0S2RQWgaBSC4f2Mnxv2hI1hJP96MEozwjU=; b=nlbjgu0UvGK2B7MCax3AtJuHG9c9qI3LwMvt/PWNmbQO7b3TMj6sXDmX4GPBJ0UjVs IlYNCwgVd291KABpV6A70atdht8fEtquels0QzJdn1A/Y3PAXpgSgx2B3Eu3a+68cZu/ 8LwDpXhg6c9yZW27llxJ15Nuac1Gqwrck7cz5gc6ASQWDpe38DlO/7rdKsV0oRrS8zO0 gMP8Nxwk5pJXxHO/SVDTIix/TH5CWlcmP9v5S7loxFR34bJO4T1/0YPdu7852b1fk99F 9HlL6w9BbjM1lA5YJKUyUr3ggCLYkG3vVGjBKJ8llu+V5+rMtUbWWBsE1j88jWfE83cS QJIQ== 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=ZFYKxf7UW0S2RQWgaBSC4f2Mnxv2hI1hJP96MEozwjU=; b=QtdnpGGpMdXQtwHvjXLjv04wGKeDpyKp7XdXWzIO2T/ZEdKqN88n3ES9aXLv7g0hwH uUVqR9xitm4CwFWaEYJx47lxnPIGKFGMUlOynpMrLX2+aSNIvHWz6PcUJj7c4BqCZxQy GZUIpmFj+SYWPJwVp2C2ccILeGhcfMYtRvOTfo16A9DKLK2cyO8RyhrIMM2fAmCC3KP/ MNDWK5RM85W08+qCkU20yR1IFgOBDfw8idWX+iKniB0Qead8r5vMen8wxKiZRpWT0txV vqQ5C8WT4H5bRNhIWM60FUXVyWoU6fVTrsIe+E3mtdxpwfKvFOsC2JcpINwrDRZrrxqz x5Jg== X-Gm-Message-State: AOAM531x9OsCqRLLhHS87+dA8z8m1pzfDv2qhfexpnY5R1w01cDMK1e/ P91RKuXXxhmFtb+HNC/rMA2Oag== X-Google-Smtp-Source: ABdhPJyp5l4OtvQSGoI0WRjiU41xl/0XfQi95ON2e7+4SMIhL8dEG6oG8KB4+f/7wHEwO3kJV2IroA== X-Received: by 2002:a2e:711e:: with SMTP id m30mr8510936ljc.489.1623542727502; Sat, 12 Jun 2021 17:05:27 -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 n10sm1022702lfl.104.2021.06.12.17.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 17:05:27 -0700 (PDT) From: Linus Walleij To: Pavel Machek Cc: linux-leds@vger.kernel.org, Linus Walleij , Sekhar Nori , Bartosz Golaszewski Subject: [PATCH 2/2] ARM: davinci: dm646x: Convert LEDs to GPIO descriptor table Date: Sun, 13 Jun 2021 02:03:02 +0200 Message-Id: <20210613000302.421268-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210613000302.421268-1-linus.walleij@linaro.org> References: <20210613000302.421268-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@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 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 | 33 +++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index ee91d81ebbfd..a7d720e8f0e2 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("1-0038", 4, NULL, 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 5, NULL, 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 6, NULL, 2, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("1-0038", 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,