]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: at91/PMC: make register base soc independent
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Fri, 25 Nov 2011 01:59:46 +0000 (09:59 +0800)
committerNicolas Ferre <nicolas.ferre@atmel.com>
Thu, 23 Feb 2012 13:57:57 +0000 (14:57 +0100)
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Reviewed-by: Ryan Mallon <rmallon@gmail.com>
14 files changed:
arch/arm/mach-at91/at91rm9200.c
arch/arm/mach-at91/clock.c
arch/arm/mach-at91/include/mach/at91_pmc.h
arch/arm/mach-at91/include/mach/at91rm9200.h
arch/arm/mach-at91/include/mach/at91sam9260.h
arch/arm/mach-at91/include/mach/at91sam9261.h
arch/arm/mach-at91/include/mach/at91sam9263.h
arch/arm/mach-at91/include/mach/at91sam9g45.h
arch/arm/mach-at91/include/mach/at91sam9rl.h
arch/arm/mach-at91/include/mach/at91sam9x5.h
arch/arm/mach-at91/include/mach/hardware.h
arch/arm/mach-at91/pm.c
arch/arm/mach-at91/pm_slowclock.S
drivers/usb/gadget/atmel_usba_udc.c

index 7923197cb506b5a75e8a27a8b43c64b9bc2a9b7e..0df1045311e420e2e96670e62f182f44d39f5481 100644 (file)
@@ -295,7 +295,7 @@ static void at91rm9200_idle(void)
         * Disable the processor clock.  The processor will be automatically
         * re-enabled by an interrupt or by a reset.
         */
-       at91_sys_write(AT91_PMC_SCDR, AT91_PMC_PCK);
+       at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
 }
 
 static void at91rm9200_restart(char mode, const char *cmd)
index 9ab86274016196e235f363dbf63deb1bcbe5ac15..be51ca7f694d1a0515ddd9d5ecf0c4a9253dc078 100644 (file)
@@ -33,6 +33,7 @@
 #include "clock.h"
 #include "generic.h"
 
+void __iomem *at91_pmc_base;
 
 /*
  * There's a lot more which can be done with clocks, including cpufreq
@@ -125,11 +126,11 @@ static void pllb_mode(struct clk *clk, int is_on)
                value = 0;
 
        // REVISIT: Add work-around for AT91RM9200 Errata #26 ?
-       at91_sys_write(AT91_CKGR_PLLBR, value);
+       at91_pmc_write(AT91_CKGR_PLLBR, value);
 
        do {
                cpu_relax();
-       } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on);
+       } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on);
 }
 
 static struct clk pllb = {
@@ -144,24 +145,24 @@ static struct clk pllb = {
 static void pmc_sys_mode(struct clk *clk, int is_on)
 {
        if (is_on)
-               at91_sys_write(AT91_PMC_SCER, clk->pmc_mask);
+               at91_pmc_write(AT91_PMC_SCER, clk->pmc_mask);
        else
-               at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask);
+               at91_pmc_write(AT91_PMC_SCDR, clk->pmc_mask);
 }
 
 static void pmc_uckr_mode(struct clk *clk, int is_on)
 {
-       unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
+       unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
 
        if (is_on) {
                is_on = AT91_PMC_LOCKU;
-               at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask);
+               at91_pmc_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask);
        } else
-               at91_sys_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask));
+               at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask));
 
        do {
                cpu_relax();
-       } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on);
+       } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on);
 }
 
 /* USB function clocks (PLLB must be 48 MHz) */
@@ -197,9 +198,9 @@ struct clk mck = {
 static void pmc_periph_mode(struct clk *clk, int is_on)
 {
        if (is_on)
-               at91_sys_write(AT91_PMC_PCER, clk->pmc_mask);
+               at91_pmc_write(AT91_PMC_PCER, clk->pmc_mask);
        else
-               at91_sys_write(AT91_PMC_PCDR, clk->pmc_mask);
+               at91_pmc_write(AT91_PMC_PCDR, clk->pmc_mask);
 }
 
 static struct clk __init *at91_css_to_clk(unsigned long css)
@@ -359,10 +360,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
                if (actual && actual <= rate) {
                        u32     pckr;
 
-                       pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
+                       pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id));
                        pckr &= css_mask;       /* keep clock selection */
                        pckr |= prescale << prescale_offset;
