aboutsummaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/bridge/tc358767.c
AgeCommit message (Collapse)AuthorFilesLines
2020-07-27drm/bridge: tc358767: add drm_panel_bridge supportSam Ravnborg1-35/+32
With the bridge operations implemented the last step to prepare this driver for a chained setup is the use of the bridge panel driver. The bridge panel driver is only used when a port@2 is present in the DT. So when the display driver requests a connector support both situations: - connector created by bridge panel driver - connector created by this driver And on top, support that the display driver creates the connector, which is the preferred setup. Note: the bridge panel will use the connector type from the panel. v3: - Fix wrong logic in connector creation (Laurent) v2: - Merge connector and drm_panel_bridge patches and fix so we do not create two connectors (Laurent) Signed-off-by: Sam Ravnborg <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Jonas Karlman <[email protected]> Cc: Jernej Skrabec <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-07-27drm/bridge: tc358767: add get_edid bridge operationSam Ravnborg1-16/+18
Prepare for chained bridge with the addition of get_edid support. v2: - Fixed handling of edid storage (Laurent) Signed-off-by: Sam Ravnborg <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Jonas Karlman <[email protected]> Cc: Jernej Skrabec <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-07-27drm/bridge: tc358767: add detect bridge operationSam Ravnborg1-10/+20
Prepare the bridge driver for chained operation by adding support for the detect operation. v3: - Fix code to make it readable (Laurent) v2: - Do not announce detect operation if there is no hpd pin (Laurent) Signed-off-by: Sam Ravnborg <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Jonas Karlman <[email protected]> Cc: Jernej Skrabec <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-06-23drm: bridge: Pass drm_display_info to drm_bridge_funcs .mode_valid()Laurent Pinchart1-0/+1
When validating a mode, bridges may need to do so in the context of a display, as specified by drm_display_info. An example is the meson dw-hdmi bridge that needs to consider the YUV 4:2:0 output format to perform clock calculations. Bridges that need the display info currently retrieve it from the drm_connector created by the bridge. This gets in the way of moving connector creation out of bridge drivers. To make this possible, pass the drm_display_info to drm_bridge_funcs .mode_valid(). Changes to the bridge drivers have been performed with the following coccinelle semantic patch and have been compile-tested. @ rule1 @ identifier funcs; identifier fn; @@ struct drm_bridge_funcs funcs = { ..., .mode_valid = fn }; @ depends on rule1 @ identifier rule1.fn; identifier bridge; identifier mode; @@ enum drm_mode_status fn( struct drm_bridge *bridge, + const struct drm_display_info *info, const struct drm_display_mode *mode ) { ... } Signed-off-by: Laurent Pinchart <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Reviewed-by: Guido Günther <[email protected]> # for the nwl-dsi part: Signed-off-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20200526011505.31884-11-laurent.pinchart+renesas@ideasonboard.com
2020-03-11Merge v5.6-rc5 into drm-nextDave Airlie1-4/+4
Requested my mripard for some misc patches that need this as a base. Signed-off-by: Dave Airlie <[email protected]>
2020-02-26drm/bridge: Extend bridge API to disable connector creationLaurent Pinchart1-1/+8
Most bridge drivers create a DRM connector to model the connector at the output of the bridge. This model is historical and has worked pretty well so far, but causes several issues: - It prevents supporting more complex display pipelines where DRM connector operations are split over multiple components. For instance a pipeline with a bridge connected to the DDC signals to read EDID data, and another one connected to the HPD signal to detect connection and disconnection, will not be possible to support through this model. - It requires every bridge driver to implement similar connector handling code, resulting in code duplication. - It assumes that a bridge will either be wired to a connector or to another bridge, but doesn't support bridges that can be used in both positions very well (although there is some ad-hoc support for this in the analogix_dp bridge driver). In order to solve these issues, ownership of the connector should be moved to the display controller driver (where it can be implemented using helpers provided by the core). Extend the bridge API to allow disabling connector creation in bridge drivers as a first step towards the new model. The new flags argument to the bridge .attach() operation allows instructing the bridge driver to skip creating a connector. Unconditionally set the new flags argument to 0 for now to keep the existing behaviour, and modify all existing bridge drivers to return an error when connector creation is not requested as they don't support this feature yet. The change is based on the following semantic patch, with manual review and edits. @ rule1 @ identifier funcs; identifier fn; @@ struct drm_bridge_funcs funcs = { ..., .attach = fn }; @ depends on rule1 @ identifier rule1.fn; identifier bridge; statement S, S1; @@ int fn( struct drm_bridge *bridge + , enum drm_bridge_attach_flags flags ) { ... when != S + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) { + DRM_ERROR("Fix bridge driver to make connector optional!"); + return -EINVAL; + } + S1 ... } @ depends on rule1 @ identifier rule1.fn; identifier bridge, flags; expression E1, E2, E3; @@ int fn( struct drm_bridge *bridge, enum drm_bridge_attach_flags flags ) { <... drm_bridge_attach(E1, E2, E3 + , flags ) ...> } @@ expression E1, E2, E3; @@ drm_bridge_attach(E1, E2, E3 + , 0 ) Signed-off-by: Laurent Pinchart <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Tested-by: Sebastian Reichel <[email protected]> Reviewed-by: Sebastian Reichel <[email protected]> Acked-by: Daniel Vetter <[email protected]> Signed-off-by: Tomi Valkeinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2020-02-12Merge v5.6-rc1 into drm-misc-fixesMaarten Lankhorst1-1/+1
We're based on v5.6, need v5.6-rc1 at least. :) Signed-off-by: Maarten Lankhorst <[email protected]>
2020-02-10drm/bridge: tc358767: fix poll timeoutsTomi Valkeinen1-4/+4
Link training fails with: Link training timeout waiting for LT_LOOPDONE! main link enable error: -110 This is caused by too tight timeouts, which were changed recently in aa92213f388b ("drm/bridge: tc358767: Simplify polling in tc_link_training()"). With a quick glance, the commit does not change the timeouts. However, the method of delaying/sleeping is different, and as the timeout in the previous implementation was not explicit, the new version in practice has much tighter timeout. The same change was made to other parts in the driver, but the link training timeout is the only one I have seen causing issues. Nevertheless, 1 us sleep is not very sane, and the timeouts look pretty tight, so lets fix all the timeouts. One exception was the aux busy poll, where the poll sleep was much longer than necessary (or optimal). I measured the times on my setup, and now the sleep times are set to such values that they result in multiple loops, but not too many (say, 5-10 loops). The timeouts were all increased to 100ms, which should be more than enough for all of these, but in case of bad errors, shouldn't stop the driver as multi-second timeouts could do. Signed-off-by: Tomi Valkeinen <[email protected]> Fixes: aa92213f388b ("drm/bridge: tc358767: Simplify polling in tc_link_training()") Tested-by: Andrey Smirnov <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-12-09drm/panel: decouple connector from drm_panelSam Ravnborg1-1/+1
To facilitate moving connector creation to display drivers, decouple the drm_connector from drm_panel. This patch adds a connector argument to drm_panel_get_modes(). All users of drm_panel_get_modes() already had the connector available, so updating users was trivial. With this patch drm_panel no longer keeps a reference to the drm_connector. Signed-off-by: Sam Ravnborg <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Acked-by: Jeffrey Hugo <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Jonas Karlman <[email protected]> Cc: Jernej Skrabec <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Inki Dae <[email protected]> Cc: Joonyoung Shim <[email protected]> Cc: Seung-Woo Kim <[email protected]> Cc: Kyungmin Park <[email protected]> Cc: Kukjin Kim <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Cc: Stefan Agner <[email protected]> Cc: Alison Wang <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Pengutronix Kernel Team <[email protected]> Cc: Fabio Estevam <[email protected]> Cc: NXP Linux Team <[email protected]> Cc: CK Hu <[email protected]> Cc: Matthias Brugger <[email protected]> Cc: Marek Vasut <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Kieran Bingham <[email protected]> Cc: Sandy Huang <[email protected]> Cc: "Heiko Stübner" <[email protected]> Cc: Benjamin Gaignard <[email protected]> Cc: Vincent Abriou <[email protected]> Cc: Chen-Yu Tsai <[email protected]> Cc: Jonathan Hunter <[email protected]> Cc: Torsten Duwe <[email protected]> Cc: Vasily Khoruzhick <[email protected]> Cc: Icenowy Zheng <[email protected]> Cc: Sean Paul <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Boris Brezillon <[email protected]> Cc: Hariprasad Kelam <[email protected]> Cc: Alexios Zavras <[email protected]> Cc: Brian Masney <[email protected]> Cc: Rob Clark <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Allison Randal <[email protected]> Cc: Shayenne Moura <[email protected]> Cc: Abhinav Kumar <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-10-23drm/bridge: tc358767: Use DP nomenclatureThierry Reding1-1/+1
The DP specification uses the term "default framing" instead of "non- enhanced framing". Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Thierry Reding <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-10-23drm/bridge: tc358767: Avoid drm_dp_link helpersThierry Reding1-22/+41
During the discussion of patches that enhance the drm_dp_link helpers it was concluded that these helpers aren't very useful to begin with. Start pushing the equivalent code into individual drivers to ultimately remove them. v3: make link rate unsigned int to avoid overflow Signed-off-by: Thierry Reding <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-10-23Merge v5.4-rc4 into drm-nextDaniel Vetter1-1/+6
Thierry needs fd70c7755bf0 ("drm/bridge: tc358767: fix max_tu_symbol value") to be able to merge his dp_link patch series. Some adjacent changes conflicts, plus some clashes in i915 due to cherry-picking and git trying to be helpful and leaving both versions in. Signed-off-by: Daniel Vetter <[email protected]>
2019-10-10drm/bridge: tc358767: fix max_tu_symbol valueTomi Valkeinen1-1/+6
max_tu_symbol was programmed to TU_SIZE_RECOMMENDED - 1, which is not what the spec says. The spec says: roundup ((input active video bandwidth in bytes/output active video bandwidth in bytes) * tu_size) It is not quite clear what the above means, but calculating max_tu_symbol = (input Bps / output Bps) * tu_size seems to work and fixes the issues seen. This fixes artifacts in some videomodes (e.g. 1024x768@60 on 2-lanes & 1.62Gbps was pretty bad for me). Signed-off-by: Tomi Valkeinen <[email protected]> Tested-by: Jyri Sarha <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-08-28drm: Stop including drm_bridge.h from drm_crtc.hBoris Brezillon1-0/+1
We are about to add a drm_bridge_state that inherits from drm_private_state which is defined in drm_atomic.h. Problem is, drm_atomic.h includes drm_crtc.h which in turn includes drm_bridge.h, leading to "drm_private_state has incomplete type" error. Let's force all users of the drm_bridge API to explicitly include drm_bridge.h. Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Sam Ravnborg <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-08-10drm/bridge: tc358767: fix opencoded use of drm_panel_*Sam Ravnborg1-6/+4
Replace open coded version with call to drm_panel_get_modes(). Include change to deal with the possible negative return values from drm_panel_get_modes() v2: - Added more info to changelog (Philipp) Signed-off-by: Sam Ravnborg <[email protected]> Reviewed-by: Philipp Zabel <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Jonas Karlman <[email protected]> Cc: Jernej Skrabec <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-07-01drm/bridge: tc358767: do a software reset if reset pin isn't connectedLucas Stach1-0/+23
To get the chip into the expected state, even when the hardware reset pin isn't connected, do a software reset in this case. It isn't as thorough as the hardware reset, as the I2C communication block can not be reset for obvious reasons, but it's getting the chip into a defined state. Signed-off-by: Lucas Stach <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Add support for address-only I2C transfersAndrey Smirnov1-11/+31
Transfer size of zero means a request to do an address-only transfer. Since the HW support this, we probably shouldn't be just ignoring such requests. While at it allow DP_AUX_I2C_MOT flag to pass through, since it is supported by the HW as well. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Replace magic number in tc_main_link_enable()Andrey Smirnov1-1/+1
We don't need 8 byte array, DP_LINK_STATUS_SIZE (6) should be enough. This also gets rid of a magic number as a bonus. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Drop unnecessary 8 byte bufferAndrey Smirnov1-7/+6
tc_get_display_props() never reads more than a byte via AUX, so there's no need to reserve 8 for that purpose. No function change intended. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Simplify tc_aux_wait_busy()Andrey Smirnov1-5/+4
We never pass anything but 100 as timeout_ms to tc_aux_wait_busy(), so we may as well hardcode that value and simplify function's signature. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Introduce tc_pllupdate()Andrey Smirnov1-16/+14
tc_wait_pll_lock() is always called as a follow-up for updating PLLUPDATE and PLLEN bit of a given PLL control register. To simplify things, merge the two operation into a single helper function tc_pllupdate() and convert the rest of the code to use it. No functional change intended. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Introduce tc_set_syspllparam()Andrey Smirnov1-30/+16
Move common code converting clock rate to an appropriate constant and configuring SYS_PLLPARAM register into a separate routine and convert the rest of the code to use it. No functional change intended. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Chris Healy <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Use reported AUX transfer sizeAndrey Smirnov1-28/+12
Don't assume that requested data transfer size is the same as amount of data that was transferred. Change the code to get that information from DP0_AUXSTATUS instead. Since the check for AUX_BUSY in tc_aux_get_status() is pointless (it will always called after tc_aux_wait_busy()) and there's only one user of it, inline its code into tc_aux_transfer() instead of trying to accommodate the change above. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Increase AUX transfer length limitAndrey Smirnov1-1/+1
According to the datasheet tc358767 can transfer up to 16 bytes via its AUX channel, so the artificial limit of 8 appears to be too low. However only up to 15-bytes seem to be actually supported and trying to use 16-byte transfers results in transfers failing sporadically (with bogus status in case of I2C transfers), so limit it to 15. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Simplify AUX data writeAndrey Smirnov1-22/+26
Simplify AUX data write by dropping index arithmetic and shifting and replacing it with a call to a helper function that does two things: 1. Copies user-provided data into a write buffer 2. Transfers contents of the write buffer to up to 4 32-bit registers on the chip Note that separate data endianness fix: tmp = (tmp << 8) | buf[i]; that was reserved for DP_AUX_I2C_WRITE looks really strange, since it will place data differently depending on the passed user-data size. E.g. for a write of 1 byte, data transferred to the chip would look like: [byte0] [dummy1] [dummy2] [dummy3] whereas for a write of 4 bytes we'd get: [byte3] [byte2] [byte1] [byte0] Since there's no indication in the datasheet that I2C write buffer should be treated differently than AUX write buffer and no comment in the original code explaining why it was done this way, that special I2C write buffer transformation was dropped in this patch. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Simplify AUX data readAndrey Smirnov1-13/+18
Simplify AUX data read by removing index arithmetic and shifting with a helper function that does two things: 1. Fetch data from up to 4 32-bit registers from the chip 2. Copy read data into user provided array. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Drop custom tc_write()/tc_read() accessorsAndrey Smirnov1-152/+230
A very unfortunate aspect of tc_write()/tc_read() macro helpers is that they capture quite a bit of context around them and thus require the caller to have magic variables 'ret' and 'tc' as well as label 'err'. That makes a number of code paths rather counter-intuitive and somewhat clunky, for example tc_stream_clock_calc() ends up being like this: int ret; tc_write(DP0_VIDMNGEN1, 32768); return 0; err: return ret; which is rather surprising when you read the code for the first time. Since those helpers arguably aren't really saving that much code and there's no way of fixing them without making them too verbose to be worth it change the driver code to not use them at all. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Simplify tc_set_video_mode()Andrey Smirnov1-28/+78
Simplify tc_set_video_mode() by replacing explicit shifting using macros from <linux/bitfield.h>. No functional change intended. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Simplify polling in tc_link_training()Andrey Smirnov1-9/+6
Replace explicit polling in tc_link_training() with equivalent call to tc_poll_timeout() for simplicity. No functional change intended (not including slightly altered debug output). Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Simplify polling in tc_main_link_setup()Andrey Smirnov1-9/+3
Replace explicit polling loop with equivalent call to tc_poll_timeout() for brevity. No functional change intended. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-27drm/bridge: tc358767: Simplify tc_poll_timeout()Andrey Smirnov1-20/+6
Implementation of tc_poll_timeout() is almost a 100% copy-and-paste of the code for regmap_read_poll_timeout(). Replace copied code with a call to the original. While at it change tc_poll_timeout to accept "struct tc_data *" instead of "struct regmap *" for brevity. No functional change intended. Signed-off-by: Andrey Smirnov <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Cc: Andrzej Hajda <[email protected]> Cc: Laurent Pinchart <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Andrey Gusakov <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Cory Tusar <[email protected]> Cc: Chris Healy <[email protected]> Cc: Lucas Stach <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-06-19Merge v5.2-rc5 into drm-nextDaniel Vetter1-10/+1
Maarten needs -rc4 backmerged so he can pull in the fbcon notifier removal topic branch into drm-misc-next. Signed-off-by: Daniel Vetter <[email protected]>
2019-05-31drm/bridge: tc358767: add IRQ and HPD supportTomi Valkeinen1-18/+145
Add support for interrupt and hotplug handling. Both are optional. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: add GPIO & interrupt registersTomi Valkeinen1-0/+8
Add GPIO and interrupt related registers for HPD work. Mark INTSTS_G and GPIOI as volatile. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: read display_props in get_modes()Tomi Valkeinen1-0/+7
We need to know the link bandwidth to filter out modes we cannot support, so we need to have read the display props before doing the filtering. To ensure we have up to date display props, call tc_get_display_props() in the beginning of tc_connector_get_modes(). Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: copy the mode data, instead of storing the pointerTomi Valkeinen1-4/+4
In tc_bridge_mode_set callback, we store the pointer to the given drm_display_mode, and use the mode later. Storing a pointer in such a way looks very suspicious to me, and I have observed odd issues where the timings were apparently (at least mostly) zero. Do a copy of the drm_display_mode instead to ensure we don't refer to freed/modified data. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: remove tc_connector_best_encoderTomi Valkeinen1-9/+0
drm_connector_helper_funcs.best_encoder is only needed when the connector can have more than one encoder, and that is never the case here. So remove tc_connector_best_encoder. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: use bridge mode_validTomi Valkeinen1-4/+4
We have tc_connector_mode_valid() to filter out videomdoes that the tc358767 cannot support. As it is a bridge limitation, change the code to use drm_bridge_funcs's mode_valid instead. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: remove check for video mode in link enableTomi Valkeinen1-4/+0
tc_main_link_enable() checks if videomode has been set, and fails if there's no videomode. As tc_main_link_enable() no longer depends on the videomode, we can drop the check. Also, while tc_stream_enable() does depend on the videomode, we can expect that a mode has been set before drm_bridge_funcs.enable is called, so we don't need the check there either. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: clean-up link trainingTomi Valkeinen1-76/+60
The current link training code does unnecessary retry-loops, and does extra writes to the registers. It is easier to follow the flow and ensure it's similar to Toshiba's documentation if we deal with LT inside tc_main_link_enable() function. This patch adds tc_wait_link_training() which handles waiting for the LT phase to finish, and does the necessary LT register setups in tc_main_link_enable, without extra loops. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: cleanup LT result checkTomi Valkeinen1-27/+35
The driver has a loop after ending link training, where it reads the DPCD link status and prints an error if that status is not ok. The loop is unnecessary, as far as I can understand from DP specs, so let's remove it. We can also print the more specific errors to help debugging. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: use more reliable seq when finishing LTTomi Valkeinen1-3/+12
At the end of the link training, two steps have to be taken: 1) tc358767's LT mode is disabled by a write to DP0_SRCCTRL, and 2) Remove LT flag in DPCD 0x102. Toshiba's documentation tells to first write the DPCD, then modify DP0_SRCCTRL. In my testing this often causes issues, and the link disconnects right after those steps. If I reverse the steps, it works every time. There's a chance that this is DP sink specific, though, but as my testing shows this sequence to be much more reliable, let's change it. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: remove unnecessary msleepTomi Valkeinen1-1/+0
For some reason the driver has a msleep(100) after writing to DP_PHY_CTRL. Toshiba's documentation doesn't suggest any delay is needed, and I have not seen any issues with the sleep removed. Drop it, as msleep(100) is a rather big one. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Andrey Gusakov <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: ensure DP is disabled before LTTomi Valkeinen1-0/+4
Link training will sometimes fail if the DP link is enabled when tc_main_link_enable() is called. The driver makes sure the DP link is disabled when the DP output is disabled, and we never enable the DP without first disabling it, so this should never happen. However, as the HW behavior seems to be somewhat random if DP link has erroneously been left enabled, let's add a WARN_ON() for the case and set DP0CTL to 0. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: disable only video stream in tc_stream_disableTomi Valkeinen1-1/+4
Currently the code writes 0 to DP0CTL in tc_stream_disable(), which disables the whole DP link instead of just the video stream. We always disable the link and the stream together from tc_bridge_disable(), so this doesn't cause any issues. Nevertheless, fix this by only clearing VID_EN in tc_stream_disable to stop the video stream while keeping the link enabled. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: add link disable functionTomi Valkeinen1-3/+24
Currently we have tc_main_link_setup(), which configures and enabled the link, but we have no counter-part for disabling the link. Add tc_main_link_disable, and rename tc_main_link_setup to tc_main_link_enable. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: move PXL PLL enable/disable to stream enable/disableTomi Valkeinen1-10/+10
We set up the PXL PLL inside tc_main_link_setup. This is unnecessary, and makes tc_main_link_setup depend on the video-mode, which should not be the case. As PXL PLL is used only for the video stream (and only when using the HW test pattern), let's move the PXL PLL setup into tc_stream_enable. Also, currently the PXL PLL is only disabled if the driver if removed. Let's disable the PXL PLL when the stream is disabled. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: split stream enable/disableTomi Valkeinen1-36/+45
It is nicer to have enable/disable functions instead of set(bool enable) style function. Split tc_main_link_stream into tc_stream_enable and tc_stream_disable. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: move video stream setup to tc_main_link_streamTomi Valkeinen1-9/+9
The driver currently sets the video stream registers in tc_main_link_setup. One should be able to establish the DP link without any video stream, so a more logical place is to configure the stream in the tc_main_link_stream. So move them there. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2019-05-31drm/bridge: tc358767: cleanup aux_link_setupTomi Valkeinen1-6/+3
The driver sets up AUX link at probe time, but, for some reason, also sets the main link's number of lanes using tc->link.base.num_lanes. This is not needed nor correct, as the number of lanes has not been decided yet. The number of lanes will be set later during main link setup. Modify aux_link_setup so that it does not use tc->link, and thus makes aux setup independent of the link probing. Signed-off-by: Tomi Valkeinen <[email protected]> Reviewed-by: Andrzej Hajda <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Andrzej Hajda <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]