提交 c10b8ef4 编写于 作者: P Phil Elwell 提交者: Zheng Zengkai

clk-bcm2835: Add claim-clocks property

raspberrypi inclusion
category: feature
bugzilla: 50432

--------------------------------

The claim-clocks property can be used to prevent PLLs and dividers
from being marked as critical. It contains a vector of clock IDs,
as defined by dt-bindings/clock/bcm2835.h.

Use this mechanism to claim PLLD_DSI0, PLLD_DSI1, PLLH_AUX and
PLLH_PIX for the vc4_kms_v3d driver.
Signed-off-by: NPhil Elwell <phil@raspberrypi.org>
Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 fbd5c1c1
......@@ -1312,6 +1312,8 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
.debug_init = bcm2835_clock_debug_init,
};
static bool bcm2835_clk_is_claimed(const char *name);
static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
const void *data)
{
......@@ -1329,6 +1331,9 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
init.ops = &bcm2835_pll_clk_ops;
init.flags = pll_data->flags | CLK_IGNORE_UNUSED;
if (!bcm2835_clk_is_claimed(pll_data->name))
init.flags |= CLK_IS_CRITICAL;
pll = kzalloc(sizeof(*pll), GFP_KERNEL);
if (!pll)
return NULL;
......@@ -1384,8 +1389,10 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
divider->div.hw.init = &init;
divider->div.table = NULL;
if (!(cprman_read(cprman, data->cm_reg) & data->hold_mask)) {
if (!(cprman_read(cprman, divider_data->cm_reg) & divider_data->hold_mask)) {
if (!bcm2835_clk_is_claimed(divider_data->source_pll))
init.flags |= CLK_IS_CRITICAL;
if (!bcm2835_clk_is_claimed(divider_data->name))
divider->div.flags |= CLK_IS_CRITICAL;
}
......@@ -1442,6 +1449,15 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
init.name = clock_data->name;
init.flags = clock_data->flags | CLK_IGNORE_UNUSED;
/*
* Some GPIO clocks for ethernet/wifi PLLs are marked as
* critical (since some platforms use them), but if the
* firmware didn't have them turned on then they clearly
* aren't actually critical.
*/
if ((cprman_read(cprman, clock_data->ctl_reg) & CM_ENABLE) == 0)
init.flags &= ~CLK_IS_CRITICAL;
/*
* Pass the CLK_SET_RATE_PARENT flag if we are allowed to propagate
* rate changes on at least of the parents.
......@@ -2221,6 +2237,8 @@ static const struct bcm2835_clk_desc clk_desc_array[] = {
.ctl_reg = CM_PERIICTL),
};
static bool bcm2835_clk_claimed[ARRAY_SIZE(clk_desc_array)];
/*
* Permanently take a reference on the parent of the SDRAM clock.
*
......@@ -2240,6 +2258,19 @@ static int bcm2835_mark_sdc_parent_critical(struct clk *sdc)
return clk_prepare_enable(parent);
}
static bool bcm2835_clk_is_claimed(const char *name)
{
int i;
for (i = 0; i < ARRAY_SIZE(clk_desc_array); i++) {
const char *clk_name = *(const char **)(clk_desc_array[i].data);
if (!strcmp(name, clk_name))
return bcm2835_clk_claimed[i];
}
return false;
}
static int bcm2835_clk_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
......@@ -2249,6 +2280,7 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
const size_t asize = ARRAY_SIZE(clk_desc_array);
const struct cprman_plat_data *pdata;
size_t i;
u32 clk_id;
int ret;
pdata = of_device_get_match_data(&pdev->dev);
......@@ -2267,6 +2299,13 @@ static int bcm2835_clk_probe(struct platform_device *pdev)
if (IS_ERR(cprman->regs))
return PTR_ERR(cprman->regs);
memset(bcm2835_clk_claimed, 0, sizeof(bcm2835_clk_claimed));
for (i = 0;
!of_property_read_u32_index(pdev->dev.of_node, "claim-clocks",
i, &clk_id);
i++)
bcm2835_clk_claimed[clk_id]= true;
memcpy(cprman->real_parent_names, cprman_parent_names,
sizeof(cprman_parent_names));
of_clk_parent_fill(dev->of_node, cprman->real_parent_names,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册