Skip to content

Commit 7e13613

Browse files
Wenyou Yangehristev
authored andcommitted
media: atmel-isc: Enable the clocks during probe
To meet the relationship, enable the HCLOCK and ispck during the device probe, "isc_pck frequency is less than or equal to isc_ispck, and isc_ispck is greater than or equal to HCLOCK." Meanwhile, call the pm_runtime_enable() in the right place. Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
1 parent 3d520fe commit 7e13613

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

drivers/media/platform/atmel/atmel-isc.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,14 @@ static int isc_clk_is_enabled(struct clk_hw *hw)
389389
struct isc_clk *isc_clk = to_isc_clk(hw);
390390
u32 status;
391391

392+
if (isc_clk->id == ISC_MCK)
393+
pm_runtime_get_sync(isc_clk->dev);
394+
392395
regmap_read(isc_clk->regmap, ISC_CLKSR, &status);
393396

397+
if (isc_clk->id == ISC_MCK)
398+
pm_runtime_put_sync(isc_clk->dev);
399+
394400
return status & ISC_CLK(isc_clk->id) ? 1 : 0;
395401
}
396402

@@ -1866,25 +1872,37 @@ static int atmel_isc_probe(struct platform_device *pdev)
18661872
return ret;
18671873
}
18681874

1875+
ret = clk_prepare_enable(isc->hclock);
1876+
if (ret) {
1877+
dev_err(dev, "failed to enable hclock: %d\n", ret);
1878+
return ret;
1879+
}
1880+
18691881
ret = isc_clk_init(isc);
18701882
if (ret) {
18711883
dev_err(dev, "failed to init isc clock: %d\n", ret);
1872-
goto clean_isc_clk;
1884+
goto unprepare_hclk;
18731885
}
18741886

18751887
isc->ispck = isc->isc_clks[ISC_ISPCK].clk;
18761888

1889+
ret = clk_prepare_enable(isc->ispck);
1890+
if (ret) {
1891+
dev_err(dev, "failed to enable ispck: %d\n", ret);
1892+
goto unprepare_hclk;
1893+
}
1894+
18771895
/* ispck should be greater or equal to hclock */
18781896
ret = clk_set_rate(isc->ispck, clk_get_rate(isc->hclock));
18791897
if (ret) {
18801898
dev_err(dev, "failed to set ispck rate: %d\n", ret);
1881-
goto clean_isc_clk;
1899+
goto unprepare_clk;
18821900
}
18831901

18841902
ret = v4l2_device_register(dev, &isc->v4l2_dev);
18851903
if (ret) {
18861904
dev_err(dev, "unable to register v4l2 device.\n");
1887-
goto clean_isc_clk;
1905+
goto unprepare_clk;
18881906
}
18891907

18901908
ret = isc_parse_dt(dev, isc);
@@ -1917,7 +1935,9 @@ static int atmel_isc_probe(struct platform_device *pdev)
19171935
break;
19181936
}
19191937

1938+
pm_runtime_set_active(dev);
19201939
pm_runtime_enable(dev);
1940+
pm_request_idle(dev);
19211941

19221942
return 0;
19231943

@@ -1927,7 +1947,11 @@ static int atmel_isc_probe(struct platform_device *pdev)
19271947
unregister_v4l2_device:
19281948
v4l2_device_unregister(&isc->v4l2_dev);
19291949

1930-
clean_isc_clk:
1950+
unprepare_clk:
1951+
clk_disable_unprepare(isc->ispck);
1952+
unprepare_hclk:
1953+
clk_disable_unprepare(isc->hclock);
1954+
19311955
isc_clk_cleanup(isc);
19321956

19331957
return ret;
@@ -1938,6 +1962,8 @@ static int atmel_isc_remove(struct platform_device *pdev)
19381962
struct isc_device *isc = platform_get_drvdata(pdev);
19391963

19401964
pm_runtime_disable(&pdev->dev);
1965+
clk_disable_unprepare(isc->ispck);
1966+
clk_disable_unprepare(isc->hclock);
19411967

19421968
isc_subdev_cleanup(isc);
19431969

0 commit comments

Comments
 (0)