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

Configure Feed

Select the types of activity you want to include in your feed.

drm/sun4i: dsi: Handle bus clock via regmap_mmio_attach_clk

regmap has special API to enable the controller bus clock while
initializing register space, and current driver is using
devm_regmap_init_mmio_clk which require to specify bus
clk_id argument as "bus"

But, the usage of clocks are varies between different Allwinner
DSI controllers. Clocking in A33 would need bus and mod clocks
where as A64 would need only bus clock.

Since A64 support only single bus clock, it is optional to
specify the clock-names on the controller device tree node.
So using NULL on clk_id would get the attached clock.

To support clk_id as "bus" and "NULL" during clock enablement
between controllers, this patch add generic code to handle
the bus clock using regmap_mmio_attach_clk with associated
regmap APIs.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20191222132229.30276-5-jagan@amarulasolutions.com

authored by

Jagan Teki and committed by
Maxime Ripard
66dbdc7c 26a839b3

+29 -8
+29 -8
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
··· 1081 1081 static int sun6i_dsi_probe(struct platform_device *pdev) 1082 1082 { 1083 1083 struct device *dev = &pdev->dev; 1084 + const char *bus_clk_name = NULL; 1084 1085 struct sun6i_dsi *dsi; 1085 1086 struct resource *res; 1086 1087 void __iomem *base; ··· 1094 1093 dsi->dev = dev; 1095 1094 dsi->host.ops = &sun6i_dsi_host_ops; 1096 1095 dsi->host.dev = dev; 1096 + 1097 + if (of_device_is_compatible(dev->of_node, 1098 + "allwinner,sun6i-a31-mipi-dsi")) 1099 + bus_clk_name = "bus"; 1097 1100 1098 1101 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1099 1102 base = devm_ioremap_resource(dev, res); ··· 1112 1107 return PTR_ERR(dsi->regulator); 1113 1108 } 1114 1109 1115 - dsi->regs = devm_regmap_init_mmio_clk(dev, "bus", base, 1116 - &sun6i_dsi_regmap_config); 1117 - if (IS_ERR(dsi->regs)) { 1118 - dev_err(dev, "Couldn't create the DSI encoder regmap\n"); 1119 - return PTR_ERR(dsi->regs); 1120 - } 1121 - 1122 1110 dsi->reset = devm_reset_control_get_shared(dev, NULL); 1123 1111 if (IS_ERR(dsi->reset)) { 1124 1112 dev_err(dev, "Couldn't get our reset line\n"); 1125 1113 return PTR_ERR(dsi->reset); 1126 1114 } 1127 1115 1116 + dsi->regs = devm_regmap_init_mmio(dev, base, &sun6i_dsi_regmap_config); 1117 + if (IS_ERR(dsi->regs)) { 1118 + dev_err(dev, "Couldn't init regmap\n"); 1119 + return PTR_ERR(dsi->regs); 1120 + } 1121 + 1122 + dsi->bus_clk = devm_clk_get(dev, bus_clk_name); 1123 + if (IS_ERR(dsi->bus_clk)) { 1124 + dev_err(dev, "Couldn't get the DSI bus clock\n"); 1125 + return PTR_ERR(dsi->bus_clk); 1126 + } 1127 + 1128 + ret = regmap_mmio_attach_clk(dsi->regs, dsi->bus_clk); 1129 + if (ret) 1130 + return ret; 1131 + 1128 1132 if (of_device_is_compatible(dev->of_node, 1129 1133 "allwinner,sun6i-a31-mipi-dsi")) { 1130 1134 dsi->mod_clk = devm_clk_get(dev, "mod"); 1131 1135 if (IS_ERR(dsi->mod_clk)) { 1132 1136 dev_err(dev, "Couldn't get the DSI mod clock\n"); 1133 - return PTR_ERR(dsi->mod_clk); 1137 + ret = PTR_ERR(dsi->mod_clk); 1138 + goto err_attach_clk; 1134 1139 } 1135 1140 } 1136 1141 ··· 1179 1164 pm_runtime_disable(dev); 1180 1165 err_unprotect_clk: 1181 1166 clk_rate_exclusive_put(dsi->mod_clk); 1167 + err_attach_clk: 1168 + if (!IS_ERR(dsi->bus_clk)) 1169 + regmap_mmio_detach_clk(dsi->regs); 1182 1170 return ret; 1183 1171 } 1184 1172 ··· 1194 1176 mipi_dsi_host_unregister(&dsi->host); 1195 1177 pm_runtime_disable(dev); 1196 1178 clk_rate_exclusive_put(dsi->mod_clk); 1179 + 1180 + if (!IS_ERR(dsi->bus_clk)) 1181 + regmap_mmio_detach_clk(dsi->regs); 1197 1182 1198 1183 return 0; 1199 1184 }