rockchip: video: convert display driver to live dt

Convert to live dt for kernel dtb, display driver will depends on
OF_LIVE after this patch.

Change-Id: I536e936d551c0320f30dca82c9cf376e77589ffc
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
Kever Yang 2018-02-06 21:31:18 +08:00
parent 3d29ee38ce
commit e2bce6e47e
17 changed files with 218 additions and 293 deletions

View File

@ -1,6 +1,6 @@
menuconfig DRM_ROCKCHIP
bool "Rockchip DRM Support"
depends on DM_VIDEO
depends on DM_VIDEO && OF_LIVE
help
Rockchip SoCs provide video output capabilities for High-Definition
Multimedia Interface (HDMI), Low-voltage Differential Signalling

View File

@ -5,12 +5,13 @@
*/
#include <common.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <malloc.h>
#include <syscon.h>
#include <asm/arch-rockchip/clock.h>
#include <edid.h>
#include <dm/device.h>
#include <dm/of_node.h>
#include <dm/read.h>
#include <linux/hdmi.h>
#include <linux/media-bus-format.h>
#include <linux/dw_hdmi.h>
@ -2087,7 +2088,7 @@ int rockchip_dw_hdmi_init(struct display_state *state)
struct crtc_state *crtc_state = &state->crtc_state;
struct dw_hdmi *hdmi;
struct drm_display_mode *mode_buf;
int hdmi_node = conn_state->node;
ofnode hdmi_node = conn_state->node;
u32 val;
hdmi = malloc(sizeof(struct dw_hdmi));
@ -2101,10 +2102,8 @@ int rockchip_dw_hdmi_init(struct display_state *state)
return -ENOMEM;
memset(mode_buf, 0, MODE_LEN * sizeof(struct drm_display_mode));
hdmi->regs = (void *)fdtdec_get_addr_size_auto_noparent(state->blob,
hdmi_node, "reg", 0, NULL, false);
hdmi->io_width = fdtdec_get_int(state->blob, hdmi_node,
"reg-io-width", -1);
hdmi->regs = dev_read_addr_ptr(conn_state->dev);
hdmi->io_width = ofnode_read_s32_default(hdmi_node, "reg-io-width", -1);
hdmi->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
if (hdmi->grf <= 0) {
printf("%s: Get syscon grf failed (ret=%p)\n",

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <linux/list.h>
#include <linux/media-bus-format.h>
@ -106,7 +104,7 @@ static int panel_simple_disable(struct display_state *state)
return 0;
}
static int panel_simple_parse_dt(const void *blob, int node,
static int panel_simple_parse_dt(const void *blob, ofnode node,
struct panel_simple *panel)
{
int ret;
@ -134,13 +132,13 @@ static int panel_simple_parse_dt(const void *blob, int node,
return ret;
}
panel->power_invert = !!fdtdec_get_int(blob, node, "power_invert", 0);
panel->power_invert = !!ofnode_read_s32_default(node, "power_invert", 0);
panel->delay_prepare = fdtdec_get_int(blob, node, "delay,prepare", 0);
panel->delay_unprepare = fdtdec_get_int(blob, node, "delay,unprepare", 0);
panel->delay_enable = fdtdec_get_int(blob, node, "delay,enable", 0);
panel->delay_disable = fdtdec_get_int(blob, node, "delay,disable", 0);
panel->bus_format = fdtdec_get_int(blob, node, "bus-format", MEDIA_BUS_FMT_RBG888_1X24);
panel->delay_prepare = ofnode_read_s32_default(node, "delay,prepare", 0);
panel->delay_unprepare = ofnode_read_s32_default(node, "delay,unprepare", 0);
panel->delay_enable = ofnode_read_s32_default(node, "delay,enable", 0);
panel->delay_disable = ofnode_read_s32_default(node, "delay,disable", 0);
panel->bus_format = ofnode_read_s32_default(node, "bus-format", MEDIA_BUS_FMT_RBG888_1X24);
printf("delay prepare[%d] unprepare[%d] enable[%d] disable[%d]\n",
panel->delay_prepare, panel->delay_unprepare,
@ -157,7 +155,7 @@ static int panel_simple_init(struct display_state *state)
const void *blob = state->blob;
struct connector_state *conn_state = &state->conn_state;
struct panel_state *panel_state = &state->panel_state;
int node = panel_state->node;
ofnode node = panel_state->node;
const struct drm_display_mode *mode = panel_state->panel->data;
struct panel_simple *panel;
int ret;

View File

@ -8,12 +8,12 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <asm/io.h>
#include <linux/list.h>
#include <dm/device.h>
#include <dm/read.h>
#include <dm/of_access.h>
#include <syscon.h>
#include <asm/arch-rockchip/clock.h>
@ -340,7 +340,7 @@ struct dw_mipi_dsi {
void *base;
void *grf;
const void *blob;
int node;
ofnode node;
/* dual-channel */
struct dw_mipi_dsi *master;
@ -531,7 +531,7 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
ret = readl_poll_timeout(dsi->base + DSI_PHY_STATUS,
val, val & LOCK, 1000, PHY_STATUS_TIMEOUT_US);
if (ret < 0) {
printf("failed to wait for phy lock state\n");
printf("failed to wait for phy lock state %p\n", dsi->base);
return ret;
}
@ -554,8 +554,7 @@ static unsigned long rockchip_dsi_calc_bandwidth(struct dw_mipi_dsi *dsi)
int rate;
/* optional override of the desired bandwidth */
rate = fdt_getprop_u32_default_node(dsi->blob, dsi->node, 0,
"rockchip,lane-rate", -1);
rate = ofnode_read_u32_default(dsi->node, "rockchip,lane-rate", -1);
if (rate > 0) {
return rate;
}
@ -955,21 +954,21 @@ static int dw_mipi_dsi_clk_enable(struct dw_mipi_dsi *dsi)
static int rockchip_dsi_dual_channel_probe(struct dw_mipi_dsi *master)
{
int node0, node1;
int phandle;
struct device_node *np;
struct dw_mipi_dsi *slave = NULL;
node0 = fdt_getprop_u32_default_node(master->blob, master->node, 0,
"rockchip,dual-channel", -1);
if (node0 < 0)
phandle = ofnode_read_u32_default(master->node, "rockchip,dual-channel", -1);
if (phandle < 0)
return 0;
node1 = fdt_node_offset_by_phandle(master->blob, node0);
if (node1 < 0) {
np = of_find_node_by_phandle(phandle);
if (ofnode_valid(np_to_ofnode(np))) {
printf("failed to find dsi slave node\n");
return -ENODEV;
}
if (!fdt_device_is_available(master->blob, node1)) {
if (!of_device_is_available(np)) {
printf("dsi slave node is not available\n");
return -ENODEV;
}
@ -985,10 +984,8 @@ static int rockchip_dsi_dual_channel_probe(struct dw_mipi_dsi *master)
slave->master = master;
slave->blob = master->blob;
slave->node = node1;
slave->base = (void *)fdtdec_get_addr_size_auto_noparent(slave->blob,
node1, "reg",
0, NULL, false);
slave->node = np_to_ofnode(np);
slave->base = (u32 *)ofnode_get_addr_index(slave->node, 0);
slave->pdata = master->pdata;
slave->dphy.phy = master->dphy.phy;
slave->lanes = master->lanes;
@ -1004,9 +1001,9 @@ static int rockchip_dw_mipi_dsi_init(struct display_state *state)
struct connector_state *conn_state = &state->conn_state;
const struct rockchip_connector *connector = conn_state->connector;
const struct dw_mipi_dsi_plat_data *pdata = connector->data;
int mipi_node = conn_state->node;
ofnode mipi_node = conn_state->node;
struct dw_mipi_dsi *dsi;
int panel;
ofnode panel;
int ret;
dsi = malloc(sizeof(*dsi));
@ -1014,9 +1011,7 @@ static int rockchip_dw_mipi_dsi_init(struct display_state *state)
return -ENOMEM;
memset(dsi, 0, sizeof(*dsi));
dsi->base = (void *)fdtdec_get_addr_size_auto_noparent(state->blob,
mipi_node, "reg", 0, NULL, false);
dsi->base = dev_read_addr_ptr(conn_state->dev);
dsi->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
if (dsi->grf <= 0) {
printf("%s: Get syscon grf failed (ret=%p)\n",
@ -1030,14 +1025,14 @@ static int rockchip_dw_mipi_dsi_init(struct display_state *state)
conn_state->private = dsi;
conn_state->output_mode = ROCKCHIP_OUT_MODE_P888;
panel = fdt_subnode_offset(state->blob, mipi_node, "panel");
if (panel < 0) {
panel = dev_read_subnode(conn_state->dev, "panel");
if (!ofnode_valid(panel)) {
printf("failed to find panel node\n");
return -1;
}
#define FDT_GET_INT(val, name) \
val = fdtdec_get_int(state->blob, panel, name, -1); \
val = ofnode_read_s32_default(panel, name, -1); \
if (val < 0) { \
printf("Can't get %s\n", name); \
return -1; \

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <asm/io.h>
#include <linux/list.h>
@ -125,7 +123,7 @@ struct inno_mipi_dphy_timing {
struct inno_mipi_dphy {
const void *blob;
int node;
ofnode node;
u32 regs;
unsigned int lane_mbps;
@ -507,7 +505,7 @@ static unsigned long inno_mipi_dphy_set_pll(struct display_state *state,
fin = 24000000;
fout = inno_mipi_dphy_pll_round_rate(fin, rate, &prediv, &fbdiv);
printf("%s: fin=%lu, fout=%lu, prediv=%u, fbdiv=%u\n",
debug("%s: fin=%lu, fout=%lu, prediv=%u, fbdiv=%u\n",
__func__, fin, fout, prediv, fbdiv);
m = FBDIV_HI_MASK | PREDIV_MASK;
@ -523,16 +521,15 @@ static unsigned long inno_mipi_dphy_set_pll(struct display_state *state,
return fout;
}
static int inno_mipi_dphy_parse_dt(int panel_node, struct inno_mipi_dphy *inno)
static int inno_mipi_dphy_parse_dt(ofnode panel_node, struct inno_mipi_dphy *inno)
{
const void *blob = inno->blob;
int format;
inno->lanes = fdtdec_get_int(blob, panel_node, "dsi,lanes", -1);
inno->lanes = ofnode_read_s32_default(panel_node, "dsi,lanes", -1);
if (inno->lanes < 0)
inno->lanes = 4;
format = fdtdec_get_int(blob, panel_node, "dsi,format", -1);
format = ofnode_read_s32_default(panel_node, "dsi,format", -1);
inno->bpp = mipi_dsi_pixel_format_to_bpp(format);
if (inno->bpp < 0)
inno->bpp = 24;
@ -545,8 +542,8 @@ static int inno_mipi_dphy_init(struct display_state *state)
const void *blob = state->blob;
struct connector_state *conn_state = &state->conn_state;
struct panel_state *panel_state = &state->panel_state;
int node = conn_state->phy_node;
int panel_node = panel_state->node;
ofnode node = conn_state->phy_node;
ofnode panel_node = panel_state->node;
struct inno_mipi_dphy *inno;
int ret;
@ -563,8 +560,7 @@ static int inno_mipi_dphy_init(struct display_state *state)
return ret;
}
inno->regs = fdtdec_get_addr_size_auto_noparent(blob, node, "reg",
0, NULL, false);
inno->regs = (u32)ofnode_get_addr(node);
if (inno->regs == FDT_ADDR_T_NONE) {
printf("%s: failed to get mipi phy address\n", __func__);
return -ENOMEM;

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <asm/io.h>
#include <dm/device.h>
@ -856,8 +854,7 @@ static int rockchip_analogix_dp_init(struct display_state *state)
plat_data = malloc(sizeof(*pdata));
if (!plat_data)
return -ENOMEM;
dp->reg_base = (void *)fdtdec_get_addr_size_auto_noparent(state->blob,
dp_node, "reg", 0, NULL, false);
dp->reg_base = dev_read_addr_ptr(conn_state->dev);
dp->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
if (dp->grf <= 0) {
printf("%s: Get syscon grf failed (ret=%p)\n",

View File

@ -15,8 +15,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <linux/list.h>
#include <dm/device.h>

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <linux/list.h>
#include <dm/device.h>

View File

@ -27,6 +27,9 @@
#include "rockchip_connector.h"
#include "rockchip_phy.h"
#include "rockchip_panel.h"
#include <dm.h>
#include <dm/of_access.h>
#include <dm/ofnode.h>
#define RK_BLK_SIZE 512
@ -71,68 +74,61 @@ static bool can_direct_logo(int bpp)
return bpp == 24 || bpp == 32;
}
static struct udevice *find_panel_device_by_node(const void *blob,
int panel_node)
{
struct udevice *dev;
int ret;
ret = uclass_find_device_by_of_offset(UCLASS_PANEL, panel_node, &dev);
if (ret) {
printf("Warn: %s: can't find panel driver\n",
fdt_get_name(blob, panel_node, NULL));
return NULL;
}
return dev;
}
static struct udevice *get_panel_device(struct display_state *state, int conn_node)
static struct udevice *get_panel_device(struct display_state *state, ofnode conn_node)
{
struct panel_state *panel_state = &state->panel_state;
const void *blob = state->blob;
int panel, ports, port, ep, remote, ph, nodedepth;
struct udevice *dev;
struct connector_state *conn_state = &state->conn_state;
ofnode node, ports_node, port_node;
struct device_node *port, *panel, *ep;
int ph;
int ret;
panel = fdt_subnode_offset(blob, conn_node, "panel");
if (panel > 0 && fdt_device_is_available(blob, panel)) {
dev = find_panel_device_by_node(blob, panel);
if (dev) {
panel_state->node = panel;
node = dev_read_subnode(conn_state->dev, "panel");
if (ofnode_valid(node) &&
of_device_is_available(ofnode_to_np(node))){
ret = uclass_get_device_by_ofnode(UCLASS_PANEL, node, &dev);
if(!ret) {
printf("%s get panel dev\n", __func__);
panel_state->node = node;
return dev;
}
}
ports = fdt_subnode_offset(blob, conn_node, "ports");
if (ports < 0)
/* TODO: this path not tested */
ports_node = dev_read_subnode(conn_state->dev, "ports");
if (!ofnode_valid(ports_node))
return NULL;
fdt_for_each_subnode(port, blob, ports) {
fdt_for_each_subnode(ep, blob, port) {
ph = fdt_getprop_u32_default_node(blob, ep, 0,
"remote-endpoint", 0);
ofnode_for_each_subnode(port_node, ports_node) {
ofnode_for_each_subnode(node, port_node) {
ph = ofnode_read_u32_default(node, "remote-endpoint", -1);
if (!ph)
continue;
remote = fdt_node_offset_by_phandle(blob, ph);
nodedepth = fdt_node_depth(blob, remote);
if (nodedepth < 2)
continue;
panel = fdt_supernode_atdepth_offset(blob, remote,
nodedepth - 2,
NULL);
if (!fdt_device_is_available(blob, panel)) {
debug("[%s]: panel is disabled\n",
fdt_get_name(blob, panel, NULL));
ep = of_find_node_by_phandle(ph);
if (!ofnode_valid(np_to_ofnode(ep))) {
printf("Warn: can't find endpoint from phdl\n");
continue;
}
dev = find_panel_device_by_node(blob, panel);
if (dev) {
panel_state->node = panel;
return dev;
port = of_get_parent(ep);
if (!ofnode_valid(np_to_ofnode(port))) {
printf("Warn: can't find port node\n");
continue;
}
panel = of_get_parent(port);
if (!ofnode_valid(np_to_ofnode(panel))) {
printf("Warn: can't find panel node\n");
continue;
}
ret = uclass_get_device_by_ofnode(UCLASS_PANEL,
np_to_ofnode(panel),
&dev);
if (ret) {
printf("Warn: can't find crtc driver\n");
continue;
}
return dev;
}
}
@ -142,28 +138,14 @@ static struct udevice *get_panel_device(struct display_state *state, int conn_no
static int connector_phy_init(struct display_state *state)
{
struct connector_state *conn_state = &state->conn_state;
int conn_node = conn_state->node;
const void *blob = state->blob;
const struct rockchip_phy *phy;
int phy_node, phandle;
struct udevice *dev;
int ret;
phandle = fdt_getprop_u32_default_node(blob, conn_node, 0,
"phys", -1);
if (phandle < 0)
return 0;
phy_node = fdt_node_offset_by_phandle(blob, phandle);
if (phy_node < 0) {
printf("failed to find phy node\n");
return phy_node;
}
ret = uclass_find_device_by_of_offset(UCLASS_PHY, phy_node, &dev);
ret = uclass_get_device_by_phandle(UCLASS_PHY, conn_state->dev, "phys",
&dev);
if (ret) {
printf("Warn: %s: can't find phy driver\n",
fdt_get_name(blob, phy_node, NULL));
printf("Warn: can't find phy driver\n");
return ret;
}
phy = (const struct rockchip_phy *)dev_get_driver_data(dev);
@ -173,7 +155,7 @@ static int connector_phy_init(struct display_state *state)
}
conn_state->phy_dev = dev;
conn_state->phy_node = phy_node;
conn_state->phy_node = dev->node;
if (!phy->funcs || !phy->funcs->init ||
phy->funcs->init(state)) {
@ -190,10 +172,9 @@ static int connector_panel_init(struct display_state *state)
struct connector_state *conn_state = &state->conn_state;
struct panel_state *panel_state = &state->panel_state;
struct udevice *dev;
const void *blob = state->blob;
int conn_node = conn_state->node;
ofnode conn_node = conn_state->node;
const struct rockchip_panel *panel;
int dsp_lut_node;
ofnode dsp_lut_node;
int ret, len;
dm_scan_fdt_dev(conn_state->dev);
@ -217,19 +198,22 @@ static int connector_panel_init(struct display_state *state)
printf("failed to init panel driver\n");
return ret;
}
dsp_lut_node = fdt_subnode_offset(blob, panel_state->node, "dsp-lut");
fdt_getprop(blob, dsp_lut_node, "gamma-lut", &len);
dsp_lut_node = dev_read_subnode(dev, "dsp-lut");
if (!ofnode_valid(dsp_lut_node)) {
printf("%s can not find dsp-lut node\n", __func__);
}
ofnode_get_property(dsp_lut_node, "gamma-lut", &len);
if (len > 0) {
conn_state->gamma.size = len / sizeof(u32);
conn_state->gamma.size = len / sizeof(u32);
conn_state->gamma.lut = malloc(len);
if (!conn_state->gamma.lut) {
printf("malloc gamma lut failed\n");
return -ENOMEM;
}
if (fdtdec_get_int_array(blob, dsp_lut_node, "gamma-lut",
conn_state->gamma.lut,
conn_state->gamma.size)) {
ret = ofnode_read_u32_array(dsp_lut_node, "gamma-lut",
conn_state->gamma.lut,
conn_state->gamma.size);
if (ret) {
printf("Cannot decode gamma_lut\n");
conn_state->gamma.lut = NULL;
return -EINVAL;
@ -266,32 +250,32 @@ int drm_mode_vrefresh(const struct drm_display_mode *mode)
return refresh;
}
static int display_get_timing_from_dts(int panel, const void *blob,
static int display_get_timing_from_dts(struct panel_state *panel_state,
struct drm_display_mode *mode)
{
int timing, phandle, native_mode;
int phandle;
int hactive, vactive, pixelclock;
int hfront_porch, hback_porch, hsync_len;
int vfront_porch, vback_porch, vsync_len;
int val, flags = 0;
ofnode timing, native_mode;
timing = fdt_subnode_offset(blob, panel, "display-timings");
if (timing < 0)
timing = dev_read_subnode(panel_state->dev, "display-timings");
if (!ofnode_valid(timing))
return -ENODEV;
native_mode = fdt_subnode_offset(blob, timing, "timing");
if (native_mode < 0) {
phandle = fdt_getprop_u32_default_node(blob, timing, 0,
"native-mode", -1);
native_mode = fdt_node_offset_by_phandle_node(blob, timing, phandle);
if (native_mode <= 0) {
native_mode = ofnode_find_subnode(timing, "timing");
if (!ofnode_valid(native_mode)) {
phandle = ofnode_read_u32_default(timing, "native-mode", -1);
native_mode = np_to_ofnode(of_find_node_by_phandle(phandle));
if (!ofnode_valid(native_mode)) {
printf("failed to get display timings from DT\n");
return -ENXIO;
}
}
#define FDT_GET_INT(val, name) \
val = fdtdec_get_int(blob, native_mode, name, -1); \
val = ofnode_read_s32_default(native_mode, name, -1); \
if (val < 0) { \
printf("Can't get %s\n", name); \
return -ENXIO; \
@ -334,11 +318,10 @@ static int display_get_timing(struct display_state *state)
const struct rockchip_connector_funcs *conn_funcs = conn->funcs;
struct drm_display_mode *mode = &conn_state->mode;
const struct drm_display_mode *m;
const void *blob = state->blob;
struct panel_state *panel_state = &state->panel_state;
int panel = panel_state->node;
ofnode panel = panel_state->node;
if (panel > 0 && !display_get_timing_from_dts(panel, blob, mode)) {
if (ofnode_valid(panel) && !display_get_timing_from_dts(panel_state, mode)) {
printf("Using display timing dts\n");
goto done;
}
@ -619,18 +602,17 @@ static int display_logo(struct display_state *state)
return 0;
}
static int get_crtc_id(const void *blob, int connect)
static int get_crtc_id(ofnode connect)
{
int phandle, remote;
int phandle;
struct device_node *remote;
int val;
phandle = fdt_getprop_u32_default_node(blob, connect, 0,
"remote-endpoint", -1);
phandle = ofnode_read_u32_default(connect, "remote-endpoint", -1);
if (phandle < 0)
goto err;
remote = fdt_node_offset_by_phandle(blob, phandle);
val = fdtdec_get_int(blob, remote, "reg", -1);
remote = of_find_node_by_phandle(phandle);
val = ofnode_read_u32_default(np_to_ofnode(remote), "reg", -1);
if (val < 0)
goto err;
@ -640,31 +622,6 @@ err:
return 0;
}
static int find_crtc_node(const void *blob, int node)
{
int nodedepth = fdt_node_depth(blob, node);
if (nodedepth < 2)
return -EINVAL;
return fdt_supernode_atdepth_offset(blob, node,
nodedepth - 2, NULL);
}
static int find_connector_node(const void *blob, int node)
{
int phandle, remote;
int nodedepth;
phandle = fdt_getprop_u32_default_node(blob, node, 0,
"remote-endpoint", -1);
remote = fdt_node_offset_by_phandle(blob, phandle);
nodedepth = fdt_node_depth(blob, remote);
return fdt_supernode_atdepth_offset(blob, remote,
nodedepth - 3, NULL);
}
struct rockchip_logo_cache *find_or_alloc_logo_cache(const char *bmp)
{
struct rockchip_logo_cache *tmp, *logo_cache = NULL;
@ -841,73 +798,76 @@ static int rockchip_display_probe(struct udevice *dev)
struct video_priv *uc_priv = dev_get_uclass_priv(dev);
struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
const void *blob = gd->fdt_blob;
int route, child, phandle, connect, crtc_node, conn_node;
int phandle;
struct udevice *crtc_dev, *conn_dev;
const struct rockchip_crtc *crtc;
const struct rockchip_connector *conn;
struct display_state *s;
const char *name;
int ret;
ofnode node, route_node;
struct device_node *port_node, *vop_node, *ep_node;
struct device_node *cnt_node, *p;
/* Before relocation we don't need to do anything */
if (!(gd->flags & GD_FLG_RELOC))
return 0;
route = fdt_path_offset(blob, "/display-subsystem/route");
if (route < 0) {
printf("Can't find display display route node\n");
return -ENODEV;
}
if (!fdt_device_is_available(blob, route))
return -ENODEV;
init_display_buffer(plat->base);
fdt_for_each_subnode(child, blob, route) {
if (!fdt_device_is_available(blob, child))
continue;
route_node = dev_read_subnode(dev, "route");
if (!ofnode_valid(route_node))
return -ENODEV;
phandle = fdt_getprop_u32_default_node(blob, child, 0,
"connect", -1);
ofnode_for_each_subnode(node, route_node){
phandle = ofnode_read_u32_default(node, "connect", -1);
if (phandle < 0) {
printf("Warn: %s: can't find connect node's handle\n",
fdt_get_name(blob, child, NULL));
printf("Warn: can't find connect node's handle\n");
continue;
}
connect = fdt_node_offset_by_phandle(blob, phandle);
if (connect < 0) {
printf("Warn: %s: can't find connect node\n",
fdt_get_name(blob, child, NULL));
ep_node = of_find_node_by_phandle(phandle);
if (!ofnode_valid(np_to_ofnode(ep_node))) {
printf("Warn: can't find endpoint node from phandle\n");
continue;
}
crtc_node = find_crtc_node(blob, connect);
if (!fdt_device_is_available(blob, crtc_node)) {
printf("Warn: %s: crtc node is not available\n",
fdt_get_name(blob, child, NULL));
port_node = of_get_parent(ep_node);
if (!ofnode_valid(np_to_ofnode(port_node))) {
printf("Warn: can't find port node from phandle\n");
continue;
}
ret = uclass_find_device_by_of_offset(UCLASS_VIDEO_CRTC, crtc_node, &crtc_dev);
vop_node = of_get_parent(port_node);
if (!ofnode_valid(np_to_ofnode(vop_node))) {
printf("Warn: can't find crtc node from phandle\n");
continue;
}
ret = uclass_get_device_by_ofnode(UCLASS_VIDEO_CRTC,
np_to_ofnode(vop_node),
&crtc_dev);
if (ret) {
printf("Warn: %s: can't find crtc driver\n",
fdt_get_name(blob, child, NULL));
printf("Warn: can't find crtc driver\n");
continue;
}
crtc = (const struct rockchip_crtc *)dev_get_driver_data(crtc_dev);
conn_node = find_connector_node(blob, connect);
if (!fdt_device_is_available(blob, conn_node)) {
printf("Warn: %s: connector node is not available\n",
fdt_get_name(blob, child, NULL));
phandle = ofnode_read_u32_default(np_to_ofnode(ep_node),
"remote-endpoint", -1);
cnt_node = of_find_node_by_phandle(phandle);
if (phandle < 0) {
printf("Warn: can't find remote-endpoint's handle\n");
continue;
}
ret = uclass_get_device_by_of_offset(UCLASS_DISPLAY, conn_node, &conn_dev);
while (cnt_node->parent){
p = of_get_parent(cnt_node);
if (!strcmp(p->full_name, "/"))
break;
cnt_node = p;
}
if (!of_device_is_available(cnt_node))
continue;
ret = uclass_get_device_by_ofnode(UCLASS_DISPLAY,
np_to_ofnode(cnt_node),
&conn_dev);
if (ret) {
printf("Warn: %s: can't find connector driver\n",
fdt_get_name(blob, child, NULL));
printf("Warn: can't find connect driver\n");
continue;
}
conn = (const struct rockchip_connector *)dev_get_driver_data(conn_dev);
@ -919,43 +879,42 @@ static int rockchip_display_probe(struct udevice *dev)
memset(s, 0, sizeof(*s));
INIT_LIST_HEAD(&s->head);
s->ulogo_name = fdt_stringlist_get(blob, child, "logo,uboot", 0, NULL);
s->klogo_name = fdt_stringlist_get(blob, child, "logo,kernel", 0, NULL);
name = fdt_stringlist_get(blob, child, "logo,mode", 0, NULL);
ret = ofnode_read_string_index(node, "logo,uboot", 0, &s->ulogo_name);
ret = ofnode_read_string_index(node, "logo,kernel", 0, &s->klogo_name);
ret = ofnode_read_string_index(node, "logo,mode", 0, &name);
if (!strcmp(name, "fullscreen"))
s->logo_mode = ROCKCHIP_DISPLAY_FULLSCREEN;
else
s->logo_mode = ROCKCHIP_DISPLAY_CENTER;
name = fdt_stringlist_get(blob, child, "charge_logo,mode", 0, NULL);
ret = ofnode_read_string_index(node, "charge_logo,mode", 0, &name);
if (!strcmp(name, "fullscreen"))
s->charge_logo_mode = ROCKCHIP_DISPLAY_FULLSCREEN;
else
s->charge_logo_mode = ROCKCHIP_DISPLAY_CENTER;
s->blob = blob;
s->conn_state.node = conn_node;
s->conn_state.node = np_to_ofnode(cnt_node);
s->conn_state.dev = conn_dev;
s->conn_state.connector = conn;
s->crtc_state.node = crtc_node;
s->crtc_state.node = np_to_ofnode(vop_node);
s->crtc_state.dev = crtc_dev;
s->crtc_state.crtc = crtc;
s->crtc_state.crtc_id = get_crtc_id(blob, connect);
s->node = child;
s->crtc_state.crtc_id = get_crtc_id(np_to_ofnode(ep_node));
s->node = node;
if (connector_phy_init(s)) {
printf("Warn: %s: Failed to init phy drivers\n",
fdt_get_name(blob, child, NULL));
if (connector_panel_init(s)) {
printf("Warn: Failed to init panel drivers\n");
free(s);
continue;
}
if (connector_panel_init(s)) {
printf("Warn: %s: Failed to init panel drivers\n",
fdt_get_name(blob, child, NULL));
if (connector_phy_init(s)) {
printf("Warn: Failed to init phy drivers\n");
free(s);
continue;
}
list_add_tail(&s->head, &rockchip_display_list);
}
if (list_empty(&rockchip_display_list)) {

View File

@ -10,6 +10,7 @@
#include <bmp_layout.h>
#include <drm_modes.h>
#include <edid.h>
#include <dm/ofnode.h>
#define ROCKCHIP_OUTPUT_DSI_DUAL_CHANNEL BIT(0)
#define ROCKCHIP_OUTPUT_DSI_DUAL_LINK BIT(1)
@ -41,7 +42,7 @@ struct crtc_state {
struct udevice *dev;
const struct rockchip_crtc *crtc;
void *private;
int node;
ofnode node;
int crtc_id;
int format;
@ -61,8 +62,8 @@ struct crtc_state {
struct panel_state {
struct udevice *dev;
int node;
int dsp_lut_node;
ofnode node;
ofnode dsp_lut_node;
const struct rockchip_panel *panel;
void *private;
@ -73,8 +74,8 @@ struct connector_state {
const struct rockchip_connector *connector;
struct udevice *phy_dev;
const struct rockchip_phy *phy;
int node;
int phy_node;
ofnode node;
ofnode phy_node;
void *private;
void *phy_private;
@ -112,7 +113,7 @@ struct display_state {
struct list_head head;
const void *blob;
int node;
ofnode node;
struct crtc_state crtc_state;
struct connector_state conn_state;

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <linux/list.h>
#include <linux/media-bus-format.h>
@ -51,7 +49,7 @@ struct dsi_panel_cmds {
struct rockchip_dsi_panel {
struct udevice *dev;
const void *blob;
int node;
ofnode node;
int bus_format;
@ -72,7 +70,7 @@ struct rockchip_dsi_panel {
struct dsi_panel_cmds *off_cmds;
};
static int rockchip_dsi_panel_parse_cmds(const void *blob, int node,
static int rockchip_dsi_panel_parse_cmds(ofnode node,
const u8 *data, int blen,
struct dsi_panel_cmds *pcmds)
{
@ -263,27 +261,27 @@ static int rockchip_dsi_panel_disable(struct display_state *state)
return 0;
}
static int rockchip_dsi_panel_parse_dt(const void *blob, int node, struct rockchip_dsi_panel *panel)
static int rockchip_dsi_panel_parse_dt(ofnode node, struct rockchip_dsi_panel *panel)
{
const void *data;
int len = 0;
int ret = 0;
panel->delay_prepare = fdtdec_get_int(blob, node, "prepare-delay-ms", 0);
panel->delay_unprepare = fdtdec_get_int(blob, node, "unprepare-delay-ms", 0);
panel->delay_enable = fdtdec_get_int(blob, node, "enable-delay-ms", 0);
panel->delay_disable = fdtdec_get_int(blob, node, "disable-delay-ms", 0);
panel->delay_init = fdtdec_get_int(blob, node, "init-delay-ms", 0);
panel->delay_reset = fdtdec_get_int(blob, node, "reset-delay-ms", 0);
panel->bus_format = fdtdec_get_int(blob, node, "bus-format", MEDIA_BUS_FMT_RBG888_1X24);
panel->delay_prepare = ofnode_read_u32_default(node, "prepare-delay-ms", 0);
panel->delay_unprepare = ofnode_read_u32_default(node, "unprepare-delay-ms", 0);
panel->delay_enable = ofnode_read_u32_default(node, "enable-delay-ms", 0);
panel->delay_disable = ofnode_read_u32_default(node, "disable-delay-ms", 0);
panel->delay_init = ofnode_read_u32_default(node, "init-delay-ms", 0);
panel->delay_reset = ofnode_read_u32_default(node, "reset-delay-ms", 0);
panel->bus_format = ofnode_read_u32_default(node, "bus-format", MEDIA_BUS_FMT_RBG888_1X24);
data = fdt_getprop(blob, node, "panel-init-sequence", &len);
data = ofnode_get_property(node, "panel-init-sequence", &len);
if (data) {
panel->on_cmds = malloc(sizeof(*panel->on_cmds));
if (!panel->on_cmds)
return -ENOMEM;
ret = rockchip_dsi_panel_parse_cmds(blob, node, data, len,
ret = rockchip_dsi_panel_parse_cmds(node, data, len,
panel->on_cmds);
if (ret) {
printf("failed to parse panel init sequence\n");
@ -291,7 +289,7 @@ static int rockchip_dsi_panel_parse_dt(const void *blob, int node, struct rockch
}
}
data = fdt_getprop(blob, node, "panel-exit-sequence", &len);
data = ofnode_get_property(node, "panel-exit-sequence", &len);
if (data) {
panel->off_cmds = malloc(sizeof(*panel->off_cmds));
if (!panel->off_cmds) {
@ -299,7 +297,7 @@ static int rockchip_dsi_panel_parse_dt(const void *blob, int node, struct rockch
goto free_on_cmds;
}
ret = rockchip_dsi_panel_parse_cmds(blob, node, data, len,
ret = rockchip_dsi_panel_parse_cmds(node, data, len,
panel->off_cmds);
if (ret) {
printf("failed to parse panel exit sequence\n");
@ -338,7 +336,7 @@ static int rockchip_dsi_panel_parse_dt(const void *blob, int node, struct rockch
return ret;
}
panel->power_invert = !!fdtdec_get_int(blob, node, "power_invert", 0);
panel->power_invert = !!ofnode_read_u32_default(node, "power_invert", 0);
/* keep panel blank on init. */
dm_gpio_set_value(&panel->enable, 0);
@ -358,7 +356,7 @@ static int rockchip_dsi_panel_init(struct display_state *state)
const void *blob = state->blob;
struct connector_state *conn_state = &state->conn_state;
struct panel_state *panel_state = &state->panel_state;
int node = panel_state->node;
ofnode node = panel_state->node;
struct rockchip_dsi_panel *panel;
int ret;
@ -373,7 +371,7 @@ static int rockchip_dsi_panel_init(struct display_state *state)
panel->dev = panel_state->dev;
panel_state->private = panel;
ret = rockchip_dsi_panel_parse_dt(blob, node, panel);
ret = rockchip_dsi_panel_parse_dt(node, panel);
if (ret) {
printf("%s: failed to parse DT\n", __func__);
free(panel);

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <linux/list.h>
#include <asm/io.h>
@ -515,6 +513,7 @@ static int rockchip_lvds_init(struct display_state *state)
struct fdt_resource lvds_phy, lvds_ctrl;
struct panel_state *panel_state = &state->panel_state;
int panel_node = panel_state->node;
int ret;
lvds = malloc(sizeof(*lvds));
if (!lvds)
@ -522,19 +521,16 @@ static int rockchip_lvds_init(struct display_state *state)
lvds->pdata = pdata;
if (pdata->chip_type == RK3288_LVDS) {
lvds->regbase = (void *)fdtdec_get_addr_size_auto_noparent(state->blob,
lvds_node, "reg", 0, NULL, false);
lvds->regbase = dev_read_addr_ptr(conn_state->dev);
} else {
i = fdt_get_named_resource(state->blob, lvds_node, "reg", "reg-names",
"mipi_lvds_phy", &lvds_phy);
i = dev_read_resource_byname(conn_state->dev, "mipi_lvds_phy", &lvds_phy);
if (i) {
printf("can't get regs lvds_phy addresses!\n");
free(lvds);
return -ENOMEM;
}
i = fdt_get_named_resource(state->blob, lvds_node, "reg", "reg-names",
"mipi_lvds_ctl", &lvds_ctrl);
i = dev_read_resource_byname(conn_state->dev, "mipi_lvds_ctl", &lvds_ctrl);
if (i) {
printf("can't get regs lvds_ctrl addresses!\n");
free(lvds);
@ -544,7 +540,7 @@ static int rockchip_lvds_init(struct display_state *state)
lvds->regbase = (void *)lvds_phy.start;
lvds->ctrl_reg = (void *)lvds_ctrl.start;
}
printf("%s regbase %p\n", __func__, lvds->regbase);
lvds->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
if (lvds->grf <= 0) {
printf("%s: Get syscon grf failed (ret=%p)\n",
@ -552,8 +548,8 @@ static int rockchip_lvds_init(struct display_state *state)
return -ENXIO;
}
name = fdt_stringlist_get(state->blob, panel_node, "rockchip,output", 0, NULL);
if (!name)
ret = dev_read_string_index(panel_state->dev, "rockchip,output", 0, &name);
if (ret)
/* default set it as output rgb */
lvds->output = DISPLAY_OUTPUT_RGB;
else
@ -563,8 +559,8 @@ static int rockchip_lvds_init(struct display_state *state)
free(lvds);
return lvds->output;
}
name = fdt_stringlist_get(state->blob, panel_node, "rockchip,data-mapping", 0, NULL);
if (!name)
ret = dev_read_string_index(panel_state->dev, "rockchip,data-mapping", 0, &name);
if (ret)
/* default set it as format jeida */
lvds->format = LVDS_FORMAT_JEIDA;
else
@ -575,7 +571,7 @@ static int rockchip_lvds_init(struct display_state *state)
free(lvds);
return lvds->format;
}
width = fdtdec_get_int(state->blob, panel_node, "rockchip,data-width", 24);
width = ofnode_read_u32_default(panel_node, "rockchip,data-width", 24);
if (width == 24) {
lvds->format |= LVDS_24BIT;
} else if (width == 18) {

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <linux/list.h>

View File

@ -9,8 +9,6 @@
#include <common.h>
#include <errno.h>
#include <dm/device.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include "rockchip_display.h"
#include "rockchip_crtc.h"

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <dm/device.h>
#include <errno.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <linux/list.h>

View File

@ -17,6 +17,8 @@
#include <clk.h>
#include <asm/arch/clock.h>
#include <linux/err.h>
#include <dm/device.h>
#include <dm/read.h>
#include "rockchip_display.h"
#include "rockchip_crtc.h"
@ -33,7 +35,6 @@ static int rockchip_vop_init_gamma(struct vop *vop, struct display_state *state)
struct crtc_state *crtc_state = &state->crtc_state;
struct connector_state *conn_state = &state->conn_state;
u32 *lut = conn_state->gamma.lut;
int node = crtc_state->node;
fdt_size_t lut_size;
int i, lut_len;
u32 *lut_regs;
@ -41,14 +42,12 @@ static int rockchip_vop_init_gamma(struct vop *vop, struct display_state *state)
if (!conn_state->gamma.lut)
return 0;
i = fdt_stringlist_search(state->blob, node, "reg-names", "gamma_lut");
i = dev_read_stringlist_search(crtc_state->dev, "reg-names", "gamma_lut");
if (i < 0) {
printf("Warning: vop not support gamma\n");
return 0;
}
lut_regs = (u32 *)fdtdec_get_addr_size_auto_noparent(state->blob,
node, "reg", i,
&lut_size, false);
lut_regs = (u32 *)dev_read_addr_size(crtc_state->dev, "reg", &lut_size);
if (lut_regs == (u32 *)FDT_ADDR_T_NONE) {
printf("failed to get gamma lut register\n");
return 0;
@ -111,8 +110,7 @@ static int rockchip_vop_init(struct display_state *state)
memset(vop, 0, sizeof(*vop));
crtc_state->private = vop;
vop->regs = (void *)fdtdec_get_addr_size_auto_noparent(state->blob,
crtc_state->node, "reg", 0, NULL, false);
vop->regs = dev_read_addr_ptr(crtc_state->dev);
vop->regsbak = malloc(vop_data->reg_len);
vop->win = vop_data->win;
vop->win_offset = vop_data->win_offset;
@ -435,15 +433,15 @@ static int rockchip_vop_disable(struct display_state *state)
static int rockchip_vop_fixup_dts(struct display_state *state, void *blob)
{
#if 0
struct crtc_state *crtc_state = &state->crtc_state;
struct panel_state *pstate = &state->panel_state;
uint32_t phandle;
char path[100];
int ret, dsp_lut_node;
if (!pstate->dsp_lut_node)
if (!ofnode_valid(pstate->dsp_lut_node))
return 0;
ret = fdt_get_path(state->blob, pstate->dsp_lut_node, path, sizeof(path));
if (ret < 0) {
printf("failed to get dsp_lut path[%s], ret=%d\n",
@ -471,7 +469,7 @@ static int rockchip_vop_fixup_dts(struct display_state *state, void *blob)
}
do_fixup_by_path_u32(blob, path, "dsp-lut", phandle, 1);
#endif
return 0;
}

View File

@ -8,8 +8,6 @@
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <fdtdec.h>
#include <fdt_support.h>
#include <asm/unaligned.h>
#include <asm/io.h>
#include <linux/list.h>