Add DRM driver for Hisilicon Hibmc
Subsystems (4)
v2 cover Add DRM driver for Hisilicon Hibmc
This patch set adds a new drm driver for Hisilicon Hibmc. Hibmc is a base board management controller, usually it is used on server for Out-of-band management purpose. In this patch set, we just support basic function for Hibmc display subsystem. Hibmc display subsystem is connected to host CPU by PCIe as blow:
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+
Hardware Detail for Hibmc display subsystem
-----------
The display subsystem of Hibmc is show as bellow:
+----+ +----+ +----+ +--------+ | | | | | | | | | FB |----->| DE |----->|VDAC|---->|external| | | | | | | | VGA | +----+ +----+ +----+ +--------+
-DE(Display Engine) is the display controller.
-VDAC(Video Digital-to-Analog converter) converts the RGB diaital data stream from DE to VGA analog signals.
Change History
------------
Changes in v2:
-Remove self-defined macros for bit operations. -Remove unused register.
-Replace those deprecated functions with new version of them. -use drm_connector_register_all() to register connector after
drm_dev_register().
The patch v1 is at
https://lists.freedesktop.org/archives/dri-devel/2016-February/101921.html
Sorry for too late sending.
Rongrong Zou (7):
idrm/hisilicon/hibmc: Add hisilicon hibmc drm master driver drm/hisilicon/hibmc: Add plane for DE drm/hisilicon/hibmc: Add crtc for DE drm/hisilicon/hibmc: Add encoder for VDAC drm/hisilicon/hibmc: Add connector for VDAC drm/hisilicon/hibmc: Add support for frame buffer drm/hisilicon/hibmc: Add maintainer for Hibmc DRM
MAINTAINERS | 7 + drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 3 +- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 13 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 4 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 477 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h | 29 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 399 ++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 64 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 286 +++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 91 +++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 214 ++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 174 ++++++++ 14 files changed, 1789 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Kconfig create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Makefile create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
Signature · 1 line
1.9.1
PATCH v2 1/7 drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver
Add DRM master driver for Hisilicon Hibmc SoC which used for Out-of-band management. Blow is the general hardware connection, both the Hibmc and the host CPU are on the same mother board.
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+
--- drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 3 +- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 13 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 4 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 307 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 39 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 91 +++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 214 +++++++++++++++ 9 files changed, 699 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Kconfig create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Makefile create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h
drivers/gpu/drm/hisilicon/Kconfig +1 -0
@@ -2,4 +2,5 @@ # hisilicon drm device configuration. # Please keep this list sorted alphabetically +source "drivers/gpu/drm/hisilicon/hibmc/Kconfig" source "drivers/gpu/drm/hisilicon/kirin/Kconfig"
drivers/gpu/drm/hisilicon/Makefile +2 -1
@@ -2,4 +2,5 @@ # Makefile for hisilicon drm drivers. # Please keep this list sorted alphabetically -obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/ +obj-$(CONFIG_DRM_HISI_HIBMC) += hibmc/ +obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +config DRM_HISI_HIBMC + tristate "DRM Support for Hisilicon Hibmc" + depends on DRM && PCI + select DRM_KMS_HELPER + select DRM_KMS_FB_HELPER + select DRM_GEM_CMA_HELPER + select DRM_KMS_CMA_HELPER + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + help + Choose this option if you have a Hisilicon Hibmc soc chipset. + If M is selected the module will be called hibmc-drm.
drivers/gpu/drm/hisilicon/hibmc/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o + +obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o +#obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +307 -0
307 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h new file +39 -0
@@ -0,0 +1,39 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_DRV_H +#define HIBMC_DRM_DRV_H + +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> + +struct hibmc_drm_device { +/* hw */ +void __iomem *mmio; +void __iomem *fb_map; +unsigned long fb_base; +unsigned long fb_size; + +/* drm */ +struct drm_device *dev; +bool mode_config_initialized; +}; + + +#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c new file +91 -0
91 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h new file +28 -0
@@ -0,0 +1,28 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_POWER_H +#define HIBMC_DRM_POWER_H + +#include "hibmc_drm_drv.h" + +extern void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode); +extern void hibmc_set_current_gate (struct hibmc_drm_device *hidev, +unsigned int gate); +#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h new file +214 -0
214 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [path v2 1/7] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver
Quoted 141 lines · Rongrong Zou
Add DRM master driver for Hisilicon Hibmc SoC which used for Out-of-band management. Blow is the general hardware connection, both the Hibmc and the host CPU are on the same mother board.
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+Signed-off-by Rongrong Zou <[email protected]>Signed-off-by Jianhua Li <[email protected]>--- drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 3 +- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 13 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 4 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 307 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 39 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 91 +++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 214 +++++++++++++++ 9 files changed, 699 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Kconfig create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Makefile create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.hdrivers/gpu/drm/hisilicon/Kconfig +1
-0@@ -2,4 +2,5 @@ # hisilicon drm device configuration. # Please keep this list sorted alphabetically +source "drivers/gpu/drm/hisilicon/hibmc/Kconfig" source "drivers/gpu/drm/hisilicon/kirin/Kconfig"drivers/gpu/drm/hisilicon/Makefile +2
-1@@ -2,4 +2,5 @@ # Makefile for hisilicon drm drivers. # Please keep this list sorted alphabetically -obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/ +obj-$(CONFIG_DRM_HISI_HIBMC) += hibmc/ +obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +13
-0@@ -0,0 +1,13 @@ +config DRM_HISI_HIBMC + tristate "DRM Support for Hisilicon Hibmc" + depends on DRM && PCI + select DRM_KMS_HELPER + select DRM_KMS_FB_HELPER + select DRM_GEM_CMA_HELPER + select DRM_KMS_CMA_HELPER + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + help + Choose this option if you have a Hisilicon Hibmc soc chipset. + If M is selected the module will be called hibmc-drm.drivers/gpu/drm/hisilicon/hibmc/Makefile new file +4
-0@@ -0,0 +1,4 @@ +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o + +obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o +#obj-y += hibmc-drm.odrivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +53
-0@@ -0,0 +1,307 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/module.h> +#include <linux/console.h> +#include <drm/drm_atomic_helper.h> +#include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> +#include <drm/drmP.h> + +#include "hibmc_drm_drv.h" +#include "hibmc_drm_regs.h" +#include "hibmc_drm_power.h" + +static const struct file_operations hibmc_fops = { + .owner =THIS_MODULE , + .open = drm_open, + .release = drm_release, + .unlocked_ioctl = drm_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = drm_compat_ioctl, +#endif + .poll = drm_poll, + .read = drm_read, + .llseek = no_llseek, +}; + +static int hibmc_enable_vblank (struct drm_device *dev,unsigned int pipe) +{ +return 0 ; +} + +static void hibmc_disable_vblank (struct drm_device *dev,unsigned int pipe) +{ +} + +static struct drm_driver hibmc_driver = {
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 63
Quoted 10 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +10
-0+ .driver_features = DRIVER_GEM | DRIVER_MODESET, + .fops = &hibmc_fops, + .name = "hibmc", + .desc = "hibmc drm driver", + .major = 1, + .minor = 0, + .get_vblank_counter = drm_vblank_no_hw_counter, + .enable_vblank = hibmc_enable_vblank, + .disable_vblank = hibmc_disable_vblank, + .gem_free_object = drm_gem_cma_free_object,
gem_free_object_unlocked pls.
Quoted 25 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +25
-0+ .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create, + .dumb_map_offset = drm_gem_cma_dumb_map_offset, + .dumb_destroy = drm_gem_dumb_destroy, +}; + +static int hibmc_pm_suspend (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); + +drm_kms_helper_poll_disable (drm_dev); + +return 0 ; +} + +static int hibmc_pm_resume (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); + +drm_helper_resume_force_mode (drm_dev); +drm_kms_helper_poll_enable (drm_dev); + +return 0 ;
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 98
Quoted 10 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +10
-0+} + +static const struct dev_pm_ops hibmc_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (hibmc_pm_suspend, + hibmc_pm_resume) +}; + +static const struct drm_mode_config_funcs mode_config_funcs = { + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit,
So how exactly does nonblocking commit work for you? Please run the igt validation suit on your new driver, a bunch of collabora engineers are working hard to make it run on non-intel drivers too. Ping Tomeu and Robert Foss for more info on this please.
Lucky for you I'm working on generic nonblocking support in the atomic helpers, patches are on the mailing list.
Quoted 612 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +209
-0+}; + + +static int hibmc_hw_config (struct hibmc_drm_device *hidev) +{ +unsigned int reg; + +/* On hardware reset, power mode 0 is default. */ +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_MODE0 ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg |=HIBMC_CURR_GATE_DISPLAY (ON ); + reg |=HIBMC_CURR_GATE_LOCALMEM (ON ); + +hibmc_set_current_gate (hidev, reg); + +/* Reset the memory controller. If the memory controller +* is not reset in chip,the system might hang when sw accesses +* the memory.The memory should be resetted after +* changing the MXCLK. +*/ + reg =readl (hidev->mmio +HIBMC_MISC_CTRL ); + reg &= ~HIBMC_MSCCTL_LOCALMEM_RESET_MASK ; + reg |=HIBMC_MSCCTL_LOCALMEM_RESET (RESET ); +writel (reg, hidev->mmio +HIBMC_MISC_CTRL ); + + reg &= ~HIBMC_MSCCTL_LOCALMEM_RESET_MASK ; + reg |=HIBMC_MSCCTL_LOCALMEM_RESET (NORMAL ); + +writel (reg, hidev->mmio +HIBMC_MISC_CTRL ); + +/* We can add more initialization as needed. */ + +return 0 ; +} + +static int hibmc_hw_map (struct hibmc_drm_device *hidev) +{ +struct drm_device *dev = hidev->dev; +struct pci_dev *pdev = dev->pdev; +resource_size_t addr, size, ioaddr, iosize; + + ioaddr =pci_resource_start (pdev,1 ); + iosize =MB (2 ); + + hidev->mmio =ioremap_nocache (ioaddr, iosize); + +if (!hidev->mmio) { +DRM_ERROR ("Cannot map mmio region\n" ); +return -ENOMEM ; + } + + addr =pci_resource_start (pdev,0 ); + size =MB (16 ); + + hidev->fb_map =ioremap (addr, size); +if (!hidev->fb_map) { +DRM_ERROR ("Cannot map framebuffer\n" ); +return -ENOMEM ; + } + hidev->fb_base = addr; + hidev->fb_size = size; + +return 0 ; +} + +static void hibmc_hw_fini (struct hibmc_drm_device *hidev) +{ +if (hidev->mmio) +iounmap (hidev->mmio); +if (hidev->fb_map) +iounmap (hidev->fb_map); +} + +static int hibmc_hw_init (struct hibmc_drm_device *hidev) +{ +int ret; + + ret =hibmc_hw_map (hidev); +if (ret) +return ret; + +hibmc_hw_config (hidev); + +return 0 ; +} + +static int hibmc_unload (struct drm_device *dev) +{ +struct hibmc_drm_device *hidev = dev->dev_private; + +hibmc_hw_fini (hidev); + dev->dev_private =NULL ; +return 0 ; +} + +static int hibmc_load (struct drm_device *dev,unsigned long flags) +{ +struct hibmc_drm_device *hidev; +int ret; + + hidev =devm_kzalloc (dev->dev,sizeof (*hidev),GFP_KERNEL ); +if (!hidev) +return -ENOMEM ; + dev->dev_private = hidev; + hidev->dev = dev; + + ret =hibmc_hw_init (hidev); +if (ret) + goto err; + + + ret =drm_vblank_init (dev, dev->mode_config.num_crtc); +if (ret) { +DRM_ERROR ("failed to initialize vblank.\n" ); +return ret; + } +/* reset all the states of crtc/plane/encoder/connector */ +drm_mode_config_reset (dev); + +return 0 ; + +err: +hibmc_unload (dev); +DRM_ERROR ("failed to initialize drm driver.\n" ); +return ret; +} + + +static int hibmc_pci_probe (struct pci_dev *pdev, +const struct pci_device_id *ent) +{ +struct drm_device *dev; +int ret; + + dev =drm_dev_alloc (&hibmc_driver, &pdev->dev); +if (!dev) +return -ENOMEM ; + + dev->pdev = pdev; +pci_set_drvdata (pdev, dev); + + ret =pci_enable_device (pdev); +if (ret) + goto err_free; + + ret =hibmc_load (dev,0 ); +if (ret) + goto err_disable; + + ret =drm_dev_register (dev,0 ); +if (ret) + goto err_unload; + +return 0 ; + +err_unload: +hibmc_unload (dev); +err_disable: +pci_disable_device (pdev); +err_free: +drm_dev_unref (dev); + +return ret; +} + +static void hibmc_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_dev_unregister (dev); +hibmc_unload (dev); +drm_dev_unref (dev); +} + +static struct pci_device_id hibmc_pci_table[] = { + {0x19e5 ,0x1711 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {0 ,} +}; + +static struct pci_driver hibmc_pci_driver = { + .name ="hibmc-drm" , + .id_table = hibmc_pci_table, + .probe = hibmc_pci_probe, + .remove = hibmc_pci_remove, + .driver.pm = &hibmc_pm_ops, +}; + +static int __init hibmc_init (void ) +{ +return pci_register_driver (&hibmc_pci_driver); +} + +static void __exit hibmc_exit(void) +{ +return pci_unregister_driver (&hibmc_pci_driver); +} + +module_init (hibmc_init); +module_exit (hibmc_exit); + +MODULE_DEVICE_TABLE (pci, hibmc_pci_table); +MODULE_AUTHOR ("RongrongZou <[email protected]>" ); +MODULE_DESCRIPTION ("DRM Driver for Hisilicon Hibmc" ); +MODULE_LICENSE ("GPL v2" ); +drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h new file +39
-0@@ -0,0 +1,39 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_DRV_H +#define HIBMC_DRM_DRV_H + +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> + +struct hibmc_drm_device { +/* hw */ +void __iomem *mmio; +void __iomem *fb_map; +unsigned long fb_base; +unsigned long fb_size; + +/* drm */ +struct drm_device *dev; +bool mode_config_initialized; +}; + + +#endif drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c new file +91
-0@@ -0,0 +1,91 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/io.h> +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> +#include "hibmc_drm_drv.h" +#include "hibmc_drm_regs.h" + +/* +* It can operate in one of three modes: 0, 1 or Sleep. +*/ +void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode) +{ +unsigned int control_value =0 ; +void __iomem *mmio = hidev->mmio; + +if (power_mode >HIBMC_PW_MODE_CTL_MODE_SLEEP ) +return ; + + control_value =readl (mmio +HIBMC_POWER_MODE_CTRL ); + control_value &= ~HIBMC_PW_MODE_CTL_MODE_MASK ; + + control_value |=HIBMC_PW_MODE_CTL_MODE (power_mode) & +HIBMC_PW_MODE_CTL_MODE_MASK ; + + +/* Set up other fields in Power Control Register */ +if (power_mode ==HIBMC_PW_MODE_CTL_MODE_SLEEP ) { + control_value &= ~HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + control_value |=HIBMC_PW_MODE_CTL_OSC_INPUT (0 ) & +HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + }else { + control_value &= ~HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + control_value |=HIBMC_PW_MODE_CTL_OSC_INPUT (1 ) & +HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + + } +/* Program new power mode. */ +writel (control_value, mmio +HIBMC_POWER_MODE_CTRL ); +} + +static unsigned int hibmc_get_power_mode (struct hibmc_drm_device *hidev) +{ +void __iomem *mmio = hidev->mmio; + +return (readl (mmio +HIBMC_POWER_MODE_CTRL )& +HIBMC_PW_MODE_CTL_MODE_MASK ) >>HIBMC_PW_MODE_CTL_MODE_SHIFT ; +} + +void hibmc_set_current_gate (struct hibmc_drm_device *hidev,unsigned int gate) +{ +unsigned int gate_reg; +unsigned int mode; +void __iomem *mmio = hidev->mmio; + +/* Get current power mode. */ + mode =hibmc_get_power_mode (hidev); + +switch (mode) { +case HIBMC_PW_MODE_CTL_MODE_MODE0 : + gate_reg =HIBMC_MODE0_GATE ; +break ; + +case HIBMC_PW_MODE_CTL_MODE_MODE1 : + gate_reg =HIBMC_MODE1_GATE ; +break ; + +default : + gate_reg =HIBMC_MODE0_GATE ; +break ; + } +writel (gate, mmio + gate_reg); +} +drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h new file +28
-0@@ -0,0 +1,28 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_POWER_H +#define HIBMC_DRM_POWER_H + +#include "hibmc_drm_drv.h" + +extern void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode); +extern void hibmc_set_current_gate (struct hibmc_drm_device *hidev, +unsigned int gate); +#endif drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h new file +214
-0@@ -0,0 +1,214 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_HW_H +#define HIBMC_DRM_HW_H + +#define OFF 0 +#define ON 1 +#define DISABLE 0 +#define ENABLE 1 + + + +/* register definition */ +#define HIBMC_MISC_CTRL 0x4 + +#define HIBMC_MSCCTL_LOCALMEM_RESET (x) ((x) << 6) +#define HIBMC_MSCCTL_LOCALMEM_RESET_MASK 0x40 + +#define RESET 0 +#define NORMAL 1 + +#define HIBMC_CURRENT_GATE 0x000040 +#define HIBMC_CURR_GATE_DISPLAY (x) ((x) << 2) +#define HIBMC_CURR_GATE_DISPLAY_MASK 0x4 + +#define HIBMC_CURR_GATE_LOCALMEM (x) ((x) << 1) +#define HIBMC_CURR_GATE_LOCALMEM_MASK 0x2 + +#define HIBMC_MODE0_GATE 0x000044 +#define HIBMC_MODE1_GATE 0x000048 +#define HIBMC_POWER_MODE_CTRL 0x00004C + +#define HIBMC_PW_MODE_CTL_OSC_INPUT (x) ((x) << 3) +#define HIBMC_PW_MODE_CTL_OSC_INPUT_MASK 0x8 + +#define HIBMC_PW_MODE_CTL_MODE (x) ((x) << 0) +#define HIBMC_PW_MODE_CTL_MODE_MASK 0x03 +#define HIBMC_PW_MODE_CTL_MODE_SHIFT 0 + + +#define HIBMC_PW_MODE_CTL_MODE_MODE0 0 +#define HIBMC_PW_MODE_CTL_MODE_MODE1 1 +#define HIBMC_PW_MODE_CTL_MODE_SLEEP 2 + +#define HIBMC_PANEL_PLL_CTRL 0x00005C +#define HIBMC_CRT_PLL_CTRL 0x000060 + +#define HIBMC_PLL_CTRL_BYPASS (x) ((x) << 18) +#define HIBMC_PLL_CTRL_BYPASS_MASK 0x40000 + +#define HIBMC_PLL_CTRL_POWER (x) ((x) << 17) +#define HIBMC_PLL_CTRL_POWER_MASK 0x20000 + +#define HIBMC_PLL_CTRL_INPUT (x) ((x) << 16) +#define HIBMC_PLL_CTRL_INPUT_MASK 0x10000 + +#define OSC 0 +#define TESTCLK 1 + +#define HIBMC_PLL_CTRL_POD (x) ((x) << 14) +#define HIBMC_PLL_CTRL_POD_MASK 0xC000 + +#define HIBMC_PLL_CTRL_OD (x) ((x) << 12) +#define HIBMC_PLL_CTRL_OD_MASK 0x3000 + +#define HIBMC_PLL_CTRL_N (x) ((x) << 8) +#define HIBMC_PLL_CTRL_N_MASK 0xF00 + +#define HIBMC_PLL_CTRL_M (x) ((x) << 0) +#define HIBMC_PLL_CTRL_M_MASK 0xFF + + +#define HIBMC_CRT_DISP_CTL 0x80200 + +#define HIBMC_CRT_DISP_CTL_CRTSELECT (x) ((x) << 25) +#define HIBMC_CRT_DISP_CTL_CRTSELECT_MASK 0x2000000 + +#define CRTSELECT_VGA 0 +#define CRTSELECT_CRT 1 + +#define HIBMC_CRT_DISP_CTL_CLOCK_PHASE (x) ((x) << 14) +#define HIBMC_CRT_DISP_CTL_CLOCK_PHASE_MASK 0x4000 + +#define PHASE_ACTIVE_HIGH 0 +#define PHASE_ACTIVE_LOW 1 + +#define HIBMC_CRT_DISP_CTL_VSYNC_PHASE (x) ((x) << 13) +#define HIBMC_CRT_DISP_CTL_VSYNC_PHASE_MASK 0x2000 + +#define HIBMC_CRT_DISP_CTL_HSYNC_PHASE (x) ((x) << 12) +#define HIBMC_CRT_DISP_CTL_HSYNC_PHASE_MASK 0x1000 + +#define HIBMC_CRT_DISP_CTL_TIMING (x) ((x) << 8) +#define HIBMC_CRT_DISP_CTL_TIMING_MASK 0x100 + + +#define HIBMC_CRT_DISP_CTL_PLANE (x) ((x) << 2) +#define HIBMC_CRT_DISP_CTL_PLANE_MASK 4 + +#define HIBMC_CRT_DISP_CTL_FORMAT (x) ((x) << 0) +#define HIBMC_CRT_DISP_CTL_FORMAT_MASK 0x03 + + + +#define HIBMC_CRT_FB_ADDRESS 0x080204 + +#define HIBMC_CRT_FB_WIDTH 0x080208 +#define HIBMC_CRT_FB_WIDTH_WIDTH (x) ((x) << 16) +#define HIBMC_CRT_FB_WIDTH_WIDTH_MASK 0x3FFF0000 +#define HIBMC_CRT_FB_WIDTH_OFFS (x) ((x) << 0) +#define HIBMC_CRT_FB_WIDTH_OFFS_MASK 0x3FFF + + +#define HIBMC_CRT_HORZ_TOTAL 0x08020C +#define HIBMC_CRT_HORZ_TOTAL_TOTAL (x) ((x) << 16) +#define HIBMC_CRT_HORZ_TOTAL_TOTAL_MASK 0xFFF0000 + + +#define HIBMC_CRT_HORZ_TOTAL_DISPLAY_END (x) ((x) << 0) +#define HIBMC_CRT_HORZ_TOTAL_DISPLAY_END_MASK 0xFFF + +#define HIBMC_CRT_HORZ_SYNC 0x080210 +#define HIBMC_CRT_HORZ_SYNC_WIDTH (x) ((x) << 16) +#define HIBMC_CRT_HORZ_SYNC_WIDTH_MASK 0xFF0000 + +#define HIBMC_CRT_HORZ_SYNC_START (x) ((x) << 0) +#define HIBMC_CRT_HORZ_SYNC_START_MASK 0xFFF + +#define HIBMC_CRT_VERT_TOTAL 0x080214 +#define HIBMC_CRT_VERT_TOTAL_TOTAL (x) ((x) << 16) +#define HIBMC_CRT_VERT_TOTAL_TOTAL_MASK 0x7FFF0000 + +#define HIBMC_CRT_VERT_TOTAL_DISPLAY_END (x) ((x) << 0) +#define HIBMC_CRT_VERT_TOTAL_DISPLAY_END_MASK 0x7FF + +#define HIBMC_CRT_VERT_SYNC 0x080218 +#define HIBMC_CRT_VERT_SYNC_HEIGHT (x) ((x) << 16) +#define HIBMC_CRT_VERT_SYNC_HEIGHT_MASK 0x3F0000 + + +#define HIBMC_CRT_VERT_SYNC_START (x) ((x) << 0) +#define HIBMC_CRT_VERT_SYNC_START_MASK 0x7FF + +/* Auto Centering */ +#define HIBMC_CRT_AUTO_CENTERING_TL 0x080280 +#define HIBMC_CRT_AUTO_CENTERING_TL_TOP (x) ((x) << 16) +#define HIBMC_CRT_AUTO_CENTERING_TL_TOP_MSK 0x7FF0000 + +#define HIBMC_CRT_AUTO_CENTERING_TL_LEFT (x) ((x) << 0) +#define HIBMC_CRT_AUTO_CENTERING_TL_LEFT_MSK 0x7FF + +#define HIBMC_CRT_AUTO_CENTERING_BR 0x080284 +#define HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM (x) ((x) << 16) +#define HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM_MASK 0x7FF0000 + +#define HIBMC_CRT_AUTO_CENTERING_BR_RIGHT (x) ((x) << 0) +#define HIBMC_CRT_AUTO_CENTERING_BR_RIGHT_MASK 0x7FF + +/* register to control panel output */ +#define DISPLAY_CONTROL_HISILE 0x80288 + +/* register and values for PLL control */ +#define CRT_PLL1_HS 0x802a8 +#define CRT_PLL1_HS_25MHZ 0x23d40f02 +#define CRT_PLL1_HS_40MHZ 0x23940801 +#define CRT_PLL1_HS_65MHZ 0x23940d01 +#define CRT_PLL1_HS_78MHZ 0x23540F82 +#define CRT_PLL1_HS_74MHZ 0x23941dc2 +#define CRT_PLL1_HS_80MHZ 0x23941001 +#define CRT_PLL1_HS_80MHZ_1152 0x23540fc2 +#define CRT_PLL1_HS_108MHZ 0x23b41b01 +#define CRT_PLL1_HS_162MHZ 0x23480681 +#define CRT_PLL1_HS_148MHZ 0x23541dc2 +#define CRT_PLL1_HS_193MHZ 0x234807c1 + +#define CRT_PLL2_HS 0x802ac +#define CRT_PLL2_HS_25MHZ 0x206B851E +#define CRT_PLL2_HS_40MHZ 0x30000000 +#define CRT_PLL2_HS_65MHZ 0x40000000 +#define CRT_PLL2_HS_78MHZ 0x50E147AE +#define CRT_PLL2_HS_74MHZ 0x602B6AE7 +#define CRT_PLL2_HS_80MHZ 0x70000000 +#define CRT_PLL2_HS_108MHZ 0x80000000 +#define CRT_PLL2_HS_162MHZ 0xA0000000 +#define CRT_PLL2_HS_148MHZ 0xB0CCCCCD +#define CRT_PLL2_HS_193MHZ 0xC0872B02 + +/* Global macros */ +#define RGB (r, g, b) \ +( \ + (unsigned long)(((r) << 16) | ((g) << 8) | (b)) \ +) + +#define PADDING (align, data) (((data) + (align) - 1) & (~((align) - 1))) + +#define MB (x) ((x) << 20) + +#endif Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list dri-devel at lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Rongrong Zou
AppliedRe: [path v2 1/7] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver
Hi Daniel,
Thanks for reveiwing!
Quoted 146 lines · Daniel Vetter
Quoted 145 lines · Rongrong Zou
Add DRM master driver for Hisilicon Hibmc SoC which used for Out-of-band management. Blow is the general hardware connection, both the Hibmc and the host CPU are on the same mother board.
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+Signed-off-by Rongrong Zou <[email protected]>Signed-off-by Jianhua Li <[email protected]>--- drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 3 +- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 13 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 4 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 307 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 39 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 91 +++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 214 +++++++++++++++ 9 files changed, 699 insertions(+), 1 deletion(-)create mode 100644
drivers/gpu/drm/hisilicon/hibmc/Kconfigcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/Makefilecreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.hdrivers/gpu/drm/hisilicon/Kconfig +1
-0@@ -2,4 +2,5 @@ # hisilicon drm device configuration. # Please keep this list sorted alphabetically +source "drivers/gpu/drm/hisilicon/hibmc/Kconfig" source "drivers/gpu/drm/hisilicon/kirin/Kconfig"drivers/gpu/drm/hisilicon/Makefile +2
-1@@ -2,4 +2,5 @@ # Makefile for hisilicon drm drivers. # Please keep this list sorted alphabetically -obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/ +obj-$(CONFIG_DRM_HISI_HIBMC) += hibmc/ +obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +13
-0@@ -0,0 +1,13 @@ +config DRM_HISI_HIBMC + tristate "DRM Support for Hisilicon Hibmc" + depends on DRM && PCI + select DRM_KMS_HELPER + select DRM_KMS_FB_HELPER + select DRM_GEM_CMA_HELPER + select DRM_KMS_CMA_HELPER + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + help + Choose this option if you have a Hisilicon Hibmc soc chipset. + If M is selected the module will be called hibmc-drm.drivers/gpu/drm/hisilicon/hibmc/Makefile new file +4
-0@@ -0,0 +1,4 @@ +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o + +obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o +#obj-y += hibmc-drm.odrivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +57
-0@@ -0,0 +1,307 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/module.h> +#include <linux/console.h> +#include <drm/drm_atomic_helper.h> +#include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> +#include <drm/drmP.h> + +#include "hibmc_drm_drv.h" +#include "hibmc_drm_regs.h" +#include "hibmc_drm_power.h" + +static const struct file_operations hibmc_fops = { + .owner =THIS_MODULE , + .open = drm_open, + .release = drm_release, + .unlocked_ioctl = drm_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = drm_compat_ioctl, +#endif + .poll = drm_poll, + .read = drm_read, + .llseek = no_llseek, +}; + +static int hibmc_enable_vblank (struct drm_device *dev,unsigned int pipe) +{ +return 0 ; +} + +static void hibmc_disable_vblank (struct drm_device *dev,unsigned int pipe) +{ +} + +static struct drm_driver hibmc_driver = { + .driver_features =DRIVER_GEM |DRIVER_MODESET , + .fops = &hibmc_fops, + .name ="hibmc" , + .desc ="hibmc drm driver" ,
Quoted 8 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 63
Quoted 6 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6
-0+ .major = 1, + .minor = 0, + .get_vblank_counter = drm_vblank_no_hw_counter, + .enable_vblank = hibmc_enable_vblank, + .disable_vblank = hibmc_disable_vblank, + .gem_free_object = drm_gem_cma_free_object,
gem_free_object_unlockedpls.
Applied, thanks.
Quoted 33 lines
Quoted 33 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +32
-0+ .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create, + .dumb_map_offset = drm_gem_cma_dumb_map_offset, + .dumb_destroy = drm_gem_dumb_destroy, +}; + +static int hibmc_pm_suspend (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); + +drm_kms_helper_poll_disable (drm_dev); + +return 0 ; +} + +static int hibmc_pm_resume (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); + +drm_helper_resume_force_mode (drm_dev); +drm_kms_helper_poll_enable (drm_dev); + +return 0 ; +} + +static const struct dev_pm_ops hibmc_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (hibmc_pm_suspend, + hibmc_pm_resume) +}; +
Quoted 8 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 98
Quoted 3 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +3
-0+static const struct drm_mode_config_funcs mode_config_funcs = { + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit,So how exactly does nonblocking commit work for you? Please run the igt validation suit on your new driver, a bunch of collabora engineers are working hard to make it run on non-intel drivers too. Ping Tomeu and Robert Foss for more info on this please.
OK, I should learn igt validation suit and test the new driver. I tested the driver with tools such as fbtest before. Thanks.
Quoted 4 lines
Lucky for you I'm working on generic nonblocking support in the atomic helpers, patches are on the mailing list.
It's nice, thanks. :)
Quoted 613 lines
Quoted 612 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +209
-0+}; + + +static int hibmc_hw_config (struct hibmc_drm_device *hidev) +{ +unsigned int reg; + +/* On hardware reset, power mode 0 is default. */ +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_MODE0 ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg |=HIBMC_CURR_GATE_DISPLAY (ON ); + reg |=HIBMC_CURR_GATE_LOCALMEM (ON ); + +hibmc_set_current_gate (hidev, reg); + +/* Reset the memory controller. If the memory controller +* is not reset in chip,the system might hang when sw accesses +* the memory.The memory should be resetted after +* changing the MXCLK. +*/ + reg =readl (hidev->mmio +HIBMC_MISC_CTRL ); + reg &= ~HIBMC_MSCCTL_LOCALMEM_RESET_MASK ; + reg |=HIBMC_MSCCTL_LOCALMEM_RESET (RESET ); +writel (reg, hidev->mmio +HIBMC_MISC_CTRL ); + + reg &= ~HIBMC_MSCCTL_LOCALMEM_RESET_MASK ; + reg |=HIBMC_MSCCTL_LOCALMEM_RESET (NORMAL ); + +writel (reg, hidev->mmio +HIBMC_MISC_CTRL ); + +/* We can add more initialization as needed. */ + +return 0 ; +} + +static int hibmc_hw_map (struct hibmc_drm_device *hidev) +{ +struct drm_device *dev = hidev->dev; +struct pci_dev *pdev = dev->pdev; +resource_size_t addr, size, ioaddr, iosize; + + ioaddr =pci_resource_start (pdev,1 ); + iosize =MB (2 ); + + hidev->mmio =ioremap_nocache (ioaddr, iosize); + +if (!hidev->mmio) { +DRM_ERROR ("Cannot map mmio region\n" ); +return -ENOMEM ; + } + + addr =pci_resource_start (pdev,0 ); + size =MB (16 ); + + hidev->fb_map =ioremap (addr, size); +if (!hidev->fb_map) { +DRM_ERROR ("Cannot map framebuffer\n" ); +return -ENOMEM ; + } + hidev->fb_base = addr; + hidev->fb_size = size; + +return 0 ; +} + +static void hibmc_hw_fini (struct hibmc_drm_device *hidev) +{ +if (hidev->mmio) +iounmap (hidev->mmio); +if (hidev->fb_map) +iounmap (hidev->fb_map); +} + +static int hibmc_hw_init (struct hibmc_drm_device *hidev) +{ +int ret; + + ret =hibmc_hw_map (hidev); +if (ret) +return ret; + +hibmc_hw_config (hidev); + +return 0 ; +} + +static int hibmc_unload (struct drm_device *dev) +{ +struct hibmc_drm_device *hidev = dev->dev_private; + +hibmc_hw_fini (hidev); + dev->dev_private =NULL ; +return 0 ; +} + +static int hibmc_load (struct drm_device *dev,unsigned long flags) +{ +struct hibmc_drm_device *hidev; +int ret; + + hidev =devm_kzalloc (dev->dev,sizeof (*hidev),GFP_KERNEL ); +if (!hidev) +return -ENOMEM ; + dev->dev_private = hidev; + hidev->dev = dev; + + ret =hibmc_hw_init (hidev); +if (ret) + goto err; + + + ret =drm_vblank_init (dev, dev->mode_config.num_crtc); +if (ret) { +DRM_ERROR ("failed to initialize vblank.\n" ); +return ret; + } +/* reset all the states of crtc/plane/encoder/connector */ +drm_mode_config_reset (dev); + +return 0 ; + +err: +hibmc_unload (dev); +DRM_ERROR ("failed to initialize drm driver.\n" ); +return ret; +} + + +static int hibmc_pci_probe (struct pci_dev *pdev, +const struct pci_device_id *ent) +{ +struct drm_device *dev; +int ret; + + dev =drm_dev_alloc (&hibmc_driver, &pdev->dev); +if (!dev) +return -ENOMEM ; + + dev->pdev = pdev; +pci_set_drvdata (pdev, dev); + + ret =pci_enable_device (pdev); +if (ret) + goto err_free; + + ret =hibmc_load (dev,0 ); +if (ret) + goto err_disable; + + ret =drm_dev_register (dev,0 ); +if (ret) + goto err_unload; + +return 0 ; + +err_unload: +hibmc_unload (dev); +err_disable: +pci_disable_device (pdev); +err_free: +drm_dev_unref (dev); + +return ret; +} + +static void hibmc_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_dev_unregister (dev); +hibmc_unload (dev); +drm_dev_unref (dev); +} + +static struct pci_device_id hibmc_pci_table[] = { + {0x19e5 ,0x1711 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {0 ,} +}; + +static struct pci_driver hibmc_pci_driver = { + .name ="hibmc-drm" , + .id_table = hibmc_pci_table, + .probe = hibmc_pci_probe, + .remove = hibmc_pci_remove, + .driver.pm = &hibmc_pm_ops, +}; + +static int __init hibmc_init (void ) +{ +return pci_register_driver (&hibmc_pci_driver); +} + +static void __exit hibmc_exit(void) +{ +return pci_unregister_driver (&hibmc_pci_driver); +} + +module_init (hibmc_init); +module_exit (hibmc_exit); + +MODULE_DEVICE_TABLE (pci, hibmc_pci_table); +MODULE_AUTHOR ("RongrongZou <[email protected]>" ); +MODULE_DESCRIPTION ("DRM Driver for Hisilicon Hibmc" ); +MODULE_LICENSE ("GPL v2" ); +drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h new file +39
-0@@ -0,0 +1,39 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_DRV_H +#define HIBMC_DRM_DRV_H + +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> + +struct hibmc_drm_device { +/* hw */ +void __iomem *mmio; +void __iomem *fb_map; +unsigned long fb_base; +unsigned long fb_size; + +/* drm */ +struct drm_device *dev; +bool mode_config_initialized; +}; + + +#endif drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c new file +91
-0@@ -0,0 +1,91 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/io.h> +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> +#include "hibmc_drm_drv.h" +#include "hibmc_drm_regs.h" + +/* +* It can operate in one of three modes: 0, 1 or Sleep. +*/ +void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode) +{ +unsigned int control_value =0 ; +void __iomem *mmio = hidev->mmio; + +if (power_mode >HIBMC_PW_MODE_CTL_MODE_SLEEP ) +return ; + + control_value =readl (mmio +HIBMC_POWER_MODE_CTRL ); + control_value &= ~HIBMC_PW_MODE_CTL_MODE_MASK ; + + control_value |=HIBMC_PW_MODE_CTL_MODE (power_mode) & +HIBMC_PW_MODE_CTL_MODE_MASK ; + + +/* Set up other fields in Power Control Register */ +if (power_mode ==HIBMC_PW_MODE_CTL_MODE_SLEEP ) { + control_value &= ~HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + control_value |=HIBMC_PW_MODE_CTL_OSC_INPUT (0 ) & +HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + }else { + control_value &= ~HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + control_value |=HIBMC_PW_MODE_CTL_OSC_INPUT (1 ) & +HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + + } +/* Program new power mode. */ +writel (control_value, mmio +HIBMC_POWER_MODE_CTRL ); +} + +static unsigned int hibmc_get_power_mode (struct hibmc_drm_device *hidev) +{ +void __iomem *mmio = hidev->mmio; + +return (readl (mmio +HIBMC_POWER_MODE_CTRL )& +HIBMC_PW_MODE_CTL_MODE_MASK ) >>HIBMC_PW_MODE_CTL_MODE_SHIFT ; +} + +void hibmc_set_current_gate (struct hibmc_drm_device *hidev,unsigned int gate) +{ +unsigned int gate_reg; +unsigned int mode; +void __iomem *mmio = hidev->mmio; + +/* Get current power mode. */ + mode =hibmc_get_power_mode (hidev); + +switch (mode) { +case HIBMC_PW_MODE_CTL_MODE_MODE0 : + gate_reg =HIBMC_MODE0_GATE ; +break ; + +case HIBMC_PW_MODE_CTL_MODE_MODE1 : + gate_reg =HIBMC_MODE1_GATE ; +break ; + +default : + gate_reg =HIBMC_MODE0_GATE ; +break ; + } +writel (gate, mmio + gate_reg); +} +drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h new file +28
-0@@ -0,0 +1,28 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_POWER_H +#define HIBMC_DRM_POWER_H + +#include "hibmc_drm_drv.h" + +extern void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode); +extern void hibmc_set_current_gate (struct hibmc_drm_device *hidev, +unsigned int gate); +#endif drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h new file +214
-1@@ -0,0 +1,214 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_HW_H +#define HIBMC_DRM_HW_H + +#define OFF 0 +#define ON 1 +#define DISABLE 0 +#define ENABLE 1 + + + +/* register definition */ +#define HIBMC_MISC_CTRL 0x4 + +#define HIBMC_MSCCTL_LOCALMEM_RESET (x) ((x) << 6) +#define HIBMC_MSCCTL_LOCALMEM_RESET_MASK 0x40 + +#define RESET 0 +#define NORMAL 1 + +#define HIBMC_CURRENT_GATE 0x000040 +#define HIBMC_CURR_GATE_DISPLAY (x) ((x) << 2) +#define HIBMC_CURR_GATE_DISPLAY_MASK 0x4 + +#define HIBMC_CURR_GATE_LOCALMEM (x) ((x) << 1) +#define HIBMC_CURR_GATE_LOCALMEM_MASK 0x2 + +#define HIBMC_MODE0_GATE 0x000044 +#define HIBMC_MODE1_GATE 0x000048 +#define HIBMC_POWER_MODE_CTRL 0x00004C + +#define HIBMC_PW_MODE_CTL_OSC_INPUT (x) ((x) << 3) +#define HIBMC_PW_MODE_CTL_OSC_INPUT_MASK 0x8 + +#define HIBMC_PW_MODE_CTL_MODE (x) ((x) << 0) +#define HIBMC_PW_MODE_CTL_MODE_MASK 0x03 +#define HIBMC_PW_MODE_CTL_MODE_SHIFT 0 + + +#define HIBMC_PW_MODE_CTL_MODE_MODE0 0 +#define HIBMC_PW_MODE_CTL_MODE_MODE1 1 +#define HIBMC_PW_MODE_CTL_MODE_SLEEP 2 + +#define HIBMC_PANEL_PLL_CTRL 0x00005C +#define HIBMC_CRT_PLL_CTRL 0x000060 + +#define HIBMC_PLL_CTRL_BYPASS (x) ((x) << 18) +#define HIBMC_PLL_CTRL_BYPASS_MASK 0x40000 + +#define HIBMC_PLL_CTRL_POWER (x) ((x) << 17) +#define HIBMC_PLL_CTRL_POWER_MASK 0x20000 + +#define HIBMC_PLL_CTRL_INPUT (x) ((x) << 16) +#define HIBMC_PLL_CTRL_INPUT_MASK 0x10000 + +#define OSC 0 +#define TESTCLK 1 + +#define HIBMC_PLL_CTRL_POD (x) ((x) << 14) +#define HIBMC_PLL_CTRL_POD_MASK 0xC000 + +#define HIBMC_PLL_CTRL_OD (x) ((x) << 12) +#define HIBMC_PLL_CTRL_OD_MASK 0x3000 + +#define HIBMC_PLL_CTRL_N (x) ((x) << 8) +#define HIBMC_PLL_CTRL_N_MASK 0xF00 + +#define HIBMC_PLL_CTRL_M (x) ((x) << 0) +#define HIBMC_PLL_CTRL_M_MASK 0xFF + + +#define HIBMC_CRT_DISP_CTL 0x80200 + +#define HIBMC_CRT_DISP_CTL_CRTSELECT (x) ((x) << 25) +#define HIBMC_CRT_DISP_CTL_CRTSELECT_MASK 0x2000000 + +#define CRTSELECT_VGA 0 +#define CRTSELECT_CRT 1 + +#define HIBMC_CRT_DISP_CTL_CLOCK_PHASE (x) ((x) << 14) +#define HIBMC_CRT_DISP_CTL_CLOCK_PHASE_MASK 0x4000 + +#define PHASE_ACTIVE_HIGH 0 +#define PHASE_ACTIVE_LOW 1 + +#define HIBMC_CRT_DISP_CTL_VSYNC_PHASE (x) ((x) << 13) +#define HIBMC_CRT_DISP_CTL_VSYNC_PHASE_MASK 0x2000 + +#define HIBMC_CRT_DISP_CTL_HSYNC_PHASE (x) ((x) << 12) +#define HIBMC_CRT_DISP_CTL_HSYNC_PHASE_MASK 0x1000 + +#define HIBMC_CRT_DISP_CTL_TIMING (x) ((x) << 8) +#define HIBMC_CRT_DISP_CTL_TIMING_MASK 0x100 + + +#define HIBMC_CRT_DISP_CTL_PLANE (x) ((x) << 2) +#define HIBMC_CRT_DISP_CTL_PLANE_MASK 4 + +#define HIBMC_CRT_DISP_CTL_FORMAT (x) ((x) << 0) +#define HIBMC_CRT_DISP_CTL_FORMAT_MASK 0x03 + + + +#define HIBMC_CRT_FB_ADDRESS 0x080204 + +#define HIBMC_CRT_FB_WIDTH 0x080208 +#define HIBMC_CRT_FB_WIDTH_WIDTH (x) ((x) << 16) +#define HIBMC_CRT_FB_WIDTH_WIDTH_MASK 0x3FFF0000 +#define HIBMC_CRT_FB_WIDTH_OFFS (x) ((x) << 0) +#define HIBMC_CRT_FB_WIDTH_OFFS_MASK 0x3FFF + + +#define HIBMC_CRT_HORZ_TOTAL 0x08020C +#define HIBMC_CRT_HORZ_TOTAL_TOTAL (x) ((x) << 16) +#define HIBMC_CRT_HORZ_TOTAL_TOTAL_MASK 0xFFF0000 + + +#define HIBMC_CRT_HORZ_TOTAL_DISPLAY_END (x) ((x) << 0) +#define HIBMC_CRT_HORZ_TOTAL_DISPLAY_END_MASK 0xFFF + +#define HIBMC_CRT_HORZ_SYNC 0x080210 +#define HIBMC_CRT_HORZ_SYNC_WIDTH (x) ((x) << 16) +#define HIBMC_CRT_HORZ_SYNC_WIDTH_MASK 0xFF0000 + +#define HIBMC_CRT_HORZ_SYNC_START (x) ((x) << 0) +#define HIBMC_CRT_HORZ_SYNC_START_MASK 0xFFF + +#define HIBMC_CRT_VERT_TOTAL 0x080214 +#define HIBMC_CRT_VERT_TOTAL_TOTAL (x) ((x) << 16) +#define HIBMC_CRT_VERT_TOTAL_TOTAL_MASK 0x7FFF0000 + +#define HIBMC_CRT_VERT_TOTAL_DISPLAY_END (x) ((x) << 0) +#define HIBMC_CRT_VERT_TOTAL_DISPLAY_END_MASK 0x7FF + +#define HIBMC_CRT_VERT_SYNC 0x080218 +#define HIBMC_CRT_VERT_SYNC_HEIGHT (x) ((x) << 16) +#define HIBMC_CRT_VERT_SYNC_HEIGHT_MASK 0x3F0000 + + +#define HIBMC_CRT_VERT_SYNC_START (x) ((x) << 0) +#define HIBMC_CRT_VERT_SYNC_START_MASK 0x7FF + +/* Auto Centering */ +#define HIBMC_CRT_AUTO_CENTERING_TL 0x080280 +#define HIBMC_CRT_AUTO_CENTERING_TL_TOP (x) ((x) << 16) +#define HIBMC_CRT_AUTO_CENTERING_TL_TOP_MSK 0x7FF0000 + +#define HIBMC_CRT_AUTO_CENTERING_TL_LEFT (x) ((x) << 0) +#define HIBMC_CRT_AUTO_CENTERING_TL_LEFT_MSK 0x7FF + +#define HIBMC_CRT_AUTO_CENTERING_BR 0x080284 +#define HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM (x) ((x) << 16) +#define HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM_MASK 0x7FF0000 + +#define HIBMC_CRT_AUTO_CENTERING_BR_RIGHT (x) ((x) << 0) +#define HIBMC_CRT_AUTO_CENTERING_BR_RIGHT_MASK 0x7FF + +/* register to control panel output */ +#define DISPLAY_CONTROL_HISILE 0x80288 + +/* register and values for PLL control */ +#define CRT_PLL1_HS 0x802a8 +#define CRT_PLL1_HS_25MHZ 0x23d40f02 +#define CRT_PLL1_HS_40MHZ 0x23940801 +#define CRT_PLL1_HS_65MHZ 0x23940d01 +#define CRT_PLL1_HS_78MHZ 0x23540F82 +#define CRT_PLL1_HS_74MHZ 0x23941dc2 +#define CRT_PLL1_HS_80MHZ 0x23941001 +#define CRT_PLL1_HS_80MHZ_1152 0x23540fc2 +#define CRT_PLL1_HS_108MHZ 0x23b41b01 +#define CRT_PLL1_HS_162MHZ 0x23480681 +#define CRT_PLL1_HS_148MHZ 0x23541dc2 +#define CRT_PLL1_HS_193MHZ 0x234807c1 + +#define CRT_PLL2_HS 0x802ac +#define CRT_PLL2_HS_25MHZ 0x206B851E +#define CRT_PLL2_HS_40MHZ 0x30000000 +#define CRT_PLL2_HS_65MHZ 0x40000000 +#define CRT_PLL2_HS_78MHZ 0x50E147AE +#define CRT_PLL2_HS_74MHZ 0x602B6AE7 +#define CRT_PLL2_HS_80MHZ 0x70000000 +#define CRT_PLL2_HS_108MHZ 0x80000000 +#define CRT_PLL2_HS_162MHZ 0xA0000000 +#define CRT_PLL2_HS_148MHZ 0xB0CCCCCD +#define CRT_PLL2_HS_193MHZ 0xC0872B02 + +/* Global macros */ +#define RGB (r, g, b) \ +( \ + (unsigned long)(((r) << 16) | ((g) << 8) | (b)) \ +) + +#define PADDING (align, data) (((data) + (align) - 1) & (~((align) - 1))) + +#define MB (x) ((x) << 20) + +#endif --1.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Regards, Rongrong
Re: [path v2 1/7] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver
Sorry, forgot to add [email protected] to sendto list.
Quoted 828 lines · Rongrong Zou
Hi Daniel,
Thanks for reveiwing!Quoted 146 lines · Daniel Vetter
Quoted 145 lines · Rongrong Zou
Add DRM master driver for Hisilicon Hibmc SoC which used for Out-of-band management. Blow is the general hardware connection, both the Hibmc and the host CPU are on the same mother board.
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+Signed-off-by Rongrong Zou <[email protected]>Signed-off-by Jianhua Li <[email protected]>--- drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 3 +- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 13 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 4 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 307 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 39 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 91 +++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 214 +++++++++++++++ 9 files changed, 699 insertions(+), 1 deletion(-)create mode 100644
drivers/gpu/drm/hisilicon/hibmc/Kconfigcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/Makefilecreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.hdrivers/gpu/drm/hisilicon/Kconfig +1
-0@@ -2,4 +2,5 @@ # hisilicon drm device configuration. # Please keep this list sorted alphabetically +source "drivers/gpu/drm/hisilicon/hibmc/Kconfig" source "drivers/gpu/drm/hisilicon/kirin/Kconfig"drivers/gpu/drm/hisilicon/Makefile +2
-1@@ -2,4 +2,5 @@ # Makefile for hisilicon drm drivers. # Please keep this list sorted alphabetically -obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/ +obj-$(CONFIG_DRM_HISI_HIBMC) += hibmc/ +obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +13
-0@@ -0,0 +1,13 @@ +config DRM_HISI_HIBMC + tristate "DRM Support for Hisilicon Hibmc" + depends on DRM && PCI + select DRM_KMS_HELPER + select DRM_KMS_FB_HELPER + select DRM_GEM_CMA_HELPER + select DRM_KMS_CMA_HELPER + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + help + Choose this option if you have a Hisilicon Hibmc soc chipset. + If M is selected the module will be called hibmc-drm.drivers/gpu/drm/hisilicon/hibmc/Makefile new file +4
-0@@ -0,0 +1,4 @@ +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o + +obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o +#obj-y += hibmc-drm.odrivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +57
-0@@ -0,0 +1,307 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/module.h> +#include <linux/console.h> +#include <drm/drm_atomic_helper.h> +#include <drm/drm_crtc_helper.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> +#include <drm/drmP.h> + +#include "hibmc_drm_drv.h" +#include "hibmc_drm_regs.h" +#include "hibmc_drm_power.h" + +static const struct file_operations hibmc_fops = { + .owner =THIS_MODULE , + .open = drm_open, + .release = drm_release, + .unlocked_ioctl = drm_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = drm_compat_ioctl, +#endif + .poll = drm_poll, + .read = drm_read, + .llseek = no_llseek, +}; + +static int hibmc_enable_vblank (struct drm_device *dev,unsigned int pipe) +{ +return 0 ; +} + +static void hibmc_disable_vblank (struct drm_device *dev,unsigned int pipe) +{ +} + +static struct drm_driver hibmc_driver = { + .driver_features =DRIVER_GEM |DRIVER_MODESET , + .fops = &hibmc_fops, + .name ="hibmc" , + .desc ="hibmc drm driver" ,Quoted 8 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 63
Quoted 6 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6
-0+ .major = 1, + .minor = 0, + .get_vblank_counter = drm_vblank_no_hw_counter, + .enable_vblank = hibmc_enable_vblank, + .disable_vblank = hibmc_disable_vblank, + .gem_free_object = drm_gem_cma_free_object,
gem_free_object_unlockedpls.Applied, thanks.
Quoted 33 lines
Quoted 33 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +32
-0+ .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create, + .dumb_map_offset = drm_gem_cma_dumb_map_offset, + .dumb_destroy = drm_gem_dumb_destroy, +}; + +static int hibmc_pm_suspend (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); + +drm_kms_helper_poll_disable (drm_dev); + +return 0 ; +} + +static int hibmc_pm_resume (struct device *dev) +{ +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); + +drm_helper_resume_force_mode (drm_dev); +drm_kms_helper_poll_enable (drm_dev); + +return 0 ; +} + +static const struct dev_pm_ops hibmc_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (hibmc_pm_suspend, + hibmc_pm_resume) +}; +Quoted 8 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 98
Quoted 3 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +3
-0+static const struct drm_mode_config_funcs mode_config_funcs = { + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit,So how exactly does nonblocking commit work for you? Please run the igt validation suit on your new driver, a bunch of collabora engineers are working hard to make it run on non-intel drivers too. Ping Tomeu and Robert Foss for more info on this please.
OK, I should learn igt validation suit and test the new driver. I tested the driver with tools such as fbtest before. Thanks.
Quoted 4 lines
Lucky for you I'm working on generic nonblocking support in the atomic helpers, patches are on the mailing list.
It's nice, thanks. :)
Quoted 613 lines
Quoted 612 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +209
-0+}; + + +static int hibmc_hw_config (struct hibmc_drm_device *hidev) +{ +unsigned int reg; + +/* On hardware reset, power mode 0 is default. */ +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_MODE0 ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg |=HIBMC_CURR_GATE_DISPLAY (ON ); + reg |=HIBMC_CURR_GATE_LOCALMEM (ON ); + +hibmc_set_current_gate (hidev, reg); + +/* Reset the memory controller. If the memory controller +* is not reset in chip,the system might hang when sw accesses +* the memory.The memory should be resetted after +* changing the MXCLK. +*/ + reg =readl (hidev->mmio +HIBMC_MISC_CTRL ); + reg &= ~HIBMC_MSCCTL_LOCALMEM_RESET_MASK ; + reg |=HIBMC_MSCCTL_LOCALMEM_RESET (RESET ); +writel (reg, hidev->mmio +HIBMC_MISC_CTRL ); + + reg &= ~HIBMC_MSCCTL_LOCALMEM_RESET_MASK ; + reg |=HIBMC_MSCCTL_LOCALMEM_RESET (NORMAL ); + +writel (reg, hidev->mmio +HIBMC_MISC_CTRL ); + +/* We can add more initialization as needed. */ + +return 0 ; +} + +static int hibmc_hw_map (struct hibmc_drm_device *hidev) +{ +struct drm_device *dev = hidev->dev; +struct pci_dev *pdev = dev->pdev; +resource_size_t addr, size, ioaddr, iosize; + + ioaddr =pci_resource_start (pdev,1 ); + iosize =MB (2 ); + + hidev->mmio =ioremap_nocache (ioaddr, iosize); + +if (!hidev->mmio) { +DRM_ERROR ("Cannot map mmio region\n" ); +return -ENOMEM ; + } + + addr =pci_resource_start (pdev,0 ); + size =MB (16 ); + + hidev->fb_map =ioremap (addr, size); +if (!hidev->fb_map) { +DRM_ERROR ("Cannot map framebuffer\n" ); +return -ENOMEM ; + } + hidev->fb_base = addr; + hidev->fb_size = size; + +return 0 ; +} + +static void hibmc_hw_fini (struct hibmc_drm_device *hidev) +{ +if (hidev->mmio) +iounmap (hidev->mmio); +if (hidev->fb_map) +iounmap (hidev->fb_map); +} + +static int hibmc_hw_init (struct hibmc_drm_device *hidev) +{ +int ret; + + ret =hibmc_hw_map (hidev); +if (ret) +return ret; + +hibmc_hw_config (hidev); + +return 0 ; +} + +static int hibmc_unload (struct drm_device *dev) +{ +struct hibmc_drm_device *hidev = dev->dev_private; + +hibmc_hw_fini (hidev); + dev->dev_private =NULL ; +return 0 ; +} + +static int hibmc_load (struct drm_device *dev,unsigned long flags) +{ +struct hibmc_drm_device *hidev; +int ret; + + hidev =devm_kzalloc (dev->dev,sizeof (*hidev),GFP_KERNEL ); +if (!hidev) +return -ENOMEM ; + dev->dev_private = hidev; + hidev->dev = dev; + + ret =hibmc_hw_init (hidev); +if (ret) + goto err; + + + ret =drm_vblank_init (dev, dev->mode_config.num_crtc); +if (ret) { +DRM_ERROR ("failed to initialize vblank.\n" ); +return ret; + } +/* reset all the states of crtc/plane/encoder/connector */ +drm_mode_config_reset (dev); + +return 0 ; + +err: +hibmc_unload (dev); +DRM_ERROR ("failed to initialize drm driver.\n" ); +return ret; +} + + +static int hibmc_pci_probe (struct pci_dev *pdev, +const struct pci_device_id *ent) +{ +struct drm_device *dev; +int ret; + + dev =drm_dev_alloc (&hibmc_driver, &pdev->dev); +if (!dev) +return -ENOMEM ; + + dev->pdev = pdev; +pci_set_drvdata (pdev, dev); + + ret =pci_enable_device (pdev); +if (ret) + goto err_free; + + ret =hibmc_load (dev,0 ); +if (ret) + goto err_disable; + + ret =drm_dev_register (dev,0 ); +if (ret) + goto err_unload; + +return 0 ; + +err_unload: +hibmc_unload (dev); +err_disable: +pci_disable_device (pdev); +err_free: +drm_dev_unref (dev); + +return ret; +} + +static void hibmc_pci_remove (struct pci_dev *pdev) +{ +struct drm_device *dev =pci_get_drvdata (pdev); + +drm_dev_unregister (dev); +hibmc_unload (dev); +drm_dev_unref (dev); +} + +static struct pci_device_id hibmc_pci_table[] = { + {0x19e5 ,0x1711 ,PCI_ANY_ID ,PCI_ANY_ID ,0 ,0 ,0 }, + {0 ,} +}; + +static struct pci_driver hibmc_pci_driver = { + .name ="hibmc-drm" , + .id_table = hibmc_pci_table, + .probe = hibmc_pci_probe, + .remove = hibmc_pci_remove, + .driver.pm = &hibmc_pm_ops, +}; + +static int __init hibmc_init (void ) +{ +return pci_register_driver (&hibmc_pci_driver); +} + +static void __exit hibmc_exit(void) +{ +return pci_unregister_driver (&hibmc_pci_driver); +} + +module_init (hibmc_init); +module_exit (hibmc_exit); + +MODULE_DEVICE_TABLE (pci, hibmc_pci_table); +MODULE_AUTHOR ("RongrongZou <[email protected]>" ); +MODULE_DESCRIPTION ("DRM Driver for Hisilicon Hibmc" ); +MODULE_LICENSE ("GPL v2" ); +drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h new file +39
-0@@ -0,0 +1,39 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_DRV_H +#define HIBMC_DRM_DRV_H + +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> +#include <drm/drm_gem_cma_helper.h> + +struct hibmc_drm_device { +/* hw */ +void __iomem *mmio; +void __iomem *fb_map; +unsigned long fb_base; +unsigned long fb_size; + +/* drm */ +struct drm_device *dev; +bool mode_config_initialized; +}; + + +#endif drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c new file +91
-0@@ -0,0 +1,91 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/io.h> +#include <drm/drmP.h> +#include <drm/drm_fb_helper.h> +#include "hibmc_drm_drv.h" +#include "hibmc_drm_regs.h" + +/* +* It can operate in one of three modes: 0, 1 or Sleep. +*/ +void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode) +{ +unsigned int control_value =0 ; +void __iomem *mmio = hidev->mmio; + +if (power_mode >HIBMC_PW_MODE_CTL_MODE_SLEEP ) +return ; + + control_value =readl (mmio +HIBMC_POWER_MODE_CTRL ); + control_value &= ~HIBMC_PW_MODE_CTL_MODE_MASK ; + + control_value |=HIBMC_PW_MODE_CTL_MODE (power_mode) & +HIBMC_PW_MODE_CTL_MODE_MASK ; + + +/* Set up other fields in Power Control Register */ +if (power_mode ==HIBMC_PW_MODE_CTL_MODE_SLEEP ) { + control_value &= ~HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + control_value |=HIBMC_PW_MODE_CTL_OSC_INPUT (0 ) & +HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + }else { + control_value &= ~HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + control_value |=HIBMC_PW_MODE_CTL_OSC_INPUT (1 ) & +HIBMC_PW_MODE_CTL_OSC_INPUT_MASK ; + + } +/* Program new power mode. */ +writel (control_value, mmio +HIBMC_POWER_MODE_CTRL ); +} + +static unsigned int hibmc_get_power_mode (struct hibmc_drm_device *hidev) +{ +void __iomem *mmio = hidev->mmio; + +return (readl (mmio +HIBMC_POWER_MODE_CTRL )& +HIBMC_PW_MODE_CTL_MODE_MASK ) >>HIBMC_PW_MODE_CTL_MODE_SHIFT ; +} + +void hibmc_set_current_gate (struct hibmc_drm_device *hidev,unsigned int gate) +{ +unsigned int gate_reg; +unsigned int mode; +void __iomem *mmio = hidev->mmio; + +/* Get current power mode. */ + mode =hibmc_get_power_mode (hidev); + +switch (mode) { +case HIBMC_PW_MODE_CTL_MODE_MODE0 : + gate_reg =HIBMC_MODE0_GATE ; +break ; + +case HIBMC_PW_MODE_CTL_MODE_MODE1 : + gate_reg =HIBMC_MODE1_GATE ; +break ; + +default : + gate_reg =HIBMC_MODE0_GATE ; +break ; + } +writel (gate, mmio + gate_reg); +} +drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h new file +28
-0@@ -0,0 +1,28 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_POWER_H +#define HIBMC_DRM_POWER_H + +#include "hibmc_drm_drv.h" + +extern void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode); +extern void hibmc_set_current_gate (struct hibmc_drm_device *hidev, +unsigned int gate); +#endif drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h new file +214
-1@@ -0,0 +1,214 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_HW_H +#define HIBMC_DRM_HW_H + +#define OFF 0 +#define ON 1 +#define DISABLE 0 +#define ENABLE 1 + + + +/* register definition */ +#define HIBMC_MISC_CTRL 0x4 + +#define HIBMC_MSCCTL_LOCALMEM_RESET (x) ((x) << 6) +#define HIBMC_MSCCTL_LOCALMEM_RESET_MASK 0x40 + +#define RESET 0 +#define NORMAL 1 + +#define HIBMC_CURRENT_GATE 0x000040 +#define HIBMC_CURR_GATE_DISPLAY (x) ((x) << 2) +#define HIBMC_CURR_GATE_DISPLAY_MASK 0x4 + +#define HIBMC_CURR_GATE_LOCALMEM (x) ((x) << 1) +#define HIBMC_CURR_GATE_LOCALMEM_MASK 0x2 + +#define HIBMC_MODE0_GATE 0x000044 +#define HIBMC_MODE1_GATE 0x000048 +#define HIBMC_POWER_MODE_CTRL 0x00004C + +#define HIBMC_PW_MODE_CTL_OSC_INPUT (x) ((x) << 3) +#define HIBMC_PW_MODE_CTL_OSC_INPUT_MASK 0x8 + +#define HIBMC_PW_MODE_CTL_MODE (x) ((x) << 0) +#define HIBMC_PW_MODE_CTL_MODE_MASK 0x03 +#define HIBMC_PW_MODE_CTL_MODE_SHIFT 0 + + +#define HIBMC_PW_MODE_CTL_MODE_MODE0 0 +#define HIBMC_PW_MODE_CTL_MODE_MODE1 1 +#define HIBMC_PW_MODE_CTL_MODE_SLEEP 2 + +#define HIBMC_PANEL_PLL_CTRL 0x00005C +#define HIBMC_CRT_PLL_CTRL 0x000060 + +#define HIBMC_PLL_CTRL_BYPASS (x) ((x) << 18) +#define HIBMC_PLL_CTRL_BYPASS_MASK 0x40000 + +#define HIBMC_PLL_CTRL_POWER (x) ((x) << 17) +#define HIBMC_PLL_CTRL_POWER_MASK 0x20000 + +#define HIBMC_PLL_CTRL_INPUT (x) ((x) << 16) +#define HIBMC_PLL_CTRL_INPUT_MASK 0x10000 + +#define OSC 0 +#define TESTCLK 1 + +#define HIBMC_PLL_CTRL_POD (x) ((x) << 14) +#define HIBMC_PLL_CTRL_POD_MASK 0xC000 + +#define HIBMC_PLL_CTRL_OD (x) ((x) << 12) +#define HIBMC_PLL_CTRL_OD_MASK 0x3000 + +#define HIBMC_PLL_CTRL_N (x) ((x) << 8) +#define HIBMC_PLL_CTRL_N_MASK 0xF00 + +#define HIBMC_PLL_CTRL_M (x) ((x) << 0) +#define HIBMC_PLL_CTRL_M_MASK 0xFF + + +#define HIBMC_CRT_DISP_CTL 0x80200 + +#define HIBMC_CRT_DISP_CTL_CRTSELECT (x) ((x) << 25) +#define HIBMC_CRT_DISP_CTL_CRTSELECT_MASK 0x2000000 + +#define CRTSELECT_VGA 0 +#define CRTSELECT_CRT 1 + +#define HIBMC_CRT_DISP_CTL_CLOCK_PHASE (x) ((x) << 14) +#define HIBMC_CRT_DISP_CTL_CLOCK_PHASE_MASK 0x4000 + +#define PHASE_ACTIVE_HIGH 0 +#define PHASE_ACTIVE_LOW 1 + +#define HIBMC_CRT_DISP_CTL_VSYNC_PHASE (x) ((x) << 13) +#define HIBMC_CRT_DISP_CTL_VSYNC_PHASE_MASK 0x2000 + +#define HIBMC_CRT_DISP_CTL_HSYNC_PHASE (x) ((x) << 12) +#define HIBMC_CRT_DISP_CTL_HSYNC_PHASE_MASK 0x1000 + +#define HIBMC_CRT_DISP_CTL_TIMING (x) ((x) << 8) +#define HIBMC_CRT_DISP_CTL_TIMING_MASK 0x100 + + +#define HIBMC_CRT_DISP_CTL_PLANE (x) ((x) << 2) +#define HIBMC_CRT_DISP_CTL_PLANE_MASK 4 + +#define HIBMC_CRT_DISP_CTL_FORMAT (x) ((x) << 0) +#define HIBMC_CRT_DISP_CTL_FORMAT_MASK 0x03 + + + +#define HIBMC_CRT_FB_ADDRESS 0x080204 + +#define HIBMC_CRT_FB_WIDTH 0x080208 +#define HIBMC_CRT_FB_WIDTH_WIDTH (x) ((x) << 16) +#define HIBMC_CRT_FB_WIDTH_WIDTH_MASK 0x3FFF0000 +#define HIBMC_CRT_FB_WIDTH_OFFS (x) ((x) << 0) +#define HIBMC_CRT_FB_WIDTH_OFFS_MASK 0x3FFF + + +#define HIBMC_CRT_HORZ_TOTAL 0x08020C +#define HIBMC_CRT_HORZ_TOTAL_TOTAL (x) ((x) << 16) +#define HIBMC_CRT_HORZ_TOTAL_TOTAL_MASK 0xFFF0000 + + +#define HIBMC_CRT_HORZ_TOTAL_DISPLAY_END (x) ((x) << 0) +#define HIBMC_CRT_HORZ_TOTAL_DISPLAY_END_MASK 0xFFF + +#define HIBMC_CRT_HORZ_SYNC 0x080210 +#define HIBMC_CRT_HORZ_SYNC_WIDTH (x) ((x) << 16) +#define HIBMC_CRT_HORZ_SYNC_WIDTH_MASK 0xFF0000 + +#define HIBMC_CRT_HORZ_SYNC_START (x) ((x) << 0) +#define HIBMC_CRT_HORZ_SYNC_START_MASK 0xFFF + +#define HIBMC_CRT_VERT_TOTAL 0x080214 +#define HIBMC_CRT_VERT_TOTAL_TOTAL (x) ((x) << 16) +#define HIBMC_CRT_VERT_TOTAL_TOTAL_MASK 0x7FFF0000 + +#define HIBMC_CRT_VERT_TOTAL_DISPLAY_END (x) ((x) << 0) +#define HIBMC_CRT_VERT_TOTAL_DISPLAY_END_MASK 0x7FF + +#define HIBMC_CRT_VERT_SYNC 0x080218 +#define HIBMC_CRT_VERT_SYNC_HEIGHT (x) ((x) << 16) +#define HIBMC_CRT_VERT_SYNC_HEIGHT_MASK 0x3F0000 + + +#define HIBMC_CRT_VERT_SYNC_START (x) ((x) << 0) +#define HIBMC_CRT_VERT_SYNC_START_MASK 0x7FF + +/* Auto Centering */ +#define HIBMC_CRT_AUTO_CENTERING_TL 0x080280 +#define HIBMC_CRT_AUTO_CENTERING_TL_TOP (x) ((x) << 16) +#define HIBMC_CRT_AUTO_CENTERING_TL_TOP_MSK 0x7FF0000 + +#define HIBMC_CRT_AUTO_CENTERING_TL_LEFT (x) ((x) << 0) +#define HIBMC_CRT_AUTO_CENTERING_TL_LEFT_MSK 0x7FF + +#define HIBMC_CRT_AUTO_CENTERING_BR 0x080284 +#define HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM (x) ((x) << 16) +#define HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM_MASK 0x7FF0000 + +#define HIBMC_CRT_AUTO_CENTERING_BR_RIGHT (x) ((x) << 0) +#define HIBMC_CRT_AUTO_CENTERING_BR_RIGHT_MASK 0x7FF + +/* register to control panel output */ +#define DISPLAY_CONTROL_HISILE 0x80288 + +/* register and values for PLL control */ +#define CRT_PLL1_HS 0x802a8 +#define CRT_PLL1_HS_25MHZ 0x23d40f02 +#define CRT_PLL1_HS_40MHZ 0x23940801 +#define CRT_PLL1_HS_65MHZ 0x23940d01 +#define CRT_PLL1_HS_78MHZ 0x23540F82 +#define CRT_PLL1_HS_74MHZ 0x23941dc2 +#define CRT_PLL1_HS_80MHZ 0x23941001 +#define CRT_PLL1_HS_80MHZ_1152 0x23540fc2 +#define CRT_PLL1_HS_108MHZ 0x23b41b01 +#define CRT_PLL1_HS_162MHZ 0x23480681 +#define CRT_PLL1_HS_148MHZ 0x23541dc2 +#define CRT_PLL1_HS_193MHZ 0x234807c1 + +#define CRT_PLL2_HS 0x802ac +#define CRT_PLL2_HS_25MHZ 0x206B851E +#define CRT_PLL2_HS_40MHZ 0x30000000 +#define CRT_PLL2_HS_65MHZ 0x40000000 +#define CRT_PLL2_HS_78MHZ 0x50E147AE +#define CRT_PLL2_HS_74MHZ 0x602B6AE7 +#define CRT_PLL2_HS_80MHZ 0x70000000 +#define CRT_PLL2_HS_108MHZ 0x80000000 +#define CRT_PLL2_HS_162MHZ 0xA0000000 +#define CRT_PLL2_HS_148MHZ 0xB0CCCCCD +#define CRT_PLL2_HS_193MHZ 0xC0872B02 + +/* Global macros */ +#define RGB (r, g, b) \ +( \ + (unsigned long)(((r) << 16) | ((g) << 8) | (b)) \ +) + +#define PADDING (align, data) (((data) + (align) - 1) & (~((align) - 1))) + +#define MB (x) ((x) << 20) + +#endif --1.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Regards, Rongrong
PATCH v2 2/7 drm/hisilicon/hibmc: Add plane for DE
In reply to Rongrong ZouAdd plane funcs and helper funcs for DE.
--- drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 170 ++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 41 +++++- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 3 + 4 files changed, 214 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
@@ -1,4 +1,4 @@ -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_power.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c new file +170 -0
170 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +40 -1
65 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +3 -0
@@ -32,8 +32,11 @@ struct hibmc_drm_device {/* drm */ struct drm_device *dev; +struct drm_plane plane; bool mode_config_initialized; }; +int hibmc_plane_init (struct hibmc_drm_device *hidev); +#endif
Signature · 1 line
1.9.1
PATCH v2 3/7 drm/hisilicon/hibmc: Add crtc for DE
In reply to Rongrong ZouAdd crtc funcs and helper funcs for DE.
--- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 307 ++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h | 29 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 6 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 2 + 4 files changed, 344 insertions(+) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +307 -0
@@ -26,6 +26,7 @@#include "hibmc_drm_drv.h" #include "hibmc_drm_regs.h" +#include "hibmc_drm_de.h" #include "hibmc_drm_power.h" /* ---------------------------------------------------------------------- */
@@ -168,3 +169,309 @@ int hibmc_plane_init(struct hibmc_drm_device *hidev)return 0 ; } +static void hibmc_crtc_enable (struct drm_crtc *crtc) +{ +unsigned int reg; +/* power mode 0 is default. */ +struct hibmc_drm_device *hidev = crtc->dev->dev_private; + +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_MODE0 ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg |=HIBMC_CURR_GATE_LOCALMEM (ON ); + reg |=HIBMC_CURR_GATE_DISPLAY (ON ); +hibmc_set_current_gate (hidev, reg); +} + +static void hibmc_crtc_disable (struct drm_crtc *crtc) +{ +unsigned int reg; +struct hibmc_drm_device *hidev = crtc->dev->dev_private; + +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_SLEEP ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg |=HIBMC_CURR_GATE_LOCALMEM (OFF ); + reg |=HIBMC_CURR_GATE_DISPLAY (OFF ); +hibmc_set_current_gate (hidev, reg); +} + +static int hibmc_crtc_atomic_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return 0 ; +} + +static unsigned int format_pll_reg (void ) +{ +unsigned int pllreg =0 ; +struct panel_pll pll = {0 }; + +/* Note that all PLL's have the same format. Here, +* we just use Panel PLL parameter to work out the bit +* fields in the register.On returning a 32 bit number, the value can +* be applied to any PLL in the calling function. +*/ + pllreg |=HIBMC_PLL_CTRL_BYPASS (OFF ) &HIBMC_PLL_CTRL_BYPASS_MASK ; + pllreg |=HIBMC_PLL_CTRL_POWER (ON ) &HIBMC_PLL_CTRL_POWER_MASK ; + pllreg |=HIBMC_PLL_CTRL_INPUT (OSC ) &HIBMC_PLL_CTRL_INPUT_MASK ; + pllreg |=HIBMC_PLL_CTRL_POD (pll.POD) &HIBMC_PLL_CTRL_POD_MASK ; + pllreg |=HIBMC_PLL_CTRL_OD (pll.OD) &HIBMC_PLL_CTRL_OD_MASK ; + pllreg |=HIBMC_PLL_CTRL_N (pll.N) &HIBMC_PLL_CTRL_N_MASK ; + pllreg |=HIBMC_PLL_CTRL_M (pll.M) &HIBMC_PLL_CTRL_M_MASK ; + +return pllreg; +} + +static void set_vclock_hisilicon (struct drm_device *dev,unsigned long pll) +{ +unsigned long tmp0, tmp1; +struct hibmc_drm_device *hidev = dev->dev_private; + +/* 1. outer_bypass_n=0 */ + tmp0 =readl (hidev->mmio +CRT_PLL1_HS ); + tmp0 &=0xBFFFFFFF ; +writel (tmp0, hidev->mmio +CRT_PLL1_HS ); + +/* 2. pll_pd=1?inter_bypass=1 */ +writel (0x21000000 , hidev->mmio +CRT_PLL1_HS ); + +/* 3. config pll */ +writel (pll, hidev->mmio +CRT_PLL1_HS ); + +/* 4. delay */ +mdelay (1 ); + +/* 5. pll_pd =0 */ + tmp1 = pll & ~0x01000000 ; +writel (tmp1, hidev->mmio +CRT_PLL1_HS ); + +/* 6. delay */ +mdelay (1 ); + +/* 7. inter_bypass=0 */ + tmp1 &= ~0x20000000 ; +writel (tmp1, hidev->mmio +CRT_PLL1_HS ); + +/* 8. delay */ +mdelay (1 ); + +/* 9. outer_bypass_n=1 */ + tmp1 |=0x40000000 ; +writel (tmp1, hidev->mmio +CRT_PLL1_HS ); +} + +/* This function takes care the extra registers and bit fields required to +*setup a mode in board. +*Explanation about Display Control register: +*FPGA only supports 7 predefined pixel clocks, and clock select is +*in bit 4:0 of new register 0x802a8. +*/ +static unsigned int display_ctrl_adjust (struct drm_device *dev, +struct drm_display_mode *mode, +unsigned int ctrl) +{ +unsigned long x, y; +unsigned long pll1;/* bit[31:0] of PLL */ +unsigned long pll2;/* bit[63:32] of PLL */ +struct hibmc_drm_device *hidev = dev->dev_private; + + x = mode->hdisplay; + y = mode->vdisplay; + +/* Hisilicon has to set up a new register for PLL control +*(CRT_PLL1_HS & CRT_PLL2_HS). +*/ +if (x ==800 && y ==600 ) { + pll1 =CRT_PLL1_HS_40MHZ ; + pll2 =CRT_PLL2_HS_40MHZ ; + }else if (x ==1024 && y ==768 ) { + pll1 =CRT_PLL1_HS_65MHZ ; + pll2 =CRT_PLL2_HS_65MHZ ; + }else if (x ==1152 && y ==864 ) { + pll1 =CRT_PLL1_HS_80MHZ_1152 ; + pll2 =CRT_PLL2_HS_80MHZ ; + }else if (x ==1280 && y ==768 ) { + pll1 =CRT_PLL1_HS_80MHZ ; + pll2 =CRT_PLL2_HS_80MHZ ; + }else if (x ==1280 && y ==720 ) { + pll1 =CRT_PLL1_HS_74MHZ ; + pll2 =CRT_PLL2_HS_74MHZ ; + }else if (x ==1280 && y ==960 ) { + pll1 =CRT_PLL1_HS_108MHZ ; + pll2 =CRT_PLL2_HS_108MHZ ; + }else if (x ==1280 && y ==1024 ) { + pll1 =CRT_PLL1_HS_108MHZ ; + pll2 =CRT_PLL2_HS_108MHZ ; + }else if (x ==1600 && y ==1200 ) { + pll1 =CRT_PLL1_HS_162MHZ ; + pll2 =CRT_PLL2_HS_162MHZ ; + }else if (x ==1920 && y ==1080 ) { + pll1 =CRT_PLL1_HS_148MHZ ; + pll2 =CRT_PLL2_HS_148MHZ ; + }else if (x ==1920 && y ==1200 ) { + pll1 =CRT_PLL1_HS_193MHZ ; + pll2 =CRT_PLL2_HS_193MHZ ; + }else /* default to VGA clock */ { + pll1 =CRT_PLL1_HS_25MHZ ; + pll2 =CRT_PLL2_HS_25MHZ ; + } + +writel (pll2, hidev->mmio +CRT_PLL2_HS ); +set_vclock_hisilicon (dev, pll1); + +/* Hisilicon has to set up the top-left and bottom-right +* registers as well. +* Note that normal chip only use those two register for +* auto-centering mode. +*/ +writel ((HIBMC_CRT_AUTO_CENTERING_TL_TOP (0 ) & +HIBMC_CRT_AUTO_CENTERING_TL_TOP_MSK ) | + (HIBMC_CRT_AUTO_CENTERING_TL_LEFT (0 ) & +HIBMC_CRT_AUTO_CENTERING_TL_LEFT_MSK ), + hidev->mmio +HIBMC_CRT_AUTO_CENTERING_TL ); + +writel ((HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM (y -1 ) & +HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM_MASK ) | + (HIBMC_CRT_AUTO_CENTERING_BR_RIGHT (x -1 ) & +HIBMC_CRT_AUTO_CENTERING_BR_RIGHT_MASK ), + hidev->mmio +HIBMC_CRT_AUTO_CENTERING_BR ); + +/* Assume common fields in ctrl have been properly set before +* calling this function. +* This function only sets the extra fields in ctrl. +*/ + +/* Set bit 25 of display controller: Select CRT or VGA clock */ + ctrl &= ~HIBMC_CRT_DISP_CTL_CRTSELECT_MASK ; + ctrl &= ~HIBMC_CRT_DISP_CTL_CLOCK_PHASE_MASK ; + + ctrl |=HIBMC_CRT_DISP_CTL_CRTSELECT (CRTSELECT_CRT ); + +/*ctrl = FIELD_SET(ctrl, HIBMC_CRT_DISP_CTL, CRTSELECT, CRT);*/ + +/* Set bit 14 of display controller */ +/*ctrl &= FIELD_CLEAR(HIBMC_CRT_DISP_CTL, CLOCK_PHASE);*/ + +/* clock_phase_polarity is 0 */ + ctrl |=HIBMC_CRT_DISP_CTL_CLOCK_PHASE (PHASE_ACTIVE_HIGH ); +/*ctrl = FIELD_SET(ctrl, HIBMC_CRT_DISP_CTL,*/ +/*CLOCK_PHASE, ACTIVE_HIGH);*/ + +writel (ctrl, hidev->mmio +HIBMC_CRT_DISP_CTL ); + +return ctrl; +} + +static void hibmc_crtc_mode_set_nofb (struct drm_crtc *crtc) +{ +unsigned int val; +struct drm_display_mode *mode = &crtc->state->mode; +struct drm_device *dev = crtc->dev; +struct hibmc_drm_device *hidev = dev->dev_private; + +writel (format_pll_reg (), hidev->mmio +HIBMC_CRT_PLL_CTRL ); +writel ((HIBMC_CRT_HORZ_TOTAL_TOTAL (mode->htotal -1 ) & +HIBMC_CRT_HORZ_TOTAL_TOTAL_MASK ) | + (HIBMC_CRT_HORZ_TOTAL_DISPLAY_END (mode->hdisplay -1 ) & +HIBMC_CRT_HORZ_TOTAL_DISPLAY_END_MASK ), + hidev->mmio +HIBMC_CRT_HORZ_TOTAL ); + +writel ((HIBMC_CRT_HORZ_SYNC_WIDTH (mode->hsync_end - mode->hsync_start) + &HIBMC_CRT_HORZ_SYNC_WIDTH_MASK ) | + (HIBMC_CRT_HORZ_SYNC_START (mode->hsync_start -1 ) + &HIBMC_CRT_HORZ_SYNC_START_MASK ), + hidev->mmio +HIBMC_CRT_HORZ_SYNC ); + +writel ((HIBMC_CRT_VERT_TOTAL_TOTAL (mode->vtotal -1 ) & +HIBMC_CRT_VERT_TOTAL_TOTAL_MASK ) | + (HIBMC_CRT_VERT_TOTAL_DISPLAY_END (mode->vdisplay -1 ) & +HIBMC_CRT_VERT_TOTAL_DISPLAY_END_MASK ), + hidev->mmio +HIBMC_CRT_VERT_TOTAL ); + +writel ((HIBMC_CRT_VERT_SYNC_HEIGHT (mode->vsync_end - mode->vsync_start) + &HIBMC_CRT_VERT_SYNC_HEIGHT_MASK ) | + (HIBMC_CRT_VERT_SYNC_START (mode->vsync_start -1 ) & +HIBMC_CRT_VERT_SYNC_START_MASK ), + hidev->mmio +HIBMC_CRT_VERT_SYNC ); + + val =HIBMC_CRT_DISP_CTL_VSYNC_PHASE (0 ) & +HIBMC_CRT_DISP_CTL_VSYNC_PHASE_MASK ; + val |=HIBMC_CRT_DISP_CTL_HSYNC_PHASE (0 ) & +HIBMC_CRT_DISP_CTL_HSYNC_PHASE_MASK ; + val |=HIBMC_CRT_DISP_CTL_TIMING (ENABLE ); + val |=HIBMC_CRT_DISP_CTL_PLANE (ENABLE ); + +display_ctrl_adjust (dev, mode, val); +} + +static void hibmc_crtc_atomic_begin (struct drm_crtc *crtc, +struct drm_crtc_state *old_state) +{ +unsigned int reg; +struct drm_device *dev = crtc->dev; +struct hibmc_drm_device *hidev = dev->dev_private; + +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_MODE0 ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg |=HIBMC_CURR_GATE_DISPLAY (ON ); + reg |=HIBMC_CURR_GATE_LOCALMEM (ON ); +hibmc_set_current_gate (hidev, reg); + +/* We can add more initialization as needed. */ +} + +static void hibmc_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_state) + +{ +} + +/* These provide the minimum set of functions required to handle a CRTC */ +static const struct drm_crtc_funcs hibmc_crtc_funcs = { + .page_flip = drm_atomic_helper_page_flip, + .set_config = drm_atomic_helper_set_config, + .destroy = drm_crtc_cleanup, + .reset = drm_atomic_helper_crtc_reset, + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, +}; + +static const struct drm_crtc_helper_funcs hibmc_crtc_helper_funcs = { + .enable = hibmc_crtc_enable, + .disable = hibmc_crtc_disable, + .mode_set_nofb = hibmc_crtc_mode_set_nofb, + .atomic_check = hibmc_crtc_atomic_check, + .atomic_begin = hibmc_crtc_atomic_begin, + .atomic_flush = hibmc_crtc_atomic_flush, +}; + +int hibmc_crtc_init (struct hibmc_drm_device *hidev) +{ +struct drm_device *dev = hidev->dev; +struct drm_crtc *crtc = &hidev->crtc; +struct drm_plane *plane = &hidev->plane; +int ret; + + ret =drm_crtc_init_with_planes (dev, crtc, plane, +NULL , &hibmc_crtc_funcs,NULL ); +if (ret) { +DRM_ERROR ("failed to init crtc.\n" ); +return ret; + } + +drm_mode_crtc_set_gamma_size (crtc,256 ); +drm_crtc_helper_add (crtc, &hibmc_crtc_helper_funcs); +return 0 ; +} +
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h new file +29 -0
@@ -0,0 +1,29 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <zourongrong@huawei> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_DE_H +#define HIBMC_DRM_DE_H + +struct panel_pll { +unsigned long M; +unsigned long N; +unsigned long OD; +unsigned long POD; +}; + +#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +6 -0
@@ -123,6 +123,12 @@ static int hibmc_kms_init(struct hibmc_drm_device *hidev)return ret; } + ret =hibmc_crtc_init (hidev); +if (ret) { +DRM_ERROR ("failed to init crtc.\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +2 -0
@@ -33,10 +33,12 @@ struct hibmc_drm_device {/* drm */ struct drm_device *dev;struct drm_plane plane; +struct drm_crtc crtc; bool mode_config_initialized; };int hibmc_plane_init (struct hibmc_drm_device *hidev); +int hibmc_crtc_init (struct hibmc_drm_device *hidev);#endif
Signature · 1 line
1.9.1
PATCH v2 4/7 drm/hisilicon/hibmc: Add encoder for VDAC
In reply to Rongrong ZouAdd encoder funcs and helpers for VDAC.
--- drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 6 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 2 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 85 ++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
@@ -1,4 +1,4 @@ -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_power.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_vdac.o hibmc_drm_power.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +6 -0
@@ -129,6 +129,12 @@ static int hibmc_kms_init(struct hibmc_drm_device *hidev)return ret; } + ret =hibmc_encoder_init (hidev); +if (ret) { +DRM_ERROR ("failed to init encoder\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +2 -0
@@ -34,11 +34,13 @@ struct hibmc_drm_device {struct drm_device *dev;struct drm_plane plane;struct drm_crtc crtc; +struct drm_encoder encoder; bool mode_config_initialized; };int hibmc_plane_init (struct hibmc_drm_device *hidev);int hibmc_crtc_init (struct hibmc_drm_device *hidev); +int hibmc_encoder_init (struct hibmc_drm_device *hidev);#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 5/7 drm/hisilicon/hibmc: Add connector for VDAC
In reply to Rongrong ZouAdd connector funcs and helper funcs for VDAC.
--- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 21 ++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 3 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 89 ++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +21 -0
@@ -135,6 +135,14 @@ static int hibmc_kms_init(struct hibmc_drm_device *hidev)return ret; } + ret =hibmc_connector_init (hidev); +if (ret) { +DRM_ERROR ("failed to init connector\n" ); +return ret; + } + +drm_mode_connector_attach_encoder (&hidev->connector, + &hidev->encoder);return 0 ; }
@@ -278,6 +286,12 @@ err:return ret; } +static void hibmc_connector_unplug_all (struct drm_device *dev) +{ +mutex_lock (&dev->mode_config.mutex); +drm_connector_unregister_all (dev); +mutex_unlock (&dev->mode_config.mutex); +}static int hibmc_pci_probe (struct pci_dev *pdev,const struct pci_device_id *ent)
@@ -304,8 +318,14 @@ static int hibmc_pci_probe(struct pci_dev *pdev,if (ret) goto err_unload; + ret =drm_connector_register_all (dev); +if (ret) + goto err_unregister; +return 0 ; +err_unregister: +drm_dev_unregister (dev); err_unload:hibmc_unload (dev); err_disable:
@@ -320,6 +340,7 @@ static void hibmc_pci_remove(struct pci_dev *pdev) {struct drm_device *dev =pci_get_drvdata (pdev); +hibmc_connector_unplug_all (dev);drm_dev_unregister (dev);hibmc_unload (dev);drm_dev_unref (dev);
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +2 -1
@@ -35,12 +35,13 @@ struct hibmc_drm_device {struct drm_plane plane;struct drm_crtc crtc;struct drm_encoder encoder; +struct drm_connector connector; bool mode_config_initialized; };int hibmc_plane_init (struct hibmc_drm_device *hidev);int hibmc_crtc_init (struct hibmc_drm_device *hidev);int hibmc_encoder_init (struct hibmc_drm_device *hidev); - +int hibmc_connector_init (struct hibmc_drm_device *hidev);#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +89 -0
98 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 6/7 drm/hisilicon/hibmc: Add support for frame buffer
In reply to Rongrong ZouAdd support for fbdev.
--- drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 20 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 17 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 286 ++++++++++++++++++++++ 4 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
@@ -1,4 +1,4 @@ -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_vdac.o hibmc_drm_power.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_vdac.o hibmc_drm_fbdev.o hibmc_drm_power.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +20 -0
@@ -72,9 +72,16 @@ static int hibmc_pm_suspend(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct hibmc_drm_device *hidev = drm_dev->dev_private;drm_kms_helper_poll_disable (drm_dev); +if (hidev->fbdev.initialized) { +console_lock (); +drm_fb_helper_set_suspend (&hidev->fbdev.helper,1 ); +console_unlock (); + } +return 0 ; }
@@ -82,8 +89,16 @@ static int hibmc_pm_resume(struct device *dev) {struct pci_dev *pdev =to_pci_dev (dev);struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct hibmc_drm_device *hidev = drm_dev->dev_private;drm_helper_resume_force_mode (drm_dev); + +if (hidev->fbdev.initialized) { +console_lock (); +drm_fb_helper_set_suspend (&hidev->fbdev.helper,0 ); +console_unlock (); + } +drm_kms_helper_poll_enable (drm_dev);return 0 ;
@@ -245,6 +260,7 @@ static int hibmc_unload(struct drm_device *dev) {struct hibmc_drm_device *hidev = dev->dev_private; +hibmc_fbdev_fini (hidev);hibmc_kms_fini (hidev);hibmc_hw_fini (hidev); dev->dev_private =NULL ;
@@ -278,6 +294,10 @@ static int hibmc_load(struct drm_device *dev, unsigned long flags)/* reset all the states of crtc/plane/encoder/connector */ drm_mode_config_reset (dev); + ret =hibmc_fbdev_init (hidev); +if (ret) + goto err; +return 0 ; err:
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +17 -0
@@ -23,6 +23,18 @@#include <drm/drm_fb_helper.h> #include <drm/drm_gem_cma_helper.h> +struct hibmc_framebuffer { +struct drm_framebuffer fb; +struct drm_gem_cma_object *obj; +bool is_fbdev_fb; +}; + +struct hibmc_fbdev { +struct hibmc_framebuffer fb; +struct drm_fb_helper helper; +bool initialized; +}; +struct hibmc_drm_device {/* hw */ void __iomem *mmio;
@@ -37,11 +49,16 @@ struct hibmc_drm_device {struct drm_encoder encoder;struct drm_connector connector;bool mode_config_initialized; + +/* fbdev */ + struct hibmc_fbdev fbdev; };int hibmc_plane_init (struct hibmc_drm_device *hidev);int hibmc_crtc_init (struct hibmc_drm_device *hidev);int hibmc_encoder_init (struct hibmc_drm_device *hidev);int hibmc_connector_init (struct hibmc_drm_device *hidev); +int hibmc_fbdev_init (struct hibmc_drm_device *hidev); +void hibmc_fbdev_fini (struct hibmc_drm_device *hidev);#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c new file +286 -0
286 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 7/7 drm/hisilicon/hibmc: Add maintainer for Hibmc DRM
In reply to Rongrong Zou--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -3957,6 +3957,13 @@ T: git git://github.com/patjak/drm-gma500 S: Maintained F: drivers/gpu/drm/gma500/ +DRM DRIVERS FOR HIBMC +M: lijianhua <[email protected]> +M: Rongrong Zou <[email protected]> +L: [email protected] +S: Maintained +F: drivers/gpu/drm/hisilicon/hibmc + DRM DRIVERS FOR HISILICON M: Xinliang Liu <[email protected]> R: Xinwei Kong <[email protected]>
Signature · 1 line
1.9.1
Re: [path v2 7/7] drm/hisilicon/hibmc: Add maintainer for Hibmc DRM
Quoted 11 lines · Rongrong Zou
Signed-off-by Rongrong Zou <[email protected]>Signed-off-by Jianhua Li <[email protected]>--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)MAINTAINERS +0
-0
MAINTAINERS T: git git://github.com/patjak/drm-gma500 · line 3965
Quoted 9 lines
MAINTAINERS +6
-0@@ -3957,6 +3957,13 @@ T: git git://github.com/patjak/drm-gma500 S: Maintained F: drivers/gpu/drm/gma500/ +DRM DRIVERS FOR HIBMC +M: lijianhua <[email protected]> +M: Rongrong Zou <[email protected]> +L: dri-devel at lists.freedesktop.org +S: Maintained +F: drivers/gpu/drm/hisilicon/hibmc
Please add a "/" ad the end of this line.
And move this part into DRM DRIVERS FOR HISILICON
Thanks,
-xinliang
Quoted 7 lines
MAINTAINERS +1
-1+ DRM DRIVERS FOR HISILICON M: Xinliang Liu <[email protected]> R: Xinwei Kong <[email protected]> --1.9.1
Re: [path v2 7/7] drm/hisilicon/hibmc: Add maintainer for Hibmc DRM
Hi Xinliang,
Quoted 15 lines · Xinliang Liu
Quoted 14 lines · Rongrong Zou
Signed-off-by Rongrong Zou <[email protected]>Signed-off-by Jianhua Li <[email protected]>--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)MAINTAINERS +0
-0@@ -3957,6 +3957,13 @@ T: git git://github.com/patjak/drm-gma500 S: Maintained F: drivers/gpu/drm/gma500/
Quoted 8 lines
MAINTAINERS T: git git://github.com/patjak/drm-gma500 · line 3965
Quoted 6 lines
MAINTAINERS +6
-0+DRM DRIVERS FOR HIBMC +M: lijianhua <[email protected]> +M: Rongrong Zou <[email protected]> +L: [email protected] +S: Maintained +F: drivers/gpu/drm/hisilicon/hibmcPlease add a "/" ad the end of this line.
OK, thanks!
Quoted 1 line
And move this part into DRM DRIVERS FOR HISILICON
Can it be placed as below:
DRM DRIVERS FOR HISILICON HIBMC
M: lijianhua <[email protected]> M: Rongrong Zou <[email protected]>
...
DRM DRIVERS FOR HISILICON KIRIN
M: Xinliang Liu <[email protected]> R: Xinwei Kong <[email protected]>
...
Quoted 14 lines
Thanks,
-xinliangQuoted 7 lines
+
DRM DRIVERS FOR HISILICON
M: Xinliang Liu <[email protected]>
R: Xinwei Kong <[email protected]>
--
1.9.1.
Signature · 2 lines
Regards, Rongrong
Hi Rongrong,
It seems that you haven't run the checkpatch script.
Please run this script to check your patches before you send them. Like bellow:
$ cd yourkerneldir $ ./scripts/checkpatch.pl --strict yourpatches
Thanks,
-xinliang
Quoted 80 lines · Rongrong Zou
This patch set adds a new drm driver for Hisilicon Hibmc. Hibmc is a base board management controller, usually it is used on server for Out-of-band management purpose. In this patch set, we just support basic function for Hibmc display subsystem. Hibmc display subsystem is connected to host CPU by PCIe as blow:
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+Hardware Detail for Hibmc display subsystem
-----------The display subsystem of Hibmc is show as bellow:
+----+ +----+ +----+ +--------+ | | | | | | | | | FB |----->| DE |----->|VDAC|---->|external| | | | | | | | VGA | +----+ +----+ +----+ +--------+-DE(Display Engine) is the display controller.
-VDAC(Video Digital-to-Analog converter) converts the RGB diaital data stream from DE to VGA analog signals.Change History
------------Changes in v2:
-Remove self-defined macros for bit operations. -Remove unused register.
-Replace those deprecated functions with new version of them. -usedrm_connector_register_all()to register connector after
drm_dev_register().The patch v1 is at
https://lists.freedesktop.org/archives/dri-devel/2016-February/101921.html
Sorry for too late sending.Rongrong Zou (7):
idrm/hisilicon/hibmc: Add hisilicon hibmc drm master driver drm/hisilicon/hibmc: Add plane for DE drm/hisilicon/hibmc: Add crtc for DE drm/hisilicon/hibmc: Add encoder for VDAC drm/hisilicon/hibmc: Add connector for VDAC drm/hisilicon/hibmc: Add support for frame buffer drm/hisilicon/hibmc: Add maintainer for Hibmc DRMMAINTAINERS | 7 + drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 3 +- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 13 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 4 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 477 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h | 29 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 399 ++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 64 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 286 +++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 91 +++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 214 ++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 174 ++++++++ 14 files changed, 1789 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Kconfig create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Makefile create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c--
1.9.1
Hi Xinliang
Quoted 6 lines · Xinliang Liu
Hi Rongrong,
It seems that you haven't run the checkpatch script.
Please run this script to check your patches before you send them. Like bellow:$ cd yourkerneldir $ ./scripts/checkpatch.pl --strict yourpatches
I run checkpatch.pl without "--strict", and i'll check again with this parameter, thanks!
Quoted 88 lines
Thanks,
-xinliangQuoted 77 lines · Rongrong Zou
This patch set adds a new drm driver for Hisilicon Hibmc. Hibmc is a base board management controller, usually it is used on server for Out-of-band management purpose. In this patch set, we just support basic function for Hibmc display subsystem. Hibmc display subsystem is connected to host CPU by PCIe as blow:
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+Hardware Detail for Hibmc display subsystem
-----------The display subsystem of Hibmc is show as bellow:
+----+ +----+ +----+ +--------+ | | | | | | | | | FB |----->| DE |----->|VDAC|---->|external| | | | | | | | VGA | +----+ +----+ +----+ +--------+-DE(Display Engine) is the display controller.
-VDAC(Video Digital-to-Analog converter) converts the RGB diaital data stream from DE to VGA analog signals.Change History
------------Changes in v2:
-Remove self-defined macros for bit operations. -Remove unused register.
-Replace those deprecated functions with new version of them. -usedrm_connector_register_all()to register connector afterdrm_dev_register().The patch v1 is at
https://lists.freedesktop.org/archives/dri-devel/2016-February/101921.html
Sorry for too late sending.Rongrong Zou (7):
idrm/hisilicon/hibmc: Add hisilicon hibmc drm master driver drm/hisilicon/hibmc: Add plane for DE drm/hisilicon/hibmc: Add crtc for DE drm/hisilicon/hibmc: Add encoder for VDAC drm/hisilicon/hibmc: Add connector for VDAC drm/hisilicon/hibmc: Add support for frame buffer drm/hisilicon/hibmc: Add maintainer for Hibmc DRMMAINTAINERS | 7 + drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 3 +- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 13 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 4 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 477 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h | 29 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 399 ++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 64 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 286 +++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 91 +++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 214 ++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 174 ++++++++ 14 files changed, 1789 insertions(+), 1 deletion(-)create mode 100644
drivers/gpu/drm/hisilicon/hibmc/Kconfigcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/Makefilecreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.ccreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.hcreate mode 100644drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.cQuoted 3 lines
--
1.9.1.
Signature · 2 lines
Regards, Rongrong