Message ID | 20220607190131.1647511-8-pmalani@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | usb: typec: Introduce typec-switch binding | expand |
Hi Prashant, Thank you for the patch! Yet something to improve: [auto build test ERROR on drm/drm-next] [also build test ERROR on usb/usb-testing v5.19-rc1 next-20220608] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Prashant-Malani/usb-typec-Introduce-typec-switch-binding/20220608-042545 base: git://anongit.freedesktop.org/drm/drm drm-next config: nios2-buildonly-randconfig-r006-20220608 (https://download.01.org/0day-ci/archive/20220609/202206090842.UVDwwfxx-lkp@intel.com/config) compiler: nios2-linux-gcc (GCC) 11.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/49c4c89ed5b50cbd623e611c8f4eba4b5ca9dd02 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Prashant-Malani/usb-typec-Introduce-typec-switch-binding/20220608-042545 git checkout 49c4c89ed5b50cbd623e611c8f4eba4b5ca9dd02 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/gpu/drm/bridge/analogix/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): In file included from drivers/gpu/drm/bridge/analogix/anx7625.c:19: include/linux/usb/typec_mux.h:83:19: warning: no previous prototype for 'fwnode_typec_mux_get' [-Wmissing-prototypes] 83 | struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode, | ^~~~~~~~~~~~~~~~~~~~ include/linux/usb/typec_mux.h:89:6: warning: no previous prototype for 'typec_mux_put' [-Wmissing-prototypes] 89 | void typec_mux_put(struct typec_mux *mux) {} | ^~~~~~~~~~~~~ include/linux/usb/typec_mux.h:91:5: warning: no previous prototype for 'typec_mux_set' [-Wmissing-prototypes] 91 | int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state) | ^~~~~~~~~~~~~ include/linux/usb/typec_mux.h:103:1: warning: no previous prototype for 'typec_mux_register' [-Wmissing-prototypes] 103 | typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) | ^~~~~~~~~~~~~~~~~~ include/linux/usb/typec_mux.h:107:6: warning: no previous prototype for 'typec_mux_unregister' [-Wmissing-prototypes] 107 | void typec_mux_unregister(struct typec_mux *mux) {} | ^~~~~~~~~~~~~~~~~~~~ include/linux/usb/typec_mux.h:109:6: warning: no previous prototype for 'typec_mux_set_drvdata' [-Wmissing-prototypes] 109 | void typec_mux_set_drvdata(struct typec_mux *mux, void *data) {} | ^~~~~~~~~~~~~~~~~~~~~ include/linux/usb/typec_mux.h:110:7: warning: no previous prototype for 'typec_mux_get_drvdata' [-Wmissing-prototypes] 110 | void *typec_mux_get_drvdata(struct typec_mux *mux) | ^~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/bridge/analogix/anx7625.c: In function 'anx7625_typec_mux_set': >> drivers/gpu/drm/bridge/analogix/anx7625.c:2616:64: error: passing argument 1 of 'typec_mux_get_drvdata' from incompatible pointer type [-Werror=incompatible-pointer-types] 2616 | struct anx7625_port_data *data = typec_mux_get_drvdata(mux); | ^~~ | | | struct typec_mux_dev * In file included from drivers/gpu/drm/bridge/analogix/anx7625.c:19: include/linux/usb/typec_mux.h:110:47: note: expected 'struct typec_mux *' but argument is of type 'struct typec_mux_dev *' 110 | void *typec_mux_get_drvdata(struct typec_mux *mux) | ~~~~~~~~~~~~~~~~~~^~~ drivers/gpu/drm/bridge/analogix/anx7625.c: In function 'anx7625_register_mode_switch': drivers/gpu/drm/bridge/analogix/anx7625.c:2675:30: error: assignment to 'struct typec_mux_dev *' from incompatible pointer type 'struct typec_mux *' [-Werror=incompatible-pointer-types] 2675 | port_data->typec_mux = typec_mux_register(dev, &mux_desc); | ^ drivers/gpu/drm/bridge/analogix/anx7625.c: In function 'anx7625_unregister_typec_switches': drivers/gpu/drm/bridge/analogix/anx7625.c:2689:57: error: passing argument 1 of 'typec_mux_unregister' from incompatible pointer type [-Werror=incompatible-pointer-types] 2689 | typec_mux_unregister(ctx->typec_ports[i].typec_mux); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ | | | struct typec_mux_dev * In file included from drivers/gpu/drm/bridge/analogix/anx7625.c:19: include/linux/usb/typec_mux.h:107:45: note: expected 'struct typec_mux *' but argument is of type 'struct typec_mux_dev *' 107 | void typec_mux_unregister(struct typec_mux *mux) {} | ~~~~~~~~~~~~~~~~~~^~~ cc1: some warnings being treated as errors vim +/typec_mux_get_drvdata +2616 drivers/gpu/drm/bridge/analogix/anx7625.c 2612 2613 static int anx7625_typec_mux_set(struct typec_mux_dev *mux, 2614 struct typec_mux_state *state) 2615 { > 2616 struct anx7625_port_data *data = typec_mux_get_drvdata(mux); 2617 struct anx7625_data *ctx = data->ctx; 2618 struct device *dev = &ctx->client->dev; 2619 2620 bool old_dp_connected = (ctx->typec_ports[0].dp_connected || 2621 ctx->typec_ports[1].dp_connected); 2622 bool new_dp_connected; 2623 2624 if (ctx->num_typec_switches == 1) 2625 return 0; 2626 2627 dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n", 2628 ctx->typec_ports[0].dp_connected, ctx->typec_ports[1].dp_connected); 2629 2630 data->dp_connected = (state->alt && state->alt->svid == USB_TYPEC_DP_SID && 2631 state->alt->mode == USB_TYPEC_DP_MODE); 2632 2633 new_dp_connected = (ctx->typec_ports[0].dp_connected || 2634 ctx->typec_ports[1].dp_connected); 2635 2636 /* dp on, power on first */ 2637 if (!old_dp_connected && new_dp_connected) 2638 pm_runtime_get_sync(dev); 2639 2640 anx7625_typec_two_ports_update(ctx); 2641 2642 /* dp off, power off last */ 2643 if (old_dp_connected && !new_dp_connected) 2644 pm_runtime_put_sync(dev); 2645 2646 return 0; 2647 } 2648
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index d41a21103bd3..2c308d12fab2 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -15,6 +15,7 @@ #include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/usb/typec_dp.h> #include <linux/usb/typec_mux.h> #include <linux/workqueue.h> @@ -2582,9 +2583,66 @@ static void anx7625_runtime_disable(void *data) pm_runtime_disable(data); } +static void anx7625_set_crosspoint_switch(struct anx7625_data *ctx, + enum typec_orientation orientation) +{ + if (orientation == TYPEC_ORIENTATION_NORMAL) { + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_0, + SW_SEL1_SSRX_RX1 | SW_SEL1_DPTX0_RX2); + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_1, + SW_SEL2_SSTX_TX1 | SW_SEL2_DPTX1_TX2); + } else if (orientation == TYPEC_ORIENTATION_REVERSE) { + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_0, + SW_SEL1_SSRX_RX2 | SW_SEL1_DPTX0_RX1); + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_1, + SW_SEL2_SSTX_TX2 | SW_SEL2_DPTX1_TX1); + } +} + +static void anx7625_typec_two_ports_update(struct anx7625_data *ctx) +{ + if (ctx->typec_ports[0].dp_connected && ctx->typec_ports[1].dp_connected) + /* Both ports available, do nothing to retain the current one. */ + return; + else if (ctx->typec_ports[0].dp_connected) + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_NORMAL); + else if (ctx->typec_ports[1].dp_connected) + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_REVERSE); +} + static int anx7625_typec_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) { + struct anx7625_port_data *data = typec_mux_get_drvdata(mux); + struct anx7625_data *ctx = data->ctx; + struct device *dev = &ctx->client->dev; + + bool old_dp_connected = (ctx->typec_ports[0].dp_connected || + ctx->typec_ports[1].dp_connected); + bool new_dp_connected; + + if (ctx->num_typec_switches == 1) + return 0; + + dev_dbg(dev, "mux_set dp_connected: c0=%d, c1=%d\n", + ctx->typec_ports[0].dp_connected, ctx->typec_ports[1].dp_connected); + + data->dp_connected = (state->alt && state->alt->svid == USB_TYPEC_DP_SID && + state->alt->mode == USB_TYPEC_DP_MODE); + + new_dp_connected = (ctx->typec_ports[0].dp_connected || + ctx->typec_ports[1].dp_connected); + + /* dp on, power on first */ + if (!old_dp_connected && new_dp_connected) + pm_runtime_get_sync(dev); + + anx7625_typec_two_ports_update(ctx); + + /* dp off, power off last */ + if (old_dp_connected && !new_dp_connected) + pm_runtime_put_sync(dev); + return 0; } diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h index 76cfc64f7574..7d6c6fdf9a3a 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.h +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h @@ -55,6 +55,18 @@ #define HPD_STATUS_CHANGE 0x80 #define HPD_STATUS 0x80 +#define TCPC_SWITCH_0 0xB4 +#define SW_SEL1_DPTX0_RX2 BIT(0) +#define SW_SEL1_DPTX0_RX1 BIT(1) +#define SW_SEL1_SSRX_RX2 BIT(4) +#define SW_SEL1_SSRX_RX1 BIT(5) + +#define TCPC_SWITCH_1 0xB5 +#define SW_SEL2_DPTX1_TX2 BIT(0) +#define SW_SEL2_DPTX1_TX1 BIT(1) +#define SW_SEL2_SSTX_TX2 BIT(4) +#define SW_SEL2_SSTX_TX1 BIT(5) + /******** END of I2C Address 0x58 ********/ /***************************************************************/ @@ -444,6 +456,7 @@ struct anx7625_i2c_client { }; struct anx7625_port_data { + bool dp_connected; struct typec_mux_dev *typec_mux; struct anx7625_data *ctx; };