-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers, depending on which chip variant/version. (As far as I can tell, current devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And then external to the display controller are HDMI, DSI, etc. blocks which may be shared across devices which have different display controller blocks. To more easily add support for different display controller blocks, the display controller specific bits are split out into a "kms" module, which provides the kms plane/crtc/encoder objects. The external HDMI, DSI, etc. blocks are part encoder, and part connector currently. But I think I will pull in the drm_bridge patches from chromeos tree, and split them into a bridge+connector, with the registers that need to be set in modeset handled by the bridge. This would remove the 'msm_connector' base class. But some things need to be double checked to make sure I could get the correct ON/OFF sequencing.. This patch adds support for mdp4 crtc (including hw cursor), dtv encoder (part of MDP4 block), and hdmi. Signed-off-by: Rob Clark <robdclark@gmail.com>
- Loading branch information
Rob Clark
committed
Aug 24, 2013
1 parent
0cf6c71
commit c8afe68
Showing
26 changed files
with
5,483 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
config DRM_MSM | ||
tristate "MSM DRM" | ||
depends on DRM | ||
depends on ARCH_MSM | ||
depends on ARCH_MSM8960 | ||
select DRM_KMS_HELPER | ||
select SHMEM | ||
select TMPFS | ||
default y | ||
help | ||
DRM/KMS driver for MSM/snapdragon. | ||
|
||
config DRM_MSM_FBDEV | ||
bool "Enable legacy fbdev support for MSM modesetting driver" | ||
depends on DRM_MSM | ||
select FB_SYS_FILLRECT | ||
select FB_SYS_COPYAREA | ||
select FB_SYS_IMAGEBLIT | ||
select FB_SYS_FOPS | ||
default y | ||
help | ||
Choose this option if you have a need for the legacy fbdev | ||
support. Note that this support also provide the linux console | ||
support on top of the MSM modesetting driver. | ||
|
||
config DRM_MSM_REGISTER_LOGGING | ||
bool "MSM DRM register logging" | ||
depends on DRM_MSM | ||
default n | ||
help | ||
Compile in support for logging register reads/writes in a format | ||
that can be parsed by envytools demsm tool. If enabled, register | ||
logging can be switched on via msm.reglog=y module param. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/msm | ||
ifeq (, $(findstring -W,$(EXTRA_CFLAGS))) | ||
ccflags-y += -Werror | ||
endif | ||
|
||
msm-y := \ | ||
hdmi/hdmi.o \ | ||
hdmi/hdmi_connector.o \ | ||
hdmi/hdmi_i2c.o \ | ||
hdmi/hdmi_phy_8960.o \ | ||
hdmi/hdmi_phy_8x60.o \ | ||
mdp4/mdp4_crtc.o \ | ||
mdp4/mdp4_dtv_encoder.o \ | ||
mdp4/mdp4_format.o \ | ||
mdp4/mdp4_irq.o \ | ||
mdp4/mdp4_kms.o \ | ||
mdp4/mdp4_plane.o \ | ||
msm_connector.o \ | ||
msm_drv.o \ | ||
msm_fb.o \ | ||
msm_gem.o | ||
|
||
msm-$(CONFIG_DRM_MSM_FBDEV) += msm_fbdev.o | ||
|
||
obj-$(CONFIG_DRM_MSM) += msm.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
NOTES about msm drm/kms driver: | ||
|
||
In the current snapdragon SoC's, we have (at least) 3 different | ||
display controller blocks at play: | ||
+ MDP3 - ?? seems to be what is on geeksphone peak device | ||
+ MDP4 - S3 (APQ8060, touchpad), S4-pro (APQ8064, nexus4 & ifc6410) | ||
+ MDSS - snapdragon 800 | ||
|
||
(I don't have a completely clear picture on which display controller | ||
maps to which part #) | ||
|
||
Plus a handful of blocks around them for HDMI/DSI/etc output. | ||
|
||
And on gpu side of things: | ||
+ zero, one, or two 2d cores (z180) | ||
+ and either a2xx or a3xx 3d core. | ||
|
||
But, HDMI/DSI/etc blocks seem like they can be shared across multiple | ||
display controller blocks. And I for sure don't want to have to deal | ||
with N different kms devices from xf86-video-freedreno. Plus, it | ||
seems like we can do some clever tricks like use GPU to trigger | ||
pageflip after rendering completes (ie. have the kms/crtc code build | ||
up gpu cmdstream to update scanout and write FLUSH register after). | ||
|
||
So, the approach is one drm driver, with some modularity. Different | ||
'struct msm_kms' implementations, depending on display controller. | ||
And one or more 'struct msm_gpu' for the various different gpu sub- | ||
modules. | ||
|
||
(Second part is not implemented yet. So far this is just basic KMS | ||
driver, and not exposing any custom ioctls to userspace for now.) | ||
|
||
The kms module provides the plane, crtc, and encoder objects, and | ||
loads whatever connectors are appropriate. | ||
|
||
For MDP4, the mapping is: | ||
|
||
plane -> PIPE{RGBn,VGn} \ | ||
crtc -> OVLP{n} + DMA{P,S,E} (??) |-> MDP "device" | ||
encoder -> DTV/LCDC/DSI (within MDP4) / | ||
connector -> HDMI/DSI/etc --> other device(s) | ||
|
||
Since the irq's that drm core mostly cares about are vblank/framedone, | ||
we'll let msm_mdp4_kms provide the irq install/uninstall/etc functions | ||
and treat the MDP4 block's irq as "the" irq. Even though the connectors | ||
may have their own irqs which they install themselves. For this reason | ||
the display controller is the "master" device. | ||
|
||
Each connector probably ends up being a separate device, just for the | ||
logistics of finding/mapping io region, irq, etc. Idealy we would | ||
have a better way than just stashing the platform device in a global | ||
(ie. like DT super-node.. but I don't have any snapdragon hw yet that | ||
is using DT). | ||
|
||
Note that so far I've not been able to get any docs on the hw, and it | ||
seems that access to such docs would prevent me from working on the | ||
freedreno gallium driver. So there may be some mistakes in register | ||
names (I had to invent a few, since no sufficient hint was given in | ||
the downstream android fbdev driver), bitfield sizes, etc. My current | ||
state of understanding the registers is given in the envytools rnndb | ||
files at: | ||
|
||
https://github.com/freedreno/envytools/tree/master/rnndb | ||
(the mdp4/hdmi/dsi directories) | ||
|
||
These files are used both for a parser tool (in the same tree) to | ||
parse logged register reads/writes (both from downstream android fbdev | ||
driver, and this driver with register logging enabled), as well as to | ||
generate the register level headers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
/* | ||
* Copyright (C) 2013 Red Hat | ||
* Author: Rob Clark <robdclark@gmail.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published by | ||
* the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
* more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "hdmi.h" | ||
|
||
static struct platform_device *hdmi_pdev; | ||
|
||
void hdmi_set_mode(struct hdmi *hdmi, bool power_on) | ||
{ | ||
uint32_t ctrl = 0; | ||
|
||
if (power_on) { | ||
ctrl |= HDMI_CTRL_ENABLE; | ||
if (!hdmi->hdmi_mode) { | ||
ctrl |= HDMI_CTRL_HDMI; | ||
hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); | ||
ctrl &= ~HDMI_CTRL_HDMI; | ||
} else { | ||
ctrl |= HDMI_CTRL_HDMI; | ||
} | ||
} else { | ||
ctrl = HDMI_CTRL_HDMI; | ||
} | ||
|
||
hdmi_write(hdmi, REG_HDMI_CTRL, ctrl); | ||
DBG("HDMI Core: %s, HDMI_CTRL=0x%08x", | ||
power_on ? "Enable" : "Disable", ctrl); | ||
} | ||
|
||
static irqreturn_t hdmi_irq(int irq, void *dev_id) | ||
{ | ||
struct hdmi *hdmi = dev_id; | ||
|
||
/* Process HPD: */ | ||
hdmi_connector_irq(hdmi->connector); | ||
|
||
/* Process DDC: */ | ||
hdmi_i2c_irq(hdmi->i2c); | ||
|
||
/* TODO audio.. */ | ||
|
||
return IRQ_HANDLED; | ||
} | ||
|
||
void hdmi_destroy(struct hdmi *hdmi) | ||
{ | ||
struct hdmi_phy *phy = hdmi->phy; | ||
|
||
if (phy) | ||
phy->funcs->destroy(phy); | ||
|
||
if (hdmi->i2c) | ||
hdmi_i2c_destroy(hdmi->i2c); | ||
|
||
put_device(&hdmi->pdev->dev); | ||
} | ||
|
||
/* initialize connector */ | ||
int hdmi_init(struct hdmi *hdmi, struct drm_device *dev, | ||
struct drm_connector *connector) | ||
{ | ||
struct platform_device *pdev = hdmi_pdev; | ||
struct hdmi_platform_config *config; | ||
int ret; | ||
|
||
if (!pdev) { | ||
dev_err(dev->dev, "no hdmi device\n"); | ||
ret = -ENXIO; | ||
goto fail; | ||
} | ||
|
||
config = pdev->dev.platform_data; | ||
|
||
get_device(&pdev->dev); | ||
|
||
hdmi->dev = dev; | ||
hdmi->pdev = pdev; | ||
hdmi->connector = connector; | ||
|
||
/* not sure about which phy maps to which msm.. probably I miss some */ | ||
if (config->phy_init) | ||
hdmi->phy = config->phy_init(hdmi); | ||
else | ||
hdmi->phy = ERR_PTR(-ENXIO); | ||
|
||
if (IS_ERR(hdmi->phy)) { | ||
ret = PTR_ERR(hdmi->phy); | ||
dev_err(dev->dev, "failed to load phy: %d\n", ret); | ||
hdmi->phy = NULL; | ||
goto fail; | ||
} | ||
|
||
hdmi->mmio = msm_ioremap(pdev, "hdmi_msm_hdmi_addr", "HDMI"); | ||
if (IS_ERR(hdmi->mmio)) { | ||
ret = PTR_ERR(hdmi->mmio); | ||
goto fail; | ||
} | ||
|
||
hdmi->mvs = devm_regulator_get(&pdev->dev, "8901_hdmi_mvs"); | ||
if (IS_ERR(hdmi->mvs)) | ||
hdmi->mvs = devm_regulator_get(&pdev->dev, "hdmi_mvs"); | ||
if (IS_ERR(hdmi->mvs)) { | ||
ret = PTR_ERR(hdmi->mvs); | ||
dev_err(dev->dev, "failed to get mvs regulator: %d\n", ret); | ||
goto fail; | ||
} | ||
|
||
hdmi->mpp0 = devm_regulator_get(&pdev->dev, "8901_mpp0"); | ||
if (IS_ERR(hdmi->mpp0)) | ||
hdmi->mpp0 = NULL; | ||
|
||
hdmi->clk = devm_clk_get(&pdev->dev, "core_clk"); | ||
if (IS_ERR(hdmi->clk)) { | ||
ret = PTR_ERR(hdmi->clk); | ||
dev_err(dev->dev, "failed to get 'clk': %d\n", ret); | ||
goto fail; | ||
} | ||
|
||
hdmi->m_pclk = devm_clk_get(&pdev->dev, "master_iface_clk"); | ||
if (IS_ERR(hdmi->m_pclk)) { | ||
ret = PTR_ERR(hdmi->m_pclk); | ||
dev_err(dev->dev, "failed to get 'm_pclk': %d\n", ret); | ||
goto fail; | ||
} | ||
|
||
hdmi->s_pclk = devm_clk_get(&pdev->dev, "slave_iface_clk"); | ||
if (IS_ERR(hdmi->s_pclk)) { | ||
ret = PTR_ERR(hdmi->s_pclk); | ||
dev_err(dev->dev, "failed to get 's_pclk': %d\n", ret); | ||
goto fail; | ||
} | ||
|
||
hdmi->i2c = hdmi_i2c_init(hdmi); | ||
if (IS_ERR(hdmi->i2c)) { | ||
ret = PTR_ERR(hdmi->i2c); | ||
dev_err(dev->dev, "failed to get i2c: %d\n", ret); | ||
hdmi->i2c = NULL; | ||
goto fail; | ||
} | ||
|
||
hdmi->irq = platform_get_irq(pdev, 0); | ||
if (hdmi->irq < 0) { | ||
ret = hdmi->irq; | ||
dev_err(dev->dev, "failed to get irq: %d\n", ret); | ||
goto fail; | ||
} | ||
|
||
ret = devm_request_threaded_irq(&pdev->dev, hdmi->irq, | ||
NULL, hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, | ||
"hdmi_isr", hdmi); | ||
if (ret < 0) { | ||
dev_err(dev->dev, "failed to request IRQ%u: %d\n", | ||
hdmi->irq, ret); | ||
goto fail; | ||
} | ||
|
||
return 0; | ||
|
||
fail: | ||
if (hdmi) | ||
hdmi_destroy(hdmi); | ||
|
||
return ret; | ||
} | ||
|
||
/* | ||
* The hdmi device: | ||
*/ | ||
|
||
static int hdmi_dev_probe(struct platform_device *pdev) | ||
{ | ||
static struct hdmi_platform_config config = {}; | ||
#ifdef CONFIG_OF | ||
/* TODO */ | ||
#else | ||
if (cpu_is_apq8064()) { | ||
config.phy_init = hdmi_phy_8960_init; | ||
config.ddc_clk_gpio = 70; | ||
config.ddc_data_gpio = 71; | ||
config.hpd_gpio = 72; | ||
config.pmic_gpio = 13 + NR_GPIO_IRQS; | ||
} else if (cpu_is_msm8960()) { | ||
config.phy_init = hdmi_phy_8960_init; | ||
config.ddc_clk_gpio = 100; | ||
config.ddc_data_gpio = 101; | ||
config.hpd_gpio = 102; | ||
config.pmic_gpio = -1; | ||
} else if (cpu_is_msm8x60()) { | ||
config.phy_init = hdmi_phy_8x60_init; | ||
config.ddc_clk_gpio = 170; | ||
config.ddc_data_gpio = 171; | ||
config.hpd_gpio = 172; | ||
config.pmic_gpio = -1; | ||
} | ||
#endif | ||
pdev->dev.platform_data = &config; | ||
hdmi_pdev = pdev; | ||
return 0; | ||
} | ||
|
||
static int hdmi_dev_remove(struct platform_device *pdev) | ||
{ | ||
hdmi_pdev = NULL; | ||
return 0; | ||
} | ||
|
||
static struct platform_driver hdmi_driver = { | ||
.probe = hdmi_dev_probe, | ||
.remove = hdmi_dev_remove, | ||
.driver.name = "hdmi_msm", | ||
}; | ||
|
||
void __init hdmi_register(void) | ||
{ | ||
platform_driver_register(&hdmi_driver); | ||
} | ||
|
||
void __exit hdmi_unregister(void) | ||
{ | ||
platform_driver_unregister(&hdmi_driver); | ||
} |
Oops, something went wrong.