-                       at91_sys_write(AT91_PMC_PCKR(clk->id), pckr);
+                       at91_pmc_write(AT91_PMC_PCKR(clk->id), pckr);
                        clk->rate_hz = actual;
                        break;
                }
@@ -396,7 +397,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 
        clk->rate_hz = parent->rate_hz;
        clk->parent = parent;
-       at91_sys_write(AT91_PMC_PCKR(clk->id), parent->id);
+       at91_pmc_write(AT91_PMC_PCKR(clk->id), parent->id);
 
        spin_unlock_irqrestore(&clk_lock, flags);
        return 0;
@@ -415,7 +416,7 @@ static void __init init_programmable_clock(struct clk *clk)
        else
                css_mask = AT91_PMC_CSS;
 
-       pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
+       pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id));
        parent = at91_css_to_clk(pckr & css_mask);
        clk->parent = parent;
        clk->rate_hz = parent->rate_hz / pmc_prescaler_divider(pckr);
@@ -432,23 +433,23 @@ static int at91_clk_show(struct seq_file *s, void *unused)
        u32             scsr, pcsr, uckr = 0, sr;
        struct clk      *clk;
 
-       scsr = at91_sys_read(AT91_PMC_SCSR);
-       pcsr = at91_sys_read(AT91_PMC_PCSR);
-       sr = at91_sys_read(AT91_PMC_SR);
+       scsr = at91_pmc_read(AT91_PMC_SCSR);
+       pcsr = at91_pmc_read(AT91_PMC_PCSR);
+       sr = at91_pmc_read(AT91_PMC_SR);
        seq_printf(s, "SCSR = %8x\n", scsr);
        seq_printf(s, "PCSR = %8x\n", pcsr);
-       seq_printf(s, "MOR  = %8x\n", at91_sys_read(AT91_CKGR_MOR));
-       seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR));
-       seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR));
+       seq_printf(s, "MOR  = %8x\n", at91_pmc_read(AT91_CKGR_MOR));
+       seq_printf(s, "MCFR = %8x\n", at91_pmc_read(AT91_CKGR_MCFR));
+       seq_printf(s, "PLLA = %8x\n", at91_pmc_read(AT91_CKGR_PLLAR));
        if (cpu_has_pllb())
-               seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR));
+               seq_printf(s, "PLLB = %8x\n", at91_pmc_read(AT91_CKGR_PLLBR));
        if (cpu_has_utmi()) {
-               uckr = at91_sys_read(AT91_CKGR_UCKR);
+               uckr = at91_pmc_read(AT91_CKGR_UCKR);
                seq_printf(s, "UCKR = %8x\n", uckr);
        }
-       seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR));
+       seq_printf(s, "MCKR = %8x\n", at91_pmc_read(AT91_PMC_MCKR));
        if (cpu_has_upll())
-               seq_printf(s, "USB  = %8x\n", at91_sys_read(AT91_PMC_USB));
+               seq_printf(s, "USB  = %8x\n", at91_pmc_read(AT91_PMC_USB));
        seq_printf(s, "SR   = %8x\n", sr);
 
        seq_printf(s, "\n");
@@ -637,14 +638,14 @@ static void __init at91_pllb_usbfs_clock_init(unsigned long main_clock)
        if (cpu_is_at91rm9200()) {
                uhpck.pmc_mask = AT91RM9200_PMC_UHP;
                udpck.pmc_mask = AT91RM9200_PMC_UDP;
-               at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);
+               at91_pmc_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);
        } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() ||
                   cpu_is_at91sam9263() || cpu_is_at91sam9g20() ||
                   cpu_is_at91sam9g10()) {
                uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
                udpck.pmc_mask = AT91SAM926x_PMC_UDP;
        }
-       at91_sys_write(AT91_CKGR_PLLBR, 0);
+       at91_pmc_write(AT91_CKGR_PLLBR, 0);
 
        udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
        uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
@@ -661,13 +662,13 @@ static void __init at91_upll_usbfs_clock_init(unsigned long main_clock)
        /* Setup divider by 10 to reach 48 MHz */
        usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV;
 
