1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-28 14:38:26 +02:00

jz4740: GPIO: Add functions to put function pins to high-z and to restore their

function.

We want to put function pins to high-z to decrease power leakage during suspend.
This commit is contained in:
Lars-Peter Clausen 2009-12-02 04:12:39 +01:00
parent aa7c40a8c1
commit 3ae48ccb8c
3 changed files with 36 additions and 13 deletions

View File

@ -19,13 +19,12 @@
#include <linux/types.h>
enum jz_gpio_function {
JZ_GPIO_FUNC_NONE,
JZ_GPIO_FUNC1,
JZ_GPIO_FUNC2,
JZ_GPIO_FUNC3,
JZ_GPIO_FUNC_NONE,
JZ_GPIO_FUNC1,
JZ_GPIO_FUNC2,
JZ_GPIO_FUNC3,
};
/*
Usually a driver for a SoC component has to request several gpio pins and
configure them as funcion pins.
@ -39,13 +38,13 @@ enum jz_gpio_function {
inside the probe function:
ret = jz_gpio_bulk_request(i2c_pins, ARRAY_SIZE(i2c_pins));
if (ret) {
ret = jz_gpio_bulk_request(i2c_pins, ARRAY_SIZE(i2c_pins));
if (ret) {
...
inside the remove function:
jz_gpio_bulk_free(i2c_pins, ARRAY_SIZE(i2c_pins));
jz_gpio_bulk_free(i2c_pins, ARRAY_SIZE(i2c_pins));
*/
@ -56,13 +55,15 @@ struct jz_gpio_bulk_request {
};
#define JZ_GPIO_BULK_PIN(pin) { \
.gpio = JZ_GPIO_ ## pin, \
.name = #pin, \
.function = JZ_GPIO_FUNC_ ## pin \
.gpio = JZ_GPIO_ ## pin, \
.name = #pin, \
.function = JZ_GPIO_FUNC_ ## pin \
}
int jz_gpio_bulk_request(const struct jz_gpio_bulk_request *request, size_t num);
void jz_gpio_bulk_free(const struct jz_gpio_bulk_request *request, size_t num);
void jz_gpio_bulk_suspend(const struct jz_gpio_bulk_request *request, size_t num);
void jz_gpio_bulk_resume(const struct jz_gpio_bulk_request *request, size_t num);
void jz_gpio_enable_pullup(unsigned gpio);
void jz_gpio_disable_pullup(unsigned gpio);
int jz_gpio_set_function(int gpio, enum jz_gpio_function function);
@ -192,7 +193,7 @@ int jz_gpio_set_function(int gpio, enum jz_gpio_function function);
#define JZ_GPIO_FUNC_MEM_ADDR14 JZ_GPIO_FUNC1
#define JZ_GPIO_FUNC_MEM_ADDR15 JZ_GPIO_FUNC1
#define JZ_GPIO_FUNC_MEM_ADDR16 JZ_GPIO_FUNC1
#define JZ_GPIO_FUNC_MEM_CLS JZ_GPIO_FUNC1
#define JZ_GPIO_FUNC_MEM_CLS JZ_GPIO_FUNC1
#define JZ_GPIO_FUNC_MEM_SPL JZ_GPIO_FUNC1
#define JZ_GPIO_FUNC_MEM_DCS JZ_GPIO_FUNC1
#define JZ_GPIO_FUNC_MEM_RAS JZ_GPIO_FUNC1

View File

@ -78,6 +78,7 @@
#define GPIO_TO_SEL_REG(gpio) GPIO_TO_REG(gpio, 0x50)
#define GPIO_TO_SEL_SET_REG(gpio) GPIO_TO_REG(gpio, 0x54)
#define GPIO_TO_SEL_CLEAR_REG(gpio) GPIO_TO_REG(gpio, 0x58)
#define GPIO_TO_DIRECTION_CLEAR_REG(chip) GPIO_TO_REG(chip, 0x68)
#define GPIO_TO_TRIGGER_REG(gpio) GPIO_TO_REG(gpio, 0x70)
#define GPIO_TO_TRIGGER_SET_REG(gpio) GPIO_TO_REG(gpio, 0x74)
#define GPIO_TO_TRIGGER_CLEAR_REG(gpio) GPIO_TO_REG(gpio, 0x78)
@ -162,6 +163,28 @@ void jz_gpio_bulk_free(const struct jz_gpio_bulk_request *request, size_t num)
}
EXPORT_SYMBOL_GPL(jz_gpio_bulk_free);
void jz_gpio_bulk_suspend(const struct jz_gpio_bulk_request *request, size_t num)
{
size_t i;
for (i = 0; i < num; ++i, ++request) {
jz_gpio_set_function(request->gpio, JZ_GPIO_FUNC_NONE);
writel(BIT(request->gpio), GPIO_TO_DIRECTION_CLEAR_REG(request->gpio));
}
}
EXPORT_SYMBOL_GPL(jz_gpio_bulk_suspend);
void jz_gpio_bulk_resume(const struct jz_gpio_bulk_request *request, size_t num)
{
size_t i;
for (i = 0; i < num; ++i, ++request) {
jz_gpio_set_function(request->gpio, request->function);
}
}
EXPORT_SYMBOL_GPL(jz_gpio_bulk_resume);
void jz_gpio_enable_pullup(unsigned gpio)
{
writel(GPIO_TO_BIT(gpio), GPIO_TO_PULL_CLEAR_REG(gpio));

View File

@ -45,7 +45,6 @@
#define JZ_REG_MMC_RXFIFO 0x38
#define JZ_REG_MMC_TXFIFO 0x3C
#define JZ_MMC_STRPCL_EXIT_MULTIPLE BIT(7)
#define JZ_MMC_STRPCL_EXIT_TRANSFER BIT(6)
#define JZ_MMC_STRPCL_START_READWAIT BIT(5)