~ubuntu-branches/ubuntu/precise/linux-linaro-u8500/precise

« back to all changes in this revision

Viewing changes to arch/arm/mach-omap2/gpmc.c

  • Committer: Bazaar Package Importer
  • Author(s): John Rigby, Upstream Fixes, Andy Green, John Rigby
  • Date: 2011-04-14 12:16:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110414121606-b77podkyqgr2oix7
Tags: 2.6.38-1002.3
[ Upstream Fixes ]

* MUSB: shutdown: Make sure block is awake before doing shutdown
  - LP: #745737
* Fixed gpio polarity of gpio USB-phy reset.
  - LP: #747639

[ Andy Green ]

* LINARO: SAUCE: disable CONFIG_OMAP_RESET_CLOCKS
  - LP: #752900

[ John Rigby ]

* Rebase to new upstreams:
  Linux v2.6.38.1
  linaro-linux-2.6.38-upstream-29Mar2011
  Ubuntu-2.6.38-7.35
* SAUCE: OMAP4: clock: wait for module to become accessible on
  a clk enable
  - LP: #745737
* Rebase to new upstreams:
  Linux v2.6.38.2
  linaro-linux-2.6.38-upstream-5Apr2011
  Ubuntu-2.6.38-8.41
  - LP: #732842
* Update configs for device tree, dvfs and lttng
* LINARO: add building of dtb's
* LINARO: SAUCE: Disable lowest operating freqs on omap34xx
  - LP: #732912

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 */
15
15
#undef DEBUG
16
16
 
 
17
#include <linux/irq.h>
17
18
#include <linux/kernel.h>
18
19
#include <linux/init.h>
19
20
#include <linux/err.h>
22
23
#include <linux/spinlock.h>
23
24
#include <linux/io.h>
24
25
#include <linux/module.h>
 
26
#include <linux/interrupt.h>
25
27
 
26
28
#include <asm/mach-types.h>
27
29
#include <plat/gpmc.h>
58
60
#define GPMC_CHUNK_SHIFT        24              /* 16 MB */
59
61
#define GPMC_SECTION_SHIFT      28              /* 128 MB */
60
62
 
61
 
#define PREFETCH_FIFOTHRESHOLD  (0x40 << 8)
62
63
#define CS_NUM_SHIFT            24
63
64
#define ENABLE_PREFETCH         (0x1 << 7)
64
65
#define DMA_MPU_MODE            2
100
101
 
101
102
static struct clk *gpmc_l3_clk;
102
103
 
 
104
static irqreturn_t gpmc_handle_irq(int irq, void *dev);
 
105
 
