From patchwork Mon Aug 19 04:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13767916 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 C4D56C3DA4A for ; Mon, 19 Aug 2024 05:08:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mcaRHM3+7D0S7NodLplOw/AYGyYPhnOV3W4X3E8TpD0=; b=ZAsoJgCfL77NksV1LsH2MJZ+Wx j1tFTt/W+T+pDer8JdquoyTPrFI2ygpw+LlFIhPevjBA8tuW5MgwjIyg6YppYaZW0Sbrug1MCxuCH MuzeCZSFchK8m7Wb6Plhf6T+GxDfTdS4k2zu2Ikbc1a24PHHbmbpyr2PNQ7Sz7DXTh/CiRAZSWG7X P5HtER5xO/3mRDaXA2qnWAn7vl59LtpRBKkonqFtcXKWyRRz/oAFvVA4Ce+3laOuueCm+2MFr/A1a 0SFkazqVtJAw7IbXFWLoQ0630lPdBuNIuGX20oj2+sJoOQF4nsWHFvbuUlRGW/kpjQvPMzCm3zRsd QZmBreXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfucv-00000000Ntq-1PxL; Mon, 19 Aug 2024 05:08:21 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfuTc-00000000Lbp-0MX7 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 04:58:45 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1fc47abc040so29505365ad.0 for ; Sun, 18 Aug 2024 21:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724043523; x=1724648323; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mcaRHM3+7D0S7NodLplOw/AYGyYPhnOV3W4X3E8TpD0=; b=VfUTa4W+dRSPi4gq8Rg05kPZql6RGCjFqe84aH9i7/QKjy1my5Jv66MF4B4Z2n8u2B kgQ+DFU3vD6S6qcM4obut6S2bxmO3biezcXSlIOTdmxyXPxyvjYItGXi5tccnHkaFF5C E8/wwDduKR3dGMGdZn5ucYMmFLWHXrR9NYNLIh1x9urI8Y/QwgpOoFt+Hpo6tQXq1Gp0 dl2H7gOi36oXSkPMo+pZ8EJMtX/nrI4/shRwHLps9caFICoKRR7m5HmA3i7KhTE4r1b8 8rqs1wT3pisrY3NCxvfBdBttpCxPBPbr9Q0eOBuGTnVaNIwA64pDSY3hKgQK78kT5d6W m4PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724043523; x=1724648323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mcaRHM3+7D0S7NodLplOw/AYGyYPhnOV3W4X3E8TpD0=; b=gMG4M/w8RrAgTUp8VFkqJnv8OZnr1PbSWGxkCHzCKUiJyYVs8k7VapZ2b3ExiPosB/ qWNIM4srRSEDpeOwstLb1bDhJW1fWU+bIBiQMCP3ijggzABrvDALTL4i8IkyqtAfh669 4OALm67zwlZDwNBOpScYQrPXAl3tWiSVmq1DCM8Iaa3Bh7CnNQW/R+dSvbO7mZNyctdk ZSHOFoiMwJ/lPKdbg0qQKafcHro0uo/Dior2km5Drjq2ne0sNNMKuYyHVigNvswbEVjj FpaUUFydtBA8QclAwzY9nd967bW6aeP9MdtbAhSm/wUvRNZRO23qztUJDSLJgQF27+dZ kaYw== X-Forwarded-Encrypted: i=1; AJvYcCXVZ3kTnDMY4hkX68H60lOiMir35D+5b5IKapCPDvcK+H3PkSkAdRt1IEtdXFq1XvV5fbwmcJ/lg+8HcSQRgYygbSAgXb5sd33sKHvfvxu6cLr/W/I= X-Gm-Message-State: AOJu0Yw6Qx8Lk4bCy4FWVjGR39z8xLTg7W+QP5nQz0bm4v5xoJq5y2qt qPbZW2W4EC7X1tXYP+gE53+wsHI3jLPGoSEdfPD2eMNmG5EVFu7B X-Google-Smtp-Source: AGHT+IHM1aUHr6FlaVm7qvuOxYje+ccNPFOl/JhsZ8ri8UtXMzODBg9MkExumxB7dA0FrEYWROONhg== X-Received: by 2002:a17:902:cec9:b0:202:1033:8d25 with SMTP id d9443c01a7336-202195f9591mr81380085ad.35.1724043522899; Sun, 18 Aug 2024 21:58:42 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:4eb5:4500:6efc:6c24]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-202068497b4sm43483445ad.269.2024.08.18.21.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 21:58:42 -0700 (PDT) From: Dmitry Torokhov To: Arnd Bergmann , Mark Brown , Krzysztof Kozlowski Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com Subject: [PATCH 14/14] ARM: s3c: crag6410 - convert GPIO lookup tables to property entries Date: Sun, 18 Aug 2024 21:58:11 -0700 Message-ID: <20240819045813.2154642-15-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> References: <20240819045813.2154642-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_215844_157795_CADF3672 X-CRM114-Status: GOOD ( 24.80 ) 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 Static property entries support defining GPIOs and are more similar to device tree properties and are not prone to losing link between device and a lookup table because of changes in device name. Convert the board to use them. This also fixes issue with recent conversion to GPIO descriptors where GPIO lookup tables were specifying incorrect GPIO chip name ("GPIO" vs "GP"). Fixes: 10a366f36e2a ("ASoC: wm1250-ev1: Convert to GPIO descriptors") Fixes: a45cf3cc72dd ("spi: s3c64xx: Convert to use GPIO descriptors") Fixes: 9a5ed0bac86e ("regulator: wm831x: Convert to use GPIO descriptors") Signed-off-by: Dmitry Torokhov Acked-by: Krzysztof Kozlowski --- arch/arm/mach-s3c/devs.c | 35 ---------- arch/arm/mach-s3c/devs.h | 1 - arch/arm/mach-s3c/mach-crag6410.c | 108 ++++++++++++++++++------------ 3 files changed, 67 insertions(+), 77 deletions(-) diff --git a/arch/arm/mach-s3c/devs.c b/arch/arm/mach-s3c/devs.c index 31827cfc5700..e24967cc648b 100644 --- a/arch/arm/mach-s3c/devs.c +++ b/arch/arm/mach-s3c/devs.c @@ -336,38 +336,3 @@ void __init dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat *pd) npd->phy_exit = s3c_usb_phy_exit; } #endif /* CONFIG_S3C_DEV_USB_HSOTG */ - -#ifdef CONFIG_S3C64XX_DEV_SPI0 -static struct resource s3c64xx_spi0_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_SPI0), -}; - -struct platform_device s3c64xx_device_spi0 = { - .name = "s3c6410-spi", - .id = 0, - .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource), - .resource = s3c64xx_spi0_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init s3c64xx_spi0_set_platdata(int src_clk_nr, int num_cs) -{ - struct s3c64xx_spi_info pd; - - /* Reject invalid configuration */ - if (!num_cs || src_clk_nr < 0) { - pr_err("%s: Invalid SPI configuration\n", __func__); - return; - } - - pd.num_cs = num_cs; - pd.src_clk_nr = src_clk_nr; - pd.cfg_gpio = s3c64xx_spi0_cfg_gpio; - - s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi0); -} -#endif /* CONFIG_S3C64XX_DEV_SPI0 */ diff --git a/arch/arm/mach-s3c/devs.h b/arch/arm/mach-s3c/devs.h index 2737990063b1..90a86ade3570 100644 --- a/arch/arm/mach-s3c/devs.h +++ b/arch/arm/mach-s3c/devs.h @@ -27,7 +27,6 @@ extern struct platform_device *s3c24xx_uart_src[]; extern struct platform_device s3c64xx_device_iis0; extern struct platform_device s3c64xx_device_iis1; -extern struct platform_device s3c64xx_device_spi0; extern struct platform_device s3c_device_fb; extern struct platform_device s3c_device_hsmmc0; diff --git a/arch/arm/mach-s3c/mach-crag6410.c b/arch/arm/mach-s3c/mach-crag6410.c index 6aa74db08af9..a7a25239793e 100644 --- a/arch/arm/mach-s3c/mach-crag6410.c +++ b/arch/arm/mach-s3c/mach-crag6410.c @@ -435,7 +435,6 @@ static struct platform_device *crag6410_devs0[] __initdata = { static struct platform_device *crag6410_devs1[] __initdata = { &crag6410_dm9k_device, - &s3c64xx_device_spi0, &crag6410_mmgpio, &crag6410_lcd_powerdev, &crag6410_backlight_device, @@ -654,22 +653,13 @@ static struct wm831x_pdata crag_pmic_pdata = { .touch = &touch_pdata, }; -/* - * VDDARM is eventually ending up as a regulator hanging on the MFD cell device - * "wm831x-buckv.1" spawn from drivers/mfd/wm831x-core.c. - * - * From the note on the platform data we can see that this is clearly DVS1 - * and assigned as dcdc1 resource to the MFD core which sets .id of the cell - * spawning the DVS1 platform device to 1, then the cell platform device - * name is calculated from 10*instance + id resulting in the device name - * "wm831x-buckv.11" - */ -static struct gpiod_lookup_table crag_pmic_gpiod_table = { - .dev_id = "wm831x-buckv.11", - .table = { - GPIO_LOOKUP("GPIOK", 0, "dvs", GPIO_ACTIVE_HIGH), - { }, - }, +static const struct property_entry crag_pmic_properties[] = { + PROPERTY_ENTRY_GPIO("dvs-gpios", + SAMSUNG_GPIO_NODE('K'), 0, GPIO_ACTIVE_HIGH), + { } +}; +static const struct software_node crag_pmic_swnode = { + .properties = crag_pmic_properties, }; static struct i2c_board_info i2c_devs0[] = { @@ -680,6 +670,7 @@ static struct i2c_board_info i2c_devs0[] = { { I2C_BOARD_INFO("wm8312", 0x34), .platform_data = &crag_pmic_pdata, .irq = S3C_EINT(23), + .swnode = &crag_pmic_swnode, }, }; @@ -774,17 +765,22 @@ static struct wm831x_pdata glenfarclas_pmic_pdata = { .disable_touch = true, }; -static struct gpiod_lookup_table crag_wm1250_ev1_gpiod_table = { - /* The WM1250-EV1 is device 0027 on I2C bus 1 */ - .dev_id = "1-0027", - .table = { - GPIO_LOOKUP("GPION", 12, "clk-ena", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 12, "clk-sel0", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 13, "clk-sel1", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 14, "osr", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("GPIOL", 8, "master", GPIO_ACTIVE_HIGH), - { }, - }, +static const struct property_entry crag_wm1250_ev1_properties[] = { + PROPERTY_ENTRY_GPIO("clk-ena-gpios", + SAMSUNG_GPIO_NODE('N'), 12, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("clk-sel0-gpios", + SAMSUNG_GPIO_NODE('L'), 12, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("clk-sel1-gpios", + SAMSUNG_GPIO_NODE('L'), 13, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("osr-gpios", + SAMSUNG_GPIO_NODE('L'), 14, GPIO_ACTIVE_HIGH), + PROPERTY_ENTRY_GPIO("master-gpios", + SAMSUNG_GPIO_NODE('L'), 8, GPIO_ACTIVE_HIGH), + { } +}; + +static const struct software_node crag_wm1250_ev1_swnode = { + .properties = crag_wm1250_ev1_properties, }; static struct i2c_board_info i2c_devs1[] = { @@ -797,7 +793,8 @@ static struct i2c_board_info i2c_devs1[] = { { I2C_BOARD_INFO("wlf-gf-module", 0x24) }, { I2C_BOARD_INFO("wlf-gf-module", 0x25) }, { I2C_BOARD_INFO("wlf-gf-module", 0x26) }, - { I2C_BOARD_INFO("wm1250-ev1", 0x27), }, + { I2C_BOARD_INFO("wm1250-ev1", 0x27), + .swnode = &crag_wm1250_ev1_swnode, }, }; static struct s3c2410_platform_i2c i2c1_pdata = { @@ -887,15 +884,48 @@ static const struct gpio_led_platform_data gpio_leds_pdata = { static struct dwc2_hsotg_plat crag6410_hsotg_pdata; -static struct gpiod_lookup_table crag_spi0_gpiod_table = { - .dev_id = "s3c6410-spi.0", - .table = { - GPIO_LOOKUP_IDX("GPIOC", 3, "cs", 0, GPIO_ACTIVE_LOW), - GPIO_LOOKUP_IDX("GPION", 5, "cs", 1, GPIO_ACTIVE_LOW), - { }, - }, +static const struct software_node_ref_args crag6410_spi0_gpio_refs[] = { + SOFTWARE_NODE_REFERENCE(SAMSUNG_GPIO_NODE('C'), 3, GPIO_ACTIVE_LOW), + SOFTWARE_NODE_REFERENCE(SAMSUNG_GPIO_NODE('N'), 5, GPIO_ACTIVE_LOW), +}; + +static const struct property_entry crag6410_spi0_properties[] __initconst = { + PROPERTY_ENTRY_REF_ARRAY("cs-gpios", crag6410_spi0_gpio_refs), + { } }; +static const struct resource crag6410_spi0_resource[] __initconst = { + [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256), + [1] = DEFINE_RES_IRQ(IRQ_SPI0), +}; + +static const struct s3c64xx_spi_info crag6410_spi0_platform_data __initconst = { + .num_cs = 2, + .cfg_gpio = s3c64xx_spi0_cfg_gpio, +}; + +static const struct platform_device_info crag6410_spi0_info __initconst = { + .name = "s3c6410-spi", + .id = 0, + .res = crag6410_spi0_resource, + .num_res = ARRAY_SIZE(crag6410_spi0_resource), + .data = &crag6410_spi0_platform_data, + .size_data = sizeof(crag6410_spi0_platform_data), + .dma_mask = DMA_BIT_MASK(32), + .properties = crag6410_spi0_properties, +}; + +static void __init crag6410_setup_spi0(void) +{ + struct platform_device *pd; + int err; + + pd = platform_device_register_full(&crag6410_spi0_info); + err = PTR_ERR_OR_ZERO(pd); + if (err) + pr_err("failed to create spi0 device: %d\n", err); +} + static void __init crag6410_machine_init(void) { /* Open drain IRQs need pullups */ @@ -922,19 +952,15 @@ static void __init crag6410_machine_init(void) s3c_fb_set_platdata(&crag6410_lcd_pdata); dwc2_hsotg_set_platdata(&crag6410_hsotg_pdata); - gpiod_add_lookup_table(&crag_pmic_gpiod_table); i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0)); - gpiod_add_lookup_table(&crag_wm1250_ev1_gpiod_table); i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); - gpiod_add_lookup_table(&crag_spi0_gpiod_table); - s3c64xx_spi0_set_platdata(0, 2); - pwm_add_table(crag6410_pwm_lookup, ARRAY_SIZE(crag6410_pwm_lookup)); platform_add_devices(crag6410_devs0, ARRAY_SIZE(crag6410_devs0)); crag6410_setup_keypad(); crag6410_setup_gpio_keys(); + crag6410_setup_spi0(); platform_add_devices(crag6410_devs1, ARRAY_SIZE(crag6410_devs1));