~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/mach-mmp/clock.c

Version: ~ [ linux-5.4-rc7 ] ~ [ linux-5.3.11 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.84 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.154 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.201 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.201 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.77 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  linux/arch/arm/mach-mmp/clock.c
  3  *
  4  *  This program is free software; you can redistribute it and/or modify
  5  *  it under the terms of the GNU General Public License version 2 as
  6  *  published by the Free Software Foundation.
  7  */
  8 
  9 #include <linux/module.h>
 10 #include <linux/kernel.h>
 11 #include <linux/list.h>
 12 #include <linux/spinlock.h>
 13 #include <linux/clk.h>
 14 #include <linux/io.h>
 15 
 16 #include <mach/regs-apbc.h>
 17 #include "clock.h"
 18 
 19 static void apbc_clk_enable(struct clk *clk)
 20 {
 21         uint32_t clk_rst;
 22 
 23         clk_rst = APBC_APBCLK | APBC_FNCLK | APBC_FNCLKSEL(clk->fnclksel);
 24         __raw_writel(clk_rst, clk->clk_rst);
 25 }
 26 
 27 static void apbc_clk_disable(struct clk *clk)
 28 {
 29         __raw_writel(0, clk->clk_rst);
 30 }
 31 
 32 struct clkops apbc_clk_ops = {
 33         .enable         = apbc_clk_enable,
 34         .disable        = apbc_clk_disable,
 35 };
 36 
 37 static void apmu_clk_enable(struct clk *clk)
 38 {
 39         __raw_writel(clk->enable_val, clk->clk_rst);
 40 }
 41 
 42 static void apmu_clk_disable(struct clk *clk)
 43 {
 44         __raw_writel(0, clk->clk_rst);
 45 }
 46 
 47 struct clkops apmu_clk_ops = {
 48         .enable         = apmu_clk_enable,
 49         .disable        = apmu_clk_disable,
 50 };
 51 
 52 static DEFINE_SPINLOCK(clocks_lock);
 53 
 54 int clk_enable(struct clk *clk)
 55 {
 56         unsigned long flags;
 57 
 58         spin_lock_irqsave(&clocks_lock, flags);
 59         if (clk->enabled++ == 0)
 60                 clk->ops->enable(clk);
 61         spin_unlock_irqrestore(&clocks_lock, flags);
 62         return 0;
 63 }
 64 EXPORT_SYMBOL(clk_enable);
 65 
 66 void clk_disable(struct clk *clk)
 67 {
 68         unsigned long flags;
 69 
 70         WARN_ON(clk->enabled == 0);
 71 
 72         spin_lock_irqsave(&clocks_lock, flags);
 73         if (--clk->enabled == 0)
 74                 clk->ops->disable(clk);
 75         spin_unlock_irqrestore(&clocks_lock, flags);
 76 }
 77 EXPORT_SYMBOL(clk_disable);
 78 
 79 unsigned long clk_get_rate(struct clk *clk)
 80 {
 81         unsigned long rate;
 82 
 83         if (clk->ops->getrate)
 84                 rate = clk->ops->getrate(clk);
 85         else
 86                 rate = clk->rate;
 87 
 88         return rate;
 89 }
 90 EXPORT_SYMBOL(clk_get_rate);
 91 
 92 int clk_set_rate(struct clk *clk, unsigned long rate)
 93 {
 94         unsigned long flags;
 95         int ret = -EINVAL;
 96 
 97         if (clk->ops->setrate) {
 98                 spin_lock_irqsave(&clocks_lock, flags);
 99                 ret = clk->ops->setrate(clk, rate);
100                 spin_unlock_irqrestore(&clocks_lock, flags);
101         }
102 
103         return ret;
104 }
105 EXPORT_SYMBOL(clk_set_rate);
106 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp