1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-28 17:35:19 +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

@ -25,7 +25,6 @@ enum jz_gpio_function {
JZ_GPIO_FUNC3, JZ_GPIO_FUNC3,
}; };
/* /*
Usually a driver for a SoC component has to request several gpio pins and Usually a driver for a SoC component has to request several gpio pins and
configure them as funcion pins. configure them as funcion pins.
@ -63,6 +62,8 @@ struct jz_gpio_bulk_request {
int jz_gpio_bulk_request(const struct jz_gpio_bulk_request *request, size_t num); 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_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_enable_pullup(unsigned gpio);
void jz_gpio_disable_pullup(unsigned gpio); void jz_gpio_disable_pullup(unsigned gpio);
int jz_gpio_set_function(int gpio, enum jz_gpio_function function); int jz_gpio_set_function(int gpio, enum jz_gpio_function function);

View File

@ -78,6 +78,7 @@
#define GPIO_TO_SEL_REG(gpio) GPIO_TO_REG(gpio, 0x50) #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_SET_REG(gpio) GPIO_TO_REG(gpio, 0x54)
#define GPIO_TO_SEL_CLEAR_REG(gpio) GPIO_TO_REG(gpio, 0x58) #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_REG(gpio) GPIO_TO_REG(gpio, 0x70)
#define GPIO_TO_TRIGGER_SET_REG(gpio) GPIO_TO_REG(gpio, 0x74) #define GPIO_TO_TRIGGER_SET_REG(gpio) GPIO_TO_REG(gpio, 0x74)
#define GPIO_TO_TRIGGER_CLEAR_REG(gpio) GPIO_TO_REG(gpio, 0x78) #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); 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) void jz_gpio_enable_pullup(unsigned gpio)
{ {
writel(GPIO_TO_BIT(gpio), GPIO_TO_PULL_CLEAR_REG(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_RXFIFO 0x38
#define JZ_REG_MMC_TXFIFO 0x3C #define JZ_REG_MMC_TXFIFO 0x3C
#define JZ_MMC_STRPCL_EXIT_MULTIPLE BIT(7) #define JZ_MMC_STRPCL_EXIT_MULTIPLE BIT(7)
#define JZ_MMC_STRPCL_EXIT_TRANSFER BIT(6) #define JZ_MMC_STRPCL_EXIT_TRANSFER BIT(6)
#define JZ_MMC_STRPCL_START_READWAIT BIT(5) #define JZ_MMC_STRPCL_START_READWAIT BIT(5)