clock36xx.c 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * OMAP36xx-specific clkops
 *
 * Copyright (C) 2010 Texas Instruments, Inc.
 * Copyright (C) 2010 Nokia Corporation
 *
 * Mike Turquette
 * Vijaykumar GN
 * Paul Walmsley
 *
 * Parts of this code are based on code written by
 * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu,
 * Russell King
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#undef DEBUG

#include <linux/kernel.h>
#include <linux/clk.h>
23
#include <linux/clk-provider.h>
24 25 26 27
#include <linux/io.h>

#include "clock.h"
#include "clock36xx.h"
28
#define to_clk_divider(_hw) container_of(_hw, struct clk_divider, hw)
29 30 31 32 33 34 35 36 37 38 39 40

/**
 * omap36xx_pwrdn_clk_enable_with_hsdiv_restore - enable clocks suffering
 *         from HSDivider PWRDN problem Implements Errata ID: i556.
 * @clk: DPLL output struct clk
 *
 * 3630 only: dpll3_m3_ck, dpll4_m2_ck, dpll4_m3_ck, dpll4_m4_ck,
 * dpll4_m5_ck & dpll4_m6_ck dividers gets loaded with reset
 * valueafter their respective PWRDN bits are set.  Any dummy write
 * (Any other value different from the Read value) to the
 * corresponding CM_CLKSEL register will refresh the dividers.
 */
41 42
int omap36xx_pwrdn_clk_enable_with_hsdiv_restore(struct clk_hw *clk)
{
43
	struct clk_divider *parent;
44
	struct clk_hw *parent_hw;
45
	u32 dummy_v, orig_v;
46
	struct clk_hw_omap *omap_clk = to_clk_hw_omap(clk);
47 48 49 50 51
	int ret;

	/* Clear PWRDN bit of HSDIVIDER */
	ret = omap2_dflt_clk_enable(clk);

52
	parent_hw = __clk_get_hw(__clk_get_parent(clk->clk));
53
	parent = to_clk_divider(parent_hw);
54

55 56
	/* Restore the dividers */
	if (!ret) {
57
		orig_v = omap2_clk_readl(omap_clk, parent->reg);
58 59 60
		dummy_v = orig_v;

		/* Write any other value different from the Read value */
61
		dummy_v ^= (1 << parent->shift);
62
		omap2_clk_writel(dummy_v, omap_clk, parent->reg);
63 64

		/* Write the original divider */
65
		omap2_clk_writel(orig_v, omap_clk, parent->reg);
66 67 68 69
	}

	return ret;
}