-       at91_sys_write(AT91_PMC_USB, usbr);
+       at91_pmc_write(AT91_PMC_USB, usbr);
 
        /* Now set uhpck values */
        uhpck.parent = &utmi_clk;
        uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
        uhpck.rate_hz = utmi_clk.rate_hz;
-       uhpck.rate_hz /= 1 + ((at91_sys_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8);
+       uhpck.rate_hz /= 1 + ((at91_pmc_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8);
 }
 
 int __init at91_clock_init(unsigned long main_clock)
@@ -676,6 +677,10 @@ int __init at91_clock_init(unsigned long main_clock)
        int i;
        int pll_overclock = false;
 
+       at91_pmc_base = ioremap(AT91_PMC, 256);
+       if (!at91_pmc_base)
+               panic("Impossible to ioremap AT91_PMC 0x%x\n", AT91_PMC);
+
        /*
         * When the bootloader initialized the main oscillator correctly,
         * there's no problem using the cycle counter.  But if it didn't,
@@ -684,14 +689,14 @@ int __init at91_clock_init(unsigned long main_clock)
         */
        if (!main_clock) {
                do {
-                       tmp = at91_sys_read(AT91_CKGR_MCFR);
+                       tmp = at91_pmc_read(AT91_CKGR_MCFR);
                } while (!(tmp & AT91_PMC_MAINRDY));
                main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);
        }
        main_clk.rate_hz = main_clock;
 
        /* report if PLLA is more than mildly overclocked */
-       plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR));
+       plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_pmc_read(AT91_CKGR_PLLAR));
        if (cpu_has_300M_plla()) {
                if (plla.rate_hz > 300000000)
                        pll_overclock = true;
@@ -706,7 +711,7 @@ int __init at91_clock_init(unsigned long main_clock)
                pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000);
 
        if (cpu_has_plladiv2()) {
-               mckr = at91_sys_read(AT91_PMC_MCKR);
+               mckr = at91_pmc_read(AT91_PMC_MCKR);
                plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12));      /* plla divisor by 2 */
        }
 
@@ -746,7 +751,7 @@ int __init at91_clock_init(unsigned long main_clock)
         * MCK and CPU derive from one of those primary clocks.
         * For now, assume this parentage won't change.
         */
-       mckr = at91_sys_read(AT91_PMC_MCKR);
+       mckr = at91_pmc_read(AT91_PMC_MCKR);
        mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS);
        freq = mck.parent->rate_hz;
        freq /= pmc_prescaler_divider(mckr);                                    /* prescale */
@@ -819,8 +824,8 @@ static int __init at91_clock_reset(void)
                pr_debug("Clocks: disable unused %s\n", clk->name);
        }
 
-       at91_sys_write(AT91_PMC_PCDR, pcdr);
-       at91_sys_write(AT91_PMC_SCDR, scdr);
+       at91_pmc_write(AT91_PMC_PCDR, pcdr);
+       at91_pmc_write(AT91_PMC_SCDR, scdr);
 
        return 0;
 }
@@ -828,6 +833,6 @@ late_initcall(at91_clock_reset);
 
 void at91sam9_idle(void)
 {
-       at91_sys_write(AT91_PMC_SCDR, AT91_PMC_PCK);
+       at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
        cpu_do_idle();
 }
index f9fdbbe0c53a9d506759b541a201671c179fc05b..36604782a78f0e52d4bed0d6af21c787dacf418f 100644 (file)
 #ifndef AT91_PMC_H
 #define AT91_PMC_H
 
-#define        AT91_PMC_SCER           (AT91_PMC + 0x00)       /* System Clock Enable Register */
-#define        AT91_PMC_SCDR           (AT91_PMC + 0x04)       /* System Clock Disable Register */
+#ifndef __ASSEMBLY__
+extern void __iomem *at91_pmc_base;
 
