From nobody Wed Dec 17 03:27:48 2025 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 933EC210D for ; Mon, 13 May 2024 00:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715559236; cv=none; b=VqISJ3v6GGmKGRoKKg4PP+VjEJhwuEcLupulmA8t8hyn+bGYoZOsLElh/ixs38IcZDztCaEv7zF0ZEqbDoekek59FFk6GiEB5hglELOJYGtabaWfaUcsLIqdn2IfVykdPwaXmp0ZMX7dYSYFP/jQkxL4b7dsydmUf9dO8p4hvbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715559236; c=relaxed/simple; bh=75IR+SDgGVMZc3p/WH0Rl8DpIbSB3xec2ffzUOQD+aI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DlbkcVw2RZm8JHpn8yzqgWZB+KnT5+1fsMelIOEPRfL5dl4A5kM080mq/PKD4wUMQ1Xrng6LFHEb0XMY8mOsm5kP1lpzR9gx61Rixkwmu39lK36cCUtdN0VEQT3KCBTAiI84DjDnajqfc0MGahWmlALwStVIG11JtkXHVpVk+v4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=q9ZNveTR; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="q9ZNveTR" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715559232; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e3pEj0WWodLS42WTaYGSsqEklXWqCa1MeU3yE8jdV00=; b=q9ZNveTRce1txu2wT/QMCvQF8h05xke4kbajjOEKNMXEiMDEBn1GGbSb5PjWYwTuEv7mlg MLsmTalfac1oB+TxkA4R3srQA8SWWIIkUowJBJJnh0MMounveE7o+UPxb17A3sG88aaSR4 CrM769A5sVoVqqeQWZJT5JjMY5RaAvk= From: Sui Jingfeng To: Maxime Ripard , Thomas Zimmermann Cc: Sui Jingfeng , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [PATCH 1/3] drm/loongson: Add helpers for creating subdevice Date: Mon, 13 May 2024 08:12:41 +0800 Message-Id: <20240513001243.1739336-2-sui.jingfeng@linux.dev> In-Reply-To: <20240513001243.1739336-1-sui.jingfeng@linux.dev> References: <20240513001243.1739336-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" In some display subsystems, the functionality of a PCI(e) device may too complex for a single driver to be managed by a monolithic driver. A split of the functionality into child devices can helps to achieve better modularity, eaiser for understand and maintain. Add the loongson_create_platform_device() function to pove the way for the mentioned goals. Pure software method, no hardware operations involved. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/loongson/loongson_device.c | 42 ++++++++++++++++++++++ drivers/gpu/drm/loongson/lsdc_drv.h | 6 ++++ 2 files changed, 48 insertions(+) diff --git a/drivers/gpu/drm/loongson/loongson_device.c b/drivers/gpu/drm/l= oongson/loongson_device.c index 9986c8a2a255..b268549d643e 100644 --- a/drivers/gpu/drm/loongson/loongson_device.c +++ b/drivers/gpu/drm/loongson/loongson_device.c @@ -4,6 +4,7 @@ */ =20 #include +#include =20 #include "lsdc_drv.h" =20 @@ -100,3 +101,44 @@ lsdc_device_probe(struct pci_dev *pdev, enum loongson_= chip_id chip_id) { return __chip_id_desc_table[chip_id]; } + +int loongson_create_platform_device(struct device *parent, + const char *name, int id, + struct resource *pres, + void *data, + struct platform_device **ppdev) +{ + struct platform_device *pdev; + int ret; + + pdev =3D platform_device_alloc(name, id); + if (!pdev) + return -ENOMEM; + + pdev->dev.parent =3D parent; + + if (pres) { + ret =3D platform_device_add_resources(pdev, pres, 1); + if (ret) { + platform_device_put(pdev); + return ret; + } + } + + if (data) { + void *pdata =3D kmalloc(sizeof(void *), GFP_KERNEL); + + *(void **)pdata =3D data; + pdev->dev.platform_data =3D pdata; + } + + ret =3D platform_device_add(pdev); + if (ret) { + platform_device_put(pdev); + return ret; + } + + *ppdev =3D pdev; + + return 0; +} diff --git a/drivers/gpu/drm/loongson/lsdc_drv.h b/drivers/gpu/drm/loongson= /lsdc_drv.h index fbf2d760ef27..a2c6b496a69f 100644 --- a/drivers/gpu/drm/loongson/lsdc_drv.h +++ b/drivers/gpu/drm/loongson/lsdc_drv.h @@ -47,6 +47,12 @@ enum loongson_chip_id { const struct lsdc_desc * lsdc_device_probe(struct pci_dev *pdev, enum loongson_chip_id chip); =20 +int loongson_create_platform_device(struct device *parent, + const char *name, int id, + struct resource *pres, + void *data, + struct platform_device **ppdev); + struct lsdc_kms_funcs; =20 /* DC specific */ --=20 2.34.1 From nobody Wed Dec 17 03:27:48 2025 Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1B2917E for ; Mon, 13 May 2024 00:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715559289; cv=none; b=kov02nBgVW/86m5h1lqOJvCpUCTvnsmMcJWPFkqUpyLzY1XNpGG9k2Fv3aRK/LAwjFsi7nXP/9WeuPTqe4Vd1ZkMRIFHFlbliIla1Ky2OagxfQ5/PVFbwK8/gOolD81aFghyImGIVLJ4wdWF1OZzOMkBKsCC5b6sZKV6KkA5t/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715559289; c=relaxed/simple; bh=6KXMmIO5xKqnb0dbgTwqYXgjGunpHacHh7hbzGT07V8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HcOGjIzwYf0P7vFZYkgW9dUrp1iBfP34jhxwOoUtSBFrJhchnlUWocgNS5wyQ76If3YHC+MpgKCvB2/OrPnGylmOCNGcQU3nrhb1u7A7qam2RKYfwIF7D8iTMt9gDwWdF2ZEJKri7k1qDYvgTyeY6lAHuLOygPwb2e/43bz3Fr0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=WTOYWcRX; arc=none smtp.client-ip=91.218.175.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="WTOYWcRX" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715559284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FosN8AJZZ0vwxsKhagS4hdt1OIJWrMoEgJv1L3If2Xc=; b=WTOYWcRXo2/DrRgqvmrfr2EhotGBYpufsq8/9YOnoqSVGjZ5WjWeRKMeeiq8X581oy/oOn WoTQNfpBh8cRQ5Q5fqIQuba54/7occZT2GfpBxsE6sqo89804hJybyZCaE9htN8a5qimPv BGGVf/uhT9CRwclxE0HJrYtoEs5gEd4= From: Sui Jingfeng To: Maxime Ripard , Thomas Zimmermann Cc: Sui Jingfeng , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [PATCH 2/3] drm/loongson: Introduce component framework support Date: Mon, 13 May 2024 08:12:42 +0800 Message-Id: <20240513001243.1739336-3-sui.jingfeng@linux.dev> In-Reply-To: <20240513001243.1739336-1-sui.jingfeng@linux.dev> References: <20240513001243.1739336-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Introduce the component framework to bind childs and siblings, for better modularity and paper over the deferral probe problems if it need to attach exterinal module someday. Hardware units come with PCI(e) are actually all ready to drive, but there has some board specific modules will return -EPROBE_DEFER. We need all other submodules ready to attach before we can register the drm device to userspace. The idea is to devide the exterinal module dependent part and exterinal module independent part clearly, for example, the display controller and the builtin GPIO-I2C just belong to exterinal module independent part. While the output is belong to exterinal module dependent part. Also for better reflecting the hardware, we intend to abstract the output ports as child devices. The output ports may consists of encoder phy and level shift, while the GPU and VPU are standalone siblings. As those units are relative separate hardware units from display controller itself. By design, the display controller PCI(e) is selected as the component master, gpio-i2c go with master. The manually created virtual child device are functional as agents for the master, it could return the -EPROBE_DEFER back to the component core. This allows the master don't have to tear down everything, the majority setups work can be preserved. The potential cyclic dependency problem can be solved with such framework. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/loongson/Makefile | 1 + drivers/gpu/drm/loongson/loongson_module.c | 17 ++- drivers/gpu/drm/loongson/loongson_module.h | 1 + drivers/gpu/drm/loongson/lsdc_drv.c | 59 +++++++++ drivers/gpu/drm/loongson/lsdc_drv.h | 6 +- drivers/gpu/drm/loongson/lsdc_output.c | 142 +++++++++++++++++++++ drivers/gpu/drm/loongson/lsdc_output.h | 22 +++- 7 files changed, 241 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/drm/loongson/lsdc_output.c diff --git a/drivers/gpu/drm/loongson/Makefile b/drivers/gpu/drm/loongson/M= akefile index 91e72bd900c1..e15cb9bff378 100644 --- a/drivers/gpu/drm/loongson/Makefile +++ b/drivers/gpu/drm/loongson/Makefile @@ -9,6 +9,7 @@ loongson-y :=3D \ lsdc_gfxpll.o \ lsdc_i2c.o \ lsdc_irq.o \ + lsdc_output.o \ lsdc_output_7a1000.o \ lsdc_output_7a2000.o \ lsdc_plane.o \ diff --git a/drivers/gpu/drm/loongson/loongson_module.c b/drivers/gpu/drm/l= oongson/loongson_module.c index d2a51bd395f6..037fa7ffe9c9 100644 --- a/drivers/gpu/drm/loongson/loongson_module.c +++ b/drivers/gpu/drm/loongson/loongson_module.c @@ -4,6 +4,7 @@ */ =20 #include +#include =20 #include