mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 02:35:09 +07:00
be8454afc5
-----BEGIN PGP SIGNATURE----- iQIcBAABAgAGBQJdLMSbAAoJEAx081l5xIa+udkP/iWr8mw44tWYb8Wuzc/aR91v 02X/J4S9XTQttNn/1Gpq9ItTLMf0Gc08tk1wEBBHAWi/qGaGZS2al+rv0afeuuQa aFhQzioDi7K/YZt92iEJhdx7wVMyydICTg3INmYlSP7/FyzLp6gBQRGSJ1kX5mHZ qWsFZgUOH9V5evyB6fDMleDaqFOKfcwrD7XYwbOheL/HeYQSv5AYn3VBupBFQ76L 0hclI5VzZQ5V0nnqRTNDQVA9Yl6NTl+2eXTn5vuBtwKXEI6JJw8eihZp2oZDXqfS L441w7wGbkRPzN5kjMZjs1ToPMTlMveR5kL6Sc+o3DT/HmIr1odeaSDXR/93UOLd z0CRJ6xMC8h1ThLNHp8UgbxCKqIwYPsY2wVqjsJt7lDY5jma7Yv2YJ9ocYGHN/sO DVHcU6ugbwvuC5wZZtVZl5J4hjnBZwNRGSVK+iM0tkjalgdEuSFehXT7eQ8SphF/ yI5gD1xNEwGfZ4bvZ3u/QrDCcpUAgPIUYmxEa2tPJILQWOJ9O87yc0y9Z21k9Ef1 9yDqrFV3sPqC2xj/0ufZG/18+Yt99Ykg1jQE3RGDwD/59KAeqPbOvqTKyVODV9jE qje6ScSIc2G0713uss2bcaD3k+rCB5YL2JkKrk5OWW/T2+n9T+JFaiNh7dnSFFcU gBKyeY24OyCDMwXrby0K =SI+Y -----END PGP SIGNATURE----- Merge tag 'drm-next-2019-07-16' of git://anongit.freedesktop.org/drm/drm Pull drm updates from Dave Airlie: "The biggest thing in this is the AMD Navi GPU support, this again contains a bunch of header files that are large. These are the new AMD RX5700 GPUs that just recently became available. New drivers: - ST-Ericsson MCDE driver - Ingenic JZ47xx SoC UAPI change: - HDR source metadata property Core: - HDR inforframes and EDID parsing - drm hdmi infoframe unpacking - remove prime sg_table caching into dma-buf - New gem vram helpers to reduce driver code - Lots of drmP.h removal - reservation fencing fix - documentation updates - drm_fb_helper_connector removed - mode name command handler rewrite fbcon: - Remove the fbcon notifiers ttm: - forward progress fixes dma-buf: - make mmap call optional - debugfs refcount fixes - dma-fence free with pending signals fix - each dma-buf gets an inode Panels: - Lots of additional panel bindings amdgpu: - initial navi10 support - avoid hw reset - HDR metadata support - new thermal sensors for vega asics - RAS fixes - use HMM rather than MMU notifier - xgmi topology via kfd - SR-IOV fixes - driver reload fixes - DC use a core bpc attribute - Aux fixes for DC - Bandwidth calc updates for DC - Clock handling refactor - kfd VEGAM support vmwgfx: - Coherent memory support changes i915: - HDR Support - HDMI i2c link - Icelake multi-segmented gamma support - GuC firmware update - Mule Creek Canyon PCH support for EHL - EHL platform updtes - move i915.alpha_support to i915.force_probe - runtime PM refactoring - VBT parsing refactoring - DSI fixes - struct mutex dependency reduction - GEM code reorg mali-dp: - Komeda driver features msm: - dsi vs EPROBE_DEFER fixes - msm8998 snapdragon 835 support - a540 gpu support - mdp5 and dpu interconnect support exynos: - drmP.h removal tegra: - misc fixes tda998x: - audio support improvements - pixel repeated mode support - quantisation range handling corrections - HDMI vendor info fix armada: - interlace support fix - overlay/video plane register handling refactor - add gamma support rockchip: - RX3328 support panfrost: - expose perf counters via hidden ioctls vkms: - enumerate CRC sources list ast: - rework BO handling mgag200: - rework BO handling dw-hdmi: - suspend/resume support rcar-du: - R8A774A1 Soc Support - LVDS dual-link mode support - Additional formats - Misc fixes omapdrm: - DSI command mode display support stm - fb modifier support - runtime PM support sun4i: - use vmap ops vc4: - binner bo binding rework v3d: - compute shader support - resync/sync fixes - job management refactoring lima: - NULL pointer in irq handler fix - scheduler default timeout virtio: - fence seqno support - trace events bochs: - misc fixes tc458767: - IRQ/HDP handling sii902x: - HDMI audio support atmel-hlcdc: - misc fixes meson: - zpos support" * tag 'drm-next-2019-07-16' of git://anongit.freedesktop.org/drm/drm: (1815 commits) Revert "Merge branch 'vmwgfx-next' of git://people.freedesktop.org/~thomash/linux into drm-next" Revert "mm: adjust apply_to_pfn_range interface for dropped token." mm: adjust apply_to_pfn_range interface for dropped token. drm/amdgpu/navi10: add uclk activity sensor drm/amdgpu: properly guard the generic discovery code drm/amdgpu: add missing documentation on new module parameters drm/amdgpu: don't invalidate caches in RELEASE_MEM, only do the writeback drm/amd/display: avoid 64-bit division drm/amdgpu/psp11: simplify the ucode register logic drm/amdgpu: properly guard DC support in navi code drm/amd/powerplay: vega20: fix uninitialized variable use drm/amd/display: dcn20: include linux/delay.h amdgpu: make pmu support optional drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq drm/amd/powerplay: Use memset to initialize metrics structs drm/amdgpu/mes10.1: Fix header guard drm/amd/powerplay: add temperature sensor support for navi10 drm/amdgpu: fix scheduler timeout calc drm/amdgpu: Prepare for hmm_range_register API change (v2) ...
390 lines
11 KiB
C
390 lines
11 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* ld9040 AMOLED LCD drm_panel driver.
|
|
*
|
|
* Copyright (c) 2014 Samsung Electronics Co., Ltd
|
|
* Derived from drivers/video/backlight/ld9040.c
|
|
*
|
|
* Andrzej Hajda <a.hajda@samsung.com>
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
#include <linux/gpio/consumer.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/regulator/consumer.h>
|
|
#include <linux/spi/spi.h>
|
|
|
|
#include <video/mipi_display.h>
|
|
#include <video/of_videomode.h>
|
|
#include <video/videomode.h>
|
|
|
|
#include <drm/drm_modes.h>
|
|
#include <drm/drm_panel.h>
|
|
#include <drm/drm_print.h>
|
|
|
|
/* Manufacturer Command Set */
|
|
#define MCS_MANPWR 0xb0
|
|
#define MCS_ELVSS_ON 0xb1
|
|
#define MCS_USER_SETTING 0xf0
|
|
#define MCS_DISPCTL 0xf2
|
|
#define MCS_POWER_CTRL 0xf4
|
|
#define MCS_GTCON 0xf7
|
|
#define MCS_PANEL_CONDITION 0xf8
|
|
#define MCS_GAMMA_SET1 0xf9
|
|
#define MCS_GAMMA_CTRL 0xfb
|
|
|
|
/* array of gamma tables for gamma value 2.2 */
|
|
static u8 const ld9040_gammas[25][22] = {
|
|
{ 0xf9, 0x00, 0x13, 0xb2, 0xba, 0xd2, 0x00, 0x30, 0x00, 0xaf, 0xc0,
|
|
0xb8, 0xcd, 0x00, 0x3d, 0x00, 0xa8, 0xb8, 0xb7, 0xcd, 0x00, 0x44 },
|
|
{ 0xf9, 0x00, 0x13, 0xb9, 0xb9, 0xd0, 0x00, 0x3c, 0x00, 0xaf, 0xbf,
|
|
0xb6, 0xcb, 0x00, 0x4b, 0x00, 0xa8, 0xb9, 0xb5, 0xcc, 0x00, 0x52 },
|
|
{ 0xf9, 0x00, 0x13, 0xba, 0xb9, 0xcd, 0x00, 0x41, 0x00, 0xb0, 0xbe,
|
|
0xb5, 0xc9, 0x00, 0x51, 0x00, 0xa9, 0xb9, 0xb5, 0xca, 0x00, 0x57 },
|
|
{ 0xf9, 0x00, 0x13, 0xb9, 0xb8, 0xcd, 0x00, 0x46, 0x00, 0xb1, 0xbc,
|
|
0xb5, 0xc8, 0x00, 0x56, 0x00, 0xaa, 0xb8, 0xb4, 0xc9, 0x00, 0x5d },
|
|
{ 0xf9, 0x00, 0x13, 0xba, 0xb8, 0xcb, 0x00, 0x4b, 0x00, 0xb3, 0xbc,
|
|
0xb4, 0xc7, 0x00, 0x5c, 0x00, 0xac, 0xb8, 0xb4, 0xc8, 0x00, 0x62 },
|
|
{ 0xf9, 0x00, 0x13, 0xbb, 0xb7, 0xca, 0x00, 0x4f, 0x00, 0xb4, 0xbb,
|
|
0xb3, 0xc7, 0x00, 0x60, 0x00, 0xad, 0xb8, 0xb4, 0xc7, 0x00, 0x67 },
|
|
{ 0xf9, 0x00, 0x47, 0xba, 0xb6, 0xca, 0x00, 0x53, 0x00, 0xb5, 0xbb,
|
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a, 0xbc, 0x00, 0xa4 },
|
|
{ 0xf9, 0x00, 0xa9, 0xb6, 0xad, 0xbf, 0x00, 0x86, 0x00, 0xb8, 0xb5,
|
|
0xa8, 0xbc, 0x00, 0xa0, 0x00, 0xb3, 0xb3, 0xa9, 0xbc, 0x00, 0xa7 },
|
|
{ 0xf9, 0x00, 0xa9, 0xb7, 0xae, 0xbd, 0x00, 0x89, 0x00, 0xb7, 0xb6,
|
|
0xa8, 0xba, 0x00, 0xa4, 0x00, 0xb1, 0xb4, 0xaa, 0xbb, 0x00, 0xaa },
|
|
{ 0xf9, 0x00, 0xa7, 0xb4, 0xae, 0xbf, 0x00, 0x91, 0x00, 0xb2, 0xb4,
|
|
0xaa, 0xbb, 0x00, 0xac, 0x00, 0xb3, 0xb1, 0xaa, 0xbc, 0x00, 0xb3 },
|
|
};
|
|
|
|
struct ld9040 {
|
|
struct device *dev;
|
|
struct drm_panel panel;
|
|
|
|
struct regulator_bulk_data supplies[2];
|
|
struct gpio_desc *reset_gpio;
|
|
u32 power_on_delay;
|
|
u32 reset_delay;
|
|
struct videomode vm;
|
|
u32 width_mm;
|
|
u32 height_mm;
|
|
|
|
int brightness;
|
|
|
|
/* This field is tested by functions directly accessing bus before
|
|
* transfer, transfer is skipped if it is set. In case of transfer
|
|
* failure or unexpected response the field is set to error value.
|
|
* Such construct allows to eliminate many checks in higher level
|
|
* functions.
|
|
*/
|
|
int error;
|
|
};
|
|
|
|
static inline struct ld9040 *panel_to_ld9040(struct drm_panel *panel)
|
|
{
|
|
return container_of(panel, struct ld9040, panel);
|
|
}
|
|
|
|
static int ld9040_clear_error(struct ld9040 *ctx)
|
|
{
|
|
int ret = ctx->error;
|
|
|
|
ctx->error = 0;
|
|
return ret;
|
|
}
|
|
|
|
static int ld9040_spi_write_word(struct ld9040 *ctx, u16 data)
|
|
{
|
|
struct spi_device *spi = to_spi_device(ctx->dev);
|
|
struct spi_transfer xfer = {
|
|
.len = 2,
|
|
.tx_buf = &data,
|
|
};
|
|
struct spi_message msg;
|
|
|
|
spi_message_init(&msg);
|
|
spi_message_add_tail(&xfer, &msg);
|
|
|
|
return spi_sync(spi, &msg);
|
|
}
|
|
|
|
static void ld9040_dcs_write(struct ld9040 *ctx, const u8 *data, size_t len)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (ctx->error < 0 || len == 0)
|
|
return;
|
|
|
|
dev_dbg(ctx->dev, "writing dcs seq: %*ph\n", (int)len, data);
|
|
ret = ld9040_spi_write_word(ctx, *data);
|
|
|
|
while (!ret && --len) {
|
|
++data;
|
|
ret = ld9040_spi_write_word(ctx, *data | 0x100);
|
|
}
|
|
|
|
if (ret) {
|
|
dev_err(ctx->dev, "error %d writing dcs seq: %*ph\n", ret,
|
|
(int)len, data);
|
|
ctx->error = ret;
|
|
}
|
|
|
|
usleep_range(300, 310);
|
|
}
|
|
|
|
#define ld9040_dcs_write_seq_static(ctx, seq...) \
|
|
({\
|
|
static const u8 d[] = { seq };\
|
|
ld9040_dcs_write(ctx, d, ARRAY_SIZE(d));\
|
|
})
|
|
|
|
static void ld9040_brightness_set(struct ld9040 *ctx)
|
|
{
|
|
ld9040_dcs_write(ctx, ld9040_gammas[ctx->brightness],
|
|
ARRAY_SIZE(ld9040_gammas[ctx->brightness]));
|
|
|
|
ld9040_dcs_write_seq_static(ctx, MCS_GAMMA_CTRL, 0x02, 0x5a);
|
|
}
|
|
|
|
static void ld9040_init(struct ld9040 *ctx)
|
|
{
|
|
ld9040_dcs_write_seq_static(ctx, MCS_USER_SETTING, 0x5a, 0x5a);
|
|
ld9040_dcs_write_seq_static(ctx, MCS_PANEL_CONDITION,
|
|
0x05, 0x65, 0x96, 0x71, 0x7d, 0x19, 0x3b, 0x0d,
|
|
0x19, 0x7e, 0x0d, 0xe2, 0x00, 0x00, 0x7e, 0x7d,
|
|
0x07, 0x07, 0x20, 0x20, 0x20, 0x02, 0x02);
|
|
ld9040_dcs_write_seq_static(ctx, MCS_DISPCTL,
|
|
0x02, 0x08, 0x08, 0x10, 0x10);
|
|
ld9040_dcs_write_seq_static(ctx, MCS_MANPWR, 0x04);
|
|
ld9040_dcs_write_seq_static(ctx, MCS_POWER_CTRL,
|
|
0x0a, 0x87, 0x25, 0x6a, 0x44, 0x02, 0x88);
|
|
ld9040_dcs_write_seq_static(ctx, MCS_ELVSS_ON, 0x0d, 0x00, 0x16);
|
|
ld9040_dcs_write_seq_static(ctx, MCS_GTCON, 0x09, 0x00, 0x00);
|
|
ld9040_brightness_set(ctx);
|
|
ld9040_dcs_write_seq_static(ctx, MIPI_DCS_EXIT_SLEEP_MODE);
|
|
ld9040_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_ON);
|
|
}
|
|
|
|
static int ld9040_power_on(struct ld9040 *ctx)
|
|
{
|
|
int ret;
|
|
|
|
ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
msleep(ctx->power_on_delay);
|
|
gpiod_set_value(ctx->reset_gpio, 0);
|
|
msleep(ctx->reset_delay);
|
|
gpiod_set_value(ctx->reset_gpio, 1);
|
|
msleep(ctx->reset_delay);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ld9040_power_off(struct ld9040 *ctx)
|
|
{
|
|
return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
|
|
}
|
|
|
|
static int ld9040_disable(struct drm_panel *panel)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int ld9040_unprepare(struct drm_panel *panel)
|
|
{
|
|
struct ld9040 *ctx = panel_to_ld9040(panel);
|
|
|
|
msleep(120);
|
|
ld9040_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_OFF);
|
|
ld9040_dcs_write_seq_static(ctx, MIPI_DCS_ENTER_SLEEP_MODE);
|
|
msleep(40);
|
|
|
|
ld9040_clear_error(ctx);
|
|
|
|
return ld9040_power_off(ctx);
|
|
}
|
|
|
|
static int ld9040_prepare(struct drm_panel *panel)
|
|
{
|
|
struct ld9040 *ctx = panel_to_ld9040(panel);
|
|
int ret;
|
|
|
|
ret = ld9040_power_on(ctx);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
ld9040_init(ctx);
|
|
|
|
ret = ld9040_clear_error(ctx);
|
|
|
|
if (ret < 0)
|
|
ld9040_unprepare(panel);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int ld9040_enable(struct drm_panel *panel)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int ld9040_get_modes(struct drm_panel *panel)
|
|
{
|
|
struct drm_connector *connector = panel->connector;
|
|
struct ld9040 *ctx = panel_to_ld9040(panel);
|
|
struct drm_display_mode *mode;
|
|
|
|
mode = drm_mode_create(connector->dev);
|
|
if (!mode) {
|
|
DRM_ERROR("failed to create a new display mode\n");
|
|
return 0;
|
|
}
|
|
|
|
drm_display_mode_from_videomode(&ctx->vm, mode);
|
|
mode->width_mm = ctx->width_mm;
|
|
mode->height_mm = ctx->height_mm;
|
|
connector->display_info.width_mm = mode->width_mm;
|
|
connector->display_info.height_mm = mode->height_mm;
|
|
|
|
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
|
|
drm_mode_probed_add(connector, mode);
|
|
|
|
return 1;
|
|
}
|
|
|
|
static const struct drm_panel_funcs ld9040_drm_funcs = {
|
|
.disable = ld9040_disable,
|
|
.unprepare = ld9040_unprepare,
|
|
.prepare = ld9040_prepare,
|
|
.enable = ld9040_enable,
|
|
.get_modes = ld9040_get_modes,
|
|
};
|
|
|
|
static int ld9040_parse_dt(struct ld9040 *ctx)
|
|
{
|
|
struct device *dev = ctx->dev;
|
|
struct device_node *np = dev->of_node;
|
|
int ret;
|
|
|
|
ret = of_get_videomode(np, &ctx->vm, 0);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
of_property_read_u32(np, "power-on-delay", &ctx->power_on_delay);
|
|
of_property_read_u32(np, "reset-delay", &ctx->reset_delay);
|
|
of_property_read_u32(np, "panel-width-mm", &ctx->width_mm);
|
|
of_property_read_u32(np, "panel-height-mm", &ctx->height_mm);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ld9040_probe(struct spi_device *spi)
|
|
{
|
|
struct device *dev = &spi->dev;
|
|
struct ld9040 *ctx;
|
|
int ret;
|
|
|
|
ctx = devm_kzalloc(dev, sizeof(struct ld9040), GFP_KERNEL);
|
|
if (!ctx)
|
|
return -ENOMEM;
|
|
|
|
spi_set_drvdata(spi, ctx);
|
|
|
|
ctx->dev = dev;
|
|
ctx->brightness = ARRAY_SIZE(ld9040_gammas) - 1;
|
|
|
|
ret = ld9040_parse_dt(ctx);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
ctx->supplies[0].supply = "vdd3";
|
|
ctx->supplies[1].supply = "vci";
|
|
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
|
|
ctx->supplies);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
|
|
if (IS_ERR(ctx->reset_gpio)) {
|
|
dev_err(dev, "cannot get reset-gpios %ld\n",
|
|
PTR_ERR(ctx->reset_gpio));
|
|
return PTR_ERR(ctx->reset_gpio);
|
|
}
|
|
|
|
spi->bits_per_word = 9;
|
|
ret = spi_setup(spi);
|
|
if (ret < 0) {
|
|
dev_err(dev, "spi setup failed.\n");
|
|
return ret;
|
|
}
|
|
|
|
drm_panel_init(&ctx->panel);
|
|
ctx->panel.dev = dev;
|
|
ctx->panel.funcs = &ld9040_drm_funcs;
|
|
|
|
return drm_panel_add(&ctx->panel);
|
|
}
|
|
|
|
static int ld9040_remove(struct spi_device *spi)
|
|
{
|
|
struct ld9040 *ctx = spi_get_drvdata(spi);
|
|
|
|
ld9040_power_off(ctx);
|
|
drm_panel_remove(&ctx->panel);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id ld9040_of_match[] = {
|
|
{ .compatible = "samsung,ld9040" },
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, ld9040_of_match);
|
|
|
|
static struct spi_driver ld9040_driver = {
|
|
.probe = ld9040_probe,
|
|
.remove = ld9040_remove,
|
|
.driver = {
|
|
.name = "panel-samsung-ld9040",
|
|
.of_match_table = ld9040_of_match,
|
|
},
|
|
};
|
|
module_spi_driver(ld9040_driver);
|
|
|
|
MODULE_AUTHOR("Andrzej Hajda <a.hajda@samsung.com>");
|
|
MODULE_DESCRIPTION("ld9040 LCD Driver");
|
|
MODULE_LICENSE("GPL v2");
|