-#define        AT91_PMC_SCSR           (AT91_PMC + 0x08)       /* System Clock Status Register */
+#define at91_pmc_read(field) \
+       __raw_readl(at91_pmc_base + field)
+
+#define at91_pmc_write(field, value) \
+       __raw_writel(value, at91_pmc_base + field)
+#else
+.extern at91_aic_base
+#endif
+
+#define        AT91_PMC_SCER           0x00                    /* System Clock Enable Register */
+#define        AT91_PMC_SCDR           0x04                    /* System Clock Disable Register */
+
+#define        AT91_PMC_SCSR           0x08                    /* System Clock Status Register */
 #define                AT91_PMC_PCK            (1 <<  0)               /* Processor Clock */
 #define                AT91RM9200_PMC_UDP      (1 <<  1)               /* USB Devcice Port Clock [AT91RM9200 only] */
 #define                AT91RM9200_PMC_MCKUDP   (1 <<  2)               /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */
 #define                AT91_PMC_HCK0           (1 << 16)               /* AHB Clock (USB host) [AT91SAM9261 only] */
 #define                AT91_PMC_HCK1           (1 << 17)               /* AHB Clock (LCD) [AT91SAM9261 only] */
 
-#define        AT91_PMC_PCER           (AT91_PMC + 0x10)       /* Peripheral Clock Enable Register */
-#define        AT91_PMC_PCDR           (AT91_PMC + 0x14)       /* Peripheral Clock Disable Register */
-#define        AT91_PMC_PCSR           (AT91_PMC + 0x18)       /* Peripheral Clock Status Register */
+#define        AT91_PMC_PCER           0x10                    /* Peripheral Clock Enable Register */
+#define        AT91_PMC_PCDR           0x14                    /* Peripheral Clock Disable Register */
+#define        AT91_PMC_PCSR           0x18                    /* Peripheral Clock Status Register */
 
-#define        AT91_CKGR_UCKR          (AT91_PMC + 0x1C)       /* UTMI Clock Register [some SAM9] */
+#define        AT91_CKGR_UCKR          0x1C                    /* UTMI Clock Register [some SAM9] */
 #define                AT91_PMC_UPLLEN         (1   << 16)             /* UTMI PLL Enable */
 #define                AT91_PMC_UPLLCOUNT      (0xf << 20)             /* UTMI PLL Start-up Time */
 #define                AT91_PMC_BIASEN         (1   << 24)             /* UTMI BIAS Enable */
 #define                AT91_PMC_BIASCOUNT      (0xf << 28)             /* UTMI BIAS Start-up Time */
 
-#define        AT91_CKGR_MOR           (AT91_PMC + 0x20)       /* Main Oscillator Register [not on SAM9RL] */
+#define        AT91_CKGR_MOR           0x20                    /* Main Oscillator Register [not on SAM9RL] */
 #define                AT91_PMC_MOSCEN         (1    <<  0)            /* Main Oscillator Enable */
 #define                AT91_PMC_OSCBYPASS      (1    <<  1)            /* Oscillator Bypass */
 #define                AT91_PMC_MOSCRCEN       (1    <<  3)            /* Main On-Chip RC Oscillator Enable [some SAM9] */
 #define                AT91_PMC_MOSCSEL        (1    << 24)            /* Main Oscillator Selection [some SAM9] */
 #define                AT91_PMC_CFDEN          (1    << 25)            /* Clock Failure Detector Enable [some SAM9] */
 
-#define        AT91_CKGR_MCFR          (AT91_PMC + 0x24)       /* Main Clock Frequency Register */
+#define        AT91_CKGR_MCFR          0x24                    /* Main Clock Frequency Register */
 #define                AT91_PMC_MAINF          (0xffff <<  0)          /* Main Clock Frequency */
 #define                AT91_PMC_MAINRDY        (1      << 16)          /* Main Clock Ready */
 
-#define        AT91_CKGR_PLLAR         (AT91_PMC + 0x28)       /* PLL A Register */
-#define        AT91_CKGR_PLLBR         (AT91_PMC + 0x2c)       /* PLL B Register */
+#define        AT91_CKGR_PLLAR         0x28                    /* PLL A Register */
+#define        AT91_CKGR_PLLBR         0x2c                    /* PLL B Register */
 #define                AT91_PMC_DIV            (0xff  <<  0)           /* Divider */
 #define                AT91_PMC_PLLCOUNT       (0x3f  <<  8)           /* PLL Counter */
 #define                AT91_PMC_OUT            (3     << 14)           /* PLL Clock Frequency Range */
