summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/pinctrl/tegra/pinctrl-tegra.c56
-rw-r--r--drivers/video/Kconfig19
-rw-r--r--drivers/video/Makefile2
-rw-r--r--drivers/video/lp855x_backlight.c302
-rw-r--r--drivers/video/sharp-lq079l1sx01.c288
-rw-r--r--drivers/video/tegra20/tegra-dc.c107
-rw-r--r--drivers/video/tegra20/tegra-dsi.c231
-rw-r--r--drivers/video/tegra20/tegra-mipi.c134
8 files changed, 1003 insertions, 136 deletions
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index ad7112a05e6..e6b957f5537 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -67,6 +67,58 @@ exit:
kfree(drive_group);
}
+#ifdef TEGRA_PMX_SOC_HAS_MIPI_PAD_CTRL_GRPS
+static void tegra_pinctrl_set_mipipad(struct udevice *config, int padcnt)
+{
+ struct pmux_mipipadctrlgrp_config *mipipad_group;
+ int i, ret, pad_id;
+ const char *function;
+ const char **pads;
+
+ mipipad_group = kmalloc_array(padcnt, sizeof(*mipipad_group), GFP_KERNEL);
+ if (!mipipad_group) {
+ log_debug("%s: cannot allocate mipi pad group array\n", __func__);
+ return;
+ }
+
+ /* decode function id and fill the first copy of pmux_mipipadctrlgrp_config */
+ function = dev_read_string(config, "nvidia,function");
+ if (function)
+ for (i = 0; i < PMUX_FUNC_COUNT; i++)
+ if (tegra_pinctrl_to_func[i])
+ if (!strcmp(function, tegra_pinctrl_to_func[i]))
+ break;
+
+ mipipad_group[0].func = i;
+
+ for (i = 1; i < padcnt; i++)
+ memcpy(&mipipad_group[i], &mipipad_group[0], sizeof(mipipad_group[0]));
+
+ ret = dev_read_string_list(config, "nvidia,pins", &pads);
+ if (ret < 0) {
+ log_debug("%s: could not parse property nvidia,pins\n", __func__);
+ goto exit;
+ }
+
+ for (i = 0; i < padcnt; i++) {
+ for (pad_id = 0; pad_id < PMUX_MIPIPADCTRLGRP_COUNT; pad_id++)
+ if (tegra_pinctrl_to_mipipadgrp[pad_id])
+ if (!strcmp(pads[i], tegra_pinctrl_to_mipipadgrp[pad_id])) {
+ mipipad_group[i].grp = pad_id;
+ break;
+ }
+ }
+
+ pinmux_config_mipipadctrlgrp_table(mipipad_group, padcnt);
+
+ free(pads);
+exit:
+ kfree(mipipad_group);
+}
+#else
+static void tegra_pinctrl_set_mipipad(struct udevice *config, int padcnt) { }
+#endif
+
static void tegra_pinctrl_set_pin(struct udevice *config, int pincnt)
{
struct pmux_pingrp_config *pinmux_group;
@@ -170,6 +222,9 @@ static int tegra_pinctrl_set_state(struct udevice *dev, struct udevice *config)
if (!strncmp(name, "drive_", 6))
/* Drive node is detected */
tegra_pinctrl_set_drive(child, ret);
+ else if (!strncmp(name, "mipi_pad_ctrl_", 14))
+ /* Handle T124 specific pinconfig */
+ tegra_pinctrl_set_mipipad(child, ret);
else
/* Pin node is detected */
tegra_pinctrl_set_pin(child, ret);
@@ -236,6 +291,7 @@ static int tegra_pinctrl_bind(struct udevice *dev)
static const struct udevice_id tegra_pinctrl_ids[] = {
{ .compatible = "nvidia,tegra30-pinmux" },
{ .compatible = "nvidia,tegra114-pinmux" },
+ { .compatible = "nvidia,tegra124-pinmux" },
{ },
};
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 3c3cebaacd0..b1ef73f3e5c 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -599,6 +599,15 @@ config VIDEO_LCD_SAMSUNG_LTL106HL02
LCD module found in Microsoft Surface 2. The panel has a FullHD
resolution (1920x1080).
+config VIDEO_LCD_SHARP_LQ079L1SX01
+ tristate "Sharp LQ079L1SX01 1536x2048 DSI video mode panel"
+ depends on PANEL && BACKLIGHT
+ select VIDEO_MIPI_DSI
+ help
+ Say Y here if you want to enable support for Sharp LQ079L1SX01
+ LCD module found in Xiaomi Mi Pad tablet. The panel has a QXGA
+ resolution (1536x2048).
+
config VIDEO_LCD_SHARP_LQ101R1SX01
tristate "Sharp LQ101R1SX01 2560x1600 DSI video mode panel"
depends on PANEL && BACKLIGHT
@@ -743,6 +752,16 @@ config BACKLIGHT_LM3533
LM3533 Lighting Power chip. Only Bank A is supported as for now.
Supported backlight level range is from 2 to 255 with step of 1.
+config BACKLIGHT_LP855x
+ bool "Backlight Driver for LP855x"
+ depends on BACKLIGHT
+ select DM_I2C
+ help
+ Say Y to enable the backlight driver for National Semiconductor / TI
+ LP8550/1/2/3/5/6/7 LED Backlight Driver. Only register driven mode is
+ supported for now, PWM mode can be added if there will be any need in
+ it. Supported backlight level range is from 0 to 255 with step of 1.
+
source "drivers/video/ti/Kconfig"
source "drivers/video/exynos/Kconfig"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 5a00438ce06..6073bc5234a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_$(PHASE_)BMP) += bmp.o
endif
obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_backlight.o
+obj-$(CONFIG_BACKLIGHT_LP855x) += lp855x_backlight.o
obj-${CONFIG_EXYNOS_FB} += exynos/
obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/
obj-${CONFIG_VIDEO_STM32} += stm32/
@@ -64,6 +65,7 @@ obj-$(CONFIG_VIDEO_LCD_RAYDIUM_RM68200) += raydium-rm68200.o
obj-$(CONFIG_VIDEO_LCD_RENESAS_R61307) += renesas-r61307.o
obj-$(CONFIG_VIDEO_LCD_RENESAS_R69328) += renesas-r69328.o
obj-$(CONFIG_VIDEO_LCD_SAMSUNG_LTL106HL02) += samsung-ltl106hl02.o
+obj-$(CONFIG_VIDEO_LCD_SHARP_LQ079L1SX01) += sharp-lq079l1sx01.o
obj-$(CONFIG_VIDEO_LCD_SHARP_LQ101R1SX01) += sharp-lq101r1sx01.o
obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
obj-$(CONFIG_VIDEO_LCD_TDO_TL070WSH30) += tdo-tl070wsh30.o
diff --git a/drivers/video/lp855x_backlight.c b/drivers/video/lp855x_backlight.c
new file mode 100644
index 00000000000..5debc0aa453
--- /dev/null
+++ b/drivers/video/lp855x_backlight.c
@@ -0,0 +1,302 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2011 Texas Instruments
+ * Copyright (c) 2024 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#define LOG_CATEGORY UCLASS_PANEL_BACKLIGHT
+
+#include <malloc.h>
+#include <backlight.h>
+#include <dm.h>
+#include <dm/devres.h>
+#include <i2c.h>
+#include <log.h>
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <asm/gpio.h>
+#include <power/regulator.h>
+
+#define LP855x_MIN_BRIGHTNESS 0x00
+#define LP855x_MAX_BRIGHTNESS 0xff
+
+/* LP8550/1/2/3/6 Registers */
+#define LP855X_BRIGHTNESS_CTRL 0x00
+#define LP855X_DEVICE_CTRL 0x01
+#define LP855X_EEPROM_START 0xa0
+#define LP855X_EEPROM_END 0xa7
+#define LP8556_EPROM_START 0x98
+#define LP8556_EPROM_END 0xaf
+
+/* LP8555/7 Registers */
+#define LP8557_BL_CMD 0x00
+#define LP8557_BL_MASK 0x01
+#define LP8557_BL_ON 0x01
+#define LP8557_BL_OFF 0x00
+#define LP8557_BRIGHTNESS_CTRL 0x04
+#define LP8557_CONFIG 0x10
+#define LP8555_EPROM_START 0x10
+#define LP8555_EPROM_END 0x7a
+#define LP8557_EPROM_START 0x10
+#define LP8557_EPROM_END 0x1e
+
+struct lp855x_rom_data {
+ u8 addr;
+ u8 val;
+};
+
+struct lp855x_backlight_priv;
+
+/*
+ * struct lp855x_device_config
+ * @pre_init_device: init device function call before updating the brightness
+ * @reg_brightness: register address for brigthenss control
+ * @reg_devicectrl: register address for device control
+ * @post_init_device: late init device function call
+ */
+struct lp855x_device_config {
+ int (*pre_init_device)(struct udevice *dev);
+ u8 reg_brightness;
+ u8 reg_devicectrl;
+ u8 reg_eepromstart;
+ u8 reg_eepromend;
+ int (*post_init_device)(struct udevice *dev);
+};
+
+struct lp855x_backlight_priv {
+ struct udevice *supply; /* regulator for VDD input */
+ struct udevice *enable; /* regulator for EN/VDDIO input */
+
+ u8 device_control;
+ u8 initial_brightness;
+
+ int size_program;
+ struct lp855x_rom_data *rom_data;
+ struct lp855x_device_config *cfg;
+};
+
+static int lp855x_backlight_enable(struct udevice *dev)
+{
+ struct lp855x_backlight_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ ret = regulator_set_enable_if_allowed(priv->supply, 1);
+ if (ret) {
+ log_debug("%s: enabling power-supply failed (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = regulator_set_enable_if_allowed(priv->enable, 1);
+ if (ret) {
+ log_debug("%s: enabling enable-supply failed (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+ mdelay(2);
+
+ if (priv->cfg->pre_init_device) {
+ ret = priv->cfg->pre_init_device(dev);
+ if (ret) {
+ log_debug("%s: pre init device err: %d\n",
+ __func__, ret);
+ return ret;
+ }
+ }
+
+ ret = dm_i2c_reg_write(dev, priv->cfg->reg_brightness,
+ priv->initial_brightness);
+ if (ret)
+ return ret;
+
+ ret = dm_i2c_reg_write(dev, priv->cfg->reg_devicectrl,
+ priv->device_control);
+ if (ret)
+ return ret;
+
+ if (priv->size_program > 0) {
+ int i;
+ u8 val, addr;
+
+ for (i = 0; i < priv->size_program; i++) {
+ addr = priv->rom_data[i].addr;
+ val = priv->rom_data[i].val;
+
+ if (addr < priv->cfg->reg_eepromstart &&
+ addr > priv->cfg->reg_eepromend)
+ continue;
+
+ ret = dm_i2c_reg_write(dev, addr, val);
+ if (ret)
+ return ret;
+ }
+ }
+
+ if (priv->cfg->post_init_device) {
+ ret = priv->cfg->post_init_device(dev);
+ if (ret) {
+ log_debug("%s: post init device err: %d\n",
+ __func__, ret);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int lp855x_backlight_set_brightness(struct udevice *dev, int percent)
+{
+ struct lp855x_backlight_priv *priv = dev_get_priv(dev);
+
+ if (percent == BACKLIGHT_DEFAULT)
+ percent = priv->initial_brightness;
+
+ if (percent < LP855x_MIN_BRIGHTNESS)
+ percent = LP855x_MIN_BRIGHTNESS;
+
+ if (percent > LP855x_MAX_BRIGHTNESS)
+ percent = LP855x_MAX_BRIGHTNESS;
+
+ /* Set brightness level */
+ return dm_i2c_reg_write(dev, priv->cfg->reg_brightness,
+ percent);
+}
+
+static int lp855x_backlight_probe(struct udevice *dev)
+{
+ struct lp855x_backlight_priv *priv = dev_get_priv(dev);
+ int rom_length, ret;
+
+ if (device_get_uclass_id(dev->parent) != UCLASS_I2C)
+ return -EPROTONOSUPPORT;
+
+ priv->cfg = (struct lp855x_device_config *)dev_get_driver_data(dev);
+
+ dev_read_u8(dev, "dev-ctrl", &priv->device_control);
+ dev_read_u8(dev, "init-brt", &priv->initial_brightness);
+
+ /* Fill ROM platform data if defined */
+ rom_length = dev_get_child_count(dev);
+ if (rom_length > 0) {
+ struct lp855x_rom_data *rom;
+ ofnode child;
+ int i = 0;
+
+ rom = devm_kcalloc(dev, rom_length, sizeof(*rom), GFP_KERNEL);
+ if (!rom)
+ return -ENOMEM;
+
+ dev_for_each_subnode(child, dev) {
+ ofnode_read_u8(child, "rom-addr", &rom[i].addr);
+ ofnode_read_u8(child, "rom-val", &rom[i].val);
+ i++;
+ }
+
+ priv->size_program = rom_length;
+ priv->rom_data = &rom[0];
+ }
+
+ ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+ "power-supply", &priv->supply);
+ if (ret) {
+ log_err("%s: cannot get power-supply: ret = %d\n", __func__, ret);
+ return ret;
+ }
+
+ ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+ "enable-supply", &priv->enable);
+ if (ret) {
+ log_err("%s: cannot get enable-supply: ret = %d\n", __func__, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct backlight_ops lp855x_backlight_ops = {
+ .enable = lp855x_backlight_enable,
+ .set_brightness = lp855x_backlight_set_brightness,
+};
+
+static int lp8556_bl_rst(struct udevice *dev)
+{
+ int ret;
+
+ /* Reset backlight after updating EPROM settings */
+ ret = dm_i2c_reg_clrset(dev, LP855X_DEVICE_CTRL, LP8557_BL_MASK,
+ LP8557_BL_OFF);
+ if (ret)
+ return ret;
+
+ mdelay(10);
+
+ return dm_i2c_reg_clrset(dev, LP855X_DEVICE_CTRL, LP8557_BL_MASK,
+ LP8557_BL_ON);
+}
+
+static int lp8557_bl_off(struct udevice *dev)
+{
+ /* BL_ON = 0 before updating EPROM settings */
+ return dm_i2c_reg_clrset(dev, LP8557_BL_CMD, LP8557_BL_MASK,
+ LP8557_BL_OFF);
+}
+
+static int lp8557_bl_on(struct udevice *dev)
+{
+ /* BL_ON = 1 after updating EPROM settings */
+ return dm_i2c_reg_clrset(dev, LP8557_BL_CMD, LP8557_BL_MASK,
+ LP8557_BL_ON);
+}
+
+static struct lp855x_device_config lp855x_dev_cfg = {
+ .reg_brightness = LP855X_BRIGHTNESS_CTRL,
+ .reg_devicectrl = LP855X_DEVICE_CTRL,
+ .reg_eepromstart = LP855X_EEPROM_START,
+ .reg_eepromend = LP855X_EEPROM_END,
+};
+
+static struct lp855x_device_config lp8555_dev_cfg = {
+ .reg_brightness = LP8557_BRIGHTNESS_CTRL,
+ .reg_devicectrl = LP8557_CONFIG,
+ .reg_eepromstart = LP8555_EPROM_START,
+ .reg_eepromend = LP8555_EPROM_END,
+ .pre_init_device = lp8557_bl_off,
+ .post_init_device = lp8557_bl_on,
+};
+
+static struct lp855x_device_config lp8556_dev_cfg = {
+ .reg_brightness = LP855X_BRIGHTNESS_CTRL,
+ .reg_devicectrl = LP855X_DEVICE_CTRL,
+ .reg_eepromstart = LP8556_EPROM_START,
+ .reg_eepromend = LP8556_EPROM_END,
+ .post_init_device = lp8556_bl_rst,
+};
+
+static struct lp855x_device_config lp8557_dev_cfg = {
+ .reg_brightness = LP8557_BRIGHTNESS_CTRL,
+ .reg_devicectrl = LP8557_CONFIG,
+ .reg_eepromstart = LP8557_EPROM_START,
+ .reg_eepromend = LP8557_EPROM_END,
+ .pre_init_device = lp8557_bl_off,
+ .post_init_device = lp8557_bl_on,
+};
+
+static const struct udevice_id lp855x_backlight_ids[] = {
+ { .compatible = "ti,lp8550", .data = (ulong)&lp855x_dev_cfg },
+ { .compatible = "ti,lp8551", .data = (ulong)&lp855x_dev_cfg },
+ { .compatible = "ti,lp8552", .data = (ulong)&lp855x_dev_cfg },
+ { .compatible = "ti,lp8553", .data = (ulong)&lp855x_dev_cfg },
+ { .compatible = "ti,lp8555", .data = (ulong)&lp8555_dev_cfg },
+ { .compatible = "ti,lp8556", .data = (ulong)&lp8556_dev_cfg },
+ { .compatible = "ti,lp8557", .data = (ulong)&lp8557_dev_cfg },
+ { }
+};
+
+U_BOOT_DRIVER(lp855x_backlight) = {
+ .name = "lp855x_backlight",
+ .id = UCLASS_PANEL_BACKLIGHT,
+ .of_match = lp855x_backlight_ids,
+ .probe = lp855x_backlight_probe,
+ .ops = &lp855x_backlight_ops,
+ .priv_auto = sizeof(struct lp855x_backlight_priv),
+};
diff --git a/drivers/video/sharp-lq079l1sx01.c b/drivers/video/sharp-lq079l1sx01.c
new file mode 100644
index 00000000000..a8197f40fc7
--- /dev/null
+++ b/drivers/video/sharp-lq079l1sx01.c
@@ -0,0 +1,288 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Sharp LQ079L1SX01 DSI panel driver
+ *
+ * Copyright (c) 2024 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <backlight.h>
+#include <dm.h>
+#include <panel.h>
+#include <log.h>
+#include <mipi_dsi.h>
+#include <linux/delay.h>
+#include <asm/gpio.h>
+#include <power/regulator.h>
+
+struct sharp_lq079l1sx01_priv {
+ struct udevice *backlight;
+ struct udevice *panel_sec;
+
+ struct udevice *avdd;
+ struct udevice *vddio;
+ struct udevice *vsp;
+ struct udevice *vsn;
+
+ struct gpio_desc reset_gpio;
+};
+
+static struct display_timing default_timing = {
+ .pixelclock.typ = 215000000,
+ .hactive.typ = 1536,
+ .hfront_porch.typ = 136,
+ .hback_porch.typ = 28,
+ .hsync_len.typ = 28,
+ .vactive.typ = 2048,
+ .vfront_porch.typ = 14,
+ .vback_porch.typ = 8,
+ .vsync_len.typ = 2,
+};
+
+static int dcs_write_one(struct mipi_dsi_device *dsi, u8 cmd, u8 data)
+{
+ return mipi_dsi_dcs_write(dsi, cmd, &data, 1);
+}
+
+static int sharp_lq079l1sx01_configure_link(struct udevice *dev)
+{
+ struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
+ struct mipi_dsi_device *dsi = plat->device;
+ int ret;
+
+ ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+ if (ret < 0) {
+ log_debug("%s: failed to exit sleep mode %s: %d\n",
+ __func__, dev->parent->name, ret);
+ }
+ mdelay(120);
+
+ ret = dcs_write_one(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 0xff);
+ if (ret < 0) {
+ log_debug("%s: failed to SET_DISPLAY_BRIGHTNESS %s: %d\n",
+ __func__, dev->parent->name, ret);
+ }
+ ret = dcs_write_one(dsi, MIPI_DCS_WRITE_POWER_SAVE, 0x01);
+ if (ret < 0) {
+ log_debug("%s: failed to WRITE_POWER_SAVE %s: %d\n",
+ __func__, dev->parent->name, ret);
+ }
+ ret = dcs_write_one(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x2c);
+ if (ret < 0) {
+ log_debug("%s: failed to WRITE_CONTROL_DISPLAY %s: %d\n",
+ __func__, dev->parent->name, ret);
+ }
+
+ ret = mipi_dsi_dcs_set_display_on(dsi);
+ if (ret < 0) {
+ log_debug("%s: failed to set panel on %s: %d\n",
+ __func__, dev->parent->name, ret);
+ }
+
+ return 0;
+}
+
+static int sharp_lq079l1sx01_enable_backlight(struct udevice *dev)
+{
+ struct sharp_lq079l1sx01_priv *priv = dev_get_priv(dev);
+
+ if (!priv->panel_sec)
+ return 0;
+
+ sharp_lq079l1sx01_configure_link(dev);
+ sharp_lq079l1sx01_configure_link(priv->panel_sec);
+
+ return 0;
+}
+
+static int sharp_lq079l1sx01_set_backlight(struct udevice *dev, int percent)
+{
+ struct sharp_lq079l1sx01_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ if (!priv->panel_sec)
+ return 0;
+
+ ret = backlight_enable(priv->backlight);
+ if (ret)
+ return ret;
+
+ return backlight_set_brightness(priv->backlight, percent);
+}
+
+static int sharp_lq079l1sx01_timings(struct udevice *dev,
+ struct display_timing *timing)
+{
+ memcpy(timing, &default_timing, sizeof(*timing));
+ return 0;
+}
+
+static int sharp_lq079l1sx01_of_to_plat(struct udevice *dev)
+{
+ struct sharp_lq079l1sx01_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ /* If node has no link2 it is secondary panel */
+ if (!dev_read_bool(dev, "link2"))
+ return 0;
+
+ ret = uclass_get_device_by_phandle(UCLASS_PANEL, dev,
+ "link2", &priv->panel_sec);
+ if (ret) {
+ log_debug("%s: cannot get secondary panel: ret = %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
+ "backlight", &priv->backlight);
+ if (ret) {
+ log_debug("%s: cannot get backlight: ret = %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+ "avdd-supply", &priv->avdd);
+ if (ret) {
+ log_debug("%s: cannot get avdd-supply: ret = %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+ "vddio-supply", &priv->vddio);
+ if (ret) {
+ log_debug("%s: cannot get vddio-supply: ret = %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+ "vsp-supply", &priv->vsp);
+ if (ret) {
+ log_debug("%s: cannot get vsp-supply: ret = %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = uclass_get_device_by_phandle(UCLASS_REGULATOR, dev,
+ "vsn-supply", &priv->vsn);
+ if (ret) {
+ log_debug("%s: cannot get vsn-supply: ret = %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = gpio_request_by_name(dev, "reset-gpios", 0,
+ &priv->reset_gpio, GPIOD_IS_OUT);
+ if (ret) {
+ log_debug("%s: cannot get reser-gpios (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int sharp_lq079l1sx01_hw_init(struct udevice *dev)
+{
+ struct sharp_lq079l1sx01_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ if (!priv->panel_sec)
+ return 0;
+
+ ret = regulator_set_enable_if_allowed(priv->vddio, 1);
+ if (ret) {
+ log_debug("%s: enabling vddio-supply failed (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ ret = regulator_set_enable_if_allowed(priv->avdd, 1);
+ if (ret) {
+ log_debug("%s: enabling avdd-supply failed (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ mdelay(12);
+
+ ret = regulator_set_enable_if_allowed(priv->vsp, 1);
+ if (ret) {
+ log_debug("%s: enabling vsp-supply failed (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ mdelay(12);
+
+ ret = regulator_set_enable_if_allowed(priv->vsn, 1);
+ if (ret) {
+ log_debug("%s: enabling vsn-supply failed (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+
+ mdelay(24);
+
+ ret = dm_gpio_set_value(&priv->reset_gpio, 0);
+ if (ret) {
+ log_debug("%s: error disabling reset-gpios (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+ udelay(3);
+
+ ret = dm_gpio_set_value(&priv->reset_gpio, 1);
+ if (ret) {
+ log_debug("%s: error enabling reset-gpios (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+ udelay(3);
+
+ ret = dm_gpio_set_value(&priv->reset_gpio, 0);
+ if (ret) {
+ log_debug("%s: error disabling reset-gpios (%d)\n",
+ __func__, ret);
+ return ret;
+ }
+ mdelay(32);
+
+ return 0;
+}
+
+static int sharp_lq079l1sx01_probe(struct udevice *dev)
+{
+ struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
+
+ /* fill characteristics of DSI data link */
+ plat->lanes = 4;
+ plat->format = MIPI_DSI_FMT_RGB888;
+ plat->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM;
+
+ return sharp_lq079l1sx01_hw_init(dev);
+}
+
+static const struct panel_ops sharp_lq079l1sx01_ops = {
+ .enable_backlight = sharp_lq079l1sx01_enable_backlight,
+ .set_backlight = sharp_lq079l1sx01_set_backlight,
+ .get_display_timing = sharp_lq079l1sx01_timings,
+};
+
+static const struct udevice_id sharp_lq079l1sx01_ids[] = {
+ { .compatible = "sharp,lq079l1sx01" },
+ { }
+};
+
+U_BOOT_DRIVER(sharp_lq079l1sx01) = {
+ .name = "sharp_lq079l1sx01",
+ .id = UCLASS_PANEL,
+ .of_match = sharp_lq079l1sx01_ids,
+ .ops = &sharp_lq079l1sx01_ops,
+ .of_to_plat = sharp_lq079l1sx01_of_to_plat,
+ .probe = sharp_lq079l1sx01_probe,
+ .plat_auto = sizeof(struct mipi_dsi_panel_plat),
+ .priv_auto = sizeof(struct sharp_lq079l1sx01_priv),
+};
diff --git a/drivers/video/tegra20/tegra-dc.c b/drivers/video/tegra20/tegra-dc.c
index d24aa375b39..16a2b5281bf 100644
--- a/drivers/video/tegra20/tegra-dc.c
+++ b/drivers/video/tegra20/tegra-dc.c
@@ -5,24 +5,16 @@
#include <backlight.h>
#include <cpu_func.h>
+#include <clk.h>
#include <dm.h>
#include <fdtdec.h>
#include <log.h>
#include <panel.h>
-#include <part.h>
-#include <pwm.h>
#include <video.h>
-#include <asm/cache.h>
-#include <asm/global_data.h>
#include <asm/system.h>
-#include <asm/gpio.h>
#include <asm/io.h>
-
#include <asm/arch/clock.h>
-#include <asm/arch/funcmux.h>
-#include <asm/arch/pinmux.h>
#include <asm/arch/powergate.h>
-#include <asm/arch/pwm.h>
#include "tegra-dc.h"
@@ -44,7 +36,8 @@ struct tegra_lcd_priv {
const struct tegra_dc_soc_info *soc;
fdt_addr_t frame_buffer; /* Address of frame buffer */
unsigned pixel_clock; /* Pixel clock in Hz */
- int dc_clk[2]; /* Contains clk and its parent */
+ struct clk *clk;
+ struct clk *clk_parent;
ulong scdiv; /* Clock divider used by disp_clk_ctrl */
bool rotation; /* 180 degree panel turn */
int pipe; /* DC controller: 0 for A, 1 for B */
@@ -144,10 +137,9 @@ static int update_display_mode(struct tegra_lcd_priv *priv)
val |= DATA_ALIGNMENT_MSB << DATA_ALIGNMENT_SHIFT;
val |= DATA_ORDER_RED_BLUE << DATA_ORDER_SHIFT;
writel(val, &disp->disp_interface_ctrl);
- }
- if (priv->soc->has_rgb)
writel(0x00010001, &disp->shift_clk_opt);
+ }
val = PIXEL_CLK_DIVIDER_PCD1 << PIXEL_CLK_DIVIDER_SHIFT;
val |= priv->scdiv << SHIFT_CLK_DIVIDER_SHIFT;
@@ -267,7 +259,9 @@ static int setup_window(struct tegra_lcd_priv *priv,
win->out_h = priv->height;
win->phys_addr = priv->frame_buffer;
win->stride = priv->width * (1 << priv->log2_bpp) / 8;
- debug("%s: depth = %d\n", __func__, priv->log2_bpp);
+
+ log_debug("%s: depth = %d\n", __func__, priv->log2_bpp);
+
switch (priv->log2_bpp) {
case VIDEO_BPP32:
win->fmt = COLOR_DEPTH_R8G8B8A8;
@@ -279,7 +273,7 @@ static int setup_window(struct tegra_lcd_priv *priv,
break;
default:
- debug("Unsupported LCD bit depth");
+ log_debug("Unsupported LCD bit depth\n");
return -1;
}
@@ -301,7 +295,8 @@ static int tegra_display_probe(struct tegra_lcd_priv *priv,
void *default_lcd_base)
{
struct disp_ctl_win window;
- unsigned long rate = clock_get_rate(priv->dc_clk[1]);
+ unsigned long rate = clk_get_rate(priv->clk_parent);
+ int ret;
priv->frame_buffer = (u32)default_lcd_base;
@@ -309,14 +304,9 @@ static int tegra_display_probe(struct tegra_lcd_priv *priv,
* We halve the rate if DISP1 parent is PLLD, since actual parent
* is plld_out0 which is PLLD divided by 2.
*/
- if (priv->dc_clk[1] == CLOCK_ID_DISPLAY)
- rate /= 2;
-
-#ifndef CONFIG_TEGRA20
- /* PLLD2 obeys same rules as PLLD but it is present only on T30+ */
- if (priv->dc_clk[1] == CLOCK_ID_DISPLAY2)
+ if (priv->clk_parent->id == CLOCK_ID_DISPLAY ||
+ priv->clk_parent->id == CLOCK_ID_DISPLAY2)
rate /= 2;
-#endif
/*
* The pixel clock divider is in 7.1 format (where the bottom bit
@@ -327,14 +317,14 @@ static int tegra_display_probe(struct tegra_lcd_priv *priv,
if (!priv->scdiv)
priv->scdiv = ((rate * 2 + priv->pixel_clock / 2)
/ priv->pixel_clock) - 2;
- debug("Display clock %lu, divider %lu\n", rate, priv->scdiv);
+ log_debug("Display clock %lu, divider %lu\n", rate, priv->scdiv);
/*
* HOST1X is init by default at 150MHz with PLLC as parent
*/
clock_start_periph_pll(PERIPH_ID_HOST1X, CLOCK_ID_CGENERAL,
150 * 1000000);
- clock_start_periph_pll(priv->dc_clk[0], priv->dc_clk[1],
+ clock_start_periph_pll(priv->clk->id, priv->clk_parent->id,
rate);
basic_init(&priv->dc->cmd);
@@ -348,8 +338,9 @@ static int tegra_display_probe(struct tegra_lcd_priv *priv,
if (priv->pixel_clock)
update_display_mode(priv);
- if (setup_window(priv, &window))
- return -1;
+ ret = setup_window(priv, &window);
+ if (ret)
+ return ret;
update_window(priv, &window);
@@ -364,10 +355,6 @@ static int tegra_lcd_probe(struct udevice *dev)
int ret;
/* Initialize the Tegra display controller */
-#ifdef CONFIG_TEGRA20
- funcmux_select(PERIPH_ID_DISP1, FUNCMUX_DEFAULT);
-#endif
-
if (priv->soc->has_pgate) {
uint powergate;
@@ -378,14 +365,14 @@ static int tegra_lcd_probe(struct udevice *dev)
ret = tegra_powergate_power_off(powergate);
if (ret < 0) {
- log_err("failed to power off DISP gate: %d", ret);
+ log_debug("failed to power off DISP gate: %d", ret);
return ret;
}
ret = tegra_powergate_sequence_power_up(powergate,
- priv->dc_clk[0]);
+ priv->clk->id);
if (ret < 0) {
- log_err("failed to power up DISP gate: %d", ret);
+ log_debug("failed to power up DISP gate: %d", ret);
return ret;
}
}
@@ -402,19 +389,15 @@ static int tegra_lcd_probe(struct udevice *dev)
memset((u8 *)plat->base, 0, plat->size);
flush_dcache_all();
- if (tegra_display_probe(priv, (void *)plat->base)) {
- debug("%s: Failed to probe display driver\n", __func__);
- return -1;
+ ret = tegra_display_probe(priv, (void *)plat->base);
+ if (ret) {
+ log_debug("%s: Failed to probe display driver\n", __func__);
+ return ret;
}
-#ifdef CONFIG_TEGRA20
- pinmux_set_func(PMUX_PINGRP_GPU, PMUX_FUNC_PWM);
- pinmux_tristate_disable(PMUX_PINGRP_GPU);
-#endif
-
ret = panel_enable_backlight(priv->panel);
if (ret) {
- debug("%s: Cannot enable backlight, ret=%d\n", __func__, ret);
+ log_debug("%s: Cannot enable backlight, ret=%d\n", __func__, ret);
return ret;
}
@@ -427,8 +410,8 @@ static int tegra_lcd_probe(struct udevice *dev)
uc_priv->xsize = priv->width;
uc_priv->ysize = priv->height;
uc_priv->bpix = priv->log2_bpp;
- debug("LCD frame buffer at %08x, size %x\n", priv->frame_buffer,
- plat->size);
+ log_debug("LCD frame buffer at %08x, size %x\n", priv->frame_buffer,
+ plat->size);
return panel_set_backlight(priv->panel, BACKLIGHT_DEFAULT);
}
@@ -445,17 +428,24 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)
priv->dc = (struct dc_ctlr *)dev_read_addr_ptr(dev);
if (!priv->dc) {
- debug("%s: No display controller address\n", __func__);
+ log_debug("%s: No display controller address\n", __func__);
return -EINVAL;
}
priv->soc = (struct tegra_dc_soc_info *)dev_get_driver_data(dev);
- ret = clock_decode_pair(dev, priv->dc_clk);
- if (ret < 0) {
- debug("%s: Cannot decode clocks for '%s' (ret = %d)\n",
- __func__, dev->name, ret);
- return -EINVAL;
+ priv->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ log_debug("%s: Could not get DC clock: %ld\n",
+ __func__, PTR_ERR(priv->clk));
+ return PTR_ERR(priv->clk);
+ }
+
+ priv->clk_parent = devm_clk_get(dev, "parent");
+ if (IS_ERR(priv->clk_parent)) {
+ log_debug("%s: Could not get DC clock parent: %ld\n",
+ __func__, PTR_ERR(priv->clk_parent));
+ return PTR_ERR(priv->clk_parent);
}
priv->rotation = dev_read_bool(dev, "nvidia,180-rotation");
@@ -463,8 +453,8 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)
rgb = fdt_subnode_offset(blob, node, "rgb");
if (rgb < 0) {
- debug("%s: Cannot find rgb subnode for '%s' (ret=%d)\n",
- __func__, dev->name, rgb);
+ log_debug("%s: Cannot find rgb subnode for '%s' (ret=%d)\n",
+ __func__, dev->name, rgb);
return -EINVAL;
}
@@ -474,15 +464,15 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)
*/
panel_node = fdtdec_lookup_phandle(blob, rgb, "nvidia,panel");
if (panel_node < 0) {
- debug("%s: Cannot find panel information\n", __func__);
+ log_debug("%s: Cannot find panel information\n", __func__);
return -EINVAL;
}
ret = uclass_get_device_by_of_offset(UCLASS_PANEL, panel_node,
&priv->panel);
if (ret) {
- debug("%s: Cannot find panel for '%s' (ret=%d)\n", __func__,
- dev->name, ret);
+ log_debug("%s: Cannot find panel for '%s' (ret=%d)\n", __func__,
+ dev->name, ret);
return ret;
}
@@ -500,8 +490,8 @@ static int tegra_lcd_of_to_plat(struct udevice *dev)
if (ret) {
ret = fdtdec_decode_display_timing(blob, rgb, 0, &priv->timing);
if (ret) {
- debug("%s: Cannot read display timing for '%s' (ret=%d)\n",
- __func__, dev->name, ret);
+ log_debug("%s: Cannot read display timing for '%s' (ret=%d)\n",
+ __func__, dev->name, ret);
return -EINVAL;
}
}
@@ -564,6 +554,9 @@ static const struct udevice_id tegra_lcd_ids[] = {
.compatible = "nvidia,tegra114-dc",
.data = (ulong)&tegra114_dc_soc_info
}, {
+ .compatible = "nvidia,tegra124-dc",
+ .data = (ulong)&tegra114_dc_soc_info
+ }, {
/* sentinel */
}
};
diff --git a/drivers/video/tegra20/tegra-dsi.c b/drivers/video/tegra20/tegra-dsi.c
index 6327266dd22..9f39ac7589b 100644
--- a/drivers/video/tegra20/tegra-dsi.c
+++ b/drivers/video/tegra20/tegra-dsi.c
@@ -5,6 +5,7 @@
*/
#include <dm.h>
+#include <clk.h>
#include <log.h>
#include <misc.h>
#include <mipi_display.h>
@@ -46,10 +47,13 @@ struct tegra_dsi_priv {
enum tegra_dsi_format format;
- int dsi_clk;
+ struct clk *clk;
+ struct clk *clk_parent;
+
int video_fifo_depth;
int host_fifo_depth;
+ u32 calibration_pads;
u32 version;
/* for ganged-mode support */
@@ -515,8 +519,9 @@ static void tegra_dsi_pad_calibrate(struct dsi_pad_ctrl_reg *pad)
writel(value, TEGRA_VI_BASE + (CSI_CIL_PAD_CONFIG << 2));
}
-static void tegra_dsi_mipi_calibrate(struct tegra_dsi_priv *priv)
+static void tegra_dsi_mipi_calibrate(struct udevice *dev)
{
+ struct tegra_dsi_priv *priv = dev_get_priv(dev);
struct dsi_pad_ctrl_reg *pad = &priv->dsi->pad;
u32 value;
int ret;
@@ -545,15 +550,20 @@ static void tegra_dsi_mipi_calibrate(struct tegra_dsi_priv *priv)
DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3);
writel(value, &pad->pad_ctrl_3);
- ret = misc_write(priv->mipi, 0, NULL, 0);
+ ret = misc_write(priv->mipi, priv->calibration_pads, NULL, 0);
if (ret)
log_debug("%s: MIPI calibration failed %d\n", __func__, ret);
+
+ if (priv->slave)
+ tegra_dsi_mipi_calibrate(priv->slave);
}
-static void tegra_dsi_set_timeout(struct dsi_timeout_reg *rtimeout,
+static void tegra_dsi_set_timeout(struct udevice *dev,
unsigned long bclk,
unsigned int vrefresh)
{
+ struct tegra_dsi_priv *priv = dev_get_priv(dev);
+ struct dsi_timeout_reg *rtimeout = &priv->dsi->timeout;
unsigned int timeout;
u32 value;
@@ -569,12 +579,17 @@ static void tegra_dsi_set_timeout(struct dsi_timeout_reg *rtimeout,
value = DSI_TALLY_TA(0) | DSI_TALLY_LRX(0) | DSI_TALLY_HTX(0);
writel(value, &rtimeout->dsi_to_tally);
+
+ if (priv->slave)
+ tegra_dsi_set_timeout(priv->slave, bclk, vrefresh);
}
-static void tegra_dsi_set_phy_timing(struct dsi_timing_reg *ptiming,
+static void tegra_dsi_set_phy_timing(struct udevice *dev,
unsigned long period,
const struct mipi_dphy_timing *dphy_timing)
{
+ struct tegra_dsi_priv *priv = dev_get_priv(dev);
+ struct dsi_timing_reg *ptiming = &priv->dsi->ptiming;
u32 value;
value = DSI_TIMING_FIELD(dphy_timing->hsexit, period, 1) << 24 |
@@ -598,6 +613,31 @@ static void tegra_dsi_set_phy_timing(struct dsi_timing_reg *ptiming,
DSI_TIMING_FIELD(dphy_timing->tasure, period, 1) << 8 |
DSI_TIMING_FIELD(dphy_timing->tago, period, 1);
writel(value, &ptiming->dsi_bta_timing);
+
+ if (priv->slave)
+ tegra_dsi_set_phy_timing(priv->slave, period, dphy_timing);
+}
+
+static u32 tegra_dsi_get_lanes(struct udevice *dev)
+{
+ struct tegra_dsi_priv *priv = dev_get_priv(dev);
+ struct mipi_dsi_device *device = &priv->device;
+
+ if (priv->master) {
+ struct tegra_dsi_priv *mpriv = dev_get_priv(priv->master);
+ struct mipi_dsi_device *mdevice = &mpriv->device;
+
+ return mdevice->lanes + device->lanes;
+ }
+
+ if (priv->slave) {
+ struct tegra_dsi_priv *spriv = dev_get_priv(priv->slave);
+ struct mipi_dsi_device *sdevice = &spriv->device;
+
+ return device->lanes + sdevice->lanes;
+ }
+
+ return device->lanes;
}
static void tegra_dsi_ganged_enable(struct udevice *dev, unsigned int start,
@@ -611,7 +651,7 @@ static void tegra_dsi_ganged_enable(struct udevice *dev, unsigned int start,
writel(DSI_GANGED_MODE_CONTROL_ENABLE, &ganged->ganged_mode_ctrl);
}
-static void tegra_dsi_configure(struct udevice *dev,
+static void tegra_dsi_configure(struct udevice *dev, unsigned int pipe,
unsigned long mode_flags)
{
struct tegra_dsi_priv *priv = dev_get_priv(dev);
@@ -642,7 +682,7 @@ static void tegra_dsi_configure(struct udevice *dev,
value = DSI_CONTROL_CHANNEL(0) |
DSI_CONTROL_FORMAT(priv->format) |
DSI_CONTROL_LANES(device->lanes - 1) |
- DSI_CONTROL_SOURCE(0);
+ DSI_CONTROL_SOURCE(pipe);
writel(value, &misc->dsi_ctrl);
writel(priv->video_fifo_depth, &misc->dsi_max_threshold);
@@ -680,12 +720,19 @@ static void tegra_dsi_configure(struct udevice *dev,
/* horizontal back porch */
hbp = timing->hback_porch.typ * mul / div;
- if ((mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) == 0)
- hbp += hsw;
-
/* horizontal front porch */
hfp = timing->hfront_porch.typ * mul / div;
+ if (priv->master || priv->slave) {
+ hact /= 2;
+ hsw /= 2;
+ hbp = hbp / 2 - 1;
+ hfp /= 2;
+ }
+
+ if ((mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) == 0)
+ hbp += hsw;
+
/* subtract packet overhead */
hsw -= 10;
hbp -= 14;
@@ -695,9 +742,6 @@ static void tegra_dsi_configure(struct udevice *dev,
writel(hact << 16 | hbp, &len->dsi_pkt_len_2_3);
writel(hfp, &len->dsi_pkt_len_4_5);
writel(0x0f0f << 16, &len->dsi_pkt_len_6_7);
-
- /* set SOL delay (for non-burst mode only) */
- writel(8 * mul / div, &misc->dsi_sol_delay);
} else {
if (priv->master || priv->slave) {
/*
@@ -717,32 +761,33 @@ static void tegra_dsi_configure(struct udevice *dev,
value = MIPI_DCS_WRITE_MEMORY_START << 8 |
MIPI_DCS_WRITE_MEMORY_CONTINUE;
writel(value, &len->dsi_dcs_cmds);
+ }
- /* set SOL delay */
- if (priv->master || priv->slave) {
- unsigned long delay, bclk, bclk_ganged;
- unsigned int lanes = device->lanes;
- unsigned long htotal = timing->hactive.typ + timing->hfront_porch.typ +
- timing->hback_porch.typ + timing->hsync_len.typ;
-
- /* SOL to valid, valid to FIFO and FIFO write delay */
- delay = 4 + 4 + 2;
- delay = DIV_ROUND_UP(delay * mul, div * lanes);
- /* FIFO read delay */
- delay = delay + 6;
-
- bclk = DIV_ROUND_UP(htotal * mul, div * lanes);
- bclk_ganged = DIV_ROUND_UP(bclk * lanes / 2, lanes);
- value = bclk - bclk_ganged + delay + 20;
- } else {
- /* TODO: revisit for non-ganged mode */
- value = 8 * mul / div;
- }
-
- writel(value, &misc->dsi_sol_delay);
+ /* set SOL delay */
+ if (priv->master || priv->slave) {
+ unsigned long delay, bclk, bclk_ganged;
+ unsigned int lanes = tegra_dsi_get_lanes(dev);
+ unsigned long htotal = timing->hactive.typ + timing->hfront_porch.typ +
+ timing->hback_porch.typ + timing->hsync_len.typ;
+
+ /* SOL to valid, valid to FIFO and FIFO write delay */
+ delay = 4 + 4 + 2;
+ delay = DIV_ROUND_UP(delay * mul, div * lanes);
+ /* FIFO read delay */
+ delay = delay + 6;
+
+ bclk = DIV_ROUND_UP(htotal * mul, div * lanes);
+ bclk_ganged = DIV_ROUND_UP(bclk * lanes / 2, lanes);
+ value = bclk - bclk_ganged + delay + 20;
+ } else {
+ /* set SOL delay (for non-burst mode only) */
+ value = 8 * mul / div;
}
+ writel(value, &misc->dsi_sol_delay);
+
if (priv->slave) {
+ tegra_dsi_configure(priv->slave, pipe, mode_flags);
/*
* TODO: Support modes other than symmetrical left-right
* split.
@@ -753,15 +798,31 @@ static void tegra_dsi_configure(struct udevice *dev,
}
}
+static void tegra_dsi_enable(struct udevice *dev)
+{
+ struct tegra_dsi_priv *priv = dev_get_priv(dev);
+ struct dsi_misc_reg *misc = &priv->dsi->misc;
+ u32 value;
+
+ /* enable DSI controller */
+ value = readl(&misc->dsi_pwr_ctrl);
+ value |= DSI_POWER_CONTROL_ENABLE;
+ writel(value, &misc->dsi_pwr_ctrl);
+
+ if (priv->slave)
+ tegra_dsi_enable(priv->slave);
+}
+
static int tegra_dsi_encoder_enable(struct udevice *dev)
{
struct tegra_dsi_priv *priv = dev_get_priv(dev);
+ struct tegra_dc_plat *dc_plat = dev_get_plat(dev);
struct mipi_dsi_device *device = &priv->device;
struct display_timing *timing = &priv->timing;
struct dsi_misc_reg *misc = &priv->dsi->misc;
unsigned int mul, div;
unsigned long bclk, plld, period;
- u32 value;
+ u32 value, lanes;
int ret;
/* If for some reasone DSI is enabled then it needs to
@@ -780,16 +841,17 @@ static int tegra_dsi_encoder_enable(struct udevice *dev)
writel(0, &misc->int_enable);
if (priv->version)
- tegra_dsi_mipi_calibrate(priv);
+ tegra_dsi_mipi_calibrate(dev);
else
tegra_dsi_pad_calibrate(&priv->dsi->pad);
tegra_dsi_get_muldiv(device->format, &mul, &div);
/* compute byte clock */
- bclk = (timing->pixelclock.typ * mul) / (div * device->lanes);
+ lanes = tegra_dsi_get_lanes(dev);
+ bclk = (timing->pixelclock.typ * mul) / (div * lanes);
- tegra_dsi_set_timeout(&priv->dsi->timeout, bclk, 60);
+ tegra_dsi_set_timeout(dev, bclk, 60);
/*
* Compute bit clock and round up to the next MHz.
@@ -813,25 +875,18 @@ static int tegra_dsi_encoder_enable(struct udevice *dev)
* The D-PHY timing fields are expressed in byte-clock cycles, so
* multiply the period by 8.
*/
- tegra_dsi_set_phy_timing(&priv->dsi->ptiming,
- period * 8, &priv->dphy_timing);
+ tegra_dsi_set_phy_timing(dev, period * 8, &priv->dphy_timing);
/* Perform panel HW setup */
ret = panel_enable_backlight(priv->panel);
if (ret)
return ret;
- tegra_dsi_configure(dev, device->mode_flags);
+ tegra_dsi_configure(dev, dc_plat->pipe, device->mode_flags);
tegra_dc_enable_controller(dev);
- /* enable DSI controller */
- value = readl(&misc->dsi_pwr_ctrl);
- value |= DSI_POWER_CONTROL_ENABLE;
- writel(value, &misc->dsi_pwr_ctrl);
-
- if (priv->slave)
- tegra_dsi_encoder_enable(priv->slave);
+ tegra_dsi_enable(dev);
return 0;
}
@@ -859,21 +914,35 @@ static void tegra_dsi_init_clocks(struct udevice *dev)
struct tegra_dsi_priv *priv = dev_get_priv(dev);
struct tegra_dc_plat *dc_plat = dev_get_plat(dev);
struct mipi_dsi_device *device = &priv->device;
- unsigned int mul, div;
+ unsigned int mul, div, lanes;
unsigned long bclk, plld;
- if (!priv->slave) {
+ /* Switch parents of DSI clocks in case of not standard parent */
+ if (priv->clk->id == PERIPH_ID_DSI &&
+ priv->clk_parent->id == CLOCK_ID_DISPLAY2) {
+ /* Change DSIA clock parent to PLLD2 */
+ struct clk_rst_ctlr *clkrst =
+ (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
+
+ /* DSIA_CLK_SRC */
+ setbits_le32(&clkrst->crc_pll[CLOCK_ID_DISPLAY].pll_base,
+ BIT(25));
+ }
+
+ if (priv->clk->id == PERIPH_ID_DSIB &&
+ priv->clk_parent->id == CLOCK_ID_DISPLAY) {
/* Change DSIB clock parent to match DSIA */
struct clk_rst_ctlr *clkrst =
(struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
- clrbits_le32(&clkrst->plld2.pll_base, BIT(25)); /* DSIB_CLK_SRC */
+ /* DSIB_CLK_SRC */
+ clrbits_le32(&clkrst->plld2.pll_base, BIT(25));
}
tegra_dsi_get_muldiv(device->format, &mul, &div);
- bclk = (priv->timing.pixelclock.typ * mul) /
- (div * device->lanes);
+ lanes = tegra_dsi_get_lanes(dev);
+ bclk = (priv->timing.pixelclock.typ * mul) / (div * lanes);
plld = DIV_ROUND_UP(bclk * 8, USEC_PER_SEC);
@@ -893,16 +962,16 @@ static void tegra_dsi_init_clocks(struct udevice *dev)
switch (clock_get_osc_freq()) {
case CLOCK_OSC_FREQ_12_0: /* OSC is 12Mhz */
case CLOCK_OSC_FREQ_48_0: /* OSC is 48Mhz */
- clock_set_rate(CLOCK_ID_DISPLAY, plld, 12, 0, 8);
+ clock_set_rate(priv->clk_parent->id, plld, 12, 0, 8);
break;
case CLOCK_OSC_FREQ_26_0: /* OSC is 26Mhz */
- clock_set_rate(CLOCK_ID_DISPLAY, plld, 26, 0, 8);
+ clock_set_rate(priv->clk_parent->id, plld, 26, 0, 8);
break;
case CLOCK_OSC_FREQ_13_0: /* OSC is 13Mhz */
case CLOCK_OSC_FREQ_16_8: /* OSC is 16.8Mhz */
- clock_set_rate(CLOCK_ID_DISPLAY, plld, 13, 0, 8);
+ clock_set_rate(priv->clk_parent->id, plld, 13, 0, 8);
break;
case CLOCK_OSC_FREQ_19_2:
@@ -914,11 +983,7 @@ static void tegra_dsi_init_clocks(struct udevice *dev)
break;
}
- priv->dsi_clk = clock_decode_periph_id(dev);
-
- clock_enable(priv->dsi_clk);
- udelay(2);
- reset_set_enable(priv->dsi_clk, 0);
+ clk_enable(priv->clk);
}
static int tegra_dsi_ganged_probe(struct udevice *dev)
@@ -955,6 +1020,20 @@ static int tegra_dsi_bridge_probe(struct udevice *dev)
return -EINVAL;
}
+ priv->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(priv->clk)) {
+ log_debug("%s: Could not get DSI clock: %ld\n",
+ __func__, PTR_ERR(priv->clk));
+ return PTR_ERR(priv->clk);
+ }
+
+ priv->clk_parent = devm_clk_get(dev, "parent");
+ if (IS_ERR(priv->clk_parent)) {
+ log_debug("%s: Could not get DSI clock parent: %ld\n",
+ __func__, PTR_ERR(priv->clk_parent));
+ return PTR_ERR(priv->clk_parent);
+ }
+
priv->video_fifo_depth = 1920;
priv->host_fifo_depth = 64;
@@ -973,10 +1052,22 @@ static int tegra_dsi_bridge_probe(struct udevice *dev)
debug("%s: Cannot get avdd-dsi-csi-supply: error %d\n",
__func__, ret);
- ret = uclass_get_device_by_phandle(UCLASS_PANEL, dev,
- "panel", &priv->panel);
+ /* Check all DSI children */
+ device_foreach_child(priv->panel, dev) {
+ if (device_get_uclass_id(priv->panel) == UCLASS_PANEL)
+ break;
+ }
+
+ /* if loop exits without panel device return error */
+ if (device_get_uclass_id(priv->panel) != UCLASS_PANEL) {
+ log_debug("%s: panel not found, ret %d\n", __func__, ret);
+ return -EINVAL;
+ }
+
+ ret = uclass_get_device_by_ofnode(UCLASS_PANEL, dev_ofnode(priv->panel),
+ &priv->panel);
if (ret) {
- printf("%s: Cannot get panel: error %d\n", __func__, ret);
+ log_debug("%s: Cannot get panel: error %d\n", __func__, ret);
return log_ret(ret);
}
@@ -988,6 +1079,14 @@ static int tegra_dsi_bridge_probe(struct udevice *dev)
log_debug("%s: cannot get MIPI: error %d\n", __func__, ret);
return ret;
}
+
+ ret = dev_read_u32_index(dev, "nvidia,mipi-calibrate", 1,
+ &priv->calibration_pads);
+ if (ret) {
+ log_debug("%s: cannot get calibration pads: error %d\n",
+ __func__, ret);
+ return ret;
+ }
}
panel_get_display_timing(priv->panel, &priv->timing);
@@ -1028,6 +1127,7 @@ static const struct panel_ops tegra_dsi_bridge_ops = {
static const struct udevice_id tegra_dsi_bridge_ids[] = {
{ .compatible = "nvidia,tegra30-dsi", .data = DSI_V0 },
{ .compatible = "nvidia,tegra114-dsi", .data = DSI_V1 },
+ { .compatible = "nvidia,tegra124-dsi", .data = DSI_V1 },
{ }
};
@@ -1036,6 +1136,7 @@ U_BOOT_DRIVER(tegra_dsi) = {
.id = UCLASS_PANEL,
.of_match = tegra_dsi_bridge_ids,
.ops = &tegra_dsi_bridge_ops,
+ .bind = dm_scan_fdt_dev,
.probe = tegra_dsi_bridge_probe,
.plat_auto = sizeof(struct tegra_dc_plat),
.priv_auto = sizeof(struct tegra_dsi_priv),
diff --git a/drivers/video/tegra20/tegra-mipi.c b/drivers/video/tegra20/tegra-mipi.c
index 2df3c1a9942..a4f4343d008 100644
--- a/drivers/video/tegra20/tegra-mipi.c
+++ b/drivers/video/tegra20/tegra-mipi.c
@@ -10,9 +10,10 @@
#include <linux/delay.h>
#include <linux/iopoll.h>
+#include <asm/arch/clock.h>
#include <asm/io.h>
-/* MIPI control registers 0x00 ~ 0x60 */
+/* MIPI control registers 0x00 ~ 0x74 */
struct mipi_ctlr {
uint mipi_cal_ctrl;
uint mipi_cal_autocal_ctrl;
@@ -38,8 +39,17 @@ struct mipi_ctlr {
uint mipi_cal_bias_pad_cfg0;
uint mipi_cal_bias_pad_cfg1;
uint mipi_cal_bias_pad_cfg2;
+
+ uint mipi_cal_dsia_config_2;
+ uint mipi_cal_dsib_config_2;
+ uint mipi_cal_cilc_config_2;
+ uint mipi_cal_cild_config_2;
+ uint mipi_cal_csie_config_2;
};
+#define MIPI_DSIA_PADS 0x60
+#define MIPI_DSIB_PADS 0x180
+
#define MIPI_CAL_CTRL_NOISE_FILTER(x) (((x) & 0xf) << 26)
#define MIPI_CAL_CTRL_PRESCALE(x) (((x) & 0x3) << 24)
#define MIPI_CAL_CTRL_CLKEN_OVR BIT(4)
@@ -64,26 +74,25 @@ struct mipi_ctlr {
#define MIPI_CAL_BIAS_PAD_VAUXP(x) (((x) & 0x7) << 4)
#define MIPI_CAL_BIAS_PAD_PDVREG BIT(1)
+#define MIPI_CAL_HSCLKPDOSDSI(x) (((x) & 0x1f) << 8)
+#define MIPI_CAL_HSCLKPUOSDSI(x) (((x) & 0x1f) << 0)
+
struct tegra_mipi_priv {
struct mipi_ctlr *mipi;
struct clk *mipi_cal;
+ u32 version;
};
-static int tegra_mipi_calibrate(struct udevice *dev, int offset, const void *buf,
- int size)
+enum {
+ T114,
+ T124,
+};
+
+static void tegra114_mipi_pads_cal(struct tegra_mipi_priv *priv,
+ int calibration_pads)
{
- struct tegra_mipi_priv *priv = dev_get_priv(dev);
u32 value;
- value = MIPI_CAL_BIAS_PAD_DRV_DN_REF(0x2) |
- MIPI_CAL_BIAS_PAD_DRV_UP_REF(0x0);
- writel(value, &priv->mipi->mipi_cal_bias_pad_cfg1);
-
- value = readl(&priv->mipi->mipi_cal_bias_pad_cfg2);
- value &= ~MIPI_CAL_BIAS_PAD_VCLAMP(0x7);
- value &= ~MIPI_CAL_BIAS_PAD_VAUXP(0x7);
- writel(value, &priv->mipi->mipi_cal_bias_pad_cfg2);
-
value = MIPI_CAL_OVERIDE(0x0) | MIPI_CAL_SEL(0x1) |
MIPI_CAL_HSPDOS(0x0) | MIPI_CAL_HSPUOS(0x4) |
MIPI_CAL_TERMOS(0x5);
@@ -99,6 +108,95 @@ static int tegra_mipi_calibrate(struct udevice *dev, int offset, const void *buf
value = readl(&priv->mipi->mipi_cal_config_dsid);
value &= ~(MIPI_CAL_SEL(0x1));
writel(value, &priv->mipi->mipi_cal_config_dsid);
+}
+
+static void tegra124_mipi_pads_cal(struct tegra_mipi_priv *priv,
+ int calibration_pads)
+{
+ u32 value;
+
+ /* Calibrate DSI-A */
+ if (calibration_pads == MIPI_DSIA_PADS) {
+ printf("Calibrating DSI-A pads\n");
+
+ value = MIPI_CAL_OVERIDE(0x0) | MIPI_CAL_SEL(0x1) |
+ MIPI_CAL_HSPDOS(0x0) | MIPI_CAL_HSPUOS(0x0) |
+ MIPI_CAL_TERMOS(0x0);
+ writel(value, &priv->mipi->mipi_cal_config_dsia);
+ writel(value, &priv->mipi->mipi_cal_config_dsib);
+
+ value = MIPI_CAL_SEL(0x1) |
+ MIPI_CAL_HSCLKPDOSDSI(0x1) |
+ MIPI_CAL_HSCLKPUOSDSI(0x2);
+ writel(value, &priv->mipi->mipi_cal_dsia_config_2);
+ writel(value, &priv->mipi->mipi_cal_dsib_config_2);
+
+ /* Deselect PAD C */
+ value = readl(&priv->mipi->mipi_cal_cilc_config_2);
+ value &= ~(MIPI_CAL_SEL(0x1));
+ writel(value, &priv->mipi->mipi_cal_cilc_config_2);
+
+ /* Deselect PAD D */
+ value = readl(&priv->mipi->mipi_cal_cild_config_2);
+ value &= ~(MIPI_CAL_SEL(0x1));
+ writel(value, &priv->mipi->mipi_cal_cild_config_2);
+ }
+
+ /* Calibrate DSI-B */
+ if (calibration_pads == MIPI_DSIB_PADS) {
+ printf("Calibrating DSI-B pads\n");
+
+ value = MIPI_CAL_OVERIDE(0x0) | MIPI_CAL_SEL(0x1) |
+ MIPI_CAL_HSPDOS(0x0) | MIPI_CAL_HSPUOS(0x0) |
+ MIPI_CAL_TERMOS(0x0);
+ writel(value, &priv->mipi->mipi_cal_config_csic);
+ writel(value, &priv->mipi->mipi_cal_config_csid);
+
+ value = MIPI_CAL_SEL(0x1) |
+ MIPI_CAL_HSCLKPDOSDSI(0x1) |
+ MIPI_CAL_HSCLKPUOSDSI(0x2);
+ writel(value, &priv->mipi->mipi_cal_cilc_config_2);
+ writel(value, &priv->mipi->mipi_cal_cild_config_2);
+
+ /* Deselect PAD A */
+ value = readl(&priv->mipi->mipi_cal_dsia_config_2);
+ value &= ~(MIPI_CAL_SEL(0x1));
+ writel(value, &priv->mipi->mipi_cal_dsia_config_2);
+
+ /* Deselect PAD B */
+ value = readl(&priv->mipi->mipi_cal_dsib_config_2);
+ value &= ~(MIPI_CAL_SEL(0x1));
+ writel(value, &priv->mipi->mipi_cal_dsib_config_2);
+ }
+}
+
+static int tegra_mipi_calibrate(struct udevice *dev, int offset, const void *buf,
+ int size)
+{
+ struct tegra_mipi_priv *priv = dev_get_priv(dev);
+ u32 value;
+
+ value = MIPI_CAL_BIAS_PAD_DRV_DN_REF(0x2) |
+ MIPI_CAL_BIAS_PAD_DRV_UP_REF(0x0);
+ writel(value, &priv->mipi->mipi_cal_bias_pad_cfg1);
+
+ value = readl(&priv->mipi->mipi_cal_bias_pad_cfg2);
+ value &= ~MIPI_CAL_BIAS_PAD_VCLAMP(0x7);
+ value &= ~MIPI_CAL_BIAS_PAD_VAUXP(0x7);
+ writel(value, &priv->mipi->mipi_cal_bias_pad_cfg2);
+
+ switch (priv->version) {
+ case T114:
+ tegra114_mipi_pads_cal(priv, offset);
+ break;
+
+ case T124:
+ tegra124_mipi_pads_cal(priv, offset);
+ break;
+
+ default:
+ return -EINVAL;
+ }
value = readl(&priv->mipi->mipi_cal_ctrl);
value &= ~MIPI_CAL_CTRL_NOISE_FILTER(0xf);
@@ -134,6 +232,11 @@ static int tegra_mipi_enable(struct udevice *dev, bool val)
struct tegra_mipi_priv *priv = dev_get_priv(dev);
u32 value;
+ reset_set_enable(priv->mipi_cal->id, 1);
+ mdelay(100);
+ reset_set_enable(priv->mipi_cal->id, 0);
+ mdelay(1);
+
clk_enable(priv->mipi_cal);
value = readl(&priv->mipi->mipi_cal_bias_pad_cfg0);
@@ -157,6 +260,8 @@ static int tegra_mipi_probe(struct udevice *dev)
{
struct tegra_mipi_priv *priv = dev_get_priv(dev);
+ priv->version = dev_get_driver_data(dev);
+
priv->mipi = (struct mipi_ctlr *)dev_read_addr_ptr(dev);
if (!priv->mipi) {
log_debug("%s: no MIPI controller address\n", __func__);
@@ -174,7 +279,8 @@ static int tegra_mipi_probe(struct udevice *dev)
}
static const struct udevice_id tegra_mipi_ids[] = {
- { .compatible = "nvidia,tegra114-mipi" },
+ { .compatible = "nvidia,tegra114-mipi", .data = T114 },
+ { .compatible = "nvidia,tegra124-mipi", .data = T124 },
{ }
};