Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'drm/tegra/for-4.8-rc1' of git://anongit.freedesktop.org/tegra/linux into drm-next

drm/tegra: Changes for v4.8-rc1

This set of changes contains a bunch of cleanups to the host1x driver as
well as the addition of a pin controller for DPAUX, which is required by
boards to configure the DPAUX pads in AUX mode (for DisplayPort) or I2C
mode (for HDMI and DDC).

Included is also a bit of rework of the SOR driver in preparation to add
DisplayPort support as well as some refactoring and cleanup.

Finally, all output drivers are converted to runtime PM, which greatly
simplifies the handling of clocks and resets.

* tag 'drm/tegra/for-4.8-rc1' of git://anongit.freedesktop.org/tegra/linux: (35 commits)
drm/tegra: sor: Reject HDMI 2.0 modes
drm/tegra: sor: Prepare for generic PM domain support
drm/tegra: dsi: Prepare for generic PM domain support
drm/tegra: sor: Make XBAR configurable per SoC
drm/tegra: sor: Use sor1_src clock to set parent for HDMI
dt-bindings: display: tegra: Add source clock for SOR
drm/tegra: sor: Implement sor1_brick clock
drm/tegra: sor: Implement runtime PM
drm/tegra: hdmi: Implement runtime PM
drm/tegra: dsi: Implement runtime PM
drm/tegra: dc: Implement runtime PM
drm/tegra: hdmi: Enable audio over HDMI
drm/tegra: sor: Do not support deep color modes
drm/tegra: sor: Extract tegra_sor_mode_set()
drm/tegra: sor: Split out tegra_sor_apply_config()
drm/tegra: sor: Rename tegra_sor_calc_config()
drm/tegra: sor: Factor out tegra_sor_set_parent_clock()
drm/tegra: dpaux: Add pinctrl support
dt-bindings: Add bindings for Tegra DPAUX pinctrl driver
drm/tegra: Prepare DPAUX for supporting generic PM domains
...

