From: heiko@sntech.de (Heiko Stuebner)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/8] clk: rockchip: Allow more precision for some mmc clock phases
Date: Wed, 30 Sep 2015 16:07:37 +0200 [thread overview]
Message-ID: <1443622064-14362-2-git-send-email-heiko@sntech.de> (raw)
In-Reply-To: <1443622064-14362-1-git-send-email-heiko@sntech.de>
From: Douglas Anderson <dianders@chromium.org>
Because of the inexact nature of the extra MMC delay elements (it's
not possible to keep the phase monotonic and to also make phases (mod
90) > 70), we previously only allowed phases (mod 90) of 22.5, 45,
and 67.5.
But it's not the end of the world if the MMC clock phase goes
non-monotonic. At most we'll be 25 degrees off. It's way better to
test more phases to look for bad ones than to be 25 degrees off, because
in the case of MMC really the point is to find bad phases and get as far
asway from the as possible. If we get to test extra phases by going
slightly non-monotonic then that might be fine. Worst case we would
end up at a phases that's slight differnt than the one we wanted, but
at least we'd still be quite far away from the a bad phase.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Fold in more precise variance-values of 44-77 instead of 40-80.
Fold in the actual removal of the monotonic requirement and adapt
patch message accordingly.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
drivers/clk/rockchip/clk-mmc-phase.c | 45 ++++++++++++++++++++++++------------
1 file changed, 30 insertions(+), 15 deletions(-)
diff --git a/drivers/clk/rockchip/clk-mmc-phase.c b/drivers/clk/rockchip/clk-mmc-phase.c
index 9b61342..a797d86 100644
--- a/drivers/clk/rockchip/clk-mmc-phase.c
+++ b/drivers/clk/rockchip/clk-mmc-phase.c
@@ -45,8 +45,8 @@ static unsigned long rockchip_mmc_recalc(struct clk_hw *hw,
#define PSECS_PER_SEC 1000000000000LL
/*
- * Each fine delay is between 40ps-80ps. Assume each fine delay is 60ps to
- * simplify calculations. So 45degs could be anywhere between 33deg and 66deg.
+ * Each fine delay is between 44ps-77ps. Assume each fine delay is 60ps to
+ * simplify calculations. So 45degs could be anywhere between 33deg and 57.8deg.
*/
#define ROCKCHIP_MMC_DELAY_ELEMENT_PSEC 60
@@ -84,22 +84,37 @@ static int rockchip_mmc_set_phase(struct clk_hw *hw, int degrees)
u32 raw_value;
u64 delay;
- /* allow 22 to be 22.5 */
- degrees++;
- /* floor to 22.5 increment */
- degrees -= ((degrees) * 10 % 225) / 10;
-
nineties = degrees / 90;
- /* 22.5 multiples */
- remainder = (degrees % 90) / 22;
-
+ remainder = (degrees % 90);
+
+ /*
+ * Due to the inexact nature of the "fine" delay, we might
+ * actually go non-monotonic. We don't go _too_ monotonic
+ * though, so we should be OK. Here are options of how we may
+ * work:
+ *
+ * Ideally we end up with:
+ * 1.0, 2.0, ..., 69.0, 70.0, ..., 89.0, 90.0
+ *
+ * On one extreme (if delay is actually 44ps):
+ * .73, 1.5, ..., 50.6, 51.3, ..., 65.3, 90.0
+ * The other (if delay is actually 77ps):
+ * 1.3, 2.6, ..., 88.6. 89.8, ..., 114.0, 90
+ *
+ * It's possible we might make a delay that is up to 25
+ * degrees off from what we think we're making. That's OK
+ * though because we should be REALLY far from any bad range.
+ */
+
+ /*
+ * Convert to delay; do a little extra work to make sure we
+ * don't overflow 32-bit / 64-bit numbers.
+ */
delay = PSECS_PER_SEC;
- do_div(delay, rate);
- /* / 360 / 22.5 */
- do_div(delay, 16);
- do_div(delay, ROCKCHIP_MMC_DELAY_ELEMENT_PSEC);
-
delay *= remainder;
+ do_div(delay, 10000);
+ do_div(delay, (rate / 1000) * 36 * ROCKCHIP_MMC_DELAY_ELEMENT_PSEC);
+
delay_num = (u8) min(delay, 255ULL);
raw_value = delay_num ? ROCKCHIP_MMC_DELAY_SEL : 0;
--
2.5.1
next prev parent reply other threads:[~2015-09-30 14:07 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 14:07 [PATCH v2 0/8] mmc: dw_mmc-rockchip: allow tuning using the clk-phase api Heiko Stuebner
2015-09-30 14:07 ` Heiko Stuebner [this message]
2015-10-22 12:03 ` [PATCH v2 1/8] clk: rockchip: Allow more precision for some mmc clock phases Michael Turquette
2015-10-22 13:47 ` Heiko Stübner
2015-09-30 14:07 ` [PATCH v2 2/8] clk: rockchip: Make calculations use rounding Heiko Stuebner
2015-10-22 12:04 ` Michael Turquette
2015-09-30 14:07 ` [PATCH v2 3/8] mmc: core: Add mmc_regulator_set_vqmmc() Heiko Stuebner
2015-09-30 14:42 ` Ulf Hansson
2015-09-30 14:55 ` Heiko Stübner
2015-10-01 9:54 ` Ulf Hansson
2015-10-01 10:21 ` Heiko Stübner
2015-10-01 17:35 ` Stephen Boyd
2015-10-01 21:05 ` Ulf Hansson
2015-10-02 2:52 ` Jaehoon Chung
2015-10-02 7:06 ` Heiko Stübner
2015-10-02 7:53 ` Jaehoon Chung
2015-10-02 8:43 ` Ulf Hansson
2015-10-02 8:48 ` Jaehoon Chung
2015-10-02 8:57 ` Ulf Hansson
2015-09-30 14:07 ` [PATCH v2 4/8] mmc: dw_mmc: Use mmc_regulator_set_vqmmc in start_signal_voltage_switch Heiko Stuebner
2015-10-08 1:15 ` Jaehoon Chung
2015-10-09 19:06 ` Kevin Hilman
2015-10-09 20:12 ` Doug Anderson
2015-10-09 20:17 ` Kevin Hilman
2015-09-30 14:07 ` [PATCH v2 5/8] mmc: dw_mmc-rockchip: dt-binding: Add tuning related things Heiko Stuebner
2015-10-08 1:15 ` Jaehoon Chung
2015-09-30 14:07 ` [PATCH v2 6/8] mmc: dw_mmc-rockchip: MMC tuning with the clock phase framework Heiko Stuebner
2015-10-08 1:16 ` Jaehoon Chung
2015-09-30 14:07 ` [PATCH v2 7/8] ARM: dts: rockchip: Add drive/sample clocks for rk3288 dw_mmc devices Heiko Stuebner
2015-09-30 14:07 ` [PATCH v2 8/8] ARM: dts: rockchip: add tuning related settings to veyron devices Heiko Stuebner
2015-10-08 17:36 ` [PATCH v2 0/8] mmc: dw_mmc-rockchip: allow tuning using the clk-phase api Ulf Hansson
2015-10-09 8:10 ` Ulf Hansson
2015-10-09 17:19 ` Doug Anderson
2015-10-09 20:11 ` Doug Anderson
2015-10-09 22:31 ` Heiko Stuebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443622064-14362-2-git-send-email-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).