From patchwork Sun Oct 2 06:45:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 2415 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AB3C43F331 for ; Sun, 2 Oct 2022 08:45:50 +0200 (CEST) Received: by mail-ed1-f71.google.com with SMTP id v11-20020a056402348b00b004516e0b7eedsf6616098edc.8 for ; Sat, 01 Oct 2022 23:45:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664693150; cv=pass; d=google.com; s=arc-20160816; b=ExrROLfrefNHha/YSyvaTmrxPZzNSCgVNmlfdpnTN7GV6DgPY+9p39BPoZKKtWM63w 1dAmmn6SjjE2ZxgjC5657zPsU82yLTdeIdlthZZZga8vGWfEZAOeuQwdinEjHL/7ft3J ykjxl+gll+gdW1Nw2Ofm/jlNgJ4XVuQF6QTeODWoDQUV4+v6OFQwWRQsviYQE5WfSZrv G/OzT7fqI80UDjCBbW6rIFLseycAQlcVaPUuK6RixTJUxoqm5TnmtMhirpagiVpBQzwN hTIuJvHQTzMqkssj2wEiP5WTNIx4wyUFXu01pIIKayhgivpo7iVVpjb1LABz2uA+aNzg x/iQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=fXuWLDSM1rcnB4IVRVDn58cYyBfVnseOZVpWw1GaH/A=; b=OhXll0XvrhZ9sdyW8RGBcSTQo0Nqc3cS99oFUXPsZp+SOQBixOSbsQLzz2DWmRI0Wv /NRpibiCMyFlMfsi0JYCtXW6SibXGgz2dPgZ9isewRkH/wTkc79RxfJPUvwyz6YNgB7Z beXmQ/6dXLPJPM4LA+ukjYloLqysJdrPQeh17bhHRui5e4hu9P968H64NcZ28qbQWQrC Q/lz9C3p6zZjkO4E5DNNkJSpTfb4DLDom4BHBMqqjNljjv6iwJa6npIlTGLAmpTmxiH+ QwIi87yPgHEhd2O2KoKEOlYpcFJPEPPeAXtDOqEF1txf8pVHZY/U1w/lDgt8AyHEUl6x DzvA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rsLBLijZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date; bh=fXuWLDSM1rcnB4IVRVDn58cYyBfVnseOZVpWw1GaH/A=; b=A6mLIJY6xTXmwd7hKR+Va2JxQBtWIFLDJquMTGjbukprdvS0F+hStKTYMyro4MVuFR h2ihi27MKPfYFslCv1jwEPdE3CShDOOw4mHE66lIjsYQXQVIqdFIXtRTpVuY6Tpv1aEO bAe806gnAsvKHzvSH+J9OqvKND+7cBR+NoMms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date; bh=fXuWLDSM1rcnB4IVRVDn58cYyBfVnseOZVpWw1GaH/A=; b=5XT3LO7ASbJGKtm/X+JsHml8j+AWKm7TMx/87B+tSrPquBTEuZazmOQ3eUw18iYcgB Yu+7QesgLYcsYyZa/aPcyvyUoJmA235PvBzx1VYxu4Kgjmtq1QvpBtt7vDLGibsD088L wiWCu2gaBJna5XfXOhLkbKVje2KjngCJi4r2NjqFRN+iG12p6Lpvgc3V/RCYa+uNTf6d ms23YkxAPZb9EaStZrGPm+vwExOgNZLYGz3V4swwWsaYBGIx//4GQ/Vfy/vewpKSF/G8 i2cw85eP6dkM4hLRRYsC8Q6M975OBdswFu6AryQvnGx5WFquRqmX3MsjxDTO6su4aryD +r/g== X-Gm-Message-State: ACrzQf3k92DJO9G42CgiETujqr6JrqZtfp5J7FLJHSDh9+EUOTL+ihXP 36KkbgMTF9pO6ysUUUYuCZpIXyc2 X-Google-Smtp-Source: AMsMyM5yPtrJ9EuPUxmiGO1piIzX3nEcmsW841mHDBg8d5brBYDZI1vm95vwBUkwAAKAiiFC7ya0Kw== X-Received: by 2002:a05:6402:d6c:b0:458:ef3d:5926 with SMTP id ec44-20020a0564020d6c00b00458ef3d5926mr727593edb.54.1664693150376; Sat, 01 Oct 2022 23:45:50 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:51d0:b0:43d:b3c4:cd21 with SMTP id r16-20020a05640251d000b0043db3c4cd21ls7950388edd.2.-pod-prod-gmail; Sat, 01 Oct 2022 23:45:49 -0700 (PDT) X-Received: by 2002:a05:6402:1e96:b0:451:129e:1a2c with SMTP id f22-20020a0564021e9600b00451129e1a2cmr14203260edf.60.1664693149109; Sat, 01 Oct 2022 23:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664693149; cv=none; d=google.com; s=arc-20160816; b=TJRUUKewmZW3mxtd82Qp2ZwGPaD5P0Wlv0kdC8o84YGuileMUzPyw9uioe2WsKz8Up GYmQTRW83H6eg40D49jHVo0iV0nBVdhSgZyBBF76xK5pjUYrgifQlKTlT7adohKwp05M RHYKgD41L3tcrfq9JFKzwXaYkb43je4Rr1njgzoERW3CR+M1d/HuK9D66zu55sK0nBIL Ra9250eMVm1qeT+zsO4+rJZaos9KCrLXUMDINZ6K6I4qSlDRAUJnAuSlVeg0f7kY22Et zIMS7BWCEzyjlmN7fLS1tZy8X8pIqJwMOxNJwtekLYIWus+Cm15MKIUD8rm7FuBEQcKa ry6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=riE4lHaMXHSULeXJrv4hqGT03pNNa5PlNR8v7ryuD60=; b=NkzSWmLyQUS4seEASrcYDG45Wp+ALk+aTTcaBKCH56lKd6q49awmvc1sKDvGskwYV1 l8x5PyU0NGEvnReOipDL2Hklqjs5YnghyjMFZMsZhdSMyXQmXdzWBTuogFUNiCnufa8q gJKhGm4UeV4DGeBcFKkvwhL42PPBXR8EGo5pHq/ySCxKOGWyY73IvMxWloi5b/INWe++ 3Iu7AGjkRDSZPXZyIWODsPvMLb+A+hfqbgj6axLdsmOaWczmiUIATmFxXp01CVUN5kkk P2iOd7vuj0qHtUmD4mskeDPYx4pI03z+pK77eHGH4gF6ms5IZavBxsApq/h4nxcOir0q 59sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rsLBLijZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 14-20020a50874e000000b00457f1c53aa7sor2937460edv.28.2022.10.01.23.45.49 for (Google Transport Security); Sat, 01 Oct 2022 23:45:49 -0700 (PDT) Received-SPF: pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:448c:b0:457:52eb:b57e with SMTP id er12-20020a056402448c00b0045752ebb57emr14243393edb.178.1664693148777; Sat, 01 Oct 2022 23:45:48 -0700 (PDT) Received: from panicking.. ([109.52.206.103]) by smtp.gmail.com with ESMTPSA id 26-20020a170906329a00b0077f5e96129fsm3569894ejw.158.2022.10.01.23.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 23:45:48 -0700 (PDT) From: Michael Trimarchi To: Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , David Airlie , Daniel Vetter Cc: Kishon Vijay Abraham I , Vinod Koul , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-amarula@amarulasolutions.com Subject: [RFC PATCH 3/4] phy: rockchip: Implement TTY phy mode Date: Sun, 2 Oct 2022 08:45:39 +0200 Message-Id: <20221002064540.2500257-4-michael@amarulasolutions.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221002064540.2500257-1-michael@amarulasolutions.com> References: <20221002064540.2500257-1-michael@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: michael@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=rsLBLijZ; spf=pass (google.com: domain of michael@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=michael@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The rockchip phy can be programmed in 3 modes: - dsi - lvds - ttl For instance in px30 there are two sets of rgb interface pins m0 and m1. The logic can go outside from the VOP using m0 set or go outside using the m1 set and the ttl logic enable. There are combination where a set of pin can be taken from m1 and m0 where all the two path are enabled. dsi and ttl enable share one register in their register area. Simple implementation is overlap the area where we want access the register Signed-off-by: Michael Trimarchi --- .../phy/rockchip/phy-rockchip-inno-dsidphy.c | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c b/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c index 644cf73cfd53..0af50d2e0402 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c @@ -217,6 +217,17 @@ static void phy_update_bits(struct inno_dsidphy *inno, writel(tmp, inno->phy_base + reg); } +static void host_update_bits(struct inno_dsidphy *inno, + u32 reg, u32 mask, u32 val) +{ + unsigned int tmp, orig; + + orig = readl(inno->host_base + reg); + tmp = orig & ~mask; + tmp |= val & mask; + writel(tmp, inno->host_base + reg); +} + static int inno_is_valid_phy_mode(struct inno_dsidphy *inno) { switch (inno->mode) { @@ -224,6 +235,10 @@ static int inno_is_valid_phy_mode(struct inno_dsidphy *inno) break; case PHY_MODE_LVDS: break; + case PHY_MODE_TTL: + if (IS_ERR(inno->host_base)) + return -EINVAL; + break; default: return -EINVAL; } @@ -506,6 +521,32 @@ static void inno_dsidphy_lvds_mode_enable(struct inno_dsidphy *inno) LVDS_DATA_LANE2_EN | LVDS_DATA_LANE3_EN); } +static void inno_dsidphy_ttl_mode_enable(struct inno_dsidphy *inno) +{ + /* Select TTL mode */ + phy_update_bits(inno, REGISTER_PART_LVDS, 0x03, + MODE_ENABLE_MASK, TTL_MODE_ENABLE); + /* Reset digital logic */ + phy_update_bits(inno, REGISTER_PART_LVDS, 0x00, + LVDS_DIGITAL_INTERNAL_RESET_MASK, + LVDS_DIGITAL_INTERNAL_RESET_ENABLE); + udelay(1); + phy_update_bits(inno, REGISTER_PART_LVDS, 0x00, + LVDS_DIGITAL_INTERNAL_RESET_MASK, + LVDS_DIGITAL_INTERNAL_RESET_DISABLE); + /* Enable digital logic */ + phy_update_bits(inno, REGISTER_PART_LVDS, 0x01, + LVDS_DIGITAL_INTERNAL_ENABLE_MASK, + LVDS_DIGITAL_INTERNAL_ENABLE); + /* Enable analog driver */ + phy_update_bits(inno, REGISTER_PART_LVDS, 0x0b, + LVDS_LANE_EN_MASK, LVDS_CLK_LANE_EN | + LVDS_DATA_LANE0_EN | LVDS_DATA_LANE1_EN | + LVDS_DATA_LANE2_EN | LVDS_DATA_LANE3_EN); + /* Enable for clk lane in TTL mode */ + host_update_bits(inno, DSI_PHY_RSTZ, PHY_ENABLECLK, PHY_ENABLECLK); +} + static int inno_dsidphy_power_on(struct phy *phy) { struct inno_dsidphy *inno = phy_get_drvdata(phy); @@ -533,6 +574,9 @@ static int inno_dsidphy_power_on(struct phy *phy) case PHY_MODE_LVDS: inno_dsidphy_lvds_mode_enable(inno); break; + case PHY_MODE_TTL: + inno_dsidphy_ttl_mode_enable(inno); + break; default: return -EINVAL; } @@ -561,6 +605,10 @@ static int inno_dsidphy_power_off(struct phy *phy) LVDS_PLL_POWER_MASK | LVDS_BANDGAP_POWER_MASK, LVDS_PLL_POWER_OFF | LVDS_BANDGAP_POWER_DOWN); + /* Disable for clk lane in TTL mode */ + if (!IS_ERR(inno->host_base)) + host_update_bits(inno, DSI_PHY_RSTZ, PHY_ENABLECLK, 0); + pm_runtime_put(inno->dev); clk_disable_unprepare(inno->ref_clk); clk_disable_unprepare(inno->pclk_phy); @@ -576,6 +624,7 @@ static int inno_dsidphy_set_mode(struct phy *phy, enum phy_mode mode, switch (mode) { case PHY_MODE_MIPI_DPHY: case PHY_MODE_LVDS: + case PHY_MODE_TTL: inno->mode = mode; break; default: @@ -630,6 +679,10 @@ static int inno_dsidphy_probe(struct platform_device *pdev) if (IS_ERR(inno->phy_base)) return PTR_ERR(inno->phy_base); + inno->host_base = devm_platform_ioremap_resource(pdev, 1); + if (IS_ERR(inno->host_base)) + dev_warn(dev, "TTL mode is not supported\n"); + inno->ref_clk = devm_clk_get(dev, "ref"); if (IS_ERR(inno->ref_clk)) { ret = PTR_ERR(inno->ref_clk);