From patchwork Fri Jan 26 18:26:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767627 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 53CF920326 for ; Fri, 26 Jan 2024 18:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293591; cv=none; b=Sdffyru+/96zZGJUoE6j2wM5bNQZfps20p0dsXIBLYY9aLrJje/UMc+F6g5Fm3KNmhWWnARN3EGl0jsUecgxI6wJ3e7LGrrcsF6/TaQXzpkoEBKMeVJalX4Xfz22HFDezHEJlosuV3zgt/UybHYORHyxqiysm6mpLJkavEDZPI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293591; c=relaxed/simple; bh=yVyRmmNda9mfXwPWksVdLkO9SsjdUAzlZBACGcKQbRg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y7zrum8WjKO15Corc+UuVGj7Y5ivHGKlJ5oaFfzlL5NSJ9+neA5PpRjruCuJUqbwkysE58E/btoNtLFeuNjc/BOTy0Qj4yXmnI1Cv00RfgoDtF1s00P1lsvKUQNKgokFm/v2yiYrdeBTCf72gUJlGR6rdbDaNOYMqOUxeDUDcfI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NCxy3G/8; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NCxy3G/8" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2cf4a845a76so8034851fa.3 for ; Fri, 26 Jan 2024 10:26:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293587; x=1706898387; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3oS3e08i9+4napyM4Cx2ITHLfZ0NtaHlzp9IZJ5e4DI=; b=NCxy3G/8wJ0VMMqL23cB8+w0OPCmPnRHAPGTp3lXQa65z5FKY7YpQDA9gtCD2dYO2g kXgiELxjeNoVbOkN6KA6y0R0FCjGrrTctgih9mpSJp4tjX2eT4Sga+UsXth2C1h3bpMb OZ3QRbeQD1rIHjiPdt96E/1bmcgyWN5z8R+9iA0qg/X8KI0t3FPcy485WHFHuf91cD1G oDW4+WUOl5XiJ6IwxY39bnFflYZWP94nkqf+I1mnBPYGxLH5Jveui8xySqtYczdGQoXn IJCiTrfJgK8uf9oXsKRM8Z8EkqcHNoc5LlH2EqRarso4blwvCBy3xMoDcd/ApA4B+h5K 81Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293587; x=1706898387; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3oS3e08i9+4napyM4Cx2ITHLfZ0NtaHlzp9IZJ5e4DI=; b=nYMqlXTPfvdERoZG+VCN0WIeT4e8tgj9OH98wQ829UQHsCGiJ9ZapNNtRdnHUVL3G/ DCgXcoJ9jh5yvxfT9FvgccSce0QZiFnQ5BlWoifK2tRez/ygU4kiKzuOdxNjbNOmXigv TBoi/XRmJzWvWmzlqHaTKgHewCsrKS/NXnsPulVMNawKy3PJAPg6f3w5LfmcqrXOrVtt MTrT2bEj9H/62X8GHuvTS3LEWWGqFTHFwcgoszfl1VwDXNDgN2HxhJ29DFYqfpNEJ/jn mINmh/4Mb+Zw2nD9nBbhsgpa3IJRNeBOkRdBuR3Zdd5/Kg4y+IEAoy04mbsinkH5rSaW H+jA== X-Gm-Message-State: AOJu0Yz/q+4zWIEckt1v1wB+7hDV0PO4ZQscci+oQfMzAHhjyOE9D6UR plmnGAJnpEEFHQJPplMYAs7wf+Njd+MctpMTpqRVbNzfXNtwZmStBecv6HWThrc= X-Google-Smtp-Source: AGHT+IEjwBaqC2fPBa/bAz9/T5mw/biJlp2Hq5zrXGrLEabCZhlsIh0GbkHRacokvUrtT0eWuzdmxQ== X-Received: by 2002:a2e:7801:0:b0:2cf:1c74:9bcb with SMTP id t1-20020a2e7801000000b002cf1c749bcbmr112743ljc.106.1706293587342; Fri, 26 Jan 2024 10:26:27 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:27 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:20 +0200 Subject: [PATCH RESEND v3 01/15] drm/msm/dp: drop unused parser definitions Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-1-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2918; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=yVyRmmNda9mfXwPWksVdLkO9SsjdUAzlZBACGcKQbRg=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lPOJbzNIqeApQ8DbgE/UP/idD/MUc3Ag/NF 99jdcF4k52JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5TwAKCRCLPIo+Aiko 1d/eB/9FpFX864Yjm80sEUWwzzg25jC/nJ5LbwAhFLUf2BNJlzCilUSxv2x/hVpOO2muGkgqHWA T/OFelIcZL2xD1sJPBJESu1REdVZ/Zlw7FDUQiQMk1ZbZ/4RtZq8W4wW5TmikDrft9WkqOntPHo vy105O9vosbmNLYpALFUfYfZ1fol8HUMSqTuUDJUZarjOLuvCgHhNN8O4IjH6raya3uzyig7Tp/ mm5ftptfZGFpClbNkJ+tPLi1qQZUJ6GD+JPwxb28VZslj6p/4ljxCr3kSOfCYm692RJWiv59vI0 d7wx6GjlUoTwrwmB9CkjVHPIRpjDyVqRGC3vZ9xqEkZf1kJU X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Drop several unused and obsolete definitions from the dp_parser module. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_parser.h | 46 -------------------------------------- 1 file changed, 46 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index 1f068626d445..90a2cdbbe344 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -12,7 +12,6 @@ #include "msm_drv.h" -#define DP_LABEL "MDSS DP DISPLAY" #define DP_MAX_PIXEL_CLK_KHZ 675000 #define DP_MAX_NUM_DP_LANES 4 #define DP_LINK_RATE_HBR2 540000 /* kbytes */ @@ -21,7 +20,6 @@ enum dp_pm_type { DP_CORE_PM, DP_CTRL_PM, DP_STREAM_PM, - DP_PHY_PM, DP_MAX_PM }; @@ -43,28 +41,10 @@ static inline const char *dp_parser_pm_name(enum dp_pm_type module) case DP_CORE_PM: return "DP_CORE_PM"; case DP_CTRL_PM: return "DP_CTRL_PM"; case DP_STREAM_PM: return "DP_STREAM_PM"; - case DP_PHY_PM: return "DP_PHY_PM"; default: return "???"; } } -/** - * struct dp_display_data - display related device tree data. - * - * @ctrl_node: referece to controller device - * @phy_node: reference to phy device - * @is_active: is the controller currently active - * @name: name of the display - * @display_type: type of the display - */ -struct dp_display_data { - struct device_node *ctrl_node; - struct device_node *phy_node; - bool is_active; - const char *name; - const char *display_type; -}; - /** * struct dp_ctrl_resource - controller's IO related data * @@ -77,28 +57,6 @@ struct dp_io { union phy_configure_opts phy_opts; }; -/** - * struct dp_pinctrl - DP's pin control - * - * @pin: pin-controller's instance - * @state_active: active state pin control - * @state_hpd_active: hpd active state pin control - * @state_suspend: suspend state pin control - */ -struct dp_pinctrl { - struct pinctrl *pin; - struct pinctrl_state *state_active; - struct pinctrl_state *state_hpd_active; - struct pinctrl_state *state_suspend; -}; - -/* Regulators for DP devices */ -struct dp_reg_entry { - char name[32]; - int enable_load; - int disable_load; -}; - struct dss_module_power { unsigned int num_clk; struct clk_bulk_data *clocks; @@ -109,16 +67,12 @@ struct dss_module_power { * * @pdev: platform data of the client * @mp: gpio, regulator and clock related data - * @pinctrl: pin-control related data - * @disp_data: controller's display related data * @parse: function to be called by client to parse device tree. */ struct dp_parser { struct platform_device *pdev; struct dss_module_power mp[DP_MAX_PM]; - struct dp_pinctrl pinctrl; struct dp_io io; - struct dp_display_data disp_data; u32 max_dp_lanes; u32 max_dp_link_rate; struct drm_bridge *next_bridge; From patchwork Fri Jan 26 18:26:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 766452 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 E60C520B27 for ; Fri, 26 Jan 2024 18:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293591; cv=none; b=qAU0EBEQVFzbKeiMd0GZrkVthAQhYxKg1rS4W59NtAySALiCUZ8cm1vkxmKZdiNlFyB30ImcbjzF9TBReS0i7w36RwGq0PyTher2+TO1RfYeTombsDIWh0dJig/tEmx72pPahT557b1PmA/t0JrQP1ZO5u+QHkQp9MOWdgY+hqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293591; c=relaxed/simple; bh=mPuJ0sdVtb49CzPgC03wOi5IYVOAPxO/LgrDoWoA7+M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=auhPmMeu6lQYe6Sc6UIOPUPNzNlEmsTHpwItP6xN1/vfJxWZY169GF10u+Xyu26gs3OQvZnW+KqYE8T0xHJEeeXWHFX6TbA8bI+fXChTDXxu6Dy2y8MmyxjAj8BVXyzbb4nZlJliaJbidBWeFmovIo2uwuLaoS90Zzc/Dwe2N38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=xEYCbb02; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="xEYCbb02" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2cf4696b90fso6662301fa.1 for ; Fri, 26 Jan 2024 10:26:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293588; x=1706898388; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=i0o+ygDvKgdzg84z/yGD97dQg8nwAd++RNbp4iSd1H4=; b=xEYCbb02mTwA9uLKsfb7GFqmwkdHDO7V/L9G8Jk4tV2pGzCQdIX3fGnV1LqGb/YvGE /+V+qLifXPh2jUwVdJhFDb4u2+5qOJFFofv4v9D3DtrrZQ9AZELxH3syHkN27KcVwwR5 U/Km0V41JiQKvKfODynZIoePCyNajtg/P7Hlo1jLpnBAJagJOWhkw3T2kMI5tx/HZ5zm Xn7B5xjHm9//AnnGZrPFlW2vacNWPr4IDwMrxoDe43XrP+DHcqU/lUXvdfH+qk2ioVHP i1VqzOZbOPxrU0nTfPlLq2xrDATnJgP6wBQC/8K8ZzSbnSHh3QEAOXDi4aIyZBrqTRIq 5yxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293588; x=1706898388; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i0o+ygDvKgdzg84z/yGD97dQg8nwAd++RNbp4iSd1H4=; b=NChBbe7il89fPOeEUWKB0ETWeVvAqOcBcbc1UCqFGgL8CzJMsn6UOk31nIsU8IQJzr 1MiqX08HMRl3N1nSAA7ej2PM9SlCxFKbipgefW84A8Z09mtz8tMxF9k7F0EGy2mbKy5x ERp70YXWhTVWNoJXusPQ4oehVrbftVXibSfJvj7LzAfb4StaBU+I5s5zDkNiXhJtKeLm E4i4yVYE8MUajlxERdauGq53wtcDn5HPm7K7xLQTK9oweYHA5tMDm7kuN1GQafHbVUGm EAaW11NZOqIQyk/Hv8rpdFbMkttUhfmDG7PfMaWJ8O/R66W/HqwUqsNcTtra3uenoavg gUKw== X-Gm-Message-State: AOJu0YznsTxZMZERwAcx/iSPpInMOPO5laXgZCgoqFh9nTxX/CXQxWYS CZnmhtE0CV+VOuaTB6QNChzHonWgzI0WlrrqSipg6ZEi1xtPz2lMomLqc6zPApE= X-Google-Smtp-Source: AGHT+IFiRKKpC1MmWIOnmeVOU5vtrhmk3jEYF1uhWYyx+KxUzzr21U3Wn8emuBWR1ul2mE+Khq00Vg== X-Received: by 2002:a05:651c:8c:b0:2cc:6928:ee59 with SMTP id 12-20020a05651c008c00b002cc6928ee59mr124763ljq.74.1706293587940; Fri, 26 Jan 2024 10:26:27 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:27 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:21 +0200 Subject: [PATCH RESEND v3 02/15] drm/msm/dp: drop unused fields from dp_power_private Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-2-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=744; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=mPuJ0sdVtb49CzPgC03wOi5IYVOAPxO/LgrDoWoA7+M=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ+rmn/5PvPfVfjOeuI1p7jcvFa+LkR/j2pj777UEZHw73 3Hi3hS1TkYjFgZGLgZZMUUWn4KWqTGbksM+7JhaDzOIlQlkCgMXpwBM5BYb+xeeyqxS4R97TFY9 aJ6ldumqBV9IZ4uk/TK9eFu+K12lcaYMr/+6rm3NS9B3lVY4PSFx1zPV405TjpR9532oY9i14n6 y6V2v91e/7dznbrNc5cijwgctVe9rZf/P+C/md/nkHAUHT03VwB71e0szZexvHjL2C24OkDQT1V RiyPk0N6tzWn+U03qZ0oSfDFELuDmmpIsInfO3WDOjh/XzBK6rH5pkw1tuXXuoJLWN5Y6ioeeWG bz+s30WyOUyLLi3/f1EAQW1qCVP9TS4LJxCM1bcups7u13mjWOhwrYz61/2WPU2NTz5z3uq0Ukk MOzSJNW4ExbHuG+fMa/o+tz2cV1w23YzruUldY+knXoA X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Drop unused and obsolete fields from struct dp_power_private. Reviewed-by: Konrad Dybcio Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_power.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_power.c b/drivers/gpu/drm/msm/dp/dp_power.c index c4843dd69f47..b095a5b47c8b 100644 --- a/drivers/gpu/drm/msm/dp/dp_power.c +++ b/drivers/gpu/drm/msm/dp/dp_power.c @@ -16,9 +16,6 @@ struct dp_power_private { struct dp_parser *parser; struct device *dev; struct drm_device *drm_dev; - struct clk *link_clk_src; - struct clk *pixel_provider; - struct clk *link_provider; struct dp_power dp_power; }; From patchwork Fri Jan 26 18:26:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 766451 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 4D99E20B34 for ; Fri, 26 Jan 2024 18:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293594; cv=none; b=qCzinDbFYGHpGL/3JSJ80MRb7dPJ/Af6998By4JTatwh994jR+p3k8ozmD4LzhwSaMlIDC2/jfeTeDE1riczok+Ot5y/DNTaZAH8RL/h0tCCMWD5dkn2vEqzFqidmjMtUfnu6RhhBo/kpu4/hTFL+SKEHTgyJHyG2FLhoqGGnxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293594; c=relaxed/simple; bh=nbI6O2jVJmJKDcIwmvwKvAtsadxXm7JZt5ZEib+SKuc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XKK2trC8mZditnK6GVQ2J+ugpP+trPx15YE2w3BDRBcPP2q32W45fwLJL8/rrksbxc9uRHmnw5PjS5U7hyTW5bzNNM3uP1SIK6b2OSNN87Rr5S84kLfcdKFUN+YN34jGDIwGxAOXZuy0xwVjiyl5Uetkw7aEpBvU6uYedSOs+Q8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fQeQMg9+; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fQeQMg9+" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2cf1b770833so13122761fa.0 for ; Fri, 26 Jan 2024 10:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293588; x=1706898388; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=WsClFXjXZL1/cgwwi1vtRBjWGBqeVxIEF70yOJflqhU=; b=fQeQMg9+xJURLQhUfbQRmbyrb6mRQPPoWgwqK9tVSbQ6nW9O6v8aRRinkLt8Ef3bZJ Huw+w20TNUDCzz47plVgmVb8OjkeFPeRjNbTyb1VB/iBb6zwzHrId++m8279LiOb3Qra h0kXhuO+vzL/qa/5gc88zAQBUqKJ+O49AvFjHhxzsP8aBPdn3D+e2/bvLe83s0Vt8IdA jn22O88ebq8bIhtJtuNau/lpz7ogFl8M7XUkByfSblJ5lWfWGJbtWl327PE4ukBC/htt yRncZI6pPx0Er5I6AZvL57l5Pp0OxViKwSXeFUf67bHn/h1Rx0zIvByGXXmcT+gzmEE3 Y3FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293588; x=1706898388; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WsClFXjXZL1/cgwwi1vtRBjWGBqeVxIEF70yOJflqhU=; b=asyw5pLuQDjProsR0mw+xpImG4tLwtMyHdWYMObHZyBUIa9ntSbvZ+9uav2tJ+Hdbt ZyL763As5jNB9XNfkIvSJcnvCY0flN4rzle0258ny2emAYJ8kaBld+OeDXe+TvcVkDdI f/yIiakZX1Zjs4H/2LwN+vmKAeg3lDi8YVSiKSm/4M8DGU5C+cGo5uPSgS+XpNq4qK5p nbDHxlgJ36XAK+D+s/sdyfZ8GY/w9t5kKRssjjVpWFVGW+LM0afZXQtGj8vq3E/DVACD yVxcemL/Z759BwEAly89nyDYOZSvZqSuHXcOCqodcUJfpwudKpdfAh699PNsopSaUbdA aiJQ== X-Gm-Message-State: AOJu0Yxxw13M/jYFxPzuQ6LRAmQH61Hdui3QL/S19IU8bJDouguEpNYm yG6JqYrsngNkSl5pPdG2ygbnUqKnoX7RKJRnQsWBoTPJUe+zMaJn+dP3eQwP0os= X-Google-Smtp-Source: AGHT+IH6v7IJZWpMt5uHQPOcrEe2FO/dTFAzytBW5kDe0i1xJOiATlSJIdisAZmyxcLrz24mpwvMxg== X-Received: by 2002:a2e:b81a:0:b0:2cc:89f4:15a3 with SMTP id u26-20020a2eb81a000000b002cc89f415a3mr150252ljo.49.1706293588648; Fri, 26 Jan 2024 10:26:28 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:28 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:22 +0200 Subject: [PATCH RESEND v3 03/15] drm/msm/dp: parse DT from dp_parser_get Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-3-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2495; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=nbI6O2jVJmJKDcIwmvwKvAtsadxXm7JZt5ZEib+SKuc=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lPIQiz99mijPv7APhc0aOtQpr7FSxP7uUf6 fQtUhmCq5eJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5TwAKCRCLPIo+Aiko 1UoxB/0Xr3DzXz0QRZ6P4cU4vQAkaAzak1HsYyIMPeIWORcxjTRJZdejUp4k5LjJlXskB/FTwrN 3RELHh+696DgAwUIDJyYZp+iFlySlD3Dxm0oKX9jT1uLu2jve8drSLZTc6FPMIELkZqBEDwY8ZP fIjvHKGl71esRnwe/dL+8e9Vpj+8A8FyxNtVKo1Mz8S3n5kRG+V18ihrwQvDIbxqTx6ptAblDRx dxbifiE4iii1N3vJTq6KOGSnk2lagyfkNQUL6ieh6BqO6UZKxX1bIlnQjfzR9xDd1ilJTQYoBAg gVK/BMQ1Mtp6U2FlZa0uIQdAsHzATmc6UZoYgTi+KfjM5ywn X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A It makes little sense to split the submodule get and actual DT parsing. Call dp_parser_parse() directly from dp_parser_get(), so that the parser data is fully initialised once it is returned to the caller. Reviewed-by: Konrad Dybcio Signed-off-by: Dmitry Baryshkov Tested-by: Kuogee Hsieh Reviewed-by: Kuogee Hsieh --- drivers/gpu/drm/msm/dp/dp_display.c | 6 ------ drivers/gpu/drm/msm/dp/dp_parser.c | 8 +++++++- drivers/gpu/drm/msm/dp/dp_parser.h | 3 --- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index d37d599aec27..67b48f0a6c83 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -1266,12 +1266,6 @@ static int dp_display_probe(struct platform_device *pdev) return -EPROBE_DEFER; } - rc = dp->parser->parse(dp->parser); - if (rc) { - DRM_ERROR("device tree parsing failed\n"); - goto err; - } - rc = dp_power_client_init(dp->power); if (rc) { DRM_ERROR("Power client create failed\n"); diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index 7032dcc8842b..2d9d126c119b 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -315,13 +315,19 @@ static int dp_parser_parse(struct dp_parser *parser) struct dp_parser *dp_parser_get(struct platform_device *pdev) { struct dp_parser *parser; + int ret; parser = devm_kzalloc(&pdev->dev, sizeof(*parser), GFP_KERNEL); if (!parser) return ERR_PTR(-ENOMEM); - parser->parse = dp_parser_parse; parser->pdev = pdev; + ret = dp_parser_parse(parser); + if (ret) { + dev_err(&pdev->dev, "device tree parsing failed\n"); + return ERR_PTR(ret); + } + return parser; } diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index 90a2cdbbe344..4ccc432b4142 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -67,7 +67,6 @@ struct dss_module_power { * * @pdev: platform data of the client * @mp: gpio, regulator and clock related data - * @parse: function to be called by client to parse device tree. */ struct dp_parser { struct platform_device *pdev; @@ -76,8 +75,6 @@ struct dp_parser { u32 max_dp_lanes; u32 max_dp_link_rate; struct drm_bridge *next_bridge; - - int (*parse)(struct dp_parser *parser); }; /** From patchwork Fri Jan 26 18:26:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767626 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 4E9AD20B35 for ; Fri, 26 Jan 2024 18:26:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293593; cv=none; b=u+GE+Aj8NmezMkJpdBagvEyZ5w4kICM/mxOs8rzPUmTHu4dwFXZFYIQiX5FcnA8U3EDE5+jeKLklOfpRChKlTBdsW0Lk/QgLoTkkgL6fpvvvj2bHNoIKa8OSMukPcg6IReEGzMXPrzz/XW16yLGrKVUnQTD+fp25WUzYoI87t30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293593; c=relaxed/simple; bh=0tPYPq9OqCyaK2qdciiqePf9VS3u8McIRcRAIy4vqEY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=anj8fJiGULGXMMmYN2WdzSRX7IL+H76mQv4BMw/z8bqXwednkQrU8M05GLA/YptOS0G9oJDtXHjwWDnpKTZlOcYuNW84+bg8jOHYpY9/kMIwDKxrKjzBtPpmqPOpxuUJLgPqiT6YL5swSwQJYkvL8w7OIUPl+Xm6NDUlslB/3xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=jDKe2ZOG; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jDKe2ZOG" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2cf3a095ba6so7706931fa.2 for ; Fri, 26 Jan 2024 10:26:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293589; x=1706898389; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=W/0vQlu3/zRSTNUc/QWsRNBkw7wsjD404h/u9X2qZl0=; b=jDKe2ZOGGgrh5n1nxGBZ4jWy/k3CVFuDtvJHhFdkRgC/R4ilziG6YZbMU/BiP7uaSt 5e0LOr5qMWP3qN7sRY2hiN2u8d+Bhw5KPQ79pGPre1SBf+G6h/9XrwYf/w4301vog0Q5 pBVDVrW2pcjckChK8zjffcZgyX4CPbmdaz3lAkqyyR8sSMcWR/ep6R7tWtaABGWZr8wY bjvT/qDQiI/cvojRrbO5HPGT1pLNIDWydWcK/vHARGNCA4lKmK4wSXv8bfLI1DcBRLis m19S3XocGNE6AgaTLc+iJXIn7dguonREk6MU8DGzfnZAz3O4WpCz3RZ5UYV72enb53+N swIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293589; x=1706898389; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W/0vQlu3/zRSTNUc/QWsRNBkw7wsjD404h/u9X2qZl0=; b=pg3HTRLc8QOVKES0pBhio5WG7inG9M4MzMivQQqp7VISayNZpAil56k2HSb7E1w8cY U72kG5yJ11rXcgqdGpVYTIi6zCjDwpCf4Ujgwl7BKykmGrTiG+UJviaZMbTfllP4qvfh 7BkunYI1wMXy8MnRlDvaJ/oMT06JZCMysj6s/nnrB4llRLQrvyPeb4hO3NVXeIufmmRr Dez5FrHt4X42iW3jMd+mFAUXBKNHZBMx3E5QUspfEpDPYM+2NTkyDAXDHnfg5m6LPpgx +WySabB6bdCsCkQXTCAfXChE5fF+oZT9Kd4ceBclmFcF4uIWOjzpkt8uTA1dKA/M3Gt/ M6Vg== X-Gm-Message-State: AOJu0Yw+KTGSxJc4uRPIYmlmnOEw8pON5Z/fV7ZdVaFE/IqKUh3fDgpY VepcUejRLYsFmrmmyKJbK3HSblA4dQ62bI8QDk8ZsPiLClsuN7MtXV1pCsj1vyw= X-Google-Smtp-Source: AGHT+IEPWX4Lz/H8/swWBAYAe0lk0wFuw6fBf2Hq+dQ3GRoiOiWAbkzoaY14FLVp7ZZ4TdxycFKtCg== X-Received: by 2002:a2e:968f:0:b0:2cc:7df7:3649 with SMTP id q15-20020a2e968f000000b002cc7df73649mr130496lji.46.1706293589259; Fri, 26 Jan 2024 10:26:29 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:28 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:23 +0200 Subject: [PATCH RESEND v3 04/15] drm/msm/dp: inline dp_power_(de)init Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-4-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=2942; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=0tPYPq9OqCyaK2qdciiqePf9VS3u8McIRcRAIy4vqEY=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lQIsAfKH/xrlU4ikbYWUv98SABGowk2KICx AtJJlyd9u+JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UAAKCRCLPIo+Aiko 1Y25B/0TS/+5IJDY+MyW4gxKAkONHP+wLqnydxN+t6oMIT3SGOSLBWZRPUyUT3guCuXXTuM+i0D fRsL7UlkNZRFJ0/hlZwVwFsx+nwTDKF4yDG2YrQOCuFRQ5fDK44KGnf1ts0JZ8n36YWuwOd2dqs jm5djOU2r+DqjqeNmj2UYRfp/mJOTPIJPcMP4SFfGMoXayvr0QHOsQy/ipqcMqXFyfJuc1o9VUJ SWuD428c2AXwSXe5eKv+hvuLqF1Bll3PLkpk7YZW84RNYcAokT9FJAuiEj4EPBRpB0O/Jf4bFUi 95pGM6M6Qljuffld8cPsSIyUKeXC7EtP+8/MhZ/1i09aUJ9h X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A In preparation to cleanup of the dp_power module, inline dp_power_init() and dp_power_deinit() functions, which are now just turning the clocks on and off. Reviewed-by: Konrad Dybcio Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_display.c | 4 ++-- drivers/gpu/drm/msm/dp/dp_power.c | 10 ---------- drivers/gpu/drm/msm/dp/dp_power.h | 21 --------------------- 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 67b48f0a6c83..8cd18705740f 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -434,7 +434,7 @@ static void dp_display_host_init(struct dp_display_private *dp) dp->dp_display.connector_type, dp->core_initialized, dp->phy_initialized); - dp_power_init(dp->power); + dp_power_clk_enable(dp->power, DP_CORE_PM, true); dp_ctrl_reset_irq_ctrl(dp->ctrl, true); dp_aux_init(dp->aux); dp->core_initialized = true; @@ -448,7 +448,7 @@ static void dp_display_host_deinit(struct dp_display_private *dp) dp_ctrl_reset_irq_ctrl(dp->ctrl, false); dp_aux_deinit(dp->aux); - dp_power_deinit(dp->power); + dp_power_clk_enable(dp->power, DP_CORE_PM, false); dp->core_initialized = false; } diff --git a/drivers/gpu/drm/msm/dp/dp_power.c b/drivers/gpu/drm/msm/dp/dp_power.c index b095a5b47c8b..f49e3aede308 100644 --- a/drivers/gpu/drm/msm/dp/dp_power.c +++ b/drivers/gpu/drm/msm/dp/dp_power.c @@ -152,16 +152,6 @@ int dp_power_client_init(struct dp_power *dp_power) return dp_power_clk_init(power); } -int dp_power_init(struct dp_power *dp_power) -{ - return dp_power_clk_enable(dp_power, DP_CORE_PM, true); -} - -int dp_power_deinit(struct dp_power *dp_power) -{ - return dp_power_clk_enable(dp_power, DP_CORE_PM, false); -} - struct dp_power *dp_power_get(struct device *dev, struct dp_parser *parser) { struct dp_power_private *power; diff --git a/drivers/gpu/drm/msm/dp/dp_power.h b/drivers/gpu/drm/msm/dp/dp_power.h index 55ada51edb57..eb836b5aa24a 100644 --- a/drivers/gpu/drm/msm/dp/dp_power.h +++ b/drivers/gpu/drm/msm/dp/dp_power.h @@ -22,27 +22,6 @@ struct dp_power { bool stream_clks_on; }; -/** - * dp_power_init() - enable power supplies for display controller - * - * @power: instance of power module - * return: 0 if success or error if failure. - * - * This API will turn on the regulators and configures gpio's - * aux/hpd. - */ -int dp_power_init(struct dp_power *power); - -/** - * dp_power_deinit() - turn off regulators and gpios. - * - * @power: instance of power module - * return: 0 for success - * - * This API turns off power and regulators. - */ -int dp_power_deinit(struct dp_power *power); - /** * dp_power_clk_status() - display controller clocks status * From patchwork Fri Jan 26 18:26:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 766450 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 7FEB720B27 for ; Fri, 26 Jan 2024 18:26:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293595; cv=none; b=PF+xNqJ5veLPmKz2zWHwbyWY+mdcmhcMJ/+caq5Eby9nmNl/ImYScsTxTLXbRxSR2RCOuh7GMUoFXfbUKuAusDkkfKwjT2JG+8PvEfY8mXsavQ7pIugdHT9xWqQpoHJGjFL745qaC7L9vuztvj6NSc2QBYV30Bi/JQJ8Snkis70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293595; c=relaxed/simple; bh=dCw0JTAvwTm3wGka2zU3RC0fLmOOYChcuRvVrtRzN5I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Gj2cfO2jrZOyxrR2zmLwnU7a9kUe9l65EjA4O95ax3MpoeIf2fqIe2lWZhgSfSkNnFNzm9bSLlG0nk7DdW6zLEcX8f2fTFYrXzAXVM5oQQ8ny6lDIZAY0iieg7bUyk8tCBn+NnqEAxNFAZTDsu+VYXnIwhGBjpka6DMyvtHVvgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=c5lXvTAp; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="c5lXvTAp" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2cf3a04ea1cso9021571fa.2 for ; Fri, 26 Jan 2024 10:26:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293590; x=1706898390; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nJWE1GkcFImEj2DxRPKAZs3b3f9vVuqQlVDaF+/qbvU=; b=c5lXvTAprPRJC+dk6PBUywXksQ79fSwQQBN40Jhe8P/46ZRFJVdiNDh7TpP6HUNkrR 9kfdDD3QIN2VEGuqQjM/HM09NftDJLZe/EL9i76Rkqr6fwCMbXehZljhuXEFSyRe7AV/ saBGOYrRXOoQLwYffpRHisqu/5utup3pgJ0wFr72+NzjQ6ivy85lGRYRDLJ76PF1HRyz SEU8HIOSOgzvTYl5whoVFKmtDsZUV7Md0sbAdHnbHlN2dgb+PE9ZFHqkOMqOn4gXTBx5 6cXLeMeU7RFIMkhKhhXO8TQsv5a0hf+z1rPWaTFvOly3TZVis2M7rQPfMd7Kv0SEA+E1 XMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293590; x=1706898390; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nJWE1GkcFImEj2DxRPKAZs3b3f9vVuqQlVDaF+/qbvU=; b=qBtgWEVRZmuu3CUhV/6D4SHmxZ3la2DAKr+Z1/3NUXazRDvep8hdquv0e/DW4hmseX CrWY2/BzsFUi/Kysp4FOpF/W9NQsxl6W9Pyg2D97EtW/xCDW64YEXaoKudkJxX8bp/SV tarN61z2d1aKNi1d3QUGGqpGdadtBZoRSTJuyp7izp137BnXASghdnbZTeunYfzu8Lpv McPTcMgCoqv8aWhYIu+gWZBFDBqa42jubuCLLsHp/1F3k8JuC/gcMGq9O+8eYfzMrMm1 F/hOILuAANcsR4naX6pILWtu+QM9rtVGWPPejgRLYJ3qxN2fE+awingpbtdr/rMXqfRp uOgA== X-Gm-Message-State: AOJu0YyWb+iWRT6bX3jF7VbhGxU1jJKSBusTP4WAcU9enaXrhkJme0iw dXW5fZdBCxzdQMMbx6C5NF+QowHGx+qbFUBF7luo/BXC0FoGwhnozoZ+QcZRvpg= X-Google-Smtp-Source: AGHT+IE9js+jiMl9HAgf7a0xx+UUFgdbeu4zM5rWNMS7Of/4SzAy/9qNO/AZQUuT8WwdjPrS8IBXlA== X-Received: by 2002:a2e:9089:0:b0:2cf:2f60:cdcc with SMTP id l9-20020a2e9089000000b002cf2f60cdccmr142863ljg.72.1706293589966; Fri, 26 Jan 2024 10:26:29 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:29 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:24 +0200 Subject: [PATCH RESEND v3 05/15] drm/msm/dp: fold dp_power into dp_ctrl module Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-5-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=20838; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=dCw0JTAvwTm3wGka2zU3RC0fLmOOYChcuRvVrtRzN5I=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lQ2wCxhri7sBLBAZECfAx/xoe1o8fEwUu/y 0d4jCO+ZSeJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UAAKCRCLPIo+Aiko 1UNLB/94FMPePgcgET5nlim1nq83D0ue9CqAhhGO7Yv/8JGUysPSCCIo3YHodORuB6KHIUNvtP4 Zso8+HBiSiMOID8zC2ip2TuIB+H2vSiEQfc2Z55Hj2aPS5vAxG1yLGrd+2Kmz2gnEj1esLjI2f0 B2PZCnIdPL3YDlcP839yd9RDV3PdLUQZojNnjl+njtIgacKuMrOjxQkPqjFJZVUkeUf0dDmx/fX YHJskarTz5CuBMnSNn/HKtGgDH/KbHq9EOK/hbFuTuDaVmJZ47c81NjevtvLI0MiYRqqXIDaAYV CQdO0F5vX3dNN8EdAHdfllx4UhMwftpB48avWXu12arm1Oo+ X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A The dp_power submodule is limited to handling the clocks only following previous cleanups. Fold it into the dp_ctrl submodule, removing one unnecessary level of indirection. Signed-off-by: Dmitry Baryshkov Tested-by: Kuogee Hsieh Reviewed-by: Kuogee Hsieh --- drivers/gpu/drm/msm/Makefile | 1 - drivers/gpu/drm/msm/dp/dp_ctrl.c | 150 +++++++++++++++++++++++++++---- drivers/gpu/drm/msm/dp/dp_ctrl.h | 6 +- drivers/gpu/drm/msm/dp/dp_display.c | 24 +---- drivers/gpu/drm/msm/dp/dp_power.c | 170 ------------------------------------ drivers/gpu/drm/msm/dp/dp_power.h | 74 ---------------- 6 files changed, 142 insertions(+), 283 deletions(-) diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index b1173128b5b9..8dbdf3fba69e 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -128,7 +128,6 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \ dp/dp_link.o \ dp/dp_panel.o \ dp/dp_parser.o \ - dp/dp_power.o \ dp/dp_audio.o msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c index 77a8d9366ed7..da29281c575b 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c @@ -76,13 +76,16 @@ struct dp_ctrl_private { struct drm_dp_aux *aux; struct dp_panel *panel; struct dp_link *link; - struct dp_power *power; struct dp_parser *parser; struct dp_catalog *catalog; struct completion idle_comp; struct completion psr_op_comp; struct completion video_comp; + + bool core_clks_on; + bool link_clks_on; + bool stream_clks_on; }; static int dp_aux_link_configure(struct drm_dp_aux *aux, @@ -1338,6 +1341,83 @@ static void dp_ctrl_set_clock_rate(struct dp_ctrl_private *ctrl, name, rate); } +int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, + enum dp_pm_type pm_type, bool enable) +{ + struct dp_ctrl_private *ctrl; + struct dss_module_power *mp; + int ret = 0; + + ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); + + if (pm_type != DP_CORE_PM && + pm_type != DP_CTRL_PM && + pm_type != DP_STREAM_PM) { + DRM_ERROR("unsupported ctrl module: %s\n", + dp_parser_pm_name(pm_type)); + return -EINVAL; + } + + if (enable) { + if (pm_type == DP_CORE_PM && ctrl->core_clks_on) { + drm_dbg_dp(ctrl->drm_dev, + "core clks already enabled\n"); + return 0; + } + + if (pm_type == DP_CTRL_PM && ctrl->link_clks_on) { + drm_dbg_dp(ctrl->drm_dev, + "links clks already enabled\n"); + return 0; + } + + if (pm_type == DP_STREAM_PM && ctrl->stream_clks_on) { + drm_dbg_dp(ctrl->drm_dev, + "pixel clks already enabled\n"); + return 0; + } + + if ((pm_type == DP_CTRL_PM) && (!ctrl->core_clks_on)) { + drm_dbg_dp(ctrl->drm_dev, + "Enable core clks before link clks\n"); + mp = &ctrl->parser->mp[DP_CORE_PM]; + + ret = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); + if (ret) + return ret; + + ctrl->core_clks_on = true; + } + } + + mp = &ctrl->parser->mp[pm_type]; + if (enable) { + ret = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); + if (ret) + return ret; + } else { + clk_bulk_disable_unprepare(mp->num_clk, mp->clocks); + } + + if (pm_type == DP_CORE_PM) + ctrl->core_clks_on = enable; + else if (pm_type == DP_STREAM_PM) + ctrl->stream_clks_on = enable; + else + ctrl->link_clks_on = enable; + + drm_dbg_dp(ctrl->drm_dev, "%s clocks for %s\n", + enable ? "enable" : "disable", + dp_parser_pm_name(pm_type)); + drm_dbg_dp(ctrl->drm_dev, + "stream_clks:%s link_clks:%s core_clks:%s\n", + ctrl->stream_clks_on ? "on" : "off", + ctrl->link_clks_on ? "on" : "off", + ctrl->core_clks_on ? "on" : "off"); + + return 0; +} + static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) { int ret = 0; @@ -1354,7 +1434,7 @@ static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) phy_power_on(phy); dev_pm_opp_set_rate(ctrl->dev, ctrl->link->link_params.rate * 1000); - ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, true); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, true); if (ret) DRM_ERROR("Unable to start link clocks. ret=%d\n", ret); @@ -1502,7 +1582,7 @@ static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl) * link maintenance. */ dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); if (ret) { DRM_ERROR("Failed to disable clocks. ret=%d\n", ret); return ret; @@ -1534,7 +1614,7 @@ static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl) dp_catalog_ctrl_reset(ctrl->catalog); dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); if (ret) { DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); } @@ -1656,7 +1736,7 @@ static int dp_ctrl_process_phy_test_request(struct dp_ctrl_private *ctrl) pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; dp_ctrl_set_clock_rate(ctrl, DP_STREAM_PM, "stream_pixel", pixel_rate * 1000); - ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, true); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, true); if (ret) { DRM_ERROR("Failed to start pixel clocks. ret=%d\n", ret); return ret; @@ -1752,7 +1832,7 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) rate = ctrl->panel->link_info.rate; pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; - dp_power_clk_enable(ctrl->power, DP_CORE_PM, true); + dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CORE_PM, true); if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) { drm_dbg_dp(ctrl->drm_dev, @@ -1885,7 +1965,11 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train) ctrl->link->link_params.rate, ctrl->link->link_params.num_lanes, pixel_rate); - if (!dp_power_clk_status(ctrl->power, DP_CTRL_PM)) { /* link clk is off */ + drm_dbg_dp(ctrl->drm_dev, + "core_clk_on=%d link_clk_on=%d stream_clk_on=%d\n", + ctrl->core_clks_on, ctrl->link_clks_on, ctrl->stream_clks_on); + + if (!ctrl->link_clks_on) { /* link clk is off */ ret = dp_ctrl_enable_mainlink_clocks(ctrl); if (ret) { DRM_ERROR("Failed to start link clocks. ret=%d\n", ret); @@ -1895,7 +1979,7 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train) dp_ctrl_set_clock_rate(ctrl, DP_STREAM_PM, "stream_pixel", pixel_rate * 1000); - ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, true); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, true); if (ret) { DRM_ERROR("Unable to start pixel clocks. ret=%d\n", ret); goto end; @@ -1951,8 +2035,8 @@ int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); - if (dp_power_clk_status(ctrl->power, DP_STREAM_PM)) { - ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, false); + if (ctrl->stream_clks_on) { + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, false); if (ret) { DRM_ERROR("Failed to disable pclk. ret=%d\n", ret); return ret; @@ -1960,7 +2044,7 @@ int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) } dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); if (ret) { DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); return ret; @@ -1990,7 +2074,7 @@ int dp_ctrl_off_link(struct dp_ctrl *dp_ctrl) dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); - ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); if (ret) { DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); } @@ -2024,12 +2108,12 @@ int dp_ctrl_off(struct dp_ctrl *dp_ctrl) dp_catalog_ctrl_reset(ctrl->catalog); - ret = dp_power_clk_enable(ctrl->power, DP_STREAM_PM, false); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, false); if (ret) DRM_ERROR("Failed to disable pixel clocks. ret=%d\n", ret); dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_power_clk_enable(ctrl->power, DP_CTRL_PM, false); + ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); if (ret) { DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); } @@ -2086,9 +2170,38 @@ irqreturn_t dp_ctrl_isr(struct dp_ctrl *dp_ctrl) return ret; } +static int dp_ctrl_clk_init(struct dp_ctrl *dp_ctrl) +{ + struct dp_ctrl_private *ctrl_private; + int rc = 0; + struct dss_module_power *core, *ctrl, *stream; + struct device *dev; + + ctrl_private = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); + dev = ctrl_private->dev; + + core = &ctrl_private->parser->mp[DP_CORE_PM]; + ctrl = &ctrl_private->parser->mp[DP_CTRL_PM]; + stream = &ctrl_private->parser->mp[DP_STREAM_PM]; + + rc = devm_clk_bulk_get(dev, core->num_clk, core->clocks); + if (rc) + return rc; + + rc = devm_clk_bulk_get(dev, ctrl->num_clk, ctrl->clocks); + if (rc) + return -ENODEV; + + rc = devm_clk_bulk_get(dev, stream->num_clk, stream->clocks); + if (rc) + return -ENODEV; + + return 0; +} + struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, struct dp_panel *panel, struct drm_dp_aux *aux, - struct dp_power *power, struct dp_catalog *catalog, + struct dp_catalog *catalog, struct dp_parser *parser) { struct dp_ctrl_private *ctrl; @@ -2125,11 +2238,16 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, /* in parameters */ ctrl->parser = parser; ctrl->panel = panel; - ctrl->power = power; ctrl->aux = aux; ctrl->link = link; ctrl->catalog = catalog; ctrl->dev = dev; + ret = dp_ctrl_clk_init(&ctrl->dp_ctrl); + if (ret) { + dev_err(dev, "failed to init clocks\n"); + return ERR_PTR(ret); + } + return &ctrl->dp_ctrl; } diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h index b2c27d3532bf..85da5a7e5307 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h @@ -10,7 +10,6 @@ #include "dp_panel.h" #include "dp_link.h" #include "dp_parser.h" -#include "dp_power.h" #include "dp_catalog.h" struct dp_ctrl { @@ -28,7 +27,7 @@ irqreturn_t dp_ctrl_isr(struct dp_ctrl *dp_ctrl); void dp_ctrl_handle_sink_request(struct dp_ctrl *dp_ctrl); struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, struct dp_panel *panel, struct drm_dp_aux *aux, - struct dp_power *power, struct dp_catalog *catalog, + struct dp_catalog *catalog, struct dp_parser *parser); void dp_ctrl_reset_irq_ctrl(struct dp_ctrl *dp_ctrl, bool enable); @@ -39,4 +38,7 @@ void dp_ctrl_irq_phy_exit(struct dp_ctrl *dp_ctrl); void dp_ctrl_set_psr(struct dp_ctrl *dp_ctrl, bool enable); void dp_ctrl_config_psr(struct dp_ctrl *dp_ctrl); +int dp_ctrl_clk_enable(struct dp_ctrl *ctrl, enum dp_pm_type pm_type, + bool enable); + #endif /* _DP_CTRL_H_ */ diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 8cd18705740f..33e9d7deb3f8 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -15,13 +15,12 @@ #include "msm_drv.h" #include "msm_kms.h" #include "dp_parser.h" -#include "dp_power.h" +#include "dp_ctrl.h" #include "dp_catalog.h" #include "dp_aux.h" #include "dp_reg.h" #include "dp_link.h" #include "dp_panel.h" -#include "dp_ctrl.h" #include "dp_display.h" #include "dp_drm.h" #include "dp_audio.h" @@ -89,7 +88,6 @@ struct dp_display_private { struct dentry *root; struct dp_parser *parser; - struct dp_power *power; struct dp_catalog *catalog; struct drm_dp_aux *aux; struct dp_link *link; @@ -434,7 +432,7 @@ static void dp_display_host_init(struct dp_display_private *dp) dp->dp_display.connector_type, dp->core_initialized, dp->phy_initialized); - dp_power_clk_enable(dp->power, DP_CORE_PM, true); + dp_ctrl_clk_enable(dp->ctrl, DP_CORE_PM, true); dp_ctrl_reset_irq_ctrl(dp->ctrl, true); dp_aux_init(dp->aux); dp->core_initialized = true; @@ -448,7 +446,7 @@ static void dp_display_host_deinit(struct dp_display_private *dp) dp_ctrl_reset_irq_ctrl(dp->ctrl, false); dp_aux_deinit(dp->aux); - dp_power_clk_enable(dp->power, DP_CORE_PM, false); + dp_ctrl_clk_enable(dp->ctrl, DP_CORE_PM, false); dp->core_initialized = false; } @@ -731,14 +729,6 @@ static int dp_init_sub_modules(struct dp_display_private *dp) goto error; } - dp->power = dp_power_get(dev, dp->parser); - if (IS_ERR(dp->power)) { - rc = PTR_ERR(dp->power); - DRM_ERROR("failed to initialize power, rc = %d\n", rc); - dp->power = NULL; - goto error; - } - dp->aux = dp_aux_get(dev, dp->catalog, dp->dp_display.is_edp); if (IS_ERR(dp->aux)) { rc = PTR_ERR(dp->aux); @@ -768,7 +758,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp) } dp->ctrl = dp_ctrl_get(dev, dp->link, dp->panel, dp->aux, - dp->power, dp->catalog, dp->parser); + dp->catalog, dp->parser); if (IS_ERR(dp->ctrl)) { rc = PTR_ERR(dp->ctrl); DRM_ERROR("failed to initialize ctrl, rc = %d\n", rc); @@ -1266,12 +1256,6 @@ static int dp_display_probe(struct platform_device *pdev) return -EPROBE_DEFER; } - rc = dp_power_client_init(dp->power); - if (rc) { - DRM_ERROR("Power client create failed\n"); - goto err; - } - /* setup event q */ mutex_init(&dp->event_mutex); init_waitqueue_head(&dp->event_q); diff --git a/drivers/gpu/drm/msm/dp/dp_power.c b/drivers/gpu/drm/msm/dp/dp_power.c deleted file mode 100644 index f49e3aede308..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_power.c +++ /dev/null @@ -1,170 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#define pr_fmt(fmt) "[drm-dp] %s: " fmt, __func__ - -#include -#include -#include -#include -#include "dp_power.h" -#include "msm_drv.h" - -struct dp_power_private { - struct dp_parser *parser; - struct device *dev; - struct drm_device *drm_dev; - - struct dp_power dp_power; -}; - -static int dp_power_clk_init(struct dp_power_private *power) -{ - int rc = 0; - struct dss_module_power *core, *ctrl, *stream; - struct device *dev = power->dev; - - core = &power->parser->mp[DP_CORE_PM]; - ctrl = &power->parser->mp[DP_CTRL_PM]; - stream = &power->parser->mp[DP_STREAM_PM]; - - rc = devm_clk_bulk_get(dev, core->num_clk, core->clocks); - if (rc) - return rc; - - rc = devm_clk_bulk_get(dev, ctrl->num_clk, ctrl->clocks); - if (rc) - return -ENODEV; - - rc = devm_clk_bulk_get(dev, stream->num_clk, stream->clocks); - if (rc) - return -ENODEV; - - return 0; -} - -int dp_power_clk_status(struct dp_power *dp_power, enum dp_pm_type pm_type) -{ - struct dp_power_private *power; - - power = container_of(dp_power, struct dp_power_private, dp_power); - - drm_dbg_dp(power->drm_dev, - "core_clk_on=%d link_clk_on=%d stream_clk_on=%d\n", - dp_power->core_clks_on, dp_power->link_clks_on, dp_power->stream_clks_on); - - if (pm_type == DP_CORE_PM) - return dp_power->core_clks_on; - - if (pm_type == DP_CTRL_PM) - return dp_power->link_clks_on; - - if (pm_type == DP_STREAM_PM) - return dp_power->stream_clks_on; - - return 0; -} - -int dp_power_clk_enable(struct dp_power *dp_power, - enum dp_pm_type pm_type, bool enable) -{ - int rc = 0; - struct dp_power_private *power; - struct dss_module_power *mp; - - power = container_of(dp_power, struct dp_power_private, dp_power); - - if (pm_type != DP_CORE_PM && pm_type != DP_CTRL_PM && - pm_type != DP_STREAM_PM) { - DRM_ERROR("unsupported power module: %s\n", - dp_parser_pm_name(pm_type)); - return -EINVAL; - } - - if (enable) { - if (pm_type == DP_CORE_PM && dp_power->core_clks_on) { - drm_dbg_dp(power->drm_dev, - "core clks already enabled\n"); - return 0; - } - - if (pm_type == DP_CTRL_PM && dp_power->link_clks_on) { - drm_dbg_dp(power->drm_dev, - "links clks already enabled\n"); - return 0; - } - - if (pm_type == DP_STREAM_PM && dp_power->stream_clks_on) { - drm_dbg_dp(power->drm_dev, - "pixel clks already enabled\n"); - return 0; - } - - if ((pm_type == DP_CTRL_PM) && (!dp_power->core_clks_on)) { - drm_dbg_dp(power->drm_dev, - "Enable core clks before link clks\n"); - mp = &power->parser->mp[DP_CORE_PM]; - - rc = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); - if (rc) - return rc; - - dp_power->core_clks_on = true; - } - } - - mp = &power->parser->mp[pm_type]; - if (enable) { - rc = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); - if (rc) - return rc; - } else { - clk_bulk_disable_unprepare(mp->num_clk, mp->clocks); - } - - if (pm_type == DP_CORE_PM) - dp_power->core_clks_on = enable; - else if (pm_type == DP_STREAM_PM) - dp_power->stream_clks_on = enable; - else - dp_power->link_clks_on = enable; - - drm_dbg_dp(power->drm_dev, "%s clocks for %s\n", - enable ? "enable" : "disable", - dp_parser_pm_name(pm_type)); - drm_dbg_dp(power->drm_dev, - "strem_clks:%s link_clks:%s core_clks:%s\n", - dp_power->stream_clks_on ? "on" : "off", - dp_power->link_clks_on ? "on" : "off", - dp_power->core_clks_on ? "on" : "off"); - - return 0; -} - -int dp_power_client_init(struct dp_power *dp_power) -{ - struct dp_power_private *power; - - power = container_of(dp_power, struct dp_power_private, dp_power); - - return dp_power_clk_init(power); -} - -struct dp_power *dp_power_get(struct device *dev, struct dp_parser *parser) -{ - struct dp_power_private *power; - struct dp_power *dp_power; - - power = devm_kzalloc(dev, sizeof(*power), GFP_KERNEL); - if (!power) - return ERR_PTR(-ENOMEM); - - power->parser = parser; - power->dev = dev; - - dp_power = &power->dp_power; - - return dp_power; -} diff --git a/drivers/gpu/drm/msm/dp/dp_power.h b/drivers/gpu/drm/msm/dp/dp_power.h deleted file mode 100644 index eb836b5aa24a..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_power.h +++ /dev/null @@ -1,74 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#ifndef _DP_POWER_H_ -#define _DP_POWER_H_ - -#include "dp_parser.h" - -/** - * sruct dp_power - DisplayPort's power related data - * - * @init: initializes the regulators/core clocks/GPIOs/pinctrl - * @deinit: turns off the regulators/core clocks/GPIOs/pinctrl - * @clk_enable: enable/disable the DP clocks - * @set_pixel_clk_parent: set the parent of DP pixel clock - */ -struct dp_power { - bool core_clks_on; - bool link_clks_on; - bool stream_clks_on; -}; - -/** - * dp_power_clk_status() - display controller clocks status - * - * @power: instance of power module - * @pm_type: type of pm, core/ctrl/phy - * return: status of power clocks - * - * This API return status of DP clocks - */ - -int dp_power_clk_status(struct dp_power *dp_power, enum dp_pm_type pm_type); - -/** - * dp_power_clk_enable() - enable display controller clocks - * - * @power: instance of power module - * @pm_type: type of pm, core/ctrl/phy - * @enable: enables or disables - * return: pointer to allocated power module data - * - * This API will call setrate and enable for DP clocks - */ - -int dp_power_clk_enable(struct dp_power *power, enum dp_pm_type pm_type, - bool enable); - -/** - * dp_power_client_init() - initialize clock and regulator modules - * - * @power: instance of power module - * return: 0 for success, error for failure. - * - * This API will configure the DisplayPort's clocks and regulator - * modules. - */ -int dp_power_client_init(struct dp_power *power); - -/** - * dp_power_get() - configure and get the DisplayPort power module data - * - * @parser: instance of parser module - * return: pointer to allocated power module data - * - * This API will configure the DisplayPort's power module and provides - * methods to be called by the client to configure the power related - * modules. - */ -struct dp_power *dp_power_get(struct device *dev, struct dp_parser *parser); - -#endif /* _DP_POWER_H_ */ From patchwork Fri Jan 26 18:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767625 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 A2F1C20B3D for ; Fri, 26 Jan 2024 18:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293594; cv=none; b=OdDVq5h5ZzkbQ0H8Swn4nW3dG6rAioDaTMrX+i3BH120kGCZa5kN2h0Ra18F5NloU+8hSikTdecmVYrgWcZachpp5OfNtAglnfUvHCE67XsR1xHza9+czfhn7xHIxdU+yE3TPU0G9104Z8PBPFqZmnRlIzW1JmTjk1WtWB8o9t8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293594; c=relaxed/simple; bh=hNPMvZ0gaSY5MPKRR/EBckDQolNgLCvX0skn+OxZNXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BtSTB+lONosQ5FzJd8MknIHoRciUZmUoKHygnzMQsJlbQf366lXVk9Qskagd4C81ms6ttkVj1w+mi7VDaQLs6+hNCmsMlw78Gsrjzzd/S4QpjT2yTAlfUjieIj30US/xIfcIkhffRSOXQ2gOb1Nw6QNZSbWaC1stVcU61mFDvIk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=lKIjeEfO; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lKIjeEfO" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2cf1fd1cc5bso7693891fa.3 for ; Fri, 26 Jan 2024 10:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293590; x=1706898390; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=becAfxylwmZejS0VIfTonRkPwt9DcFnsVmjDJA3q3c4=; b=lKIjeEfOXff51MP9bYhT9W/oMsL7n61ZmFfYkzdBd65Sz4GnYNWhlj7PaB0RuBGx5C quQILhF+0X2g7mef+Cg/zO9XAXQClJwksZMo/dvdBgqaiLPEgrMPN1KDyq55i+YzsWR8 tWngCEf03EEPRrPP223uLKd0rgJ7Xb1FQ7rR2QcdIn8FQejZcMRSem6zdlPYTsHbgnz3 0/8rCi7dIizrGuW8qOkKAensoKRM+M3BTxcLxlLsTfBLYB3QWxKSlbBOqiC1YKv61Bwv s5ctX9RYCFe9xRoU2xRVCSNfOKv+2ThUx6hUK+Jrr6QbsAS5owUStCppJwNwuAl9Z/nE 7tkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293590; x=1706898390; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=becAfxylwmZejS0VIfTonRkPwt9DcFnsVmjDJA3q3c4=; b=Yq69NRFyQ+QFvs76RNx95qg8wI122S4914cGsHHGJLYq2d3r2RB6H1wxniWA9gh1TW nJTUOozkKm8XM2SfAb3bIY+Pqa3xW4FE9Xl+d13cDUIgInlKfToYTKnNk/geoq2t4r55 TXEacKsbp20j9oeiDXp0CbwCFbFSRCp14GH3KmicSGqaRDFGQbSRBuUOGn14l1JeRiGe +fKn77+QFE9KcGlwZSflYrYh4NmJGJURflzYwduWPb7kMaCe84UkWEz5fshsJ53X74tV sPANY/cdR56rAsvElZJ6UzdKb/iQet3j5IgVic1WZUFCDYDPfjgcKMWawO7Yu/1g5aV4 bOFg== X-Gm-Message-State: AOJu0YxkVf54bKP5RENtUBHYqiJ9MQX4QHOxRZsNPUf+LFN4SpaI89wW QJWcU9DbyWYeG+rjeXu0bU8fVJN2D188kjepPArLoCfivd9Q5Z66mO37mi9KpK4= X-Google-Smtp-Source: AGHT+IFDgewkzfPfYs4LoKC03Wro/TzujtoDV1JPwPIUfoGEIGsM+W3SR9UE6BHvCdkG6Vd1ZyErVw== X-Received: by 2002:a2e:8316:0:b0:2cd:50a7:12d0 with SMTP id a22-20020a2e8316000000b002cd50a712d0mr235206ljh.38.1706293590616; Fri, 26 Jan 2024 10:26:30 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:30 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:25 +0200 Subject: [PATCH RESEND v3 06/15] drm/msm/dp: simplify stream clocks handling Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-6-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=10486; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=hNPMvZ0gaSY5MPKRR/EBckDQolNgLCvX0skn+OxZNXs=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lQSSYv8c1DSvtZRJhpBMqcUiTUMJ4Qzsp9m 6B/y62AkAmJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UAAKCRCLPIo+Aiko 1bJ5B/4+oMoasQ1D+tsbBp1nzqLZ5nio8y2dDl5L06I+E4qwZdO5s/Gt0zAsgalHpoV3Z31pZes TYcuSsndx+FqyG6uSErko82wDWde9a3xZshxudS1B/W7gjCw/dFlxmLEgb1QSkDz4S6NJa89WR9 aDAkAyZTCwDvlVGeCm840BNgjhbFG/qwO8GjuK/1gUaSoJZXkvVfwNyZ6sc42UyKtRAVXeygYBC 2NyIrzrln4v0DPe12y847cgQfwQWjb2SfP3E3mr/qDhECzWUDc77Zz1R9RTrZARcOcEy6pJuwb1 A6CktOV/skpgBuOLNfG1AEQ+I+hPNOeEkeCk3h/UDvzYlX+q X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A There is only a single DP_STREAM_PM clock, stream_pixel. Instead of using a separate dss_module_power instance for this single clock, handle this clock directly. This allows us to drop several wrapping functions. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_ctrl.c | 91 ++++++++++++++++---------------------- drivers/gpu/drm/msm/dp/dp_parser.c | 41 ++++------------- drivers/gpu/drm/msm/dp/dp_parser.h | 2 - 3 files changed, 47 insertions(+), 87 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c index da29281c575b..56a424a82a1b 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c @@ -79,6 +79,8 @@ struct dp_ctrl_private { struct dp_parser *parser; struct dp_catalog *catalog; + struct clk *pixel_clk; + struct completion idle_comp; struct completion psr_op_comp; struct completion video_comp; @@ -1320,27 +1322,6 @@ static int dp_ctrl_setup_main_link(struct dp_ctrl_private *ctrl, return ret; } -static void dp_ctrl_set_clock_rate(struct dp_ctrl_private *ctrl, - enum dp_pm_type module, char *name, unsigned long rate) -{ - u32 num = ctrl->parser->mp[module].num_clk; - struct clk_bulk_data *cfg = ctrl->parser->mp[module].clocks; - - while (num && strcmp(cfg->id, name)) { - num--; - cfg++; - } - - drm_dbg_dp(ctrl->drm_dev, "setting rate=%lu on clk=%s\n", - rate, name); - - if (num) - clk_set_rate(cfg->clk, rate); - else - DRM_ERROR("%s clock doesn't exit to set rate %lu\n", - name, rate); -} - int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, enum dp_pm_type pm_type, bool enable) { @@ -1351,8 +1332,7 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); if (pm_type != DP_CORE_PM && - pm_type != DP_CTRL_PM && - pm_type != DP_STREAM_PM) { + pm_type != DP_CTRL_PM) { DRM_ERROR("unsupported ctrl module: %s\n", dp_parser_pm_name(pm_type)); return -EINVAL; @@ -1371,12 +1351,6 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, return 0; } - if (pm_type == DP_STREAM_PM && ctrl->stream_clks_on) { - drm_dbg_dp(ctrl->drm_dev, - "pixel clks already enabled\n"); - return 0; - } - if ((pm_type == DP_CTRL_PM) && (!ctrl->core_clks_on)) { drm_dbg_dp(ctrl->drm_dev, "Enable core clks before link clks\n"); @@ -1401,8 +1375,6 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, if (pm_type == DP_CORE_PM) ctrl->core_clks_on = enable; - else if (pm_type == DP_STREAM_PM) - ctrl->stream_clks_on = enable; else ctrl->link_clks_on = enable; @@ -1734,14 +1706,23 @@ static int dp_ctrl_process_phy_test_request(struct dp_ctrl_private *ctrl) } pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; - dp_ctrl_set_clock_rate(ctrl, DP_STREAM_PM, "stream_pixel", pixel_rate * 1000); - - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, true); + ret = clk_set_rate(ctrl->pixel_clk, pixel_rate * 1000); if (ret) { - DRM_ERROR("Failed to start pixel clocks. ret=%d\n", ret); + DRM_ERROR("Failed to set pixel clock rate. ret=%d\n", ret); return ret; } + if (ctrl->stream_clks_on) { + drm_dbg_dp(ctrl->drm_dev, "pixel clks already enabled\n"); + } else { + ret = clk_prepare_enable(ctrl->pixel_clk); + if (ret) { + DRM_ERROR("Failed to start pixel clocks. ret=%d\n", ret); + return ret; + } + ctrl->stream_clks_on = true; + } + dp_ctrl_send_phy_test_pattern(ctrl); return 0; @@ -1977,14 +1958,23 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train) } } - dp_ctrl_set_clock_rate(ctrl, DP_STREAM_PM, "stream_pixel", pixel_rate * 1000); - - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, true); + ret = clk_set_rate(ctrl->pixel_clk, pixel_rate * 1000); if (ret) { - DRM_ERROR("Unable to start pixel clocks. ret=%d\n", ret); + DRM_ERROR("Failed to set pixel clock rate. ret=%d\n", ret); goto end; } + if (ctrl->stream_clks_on) { + drm_dbg_dp(ctrl->drm_dev, "pixel clks already enabled\n"); + } else { + ret = clk_prepare_enable(ctrl->pixel_clk); + if (ret) { + DRM_ERROR("Failed to start pixel clocks. ret=%d\n", ret); + goto end; + } + ctrl->stream_clks_on = true; + } + if (force_link_train || !dp_ctrl_channel_eq_ok(ctrl)) dp_ctrl_link_retrain(ctrl); @@ -2036,11 +2026,8 @@ int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); if (ctrl->stream_clks_on) { - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, false); - if (ret) { - DRM_ERROR("Failed to disable pclk. ret=%d\n", ret); - return ret; - } + clk_disable_unprepare(ctrl->pixel_clk); + ctrl->stream_clks_on = false; } dev_pm_opp_set_rate(ctrl->dev, 0); @@ -2108,9 +2095,10 @@ int dp_ctrl_off(struct dp_ctrl *dp_ctrl) dp_catalog_ctrl_reset(ctrl->catalog); - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_STREAM_PM, false); - if (ret) - DRM_ERROR("Failed to disable pixel clocks. ret=%d\n", ret); + if (ctrl->stream_clks_on) { + clk_disable_unprepare(ctrl->pixel_clk); + ctrl->stream_clks_on = false; + } dev_pm_opp_set_rate(ctrl->dev, 0); ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); @@ -2174,7 +2162,7 @@ static int dp_ctrl_clk_init(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl_private; int rc = 0; - struct dss_module_power *core, *ctrl, *stream; + struct dss_module_power *core, *ctrl; struct device *dev; ctrl_private = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); @@ -2182,7 +2170,6 @@ static int dp_ctrl_clk_init(struct dp_ctrl *dp_ctrl) core = &ctrl_private->parser->mp[DP_CORE_PM]; ctrl = &ctrl_private->parser->mp[DP_CTRL_PM]; - stream = &ctrl_private->parser->mp[DP_STREAM_PM]; rc = devm_clk_bulk_get(dev, core->num_clk, core->clocks); if (rc) @@ -2192,9 +2179,9 @@ static int dp_ctrl_clk_init(struct dp_ctrl *dp_ctrl) if (rc) return -ENODEV; - rc = devm_clk_bulk_get(dev, stream->num_clk, stream->clocks); - if (rc) - return -ENODEV; + ctrl_private->pixel_clk = devm_clk_get(dev, "stream_pixel"); + if (IS_ERR(ctrl_private->pixel_clk)) + return PTR_ERR(ctrl_private->pixel_clk); return 0; } diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index 2d9d126c119b..fe2b75f7555a 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -150,12 +150,11 @@ static inline bool dp_parser_check_prefix(const char *clk_prefix, static int dp_parser_init_clk_data(struct dp_parser *parser) { int num_clk, i, rc; - int core_clk_count = 0, ctrl_clk_count = 0, stream_clk_count = 0; + int core_clk_count = 0, ctrl_clk_count = 0; const char *clk_name; struct device *dev = &parser->pdev->dev; struct dss_module_power *core_power = &parser->mp[DP_CORE_PM]; struct dss_module_power *ctrl_power = &parser->mp[DP_CTRL_PM]; - struct dss_module_power *stream_power = &parser->mp[DP_STREAM_PM]; num_clk = of_property_count_strings(dev->of_node, "clock-names"); if (num_clk <= 0) { @@ -174,9 +173,6 @@ static int dp_parser_init_clk_data(struct dp_parser *parser) if (dp_parser_check_prefix("ctrl", clk_name)) ctrl_clk_count++; - - if (dp_parser_check_prefix("stream", clk_name)) - stream_clk_count++; } /* Initialize the CORE power module */ @@ -207,47 +203,30 @@ static int dp_parser_init_clk_data(struct dp_parser *parser) return -ENOMEM; } - /* Initialize the STREAM power module */ - if (stream_clk_count == 0) { - DRM_ERROR("no stream (pixel) clocks are defined\n"); - return -EINVAL; - } - - stream_power->num_clk = stream_clk_count; - stream_power->clocks = devm_kcalloc(dev, - stream_power->num_clk, sizeof(struct clk_bulk_data), - GFP_KERNEL); - if (!stream_power->clocks) { - stream_power->num_clk = 0; - return -ENOMEM; - } - - return 0; + return num_clk; } static int dp_parser_clock(struct dp_parser *parser) { int rc = 0, i = 0; int num_clk = 0; - int core_clk_index = 0, ctrl_clk_index = 0, stream_clk_index = 0; - int core_clk_count = 0, ctrl_clk_count = 0, stream_clk_count = 0; + int core_clk_index = 0, ctrl_clk_index = 0; + int core_clk_count = 0, ctrl_clk_count = 0; const char *clk_name; struct device *dev = &parser->pdev->dev; struct dss_module_power *core_power = &parser->mp[DP_CORE_PM]; struct dss_module_power *ctrl_power = &parser->mp[DP_CTRL_PM]; - struct dss_module_power *stream_power = &parser->mp[DP_STREAM_PM]; rc = dp_parser_init_clk_data(parser); - if (rc) { + if (rc < 0) { DRM_ERROR("failed to initialize power data %d\n", rc); - return -EINVAL; + return rc; } + num_clk = rc; + core_clk_count = core_power->num_clk; ctrl_clk_count = ctrl_power->num_clk; - stream_clk_count = stream_power->num_clk; - - num_clk = core_clk_count + ctrl_clk_count + stream_clk_count; for (i = 0; i < num_clk; i++) { rc = of_property_read_string_index(dev->of_node, "clock-names", @@ -260,10 +239,6 @@ static int dp_parser_clock(struct dp_parser *parser) core_clk_index < core_clk_count) { core_power->clocks[core_clk_index].id = devm_kstrdup(dev, clk_name, GFP_KERNEL); core_clk_index++; - } else if (dp_parser_check_prefix("stream", clk_name) && - stream_clk_index < stream_clk_count) { - stream_power->clocks[stream_clk_index].id = devm_kstrdup(dev, clk_name, GFP_KERNEL); - stream_clk_index++; } else if (dp_parser_check_prefix("ctrl", clk_name) && ctrl_clk_index < ctrl_clk_count) { ctrl_power->clocks[ctrl_clk_index].id = devm_kstrdup(dev, clk_name, GFP_KERNEL); diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index 4ccc432b4142..c6fe26602e07 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -19,7 +19,6 @@ enum dp_pm_type { DP_CORE_PM, DP_CTRL_PM, - DP_STREAM_PM, DP_MAX_PM }; @@ -40,7 +39,6 @@ static inline const char *dp_parser_pm_name(enum dp_pm_type module) switch (module) { case DP_CORE_PM: return "DP_CORE_PM"; case DP_CTRL_PM: return "DP_CTRL_PM"; - case DP_STREAM_PM: return "DP_STREAM_PM"; default: return "???"; } } From patchwork Fri Jan 26 18:26:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767624 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 8B58E20DC5 for ; Fri, 26 Jan 2024 18:26:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293595; cv=none; b=Zu6u2S14nhW212Ki6WaX7V/5Z5FpIIL5hBcvJG1mpp+6XH/4japv8d1s1shJOUpupV0feH5FQrsg4yyP9+VywXArqFzMXVyvxa+W82gzi4wrI+ZpMhOpkGZMNT5YufOc9KACpd4bMhYZ2ry4p8+cjjSkw5sUig3qRaX4GbX/kwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293595; c=relaxed/simple; bh=jlCbwCtXmASgMzTIlxwNTO3EoGrFovMlywq9Nb9Ul3Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hlN1j01A7/Wa3c6iTPlApfxNjZxrAURHzis610TyMGAXV3woTCnNvrFvgczz+KFcfaCKWF3KsPfbhinYs47k/w07E8Ow4Cw92bhKEJluulpIxqRblPLBu29cdvecjhOrXwOGCyPi2Dq9CdqBI/W3aVDBpmTYflLqEJqC47IX3pw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=BHvKcfnA; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BHvKcfnA" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2cddb2c2b54so6644891fa.1 for ; Fri, 26 Jan 2024 10:26:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293591; x=1706898391; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LV6p00KhO1LDwvwQC4F9WJVNdeFMCAAEui1qxHdo5Cw=; b=BHvKcfnAqOWpSkasf+M7SIb/0h7d88KxyqEiQxZBLz9wY7tnE1G6sveCzfcs/Ai2R4 P072eeDDLBUrHK4BvM+iqUXVWstSUvVLfoyII2EEk0knLvLAKpVHYY5kI5JObq/q7fPp C8lJ75fjY6nTlcGKWaHlND+cux/YAczZW/rJQdJ7xfYQSZQ2n6XvAgdueyb0WwL1qNY3 a1Zl4vI8efl+fV3DHS6zdZaSbLkPNxZPrDX6Y7CpI1X1LkUUNovtyiV2l7eUIQsS8iRJ 0cgfU/LwhUcVzAcxhEn/qQE/vcoOb784ujFs+zyfmAfq7alMrWGaIpCb/h0Qxn36G9JL jo2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293591; x=1706898391; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LV6p00KhO1LDwvwQC4F9WJVNdeFMCAAEui1qxHdo5Cw=; b=fJAnff+EaVcd16ifZce+4qPsxc1Z7JHfs96b5ifvjtVdodV6CSw9dwD6hQ6sL6Klqi ii+3P6ibiFxjD+xJeHu7mlCNIFmucbblRifdCqqxJ5gYhZe79OgK1CdfEAj1A4MM11XB DKTs9AsTlO6dY/0egh8jOCaRU8eDWE700+zBseHjEtdvEIgyVgpU0Az+0IAX2RaPEfyt hKS1c0m0UwMkipjehUIzlpCkukRAIYY/tofDswVERFWt8nNsUONTbdIjBV8e8BFlzqis uuiUcnKW9aPuns/GtyTZDkWfYB4QCpNuJIwidQ5EvjOQzXn/3r6yQQjXQoU/QGWxjv8X auzw== X-Gm-Message-State: AOJu0YyFDq3UfvKERlSaxRrRCz6x5iKBDvozS1AXFtRnoNDm1mpP/vbd ed6inxVers+2HdpL0+UoCL+mwVusaCfbI+AAAQPD0WUbXz7NG7TeCFyRq22bN88= X-Google-Smtp-Source: AGHT+IFe6n5lhuUGZ/t0dU5rxyqzKp6v88Ja4oC0wn4/NqqTa7zBrtXpaZn8zEdv77qwvMckCgFSzw== X-Received: by 2002:a2e:b910:0:b0:2cf:32d3:3073 with SMTP id b16-20020a2eb910000000b002cf32d33073mr191703ljb.47.1706293591463; Fri, 26 Jan 2024 10:26:31 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:30 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:26 +0200 Subject: [PATCH RESEND v3 07/15] drm/msm/dp: stop parsing clock names from DT Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-7-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=10440; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=jlCbwCtXmASgMzTIlxwNTO3EoGrFovMlywq9Nb9Ul3Y=; b=owGbwMvMwMXYbdNlx6SpcZXxtFoSQ+rmnwH/wsq3HTCT6yk5yBEbuqxtws+YZ046eu7LP6+/K BnBP8Wxk9GYhYGRi0FWTJHFp6Blasym5LAPO6bWwwxiZQKZwsDFKQAT6Yhi/593Z/MF9jSXSV11 OcVTGh29NwgenOa2cgJjn4bBvZszfotUMQrKWVycW13hpHVDVYx9Y7DcRZGwMyUVKil+XeId346 9WC3JrrFCsrBj5nJJxYmVkrNlbXWVnHfPfLIhVHN//oWqdPWSUsaQvSXprEd2+KtzOlde+VjzZd 1JfldXzeV+f7aa+lqpqBu37Xo9SW2/xqudq2RvfChwzQ7wrTe2brmd66TE5aLIHPNYN3ti1tFIA /GXxSsffnoaXrpW7vLtG8JC01mc65Ld2i/9lhHkvayctfONE+vKmoC2gw8//Uq/Nf118TYd1Rmb l+2oCPuZXtNnwMp6KUDo9Y6rGwXj+HVPrF4ZclqihO0QAA== X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A All supported platforms use the same clocks configuration. Instead of parsing names from DT in a pretty complex manner, use the static configuration. If at some point newer (or older) platforms have different clock configuration, this clock config can be moved to the device data. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_ctrl.c | 73 ++++++++++++++++++------ drivers/gpu/drm/msm/dp/dp_ctrl.h | 6 ++ drivers/gpu/drm/msm/dp/dp_parser.c | 112 ------------------------------------- drivers/gpu/drm/msm/dp/dp_parser.h | 22 -------- 4 files changed, 63 insertions(+), 150 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c index 56a424a82a1b..cfcf6136ffa6 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c @@ -69,6 +69,11 @@ struct dp_vc_tu_mapping_table { u8 tu_size_minus1; }; +struct dss_module_power { + unsigned int num_clk; + struct clk_bulk_data *clocks; +}; + struct dp_ctrl_private { struct dp_ctrl dp_ctrl; struct drm_device *drm_dev; @@ -79,6 +84,7 @@ struct dp_ctrl_private { struct dp_parser *parser; struct dp_catalog *catalog; + struct dss_module_power mp[DP_MAX_PM]; struct clk *pixel_clk; struct completion idle_comp; @@ -90,6 +96,15 @@ struct dp_ctrl_private { bool stream_clks_on; }; +static inline const char *dp_pm_name(enum dp_pm_type module) +{ + switch (module) { + case DP_CORE_PM: return "DP_CORE_PM"; + case DP_CTRL_PM: return "DP_CTRL_PM"; + default: return "???"; + } +} + static int dp_aux_link_configure(struct drm_dp_aux *aux, struct dp_link_info *link) { @@ -1334,7 +1349,7 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, if (pm_type != DP_CORE_PM && pm_type != DP_CTRL_PM) { DRM_ERROR("unsupported ctrl module: %s\n", - dp_parser_pm_name(pm_type)); + dp_pm_name(pm_type)); return -EINVAL; } @@ -1354,7 +1369,7 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, if ((pm_type == DP_CTRL_PM) && (!ctrl->core_clks_on)) { drm_dbg_dp(ctrl->drm_dev, "Enable core clks before link clks\n"); - mp = &ctrl->parser->mp[DP_CORE_PM]; + mp = &ctrl->mp[DP_CORE_PM]; ret = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); if (ret) @@ -1364,7 +1379,7 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, } } - mp = &ctrl->parser->mp[pm_type]; + mp = &ctrl->mp[pm_type]; if (enable) { ret = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); if (ret) @@ -1380,7 +1395,7 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, drm_dbg_dp(ctrl->drm_dev, "%s clocks for %s\n", enable ? "enable" : "disable", - dp_parser_pm_name(pm_type)); + dp_pm_name(pm_type)); drm_dbg_dp(ctrl->drm_dev, "stream_clks:%s link_clks:%s core_clks:%s\n", ctrl->stream_clks_on ? "on" : "off", @@ -2158,30 +2173,56 @@ irqreturn_t dp_ctrl_isr(struct dp_ctrl *dp_ctrl) return ret; } +static const char *core_clks[] = { + "core_iface", + "core_aux", +}; + +static const char *ctrl_clks[] = { + "ctrl_link", + "ctrl_link_iface", +}; + static int dp_ctrl_clk_init(struct dp_ctrl *dp_ctrl) { - struct dp_ctrl_private *ctrl_private; - int rc = 0; - struct dss_module_power *core, *ctrl; + struct dp_ctrl_private *ctrl; + struct dss_module_power *core, *link; struct device *dev; + int i, rc; + + ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); + dev = ctrl->dev; - ctrl_private = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - dev = ctrl_private->dev; + core = &ctrl->mp[DP_CORE_PM]; + link = &ctrl->mp[DP_CTRL_PM]; - core = &ctrl_private->parser->mp[DP_CORE_PM]; - ctrl = &ctrl_private->parser->mp[DP_CTRL_PM]; + core->num_clk = ARRAY_SIZE(core_clks); + core->clocks = devm_kcalloc(dev, core->num_clk, sizeof(*core->clocks), GFP_KERNEL); + if (!core->clocks) + return -ENOMEM; + + for (i = 0; i < core->num_clk; i++) + core->clocks[i].id = core_clks[i]; rc = devm_clk_bulk_get(dev, core->num_clk, core->clocks); if (rc) return rc; - rc = devm_clk_bulk_get(dev, ctrl->num_clk, ctrl->clocks); + link->num_clk = ARRAY_SIZE(ctrl_clks); + link->clocks = devm_kcalloc(dev, link->num_clk, sizeof(*link->clocks), GFP_KERNEL); + if (!link->clocks) + return -ENOMEM; + + for (i = 0; i < link->num_clk; i++) + link->clocks[i].id = ctrl_clks[i]; + + rc = devm_clk_bulk_get(dev, link->num_clk, link->clocks); if (rc) - return -ENODEV; + return rc; - ctrl_private->pixel_clk = devm_clk_get(dev, "stream_pixel"); - if (IS_ERR(ctrl_private->pixel_clk)) - return PTR_ERR(ctrl_private->pixel_clk); + ctrl->pixel_clk = devm_clk_get(dev, "stream_pixel"); + if (IS_ERR(ctrl->pixel_clk)) + return PTR_ERR(ctrl->pixel_clk); return 0; } diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h index 85da5a7e5307..d8007a9d8260 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h @@ -17,6 +17,12 @@ struct dp_ctrl { bool wide_bus_en; }; +enum dp_pm_type { + DP_CORE_PM, + DP_CTRL_PM, + DP_MAX_PM +}; + int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl); int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train); int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl); diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index fe2b75f7555a..de7cfc340f0c 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -141,114 +141,6 @@ static int dp_parser_misc(struct dp_parser *parser) return 0; } -static inline bool dp_parser_check_prefix(const char *clk_prefix, - const char *clk_name) -{ - return !strncmp(clk_prefix, clk_name, strlen(clk_prefix)); -} - -static int dp_parser_init_clk_data(struct dp_parser *parser) -{ - int num_clk, i, rc; - int core_clk_count = 0, ctrl_clk_count = 0; - const char *clk_name; - struct device *dev = &parser->pdev->dev; - struct dss_module_power *core_power = &parser->mp[DP_CORE_PM]; - struct dss_module_power *ctrl_power = &parser->mp[DP_CTRL_PM]; - - num_clk = of_property_count_strings(dev->of_node, "clock-names"); - if (num_clk <= 0) { - DRM_ERROR("no clocks are defined\n"); - return -EINVAL; - } - - for (i = 0; i < num_clk; i++) { - rc = of_property_read_string_index(dev->of_node, - "clock-names", i, &clk_name); - if (rc < 0) - return rc; - - if (dp_parser_check_prefix("core", clk_name)) - core_clk_count++; - - if (dp_parser_check_prefix("ctrl", clk_name)) - ctrl_clk_count++; - } - - /* Initialize the CORE power module */ - if (core_clk_count == 0) { - DRM_ERROR("no core clocks are defined\n"); - return -EINVAL; - } - - core_power->num_clk = core_clk_count; - core_power->clocks = devm_kcalloc(dev, - core_power->num_clk, sizeof(struct clk_bulk_data), - GFP_KERNEL); - if (!core_power->clocks) - return -ENOMEM; - - /* Initialize the CTRL power module */ - if (ctrl_clk_count == 0) { - DRM_ERROR("no ctrl clocks are defined\n"); - return -EINVAL; - } - - ctrl_power->num_clk = ctrl_clk_count; - ctrl_power->clocks = devm_kcalloc(dev, - ctrl_power->num_clk, sizeof(struct clk_bulk_data), - GFP_KERNEL); - if (!ctrl_power->clocks) { - ctrl_power->num_clk = 0; - return -ENOMEM; - } - - return num_clk; -} - -static int dp_parser_clock(struct dp_parser *parser) -{ - int rc = 0, i = 0; - int num_clk = 0; - int core_clk_index = 0, ctrl_clk_index = 0; - int core_clk_count = 0, ctrl_clk_count = 0; - const char *clk_name; - struct device *dev = &parser->pdev->dev; - struct dss_module_power *core_power = &parser->mp[DP_CORE_PM]; - struct dss_module_power *ctrl_power = &parser->mp[DP_CTRL_PM]; - - rc = dp_parser_init_clk_data(parser); - if (rc < 0) { - DRM_ERROR("failed to initialize power data %d\n", rc); - return rc; - } - - num_clk = rc; - - core_clk_count = core_power->num_clk; - ctrl_clk_count = ctrl_power->num_clk; - - for (i = 0; i < num_clk; i++) { - rc = of_property_read_string_index(dev->of_node, "clock-names", - i, &clk_name); - if (rc) { - DRM_ERROR("error reading clock-names %d\n", rc); - return rc; - } - if (dp_parser_check_prefix("core", clk_name) && - core_clk_index < core_clk_count) { - core_power->clocks[core_clk_index].id = devm_kstrdup(dev, clk_name, GFP_KERNEL); - core_clk_index++; - } else if (dp_parser_check_prefix("ctrl", clk_name) && - ctrl_clk_index < ctrl_clk_count) { - ctrl_power->clocks[ctrl_clk_index].id = devm_kstrdup(dev, clk_name, GFP_KERNEL); - ctrl_clk_index++; - } - } - - return 0; -} - int devm_dp_parser_find_next_bridge(struct device *dev, struct dp_parser *parser) { struct platform_device *pdev = parser->pdev; @@ -280,10 +172,6 @@ static int dp_parser_parse(struct dp_parser *parser) if (rc) return rc; - rc = dp_parser_clock(parser); - if (rc) - return rc; - return 0; } diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index c6fe26602e07..cad82c4d07da 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -16,12 +16,6 @@ #define DP_MAX_NUM_DP_LANES 4 #define DP_LINK_RATE_HBR2 540000 /* kbytes */ -enum dp_pm_type { - DP_CORE_PM, - DP_CTRL_PM, - DP_MAX_PM -}; - struct dss_io_region { size_t len; void __iomem *base; @@ -34,15 +28,6 @@ struct dss_io_data { struct dss_io_region p0; }; -static inline const char *dp_parser_pm_name(enum dp_pm_type module) -{ - switch (module) { - case DP_CORE_PM: return "DP_CORE_PM"; - case DP_CTRL_PM: return "DP_CTRL_PM"; - default: return "???"; - } -} - /** * struct dp_ctrl_resource - controller's IO related data * @@ -55,20 +40,13 @@ struct dp_io { union phy_configure_opts phy_opts; }; -struct dss_module_power { - unsigned int num_clk; - struct clk_bulk_data *clocks; -}; - /** * struct dp_parser - DP parser's data exposed to clients * * @pdev: platform data of the client - * @mp: gpio, regulator and clock related data */ struct dp_parser { struct platform_device *pdev; - struct dss_module_power mp[DP_MAX_PM]; struct dp_io io; u32 max_dp_lanes; u32 max_dp_link_rate; From patchwork Fri Jan 26 18:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 766449 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 5592920DC6 for ; Fri, 26 Jan 2024 18:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293596; cv=none; b=bj6/BZyxvzrHSc/BprwHOJ+Cn12sCRxH1Q1svpjdPzB4q4kmxlsRYf5cInU6Rjj8ey5/YlkjSVvmNNKsLq7fYhUThzhayBN7IFp7avf2NLQC2qX17CKBAcBZ4z7GKssvUaDy23hLvOKfvQ3qs5flkkEPhzbbFW74i2YpH/J5wGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293596; c=relaxed/simple; bh=CuOUcUYoOW9aEzG7k566U8KJoISzql09wErRpuOUKaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KqCAN9Gw5aYEWf0I+BiGBqat+rnhNqZwhmiU5YQXnPCsrIsjb/2jCJGvsaYmsVe/1rdXQ8hkjt/OQSQaeokqrQCgBueX6PXDjSUlouvRDYyhwb4dVWKRAlf4JocbjucoU1Nr3g9DnvM5TaXaDvihlguvzw3cC1RxlE48vaUglwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=grMkqyvV; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="grMkqyvV" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2cf42ca9bb2so9216651fa.1 for ; Fri, 26 Jan 2024 10:26:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293592; x=1706898392; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=FDjngIAgyaNOEXPfDUMIuujOfmjvFlpOeLVhFSGQ3io=; b=grMkqyvVlWookfEKXoi/o4X88Tna0/SFulbOnkbX780X1JE+f8/DW63+wofAWn5xBV torIcywjrBRWpetf3yUliBgJLmofoyt8TeO9WwT9wSCNvGZuJBGSlI2ZhjCTAjZmgDgv dnOAH7a/BARJyXyrBcWEhzZU7SOa3uiVthVE6WhaZhxTwYwrEjHQsewuH7J+wkhKlTtG U6zCGgCASolBL11cHdoQ7qAJ942nVVWHmWy9w7KrgmPs7G9jtdLUHSadHMyxnlg55CDo RJS/G30kx27M3DIDIiOL7f6a/jK5D8DAYJUIcE9CNmpayKH1bpAaGQDjOs+Jfd7xCS8m ykQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293592; x=1706898392; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FDjngIAgyaNOEXPfDUMIuujOfmjvFlpOeLVhFSGQ3io=; b=DJNOC+CVhaVvQDlXjpvLqSD7hLf9JkZW9Y1Mtk1bjeftrphij++JE7S3Mkbhh7Fe/G o2iy0j9a0U5Iw0Pewt2q6Z5R9GTuZmxRDVJeG/HEPwdm/2HJUAK8shk5XV4olb82CFZX oSDXxuPVjNZcuppOGRQK6fJj5xV+L62kiqdXDJ7mk4sFll7QUkrITEZ+cvjcY+eJpVJl V/RQNvHJgDqGimMQR7B79hHUECk3jrx15vWj39I7j0rK3Knp8CAd8CUfuprvsJ90zYlY Wtr9zm9zeAng/XbHNlGfxzkQiS0/9KBoYHcL90XsO5lFPgR7qqfv+DgrpMiugXG3VKma kIxQ== X-Gm-Message-State: AOJu0YxBxSH1yAnyDxCPQRq8S+prtjE1ZlfK9yQkrfNLU9oIJ+insR+s 1e4V6yE/drRxVsPssrZ64i4i1VsALoRGb/iEnbecpSz3qIeb9LMBNI6rrPyJ17g= X-Google-Smtp-Source: AGHT+IFXphI1kYlp3YvBXWbWG02DPEv3mXQiMhN77yi4pwgykj0H657zOsQ3VJ+Sb/Dvp0oBfyJ74g== X-Received: by 2002:a2e:9350:0:b0:2cf:4d88:1763 with SMTP id m16-20020a2e9350000000b002cf4d881763mr93947ljh.98.1706293592231; Fri, 26 Jan 2024 10:26:32 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:31 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:27 +0200 Subject: [PATCH RESEND v3 08/15] drm/msm/dp: split dp_ctrl_clk_enable into four functuions Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-8-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=15067; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=CuOUcUYoOW9aEzG7k566U8KJoISzql09wErRpuOUKaE=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lQNmuwnvMtAdWnWeW8XqJhmP2nOSPIVXx1p imHCbaP3KOJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UAAKCRCLPIo+Aiko 1U2JB/9QXvUlqVQ0V8zl6VsILjelMWxoP3yfHiL863g8YBpYiJaG8cvbbxnurkwwUFqzRjjHhLv uHbnduoJ5+B4UOqpdrTSIHXjBx8FwmKLkuDmzUjC7c4ypcK6xyOOa++op/yMUWnu5GTxt3wIlH+ uy/IyfEIUlL/k9lwnj4TaOiVLWEQbPlq8265+GETmqf72qAQTcE7a2mfENSlDIThjNyMN4w7cqM +ghBAic/jlz20LKYyYDP9VQuIzECqqnNIskFr8sTtF18aFKctfnAPvjFxDjr4+ZMB5zm0+Fx0W7 CBrx+JDxZdmYRP9cBx6SjskNqehcVNW7ZsFEyKirHSTUeovc X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Split the dp_ctrl_clk_enable() beast into four functions, each of them doing just a single item: enabling or disabling core or link clocks. This allows us to cleanup the dss_module_power structure and makes several dp_ctrl functions return void. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_ctrl.c | 220 +++++++++++++++++------------------- drivers/gpu/drm/msm/dp/dp_ctrl.h | 16 +-- drivers/gpu/drm/msm/dp/dp_display.c | 4 +- 3 files changed, 108 insertions(+), 132 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c index cfcf6136ffa6..e367eb8e5bea 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c @@ -69,11 +69,6 @@ struct dp_vc_tu_mapping_table { u8 tu_size_minus1; }; -struct dss_module_power { - unsigned int num_clk; - struct clk_bulk_data *clocks; -}; - struct dp_ctrl_private { struct dp_ctrl dp_ctrl; struct drm_device *drm_dev; @@ -84,7 +79,12 @@ struct dp_ctrl_private { struct dp_parser *parser; struct dp_catalog *catalog; - struct dss_module_power mp[DP_MAX_PM]; + unsigned int num_core_clks; + struct clk_bulk_data *core_clks; + + unsigned int num_link_clks; + struct clk_bulk_data *link_clks; + struct clk *pixel_clk; struct completion idle_comp; @@ -96,15 +96,6 @@ struct dp_ctrl_private { bool stream_clks_on; }; -static inline const char *dp_pm_name(enum dp_pm_type module) -{ - switch (module) { - case DP_CORE_PM: return "DP_CORE_PM"; - case DP_CTRL_PM: return "DP_CTRL_PM"; - default: return "???"; - } -} - static int dp_aux_link_configure(struct drm_dp_aux *aux, struct dp_link_info *link) { @@ -1337,67 +1328,76 @@ static int dp_ctrl_setup_main_link(struct dp_ctrl_private *ctrl, return ret; } -int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, - enum dp_pm_type pm_type, bool enable) +int dp_ctrl_core_clk_enable(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; - struct dss_module_power *mp; int ret = 0; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - if (pm_type != DP_CORE_PM && - pm_type != DP_CTRL_PM) { - DRM_ERROR("unsupported ctrl module: %s\n", - dp_pm_name(pm_type)); - return -EINVAL; + if (ctrl->core_clks_on) { + drm_dbg_dp(ctrl->drm_dev, "core clks already enabled\n"); + return 0; } - if (enable) { - if (pm_type == DP_CORE_PM && ctrl->core_clks_on) { - drm_dbg_dp(ctrl->drm_dev, - "core clks already enabled\n"); - return 0; - } + ret = clk_bulk_prepare_enable(ctrl->num_core_clks, ctrl->core_clks); + if (ret) + return ret; - if (pm_type == DP_CTRL_PM && ctrl->link_clks_on) { - drm_dbg_dp(ctrl->drm_dev, - "links clks already enabled\n"); - return 0; - } + ctrl->core_clks_on = true; - if ((pm_type == DP_CTRL_PM) && (!ctrl->core_clks_on)) { - drm_dbg_dp(ctrl->drm_dev, - "Enable core clks before link clks\n"); - mp = &ctrl->mp[DP_CORE_PM]; + drm_dbg_dp(ctrl->drm_dev, "enable core clocks \n"); + drm_dbg_dp(ctrl->drm_dev, "stream_clks:%s link_clks:%s core_clks:%s\n", + ctrl->stream_clks_on ? "on" : "off", + ctrl->link_clks_on ? "on" : "off", + ctrl->core_clks_on ? "on" : "off"); - ret = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); - if (ret) - return ret; + return 0; +} - ctrl->core_clks_on = true; - } +void dp_ctrl_core_clk_disable(struct dp_ctrl *dp_ctrl) +{ + struct dp_ctrl_private *ctrl; + + ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); + + clk_bulk_disable_unprepare(ctrl->num_core_clks, ctrl->core_clks); + + ctrl->core_clks_on = false; + + drm_dbg_dp(ctrl->drm_dev, "disable core clocks \n"); + drm_dbg_dp(ctrl->drm_dev, "stream_clks:%s link_clks:%s core_clks:%s\n", + ctrl->stream_clks_on ? "on" : "off", + ctrl->link_clks_on ? "on" : "off", + ctrl->core_clks_on ? "on" : "off"); +} + +static int dp_ctrl_link_clk_enable(struct dp_ctrl *dp_ctrl) +{ + struct dp_ctrl_private *ctrl; + int ret = 0; + + ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); + + if (ctrl->link_clks_on) { + drm_dbg_dp(ctrl->drm_dev, "links clks already enabled\n"); + return 0; } - mp = &ctrl->mp[pm_type]; - if (enable) { - ret = clk_bulk_prepare_enable(mp->num_clk, mp->clocks); - if (ret) - return ret; - } else { - clk_bulk_disable_unprepare(mp->num_clk, mp->clocks); + if (!ctrl->core_clks_on) { + drm_dbg_dp(ctrl->drm_dev, "Enable core clks before link clks\n"); + + dp_ctrl_core_clk_enable(dp_ctrl); } - if (pm_type == DP_CORE_PM) - ctrl->core_clks_on = enable; - else - ctrl->link_clks_on = enable; + ret = clk_bulk_prepare_enable(ctrl->num_link_clks, ctrl->link_clks); + if (ret) + return ret; - drm_dbg_dp(ctrl->drm_dev, "%s clocks for %s\n", - enable ? "enable" : "disable", - dp_pm_name(pm_type)); - drm_dbg_dp(ctrl->drm_dev, - "stream_clks:%s link_clks:%s core_clks:%s\n", + ctrl->link_clks_on = true; + + drm_dbg_dp(ctrl->drm_dev, "enale link clocks\n"); + drm_dbg_dp(ctrl->drm_dev, "stream_clks:%s link_clks:%s core_clks:%s\n", ctrl->stream_clks_on ? "on" : "off", ctrl->link_clks_on ? "on" : "off", ctrl->core_clks_on ? "on" : "off"); @@ -1405,6 +1405,23 @@ int dp_ctrl_clk_enable(struct dp_ctrl *dp_ctrl, return 0; } +static void dp_ctrl_link_clk_disable(struct dp_ctrl *dp_ctrl) +{ + struct dp_ctrl_private *ctrl; + + ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); + + clk_bulk_disable_unprepare(ctrl->num_link_clks, ctrl->link_clks); + + ctrl->link_clks_on = false; + + drm_dbg_dp(ctrl->drm_dev, "disabled link clocks\n"); + drm_dbg_dp(ctrl->drm_dev, "stream_clks:%s link_clks:%s core_clks:%s\n", + ctrl->stream_clks_on ? "on" : "off", + ctrl->link_clks_on ? "on" : "off", + ctrl->core_clks_on ? "on" : "off"); +} + static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) { int ret = 0; @@ -1421,7 +1438,7 @@ static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) phy_power_on(phy); dev_pm_opp_set_rate(ctrl->dev, ctrl->link->link_params.rate * 1000); - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, true); + ret = dp_ctrl_link_clk_enable(&ctrl->dp_ctrl); if (ret) DRM_ERROR("Unable to start link clocks. ret=%d\n", ret); @@ -1569,11 +1586,9 @@ static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl) * link maintenance. */ dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); - if (ret) { - DRM_ERROR("Failed to disable clocks. ret=%d\n", ret); - return ret; - } + + dp_ctrl_link_clk_disable(&ctrl->dp_ctrl); + phy_power_off(phy); /* hw recommended delay before re-enabling clocks */ msleep(20); @@ -1591,7 +1606,6 @@ static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl) { struct dp_io *dp_io; struct phy *phy; - int ret; dp_io = &ctrl->parser->io; phy = dp_io->phy; @@ -1601,10 +1615,7 @@ static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl) dp_catalog_ctrl_reset(ctrl->catalog); dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); - if (ret) { - DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); - } + dp_ctrl_link_clk_disable(&ctrl->dp_ctrl); phy_power_off(phy); @@ -1708,11 +1719,7 @@ static int dp_ctrl_process_phy_test_request(struct dp_ctrl_private *ctrl) * running. Add the global reset just before disabling the * link clocks and core clocks. */ - ret = dp_ctrl_off(&ctrl->dp_ctrl); - if (ret) { - DRM_ERROR("failed to disable DP controller\n"); - return ret; - } + dp_ctrl_off(&ctrl->dp_ctrl); ret = dp_ctrl_on_link(&ctrl->dp_ctrl); if (ret) { @@ -1828,7 +1835,7 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) rate = ctrl->panel->link_info.rate; pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; - dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CORE_PM, true); + dp_ctrl_core_clk_enable(&ctrl->dp_ctrl); if (ctrl->link->sink_request & DP_TEST_LINK_PHY_TEST_PATTERN) { drm_dbg_dp(ctrl->drm_dev, @@ -2024,12 +2031,11 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train) return ret; } -int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) +void dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; struct dp_io *dp_io; struct phy *phy; - int ret; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); dp_io = &ctrl->parser->io; @@ -2046,11 +2052,7 @@ int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) } dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); - if (ret) { - DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); - return ret; - } + dp_ctrl_link_clk_disable(&ctrl->dp_ctrl); phy_power_off(phy); @@ -2060,15 +2062,13 @@ int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) drm_dbg_dp(ctrl->drm_dev, "phy=%p init=%d power_on=%d\n", phy, phy->init_count, phy->power_count); - return ret; } -int dp_ctrl_off_link(struct dp_ctrl *dp_ctrl) +void dp_ctrl_off_link(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; struct dp_io *dp_io; struct phy *phy; - int ret; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); dp_io = &ctrl->parser->io; @@ -2076,10 +2076,7 @@ int dp_ctrl_off_link(struct dp_ctrl *dp_ctrl) dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); - if (ret) { - DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); - } + dp_ctrl_link_clk_disable(&ctrl->dp_ctrl); DRM_DEBUG_DP("Before, phy=%p init_count=%d power_on=%d\n", phy, phy->init_count, phy->power_count); @@ -2088,19 +2085,13 @@ int dp_ctrl_off_link(struct dp_ctrl *dp_ctrl) DRM_DEBUG_DP("After, phy=%p init_count=%d power_on=%d\n", phy, phy->init_count, phy->power_count); - - return ret; } -int dp_ctrl_off(struct dp_ctrl *dp_ctrl) +void dp_ctrl_off(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; struct dp_io *dp_io; struct phy *phy; - int ret = 0; - - if (!dp_ctrl) - return -EINVAL; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); dp_io = &ctrl->parser->io; @@ -2116,16 +2107,11 @@ int dp_ctrl_off(struct dp_ctrl *dp_ctrl) } dev_pm_opp_set_rate(ctrl->dev, 0); - ret = dp_ctrl_clk_enable(&ctrl->dp_ctrl, DP_CTRL_PM, false); - if (ret) { - DRM_ERROR("Failed to disable link clocks. ret=%d\n", ret); - } + dp_ctrl_link_clk_disable(&ctrl->dp_ctrl); phy_power_off(phy); drm_dbg_dp(ctrl->drm_dev, "phy=%p init=%d power_on=%d\n", phy, phy->init_count, phy->power_count); - - return ret; } irqreturn_t dp_ctrl_isr(struct dp_ctrl *dp_ctrl) @@ -2186,37 +2172,33 @@ static const char *ctrl_clks[] = { static int dp_ctrl_clk_init(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; - struct dss_module_power *core, *link; struct device *dev; int i, rc; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); dev = ctrl->dev; - core = &ctrl->mp[DP_CORE_PM]; - link = &ctrl->mp[DP_CTRL_PM]; - - core->num_clk = ARRAY_SIZE(core_clks); - core->clocks = devm_kcalloc(dev, core->num_clk, sizeof(*core->clocks), GFP_KERNEL); - if (!core->clocks) + ctrl->num_core_clks = ARRAY_SIZE(core_clks); + ctrl->core_clks = devm_kcalloc(dev, ctrl->num_core_clks, sizeof(*ctrl->core_clks), GFP_KERNEL); + if (!ctrl->core_clks) return -ENOMEM; - for (i = 0; i < core->num_clk; i++) - core->clocks[i].id = core_clks[i]; + for (i = 0; i < ctrl->num_core_clks; i++) + ctrl->core_clks[i].id = core_clks[i]; - rc = devm_clk_bulk_get(dev, core->num_clk, core->clocks); + rc = devm_clk_bulk_get(dev, ctrl->num_core_clks, ctrl->core_clks); if (rc) return rc; - link->num_clk = ARRAY_SIZE(ctrl_clks); - link->clocks = devm_kcalloc(dev, link->num_clk, sizeof(*link->clocks), GFP_KERNEL); - if (!link->clocks) + ctrl->num_link_clks = ARRAY_SIZE(ctrl_clks); + ctrl->link_clks = devm_kcalloc(dev, ctrl->num_link_clks, sizeof(*ctrl->link_clks), GFP_KERNEL); + if (!ctrl->link_clks) return -ENOMEM; - for (i = 0; i < link->num_clk; i++) - link->clocks[i].id = ctrl_clks[i]; + for (i = 0; i < ctrl->num_link_clks; i++) + ctrl->link_clks[i].id = ctrl_clks[i]; - rc = devm_clk_bulk_get(dev, link->num_clk, link->clocks); + rc = devm_clk_bulk_get(dev, ctrl->num_link_clks, ctrl->link_clks); if (rc) return rc; diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h index d8007a9d8260..023f14d0b021 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h @@ -17,17 +17,11 @@ struct dp_ctrl { bool wide_bus_en; }; -enum dp_pm_type { - DP_CORE_PM, - DP_CTRL_PM, - DP_MAX_PM -}; - int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl); int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train); -int dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl); -int dp_ctrl_off_link(struct dp_ctrl *dp_ctrl); -int dp_ctrl_off(struct dp_ctrl *dp_ctrl); +void dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl); +void dp_ctrl_off_link(struct dp_ctrl *dp_ctrl); +void dp_ctrl_off(struct dp_ctrl *dp_ctrl); void dp_ctrl_push_idle(struct dp_ctrl *dp_ctrl); irqreturn_t dp_ctrl_isr(struct dp_ctrl *dp_ctrl); void dp_ctrl_handle_sink_request(struct dp_ctrl *dp_ctrl); @@ -44,7 +38,7 @@ void dp_ctrl_irq_phy_exit(struct dp_ctrl *dp_ctrl); void dp_ctrl_set_psr(struct dp_ctrl *dp_ctrl, bool enable); void dp_ctrl_config_psr(struct dp_ctrl *dp_ctrl); -int dp_ctrl_clk_enable(struct dp_ctrl *ctrl, enum dp_pm_type pm_type, - bool enable); +int dp_ctrl_core_clk_enable(struct dp_ctrl *dp_ctrl); +void dp_ctrl_core_clk_disable(struct dp_ctrl *dp_ctrl); #endif /* _DP_CTRL_H_ */ diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 33e9d7deb3f8..6fbbd0f93d13 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -432,7 +432,7 @@ static void dp_display_host_init(struct dp_display_private *dp) dp->dp_display.connector_type, dp->core_initialized, dp->phy_initialized); - dp_ctrl_clk_enable(dp->ctrl, DP_CORE_PM, true); + dp_ctrl_core_clk_enable(dp->ctrl); dp_ctrl_reset_irq_ctrl(dp->ctrl, true); dp_aux_init(dp->aux); dp->core_initialized = true; @@ -446,7 +446,7 @@ static void dp_display_host_deinit(struct dp_display_private *dp) dp_ctrl_reset_irq_ctrl(dp->ctrl, false); dp_aux_deinit(dp->aux); - dp_ctrl_clk_enable(dp->ctrl, DP_CORE_PM, false); + dp_ctrl_core_clk_disable(dp->ctrl); dp->core_initialized = false; } From patchwork Fri Jan 26 18:26:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767623 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 CF12720DC9 for ; Fri, 26 Jan 2024 18:26:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293596; cv=none; b=VUD4ZEJX2QnbkY9AxCfTxEZUVf8zhoysOyJcUbZoF9pCo6KYMSlmF5s/ASuURgMPRHxD4D+7uSv3lABccoeJiXBG1YxZtvmjs/pJsY6UsnhWzujGJw3pgGosMlG5eylXkMQLLT7HSacQI+m2PvpUZl4KllYFpRjbva2Ry6BwWp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293596; c=relaxed/simple; bh=JHMCbSPE7gZXRzZ8Yh8uYk+Fdg3YzXkUqA/+AlXGaYM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K+rlYmBRS022P8dZkDcsxr+teHn6QkcNHLROrOYI+n3hXJoJ7sBSqhQRHriMYRAczLUQKLD6PELn7vHSa3rKX/68pi1+FXszbA/wjKSqe67F83rQRK9E7+3T/ekrkzAIPCY9b7lUIkbYnwmeSeuQ/ymOehZkG2sxliVQKsI3nlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Cnp1n5eW; arc=none smtp.client-ip=209.85.208.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Cnp1n5eW" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2cf3a095ba6so7708031fa.2 for ; Fri, 26 Jan 2024 10:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293593; x=1706898393; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=f23f6k2NURR3hjj9IxLe37rVyBQBMzjyoSIDJiZdG1c=; b=Cnp1n5eWx1NXQ/hS9a2XNSywEXowx06PMVO9nLLTQV/LOx+AozLbaqX3GIdCnCGpil ew2botblkYpm6AXC7IpF2BmFueJIiDjbvV/v7apaAsgKRfZ2cLGQMkp0p28QZI8RHiHC ph1zHKevz4+BbTc33hJLkOYxL6ugB+ujUgA5atb6q48i39gltv6qNmvW33T+0S/oSVyx dMhUDQ363MBkhne4qlAH6YVHODOyTg2yAK8PXT/W2XU5xSu2eorAU4OEjYcJ0NQzQZ56 EPVjdyQwO6r5OXH3MGpUXQaYDzFmC1AX9gPk53fQq3lfz3XdMbQcdNpgzC1RE+AraEYq xycg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293593; x=1706898393; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f23f6k2NURR3hjj9IxLe37rVyBQBMzjyoSIDJiZdG1c=; b=vwEff/ukJv2TWMGJgJxLOcc5w2AFjAKGaRJO0/qgI9MKjR0KCTVN/YXMJmTvC7ufi1 ldqznR/0bVJfRRxzkdYi/2Z81qu8cw0NZW3xdVwWl8N+MVikTF1eoXfIXg5eMPfVEXkI nW7bYYKlpFNrbMa0JiEoUp+f9KOYUI7XfL7dvzM4xChlQt1DIEkjmvQQEayfp9LhiViJ kWWewSqBn0ckecmO8MG+Q+QAZtf0NIuIg8mW8yRLzpOl3iUsmQc/pwwaMQFiUh7GrEN3 boEPMb7jzZyfG6RGK0TmLylvg/JkG247z4lRmBNlGiZvxk18y/1vBFZFhjXlHxAV5Sgm ersQ== X-Gm-Message-State: AOJu0Yz3HDTtnphRdmjVxby05JDLF7E09DhZNJzWnWNIlWEFBQrsVaUp TtKOWtffJ9fNo327bueKonuFToP1wyOQIz4pSNwXLkPg0e3kEgZP+LJmYsxxCVY= X-Google-Smtp-Source: AGHT+IGjlUrMhEpbIMW/rvZqRa/hDjK0BsUf0WeeaJvymIi56Gh1h1xsa5PM34V2c6oCS7P/cmRcjw== X-Received: by 2002:a2e:bba4:0:b0:2cf:2db4:cd88 with SMTP id y36-20020a2ebba4000000b002cf2db4cd88mr101343lje.106.1706293592858; Fri, 26 Jan 2024 10:26:32 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:32 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:28 +0200 Subject: [PATCH RESEND v3 09/15] drm/msm/dp: move phy_configure_opts to dp_ctrl Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-9-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=6449; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=JHMCbSPE7gZXRzZ8Yh8uYk+Fdg3YzXkUqA/+AlXGaYM=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lQxLXdlmfBOU6OoF+Yl2vx9gwZWj+dopw7a YnF4Cr3us2JATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UAAKCRCLPIo+Aiko 1URoB/9sQLRTGk6UHNgPhrcEHssY0Wls+S8HiMKWxanXOLJ7WbMEC1PXKafmwQcktR0XUSrI1Bt sTjdzMhZj7iK5uH7R+D/q2k8DsG86BWVCH5U/VHDY22i7jO+bPLQ4qMmVKqxrWQNamWW9mFNw0K eDVEj1AaN+lUvAmMF8AkyrhW2l62FsQCOrYmUGrAKaT2Sq5deizJhAASB19EhBqJ8pBTPKKYW71 Wz5kAlYTbJqKt22o8g8U5Zz5x15OvXT8lKsWS7nZJTXaNwHm3KwgixT6emyNwr4yu0IVL8HAj6a t36IBZKgS6Qys9Gn1/JmwmzpFLA3IfTQ6gHXWe/awJYBIpVH X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A There is little point in sharing phy configuration structure between several modules. Move it to dp_ctrl, which becomes the only submodule re-configuring the PHY. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_catalog.c | 19 ----------------- drivers/gpu/drm/msm/dp/dp_catalog.h | 2 -- drivers/gpu/drm/msm/dp/dp_ctrl.c | 41 ++++++++++++++++++++++++------------- drivers/gpu/drm/msm/dp/dp_parser.h | 3 --- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.c b/drivers/gpu/drm/msm/dp/dp_catalog.c index 5142aeb705a4..e07651768805 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.c +++ b/drivers/gpu/drm/msm/dp/dp_catalog.c @@ -765,25 +765,6 @@ void dp_catalog_ctrl_phy_reset(struct dp_catalog *dp_catalog) dp_write_ahb(catalog, REG_DP_PHY_CTRL, 0x0); } -int dp_catalog_ctrl_update_vx_px(struct dp_catalog *dp_catalog, - u8 v_level, u8 p_level) -{ - struct dp_catalog_private *catalog = container_of(dp_catalog, - struct dp_catalog_private, dp_catalog); - struct dp_io *dp_io = catalog->io; - struct phy *phy = dp_io->phy; - struct phy_configure_opts_dp *opts_dp = &dp_io->phy_opts.dp; - - /* TODO: Update for all lanes instead of just first one */ - opts_dp->voltage[0] = v_level; - opts_dp->pre[0] = p_level; - opts_dp->set_voltages = 1; - phy_configure(phy, &dp_io->phy_opts); - opts_dp->set_voltages = 0; - - return 0; -} - void dp_catalog_ctrl_send_phy_pattern(struct dp_catalog *dp_catalog, u32 pattern) { diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.h b/drivers/gpu/drm/msm/dp/dp_catalog.h index 38786e855b51..ba7c62ba7ca3 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.h +++ b/drivers/gpu/drm/msm/dp/dp_catalog.h @@ -111,8 +111,6 @@ void dp_catalog_ctrl_set_psr(struct dp_catalog *dp_catalog, bool enter); u32 dp_catalog_link_is_connected(struct dp_catalog *dp_catalog); u32 dp_catalog_hpd_get_intr_status(struct dp_catalog *dp_catalog); void dp_catalog_ctrl_phy_reset(struct dp_catalog *dp_catalog); -int dp_catalog_ctrl_update_vx_px(struct dp_catalog *dp_catalog, u8 v_level, - u8 p_level); int dp_catalog_ctrl_get_interrupt(struct dp_catalog *dp_catalog); u32 dp_catalog_ctrl_read_psr_interrupt_status(struct dp_catalog *dp_catalog); void dp_catalog_ctrl_update_transfer_unit(struct dp_catalog *dp_catalog, diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c index e367eb8e5bea..4aea72a2b8e8 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c @@ -87,6 +87,8 @@ struct dp_ctrl_private { struct clk *pixel_clk; + union phy_configure_opts phy_opts; + struct completion idle_comp; struct completion psr_op_comp; struct completion video_comp; @@ -1017,6 +1019,21 @@ static int dp_ctrl_wait4video_ready(struct dp_ctrl_private *ctrl) return ret; } +static int dp_ctrl_set_vx_px(struct dp_ctrl_private *ctrl, + u8 v_level, u8 p_level) +{ + union phy_configure_opts *phy_opts = &ctrl->phy_opts; + + /* TODO: Update for all lanes instead of just first one */ + phy_opts->dp.voltage[0] = v_level; + phy_opts->dp.pre[0] = p_level; + phy_opts->dp.set_voltages = 1; + phy_configure(ctrl->parser->io.phy, phy_opts); + phy_opts->dp.set_voltages = 0; + + return 0; +} + static int dp_ctrl_update_vx_px(struct dp_ctrl_private *ctrl) { struct dp_link *link = ctrl->link; @@ -1029,7 +1046,7 @@ static int dp_ctrl_update_vx_px(struct dp_ctrl_private *ctrl) drm_dbg_dp(ctrl->drm_dev, "voltage level: %d emphasis level: %d\n", voltage_swing_level, pre_emphasis_level); - ret = dp_catalog_ctrl_update_vx_px(ctrl->catalog, + ret = dp_ctrl_set_vx_px(ctrl, voltage_swing_level, pre_emphasis_level); if (ret) @@ -1425,16 +1442,14 @@ static void dp_ctrl_link_clk_disable(struct dp_ctrl *dp_ctrl) static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) { int ret = 0; - struct dp_io *dp_io = &ctrl->parser->io; - struct phy *phy = dp_io->phy; - struct phy_configure_opts_dp *opts_dp = &dp_io->phy_opts.dp; + struct phy *phy = ctrl->parser->io.phy; const u8 *dpcd = ctrl->panel->dpcd; - opts_dp->lanes = ctrl->link->link_params.num_lanes; - opts_dp->link_rate = ctrl->link->link_params.rate / 100; - opts_dp->ssc = drm_dp_max_downspread(dpcd); + ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes; + ctrl->phy_opts.dp.link_rate = ctrl->link->link_params.rate / 100; + ctrl->phy_opts.dp.ssc = drm_dp_max_downspread(dpcd); - phy_configure(phy, &dp_io->phy_opts); + phy_configure(phy, &ctrl->phy_opts); phy_power_on(phy); dev_pm_opp_set_rate(ctrl->dev, ctrl->link->link_params.rate * 1000); @@ -1572,14 +1587,12 @@ static bool dp_ctrl_use_fixed_nvid(struct dp_ctrl_private *ctrl) static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl) { + struct phy *phy = ctrl->parser->io.phy; int ret = 0; - struct dp_io *dp_io = &ctrl->parser->io; - struct phy *phy = dp_io->phy; - struct phy_configure_opts_dp *opts_dp = &dp_io->phy_opts.dp; dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); - opts_dp->lanes = ctrl->link->link_params.num_lanes; - phy_configure(phy, &dp_io->phy_opts); + ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes; + phy_configure(phy, &ctrl->phy_opts); /* * Disable and re-enable the mainlink clock since the * link clock might have been adjusted as part of the @@ -1659,7 +1672,7 @@ static bool dp_ctrl_send_phy_test_pattern(struct dp_ctrl_private *ctrl) drm_dbg_dp(ctrl->drm_dev, "request: 0x%x\n", pattern_requested); - if (dp_catalog_ctrl_update_vx_px(ctrl->catalog, + if (dp_ctrl_set_vx_px(ctrl, ctrl->link->phy_params.v_level, ctrl->link->phy_params.p_level)) { DRM_ERROR("Failed to set v/p levels\n"); diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index cad82c4d07da..b28052e87101 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -7,8 +7,6 @@ #define _DP_PARSER_H_ #include -#include -#include #include "msm_drv.h" @@ -37,7 +35,6 @@ struct dss_io_data { struct dp_io { struct dss_io_data dp_controller; struct phy *phy; - union phy_configure_opts phy_opts; }; /** From patchwork Fri Jan 26 18:26:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 766448 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 6A3BE20DD4 for ; Fri, 26 Jan 2024 18:26:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293597; cv=none; b=ojAq0PMZ1rS4q9u9iBGDT1Jz05kQIds/HJxDwlS8lcwA8RrfLP6QWJs8Jpl4RP9kceadAjg+t3Y0o8zrBCyDJH74XGLgeVIxhJYiDWqiOWnTfwcL79UeJA7AwPX1DZneLXFt/87Hz0aJwPMkd2GbNdPsRnzmwF2tP+0yQsFoZI4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293597; c=relaxed/simple; bh=lj8fVAqF9xjHx1KrBL3A1/vTOxjI6sPTTzeJIEKTWus=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=efX3QCnt415eIhG7pZ87IlUIV0d6nD63H2lp8YZxcFOG+jshl8yH50J903PDbSYQP6/0tcjs+H96t54ZKSI9XXQBkZO4rO3PGPF63+rHiIXorVDUoKBifgbXu4d1WnKUaX6TUbmZqmaY6myiOf94YNY1RIDPQbEQfdcCt4uSfT8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ncxcY8yJ; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ncxcY8yJ" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2ccec119587so8366471fa.0 for ; Fri, 26 Jan 2024 10:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293593; x=1706898393; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IQTuJ8wNeg68JOx46UjSbtRu40sdbbzeiAcOLYDTPCw=; b=ncxcY8yJ9ykn2Sgd4l/AAtxJS8RWCFkJFDUkw1zrk6Or0fLutCj8ioTRHNMfjgMamm a00mHbq8Akducg1g/JNU1El1hmp6ZLQLxY0icG9fupymyDgJl4kAdEIX19rFPA64kDmM 74uZQh4SPT+ImHX/Zc8w1z5fw2DKQb1vNBdsYnqOVADzFPsQ2DPVYbdRMo1WMl0mS2Al HKaCs5xy86ujEZ5VZl5b6pHPQwF/I+op10BvZDIvQEXNdjYJPXD4Fs39WaiiU0ZA7YKp 051bqf0e94O/MaNt4WV2WZJNWnpG/y5Dk+wXeqYtIPJPQaJV1lK7XIf+QVkfCiMFwhen g4XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293593; x=1706898393; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IQTuJ8wNeg68JOx46UjSbtRu40sdbbzeiAcOLYDTPCw=; b=Cx+VNyrsgY5V1tt6Yy74QNGOjGIimqmOnB36J7JP29XTM8aNScKV9zfq2xAO6KO6vw SvrCIryRFRh8oEiz+SDiEx+17wX6a7mtaIutakhZVYdIqaeSgWR4LKl5vzCj34gKPbAc FY4o7jKIJo/ELPAJuIPIkgtYEZJa6IIwodJdB5DA2qHHScdP6iYnaNRag+mFr0mLnyvi Kh9zDWeZh+SyGelTuI0ChqJp5FFXbns8LJEz4nSV4IhXKkZ9/y9nszb3w5dvtldHLe4+ y6g9chMM7o0juQ80k9IoN3UlpI++cYn9CrzomrVjAcdupqRcvTPhnC4GlX4Ii+TO7sLR t6sw== X-Gm-Message-State: AOJu0Yz1Y1SoTVX08pmfECRTAzFff1DhAHL3/xOfihn7BGSjEwH2GyWO vfVmOGwLyYG+Ar7g3OpCa3NWIYZkoB3J8s5pxRDQ9nM51dg+5FNgumr4mDq4eQw= X-Google-Smtp-Source: AGHT+IHmT/8FPVr4UsEYhUnTnxGmf4Tf0ZyUbxmSUo8KNUuoNIyPCgKK6nrVSykS9tFH+1x+7sDvIw== X-Received: by 2002:a2e:9011:0:b0:2cf:81d:3abe with SMTP id h17-20020a2e9011000000b002cf081d3abemr241205ljg.33.1706293593443; Fri, 26 Jan 2024 10:26:33 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:33 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:29 +0200 Subject: [PATCH RESEND v3 10/15] drm/msm/dp: remove PHY handling from dp_catalog.c Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-10-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4868; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=lj8fVAqF9xjHx1KrBL3A1/vTOxjI6sPTTzeJIEKTWus=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lRDUjtsgokGIChkNkcCSIk4Re+J4dW2QeZR oTatm+plwyJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UQAKCRCLPIo+Aiko 1QEQB/4+8auRK/nQooym4b7t8QyIhgOBY7o+1CqLBZfzU6fdlHastDtw12FpDtfuo98fEwHPf32 JLN95Ic0ogTDkHgJRLISoJbM7KMXEDAyEdG2V5UiyogPoyOw0eLlgR/3elhBuHfPD0oqpCw+sC5 xNcfN2vBOiIQyBuL5LUVHOpMs7hjFRcfl+Gyj2AjXb7YdHaYQ18O9EtaBwpM/t7kYR6hxzBooba uKSHfeusJVVFTFw33bmR3Ar2u2L7r8uAR4PTqneNMu3tEDjmYQUf6gFqbRdHjr2FraG5zK/NIIp b/BMn/JrTbBlbcjqiKCJEqCDaLzDWliFkCQgKcY+SH5TzI11 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Inline dp_catalog_aux_update_cfg() and call phy_calibrate() from dp_aux functions directly. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_aux.c | 9 +++++++-- drivers/gpu/drm/msm/dp/dp_aux.h | 1 + drivers/gpu/drm/msm/dp/dp_catalog.c | 12 ------------ drivers/gpu/drm/msm/dp/dp_catalog.h | 1 - drivers/gpu/drm/msm/dp/dp_display.c | 4 +++- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c index 03f4951c49f4..adbd5a367395 100644 --- a/drivers/gpu/drm/msm/dp/dp_aux.c +++ b/drivers/gpu/drm/msm/dp/dp_aux.c @@ -4,6 +4,7 @@ */ #include +#include #include #include "dp_reg.h" @@ -23,6 +24,8 @@ struct dp_aux_private { struct device *dev; struct dp_catalog *catalog; + struct phy *phy; + struct mutex mutex; struct completion comp; @@ -336,7 +339,7 @@ static ssize_t dp_aux_transfer(struct drm_dp_aux *dp_aux, if (aux->native) { aux->retry_cnt++; if (!(aux->retry_cnt % MAX_AUX_RETRIES)) - dp_catalog_aux_update_cfg(aux->catalog); + phy_calibrate(aux->phy); } /* reset aux if link is in connected state */ if (dp_catalog_link_is_connected(aux->catalog)) @@ -439,7 +442,7 @@ void dp_aux_reconfig(struct drm_dp_aux *dp_aux) aux = container_of(dp_aux, struct dp_aux_private, dp_aux); - dp_catalog_aux_update_cfg(aux->catalog); + phy_calibrate(aux->phy); dp_catalog_aux_reset(aux->catalog); } @@ -517,6 +520,7 @@ static int dp_wait_hpd_asserted(struct drm_dp_aux *dp_aux, } struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, + struct phy *phy, bool is_edp) { struct dp_aux_private *aux; @@ -537,6 +541,7 @@ struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, aux->dev = dev; aux->catalog = catalog; + aux->phy = phy; aux->retry_cnt = 0; /* diff --git a/drivers/gpu/drm/msm/dp/dp_aux.h b/drivers/gpu/drm/msm/dp/dp_aux.h index 511305da4f66..16d9b1758748 100644 --- a/drivers/gpu/drm/msm/dp/dp_aux.h +++ b/drivers/gpu/drm/msm/dp/dp_aux.h @@ -17,6 +17,7 @@ void dp_aux_deinit(struct drm_dp_aux *dp_aux); void dp_aux_reconfig(struct drm_dp_aux *dp_aux); struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, + struct phy *phy, bool is_edp); void dp_aux_put(struct drm_dp_aux *aux); diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.c b/drivers/gpu/drm/msm/dp/dp_catalog.c index e07651768805..4c6207797c99 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.c +++ b/drivers/gpu/drm/msm/dp/dp_catalog.c @@ -7,8 +7,6 @@ #include #include -#include -#include #include #include #include @@ -243,16 +241,6 @@ void dp_catalog_aux_enable(struct dp_catalog *dp_catalog, bool enable) dp_write_aux(catalog, REG_DP_AUX_CTRL, aux_ctrl); } -void dp_catalog_aux_update_cfg(struct dp_catalog *dp_catalog) -{ - struct dp_catalog_private *catalog = container_of(dp_catalog, - struct dp_catalog_private, dp_catalog); - struct dp_io *dp_io = catalog->io; - struct phy *phy = dp_io->phy; - - phy_calibrate(phy); -} - int dp_catalog_aux_wait_for_hpd_connect_state(struct dp_catalog *dp_catalog) { u32 state; diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.h b/drivers/gpu/drm/msm/dp/dp_catalog.h index ba7c62ba7ca3..1f3f58d4b8de 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.h +++ b/drivers/gpu/drm/msm/dp/dp_catalog.h @@ -84,7 +84,6 @@ int dp_catalog_aux_clear_trans(struct dp_catalog *dp_catalog, bool read); int dp_catalog_aux_clear_hw_interrupts(struct dp_catalog *dp_catalog); void dp_catalog_aux_reset(struct dp_catalog *dp_catalog); void dp_catalog_aux_enable(struct dp_catalog *dp_catalog, bool enable); -void dp_catalog_aux_update_cfg(struct dp_catalog *dp_catalog); int dp_catalog_aux_wait_for_hpd_connect_state(struct dp_catalog *dp_catalog); u32 dp_catalog_aux_get_irq(struct dp_catalog *dp_catalog); diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 6fbbd0f93d13..c1a51c498e01 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -729,7 +729,9 @@ static int dp_init_sub_modules(struct dp_display_private *dp) goto error; } - dp->aux = dp_aux_get(dev, dp->catalog, dp->dp_display.is_edp); + dp->aux = dp_aux_get(dev, dp->catalog, + dp->parser->io.phy, + dp->dp_display.is_edp); if (IS_ERR(dp->aux)) { rc = PTR_ERR(dp->aux); DRM_ERROR("failed to initialize aux, rc = %d\n", rc); From patchwork Fri Jan 26 18:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767622 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 0F75520DD9 for ; Fri, 26 Jan 2024 18:26:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293597; cv=none; b=ehTAS5CLD3YIX2VLmGKpU03Mkxai+Ljfg37L+xlWuG/1tZ41De7s2cbfcvzFg/2wBilPNsSU7DQzOxggJnze4ZRWrqJqgPS6Cr+46zmD/YAsWBGGaT6Vx1l4Jght/h1owxmXpOdnHHXJPHri5+A9u87JUDCnq1nlThXUFlQtkyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293597; c=relaxed/simple; bh=wVNyfHlk6qxMhT/7/ZVII3sNHgLBjpEAI4YnszPdTtw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R4NtAP4eimfTlFsQSKROCkRgbZttjwJo89e4HB8W5xNt/0DyVbUrVM0LdPrHkoFRbiJHWv4tkc4LNYnztbe4DZF7WS19NQ4MeDv9XdBPMOBqRKs1OZ63/ynqCuiD+IiX/NpgnUAvzrKzaRoXYc8eG2uOQ6e7OsDqQMX/YSVPcKg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=I5jZCYeT; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="I5jZCYeT" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2cf1c3b23aeso6292711fa.1 for ; Fri, 26 Jan 2024 10:26:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293594; x=1706898394; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JBWEWQ1lHx25M39T9M547AD4gOAvWiz91uIbsab7PCM=; b=I5jZCYeTXmNth84e+rSe0+ihaT4wi1BzArlKAWZxUWzDpsdo/Yjlvb7C4Ngs9GbVQW s/ebg+QdNIchLJ6YSpoIZEB/j9BVtN5uHz03wrTFH+v6Wi9HG0bWl3VtC9FIwyD2mzv6 G4PtEUP0VLD3gnZ5o3PMRvlBnx5Z+gjA3M9IzjclqDKlBV4GZNzLIjkGCMbPXJ8CaUQo rjr9XSo83LO7/8yaVDXOcnjIkiixycdkKoZf5KVUIdFBgzXsJHY3HV8Kreb0tMYZf27G rjYDzIaA6RaCIRXeDm8U7x8iXxmLDqP7NS7Z8bXd6rH4iLcatHC1UKHc4wdnzL55PEPz 8nog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293594; x=1706898394; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JBWEWQ1lHx25M39T9M547AD4gOAvWiz91uIbsab7PCM=; b=SHMKwNU/t5kbqYA1wWib7dU43KhIGpx87epEyQFmtTgGyU8tWjn/XDsqOVYaNudbzO ov8y7barAz83Krb2x1k4QkbCUTWvFND45KWDM/F13KgLd2J+oVTZ0lUToJLGvw5f+erU XXmvBXFp6hDgG/wE4zycBcUuVUwM80hBQuMCkPcq2e7N0Ix5FOqZF7ARxGqdvGW1yFz+ 4xDnjDDR9LjiLFx3hYr2uG8TqTyB4nsY41vFmqxCpHrk3oJhws6nA7cXJHnbMYrxcdCL VXHt9ftEDuwkHXoKR+lqpSBKzfusXC9uGYMicHA4SsMnnvD/EnRQpmmWJGuwm6YNABJ6 Intg== X-Gm-Message-State: AOJu0YzlmBIzK50UUIvHYmDqUXjgvX5LWKRLneZyRRd4RjvZmCKbIAV5 5fljKsrXiR1P7IqMIZ7CskNEun9OJ2J7Q5SgsESnJrLh4QB5UxjlYYc4y971C+g= X-Google-Smtp-Source: AGHT+IE4CClqK4p7NoDUAQmR3krsIxOn0JGUEeJTvbfHgeZnwSSRyskcds0Fr6o7B/4LrrIXyGjhBg== X-Received: by 2002:a2e:b166:0:b0:2cd:a68b:f5c7 with SMTP id a6-20020a2eb166000000b002cda68bf5c7mr141667ljm.9.1706293594107; Fri, 26 Jan 2024 10:26:34 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:33 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:30 +0200 Subject: [PATCH RESEND v3 11/15] drm/msm/dp: handle PHY directly in dp_ctrl Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-11-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=6372; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=wVNyfHlk6qxMhT/7/ZVII3sNHgLBjpEAI4YnszPdTtw=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lRDPb8v3+I2P8bo8fCasslScdBIjyqaRNrv jBvfVt58dmJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UQAKCRCLPIo+Aiko 1Zd3B/40v9Iu0VQML+VtpxKqNDC55RhFx18caCGUs8An5Cit8lMWAUIupPWD1/TSjawOMI+joy9 WHsQKvDEcVdMCx+TAurQrqlvUbthkR6sx6BAv0tw7fa1CH/25QmdmgIcZmTDKIYmbWcMGyNKJdV akY7uyGK8jEmNDSx7OVcbxoy/Usg/l0V16HKV7Y/iQcxIiXZ3rTxFmlBw6yxFB1As7vvlai1Ref k1U0e+YfqTkuetLIGYMFXv7dYjzRjUEWREB1UBMNNnIadFnbLuPKu9VAzfbGSjkDK11oqfVpgxp GmjZsHb3OLeA4IEwGkMtx/3xqc51ICpCoRyy1eMguO9ln2xI X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A There is little point in going trough dp_parser->io indirection each time the driver needs to access the PHY. Store the pointer directly in dp_ctrl_private. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_ctrl.c | 37 +++++++++++++------------------------ drivers/gpu/drm/msm/dp/dp_ctrl.h | 2 +- drivers/gpu/drm/msm/dp/dp_display.c | 3 ++- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c index 4aea72a2b8e8..fc7ce315ae41 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c @@ -76,9 +76,10 @@ struct dp_ctrl_private { struct drm_dp_aux *aux; struct dp_panel *panel; struct dp_link *link; - struct dp_parser *parser; struct dp_catalog *catalog; + struct phy *phy; + unsigned int num_core_clks; struct clk_bulk_data *core_clks; @@ -1028,7 +1029,7 @@ static int dp_ctrl_set_vx_px(struct dp_ctrl_private *ctrl, phy_opts->dp.voltage[0] = v_level; phy_opts->dp.pre[0] = p_level; phy_opts->dp.set_voltages = 1; - phy_configure(ctrl->parser->io.phy, phy_opts); + phy_configure(ctrl->phy, phy_opts); phy_opts->dp.set_voltages = 0; return 0; @@ -1442,7 +1443,7 @@ static void dp_ctrl_link_clk_disable(struct dp_ctrl *dp_ctrl) static int dp_ctrl_enable_mainlink_clocks(struct dp_ctrl_private *ctrl) { int ret = 0; - struct phy *phy = ctrl->parser->io.phy; + struct phy *phy = ctrl->phy; const u8 *dpcd = ctrl->panel->dpcd; ctrl->phy_opts.dp.lanes = ctrl->link->link_params.num_lanes; @@ -1540,12 +1541,10 @@ void dp_ctrl_set_psr(struct dp_ctrl *dp_ctrl, bool enter) void dp_ctrl_phy_init(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; - struct dp_io *dp_io; struct phy *phy; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - dp_io = &ctrl->parser->io; - phy = dp_io->phy; + phy = ctrl->phy; dp_catalog_ctrl_phy_reset(ctrl->catalog); phy_init(phy); @@ -1557,12 +1556,10 @@ void dp_ctrl_phy_init(struct dp_ctrl *dp_ctrl) void dp_ctrl_phy_exit(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; - struct dp_io *dp_io; struct phy *phy; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - dp_io = &ctrl->parser->io; - phy = dp_io->phy; + phy = ctrl->phy; dp_catalog_ctrl_phy_reset(ctrl->catalog); phy_exit(phy); @@ -1587,7 +1584,7 @@ static bool dp_ctrl_use_fixed_nvid(struct dp_ctrl_private *ctrl) static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl) { - struct phy *phy = ctrl->parser->io.phy; + struct phy *phy = ctrl->phy; int ret = 0; dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); @@ -1617,11 +1614,9 @@ static int dp_ctrl_reinitialize_mainlink(struct dp_ctrl_private *ctrl) static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl) { - struct dp_io *dp_io; struct phy *phy; - dp_io = &ctrl->parser->io; - phy = dp_io->phy; + phy = ctrl->phy; dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); @@ -2047,12 +2042,10 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train) void dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; - struct dp_io *dp_io; struct phy *phy; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - dp_io = &ctrl->parser->io; - phy = dp_io->phy; + phy = ctrl->phy; /* set dongle to D3 (power off) mode */ dp_link_psm_config(ctrl->link, &ctrl->panel->link_info, true); @@ -2080,12 +2073,10 @@ void dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl) void dp_ctrl_off_link(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; - struct dp_io *dp_io; struct phy *phy; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - dp_io = &ctrl->parser->io; - phy = dp_io->phy; + phy = ctrl->phy; dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); @@ -2103,12 +2094,10 @@ void dp_ctrl_off_link(struct dp_ctrl *dp_ctrl) void dp_ctrl_off(struct dp_ctrl *dp_ctrl) { struct dp_ctrl_private *ctrl; - struct dp_io *dp_io; struct phy *phy; ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - dp_io = &ctrl->parser->io; - phy = dp_io->phy; + phy = ctrl->phy; dp_catalog_ctrl_mainlink_ctrl(ctrl->catalog, false); @@ -2225,7 +2214,7 @@ static int dp_ctrl_clk_init(struct dp_ctrl *dp_ctrl) struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, struct dp_panel *panel, struct drm_dp_aux *aux, struct dp_catalog *catalog, - struct dp_parser *parser) + struct phy *phy) { struct dp_ctrl_private *ctrl; int ret; @@ -2259,12 +2248,12 @@ struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, init_completion(&ctrl->video_comp); /* in parameters */ - ctrl->parser = parser; ctrl->panel = panel; ctrl->aux = aux; ctrl->link = link; ctrl->catalog = catalog; ctrl->dev = dev; + ctrl->phy = phy; ret = dp_ctrl_clk_init(&ctrl->dp_ctrl); if (ret) { diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h index 023f14d0b021..6e9f375b856a 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h @@ -28,7 +28,7 @@ void dp_ctrl_handle_sink_request(struct dp_ctrl *dp_ctrl); struct dp_ctrl *dp_ctrl_get(struct device *dev, struct dp_link *link, struct dp_panel *panel, struct drm_dp_aux *aux, struct dp_catalog *catalog, - struct dp_parser *parser); + struct phy *phy); void dp_ctrl_reset_irq_ctrl(struct dp_ctrl *dp_ctrl, bool enable); void dp_ctrl_phy_init(struct dp_ctrl *dp_ctrl); diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index c1a51c498e01..b8388e04bd0f 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -760,7 +760,8 @@ static int dp_init_sub_modules(struct dp_display_private *dp) } dp->ctrl = dp_ctrl_get(dev, dp->link, dp->panel, dp->aux, - dp->catalog, dp->parser); + dp->catalog, + dp->parser->io.phy); if (IS_ERR(dp->ctrl)) { rc = PTR_ERR(dp->ctrl); DRM_ERROR("failed to initialize ctrl, rc = %d\n", rc); From patchwork Fri Jan 26 18:26:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 766447 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 BADAC20DDD for ; Fri, 26 Jan 2024 18:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293599; cv=none; b=tFPReHMi9rB5C3RxXvLKBz080nPuKqnyOpzYoD/l1sDAb8ikpQ8izkx3KiA5AV4a2TOxP5fQPGbzfeyTeiiNpu4rqUqdxKi4x0L0LqckyDdI07ZHRSsWxnVBfMSbRIiPisH0qNB86qU1TjRdOSWsaGTVJlmBY7YaVG+BXt/lq0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293599; c=relaxed/simple; bh=4haPu/EU0pKy8SZtYGHLRCJK+SOCPq9DESc6lfR/q/8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g4BteUxEM5iWBHCZs5Fvi6tKnB0laZiAnrKJRA2GzceRJJaDYj5LoWJJLWvXjEW/f4ksQ38WuH0l50+CxdGagbv6M2FfoQRx2f16CjJzrrOzsbv6vbWdOtJ78hJ3h6k86gon9cCLzWaPPrmwMaC6eBtErmcPTrV/xzoytHxJtIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=bOQfmCTk; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bOQfmCTk" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2cc9fa5e8e1so7339341fa.3 for ; Fri, 26 Jan 2024 10:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293595; x=1706898395; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EPgkhGQ6zER9SACuWkra57baVOgflgf9HfV1jDO/gQk=; b=bOQfmCTkZ6FGS0/TiIoiuKddMe4Y+yT6UtaPKt1BGLLipxWHkLDRx6kaS8OyX4Gcro qlEqtzLNNTruBtC5vpmUrvJe6dD+9Q1ZSV7GCG//tZ4cBoP6sfFaaOlgdmUK6uf9Yh4K 2WGvdg1+wkEELOFbuYq5XDJYiVgJbnZe/Qe/GVoaUNglmEpS+5NzWrSNH5I8TKIefUAS fpyZR7nZb430zqJRK5gKOqC950J4OKjIQK2r16tGC2z9J8DXQz8C1US4SdouFgBVRZCE QZBwuCMsiThrIXqIK46v0ONSabM9One/x8y2UDnuec5i620qOb9XkmdYx7K3E1syKNh1 AJEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293595; x=1706898395; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EPgkhGQ6zER9SACuWkra57baVOgflgf9HfV1jDO/gQk=; b=nHgVG8M5WXJszfDWGLUTL4gdmeSeMcJxTErjLpqPBt4+/+HAUZHPuzswCPHNkJXjKp YsCdziA5/RzyrsKJGHqqHWRooXTexOJAB0Gr2lengnPCU6BIaV8X1LmcF+VFrtcwdEHm j8zK2TiqmDZeHf0AEKr1AYv8R0H/uOk2x20Q1yH6SlwNNrqbL7lV1TWRvFezuG7xCeYS xyTF+Bj/Xlwc+iQdE4m1+c318zWDcx06D+ixSFAZCHdZAOu4THxxOobl8mpyRpAz3a8n 1mQhOr2UOihI5zIxgBUVv8PhqbQo7chfK59IoQGKJScfcGyiAV931AIoCnqjwSWPNu8u EI6g== X-Gm-Message-State: AOJu0YyC/z/gFwNYlG+SOB8SAagRY0jFaH/sBPw/P+WNjwuIKt08cyCV uTNYh5Li5mmkfanrQDSS97LTMsDIZ8vXWRwisOvcmu0o90TqiEZu4M0i1q7E278= X-Google-Smtp-Source: AGHT+IHNbf1RWQTGTwOTTmjV8IgRKyp9pdRCGhqH8JGzTjFYfLJ8C1vbZ5A7MFP+cW+GkMS619T32Q== X-Received: by 2002:a2e:8513:0:b0:2cf:48c9:6ed1 with SMTP id j19-20020a2e8513000000b002cf48c96ed1mr142711lji.20.1706293594735; Fri, 26 Jan 2024 10:26:34 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:34 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:31 +0200 Subject: [PATCH RESEND v3 12/15] drm/msm/dp: move all IO handling to dp_catalog Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-12-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=15683; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=4haPu/EU0pKy8SZtYGHLRCJK+SOCPq9DESc6lfR/q/8=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lRb9R+eOBi8fM6Y4ELfUApM1OR2KGY6PYOu 8Rw/xKlkiKJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UQAKCRCLPIo+Aiko 1Qw0CACOBbPPD1LY/cE3sSjhZ4Mpe+YYcz+LWOfLzOa/qlnF8assxp/KT+2xBJmroY7/oajMyGP F/FF8S7dTyAMG9dT5HiSSxciLVYUSfO1h1ACn9CHEo8nzROgc7y5LIwkt973MrQ0t82kyOU31Ur tmVFOYxeZ/HTYurOg9AzFsNeOosf58DYJ8rc2tcI4aMp5DtVVnzd3w+Hsco7rV5O+4esHuRDp3Z 44tfo/q3nHXwhXGiy+7B9xaOstE11Hmd3MsPZwBRQLxlLiS8o3iHGqDCqwsuPWCJlMLW/mh8fLH 2RPcMwXNkhqEsTlLgQbC5BTLmuFBa32L4AnrFl4uoP5xk62U X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Rather than parsing the I/O addresses from dp_parser and then passing them via a struct pointer to dp_catalog, handle I/O region parsing in dp_catalog and drop it from dp_parser. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_catalog.c | 125 ++++++++++++++++++++++++++++++------ drivers/gpu/drm/msm/dp/dp_catalog.h | 2 +- drivers/gpu/drm/msm/dp/dp_display.c | 6 +- drivers/gpu/drm/msm/dp/dp_parser.c | 73 +-------------------- drivers/gpu/drm/msm/dp/dp_parser.h | 26 +------- 5 files changed, 114 insertions(+), 118 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.c b/drivers/gpu/drm/msm/dp/dp_catalog.c index 4c6207797c99..541aac2cb246 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.c +++ b/drivers/gpu/drm/msm/dp/dp_catalog.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -53,10 +54,31 @@ (PSR_UPDATE_MASK | PSR_CAPTURE_MASK | PSR_EXIT_MASK | \ PSR_UPDATE_ERROR_MASK | PSR_WAKE_ERROR_MASK) +#define DP_DEFAULT_AHB_OFFSET 0x0000 +#define DP_DEFAULT_AHB_SIZE 0x0200 +#define DP_DEFAULT_AUX_OFFSET 0x0200 +#define DP_DEFAULT_AUX_SIZE 0x0200 +#define DP_DEFAULT_LINK_OFFSET 0x0400 +#define DP_DEFAULT_LINK_SIZE 0x0C00 +#define DP_DEFAULT_P0_OFFSET 0x1000 +#define DP_DEFAULT_P0_SIZE 0x0400 + +struct dss_io_region { + size_t len; + void __iomem *base; +}; + +struct dss_io_data { + struct dss_io_region ahb; + struct dss_io_region aux; + struct dss_io_region link; + struct dss_io_region p0; +}; + struct dp_catalog_private { struct device *dev; struct drm_device *drm_dev; - struct dp_io *io; + struct dss_io_data io; u32 (*audio_map)[DP_AUDIO_SDP_HEADER_MAX]; struct dp_catalog dp_catalog; u8 aux_lut_cfg_index[PHY_AUX_CFG_MAX]; @@ -66,7 +88,7 @@ void dp_catalog_snapshot(struct dp_catalog *dp_catalog, struct msm_disp_state *d { struct dp_catalog_private *catalog = container_of(dp_catalog, struct dp_catalog_private, dp_catalog); - struct dss_io_data *dss = &catalog->io->dp_controller; + struct dss_io_data *dss = &catalog->io; msm_disp_snapshot_add_block(disp_state, dss->ahb.len, dss->ahb.base, "dp_ahb"); msm_disp_snapshot_add_block(disp_state, dss->aux.len, dss->aux.base, "dp_aux"); @@ -76,7 +98,7 @@ void dp_catalog_snapshot(struct dp_catalog *dp_catalog, struct msm_disp_state *d static inline u32 dp_read_aux(struct dp_catalog_private *catalog, u32 offset) { - return readl_relaxed(catalog->io->dp_controller.aux.base + offset); + return readl_relaxed(catalog->io.aux.base + offset); } static inline void dp_write_aux(struct dp_catalog_private *catalog, @@ -86,12 +108,12 @@ static inline void dp_write_aux(struct dp_catalog_private *catalog, * To make sure aux reg writes happens before any other operation, * this function uses writel() instread of writel_relaxed() */ - writel(data, catalog->io->dp_controller.aux.base + offset); + writel(data, catalog->io.aux.base + offset); } static inline u32 dp_read_ahb(const struct dp_catalog_private *catalog, u32 offset) { - return readl_relaxed(catalog->io->dp_controller.ahb.base + offset); + return readl_relaxed(catalog->io.ahb.base + offset); } static inline void dp_write_ahb(struct dp_catalog_private *catalog, @@ -101,7 +123,7 @@ static inline void dp_write_ahb(struct dp_catalog_private *catalog, * To make sure phy reg writes happens before any other operation, * this function uses writel() instread of writel_relaxed() */ - writel(data, catalog->io->dp_controller.ahb.base + offset); + writel(data, catalog->io.ahb.base + offset); } static inline void dp_write_p0(struct dp_catalog_private *catalog, @@ -111,7 +133,7 @@ static inline void dp_write_p0(struct dp_catalog_private *catalog, * To make sure interface reg writes happens before any other operation, * this function uses writel() instread of writel_relaxed() */ - writel(data, catalog->io->dp_controller.p0.base + offset); + writel(data, catalog->io.p0.base + offset); } static inline u32 dp_read_p0(struct dp_catalog_private *catalog, @@ -121,12 +143,12 @@ static inline u32 dp_read_p0(struct dp_catalog_private *catalog, * To make sure interface reg writes happens before any other operation, * this function uses writel() instread of writel_relaxed() */ - return readl_relaxed(catalog->io->dp_controller.p0.base + offset); + return readl_relaxed(catalog->io.p0.base + offset); } static inline u32 dp_read_link(struct dp_catalog_private *catalog, u32 offset) { - return readl_relaxed(catalog->io->dp_controller.link.base + offset); + return readl_relaxed(catalog->io.link.base + offset); } static inline void dp_write_link(struct dp_catalog_private *catalog, @@ -136,7 +158,7 @@ static inline void dp_write_link(struct dp_catalog_private *catalog, * To make sure link reg writes happens before any other operation, * this function uses writel() instread of writel_relaxed() */ - writel(data, catalog->io->dp_controller.link.base + offset); + writel(data, catalog->io.link.base + offset); } /* aux related catalog functions */ @@ -248,7 +270,7 @@ int dp_catalog_aux_wait_for_hpd_connect_state(struct dp_catalog *dp_catalog) struct dp_catalog_private, dp_catalog); /* poll for hpd connected status every 2ms and timeout after 500ms */ - return readl_poll_timeout(catalog->io->dp_controller.aux.base + + return readl_poll_timeout(catalog->io.aux.base + REG_DP_DP_HPD_INT_STATUS, state, state & DP_DP_HPD_STATE_STATUS_CONNECTED, 2000, 500000); @@ -276,7 +298,7 @@ void dp_catalog_dump_regs(struct dp_catalog *dp_catalog) { struct dp_catalog_private *catalog = container_of(dp_catalog, struct dp_catalog_private, dp_catalog); - struct dss_io_data *io = &catalog->io->dp_controller; + struct dss_io_data *io = &catalog->io; pr_info("AHB regs\n"); dump_regs(io->ahb.base, io->ahb.len); @@ -500,7 +522,7 @@ int dp_catalog_ctrl_set_pattern_state_bit(struct dp_catalog *dp_catalog, bit = BIT(state_bit - 1) << DP_MAINLINK_READY_LINK_TRAINING_SHIFT; /* Poll for mainlink ready status */ - ret = readx_poll_timeout(readl, catalog->io->dp_controller.link.base + + ret = readx_poll_timeout(readl, catalog->io.link.base + REG_DP_MAINLINK_READY, data, data & bit, POLLING_SLEEP_US, POLLING_TIMEOUT_US); @@ -563,7 +585,7 @@ bool dp_catalog_ctrl_mainlink_ready(struct dp_catalog *dp_catalog) struct dp_catalog_private, dp_catalog); /* Poll for mainlink ready status */ - ret = readl_poll_timeout(catalog->io->dp_controller.link.base + + ret = readl_poll_timeout(catalog->io.link.base + REG_DP_MAINLINK_READY, data, data & DP_MAINLINK_READY_FOR_VIDEO, POLLING_SLEEP_US, POLLING_TIMEOUT_US); @@ -945,21 +967,84 @@ void dp_catalog_panel_tpg_disable(struct dp_catalog *dp_catalog) dp_write_p0(catalog, MMSS_DP_TIMING_ENGINE_EN, 0x0); } -struct dp_catalog *dp_catalog_get(struct device *dev, struct dp_io *io) +static void __iomem *dp_ioremap(struct platform_device *pdev, int idx, size_t *len) { - struct dp_catalog_private *catalog; + struct resource *res; + void __iomem *base; + + base = devm_platform_get_and_ioremap_resource(pdev, idx, &res); + if (!IS_ERR(base)) + *len = resource_size(res); + + return base; +} + +static int dp_catalog_get_io(struct dp_catalog_private *catalog) +{ + struct platform_device *pdev = to_platform_device(catalog->dev); + struct dss_io_data *dss = &catalog->io; + + dss->ahb.base = dp_ioremap(pdev, 0, &dss->ahb.len); + if (IS_ERR(dss->ahb.base)) + return PTR_ERR(dss->ahb.base); - if (!io) { - DRM_ERROR("invalid input\n"); - return ERR_PTR(-EINVAL); + dss->aux.base = dp_ioremap(pdev, 1, &dss->aux.len); + if (IS_ERR(dss->aux.base)) { + /* + * The initial binding had a single reg, but in order to + * support variation in the sub-region sizes this was split. + * dp_ioremap() will fail with -EINVAL here if only a single + * reg is specified, so fill in the sub-region offsets and + * lengths based on this single region. + */ + if (PTR_ERR(dss->aux.base) == -EINVAL) { + if (dss->ahb.len < DP_DEFAULT_P0_OFFSET + DP_DEFAULT_P0_SIZE) { + DRM_ERROR("legacy memory region not large enough\n"); + return -EINVAL; + } + + dss->ahb.len = DP_DEFAULT_AHB_SIZE; + dss->aux.base = dss->ahb.base + DP_DEFAULT_AUX_OFFSET; + dss->aux.len = DP_DEFAULT_AUX_SIZE; + dss->link.base = dss->ahb.base + DP_DEFAULT_LINK_OFFSET; + dss->link.len = DP_DEFAULT_LINK_SIZE; + dss->p0.base = dss->ahb.base + DP_DEFAULT_P0_OFFSET; + dss->p0.len = DP_DEFAULT_P0_SIZE; + } else { + DRM_ERROR("unable to remap aux region: %pe\n", dss->aux.base); + return PTR_ERR(dss->aux.base); + } + } else { + dss->link.base = dp_ioremap(pdev, 2, &dss->link.len); + if (IS_ERR(dss->link.base)) { + DRM_ERROR("unable to remap link region: %pe\n", dss->link.base); + return PTR_ERR(dss->link.base); + } + + dss->p0.base = dp_ioremap(pdev, 3, &dss->p0.len); + if (IS_ERR(dss->p0.base)) { + DRM_ERROR("unable to remap p0 region: %pe\n", dss->p0.base); + return PTR_ERR(dss->p0.base); + } } + return 0; +} + +struct dp_catalog *dp_catalog_get(struct device *dev) +{ + struct dp_catalog_private *catalog; + int ret; + catalog = devm_kzalloc(dev, sizeof(*catalog), GFP_KERNEL); if (!catalog) return ERR_PTR(-ENOMEM); catalog->dev = dev; - catalog->io = io; + + ret = dp_catalog_get_io(catalog); + if (ret) + return ERR_PTR(ret); return &catalog->dp_catalog; } diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.h b/drivers/gpu/drm/msm/dp/dp_catalog.h index 1f3f58d4b8de..989e4c4fd6fa 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.h +++ b/drivers/gpu/drm/msm/dp/dp_catalog.h @@ -126,7 +126,7 @@ void dp_catalog_panel_tpg_enable(struct dp_catalog *dp_catalog, struct drm_display_mode *drm_mode); void dp_catalog_panel_tpg_disable(struct dp_catalog *dp_catalog); -struct dp_catalog *dp_catalog_get(struct device *dev, struct dp_io *io); +struct dp_catalog *dp_catalog_get(struct device *dev); /* DP Audio APIs */ void dp_catalog_audio_get_header(struct dp_catalog *catalog); diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index b8388e04bd0f..5ad96989c5f2 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -721,7 +721,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp) goto error; } - dp->catalog = dp_catalog_get(dev, &dp->parser->io); + dp->catalog = dp_catalog_get(dev); if (IS_ERR(dp->catalog)) { rc = PTR_ERR(dp->catalog); DRM_ERROR("failed to initialize catalog, rc = %d\n", rc); @@ -730,7 +730,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp) } dp->aux = dp_aux_get(dev, dp->catalog, - dp->parser->io.phy, + dp->parser->phy, dp->dp_display.is_edp); if (IS_ERR(dp->aux)) { rc = PTR_ERR(dp->aux); @@ -761,7 +761,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp) dp->ctrl = dp_ctrl_get(dev, dp->link, dp->panel, dp->aux, dp->catalog, - dp->parser->io.phy); + dp->parser->phy); if (IS_ERR(dp->ctrl)) { rc = PTR_ERR(dp->ctrl); DRM_ERROR("failed to initialize ctrl, rc = %d\n", rc); diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index de7cfc340f0c..2d0dd4353cdf 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -13,80 +13,13 @@ #include "dp_parser.h" #include "dp_reg.h" -#define DP_DEFAULT_AHB_OFFSET 0x0000 -#define DP_DEFAULT_AHB_SIZE 0x0200 -#define DP_DEFAULT_AUX_OFFSET 0x0200 -#define DP_DEFAULT_AUX_SIZE 0x0200 -#define DP_DEFAULT_LINK_OFFSET 0x0400 -#define DP_DEFAULT_LINK_SIZE 0x0C00 -#define DP_DEFAULT_P0_OFFSET 0x1000 -#define DP_DEFAULT_P0_SIZE 0x0400 - -static void __iomem *dp_ioremap(struct platform_device *pdev, int idx, size_t *len) -{ - struct resource *res; - void __iomem *base; - - base = devm_platform_get_and_ioremap_resource(pdev, idx, &res); - if (!IS_ERR(base)) - *len = resource_size(res); - - return base; -} - static int dp_parser_ctrl_res(struct dp_parser *parser) { struct platform_device *pdev = parser->pdev; - struct dp_io *io = &parser->io; - struct dss_io_data *dss = &io->dp_controller; - - dss->ahb.base = dp_ioremap(pdev, 0, &dss->ahb.len); - if (IS_ERR(dss->ahb.base)) - return PTR_ERR(dss->ahb.base); - - dss->aux.base = dp_ioremap(pdev, 1, &dss->aux.len); - if (IS_ERR(dss->aux.base)) { - /* - * The initial binding had a single reg, but in order to - * support variation in the sub-region sizes this was split. - * dp_ioremap() will fail with -EINVAL here if only a single - * reg is specified, so fill in the sub-region offsets and - * lengths based on this single region. - */ - if (PTR_ERR(dss->aux.base) == -EINVAL) { - if (dss->ahb.len < DP_DEFAULT_P0_OFFSET + DP_DEFAULT_P0_SIZE) { - DRM_ERROR("legacy memory region not large enough\n"); - return -EINVAL; - } - - dss->ahb.len = DP_DEFAULT_AHB_SIZE; - dss->aux.base = dss->ahb.base + DP_DEFAULT_AUX_OFFSET; - dss->aux.len = DP_DEFAULT_AUX_SIZE; - dss->link.base = dss->ahb.base + DP_DEFAULT_LINK_OFFSET; - dss->link.len = DP_DEFAULT_LINK_SIZE; - dss->p0.base = dss->ahb.base + DP_DEFAULT_P0_OFFSET; - dss->p0.len = DP_DEFAULT_P0_SIZE; - } else { - DRM_ERROR("unable to remap aux region: %pe\n", dss->aux.base); - return PTR_ERR(dss->aux.base); - } - } else { - dss->link.base = dp_ioremap(pdev, 2, &dss->link.len); - if (IS_ERR(dss->link.base)) { - DRM_ERROR("unable to remap link region: %pe\n", dss->link.base); - return PTR_ERR(dss->link.base); - } - - dss->p0.base = dp_ioremap(pdev, 3, &dss->p0.len); - if (IS_ERR(dss->p0.base)) { - DRM_ERROR("unable to remap p0 region: %pe\n", dss->p0.base); - return PTR_ERR(dss->p0.base); - } - } - io->phy = devm_phy_get(&pdev->dev, "dp"); - if (IS_ERR(io->phy)) - return PTR_ERR(io->phy); + parser->phy = devm_phy_get(&pdev->dev, "dp"); + if (IS_ERR(parser->phy)) + return PTR_ERR(parser->phy); return 0; } diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index b28052e87101..7306768547a6 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -14,37 +14,15 @@ #define DP_MAX_NUM_DP_LANES 4 #define DP_LINK_RATE_HBR2 540000 /* kbytes */ -struct dss_io_region { - size_t len; - void __iomem *base; -}; - -struct dss_io_data { - struct dss_io_region ahb; - struct dss_io_region aux; - struct dss_io_region link; - struct dss_io_region p0; -}; - -/** - * struct dp_ctrl_resource - controller's IO related data - * - * @dp_controller: Display Port controller mapped memory address - * @phy_io: phy's mapped memory address - */ -struct dp_io { - struct dss_io_data dp_controller; - struct phy *phy; -}; - /** * struct dp_parser - DP parser's data exposed to clients * * @pdev: platform data of the client + * @phy: PHY handle */ struct dp_parser { struct platform_device *pdev; - struct dp_io io; + struct phy *phy; u32 max_dp_lanes; u32 max_dp_link_rate; struct drm_bridge *next_bridge; From patchwork Fri Jan 26 18:26:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767621 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 BA00A20DD4 for ; Fri, 26 Jan 2024 18:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293599; cv=none; b=AMXciY1kVwLUUcFO/WWggJC66Q7JYUPBUHaZC/EVLspB+zKg/wcHz4I/ZSuC81KVUDapqvLNWenyfxF/6MUnMu7CTrnPp9eH4I77aI8NYcNnteMAyCvFrc1LKIAfYhvjuAjQ5SP84kwMXpKufgiAH0mhRZb0WsDt3HWPN84FSKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293599; c=relaxed/simple; bh=0NAS4mEEbdPscE96IS/ZQUPtnwStNLMs/YpeYKfO3to=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EZ5ADb1XhjmWuHCggMEPh6jSIeUoo2vkZBRXmNPtwIHPvhwuONmshKXq5MQjraS9pVV1ulYcsvlrUSGvZHI0pdREKlDE3O4kRMCoR27tbxjNutDnyiyUUvU2YEtY9xUyam97fgSf39R7ynr4LATX/3lDCOPAsupYkLheVjUcgoE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oRoyDo3e; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oRoyDo3e" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2cf1524cb17so8047281fa.2 for ; Fri, 26 Jan 2024 10:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293595; x=1706898395; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=UxGc0QEVEAiuhcb+m6WRpEuH/wAutaZBlt2LY4FoYiU=; b=oRoyDo3eeHJp5ecImGM3wpZEaInz5DQwlHV44vgqZKp/40Bq7b9BN7uhnAXPCRAqkK wRwYW4UE1LSHBkHYCNuAlttR7Iej/jEco0O5LbSNAZbH1zwN4b7YqLJ9yvXoILYRJe7l v+85wVFFwSXtM08JBLCxetKtKwqxzj+06OJxAaUcrCrML41zHqMwREUGUjGxBS8s1FSr SsaSPJDojyYAgN97bT9MVh4lTS5fdVaDi03Yvh7K7H35fEkyW1FRDj76LvVIHA+l8vaR 89xlUWPnI59/ic7bqCZvsvCrYGh8zDg9cZxZIUID/qeFPO9I8fNy4SpIBklr6swVuYwV qWxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293595; x=1706898395; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UxGc0QEVEAiuhcb+m6WRpEuH/wAutaZBlt2LY4FoYiU=; b=IjZtjJP08U0JOS6xlQC98K1kfu/bdx7LWX/fvESIglPkfroSGEuc4PuqAXxNplKq1D UW8KgQA/G7FYmd/qo3i0AM4HsptR957n1RcrgT5jUxeCTF551MZ+snYIrJwEbvgqgE45 Dgby3GClQqymJNGzVluK4947gWzbtqehJ8rxqxD8WeYqAjcaUkT62+FUVph2cjDTLuTu Cf4hFkaqo1WmPM9+FD1x8Qub60JJKqZgiYBDNMVvd3ypvFxYKl/KldADPVybr15vgNqn oPaOhEcLJv2t8x7ogphPfSoql/Tve7kTiK1+PAzj9xkDQ+OoNRBeXoZKZyi1DZcx8QQz CKUg== X-Gm-Message-State: AOJu0YwCZXsdcLt+l9NJxgXYcmyMQ+txHo6UiqaKh42lV/W3E1D2LEMB VEznJ5484y2US3Rgvv3gYs7Oe/fGpUs7tyoa2yw3JsZnk/Qv8xrH72cY4KIpoTs= X-Google-Smtp-Source: AGHT+IFgo15F6h5uixsWvyp4Zc1cUf2mgWm4uKlHaGtbaU2zokxMBO0Er+q909UTkk2SB4gislNDqA== X-Received: by 2002:a05:651c:b8c:b0:2cf:425b:59ee with SMTP id bg12-20020a05651c0b8c00b002cf425b59eemr138292ljb.24.1706293595612; Fri, 26 Jan 2024 10:26:35 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:35 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:32 +0200 Subject: [PATCH RESEND v3 13/15] drm/msm/dp: move link property handling to dp_panel Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-13-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=7400; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=0NAS4mEEbdPscE96IS/ZQUPtnwStNLMs/YpeYKfO3to=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lRP1QCt9GBigGfqxw/tYUlRxPfAkf+5rY1Y mHcknjGLUqJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UQAKCRCLPIo+Aiko 1VXSCACHgM26HuEVnbtE/81sb1mkQTTBMB8cmmM00c1h/1OjnKTVHlWdwK8hblazQYW2tjYHPL3 IWYLzqSzYvJRJvnwIZ6kY3S7J5MFJ4ha1FjV08+OMYfAhpvTSQ8bCgmDjWuIofuXDPbHAx0g+04 ToD5tI8JodrV40sKld2gwTBdry1FLrW0XgiL1PNAoD0TucOVCR46cOA88mmE47jf1QX3K72ZHGE v93+RGIyUavp9E+m8eImRayOIX+XHZ3wVXt7ECvw5Dyg+fv0YJtDI7yDMNA6MJOA8XYD44Ubnxg mygoFNYByHyg8S5v4kmQXYiGiNEjJXSaRRhjQAEYZ603b7jg X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Instead of passing link properties through the separate struct, parse them directly in the dp_panel. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_display.c | 8 ----- drivers/gpu/drm/msm/dp/dp_display.h | 1 - drivers/gpu/drm/msm/dp/dp_panel.c | 66 +++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/dp/dp_parser.c | 54 ------------------------------ drivers/gpu/drm/msm/dp/dp_parser.h | 4 --- 5 files changed, 66 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index 5ad96989c5f2..f19cb8c7e8cb 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -356,12 +356,6 @@ static int dp_display_process_hpd_high(struct dp_display_private *dp) int rc = 0; struct edid *edid; - dp->panel->max_dp_lanes = dp->parser->max_dp_lanes; - dp->panel->max_dp_link_rate = dp->parser->max_dp_link_rate; - - drm_dbg_dp(dp->drm_dev, "max_lanes=%d max_link_rate=%d\n", - dp->panel->max_dp_lanes, dp->panel->max_dp_link_rate); - rc = dp_panel_read_sink_caps(dp->panel, dp->dp_display.connector); if (rc) goto end; @@ -381,8 +375,6 @@ static int dp_display_process_hpd_high(struct dp_display_private *dp) dp->audio_supported = drm_detect_monitor_audio(edid); dp_panel_handle_sink_request(dp->panel); - dp->dp_display.max_dp_lanes = dp->parser->max_dp_lanes; - /* * set sink to normal operation mode -- D0 * before dpcd read diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 102f3507d824..70759dd1bfd0 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -28,7 +28,6 @@ struct msm_dp { bool wide_bus_en; - u32 max_dp_lanes; struct dp_audio *dp_audio; bool psr_supported; }; diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c b/drivers/gpu/drm/msm/dp/dp_panel.c index 127f6af995cd..8242541a81b9 100644 --- a/drivers/gpu/drm/msm/dp/dp_panel.c +++ b/drivers/gpu/drm/msm/dp/dp_panel.c @@ -7,8 +7,12 @@ #include #include +#include #include +#define DP_MAX_NUM_DP_LANES 4 +#define DP_LINK_RATE_HBR2 540000 /* kbytes */ + struct dp_panel_private { struct device *dev; struct drm_device *drm_dev; @@ -138,6 +142,9 @@ int dp_panel_read_sink_caps(struct dp_panel *dp_panel, panel = container_of(dp_panel, struct dp_panel_private, dp_panel); + drm_dbg_dp(panel->drm_dev, "max_lanes=%d max_link_rate=%d\n", + dp_panel->max_dp_lanes, dp_panel->max_dp_link_rate); + rc = dp_panel_read_dpcd(dp_panel); if (rc) { DRM_ERROR("read dpcd failed %d\n", rc); @@ -386,10 +393,65 @@ int dp_panel_init_panel_info(struct dp_panel *dp_panel) return 0; } +static u32 dp_panel_link_frequencies(struct device_node *of_node) +{ + struct device_node *endpoint; + u64 frequency = 0; + int cnt; + + endpoint = of_graph_get_endpoint_by_regs(of_node, 1, 0); /* port@1 */ + if (!endpoint) + return 0; + + cnt = of_property_count_u64_elems(endpoint, "link-frequencies"); + + if (cnt > 0) + of_property_read_u64_index(endpoint, "link-frequencies", + cnt - 1, &frequency); + of_node_put(endpoint); + + do_div(frequency, + 10 * /* from symbol rate to link rate */ + 1000); /* kbytes */ + + return frequency; +} + +static int dp_panel_parse_dt(struct dp_panel *dp_panel) +{ + struct dp_panel_private *panel; + struct device_node *of_node; + int cnt; + + panel = container_of(dp_panel, struct dp_panel_private, dp_panel); + of_node = panel->dev->of_node; + + /* + * data-lanes is the property of dp_out endpoint + */ + cnt = drm_of_get_data_lanes_count_ep(of_node, 1, 0, 1, DP_MAX_NUM_DP_LANES); + if (cnt < 0) { + /* legacy code, data-lanes is the property of mdss_dp node */ + cnt = drm_of_get_data_lanes_count(of_node, 1, DP_MAX_NUM_DP_LANES); + } + + if (cnt > 0) + dp_panel->max_dp_lanes = cnt; + else + dp_panel->max_dp_lanes = DP_MAX_NUM_DP_LANES; /* 4 lanes */ + + dp_panel->max_dp_link_rate = dp_panel_link_frequencies(of_node); + if (!dp_panel->max_dp_link_rate) + dp_panel->max_dp_link_rate = DP_LINK_RATE_HBR2; + + return 0; +} + struct dp_panel *dp_panel_get(struct dp_panel_in *in) { struct dp_panel_private *panel; struct dp_panel *dp_panel; + int ret; if (!in->dev || !in->catalog || !in->aux || !in->link) { DRM_ERROR("invalid input\n"); @@ -408,6 +470,10 @@ struct dp_panel *dp_panel_get(struct dp_panel_in *in) dp_panel = &panel->dp_panel; dp_panel->max_bw_code = DP_LINK_BW_8_1; + ret = dp_panel_parse_dt(dp_panel); + if (ret) + return ERR_PTR(ret); + return dp_panel; } diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index 2d0dd4353cdf..aa135d5cedbd 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -24,56 +24,6 @@ static int dp_parser_ctrl_res(struct dp_parser *parser) return 0; } -static u32 dp_parser_link_frequencies(struct device_node *of_node) -{ - struct device_node *endpoint; - u64 frequency = 0; - int cnt; - - endpoint = of_graph_get_endpoint_by_regs(of_node, 1, 0); /* port@1 */ - if (!endpoint) - return 0; - - cnt = of_property_count_u64_elems(endpoint, "link-frequencies"); - - if (cnt > 0) - of_property_read_u64_index(endpoint, "link-frequencies", - cnt - 1, &frequency); - of_node_put(endpoint); - - do_div(frequency, - 10 * /* from symbol rate to link rate */ - 1000); /* kbytes */ - - return frequency; -} - -static int dp_parser_misc(struct dp_parser *parser) -{ - struct device_node *of_node = parser->pdev->dev.of_node; - int cnt; - - /* - * data-lanes is the property of dp_out endpoint - */ - cnt = drm_of_get_data_lanes_count_ep(of_node, 1, 0, 1, DP_MAX_NUM_DP_LANES); - if (cnt < 0) { - /* legacy code, data-lanes is the property of mdss_dp node */ - cnt = drm_of_get_data_lanes_count(of_node, 1, DP_MAX_NUM_DP_LANES); - } - - if (cnt > 0) - parser->max_dp_lanes = cnt; - else - parser->max_dp_lanes = DP_MAX_NUM_DP_LANES; /* 4 lanes */ - - parser->max_dp_link_rate = dp_parser_link_frequencies(of_node); - if (!parser->max_dp_link_rate) - parser->max_dp_link_rate = DP_LINK_RATE_HBR2; - - return 0; -} - int devm_dp_parser_find_next_bridge(struct device *dev, struct dp_parser *parser) { struct platform_device *pdev = parser->pdev; @@ -101,10 +51,6 @@ static int dp_parser_parse(struct dp_parser *parser) if (rc) return rc; - rc = dp_parser_misc(parser); - if (rc) - return rc; - return 0; } diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index 7306768547a6..21a66932e35e 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -11,8 +11,6 @@ #include "msm_drv.h" #define DP_MAX_PIXEL_CLK_KHZ 675000 -#define DP_MAX_NUM_DP_LANES 4 -#define DP_LINK_RATE_HBR2 540000 /* kbytes */ /** * struct dp_parser - DP parser's data exposed to clients @@ -23,8 +21,6 @@ struct dp_parser { struct platform_device *pdev; struct phy *phy; - u32 max_dp_lanes; - u32 max_dp_link_rate; struct drm_bridge *next_bridge; }; From patchwork Fri Jan 26 18:26:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 766446 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 9366A20DD9 for ; Fri, 26 Jan 2024 18:26:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293600; cv=none; b=FwrTGk4k3u5WF6OLMDzrDHHp4248Vhf8t2qS+c/LGwDVQ7pn/e//eVoNYhGR0s+qA+OZjNhkTz8Tf2/XargyQ5DBpoQlSboWlyIuCiQTfHjBZOf7iPKJv+rXg7AxilMJ88v3J0l9cNPqaqIwTjji9n1eUxi+qu4NDVjGL3BDs/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293600; c=relaxed/simple; bh=+QSUGzw12ZOJpwShyYqXjiKmNZgVat/nLLyxEBSUwK0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bXrQbgWQVMz7xxzG0EcuIz2bI4/9eOYIWOrgP+X921c8p7I/fyIeNmkgQc+bW0/PDsf2xBEySBO4ybd2GXhOkuRLmi/U4sKX7gVdX5evieDqw76iIR/XT5cG/dYC40zy51cWmi8Nbs2CXElxU2v04OuSODBEegivDEBYMrLlP4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=R7RV4wO/; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="R7RV4wO/" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2cf3a04ea1cso9023371fa.2 for ; Fri, 26 Jan 2024 10:26:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293596; x=1706898396; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=l2yugd+v/ByLcDD9w+nePT0BWk3YvBKgR/XwHowmol4=; b=R7RV4wO/5/a+5viUFK3pXMCcbwjGhVmdhOVwgh9orNGf0Z+RHXVrdKE/w/G+aYjCpf 0iP3WFnVf+cP62g1xnorcp/irYx1XxWG2MIH8ywkyZjqm4dQIYBXnKIcr6R4G6ofqDW3 MiFTZxHzQFlWSkNXR8zMfNh98L4tR3iBtW+oOxtSJBg85zfJYaNSUqfEc3XB1gQkSDAl NUMvVJolOYYUHlD9KxlghXKIxuE/x2au2dTfx5ErwVpiaIa5qUoKEl/kZDo2L/enOBgD b+xnAKUdvOcuRApnsXmv2bbbOhhBQlBHWsrrT4puJov+r7E50X6HcAvAGU6VaCL2Tz6z OtvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293596; x=1706898396; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l2yugd+v/ByLcDD9w+nePT0BWk3YvBKgR/XwHowmol4=; b=SBecQPZGHIYMp1qzZyYnzxXJpYJxvo6C55eSajppo6EaB4ivbEaCF9ZDu+P90sNJdv NFaCf+6CHRtpBoEp6BoKeJSAkCm1Z6TxpTGrwkC9SAEY46P6l6LI4u7cRiz3c/J/nj16 o1wsRij3qu2ggixoOnZZyZhDamcyN8A5GzRQefhcRWwWRv2X88UlZoFph6DET7ZP9Rk6 h/1N2jAsxtLX4Y04K6Tk84MJ1PsvcBXqj93iZP6HqgNSAKMqNaaPXmeHC+/3FyPmOGxT 1XhnoqQYgHv59PPCuKzlXDl+cb2wfUqm3ysJ/HRizwFjQuuQid5sqagaPgIQjVS8LGaT RC3A== X-Gm-Message-State: AOJu0YwkVNr4iKMEV8lGBAhw1Wbpb5t9LIh2fE7pP6Z3Mw7G259Fc50R k3Eaw6jvFMqgfJCVY/gJI1V/GCmWFVcY5p6CmjfRrfHp/qmiFe+KUnHvEAwHH+o= X-Google-Smtp-Source: AGHT+IFF+Hle16o5QzHW7CU+gllINLx0kVwbIrsaVVQfWsqs8kBOAPqi/6szTgjP+pbDLmJp6xCG/w== X-Received: by 2002:a05:651c:1507:b0:2cf:131e:41ec with SMTP id e7-20020a05651c150700b002cf131e41ecmr161481ljf.43.1706293596532; Fri, 26 Jan 2024 10:26:36 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:35 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:33 +0200 Subject: [PATCH RESEND v3 14/15] drm/msm/dp: move next_bridge handling to dp_display Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-14-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=4251; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=+QSUGzw12ZOJpwShyYqXjiKmNZgVat/nLLyxEBSUwK0=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lR1JlWhP5Os+8twqg9foVlfni3Z0FMxujy8 xF+P7iglBaJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UQAKCRCLPIo+Aiko 1W6JCACDV6kLdRkLqo+MxDqheXoMpgdAYwwDkXJ5Apb12fvSbVFu8ijEZNfc9vpr5qVfsOh3H5M iumjDr4jobpBFDkRPJ8skEe8thrgCwJY/e5cLJKwhjnYjYBVpc+a9KhVDj8VFFpyNFnWrdZsoXP hjGIsliWcBBPrgieEhc1dYeSC3Fb3sSI8BmVd329mY0yLgiS35vqM+Y8cRoQoWqy50DyoSicrVf znestzgb0euX7dbZQnzbsNg0OTW1lP0tf0veeTR43v10e72a1SUzpNQgGtmKlbojDpeX9GF6hMO fvunosd/ceC0W74n+14fHsNu02chCRrXKkmCDp8bUY5n7abj X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Remove two levels of indirection and fetch next bridge directly in dp_display_probe_tail(). Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/dp/dp_display.c | 43 ++++++++++++------------------------- drivers/gpu/drm/msm/dp/dp_parser.c | 14 ------------ drivers/gpu/drm/msm/dp/dp_parser.h | 14 ------------ 3 files changed, 14 insertions(+), 57 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index f19cb8c7e8cb..de1306a88748 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -1195,16 +1195,25 @@ static const struct msm_dp_desc *dp_display_get_desc(struct platform_device *pde return NULL; } -static int dp_display_get_next_bridge(struct msm_dp *dp); - static int dp_display_probe_tail(struct device *dev) { struct msm_dp *dp = dev_get_drvdata(dev); int ret; - ret = dp_display_get_next_bridge(dp); - if (ret) - return ret; + /* + * External bridges are mandatory for eDP interfaces: one has to + * provide at least an eDP panel (which gets wrapped into panel-bridge). + * + * For DisplayPort interfaces external bridges are optional, so + * silently ignore an error if one is not present (-ENODEV). + */ + dp->next_bridge = devm_drm_of_get_bridge(&dp->pdev->dev, dp->pdev->dev.of_node, 1, 0); + if (IS_ERR(dp->next_bridge)) { + ret = PTR_ERR(dp->next_bridge); + dp->next_bridge = NULL; + if (dp->is_edp || ret != -ENODEV) + return ret; + } ret = component_add(dev, &dp_display_comp_ops); if (ret) @@ -1397,30 +1406,6 @@ void dp_display_debugfs_init(struct msm_dp *dp_display, struct dentry *root, boo } } -static int dp_display_get_next_bridge(struct msm_dp *dp) -{ - int rc; - struct dp_display_private *dp_priv; - - dp_priv = container_of(dp, struct dp_display_private, dp_display); - - /* - * External bridges are mandatory for eDP interfaces: one has to - * provide at least an eDP panel (which gets wrapped into panel-bridge). - * - * For DisplayPort interfaces external bridges are optional, so - * silently ignore an error if one is not present (-ENODEV). - */ - rc = devm_dp_parser_find_next_bridge(&dp->pdev->dev, dp_priv->parser); - if (!dp->is_edp && rc == -ENODEV) - return 0; - - if (!rc) - dp->next_bridge = dp_priv->parser->next_bridge; - - return rc; -} - int msm_dp_modeset_init(struct msm_dp *dp_display, struct drm_device *dev, struct drm_encoder *encoder) { diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index aa135d5cedbd..f95ab3c5c72c 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -24,20 +24,6 @@ static int dp_parser_ctrl_res(struct dp_parser *parser) return 0; } -int devm_dp_parser_find_next_bridge(struct device *dev, struct dp_parser *parser) -{ - struct platform_device *pdev = parser->pdev; - struct drm_bridge *bridge; - - bridge = devm_drm_of_get_bridge(dev, pdev->dev.of_node, 1, 0); - if (IS_ERR(bridge)) - return PTR_ERR(bridge); - - parser->next_bridge = bridge; - - return 0; -} - static int dp_parser_parse(struct dp_parser *parser) { int rc = 0; diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h index 21a66932e35e..38fd335d5950 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ b/drivers/gpu/drm/msm/dp/dp_parser.h @@ -21,7 +21,6 @@ struct dp_parser { struct platform_device *pdev; struct phy *phy; - struct drm_bridge *next_bridge; }; /** @@ -37,17 +36,4 @@ struct dp_parser { */ struct dp_parser *dp_parser_get(struct platform_device *pdev); -/** - * devm_dp_parser_find_next_bridge() - find an additional bridge to DP - * - * @dev: device to tie bridge lifetime to - * @parser: dp_parser data from client - * - * This function is used to find any additional bridge attached to - * the DP controller. The eDP interface requires a panel bridge. - * - * Return: 0 if able to get the bridge, otherwise negative errno for failure. - */ -int devm_dp_parser_find_next_bridge(struct device *dev, struct dp_parser *parser); - #endif From patchwork Fri Jan 26 18:26:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 767620 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 821AB210E5 for ; Fri, 26 Jan 2024 18:26:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293601; cv=none; b=SGtb0IXWEcGNXZQlSLI4UslWpHTIqu/HTwpEWxVKnQcVdCNrQ5v8guMbCKO47BvpHoLyKcifIsz35OGDBOrcQVXhWsf8g9P1St48qERReKxQqktUyyvTy/XiLQ9d8RL3z8lg/an75N3dyiTTX9MuWAmpGeSYKHIMTYuA7PGk0YQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706293601; c=relaxed/simple; bh=RoKpTVBsxpMASa9yoVqt3JBq00erT3eMVvT5PSXJn9w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FDuw41NE0L+GcKzoojsygQ0Dtq0XswQxQ2ftizhZVrqYO/0BqIiC7pp0HDqAQrHzRebiJ3mO4XTNGVn/TBHDU1B8s2POrnBAPPPpCymsVtliU/w4HQj2hWPW5Zt070PpMJeAodC0O8LqSfWE5elamkI0DNUHmipnIjm3B3byOoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=PJFVDlRQ; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PJFVDlRQ" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2cdfa8e69b5so7757641fa.0 for ; Fri, 26 Jan 2024 10:26:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706293597; x=1706898397; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8ySPPPenxiGTjdzeJAw9tYqihnqIkt3gl/pAGzcWDis=; b=PJFVDlRQSdO9sHpjcXxWGYD3iT5/srotgtausnTbsS3O5giTpaamG0FX3pcxA1LZ6U HJi0lUo5qFhFDq+Loqi1EQuZ0GOIRKsvpkQi348lLpw3Wxt6j5xwPMP5wDlPBl5zn44l +yC23Y71BO9iKo6Yoa8c436ESRvzavRs7pBKoKZ79p/dpfX12akim849gB5AFsYKGfQz Z/opoizFHDWm8aqr3tABGSJST8LWIQzygI6aMsfna+Wh43fnrZ/pQhH20cIir1UBmW8H p5SMHiNuxU8sT8ddXHo6PvV9Nv4T48em3WNO9cAhMdKZ05GBUBxx3a6lWqDuqUjxYOc0 s2dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706293597; x=1706898397; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8ySPPPenxiGTjdzeJAw9tYqihnqIkt3gl/pAGzcWDis=; b=wHBzJcOCcr0IFfsyKL4e9sghwb3JxA2HtKLxuhULC0isMRjkaxjmBCHiecyskjKsLz M59bxDxPOzJpO9mx1aRlY49Boa9CwthXGfIfsFMtOm6Eo9Swq7R8y1wCYJElj3CD5LwS lE3VM0iKbFrKCTdAAKhIvCRfR3WMGHCZ0+WtBsAZlQqWpt448j5ufgAiOOMoe6S3I6D3 RB/1e7CEr7cJ0TZxJaN60MPVvWplKXXOd0FvmItfhSQz+5zUR0UWDBJpQhJXJbzGz1aT 0y7GhelYf6vd1gQMosMw+8QJFqdrbqbp5h9pVIrDvg2PyB/cDcTM7VZxAfT0IdjRruhL F0Fw== X-Gm-Message-State: AOJu0YzizYSRqK85Lv5qbHhgTjcnCyEALUdLWpfALFVlkwxKrzE42Nnw 0T06v54/WEFq0pjs+9bhFHjygy1E25+gpci+UmQ8sm6WVzxicPI82PtYenO3Oi4= X-Google-Smtp-Source: AGHT+IG8eg+HGDARfhlUc/96quaZmMcb7ILtQFcj7NUIdMtM0UZYAbOE5rX91P5YhRH13EcbWbkbOA== X-Received: by 2002:a2e:8092:0:b0:2cd:6865:e6db with SMTP id i18-20020a2e8092000000b002cd6865e6dbmr99162ljg.46.1706293597470; Fri, 26 Jan 2024 10:26:37 -0800 (PST) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id l25-20020a2e8699000000b002cf30f27698sm232218lji.91.2024.01.26.10.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 10:26:37 -0800 (PST) From: Dmitry Baryshkov Date: Fri, 26 Jan 2024 20:26:34 +0200 Subject: [PATCH RESEND v3 15/15] drm/msm/dp: drop dp_parser Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240126-dp-power-parser-cleanup-v3-15-098d5f581dd3@linaro.org> References: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> In-Reply-To: <20240126-dp-power-parser-cleanup-v3-0-098d5f581dd3@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Bjorn Andersson , Konrad Dybcio X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=8054; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=RoKpTVBsxpMASa9yoVqt3JBq00erT3eMVvT5PSXJn9w=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBls/lS/j1KEcwqnqJuzaoEG/xDb8+ZssuVOs2bK XE+cLEsBSeJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZbP5UgAKCRCLPIo+Aiko 1TrQB/44hlTnY7oryqq3wyhggdG/RWvEZN+BAdKVQbgTlwtGPWu9df7JyitlN7/Wwjivwp2sTOn V91EgtTKTCXBmMvwWchSmHcPiacllg4hiaBOgMwL6KathTg5E5bjbhrHeBcXicEgN+XuFcj/myb gnCX7/0gQsSn/eWCzk0HNYfortgz7x9ua8wpeEo422B0B+f54vQkTmPYHX7/2rYFKE/lKnAuiHR 5NkQBuoRv9a95xwU1EcmvJtfsrHSg0D7LkxFFDE73tnTcG7ro64N6Hruao7SBihZUJc6mZmsO6W N3tHeQ/NDdmqd+2E6rovA6o6XXwUOwbIVICKdn5MZCdEZsQ0 X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A Finally drop separate "parsing" submodule. There is no need in it anymore. All submodules handle DT properties directly rather than passing them via the separate structure pointer. Signed-off-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/Makefile | 1 - drivers/gpu/drm/msm/dp/dp_aux.h | 1 + drivers/gpu/drm/msm/dp/dp_catalog.h | 1 - drivers/gpu/drm/msm/dp/dp_ctrl.h | 3 +- drivers/gpu/drm/msm/dp/dp_debug.c | 1 - drivers/gpu/drm/msm/dp/dp_display.c | 18 +++++------ drivers/gpu/drm/msm/dp/dp_display.h | 2 ++ drivers/gpu/drm/msm/dp/dp_parser.c | 61 ------------------------------------- drivers/gpu/drm/msm/dp/dp_parser.h | 39 ------------------------ 9 files changed, 12 insertions(+), 115 deletions(-) diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index 8dbdf3fba69e..543e04fa72e3 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -127,7 +127,6 @@ msm-$(CONFIG_DRM_MSM_DP)+= dp/dp_aux.o \ dp/dp_drm.o \ dp/dp_link.o \ dp/dp_panel.o \ - dp/dp_parser.o \ dp/dp_audio.o msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o diff --git a/drivers/gpu/drm/msm/dp/dp_aux.h b/drivers/gpu/drm/msm/dp/dp_aux.h index 16d9b1758748..f47d591c1f54 100644 --- a/drivers/gpu/drm/msm/dp/dp_aux.h +++ b/drivers/gpu/drm/msm/dp/dp_aux.h @@ -16,6 +16,7 @@ void dp_aux_init(struct drm_dp_aux *dp_aux); void dp_aux_deinit(struct drm_dp_aux *dp_aux); void dp_aux_reconfig(struct drm_dp_aux *dp_aux); +struct phy; struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, struct phy *phy, bool is_edp); diff --git a/drivers/gpu/drm/msm/dp/dp_catalog.h b/drivers/gpu/drm/msm/dp/dp_catalog.h index 989e4c4fd6fa..a724a986b6ee 100644 --- a/drivers/gpu/drm/msm/dp/dp_catalog.h +++ b/drivers/gpu/drm/msm/dp/dp_catalog.h @@ -8,7 +8,6 @@ #include -#include "dp_parser.h" #include "disp/msm_disp_snapshot.h" /* interrupts */ diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h index 6e9f375b856a..fa014cee7e21 100644 --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h @@ -9,7 +9,6 @@ #include "dp_aux.h" #include "dp_panel.h" #include "dp_link.h" -#include "dp_parser.h" #include "dp_catalog.h" struct dp_ctrl { @@ -17,6 +16,8 @@ struct dp_ctrl { bool wide_bus_en; }; +struct phy; + int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl); int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl, bool force_link_train); void dp_ctrl_off_link_stream(struct dp_ctrl *dp_ctrl); diff --git a/drivers/gpu/drm/msm/dp/dp_debug.c b/drivers/gpu/drm/msm/dp/dp_debug.c index 6c281dc095b9..ac68554801a4 100644 --- a/drivers/gpu/drm/msm/dp/dp_debug.c +++ b/drivers/gpu/drm/msm/dp/dp_debug.c @@ -9,7 +9,6 @@ #include #include -#include "dp_parser.h" #include "dp_catalog.h" #include "dp_aux.h" #include "dp_ctrl.h" diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index de1306a88748..67956e34436d 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -9,12 +9,12 @@ #include #include #include +#include #include #include #include "msm_drv.h" #include "msm_kms.h" -#include "dp_parser.h" #include "dp_ctrl.h" #include "dp_catalog.h" #include "dp_aux.h" @@ -87,7 +87,6 @@ struct dp_display_private { struct drm_device *drm_dev; struct dentry *root; - struct dp_parser *parser; struct dp_catalog *catalog; struct drm_dp_aux *aux; struct dp_link *link; @@ -704,14 +703,11 @@ static int dp_init_sub_modules(struct dp_display_private *dp) struct dp_panel_in panel_in = { .dev = dev, }; + struct phy *phy; - dp->parser = dp_parser_get(dp->dp_display.pdev); - if (IS_ERR(dp->parser)) { - rc = PTR_ERR(dp->parser); - DRM_ERROR("failed to initialize parser, rc = %d\n", rc); - dp->parser = NULL; - goto error; - } + phy = devm_phy_get(dev, "dp"); + if (IS_ERR(phy)) + return PTR_ERR(phy); dp->catalog = dp_catalog_get(dev); if (IS_ERR(dp->catalog)) { @@ -722,7 +718,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp) } dp->aux = dp_aux_get(dev, dp->catalog, - dp->parser->phy, + phy, dp->dp_display.is_edp); if (IS_ERR(dp->aux)) { rc = PTR_ERR(dp->aux); @@ -753,7 +749,7 @@ static int dp_init_sub_modules(struct dp_display_private *dp) dp->ctrl = dp_ctrl_get(dev, dp->link, dp->panel, dp->aux, dp->catalog, - dp->parser->phy); + phy); if (IS_ERR(dp->ctrl)) { rc = PTR_ERR(dp->ctrl); DRM_ERROR("failed to initialize ctrl, rc = %d\n", rc); diff --git a/drivers/gpu/drm/msm/dp/dp_display.h b/drivers/gpu/drm/msm/dp/dp_display.h index 70759dd1bfd0..234dada88687 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.h +++ b/drivers/gpu/drm/msm/dp/dp_display.h @@ -10,6 +10,8 @@ #include #include "disp/msm_disp_snapshot.h" +#define DP_MAX_PIXEL_CLK_KHZ 675000 + struct msm_dp { struct drm_device *drm_dev; struct platform_device *pdev; diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c deleted file mode 100644 index f95ab3c5c72c..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ /dev/null @@ -1,61 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#include -#include - -#include -#include -#include - -#include "dp_parser.h" -#include "dp_reg.h" - -static int dp_parser_ctrl_res(struct dp_parser *parser) -{ - struct platform_device *pdev = parser->pdev; - - parser->phy = devm_phy_get(&pdev->dev, "dp"); - if (IS_ERR(parser->phy)) - return PTR_ERR(parser->phy); - - return 0; -} - -static int dp_parser_parse(struct dp_parser *parser) -{ - int rc = 0; - - if (!parser) { - DRM_ERROR("invalid input\n"); - return -EINVAL; - } - - rc = dp_parser_ctrl_res(parser); - if (rc) - return rc; - - return 0; -} - -struct dp_parser *dp_parser_get(struct platform_device *pdev) -{ - struct dp_parser *parser; - int ret; - - parser = devm_kzalloc(&pdev->dev, sizeof(*parser), GFP_KERNEL); - if (!parser) - return ERR_PTR(-ENOMEM); - - parser->pdev = pdev; - - ret = dp_parser_parse(parser); - if (ret) { - dev_err(&pdev->dev, "device tree parsing failed\n"); - return ERR_PTR(ret); - } - - return parser; -} diff --git a/drivers/gpu/drm/msm/dp/dp_parser.h b/drivers/gpu/drm/msm/dp/dp_parser.h deleted file mode 100644 index 38fd335d5950..000000000000 --- a/drivers/gpu/drm/msm/dp/dp_parser.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. - */ - -#ifndef _DP_PARSER_H_ -#define _DP_PARSER_H_ - -#include - -#include "msm_drv.h" - -#define DP_MAX_PIXEL_CLK_KHZ 675000 - -/** - * struct dp_parser - DP parser's data exposed to clients - * - * @pdev: platform data of the client - * @phy: PHY handle - */ -struct dp_parser { - struct platform_device *pdev; - struct phy *phy; -}; - -/** - * dp_parser_get() - get the DP's device tree parser module - * - * @pdev: platform data of the client - * return: pointer to dp_parser structure. - * - * This function provides client capability to parse the - * device tree and populate the data structures. The data - * related to clock, regulators, pin-control and other - * can be parsed using this module. - */ -struct dp_parser *dp_parser_get(struct platform_device *pdev); - -#endif