Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 303024
b: refs/heads/master
c: 5d95dde
h: refs/heads/master
v: v3
  • Loading branch information
Paul Walmsley committed Apr 19, 2012
1 parent e49d553 commit b76eff1
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 49 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2d6141baf15df188283ada7c0fa04679c4fcf1c7
refs/heads/master: 5d95dde7316101656102cb585b73381e4eaadaa7
115 changes: 67 additions & 48 deletions trunk/arch/arm/mach-omap2/omap_hwmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,29 @@ static struct omap_hwmod *mpu_oh;

/* Private functions */

/**
* _fetch_next_ocp_if - return @i'th OCP interface in an array
* @p: ptr to a ptr to the list_head inside the ocp_if to return (not yet used)
* @old: ptr to an array of struct omap_hwmod_ocp_if records
* @i: pointer to the index into the @old array
*
* Return a pointer to the next struct omap_hwmod_ocp_if record in a
* sequence. Currently returns a struct omap_hwmod_ocp_if record
* corresponding to the element index pointed to by @i in the @old
* array, and increments the index pointed to by @i.
*/
static struct omap_hwmod_ocp_if *_fetch_next_ocp_if(struct list_head **p,
struct omap_hwmod_ocp_if **old,
int *i)
{
struct omap_hwmod_ocp_if *oi;

oi = old[*i];
*i = *i + 1;

return oi;
}

/**
* _update_sysc_cache - return the module OCP_SYSCONFIG register, keep copy
* @oh: struct omap_hwmod *
Expand Down Expand Up @@ -582,16 +605,13 @@ static int _init_main_clk(struct omap_hwmod *oh)
*/
static int _init_interface_clks(struct omap_hwmod *oh)
{
struct omap_hwmod_ocp_if *os;
struct clk *c;
int i;
int i = 0;
int ret = 0;

if (oh->slaves_cnt == 0)
return 0;

for (i = 0; i < oh->slaves_cnt; i++) {
struct omap_hwmod_ocp_if *os = oh->slaves[i];

while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);
if (!os->clk)
continue;

Expand Down Expand Up @@ -643,21 +663,19 @@ static int _init_opt_clks(struct omap_hwmod *oh)
*/
static int _enable_clocks(struct omap_hwmod *oh)
{
int i;
struct omap_hwmod_ocp_if *os;
int i = 0;

pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name);

if (oh->_clk)
clk_enable(oh->_clk);

if (oh->slaves_cnt > 0) {
for (i = 0; i < oh->slaves_cnt; i++) {
struct omap_hwmod_ocp_if *os = oh->slaves[i];
struct clk *c = os->_clk;
while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);

if (c && (os->flags & OCPIF_SWSUP_IDLE))
clk_enable(c);
}
if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE))
clk_enable(os->_clk);
}

/* The opt clocks are controlled by the device driver. */
Expand All @@ -673,21 +691,19 @@ static int _enable_clocks(struct omap_hwmod *oh)
*/
static int _disable_clocks(struct omap_hwmod *oh)
{
int i;
struct omap_hwmod_ocp_if *os;
int i = 0;

pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);

if (oh->_clk)
clk_disable(oh->_clk);

if (oh->slaves_cnt > 0) {
for (i = 0; i < oh->slaves_cnt; i++) {
struct omap_hwmod_ocp_if *os = oh->slaves[i];
struct clk *c = os->_clk;
while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);

if (c && (os->flags & OCPIF_SWSUP_IDLE))
clk_disable(c);
}
if (os->_clk && (os->flags & OCPIF_SWSUP_IDLE))
clk_disable(os->_clk);
}

/* The opt clocks are controlled by the device driver. */
Expand Down Expand Up @@ -961,8 +977,9 @@ static int _get_addr_space_by_name(struct omap_hwmod *oh, const char *name,
struct omap_hwmod_ocp_if *os;
bool found = false;

for (i = 0; i < oh->slaves_cnt; i++) {
os = oh->slaves[i];
i = 0;
while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);

if (!os->addr)
return -ENOENT;
Expand Down Expand Up @@ -999,15 +1016,15 @@ static int _get_addr_space_by_name(struct omap_hwmod *oh, const char *name,
*/
static int __init _find_mpu_port_index(struct omap_hwmod *oh)
{
int i;
struct omap_hwmod_ocp_if *os;
int i = 0;
int found = 0;

if (!oh || oh->slaves_cnt == 0)
if (!oh)
return -EINVAL;

for (i = 0; i < oh->slaves_cnt; i++) {
struct omap_hwmod_ocp_if *os = oh->slaves[i];

while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);
if (os->user & OCP_USER_MPU) {
found = 1;
break;
Expand All @@ -1016,12 +1033,12 @@ static int __init _find_mpu_port_index(struct omap_hwmod *oh)

if (found)
pr_debug("omap_hwmod: %s: MPU OCP slave port ID %d\n",
oh->name, i);
oh->name, i - 1);
else
pr_debug("omap_hwmod: %s: no MPU OCP slave port found\n",
oh->name);

return (found) ? i : -EINVAL;
return (found) ? (i - 1) : -EINVAL;
}

/**
Expand Down Expand Up @@ -2027,23 +2044,22 @@ static int __init _init(struct omap_hwmod *oh, void *data)
*/
static void __init _setup_iclk_autoidle(struct omap_hwmod *oh)
{
int i;

struct omap_hwmod_ocp_if *os;
int i = 0;
if (oh->_state != _HWMOD_STATE_INITIALIZED)
return;

for (i = 0; i < oh->slaves_cnt; i++) {
struct omap_hwmod_ocp_if *os = oh->slaves[i];
struct clk *c = os->_clk;

if (!c)
while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);
if (!os->_clk)
continue;

if (os->flags & OCPIF_SWSUP_IDLE) {
/* XXX omap_iclk_deny_idle(c); */
} else {
/* XXX omap_iclk_allow_idle(c); */
clk_enable(c);
clk_enable(os->_clk);
}
}

Expand Down Expand Up @@ -2623,12 +2639,16 @@ int omap_hwmod_reset(struct omap_hwmod *oh)
*/
int omap_hwmod_count_resources(struct omap_hwmod *oh)
{
int ret, i;
struct omap_hwmod_ocp_if *os;
int ret;
int i = 0;

ret = _count_mpu_irqs(oh) + _count_sdma_reqs(oh);

for (i = 0; i < oh->slaves_cnt; i++)
ret += _count_ocp_if_addr_spaces(oh->slaves[i]);
while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);
ret += _count_ocp_if_addr_spaces(os);
}

return ret;
}
Expand All @@ -2645,7 +2665,8 @@ int omap_hwmod_count_resources(struct omap_hwmod *oh)
*/
int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)
{
int i, j, mpu_irqs_cnt, sdma_reqs_cnt;
struct omap_hwmod_ocp_if *os;
int i, j, mpu_irqs_cnt, sdma_reqs_cnt, addr_cnt;
int r = 0;

/* For each IRQ, DMA, memory area, fill in array.*/
Expand All @@ -2668,11 +2689,9 @@ int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)
r++;
}

for (i = 0; i < oh->slaves_cnt; i++) {
struct omap_hwmod_ocp_if *os;
int addr_cnt;

os = oh->slaves[i];
i = 0;
while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);
addr_cnt = _count_ocp_if_addr_spaces(os);

for (j = 0; j < addr_cnt; j++) {
Expand Down

0 comments on commit b76eff1

Please sign in to comment.