67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
/*
|
|
* drivers/video/tegra/dc/clock.c
|
|
*
|
|
* Copyright (C) 2010 Google, Inc.
|
|
*
|
|
* Copyright (c) 2010-2012, NVIDIA CORPORATION, All rights reserved.
|
|
*
|
|
* This software is licensed under the terms of the GNU General Public
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
* may be copied, distributed, and modified under those terms.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#include <linux/err.h>
|
|
#include <linux/types.h>
|
|
#include <linux/clk.h>
|
|
|
|
#include "dc_reg.h"
|
|
#include "dc_priv.h"
|
|
|
|
unsigned long tegra_dc_pclk_round_rate(struct tegra_dc *dc, int pclk)
|
|
{
|
|
unsigned long rate;
|
|
unsigned long div;
|
|
|
|
rate = tegra_dc_clk_get_rate(dc);
|
|
|
|
div = DIV_ROUND_CLOSEST(rate * 2, pclk);
|
|
|
|
if (div < 2)
|
|
return 0;
|
|
|
|
return rate * 2 / div;
|
|
}
|
|
|
|
unsigned long tegra_dc_pclk_predict_rate(struct clk *parent, int pclk)
|
|
{
|
|
unsigned long rate;
|
|
unsigned long div;
|
|
|
|
rate = clk_get_rate(parent);
|
|
|
|
div = DIV_ROUND_CLOSEST(rate * 2, pclk);
|
|
|
|
if (div < 2)
|
|
return 0;
|
|
|
|
return rate * 2 / div;
|
|
}
|
|
|
|
void tegra_dc_setup_clk(struct tegra_dc *dc, struct clk *clk)
|
|
{
|
|
int pclk;
|
|
|
|
if (dc->out_ops->setup_clk)
|
|
pclk = dc->out_ops->setup_clk(dc, clk);
|
|
else
|
|
pclk = 0;
|
|
|
|
WARN_ONCE(!pclk, "pclk is 0\n");
|
|
}
|