[ARM] 5026/1: locomo: add .settype for gpio and several small fixes
authorThomas Kunze <thommycheck@gmx.de>
Tue, 29 Apr 2008 16:44:54 +0000 (17:44 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 17 May 2008 21:53:54 +0000 (22:53 +0100)
irqs.h:
    * rename IRQ_LOCOMO_SPI_OVRN to IRQ_LOCOMO_SPI_REND
locomo.h:
    * add some definition for locomo spi controller
    * correct some errors
locomo.c:
    * correct some errors
    * add set_type for locomo gpio irq chip

Signed-off-by: Thomas Kunze <thommycheck@gmx.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/common/locomo.c
include/asm-arm/arch-sa1100/irqs.h
include/asm-arm/hardware/locomo.h

index ae21755..d973c98 100644 (file)
@@ -321,11 +321,42 @@ static void locomo_gpio_unmask_irq(unsigned int irq)
        locomo_writel(r, mapbase + LOCOMO_GIE);
 }
 
+static int GPIO_IRQ_rising_edge;
+static int GPIO_IRQ_falling_edge;
+
+static int locomo_gpio_type(unsigned int irq, unsigned int type)
+{
+       unsigned int mask;
+       void __iomem *mapbase = get_irq_chip_data(irq);
+
+       mask = 1 << (irq - LOCOMO_IRQ_GPIO_START);
+
+       if (type == IRQT_PROBE) {
+               if ((GPIO_IRQ_rising_edge | GPIO_IRQ_falling_edge) & mask)
+                       return 0;
+               type = __IRQT_RISEDGE | __IRQT_FALEDGE;
+       }
+
+       if (type & __IRQT_RISEDGE)
+               GPIO_IRQ_rising_edge |= mask;
+       else
+               GPIO_IRQ_rising_edge &= ~mask;
+       if (type & __IRQT_FALEDGE)
+               GPIO_IRQ_falling_edge |= mask;
+       else
+               GPIO_IRQ_falling_edge &= ~mask;
+       locomo_writel(GPIO_IRQ_rising_edge, mapbase + LOCOMO_GRIE);
+       locomo_writel(GPIO_IRQ_falling_edge, mapbase + LOCOMO_GFIE);
+
+       return 0;
+}
+
 static struct irq_chip locomo_gpio_chip = {
-       .name   = "LOCOMO-gpio",
-       .ack    = locomo_gpio_ack_irq,
-       .mask   = locomo_gpio_mask_irq,
-       .unmask = locomo_gpio_unmask_irq,
+       .name     = "LOCOMO-gpio",
+       .ack      = locomo_gpio_ack_irq,
+       .mask     = locomo_gpio_mask_irq,
+       .unmask   = locomo_gpio_unmask_irq,
+       .set_type = locomo_gpio_type,
 };
 
 static void locomo_lt_handler(unsigned int irq, struct irq_desc *desc)
@@ -450,22 +481,18 @@ static void locomo_setup_irq(struct locomo *lchip)
        set_irq_chip(IRQ_LOCOMO_KEY_BASE, &locomo_chip);
        set_irq_chip_data(IRQ_LOCOMO_KEY_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_KEY_BASE, locomo_key_handler);
-       set_irq_flags(IRQ_LOCOMO_KEY_BASE, IRQF_VALID | IRQF_PROBE);
 
        set_irq_chip(IRQ_LOCOMO_GPIO_BASE, &locomo_chip);
        set_irq_chip_data(IRQ_LOCOMO_GPIO_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_GPIO_BASE, locomo_gpio_handler);
-       set_irq_flags(IRQ_LOCOMO_GPIO_BASE, IRQF_VALID | IRQF_PROBE);
 
        set_irq_chip(IRQ_LOCOMO_LT_BASE, &locomo_chip);
        set_irq_chip_data(IRQ_LOCOMO_LT_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_LT_BASE, locomo_lt_handler);
-       set_irq_flags(IRQ_LOCOMO_LT_BASE, IRQF_VALID | IRQF_PROBE);
 
        set_irq_chip(IRQ_LOCOMO_SPI_BASE, &locomo_chip);
        set_irq_chip_data(IRQ_LOCOMO_SPI_BASE, irqbase);
        set_irq_chained_handler(IRQ_LOCOMO_SPI_BASE, locomo_spi_handler);
-       set_irq_flags(IRQ_LOCOMO_SPI_BASE, IRQF_VALID | IRQF_PROBE);
 
        /* install handlers for IRQ_LOCOMO_KEY_BASE generated interrupts */
        set_irq_chip(LOCOMO_IRQ_KEY_START, &locomo_key_chip);
@@ -488,7 +515,7 @@ static void locomo_setup_irq(struct locomo *lchip)
        set_irq_flags(LOCOMO_IRQ_LT_START, IRQF_VALID | IRQF_PROBE);
 
        /* install handlers for IRQ_LOCOMO_SPI_BASE generated interrupts */
