From patchwork Fri Dec 6 11:13:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897018 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 067C01FC106 for ; Fri, 6 Dec 2024 11:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483639; cv=none; b=LwlbMB7uM8S7+vX+RJrtyc1dQgYuTRVBjSFASPCFzV5E+CNPChkrmjjzvLX6qFrj3pZuM7l/FGp/kfn3cVtPheW/H2Ytw0O/zz5FH5egyzTZdzgAGuoMtk3I7DJYkt4SAKNPU8MP/FW/OsUtqKb76Cy6o/kJ3rPf+SvXv8+r3NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483639; c=relaxed/simple; bh=wtbhFgAIjwtZ+tw8WU+bfOrzW74Jy0OL371+f4t8O5Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aI8R36mFTS4KTd4emQWDqGhaqClY6vRhzhCvh8X/grDmaUzulP8tOg3h9BNQ7t5+Ib9xKZsA7vphGUjuwSwXvp26lz4dztItnvfZdFgFsf0auTHXw2psdZWgJD0paAwSnC+omej3SIpfo05x3Yb/hFskklUZMz8+qclGJ5KNaoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=nhgkgWl2; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="nhgkgWl2" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-434a45f05feso21542235e9.3 for ; Fri, 06 Dec 2024 03:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483635; x=1734088435; darn=vger.kernel.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=h4ybOWdThQduxVTLLkmT3I5G8o7KcPOKxk8AzY6bhhc=; b=nhgkgWl2txX1NYdiqSvofStwXS/hGamQ9x6DhLLxxpoh2kuNXnqJLGBxrp29/4O6nU gvpW/3MzW4XpgKirPdSDbbgmIa64lDqZzYTilYpoaorKkmRqlm1z1aMg+WEonNTZ/YiW xyarKDj66tKX6HFKphTPMDMvUdUvb8EhE5ayAnu0NpzeH0w0OD4cfbB/19zT2U+0wHw5 5/GVKk4eu+LtAH9MWaFzHw3MFX6Ws7QPfeLIUXZ0xwSXW7koYvDAFHXm59PrB9mLF2Jl zrDCwyiQ+pv7wMiLW4TULwd/AkMuI2NnD1gV2wieeX1dZOL30rF/KfD41QerOKDIJDzD 8uBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483635; x=1734088435; 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=h4ybOWdThQduxVTLLkmT3I5G8o7KcPOKxk8AzY6bhhc=; b=pdjWA3xjIynEfPUBNKgC2Nv6dJZmKEnfo0rPApFfx5A2XuIKevTibyH+tzZFQ/5YbI TzZSu/tRTJI37upbfbSP6sQLPb+JqU4q/clLptPW0ZHTe5bh6HcHh3ZQmWDvW8A/is2/ xZzVBkP2CFeT/m7ISMhfnW1mlKDjqHjoWSm4ThO/tmmxH5vlibXacdlDAo5un6/3XftG F+qasizVGtirKC+MrTxSDz17C1I2v7+F3TUmTMUqVKZFZYtLXTugAXXnZ310OXXEcKvx ZR2iwhfOs6r2zHZ0iJGLResNYJlSCpe5KWF0C9HkS1+ZNbRjwhR3JGCfNqs0TfcOc1jG vh2g== X-Forwarded-Encrypted: i=1; AJvYcCWMpAYHAczRJz9YUc2u5TGgB8cmvrt2ebylfANQFZEg0nrlcqDd+/cf866fWthfd1Hae3j7ABv/9FY=@vger.kernel.org X-Gm-Message-State: AOJu0YzQDeAB5MPdpr8rP8UFXzTsI9XIBVKnvMb+8A0OUaHyn1HoQMc+ 2p1kXqn7RyccUlu7sDQdEhZOJ9PLQaUzc870JycUyn8LLFgxt3Wudr0cOYwidGU= X-Gm-Gg: ASbGnctGxc8o7JRtrfxVvSRT0q76SwIW5LTgI3j/H0ruRfJS44aoGlVEBZthb5j+pGK mKb/BcHqNIR3Ywju7+salcCUnXD9XoRU0c7TkXWPxBNhodwdXtG2RsWhXwoAgkrnBIY+vNZfZq2 4x/SxmDYwMV1RDXWt27dc8aDyw8RWIgPUYsnhEROIFRkDyQURh5sBoaTWqnEWZpNg3fk0puBNGC 5hpgUnlKvOAdp22ZD4OQIc49O71GaRISwMTqJoXoXHJStpax1o6Y9mrrbRJTFl53CLBxuzv1nDm 4CUc X-Google-Smtp-Source: AGHT+IHD5gzyn6ySUv1/2CzhUdrsHWqA+utF/YjxqIPk/7oKZhHl7nuoqefyXJDNZSNZZHnZZAiGvg== X-Received: by 2002:a5d:5f8c:0:b0:385:fd24:3317 with SMTP id ffacd0b85a97d-3862b33cfbemr2189732f8f.1.1733483635216; Fri, 06 Dec 2024 03:13:55 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:13:54 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 01/15] clk: renesas: r9a08g045: Add clocks, resets and power domain support for the ADC IP Date: Fri, 6 Dec 2024 13:13:23 +0200 Message-Id: <20241206111337.726244-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Add clocks, resets and power domains for ADC IP available on the Renesas RZ/G3S SoC. Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven Reviewed-by: Lad Prabhakar --- Changes in v2: - rebased on top of the latest r9a08g045-cpg version drivers/clk/renesas/r9a08g045-cpg.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/clk/renesas/r9a08g045-cpg.c b/drivers/clk/renesas/r9a08g045-cpg.c index 559afc417c6c..0e7e3bf05b52 100644 --- a/drivers/clk/renesas/r9a08g045-cpg.c +++ b/drivers/clk/renesas/r9a08g045-cpg.c @@ -187,6 +187,7 @@ static const struct cpg_core_clk r9a08g045_core_clks[] __initconst = { DEF_FIXED("OSC", R9A08G045_OSCCLK, CLK_EXTAL, 1, 1), DEF_FIXED("OSC2", R9A08G045_OSCCLK2, CLK_EXTAL, 1, 3), DEF_FIXED("HP", R9A08G045_CLK_HP, CLK_PLL6, 1, 2), + DEF_FIXED("TSU", R9A08G045_CLK_TSU, CLK_PLL2_DIV2, 1, 8), }; static const struct rzg2l_mod_clk r9a08g045_mod_clks[] = { @@ -238,6 +239,8 @@ static const struct rzg2l_mod_clk r9a08g045_mod_clks[] = { DEF_MOD("scif4_clk_pck", R9A08G045_SCIF4_CLK_PCK, R9A08G045_CLK_P0, 0x584, 4), DEF_MOD("scif5_clk_pck", R9A08G045_SCIF5_CLK_PCK, R9A08G045_CLK_P0, 0x584, 5), DEF_MOD("gpio_hclk", R9A08G045_GPIO_HCLK, R9A08G045_OSCCLK, 0x598, 0), + DEF_MOD("adc_adclk", R9A08G045_ADC_ADCLK, R9A08G045_CLK_TSU, 0x5a8, 0), + DEF_MOD("adc_pclk", R9A08G045_ADC_PCLK, R9A08G045_CLK_TSU, 0x5a8, 1), DEF_MOD("vbat_bclk", R9A08G045_VBAT_BCLK, R9A08G045_OSCCLK, 0x614, 0), }; @@ -274,6 +277,8 @@ static const struct rzg2l_reset r9a08g045_resets[] = { DEF_RST(R9A08G045_GPIO_RSTN, 0x898, 0), DEF_RST(R9A08G045_GPIO_PORT_RESETN, 0x898, 1), DEF_RST(R9A08G045_GPIO_SPARE_RESETN, 0x898, 2), + DEF_RST(R9A08G045_ADC_PRESETN, 0x8a8, 0), + DEF_RST(R9A08G045_ADC_ADRST_N, 0x8a8, 1), DEF_RST(R9A08G045_VBAT_BRESETN, 0x914, 0), }; @@ -346,6 +351,8 @@ static const struct rzg2l_cpg_pm_domain_init_data r9a08g045_pm_domains[] = { DEF_REG_CONF(CPG_BUS_MCPU2_MSTOP, BIT(5)), 0), DEF_PD("scif5", R9A08G045_PD_SCIF5, DEF_REG_CONF(CPG_BUS_MCPU3_MSTOP, BIT(4)), 0), + DEF_PD("adc", R9A08G045_PD_ADC, + DEF_REG_CONF(CPG_BUS_MCPU2_MSTOP, BIT(14)), 0), DEF_PD("vbat", R9A08G045_PD_VBAT, DEF_REG_CONF(CPG_BUS_MCPU3_MSTOP, BIT(8)), GENPD_FLAG_ALWAYS_ON), From patchwork Fri Dec 6 11:13:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897019 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A57491FCF58 for ; Fri, 6 Dec 2024 11:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483640; cv=none; b=dk8heOSEaZhLiGRs4GXY31wLFem9xo+VYUPirpneruzW9k4dBwDV4iPh9tHeOe22l/VI8sXsno4biRq3lT8r4AM249m4khVk2Q1+fr05jlzoakHIpVRkeh6/6iV//RhkDwARI0G0nIQob/0q8E4C3H26pxsA5XJnRvzs/h9lgAE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483640; c=relaxed/simple; bh=SIi46sAJ3akHceZIRoH2XmfFqxFkyS3eT+KqHD6fe7k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Du+cRmD+HA20iTFZ2rUsZHXev/lRAGyF8gdaKbZfEnoyIwozQqG30Z9ABb2JhWEJMqj9B3oVkcQEyZBbLi76e5rKN34DaFwlNOpmHgZE4ikpy9xHdwofhaEcQyNWQLfLmX62s0UvUuYQruTAGLSrzQm1t/pBxKlE8fJIwPxZDrU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=Tpf7fTGG; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Tpf7fTGG" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-aa543c4db92so385751466b.0 for ; Fri, 06 Dec 2024 03:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483637; x=1734088437; darn=vger.kernel.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=r3NK3+VvNXvn4/X99VXMNRx8LERvbPVlsDcIxAPbW7c=; b=Tpf7fTGGqWRvvVKmxhqZPhxTHemi3z83lVgludb3y7timQBHx47S1IFFBreNwj8a+/ hw3hJ4Fk8wtWmIhzg23F6roQOzgpFQKBPldF2BJ4LGVWMpYkwWY3sOy/pe5yfmrZq9Q1 cpJtjp/fyCa9TZsRgm1oLmLdL1ve/mDRycnBifJDdc25pdsPwyWfJFCKewHMI0BDVdxj wjiMZIW5E3u0p/J1pcRYD84XwRr8H4awCv1nl0mTkr6pa1PVJ0EG+U0aIl8r3X66V9fc +B1+oPJBfY9viAL65b7No+0gswkJj2RYF4kKzoClpb5oYtGn1wjPtvpwaJN1ASkoJSYA 2Ngw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483637; x=1734088437; 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=r3NK3+VvNXvn4/X99VXMNRx8LERvbPVlsDcIxAPbW7c=; b=f+d9SMuK2GoaaK3Dau22rfgplnyI9gckfjn/wGkMgIPWBmOKrJArOmRJY179UcZFYt Cg0AbpryCzDgcVeZf9r5XCa3ukPZD+4Oc1urRqL7JMn91w1zW1lkyuQFOBzNQYrGuWJA U1vJ8RCErYuwMK/SxOU2BCMbcYkqC4aCp3racy4RYlVtr8L4hpcKHEwKRvZX08BtOgb7 VlT3SZgDIgOLOVxufJtrWJ34jtNGK+Fsn3wyBc8ZMW1qA1Hsl5AFd4hQFDLtazci0ffu B9LuDoCvCrBWMSlIAUpQjnGWbBv+fYFTiCu+P6NDhYf/DP01nZ1NilnePdQ0OC0SAdTm ujjg== X-Forwarded-Encrypted: i=1; AJvYcCUNnd5iEZ/MRl21B01+ofK56Fx+DX8xXRpmyO01kAQ4CHWC025ucoIJ9v5hYX/mFww6vMAxEah3d+U=@vger.kernel.org X-Gm-Message-State: AOJu0YwXnusXoIoArneeI8OT2Sbh0h86mt0+mol3NJ8V6x57l7NTU/J2 fErmoe8+0T4j4iB8Q5qTvvzbVS3GBAmqc8D/pPAEucpNZ0OB1gM9/v02Rr2hkf4= X-Gm-Gg: ASbGncsBP5m4XV5twV3ifiq6gGgFqSc+aPKamgpxfjwUAxn1bCDJmaWINLfPnXJmegY k2DoCfZxGZp+jTZYVMsiZ4XVFmpTWJuZqryH/14Iar8TMvnLkgHEa8pM0JAFGhDHDSmyRS6gE/p 7LMqjXrEaaksepPUNKZPEXU3nW4wIGBFfQVQvhCRnxpIUNFSwZva5yy8M0KmLkvP/tqeRfVYFLw 8iq/QjLsjHbUPb2RzVPxGIaIsjq+45zCJHx2Rz0uZE7AzgigqUmMyN3Y1OYVlH2R5OJZupOhlRx bBaK X-Google-Smtp-Source: AGHT+IG5ns28LlIO5EKzt3jy9KG0NXWjALwAdfE48ssUd8bpZB71xSWH7xVctc2Y/hSvsPovXL1IRQ== X-Received: by 2002:a17:906:3292:b0:aa6:4494:e354 with SMTP id a640c23a62f3a-aa64494e742mr62432466b.42.1733483637032; Fri, 06 Dec 2024 03:13:57 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:13:56 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 02/15] iio: adc: rzg2l_adc: Convert dev_err() to dev_err_probe() Date: Fri, 6 Dec 2024 13:13:24 +0200 Message-Id: <20241206111337.726244-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Convert all occurrences of dev_err() in the probe path to dev_err_probe(). This improves readability and simplifies the code. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - none, this patch is new drivers/iio/adc/rzg2l_adc.c | 64 +++++++++++++------------------------ 1 file changed, 22 insertions(+), 42 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index cd3a7e46ea53..8a804f81c04b 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -313,15 +313,11 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l return -ENOMEM; num_channels = device_get_child_node_count(&pdev->dev); - if (!num_channels) { - dev_err(&pdev->dev, "no channel children\n"); - return -ENODEV; - } + if (!num_channels) + return dev_err_probe(&pdev->dev, -ENODEV, "no channel children\n"); - if (num_channels > RZG2L_ADC_MAX_CHANNELS) { - dev_err(&pdev->dev, "num of channel children out of range\n"); - return -EINVAL; - } + if (num_channels > RZG2L_ADC_MAX_CHANNELS) + return dev_err_probe(&pdev->dev, -EINVAL, "num of channel children out of range\n"); chan_array = devm_kcalloc(&pdev->dev, num_channels, sizeof(*chan_array), GFP_KERNEL); @@ -445,62 +441,46 @@ static int rzg2l_adc_probe(struct platform_device *pdev) return PTR_ERR(adc->base); adc->pclk = devm_clk_get(dev, "pclk"); - if (IS_ERR(adc->pclk)) { - dev_err(dev, "Failed to get pclk"); - return PTR_ERR(adc->pclk); - } + if (IS_ERR(adc->pclk)) + return dev_err_probe(dev, PTR_ERR(adc->pclk), "Failed to get pclk"); adc->adclk = devm_clk_get(dev, "adclk"); - if (IS_ERR(adc->adclk)) { - dev_err(dev, "Failed to get adclk"); - return PTR_ERR(adc->adclk); - } + if (IS_ERR(adc->adclk)) + return dev_err_probe(dev, PTR_ERR(adc->adclk), "Failed to get adclk"); adc->adrstn = devm_reset_control_get_exclusive(dev, "adrst-n"); - if (IS_ERR(adc->adrstn)) { - dev_err(dev, "failed to get adrstn\n"); - return PTR_ERR(adc->adrstn); - } + if (IS_ERR(adc->adrstn)) + return dev_err_probe(dev, PTR_ERR(adc->adrstn), "failed to get adrstn\n"); adc->presetn = devm_reset_control_get_exclusive(dev, "presetn"); - if (IS_ERR(adc->presetn)) { - dev_err(dev, "failed to get presetn\n"); - return PTR_ERR(adc->presetn); - } + if (IS_ERR(adc->presetn)) + return dev_err_probe(dev, PTR_ERR(adc->presetn), "failed to get presetn\n"); ret = reset_control_deassert(adc->adrstn); - if (ret) { - dev_err(&pdev->dev, "failed to deassert adrstn pin, %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, "failed to deassert adrstn pin, %d\n", ret); ret = devm_add_action_or_reset(&pdev->dev, rzg2l_adc_reset_assert, adc->adrstn); if (ret) { - dev_err(&pdev->dev, "failed to register adrstn assert devm action, %d\n", - ret); - return ret; + return dev_err_probe(&pdev->dev, ret, + "failed to register adrstn assert devm action, %d\n", ret); } ret = reset_control_deassert(adc->presetn); - if (ret) { - dev_err(&pdev->dev, "failed to deassert presetn pin, %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, "failed to deassert presetn pin, %d\n", ret); ret = devm_add_action_or_reset(&pdev->dev, rzg2l_adc_reset_assert, adc->presetn); if (ret) { - dev_err(&pdev->dev, "failed to register presetn assert devm action, %d\n", - ret); - return ret; + return dev_err_probe(&pdev->dev, ret, + "failed to register presetn assert devm action, %d\n", ret); } ret = rzg2l_adc_hw_init(adc); - if (ret) { - dev_err(&pdev->dev, "failed to initialize ADC HW, %d\n", ret); - return ret; - } + if (ret) + return dev_err_probe(&pdev->dev, ret, "failed to initialize ADC HW, %d\n", ret); irq = platform_get_irq(pdev, 0); if (irq < 0) From patchwork Fri Dec 6 11:13:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897020 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB7AC1FF606 for ; Fri, 6 Dec 2024 11:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483642; cv=none; b=uZKV+AW0x57V1jTUTljz3OMcxuwrTebbbtJffDcfH1UmpRWJhlN8Rys1PFFEqCijHJ9tcbBQUCPT1MEM0rGkwjW3TWCdJ1hIIbuPmg3qxZECQbuh49dbyoD3ZRI1pgQXo8zpvGHAPKftzyjNnEYvhmyT1BtwF9CUjJJz0H+5LhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483642; c=relaxed/simple; bh=pFeVqwq5TdQjxpLyK7iTM1W+bmcdyJjKWS9gDr7aPgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ggy4/RgjkKDat6tP40cVxSo4iw0mWHzllHOMtgmQVpzpEsmME6NzVI2qWjZ+Z8gOmvoxCDVQXQS2BzQX8esy6c/UYZIOuLniBZHGtPxzfkjmIN7PHIHsU6OhTgd94FjilVpaqd31rPOfd1Swy6OnBQdgJwBgXNSLBaWJPwpmJQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=KTyk/JTS; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="KTyk/JTS" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5d0d4a2da4dso3154027a12.1 for ; Fri, 06 Dec 2024 03:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483639; x=1734088439; darn=vger.kernel.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=IF+3d6YLoFd8ymBLjEJf+CI6Y+EI/atf0HIxguIiGOc=; b=KTyk/JTSj84SQaukd1UW5/e2pUXUmY4LMfK3scIgA5GUK5NXxh1JUjIOy2mvdCKPoc 4RUOzTCk5ejmI4TMxPI3IwlvgJjccg1KUm6GMuMzUzjZc+HWNEj8NwF8fse4+ucyoKg+ SDm/FliQmJHkw1u9yJtjMtAyvUjx/EsHww0B4qy5WoTGpkUDAnvI4fQqEhQthyRwxEDM 5gkzMPLMBvwF4AkmMYF59/a3vKFgNjklGsCTjrJYjkFXemCR2JL54Trv7bbgoyuMxm0Y FUD3dKOJMLvLka7DIOiO+PwSXNGSqFFeDqWAWM2CHIwKpRHFdvsze5IgCdmo6d+gZSaW we4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483639; x=1734088439; 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=IF+3d6YLoFd8ymBLjEJf+CI6Y+EI/atf0HIxguIiGOc=; b=K6fSYUBKIBLL7mTyrNXLss2PWPgcvePGElOGfB7O8YiLHKnyOcccQqDyjwVCCJwfjD 0zxYSzPASwRNl7c53OC92+8AcomXndFP9KPVX4oJEj5TWYBMRrqoVgszc5jIsQ/UDi1t e8YRFYCWFYcFLdpECivAgpnyXO4fDiq8Bda6AH7rHFpKGqiU2Q+OqfS1B7L3DKlUC5hI cRNZqU/Toyn1AZQBIvXPMNr3Z88U70yRmDOzHgy2MKCVLdfVuWCZ4KrF9iAxo577iBz0 bLXsgmGv5o6PsKfvrEB4h3gZA9pwX/khIBYEWVK4dZ2yMTgBE0nuOM7ZTlQO1I9Sam5I Y1ow== X-Forwarded-Encrypted: i=1; AJvYcCXd6cPNyUbBPTxLsufiCRSelpmBttHUGNyF1U+WsCwmZYibs5AuWNC1xklIIgfQXd72v+dkXEa9oHI=@vger.kernel.org X-Gm-Message-State: AOJu0YxRJBghGVyKewcTw47cCP/PyGXtnyxpnyvDbbQ72Ta3cZNys/dc pdabUW0Sz/9GJp4eD3XwErTnyLEdG2lKUFyNwRI+QbPS/RgpokLDQt7dbOaoVgA= X-Gm-Gg: ASbGncuz1rDu02OPzS8072b5pFlHvLDdKShciOMcMot1JpgFca8A9fXuNEBl/7kPVof cHDp8Edv/OCQO+YDpBYG69T/mDU43JVbiQRWUTpRsUPqz2hwh0vB3PtEPge5Lr47W82qu8icLpi RUwEWUjdQC8xfrdRJeQLI0Nube8ezBlnnAFfI/yJCkauRObo4dvRVKln7DAQCmEJr4MlwN7EHTG k16rJwE/Cw1MHTshz0cPRPUKlf+KueIkPC2dTlt59EQdK6FTtObpHDdAYzFEgXncVxnznd/dYSx q03i X-Google-Smtp-Source: AGHT+IE8/6k5bsY8E9y5ISlKPNleG7y4yY/FFLd5nbbFNGCG10Rgtm0MhHvZLaSwwmr1LC62i+/LQg== X-Received: by 2002:a17:907:3a57:b0:aa5:1cdf:7bb1 with SMTP id a640c23a62f3a-aa63a03afedmr192091466b.24.1733483639246; Fri, 06 Dec 2024 03:13:59 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:13:58 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 03/15] iio: adc: rzg2l_adc: Use devres helpers to request pre-deasserted reset controls Date: Fri, 6 Dec 2024 13:13:25 +0200 Message-Id: <20241206111337.726244-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Starting with commit d872bed85036 ("reset: Add devres helpers to request pre-deasserted reset controls"), devres helpers are available to simplify the process of requesting pre-deasserted reset controls. Update the rzg2l_adc driver to utilize these helpers, reducing complexity in this way. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - rebased on top of patch 2/15 from this version - used "failed to get/deassert" failure messages drivers/iio/adc/rzg2l_adc.c | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 8a804f81c04b..c0c13e99aa92 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -411,11 +411,6 @@ static void rzg2l_adc_pm_runtime_set_suspended(void *data) pm_runtime_set_suspended(dev->parent); } -static void rzg2l_adc_reset_assert(void *data) -{ - reset_control_assert(data); -} - static int rzg2l_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -448,34 +443,14 @@ static int rzg2l_adc_probe(struct platform_device *pdev) if (IS_ERR(adc->adclk)) return dev_err_probe(dev, PTR_ERR(adc->adclk), "Failed to get adclk"); - adc->adrstn = devm_reset_control_get_exclusive(dev, "adrst-n"); + adc->adrstn = devm_reset_control_get_exclusive_deasserted(dev, "adrst-n"); if (IS_ERR(adc->adrstn)) - return dev_err_probe(dev, PTR_ERR(adc->adrstn), "failed to get adrstn\n"); - - adc->presetn = devm_reset_control_get_exclusive(dev, "presetn"); - if (IS_ERR(adc->presetn)) - return dev_err_probe(dev, PTR_ERR(adc->presetn), "failed to get presetn\n"); - - ret = reset_control_deassert(adc->adrstn); - if (ret) - return dev_err_probe(&pdev->dev, ret, "failed to deassert adrstn pin, %d\n", ret); - - ret = devm_add_action_or_reset(&pdev->dev, - rzg2l_adc_reset_assert, adc->adrstn); - if (ret) { - return dev_err_probe(&pdev->dev, ret, - "failed to register adrstn assert devm action, %d\n", ret); - } + return dev_err_probe(dev, PTR_ERR(adc->adrstn), "failed to get/deassert adrst-n\n"); - ret = reset_control_deassert(adc->presetn); - if (ret) - return dev_err_probe(&pdev->dev, ret, "failed to deassert presetn pin, %d\n", ret); - - ret = devm_add_action_or_reset(&pdev->dev, - rzg2l_adc_reset_assert, adc->presetn); - if (ret) { - return dev_err_probe(&pdev->dev, ret, - "failed to register presetn assert devm action, %d\n", ret); + adc->presetn = devm_reset_control_get_exclusive_deasserted(dev, "presetn"); + if (IS_ERR(adc->presetn)) { + return dev_err_probe(dev, PTR_ERR(adc->presetn), + "failed to get/deassert presetn\n"); } ret = rzg2l_adc_hw_init(adc); From patchwork Fri Dec 6 11:13:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897021 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA2C81FF7B7 for ; Fri, 6 Dec 2024 11:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483644; cv=none; b=pAz41dBwMoALSwCngS54U6T1WUlGsdkteSiOaNdNK/77feAR1AP3t5QxLYiZXhoMvmIn0ocr2VLCfWYCsLrNb3JMEeUB2RJQycv22C9V4hwn3O16DdaoKsUBW2atM9nUQjgoSvHLREgp0fDkdbJM1v55XjY5wxCVJkT2URuOFbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483644; c=relaxed/simple; bh=gLFQxm2yw1A/z6UCgE5w4vdul6md567AjzUUdwmf1eY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PXTjdgmVJ48rGF0OeD1ki5nYLzxgFFMYyoy8EkeoZoCtiB/buK+O2Y0cc8rMGdcdPYpAm5Ml0fMZaBQCSnnSEq4FC6fm9aehZNaZx5fVDguLtazj4wlfjoffwN5hkMAg94mrMYfEeU8DyC3ALCCVR3h885mt3OIrgSKZHJHf6i8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=VzBb0xhG; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="VzBb0xhG" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5d3ab136821so1425067a12.0 for ; Fri, 06 Dec 2024 03:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483641; x=1734088441; darn=vger.kernel.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=LK+A22UoYLzMHBRjgcTvKCaVtCrM95+xKIADzMQGcIY=; b=VzBb0xhGNfibMuEaQVUKHVUbq1BCEF01X2MwF5EpbXNYeb9ijpaH8iJh9ioCyMJull iF+iQogkJAF+WxiEzbFO8ublXzG8+FBUeUX58ysIJIJwBnVQ1feBdXaKCXQcUTw18BhX gPR721+tYBJjS/0+z+vIM8DgtCFK0CQs24hSg+jy2QdqXXWzOXlksEZR0elQpa+BID+n /cptDksxSsEjmQoGozm7rcHtu5Zdd2XHi6hzUqyLahxSoHdMqas2mq+2sRvvuB5DOTzx vUE10fju8463NvUAXs0XYgzdKIoQARyRbahL/mNiljrZhP7gV+DFVtjZlANpwfiVFiHf p1lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483641; x=1734088441; 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=LK+A22UoYLzMHBRjgcTvKCaVtCrM95+xKIADzMQGcIY=; b=ukZiqFLcWfO19ZRG6eHTEcR+Fzn0OWEnPR/QHviKwsoqzqgK+2R/Vm/13cgSKzy//7 W/blTDuoncDPXmuVUM1Y2cazU6HyfIK7a/zp0ewkaNeS+4D40FjGUZb2ardU7+QfbQrA J7E4uxJkkYHOujWfxJa4zXfEh2VJqDQGiLhBa7uWTcsyyUuHi0U8rL1xWdUXsYt+f2Tf vcZyULDuOjX4g0SN9lIMOoxhqX4x5VMs/Jf7oKhGb2H4C1vv+XOo7+Lr15qNFKc65/1T mbyzY012RqeQhojHZVeAZS8RSm6ahEd92QWv5126XkpIuvuhccDlOTNhbySI7hu/faed V8Cw== X-Forwarded-Encrypted: i=1; AJvYcCU9Wp9v3wIX+GYqBXaw2ol6OU5o1kJZ8XbiVH94Hdj5W362tYaem+ps3h9n+7idAgHbc6T+UhU6Tac=@vger.kernel.org X-Gm-Message-State: AOJu0YzfjyJmAqpcmHbZ05y51VJjeRKDK3c+6CKjwZWaF0yIhDATxV06 Exz+gROAzZieiE1Ozmh5sKQvHiBwPglqXy+0gS6GctpwW4i29eYc3WxZDyal/is= X-Gm-Gg: ASbGnct/JUqqJGa1Dew2INbfUJRHO5/O16Tb+jK7tldDJsT6kC/jJJsGZk36rQJVuDW nCEeAGCijB+9Tos/ptoCnS9qT0mIrnim+YsVKMsqGJnyPAo7I8AxYENDSCICMsnCn+DndNESm88 RWKP8nLMyumzaU+vjuyypApsEOe/dn6CYeNKwZ/FyjI/iL1toyfITjEvWIAIVBOKhhLGWgL61oG xJDAowCo5fFq6WlZrdVMwgSngPsOuM7ZGqzwQXHaGmrUsOdZZnOiqCERJuw3XhhCkmT5igiK8i7 AMdSIVJA X-Google-Smtp-Source: AGHT+IFuzLKbXu8rAPLAdGLusru5W/d5iskWC5RkGqbMd759pHt8MKL7B7opME79jVgcPPIhEmgadw== X-Received: by 2002:a17:907:6190:b0:aa5:c9a:5f4b with SMTP id a640c23a62f3a-aa63a07f0cdmr143555566b.24.1733483640969; Fri, 06 Dec 2024 03:14:00 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:00 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 04/15] iio: adc: rzg2l_adc: Simplify the runtime PM code Date: Fri, 6 Dec 2024 13:13:26 +0200 Message-Id: <20241206111337.726244-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea All Renesas SoCs using the rzg2l_adc driver manage ADC clocks through PM domains. Calling pm_runtime_{resume_and_get, put_sync}() implicitly sets the state of the clocks. As a result, the code in the rzg2l_adc driver that explicitly manages ADC clocks can be removed, leading to simpler and cleaner implementation. Additionally, replace the use of rzg2l_adc_set_power() with direct PM runtime API calls to further simplify and clean up the code. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - rebased on top of patch 02/15 from this version drivers/iio/adc/rzg2l_adc.c | 96 ++++++++----------------------------- 1 file changed, 20 insertions(+), 76 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index c0c13e99aa92..780cb927eab1 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -8,7 +8,6 @@ */ #include -#include #include #include #include @@ -69,8 +68,6 @@ struct rzg2l_adc_data { struct rzg2l_adc { void __iomem *base; - struct clk *pclk; - struct clk *adclk; struct reset_control *presetn; struct reset_control *adrstn; struct completion completion; @@ -188,29 +185,18 @@ static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch) return 0; } -static int rzg2l_adc_set_power(struct iio_dev *indio_dev, bool on) -{ - struct device *dev = indio_dev->dev.parent; - - if (on) - return pm_runtime_resume_and_get(dev); - - return pm_runtime_put_sync(dev); -} - static int rzg2l_adc_conversion(struct iio_dev *indio_dev, struct rzg2l_adc *adc, u8 ch) { + struct device *dev = indio_dev->dev.parent; int ret; - ret = rzg2l_adc_set_power(indio_dev, true); + ret = pm_runtime_resume_and_get(dev); if (ret) return ret; ret = rzg2l_adc_conversion_setup(adc, ch); - if (ret) { - rzg2l_adc_set_power(indio_dev, false); - return ret; - } + if (ret) + goto rpm_put; reinit_completion(&adc->completion); @@ -219,12 +205,14 @@ static int rzg2l_adc_conversion(struct iio_dev *indio_dev, struct rzg2l_adc *adc if (!wait_for_completion_timeout(&adc->completion, RZG2L_ADC_TIMEOUT)) { rzg2l_adc_writel(adc, RZG2L_ADINT, rzg2l_adc_readl(adc, RZG2L_ADINT) & ~RZG2L_ADINT_INTEN_MASK); - rzg2l_adc_start_stop(adc, false); - rzg2l_adc_set_power(indio_dev, false); - return -ETIMEDOUT; + ret = -ETIMEDOUT; } - return rzg2l_adc_set_power(indio_dev, false); + rzg2l_adc_start_stop(adc, false); + +rpm_put: + pm_runtime_put_sync(dev); + return ret; } static int rzg2l_adc_read_raw(struct iio_dev *indio_dev, @@ -348,13 +336,13 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l return 0; } -static int rzg2l_adc_hw_init(struct rzg2l_adc *adc) +static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) { int timeout = 5; u32 reg; int ret; - ret = clk_prepare_enable(adc->pclk); + ret = pm_runtime_resume_and_get(dev); if (ret) return ret; @@ -392,25 +380,10 @@ static int rzg2l_adc_hw_init(struct rzg2l_adc *adc) rzg2l_adc_writel(adc, RZG2L_ADM(3), reg); exit_hw_init: - clk_disable_unprepare(adc->pclk); - + pm_runtime_put_sync(dev); return ret; } -static void rzg2l_adc_pm_runtime_disable(void *data) -{ - struct device *dev = data; - - pm_runtime_disable(dev->parent); -} - -static void rzg2l_adc_pm_runtime_set_suspended(void *data) -{ - struct device *dev = data; - - pm_runtime_set_suspended(dev->parent); -} - static int rzg2l_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -435,14 +408,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev) if (IS_ERR(adc->base)) return PTR_ERR(adc->base); - adc->pclk = devm_clk_get(dev, "pclk"); - if (IS_ERR(adc->pclk)) - return dev_err_probe(dev, PTR_ERR(adc->pclk), "Failed to get pclk"); - - adc->adclk = devm_clk_get(dev, "adclk"); - if (IS_ERR(adc->adclk)) - return dev_err_probe(dev, PTR_ERR(adc->adclk), "Failed to get adclk"); - adc->adrstn = devm_reset_control_get_exclusive_deasserted(dev, "adrst-n"); if (IS_ERR(adc->adrstn)) return dev_err_probe(dev, PTR_ERR(adc->adrstn), "failed to get/deassert adrst-n\n"); @@ -453,7 +418,13 @@ static int rzg2l_adc_probe(struct platform_device *pdev) "failed to get/deassert presetn\n"); } - ret = rzg2l_adc_hw_init(adc); + ret = devm_pm_runtime_enable(dev); + if (ret) + return ret; + + platform_set_drvdata(pdev, indio_dev); + + ret = rzg2l_adc_hw_init(dev, adc); if (ret) return dev_err_probe(&pdev->dev, ret, "failed to initialize ADC HW, %d\n", ret); @@ -468,26 +439,12 @@ static int rzg2l_adc_probe(struct platform_device *pdev) init_completion(&adc->completion); - platform_set_drvdata(pdev, indio_dev); - indio_dev->name = DRIVER_NAME; indio_dev->info = &rzg2l_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = adc->data->channels; indio_dev->num_channels = adc->data->num_channels; - pm_runtime_set_suspended(dev); - ret = devm_add_action_or_reset(&pdev->dev, - rzg2l_adc_pm_runtime_set_suspended, &indio_dev->dev); - if (ret) - return ret; - - pm_runtime_enable(dev); - ret = devm_add_action_or_reset(&pdev->dev, - rzg2l_adc_pm_runtime_disable, &indio_dev->dev); - if (ret) - return ret; - return devm_iio_device_register(dev, indio_dev); } @@ -503,8 +460,6 @@ static int __maybe_unused rzg2l_adc_pm_runtime_suspend(struct device *dev) struct rzg2l_adc *adc = iio_priv(indio_dev); rzg2l_adc_pwr(adc, false); - clk_disable_unprepare(adc->adclk); - clk_disable_unprepare(adc->pclk); return 0; } @@ -513,17 +468,6 @@ static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct rzg2l_adc *adc = iio_priv(indio_dev); - int ret; - - ret = clk_prepare_enable(adc->pclk); - if (ret) - return ret; - - ret = clk_prepare_enable(adc->adclk); - if (ret) { - clk_disable_unprepare(adc->pclk); - return ret; - } rzg2l_adc_pwr(adc, true); From patchwork Fri Dec 6 11:13:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897022 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 487B41FCD07 for ; Fri, 6 Dec 2024 11:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483646; cv=none; b=bwNnHA1Y2vqzzxSLzb04lZEcYLfQ4dcPSRLXhKlgfJd3DkvEDrRLcuwWrMkpf7s6sJQhpYAR6EopJ2UR3AfYh4l5rl00uYP7xb8gdzTL1EwYyJA9mAHaQ9pVsDY34YLABFI26Lh7ca1ucdXZMfsADSyk/5v4SYr0fuoz6z5LKf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483646; c=relaxed/simple; bh=Dwmv4o74khoBQdkptuvQ4q7nGic6CB59TAj8g4R5I2A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kuA0Vr/rjxNqZN7x6yVNdALycgBsQYckK31UW0+YqcOSQHAdtOKelBO47A593WqXCRQxU8OZgycvGBWI4JM9qBP7hEPd5SHIFZCJZyAgggrPQQz7OquJU9LtlOtN1DTqCoVLz5YtSPnZHBUtjb1bCgRyN/w120YWp4Tvx7yMiaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=In2/7Xdf; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="In2/7Xdf" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-aa642e45241so51134366b.1 for ; Fri, 06 Dec 2024 03:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483643; x=1734088443; darn=vger.kernel.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=MNUU76506eldJbwNztMYjCQxf0w88SMXCYz1DW5xFro=; b=In2/7XdfuJQ+VvilHhtkD7O+e9S05Cfhzi+R9SmGf/eoYLhLxcRfqJ9RKkZG8CNXnB Jbql9fJNzGnWpQlCbPvbLy/tp3Vvk3L+vUBAqRb036S88aluvlxP3qTYTVTxghQuyziZ gHJnbYsb2Mk4II6juQZ+pgwZO2LH70WG5lIwUmoCGOpLo2pSqr4j8zrvpToNRb8E8hC/ It8F/dCDIP5mqhtkjQoqCGlYb8nY1Sqljddtk/PMwoWnpEdBPO5kKVWCkpVtSZxvhMf0 FBbJQPanKxlJmrvSKE6knIj3C21w5yH61mz+Ld+YUTUTmGGIztH9Xn8mpjmDccbencqa /1cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483643; x=1734088443; 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=MNUU76506eldJbwNztMYjCQxf0w88SMXCYz1DW5xFro=; b=bqIKhLEAYRNPNqaPlW47SLitkzPaYYJbSE3mMGtwF5Hxo4madoTosBGE+O1i0E/ez8 5XKJn/LZaNikR0aWFfWbzLq4uGLIChVyvA/dAnk40w+BR8LFSbRPCh3xKWh0DSLJYlGf xNE7iREda9CC28wu2tmErPvpcT/ret+nuZyi9Y58KShfTIOSvYx4u5lPJTO0mzhc4zzc CsvTJWwIo2FXW3VL6MXYQPg2+k6NVBSP2QaH+zO9WoWYq0O/HW0fKB/smIiS53Cd37TM cTm/uPOqgmxLLlwnaD0LPhyvj16GljxX2Ugt2Z3I/IflchfKXgPHGl7qkHV9Uxx5HuPf loIw== X-Forwarded-Encrypted: i=1; AJvYcCX5rMfBq33lAk9V6LHBEd8njl3oQv0htSJd980KOQ+b3TVTcF+reaYOpw2AysGPZ9L/yxWx3t+H0cM=@vger.kernel.org X-Gm-Message-State: AOJu0YxKCfDkDGBDMeer07+tlbM0M8OXDLvQl6z5pk9Ex2W6r4kFw3fC W7MmFVmZW21tItPhTuI2oKq5mOBJihalv29hBmoFmpwvolQJioyAJGOOo9lccB4= X-Gm-Gg: ASbGncvvxoMdamVTOw1Jq4PRThD2Sprz5+dRAuSfPX07VxrncDQT1k6fMk7o4RS9QdH 6uo7QSzjG7yz4JqpVdJpnq2LcsPVhSFOQbigHO4M088Hkpjcksxu4fhwv4T1A9m34BvzOl+8Wz+ Puy8jRA8ZvBFhAArve8OIBIeqG9RZ0zIXg+9tEY3bjVRa799L6+EUyoPeEPOIp/Bf779+tlFZSJ 260TWd9oJ9CteBqrTTXRzNpGYHr8Gch1kSkLbQQMpjRcHYoGYf0biTx5oeDJiqOLbE9P9YPgVv5 u1Ge X-Google-Smtp-Source: AGHT+IH6Yt9ImiRFWWuZjkCgbEGYygXRPHwjAYhKDD1eg/rWy5S/tL1CQg/zDPDowgi1wK/HCr+qTA== X-Received: by 2002:a17:907:75d8:b0:aa6:2867:4dc5 with SMTP id a640c23a62f3a-aa63a285650mr203661266b.49.1733483642631; Fri, 06 Dec 2024 03:14:02 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:02 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 05/15] iio: adc: rzg2l_adc: Switch to RUNTIME_PM_OPS() and pm_ptr() Date: Fri, 6 Dec 2024 13:13:27 +0200 Message-Id: <20241206111337.726244-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea The use of SET_RUNTIME_PM_OPS() is now deprecated and requires __maybe_unused annotations to avoid warnings about unused functions. Switching to RUNTIME_PM_OPS() and pm_ptr() eliminates the need for such annotations because the compiler can directly reference the runtime PM functions, thereby suppressing the warnings. As a result, the __maybe_unused markings can be removed. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - none drivers/iio/adc/rzg2l_adc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 780cb927eab1..482da6dcf174 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -454,7 +454,7 @@ static const struct of_device_id rzg2l_adc_match[] = { }; MODULE_DEVICE_TABLE(of, rzg2l_adc_match); -static int __maybe_unused rzg2l_adc_pm_runtime_suspend(struct device *dev) +static int rzg2l_adc_pm_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct rzg2l_adc *adc = iio_priv(indio_dev); @@ -464,7 +464,7 @@ static int __maybe_unused rzg2l_adc_pm_runtime_suspend(struct device *dev) return 0; } -static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev) +static int rzg2l_adc_pm_runtime_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct rzg2l_adc *adc = iio_priv(indio_dev); @@ -475,9 +475,7 @@ static int __maybe_unused rzg2l_adc_pm_runtime_resume(struct device *dev) } static const struct dev_pm_ops rzg2l_adc_pm_ops = { - SET_RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend, - rzg2l_adc_pm_runtime_resume, - NULL) + RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend, rzg2l_adc_pm_runtime_resume, NULL) }; static struct platform_driver rzg2l_adc_driver = { @@ -485,7 +483,7 @@ static struct platform_driver rzg2l_adc_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = rzg2l_adc_match, - .pm = &rzg2l_adc_pm_ops, + .pm = pm_ptr(&rzg2l_adc_pm_ops), }, }; From patchwork Fri Dec 6 11:13:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897023 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0943D200139 for ; Fri, 6 Dec 2024 11:14:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483648; cv=none; b=J0oah7OpkT31Ykjvp13JWF4yBJdHWz81RQ2AMEulNoPObnXN143X3sG4nB1IhtcUA3RHjYFJrOuA0jHTkTdiO+HABv2D7spfCLYnKJl2itJkJViyZbTSVdilkBo7C0YUgivUBETXKV3nxCA30ebQIjuweQ8ThXpCr7yegW41If8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483648; c=relaxed/simple; bh=k+e2xOqzzPlHXfQrE6tIHd8B8n0ckX4ZsqRauyT6SrU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ryyWQnMpvlRLrL47vYEf5JwD93r9ByAwwVyXv17ZoHQwiFYv5ILNSyFmt/yB8e76g4Ay/5JGgYJKTCQuz4JSqnlbb1dNq3vjU37qNXKfB3i1X8zOKoebdHu8VKzu7pJcwzvCAdQfsQ2CN58maa0CGgPkWakRiJp+AHjF9uH9rFQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=emkRSVVg; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="emkRSVVg" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3862ca8e0bbso389331f8f.0 for ; Fri, 06 Dec 2024 03:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483644; x=1734088444; darn=vger.kernel.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=Opknw59dd1fO7VceDAzkVbX2zeeLYIzonu5RWkuZeEg=; b=emkRSVVggyVlkmoOV1p1JmE08HiIcJ8YoF7+FB4K0l4OBR641AiHLbHDd2tKZVQVTs n1Ak1hFx1XUVUINezCkL6A/BZlVnzbihXdFoIQ9aRBgS+ixvxMbn7UbW9sAUJZXi3LKI WRnCSU78wJVggdW7OUaPqTzCUn70bKm4ZvnQ++HAyN8wx6ttyj9ZTT/XNGT3otHkp3L8 cS7OHhaVV65PCLMiE1qy86bBGZpVQZZ8CUJjMbIkMiT0z8Ckucu+ZYzXD9z+sedwV35f 0AmYy1t+EUOoNUqiFsbxm4jigpTvdThLC6pB0rkqD+fjVOf3FZ1OIFURuDdAfjqamKWh hvMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483644; x=1734088444; 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=Opknw59dd1fO7VceDAzkVbX2zeeLYIzonu5RWkuZeEg=; b=Cl0RDW2hHbkzpR3DDF3BVlfwL+cPqU+YKj2myxbP/uQcRCiui5JMpIlmrQqgiEltCR GzG2FGrZ8/Rd+z8QLucZb8NkCU07t/B95SyMPqJPM7rk2kT7ykTFmfCFHNC5P3XM4qk+ Xn/P4GHRwZZcvFnlZkNHV2c1jzqp8E9SLxskVqKqlrV3Cre9EUEmpTi3DOx+rc2Ektyh a2iBp+iDqs5S4iNGibSS60AcRnIxafHrBWeQE4fmu3wZAAvBRYDEsnCgxzxiMhavwBK8 zEaqUCPaUp4eEScVAoUwfXtX7byxlnmqA2PXR/5y+aFKhVaGfN8hSkdppg5Xqf/nGyMw slyg== X-Forwarded-Encrypted: i=1; AJvYcCVEMVGilLVxuittqQYM/TQYq9CCr7kEAfpbrFAlR59hrQ3qkyUesiha3pR1RMdJerYy/C/uYq+NxUs=@vger.kernel.org X-Gm-Message-State: AOJu0YymQCUDNdJGprTIn7F/jG/iOIAlJWifIwicD9ZhEpnUcGgBYTv3 jIhokw9bxclFJzC55BHU0BXAbli5dxFgv8+V8KeHOrSRGglCDfvPk20yR860qVQ= X-Gm-Gg: ASbGnctmfYZQi4BKyz6kXfC04O9z3bfcgKX9sg6/MVGppXCilFRzHRZ01ElEuifB86G QWZSNGXAuFxkeDx0hxtXpgcK4VlWTVkp+9UODjQdOi8HxXI/E68xj3eavsio0dWEeuHiqQs5RKr xkGuDpEg6dW3SwK+g5ZEF5Xu1D3JHi+ImipvCP4QBem6AiYMZJOAXiF69xrwWeRvJvCC1CTUUxC eUDDmQ6zwpmKM589s7yfOxD8aA8OX+x2YcUt4GHctBHTit0ldJ45kIv1U9tz394+BWzUHOn9hlY MWsh X-Google-Smtp-Source: AGHT+IGHPjOUenYoqUgXzgnQIz721t4g0doqmz4uKaZGCl3bSPXpuHOTDDdqMtgiDrRz79pHzQnacA== X-Received: by 2002:a05:6000:178e:b0:385:e013:b844 with SMTP id ffacd0b85a97d-3862b355269mr1789922f8f.15.1733483644418; Fri, 06 Dec 2024 03:14:04 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:03 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 06/15] iio: adc: rzg2l_adc: Use read_poll_timeout() Date: Fri, 6 Dec 2024 13:13:28 +0200 Message-Id: <20241206111337.726244-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Replace the driver-specific implementation with the read_poll_timeout() function. This change simplifies the code and improves maintainability by leveraging the standardized helper. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - none drivers/iio/adc/rzg2l_adc.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 482da6dcf174..38d4fb014847 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -112,7 +113,7 @@ static void rzg2l_adc_pwr(struct rzg2l_adc *adc, bool on) static void rzg2l_adc_start_stop(struct rzg2l_adc *adc, bool start) { - int timeout = 5; + int ret; u32 reg; reg = rzg2l_adc_readl(adc, RZG2L_ADM(0)); @@ -125,15 +126,10 @@ static void rzg2l_adc_start_stop(struct rzg2l_adc *adc, bool start) if (start) return; - do { - usleep_range(100, 200); - reg = rzg2l_adc_readl(adc, RZG2L_ADM(0)); - timeout--; - if (!timeout) { - pr_err("%s stopping ADC timed out\n", __func__); - break; - } - } while (((reg & RZG2L_ADM0_ADBSY) || (reg & RZG2L_ADM0_ADCE))); + ret = read_poll_timeout(rzg2l_adc_readl, reg, !(reg & (RZG2L_ADM0_ADBSY | RZG2L_ADM0_ADCE)), + 200, 1000, true, adc, RZG2L_ADM(0)); + if (ret) + pr_err("%s stopping ADC timed out\n", __func__); } static void rzg2l_set_trigger(struct rzg2l_adc *adc) @@ -338,7 +334,6 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) { - int timeout = 5; u32 reg; int ret; @@ -351,14 +346,10 @@ static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) reg |= RZG2L_ADM0_SRESB; rzg2l_adc_writel(adc, RZG2L_ADM(0), reg); - while (!(rzg2l_adc_readl(adc, RZG2L_ADM(0)) & RZG2L_ADM0_SRESB)) { - if (!timeout) { - ret = -EBUSY; - goto exit_hw_init; - } - timeout--; - usleep_range(100, 200); - } + ret = read_poll_timeout(rzg2l_adc_readl, reg, reg & RZG2L_ADM0_SRESB, + 200, 1000, false, adc, RZG2L_ADM(0)); + if (ret) + goto exit_hw_init; /* Only division by 4 can be set */ reg = rzg2l_adc_readl(adc, RZG2L_ADIVC); From patchwork Fri Dec 6 11:13:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897024 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A767B200B9A for ; Fri, 6 Dec 2024 11:14:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483649; cv=none; b=jH3g5kmBpez8n9cPzrrl/TXZHOLfpg5wGHXEbXPZqMMukSLS6HodU+biFk4vGeTxTZOkY7yLqW90c7Ayc2aI7mNQilzCcjuo3MI1mjzFrgbxELq1Q8pbM3ycZh0fv99alILos/2DjCGRn1o7cWTWrUNw1VpUU1mIyJ4yVmd/QcA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483649; c=relaxed/simple; bh=dEqGILe6UUa2QV4lg2cHxtBVoCG04Pl16cd95wtxMm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SC7SZ9O64Oh8CB/ZLLE3JCFaUIlNGlCFtu0rkvMRs76SnfNyvldBqA6jCy+sCmvjG7YtqVsemZzSsvKfvekA2FyLQCkPKabFTvhVROGf0axrVjSoXmmK2+I+h0mM4lKgmE1MXwD5B2ieN8iR+YdBZvXbA9qnSRUHBohEYvpCWpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=imMOzar5; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="imMOzar5" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5d122cf8dd1so3104466a12.2 for ; Fri, 06 Dec 2024 03:14:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483646; x=1734088446; darn=vger.kernel.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=WhaQ2fSroT77bogvtIM7JXpl0W5k90kfLSeiQn1uD6k=; b=imMOzar5XjEWVg6mv/DR06oioKCfIvh6QHLnxG6xky10HI3yEYK6Dl1YYfPAQrzrTd CCZrbF3MUOWlC2tRox/eu/Z+Rkydjplxdew0FPz2yyLF+OfkBxrKLhUWh0j8Mh831xHb 8ZVZf/UhbVeVApC2w9Wct2YQtvfmek9JBly6lOfBCbmpc+LlR86knIUGGOGDixaSe7A8 iZp3XvqrApAGMz8fdtAFjF/5H9zpw87d2YZCZl+2d4oCfsiupkTbZegbYLrXaVObhRPw Q4V9hG4+2U+icNDTpWi69vhqFm9bSi2d5q4X/qyRsIMuIJiNyKQDdwayFsxJfBIcdbNi 9zDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483646; x=1734088446; 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=WhaQ2fSroT77bogvtIM7JXpl0W5k90kfLSeiQn1uD6k=; b=X1+r7hI1aHNTkxPEtOV/jMg3LIjHrGSMvn1/k9LVX+y1gMqCG935k5YIipBXxJysAp YV41iAWpehQAJzGOJyiFutd7ia8CETxbr2TJZE6Jh6ii7L/oIJ5rU5H5fY9THRQQO3Yf OrdUe2mrZ75QORDhxyEAGEFv0CReUTeyZsuQ4G+NVfAyEW8EftOc4rhJDCHAVTsDFogX w8GChQKP0wMJyAr/YVDQBKPq2Wbk/GnwRKuHF7kDgORH4Ts7Tws4PeOcFhdlphc4JbVD mZN6jlhqLI9jxdjLgwNKbqPaEH5DyXhRMvGw0NDXlwlLUI7cDct8wlL3yjbCvoDoH/X9 B3sg== X-Forwarded-Encrypted: i=1; AJvYcCWK2xgaYmYH/N52kJSTCfwhmaF0p5YDuk63sl0dxoXfI/NInkG1sy4KEMT2/5SRLae43wWPE8MdS4Y=@vger.kernel.org X-Gm-Message-State: AOJu0YyXfrS89p9BfFczletworR+T0qZXUmvIBCO4vUpcdM5zBXMKct1 ZTI/6IkfS3t/Vo7fC3/4/q66OLEQ34+Z4beQMFWTW/Vk29ANqc6K0I/HbrjimDo= X-Gm-Gg: ASbGncvpLgEDbloMpckJt/kPHLmTUp7P5BDeSMHJLoSS8VbkjAKlxlXVC8MQawp8+8e S/wIOSITkidIUTH5qcHsEEwT46dT1F5UpH7YN7QLE9EHuL2meTHqakgEvmvgSHDR8Jz+AxA415E wiulOC/DB+xySvsYJGWrsMtfWCxJQWCSMHF0fKFuQXJG20zx+9btRXVLseSZpVsILjCi7mPKOOt 4PfBBH72clmeOoIsRV4nuGf5aWnS8zzxGJ51bZAkUkGgMOqCCLF9846WyHI0svqAz1H7eleGSYv Fa+F X-Google-Smtp-Source: AGHT+IEde3hbpI6Dn8f4HHeLFJDahnLdyyCKzWeVkTOjBA3NVheYqHyT2l/Eb2Ag14Vr/Xb63k1GrQ== X-Received: by 2002:a17:906:2922:b0:aa5:4ea6:fcae with SMTP id a640c23a62f3a-aa63a073542mr216321466b.28.1733483646108; Fri, 06 Dec 2024 03:14:06 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:05 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 07/15] iio: adc: rzg2l_adc: Simplify the locking scheme in rzg2l_adc_read_raw() Date: Fri, 6 Dec 2024 13:13:29 +0200 Message-Id: <20241206111337.726244-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Simplify the locking scheme in rzg2l_adc_read_raw() by using guard(mutex)(). Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - used guard(mutex)() - adjusted the patch description drivers/iio/adc/rzg2l_adc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 38d4fb014847..953511191eac 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -220,21 +221,21 @@ static int rzg2l_adc_read_raw(struct iio_dev *indio_dev, u8 ch; switch (mask) { - case IIO_CHAN_INFO_RAW: + case IIO_CHAN_INFO_RAW: { if (chan->type != IIO_VOLTAGE) return -EINVAL; - mutex_lock(&adc->lock); + guard(mutex)(&adc->lock); + ch = chan->channel & RZG2L_ADC_CHN_MASK; ret = rzg2l_adc_conversion(indio_dev, adc, ch); - if (ret) { - mutex_unlock(&adc->lock); + if (ret) return ret; - } + *val = adc->last_val[ch]; - mutex_unlock(&adc->lock); return IIO_VAL_INT; + } default: return -EINVAL; From patchwork Fri Dec 6 11:13:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897025 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A69D201006 for ; Fri, 6 Dec 2024 11:14:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483651; cv=none; b=eu5VKpWsbt0EnQFcqAtSdYszpeNxXQ4r8CKsEaRCnILvdDkaOp2evkgRjqW83ymZLTIUxLHqm8NwCZ9fvOp+W3slJRb8VwrOOYTUH+laEfxNKEfSYYHngD8Gbg/L0zZ4QG95OrQRu9bEP8+XVIJcD08ta6nOEpY1yrWl/NNrW1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483651; c=relaxed/simple; bh=a0X4aOYvG3pTfNgIEESajz8KrdCPF4/aLinqArXPrIM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lsyX7wiN28HZ+d7nSKKTDLkTdLxa04jzDbuB9Q6U2dmGZH4Ngt1Gr6cvIpI1VFBrhfdZVZ4TuGqPpUdoc8r8egD1+Dtj8Wp/r7mn8X5LQrxMGpCnchJkve3FithvSbrUHNZwo8FDOzruKhVGxc3VuSydy99rXy1LiHmwjqIKrGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=pgN8r8/z; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="pgN8r8/z" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-aa62f1d2b21so198247666b.1 for ; Fri, 06 Dec 2024 03:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483648; x=1734088448; darn=vger.kernel.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=JcFmoPRqWug/wF9N6rxPklzROiRzJUhH8R20dFRmNrI=; b=pgN8r8/zwM6QCbeVS/nKYXVqlIWc4HYobrPKAgRlsRchnq65qWHTmAfRn1gkIKgNQz YYPRUg/BmEcW0yfhOzPghaZ8BvOSjz14VaiKumjXY+1m/I5U/G3ulCSFZVmtrj9WDwJr A2uAkoZA6MrJTt/KnGwJNmpz35QCk3Azc2KdY1/xUW0Kq7KHbVjZp31yUgLZO0TsHdcj 7IrjROxweNebSkQOibunqR2EFmQnpvfH53BXDd/G+ssXqPegTdQBHeTXiOVcTUyjeWqF 8DxCYvdDaFsu4+bZaru6XgqVsDVdsKLVGKtgygyDB2l/jdC1wR6mFL7BdxZXebuL5rHh zV0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483648; x=1734088448; 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=JcFmoPRqWug/wF9N6rxPklzROiRzJUhH8R20dFRmNrI=; b=QKa7/0S2Al1xbnQ9dyxKEKXBdJqsWnjzNUMLskesN6t78nVYmn3Hx7THSDznJPHNOO pkGrQu+YCGCYSqUvDinQpJy22Nnvpt0wwDEhsaQ/3IRcHoiZkqygh53dlHNKdGbhQWf/ nhePbs/ObKdhuICXEXIFbkdIQRKSbCIPd1V+Ikbfw7T/whvxjN35VHdvjnoNigXPm3xK 3Z9n6zIFx1zYMl5RTdKVOoUPVD3oPAQ5pgJBuhcSkSwX2cLSPkHPpfIdhaH6MZ3RlqBj OzCx526LmN7qfPOU5G20AVsQFj1PtvJlNU5DPwISwUayzZBHmvmhlULU+aVdIbhbonEd X4uQ== X-Forwarded-Encrypted: i=1; AJvYcCX2b7dhAKJ9RWuApKLqd+csvrLOymMCkQipQSV37ksU9NvQpmPP6Lo03mNzZSKTY5v/qOueU2I6oR8=@vger.kernel.org X-Gm-Message-State: AOJu0YwIido9+hMgy4D7uHEZWz08Nyyyyv5fE5EqXsynvvFLbK8Qij+A DqU9pk8eVi4Prh5yX3DoO2/2GPubEqRxYyAwxxS8XRBmMuryHz2ldiW6Dg5WxCw= X-Gm-Gg: ASbGncsxob5Z9xDfOYAd9AvzSJbFH31lEf45lWJLGmxBTbCGhP+Jtk9IgqSC6vA9oky cXRNILzW5Jqlr/69d8pttzjoY21pXizenO3w4URbRWJg8tij4pZGnMtrF3QD/f/FSi4EvtdwCTT mG2Sqt5/DT5zAgM1ZUa9MKQsk46P8YIgAgM94JjI7zQMCjSBDVN6ikZ4m9veDwmPiTDjE17cc3a LbKSeHPLl0yqdJagf3EVzo+nqIuXgVUVWJC0Tsr5pmAFWt/cMBxW/CvHtxhbZapixB1koO8YMO1 N7pi X-Google-Smtp-Source: AGHT+IHiSsJnrO9WOBGpjGpJxD2jcZJI3sgccO1J+MWdvjykKFu0VlpAlkqINSQOhBcrCp7fpOjTGQ== X-Received: by 2002:a17:907:6194:b0:aa6:3e97:f9d8 with SMTP id a640c23a62f3a-aa63e9814ffmr105149766b.54.1733483647971; Fri, 06 Dec 2024 03:14:07 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:07 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 08/15] iio: adc: rzg2l_adc: Enable runtime PM autosuspend support Date: Fri, 6 Dec 2024 13:13:30 +0200 Message-Id: <20241206111337.726244-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Enable runtime PM autosuspend support for the rzg2l_adc driver. With this change, consecutive conversion requests will no longer cause the device to be runtime-enabled/disabled after each request. Instead, the device will transition based on the delay configured by the user. This approach reduces the frequency of hardware register access during runtime PM suspend/resume cycles, thereby saving CPU cycles. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - used a non-zero default autosusped delay - adjusted the patch description to reflect that the default autosuspend delay has been changed drivers/iio/adc/rzg2l_adc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 953511191eac..c3f9f95cdbba 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -208,7 +208,8 @@ static int rzg2l_adc_conversion(struct iio_dev *indio_dev, struct rzg2l_adc *adc rzg2l_adc_start_stop(adc, false); rpm_put: - pm_runtime_put_sync(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -372,7 +373,8 @@ static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) rzg2l_adc_writel(adc, RZG2L_ADM(3), reg); exit_hw_init: - pm_runtime_put_sync(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -410,6 +412,8 @@ static int rzg2l_adc_probe(struct platform_device *pdev) "failed to get/deassert presetn\n"); } + pm_runtime_set_autosuspend_delay(dev, 300); + pm_runtime_use_autosuspend(dev); ret = devm_pm_runtime_enable(dev); if (ret) return ret; From patchwork Fri Dec 6 11:13:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897026 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 905AF1FCF4F for ; Fri, 6 Dec 2024 11:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483654; cv=none; b=YPGKkw978LxIfNj1VZl8NwZcMfQKccWNvwS2r95+k/XTX95ih8B4hci2TX/Tf4P3+UdurxthlyWA2xUWtAlg4KgbtaA3dx9El10soh3OuWrpYFUJXzNnKlua5Oh+gybCiy4D3LXmu8IplsC3O7NOoUYwEEtz0ekp0szQ94tjRM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483654; c=relaxed/simple; bh=3izqxQ+NZjrnOnaD5puhvQqvQxGAUEQY7C3PoRFd4nQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hPoV7zC7axafhNAHs046rZjspOwqjtl2CkHv57hXk+iXLEMIq0N4pq45aisC7LHrZ05mNFh8YWn996IHca/1uM35hPS0fzpEmWmiyHKhSqIIBr+L3TazmIh1doVPCDUvs81xIzC7juEaL7m+DaqNejBbNSOKaQD0ZB0bXfiN07o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=Prgt81NJ; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Prgt81NJ" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-aa539d2b4b2so369942666b.1 for ; Fri, 06 Dec 2024 03:14:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483650; x=1734088450; darn=vger.kernel.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=4RlfVyA4yTuL34Q4V63SBVMJhYDPRvRou52ECLwTzII=; b=Prgt81NJvfhsD+YSAHZBq7FL4/40hho+5QD1gkJq7tCp5KC0ZX7tQTWr2jt9tbBREX 6HpWWQWCpbF5oKmnvj2Z7FPRYVOdYNxHt4r4NPzp2Ud7JzSFLtEnWqoecffSKa2fM2z/ fKfTXxbKpd96VENuqCdKjfR9nDBB+RGcXgedBWuarzKWIoeHcBXyKk2H8LcVuuRmYRwK MnVIEAh8KKLkDUk+oLKuhWoq6/JtbfR2ehLyKZpNJjkHiJ+Z+WBlF0TXNu4v/BDQifMN rYNQRp9549xpZ7+6IY2+lmw9Fo6R6SvHaYegvKplUiaEE9RG7FBo1XncLbjFBa3R5ruv ijNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483650; x=1734088450; 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=4RlfVyA4yTuL34Q4V63SBVMJhYDPRvRou52ECLwTzII=; b=QjLZ2L2ZAijEgO74Q1q7cq1Bcr/8DAS1MSH/uMd2wAYRmHmjr4RILNsDtNT5SZ+CVG jUguXDpHr3sBfxYWgkcF549yRBdxkq+cNLTnzBFogDfwov2TfMbk5NVVg45CnVWSgnxM oc9mtn1rSeFxmIVu7F3FaAb5DPgEoVUyDbbIlTSWgsZ1Ty0BJvVLI1VSLFspEyMhMwLL VqrBbfeYbwlg6NCQ8hjAf3EHw8DTLpYvKfmR7pZHoVyaau/x/cpSg3vaoigEewbeSx1P 101dgVWkanTLTyrra6sEJ5bZg9U08fYYuVFuPAwiS4oFe/4/2kpyOKcnLhpAJQUWT6RZ K5XQ== X-Forwarded-Encrypted: i=1; AJvYcCVaYU5dfUf50iY4CdYhg+qxhKjrc+hJ8xfxyldN5+82MgbReyvF9xWud7xHtO1AMSWimLU6VWsVIt4=@vger.kernel.org X-Gm-Message-State: AOJu0YzbqzgsGQrk31wEUKwrqj8OcxZY31QjqSmmk2PyeSHkPRkoXf+r mohd9oOIv1K+RCxqQiaKIrLwV/DH+4DRKBdQWiPdn7MdNCyluU7zVSmpkbtDZRM= X-Gm-Gg: ASbGncteU6Lr76vXGnRo2e6tfvrTOKgOzJuc2ZGxYWkI8ctq2a7HFtKXRcD/MKGIeJo KqAdAApo5UB5XNnMpPbZX+kQloyFaMAxrMLm28JCJrVqDv3dwmGiGXBNaV+x2XMtdIjfDu8zBB0 3DM3z3u8D2029fRaq/3K1deRFVC+BP1jhDiPadg1VsJtRVR+mhFpucxvXYUhwiCurjoJziBCNe8 +IksyxIDTiQA4oAm9bQEG1gYDp4fG3j2iOuatPJE4CSbxw967xr4H6NR6M2idrZbJmuDglKCVty woJz X-Google-Smtp-Source: AGHT+IGRWEyrB/Y2BmAZc/VqaxiX9x6nR7lPRyQ/O4QYP0ll8ebgAqvzWLGzM2XwBxu7jgcrnJYLzg== X-Received: by 2002:a17:907:7da4:b0:a9a:6c41:50a8 with SMTP id a640c23a62f3a-aa621892191mr682905766b.17.1733483649971; Fri, 06 Dec 2024 03:14:09 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:09 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 09/15] iio: adc: rzg2l_adc: Prepare for the addition of RZ/G3S support Date: Fri, 6 Dec 2024 13:13:31 +0200 Message-Id: <20241206111337.726244-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea The ADC IP available on the RZ/G3S differs slightly from the one found on the RZ/G2L. The identified differences are as follows: - different number of channels (one being used for temperature conversion); consequently, various registers differ - different default sampling periods - the RZ/G3S variant lacks the ADVIC register. To accommodate these differences, the rzg2l_adc driver has been updated by introducing the struct rzg2l_adc_hw_params, which encapsulates the hardware-specific differences between the IP variants. A pointer to an object of type struct rzg2l_adc_hw_params is embedded in struct rzg2l_adc_data. Additionally, the completion member of struct rzg2l_adc_data was relocated to avoid potential padding, if any. The code has been adjusted to utilize hardware-specific parameters stored in the new structure instead of relying on plain macros. The check of chan->channel in rzg2l_adc_read_raw() function, against the driver specific mask was removed as the subsystem should have already been done this before reaching the rzg2l_adc_read_raw() function. Along with it the local variable ch was dropped as chan->channel could be used instead. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - kept the RZG2L_ADC_MAX_CHANNELS as suggested in the review process; along with it, last_val[] is now again statically alocated; code from v1 around last_val has been adjusted to align with the new approach - dropped ch variable from rzg2l_adc_read_raw() and adjusted the patch description to reflect it. drivers/iio/adc/rzg2l_adc.c | 87 +++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 28 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index c3f9f95cdbba..6740912f83c5 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -33,20 +33,15 @@ #define RZG2L_ADM1_MS BIT(2) #define RZG2L_ADM1_BS BIT(4) #define RZG2L_ADM1_EGA_MASK GENMASK(13, 12) -#define RZG2L_ADM2_CHSEL_MASK GENMASK(7, 0) #define RZG2L_ADM3_ADIL_MASK GENMASK(31, 24) #define RZG2L_ADM3_ADCMP_MASK GENMASK(23, 16) -#define RZG2L_ADM3_ADCMP_E FIELD_PREP(RZG2L_ADM3_ADCMP_MASK, 0xe) -#define RZG2L_ADM3_ADSMP_MASK GENMASK(15, 0) #define RZG2L_ADINT 0x20 -#define RZG2L_ADINT_INTEN_MASK GENMASK(7, 0) #define RZG2L_ADINT_CSEEN BIT(16) #define RZG2L_ADINT_INTS BIT(31) #define RZG2L_ADSTS 0x24 #define RZG2L_ADSTS_CSEST BIT(16) -#define RZG2L_ADSTS_INTST_MASK GENMASK(7, 0) #define RZG2L_ADIVC 0x28 #define RZG2L_ADIVC_DIVADC_MASK GENMASK(8, 0) @@ -57,12 +52,27 @@ #define RZG2L_ADCR(n) (0x30 + ((n) * 0x4)) #define RZG2L_ADCR_AD_MASK GENMASK(11, 0) -#define RZG2L_ADSMP_DEFAULT_SAMPLING 0x578 - #define RZG2L_ADC_MAX_CHANNELS 8 -#define RZG2L_ADC_CHN_MASK 0x7 #define RZG2L_ADC_TIMEOUT usecs_to_jiffies(1 * 4) +/** + * struct rzg2l_adc_hw_params - ADC hardware specific parameters + * @default_adsmp: default ADC sampling period (see ADM3 register) + * @adsmp_mask: ADC sampling period mask (see ADM3 register) + * @adint_inten_mask: conversion end interrupt mask (see ADINT register) + * @default_adcmp: default ADC cmp (see ADM3 register) + * @num_channels: number of supported channels + * @adivc: specifies if ADVIC register is available + */ +struct rzg2l_adc_hw_params { + u16 default_adsmp; + u16 adsmp_mask; + u16 adint_inten_mask; + u8 default_adcmp; + u8 num_channels; + bool adivc; +}; + struct rzg2l_adc_data { const struct iio_chan_spec *channels; u8 num_channels; @@ -72,8 +82,9 @@ struct rzg2l_adc { void __iomem *base; struct reset_control *presetn; struct reset_control *adrstn; - struct completion completion; const struct rzg2l_adc_data *data; + const struct rzg2l_adc_hw_params *hw_params; + struct completion completion; struct mutex lock; u16 last_val[RZG2L_ADC_MAX_CHANNELS]; }; @@ -154,6 +165,7 @@ static void rzg2l_set_trigger(struct rzg2l_adc *adc) static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch) { + const struct rzg2l_adc_hw_params *hw_params = adc->hw_params; u32 reg; if (rzg2l_adc_readl(adc, RZG2L_ADM(0)) & RZG2L_ADM0_ADBSY) @@ -163,7 +175,7 @@ static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch) /* Select analog input channel subjected to conversion. */ reg = rzg2l_adc_readl(adc, RZG2L_ADM(2)); - reg &= ~RZG2L_ADM2_CHSEL_MASK; + reg &= ~GENMASK(hw_params->num_channels - 1, 0); reg |= BIT(ch); rzg2l_adc_writel(adc, RZG2L_ADM(2), reg); @@ -175,7 +187,7 @@ static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch) */ reg = rzg2l_adc_readl(adc, RZG2L_ADINT); reg &= ~RZG2L_ADINT_INTS; - reg &= ~RZG2L_ADINT_INTEN_MASK; + reg &= ~hw_params->adint_inten_mask; reg |= (RZG2L_ADINT_CSEEN | BIT(ch)); rzg2l_adc_writel(adc, RZG2L_ADINT, reg); @@ -184,6 +196,7 @@ static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch) static int rzg2l_adc_conversion(struct iio_dev *indio_dev, struct rzg2l_adc *adc, u8 ch) { + const struct rzg2l_adc_hw_params *hw_params = adc->hw_params; struct device *dev = indio_dev->dev.parent; int ret; @@ -201,7 +214,7 @@ static int rzg2l_adc_conversion(struct iio_dev *indio_dev, struct rzg2l_adc *adc if (!wait_for_completion_timeout(&adc->completion, RZG2L_ADC_TIMEOUT)) { rzg2l_adc_writel(adc, RZG2L_ADINT, - rzg2l_adc_readl(adc, RZG2L_ADINT) & ~RZG2L_ADINT_INTEN_MASK); + rzg2l_adc_readl(adc, RZG2L_ADINT) & ~hw_params->adint_inten_mask); ret = -ETIMEDOUT; } @@ -219,7 +232,6 @@ static int rzg2l_adc_read_raw(struct iio_dev *indio_dev, { struct rzg2l_adc *adc = iio_priv(indio_dev); int ret; - u8 ch; switch (mask) { case IIO_CHAN_INFO_RAW: { @@ -228,12 +240,11 @@ static int rzg2l_adc_read_raw(struct iio_dev *indio_dev, guard(mutex)(&adc->lock); - ch = chan->channel & RZG2L_ADC_CHN_MASK; - ret = rzg2l_adc_conversion(indio_dev, adc, ch); + ret = rzg2l_adc_conversion(indio_dev, adc, chan->channel); if (ret) return ret; - *val = adc->last_val[ch]; + *val = adc->last_val[chan->channel]; return IIO_VAL_INT; } @@ -258,6 +269,7 @@ static const struct iio_info rzg2l_adc_iio_info = { static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id) { struct rzg2l_adc *adc = dev_id; + const struct rzg2l_adc_hw_params *hw_params = adc->hw_params; unsigned long intst; u32 reg; int ch; @@ -270,11 +282,11 @@ static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id) return IRQ_HANDLED; } - intst = reg & RZG2L_ADSTS_INTST_MASK; + intst = reg & GENMASK(hw_params->num_channels - 1, 0); if (!intst) return IRQ_NONE; - for_each_set_bit(ch, &intst, RZG2L_ADC_MAX_CHANNELS) + for_each_set_bit(ch, &intst, hw_params->num_channels) adc->last_val[ch] = rzg2l_adc_readl(adc, RZG2L_ADCR(ch)) & RZG2L_ADCR_AD_MASK; /* clear the channel interrupt */ @@ -287,6 +299,7 @@ static irqreturn_t rzg2l_adc_isr(int irq, void *dev_id) static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l_adc *adc) { + const struct rzg2l_adc_hw_params *hw_params = adc->hw_params; struct iio_chan_spec *chan_array; struct rzg2l_adc_data *data; unsigned int channel; @@ -302,7 +315,7 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l if (!num_channels) return dev_err_probe(&pdev->dev, -ENODEV, "no channel children\n"); - if (num_channels > RZG2L_ADC_MAX_CHANNELS) + if (num_channels > hw_params->num_channels) return dev_err_probe(&pdev->dev, -EINVAL, "num of channel children out of range\n"); chan_array = devm_kcalloc(&pdev->dev, num_channels, sizeof(*chan_array), @@ -316,7 +329,7 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l if (ret) return ret; - if (channel >= RZG2L_ADC_MAX_CHANNELS) + if (channel >= hw_params->num_channels) return -EINVAL; chan_array[i].type = IIO_VOLTAGE; @@ -336,6 +349,7 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) { + const struct rzg2l_adc_hw_params *hw_params = adc->hw_params; u32 reg; int ret; @@ -353,11 +367,13 @@ static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) if (ret) goto exit_hw_init; - /* Only division by 4 can be set */ - reg = rzg2l_adc_readl(adc, RZG2L_ADIVC); - reg &= ~RZG2L_ADIVC_DIVADC_MASK; - reg |= RZG2L_ADIVC_DIVADC_4; - rzg2l_adc_writel(adc, RZG2L_ADIVC, reg); + if (hw_params->adivc) { + /* Only division by 4 can be set */ + reg = rzg2l_adc_readl(adc, RZG2L_ADIVC); + reg &= ~RZG2L_ADIVC_DIVADC_MASK; + reg |= RZG2L_ADIVC_DIVADC_4; + rzg2l_adc_writel(adc, RZG2L_ADIVC, reg); + } /* * Setup AMD3 @@ -368,8 +384,10 @@ static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) reg = rzg2l_adc_readl(adc, RZG2L_ADM(3)); reg &= ~RZG2L_ADM3_ADIL_MASK; reg &= ~RZG2L_ADM3_ADCMP_MASK; - reg &= ~RZG2L_ADM3_ADSMP_MASK; - reg |= (RZG2L_ADM3_ADCMP_E | RZG2L_ADSMP_DEFAULT_SAMPLING); + reg &= ~hw_params->adsmp_mask; + reg |= FIELD_PREP(RZG2L_ADM3_ADCMP_MASK, hw_params->default_adcmp) | + hw_params->default_adsmp; + rzg2l_adc_writel(adc, RZG2L_ADM(3), reg); exit_hw_init: @@ -392,6 +410,10 @@ static int rzg2l_adc_probe(struct platform_device *pdev) adc = iio_priv(indio_dev); + adc->hw_params = device_get_match_data(dev); + if (!adc->hw_params || adc->hw_params->num_channels > RZG2L_ADC_MAX_CHANNELS) + return -EINVAL; + ret = rzg2l_adc_parse_properties(pdev, adc); if (ret) return ret; @@ -444,8 +466,17 @@ static int rzg2l_adc_probe(struct platform_device *pdev) return devm_iio_device_register(dev, indio_dev); } +static const struct rzg2l_adc_hw_params rzg2l_hw_params = { + .num_channels = 8, + .default_adcmp = 0xe, + .default_adsmp = 0x578, + .adsmp_mask = GENMASK(15, 0), + .adint_inten_mask = GENMASK(7, 0), + .adivc = true +}; + static const struct of_device_id rzg2l_adc_match[] = { - { .compatible = "renesas,rzg2l-adc",}, + { .compatible = "renesas,rzg2l-adc", .data = &rzg2l_hw_params }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, rzg2l_adc_match); From patchwork Fri Dec 6 11:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897027 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27D3D201246 for ; Fri, 6 Dec 2024 11:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483655; cv=none; b=LaZl2v2twf1DbGNgN5Ki7BhLxWjkD1un/+rIWnEOIhES/wsHaGdsiB7s41DMl2vONMxTC7P5yuKGiwjIX3IfbsONuGbWg9usuxcxovRXm6ke05SsmEV+uaYAPYilP8JQ0bovZCft5wJxscMsyRsnj3HbyhyN5PpL6+uvkW3aaVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483655; c=relaxed/simple; bh=wxZRPXX+wShOhw7KsuKigJkq79dPZO6Cla2zUo3+n2w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N/bWXA62tVxteVTTxVimSAVW7dNRK76hxn+llp+hV7x1BWTKmWNGtevPDdoofnUTIptwvEOMt3L3Cvg+3BtZ+ynpb2pfoKofM+nS8+0Kayc7v7YOJ1wyaNseDryQpXIk23+UOQhEKS7exkUs8XKZv6AefNFqpeusQDX2m6iWbgg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=XDNyaHnU; arc=none smtp.client-ip=209.85.208.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="XDNyaHnU" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5d10f713ef0so5490120a12.0 for ; Fri, 06 Dec 2024 03:14:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483652; x=1734088452; darn=vger.kernel.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=GeWsRAgiOnQ9J+Bi5jRmNn74NPnMNokWHPaSe/KrAuI=; b=XDNyaHnUqoOeGNHVbu8DPm6yKi1PfeEfY+2ABhMwxpkcMqOv7aypGcIPBX/qG/YO2f eYF+w1gxf30Ey/RYGFwVbwlnJa+FsLtJjIksc+aWxrUXK06zIWT9073CPl00f7UqJitb eLA+Ftn6FnsD0bcHjTuR1aBQdL5Z+T3TTNbgJNFSz/kOhClSsu7REH662eFZJ677K4To EOXluF3CkoTGjUmPrp/cDlp8irN15BecyeE/EMXNpOT98Pz+mXrNmj2PaqApBPGo1tCG 5yVF0r8hO6XYaD06DSYVHyLG8HSFVWK7beVehy8MEWUVbFUepR5zCYPhXzfjCxH9CHbi VH+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483652; x=1734088452; 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=GeWsRAgiOnQ9J+Bi5jRmNn74NPnMNokWHPaSe/KrAuI=; b=qKlHZGzNB5sXc11TtUI3H5utlHi2IM0kc7aI0TCAQHik7ELOIyW6U33v3FYHNkh/bl Xg+PVEnkR4ge/j8XiIboYnLeyWO3WZn+qdc88kF+hzDd2bvpjDoBAbUYzylXtEKx67K7 +5+cA7G6V3P58nIS8Y3Lq1ekRk6Mj2ke4Slu+XBH2QdHsbgBK3mSznwO5UsrzbYxD1pI BcwEDFbtnVJdV3gGgMBgqKZ9Y4usgMVAbEz8EIIkA9dH3aP4F/hVwSYnUXoVBX1I+3P1 jOVgxCeRnAndxyiDH3NIRYukX1AxwxZR+XKmrS7SpQuJ7mV3fVTl02cdSh/ZY4Zvolxs R6dw== X-Forwarded-Encrypted: i=1; AJvYcCXH+8uL4I4g6Yp+A66HAy/dblKTEP+7Zlved6WsXnxPjfJTl+K4e7Zz+sOVazc1DZ4Ux9cGhjlkLjw=@vger.kernel.org X-Gm-Message-State: AOJu0Yx90iZV+9n4ar+9MJDddbRUtnnSaYvDtXW/QWZNg5vnGUuHaBNp uz7vMLb5+OQOtZv20wCBnl8Jd4YFNVe1evmJ1zzd6z2e+lZ34pGYBEcXhd5wHMY= X-Gm-Gg: ASbGncsWoPq621NdRfvvzwE5H1dRkVAbmfkEE+W3FlO0id8jn4MQSHCDDXPDLF3BA/X havSZnpU5TL9jTeAODwJhFVIIy4etvsUgc8BRELxB1d02jlHiqn1grAfgnIPDhiGCNoYxBows5Y SjKx3/OID97D0dvGXrlo3gZiEIrJ2A+8EwBkaJ8UN5iUuB56jAz8AiKwfoc/NT5kyepX3Lt8jKs TE5wlydDrXbZPfnoVSZVxOv8Gaq9OZwu6VYCTgDVYEvPan26jp2y9SThv8/or9sTaNXu8q8a7Oa VyWY X-Google-Smtp-Source: AGHT+IHTQu8XnR/9fX757rUtPWhGNIBbj7HW1RmDso9os/gZdEm8EVXl76Iicy9Ae0iw5PO3pdZnrQ== X-Received: by 2002:a17:907:2d0f:b0:aa5:ef1c:9dfc with SMTP id a640c23a62f3a-aa62032df68mr624741666b.8.1733483651596; Fri, 06 Dec 2024 03:14:11 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:11 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 10/15] iio: adc: rzg2l_adc: Add support for channel 8 Date: Fri, 6 Dec 2024 13:13:32 +0200 Message-Id: <20241206111337.726244-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea The ADC on the Renesas RZ/G3S SoC includes an additional channel (channel 8) dedicated to reading temperature values from the Thermal Sensor Unit (TSU). There is a direct in-SoC connection between the ADC and TSU IPs. To read the temperature reported by the TSU, a different sampling rate (compared to channels 0-7) must be configured in the ADM3 register. The rzg2l_adc driver has been updated to support reading the TSU temperature. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - adjusted the RZG2L_ADC_MAX_CHANNELS - introduced rzg2l_adc_ch_to_adsmp_index() and used it accordingly - made the IIO_TEMP channel as raw channel as requested in the review process. I also realized having it as scale channel is wrong as the ADC doesn't actually report a temperature but a raw value that is then converted to a temperature with the help of the TSU (Thermal Sensor Unit) driver. Code from the TSU driver (not yet published) that reads the TSU sensor through the ADC and coverts the raw value to a temperature value is as follows: // ... #define TSU_READ_STEPS 8 /* Default calibration values, if FUSE values are missing */ #define SW_CALIB0_VAL 1297 #define SW_CALIB1_VAL 751 #define MCELSIUS(temp) (temp * MILLIDEGREE_PER_DEGREE) struct rzg3s_thermal_priv { void __iomem *base; struct device *dev; struct thermal_zone_device *tz; struct reset_control *rstc; struct iio_channel *channel; u16 calib0; u16 calib1; }; // ... static int rzg3s_thermal_get_temp(struct thermal_zone_device *tz, int *temp) { struct rzg3s_thermal_priv *priv = thermal_zone_device_priv(tz); struct device *dev = priv->dev; u32 ts_code_ave = 0; int ret, val; ret = pm_runtime_resume_and_get(dev); if (ret) return ret; for (u8 i = 0; i < TSU_READ_STEPS; i++) { ret = iio_read_channel_raw(priv->channel, &val); if (ret < 0) goto rpm_put; ts_code_ave += val; /* * According to HW manual (section 40.4.4 Procedure for Measuring the Temperature) * we need to wait here at leat 3us. */ usleep_range(5, 10); } ret = 0; ts_code_ave = DIV_ROUND_CLOSEST(ts_code_ave, TSU_READ_STEPS); /* * According to HW manual (section 40.4.4 Procedure for Measuring the Temperature) * the formula to compute the temperature is as follows; * * Tj = (ts_code_ave - priv->calib0) * (165 / (priv->calib0 - priv->calib1)) - 40 */ *temp = DIV_ROUND_CLOSEST_ULL(((u64)(ts_code_ave - priv->calib1) * 165), (priv->calib0 - priv->calib1)) - 40; /* Round it up to 0.5 degrees Celsius and report it in Mili Celsius. */ *temp = roundup(MCELSIUS(*temp), 500); rpm_put: pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); return ret; } // ... drivers/iio/adc/rzg2l_adc.c | 62 ++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 6740912f83c5..e8dbc5dfbea1 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -52,12 +52,13 @@ #define RZG2L_ADCR(n) (0x30 + ((n) * 0x4)) #define RZG2L_ADCR_AD_MASK GENMASK(11, 0) -#define RZG2L_ADC_MAX_CHANNELS 8 +#define RZG2L_ADC_MAX_CHANNELS 9 #define RZG2L_ADC_TIMEOUT usecs_to_jiffies(1 * 4) /** * struct rzg2l_adc_hw_params - ADC hardware specific parameters - * @default_adsmp: default ADC sampling period (see ADM3 register) + * @default_adsmp: default ADC sampling period (see ADM3 register); index 0 is + * used for voltage channels, index 1 is used for temperature channel * @adsmp_mask: ADC sampling period mask (see ADM3 register) * @adint_inten_mask: conversion end interrupt mask (see ADINT register) * @default_adcmp: default ADC cmp (see ADM3 register) @@ -65,7 +66,7 @@ * @adivc: specifies if ADVIC register is available */ struct rzg2l_adc_hw_params { - u16 default_adsmp; + u16 default_adsmp[2]; u16 adsmp_mask; u16 adint_inten_mask; u8 default_adcmp; @@ -89,15 +90,26 @@ struct rzg2l_adc { u16 last_val[RZG2L_ADC_MAX_CHANNELS]; }; -static const char * const rzg2l_adc_channel_name[] = { - "adc0", - "adc1", - "adc2", - "adc3", - "adc4", - "adc5", - "adc6", - "adc7", +/** + * struct rzg2l_adc_channel - ADC channel descriptor + * @name: ADC channel name + * @type: ADC channel type + */ +struct rzg2l_adc_channel { + const char * const name; + enum iio_chan_type type; +}; + +static const struct rzg2l_adc_channel rzg2l_adc_channels[] = { + { "adc0", IIO_VOLTAGE }, + { "adc1", IIO_VOLTAGE }, + { "adc2", IIO_VOLTAGE }, + { "adc3", IIO_VOLTAGE }, + { "adc4", IIO_VOLTAGE }, + { "adc5", IIO_VOLTAGE }, + { "adc6", IIO_VOLTAGE }, + { "adc7", IIO_VOLTAGE }, + { "adc8", IIO_TEMP }, }; static unsigned int rzg2l_adc_readl(struct rzg2l_adc *adc, u32 reg) @@ -163,9 +175,18 @@ static void rzg2l_set_trigger(struct rzg2l_adc *adc) rzg2l_adc_writel(adc, RZG2L_ADM(1), reg); } +static u8 rzg2l_adc_ch_to_adsmp_index(u8 ch) +{ + if (rzg2l_adc_channels[ch].type == IIO_VOLTAGE) + return 0; + + return 1; +} + static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch) { const struct rzg2l_adc_hw_params *hw_params = adc->hw_params; + u8 index = rzg2l_adc_ch_to_adsmp_index(ch); u32 reg; if (rzg2l_adc_readl(adc, RZG2L_ADM(0)) & RZG2L_ADM0_ADBSY) @@ -179,6 +200,11 @@ static int rzg2l_adc_conversion_setup(struct rzg2l_adc *adc, u8 ch) reg |= BIT(ch); rzg2l_adc_writel(adc, RZG2L_ADM(2), reg); + reg = rzg2l_adc_readl(adc, RZG2L_ADM(3)); + reg &= ~hw_params->adsmp_mask; + reg |= hw_params->default_adsmp[index]; + rzg2l_adc_writel(adc, RZG2L_ADM(3), reg); + /* * Setup ADINT * INTS[31] - Select pulse signal @@ -235,7 +261,7 @@ static int rzg2l_adc_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: { - if (chan->type != IIO_VOLTAGE) + if (chan->type != IIO_VOLTAGE && chan->type != IIO_TEMP) return -EINVAL; guard(mutex)(&adc->lock); @@ -258,7 +284,7 @@ static int rzg2l_adc_read_label(struct iio_dev *iio_dev, const struct iio_chan_spec *chan, char *label) { - return sysfs_emit(label, "%s\n", rzg2l_adc_channel_name[chan->channel]); + return sysfs_emit(label, "%s\n", rzg2l_adc_channels[chan->channel].name); } static const struct iio_info rzg2l_adc_iio_info = { @@ -332,11 +358,11 @@ static int rzg2l_adc_parse_properties(struct platform_device *pdev, struct rzg2l if (channel >= hw_params->num_channels) return -EINVAL; - chan_array[i].type = IIO_VOLTAGE; + chan_array[i].type = rzg2l_adc_channels[channel].type; chan_array[i].indexed = 1; chan_array[i].channel = channel; chan_array[i].info_mask_separate = BIT(IIO_CHAN_INFO_RAW); - chan_array[i].datasheet_name = rzg2l_adc_channel_name[channel]; + chan_array[i].datasheet_name = rzg2l_adc_channels[channel].name; i++; } @@ -386,7 +412,7 @@ static int rzg2l_adc_hw_init(struct device *dev, struct rzg2l_adc *adc) reg &= ~RZG2L_ADM3_ADCMP_MASK; reg &= ~hw_params->adsmp_mask; reg |= FIELD_PREP(RZG2L_ADM3_ADCMP_MASK, hw_params->default_adcmp) | - hw_params->default_adsmp; + hw_params->default_adsmp[0]; rzg2l_adc_writel(adc, RZG2L_ADM(3), reg); @@ -469,7 +495,7 @@ static int rzg2l_adc_probe(struct platform_device *pdev) static const struct rzg2l_adc_hw_params rzg2l_hw_params = { .num_channels = 8, .default_adcmp = 0xe, - .default_adsmp = 0x578, + .default_adsmp = { 0x578 }, .adsmp_mask = GENMASK(15, 0), .adint_inten_mask = GENMASK(7, 0), .adivc = true From patchwork Fri Dec 6 11:13:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897028 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF8C2202C29 for ; Fri, 6 Dec 2024 11:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483656; cv=none; b=CpL+RQmljbDr/aWrGhCTM6+NjDkMQBQgk87VUOWIUeiAm6U0fUGRviCtLtGeo9M0sWJdNS7MQ5Pb8o7F+Xi4mThEc8+gTFDxtKWTLHhQ0reUvO/7EDhBbHDSd64tnQixvwjAG+7s7gC9qCmox8FGp0Wmfz1OmeJ18aYTUiXFER8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483656; c=relaxed/simple; bh=fiQmPOGrFM1sT1OFzrZ1mHt7tw1wgM6W+Xfd0aJucl0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iIOLHIZiJ7R1PXu4Z30Uf19nYU9y2z4HsjwPXHRbP+Av9VndDjqf4L6AHV2nMMEbpJld9ulKWOyu6tjxrr7240zyVp9RRsWQ4eUt016nzrUD959ZRcBWRCEoIdHEefQX58HTGSkHEjRzzOlT6O+TfyxtJ9GsvXlNLKkEIFDxxxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=RlVFnxWX; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="RlVFnxWX" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-385e1f12c82so1611423f8f.2 for ; Fri, 06 Dec 2024 03:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483653; x=1734088453; darn=vger.kernel.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=4G1+H4vCuAFYlF6vDclbc4UqdYRAmFagMT67tI+psAM=; b=RlVFnxWXp+EbulnFE5rQyswB6EXsnGumjjxC9xclRMpnXSTSHk5RB5Auv4T3qcKQ4t UwXtSKluyv1XPIb5FCeq+iXFeh6fWoKBK5j8c2j/hBgItksEWjI6/OCU3S0chdUpqz0z Yl6/Lymb6P9bRqZ78GHLzf44c26mp7WxsLLDXiYqx5AcgBXOsUgy5EGx+G6aKLcSuv/i RsQQDJ03Pcywb2AeAFpYbTpMuq0245cCauAPHL2wHikZ0aNJf/ya4kxn3yQbLx/gYXWE bSsj6sgxrcG6FMQOhVd9bnSgx23W6Wt4Nkw5r5SctWbSj5t8T7rdWy1oRph3O0vjAQcw 5g2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483653; x=1734088453; 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=4G1+H4vCuAFYlF6vDclbc4UqdYRAmFagMT67tI+psAM=; b=gAilD/KWCLWv5uEipYciE/LYUPbhe00mg0DA6IFMTjrMTnLW8kfg9KDKJtH6aa2Fov gmEGmZBHJouk03ysMH+Qc7A7PloAXkiIz6rG0NBDIVCqKJ9rFBbiWfCZh849Qoa8W7QN faNatU59Ad5SNsux0nudXMtadSVq9BmcTzLdkU3cdUGxUzZVpLq3aNyY7VVmMihRpgjs Sv3RXmyPnueMoIAcsay4FvjGA/GsGo0/Sx/ZxU9TY9fUOk1NFaWmBM+EW7wQtOF/xD1l 98FnKrwm6KzcUYhOFH/ASyuQuENsirdBrhwG3+TNKM3NmXixKmj8dzcMA9UMswSbOeJf iuuQ== X-Forwarded-Encrypted: i=1; AJvYcCVGALaTWr4GcYcLG1OgDZ7rnPPFCHKjjVhcRsnAjdPelCS1jLLQE+0BlThCq53zvzrZuP75me1wPo4=@vger.kernel.org X-Gm-Message-State: AOJu0Yxk2w5dtDwu3W5O3Mwg0EIHQ6704j5Ntl30c56NLBixpd40Qxm2 3ELMGzhzNBmb0orKT9xAC3PuZ1sbmpIWb4sRSyLEqK8cxt7+kBueTKpeD6Vni1w= X-Gm-Gg: ASbGnctEVmEkNa/85rQAWWy0OzSj6yDjMfw2AuDCR6D8QwLKdusq+Fgvd+flJSh6Q8o HYcbGCyubToh8ULc0D1cWODMLTCvVaeCOP+It7pg35/QYjidrwnzCHPr/3yFO+zlWk4bOrqjf6C OsKYeCmRMQY0PBnbdeTKF6bEfNLiWo8PW9p6c8NYjbx0pgiuF0Hd37VdcXODlmYg9rLulwwZTvf ZMliBb/S4EXFESI+9VTb1dms0oxEBW5VwHI52UltWMqddVb64wlsTLgdm0x1VUWv5Cr73UUI5uU k1Hk X-Google-Smtp-Source: AGHT+IEXTKNP4MKWcbf/JA1+bXvtEWlNT3ImVzjM+DDONN2Br3jW+udfgrQ804DeDzabWUv7DT92fA== X-Received: by 2002:a5d:47af:0:b0:385:e5dc:e285 with SMTP id ffacd0b85a97d-3862b3e4f43mr1602093f8f.58.1733483653344; Fri, 06 Dec 2024 03:14:13 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:12 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 11/15] iio: adc: rzg2l_adc: Add suspend/resume support Date: Fri, 6 Dec 2024 13:13:33 +0200 Message-Id: <20241206111337.726244-12-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea The Renesas RZ/G3S SoC features a power-saving mode where power to most of the SoC components is turned off, including the ADC IP. Suspend/resume support has been added to the rzg2l_adc driver to restore functionality after resuming from this power-saving mode. During suspend, the ADC resets are asserted, and the ADC is powered down. On resume, the ADC resets are de-asserted, the hardware is re-initialized, and the ADC power is restored using the runtime PM APIs. Signed-off-by: Claudiu Beznea Reviewed-by: Lad Prabhakar --- Changes in v2: - none drivers/iio/adc/rzg2l_adc.c | 70 +++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index e8dbc5dfbea1..2a911269a358 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -88,6 +88,7 @@ struct rzg2l_adc { struct completion completion; struct mutex lock; u16 last_val[RZG2L_ADC_MAX_CHANNELS]; + bool was_rpm_active; }; /** @@ -527,8 +528,77 @@ static int rzg2l_adc_pm_runtime_resume(struct device *dev) return 0; } +static int rzg2l_adc_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct rzg2l_adc *adc = iio_priv(indio_dev); + struct reset_control_bulk_data resets[] = { + { .rstc = adc->presetn }, + { .rstc = adc->adrstn }, + }; + int ret; + + if (pm_runtime_suspended(dev)) { + adc->was_rpm_active = false; + } else { + ret = pm_runtime_force_suspend(dev); + if (ret) + return ret; + adc->was_rpm_active = true; + } + + ret = reset_control_bulk_assert(ARRAY_SIZE(resets), resets); + if (ret) + goto rpm_restore; + + return 0; + +rpm_restore: + if (adc->was_rpm_active) + pm_runtime_force_resume(dev); + + return ret; +} + +static int rzg2l_adc_resume(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct rzg2l_adc *adc = iio_priv(indio_dev); + struct reset_control_bulk_data resets[] = { + { .rstc = adc->adrstn }, + { .rstc = adc->presetn }, + }; + int ret; + + ret = reset_control_bulk_deassert(ARRAY_SIZE(resets), resets); + if (ret) + return ret; + + if (adc->was_rpm_active) { + ret = pm_runtime_force_resume(dev); + if (ret) + goto resets_restore; + } + + ret = rzg2l_adc_hw_init(dev, adc); + if (ret) + goto rpm_restore; + + return 0; + +rpm_restore: + if (adc->was_rpm_active) { + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + } +resets_restore: + reset_control_bulk_assert(ARRAY_SIZE(resets), resets); + return ret; +} + static const struct dev_pm_ops rzg2l_adc_pm_ops = { RUNTIME_PM_OPS(rzg2l_adc_pm_runtime_suspend, rzg2l_adc_pm_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(rzg2l_adc_suspend, rzg2l_adc_resume) }; static struct platform_driver rzg2l_adc_driver = { From patchwork Fri Dec 6 11:13:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897029 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17F84202F7A for ; Fri, 6 Dec 2024 11:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483659; cv=none; b=d/kpf9SjLai4SnNoeZCIO6UY0nHhLXGlysFhYRdibjOhdcKHoTjnEe8qN5ChMM90ucXQ9ygSrfUaV/zcfVn1huAm7UyWajx1rvJCjlHg+6vIRgbOAZajW2n0NZKlcOdt+M/qSO0rM0cocBcEp1heiOf9KxBlfMVCteZPTfexXYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483659; c=relaxed/simple; bh=yHXEczmr3zgBN9Y5LQq53zyVDIkVuwqZazKuyqw+yEw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ait6YAQpAnovi40iuQgU1mOUMrUD3WS0MM7D2f2v7v9Bvw1Z5+Jc6rR5qXLJwcwFhW+EbHAkVv1x+WrTx57WObS6XB41dYA4P7Zg9hSKXQf7YTxlZ7PeXJz7RB7PIhqh3+pxF0fPDfRqpKCVVCCuppEDpa25emHGDGPokwqBMdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=RxSNxfTk; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="RxSNxfTk" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a9f1c590ecdso221722766b.1 for ; Fri, 06 Dec 2024 03:14:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483655; x=1734088455; darn=vger.kernel.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=ztquiO5zqo8/ypj6kpM7FV/n638PGdmNV83SwxwWZys=; b=RxSNxfTkdhKEMGKm1wiBlmyaeKNCwrVugZWsDZ8efNvBqvnpEiTOVOQY0zoKqVUspG pgEmNRfFfZQx20TO5Sk4w6ECbuKTUtLzWP+hwITACcHbvH8rPj6DpQ3UnYXdI+o5b7i3 DHS5Ad/SxxExKECRJoq2hyGX+HOw3FXbJNiYGTSH+y/8Yua2nNcxVu0I/u4nVLkQiF2K y9pNfhZvB5avNXkVneN5RWM4ypD3aIRDIJm1nX2KHYal5GCjWTn5rCboa5HquZ3sZkRC ORekgKAQd6oSVSzarRQpCLs74579Pylv1tLDYrYG8aNbi9o4S2NIK4MKQnD2DN9GxYfv cS4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483655; x=1734088455; 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=ztquiO5zqo8/ypj6kpM7FV/n638PGdmNV83SwxwWZys=; b=p4Uci8BRgwiYymDF/5BJPnu5LnxWIH3Ao3rkwodOs2/9yXZB9p69Dussw3BV4vuG+o PbAGEhtEqKThtN3vRILJ2eIexmsdzE3mv2YQv8EEJM7cd0lzEcr/6FcXDY3WjeoPbxUP Z+YM8WbIhMGSojwiNa4iJNf8Yxv0itlgwvKcilqE2Q7kfgSQ4fupsFiJHd0qn8wsbQ2K iSLJjdl7j48yiFfxk055w+T6/o4cWP1R9AFkkxHs/uT3OFT/gdib7uYQdyXB8Gl3SegP 1nW6mqcjyzqhW8iZE2L6ZP2GppuiQ2D7Tl2g1p7jEnz9Dbfenj4f70mq8NC8X0+NkfOx piQA== X-Forwarded-Encrypted: i=1; AJvYcCWm7X3Vit5AJxvIB7NqAMwV+8J0HL2+6dedEGAgqQMuAewHxdvotXEnXvBPgxP+9S4ttoIketwzJNE=@vger.kernel.org X-Gm-Message-State: AOJu0YzjdWyJpnpVUp80DjtDhxEuntSOSBisXIPsgO/rYLdWhg+8dY6w V6RHmYRGpqTPgjWG95oIWJV3OZlM4WtFRprrT0y10plNZ4PufwT30rFHfBav/pA= X-Gm-Gg: ASbGncsy7GcILcDrTPAmbga8KPAp+NcSsmBQfxEF+chm6jDOGnMRdlOu9TXz9W1KtjH QXkd607W94z5S6aD9ki9dMJA70e6PIxF4UfPbfDrLSxPs/wet4DC/CDEPQhTc8zTowUQVc7fmax 2pbqsdEDlr+D29kP4ZDkpwraznm4c7jqvxv381uxqbnD9d5zdMrA2YdDVjQn47ht3XivoPi2AwH q1rkgrD78bEH588XurETAq2oYw+6w1VBvOXMAd7/sPf/umexJfCu9SFyLn3edwJfi5exz9roHru KM1yDmAI X-Google-Smtp-Source: AGHT+IEvXec05NePap0xg2+L8yTjn/PbPq51j1Lf2h7n3v46RbGZ/jBjPtqf7h5Sg7tKTHnIWh1xJA== X-Received: by 2002:a17:906:30cc:b0:aa6:2018:8741 with SMTP id a640c23a62f3a-aa639fa2ce9mr196485666b.7.1733483655271; Fri, 06 Dec 2024 03:14:15 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:14 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea , Conor Dooley Subject: [PATCH v2 12/15] dt-bindings: iio: adc: renesas,rzg2l-adc: Document RZ/G3S SoC Date: Fri, 6 Dec 2024 13:13:34 +0200 Message-Id: <20241206111337.726244-13-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Document the ADC IP available on the RZ/G3S SoC. The ADC IP on the RZ/G3S differs slightly from the one found on the RZ/G2L. The identified differences are as follows: - different number of channels (one being used for temperature conversion); consequently, various registers differ; the temperature channel support was not available for the RZ/G2L variant; the #io-channel-cells property was added to be able to request the temperature channel from the thermal driver - different default sampling periods - the RZ/G3S variant lacks the ADVIC register. Acked-by: Conor Dooley Signed-off-by: Claudiu Beznea --- Changes in v2: - collected tags .../bindings/iio/adc/renesas,rzg2l-adc.yaml | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/renesas,rzg2l-adc.yaml b/Documentation/devicetree/bindings/iio/adc/renesas,rzg2l-adc.yaml index ba86c7b7d622..40341d541726 100644 --- a/Documentation/devicetree/bindings/iio/adc/renesas,rzg2l-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/renesas,rzg2l-adc.yaml @@ -17,12 +17,15 @@ description: | properties: compatible: - items: - - enum: - - renesas,r9a07g043-adc # RZ/G2UL and RZ/Five - - renesas,r9a07g044-adc # RZ/G2L - - renesas,r9a07g054-adc # RZ/V2L - - const: renesas,rzg2l-adc + oneOf: + - items: + - enum: + - renesas,r9a07g043-adc # RZ/G2UL and RZ/Five + - renesas,r9a07g044-adc # RZ/G2L + - renesas,r9a07g054-adc # RZ/V2L + - const: renesas,rzg2l-adc + - items: + - const: renesas,r9a08g045-adc # RZ/G3S reg: maxItems: 1 @@ -57,6 +60,9 @@ properties: '#size-cells': const: 0 + "#io-channel-cells": + const: 1 + required: - compatible - reg @@ -68,7 +74,7 @@ required: - reset-names patternProperties: - "^channel@[0-7]$": + "^channel@[0-8]$": $ref: adc.yaml type: object description: | @@ -78,6 +84,8 @@ patternProperties: reg: description: | The channel number. + minimum: 0 + maximum: 8 required: - reg @@ -92,18 +100,25 @@ allOf: const: renesas,r9a07g043-adc then: patternProperties: - "^channel@[2-7]$": false + "^channel@[2-8]$": false "^channel@[0-1]$": properties: reg: - minimum: 0 maximum: 1 - else: + + - if: + properties: + compatible: + contains: + enum: + - renesas,r9a07g044-adc + - renesas,r9a07g054-adc + then: patternProperties: + "^channel@[8]$": false "^channel@[0-7]$": properties: reg: - minimum: 0 maximum: 7 additionalProperties: false From patchwork Fri Dec 6 11:13:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897030 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE663203702 for ; Fri, 6 Dec 2024 11:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483661; cv=none; b=tvS0EX3WlVkoA6fZz+2K9P9L4ptC0wbM4RwsrjcI+gahIGK7R7GIsy0M38dfeGyUXKGtpfNoXPJaeCs4EcVQmkhFbdj/11oJzVLiOKeeYq9ontD1MmukDd+PXdaprZvEcYudap1hOCyeGgAjZs4vpz6dnSfSSMLepYz4k47YIwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483661; c=relaxed/simple; bh=AEerx4UEMe9vIhaiw+MKD2CwprNuT0vrrMjdV50wgJI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i/8k2GOyxQTmr8rnImFGAg+noF3Di0QSekIukSfQolBlQDRAV4VxPjCcyGwtjU+0NpLjECd/NAsmEC+Das4F3QPB5tj8JliWfw138OL9oY75sWyG5Fb7xMCxErigCVTAX5Nt9mvMzRpM5HMet/SYr8z1IdqG7ziX+hJ1LHGju2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=Uij/YJ5F; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Uij/YJ5F" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5d0ac27b412so2332467a12.1 for ; Fri, 06 Dec 2024 03:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483657; x=1734088457; darn=vger.kernel.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=MdtjY2iaQx3u/dvLLJlYTlL/H3kwsjb4tDYv6XZS7Mg=; b=Uij/YJ5FlUJeSIKZgyhvhtE/kAQPY8WhbGf3al6DEjnFnoIhxVhwxXKdAmrwU0/h1R Y0YisScqH8uL9r5CvCM/+Sz7o6oKJ2COQoHMuati3vl5r08u+cE9b29liNUfLK49mPDK +e4RlLssnZc1tPD0xI1RfZAb0CpbFUg2ieEhmCiM+lzeY++UzAvlP1GZysxdxxcFMEC9 7j2xATmNQ1sepEY8SwKkJ+jSTJf3cq4/9WZHMIKeNYa5mXo9+8RFEtXcJM0rP5rPSZnh dK1OXNdYEfz+jELr4i9Iyswg6ubzuPk9ljz8yn7g0Zs2pY4g7+87s1Gf9heCm5lje/bJ cxjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483657; x=1734088457; 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=MdtjY2iaQx3u/dvLLJlYTlL/H3kwsjb4tDYv6XZS7Mg=; b=e6QvDkaU7YkbL0+p40zEcnkxqGE7f5zJb1PBsebJlV/6FjrxtXr503lHy95SJF0rx3 CoKGY5Rixr6AAOCziaKSkKIH4d9lSyGXhlUjP/0yyINFYR1HNuaQ+80mu5FXsSZOqo/e lN1g5HBukGJAyCg0ztf5tRzY+TlT15oIN7gCM4ErzwHztVN5h+TmIVxnjdx/iMExfuMH HKw7ThT1kReyQwsofQYo7EKGXns6cxnriueOWhFSv9Uj9QgNaT/rpDXoaL163RACr6cT gulXn33kOCb7/qRkTdGk3xsxqb+cpv6b3c1PSRGhheEgqzdtbkAdVQaSwyArloSyjoPC +2Uw== X-Forwarded-Encrypted: i=1; AJvYcCWqjTrGdUTqR+IeIIyYTKlI/4oS97g5xE8pGp+4bhBxMbj+mcRLlKxOPlrW7VEp2cXfOiLyAsplFw8=@vger.kernel.org X-Gm-Message-State: AOJu0YzEo3yFHzjRvOiL4tKGavPDF2GoC2As6t8jDwpFSdFIfG8v3hxR WSW+eAkKyytfo3krenyOAuL/IlOLSp42tnmRXHlqXuwSuh5+xTk4gm0ncAbAIlA= X-Gm-Gg: ASbGncuCpRljbB1Hx0CvHak0vmuosjnxru4lMz5WDRAz5LBEbDFjHw/oUUExQvAxc2Y 56Lx5ivFjGS5bgDpWoV2hnV0TsOOUYSY2JB26Gqd5qmWWtgg/qVIOYdfL7FR+RwBi18pyRAhGzQ 1DYxNs53wSKp5qdup6MmlLGGtJlBtn3ty4OWm5GifJ8UGU8c7RIRtxnMKvDM8i00+YyD2ZQMhD4 KJ2HjOTK45HYikU4HWVEtehGnpYrHpnH8gGbSJly6wsi+nu+q4Zt8MdAfoG8myOSOdnXGpKzYlO C8iQ X-Google-Smtp-Source: AGHT+IFGxVio+DmpGkWuPu8PJaQl2GCwf7E3UtKIMeAaIPe+lrYbE/WDjuxxOhcCyvi/hyZufziQrw== X-Received: by 2002:a17:907:770d:b0:aa6:23ba:d8c4 with SMTP id a640c23a62f3a-aa639fb1a24mr215496566b.4.1733483657113; Fri, 06 Dec 2024 03:14:17 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:16 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 13/15] iio: adc: rzg2l_adc: Add support for Renesas RZ/G3S Date: Fri, 6 Dec 2024 13:13:35 +0200 Message-Id: <20241206111337.726244-14-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Add ADC support for the Renesas RZ/G3S SoC. The key features of this IP include: - 9 channels, with one dedicated to reading the temperature reported by the Thermal Sensor Unit (TSU) - A different default ADCMP value, which is written to the ADM3 register. - Different default sampling rates - ADM3.ADSMP field is 8 bits wide - ADINT.INTEN field is 11 bits wide Signed-off-by: Claudiu Beznea --- Changes in v2: - none drivers/iio/adc/rzg2l_adc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 2a911269a358..81904e2c4075 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -502,7 +502,16 @@ static const struct rzg2l_adc_hw_params rzg2l_hw_params = { .adivc = true }; +static const struct rzg2l_adc_hw_params rzg3s_hw_params = { + .num_channels = 9, + .default_adcmp = 0x1d, + .default_adsmp = { 0x7f, 0xff }, + .adsmp_mask = GENMASK(7, 0), + .adint_inten_mask = GENMASK(11, 0), +}; + static const struct of_device_id rzg2l_adc_match[] = { + { .compatible = "renesas,r9a08g045-adc", .data = &rzg3s_hw_params }, { .compatible = "renesas,rzg2l-adc", .data = &rzg2l_hw_params }, { /* sentinel */ } }; From patchwork Fri Dec 6 11:13:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897031 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA315202F91 for ; Fri, 6 Dec 2024 11:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483662; cv=none; b=U/vQ2PaLgk0yy2Y/q5PFf6rwVPD6pvhgE+boKLDDtCNasjJhIZbBKIJAllbv4B7/4ZRgjQjScquHx4cnhiH/6QU+LyoNFkcqF1PE2Q0ix/dAWgOT5Wz+JJZLJ9LcjUUaPgM782bi7i/IwENk6u4ILayqSljbhxRXJ737GEaWlng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483662; c=relaxed/simple; bh=k6RYl4HHJUltxEdvGU/+maC6QDo0j1srIvB9wl/UUgs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N5cYR+4l2KVuXMNu0nD7UHqcZvtFKjwZsJ9RGn32D9U7ZNVklVnxwUC2+yHxccgT6cOm+nrKoDC1GXxc3m3Xh9xZ/yb32jRoUQCCoGbxVtQQ1PaKuEbUgYzVLFnkzuHzfQnH5vQhpYZ16p58g+iyKwUo2vwRRpBMkXbnSB0utwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=O/DzIXZm; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="O/DzIXZm" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-aa62f1d2b21so198269466b.1 for ; Fri, 06 Dec 2024 03:14:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483659; x=1734088459; darn=vger.kernel.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=iFCyto6njNpoAkuMysILtuSD/dfeIfCHeW4EjJllGlU=; b=O/DzIXZmwkX0i93A3+iL4GxA5PUZ4biXdFVEanjgqHaxP2uRiI0mZmvnExjlxUKvZc Ea7vCb9jdG98JaqXn5GGTxR9DFXmipTPkzeUhdRFX9h0uVQLcOulp/c9GiFasF6zadjl 1L5KwJE7o+MXYLd4zMkxzS3nmBhbj3tgrpcTx7dAC6Vw0MOV1CbJ5UHJFdf+Mw19pdeN T96x6knK+REJq++MKkJEX/T7GlyYJwQnztS2Go2zPmIbY1cYQFer33mFFtflWuJW5FUe 1LNCrCzpGLSFxpfjO98xf/7ZGv0c5Avlp0pcNdgDnovqnXV/2cys8NTfYfmDIP408ka+ 8Gyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483659; x=1734088459; 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=iFCyto6njNpoAkuMysILtuSD/dfeIfCHeW4EjJllGlU=; b=SuH88dSFb+h0GfTLEohBPuoa5TtCzmXC7SvH/lKxFpLUm0381Hd3XSW+F0lKmVu+MB Bhyu9jzoMvvGXaCtwOUtvBYXarowf5iY8sbbr2OISmfubuzwIiW3WOADB33TI5ZVIFaJ dnedpOnjh9r67VVLjkbKWDHevn/eMfLJ+W/ozJQNHLUsTcdolfpi9LN6RqigUwhTeSU3 W2OcSxIn+C3+rA1tTRNpDLZvINVEZ2UroTsN7qd7AmlpGgBvqgvrKiZy71Lmofinodet xOgzVTXxX+H0KVFoa4eMaCc2OoXIzXwIJddCMbZn3f/KcKRhYMCuZJMhq2oxQP58Pd4a +F6w== X-Forwarded-Encrypted: i=1; AJvYcCWGPblNxBiJ/EoaArHU8r4ued6KjulW8SsaZIZfhQcSkiRpl10ftFjqVCoJVgMssMyUQrWUprV/wzo=@vger.kernel.org X-Gm-Message-State: AOJu0YxNouxSGLf4x+mP/Zg6cYcJwQEvFSG6iA2DKcIykL88mexwwzSn Wblf9qWLciF0fw4MJawc5NTMW9UI2yBxXqJKFVQgLtDdBbdJHDPNTLPk78TBA+k= X-Gm-Gg: ASbGncu+3FROAL1hYzNUBDOMCwrU2PHUhx3fEOe2zlBczqXGiozcWWcTZHozZGsPKEM xqb677aDVDmLC4zVZKZwbKmOsGHBwDio9lL2gQOkTc5IhtcN/+UJaRpgx1xA3RNc35wdqeKkzBh rOTLANPo6wAyA3Mabk3FG9EXDcmeEEwSJBSmUPjRWmYq77rQ9vd1mFEttj47IjjV0Bxf8zGmW61 pNLsP+f6R9CbuOKq2iYHlbMtF7FF7elrYOJcSSavlcI5yEcYPsXSr2jw3/h0t+BKe/IjQarAnge ay5N X-Google-Smtp-Source: AGHT+IF8K/WU6hQLOeMVWhzwcTVS0WLZFH6PaGYPfojVpOBWvreAqVKSNqVp/mmguRkGijNh7B7IJQ== X-Received: by 2002:a17:907:7850:b0:aa5:f288:e7e3 with SMTP id a640c23a62f3a-aa639fed04fmr165508366b.15.1733483659089; Fri, 06 Dec 2024 03:14:19 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:18 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 14/15] arm64: dts: renesas: r9a08g045: Add ADC node Date: Fri, 6 Dec 2024 13:13:36 +0200 Message-Id: <20241206111337.726244-15-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Add the device tree node for the ADC IP available on the Renesas RZ/G3S SoC. Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven --- Changes in v2: - none arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi index be8a0a768c65..eb57a52d2086 100644 --- a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi +++ b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi @@ -87,6 +87,59 @@ rtc: rtc@1004ec00 { status = "disabled"; }; + adc: adc@10058000 { + compatible = "renesas,r9a08g045-adc"; + reg = <0 0x10058000 0 0x400>; + interrupts = ; + clocks = <&cpg CPG_MOD R9A08G045_ADC_ADCLK>, + <&cpg CPG_MOD R9A08G045_ADC_PCLK>; + clock-names = "adclk", "pclk"; + resets = <&cpg R9A08G045_ADC_PRESETN>, + <&cpg R9A08G045_ADC_ADRST_N>; + reset-names = "presetn", "adrst-n"; + power-domains = <&cpg>; + #io-channel-cells = <1>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + + channel@0 { + reg = <0>; + }; + + channel@1 { + reg = <1>; + }; + + channel@2 { + reg = <2>; + }; + + channel@3 { + reg = <3>; + }; + + channel@4 { + reg = <4>; + }; + + channel@5 { + reg = <5>; + }; + + channel@6 { + reg = <6>; + }; + + channel@7 { + reg = <7>; + }; + + channel@8 { + reg = <8>; + }; + }; + vbattb: clock-controller@1005c000 { compatible = "renesas,r9a08g045-vbattb"; reg = <0 0x1005c000 0 0x1000>; From patchwork Fri Dec 6 11:13:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13897032 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20B29202F91 for ; Fri, 6 Dec 2024 11:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483664; cv=none; b=cBRqlJZHAU1U+OAv2qb9rYA+PXrZtu9bVDbG/U3csy9S9kYxnJ96k/0ceMtHfXMNJ9iwioDfOm3khW31U1dMyJ/VkspGenb4fXIc5SVEz2okkjVe7W1lsT3QxzF4B7RIRZpW0Vszus2wAt1tCLGpDYvmxVg5qpVVwOenlaD3sMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733483664; c=relaxed/simple; bh=a4/gsQVtR7MVHM1KJuAuPMWGtk0F3Gae6xSRbB+vIWo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OVzWq6l7ornpRYyBvPrX0W4GVxWRLOtUlH+XxtOlbBlEyN/CAIqy/HuejoVHab9ivpj6yjpm7pJagcTC7jVAmpwDiAgxK55OvDCjDON2l9IwESs1bcbsjQ3zrHTMCcxCVSiHpEY9mZk1Byl3IpcXsSt8A+/8O7iV8Wi6ARQwn/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=IGUkLjZj; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="IGUkLjZj" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-aa62f0cb198so197914766b.2 for ; Fri, 06 Dec 2024 03:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1733483661; x=1734088461; darn=vger.kernel.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=r9Dnr8lBPRV9hwY5+L6VmdONZwzLphVT7+zA8FZuSvc=; b=IGUkLjZjdXavSltmBn7WJKCt7ZmfqpeDzq+c8eJyOQNUX4pmJzPPgbOzPqDCz+QuVr 0Ee0ApCmiF9L5o970PXWXaFksLDbsPONJoXANY1yjBKK15S8LoRwv4yaI96oTxeBqJo2 Yr+gjDZ2FhW1Kh/GXVTV7lOFJ5gypIS301DAgBcVqqqsEkmOy52N31+BTOmEd/w4lLyV bSuerh/gR7UOtBdU5HxbeKm1lP8vXbSByk1US73myzpL1FAp+lFZ5EzLpOngyAbGRIu/ VC2PirSXVrkC6aPm57d0vKHq/bjE+wVAIULPleREHmFcG5WpkgNHfVv27jaeWKhyDKH2 hA+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733483661; x=1734088461; 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=r9Dnr8lBPRV9hwY5+L6VmdONZwzLphVT7+zA8FZuSvc=; b=rImsTTuKtFYlx0N9bG3rlOJ5SQcuA/b9/E3nC4vWOgSoI8mVAlw8/ixD0aoq/J3XhE NoiravF9G53rZzCki9OmrHHZIDYE8M+r4GX4fKyaUN5I4xPdfj1gpB1sjLctqaZIDfLP kGAWlVF/92Al5HaqmboXKTRNL35DQILhO18i05y7ItBs5xmFECNdoUbqla2qsxlhYG1d HyrLFKs17Z2DcE2nO/Fp4S8nCGqkyumZ1BLRcpNOQi8tmC0W1OYVlu2q2Hp4aa2yDsJJ Gi1szxJqIhubOXXvmCFuH/n4R8TWjAXPEQxvoAWdoi0JdqR1Fjq4RwXmUvPQyiPQImmM psgw== X-Forwarded-Encrypted: i=1; AJvYcCU+6uD2dWDm6Stro1efk135+2XRG9lcli9LkAJaWbm5yJmK//TM6ABRHK1YqQzpYSxJnwsKp7KeylA=@vger.kernel.org X-Gm-Message-State: AOJu0YzMa8B9o3bp7zS3Da12MOkAmNjgODsB4IS145xnnK68O5VBnqc2 yfAJPCBjElYEm5cBi8iGqxZqqYcnaDAroT9p0g8xSz3dBO1vrfgiR85nY+hPcCY= X-Gm-Gg: ASbGncsKGAQ6dszrVtvccpdgvyLSBgTwaMeMOpITH+mnPJyoCVzuSb5G+uaOo9TRSCY +8SOItoD7WCYHGuvJfkkPn8STVAZ69spxHOGoK2pUWXwCUVqAJRx+9ZOHGRHUnv3Q3Z2u2Ftiak WISc2OZ/osDMcD1qDTTO6SNViBBPRkD9TbYFNeD5W3hs7audXjw8hCdNpYxnFnKI8fouWvRZbVX +iiryFGNK0dXxjW+Hg6V6jRK2OJoUhkTFBTwjR6e8/enpf/IJmig+Y8ZrzjvQHBWt8owNSxzrYE m8ZX X-Google-Smtp-Source: AGHT+IG7gJqc4CGdANniAawsf3QrNvInv7nJ0Q0Fqm3FfT2wXTQhceZu1E4SlHPGcY841V3MyHiZiw== X-Received: by 2002:a17:906:4d2:b0:aa6:2e07:5cf2 with SMTP id a640c23a62f3a-aa63a2086e0mr165912666b.38.1733483661317; Fri, 06 Dec 2024 03:14:21 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.161]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa625eee2a6sm226877866b.90.2024.12.06.03.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 03:14:20 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, geert+renesas@glider.be, magnus.damm@gmail.com, mturquette@baylibre.com, sboyd@kernel.org, p.zabel@pengutronix.de Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 15/15] arm64: dts: renesas: rzg3s-smarc-som: Enable ADC Date: Fri, 6 Dec 2024 13:13:37 +0200 Message-Id: <20241206111337.726244-16-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> References: <20241206111337.726244-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Claudiu Beznea Enable ADC. Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven --- Changes in v2: - none arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi index 2ed01d391554..57ebdfc858eb 100644 --- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi +++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi @@ -94,6 +94,10 @@ vcc_sdhi2: regulator2 { }; }; +&adc { + status = "okay"; +}; + #if SW_CONFIG3 == SW_ON ð0 { pinctrl-0 = <ð0_pins>;