Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58661
b: refs/heads/master
c: 3896b05
h: refs/heads/master
i:
  58659: a2d426f
v: v3
  • Loading branch information
Atsushi Nemoto authored and Ralf Baechle committed Jul 10, 2007
1 parent 6714fba commit 7fdea59
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 06cf5583fd9ac782cf34996cdabb48afdf478e37
refs/heads/master: 3896b05418b9b8548a678231db754206b3ebe56e
1 change: 1 addition & 0 deletions trunk/arch/mips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ config TOSHIBA_RBTX4938
select SYS_SUPPORTS_BIG_ENDIAN
select SYS_SUPPORTS_KGDB
select GENERIC_HARDIRQS_NO__DO_IRQ
select GENERIC_GPIO
help
This Toshiba board is based on the TX4938 processor. Say Y here to
support this machine type
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/mips/configs/rbhma4500_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ CONFIG_DMA_NONCOHERENT=y
CONFIG_DMA_NEED_PCI_MAP_STATE=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_I8259=y
CONFIG_GENERIC_GPIO=y
# CONFIG_CPU_BIG_ENDIAN is not set
CONFIG_CPU_LITTLE_ENDIAN=y
CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
Expand Down
104 changes: 104 additions & 0 deletions trunk/arch/mips/tx4938/toshiba_rbtx4938/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/bootinfo.h>
#include <asm/gpio.h>
#include <asm/tx4938/rbtx4938.h>
#ifdef CONFIG_SERIAL_TXX9
#include <linux/tty.h>
Expand Down Expand Up @@ -1057,3 +1058,106 @@ static int __init rbtx4938_ne_init(void)
return IS_ERR(dev) ? PTR_ERR(dev) : 0;
}
device_initcall(rbtx4938_ne_init);

/* GPIO support */

static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock);

static void rbtx4938_spi_gpio_set(unsigned gpio, int value)
{
u8 val;
unsigned long flags;
gpio -= 16;
spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags);
val = *rbtx4938_spics_ptr;
if (value)
val |= 1 << gpio;
else
val &= ~(1 << gpio);
*rbtx4938_spics_ptr = val;
mmiowb();
spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags);
}

static int rbtx4938_spi_gpio_dir_out(unsigned gpio, int value)
{
rbtx4938_spi_gpio_set(gpio, value);
return 0;
}

static DEFINE_SPINLOCK(tx4938_gpio_lock);

static int tx4938_gpio_get(unsigned gpio)
{
return tx4938_pioptr->din & (1 << gpio);
}

static void tx4938_gpio_set_raw(unsigned gpio, int value)
{
u32 val;
val = tx4938_pioptr->dout;
if (value)
val |= 1 << gpio;
else
val &= ~(1 << gpio);
tx4938_pioptr->dout = val;
}

static void tx4938_gpio_set(unsigned gpio, int value)
{
unsigned long flags;
spin_lock_irqsave(&tx4938_gpio_lock, flags);
tx4938_gpio_set_raw(gpio, value);
mmiowb();
spin_unlock_irqrestore(&tx4938_gpio_lock, flags);
}

static int tx4938_gpio_dir_in(unsigned gpio)
{
spin_lock_irq(&tx4938_gpio_lock);
tx4938_pioptr->dir &= ~(1 << gpio);
mmiowb();
spin_unlock_irq(&tx4938_gpio_lock);
return 0;
}

static int tx4938_gpio_dir_out(unsigned int gpio, int value)
{
spin_lock_irq(&tx4938_gpio_lock);
tx4938_gpio_set_raw(gpio, value);
tx4938_pioptr->dir |= 1 << gpio;
mmiowb();
spin_unlock_irq(&tx4938_gpio_lock);
return 0;
}

int gpio_direction_input(unsigned gpio)
{
if (gpio < 16)
return tx4938_gpio_dir_in(gpio);
return -EINVAL;
}

int gpio_direction_output(unsigned gpio, int value)
{
if (gpio < 16)
return tx4938_gpio_dir_out(gpio, value);
if (gpio < 16 + 3)
return rbtx4938_spi_gpio_dir_out(gpio, value);
return -EINVAL;
}

int gpio_get_value(unsigned gpio)
{
if (gpio < 16)
return tx4938_gpio_get(gpio);
return 0;
}

void gpio_set_value(unsigned gpio, int value)
{
if (gpio < 16)
tx4938_gpio_set(gpio, value);
else
rbtx4938_spi_gpio_set(gpio, value);
}

0 comments on commit 7fdea59

Please sign in to comment.