103
106
static void gpmc_write_reg(int idx, u32 val)
104
107
{
105
108
        __raw_writel(val, gpmc_base + idx);
497
500
        u32 regval = 0;
498
501
 
499
502
        switch (cmd) {
 
503
        case GPMC_ENABLE_IRQ:
 
504
                gpmc_write_reg(GPMC_IRQENABLE, wval);
 
505
                break;
 
506
 
500
507
        case GPMC_SET_IRQ_STATUS:
501
508
                gpmc_write_reg(GPMC_IRQSTATUS, wval);
502
509
                break;
598
605
/**
599
606
 * gpmc_prefetch_enable - configures and starts prefetch transfer
600
607
 * @cs: cs (chip select) number
 
608
 * @fifo_th: fifo threshold to be used for read/ write
601
609
 * @dma_mode: dma mode enable (1) or disable (0)
602
610
 * @u32_count: number of bytes to be transferred
603
611
 * @is_write: prefetch read(0) or write post(1) mode
604
612
 */
605
 
int gpmc_prefetch_enable(int cs, int dma_mode,
 
613
int gpmc_prefetch_enable(int cs, int fifo_th, int dma_mode,
606
614
                                unsigned int u32_count, int is_write)
607
615
{
608
616
 
609
 
        if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
 
617
        if (fifo_th > PREFETCH_FIFOTHRESHOLD_MAX) {
 
618
                pr_err("gpmc: fifo threshold is not supported\n");
 
619
                return -1;
 
620
        } else if (!(gpmc_read_reg(GPMC_PREFETCH_CONTROL))) {
610
621
                /* Set the amount of bytes to be prefetched */
611
622
                gpmc_write_reg(GPMC_PREFETCH_CONFIG2, u32_count);
612
623
 
614
625
                 * enable the engine. Set which cs is has requested for.
615
626
                 */
616
627
                gpmc_write_reg(GPMC_PREFETCH_CONFIG1, ((cs << CS_NUM_SHIFT) |
617
 
                                        PREFETCH_FIFOTHRESHOLD |
 
628
                                        PREFETCH_FIFOTHRESHOLD(fifo_th) |
618
629
                                        ENABLE_PREFETCH |
619
630
                                        (dma_mode << DMA_MPU_MODE) |
620
631
                                        (0x1 & is_write)));
678
689
        }
679
690
}
680
691
 
681
 
void __init gpmc_init(void)
 
692
static int __init gpmc_init(void)
682
693
{
683
 
        u32 l;
 
694
        u32 l, irq;
 
695
        int cs, ret = -EINVAL;
 
696
        int gpmc_irq;
684
697
        char *ck = NULL;
685
698
 
686
699
        if (cpu_is_omap24xx()) {
689
702
                        l = OMAP2420_GPMC_BASE;
690
703
                else
691
704
                        l = OMAP34XX_GPMC_BASE;
 
705
                gpmc_irq = INT_34XX_GPMC_IRQ;
692
706
        } else if (cpu_is_omap34xx()) {
693
707
                ck = "gpmc_fck";
694
708
                l = OMAP34XX_GPMC_BASE;
 
709
                gpmc_irq = INT_34XX_GPMC_IRQ;
695
710
        } else if (cpu_is_omap44xx()) {
696
711
                ck = "gpmc_ck";
697
712
                l = OMAP44XX_GPMC_BASE;
 
713
                gpmc_irq = OMAP44XX_IRQ_GPMC;
698
714
        }
699
715
 
700
716
        if (WARN_ON(!ck))
701
 
                return;
 
717
                return ret;
702
718
 
703
719
        gpmc_l3_clk = clk_get(NULL, ck);
704
720
        if (IS_ERR(gpmc_l3_clk)) {
723
739
        l |= (0x02 << 3) | (1 << 0);
724
740
        gpmc_write_reg(GPMC_SYSCONFIG, l);
725
741
        gpmc_mem_init();
 
742
 
 
743
        /* initalize the irq_chained */
 
744
        irq = OMAP_GPMC_IRQ_BASE;
 
745
        for (cs = 0; cs < GPMC_CS_NUM; cs++) {
 
746
                set_irq_chip_and_handler(irq, &dummy_irq_chip,
 
747
                                                handle_simple_irq);
 
748
                set_irq_flags(irq, IRQF_VALID);
 
749
                irq++;
 
750
        }
 
751
 
 
752
        ret = request_irq(gpmc_irq,
 
753
                        gpmc_handle_irq, IRQF_SHARED, "gpmc", gpmc_base);
 
754
        if (ret)
 
755
                pr_err("gpmc: irq-%d could not claim: err %d\n",
 
756
                                                gpmc_irq, ret);
 
757
        return ret;
 
758
}
 
759
postcore_initcall(gpmc_init);
 
760
 
 
761
static irqreturn_t gpmc_handle_irq(int irq, void *dev)
 
762
{
 
763
        u8 cs;
 
764
 
 
765
        /* check cs to invoke the irq */
 
766
        cs = ((gpmc_read_reg(GPMC_PREFETCH_CONFIG1)) >> CS_NUM_SHIFT) & 0x7;
 
767
        if (OMAP_GPMC_IRQ_BASE+cs <= OMAP_GPMC_IRQ_END)
 
768
                generic_handle_irq(OMAP_GPMC_IRQ_BASE+cs);
 
769
 
 
770
        return IRQ_HANDLED;
726
771
}
727
772
 
728
773
#ifdef CONFIG_ARCH_OMAP3