From patchwork Tue Apr 23 13:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13640134 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 376B5C4345F for ; Tue, 23 Apr 2024 13:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tmc4lWLEkJ/H9HbO/vWU6ARCk8x7xqQwutmKmAGVXkc=; b=Z09GipmWWHCRaX qgENa8qhdDthJtSIjCscO/X1kjxF6RTTI/4gEYPjYPozB+1MSYzFodXnBKGEwYE5wFD/RqwJS/7dv baxAb4CGdKN3J7F9qdwps20uh8jj7hQPHjcecBCbkAFobTetoSABClI3xFXvpiCOndzlsD6mqOshj mVZul3W+NkqP5DxliDtDUeoZX7Jg88AWBqIkiTSPRjp25GOZFxgFtfBhgIfpQ3AkM0MiRpX+B7qs+ AaS0TlcRFzLZo6DR5GUP/m023tzOOeOy4/QD5LxrRg0ImrFLiydBw8FM39rnjw96o239SB5Xpifj0 Slr0JD3GYkox/JiunR6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzGbW-00000000Aq3-27cY; Tue, 23 Apr 2024 13:54:38 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzGax-00000000AaE-1hSI for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2024 13:54:04 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-51967f75763so6738959e87.2 for ; Tue, 23 Apr 2024 06:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713880440; x=1714485240; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gReuYTpcRssmlbBTeL2oSNhhV9ufTFwwH1vDMi+LMNc=; b=AdGiT0gXtUkUvOe3SLjjwCNCHEf7CM2x3Jkl/X2N0vPjA/pgLmi5qaTrbFJz5xumTt TgREogHKLx0WGFTwgySb98H+Tae7q1iHHuXrRQD1n2C1hCfqWsuljju61AciOU81g3KK PewvTpczYlqGX8ocnO1BAZ3S2ZycIcc1igGZ/v4qYJZEXOk6Ys3EJnL4WiiFKgfCSg/3 khkYKwB0pXC4JJk0dtU5ZTYInQsRktRsnt+lo+GgB808ElYncUrf1lMwyHf9QBx3NftC GXEn6kdKTWZ/RP9iVmj2pctpeQFhOytCaJ7NK+INGP+wiuvEerGYY8SZ5Q2uBksnWy0H 4Bxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713880440; x=1714485240; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gReuYTpcRssmlbBTeL2oSNhhV9ufTFwwH1vDMi+LMNc=; b=O4/9PdQjJWGCdEmEEWlFDCc4dCNkj4wLoe+N8QBei8ReDzLHVTMsTOXRlsM3M7gxPf 2QJlN9DAHiCOAb7UEhuVHsPopjcolXtTQAO0uOPzodSI9FGBaTBEZIgAYUb7hYpxp2/n 15GsE1gekTJR5HCmA+SJ4/dtsUg0Qp2dDXpkGGAAw12n74KsB4JRcKFO5As7k4P8sUE/ WDY5FvEVoK60ZS84LYfShKY8drO9sEPI84oZw4VPtCoPR/UU74iopOkNCQluruXUc09U 7yaKZqgANo23XESVlPS4PlMWmL2Vo3FkmHdg+r0qWRn16vfk5j67vvg1jMcJzioLv52h zOGw== X-Gm-Message-State: AOJu0YzyZUw6ssIaBVhtGMpAowchfSk3w9EBvF0NTOjli+mHKRf2tpFM hEAUP7VowNbdNpH6iDi1V1pPwvqdSfCcj25hn20KWr0dSc9ShJIFQS56kVkMAWPfRRX06UkiT4F 7 X-Google-Smtp-Source: AGHT+IEaJ+P/6KBOOtJyniHX1/cJOt0L+qQsFCuJMw0pbhOmIuGoJhmTttr2pc5PnXsak6Idb8O6fg== X-Received: by 2002:a05:6512:3082:b0:513:30fb:d64 with SMTP id z2-20020a056512308200b0051330fb0d64mr12144142lfd.44.1713880440589; Tue, 23 Apr 2024 06:54:00 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id b18-20020ac24112000000b0051a61f2d251sm1875997lfi.290.2024.04.23.06.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 06:54:00 -0700 (PDT) From: Linus Walleij Date: Tue, 23 Apr 2024 15:53:58 +0200 Subject: [PATCH 2/5] ARM: orion5x: Convert DNS323 board to GPIO descriptors for LEDs MIME-Version: 1.0 Message-Id: <20240423-gpio-leds-v1-2-799c2f6bc61c@linaro.org> References: <20240423-gpio-leds-v1-0-799c2f6bc61c@linaro.org> In-Reply-To: <20240423-gpio-leds-v1-0-799c2f6bc61c@linaro.org> To: Andrew Lunn , Sebastian Hesselbarth , Gregory Clement Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Linus Walleij X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240423_065403_645441_F617712F X-CRM114-Status: GOOD ( 14.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This makes the LEDs on the D-Link DNS323 Orion5x board use GPIO descriptors instead of hardcoded GPIOs from the global numberspace. Signed-off-by: Linus Walleij --- arch/arm/mach-orion5x/dns323-setup.c | 63 +++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c index d69259b6b60d..062109efa0ec 100644 --- a/arch/arm/mach-orion5x/dns323-setup.c +++ b/arch/arm/mach-orion5x/dns323-setup.c @@ -14,6 +14,7 @@ * */ #include +#include #include #include #include @@ -254,37 +255,64 @@ static int __init dns323_read_mac_addr(void) static struct gpio_led dns323ab_leds[] = { { .name = "power:blue", - .gpio = DNS323_GPIO_LED_POWER2, .default_trigger = "default-on", }, { .name = "right:amber", - .gpio = DNS323_GPIO_LED_RIGHT_AMBER, - .active_low = 1, }, { .name = "left:amber", - .gpio = DNS323_GPIO_LED_LEFT_AMBER, - .active_low = 1, }, }; +static struct gpiod_lookup_table dns323a1_leds_gpio_table = { + .dev_id = "leds-gpio", + .table = { + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_POWER2, NULL, + 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_RIGHT_AMBER, NULL, + 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_LEFT_AMBER, NULL, + 2, GPIO_ACTIVE_LOW), + { }, + }, +}; + +/* B1 is the same but power LED is active high */ +static struct gpiod_lookup_table dns323b1_leds_gpio_table = { + .dev_id = "leds-gpio", + .table = { + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_POWER2, NULL, + 0, GPIO_ACTIVE_HIGH), + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_RIGHT_AMBER, NULL, + 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_LEFT_AMBER, NULL, + 2, GPIO_ACTIVE_LOW), + { }, + }, +}; static struct gpio_led dns323c_leds[] = { { .name = "power:blue", - .gpio = DNS323C_GPIO_LED_POWER, .default_trigger = "timer", - .active_low = 1, }, { .name = "right:amber", - .gpio = DNS323C_GPIO_LED_RIGHT_AMBER, - .active_low = 1, }, { .name = "left:amber", - .gpio = DNS323C_GPIO_LED_LEFT_AMBER, - .active_low = 1, }, }; +static struct gpiod_lookup_table dns323c_leds_gpio_table = { + .dev_id = "leds-gpio", + .table = { + GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_POWER, NULL, + 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_RIGHT_AMBER, NULL, + 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_LEFT_AMBER, NULL, + 2, GPIO_ACTIVE_LOW), + { }, + }, +}; static struct gpio_led_platform_data dns323ab_led_data = { .num_leds = ARRAY_SIZE(dns323ab_leds), @@ -621,16 +649,21 @@ static void __init dns323_init(void) /* The 5181 power LED is active low and requires * DNS323_GPIO_LED_POWER1 to also be low. */ - dns323ab_leds[0].active_low = 1; - gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable"); - gpio_direction_output(DNS323_GPIO_LED_POWER1, 0); - fallthrough; + gpiod_add_lookup_table(&dns323a1_leds_gpio_table); + gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable"); + gpio_direction_output(DNS323_GPIO_LED_POWER1, 0); + i2c_register_board_info(0, dns323ab_i2c_devices, + ARRAY_SIZE(dns323ab_i2c_devices)); + + break; case DNS323_REV_B1: + gpiod_add_lookup_table(&dns323b1_leds_gpio_table); i2c_register_board_info(0, dns323ab_i2c_devices, ARRAY_SIZE(dns323ab_i2c_devices)); break; case DNS323_REV_C1: /* Hookup LEDs & Buttons */ + gpiod_add_lookup_table(&dns323c_leds_gpio_table); dns323_gpio_leds.dev.platform_data = &dns323c_led_data; dns323_button_device.dev.platform_data = &dns323c_button_data;