ckfwq/linux-3.0.4/arch/mips/include/asm/mach-loongson/gsc3280/gpio-plat.h

81 lines
2.0 KiB
C
Raw Normal View History

2024-12-30 10:53:50 +08:00
/* linux/arch/mips/include/asm/mach-loongson/gsc3280/gpio-core.h
*
* Copyright 2012 Loongson. co LTD
* Ansonn.wang <ansonn.wang@gmail.com>
*
* GSC3280 - GPIO core
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _GSC3280_GPIO_PLAT_H
#define _GSC3280_GPIO_PLAT_H
#include <linux/gpio.h>
struct GSC3280_gpio_chip;
#ifdef CONFIG_PM
/**
* struct GSC3280_gpio_pm - power management (suspend/resume) information
* @save: Routine to save the state of the GPIO block
* @resume: Routine to resume the GPIO block.
*/
struct GSC3280_gpio_pm {
void (*save)(struct gsc3280_gpio_chip *chip);
void (*resume)(struct gsc32800_gpio_chip *chip);
};
#endif
/**
* struct gsc3280_gpio_pm - wrapper for specific implementation of gpio
* @chip: The chip structure to be exported via gpiolib.
* @base: The base pointer to the gpio configuration registers.
* @irq_base: The base irq number.
* @lock: Lock for exclusive access to this gpio bank.
* @pm_save: Save information for suspend/resume support.
*
*/
struct gsc3280_gpio_chip {
struct gpio_chip chip;
#ifdef CONFIG_PM
struct gsc3280_gpio_pm *pm;
#endif
void __iomem *base;
int irq_base;
spinlock_t lock;
#ifdef CONFIG_PM
u32 pm_save[4];
#endif
};
static inline
struct gsc3280_gpio_chip *to_gsc3280_gpio(struct gpio_chip *gpc)
{
return container_of(gpc, struct gsc3280_gpio_chip, chip);
}
/* locking wrappers to deal with multiple access to the same gpio bank */
#define gsc3280_gpio_lock(_oc, _fl) \
spin_lock_irqsave(&(_oc)->lock, _fl)
#define gsc3280_gpio_unlock(_oc, _fl) \
spin_unlock_irqrestore(&(_oc)->lock, _fl)
#if 0
#define GSC3280_BANK_BASE(bank_nr) \
((volatile __iomem void *)(GSC3280_GPIO_BASEADDR + ((bank_nr) * 0x0c)))
#endif
#ifdef CONFIG_PM
void gsc3280_gpio_pm_save(struct gsc3280_gpio_chip *chip);
void gsc3280_gpio_pm_resume(struct gsc3280_gpio_chip *chip);
#endif
#endif