From patchwork Thu Jul 27 21:51:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alain Volmat X-Patchwork-Id: 127205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp31405vqg; Thu, 27 Jul 2023 14:54:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEM1hGllKo4K9XKXtR80hJ3HScdlniCWUBXcESYGo0atpoX9rKK7D5v5UhAX7oQ5PJQLf/O X-Received: by 2002:a05:6a21:78a9:b0:137:63fa:2a17 with SMTP id bf41-20020a056a2178a900b0013763fa2a17mr381454pzc.12.1690494897397; Thu, 27 Jul 2023 14:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690494897; cv=none; d=google.com; s=arc-20160816; b=L4TT6gCZMCZPwroVs9utuOyeFDIQhvAiVtkWduavWDClUNxBev7pe06Up7jt5Fpa6u QQRIiBikovqdOvrNXKCZk0Rx9bjZz+PeUg99g8tcKpU64FbiTZLGZf4G6PtbdWYZxkAs Pvm3nZABP5sb/zvYX2ZLI3IImA4zCqS+AClgogj8PuwpyDWjX+gVv9P2cutshn4qeIxj AyzgYpwo8OULLEnvH3y14qHzzyNvmZjDklAdkM3O4O5P4oB/qXUWj8zeHQbEfXdPYP1Z 0v8j/7tAQCJvQpEAK+sgcON20AwkLN0UH6g16JioS6ehYOPwLt2TO509zYPGy6XYXcY1 MfMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4Q2kPpx9tnkAzIsBSu0lR+5VOLaRmSNvSKU5kR9IbKY=; fh=YlaQJ3TP8tbT2RGJU1jM+MHAbXw6RYFhYgmjWx/ZxUI=; b=J8Hn3IFGEn04xBGFpOnROwDeyJ3rai0oeP1MhDci4kcjhylxzyMZigsSaoQ3B33KyR LDqmWysmZgjlYGXR3NX3Rgf0o8sCByppQC+rWYDmLxi1uUpFFKqUbNR7nopiOPouDWuA MdA4dPNClUEj8zUA/m40kweYNSSy8s6OBj1j+GZVSTGJZ8mnS9f/JVeXXsKFsTgjW1QD ZdK7IZiHagZz4P7VRs6abKB9MBYE3eAV4kFGTop8e7xrWnjjZ0CPO6bFmhJW5yBYCEwE Tr3QOmpnizYsqt6XLREr2zYys7wPrcK+2xitwpYLo3lElpjm6xEIPu1eTvavgDBnqeG+ T6lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@me.com header.s=1a1hai header.b=0RBvR1s3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b26-20020a6567da000000b0056003c53094si1773978pgs.433.2023.07.27.14.54.44; Thu, 27 Jul 2023 14:54:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@me.com header.s=1a1hai header.b=0RBvR1s3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=me.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232466AbjG0Vwi (ORCPT + 99 others); Thu, 27 Jul 2023 17:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232257AbjG0Vwb (ORCPT ); Thu, 27 Jul 2023 17:52:31 -0400 Received: from qs51p00im-qukt01072102.me.com (qs51p00im-qukt01072102.me.com [17.57.155.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19FAC2135 for ; Thu, 27 Jul 2023 14:52:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=1a1hai; t=1690494749; bh=4Q2kPpx9tnkAzIsBSu0lR+5VOLaRmSNvSKU5kR9IbKY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=0RBvR1s3gPsmnwWxF3fgSp6Vr5lH/sKdAVs7b3TKhp7TfOQsxqRFPin8qLOvAfTgX GXdmWe2m/l+ywwqZv5Ihnm/rfJFvuyWutgL1AXJQs0txL870Zm6ViDH2Hge/8Twxpm 1Dhv3i90ExxqIWhwsVCEUbDgccbaDFTtZNTHiRlmx0pPi4JtMAMWuQUGUWPRdByuNp +boLnefyT5BWdh6L+DN0ki6SbX/CTiGzkxkl/s0sIJMDWtEK0i28IDuI/H0JrhSQTU c8tQsfOnaoeuA7FtdlGeaDQlAyvQScsjI8N8BCSelzqKx3C7JH4FBv3ee8v0w/7nnS a3ThaBe9L7aSw== Received: from localhost (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01072102.me.com (Postfix) with ESMTPSA id 7940734099C; Thu, 27 Jul 2023 21:52:28 +0000 (UTC) From: Alain Volmat To: Alain Volmat , David Airlie , Daniel Vetter Cc: Alain Volmat , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/14] drm/sti: add support for VTG on the stih418 platform Date: Thu, 27 Jul 2023 21:51:27 +0000 Message-Id: <20230727215141.53910-4-avolmat@me.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230727215141.53910-1-avolmat@me.com> References: <20230727215141.53910-1-avolmat@me.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: TYCF9UE_guExnaT3ERZOGvZzEjQFonTj X-Proofpoint-GUID: TYCF9UE_guExnaT3ERZOGvZzEjQFonTj X-Proofpoint-Virus-Version: =?utf-8?q?vendor=3Dfsecure_engine=3D1=2E1=2E170-?= =?utf-8?q?22c6f66c430a71ce266a39bfe25bc2903e8d5c8f=3A6=2E0=2E138=2C18=2E0?= =?utf-8?q?=2E790=2C17=2E11=2E62=2E513=2E0000000_definitions=3D2022-01-12=5F?= =?utf-8?q?02=3A2020-02-14=5F02=2C2022-01-12=5F02=2C2021-12-02=5F01_signatur?= =?utf-8?q?es=3D0?= X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 clxscore=1015 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2307270199 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772612377440393053 X-GMAIL-MSGID: 1772612377440393053 VTG integrated into the STiH418 differ in the number of outputs available and allocation of each output. Indeed on STiH418, there are 6 outputs (4 on the STiH407/STiH410) and HDMI is connected to the 5th output in case of STiH418 while it is on the 1st output in case of STiH407/STiH410. A new compatible st,stih418-vtg is added to differentiate that. Signed-off-by: Alain Volmat --- drivers/gpu/drm/sti/sti_vtg.c | 62 +++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c index 5e5f82b6a5d9..b0cab72ea502 100644 --- a/drivers/gpu/drm/sti/sti_vtg.c +++ b/drivers/gpu/drm/sti/sti_vtg.c @@ -60,6 +60,18 @@ #define VTG_TOP_V_HD_4 0x012c #define VTG_BOT_V_HD_4 0x0130 +#define VTG_H_HD_5 0x0140 +#define VTG_TOP_V_VD_5 0x0144 +#define VTG_BOT_V_VD_5 0x0148 +#define VTG_TOP_V_HD_5 0x014c +#define VTG_BOT_V_HD_5 0x0150 + +#define VTG_H_HD_6 0x0160 +#define VTG_TOP_V_VD_6 0x0164 +#define VTG_BOT_V_VD_6 0x0168 +#define VTG_TOP_V_HD_6 0x016c +#define VTG_BOT_V_HD_6 0x0170 + #define VTG_IRQ_BOTTOM BIT(0) #define VTG_IRQ_TOP BIT(1) #define VTG_IRQ_MASK (VTG_IRQ_TOP | VTG_IRQ_BOTTOM) @@ -92,7 +104,12 @@ struct sti_vtg_regs_offs { u32 bot_v_hd; }; -#define VTG_MAX_SYNC_OUTPUT 4 +struct sti_vtg_data { + unsigned int nb_sync_output; + unsigned int hdmi_sync_id; +}; + +#define VTG_MAX_SYNC_OUTPUT 6 static const struct sti_vtg_regs_offs vtg_regs_offs[VTG_MAX_SYNC_OUTPUT] = { { VTG_H_HD_1, VTG_TOP_V_VD_1, VTG_BOT_V_VD_1, VTG_TOP_V_HD_1, VTG_BOT_V_HD_1 }, @@ -101,7 +118,11 @@ static const struct sti_vtg_regs_offs vtg_regs_offs[VTG_MAX_SYNC_OUTPUT] = { { VTG_H_HD_3, VTG_TOP_V_VD_3, VTG_BOT_V_VD_3, VTG_TOP_V_HD_3, VTG_BOT_V_HD_3 }, { VTG_H_HD_4, - VTG_TOP_V_VD_4, VTG_BOT_V_VD_4, VTG_TOP_V_HD_4, VTG_BOT_V_HD_4 } + VTG_TOP_V_VD_4, VTG_BOT_V_VD_4, VTG_TOP_V_HD_4, VTG_BOT_V_HD_4 }, + { VTG_H_HD_5, + VTG_TOP_V_VD_5, VTG_BOT_V_VD_5, VTG_TOP_V_HD_5, VTG_BOT_V_HD_5 }, + { VTG_H_HD_6, + VTG_TOP_V_VD_6, VTG_BOT_V_VD_6, VTG_TOP_V_HD_6, VTG_BOT_V_HD_6 } }; /* @@ -138,6 +159,7 @@ struct sti_vtg { u32 irq_status; struct raw_notifier_head notifier_list; struct drm_crtc *crtc; + struct sti_vtg_data data; }; struct sti_vtg *of_vtg_find(struct device_node *np) @@ -252,7 +274,7 @@ static void vtg_set_mode(struct sti_vtg *vtg, vtg_set_output_window(vtg->regs, mode); /* Set hsync and vsync position for HDMI */ - vtg_set_hsync_vsync_pos(&sync[VTG_SYNC_ID_HDMI - 1], HDMI_DELAY, mode); + vtg_set_hsync_vsync_pos(&sync[vtg->data.hdmi_sync_id - 1], HDMI_DELAY, mode); /* Set hsync and vsync position for HD DCS */ vtg_set_hsync_vsync_pos(&sync[VTG_SYNC_ID_HDDCS - 1], 0, mode); @@ -264,7 +286,7 @@ static void vtg_set_mode(struct sti_vtg *vtg, vtg_set_hsync_vsync_pos(&sync[VTG_SYNC_ID_DVO - 1], DVO_DELAY, mode); /* Progam the syncs outputs */ - for (i = 0; i < VTG_MAX_SYNC_OUTPUT ; i++) { + for (i = 0; i < vtg->data.nb_sync_output ; i++) { writel(sync[i].hsync, vtg->regs + vtg_regs_offs[i].h_hd); writel(sync[i].vsync_line_top, @@ -376,9 +398,27 @@ static irqreturn_t vtg_irq(int irq, void *arg) return IRQ_WAKE_THREAD; } +static const struct sti_vtg_data stih407_vtg_data = { + .nb_sync_output = 4, + .hdmi_sync_id = 1, +}; + +static const struct sti_vtg_data stih418_vtg_data = { + .nb_sync_output = 6, + .hdmi_sync_id = 5, +}; + +static const struct of_device_id vtg_of_match[] = { + { .compatible = "st,vtg", .data = &stih407_vtg_data, }, + { .compatible = "st,stih418-vtg", .data = &stih418_vtg_data, }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, vtg_of_match); + static int vtg_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; struct sti_vtg *vtg; struct resource *res; int ret; @@ -387,6 +427,14 @@ static int vtg_probe(struct platform_device *pdev) if (!vtg) return -ENOMEM; + memcpy(&vtg->data, of_match_node(vtg_of_match, np)->data, + sizeof(struct sti_vtg_data)); + + if (vtg->data.nb_sync_output > VTG_MAX_SYNC_OUTPUT) { + dev_err(dev, "Invalid number of VTG sync output\n"); + return -EINVAL; + } + /* Get Memory ressources */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -422,12 +470,6 @@ static int vtg_probe(struct platform_device *pdev) return 0; } -static const struct of_device_id vtg_of_match[] = { - { .compatible = "st,vtg", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, vtg_of_match); - struct platform_driver sti_vtg_driver = { .driver = { .name = "sti-vtg",