Skip to content

Commit fa9eb32

Browse files
Srinivas-Kandagatlaolofj
authored andcommitted
drivers/soc: qcom: do not disable the iface clock in probe
since commit 31964ff ("tty: serial: msm: Remove direct access to GSBI")' serial hangs if earlyprintk are enabled. This hang is noticed only when the GSBI driver is probed and all the earlyprintks before gsbi probe are seen on the console. The reason why it hangs is because GSBI driver disables hclk in its probe function without realizing that the serial IP might be in use by a bootconsole. As gsbi driver disables the clock in probe the bootconsole locks up. Turning off hclk's could be dangerous if there are system components like earlyprintk using the hclk. This patch fixes the issue by delegating the clock management to probe and remove functions in gsbi rather than disabling the clock in probe. More detailed problem description can be found here: http://www.spinics.net/lists/linux-arm-msm/msg10589.html Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Olof Johansson <olof@lixom.net>
1 parent 21c68e7 commit fa9eb32

1 file changed

Lines changed: 33 additions & 13 deletions

File tree

‎drivers/soc/qcom/qcom_gsbi.c‎

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,44 +22,63 @@
2222
#define GSBI_CTRL_REG 0x0000
2323
#define GSBI_PROTOCOL_SHIFT 4
2424

25+
struct gsbi_info {
26+
struct clk *hclk;
27+
u32 mode;
28+
u32 crci;
29+
};
30+
2531
static int gsbi_probe(struct platform_device *pdev)
2632
{
2733
struct device_node *node = pdev->dev.of_node;
2834
struct resource *res;
2935
void __iomem *base;
30-
struct clk *hclk;
31-
u32 mode, crci = 0;
36+
struct gsbi_info *gsbi;
37+
38+
gsbi = devm_kzalloc(&pdev->dev, sizeof(*gsbi), GFP_KERNEL);
39+
40+
if (!gsbi)
41+
return -ENOMEM;
3242

3343
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
3444
base = devm_ioremap_resource(&pdev->dev, res);
3545
if (IS_ERR(base))
3646
return PTR_ERR(base);
3747

38-
if (of_property_read_u32(node, "qcom,mode", &mode)) {
48+
if (of_property_read_u32(node, "qcom,mode", &gsbi->mode)) {
3949
dev_err(&pdev->dev, "missing mode configuration\n");
4050
return -EINVAL;
4151
}
4252

4353
/* not required, so default to 0 if not present */
44-
of_property_read_u32(node, "qcom,crci", &crci);
54+
of_property_read_u32(node, "qcom,crci", &gsbi->crci);
4555

46-
dev_info(&pdev->dev, "GSBI port protocol: %d crci: %d\n", mode, crci);
56+
dev_info(&pdev->dev, "GSBI port protocol: %d crci: %d\n",
57+
gsbi->mode, gsbi->crci);
58+
gsbi->hclk = devm_clk_get(&pdev->dev, "iface");
59+
if (IS_ERR(gsbi->hclk))
60+
return PTR_ERR(gsbi->hclk);
4761

48-
hclk = devm_clk_get(&pdev->dev, "iface");
49-
if (IS_ERR(hclk))
50-
return PTR_ERR(hclk);
62+
clk_prepare_enable(gsbi->hclk);
5163

52-
clk_prepare_enable(hclk);
53-
54-
writel_relaxed((mode << GSBI_PROTOCOL_SHIFT) | crci,
64+
writel_relaxed((gsbi->mode << GSBI_PROTOCOL_SHIFT) | gsbi->crci,
5565
base + GSBI_CTRL_REG);
5666

5767
/* make sure the gsbi control write is not reordered */
5868
wmb();
5969

60-
clk_disable_unprepare(hclk);
70+
platform_set_drvdata(pdev, gsbi);
71+
72+
return of_platform_populate(node, NULL, NULL, &pdev->dev);
73+
}
74+
75+
static int gsbi_remove(struct platform_device *pdev)
76+
{
77+
struct gsbi_info *gsbi = platform_get_drvdata(pdev);
78+
79+
clk_disable_unprepare(gsbi->hclk);
6180

62-
return of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
81+
return 0;
6382
}
6483

6584
static const struct of_device_id gsbi_dt_match[] = {
@@ -76,6 +95,7 @@ static struct platform_driver gsbi_driver = {
7695
.of_match_table = gsbi_dt_match,
7796
},
7897
.probe = gsbi_probe,
98+
.remove = gsbi_remove,
7999
};
80100

81101
module_platform_driver(gsbi_driver);

0 commit comments

Comments
 (0)