-       for (irq = LOCOMO_IRQ_SPI_START; irq < LOCOMO_IRQ_SPI_START + 3; irq++) {
+       for (irq = LOCOMO_IRQ_SPI_START; irq < LOCOMO_IRQ_SPI_START + 4; irq++) {
                set_irq_chip(irq, &locomo_spi_chip);
                set_irq_chip_data(irq, irqbase);
                set_irq_handler(irq, handle_edge_irq);
@@ -574,20 +601,20 @@ static int locomo_suspend(struct platform_device *dev, pm_message_t state)
 
        save->LCM_GPO     = locomo_readl(lchip->base + LOCOMO_GPO);     /* GPIO */
        locomo_writel(0x00, lchip->base + LOCOMO_GPO);
-       save->LCM_SPICT   = locomo_readl(lchip->base + LOCOMO_SPICT);   /* SPI */
+       save->LCM_SPICT   = locomo_readl(lchip->base + LOCOMO_SPI + LOCOMO_SPICT);      /* SPI */
        locomo_writel(0x40, lchip->base + LOCOMO_SPICT);
        save->LCM_GPE     = locomo_readl(lchip->base + LOCOMO_GPE);     /* GPIO */
        locomo_writel(0x00, lchip->base + LOCOMO_GPE);
        save->LCM_ASD     = locomo_readl(lchip->base + LOCOMO_ASD);     /* ADSTART */
        locomo_writel(0x00, lchip->base + LOCOMO_ASD);
-       save->LCM_SPIMD   = locomo_readl(lchip->base + LOCOMO_SPIMD);   /* SPI */
-       locomo_writel(0x3C14, lchip->base + LOCOMO_SPIMD);
+       save->LCM_SPIMD   = locomo_readl(lchip->base + LOCOMO_SPI + LOCOMO_SPIMD);      /* SPI */
+       locomo_writel(0x3C14, lchip->base + LOCOMO_SPI + LOCOMO_SPIMD);
 
        locomo_writel(0x00, lchip->base + LOCOMO_PAIF);
        locomo_writel(0x00, lchip->base + LOCOMO_DAC);
        locomo_writel(0x00, lchip->base + LOCOMO_BACKLIGHT + LOCOMO_TC);
 
-       if ( (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT0) & 0x88) && (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT1) & 0x88) )
+       if ((locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT0) & 0x88) && (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT1) & 0x88))
                locomo_writel(0x00, lchip->base + LOCOMO_C32K);         /* CLK32 off */
        else
                /* 18MHz already enabled, so no wait */
@@ -616,10 +643,10 @@ static int locomo_resume(struct platform_device *dev)
        spin_lock_irqsave(&lchip->lock, flags);
 
        locomo_writel(save->LCM_GPO, lchip->base + LOCOMO_GPO);
-       locomo_writel(save->LCM_SPICT, lchip->base + LOCOMO_SPICT);
+       locomo_writel(save->LCM_SPICT, lchip->base + LOCOMO_SPI + LOCOMO_SPICT);
        locomo_writel(save->LCM_GPE, lchip->base + LOCOMO_GPE);
        locomo_writel(save->LCM_ASD, lchip->base + LOCOMO_ASD);
-       locomo_writel(save->LCM_SPIMD, lchip->base + LOCOMO_SPIMD);
+       locomo_writel(save->LCM_SPIMD, lchip->base + LOCOMO_SPI + LOCOMO_SPIMD);
 
        locomo_writel(0x00, lchip->base + LOCOMO_C32K);
        locomo_writel(0x90, lchip->base + LOCOMO_TADC);
@@ -688,9 +715,9 @@ __locomo_probe(struct device *me, struct resource *mem, int irq)
 
        /* GPIO */
        locomo_writel(0, lchip->base + LOCOMO_GPO);
-       locomo_writel( (LOCOMO_GPIO(2) | LOCOMO_GPIO(3) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14))
+       locomo_writel((LOCOMO_GPIO(1) | LOCOMO_GPIO(2) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14))
                        , lchip->base + LOCOMO_GPE);
-       locomo_writel( (LOCOMO_GPIO(2) | LOCOMO_GPIO(3) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14))
+       locomo_writel((LOCOMO_GPIO(1) | LOCOMO_GPIO(2) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14))
                        , lchip->base + LOCOMO_GPD);
        locomo_writel(0, lchip->base + LOCOMO_GIE);
 