@@ -69,7 +81,7 @@
 #define                        AT91_PMC_USBDIV_4               (2 << 28)
 #define                AT91_PMC_USB96M         (1     << 28)           /* Divider by 2 Enable (PLLB only) */
 
-#define        AT91_PMC_MCKR           (AT91_PMC + 0x30)       /* Master Clock Register */
+#define        AT91_PMC_MCKR           0x30                    /* Master Clock Register */
 #define                AT91_PMC_CSS            (3 <<  0)               /* Master Clock Selection */
 #define                        AT91_PMC_CSS_SLOW               (0 << 0)
 #define                        AT91_PMC_CSS_MAIN               (1 << 0)
 #define                        AT91_PMC_PLLADIV2_OFF           (0 << 12)
 #define                        AT91_PMC_PLLADIV2_ON            (1 << 12)
 
-#define        AT91_PMC_USB            (AT91_PMC + 0x38)       /* USB Clock Register [some SAM9 only] */
+#define        AT91_PMC_USB            0x38                    /* USB Clock Register [some SAM9 only] */
 #define                AT91_PMC_USBS           (0x1 <<  0)             /* USB OHCI Input clock selection */
 #define                        AT91_PMC_USBS_PLLA              (0 << 0)
 #define                        AT91_PMC_USBS_UPLL              (1 << 0)
 #define                AT91_PMC_OHCIUSBDIV     (0xF <<  8)             /* Divider for USB OHCI Clock */
 
-#define        AT91_PMC_SMD            (AT91_PMC + 0x3c)       /* Soft Modem Clock Register [some SAM9 only] */
+#define        AT91_PMC_SMD            0x3c                    /* Soft Modem Clock Register [some SAM9 only] */
 #define                AT91_PMC_SMDS           (0x1  <<  0)            /* SMD input clock selection */
 #define                AT91_PMC_SMD_DIV        (0x1f <<  8)            /* SMD input clock divider */
 #define                AT91_PMC_SMDDIV(n)      (((n) <<  8) & AT91_PMC_SMD_DIV)
 
-#define        AT91_PMC_PCKR(n)        (AT91_PMC + 0x40 + ((n) * 4))   /* Programmable Clock 0-N Registers */
+#define        AT91_PMC_PCKR(n)        (0x40 + ((n) * 4))      /* Programmable Clock 0-N Registers */
 #define                AT91_PMC_ALT_PCKR_CSS   (0x7 <<  0)             /* Programmable Clock Source Selection [alternate length] */
 #define                        AT91_PMC_CSS_MASTER             (4 << 0)        /* [some SAM9 only] */
 #define                AT91_PMC_CSSMCK         (0x1 <<  8)             /* CSS or Master Clock Selection */
 #define                        AT91_PMC_CSSMCK_CSS             (0 << 8)
 #define                        AT91_PMC_CSSMCK_MCK             (1 << 8)
 
-#define        AT91_PMC_IER            (AT91_PMC + 0x60)       /* Interrupt Enable Register */
-#define        AT91_PMC_IDR            (AT91_PMC + 0x64)       /* Interrupt Disable Register */
-#define        AT91_PMC_SR             (AT91_PMC + 0x68)       /* Status Register */
+#define        AT91_PMC_IER            0x60                    /* Interrupt Enable Register */
+#define        AT91_PMC_IDR            0x64                    /* Interrupt Disable Register */
+#define        AT91_PMC_SR             0x68                    /* Status Register */
 #define                AT91_PMC_MOSCS          (1 <<  0)               /* MOSCS Flag */
 #define                AT91_PMC_LOCKA          (1 <<  1)               /* PLLA Lock */
 #define                AT91_PMC_LOCKB          (1 <<  2)               /* PLLB Lock */
 #define                AT91_PMC_MOSCSELS       (1 << 16)               /* Main Oscillator Selection [some SAM9] */
 #define                AT91_PMC_MOSCRCS        (1 << 17)               /* Main On-Chip RC [some SAM9] */
 #define                AT91_PMC_CFDEV          (1 << 18)               /* Clock Failure Detector Event [some SAM9] */
