Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 91275
b: refs/heads/master
c: 45528e3
h: refs/heads/master
i:
  91273: 18d5492
  91271: ae6c70b
v: v3
  • Loading branch information
Dmitry Baryshkov authored and Russell King committed Apr 10, 2008
1 parent 74e48fb commit 3dda98f
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 52 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: c353faa4b2abd8d5142640b880532c97a0807460
refs/heads/master: 45528e38173e7d8c03821850e8fd1ddbf16f2b3d
1 change: 1 addition & 0 deletions trunk/arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ config ARCH_SA1100
select GENERIC_GPIO
select GENERIC_TIME
select HAVE_IDE
select HAVE_GPIO_LIB
help
Support for StrongARM 11x0 based boards.

Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/arm/mach-sa1100/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

# Common support
obj-y := clock.o generic.o irq.o dma.o time.o #nmi-oopser.o
obj-y := clock.o generic.o gpio.o irq.o dma.o time.o #nmi-oopser.o
obj-m :=
obj-n :=
obj- :=
Expand Down
31 changes: 0 additions & 31 deletions trunk/arch/arm/mach-sa1100/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,37 +139,6 @@ unsigned long long sched_clock(void)
return v;
}

int gpio_direction_input(unsigned gpio)
{
unsigned long flags;

if (gpio > GPIO_MAX)
return -EINVAL;

local_irq_save(flags);
GPDR &= ~GPIO_GPIO(gpio);
local_irq_restore(flags);
return 0;
}

EXPORT_SYMBOL(gpio_direction_input);

int gpio_direction_output(unsigned gpio, int value)
{
unsigned long flags;

if (gpio > GPIO_MAX)
return -EINVAL;

local_irq_save(flags);
gpio_set_value(gpio, value);
GPDR |= GPIO_GPIO(gpio);
local_irq_restore(flags);
return 0;
}

EXPORT_SYMBOL(gpio_direction_output);

/*
* Default power-off for SA1100
*/
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/arm/mach-sa1100/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct sys_timer;
extern struct sys_timer sa1100_timer;
extern void __init sa1100_map_io(void);
extern void __init sa1100_init_irq(void);
extern void __init sa1100_init_gpio(void);

#define SET_BANK(__nr,__start,__size) \
mi->bank[__nr].start = (__start), \
Expand Down
65 changes: 65 additions & 0 deletions trunk/arch/arm/mach-sa1100/gpio.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* linux/arch/arm/mach-sa1100/gpio.c
*
* Generic SA-1100 GPIO handling
*
* 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.
*/

#include <linux/init.h>
#include <linux/module.h>

#include <asm/gpio.h>
#include <asm/hardware.h>
#include "generic.h"

static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset)
{
return GPLR & GPIO_GPIO(offset);
}

static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
if (value)
GPSR = GPIO_GPIO(offset);
else
GPCR = GPIO_GPIO(offset);
}

static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
{
unsigned long flags;

local_irq_save(flags);
GPDR &= ~GPIO_GPIO(offset);
local_irq_restore(flags);
return 0;
}

static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value)
{
unsigned long flags;

local_irq_save(flags);
sa1100_gpio_set(chip, offset, value);
GPDR |= GPIO_GPIO(offset);
local_irq_restore(flags);
return 0;
}

static struct gpio_chip sa1100_gpio_chip = {
.label = "gpio",
.direction_input = sa1100_direction_input,
.direction_output = sa1100_direction_output,
.set = sa1100_gpio_set,
.get = sa1100_gpio_get,
.base = 0,
.ngpio = GPIO_MAX + 1,
};

void __init sa1100_init_gpio(void)
{
gpiochip_add(&sa1100_gpio_chip);
}
2 changes: 2 additions & 0 deletions trunk/arch/arm/mach-sa1100/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,6 @@ void __init sa1100_init_irq(void)
*/
set_irq_chip(IRQ_GPIO11_27, &sa1100_normal_chip);
set_irq_chained_handler(IRQ_GPIO11_27, sa1100_high_gpio_handler);

sa1100_init_gpio();
}
31 changes: 12 additions & 19 deletions trunk/include/asm-arm/arch-sa1100/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,28 @@

#include <asm/hardware.h>
#include <asm/irq.h>

static inline int gpio_request(unsigned gpio, const char *label)
{
return 0;
}

static inline void gpio_free(unsigned gpio)
{
return;
}

extern int gpio_direction_input(unsigned gpio);
extern int gpio_direction_output(unsigned gpio, int value);

#include <asm-generic/gpio.h>

static inline int gpio_get_value(unsigned gpio)
{
return GPLR & GPIO_GPIO(gpio);
if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))
return GPLR & GPIO_GPIO(gpio);
else
return __gpio_get_value(gpio);
}

static inline void gpio_set_value(unsigned gpio, int value)
{
if (value)
GPSR = GPIO_GPIO(gpio);
if (__builtin_constant_p(gpio) && (gpio <= GPIO_MAX))
if (value)
GPSR = GPIO_GPIO(gpio);
else
GPCR = GPIO_GPIO(gpio);
else
GPCR = GPIO_GPIO(gpio);
__gpio_set_value(gpio, value);
}

#include <asm-generic/gpio.h> /* cansleep wrappers */
#define gpio_cansleep __gpio_cansleep

static inline unsigned gpio_to_irq(unsigned gpio)
{
Expand Down

0 comments on commit 3dda98f

Please sign in to comment.