+1641 -707
+10 -3
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
··· 208 208 See ../clocks/clock-bindings.txt for details. 209 209 - clock-names: Must include the following entries: 210 210 - sor: clock input for the SOR hardware 211 + - source: source clock for the SOR clock 211 212 - parent: input for the pixel clock 212 213 - dp: reference clock for the SOR clock 213 214 - safe: safe reference for the SOR clock during power up ··· 227 226 - nvidia,dpaux: phandle to a DispayPort AUX interface 228 227 229 228 - dpaux: DisplayPort AUX interface 230 - - compatible: For Tegra124, must contain "nvidia,tegra124-dpaux". Otherwise, 231 - must contain '"nvidia,<chip>-dpaux", "nvidia,tegra124-dpaux"', where 232 - <chip> is tegra132. 229 + - compatible : Should contain one of the following: 230 + - "nvidia,tegra124-dpaux": for Tegra124 and Tegra132 231 + - "nvidia,tegra210-dpaux": for Tegra210 233 232 - reg: Physical base address and length of the controller's registers. 234 233 - interrupts: The interrupt outputs from the controller. 235 234 - clocks: Must contain an entry for each entry in clock-names. ··· 242 241 - reset-names: Must include the following entries: 243 242 - dpaux 244 243 - vdd-supply: phandle of a supply that powers the DisplayPort link 244 + - i2c-bus: Subnode where I2C slave devices are listed. This subnode 245 + must be always present. If there are no I2C slave devices, an empty 246 + node should be added. See ../../i2c/i2c.txt for more information. 247 + 248 + See ../pinctrl/nvidia,tegra124-dpaux-padctl.txt for information 249 + regarding the DPAUX pad controller bindings. 245 250 246 251 Example: 247 252
+60
Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt
··· 1 + Device tree binding for NVIDIA Tegra DPAUX pad controller 2 + ======================================================== 3 + 4 + The Tegra Display Port Auxiliary (DPAUX) pad controller manages two pins 5 + which can be assigned to either the DPAUX channel or to an I2C 6 + controller. 7 + 8 + This document defines the device-specific binding for the DPAUX pad 9 + controller. Refer to pinctrl-bindings.txt in this directory for generic 10 + information about pin controller device tree bindings. Please refer to 11 + the binding document ../display/tegra/nvidia,tegra20-host1x.txt for more 12 + details on the DPAUX binding. 13 + 14 + Pin muxing: 15 + ----------- 16 + 17 + Child nodes contain the pinmux configurations following the conventions 18 + from the pinctrl-bindings.txt document. 19 + 20 + Since only three configurations are possible, only three child nodes are 21 + needed to describe the pin mux'ing options for the DPAUX pads. 22 + Furthermore, given that the pad functions are only applicable to a 23 + single set of pads, the child nodes only need to describe the pad group 24 + the functions are being applied to rather than the individual pads. 25 + 26 + Required properties: 27 + - groups: Must be "dpaux-io" 28 + - function: Must be either "aux", "i2c" or "off". 29 + 30 + Example: 31 + -------- 32 + 33 + dpaux@545c0000 { 34 + ... 35 + 36 + state_dpaux_aux: pinmux-aux { 37 + groups = "dpaux-io"; 38 + function = "aux"; 39 + }; 40 + 41 + state_dpaux_i2c: pinmux-i2c { 42 + groups = "dpaux-io"; 43 + function = "i2c"; 44 + }; 45 + 46 + state_dpaux_off: pinmux-off { 47 + groups = "dpaux-io"; 48 + function = "off"; 49 + }; 50 + }; 51 + 52 + ... 53 + 54 + i2c@7000d100 { 55 + ... 56 + pinctrl-0 = <&state_dpaux_i2c>; 57 + pinctrl-1 = <&state_dpaux_off>; 58 + pinctrl-names = "default", "idle"; 59 + status = "disabled"; 60 + };
+106 -70
drivers/gpu/drm/tegra/dc.c
··· 10 10 #include <linux/clk.h> 11 11 #include <linux/debugfs.h> 12 12 #include <linux/iommu.h> 13 + #include <linux/pm_runtime.h> 13 14 #include <linux/reset.h> 14 15 15 16 #include <soc/tegra/pmc.h> ··· 1217 1216 1218 1217 tegra_dc_stats_reset(&dc->stats); 1219 1218 drm_crtc_vblank_off(crtc); 1219 + 1220 + pm_runtime_put_sync(dc->dev); 1220 1221 } 1221 1222 1222 1223 static void tegra_crtc_enable(struct drm_crtc *crtc) ··· 1228 1225 struct tegra_dc *dc = to_tegra_dc(crtc); 1229 1226 u32 value; 1230 1227 1228 + pm_runtime_get_sync(dc->dev); 1229 + 1230 + /* initialize display controller */ 1231 + if (dc->syncpt) { 1232 + u32 syncpt = host1x_syncpt_id(dc->syncpt); 1233 + 1234 + value = SYNCPT_CNTRL_NO_STALL; 1235 + tegra_dc_writel(dc, value, DC_CMD_GENERAL_INCR_SYNCPT_CNTRL); 1236 + 1237 + value = SYNCPT_VSYNC_ENABLE | syncpt; 1238 + tegra_dc_writel(dc, value, DC_CMD_CONT_SYNCPT_VSYNC); 1239 + } 1240 + 1241 + value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1242 + WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1243 + tegra_dc_writel(dc, value, DC_CMD_INT_TYPE); 1244 + 1245 + value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1246 + WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1247 + tegra_dc_writel(dc, value, DC_CMD_INT_POLARITY); 1248 + 1249 + /* initialize timer */ 1250 + value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(0x20) | 1251 + WINDOW_B_THRESHOLD(0x20) | WINDOW_C_THRESHOLD(0x20); 1252 + tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY); 1253 + 1254 + value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(1) | 1255 + WINDOW_B_THRESHOLD(1) | WINDOW_C_THRESHOLD(1); 1256 + tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY_TIMER); 1257 + 1258 + value = VBLANK_INT | WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1259 + WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1260 + tegra_dc_writel(dc, value, DC_CMD_INT_ENABLE); 1261 + 1262 + value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1263 + WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1264 + tegra_dc_writel(dc, value, DC_CMD_INT_MASK); 1265 + 1266 + if (dc->soc->supports_border_color) 1267 + tegra_dc_writel(dc, 0, DC_DISP_BORDER_COLOR); 1268 + 1269 + /* apply PLL and pixel clock changes */ 1231 1270 tegra_dc_commit_state(dc, state); 1232 1271 1233 1272 /* program display mode */ ··· 1730 1685 struct tegra_drm *tegra = drm->dev_private; 1731 1686 struct drm_plane *primary = NULL; 1732 1687 struct drm_plane *cursor = NULL; 1733 - u32 value; 1734 1688 int err; 1735 1689 1736 1690 dc->syncpt = host1x_syncpt_request(dc->dev, flags); ··· 1798 1754 err); 1799 1755 goto cleanup; 1800 1756 } 1801 - 1802 - /* initialize display controller */ 1803 - if (dc->syncpt) { 1804 - u32 syncpt = host1x_syncpt_id(dc->syncpt); 1805 - 1806 - value = SYNCPT_CNTRL_NO_STALL; 1807 - tegra_dc_writel(dc, value, DC_CMD_GENERAL_INCR_SYNCPT_CNTRL); 1808 - 1809 - value = SYNCPT_VSYNC_ENABLE | syncpt; 1810 - tegra_dc_writel(dc, value, DC_CMD_CONT_SYNCPT_VSYNC); 1811 - } 1812 - 1813 - value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1814 - WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1815 - tegra_dc_writel(dc, value, DC_CMD_INT_TYPE); 1816 - 1817 - value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1818 - WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1819 - tegra_dc_writel(dc, value, DC_CMD_INT_POLARITY); 1820 - 1821 - /* initialize timer */ 1822 - value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(0x20) | 1823 - WINDOW_B_THRESHOLD(0x20) | WINDOW_C_THRESHOLD(0x20); 1824 - tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY); 1825 - 1826 - value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(1) | 1827 - WINDOW_B_THRESHOLD(1) | WINDOW_C_THRESHOLD(1); 1828 - tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY_TIMER); 1829 - 1830 - value = VBLANK_INT | WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1831 - WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1832 - tegra_dc_writel(dc, value, DC_CMD_INT_ENABLE); 1833 - 1834 - value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | 1835 - WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT; 1836 - tegra_dc_writel(dc, value, DC_CMD_INT_MASK); 1837 - 1838 - if (dc->soc->supports_border_color) 1839 - tegra_dc_writel(dc, 0, DC_DISP_BORDER_COLOR); 1840 - 1841 - tegra_dc_stats_reset(&dc->stats); 1842 1757 1843 1758 return 0; 1844 1759 ··· 1990 1987 return PTR_ERR(dc->rst); 1991 1988 } 1992 1989 1990 + reset_control_assert(dc->rst); 1991 + 1993 1992 if (dc->soc->has_powergate) { 1994 1993 if (dc->pipe == 0) 1995 1994 dc->powergate = TEGRA_POWERGATE_DIS; 1996 1995 else 1997 1996 dc->powergate = TEGRA_POWERGATE_DISB; 1998 1997 1999 - err = tegra_powergate_sequence_power_up(dc->powergate, dc->clk, 2000 - dc->rst); 2001 - if (err < 0) { 2002 - dev_err(&pdev->dev, "failed to power partition: %d\n", 2003 - err); 2004 - return err; 2005 - } 2006 - } else { 2007 - err = clk_prepare_enable(dc->clk); 2008 - if (err < 0) { 2009 - dev_err(&pdev->dev, "failed to enable clock: %d\n", 2010 - err); 2011 - return err; 2012 - } 2013 - 2014 - err = reset_control_deassert(dc->rst); 2015 - if (err < 0) { 2016 - dev_err(&pdev->dev, "failed to deassert reset: %d\n", 2017 - err); 2018 - return err; 2019 - } 1998 + tegra_powergate_power_off(dc->powergate); 2020 1999 } 2021 2000 2022 2001 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 2012 2027 return -ENXIO; 2013 2028 } 2014 2029 2015 - INIT_LIST_HEAD(&dc->client.list); 2016 - dc->client.ops = &dc_client_ops; 2017 - dc->client.dev = &pdev->dev; 2018 - 2019 2030 err = tegra_dc_rgb_probe(dc); 2020 2031 if (err < 0 && err != -ENODEV) { 2021 2032 dev_err(&pdev->dev, "failed to probe RGB output: %d\n", err); 2022 2033 return err; 2023 2034 } 2035 + 2036 + platform_set_drvdata(pdev, dc); 2037 + pm_runtime_enable(&pdev->dev); 2038 + 2039 + INIT_LIST_HEAD(&dc->client.list); 2040 + dc->client.ops = &dc_client_ops; 2041 + dc->client.dev = &pdev->dev; 2024 2042 2025 2043 err = host1x_client_register(&dc->client); 2026 2044 if (err < 0) { ··· 2031 2043 err); 2032 2044 return err; 2033 2045 } 2034 - 2035 - platform_set_drvdata(pdev, dc); 2036 2046 2037 2047 return 0; 2038 2048 } ··· 2053 2067 return err; 2054 2068 } 2055 2069 2056 - reset_control_assert(dc->rst); 2070 + pm_runtime_disable(&pdev->dev); 2071 + 2072 + return 0; 2073 + } 2074 + 2075 + #ifdef CONFIG_PM 2076 + static int tegra_dc_suspend(struct device *dev) 2077 + { 2078 + struct tegra_dc *dc = dev_get_drvdata(dev); 2079 + int err; 2080 + 2081 + err = reset_control_assert(dc->rst); 2082 + if (err < 0) { 2083 + dev_err(dev, "failed to assert reset: %d\n", err); 2084 + return err; 2085 + } 2057 2086 2058 2087 if (dc->soc->has_powergate) 2059 2088 tegra_powergate_power_off(dc->powergate); ··· 2078 2077 return 0; 2079 2078 } 2080 2079 2080 + static int tegra_dc_resume(struct device *dev) 2081 + { 2082 + struct tegra_dc *dc = dev_get_drvdata(dev); 2083 + int err; 2084 + 2085 + if (dc->soc->has_powergate) { 2086 + err = tegra_powergate_sequence_power_up(dc->powergate, dc->clk, 2087 + dc->rst); 2088 + if (err < 0) { 2089 + dev_err(dev, "failed to power partition: %d\n", err); 2090 + return err; 2091 + } 2092 + } else { 2093 + err = clk_prepare_enable(dc->clk); 2094 + if (err < 0) { 2095 + dev_err(dev, "failed to enable clock: %d\n", err); 2096 + return err; 2097 + } 2098 + 2099 + err = reset_control_deassert(dc->rst); 2100 + if (err < 0) { 2101 + dev_err(dev, "failed to deassert reset: %d\n", err); 2102 + return err; 2103 + } 2104 + } 2105 + 2106 + return 0; 2107 + } 2108 + #endif 2109 + 2110 + static const struct dev_pm_ops tegra_dc_pm_ops = { 2111 + SET_RUNTIME_PM_OPS(tegra_dc_suspend, tegra_dc_resume, NULL) 2112 + }; 2113 + 2081 2114 struct platform_driver tegra_dc_driver = { 2082 2115 .driver = { 2083 2116 .name = "tegra-dc", 2084 2117 .of_match_table = tegra_dc_of_match, 2118 + .pm = &tegra_dc_pm_ops, 2085 2119 }, 2086 2120 .probe = tegra_dc_probe, 2087 2121 .remove = tegra_dc_remove,
+201 -42
drivers/gpu/drm/tegra/dpaux.c
··· 12 12 #include <linux/interrupt.h> 13 13 #include <linux/io.h> 14 14 #include <linux/of_gpio.h> 15 + #include <linux/pinctrl/pinconf-generic.h> 16 + #include <linux/pinctrl/pinctrl.h> 17 + #include <linux/pinctrl/pinmux.h> 15 18 #include <linux/platform_device.h> 16 19 #include <linux/reset.h> 17 20 #include <linux/regulator/consumer.h> ··· 47 44 struct completion complete; 48 45 struct work_struct work; 49 46 struct list_head list; 47 + 48 + #ifdef CONFIG_GENERIC_PINCONF 49 + struct pinctrl_dev *pinctrl; 50 + struct pinctrl_desc desc; 51 + #endif 50 52 }; 51 53 52 54 static inline struct tegra_dpaux *to_dpaux(struct drm_dp_aux *aux) ··· 275 267 return ret; 276 268 } 277 269 270 + enum tegra_dpaux_functions { 271 + DPAUX_PADCTL_FUNC_AUX, 272 + DPAUX_PADCTL_FUNC_I2C, 273 + DPAUX_PADCTL_FUNC_OFF, 274 + }; 275 + 276 + static void tegra_dpaux_pad_power_down(struct tegra_dpaux *dpaux) 277 + { 278 + u32 value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE); 279 + 280 + value |= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN; 281 + 282 + tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE); 283 + } 284 + 285 + static void tegra_dpaux_pad_power_up(struct tegra_dpaux *dpaux) 286 + { 287 + u32 value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE); 288 + 289 + value &= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN; 290 + 291 + tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE); 292 + } 293 + 294 + static int tegra_dpaux_pad_config(struct tegra_dpaux *dpaux, unsigned function) 295 + { 296 + u32 value; 297 + 298 + switch (function) { 299 + case DPAUX_PADCTL_FUNC_AUX: 300 + value = DPAUX_HYBRID_PADCTL_AUX_CMH(2) | 301 + DPAUX_HYBRID_PADCTL_AUX_DRVZ(4) | 302 + DPAUX_HYBRID_PADCTL_AUX_DRVI(0x18) | 303 + DPAUX_HYBRID_PADCTL_AUX_INPUT_RCV | 304 + DPAUX_HYBRID_PADCTL_MODE_AUX; 305 + break; 306 + 307 + case DPAUX_PADCTL_FUNC_I2C: 308 + value = DPAUX_HYBRID_PADCTL_I2C_SDA_INPUT_RCV | 309 + DPAUX_HYBRID_PADCTL_I2C_SCL_INPUT_RCV | 310 + DPAUX_HYBRID_PADCTL_MODE_I2C; 311 + break; 312 + 313 + case DPAUX_PADCTL_FUNC_OFF: 314 + tegra_dpaux_pad_power_down(dpaux); 315 + return 0; 316 + 317 + default: 318 + return -ENOTSUPP; 319 + } 320 + 321 + tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_PADCTL); 322 + tegra_dpaux_pad_power_up(dpaux); 323 + 324 + return 0; 325 + } 326 + 327 + #ifdef CONFIG_GENERIC_PINCONF 328 + static const struct pinctrl_pin_desc tegra_dpaux_pins[] = { 329 + PINCTRL_PIN(0, "DP_AUX_CHx_P"), 330 + PINCTRL_PIN(1, "DP_AUX_CHx_N"), 331 + }; 332 + 333 + static const unsigned tegra_dpaux_pin_numbers[] = { 0, 1 }; 334 + 335 + static const char * const tegra_dpaux_groups[] = { 336 + "dpaux-io", 337 + }; 338 + 339 + static const char * const tegra_dpaux_functions[] = { 340 + "aux", 341 + "i2c", 342 + "off", 343 + }; 344 + 345 + static int tegra_dpaux_get_groups_count(struct pinctrl_dev *pinctrl) 346 + { 347 + return ARRAY_SIZE(tegra_dpaux_groups); 348 + } 349 + 350 + static const char *tegra_dpaux_get_group_name(struct pinctrl_dev *pinctrl, 351 + unsigned int group) 352 + { 353 + return tegra_dpaux_groups[group]; 354 + } 355 + 356 + static int tegra_dpaux_get_group_pins(struct pinctrl_dev *pinctrl, 357 + unsigned group, const unsigned **pins, 358 + unsigned *num_pins) 359 + { 360 + *pins = tegra_dpaux_pin_numbers; 361 + *num_pins = ARRAY_SIZE(tegra_dpaux_pin_numbers); 362 + 363 + return 0; 364 + } 365 + 366 + static const struct pinctrl_ops tegra_dpaux_pinctrl_ops = { 367 + .get_groups_count = tegra_dpaux_get_groups_count, 368 + .get_group_name = tegra_dpaux_get_group_name, 369 + .get_group_pins = tegra_dpaux_get_group_pins, 370 + .dt_node_to_map = pinconf_generic_dt_node_to_map_group, 371 + .dt_free_map = pinconf_generic_dt_free_map, 372 + }; 373 + 374 + static int tegra_dpaux_get_functions_count(struct pinctrl_dev *pinctrl) 375 + { 376 + return ARRAY_SIZE(tegra_dpaux_functions); 377 + } 378 + 379 + static const char *tegra_dpaux_get_function_name(struct pinctrl_dev *pinctrl, 380 + unsigned int function) 381 + { 382 + return tegra_dpaux_functions[function]; 383 + } 384 + 385 + static int tegra_dpaux_get_function_groups(struct pinctrl_dev *pinctrl, 386 + unsigned int function, 387 + const char * const **groups, 388 + unsigned * const num_groups) 389 + { 390 + *num_groups = ARRAY_SIZE(tegra_dpaux_groups); 391 + *groups = tegra_dpaux_groups; 392 + 393 + return 0; 394 + } 395 + 396 + static int tegra_dpaux_set_mux(struct pinctrl_dev *pinctrl, 397 + unsigned int function, unsigned int group) 398 + { 399 + struct tegra_dpaux *dpaux = pinctrl_dev_get_drvdata(pinctrl); 400 + 401 + return tegra_dpaux_pad_config(dpaux, function); 402 + } 403 + 404 + static const struct pinmux_ops tegra_dpaux_pinmux_ops = { 405 + .get_functions_count = tegra_dpaux_get_functions_count, 406 + .get_function_name = tegra_dpaux_get_function_name, 407 + .get_function_groups = tegra_dpaux_get_function_groups, 408 + .set_mux = tegra_dpaux_set_mux, 409 + }; 410 + #endif 411 + 278 412 static int tegra_dpaux_probe(struct platform_device *pdev) 279 413 { 280 414 struct tegra_dpaux *dpaux; ··· 444 294 return -ENXIO; 445 295 } 446 296 447 - dpaux->rst = devm_reset_control_get(&pdev->dev, "dpaux"); 448 - if (IS_ERR(dpaux->rst)) { 449 - dev_err(&pdev->dev, "failed to get reset control: %ld\n", 450 - PTR_ERR(dpaux->rst)); 451 - return PTR_ERR(dpaux->rst); 297 + if (!pdev->dev.pm_domain) { 298 + dpaux->rst = devm_reset_control_get(&pdev->dev, "dpaux"); 299 + if (IS_ERR(dpaux->rst)) { 300 + dev_err(&pdev->dev, 301 + "failed to get reset control: %ld\n", 302 + PTR_ERR(dpaux->rst)); 303 + return PTR_ERR(dpaux->rst); 304 + } 452 305 } 453 306 454 307 dpaux->clk = devm_clk_get(&pdev->dev, NULL); ··· 468 315 return err; 469 316 } 470 317 471 - reset_control_deassert(dpaux->rst); 318 + if (dpaux->rst) 319 + reset_control_deassert(dpaux->rst); 472 320 473 321 dpaux->clk_parent = devm_clk_get(&pdev->dev, "parent"); 474 322 if (IS_ERR(dpaux->clk_parent)) { 475 323 dev_err(&pdev->dev, "failed to get parent clock: %ld\n", 476 324 PTR_ERR(dpaux->clk_parent)); 477 - return PTR_ERR(dpaux->clk_parent); 325 + err = PTR_ERR(dpaux->clk_parent); 326 + goto assert_reset; 478 327 } 479 328 480 329 err = clk_prepare_enable(dpaux->clk_parent); 481 330 if (err < 0) { 482 331 dev_err(&pdev->dev, "failed to enable parent clock: %d\n", 483 332 err); 484 - return err; 333 + goto assert_reset; 485 334 } 486 335 487 336 err = clk_set_rate(dpaux->clk_parent, 270000000); 488 337 if (err < 0) { 489 338 dev_err(&pdev->dev, "failed to set clock to 270 MHz: %d\n", 490 339 err); 491 - return err; 340 + goto disable_parent_clk; 492 341 } 493 342 494 343 dpaux->vdd = devm_regulator_get(&pdev->dev, "vdd"); 495 344 if (IS_ERR(dpaux->vdd)) { 496 345 dev_err(&pdev->dev, "failed to get VDD supply: %ld\n", 497 346 PTR_ERR(dpaux->vdd)); 498 - return PTR_ERR(dpaux->vdd); 347 + err = PTR_ERR(dpaux->vdd); 348 + goto disable_parent_clk; 499 349 } 500 350 501 351 err = devm_request_irq(dpaux->dev, dpaux->irq, tegra_dpaux_irq, 0, ··· 506 350 if (err < 0) { 507 351 dev_err(dpaux->dev, "failed to request IRQ#%u: %d\n", 508 352 dpaux->irq, err); 509 - return err; 353 + goto disable_parent_clk; 510 354 } 511 355 512 356 disable_irq(dpaux->irq); ··· 516 360 517 361 err = drm_dp_aux_register(&dpaux->aux); 518 362 if (err < 0) 519 - return err; 363 + goto disable_parent_clk; 520 364 521 365 /* 522 366 * Assume that by default the DPAUX/I2C pads will be used for HDMI, ··· 526 370 * is no possibility to perform the I2C mode configuration in the 527 371 * HDMI path. 528 372 */ 529 - value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE); 530 - value &= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN; 531 - tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE); 373 + err = tegra_dpaux_pad_config(dpaux, DPAUX_HYBRID_PADCTL_MODE_I2C); 374 + if (err < 0) 375 + return err; 532 376 533 - value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_PADCTL); 534 - value = DPAUX_HYBRID_PADCTL_I2C_SDA_INPUT_RCV | 535 - DPAUX_HYBRID_PADCTL_I2C_SCL_INPUT_RCV | 536 - DPAUX_HYBRID_PADCTL_MODE_I2C; 537 - tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_PADCTL); 377 + #ifdef CONFIG_GENERIC_PINCONF 378 + dpaux->desc.name = dev_name(&pdev->dev); 379 + dpaux->desc.pins = tegra_dpaux_pins; 380 + dpaux->desc.npins = ARRAY_SIZE(tegra_dpaux_pins); 381 + dpaux->desc.pctlops = &tegra_dpaux_pinctrl_ops; 382 + dpaux->desc.pmxops = &tegra_dpaux_pinmux_ops; 383 + dpaux->desc.owner = THIS_MODULE; 538 384 385 + dpaux->pinctrl = devm_pinctrl_register(&pdev->dev, &dpaux->desc, dpaux); 386 + if (!dpaux->pinctrl) { 387 + dev_err(&pdev->dev, "failed to register pincontrol\n"); 388 + return -ENODEV; 389 + } 390 + #endif 539 391 /* enable and clear all interrupts */ 540 392 value = DPAUX_INTR_AUX_DONE | DPAUX_INTR_IRQ_EVENT | 541 393 DPAUX_INTR_UNPLUG_EVENT | DPAUX_INTR_PLUG_EVENT; ··· 557 393 platform_set_drvdata(pdev, dpaux); 558 394 559 395 return 0; 396 + 397 + disable_parent_clk: 398 + clk_disable_unprepare(dpaux->clk_parent); 399 + assert_reset: 400 + if (dpaux->rst) 401 + reset_control_assert(dpaux->rst); 402 + 403 + clk_disable_unprepare(dpaux->clk); 404 + 405 + return err; 560 406 } 561 407 562 408 static int tegra_dpaux_remove(struct platform_device *pdev) 563 409 { 564 410 struct tegra_dpaux *dpaux = platform_get_drvdata(pdev); 565 - u32 value; 566 411 567 412 /* make sure pads are powered down when not in use */ 568 - value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE); 569 - value |= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN; 570 - tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE); 413 + tegra_dpaux_pad_power_down(dpaux); 571 414 572 415 drm_dp_aux_unregister(&dpaux->aux); 573 416 ··· 585 414 cancel_work_sync(&dpaux->work); 586 415 587 416 clk_disable_unprepare(dpaux->clk_parent); 588 - reset_control_assert(dpaux->rst); 417 + 418 + if (dpaux->rst) 419 + reset_control_assert(dpaux->rst); 420 + 589 421 clk_disable_unprepare(dpaux->clk); 590 422 591 423 return 0; ··· 702 528 int drm_dp_aux_enable(struct drm_dp_aux *aux) 703 529 { 704 530 struct tegra_dpaux *dpaux = to_dpaux(aux); 705 - u32 value; 706 531 707 - value = DPAUX_HYBRID_PADCTL_AUX_CMH(2) | 708 - DPAUX_HYBRID_PADCTL_AUX_DRVZ(4) | 709 - DPAUX_HYBRID_PADCTL_AUX_DRVI(0x18) | 710 - DPAUX_HYBRID_PADCTL_AUX_INPUT_RCV | 711 - DPAUX_HYBRID_PADCTL_MODE_AUX; 712 - tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_PADCTL); 713 - 714 - value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE); 715 - value &= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN; 716 - tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE); 717 - 718 - return 0; 532 + return tegra_dpaux_pad_config(dpaux, DPAUX_PADCTL_FUNC_AUX); 719 533 } 720 534 721 535 int drm_dp_aux_disable(struct drm_dp_aux *aux) 722 536 { 723 537 struct tegra_dpaux *dpaux = to_dpaux(aux); 724 - u32 value; 725 538 726 - value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE); 727 - value |= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN; 728 - tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE); 539 + tegra_dpaux_pad_power_down(dpaux); 729 540 730 541 return 0; 731 542 }
+1 -1
drivers/gpu/drm/tegra/drm.c
··· 56 56 */ 57 57 58 58 drm_atomic_helper_commit_modeset_disables(drm, state); 59 - drm_atomic_helper_commit_planes(drm, state, false); 60 59 drm_atomic_helper_commit_modeset_enables(drm, state); 60 + drm_atomic_helper_commit_planes(drm, state, true); 61 61 62 62 drm_atomic_helper_wait_for_vblanks(drm, state); 63 63
+141 -106
drivers/gpu/drm/tegra/dsi.c
··· 13 13 #include <linux/of.h> 14 14 #include <linux/of_platform.h> 15 15 #include <linux/platform_device.h> 16 + #include <linux/pm_runtime.h> 16 17 #include <linux/reset.h> 17 18 18 19 #include <linux/regulator/consumer.h> ··· 678 677 tegra_dsi_writel(dsi, 0, DSI_GANGED_MODE_CONTROL); 679 678 } 680 679 680 + static int tegra_dsi_pad_enable(struct tegra_dsi *dsi) 681 + { 682 + u32 value; 683 + 684 + value = DSI_PAD_CONTROL_VS1_PULLDN(0) | DSI_PAD_CONTROL_VS1_PDIO(0); 685 + tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_0); 686 + 687 + return 0; 688 + } 689 + 690 + static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) 691 + { 692 + u32 value; 693 + 694 + /* 695 + * XXX Is this still needed? The module reset is deasserted right 696 + * before this function is called. 697 + */ 698 + tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_0); 699 + tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_1); 700 + tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_2); 701 + tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_3); 702 + tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_4); 703 + 704 + /* start calibration */ 705 + tegra_dsi_pad_enable(dsi); 706 + 707 + value = DSI_PAD_SLEW_UP(0x7) | DSI_PAD_SLEW_DN(0x7) | 708 + DSI_PAD_LP_UP(0x1) | DSI_PAD_LP_DN(0x1) | 709 + DSI_PAD_OUT_CLK(0x0); 710 + tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_2); 711 + 712 + value = DSI_PAD_PREEMP_PD_CLK(0x3) | DSI_PAD_PREEMP_PU_CLK(0x3) | 713 + DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); 714 + tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); 715 + 716 + return tegra_mipi_calibrate(dsi->mipi); 717 + } 718 + 681 719 static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk, 682 720 unsigned int vrefresh) 683 721 { ··· 876 836 877 837 tegra_dsi_disable(dsi); 878 838 879 - return; 839 + pm_runtime_put(dsi->dev); 880 840 } 881 841 882 842 static void tegra_dsi_encoder_enable(struct drm_encoder *encoder) ··· 887 847 struct tegra_dsi *dsi = to_dsi(output); 888 848 struct tegra_dsi_state *state; 889 849 u32 value; 850 + int err; 851 + 852 + pm_runtime_get_sync(dsi->dev); 853 + 854 + err = tegra_dsi_pad_calibrate(dsi); 855 + if (err < 0) 856 + dev_err(dsi->dev, "MIPI calibration failed: %d\n", err); 890 857 891 858 state = tegra_dsi_get_state(dsi); 892 859 ··· 922 875 923 876 if (output->panel) 924 877 drm_panel_enable(output->panel); 925 - 926 - return; 927 878 } 928 879 929 880 static int ··· 1011 966 .atomic_check = tegra_dsi_encoder_atomic_check, 1012 967 }; 1013 968 1014 - static int tegra_dsi_pad_enable(struct tegra_dsi *dsi) 1015 - { 1016 - u32 value; 1017 - 1018 - value = DSI_PAD_CONTROL_VS1_PULLDN(0) | DSI_PAD_CONTROL_VS1_PDIO(0); 1019 - tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_0); 1020 - 1021 - return 0; 1022 - } 1023 - 1024 - static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi) 1025 - { 1026 - u32 value; 1027 - 1028 - tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_0); 1029 - tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_1); 1030 - tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_2); 1031 - tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_3); 1032 - tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_4); 1033 - 1034 - /* start calibration */ 1035 - tegra_dsi_pad_enable(dsi); 1036 - 1037 - value = DSI_PAD_SLEW_UP(0x7) | DSI_PAD_SLEW_DN(0x7) | 1038 - DSI_PAD_LP_UP(0x1) | DSI_PAD_LP_DN(0x1) | 1039 - DSI_PAD_OUT_CLK(0x0); 1040 - tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_2); 1041 - 1042 - value = DSI_PAD_PREEMP_PD_CLK(0x3) | DSI_PAD_PREEMP_PU_CLK(0x3) | 1043 - DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3); 1044 - tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3); 1045 - 1046 - return tegra_mipi_calibrate(dsi->mipi); 1047 - } 1048 - 1049 969 static int tegra_dsi_init(struct host1x_client *client) 1050 970 { 1051 971 struct drm_device *drm = dev_get_drvdata(client->parent); 1052 972 struct tegra_dsi *dsi = host1x_client_to_dsi(client); 1053 973 int err; 1054 - 1055 - reset_control_deassert(dsi->rst); 1056 - 1057 - err = tegra_dsi_pad_calibrate(dsi); 1058 - if (err < 0) { 1059 - dev_err(dsi->dev, "MIPI calibration failed: %d\n", err); 1060 - goto reset; 1061 - } 1062 974 1063 975 /* Gangsters must not register their own outputs. */ 1064 976 if (!dsi->master) { ··· 1039 1037 drm_connector_register(&dsi->output.connector); 1040 1038 1041 1039 err = tegra_output_init(drm, &dsi->output); 1042 - if (err < 0) { 1043 - dev_err(client->dev, 1044 - "failed to initialize output: %d\n", 1040 + if (err < 0) 1041 + dev_err(dsi->dev, "failed to initialize output: %d\n", 1045 1042 err); 1046 - goto reset; 1047 - } 1048 1043 1049 1044 dsi->output.encoder.possible_crtcs = 0x3; 1050 1045 } ··· 1053 1054 } 1054 1055 1055 1056 return 0; 1056 - 1057 - reset: 1058 - reset_control_assert(dsi->rst); 1059 - return err; 1060 1057 } 1061 1058 1062 1059 static int tegra_dsi_exit(struct host1x_client *client) ··· 1064 1069 if (IS_ENABLED(CONFIG_DEBUG_FS)) 1065 1070 tegra_dsi_debugfs_exit(dsi); 1066 1071 1067 - reset_control_assert(dsi->rst); 1072 + regulator_disable(dsi->vdd); 1068 1073 1069 1074 return 0; 1070 1075 } ··· 1488 1493 dsi->format = MIPI_DSI_FMT_RGB888; 1489 1494 dsi->lanes = 4; 1490 1495 1491 - dsi->rst = devm_reset_control_get(&pdev->dev, "dsi"); 1492 - if (IS_ERR(dsi->rst)) 1493 - return PTR_ERR(dsi->rst); 1496 + if (!pdev->dev.pm_domain) { 1497 + dsi->rst = devm_reset_control_get(&pdev->dev, "dsi"); 1498 + if (IS_ERR(dsi->rst)) 1499 + return PTR_ERR(dsi->rst); 1500 + } 1494 1501 1495 1502 dsi->clk = devm_clk_get(&pdev->dev, NULL); 1496 1503 if (IS_ERR(dsi->clk)) { 1497 1504 dev_err(&pdev->dev, "cannot get DSI clock\n"); 1498 - err = PTR_ERR(dsi->clk); 1499 - goto reset; 1500 - } 1501 - 1502 - err = clk_prepare_enable(dsi->clk); 1503 - if (err < 0) { 1504 - dev_err(&pdev->dev, "cannot enable DSI clock\n"); 1505 - goto reset; 1505 + return PTR_ERR(dsi->clk); 1506 1506 } 1507 1507 1508 1508 dsi->clk_lp = devm_clk_get(&pdev->dev, "lp"); 1509 1509 if (IS_ERR(dsi->clk_lp)) { 1510 1510 dev_err(&pdev->dev, "cannot get low-power clock\n"); 1511 - err = PTR_ERR(dsi->clk_lp); 1512 - goto disable_clk; 1513 - } 1514 - 1515 - err = clk_prepare_enable(dsi->clk_lp); 1516 - if (err < 0) { 1517 - dev_err(&pdev->dev, "cannot enable low-power clock\n"); 1518 - goto disable_clk; 1511 + return PTR_ERR(dsi->clk_lp); 1519 1512 } 1520 1513 1521 1514 dsi->clk_parent = devm_clk_get(&pdev->dev, "parent"); 1522 1515 if (IS_ERR(dsi->clk_parent)) { 1523 1516 dev_err(&pdev->dev, "cannot get parent clock\n"); 1524 - err = PTR_ERR(dsi->clk_parent); 1525 - goto disable_clk_lp; 1517 + return PTR_ERR(dsi->clk_parent); 1526 1518 } 1527 1519 1528 1520 dsi->vdd = devm_regulator_get(&pdev->dev, "avdd-dsi-csi"); 1529 1521 if (IS_ERR(dsi->vdd)) { 1530 1522 dev_err(&pdev->dev, "cannot get VDD supply\n"); 1531 - err = PTR_ERR(dsi->vdd); 1532 - goto disable_clk_lp; 1533 - } 1534 - 1535 - err = regulator_enable(dsi->vdd); 1536 - if (err < 0) { 1537 - dev_err(&pdev->dev, "cannot enable VDD supply\n"); 1538 - goto disable_clk_lp; 1523 + return PTR_ERR(dsi->vdd); 1539 1524 } 1540 1525 1541 1526 err = tegra_dsi_setup_clocks(dsi); 1542 1527 if (err < 0) { 1543 1528 dev_err(&pdev->dev, "cannot setup clocks\n"); 1544 - goto disable_vdd; 1529 + return err; 1545 1530 } 1546 1531 1547 1532 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1548 1533 dsi->regs = devm_ioremap_resource(&pdev->dev, regs); 1549 - if (IS_ERR(dsi->regs)) { 1550 - err = PTR_ERR(dsi->regs); 1551 - goto disable_vdd; 1552 - } 1534 + if (IS_ERR(dsi->regs)) 1535 + return PTR_ERR(dsi->regs); 1553 1536 1554 1537 dsi->mipi = tegra_mipi_request(&pdev->dev); 1555 - if (IS_ERR(dsi->mipi)) { 1556 - err = PTR_ERR(dsi->mipi); 1557 - goto disable_vdd; 1558 - } 1538 + if (IS_ERR(dsi->mipi)) 1539 + return PTR_ERR(dsi->mipi); 1559 1540 1560 1541 dsi->host.ops = &tegra_dsi_host_ops; 1561 1542 dsi->host.dev = &pdev->dev; ··· 1541 1570 dev_err(&pdev->dev, "failed to register DSI host: %d\n", err); 1542 1571 goto mipi_free; 1543 1572 } 1573 + 1574 + platform_set_drvdata(pdev, dsi); 1575 + pm_runtime_enable(&pdev->dev); 1544 1576 1545 1577 INIT_LIST_HEAD(&dsi->client.list); 1546 1578 dsi->client.ops = &dsi_client_ops; ··· 1556 1582 goto unregister; 1557 1583 } 1558 1584 1559 - platform_set_drvdata(pdev, dsi); 1560 - 1561 1585 return 0; 1562 1586 1563 1587 unregister: 1564 1588 mipi_dsi_host_unregister(&dsi->host); 1565 1589 mipi_free: 1566 1590 tegra_mipi_free(dsi->mipi); 1567 - disable_vdd: 1568 - regulator_disable(dsi->vdd); 1569 - disable_clk_lp: 1570 - clk_disable_unprepare(dsi->clk_lp); 1571 - disable_clk: 1572 - clk_disable_unprepare(dsi->clk); 1573 - reset: 1574 - reset_control_assert(dsi->rst); 1575 1591 return err; 1576 1592 } 1577 1593 ··· 1569 1605 { 1570 1606 struct tegra_dsi *dsi = platform_get_drvdata(pdev); 1571 1607 int err; 1608 + 1609 + pm_runtime_disable(&pdev->dev); 1572 1610 1573 1611 err = host1x_client_unregister(&dsi->client); 1574 1612 if (err < 0) { ··· 1584 1618 mipi_dsi_host_unregister(&dsi->host); 1585 1619 tegra_mipi_free(dsi->mipi); 1586 1620 1587 - regulator_disable(dsi->vdd); 1621 + return 0; 1622 + } 1623 + 1624 + #ifdef CONFIG_PM 1625 + static int tegra_dsi_suspend(struct device *dev) 1626 + { 1627 + struct tegra_dsi *dsi = dev_get_drvdata(dev); 1628 + int err; 1629 + 1630 + if (dsi->rst) { 1631 + err = reset_control_assert(dsi->rst); 1632 + if (err < 0) { 1633 + dev_err(dev, "failed to assert reset: %d\n", err); 1634 + return err; 1635 + } 1636 + } 1637 + 1638 + usleep_range(1000, 2000); 1639 + 1588 1640 clk_disable_unprepare(dsi->clk_lp); 1589 1641 clk_disable_unprepare(dsi->clk); 1590 - reset_control_assert(dsi->rst); 1642 + 1643 + regulator_disable(dsi->vdd); 1591 1644 1592 1645 return 0; 1593 1646 } 1647 + 1648 + static int tegra_dsi_resume(struct device *dev) 1649 + { 1650 + struct tegra_dsi *dsi = dev_get_drvdata(dev); 1651 + int err; 1652 + 1653 + err = regulator_enable(dsi->vdd); 1654 + if (err < 0) { 1655 + dev_err(dsi->dev, "failed to enable VDD supply: %d\n", err); 1656 + return err; 1657 + } 1658 + 1659 + err = clk_prepare_enable(dsi->clk); 1660 + if (err < 0) { 1661 + dev_err(dev, "cannot enable DSI clock: %d\n", err); 1662 + goto disable_vdd; 1663 + } 1664 + 1665 + err = clk_prepare_enable(dsi->clk_lp); 1666 + if (err < 0) { 1667 + dev_err(dev, "cannot enable low-power clock: %d\n", err); 1668 + goto disable_clk; 1669 + } 1670 + 1671 + usleep_range(1000, 2000); 1672 + 1673 + if (dsi->rst) { 1674 + err = reset_control_deassert(dsi->rst); 1675 + if (err < 0) { 1676 + dev_err(dev, "cannot assert reset: %d\n", err); 1677 + goto disable_clk_lp; 1678 + } 1679 + } 1680 + 1681 + return 0; 1682 + 1683 + disable_clk_lp: 1684 + clk_disable_unprepare(dsi->clk_lp); 1685 + disable_clk: 1686 + clk_disable_unprepare(dsi->clk); 1687 + disable_vdd: 1688 + regulator_disable(dsi->vdd); 1689 + return err; 1690 + } 1691 + #endif 1692 + 1693 + static const struct dev_pm_ops tegra_dsi_pm_ops = { 1694 + SET_RUNTIME_PM_OPS(tegra_dsi_suspend, tegra_dsi_resume, NULL) 1695 + }; 1594 1696 1595 1697 static const struct of_device_id tegra_dsi_of_match[] = { 1596 1698 { .compatible = "nvidia,tegra210-dsi", }, ··· 1673 1639 .driver = { 1674 1640 .name = "tegra-dsi", 1675 1641 .of_match_table = tegra_dsi_of_match, 1642 + .pm = &tegra_dsi_pm_ops, 1676 1643 }, 1677 1644 .probe = tegra_dsi_probe, 1678 1645 .remove = tegra_dsi_remove,
+398 -121
drivers/gpu/drm/tegra/hdmi.c
··· 11 11 #include <linux/debugfs.h> 12 12 #include <linux/gpio.h> 13 13 #include <linux/hdmi.h> 14 + #include <linux/pm_runtime.h> 14 15 #include <linux/regulator/consumer.h> 15 16 #include <linux/reset.h> 16 17 ··· 19 18 #include <drm/drm_crtc.h> 20 19 #include <drm/drm_crtc_helper.h> 21 20 21 + #include <sound/hda_verbs.h> 22 + 22 23 #include "hdmi.h" 23 24 #include "drm.h" 24 25 #include "dc.h" 26 + 27 + #define HDMI_ELD_BUFFER_SIZE 96 25 28 26 29 struct tmds_config { 27 30 unsigned int pclk; ··· 44 39 u32 fuse_override_value; 45 40 46 41 bool has_sor_io_peak_current; 42 + bool has_hda; 43 + bool has_hbr; 47 44 }; 48 45 49 46 struct tegra_hdmi { ··· 67 60 const struct tegra_hdmi_config *config; 68 61 69 62 unsigned int audio_source; 70 - unsigned int audio_freq; 63 + unsigned int audio_sample_rate; 64 + unsigned int audio_channels; 65 + 66 + unsigned int pixel_clock; 71 67 bool stereo; 72 68 bool dvi; 73 69 ··· 412 402 }; 413 403 414 404 static const struct tegra_hdmi_audio_config * 415 - tegra_hdmi_get_audio_config(unsigned int audio_freq, unsigned int pclk) 405 + tegra_hdmi_get_audio_config(unsigned int sample_rate, unsigned int pclk) 416 406 { 417 407 const struct tegra_hdmi_audio_config *table; 418 408 419 - switch (audio_freq) { 409 + switch (sample_rate) { 420 410 case 32000: 421 411 table = tegra_hdmi_audio_32k; 422 412 break; ··· 486 476 } 487 477 } 488 478 489 - static int tegra_hdmi_setup_audio(struct tegra_hdmi *hdmi, unsigned int pclk) 479 + static void tegra_hdmi_write_aval(struct tegra_hdmi *hdmi, u32 value) 490 480 { 491 - struct device_node *node = hdmi->dev->of_node; 481 + static const struct { 482 + unsigned int sample_rate; 483 + unsigned int offset; 484 + } regs[] = { 485 + { 32000, HDMI_NV_PDISP_SOR_AUDIO_AVAL_0320 }, 486 + { 44100, HDMI_NV_PDISP_SOR_AUDIO_AVAL_0441 }, 487 + { 48000, HDMI_NV_PDISP_SOR_AUDIO_AVAL_0480 }, 488 + { 88200, HDMI_NV_PDISP_SOR_AUDIO_AVAL_0882 }, 489 + { 96000, HDMI_NV_PDISP_SOR_AUDIO_AVAL_0960 }, 490 + { 176400, HDMI_NV_PDISP_SOR_AUDIO_AVAL_1764 }, 491 + { 192000, HDMI_NV_PDISP_SOR_AUDIO_AVAL_1920 }, 492 + }; 493 + unsigned int i; 494 + 495 + for (i = 0; i < ARRAY_SIZE(regs); i++) { 496 + if (regs[i].sample_rate == hdmi->audio_sample_rate) { 497 + tegra_hdmi_writel(hdmi, value, regs[i].offset); 498 + break; 499 + } 500 + } 501 + } 502 + 503 + static int tegra_hdmi_setup_audio(struct tegra_hdmi *hdmi) 504 + { 492 505 const struct tegra_hdmi_audio_config *config; 493 - unsigned int offset = 0; 494 - u32 value; 506 + u32 source, value; 495 507 496 508 switch (hdmi->audio_source) { 497 509 case HDA: 498 - value = AUDIO_CNTRL0_SOURCE_SELECT_HDAL; 510 + if (hdmi->config->has_hda) 511 + source = SOR_AUDIO_CNTRL0_SOURCE_SELECT_HDAL; 512 + else 513 + return -EINVAL; 514 + 499 515 break; 500 516 501 517 case SPDIF: 502 - value = AUDIO_CNTRL0_SOURCE_SELECT_SPDIF; 518 + if (hdmi->config->has_hda) 519 + source = SOR_AUDIO_CNTRL0_SOURCE_SELECT_SPDIF; 520 + else 521 + source = AUDIO_CNTRL0_SOURCE_SELECT_SPDIF; 503 522 break; 504 523 505 524 default: 506 - value = AUDIO_CNTRL0_SOURCE_SELECT_AUTO; 525 + if (hdmi->config->has_hda) 526 + source = SOR_AUDIO_CNTRL0_SOURCE_SELECT_AUTO; 527 + else 528 + source = AUDIO_CNTRL0_SOURCE_SELECT_AUTO; 507 529 break; 508 530 } 509 531 510 - if (of_device_is_compatible(node, "nvidia,tegra30-hdmi")) { 511 - value |= AUDIO_CNTRL0_ERROR_TOLERANCE(6) | 512 - AUDIO_CNTRL0_FRAMES_PER_BLOCK(0xc0); 513 - tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_AUDIO_CNTRL0); 514 - } else { 515 - value |= AUDIO_CNTRL0_INJECT_NULLSMPL; 516 - tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_SOR_AUDIO_CNTRL0); 532 + /* 533 + * Tegra30 and later use a slightly modified version of the register 534 + * layout to accomodate for changes related to supporting HDA as the 535 + * audio input source for HDMI. The source select field has moved to 536 + * the SOR_AUDIO_CNTRL0 register, but the error tolerance and frames 537 + * per block fields remain in the AUDIO_CNTRL0 register. 538 + */ 539 + if (hdmi->config->has_hda) { 540 + /* 541 + * Inject null samples into the audio FIFO for every frame in 542 + * which the codec did not receive any samples. This applies 543 + * to stereo LPCM only. 544 + * 545 + * XXX: This seems to be a remnant of MCP days when this was 546 + * used to work around issues with monitors not being able to 547 + * play back system startup sounds early. It is possibly not 548 + * needed on Linux at all. 549 + */ 550 + if (hdmi->audio_channels == 2) 551 + value = SOR_AUDIO_CNTRL0_INJECT_NULLSMPL; 552 + else 553 + value = 0; 517 554 518 - value = AUDIO_CNTRL0_ERROR_TOLERANCE(6) | 519 - AUDIO_CNTRL0_FRAMES_PER_BLOCK(0xc0); 520 - tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_AUDIO_CNTRL0); 555 + value |= source; 556 + 557 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_SOR_AUDIO_CNTRL0); 521 558 } 522 559 523 - config = tegra_hdmi_get_audio_config(hdmi->audio_freq, pclk); 560 + /* 561 + * On Tegra20, HDA is not a supported audio source and the source 562 + * select field is part of the AUDIO_CNTRL0 register. 563 + */ 564 + value = AUDIO_CNTRL0_FRAMES_PER_BLOCK(0xc0) | 565 + AUDIO_CNTRL0_ERROR_TOLERANCE(6); 566 + 567 + if (!hdmi->config->has_hda) 568 + value |= source; 569 + 570 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_AUDIO_CNTRL0); 571 + 572 + /* 573 + * Advertise support for High Bit-Rate on Tegra114 and later. 574 + */ 575 + if (hdmi->config->has_hbr) { 576 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_SOR_AUDIO_SPARE0); 577 + value |= SOR_AUDIO_SPARE0_HBR_ENABLE; 578 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_SOR_AUDIO_SPARE0); 579 + } 580 + 581 + config = tegra_hdmi_get_audio_config(hdmi->audio_sample_rate, 582 + hdmi->pixel_clock); 524 583 if (!config) { 525 - dev_err(hdmi->dev, "cannot set audio to %u at %u pclk\n", 526 - hdmi->audio_freq, pclk); 584 + dev_err(hdmi->dev, 585 + "cannot set audio to %u Hz at %u Hz pixel clock\n", 586 + hdmi->audio_sample_rate, hdmi->pixel_clock); 527 587 return -EINVAL; 528 588 } 529 589 ··· 606 526 tegra_hdmi_writel(hdmi, ACR_SUBPACK_N(config->n) | ACR_ENABLE, 607 527 HDMI_NV_PDISP_HDMI_ACR_0441_SUBPACK_HIGH); 608 528 609 - value = ACR_SUBPACK_CTS(config->cts); 610 - tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_ACR_0441_SUBPACK_LOW); 529 + tegra_hdmi_writel(hdmi, ACR_SUBPACK_CTS(config->cts), 530 + HDMI_NV_PDISP_HDMI_ACR_0441_SUBPACK_LOW); 611 531 612 532 value = SPARE_HW_CTS | SPARE_FORCE_SW_CTS | SPARE_CTS_RESET_VAL(1); 613 533 tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_SPARE); ··· 616 536 value &= ~AUDIO_N_RESETF; 617 537 tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_AUDIO_N); 618 538 619 - if (of_device_is_compatible(node, "nvidia,tegra30-hdmi")) { 620 - switch (hdmi->audio_freq) { 621 - case 32000: 622 - offset = HDMI_NV_PDISP_SOR_AUDIO_AVAL_0320; 623 - break; 624 - 625 - case 44100: 626 - offset = HDMI_NV_PDISP_SOR_AUDIO_AVAL_0441; 627 - break; 628 - 629 - case 48000: 630 - offset = HDMI_NV_PDISP_SOR_AUDIO_AVAL_0480; 631 - break; 632 - 633 - case 88200: 634 - offset = HDMI_NV_PDISP_SOR_AUDIO_AVAL_0882; 635 - break; 636 - 637 - case 96000: 638 - offset = HDMI_NV_PDISP_SOR_AUDIO_AVAL_0960; 639 - break; 640 - 641 - case 176400: 642 - offset = HDMI_NV_PDISP_SOR_AUDIO_AVAL_1764; 643 - break; 644 - 645 - case 192000: 646 - offset = HDMI_NV_PDISP_SOR_AUDIO_AVAL_1920; 647 - break; 648 - } 649 - 650 - tegra_hdmi_writel(hdmi, config->aval, offset); 651 - } 539 + if (hdmi->config->has_hda) 540 + tegra_hdmi_write_aval(hdmi, config->aval); 652 541 653 542 tegra_hdmi_setup_audio_fs_tables(hdmi); 654 543 655 544 return 0; 545 + } 546 + 547 + static void tegra_hdmi_disable_audio(struct tegra_hdmi *hdmi) 548 + { 549 + u32 value; 550 + 551 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 552 + value &= ~GENERIC_CTRL_AUDIO; 553 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 554 + } 555 + 556 + static void tegra_hdmi_enable_audio(struct tegra_hdmi *hdmi) 557 + { 558 + u32 value; 559 + 560 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 561 + value |= GENERIC_CTRL_AUDIO; 562 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 563 + } 564 + 565 + static void tegra_hdmi_write_eld(struct tegra_hdmi *hdmi) 566 + { 567 + size_t length = drm_eld_size(hdmi->output.connector.eld), i; 568 + u32 value; 569 + 570 + for (i = 0; i < length; i++) 571 + tegra_hdmi_writel(hdmi, i << 8 | hdmi->output.connector.eld[i], 572 + HDMI_NV_PDISP_SOR_AUDIO_HDA_ELD_BUFWR); 573 + 574 + /* 575 + * The HDA codec will always report an ELD buffer size of 96 bytes and 576 + * the HDA codec driver will check that each byte read from the buffer 577 + * is valid. Therefore every byte must be written, even if no 96 bytes 578 + * were parsed from EDID. 579 + */ 580 + for (i = length; i < HDMI_ELD_BUFFER_SIZE; i++) 581 + tegra_hdmi_writel(hdmi, i << 8 | 0, 582 + HDMI_NV_PDISP_SOR_AUDIO_HDA_ELD_BUFWR); 583 + 584 + value = SOR_AUDIO_HDA_PRESENSE_VALID | SOR_AUDIO_HDA_PRESENSE_PRESENT; 585 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_SOR_AUDIO_HDA_PRESENSE); 656 586 } 657 587 658 588 static inline u32 tegra_hdmi_subpack(const u8 *ptr, size_t size) ··· 734 644 u8 buffer[17]; 735 645 ssize_t err; 736 646 737 - if (hdmi->dvi) { 738 - tegra_hdmi_writel(hdmi, 0, 739 - HDMI_NV_PDISP_HDMI_AVI_INFOFRAME_CTRL); 740 - return; 741 - } 742 - 743 647 err = drm_hdmi_avi_infoframe_from_display_mode(&frame, mode); 744 648 if (err < 0) { 745 649 dev_err(hdmi->dev, "failed to setup AVI infoframe: %zd\n", err); ··· 747 663 } 748 664 749 665 tegra_hdmi_write_infopack(hdmi, buffer, err); 666 + } 750 667 751 - tegra_hdmi_writel(hdmi, INFOFRAME_CTRL_ENABLE, 752 - HDMI_NV_PDISP_HDMI_AVI_INFOFRAME_CTRL); 668 + static void tegra_hdmi_disable_avi_infoframe(struct tegra_hdmi *hdmi) 669 + { 670 + u32 value; 671 + 672 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_AVI_INFOFRAME_CTRL); 673 + value &= ~INFOFRAME_CTRL_ENABLE; 674 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_AVI_INFOFRAME_CTRL); 675 + } 676 + 677 + static void tegra_hdmi_enable_avi_infoframe(struct tegra_hdmi *hdmi) 678 + { 679 + u32 value; 680 + 681 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_AVI_INFOFRAME_CTRL); 682 + value |= INFOFRAME_CTRL_ENABLE; 683 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_AVI_INFOFRAME_CTRL); 753 684 } 754 685 755 686 static void tegra_hdmi_setup_audio_infoframe(struct tegra_hdmi *hdmi) ··· 773 674 u8 buffer[14]; 774 675 ssize_t err; 775 676 776 - if (hdmi->dvi) { 777 - tegra_hdmi_writel(hdmi, 0, 778 - HDMI_NV_PDISP_HDMI_AUDIO_INFOFRAME_CTRL); 779 - return; 780 - } 781 - 782 677 err = hdmi_audio_infoframe_init(&frame); 783 678 if (err < 0) { 784 679 dev_err(hdmi->dev, "failed to setup audio infoframe: %zd\n", ··· 780 687 return; 781 688 } 782 689 783 - frame.channels = 2; 690 + frame.channels = hdmi->audio_channels; 784 691 785 692 err = hdmi_audio_infoframe_pack(&frame, buffer, sizeof(buffer)); 786 693 if (err < 0) { ··· 796 703 * bytes can be programmed. 797 704 */ 798 705 tegra_hdmi_write_infopack(hdmi, buffer, min_t(size_t, 10, err)); 706 + } 799 707 800 - tegra_hdmi_writel(hdmi, INFOFRAME_CTRL_ENABLE, 801 - HDMI_NV_PDISP_HDMI_AUDIO_INFOFRAME_CTRL); 708 + static void tegra_hdmi_disable_audio_infoframe(struct tegra_hdmi *hdmi) 709 + { 710 + u32 value; 711 + 712 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_AUDIO_INFOFRAME_CTRL); 713 + value &= ~INFOFRAME_CTRL_ENABLE; 714 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_AUDIO_INFOFRAME_CTRL); 715 + } 716 + 717 + static void tegra_hdmi_enable_audio_infoframe(struct tegra_hdmi *hdmi) 718 + { 719 + u32 value; 720 + 721 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_AUDIO_INFOFRAME_CTRL); 722 + value |= INFOFRAME_CTRL_ENABLE; 723 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_AUDIO_INFOFRAME_CTRL); 802 724 } 803 725 804 726 static void tegra_hdmi_setup_stereo_infoframe(struct tegra_hdmi *hdmi) ··· 821 713 struct hdmi_vendor_infoframe frame; 822 714 u8 buffer[10]; 823 715 ssize_t err; 824 - u32 value; 825 - 826 - if (!hdmi->stereo) { 827 - value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 828 - value &= ~GENERIC_CTRL_ENABLE; 829 - tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 830 - return; 831 - } 832 716 833 717 hdmi_vendor_infoframe_init(&frame); 834 718 frame.s3d_struct = HDMI_3D_STRUCTURE_FRAME_PACKING; ··· 833 733 } 834 734 835 735 tegra_hdmi_write_infopack(hdmi, buffer, err); 736 + } 737 + 738 + static void tegra_hdmi_disable_stereo_infoframe(struct tegra_hdmi *hdmi) 739 + { 740 + u32 value; 741 + 742 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 743 + value &= ~GENERIC_CTRL_ENABLE; 744 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 745 + } 746 + 747 + static void tegra_hdmi_enable_stereo_infoframe(struct tegra_hdmi *hdmi) 748 + { 749 + u32 value; 836 750 837 751 value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 838 752 value |= GENERIC_CTRL_ENABLE; ··· 886 772 return drm_detect_hdmi_monitor(edid); 887 773 } 888 774 775 + static enum drm_connector_status 776 + tegra_hdmi_connector_detect(struct drm_connector *connector, bool force) 777 + { 778 + struct tegra_output *output = connector_to_output(connector); 779 + struct tegra_hdmi *hdmi = to_hdmi(output); 780 + enum drm_connector_status status; 781 + 782 + status = tegra_output_connector_detect(connector, force); 783 + if (status == connector_status_connected) 784 + return status; 785 + 786 + tegra_hdmi_writel(hdmi, 0, HDMI_NV_PDISP_SOR_AUDIO_HDA_PRESENSE); 787 + return status; 788 + } 789 + 889 790 static const struct drm_connector_funcs tegra_hdmi_connector_funcs = { 890 791 .dpms = drm_atomic_helper_connector_dpms, 891 792 .reset = drm_atomic_helper_connector_reset, 892 - .detect = tegra_output_connector_detect, 793 + .detect = tegra_hdmi_connector_detect, 893 794 .fill_modes = drm_helper_probe_single_connector_modes, 894 795 .destroy = tegra_output_connector_destroy, 895 796 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, ··· 943 814 944 815 static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder) 945 816 { 817 + struct tegra_output *output = encoder_to_output(encoder); 946 818 struct tegra_dc *dc = to_tegra_dc(encoder->crtc); 819 + struct tegra_hdmi *hdmi = to_hdmi(output); 947 820 u32 value; 948 821 949 822 /* ··· 959 828 960 829 tegra_dc_commit(dc); 961 830 } 831 + 832 + if (!hdmi->dvi) { 833 + if (hdmi->stereo) 834 + tegra_hdmi_disable_stereo_infoframe(hdmi); 835 + 836 + tegra_hdmi_disable_audio_infoframe(hdmi); 837 + tegra_hdmi_disable_avi_infoframe(hdmi); 838 + tegra_hdmi_disable_audio(hdmi); 839 + } 840 + 841 + tegra_hdmi_writel(hdmi, 0, HDMI_NV_PDISP_INT_ENABLE); 842 + tegra_hdmi_writel(hdmi, 0, HDMI_NV_PDISP_INT_MASK); 843 + 844 + pm_runtime_put(hdmi->dev); 962 845 } 963 846 964 847 static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder) ··· 981 836 unsigned int h_sync_width, h_front_porch, h_back_porch, i, rekey; 982 837 struct tegra_output *output = encoder_to_output(encoder); 983 838 struct tegra_dc *dc = to_tegra_dc(encoder->crtc); 984 - struct device_node *node = output->dev->of_node; 985 839 struct tegra_hdmi *hdmi = to_hdmi(output); 986 - unsigned int pulse_start, div82, pclk; 840 + unsigned int pulse_start, div82; 987 841 int retries = 1000; 988 842 u32 value; 989 843 int err; 990 844 991 - hdmi->dvi = !tegra_output_is_hdmi(output); 845 + pm_runtime_get_sync(hdmi->dev); 992 846 993 - pclk = mode->clock * 1000; 847 + /* 848 + * Enable and unmask the HDA codec SCRATCH0 register interrupt. This 849 + * is used for interoperability between the HDA codec driver and the 850 + * HDMI driver. 851 + */ 852 + tegra_hdmi_writel(hdmi, INT_CODEC_SCRATCH0, HDMI_NV_PDISP_INT_ENABLE); 853 + tegra_hdmi_writel(hdmi, INT_CODEC_SCRATCH0, HDMI_NV_PDISP_INT_MASK); 854 + 855 + hdmi->pixel_clock = mode->clock * 1000; 994 856 h_sync_width = mode->hsync_end - mode->hsync_start; 995 857 h_back_porch = mode->htotal - mode->hsync_end; 996 858 h_front_porch = mode->hsync_start - mode->hdisplay; 997 859 998 - err = clk_set_rate(hdmi->clk, pclk); 860 + err = clk_set_rate(hdmi->clk, hdmi->pixel_clock); 999 861 if (err < 0) { 1000 862 dev_err(hdmi->dev, "failed to set HDMI clock frequency: %d\n", 1001 863 err); ··· 1061 909 value = SOR_REFCLK_DIV_INT(div82 >> 2) | SOR_REFCLK_DIV_FRAC(div82); 1062 910 tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_SOR_REFCLK); 1063 911 912 + hdmi->dvi = !tegra_output_is_hdmi(output); 1064 913 if (!hdmi->dvi) { 1065 - err = tegra_hdmi_setup_audio(hdmi, pclk); 914 + err = tegra_hdmi_setup_audio(hdmi); 1066 915 if (err < 0) 1067 916 hdmi->dvi = true; 1068 917 } 1069 918 1070 - if (of_device_is_compatible(node, "nvidia,tegra20-hdmi")) { 1071 - /* 1072 - * TODO: add ELD support 1073 - */ 1074 - } 919 + if (hdmi->config->has_hda) 920 + tegra_hdmi_write_eld(hdmi); 1075 921 1076 922 rekey = HDMI_REKEY_DEFAULT; 1077 923 value = HDMI_CTRL_REKEY(rekey); ··· 1081 931 1082 932 tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_HDMI_CTRL); 1083 933 1084 - if (hdmi->dvi) 1085 - tegra_hdmi_writel(hdmi, 0x0, 1086 - HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 1087 - else 1088 - tegra_hdmi_writel(hdmi, GENERIC_CTRL_AUDIO, 1089 - HDMI_NV_PDISP_HDMI_GENERIC_CTRL); 934 + if (!hdmi->dvi) { 935 + tegra_hdmi_setup_avi_infoframe(hdmi, mode); 936 + tegra_hdmi_setup_audio_infoframe(hdmi); 1090 937 1091 - tegra_hdmi_setup_avi_infoframe(hdmi, mode); 1092 - tegra_hdmi_setup_audio_infoframe(hdmi); 1093 - tegra_hdmi_setup_stereo_infoframe(hdmi); 938 + if (hdmi->stereo) 939 + tegra_hdmi_setup_stereo_infoframe(hdmi); 940 + } 1094 941 1095 942 /* TMDS CONFIG */ 1096 943 for (i = 0; i < hdmi->config->num_tmds; i++) { 1097 - if (pclk <= hdmi->config->tmds[i].pclk) { 944 + if (hdmi->pixel_clock <= hdmi->config->tmds[i].pclk) { 1098 945 tegra_hdmi_setup_tmds(hdmi, &hdmi->config->tmds[i]); 1099 946 break; 1100 947 } ··· 1177 1030 tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS); 1178 1031 1179 1032 tegra_dc_commit(dc); 1033 + 1034 + if (!hdmi->dvi) { 1035 + tegra_hdmi_enable_avi_infoframe(hdmi); 1036 + tegra_hdmi_enable_audio_infoframe(hdmi); 1037 + tegra_hdmi_enable_audio(hdmi); 1038 + 1039 + if (hdmi->stereo) 1040 + tegra_hdmi_enable_stereo_infoframe(hdmi); 1041 + } 1180 1042 1181 1043 /* TODO: add HDCP support */ 1182 1044 } ··· 1391 1235 DUMP_REG(HDMI_NV_PDISP_KEY_HDCP_KEY_TRIG); 1392 1236 DUMP_REG(HDMI_NV_PDISP_KEY_SKEY_INDEX); 1393 1237 DUMP_REG(HDMI_NV_PDISP_SOR_AUDIO_CNTRL0); 1238 + DUMP_REG(HDMI_NV_PDISP_SOR_AUDIO_SPARE0); 1239 + DUMP_REG(HDMI_NV_PDISP_SOR_AUDIO_HDA_CODEC_SCRATCH0); 1240 + DUMP_REG(HDMI_NV_PDISP_SOR_AUDIO_HDA_CODEC_SCRATCH1); 1394 1241 DUMP_REG(HDMI_NV_PDISP_SOR_AUDIO_HDA_ELD_BUFWR); 1395 1242 DUMP_REG(HDMI_NV_PDISP_SOR_AUDIO_HDA_PRESENSE); 1243 + DUMP_REG(HDMI_NV_PDISP_INT_STATUS); 1244 + DUMP_REG(HDMI_NV_PDISP_INT_MASK); 1245 + DUMP_REG(HDMI_NV_PDISP_INT_ENABLE); 1396 1246 DUMP_REG(HDMI_NV_PDISP_SOR_IO_PEAK_CURRENT); 1397 1247 1398 1248 #undef DUMP_REG ··· 1522 1360 return err; 1523 1361 } 1524 1362 1525 - err = clk_prepare_enable(hdmi->clk); 1526 - if (err < 0) { 1527 - dev_err(hdmi->dev, "failed to enable clock: %d\n", err); 1528 - return err; 1529 - } 1530 - 1531 - reset_control_deassert(hdmi->rst); 1532 - 1533 1363 return 0; 1534 1364 } 1535 1365 ··· 1530 1376 struct tegra_hdmi *hdmi = host1x_client_to_hdmi(client); 1531 1377 1532 1378 tegra_output_exit(&hdmi->output); 1533 - 1534 - reset_control_assert(hdmi->rst); 1535 - clk_disable_unprepare(hdmi->clk); 1536 1379 1537 1380 regulator_disable(hdmi->vdd); 1538 1381 regulator_disable(hdmi->pll); ··· 1552 1401 .fuse_override_offset = HDMI_NV_PDISP_SOR_LANE_DRIVE_CURRENT, 1553 1402 .fuse_override_value = 1 << 31, 1554 1403 .has_sor_io_peak_current = false, 1404 + .has_hda = false, 1405 + .has_hbr = false, 1555 1406 }; 1556 1407 1557 1408 static const struct tegra_hdmi_config tegra30_hdmi_config = { ··· 1562 1409 .fuse_override_offset = HDMI_NV_PDISP_SOR_LANE_DRIVE_CURRENT, 1563 1410 .fuse_override_value = 1 << 31, 1564 1411 .has_sor_io_peak_current = false, 1412 + .has_hda = true, 1413 + .has_hbr = false, 1565 1414 }; 1566 1415 1567 1416 static const struct tegra_hdmi_config tegra114_hdmi_config = { ··· 1572 1417 .fuse_override_offset = HDMI_NV_PDISP_SOR_PAD_CTLS0, 1573 1418 .fuse_override_value = 1 << 31, 1574 1419 .has_sor_io_peak_current = true, 1420 + .has_hda = true, 1421 + .has_hbr = true, 1575 1422 }; 1576 1423 1577 1424 static const struct tegra_hdmi_config tegra124_hdmi_config = { ··· 1582 1425 .fuse_override_offset = HDMI_NV_PDISP_SOR_PAD_CTLS0, 1583 1426 .fuse_override_value = 1 << 31, 1584 1427 .has_sor_io_peak_current = true, 1428 + .has_hda = true, 1429 + .has_hbr = true, 1585 1430 }; 1586 1431 1587 1432 static const struct of_device_id tegra_hdmi_of_match[] = { ··· 1594 1435 { }, 1595 1436 }; 1596 1437 MODULE_DEVICE_TABLE(of, tegra_hdmi_of_match); 1438 + 1439 + static void hda_format_parse(unsigned int format, unsigned int *rate, 1440 + unsigned int *channels) 1441 + { 1442 + unsigned int mul, div; 1443 + 1444 + if (format & AC_FMT_BASE_44K) 1445 + *rate = 44100; 1446 + else 1447 + *rate = 48000; 1448 + 1449 + mul = (format & AC_FMT_MULT_MASK) >> AC_FMT_MULT_SHIFT; 1450 + div = (format & AC_FMT_DIV_MASK) >> AC_FMT_DIV_SHIFT; 1451 + 1452 + *rate = *rate * (mul + 1) / (div + 1); 1453 + 1454 + *channels = (format & AC_FMT_CHAN_MASK) >> AC_FMT_CHAN_SHIFT; 1455 + } 1456 + 1457 + static irqreturn_t tegra_hdmi_irq(int irq, void *data) 1458 + { 1459 + struct tegra_hdmi *hdmi = data; 1460 + u32 value; 1461 + int err; 1462 + 1463 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_INT_STATUS); 1464 + tegra_hdmi_writel(hdmi, value, HDMI_NV_PDISP_INT_STATUS); 1465 + 1466 + if (value & INT_CODEC_SCRATCH0) { 1467 + unsigned int format; 1468 + u32 value; 1469 + 1470 + value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_SOR_AUDIO_HDA_CODEC_SCRATCH0); 1471 + 1472 + if (value & SOR_AUDIO_HDA_CODEC_SCRATCH0_VALID) { 1473 + unsigned int sample_rate, channels; 1474 + 1475 + format = value & SOR_AUDIO_HDA_CODEC_SCRATCH0_FMT_MASK; 1476 + 1477 + hda_format_parse(format, &sample_rate, &channels); 1478 + 1479 + hdmi->audio_sample_rate = sample_rate; 1480 + hdmi->audio_channels = channels; 1481 + 1482 + err = tegra_hdmi_setup_audio(hdmi); 1483 + if (err < 0) { 1484 + tegra_hdmi_disable_audio_infoframe(hdmi); 1485 + tegra_hdmi_disable_audio(hdmi); 1486 + } else { 1487 + tegra_hdmi_setup_audio_infoframe(hdmi); 1488 + tegra_hdmi_enable_audio_infoframe(hdmi); 1489 + tegra_hdmi_enable_audio(hdmi); 1490 + } 1491 + } else { 1492 + tegra_hdmi_disable_audio_infoframe(hdmi); 1493 + tegra_hdmi_disable_audio(hdmi); 1494 + } 1495 + } 1496 + 1497 + return IRQ_HANDLED; 1498 + } 1597 1499 1598 1500 static int tegra_hdmi_probe(struct platform_device *pdev) 1599 1501 { ··· 1673 1453 1674 1454 hdmi->config = match->data; 1675 1455 hdmi->dev = &pdev->dev; 1456 + 1676 1457 hdmi->audio_source = AUTO; 1677 - hdmi->audio_freq = 44100; 1458 + hdmi->audio_sample_rate = 48000; 1459 + hdmi->audio_channels = 2; 1678 1460 hdmi->stereo = false; 1679 1461 hdmi->dvi = false; 1680 1462 ··· 1737 1515 1738 1516 hdmi->irq = err; 1739 1517 1518 + err = devm_request_irq(hdmi->dev, hdmi->irq, tegra_hdmi_irq, 0, 1519 + dev_name(hdmi->dev), hdmi); 1520 + if (err < 0) { 1521 + dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", 1522 + hdmi->irq, err); 1523 + return err; 1524 + } 1525 + 1526 + platform_set_drvdata(pdev, hdmi); 1527 + pm_runtime_enable(&pdev->dev); 1528 + 1740 1529 INIT_LIST_HEAD(&hdmi->client.list); 1741 1530 hdmi->client.ops = &hdmi_client_ops; 1742 1531 hdmi->client.dev = &pdev->dev; ··· 1759 1526 return err; 1760 1527 } 1761 1528 1762 - platform_set_drvdata(pdev, hdmi); 1763 - 1764 1529 return 0; 1765 1530 } 1766 1531 ··· 1766 1535 { 1767 1536 struct tegra_hdmi *hdmi = platform_get_drvdata(pdev); 1768 1537 int err; 1538 + 1539 + pm_runtime_disable(&pdev->dev); 1769 1540 1770 1541 err = host1x_client_unregister(&hdmi->client); 1771 1542 if (err < 0) { ··· 1778 1545 1779 1546 tegra_output_remove(&hdmi->output); 1780 1547 1781 - clk_disable_unprepare(hdmi->clk_parent); 1548 + return 0; 1549 + } 1550 + 1551 + #ifdef CONFIG_PM 1552 + static int tegra_hdmi_suspend(struct device *dev) 1553 + { 1554 + struct tegra_hdmi *hdmi = dev_get_drvdata(dev); 1555 + int err; 1556 + 1557 + err = reset_control_assert(hdmi->rst); 1558 + if (err < 0) { 1559 + dev_err(dev, "failed to assert reset: %d\n", err); 1560 + return err; 1561 + } 1562 + 1563 + usleep_range(1000, 2000); 1564 + 1782 1565 clk_disable_unprepare(hdmi->clk); 1783 1566 1784 1567 return 0; 1785 1568 } 1786 1569 1570 + static int tegra_hdmi_resume(struct device *dev) 1571 + { 1572 + struct tegra_hdmi *hdmi = dev_get_drvdata(dev); 1573 + int err; 1574 + 1575 + err = clk_prepare_enable(hdmi->clk); 1576 + if (err < 0) { 1577 + dev_err(dev, "failed to enable clock: %d\n", err); 1578 + return err; 1579 + } 1580 + 1581 + usleep_range(1000, 2000); 1582 + 1583 + err = reset_control_deassert(hdmi->rst); 1584 + if (err < 0) { 1585 + dev_err(dev, "failed to deassert reset: %d\n", err); 1586 + clk_disable_unprepare(hdmi->clk); 1587 + return err; 1588 + } 1589 + 1590 + return 0; 1591 + } 1592 + #endif 1593 + 1594 + static const struct dev_pm_ops tegra_hdmi_pm_ops = { 1595 + SET_RUNTIME_PM_OPS(tegra_hdmi_suspend, tegra_hdmi_resume, NULL) 1596 + }; 1597 + 1787 1598 struct platform_driver tegra_hdmi_driver = { 1788 1599 .driver = { 1789 1600 .name = "tegra-hdmi", 1790 - .owner = THIS_MODULE, 1791 1601 .of_match_table = tegra_hdmi_of_match, 1602 + .pm = &tegra_hdmi_pm_ops, 1792 1603 }, 1793 1604 .probe = tegra_hdmi_probe, 1794 1605 .remove = tegra_hdmi_remove,
+20 -1
drivers/gpu/drm/tegra/hdmi.h
··· 468 468 #define HDMI_NV_PDISP_KEY_SKEY_INDEX 0xa3 469 469 470 470 #define HDMI_NV_PDISP_SOR_AUDIO_CNTRL0 0xac 471 - #define AUDIO_CNTRL0_INJECT_NULLSMPL (1 << 29) 471 + #define SOR_AUDIO_CNTRL0_SOURCE_SELECT_AUTO (0 << 20) 472 + #define SOR_AUDIO_CNTRL0_SOURCE_SELECT_SPDIF (1 << 20) 473 + #define SOR_AUDIO_CNTRL0_SOURCE_SELECT_HDAL (2 << 20) 474 + #define SOR_AUDIO_CNTRL0_INJECT_NULLSMPL (1 << 29) 475 + #define HDMI_NV_PDISP_SOR_AUDIO_SPARE0 0xae 476 + #define SOR_AUDIO_SPARE0_HBR_ENABLE (1 << 27) 477 + #define HDMI_NV_PDISP_SOR_AUDIO_HDA_CODEC_SCRATCH0 0xba 478 + #define SOR_AUDIO_HDA_CODEC_SCRATCH0_VALID (1 << 30) 479 + #define SOR_AUDIO_HDA_CODEC_SCRATCH0_FMT_MASK 0xffff 480 + #define HDMI_NV_PDISP_SOR_AUDIO_HDA_CODEC_SCRATCH1 0xbb 472 481 #define HDMI_NV_PDISP_SOR_AUDIO_HDA_ELD_BUFWR 0xbc 473 482 #define HDMI_NV_PDISP_SOR_AUDIO_HDA_PRESENSE 0xbd 483 + #define SOR_AUDIO_HDA_PRESENSE_VALID (1 << 1) 484 + #define SOR_AUDIO_HDA_PRESENSE_PRESENT (1 << 0) 474 485 475 486 #define HDMI_NV_PDISP_SOR_AUDIO_AVAL_0320 0xbf 476 487 #define HDMI_NV_PDISP_SOR_AUDIO_AVAL_0441 0xc0 ··· 491 480 #define HDMI_NV_PDISP_SOR_AUDIO_AVAL_0960 0xc4 492 481 #define HDMI_NV_PDISP_SOR_AUDIO_AVAL_1920 0xc5 493 482 #define HDMI_NV_PDISP_SOR_AUDIO_AVAL_DEFAULT 0xc5 483 + 484 + #define HDMI_NV_PDISP_INT_STATUS 0xcc 485 + #define INT_SCRATCH (1 << 3) 486 + #define INT_CP_REQUEST (1 << 2) 487 + #define INT_CODEC_SCRATCH1 (1 << 1) 488 + #define INT_CODEC_SCRATCH0 (1 << 0) 489 + #define HDMI_NV_PDISP_INT_MASK 0xcd 490 + #define HDMI_NV_PDISP_INT_ENABLE 0xce 494 491 495 492 #define HDMI_NV_PDISP_SOR_IO_PEAK_CURRENT 0xd1 496 493 #define PEAK_CURRENT_LANE0(x) (((x) & 0x7f) << 0)
+1
drivers/gpu/drm/tegra/output.c
··· 36 36 37 37 if (edid) { 38 38 err = drm_add_edid_modes(connector, edid); 39 + drm_edid_to_eld(connector, edid); 39 40 kfree(edid); 40 41 } 41 42
+485 -231
drivers/gpu/drm/tegra/sor.c
··· 7 7 */ 8 8 9 9 #include <linux/clk.h> 10 + #include <linux/clk-provider.h> 10 11 #include <linux/debugfs.h> 11 12 #include <linux/gpio.h> 12 13 #include <linux/io.h> 13 14 #include <linux/of_device.h> 14 15 #include <linux/platform_device.h> 16 + #include <linux/pm_runtime.h> 15 17 #include <linux/regulator/consumer.h> 16 18 #include <linux/reset.h> 17 19 ··· 151 149 152 150 const struct tegra_sor_hdmi_settings *settings; 153 151 unsigned int num_settings; 152 + 153 + const u8 *xbar_cfg; 154 154 }; 155 155 156 156 struct tegra_sor; ··· 173 169 174 170 struct reset_control *rst; 175 171 struct clk *clk_parent; 172 + struct clk *clk_brick; 176 173 struct clk *clk_safe; 174 + struct clk *clk_src; 177 175 struct clk *clk_dp; 178 176 struct clk *clk; 179 177 ··· 195 189 struct regulator *vdd_pll_supply; 196 190 struct regulator *hdmi_supply; 197 191 }; 192 + 193 + struct tegra_sor_state { 194 + struct drm_connector_state base; 195 + 196 + unsigned int bpc; 197 + }; 198 + 199 + static inline struct tegra_sor_state * 200 + to_sor_state(struct drm_connector_state *state) 201 + { 202 + return container_of(state, struct tegra_sor_state, base); 203 + } 198 204 199 205 struct tegra_sor_config { 200 206 u32 bits_per_pixel; ··· 241 223 unsigned long offset) 242 224 { 243 225 writel(value, sor->regs + (offset << 2)); 226 + } 227 + 228 + static int tegra_sor_set_parent_clock(struct tegra_sor *sor, struct clk *parent) 229 + { 230 + int err; 231 + 232 + clk_disable_unprepare(sor->clk); 233 + 234 + err = clk_set_parent(sor->clk, parent); 235 + if (err < 0) 236 + return err; 237 + 238 + err = clk_prepare_enable(sor->clk); 239 + if (err < 0) 240 + return err; 241 + 242 + return 0; 243 + } 244 + 245 + struct tegra_clk_sor_brick { 246 + struct clk_hw hw; 247 + struct tegra_sor *sor; 248 + }; 249 + 250 + static inline struct tegra_clk_sor_brick *to_brick(struct clk_hw *hw) 251 + { 252 + return container_of(hw, struct tegra_clk_sor_brick, hw); 253 + } 254 + 255 + static const char * const tegra_clk_sor_brick_parents[] = { 256 + "pll_d2_out0", "pll_dp" 257 + }; 258 + 259 + static int tegra_clk_sor_brick_set_parent(struct clk_hw *hw, u8 index) 260 + { 261 + struct tegra_clk_sor_brick *brick = to_brick(hw); 262 + struct tegra_sor *sor = brick->sor; 263 + u32 value; 264 + 265 + value = tegra_sor_readl(sor, SOR_CLK_CNTRL); 266 + value &= ~SOR_CLK_CNTRL_DP_CLK_SEL_MASK; 267 + 268 + switch (index) { 269 + case 0: 270 + value |= SOR_CLK_CNTRL_DP_CLK_SEL_SINGLE_PCLK; 271 + break; 272 + 273 + case 1: 274 + value |= SOR_CLK_CNTRL_DP_CLK_SEL_SINGLE_DPCLK; 275 + break; 276 + } 277 + 278 + tegra_sor_writel(sor, value, SOR_CLK_CNTRL); 279 + 280 + return 0; 281 + } 282 + 283 + static u8 tegra_clk_sor_brick_get_parent(struct clk_hw *hw) 284 + { 285 + struct tegra_clk_sor_brick *brick = to_brick(hw); 286 + struct tegra_sor *sor = brick->sor; 287 + u8 parent = U8_MAX; 288 + u32 value; 289 + 290 + value = tegra_sor_readl(sor, SOR_CLK_CNTRL); 291 + 292 + switch (value & SOR_CLK_CNTRL_DP_CLK_SEL_MASK) { 293 + case SOR_CLK_CNTRL_DP_CLK_SEL_SINGLE_PCLK: 294 + case SOR_CLK_CNTRL_DP_CLK_SEL_DIFF_PCLK: 295 + parent = 0; 296 + break; 297 + 298 + case SOR_CLK_CNTRL_DP_CLK_SEL_SINGLE_DPCLK: 299 + case SOR_CLK_CNTRL_DP_CLK_SEL_DIFF_DPCLK: 300 + parent = 1; 301 + break; 302 + } 303 + 304 + return parent; 305 + } 306 + 307 + static const struct clk_ops tegra_clk_sor_brick_ops = { 308 + .set_parent = tegra_clk_sor_brick_set_parent, 309 + .get_parent = tegra_clk_sor_brick_get_parent, 310 + }; 311 + 312 + static struct clk *tegra_clk_sor_brick_register(struct tegra_sor *sor, 313 + const char *name) 314 + { 315 + struct tegra_clk_sor_brick *brick; 316 + struct clk_init_data init; 317 + struct clk *clk; 318 + 319 + brick = devm_kzalloc(sor->dev, sizeof(*brick), GFP_KERNEL); 320 + if (!brick) 321 + return ERR_PTR(-ENOMEM); 322 + 323 + brick->sor = sor; 324 + 325 + init.name = name; 326 + init.flags = 0; 327 + init.parent_names = tegra_clk_sor_brick_parents; 328 + init.num_parents = ARRAY_SIZE(tegra_clk_sor_brick_parents); 329 + init.ops = &tegra_clk_sor_brick_ops; 330 + 331 + brick->hw.init = &init; 332 + 333 + clk = devm_clk_register(sor->dev, &brick->hw); 334 + if (IS_ERR(clk)) 335 + kfree(brick); 336 + 337 + return clk; 244 338 } 245 339 246 340 static int tegra_sor_dp_train_fast(struct tegra_sor *sor, ··· 699 569 return false; 700 570 } 701 571 702 - static int tegra_sor_calc_config(struct tegra_sor *sor, 703 - const struct drm_display_mode *mode, 704 - struct tegra_sor_config *config, 705 - struct drm_dp_link *link) 572 + static int tegra_sor_compute_config(struct tegra_sor *sor, 573 + const struct drm_display_mode *mode, 574 + struct tegra_sor_config *config, 575 + struct drm_dp_link *link) 706 576 { 707 577 const u64 f = 100000, link_rate = link->rate * 1000; 708 578 const u64 pclk = mode->clock * 1000; ··· 791 661 return 0; 792 662 } 793 663 664 + static void tegra_sor_apply_config(struct tegra_sor *sor, 665 + const struct tegra_sor_config *config) 666 + { 667 + u32 value; 668 + 669 + value = tegra_sor_readl(sor, SOR_DP_LINKCTL0); 670 + value &= ~SOR_DP_LINKCTL_TU_SIZE_MASK; 671 + value |= SOR_DP_LINKCTL_TU_SIZE(config->tu_size); 672 + tegra_sor_writel(sor, value, SOR_DP_LINKCTL0); 673 + 674 + value = tegra_sor_readl(sor, SOR_DP_CONFIG0); 675 + value &= ~SOR_DP_CONFIG_WATERMARK_MASK; 676 + value |= SOR_DP_CONFIG_WATERMARK(config->watermark); 677 + 678 + value &= ~SOR_DP_CONFIG_ACTIVE_SYM_COUNT_MASK; 679 + value |= SOR_DP_CONFIG_ACTIVE_SYM_COUNT(config->active_count); 680 + 681 + value &= ~SOR_DP_CONFIG_ACTIVE_SYM_FRAC_MASK; 682 + value |= SOR_DP_CONFIG_ACTIVE_SYM_FRAC(config->active_frac); 683 + 684 + if (config->active_polarity) 685 + value |= SOR_DP_CONFIG_ACTIVE_SYM_POLARITY; 686 + else 687 + value &= ~SOR_DP_CONFIG_ACTIVE_SYM_POLARITY; 688 + 689 + value |= SOR_DP_CONFIG_ACTIVE_SYM_ENABLE; 690 + value |= SOR_DP_CONFIG_DISPARITY_NEGATIVE; 691 + tegra_sor_writel(sor, value, SOR_DP_CONFIG0); 692 + 693 + value = tegra_sor_readl(sor, SOR_DP_AUDIO_HBLANK_SYMBOLS); 694 + value &= ~SOR_DP_AUDIO_HBLANK_SYMBOLS_MASK; 695 + value |= config->hblank_symbols & 0xffff; 696 + tegra_sor_writel(sor, value, SOR_DP_AUDIO_HBLANK_SYMBOLS); 697 + 698 + value = tegra_sor_readl(sor, SOR_DP_AUDIO_VBLANK_SYMBOLS); 699 + value &= ~SOR_DP_AUDIO_VBLANK_SYMBOLS_MASK; 700 + value |= config->vblank_symbols & 0xffff; 701 + tegra_sor_writel(sor, value, SOR_DP_AUDIO_VBLANK_SYMBOLS); 702 + } 703 + 704 + static void tegra_sor_mode_set(struct tegra_sor *sor, 705 + const struct drm_display_mode *mode, 706 + struct tegra_sor_state *state) 707 + { 708 + struct tegra_dc *dc = to_tegra_dc(sor->output.encoder.crtc); 709 + unsigned int vbe, vse, hbe, hse, vbs, hbs; 710 + u32 value; 711 + 712 + value = tegra_sor_readl(sor, SOR_STATE1); 713 + value &= ~SOR_STATE_ASY_PIXELDEPTH_MASK; 714 + value &= ~SOR_STATE_ASY_CRC_MODE_MASK; 715 + value &= ~SOR_STATE_ASY_OWNER_MASK; 716 + 717 + value |= SOR_STATE_ASY_CRC_MODE_COMPLETE | 718 + SOR_STATE_ASY_OWNER(dc->pipe + 1); 719 + 720 + if (mode->flags & DRM_MODE_FLAG_PHSYNC) 721 + value &= ~SOR_STATE_ASY_HSYNCPOL; 722 + 723 + if (mode->flags & DRM_MODE_FLAG_NHSYNC) 724 + value |= SOR_STATE_ASY_HSYNCPOL; 725 + 726 + if (mode->flags & DRM_MODE_FLAG_PVSYNC) 727 + value &= ~SOR_STATE_ASY_VSYNCPOL; 728 + 729 + if (mode->flags & DRM_MODE_FLAG_NVSYNC) 730 + value |= SOR_STATE_ASY_VSYNCPOL; 731 + 732 + switch (state->bpc) { 733 + case 16: 734 + value |= SOR_STATE_ASY_PIXELDEPTH_BPP_48_444; 735 + break; 736 + 737 + case 12: 738 + value |= SOR_STATE_ASY_PIXELDEPTH_BPP_36_444; 739 + break; 740 + 741 + case 10: 742 + value |= SOR_STATE_ASY_PIXELDEPTH_BPP_30_444; 743 + break; 744 + 745 + case 8: 746 + value |= SOR_STATE_ASY_PIXELDEPTH_BPP_24_444; 747 + break; 748 + 749 + case 6: 750 + value |= SOR_STATE_ASY_PIXELDEPTH_BPP_18_444; 751 + break; 752 + 753 + default: 754 + value |= SOR_STATE_ASY_PIXELDEPTH_BPP_24_444; 755 + break; 756 + } 757 + 758 + tegra_sor_writel(sor, value, SOR_STATE1); 759 + 760 + /* 761 + * TODO: The video timing programming below doesn't seem to match the 762 + * register definitions. 763 + */ 764 + 765 + value = ((mode->vtotal & 0x7fff) << 16) | (mode->htotal & 0x7fff); 766 + tegra_sor_writel(sor, value, SOR_HEAD_STATE1(dc->pipe)); 767 + 768 + /* sync end = sync width - 1 */ 769 + vse = mode->vsync_end - mode->vsync_start - 1; 770 + hse = mode->hsync_end - mode->hsync_start - 1; 771 + 772 + value = ((vse & 0x7fff) << 16) | (hse & 0x7fff); 773 + tegra_sor_writel(sor, value, SOR_HEAD_STATE2(dc->pipe)); 774 + 775 + /* blank end = sync end + back porch */ 776 + vbe = vse + (mode->vtotal - mode->vsync_end); 777 + hbe = hse + (mode->htotal - mode->hsync_end); 778 + 779 + value = ((vbe & 0x7fff) << 16) | (hbe & 0x7fff); 780 + tegra_sor_writel(sor, value, SOR_HEAD_STATE3(dc->pipe)); 781 + 782 + /* blank start = blank end + active */ 783 + vbs = vbe + mode->vdisplay; 784 + hbs = hbe + mode->hdisplay; 785 + 786 + value = ((vbs & 0x7fff) << 16) | (hbs & 0x7fff); 787 + tegra_sor_writel(sor, value, SOR_HEAD_STATE4(dc->pipe)); 788 + 789 + /* XXX interlacing support */ 790 + tegra_sor_writel(sor, 0x001, SOR_HEAD_STATE5(dc->pipe)); 791 + } 792 + 794 793 static int tegra_sor_detach(struct tegra_sor *sor) 795 794 { 796 795 unsigned long value, timeout; ··· 992 733 if ((value & SOR_PWR_TRIGGER) != 0) 993 734 return -ETIMEDOUT; 994 735 995 - err = clk_set_parent(sor->clk, sor->clk_safe); 736 + /* switch to safe parent clock */ 737 + err = tegra_sor_set_parent_clock(sor, sor->clk_safe); 996 738 if (err < 0) 997 739 dev_err(sor->dev, "failed to set safe parent clock: %d\n", err); 998 740 ··· 1298 1038 sor->debugfs = NULL; 1299 1039 } 1300 1040 1041 + static void tegra_sor_connector_reset(struct drm_connector *connector) 1042 + { 1043 + struct tegra_sor_state *state; 1044 + 1045 + state = kzalloc(sizeof(*state), GFP_KERNEL); 1046 + if (!state) 1047 + return; 1048 + 1049 + if (connector->state) { 1050 + __drm_atomic_helper_connector_destroy_state(connector->state); 1051 + kfree(connector->state); 1052 + } 1053 + 1054 + __drm_atomic_helper_connector_reset(connector, &state->base); 1055 + } 1056 + 1301 1057 static enum drm_connector_status 1302 1058 tegra_sor_connector_detect(struct drm_connector *connector, bool force) 1303 1059 { ··· 1326 1050 return tegra_output_connector_detect(connector, force); 1327 1051 } 1328 1052 1053 + static struct drm_connector_state * 1054 + tegra_sor_connector_duplicate_state(struct drm_connector *connector) 1055 + { 1056 + struct tegra_sor_state *state = to_sor_state(connector->state); 1057 + struct tegra_sor_state *copy; 1058 + 1059 + copy = kmemdup(state, sizeof(*state), GFP_KERNEL); 1060 + if (!copy) 1061 + return NULL; 1062 + 1063 + __drm_atomic_helper_connector_duplicate_state(connector, &copy->base); 1064 + 1065 + return &copy->base; 1066 + } 1067 + 1329 1068 static const struct drm_connector_funcs tegra_sor_connector_funcs = { 1330 1069 .dpms = drm_atomic_helper_connector_dpms, 1331 - .reset = drm_atomic_helper_connector_reset, 1070 + .reset = tegra_sor_connector_reset, 1332 1071 .detect = tegra_sor_connector_detect, 1333 1072 .fill_modes = drm_helper_probe_single_connector_modes, 1334 1073 .destroy = tegra_output_connector_destroy, 1335 - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, 1074 + .atomic_duplicate_state = tegra_sor_connector_duplicate_state, 1336 1075 .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 1337 1076 }; 1338 1077 ··· 1372 1081 tegra_sor_connector_mode_valid(struct drm_connector *connector, 1373 1082 struct drm_display_mode *mode) 1374 1083 { 1084 + /* HDMI 2.0 modes are not yet supported */ 1085 + if (mode->clock > 340000) 1086 + return MODE_NOCLOCK; 1087 + 1375 1088 return MODE_OK; 1376 1089 } 1377 1090 ··· 1435 1140 if (output->panel) 1436 1141 drm_panel_unprepare(output->panel); 1437 1142 1438 - reset_control_assert(sor->rst); 1439 - clk_disable_unprepare(sor->clk); 1143 + pm_runtime_put(sor->dev); 1440 1144 } 1441 1145 1442 1146 #if 0 ··· 1485 1191 struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; 1486 1192 struct tegra_output *output = encoder_to_output(encoder); 1487 1193 struct tegra_dc *dc = to_tegra_dc(encoder->crtc); 1488 - unsigned int vbe, vse, hbe, hse, vbs, hbs, i; 1489 1194 struct tegra_sor *sor = to_sor(output); 1490 1195 struct tegra_sor_config config; 1196 + struct tegra_sor_state *state; 1491 1197 struct drm_dp_link link; 1492 1198 u8 rate, lanes; 1199 + unsigned int i; 1493 1200 int err = 0; 1494 1201 u32 value; 1495 1202 1496 - err = clk_prepare_enable(sor->clk); 1497 - if (err < 0) 1498 - dev_err(sor->dev, "failed to enable clock: %d\n", err); 1203 + state = to_sor_state(output->connector.state); 1499 1204 1500 - reset_control_deassert(sor->rst); 1205 + pm_runtime_get_sync(sor->dev); 1501 1206 1502 1207 if (output->panel) 1503 1208 drm_panel_prepare(output->panel); ··· 1511 1218 return; 1512 1219 } 1513 1220 1514 - err = clk_set_parent(sor->clk, sor->clk_safe); 1221 + /* switch to safe parent clock */ 1222 + err = tegra_sor_set_parent_clock(sor, sor->clk_safe); 1515 1223 if (err < 0) 1516 1224 dev_err(sor->dev, "failed to set safe parent clock: %d\n", err); 1517 1225 1518 1226 memset(&config, 0, sizeof(config)); 1519 - config.bits_per_pixel = output->connector.display_info.bpc * 3; 1227 + config.bits_per_pixel = state->bpc * 3; 1520 1228 1521 - err = tegra_sor_calc_config(sor, mode, &config, &link); 1229 + err = tegra_sor_compute_config(sor, mode, &config, &link); 1522 1230 if (err < 0) 1523 - dev_err(sor->dev, "failed to compute link configuration: %d\n", 1524 - err); 1231 + dev_err(sor->dev, "failed to compute configuration: %d\n", err); 1525 1232 1526 1233 value = tegra_sor_readl(sor, SOR_CLK_CNTRL); 1527 1234 value &= ~SOR_CLK_CNTRL_DP_CLK_SEL_MASK; ··· 1618 1325 value &= ~SOR_PLL2_PORT_POWERDOWN; 1619 1326 tegra_sor_writel(sor, value, SOR_PLL2); 1620 1327 1621 - /* switch to DP clock */ 1622 - err = clk_set_parent(sor->clk, sor->clk_dp); 1328 + /* XXX not in TRM */ 1329 + for (value = 0, i = 0; i < 5; i++) 1330 + value |= SOR_XBAR_CTRL_LINK0_XSEL(i, sor->soc->xbar_cfg[i]) | 1331 + SOR_XBAR_CTRL_LINK1_XSEL(i, i); 1332 + 1333 + tegra_sor_writel(sor, 0x00000000, SOR_XBAR_POL); 1334 + tegra_sor_writel(sor, value, SOR_XBAR_CTRL); 1335 + 1336 + /* switch to DP parent clock */ 1337 + err = tegra_sor_set_parent_clock(sor, sor->clk_dp); 1623 1338 if (err < 0) 1624 - dev_err(sor->dev, "failed to set DP parent clock: %d\n", err); 1339 + dev_err(sor->dev, "failed to set parent clock: %d\n", err); 1625 1340 1626 1341 /* power DP lanes */ 1627 1342 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); ··· 1675 1374 value |= drm_dp_link_rate_to_bw_code(link.rate) << 2; 1676 1375 tegra_sor_writel(sor, value, SOR_CLK_CNTRL); 1677 1376 1678 - /* set linkctl */ 1377 + tegra_sor_apply_config(sor, &config); 1378 + 1379 + /* enable link */ 1679 1380 value = tegra_sor_readl(sor, SOR_DP_LINKCTL0); 1680 1381 value |= SOR_DP_LINKCTL_ENABLE; 1681 - 1682 - value &= ~SOR_DP_LINKCTL_TU_SIZE_MASK; 1683 - value |= SOR_DP_LINKCTL_TU_SIZE(config.tu_size); 1684 - 1685 1382 value |= SOR_DP_LINKCTL_ENHANCED_FRAME; 1686 1383 tegra_sor_writel(sor, value, SOR_DP_LINKCTL0); 1687 1384 ··· 1691 1392 } 1692 1393 1693 1394 tegra_sor_writel(sor, value, SOR_DP_TPG); 1694 - 1695 - value = tegra_sor_readl(sor, SOR_DP_CONFIG0); 1696 - value &= ~SOR_DP_CONFIG_WATERMARK_MASK; 1697 - value |= SOR_DP_CONFIG_WATERMARK(config.watermark); 1698 - 1699 - value &= ~SOR_DP_CONFIG_ACTIVE_SYM_COUNT_MASK; 1700 - value |= SOR_DP_CONFIG_ACTIVE_SYM_COUNT(config.active_count); 1701 - 1702 - value &= ~SOR_DP_CONFIG_ACTIVE_SYM_FRAC_MASK; 1703 - value |= SOR_DP_CONFIG_ACTIVE_SYM_FRAC(config.active_frac); 1704 - 1705 - if (config.active_polarity) 1706 - value |= SOR_DP_CONFIG_ACTIVE_SYM_POLARITY; 1707 - else 1708 - value &= ~SOR_DP_CONFIG_ACTIVE_SYM_POLARITY; 1709 - 1710 - value |= SOR_DP_CONFIG_ACTIVE_SYM_ENABLE; 1711 - value |= SOR_DP_CONFIG_DISPARITY_NEGATIVE; 1712 - tegra_sor_writel(sor, value, SOR_DP_CONFIG0); 1713 - 1714 - value = tegra_sor_readl(sor, SOR_DP_AUDIO_HBLANK_SYMBOLS); 1715 - value &= ~SOR_DP_AUDIO_HBLANK_SYMBOLS_MASK; 1716 - value |= config.hblank_symbols & 0xffff; 1717 - tegra_sor_writel(sor, value, SOR_DP_AUDIO_HBLANK_SYMBOLS); 1718 - 1719 - value = tegra_sor_readl(sor, SOR_DP_AUDIO_VBLANK_SYMBOLS); 1720 - value &= ~SOR_DP_AUDIO_VBLANK_SYMBOLS_MASK; 1721 - value |= config.vblank_symbols & 0xffff; 1722 - tegra_sor_writel(sor, value, SOR_DP_AUDIO_VBLANK_SYMBOLS); 1723 1395 1724 1396 /* enable pad calibration logic */ 1725 1397 value = tegra_sor_readl(sor, SOR_DP_PADCTL0); ··· 1747 1477 if (err < 0) 1748 1478 dev_err(sor->dev, "failed to power up SOR: %d\n", err); 1749 1479 1750 - /* 1751 - * configure panel (24bpp, vsync-, hsync-, DP-A protocol, complete 1752 - * raster, associate with display controller) 1753 - */ 1754 - value = SOR_STATE_ASY_PROTOCOL_DP_A | 1755 - SOR_STATE_ASY_CRC_MODE_COMPLETE | 1756 - SOR_STATE_ASY_OWNER(dc->pipe + 1); 1757 - 1758 - if (mode->flags & DRM_MODE_FLAG_PHSYNC) 1759 - value &= ~SOR_STATE_ASY_HSYNCPOL; 1760 - 1761 - if (mode->flags & DRM_MODE_FLAG_NHSYNC) 1762 - value |= SOR_STATE_ASY_HSYNCPOL; 1763 - 1764 - if (mode->flags & DRM_MODE_FLAG_PVSYNC) 1765 - value &= ~SOR_STATE_ASY_VSYNCPOL; 1766 - 1767 - if (mode->flags & DRM_MODE_FLAG_NVSYNC) 1768 - value |= SOR_STATE_ASY_VSYNCPOL; 1769 - 1770 - switch (config.bits_per_pixel) { 1771 - case 24: 1772 - value |= SOR_STATE_ASY_PIXELDEPTH_BPP_24_444; 1773 - break; 1774 - 1775 - case 18: 1776 - value |= SOR_STATE_ASY_PIXELDEPTH_BPP_18_444; 1777 - break; 1778 - 1779 - default: 1780 - BUG(); 1781 - break; 1782 - } 1783 - 1784 - tegra_sor_writel(sor, value, SOR_STATE1); 1785 - 1786 - /* 1787 - * TODO: The video timing programming below doesn't seem to match the 1788 - * register definitions. 1789 - */ 1790 - 1791 - value = ((mode->vtotal & 0x7fff) << 16) | (mode->htotal & 0x7fff); 1792 - tegra_sor_writel(sor, value, SOR_HEAD_STATE1(dc->pipe)); 1793 - 1794 - vse = mode->vsync_end - mode->vsync_start - 1; 1795 - hse = mode->hsync_end - mode->hsync_start - 1; 1796 - 1797 - value = ((vse & 0x7fff) << 16) | (hse & 0x7fff); 1798 - tegra_sor_writel(sor, value, SOR_HEAD_STATE2(dc->pipe)); 1799 - 1800 - vbe = vse + (mode->vsync_start - mode->vdisplay); 1801 - hbe = hse + (mode->hsync_start - mode->hdisplay); 1802 - 1803 - value = ((vbe & 0x7fff) << 16) | (hbe & 0x7fff); 1804 - tegra_sor_writel(sor, value, SOR_HEAD_STATE3(dc->pipe)); 1805 - 1806 - vbs = vbe + mode->vdisplay; 1807 - hbs = hbe + mode->hdisplay; 1808 - 1809 - value = ((vbs & 0x7fff) << 16) | (hbs & 0x7fff); 1810 - tegra_sor_writel(sor, value, SOR_HEAD_STATE4(dc->pipe)); 1811 - 1812 - tegra_sor_writel(sor, 0x1, SOR_HEAD_STATE5(dc->pipe)); 1813 - 1814 1480 /* CSTM (LVDS, link A/B, upper) */ 1815 1481 value = SOR_CSTM_LVDS | SOR_CSTM_LINK_ACT_A | SOR_CSTM_LINK_ACT_B | 1816 1482 SOR_CSTM_UPPER; 1817 1483 tegra_sor_writel(sor, value, SOR_CSTM); 1484 + 1485 + /* use DP-A protocol */ 1486 + value = tegra_sor_readl(sor, SOR_STATE1); 1487 + value &= ~SOR_STATE_ASY_PROTOCOL_MASK; 1488 + value |= SOR_STATE_ASY_PROTOCOL_DP_A; 1489 + tegra_sor_writel(sor, value, SOR_STATE1); 1490 + 1491 + tegra_sor_mode_set(sor, mode, state); 1818 1492 1819 1493 /* PWM setup */ 1820 1494 err = tegra_sor_setup_pwm(sor, 250); ··· 1791 1577 struct drm_connector_state *conn_state) 1792 1578 { 1793 1579 struct tegra_output *output = encoder_to_output(encoder); 1580 + struct tegra_sor_state *state = to_sor_state(conn_state); 1794 1581 struct tegra_dc *dc = to_tegra_dc(conn_state->crtc); 1795 1582 unsigned long pclk = crtc_state->mode.clock * 1000; 1796 1583 struct tegra_sor *sor = to_sor(output); 1584 + struct drm_display_info *info; 1797 1585 int err; 1586 + 1587 + info = &output->connector.display_info; 1798 1588 1799 1589 err = tegra_dc_state_setup_clock(dc, crtc_state, sor->clk_parent, 1800 1590 pclk, 0); 1801 1591 if (err < 0) { 1802 1592 dev_err(output->dev, "failed to setup CRTC state: %d\n", err); 1803 1593 return err; 1594 + } 1595 + 1596 + switch (info->bpc) { 1597 + case 8: 1598 + case 6: 1599 + state->bpc = info->bpc; 1600 + break; 1601 + 1602 + default: 1603 + DRM_DEBUG_KMS("%u bits-per-color not supported\n", info->bpc); 1604 + state->bpc = 8; 1605 + break; 1804 1606 } 1805 1607 1806 1608 return 0; ··· 1981 1751 if (err < 0) 1982 1752 dev_err(sor->dev, "failed to power off HDMI rail: %d\n", err); 1983 1753 1984 - reset_control_assert(sor->rst); 1985 - usleep_range(1000, 2000); 1986 - clk_disable_unprepare(sor->clk); 1754 + pm_runtime_put(sor->dev); 1987 1755 } 1988 1756 1989 1757 static void tegra_sor_hdmi_enable(struct drm_encoder *encoder) ··· 1989 1761 struct tegra_output *output = encoder_to_output(encoder); 1990 1762 unsigned int h_ref_to_sync = 1, pulse_start, max_ac; 1991 1763 struct tegra_dc *dc = to_tegra_dc(encoder->crtc); 1992 - unsigned int vbe, vse, hbe, hse, vbs, hbs, div; 1993 1764 struct tegra_sor_hdmi_settings *settings; 1994 1765 struct tegra_sor *sor = to_sor(output); 1766 + struct tegra_sor_state *state; 1995 1767 struct drm_display_mode *mode; 1996 - struct drm_display_info *info; 1768 + unsigned int div, i; 1997 1769 u32 value; 1998 1770 int err; 1999 1771 1772 + state = to_sor_state(output->connector.state); 2000 1773 mode = &encoder->crtc->state->adjusted_mode; 2001 - info = &output->connector.display_info; 2002 1774 2003 - err = clk_prepare_enable(sor->clk); 2004 - if (err < 0) 2005 - dev_err(sor->dev, "failed to enable clock: %d\n", err); 1775 + pm_runtime_get_sync(sor->dev); 2006 1776 2007 - usleep_range(1000, 2000); 2008 - 2009 - reset_control_deassert(sor->rst); 2010 - 2011 - err = clk_set_parent(sor->clk, sor->clk_safe); 1777 + /* switch to safe parent clock */ 1778 + err = tegra_sor_set_parent_clock(sor, sor->clk_safe); 2012 1779 if (err < 0) 2013 1780 dev_err(sor->dev, "failed to set safe parent clock: %d\n", err); 2014 1781 ··· 2099 1876 value = SOR_REFCLK_DIV_INT(div) | SOR_REFCLK_DIV_FRAC(div); 2100 1877 tegra_sor_writel(sor, value, SOR_REFCLK); 2101 1878 2102 - /* XXX don't hardcode */ 2103 - value = SOR_XBAR_CTRL_LINK1_XSEL(4, 4) | 2104 - SOR_XBAR_CTRL_LINK1_XSEL(3, 3) | 2105 - SOR_XBAR_CTRL_LINK1_XSEL(2, 2) | 2106 - SOR_XBAR_CTRL_LINK1_XSEL(1, 1) | 2107 - SOR_XBAR_CTRL_LINK1_XSEL(0, 0) | 2108 - SOR_XBAR_CTRL_LINK0_XSEL(4, 4) | 2109 - SOR_XBAR_CTRL_LINK0_XSEL(3, 3) | 2110 - SOR_XBAR_CTRL_LINK0_XSEL(2, 0) | 2111 - SOR_XBAR_CTRL_LINK0_XSEL(1, 1) | 2112 - SOR_XBAR_CTRL_LINK0_XSEL(0, 2); 2113 - tegra_sor_writel(sor, value, SOR_XBAR_CTRL); 1879 + /* XXX not in TRM */ 1880 + for (value = 0, i = 0; i < 5; i++) 1881 + value |= SOR_XBAR_CTRL_LINK0_XSEL(i, sor->soc->xbar_cfg[i]) | 1882 + SOR_XBAR_CTRL_LINK1_XSEL(i, i); 2114 1883 2115 1884 tegra_sor_writel(sor, 0x00000000, SOR_XBAR_POL); 1885 + tegra_sor_writel(sor, value, SOR_XBAR_CTRL); 2116 1886 2117 - err = clk_set_parent(sor->clk, sor->clk_parent); 1887 + /* switch to parent clock */ 1888 + err = clk_set_parent(sor->clk_src, sor->clk_parent); 1889 + if (err < 0) 1890 + dev_err(sor->dev, "failed to set source clock: %d\n", err); 1891 + 1892 + err = tegra_sor_set_parent_clock(sor, sor->clk_src); 2118 1893 if (err < 0) 2119 1894 dev_err(sor->dev, "failed to set parent clock: %d\n", err); 2120 1895 ··· 2222 2001 value &= ~DITHER_CONTROL_MASK; 2223 2002 value &= ~BASE_COLOR_SIZE_MASK; 2224 2003 2225 - switch (info->bpc) { 2004 + switch (state->bpc) { 2226 2005 case 6: 2227 2006 value |= BASE_COLOR_SIZE_666; 2228 2007 break; ··· 2232 2011 break; 2233 2012 2234 2013 default: 2235 - WARN(1, "%u bits-per-color not supported\n", info->bpc); 2014 + WARN(1, "%u bits-per-color not supported\n", state->bpc); 2015 + value |= BASE_COLOR_SIZE_888; 2236 2016 break; 2237 2017 } 2238 2018 ··· 2243 2021 if (err < 0) 2244 2022 dev_err(sor->dev, "failed to power up SOR: %d\n", err); 2245 2023 2246 - /* configure mode */ 2247 - value = tegra_sor_readl(sor, SOR_STATE1); 2248 - value &= ~SOR_STATE_ASY_PIXELDEPTH_MASK; 2249 - value &= ~SOR_STATE_ASY_CRC_MODE_MASK; 2250 - value &= ~SOR_STATE_ASY_OWNER_MASK; 2251 - 2252 - value |= SOR_STATE_ASY_CRC_MODE_COMPLETE | 2253 - SOR_STATE_ASY_OWNER(dc->pipe + 1); 2254 - 2255 - if (mode->flags & DRM_MODE_FLAG_PHSYNC) 2256 - value &= ~SOR_STATE_ASY_HSYNCPOL; 2257 - 2258 - if (mode->flags & DRM_MODE_FLAG_NHSYNC) 2259 - value |= SOR_STATE_ASY_HSYNCPOL; 2260 - 2261 - if (mode->flags & DRM_MODE_FLAG_PVSYNC) 2262 - value &= ~SOR_STATE_ASY_VSYNCPOL; 2263 - 2264 - if (mode->flags & DRM_MODE_FLAG_NVSYNC) 2265 - value |= SOR_STATE_ASY_VSYNCPOL; 2266 - 2267 - switch (info->bpc) { 2268 - case 8: 2269 - value |= SOR_STATE_ASY_PIXELDEPTH_BPP_24_444; 2270 - break; 2271 - 2272 - case 6: 2273 - value |= SOR_STATE_ASY_PIXELDEPTH_BPP_18_444; 2274 - break; 2275 - 2276 - default: 2277 - BUG(); 2278 - break; 2279 - } 2280 - 2281 - tegra_sor_writel(sor, value, SOR_STATE1); 2282 - 2024 + /* configure dynamic range of output */ 2283 2025 value = tegra_sor_readl(sor, SOR_HEAD_STATE0(dc->pipe)); 2284 2026 value &= ~SOR_HEAD_STATE_RANGECOMPRESS_MASK; 2285 2027 value &= ~SOR_HEAD_STATE_DYNRANGE_MASK; 2286 2028 tegra_sor_writel(sor, value, SOR_HEAD_STATE0(dc->pipe)); 2287 2029 2030 + /* configure colorspace */ 2288 2031 value = tegra_sor_readl(sor, SOR_HEAD_STATE0(dc->pipe)); 2289 2032 value &= ~SOR_HEAD_STATE_COLORSPACE_MASK; 2290 2033 value |= SOR_HEAD_STATE_COLORSPACE_RGB; 2291 2034 tegra_sor_writel(sor, value, SOR_HEAD_STATE0(dc->pipe)); 2292 2035 2293 - /* 2294 - * TODO: The video timing programming below doesn't seem to match the 2295 - * register definitions. 2296 - */ 2297 - 2298 - value = ((mode->vtotal & 0x7fff) << 16) | (mode->htotal & 0x7fff); 2299 - tegra_sor_writel(sor, value, SOR_HEAD_STATE1(dc->pipe)); 2300 - 2301 - /* sync end = sync width - 1 */ 2302 - vse = mode->vsync_end - mode->vsync_start - 1; 2303 - hse = mode->hsync_end - mode->hsync_start - 1; 2304 - 2305 - value = ((vse & 0x7fff) << 16) | (hse & 0x7fff); 2306 - tegra_sor_writel(sor, value, SOR_HEAD_STATE2(dc->pipe)); 2307 - 2308 - /* blank end = sync end + back porch */ 2309 - vbe = vse + (mode->vtotal - mode->vsync_end); 2310 - hbe = hse + (mode->htotal - mode->hsync_end); 2311 - 2312 - value = ((vbe & 0x7fff) << 16) | (hbe & 0x7fff); 2313 - tegra_sor_writel(sor, value, SOR_HEAD_STATE3(dc->pipe)); 2314 - 2315 - /* blank start = blank end + active */ 2316 - vbs = vbe + mode->vdisplay; 2317 - hbs = hbe + mode->hdisplay; 2318 - 2319 - value = ((vbs & 0x7fff) << 16) | (hbs & 0x7fff); 2320 - tegra_sor_writel(sor, value, SOR_HEAD_STATE4(dc->pipe)); 2321 - 2322 - tegra_sor_writel(sor, 0x1, SOR_HEAD_STATE5(dc->pipe)); 2036 + tegra_sor_mode_set(sor, mode, state); 2323 2037 2324 2038 tegra_sor_update(sor); 2325 2039 ··· 2353 2195 * XXX: Remove this reset once proper hand-over from firmware to 2354 2196 * kernel is possible. 2355 2197 */ 2356 - err = reset_control_assert(sor->rst); 2357 - if (err < 0) { 2358 - dev_err(sor->dev, "failed to assert SOR reset: %d\n", err); 2359 - return err; 2198 + if (sor->rst) { 2199 + err = reset_control_assert(sor->rst); 2200 + if (err < 0) { 2201 + dev_err(sor->dev, "failed to assert SOR reset: %d\n", 2202 + err); 2203 + return err; 2204 + } 2360 2205 } 2361 2206 2362 2207 err = clk_prepare_enable(sor->clk); ··· 2370 2209 2371 2210 usleep_range(1000, 3000); 2372 2211 2373 - err = reset_control_deassert(sor->rst); 2374 - if (err < 0) { 2375 - dev_err(sor->dev, "failed to deassert SOR reset: %d\n", err); 2376 - return err; 2212 + if (sor->rst) { 2213 + err = reset_control_deassert(sor->rst); 2214 + if (err < 0) { 2215 + dev_err(sor->dev, "failed to deassert SOR reset: %d\n", 2216 + err); 2217 + return err; 2218 + } 2377 2219 } 2378 2220 2379 2221 err = clk_prepare_enable(sor->clk_safe); ··· 2487 2323 .remove = tegra_sor_hdmi_remove, 2488 2324 }; 2489 2325 2326 + static const u8 tegra124_sor_xbar_cfg[5] = { 2327 + 0, 1, 2, 3, 4 2328 + }; 2329 + 2490 2330 static const struct tegra_sor_soc tegra124_sor = { 2491 2331 .supports_edp = true, 2492 2332 .supports_lvds = true, 2493 2333 .supports_hdmi = false, 2494 2334 .supports_dp = false, 2335 + .xbar_cfg = tegra124_sor_xbar_cfg, 2495 2336 }; 2496 2337 2497 2338 static const struct tegra_sor_soc tegra210_sor = { ··· 2504 2335 .supports_lvds = false, 2505 2336 .supports_hdmi = false, 2506 2337 .supports_dp = false, 2338 + .xbar_cfg = tegra124_sor_xbar_cfg, 2339 + }; 2340 + 2341 + static const u8 tegra210_sor_xbar_cfg[5] = { 2342 + 2, 1, 0, 3, 4 2507 2343 }; 2508 2344 2509 2345 static const struct tegra_sor_soc tegra210_sor1 = { ··· 2519 2345 2520 2346 .num_settings = ARRAY_SIZE(tegra210_sor_hdmi_defaults), 2521 2347 .settings = tegra210_sor_hdmi_defaults, 2348 + 2349 + .xbar_cfg = tegra210_sor_xbar_cfg, 2522 2350 }; 2523 2351 2524 2352 static const struct of_device_id tegra_sor_of_match[] = { ··· 2610 2434 goto remove; 2611 2435 } 2612 2436 2613 - sor->rst = devm_reset_control_get(&pdev->dev, "sor"); 2614 - if (IS_ERR(sor->rst)) { 2615 - err = PTR_ERR(sor->rst); 2616 - dev_err(&pdev->dev, "failed to get reset control: %d\n", err); 2617 - goto remove; 2437 + if (!pdev->dev.pm_domain) { 2438 + sor->rst = devm_reset_control_get(&pdev->dev, "sor"); 2439 + if (IS_ERR(sor->rst)) { 2440 + err = PTR_ERR(sor->rst); 2441 + dev_err(&pdev->dev, "failed to get reset control: %d\n", 2442 + err); 2443 + goto remove; 2444 + } 2618 2445 } 2619 2446 2620 2447 sor->clk = devm_clk_get(&pdev->dev, NULL); ··· 2625 2446 err = PTR_ERR(sor->clk); 2626 2447 dev_err(&pdev->dev, "failed to get module clock: %d\n", err); 2627 2448 goto remove; 2449 + } 2450 + 2451 + if (sor->soc->supports_hdmi || sor->soc->supports_dp) { 2452 + sor->clk_src = devm_clk_get(&pdev->dev, "source"); 2453 + if (IS_ERR(sor->clk_src)) { 2454 + err = PTR_ERR(sor->clk_src); 2455 + dev_err(sor->dev, "failed to get source clock: %d\n", 2456 + err); 2457 + goto remove; 2458 + } 2628 2459 } 2629 2460 2630 2461 sor->clk_parent = devm_clk_get(&pdev->dev, "parent"); ··· 2658 2469 goto remove; 2659 2470 } 2660 2471 2472 + platform_set_drvdata(pdev, sor); 2473 + pm_runtime_enable(&pdev->dev); 2474 + 2475 + pm_runtime_get_sync(&pdev->dev); 2476 + sor->clk_brick = tegra_clk_sor_brick_register(sor, "sor1_brick"); 2477 + pm_runtime_put(&pdev->dev); 2478 + 2479 + if (IS_ERR(sor->clk_brick)) { 2480 + err = PTR_ERR(sor->clk_brick); 2481 + dev_err(&pdev->dev, "failed to register SOR clock: %d\n", err); 2482 + goto remove; 2483 + } 2484 + 2661 2485 INIT_LIST_HEAD(&sor->client.list); 2662 2486 sor->client.ops = &sor_client_ops; 2663 2487 sor->client.dev = &pdev->dev; ··· 2681 2479 err); 2682 2480 goto remove; 2683 2481 } 2684 - 2685 - platform_set_drvdata(pdev, sor); 2686 2482 2687 2483 return 0; 2688 2484 ··· 2696 2496 { 2697 2497 struct tegra_sor *sor = platform_get_drvdata(pdev); 2698 2498 int err; 2499 + 2500 + pm_runtime_disable(&pdev->dev); 2699 2501 2700 2502 err = host1x_client_unregister(&sor->client); 2701 2503 if (err < 0) { ··· 2717 2515 return 0; 2718 2516 } 2719 2517 2518 + #ifdef CONFIG_PM 2519 + static int tegra_sor_suspend(struct device *dev) 2520 + { 2521 + struct tegra_sor *sor = dev_get_drvdata(dev); 2522 + int err; 2523 + 2524 + if (sor->rst) { 2525 + err = reset_control_assert(sor->rst); 2526 + if (err < 0) { 2527 + dev_err(dev, "failed to assert reset: %d\n", err); 2528 + return err; 2529 + } 2530 + } 2531 + 2532 + usleep_range(1000, 2000); 2533 + 2534 + clk_disable_unprepare(sor->clk); 2535 + 2536 + return 0; 2537 + } 2538 + 2539 + static int tegra_sor_resume(struct device *dev) 2540 + { 2541 + struct tegra_sor *sor = dev_get_drvdata(dev); 2542 + int err; 2543 + 2544 + err = clk_prepare_enable(sor->clk); 2545 + if (err < 0) { 2546 + dev_err(dev, "failed to enable clock: %d\n", err); 2547 + return err; 2548 + } 2549 + 2550 + usleep_range(1000, 2000); 2551 + 2552 + if (sor->rst) { 2553 + err = reset_control_deassert(sor->rst); 2554 + if (err < 0) { 2555 + dev_err(dev, "failed to deassert reset: %d\n", err); 2556 + clk_disable_unprepare(sor->clk); 2557 + return err; 2558 + } 2559 + } 2560 + 2561 + return 0; 2562 + } 2563 + #endif 2564 + 2565 + static const struct dev_pm_ops tegra_sor_pm_ops = { 2566 + SET_RUNTIME_PM_OPS(tegra_sor_suspend, tegra_sor_resume, NULL) 2567 + }; 2568 + 2720 2569 struct platform_driver tegra_sor_driver = { 2721 2570 .driver = { 2722 2571 .name = "tegra-sor", 2723 2572 .of_match_table = tegra_sor_of_match, 2573 + .pm = &tegra_sor_pm_ops, 2724 2574 }, 2725 2575 .probe = tegra_sor_probe, 2726 2576 .remove = tegra_sor_remove,
+3
drivers/gpu/drm/tegra/sor.h
··· 27 27 #define SOR_STATE_ASY_PIXELDEPTH_MASK (0xf << 17) 28 28 #define SOR_STATE_ASY_PIXELDEPTH_BPP_18_444 (0x2 << 17) 29 29 #define SOR_STATE_ASY_PIXELDEPTH_BPP_24_444 (0x5 << 17) 30 + #define SOR_STATE_ASY_PIXELDEPTH_BPP_30_444 (0x6 << 17) 31 + #define SOR_STATE_ASY_PIXELDEPTH_BPP_36_444 (0x8 << 17) 32 + #define SOR_STATE_ASY_PIXELDEPTH_BPP_48_444 (0x9 << 17) 30 33 #define SOR_STATE_ASY_VSYNCPOL (1 << 13) 31 34 #define SOR_STATE_ASY_HSYNCPOL (1 << 12) 32 35 #define SOR_STATE_ASY_PROTOCOL_MASK (0xf << 8)
+28 -14
drivers/gpu/host1x/cdma.c
··· 96 96 */ 97 97 static void host1x_pushbuffer_push(struct push_buffer *pb, u32 op1, u32 op2) 98 98 { 99 - u32 pos = pb->pos; 100 - u32 *p = (u32 *)((void *)pb->mapped + pos); 101 - WARN_ON(pos == pb->fence); 99 + u32 *p = (u32 *)((void *)pb->mapped + pb->pos); 100 + 101 + WARN_ON(pb->pos == pb->fence); 102 102 *(p++) = op1; 103 103 *(p++) = op2; 104 - pb->pos = (pos + 8) & (pb->size_bytes - 1); 104 + pb->pos = (pb->pos + 8) & (pb->size_bytes - 1); 105 105 } 106 106 107 107 /* ··· 134 134 enum cdma_event event) 135 135 { 136 136 for (;;) { 137 + struct push_buffer *pb = &cdma->push_buffer; 137 138 unsigned int space; 138 139 139 - if (event == CDMA_EVENT_SYNC_QUEUE_EMPTY) 140 + switch (event) { 141 + case CDMA_EVENT_SYNC_QUEUE_EMPTY: 140 142 space = list_empty(&cdma->sync_queue) ? 1 : 0; 141 - else if (event == CDMA_EVENT_PUSH_BUFFER_SPACE) { 142 - struct push_buffer *pb = &cdma->push_buffer; 143 + break; 144 + 145 + case CDMA_EVENT_PUSH_BUFFER_SPACE: 143 146 space = host1x_pushbuffer_space(pb); 144 - } else { 147 + break; 148 + 149 + default: 145 150 WARN_ON(1); 146 151 return -EINVAL; 147 152 } ··· 164 159 mutex_lock(&cdma->lock); 165 160 continue; 166 161 } 162 + 167 163 cdma->event = event; 168 164 169 165 mutex_unlock(&cdma->lock); 170 166 down(&cdma->sem); 171 167 mutex_lock(&cdma->lock); 172 168 } 169 + 173 170 return 0; 174 171 } 175 172 ··· 241 234 /* Start timer on next pending syncpt */ 242 235 if (job->timeout) 243 236 cdma_start_timer_locked(cdma, job); 237 + 244 238 break; 245 239 } 246 240 ··· 255 247 /* Pop push buffer slots */ 256 248 if (job->num_slots) { 257 249 struct push_buffer *pb = &cdma->push_buffer; 250 + 258 251 host1x_pushbuffer_pop(pb, job->num_slots); 252 + 259 253 if (cdma->event == CDMA_EVENT_PUSH_BUFFER_SPACE) 260 254 signal = true; 261 255 } ··· 279 269 void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma, 280 270 struct device *dev) 281 271 { 282 - u32 restart_addr; 283 - u32 syncpt_incrs; 284 - struct host1x_job *job = NULL; 285 - u32 syncpt_val; 286 272 struct host1x *host1x = cdma_to_host1x(cdma); 273 + u32 restart_addr, syncpt_incrs, syncpt_val; 274 + struct host1x_job *job = NULL; 287 275 288 276 syncpt_val = host1x_syncpt_load(cdma->timeout.syncpt); 289 277 ··· 350 342 syncpt_val += syncpt_incrs; 351 343 } 352 344 353 - /* The following sumbits from the same client may be dependent on the 345 + /* 346 + * The following sumbits from the same client may be dependent on the 354 347 * failed submit and therefore they may fail. Force a small timeout 355 - * to make the queue cleanup faster */ 348 + * to make the queue cleanup faster. 349 + */ 356 350 357 351 list_for_each_entry_from(job, &cdma->sync_queue, list) 358 352 if (job->client == cdma->timeout.client) ··· 385 375 err = host1x_pushbuffer_init(&cdma->push_buffer); 386 376 if (err) 387 377 return err; 378 + 388 379 return 0; 389 380 } 390 381 ··· 421 410 /* init state on first submit with timeout value */ 422 411 if (!cdma->timeout.initialized) { 423 412 int err; 413 + 424 414 err = host1x_hw_cdma_timeout_init(host1x, cdma, 425 415 job->syncpt_id); 426 416 if (err) { ··· 430 418 } 431 419 } 432 420 } 421 + 433 422 if (!cdma->running) 434 423 host1x_hw_cdma_start(host1x, cdma); 435 424 ··· 461 448 slots_free = host1x_cdma_wait_locked(cdma, 462 449 CDMA_EVENT_PUSH_BUFFER_SPACE); 463 450 } 451 + 464 452 cdma->slots_free = slots_free - 1; 465 453 cdma->slots_used++; 466 454 host1x_pushbuffer_push(pb, op1, op2);
+3 -2
drivers/gpu/host1x/channel.c
··· 83 83 struct host1x_channel *host1x_channel_request(struct device *dev) 84 84 { 85 85 struct host1x *host = dev_get_drvdata(dev->parent); 86 - int max_channels = host->info->nb_channels; 86 + unsigned int max_channels = host->info->nb_channels; 87 87 struct host1x_channel *channel = NULL; 88 - int index, err; 88 + unsigned long index; 89 + int err; 89 90 90 91 mutex_lock(&host->chlist_mutex); 91 92
+27 -11
drivers/gpu/host1x/debug.c
··· 39 39 va_start(args, fmt); 40 40 len = vsnprintf(o->buf, sizeof(o->buf), fmt, args); 41 41 va_end(args); 42 + 42 43 o->fn(o->ctx, o->buf, len); 43 44 } 44 45 ··· 49 48 struct output *o = data; 50 49 51 50 mutex_lock(&ch->reflock); 51 + 52 52 if (ch->refcount) { 53 53 mutex_lock(&ch->cdma.lock); 54 + 54 55 if (show_fifo) 55 56 host1x_hw_show_channel_fifo(m, ch, o); 57 + 56 58 host1x_hw_show_channel_cdma(m, ch, o); 57 59 mutex_unlock(&ch->cdma.lock); 58 60 } 61 + 59 62 mutex_unlock(&ch->reflock); 60 63 61 64 return 0; ··· 67 62 68 63 static void show_syncpts(struct host1x *m, struct output *o) 69 64 { 70 - int i; 65 + unsigned int i; 66 + 71 67 host1x_debug_output(o, "---- syncpts ----\n"); 68 + 72 69 for (i = 0; i < host1x_syncpt_nb_pts(m); i++) { 73 70 u32 max = host1x_syncpt_read_max(m->syncpt + i); 74 71 u32 min = host1x_syncpt_load(m->syncpt + i); 72 + 75 73 if (!min && !max) 76 74 continue; 77 - host1x_debug_output(o, "id %d (%s) min %d max %d\n", 75 + 76 + host1x_debug_output(o, "id %u (%s) min %d max %d\n", 78 77 i, m->syncpt[i].name, min, max); 79 78 } 80 79 81 80 for (i = 0; i < host1x_syncpt_nb_bases(m); i++) { 82 81 u32 base_val; 82 + 83 83 base_val = host1x_syncpt_load_wait_base(m->syncpt + i); 84 84 if (base_val) 85 - host1x_debug_output(o, "waitbase id %d val %d\n", i, 85 + host1x_debug_output(o, "waitbase id %u val %d\n", i, 86 86 base_val); 87 87 } 88 88 ··· 124 114 .fn = write_to_seqfile, 125 115 .ctx = s 126 116 }; 117 + 127 118 show_all(s->private, &o); 119 + 128 120 return 0; 129 121 } 130 122 ··· 136 124 .fn = write_to_seqfile, 137 125 .ctx = s 138 126 }; 127 + 139 128 show_all_no_fifo(s->private, &o); 129 + 140 130 return 0; 141 131 } 142 132 ··· 148 134 } 149 135 150 136 static const struct file_operations host1x_debug_all_fops = { 151 - .open = host1x_debug_open_all, 152 - .read = seq_read, 153 - .llseek = seq_lseek, 154 - .release = single_release, 137 + .open = host1x_debug_open_all, 138 + .read = seq_read, 139 + .llseek = seq_lseek, 140 + .release = single_release, 155 141 }; 156 142 157 143 static int host1x_debug_open(struct inode *inode, struct file *file) ··· 160 146 } 161 147 162 148 static const struct file_operations host1x_debug_fops = { 163 - .open = host1x_debug_open, 164 - .read = seq_read, 165 - .llseek = seq_lseek, 166 - .release = single_release, 149 + .open = host1x_debug_open, 150 + .read = seq_read, 151 + .llseek = seq_lseek, 152 + .release = single_release, 167 153 }; 168 154 169 155 static void host1x_debugfs_init(struct host1x *host1x) ··· 215 201 struct output o = { 216 202 .fn = write_to_printk 217 203 }; 204 + 218 205 show_all(host1x, &o); 219 206 } 220 207 ··· 224 209 struct output o = { 225 210 .fn = write_to_printk 226 211 }; 212 + 227 213 show_syncpts(host1x, &o); 228 214 }
+8 -8
drivers/gpu/host1x/dev.c
··· 63 63 } 64 64 65 65 static const struct host1x_info host1x01_info = { 66 - .nb_channels = 8, 67 - .nb_pts = 32, 68 - .nb_mlocks = 16, 69 - .nb_bases = 8, 70 - .init = host1x01_init, 71 - .sync_offset = 0x3000, 72 - .dma_mask = DMA_BIT_MASK(32), 66 + .nb_channels = 8, 67 + .nb_pts = 32, 68 + .nb_mlocks = 16, 69 + .nb_bases = 8, 70 + .init = host1x01_init, 71 + .sync_offset = 0x3000, 72 + .dma_mask = DMA_BIT_MASK(32), 73 73 }; 74 74 75 75 static const struct host1x_info host1x02_info = { ··· 102 102 .dma_mask = DMA_BIT_MASK(34), 103 103 }; 104 104 105 - static struct of_device_id host1x_of_match[] = { 105 + static const struct of_device_id host1x_of_match[] = { 106 106 { .compatible = "nvidia,tegra210-host1x", .data = &host1x05_info, }, 107 107 { .compatible = "nvidia,tegra124-host1x", .data = &host1x04_info, }, 108 108 { .compatible = "nvidia,tegra114-host1x", .data = &host1x02_info, },
+19 -19
drivers/gpu/host1x/dev.h
··· 45 45 void (*start)(struct host1x_cdma *cdma); 46 46 void (*stop)(struct host1x_cdma *cdma); 47 47 void (*flush)(struct host1x_cdma *cdma); 48 - int (*timeout_init)(struct host1x_cdma *cdma, u32 syncpt_id); 48 + int (*timeout_init)(struct host1x_cdma *cdma, unsigned int syncpt); 49 49 void (*timeout_destroy)(struct host1x_cdma *cdma); 50 50 void (*freeze)(struct host1x_cdma *cdma); 51 51 void (*resume)(struct host1x_cdma *cdma, u32 getptr); ··· 82 82 int (*init_host_sync)(struct host1x *host, u32 cpm, 83 83 void (*syncpt_thresh_work)(struct work_struct *work)); 84 84 void (*set_syncpt_threshold)( 85 - struct host1x *host, u32 id, u32 thresh); 86 - void (*enable_syncpt_intr)(struct host1x *host, u32 id); 87 - void (*disable_syncpt_intr)(struct host1x *host, u32 id); 85 + struct host1x *host, unsigned int id, u32 thresh); 86 + void (*enable_syncpt_intr)(struct host1x *host, unsigned int id); 87 + void (*disable_syncpt_intr)(struct host1x *host, unsigned int id); 88 88 void (*disable_all_syncpt_intrs)(struct host1x *host); 89 89 int (*free_syncpt_irq)(struct host1x *host); 90 90 }; 91 91 92 92 struct host1x_info { 93 - int nb_channels; /* host1x: num channels supported */ 94 - int nb_pts; /* host1x: num syncpoints supported */ 95 - int nb_bases; /* host1x: num syncpoints supported */ 96 - int nb_mlocks; /* host1x: number of mlocks */ 97 - int (*init)(struct host1x *); /* initialize per SoC ops */ 98 - int sync_offset; 99 - u64 dma_mask; /* mask of addressable memory */ 93 + unsigned int nb_channels; /* host1x: number of channels supported */ 94 + unsigned int nb_pts; /* host1x: number of syncpoints supported */ 95 + unsigned int nb_bases; /* host1x: number of syncpoint bases supported */ 96 + unsigned int nb_mlocks; /* host1x: number of mlocks supported */ 97 + int (*init)(struct host1x *host1x); /* initialize per SoC ops */ 98 + unsigned int sync_offset; /* offset of syncpoint registers */ 99 + u64 dma_mask; /* mask of addressable memory */ 100 100 }; 101 101 102 102 struct host1x { ··· 109 109 struct clk *clk; 110 110 111 111 struct mutex intr_mutex; 112 - struct workqueue_struct *intr_wq; 113 112 int intr_syncpt_irq; 114 113 115 114 const struct host1x_syncpt_ops *syncpt_op; ··· 182 183 } 183 184 184 185 static inline void host1x_hw_intr_set_syncpt_threshold(struct host1x *host, 185 - u32 id, u32 thresh) 186 + unsigned int id, 187 + u32 thresh) 186 188 { 187 189 host->intr_op->set_syncpt_threshold(host, id, thresh); 188 190 } 189 191 190 192 static inline void host1x_hw_intr_enable_syncpt_intr(struct host1x *host, 191 - u32 id) 193 + unsigned int id) 192 194 { 193 195 host->intr_op->enable_syncpt_intr(host, id); 194 196 } 195 197 196 198 static inline void host1x_hw_intr_disable_syncpt_intr(struct host1x *host, 197 - u32 id) 199 + unsigned int id) 198 200 { 199 201 host->intr_op->disable_syncpt_intr(host, id); 200 202 } ··· 212 212 213 213 static inline int host1x_hw_channel_init(struct host1x *host, 214 214 struct host1x_channel *channel, 215 - int chid) 215 + unsigned int id) 216 216 { 217 - return host->channel_op->init(channel, host, chid); 217 + return host->channel_op->init(channel, host, id); 218 218 } 219 219 220 220 static inline int host1x_hw_channel_submit(struct host1x *host, ··· 243 243 244 244 static inline int host1x_hw_cdma_timeout_init(struct host1x *host, 245 245 struct host1x_cdma *cdma, 246 - u32 syncpt_id) 246 + unsigned int syncpt) 247 247 { 248 - return host->cdma_op->timeout_init(cdma, syncpt_id); 248 + return host->cdma_op->timeout_init(cdma, syncpt); 249 249 } 250 250 251 251 static inline void host1x_hw_cdma_timeout_destroy(struct host1x *host,
+12 -11
drivers/gpu/host1x/hw/cdma_hw.c
··· 41 41 { 42 42 struct host1x *host1x = cdma_to_host1x(cdma); 43 43 struct push_buffer *pb = &cdma->push_buffer; 44 - u32 i; 44 + unsigned int i; 45 45 46 46 for (i = 0; i < syncpt_incrs; i++) 47 47 host1x_syncpt_incr(cdma->timeout.syncpt); ··· 58 58 &pb->phys, getptr); 59 59 getptr = (getptr + 8) & (pb->size_bytes - 1); 60 60 } 61 + 61 62 wmb(); 62 63 } 63 64 ··· 163 162 struct host1x_channel *ch = cdma_to_channel(cdma); 164 163 165 164 mutex_lock(&cdma->lock); 165 + 166 166 if (cdma->running) { 167 167 host1x_cdma_wait_locked(cdma, CDMA_EVENT_SYNC_QUEUE_EMPTY); 168 168 host1x_ch_writel(ch, HOST1X_CHANNEL_DMACTRL_DMASTOP, 169 169 HOST1X_CHANNEL_DMACTRL); 170 170 cdma->running = false; 171 171 } 172 + 172 173 mutex_unlock(&cdma->lock); 173 174 } 174 175 ··· 216 213 u32 cmdproc_stop; 217 214 218 215 dev_dbg(host1x->dev, 219 - "resuming channel (id %d, DMAGET restart = 0x%x)\n", 216 + "resuming channel (id %u, DMAGET restart = 0x%x)\n", 220 217 ch->id, getptr); 221 218 222 219 cmdproc_stop = host1x_sync_readl(host1x, HOST1X_SYNC_CMDPROC_STOP); 223 - cmdproc_stop &= ~(BIT(ch->id)); 220 + cmdproc_stop &= ~BIT(ch->id); 224 221 host1x_sync_writel(host1x, cmdproc_stop, HOST1X_SYNC_CMDPROC_STOP); 225 222 226 223 cdma->torndown = false; ··· 234 231 */ 235 232 static void cdma_timeout_handler(struct work_struct *work) 236 233 { 234 + u32 prev_cmdproc, cmdproc_stop, syncpt_val; 237 235 struct host1x_cdma *cdma; 238 236 struct host1x *host1x; 239 237 struct host1x_channel *ch; 240 - 241 - u32 syncpt_val; 242 - 243 - u32 prev_cmdproc, cmdproc_stop; 244 238 245 239 cdma = container_of(to_delayed_work(work), struct host1x_cdma, 246 240 timeout.wq); ··· 277 277 return; 278 278 } 279 279 280 - dev_warn(host1x->dev, "%s: timeout: %d (%s), HW thresh %d, done %d\n", 281 - __func__, cdma->timeout.syncpt->id, cdma->timeout.syncpt->name, 282 - syncpt_val, cdma->timeout.syncpt_val); 280 + dev_warn(host1x->dev, "%s: timeout: %u (%s), HW thresh %d, done %d\n", 281 + __func__, cdma->timeout.syncpt->id, cdma->timeout.syncpt->name, 282 + syncpt_val, cdma->timeout.syncpt_val); 283 283 284 284 /* stop HW, resetting channel/module */ 285 285 host1x_hw_cdma_freeze(host1x, cdma); ··· 291 291 /* 292 292 * Init timeout resources 293 293 */ 294 - static int cdma_timeout_init(struct host1x_cdma *cdma, u32 syncpt_id) 294 + static int cdma_timeout_init(struct host1x_cdma *cdma, unsigned int syncpt) 295 295 { 296 296 INIT_DELAYED_WORK(&cdma->timeout.wq, cdma_timeout_handler); 297 297 cdma->timeout.initialized = true; ··· 306 306 { 307 307 if (cdma->timeout.initialized) 308 308 cancel_delayed_work(&cdma->timeout.wq); 309 + 309 310 cdma->timeout.initialized = false; 310 311 } 311 312
+4 -1
drivers/gpu/host1x/hw/channel_hw.c
··· 46 46 */ 47 47 for (i = 0; i < words; i += TRACE_MAX_LENGTH) { 48 48 u32 num_words = min(words - i, TRACE_MAX_LENGTH); 49 + 49 50 offset += i * sizeof(u32); 50 51 51 52 trace_host1x_cdma_push_gather(dev_name(dev), bo, ··· 67 66 struct host1x_job_gather *g = &job->gathers[i]; 68 67 u32 op1 = host1x_opcode_gather(g->words); 69 68 u32 op2 = g->base + g->offset; 69 + 70 70 trace_write_gather(cdma, g->bo, g->offset, op1 & 0xffff); 71 71 host1x_cdma_push(cdma, op1, op2); 72 72 } ··· 77 75 { 78 76 struct host1x *host = dev_get_drvdata(job->channel->dev->parent); 79 77 struct host1x_syncpt *sp = host->syncpt + job->syncpt_id; 80 - u32 id, value; 78 + unsigned int id; 79 + u32 value; 81 80 82 81 value = host1x_syncpt_read_max(sp); 83 82 id = sp->base->id;
+18 -18
drivers/gpu/host1x/hw/debug_hw.c
··· 40 40 41 41 static unsigned int show_channel_command(struct output *o, u32 val) 42 42 { 43 - unsigned mask; 44 - unsigned subop; 43 + unsigned int mask, subop; 45 44 46 45 switch (val >> 28) { 47 46 case HOST1X_OPCODE_SETCLASS: ··· 50 51 val >> 6 & 0x3ff, 51 52 val >> 16 & 0xfff, mask); 52 53 return hweight8(mask); 53 - } else { 54 - host1x_debug_output(o, "SETCL(class=%03x)\n", 55 - val >> 6 & 0x3ff); 56 - return 0; 57 54 } 55 + 56 + host1x_debug_output(o, "SETCL(class=%03x)\n", val >> 6 & 0x3ff); 57 + return 0; 58 58 59 59 case HOST1X_OPCODE_INCR: 60 60 host1x_debug_output(o, "INCR(offset=%03x, [", ··· 141 143 struct host1x_job *job; 142 144 143 145 list_for_each_entry(job, &cdma->sync_queue, list) { 144 - int i; 146 + unsigned int i; 147 + 145 148 host1x_debug_output(o, "\n%p: JOB, syncpt_id=%d, syncpt_val=%d, first_get=%08x, timeout=%d num_slots=%d, num_handles=%d\n", 146 149 job, job->syncpt_id, job->syncpt_end, 147 150 job->first_get, job->timeout, ··· 189 190 cbread = host1x_sync_readl(host, HOST1X_SYNC_CBREAD(ch->id)); 190 191 cbstat = host1x_sync_readl(host, HOST1X_SYNC_CBSTAT(ch->id)); 191 192 192 - host1x_debug_output(o, "%d-%s: ", ch->id, dev_name(ch->dev)); 193 + host1x_debug_output(o, "%u-%s: ", ch->id, dev_name(ch->dev)); 193 194 194 195 if (HOST1X_CHANNEL_DMACTRL_DMASTOP_V(dmactrl) || 195 196 !ch->cdma.push_buffer.mapped) { ··· 199 200 200 201 if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) == HOST1X_CLASS_HOST1X && 201 202 HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 202 - HOST1X_UCLASS_WAIT_SYNCPT) 203 + HOST1X_UCLASS_WAIT_SYNCPT) 203 204 host1x_debug_output(o, "waiting on syncpt %d val %d\n", 204 205 cbread >> 24, cbread & 0xffffff); 205 206 else if (HOST1X_SYNC_CBSTAT_CBCLASS_V(cbstat) == 206 - HOST1X_CLASS_HOST1X && 207 - HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 208 - HOST1X_UCLASS_WAIT_SYNCPT_BASE) { 209 - 207 + HOST1X_CLASS_HOST1X && 208 + HOST1X_SYNC_CBSTAT_CBOFFSET_V(cbstat) == 209 + HOST1X_UCLASS_WAIT_SYNCPT_BASE) { 210 210 base = (cbread >> 16) & 0xff; 211 211 baseval = 212 212 host1x_sync_readl(host, HOST1X_SYNC_SYNCPT_BASE(base)); ··· 234 236 u32 val, rd_ptr, wr_ptr, start, end; 235 237 unsigned int data_count = 0; 236 238 237 - host1x_debug_output(o, "%d: fifo:\n", ch->id); 239 + host1x_debug_output(o, "%u: fifo:\n", ch->id); 238 240 239 241 val = host1x_ch_readl(ch, HOST1X_CHANNEL_FIFOSTAT); 240 242 host1x_debug_output(o, "FIFOSTAT %08x\n", val); ··· 288 290 289 291 static void host1x_debug_show_mlocks(struct host1x *host, struct output *o) 290 292 { 291 - int i; 293 + unsigned int i; 292 294 293 295 host1x_debug_output(o, "---- mlocks ----\n"); 296 + 294 297 for (i = 0; i < host1x_syncpt_nb_mlocks(host); i++) { 295 298 u32 owner = 296 299 host1x_sync_readl(host, HOST1X_SYNC_MLOCK_OWNER(i)); 297 300 if (HOST1X_SYNC_MLOCK_OWNER_CH_OWNS_V(owner)) 298 - host1x_debug_output(o, "%d: locked by channel %d\n", 301 + host1x_debug_output(o, "%u: locked by channel %u\n", 299 302 i, HOST1X_SYNC_MLOCK_OWNER_CHID_V(owner)); 300 303 else if (HOST1X_SYNC_MLOCK_OWNER_CPU_OWNS_V(owner)) 301 - host1x_debug_output(o, "%d: locked by cpu\n", i); 304 + host1x_debug_output(o, "%u: locked by cpu\n", i); 302 305 else 303 - host1x_debug_output(o, "%d: unlocked\n", i); 306 + host1x_debug_output(o, "%u: unlocked\n", i); 304 307 } 308 + 305 309 host1x_debug_output(o, "\n"); 306 310 } 307 311
+20 -10
drivers/gpu/host1x/hw/intr_hw.c
··· 38 38 host1x_sync_writel(host, BIT_MASK(id), 39 39 HOST1X_SYNC_SYNCPT_THRESH_CPU0_INT_STATUS(BIT_WORD(id))); 40 40 41 - queue_work(host->intr_wq, &syncpt->intr.work); 41 + schedule_work(&syncpt->intr.work); 42 42 } 43 43 44 44 static irqreturn_t syncpt_thresh_isr(int irq, void *dev_id) 45 45 { 46 46 struct host1x *host = dev_id; 47 47 unsigned long reg; 48 - int i, id; 48 + unsigned int i, id; 49 49 50 50 for (i = 0; i < DIV_ROUND_UP(host->info->nb_pts, 32); i++) { 51 51 reg = host1x_sync_readl(host, ··· 62 62 63 63 static void _host1x_intr_disable_all_syncpt_intrs(struct host1x *host) 64 64 { 65 - u32 i; 65 + unsigned int i; 66 66 67 67 for (i = 0; i < DIV_ROUND_UP(host->info->nb_pts, 32); ++i) { 68 68 host1x_sync_writel(host, 0xffffffffu, ··· 72 72 } 73 73 } 74 74 75 - static int _host1x_intr_init_host_sync(struct host1x *host, u32 cpm, 76 - void (*syncpt_thresh_work)(struct work_struct *)) 75 + static int 76 + _host1x_intr_init_host_sync(struct host1x *host, u32 cpm, 77 + void (*syncpt_thresh_work)(struct work_struct *)) 77 78 { 78 - int i, err; 79 + unsigned int i; 80 + int err; 79 81 80 82 host1x_hw_intr_disable_all_syncpt_intrs(host); 81 83 ··· 108 106 } 109 107 110 108 static void _host1x_intr_set_syncpt_threshold(struct host1x *host, 111 - u32 id, u32 thresh) 109 + unsigned int id, 110 + u32 thresh) 112 111 { 113 112 host1x_sync_writel(host, thresh, HOST1X_SYNC_SYNCPT_INT_THRESH(id)); 114 113 } 115 114 116 - static void _host1x_intr_enable_syncpt_intr(struct host1x *host, u32 id) 115 + static void _host1x_intr_enable_syncpt_intr(struct host1x *host, 116 + unsigned int id) 117 117 { 118 118 host1x_sync_writel(host, BIT_MASK(id), 119 119 HOST1X_SYNC_SYNCPT_THRESH_INT_ENABLE_CPU0(BIT_WORD(id))); 120 120 } 121 121 122 - static void _host1x_intr_disable_syncpt_intr(struct host1x *host, u32 id) 122 + static void _host1x_intr_disable_syncpt_intr(struct host1x *host, 123 + unsigned int id) 123 124 { 124 125 host1x_sync_writel(host, BIT_MASK(id), 125 126 HOST1X_SYNC_SYNCPT_THRESH_INT_DISABLE(BIT_WORD(id))); ··· 132 127 133 128 static int _host1x_free_syncpt_irq(struct host1x *host) 134 129 { 130 + unsigned int i; 131 + 135 132 devm_free_irq(host->dev, host->intr_syncpt_irq, host); 136 - flush_workqueue(host->intr_wq); 133 + 134 + for (i = 0; i < host->info->nb_pts; i++) 135 + cancel_work_sync(&host->syncpt[i].intr.work); 136 + 137 137 return 0; 138 138 } 139 139
+7 -3
drivers/gpu/host1x/hw/syncpt_hw.c
··· 26 26 */ 27 27 static void syncpt_restore(struct host1x_syncpt *sp) 28 28 { 29 + u32 min = host1x_syncpt_read_min(sp); 29 30 struct host1x *host = sp->host; 30 - int min = host1x_syncpt_read_min(sp); 31 + 31 32 host1x_sync_writel(host, min, HOST1X_SYNC_SYNCPT(sp->id)); 32 33 } 33 34 ··· 38 37 static void syncpt_restore_wait_base(struct host1x_syncpt *sp) 39 38 { 40 39 struct host1x *host = sp->host; 40 + 41 41 host1x_sync_writel(host, sp->base_val, 42 42 HOST1X_SYNC_SYNCPT_BASE(sp->id)); 43 43 } ··· 49 47 static void syncpt_read_wait_base(struct host1x_syncpt *sp) 50 48 { 51 49 struct host1x *host = sp->host; 50 + 52 51 sp->base_val = 53 52 host1x_sync_readl(host, HOST1X_SYNC_SYNCPT_BASE(sp->id)); 54 53 } ··· 88 85 if (!host1x_syncpt_client_managed(sp) && 89 86 host1x_syncpt_idle(sp)) 90 87 return -EINVAL; 88 + 91 89 host1x_sync_writel(host, BIT_MASK(sp->id), 92 90 HOST1X_SYNC_SYNCPT_CPU_INCR(reg_offset)); 93 91 wmb(); ··· 99 95 /* remove a wait pointed to by patch_addr */ 100 96 static int syncpt_patch_wait(struct host1x_syncpt *sp, void *patch_addr) 101 97 { 102 - u32 override = host1x_class_host_wait_syncpt( 103 - HOST1X_SYNCPT_RESERVED, 0); 98 + u32 override = host1x_class_host_wait_syncpt(HOST1X_SYNCPT_RESERVED, 0); 104 99 105 100 *((u32 *)patch_addr) = override; 101 + 106 102 return 0; 107 103 } 108 104
+7 -9
drivers/gpu/host1x/intr.c
··· 122 122 static void action_wakeup(struct host1x_waitlist *waiter) 123 123 { 124 124 wait_queue_head_t *wq = waiter->data; 125 + 125 126 wake_up(wq); 126 127 } 127 128 128 129 static void action_wakeup_interruptible(struct host1x_waitlist *waiter) 129 130 { 130 131 wait_queue_head_t *wq = waiter->data; 132 + 131 133 wake_up_interruptible(wq); 132 134 } 133 135 134 136 typedef void (*action_handler)(struct host1x_waitlist *waiter); 135 137 136 - static action_handler action_handlers[HOST1X_INTR_ACTION_COUNT] = { 138 + static const action_handler action_handlers[HOST1X_INTR_ACTION_COUNT] = { 137 139 action_submit_complete, 138 140 action_wakeup, 139 141 action_wakeup_interruptible, ··· 211 209 host1x_syncpt_load(host->syncpt + id)); 212 210 } 213 211 214 - int host1x_intr_add_action(struct host1x *host, u32 id, u32 thresh, 212 + int host1x_intr_add_action(struct host1x *host, unsigned int id, u32 thresh, 215 213 enum host1x_intr_action action, void *data, 216 214 struct host1x_waitlist *waiter, void **ref) 217 215 { ··· 256 254 return 0; 257 255 } 258 256 259 - void host1x_intr_put_ref(struct host1x *host, u32 id, void *ref) 257 + void host1x_intr_put_ref(struct host1x *host, unsigned int id, void *ref) 260 258 { 261 259 struct host1x_waitlist *waiter = ref; 262 260 struct host1x_syncpt *syncpt; ··· 279 277 280 278 mutex_init(&host->intr_mutex); 281 279 host->intr_syncpt_irq = irq_sync; 282 - host->intr_wq = create_workqueue("host_syncpt"); 283 - if (!host->intr_wq) 284 - return -ENOMEM; 285 280 286 281 for (id = 0; id < nb_pts; ++id) { 287 282 struct host1x_syncpt *syncpt = host->syncpt + id; ··· 287 288 INIT_LIST_HEAD(&syncpt->intr.wait_head); 288 289 snprintf(syncpt->intr.thresh_irq_name, 289 290 sizeof(syncpt->intr.thresh_irq_name), 290 - "host1x_sp_%02d", id); 291 + "host1x_sp_%02u", id); 291 292 } 292 293 293 294 host1x_intr_start(host); ··· 298 299 void host1x_intr_deinit(struct host1x *host) 299 300 { 300 301 host1x_intr_stop(host); 301 - destroy_workqueue(host->intr_wq); 302 302 } 303 303 304 304 void host1x_intr_start(struct host1x *host) ··· 340 342 if (!list_empty(&syncpt[id].intr.wait_head)) { 341 343 /* output diagnostics */ 342 344 mutex_unlock(&host->intr_mutex); 343 - pr_warn("%s cannot stop syncpt intr id=%d\n", 345 + pr_warn("%s cannot stop syncpt intr id=%u\n", 344 346 __func__, id); 345 347 return; 346 348 }
+2 -2
drivers/gpu/host1x/intr.h
··· 75 75 * 76 76 * This is a non-blocking api. 77 77 */ 78 - int host1x_intr_add_action(struct host1x *host, u32 id, u32 thresh, 78 + int host1x_intr_add_action(struct host1x *host, unsigned int id, u32 thresh, 79 79 enum host1x_intr_action action, void *data, 80 80 struct host1x_waitlist *waiter, void **ref); 81 81 ··· 84 84 * You must call this if you passed non-NULL as ref. 85 85 * @ref the ref returned from host1x_intr_add_action() 86 86 */ 87 - void host1x_intr_put_ref(struct host1x *host, u32 id, void *ref); 87 + void host1x_intr_put_ref(struct host1x *host, unsigned int id, void *ref); 88 88 89 89 /* Initialize host1x sync point interrupt */ 90 90 int host1x_intr_init(struct host1x *host, unsigned int irq_sync);
+6 -2
drivers/gpu/host1x/job.c
··· 161 161 162 162 if (host1x_syncpt_is_expired(sp, wait->thresh)) { 163 163 dev_dbg(host->dev, 164 - "drop WAIT id %d (%s) thresh 0x%x, min 0x%x\n", 164 + "drop WAIT id %u (%s) thresh 0x%x, min 0x%x\n", 165 165 wait->syncpt_id, sp->name, wait->thresh, 166 166 host1x_syncpt_read_min(sp)); 167 167 ··· 464 464 465 465 for (i = 0; i < job->num_gathers; i++) { 466 466 struct host1x_job_gather *g = &job->gathers[i]; 467 + 467 468 size += g->words * sizeof(u32); 468 469 } 469 470 ··· 515 514 bitmap_zero(waitchk_mask, host1x_syncpt_nb_pts(host)); 516 515 for (i = 0; i < job->num_waitchk; i++) { 517 516 u32 syncpt_id = job->waitchk[i].syncpt_id; 517 + 518 518 if (syncpt_id < host1x_syncpt_nb_pts(host)) 519 519 set_bit(syncpt_id, waitchk_mask); 520 520 } ··· 573 571 574 572 for (i = 0; i < job->num_unpins; i++) { 575 573 struct host1x_job_unpin_data *unpin = &job->unpins[i]; 574 + 576 575 host1x_bo_unpin(unpin->bo, unpin->sgt); 577 576 host1x_bo_put(unpin->bo); 578 577 } 578 + 579 579 job->num_unpins = 0; 580 580 581 581 if (job->gather_copy_size) 582 582 dma_free_wc(job->channel->dev, job->gather_copy_size, 583 - job->gather_copy_mapped, job->gather_copy); 583 + job->gather_copy_mapped, job->gather_copy); 584 584 } 585 585 EXPORT_SYMBOL(host1x_job_unpin); 586 586
+40 -18
drivers/gpu/host1x/syncpt.c
··· 73 73 return NULL; 74 74 } 75 75 76 - name = kasprintf(GFP_KERNEL, "%02d-%s", sp->id, 76 + name = kasprintf(GFP_KERNEL, "%02u-%s", sp->id, 77 77 dev ? dev_name(dev) : NULL); 78 78 if (!name) 79 79 return NULL; ··· 110 110 void host1x_syncpt_restore(struct host1x *host) 111 111 { 112 112 struct host1x_syncpt *sp_base = host->syncpt; 113 - u32 i; 113 + unsigned int i; 114 114 115 115 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) 116 116 host1x_hw_syncpt_restore(host, sp_base + i); 117 + 117 118 for (i = 0; i < host1x_syncpt_nb_bases(host); i++) 118 119 host1x_hw_syncpt_restore_wait_base(host, sp_base + i); 120 + 119 121 wmb(); 120 122 } 121 123 ··· 128 126 void host1x_syncpt_save(struct host1x *host) 129 127 { 130 128 struct host1x_syncpt *sp_base = host->syncpt; 131 - u32 i; 129 + unsigned int i; 132 130 133 131 for (i = 0; i < host1x_syncpt_nb_pts(host); i++) { 134 132 if (host1x_syncpt_client_managed(sp_base + i)) ··· 148 146 u32 host1x_syncpt_load(struct host1x_syncpt *sp) 149 147 { 150 148 u32 val; 149 + 151 150 val = host1x_hw_syncpt_load(sp->host, sp); 152 151 trace_host1x_syncpt_load_min(sp->id, val); 153 152 ··· 160 157 */ 161 158 u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp) 162 159 { 163 - u32 val; 164 160 host1x_hw_syncpt_load_wait_base(sp->host, sp); 165 - val = sp->base_val; 166 - return val; 161 + 162 + return sp->base_val; 167 163 } 168 164 169 165 /* ··· 181 179 static bool syncpt_load_min_is_expired(struct host1x_syncpt *sp, u32 thresh) 182 180 { 183 181 host1x_hw_syncpt_load(sp->host, sp); 182 + 184 183 return host1x_syncpt_is_expired(sp, thresh); 185 184 } 186 185 ··· 189 186 * Main entrypoint for syncpoint value waits. 190 187 */ 191 188 int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, 192 - u32 *value) 189 + u32 *value) 193 190 { 194 191 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); 195 192 void *ref; ··· 204 201 if (host1x_syncpt_is_expired(sp, thresh)) { 205 202 if (value) 206 203 *value = host1x_syncpt_load(sp); 204 + 207 205 return 0; 208 206 } 209 207 ··· 213 209 if (host1x_syncpt_is_expired(sp, thresh)) { 214 210 if (value) 215 211 *value = val; 212 + 216 213 goto done; 217 214 } 218 215 ··· 244 239 /* wait for the syncpoint, or timeout, or signal */ 245 240 while (timeout) { 246 241 long check = min_t(long, SYNCPT_CHECK_PERIOD, timeout); 247 - int remain = wait_event_interruptible_timeout(wq, 242 + int remain; 243 + 244 + remain = wait_event_interruptible_timeout(wq, 248 245 syncpt_load_min_is_expired(sp, thresh), 249 246 check); 250 247 if (remain > 0 || host1x_syncpt_is_expired(sp, thresh)) { 251 248 if (value) 252 249 *value = host1x_syncpt_load(sp); 250 + 253 251 err = 0; 252 + 254 253 break; 255 254 } 255 + 256 256 if (remain < 0) { 257 257 err = remain; 258 258 break; 259 259 } 260 + 260 261 timeout -= check; 262 + 261 263 if (timeout && check_count <= MAX_STUCK_CHECK_COUNT) { 262 264 dev_warn(sp->host->dev, 263 - "%s: syncpoint id %d (%s) stuck waiting %d, timeout=%ld\n", 265 + "%s: syncpoint id %u (%s) stuck waiting %d, timeout=%ld\n", 264 266 current->comm, sp->id, sp->name, 265 267 thresh, timeout); 266 268 267 269 host1x_debug_dump_syncpts(sp->host); 270 + 268 271 if (check_count == MAX_STUCK_CHECK_COUNT) 269 272 host1x_debug_dump(sp->host); 273 + 270 274 check_count++; 271 275 } 272 276 } 277 + 273 278 host1x_intr_put_ref(sp->host, sp->id, ref); 274 279 275 280 done: ··· 294 279 { 295 280 u32 current_val; 296 281 u32 future_val; 282 + 297 283 smp_rmb(); 284 + 298 285 current_val = (u32)atomic_read(&sp->min_val); 299 286 future_val = (u32)atomic_read(&sp->max_val); 300 287 ··· 358 341 { 359 342 struct host1x_syncpt_base *bases; 360 343 struct host1x_syncpt *syncpt; 361 - int i; 344 + unsigned int i; 362 345 363 - syncpt = devm_kzalloc(host->dev, sizeof(*syncpt) * host->info->nb_pts, 346 + syncpt = devm_kcalloc(host->dev, host->info->nb_pts, sizeof(*syncpt), 364 347 GFP_KERNEL); 365 348 if (!syncpt) 366 349 return -ENOMEM; 367 350 368 - bases = devm_kzalloc(host->dev, sizeof(*bases) * host->info->nb_bases, 351 + bases = devm_kcalloc(host->dev, host->info->nb_bases, sizeof(*bases), 369 352 GFP_KERNEL); 370 353 if (!bases) 371 354 return -ENOMEM; ··· 395 378 unsigned long flags) 396 379 { 397 380 struct host1x *host = dev_get_drvdata(dev->parent); 381 + 398 382 return host1x_syncpt_alloc(host, dev, flags); 399 383 } 400 384 EXPORT_SYMBOL(host1x_syncpt_request); ··· 416 398 417 399 void host1x_syncpt_deinit(struct host1x *host) 418 400 { 419 - int i; 420 401 struct host1x_syncpt *sp = host->syncpt; 402 + unsigned int i; 403 + 421 404 for (i = 0; i < host->info->nb_pts; i++, sp++) 422 405 kfree(sp->name); 423 406 } ··· 426 407 /* 427 408 * Read max. It indicates how many operations there are in queue, either in 428 409 * channel or in a software thread. 429 - * */ 410 + */ 430 411 u32 host1x_syncpt_read_max(struct host1x_syncpt *sp) 431 412 { 432 413 smp_rmb(); 414 + 433 415 return (u32)atomic_read(&sp->max_val); 434 416 } 435 417 EXPORT_SYMBOL(host1x_syncpt_read_max); ··· 441 421 u32 host1x_syncpt_read_min(struct host1x_syncpt *sp) 442 422 { 443 423 smp_rmb(); 424 + 444 425 return (u32)atomic_read(&sp->min_val); 445 426 } 446 427 EXPORT_SYMBOL(host1x_syncpt_read_min); ··· 452 431 } 453 432 EXPORT_SYMBOL(host1x_syncpt_read); 454 433 455 - int host1x_syncpt_nb_pts(struct host1x *host) 434 + unsigned int host1x_syncpt_nb_pts(struct host1x *host) 456 435 { 457 436 return host->info->nb_pts; 458 437 } 459 438 460 - int host1x_syncpt_nb_bases(struct host1x *host) 439 + unsigned int host1x_syncpt_nb_bases(struct host1x *host) 461 440 { 462 441 return host->info->nb_bases; 463 442 } 464 443 465 - int host1x_syncpt_nb_mlocks(struct host1x *host) 444 + unsigned int host1x_syncpt_nb_mlocks(struct host1x *host) 466 445 { 467 446 return host->info->nb_mlocks; 468 447 } 469 448 470 - struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, u32 id) 449 + struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, unsigned int id) 471 450 { 472 451 if (host->info->nb_pts < id) 473 452 return NULL; 453 + 474 454 return host->syncpt + id; 475 455 } 476 456 EXPORT_SYMBOL(host1x_syncpt_get);
+4 -4
drivers/gpu/host1x/syncpt.h
··· 37 37 }; 38 38 39 39 struct host1x_syncpt { 40 - int id; 40 + unsigned int id; 41 41 atomic_t min_val; 42 42 atomic_t max_val; 43 43 u32 base_val; ··· 58 58 void host1x_syncpt_deinit(struct host1x *host); 59 59 60 60 /* Return number of sync point supported. */ 61 - int host1x_syncpt_nb_pts(struct host1x *host); 61 + unsigned int host1x_syncpt_nb_pts(struct host1x *host); 62 62 63 63 /* Return number of wait bases supported. */ 64 - int host1x_syncpt_nb_bases(struct host1x *host); 64 + unsigned int host1x_syncpt_nb_bases(struct host1x *host); 65 65 66 66 /* Return number of mlocks supported. */ 67 - int host1x_syncpt_nb_mlocks(struct host1x *host); 67 + unsigned int host1x_syncpt_nb_mlocks(struct host1x *host); 68 68 69 69 /* 70 70 * Check sync point sanity. If max is larger than min, there have too many
+8
drivers/pinctrl/pinconf-generic.c
··· 391 391 } 392 392 EXPORT_SYMBOL_GPL(pinconf_generic_dt_node_to_map); 393 393 394 + void pinconf_generic_dt_free_map(struct pinctrl_dev *pctldev, 395 + struct pinctrl_map *map, 396 + unsigned num_maps) 397 + { 398 + pinctrl_utils_free_map(pctldev, map, num_maps); 399 + } 400 + EXPORT_SYMBOL_GPL(pinconf_generic_dt_free_map); 401 + 394 402 #endif
+2
include/linux/pinctrl/pinconf-generic.h
··· 175 175 int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev, 176 176 struct device_node *np_config, struct pinctrl_map **map, 177 177 unsigned *num_maps, enum pinctrl_map_type type); 178 + void pinconf_generic_dt_free_map(struct pinctrl_dev *pctldev, 179 + struct pinctrl_map *map, unsigned num_maps); 178 180 179 181 static inline int pinconf_generic_dt_node_to_map_group( 180 182 struct pinctrl_dev *pctldev, struct device_node *np_config,