Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7089199rwd; Tue, 6 Jun 2023 06:18:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YIve2Wu87p8jYXk0+BrLnSGBL+nq0dB4aXbJ17zcrPzYnk+K+hNkjs4HxtMHj0XzQKlnb X-Received: by 2002:a17:902:ced0:b0:1ad:d500:19d3 with SMTP id d16-20020a170902ced000b001add50019d3mr1148976plg.23.1686057490852; Tue, 06 Jun 2023 06:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686057490; cv=none; d=google.com; s=arc-20160816; b=XCWW+eNDvZ77uRbsO+qOL5R+mQkVzYAEvMGAiq8mygqEDJSzPVlzk9l5WPFOpC00/K VVlsJ1ngyyJcfi4GKjcdTqQmCuYsgiqWgZAjoQJI4IuINVMQZbCaw4/0rl0wMUm1EIe7 ScvkG3j4KTAoKmPw4gflJAQYShzOc9HaffqwQJysDWzWQN3XZLkTXj5+8tYx5AQ0oAwi WJYqiEFd1my0Iu8RB2OktWmjrh44nWnPZdHCheR7K/Y4ZS6LUKoyiYSzfbwNl89+nqPq ogJfeV4tvD4xqrFZTVh8wPMGvzXMow8gpLZbdhBDGkSzynUnioyZAu+kpxYikr4/0UJW t8vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=MsK3KfXvwDDXjdR1K4Z8iNkLw2j81KfAr/Pv963g5nQ=; b=aBPVlLMl62Z46ZZnMFa+J+vSSYdAzzmWvIHlQEJw1p7BNvweVw8MapyPxBfyHqoAZW Ee5LIXd1S2KtJXkWO/daXHCti86mJqjJ/lqvVwaoiaPuh5eicNCxVXoTSp5pzomxsOut EtX+Z6HhwPgKfwUeupVN1HPxaPNmQ+4t3yL2MqvnFCJ1LSbzpM/nORcspWr/KEGCnbOj 1j/GzOUqKkV5CvVJ/6Wh64DESqlzvMvUNDwvWU4TE5wZ7844PtgfOvCV2voABE6m1zRt AvNjJBRrkJkuZaSiWqwNGdADHSAUwTUDL065Ac60AoBZU+ohnyAwLGn75sMdZLRGfuZJ EdyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=XNGmWbqE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020a170902ec8a00b001a99ace3e76si7568966plg.554.2023.06.06.06.17.55; Tue, 06 Jun 2023 06:18:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=XNGmWbqE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237940AbjFFM6q (ORCPT + 99 others); Tue, 6 Jun 2023 08:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237937AbjFFM6a (ORCPT ); Tue, 6 Jun 2023 08:58:30 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53A5D19A7; Tue, 6 Jun 2023 05:58:12 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 878A65FD3B; Tue, 6 Jun 2023 15:58:09 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1686056289; bh=MsK3KfXvwDDXjdR1K4Z8iNkLw2j81KfAr/Pv963g5nQ=; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; b=XNGmWbqE+gcreM/m4zW6J26BakoZSNJ1Y7UnfbIw9z7G7YKoi3DATkZhYe9+KvPhu 2P49UFRlrhrMN3fYX07Kg/T5p0K3mKhKsP0lqRGUqyojcU5dZ09UD1PAjgVc0NXULC 6v3OhljNuIVARIzWLw3iEWTOV/heqky8m96JjJ7qhcIHDGNqfpOU7z+iX5dONzI1Qj zmI7xXpn0q65u1eqAYev0GayO4N3HSDbh1B/yW1vuDMF0aF/RM5JKmNQ6ArbAU/Cu8 zejU5845t2Wd6JOK7opluSy32o+vwyy+cVeKN/XUwki515icEi47bCOAjdLHrRmGGz Jy2kLeaMttHuQ== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Tue, 6 Jun 2023 15:58:07 +0300 (MSK) Message-ID: <02c7e2b4-9087-fc73-bd57-0d4c12bbe203@sberdevices.ru> Date: Tue, 6 Jun 2023 15:53:51 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH v1] meson saradc: fix clock divider mask length Content-Language: en-US To: Martin Blumenstingl CC: "jic23@kernel.org" , Dmitry Rokosov , "lars@metafoo.de" , "neil.armstrong@linaro.org" , "khilman@baylibre.com" , "jbrunet@baylibre.com" , "andy.shevchenko@gmail.com" , "nuno.sa@analog.com" , "linux-iio@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-amlogic@lists.infradead.org" , "linux-kernel@vger.kernel.org" , kernel , Vyacheslav References: <20230515210545.2100161-1-gnstark@sberdevices.ru> <6910550a-b025-0d97-0b39-bc89b235541e@sberdevices.ru> From: George Stark In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/06/06 11:10:00 #21443593 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/5/23 23:18, Martin Blumenstingl wrote: > Hi George, > > On Thu, Jun 1, 2023 at 10:56 PM George Stark wrote: > [...] >> Here the test I promised: >> Question: what's the real size of clock divder field in SAR_ADC_REG3 register in saradc in meson8 socs? >> The current kernel code says 5 bits >> The datasheet says 6 bit >> >> The parent clock of adc clock is 24Mhz >> I can check it here by: >> >> # cat /sys/kernel/debug/clk/clk_summary >> xtal 4 4 1 24000000 0 0 50000 Y >> c1108680.adc#adc_div 1 1 0 1142858 0 0 50000 Y >> c1108680.adc#adc_en 1 1 0 1142858 0 0 50000 Y >> >> for divider width 5bit min adc clock is 24Mhz / 32 = 750KHZ >> for divider width 6bit min adc clock is 24Mhz / 64 = 375KHz >> >> I suppose that the lower adc clock rate the higher measurement time >> so I need to get measurement time at both clk freqs and the times differ so >> 6bit divider is really applied >> >> I performed test at Odroid-C1, kernel 6.2-rc8 >> Two kernel patches must be applied: >> >> the topic starter patch and the helper patch at the end of the letter >> In the helper patch I turn on CLOCK_ALLOW_WRITE_DEBUGFS to change clock rate from she shell >> and use ktime_get_raw_ts64 to measure measurement time >> >> So the the test itself: >> cat /sys/devices/platform/soc/c1100000.cbus/c1108680.adc/iio:device0/in_voltage3_raw >> [ 1781.226309] ==== freq: 1142858 time 42408000 >> >> # echo 750000 > /sys/kernel/debug/clk/c1108680.adc#adc_en/clk_rate >> # cat /sys/devices/platform/soc/c1100000.cbus/c1108680.adc/iio:device0/in_voltage3_raw >> [ 1790.728656] ==== freq: 750000 time 49173000 >> >> # echo 375000 > /sys/kernel/debug/clk/c1108680.adc#adc_en/clk_rate >> # cat /sys/devices/platform/soc/c1100000.cbus/c1108680.adc/iio:device0/in_voltage3_raw >> [ 1816.955477] ==== freq: 375000 time 68245000 >> >> # cat /sys/kernel/debug/clk/clk_summary >> xtal 4 4 1 24000000 0 0 50000 Y >> c1108680.adc#adc_div 1 1 0 375000 0 0 50000 Y >> c1108680.adc#adc_en 1 1 0 375000 0 0 50000 Y > These results looks excellent - thanks for sharing the test results! > Could you please check one last thing: > $ grep -i adc /sys/kernel/debug/meson-clk-msr/measure_summary > It should confirm that the clock rate is 375kHz (or close to it, SoC > internal clock measurement is not 100% precise) Hello Martin Looks like it works as expected: # grep -i adc /sys/kernel/debug/meson-clk-msr/measure_summary   sar_adc                 1140625    +/-3125Hz # echo 375000 > /sys/kernel/debug/clk/c1108680.adc#adc_en/clk_rate # grep -i adc /sys/kernel/debug/meson-clk-msr/measure_summary  sar_adc                  371875    +/-3125Hz So I'm re-sending the patch with fixed commit message -- Best regards George > > Once we have that confirmation: can you please re-send the patch with > the description updated so it's clear which SoC generations are > affected and by stating that the fix was tested on a Meson8b Odroid-C1 > board. > > > Thank you and best regards, > Martin