From patchwork Tue Sep 26 07:55:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nickey Yang X-Patchwork-Id: 9971417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7264360365 for ; Tue, 26 Sep 2017 08:04:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EAA28806 for ; Tue, 26 Sep 2017 08:04:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E46E288E6; Tue, 26 Sep 2017 08:04:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D4C2E28F60 for ; Tue, 26 Sep 2017 08:03:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/Mg8J/u2kCSTxBV4aVwhJKuAx3SK0vcSzK8VTJfs4yo=; b=sFJYKmwglB0YFratRVP5S+4EY7 qlnKVT/jrOCSbmuEvxhySzT1jYHobKS6U0EashVY9fEW7Pl0x3bm1FjL5qb8tnCpEhHebMsz1cCAn HokhSEGDz2k2dqUXLhfyhZQgLlosgfyHh7zuXuXp3uzpOn8GMmDLWIEZldSdIDGWnoul2K84IoKDR 7RkiCnR4X5GH/q+y9QmuHfy4kJfWWlBbf9Q7gUVWnzHljnkKJTZjeQ8OLFuo3hPccDiNj+0hYq2o1 2hIoR7WhOhiBYm3tJBWMUOBQLINXm3uwQjB3GxfuWXblZnoD3W3N7/wl1GyS6Sf4P0MKUnFCYIfKl vnBsr8bA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dwkps-0005ML-EK; Tue, 26 Sep 2017 08:03:20 +0000 Received: from mail-pg0-f68.google.com ([74.125.83.68]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dwkj4-0005UM-U6 for linux-rockchip@lists.infradead.org; Tue, 26 Sep 2017 07:56:23 +0000 Received: by mail-pg0-f68.google.com with SMTP id u18so6347084pgo.1 for ; Tue, 26 Sep 2017 00:56:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xuepTEPXeXrzgRYiwGBqbwMfxIpVfdUEU1L7U3fvdsE=; b=S9pmnYWi89nc85B8+wJCHlYLcoR19sF8gzlDPCTO/GFJrNwwRsYkD5rv35u5Df/uRY JpV3TBP4CDtjMNI427LYH4ynFRmRKyCOBtiNLGKmL+QNsQdkEPYmNXlcV5RCsH9YFiv7 Ns+xOuyhhU1sCwgRw2kMa/+4eeEpjIRnA354o/GrfXRhfJJfQ8Pa/NXji77gJ11dUf1V wkamUygyaIs7FoFbSvh1k7pHiaSawDwS/ZGYB6nXHL+PkU5VMt2BM39a/YUWs/bGYULA D2cnDiigyy+DvRIrD/ZTFDWafIZJy9FtF4w+qyXwIH8m/sL+LkOzJ9Ajg5J1NZTnj9xo 6n7Q== X-Gm-Message-State: AHPjjUjjrqmo1ugedHP18JW724DIzmhH9b7cBxa9M1j3i8iYfn48rv/L 5V/xGGJ8seNVO5iBL+MNUQU= X-Google-Smtp-Source: AOwi7QDrXhTq37IeD5KuPdaavBR2Lxs4rEqwknz1mwvZyDc8jhRXmYxK68TH09VJO+67yMTVOeUIHw== X-Received: by 10.98.15.209 with SMTP id 78mr10155587pfp.87.1506412561787; Tue, 26 Sep 2017 00:56:01 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id n12sm16116908pfb.131.2017.09.26.00.55.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 00:56:01 -0700 (PDT) From: Nickey Yang To: mark.yao@rock-chips.com, robh+dt@kernel.org, heiko@sntech.de, mark.rutland@arm.com, airlied@linux.ie Subject: [PATCH v2 4/8] drm/rockchip/dsi: correct phy parameter setting Date: Tue, 26 Sep 2017 15:55:19 +0800 Message-Id: <1506412523-1766-4-git-send-email-nickey.yang@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506412523-1766-1-git-send-email-nickey.yang@rock-chips.com> References: <1506412523-1766-1-git-send-email-nickey.yang@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170926_005619_439374_A67D92B4 X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bivvy.bi@rock-chips.com, hl@rock-chips.com, briannorris@chromium.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, nickey.yang@rock-chips.com, seanpaul@chromium.org, zyw@rock-chips.com, xbl@rock-chips.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP As MIPI PHY document show, icpctrl<3..0> and lpfctrl<5..0> should depend on frequency,so fix it. Signed-off-by: Nickey Yang Reviewed-by: Matthias Kaehlcke Reviewed-by: Sean Paul --- drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 98 ++++++++++++++++++++++++---------- 1 file changed, 70 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c index 191037c..20d3f36 100644 --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c @@ -267,10 +267,21 @@ #define VCO_IN_CAP_CON_HIGH (0x2 << 1) #define REF_BIAS_CUR_SEL BIT(0) -#define CP_CURRENT_3MA BIT(3) +#define CP_CURRENT_1_5UA 0x1 +#define CP_CURRENT_4_5UA 0x2 +#define CP_CURRENT_7_5UA 0x6 +#define CP_CURRENT_6UA 0x9 +#define CP_CURRENT_12UA 0xb +#define CP_CURRENT_SEL(val) ((val) & 0xf) #define CP_PROGRAM_EN BIT(7) + +#define LPF_RESISTORS_15_5KOHM 0x1 +#define LPF_RESISTORS_13KOHM 0x2 +#define LPF_RESISTORS_11_5KOHM 0x4 +#define LPF_RESISTORS_10_5KOHM 0x8 +#define LPF_RESISTORS_8KOHM 0x10 #define LPF_PROGRAM_EN BIT(6) -#define LPF_RESISTORS_20_KOHM 0 +#define LPF_RESISTORS_SEL(val) ((val) & 0x3f) #define HSFREQRANGE_SEL(val) (((val) & 0x3f) << 1) @@ -400,32 +411,63 @@ enum dw_mipi_dsi_mode { DW_MIPI_DSI_VID_MODE, }; -struct dphy_pll_testdin_map { +struct dphy_pll_parameter_map { unsigned int max_mbps; - u8 testdin; + u8 hsfreqrange; + u8 icpctrl; + u8 lpfctrl; }; /* The table is based on 27MHz DPHY pll reference clock. */ -static const struct dphy_pll_testdin_map dptdin_map[] = { - { 90, 0x00}, { 100, 0x10}, { 110, 0x20}, { 130, 0x01}, - { 140, 0x11}, { 150, 0x21}, { 170, 0x02}, { 180, 0x12}, - { 200, 0x22}, { 220, 0x03}, { 240, 0x13}, { 250, 0x23}, - { 270, 0x04}, { 300, 0x14}, { 330, 0x05}, { 360, 0x15}, - { 400, 0x25}, { 450, 0x06}, { 500, 0x16}, { 550, 0x07}, - { 600, 0x17}, { 650, 0x08}, { 700, 0x18}, { 750, 0x09}, - { 800, 0x19}, { 850, 0x29}, { 900, 0x39}, { 950, 0x0a}, - {1000, 0x1a}, {1050, 0x2a}, {1100, 0x3a}, {1150, 0x0b}, - {1200, 0x1b}, {1250, 0x2b}, {1300, 0x3b}, {1350, 0x0c}, - {1400, 0x1c}, {1450, 0x2c}, {1500, 0x3c} +static const struct dphy_pll_parameter_map dppa_map[] = { + { 90, 0x00, CP_CURRENT_1_5UA, LPF_RESISTORS_13KOHM}, + { 100, 0x10, CP_CURRENT_1_5UA, LPF_RESISTORS_13KOHM}, + { 110, 0x20, CP_CURRENT_1_5UA, LPF_RESISTORS_13KOHM}, + { 130, 0x01, CP_CURRENT_1_5UA, LPF_RESISTORS_15_5KOHM}, + { 140, 0x11, CP_CURRENT_1_5UA, LPF_RESISTORS_15_5KOHM}, + { 150, 0x21, CP_CURRENT_1_5UA, LPF_RESISTORS_15_5KOHM}, + { 170, 0x02, CP_CURRENT_6UA, LPF_RESISTORS_13KOHM}, + { 180, 0x12, CP_CURRENT_6UA, LPF_RESISTORS_13KOHM}, + { 200, 0x22, CP_CURRENT_6UA, LPF_RESISTORS_13KOHM}, + { 220, 0x03, CP_CURRENT_4_5UA, LPF_RESISTORS_13KOHM}, + { 240, 0x13, CP_CURRENT_4_5UA, LPF_RESISTORS_13KOHM}, + { 250, 0x23, CP_CURRENT_4_5UA, LPF_RESISTORS_13KOHM}, + { 270, 0x04, CP_CURRENT_6UA, LPF_RESISTORS_11_5KOHM}, + { 300, 0x14, CP_CURRENT_6UA, LPF_RESISTORS_11_5KOHM}, + { 330, 0x05, CP_CURRENT_1_5UA, LPF_RESISTORS_15_5KOHM}, + { 360, 0x15, CP_CURRENT_1_5UA, LPF_RESISTORS_15_5KOHM}, + { 400, 0x25, CP_CURRENT_1_5UA, LPF_RESISTORS_15_5KOHM}, + { 450, 0x06, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 500, 0x16, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 550, 0x07, CP_CURRENT_7_5UA, LPF_RESISTORS_10_5KOHM}, + { 600, 0x17, CP_CURRENT_7_5UA, LPF_RESISTORS_10_5KOHM}, + { 650, 0x08, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 700, 0x18, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 750, 0x09, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 800, 0x19, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 850, 0x29, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 900, 0x39, CP_CURRENT_7_5UA, LPF_RESISTORS_11_5KOHM}, + { 950, 0x0a, CP_CURRENT_12UA, LPF_RESISTORS_8KOHM}, + {1000, 0x1a, CP_CURRENT_12UA, LPF_RESISTORS_8KOHM}, + {1050, 0x2a, CP_CURRENT_12UA, LPF_RESISTORS_8KOHM}, + {1100, 0x3a, CP_CURRENT_12UA, LPF_RESISTORS_8KOHM}, + {1150, 0x0b, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM}, + {1200, 0x1b, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM}, + {1250, 0x2b, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM}, + {1300, 0x3b, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM}, + {1350, 0x0c, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM}, + {1400, 0x1c, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM}, + {1450, 0x2c, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM}, + {1500, 0x3c, CP_CURRENT_12UA, LPF_RESISTORS_10_5KOHM} }; -static int max_mbps_to_testdin(unsigned int max_mbps) +static int max_mbps_to_parameter(unsigned int max_mbps) { int i; - for (i = 0; i < ARRAY_SIZE(dptdin_map); i++) - if (dptdin_map[i].max_mbps > max_mbps) - return dptdin_map[i].testdin; + for (i = 0; i < ARRAY_SIZE(dppa_map); i++) + if (dppa_map[i].max_mbps > max_mbps) + return i; return -EINVAL; } @@ -507,16 +549,16 @@ static inline unsigned int ns2ui(struct dw_mipi_dsi *dsi, int ns) static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi) { - int ret, testdin, vco, val; + int ret, i, vco, val; vco = (dsi->lane_mbps < 200) ? 0 : (dsi->lane_mbps + 100) / 200; - testdin = max_mbps_to_testdin(dsi->lane_mbps); - if (testdin < 0) { + i = max_mbps_to_parameter(dsi->lane_mbps); + if (i < 0) { dev_err(dsi->dev, - "failed to get testdin for %dmbps lane clock\n", + "failed to get parameter for %dmbps lane clock\n", dsi->lane_mbps); - return testdin; + return i; } /* Start by clearing PHY state */ @@ -537,13 +579,13 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi) REF_BIAS_CUR_SEL); dw_mipi_dsi_phy_write(dsi, PLL_CP_CONTROL_PLL_LOCK_BYPASS, - CP_CURRENT_3MA); + CP_CURRENT_SEL(dppa_map[i].icpctrl)); dw_mipi_dsi_phy_write(dsi, PLL_LPF_AND_CP_CONTROL, CP_PROGRAM_EN | LPF_PROGRAM_EN | - LPF_RESISTORS_20_KOHM); + LPF_RESISTORS_SEL(dppa_map[i].lpfctrl)); dw_mipi_dsi_phy_write(dsi, HS_RX_CONTROL_OF_LANE_0, - HSFREQRANGE_SEL(testdin)); + HSFREQRANGE_SEL(dppa_map[i].hsfreqrange)); dw_mipi_dsi_phy_write(dsi, PLL_INPUT_DIVIDER_RATIO, INPUT_DIVIDER(dsi->input_div)); @@ -632,7 +674,7 @@ static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi, { unsigned long mpclk, tmp; unsigned int target_mbps = 1000; - unsigned int max_mbps = dptdin_map[ARRAY_SIZE(dptdin_map) - 1].max_mbps; + unsigned int max_mbps = dppa_map[ARRAY_SIZE(dppa_map) - 1].max_mbps; int bpp; unsigned long best_freq = 0; int lanes = dsi->lanes;