-
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.
Implement an API to allow a list of pincfgs to be remuxed to active and sleep modes, for power saving. This is not exported on purpose, because it is not to be called by drivers directly. Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com> Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
- Loading branch information
Rabin Vincent
authored and
Linus Walleij
committed
Apr 24, 2012
1 parent
68293b3
commit 339bcf3
Showing
4 changed files
with
136 additions
and
1 deletion.
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
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,88 @@ | ||
/* | ||
* Copyright (C) ST-Ericsson SA 2010 | ||
* | ||
* Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson | ||
* License terms: GNU General Public License (GPL), version 2 | ||
*/ | ||
|
||
#include <linux/kernel.h> | ||
#include <linux/string.h> | ||
#include <linux/device.h> | ||
#include <linux/mutex.h> | ||
#include <linux/spinlock.h> | ||
#include <linux/err.h> | ||
#include <plat/pincfg.h> | ||
|
||
#include "pins.h" | ||
|
||
static LIST_HEAD(pin_lookups); | ||
static DEFINE_MUTEX(pin_lookups_mutex); | ||
static DEFINE_SPINLOCK(pins_lock); | ||
|
||
void __init ux500_pins_add(struct ux500_pin_lookup *pl, size_t num) | ||
{ | ||
mutex_lock(&pin_lookups_mutex); | ||
|
||
while (num--) { | ||
list_add_tail(&pl->node, &pin_lookups); | ||
pl++; | ||
} | ||
|
||
mutex_unlock(&pin_lookups_mutex); | ||
} | ||
|
||
struct ux500_pins *ux500_pins_get(const char *name) | ||
{ | ||
struct ux500_pins *pins = NULL; | ||
struct ux500_pin_lookup *pl; | ||
|
||
mutex_lock(&pin_lookups_mutex); | ||
|
||
list_for_each_entry(pl, &pin_lookups, node) { | ||
if (!strcmp(pl->name, name)) { | ||
pins = pl->pins; | ||
goto out; | ||
} | ||
} | ||
|
||
out: | ||
mutex_unlock(&pin_lookups_mutex); | ||
return pins; | ||
} | ||
|
||
int ux500_pins_enable(struct ux500_pins *pins) | ||
{ | ||
unsigned long flags; | ||
int ret = 0; | ||
|
||
spin_lock_irqsave(&pins_lock, flags); | ||
|
||
if (pins->usage++ == 0) | ||
ret = nmk_config_pins(pins->cfg, pins->num); | ||
|
||
spin_unlock_irqrestore(&pins_lock, flags); | ||
return ret; | ||
} | ||
|
||
int ux500_pins_disable(struct ux500_pins *pins) | ||
{ | ||
unsigned long flags; | ||
int ret = 0; | ||
|
||
spin_lock_irqsave(&pins_lock, flags); | ||
|
||
if (WARN_ON(pins->usage == 0)) | ||
goto out; | ||
|
||
if (--pins->usage == 0) | ||
ret = nmk_config_pins_sleep(pins->cfg, pins->num); | ||
|
||
out: | ||
spin_unlock_irqrestore(&pins_lock, flags); | ||
return ret; | ||
} | ||
|
||
void ux500_pins_put(struct ux500_pins *pins) | ||
{ | ||
WARN_ON(!pins); | ||
} |
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,46 @@ | ||
/* | ||
* Copyright (C) ST-Ericsson SA 2010 | ||
* | ||
* Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson | ||
* License terms: GNU General Public License (GPL), version 2 | ||
*/ | ||
|
||
#ifndef __MACH_UX500_PINS_H | ||
#define __MACH_UX500_PINS_H | ||
|
||
#include <linux/list.h> | ||
#include <plat/pincfg.h> | ||
|
||
#define PIN_LOOKUP(_name, _pins) \ | ||
{ \ | ||
.name = _name, \ | ||
.pins = _pins, \ | ||
} | ||
|
||
#define UX500_PINS(name, pins...) \ | ||
struct ux500_pins name = { \ | ||
.cfg = (pin_cfg_t[]) {pins}, \ | ||
.num = ARRAY_SIZE(((pin_cfg_t[]) {pins})), \ | ||
} | ||
|
||
struct ux500_pins { | ||
int usage; | ||
int num; | ||
pin_cfg_t *cfg; | ||
}; | ||
|
||
struct ux500_pin_lookup { | ||
struct list_head node; | ||
const char *name; | ||
struct ux500_pins *pins; | ||
}; | ||
|
||
void __init ux500_pins_add(struct ux500_pin_lookup *pl, size_t num); | ||
void __init ux500_offchip_gpio_init(struct ux500_pins *pins); | ||
struct ux500_pins *ux500_pins_get(const char *name); | ||
int ux500_pins_enable(struct ux500_pins *pins); | ||
int ux500_pins_disable(struct ux500_pins *pins); | ||
void ux500_pins_put(struct ux500_pins *pins); | ||
int pins_for_u9500(void); | ||
|
||
#endif |