章鹏老婆陈晨:s3c2410_gpio_pullup()

来源:百度文库 编辑:中财网 时间:2024/04/30 03:39:44
s3c2410_gpio_pullup()在gpio.c中

作用:设置相应GPIO口的上拉电阻,
如pin=S3C2410_GPB5    to=0   则:设置S3C2410_GPB5的不要上拉电阻
如pin=S3C2410_GPB5    to=1 则:设置S3C2410_GPB5的要上拉电阻

void s3c2410_gpio_pullup(unsigned int pin, unsigned int to)
{
void __iomem *base = S3C24XX_GPIO_BASE(pin);
unsigned long offs = S3C2410_GPIO_OFFSET(pin);
unsigned long flags;
unsigned long up;

if (pin < S3C2410_GPIO_BANKB)
return;

local_irq_save(flags);

up = __raw_readl(base + 0x08);
[color=Red]up &= ~(1L << offs);
up |= to << offs;[/color]
__raw_writel(up, base + 0x08);

local_irq_restore(flags);
}
EXPORT_SYMBOL(s3c2410_gpio_pullup);