@@ -833,7 +860,10 @@ void locomo_gpio_set_dir(struct device *dev, unsigned int bits, unsigned int dir
        spin_lock_irqsave(&lchip->lock, flags);
 
        r = locomo_readl(lchip->base + LOCOMO_GPD);
-       r &= ~bits;
+       if (dir)
+               r |= bits;
+       else
+               r &= ~bits;
        locomo_writel(r, lchip->base + LOCOMO_GPD);
 
        r = locomo_readl(lchip->base + LOCOMO_GPE);
index d794068..7bf8048 100644 (file)
 #define IRQ_LOCOMO_LT          (IRQ_BOARD_END + 17)
 #define IRQ_LOCOMO_SPI_RFR     (IRQ_BOARD_END + 18)
 #define IRQ_LOCOMO_SPI_RFW     (IRQ_BOARD_END + 19)
-#define IRQ_LOCOMO_SPI_OVRN    (IRQ_BOARD_END + 20)
+#define IRQ_LOCOMO_SPI_REND    (IRQ_BOARD_END + 20)
 #define IRQ_LOCOMO_SPI_TEND    (IRQ_BOARD_END + 21)
 
 /*
index adab777..fb0645d 100644 (file)
 #define LOCOMO_SPIMD   0x00            /* SPI mode setting */
 #define LOCOMO_SPICT   0x04            /* SPI mode control */
 #define LOCOMO_SPIST   0x08            /* SPI status */
+#define        LOCOMO_SPI_TEND (1 << 3)        /* Transfer end bit */
+#define        LOCOMO_SPI_REND (1 << 2)        /* Receive end bit */
+#define        LOCOMO_SPI_RFW  (1 << 1)        /* write buffer bit */
+#define        LOCOMO_SPI_RFR  (1)             /* read buffer bit */
+
 #define LOCOMO_SPIIS   0x10            /* SPI interrupt status */
 #define LOCOMO_SPIWE   0x14            /* SPI interrupt status write enable */
 #define LOCOMO_SPIIE   0x18            /* SPI interrupt enable */
 #define LOCOMO_SPIRD   0x24            /* SPI receive data read */
 #define LOCOMO_SPITS   0x28            /* SPI transfer data shift */
 #define LOCOMO_SPIRS   0x2C            /* SPI receive data shift */
-#define        LOCOMO_SPI_TEND (1 << 3)        /* Transfer end bit */
-#define        LOCOMO_SPI_OVRN (1 << 2)        /* Over Run bit */
-#define        LOCOMO_SPI_RFW  (1 << 1)        /* write buffer bit */
-#define        LOCOMO_SPI_RFR  (1)             /* read buffer bit */
 
 /* GPIO */
 #define LOCOMO_GPD             0x90    /* GPIO direction */
 #define LOCOMO_GPE             0x94    /* GPIO input enable */
 #define LOCOMO_GPL             0x98    /* GPIO level */
-#define LOCOMO_GPO             0x9c    /* GPIO out data setteing */
+#define LOCOMO_GPO             0x9c    /* GPIO out data setting */
 #define LOCOMO_GRIE            0xa0    /* GPIO rise detection */
 #define LOCOMO_GFIE            0xa4    /* GPIO fall detection */
 #define LOCOMO_GIS             0xa8    /* GPIO edge detection status */
@@ -96,6 +97,9 @@
 #define LOCOMO_GPIO_DAC_SDATA  LOCOMO_GPIO(10)
 #define LOCOMO_GPIO_DAC_SCK    LOCOMO_GPIO(11)
 #define LOCOMO_GPIO_DAC_SLOAD  LOCOMO_GPIO(12)
+#define LOCOMO_GPIO_CARD_DETECT LOCOMO_GPIO(13)
+#define LOCOMO_GPIO_WRITE_PROT  LOCOMO_GPIO(14)
+#define LOCOMO_GPIO_CARD_POWER  LOCOMO_GPIO(15)
 
 /* Start the definitions of the devices.  Each device has an initial
  * base address and a series of offsets from that base address. */
 /* Audio controller */
 #define LOCOMO_AUDIO           0x54
 #define LOCOMO_ACC             0x00    /* Audio clock */
-#define LOCOMO_PAIF            0x7C    /* PCM audio interface */
+#define LOCOMO_PAIF            0xD0    /* PCM audio interface */
 /* Audio clock */
 #define        LOCOMO_ACC_XON          0x80
 #define        LOCOMO_ACC_XEN          0x40
@@ -162,7 +166,7 @@ extern struct bus_type locomo_bus_type;
 #define LOCOMO_DEVID_AUDIO     3
 #define LOCOMO_DEVID_LED       4
 #define LOCOMO_DEVID_UART      5
-#define LOCOMO_DEVID_SPI               6
+#define LOCOMO_DEVID_SPI       6
 
 struct locomo_dev {
        struct device   dev;
@@ -204,7 +208,6 @@ int locomo_gpio_read_level(struct device *dev, unsigned int bits);
 int locomo_gpio_read_output(struct device *dev, unsigned int bits);
 void locomo_gpio_write(struct device *dev, unsigned int bits, unsigned int set);
 
-
 /* M62332 control function */
 void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int channel);