-#define        AT91_PMC_IMR            (AT91_PMC + 0x6c)       /* Interrupt Mask Register */
+#define        AT91_PMC_IMR            0x6c                    /* Interrupt Mask Register */
 
-#define AT91_PMC_PROT          (AT91_PMC + 0xe4)       /* Write Protect Mode Register [some SAM9] */
+#define AT91_PMC_PROT          0xe4                    /* Write Protect Mode Register [some SAM9] */
 #define                AT91_PMC_WPEN           (0x1  <<  0)            /* Write Protect Enable */
 #define                AT91_PMC_WPKEY          (0xffffff << 8)         /* Write Protect Key */
 #define                AT91_PMC_PROTKEY        (0x504d43 << 8)         /* Activation Code */
 
-#define AT91_PMC_WPSR          (AT91_PMC + 0xe8)       /* Write Protect Status Register [some SAM9] */
+#define AT91_PMC_WPSR          0xe8                    /* Write Protect Status Register [some SAM9] */
 #define                AT91_PMC_WPVS           (0x1  <<  0)            /* Write Protect Violation Status */
 #define                AT91_PMC_WPVSRC         (0xffff  <<  8)         /* Write Protect Violation Source */
 
-#define AT91_PMC_PCR           (AT91_PMC + 0x10c)      /* Peripheral Control Register [some SAM9] */
+#define AT91_PMC_PCR           0x10c                   /* Peripheral Control Register [some SAM9] */
 #define                AT91_PMC_PCR_PID        (0x3f  <<  0)           /* Peripheral ID */
 #define                AT91_PMC_PCR_CMD        (0x1  <<  12)           /* Command */
 #define                AT91_PMC_PCR_DIV        (0x3  <<  16)           /* Divisor Value */
index 32d57be4798653f01fcee0a12dfa30ff67f261f4..603e6aac2a4fb9d9a55c6d37b639ff19649e9e81 100644 (file)
 
 
 /*
- * System Peripherals (offset from AT91_BASE_SYS)
+ * System Peripherals
  */
-#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)    /* Power Management Controller */
-
 #define AT91RM9200_BASE_DBGU   AT91_BASE_DBGU0 /* Debug Unit */
 #define AT91RM9200_BASE_PIOA   0xfffff400      /* PIO Controller A */
 #define AT91RM9200_BASE_PIOB   0xfffff600      /* PIO Controller B */
index c5b6b3b710604433b132431c6bbf8f2aafbc2abb..1524e87c0043b2106c8e3f89f648614d99b20671 100644 (file)
@@ -80,7 +80,6 @@
 /*
  * System Peripherals (offset from AT91_BASE_SYS)
  */
-#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd50 - AT91_BASE_SYS)
 
 #define AT91SAM9260_BASE_ECC   0xffffe800
index a269cef51aec7862e689eced06b10409ffeb5dd3..a6a3c1d4bc7fd4f035382ca02eb50b73d3ec13db 100644 (file)
@@ -65,7 +65,6 @@
 /*
  * System Peripherals (offset from AT91_BASE_SYS)
  */
-#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd50 - AT91_BASE_SYS)
 
 #define AT91SAM9261_BASE_SMC   0xffffec00
index bccba0b679c24dcce9697763d009c2925d172921..dda083d1a66b98e1b9f656e1a24ba450ae5a6f0c 100644 (file)
@@ -74,7 +74,6 @@
 /*
  * System Peripherals (offset from AT91_BASE_SYS)
  */
-#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd60 - AT91_BASE_SYS)
 
 #define AT91SAM9263_BASE_ECC0  0xffffe000
index dfc4570fffe20ccfdb73fa1540c5661d4df47823..a824e15bf00d7fc8e6428c074a13ccf54cfd25e2 100644 (file)
@@ -86,7 +86,6 @@
 /*
  * System Peripherals (offset from AT91_BASE_SYS)
  */
-#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd60 - AT91_BASE_SYS)
 
 #define AT91SAM9G45_BASE_ECC   0xffffe200
