Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 264309
b: refs/heads/master
c: bd71000
h: refs/heads/master
i:
  264307: e4ed94d
v: v3
  • Loading branch information
Rafael J. Wysocki authored and Ralf Baechle committed Sep 21, 2011
1 parent f90d336 commit 8ddd148
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 31 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: 1eec6cd08b4feb72a73aff468ab72bdd21e1dc61
refs/heads/master: bd7100099a46b59f433dd15ad60adbb4d4f3d625
52 changes: 22 additions & 30 deletions trunk/arch/mips/jz4740/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <linux/init.h>

#include <linux/spinlock.h>
#include <linux/sysdev.h>
#include <linux/syscore_ops.h>
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/delay.h>
Expand Down Expand Up @@ -86,7 +86,6 @@ struct jz_gpio_chip {
spinlock_t lock;

struct gpio_chip gpio_chip;
struct sys_device sysdev;
};

static struct jz_gpio_chip jz4740_gpio_chips[];
Expand Down Expand Up @@ -459,49 +458,47 @@ static struct jz_gpio_chip jz4740_gpio_chips[] = {
JZ4740_GPIO_CHIP(D),
};

static inline struct jz_gpio_chip *sysdev_to_chip(struct sys_device *dev)
static void jz4740_gpio_suspend_chip(struct jz_gpio_chip *chip)
{
return container_of(dev, struct jz_gpio_chip, sysdev);
chip->suspend_mask = readl(chip->base + JZ_REG_GPIO_MASK);
writel(~(chip->wakeup), chip->base + JZ_REG_GPIO_MASK_SET);
writel(chip->wakeup, chip->base + JZ_REG_GPIO_MASK_CLEAR);
}

static int jz4740_gpio_suspend(struct sys_device *dev, pm_message_t state)
static int jz4740_gpio_suspend(void)
{
struct jz_gpio_chip *chip = sysdev_to_chip(dev);
int i;

chip->suspend_mask = readl(chip->base + JZ_REG_GPIO_MASK);
writel(~(chip->wakeup), chip->base + JZ_REG_GPIO_MASK_SET);
writel(chip->wakeup, chip->base + JZ_REG_GPIO_MASK_CLEAR);
for (i = 0; i < ARRAY_SIZE(jz4740_gpio_chips); i++)
jz4740_gpio_suspend_chip(&jz4740_gpio_chips[i]);

return 0;
}

static int jz4740_gpio_resume(struct sys_device *dev)
static void jz4740_gpio_resume_chip(struct jz_gpio_chip *chip)
{
struct jz_gpio_chip *chip = sysdev_to_chip(dev);
uint32_t mask = chip->suspend_mask;

writel(~mask, chip->base + JZ_REG_GPIO_MASK_CLEAR);
writel(mask, chip->base + JZ_REG_GPIO_MASK_SET);
}

return 0;
static void jz4740_gpio_resume(void)
{
int i;

for (i = ARRAY_SIZE(jz4740_gpio_chips) - 1; i >= 0 ; i--)
jz4740_gpio_resume_chip(&jz4740_gpio_chips[i]);
}

static struct sysdev_class jz4740_gpio_sysdev_class = {
.name = "gpio",
static struct syscore_ops jz4740_gpio_syscore_ops = {
.suspend = jz4740_gpio_suspend,
.resume = jz4740_gpio_resume,
};

static int jz4740_gpio_chip_init(struct jz_gpio_chip *chip, unsigned int id)
static void jz4740_gpio_chip_init(struct jz_gpio_chip *chip, unsigned int id)
{
int ret, irq;

chip->sysdev.id = id;
chip->sysdev.cls = &jz4740_gpio_sysdev_class;
ret = sysdev_register(&chip->sysdev);

if (ret)
return ret;
int irq;

spin_lock_init(&chip->lock);

Expand All @@ -519,22 +516,17 @@ static int jz4740_gpio_chip_init(struct jz_gpio_chip *chip, unsigned int id)
irq_set_chip_and_handler(irq, &jz_gpio_irq_chip,
handle_level_irq);
}

return 0;
}

static int __init jz4740_gpio_init(void)
{
unsigned int i;
int ret;

ret = sysdev_class_register(&jz4740_gpio_sysdev_class);
if (ret)
return ret;

for (i = 0; i < ARRAY_SIZE(jz4740_gpio_chips); ++i)
jz4740_gpio_chip_init(&jz4740_gpio_chips[i], i);

register_syscore_ops(&jz4740_gpio_syscore_ops);

printk(KERN_INFO "JZ4740 GPIO initialized\n");

return 0;
Expand Down

0 comments on commit 8ddd148

Please sign in to comment.