-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Magnus Damm
authored and
Paul Mundt
committed
Jul 4, 2009
1 parent
46ac653
commit f330831
Showing
30 changed files
with
1,049 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 4048e5ca29afbd747a16245f2bc4d1d521a6d0d0 | ||
refs/heads/master: 79714acbab080ad351acf4bba9a2bbc21d65c93c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef __ASM_SH_HWBLK_H | ||
#define __ASM_SH_HWBLK_H | ||
|
||
#include <asm/clock.h> | ||
#include <asm/io.h> | ||
|
||
#define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */ | ||
|
||
#define HWBLK_AREA(_flags, _parent) \ | ||
{ \ | ||
.flags = _flags, \ | ||
.parent = _parent, \ | ||
} | ||
|
||
struct hwblk_area { | ||
unsigned long cnt; | ||
unsigned char parent; | ||
unsigned char flags; | ||
}; | ||
|
||
#define HWBLK(_mstp, _bit, _area) \ | ||
{ \ | ||
.mstp = (void __iomem *)_mstp, \ | ||
.bit = _bit, \ | ||
.area = _area, \ | ||
} | ||
|
||
struct hwblk { | ||
void __iomem *mstp; | ||
unsigned char bit; | ||
unsigned char area; | ||
unsigned long cnt; | ||
}; | ||
|
||
struct hwblk_info { | ||
struct hwblk_area *areas; | ||
int nr_areas; | ||
struct hwblk *hwblks; | ||
int nr_hwblks; | ||
}; | ||
|
||
/* Should be defined by processor-specific code */ | ||
int arch_hwblk_init(void); | ||
int arch_hwblk_sleep_mode(void); | ||
|
||
int hwblk_register(struct hwblk_info *info); | ||
int hwblk_init(void); | ||
|
||
/* allow clocks to enable and disable hardware blocks */ | ||
#define SH_HWBLK_CLK(_name, _id, _parent, _hwblk, _flags) \ | ||
{ \ | ||
.name = _name, \ | ||
.id = _id, \ | ||
.parent = _parent, \ | ||
.arch_flags = _hwblk, \ | ||
.flags = _flags, \ | ||
} | ||
|
||
int sh_hwblk_clk_register(struct clk *clks, int nr); | ||
|
||
#endif /* __ASM_SH_HWBLK_H */ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#include <linux/clk.h> | ||
#include <linux/compiler.h> | ||
#include <linux/slab.h> | ||
#include <linux/io.h> | ||
#include <linux/spinlock.h> | ||
#include <asm/suspend.h> | ||
#include <asm/hwblk.h> | ||
#include <asm/clock.h> | ||
|
||
static DEFINE_SPINLOCK(hwblk_lock); | ||
|
||
static void hwblk_area_inc(struct hwblk_info *info, int area) | ||
{ | ||
struct hwblk_area *hap = info->areas + area; | ||
|
||
hap->cnt++; | ||
if (hap->cnt == 1) | ||
if (hap->flags & HWBLK_AREA_FLAG_PARENT) | ||
hwblk_area_inc(info, hap->parent); | ||
} | ||
|
||
static void hwblk_area_dec(struct hwblk_info *info, int area) | ||
{ | ||
struct hwblk_area *hap = info->areas + area; | ||
|
||
if (hap->cnt == 1) | ||
if (hap->flags & HWBLK_AREA_FLAG_PARENT) | ||
hwblk_area_dec(info, hap->parent); | ||
hap->cnt--; | ||
} | ||
|
||
static void hwblk_enable(struct hwblk_info *info, int hwblk) | ||
{ | ||
struct hwblk *hp = info->hwblks + hwblk; | ||
unsigned long tmp; | ||
unsigned long flags; | ||
|
||
spin_lock_irqsave(&hwblk_lock, flags); | ||
|
||
hp->cnt++; | ||
if (hp->cnt == 1) { | ||
hwblk_area_inc(info, hp->area); | ||
|
||
tmp = __raw_readl(hp->mstp); | ||
tmp &= ~(1 << hp->bit); | ||
__raw_writel(tmp, hp->mstp); | ||
} | ||
|
||
spin_unlock_irqrestore(&hwblk_lock, flags); | ||
} | ||
|
||
static void hwblk_disable(struct hwblk_info *info, int hwblk) | ||
{ | ||
struct hwblk *hp = info->hwblks + hwblk; | ||
unsigned long tmp; | ||
unsigned long flags; | ||
|
||
spin_lock_irqsave(&hwblk_lock, flags); | ||
|
||
if (hp->cnt == 1) { | ||
hwblk_area_dec(info, hp->area); | ||
|
||
tmp = __raw_readl(hp->mstp); | ||
tmp |= 1 << hp->bit; | ||
__raw_writel(tmp, hp->mstp); | ||
} | ||
hp->cnt--; | ||
|
||
spin_unlock_irqrestore(&hwblk_lock, flags); | ||
} | ||
|
||
static struct hwblk_info *hwblk_info; | ||
|
||
int __init hwblk_register(struct hwblk_info *info) | ||
{ | ||
hwblk_info = info; | ||
return 0; | ||
} | ||
|
||
int __init __weak arch_hwblk_init(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
int __weak arch_hwblk_sleep_mode(void) | ||
{ | ||
return SUSP_SH_SLEEP; | ||
} | ||
|
||
int __init hwblk_init(void) | ||
{ | ||
return arch_hwblk_init(); | ||
} | ||
|
||
/* allow clocks to enable and disable hardware blocks */ | ||
static int sh_hwblk_clk_enable(struct clk *clk) | ||
{ | ||
if (!hwblk_info) | ||
return -ENOENT; | ||
|
||
hwblk_enable(hwblk_info, clk->arch_flags); | ||
return 0; | ||
} | ||
|
||
static void sh_hwblk_clk_disable(struct clk *clk) | ||
{ | ||
if (hwblk_info) | ||
hwblk_disable(hwblk_info, clk->arch_flags); | ||
} | ||
|
||
static struct clk_ops sh_hwblk_clk_ops = { | ||
.enable = sh_hwblk_clk_enable, | ||
.disable = sh_hwblk_clk_disable, | ||
.recalc = followparent_recalc, | ||
}; | ||
|
||
int __init sh_hwblk_clk_register(struct clk *clks, int nr) | ||
{ | ||
struct clk *clkp; | ||
int ret = 0; | ||
int k; | ||
|
||
for (k = 0; !ret && (k < nr); k++) { | ||
clkp = clks + k; | ||
clkp->ops = &sh_hwblk_clk_ops; | ||
ret |= clk_register(clkp); | ||
} | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.