index de960dc1da05177edc7cf39739b067276e1a863f..2d7176ac9002795b91dd417b8071b5abaef97945 100644 (file)
@@ -69,7 +69,6 @@
 /*
  * System Peripherals (offset from AT91_BASE_SYS)
  */
-#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
 #define AT91_SCKCR     (0xfffffd50 - AT91_BASE_SYS)
 #define AT91_GPBR      (0xfffffd60 - AT91_BASE_SYS)
 
index 96f25f556abf49707fcae9b7a07a91a9a2c66f82..a297a77d88e2086cacde1e2bd910fb78a962085f 100644 (file)
 #define AT91SAM9X5_BASE_USART2 0xf8024000
 
 /*
- * System Peripherals (offset from AT91_BASE_SYS)
+ * System Peripherals
  */
 #define AT91SAM9X5_BASE_DDRSDRC0       0xffffe800
-#define AT91_PMC       (0xfffffc00 - AT91_BASE_SYS)
 
 /*
  * Base addresses for early serial code (uncompress.h)
index fd7dce4f7378a6de8c9857f0cfdb780a2f1bdc1e..e9e29a6c3868eb6ea462c8df13073915440ac36e 100644 (file)
 
 /*
  * On all at91 have the Advanced Interrupt Controller starts at address
- * 0xfffff000
+ * 0xfffff000 and the Power Management Controller starts at 0xfffffc00
  */
 #define AT91_AIC       0xfffff000
+#define AT91_PMC       0xfffffc00
 
 /*
  * Peripheral identifiers/interrupts.
index 2793591c73c0d1a6a9da42a7e6a6ae25d5867e8b..6c9d5e69ac282385205ed06323efd72686cc1c04 100644 (file)
@@ -136,7 +136,7 @@ static int at91_pm_verify_clocks(void)
        unsigned long scsr;
        int i;
 
-       scsr = at91_sys_read(AT91_PMC_SCSR);
+       scsr = at91_pmc_read(AT91_PMC_SCSR);
 
        /* USB must not be using PLLB */
        if (cpu_is_at91rm9200()) {
@@ -160,7 +160,7 @@ static int at91_pm_verify_clocks(void)
                if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
                        continue;
 
-               css = at91_sys_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
+               css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
                if (css != AT91_PMC_CSS_SLOW) {
                        pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
                        return 0;
@@ -197,7 +197,6 @@ extern void at91_slow_clock(void __iomem *pmc, void __iomem *ramc0,
 extern u32 at91_slow_clock_sz;
 #endif
 
-static void __iomem *at91_pmc_base = (void __iomem*)(AT91_VA_BASE_SYS + AT91_PMC);
 void __iomem *at91_ramc_base[2];
 
 void __init at91_ioremap_ramc(int id, u32 addr, u32 size)
@@ -218,7 +217,7 @@ static int at91_pm_enter(suspend_state_t state)
 
        pr_debug("AT91: PM - wake mask %08x, pm state %d\n",
                        /* remember all the always-wake irqs */
-                       (at91_sys_read(AT91_PMC_PCSR)
+                       (at91_pmc_read(AT91_PMC_PCSR)
                                        | (1 << AT91_ID_FIQ)
                                        | (1 << AT91_ID_SYS)
                                        | (at91_extern_irq))
index 2c46010953c2ba500d78ec165385e889c571ade8..db5452123f17b5e564f6378db72dd6a75e8931ed 100644 (file)
@@ -54,7 +54,7 @@ tmp2  .req    r5
 1:     sub     tmp2, tmp2, #1
        cmp     tmp2, #0
        beq     2f
-       ldr     tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_PMC_SR]
        tst     tmp1, #AT91_PMC_MCKRDY
        beq     1b
 2:
@@ -68,7 +68,7 @@ tmp2  .req    r5
 1:     sub     tmp2, tmp2, #1
        cmp     tmp2, #0
        beq     2f
-       ldr     tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_PMC_SR]
        tst     tmp1, #AT91_PMC_MOSCS
        beq     1b
 2:
@@ -82,7 +82,7 @@ tmp2  .req    r5
 1:     sub     tmp2, tmp2, #1
        cmp     tmp2, #0
        beq     2f
-       ldr     tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_PMC_SR]
        tst     tmp1, #AT91_PMC_LOCKA
        beq     1b
 2:
@@ -96,7 +96,7 @@ tmp2  .req    r5
 1:     sub     tmp2, tmp2, #1
        cmp     tmp2, #0
        beq     2f
-       ldr     tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_PMC_SR]
        tst     tmp1, #AT91_PMC_LOCKB
        beq     1b
 2:
@@ -176,14 +176,14 @@ sdr_sr_enable:
 
 sdr_sr_done:
        /* Save Master clock setting */
-       ldr     tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_PMC_MCKR]
        str     tmp1, .saved_mckr
 
        /*
         * Set the Master clock source to slow clock
         */
        bic     tmp1, tmp1, #AT91_PMC_CSS
-       str     tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_PMC_MCKR]
 
        wait_mckrdy
 
@@ -194,44 +194,44 @@ sdr_sr_done:
         * See AT91RM9200 errata #27 and #28 for details.
         */
        mov     tmp1, #0
-       str     tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_PMC_MCKR]
 
        wait_mckrdy
 #endif
 
        /* Save PLLA setting and disable it */
-       ldr     tmp1, [pmc, #(AT91_CKGR_PLLAR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_CKGR_PLLAR]
        str     tmp1, .saved_pllar
 
        mov     tmp1, #AT91_PMC_PLLCOUNT
        orr     tmp1, tmp1, #(1 << 29)          /* bit 29 always set */
-       str     tmp1, [pmc, #(AT91_CKGR_PLLAR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_CKGR_PLLAR]
 
        /* Save PLLB setting and disable it */
-       ldr     tmp1, [pmc, #(AT91_CKGR_PLLBR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_CKGR_PLLBR]
        str     tmp1, .saved_pllbr
 
        mov     tmp1, #AT91_PMC_PLLCOUNT
-       str     tmp1, [pmc, #(AT91_CKGR_PLLBR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_CKGR_PLLBR]
 
        /* Turn off the main oscillator */
-       ldr     tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_CKGR_MOR]
        bic     tmp1, tmp1, #AT91_PMC_MOSCEN
-       str     tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_CKGR_MOR]
 
        /* Wait for interrupt */
        mcr     p15, 0, tmp1, c7, c0, 4
 
        /* Turn on the main oscillator */
-       ldr     tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)]
+       ldr     tmp1, [pmc, #AT91_CKGR_MOR]
        orr     tmp1, tmp1, #AT91_PMC_MOSCEN
-       str     tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_CKGR_MOR]
 
        wait_moscrdy
 
        /* Restore PLLB setting */
        ldr     tmp1, .saved_pllbr
-       str     tmp1, [pmc, #(AT91_CKGR_PLLBR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_CKGR_PLLBR]
 
        tst     tmp1, #(AT91_PMC_MUL &  0xff0000)
        bne     1f
@@ -243,7 +243,7 @@ sdr_sr_done:
 
        /* Restore PLLA setting */
        ldr     tmp1, .saved_pllar
-       str     tmp1, [pmc, #(AT91_CKGR_PLLAR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_CKGR_PLLAR]
 
        tst     tmp1, #(AT91_PMC_MUL &  0xff0000)
        bne     3f
@@ -264,7 +264,7 @@ sdr_sr_done:
        tst     tmp1, #AT91_PMC_PRES
        beq     2f
        and     tmp1, tmp1, #AT91_PMC_PRES
-       str     tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_PMC_MCKR]
 
        wait_mckrdy
 #endif
@@ -273,7 +273,7 @@ sdr_sr_done:
         * Restore master clock setting
         */
 2:     ldr     tmp1, .saved_mckr
-       str     tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)]
+       str     tmp1, [pmc, #AT91_PMC_MCKR]
 
        wait_mckrdy
 
index e2fb6d583bd91a9b849da93224ef002bbb03f683..ce9dffb0515da0e571ddb4371c4ad226e7108354 100644 (file)
@@ -332,12 +332,12 @@ static int vbus_is_present(struct usba_udc *udc)
 
 static void toggle_bias(int is_on)
 {
-       unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
+       unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
 
        if (is_on)
-               at91_sys_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
+               at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN);
        else
-               at91_sys_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
+               at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN));
 }
 
 #else