at91 first cleanup series for 3.4
Subsystems (9)
v2 cover at91 first cleanup series for 3.4
It is the second revision of this series of cleanup. It includes enhancements adviced by Ryan Mallon and Russell King.
This series removes the at91_sys_read/write() functions that where used for all System Controller devices. The static offsets that were used prevented us from compiling several AT91 SoC support in a single zImage.
The other cleanup is the move of some early console initialization.
All this goes on top of current material that is already in arm-soc git tree (merge of all at91/* branches).
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (18):
ARM: at91: factorise duplicated at91sam9 idle
ARM: at91/at91x40: remove use of at91_sys_read/write
ARM: at91: make matrix register base soc independent
ARM: at91: make ST (System Timer) soc independent
ARM: at91/pm_slowclock: rename register to named define
ARM: at91/pm_slowclock: function slow_clock() accepts parameters
ARM: at91: move at91rm9200 sdramc defines to at91rm9200_sdramc.h
ARM: at91: make sdram/ddr register base soc independent
ARM: at91/pm_slowclock: add runtime detection of memory contoller
ARM: at91/PMC: make register base soc independent
ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
ARM: at91:rtc/rtc-at91sam9: ioremap register bank
ARM: at91/rtc-at91sam9: pass the GPBR to use via resources
ARM: at91: finally drop at91_sys_read/write
ARM: at91: merge SRAM Memory banks thanks to mirroring
Atmel: move console default platform_device to serial driver
ARM: at91/board-dt: drop default console
ARM: at91/board-dt: move at91_initialize() to init_irq()
Nicolas Ferre (1):
ARM: at91/ST: remove not needed casts
arch/arm/mach-at91/at91rm9200.c | 8 +- arch/arm/mach-at91/at91rm9200_devices.c | 14 +- arch/arm/mach-at91/at91rm9200_time.c | 37 ++- arch/arm/mach-at91/at91sam9260.c | 23 +- arch/arm/mach-at91/at91sam9260_devices.c | 38 +++- arch/arm/mach-at91/at91sam9261.c | 10 +- arch/arm/mach-at91/at91sam9261_devices.c | 31 ++- arch/arm/mach-at91/at91sam9263.c | 11 +- arch/arm/mach-at91/at91sam9263_devices.c | 59 ++++- arch/arm/mach-at91/at91sam9_alt_reset.S | 12 +- arch/arm/mach-at91/at91sam9g45.c | 11 +- arch/arm/mach-at91/at91sam9g45_devices.c | 31 ++- arch/arm/mach-at91/at91sam9g45_reset.S | 12 +- arch/arm/mach-at91/at91sam9rl.c | 10 +- arch/arm/mach-at91/at91sam9rl_devices.c | 31 ++- arch/arm/mach-at91/at91sam9x5.c | 5 +- arch/arm/mach-at91/at91x40.c | 2 +- arch/arm/mach-at91/at91x40_time.c | 28 ++- arch/arm/mach-at91/board-cpu9krea.c | 5 +- arch/arm/mach-at91/board-cpuat91.c | 1 + arch/arm/mach-at91/board-dt.c | 16 +- arch/arm/mach-at91/board-eco920.c | 5 +- arch/arm/mach-at91/board-kb9202.c | 1 + arch/arm/mach-at91/board-picotux200.c | 1 + arch/arm/mach-at91/board-rm9200dk.c | 1 + arch/arm/mach-at91/board-rm9200ek.c | 1 + arch/arm/mach-at91/board-yl-9200.c | 3 +- arch/arm/mach-at91/clock.c | 81 ++++--- arch/arm/mach-at91/generic.h | 10 + arch/arm/mach-at91/include/mach/at91_matrix.h | 23 ++ arch/arm/mach-at91/include/mach/at91_pmc.h | 56 +++-- arch/arm/mach-at91/include/mach/at91_ramc.h | 32 +++ arch/arm/mach-at91/include/mach/at91_st.h | 32 ++- arch/arm/mach-at91/include/mach/at91rm9200.h | 10 +- arch/arm/mach-at91/include/mach/at91rm9200_mc.h | 58 +---- .../arm/mach-at91/include/mach/at91rm9200_sdramc.h | 63 +++++ arch/arm/mach-at91/include/mach/at91sam9260.h | 14 +- .../mach-at91/include/mach/at91sam9260_matrix.h | 36 ++-- arch/arm/mach-at91/include/mach/at91sam9261.h | 10 +- .../mach-at91/include/mach/at91sam9261_matrix.h | 18 +- arch/arm/mach-at91/include/mach/at91sam9263.h | 12 +- .../mach-at91/include/mach/at91sam9263_matrix.h | 74 +++--- arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h | 6 - arch/arm/mach-at91/include/mach/at91sam9_sdramc.h | 6 - arch/arm/mach-at91/include/mach/at91sam9g45.h | 12 +- .../mach-at91/include/mach/at91sam9g45_matrix.h | 84 +++--- arch/arm/mach-at91/include/mach/at91sam9rl.h | 7 +- .../arm/mach-at91/include/mach/at91sam9rl_matrix.h | 42 ++-- arch/arm/mach-at91/include/mach/at91sam9x5.h | 5 +- arch/arm/mach-at91/include/mach/at91x40.h | 18 +- arch/arm/mach-at91/include/mach/hardware.h | 3 +- arch/arm/mach-at91/include/mach/io.h | 18 -- arch/arm/mach-at91/pm.c | 35 ++- arch/arm/mach-at91/pm.h | 11 +- arch/arm/mach-at91/pm_slowclock.S | 271 ++++++++++---------- arch/arm/mach-at91/setup.c | 9 + arch/avr32/mach-at32ap/at32ap700x.c | 2 - drivers/pcmcia/at91_cf.c | 5 +- drivers/rtc/rtc-at91sam9.c | 98 +++----- drivers/tty/serial/atmel_serial.c | 2 + drivers/usb/gadget/at91_udc.c | 9 +- drivers/usb/gadget/atmel_usba_udc.c | 6 +- drivers/watchdog/at91rm9200_wdt.c | 8 +- 63 files changed, 910 insertions(+), 683 deletions(-) create mode 100644 arch/arm/mach-at91/include/mach/at91_matrix.h create mode 100644 arch/arm/mach-at91/include/mach/at91_ramc.h create mode 100644 arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
PATCH v2 1/19 ARM: at91: factorise duplicated at91sam9 idle
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Remove duplicated at91sam9xxxx_idle() functions introduced by commit c9dfafb "ARM: mach-at91: move special idle code out of line". Replace by a generic at91sam9_idle() function in setup.c common location.
--- arch/arm/mach-at91/at91sam9260.c | 8 +------- arch/arm/mach-at91/at91sam9261.c | 8 +------- arch/arm/mach-at91/at91sam9263.c | 8 +------- arch/arm/mach-at91/at91sam9g45.c | 8 +------- arch/arm/mach-at91/at91sam9rl.c | 8 +------- arch/arm/mach-at91/clock.c | 8 ++++++++ arch/arm/mach-at91/generic.h | 3 +++ 7 files changed, 16 insertions(+), 35 deletions(-)
arch/arm/mach-at91/at91sam9260.c +1 -7
@@ -329,15 +329,9 @@ static void __init at91sam9260_ioremap_registers(void)at91sam9_ioremap_smc (0 ,AT91SAM9260_BASE_SMC ); } -static void at91sam9260_idle (void ) -{ -at91_sys_write (AT91_PMC_SCDR ,AT91_PMC_PCK ); -cpu_do_idle (); -} -static void __init at91sam9260_initialize (void ) { - arm_pm_idle = at91sam9260_idle; + arm_pm_idle = at91sam9_idle; arm_pm_restart = at91sam9_alt_restart; at91_extern_irq = (1 <<AT91SAM9260_ID_IRQ0 ) | (1 <<AT91SAM9260_ID_IRQ1 ) | (1 <<AT91SAM9260_ID_IRQ2 );
arch/arm/mach-at91/at91sam9261.c +1 -7
@@ -287,15 +287,9 @@ static void __init at91sam9261_ioremap_registers(void)at91sam9_ioremap_smc (0 ,AT91SAM9261_BASE_SMC ); } -static void at91sam9261_idle (void ) -{ -at91_sys_write (AT91_PMC_SCDR ,AT91_PMC_PCK ); -cpu_do_idle (); -} -static void __init at91sam9261_initialize (void ) { - arm_pm_idle = at91sam9261_idle; + arm_pm_idle = at91sam9_idle; arm_pm_restart = at91sam9_alt_restart; at91_extern_irq = (1 <<AT91SAM9261_ID_IRQ0 ) | (1 <<AT91SAM9261_ID_IRQ1 ) | (1 <<AT91SAM9261_ID_IRQ2 );
arch/arm/mach-at91/at91sam9263.c +1 -7
@@ -308,15 +308,9 @@ static void __init at91sam9263_ioremap_registers(void)at91sam9_ioremap_smc (1 ,AT91SAM9263_BASE_SMC1 ); } -static void at91sam9263_idle (void ) -{ -at91_sys_write (AT91_PMC_SCDR ,AT91_PMC_PCK ); -cpu_do_idle (); -} -static void __init at91sam9263_initialize (void ) { - arm_pm_idle = at91sam9263_idle; + arm_pm_idle = at91sam9_idle; arm_pm_restart = at91sam9_alt_restart; at91_extern_irq = (1 <<AT91SAM9263_ID_IRQ0 ) | (1 <<AT91SAM9263_ID_IRQ1 );
arch/arm/mach-at91/at91sam9g45.c +1 -7
@@ -317,12 +317,6 @@ static struct at91_gpio_bank at91sam9g45_gpio[] __initdata = { } }; -static void at91sam9g45_idle (void ) -{ -at91_sys_write (AT91_PMC_SCDR ,AT91_PMC_PCK ); -cpu_do_idle (); -} -/* -------------------------------------------------------------------- * AT91SAM9G45 processor initialization * -------------------------------------------------------------------- */
@@ -343,7 +337,7 @@ static void __init at91sam9g45_ioremap_registers(void)static void __init at91sam9g45_initialize (void ) { - arm_pm_idle = at91sam9g45_idle; + arm_pm_idle = at91sam9_idle; arm_pm_restart = at91sam9g45_restart; at91_extern_irq = (1 <<AT91SAM9G45_ID_IRQ0 );
arch/arm/mach-at91/at91sam9rl.c +1 -7
@@ -292,15 +292,9 @@ static void __init at91sam9rl_ioremap_registers(void)at91sam9_ioremap_smc (0 ,AT91SAM9RL_BASE_SMC ); } -static void at91sam9rl_idle (void ) -{ -at91_sys_write (AT91_PMC_SCDR ,AT91_PMC_PCK ); -cpu_do_idle (); -} -static void __init at91sam9rl_initialize (void ) { - arm_pm_idle = at91sam9rl_idle; + arm_pm_idle = at91sam9_idle; arm_pm_restart = at91sam9_alt_restart; at91_extern_irq = (1 <<AT91SAM9RL_ID_IRQ0 );
arch/arm/mach-at91/clock.c +8 -0
@@ -28,6 +28,8 @@#include <mach/at91_pmc.h> #include <mach/cpu.h> +#include <asm/proc-fns.h> +#include "clock.h" #include "generic.h"
@@ -818,3 +820,9 @@ static int __init at91_clock_reset(void)return 0 ; }late_initcall (at91_clock_reset); + +void at91sam9_idle (void ) +{ +at91_sys_write (AT91_PMC_SCDR ,AT91_PMC_PCK ); +cpu_do_idle (); +}
arch/arm/mach-at91/generic.h +3 -0
@@ -56,6 +56,9 @@ struct device;extern void at91_irq_suspend (void );extern void at91_irq_resume (void ); +/* idle */ +extern void at91sam9_idle (void ); +/* reset */ extern void at91_ioremap_rstc (u32 base_addr);extern void at91sam9_alt_restart (char ,const char *);
Signature · 1 line
1.7.9
PATCH v2 2/19 ARM: at91/at91x40: remove use of at91_sys_read/write
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
--- arch/arm/mach-at91/at91x40.c | 2 +- arch/arm/mach-at91/at91x40_time.c | 28 +++++++++++++++++----------- arch/arm/mach-at91/include/mach/at91x40.h | 18 +++++++++--------- 3 files changed, 27 insertions(+), 21 deletions(-)
arch/arm/mach-at91/at91x40.c +1 -1
@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );cpu_do_idle (); }
arch/arm/mach-at91/at91x40_time.c +17 -11
@@ -28,6 +28,12 @@#include <asm/mach/time.h> #include <mach/at91_tc.h> +#define at91_tc_read (field) \ + __raw_readl(AT91_TC + field) + +#define at91_tc_write (field, value) \ + __raw_writel(value, AT91_TC + field); +/* * 3 counter/timer units present. */
@@ -37,12 +43,12 @@static unsigned long at91x40_gettimeoffset (void ) { -return (at91_sys_read (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_CV ) *1000000 / (AT91X40_MASTER_CLOCK /128 )); +return (at91_tc_read (AT91_TC_CLK1BASE +AT91_TC_CV ) *1000000 / (AT91X40_MASTER_CLOCK /128 )); }static irqreturn_t at91x40_timer_interrupt (int irq,void *dev_id) { -at91_sys_read (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_SR ); +at91_tc_read (AT91_TC_CLK1BASE +AT91_TC_SR );timer_tick ();return IRQ_HANDLED ; }
@@ -57,20 +63,20 @@ void __init at91x40_timer_init(void) {unsigned int v; -at91_sys_write (AT91_TC +AT91_TC_BCR ,0 ); - v =at91_sys_read (AT91_TC +AT91_TC_BMR ); +at91_tc_write (AT91_TC_BCR ,0 ); + v =at91_tc_read (AT91_TC_BMR ); v = (v & ~AT91_TC_TC1XC1S ) |AT91_TC_TC1XC1S_NONE ; -at91_sys_write (AT91_TC +AT91_TC_BMR , v); +at91_tc_write (AT91_TC_BMR , v); -at91_sys_write (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_CCR ,AT91_TC_CLKDIS ); -at91_sys_write (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_CMR , (AT91_TC_TIMER_CLOCK4 |AT91_TC_CPCTRG )); -at91_sys_write (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_IDR ,0xffffffff ); -at91_sys_write (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_RC , (AT91X40_MASTER_CLOCK /128 ) /HZ -1 ); -at91_sys_write (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_IER , (1 <<4 )); +at91_tc_write (AT91_TC_CLK1BASE +AT91_TC_CCR ,AT91_TC_CLKDIS ); +at91_tc_write (AT91_TC_CLK1BASE +AT91_TC_CMR , (AT91_TC_TIMER_CLOCK4 |AT91_TC_CPCTRG )); +at91_tc_write (AT91_TC_CLK1BASE +AT91_TC_IDR ,0xffffffff ); +at91_tc_write (AT91_TC_CLK1BASE +AT91_TC_RC , (AT91X40_MASTER_CLOCK /128 ) /HZ -1 ); +at91_tc_write (AT91_TC_CLK1BASE +AT91_TC_IER , (1 <<4 ));setup_irq (AT91X40_ID_TC1 , &at91x40_timer_irq); -at91_sys_write (AT91_TC +AT91_TC_CLK1BASE +AT91_TC_CCR , (AT91_TC_SWTRG |AT91_TC_CLKEN )); +at91_tc_write (AT91_TC_CLK1BASE +AT91_TC_CCR , (AT91_TC_SWTRG |AT91_TC_CLKEN )); }struct sys_timer at91x40_timer = {
arch/arm/mach-at91/include/mach/at91x40.h +9 -9
@@ -28,18 +28,18 @@#define AT91X40_ID_IRQ2 18/* External IRQ 2 */ /* -* System Peripherals (offset from AT91_BASE_SYS) +* System Peripherals */ #define AT91_BASE_SYS 0xffc00000 -#define AT91_EBI (0xffe00000 - AT91_BASE_SYS)/* External Bus Interface */ -#define AT91_SF (0xfff00000 - AT91_BASE_SYS)/* Special Function */ -#define AT91_USART1 (0xfffcc000 - AT91_BASE_SYS)/* USART 1 */ -#define AT91_USART0 (0xfffd0000 - AT91_BASE_SYS)/* USART 0 */ -#define AT91_TC (0xfffe0000 - AT91_BASE_SYS)/* Timer Counter */ -#define AT91_PIOA (0xffff0000 - AT91_BASE_SYS)/* PIO Controller A */ -#define AT91_PS (0xffff4000 - AT91_BASE_SYS)/* Power Save */ -#define AT91_WD (0xffff8000 - AT91_BASE_SYS)/* Watchdog Timer */ +#define AT91_EBI 0xffe00000/* External Bus Interface */ +#define AT91_SF 0xfff00000/* Special Function */ +#define AT91_USART1 0xfffcc000/* USART 1 */ +#define AT91_USART0 0xfffd0000/* USART 0 */ +#define AT91_TC 0xfffe0000/* Timer Counter */ +#define AT91_PIOA 0xffff0000/* PIO Controller A */ +#define AT91_PS 0xffff4000/* Power Save */ +#define AT91_WD 0xffff8000/* Watchdog Timer */ /* * The AT91x40 series doesn't have a debug unit like the other AT91 parts.
Signature · 1 line
1.7.9
Re: [PATCH v2 02/19] ARM: at91/at91x40: remove use of at91_sys_read/write
Hi Nicolas and Jean-Christophe,
arch/arm/mach-at91/at91x40.c static void at91x40_idle(void) · line 49
Quoted 10 lines · Nicolas Ferre
arch/arm/mach-at91/at91x40.c +1
-1@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );cpu_do_idle (); }
How about making this writel_relaxed in the process?
I would like to see the use of __raw_*() get reduced in code that gets touched. In most cases writel_relaxed/readl_relaxed is the correct accessor function instead.
Arnd
Re: [PATCH v2 02/19] ARM: at91/at91x40: remove use of at91_sys_read/write
Quoted 18 lines · Arnd Bergmann
Hi Nicolas and Jean-Christophe,
arch/arm/mach-at91/at91x40.c static void at91x40_idle(void) · line 49
Quoted 10 lines · Nicolas Ferre
arch/arm/mach-at91/at91x40.c +1
-1@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );cpu_do_idle (); }How about making this
writel_relaxedin the process?
I would like to see the use of __raw_*() get reduced in code that gets touched. In most cases writel_relaxed/readl_relaxed is the correct accessor function instead.
It will for next release I plan to switch all of the at one
today I don't want to change it as the same time
Best Regards,
J.
Re: [PATCH v2 02/19] ARM: at91/at91x40: remove use of at91_sys_read/write
In reply to Nicolas FerreQuoted 15 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>--- arch/arm/mach-at91/at91x40.c | 2 +- arch/arm/mach-at91/at91x40_time.c | 28 +++++++++++++++++----------- arch/arm/mach-at91/include/mach/at91x40.h | 18 +++++++++--------- 3 files changed, 27 insertions(+), 21 deletions(-)arch/arm/mach-at91/at91x40.c +0
-0
arch/arm/mach-at91/at91x40.c static void at91x40_idle(void) · line 47
Quoted 5 lines
arch/arm/mach-at91/at91x40.c +1
-1@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );
This doesn't seem to be equivalent, at91_sys_write does:
void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS; __raw_writel(value, addr + reg_offset);
and this patch doesn't redefine AT91_PS_CR. Was it broken before this patch? What am I missing?
~Ryan
Re: [PATCH v2 02/19] ARM: at91/at91x40: remove use of at91_sys_read/write
Quoted 26 lines · Ryan Mallon
Quoted 15 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>--- arch/arm/mach-at91/at91x40.c | 2 +- arch/arm/mach-at91/at91x40_time.c | 28 +++++++++++++++++----------- arch/arm/mach-at91/include/mach/at91x40.h | 18 +++++++++--------- 3 files changed, 27 insertions(+), 21 deletions(-)arch/arm/mach-at91/at91x40.c +0
-0arch/arm/mach-at91/at91x40.c static void at91x40_idle(void) · line 47
Quoted 5 lines
arch/arm/mach-at91/at91x40.c +1
-1@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );This doesn't seem to be equivalent,
at91_sys_writedoes:
Quoted 5 lines
void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS; __raw_writel(value, addr + reg_offset);and this patch doesn't redefine
AT91_PS_CR. Was it broken before this patch? What am I missing?
this is right
#define AT91_PS_CR (AT91_PS + 0) /* PS Control register */
Best Regards,
J.
Re: [PATCH v2 02/19] ARM: at91/at91x40: remove use of at91_sys_read/write
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 26 lines · Ryan Mallon
Quoted 15 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>--- arch/arm/mach-at91/at91x40.c | 2 +- arch/arm/mach-at91/at91x40_time.c | 28 +++++++++++++++++----------- arch/arm/mach-at91/include/mach/at91x40.h | 18 +++++++++--------- 3 files changed, 27 insertions(+), 21 deletions(-)arch/arm/mach-at91/at91x40.c +0
-0arch/arm/mach-at91/at91x40.c static void at91x40_idle(void) · line 47
Quoted 5 lines
arch/arm/mach-at91/at91x40.c +1
-1@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );This doesn't seem to be equivalent,
at91_sys_writedoes:
Quoted 7 lines
Quoted 5 lines
void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS; __raw_writel(value, addr + reg_offset);and this patch doesn't redefine
AT91_PS_CR. Was it broken before this patch? What am I missing?this is right
#defineAT91_PS_CR(AT91_PS+ 0) /* PS Control register */
That doesn't answer my question.
The old, at91_sys_write, version was writing to (using __raw_writel):
AT91_VA_BASE_SYS + AT91_PS_CR
The new version is writing, also using __raw_writel, to:
AT91_PS_CR
The value of AT91_PS_CR is not changed in this patch. Assuming that AT91_VA_BASE_SYS for at91x40 (which at a quick glance it is not), then the old and the new version of the code are not writing to the same address.
Was it previously incorrect, or is it incorrect now?
~Ryan
Re: [PATCH v2 02/19] ARM: at91/at91x40: remove use of at91_sys_read/write
Quoted 46 lines · Ryan Mallon
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 26 lines · Ryan Mallon
Quoted 15 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>--- arch/arm/mach-at91/at91x40.c | 2 +- arch/arm/mach-at91/at91x40_time.c | 28 +++++++++++++++++----------- arch/arm/mach-at91/include/mach/at91x40.h | 18 +++++++++--------- 3 files changed, 27 insertions(+), 21 deletions(-)arch/arm/mach-at91/at91x40.c +0
-0arch/arm/mach-at91/at91x40.c static void at91x40_idle(void) · line 47
Quoted 5 lines
arch/arm/mach-at91/at91x40.c +1
-1@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );This doesn't seem to be equivalent,
at91_sys_writedoes:Quoted 7 lines
Quoted 5 lines
void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS; __raw_writel(value, addr + reg_offset);and this patch doesn't redefine
AT91_PS_CR. Was it broken before this patch? What am I missing?this is right
#defineAT91_PS_CR(AT91_PS+ 0) /* PS Control register */That doesn't answer my question.
The old,
at91_sys_write, version was writing to (using__raw_writel):
AT91_VA_BASE_SYS+AT91_PS_CRThe new version is writing, also using
__raw_writel, to:
Quoted 8 lines
AT91_PS_CRThe value of
AT91_PS_CRis not changed in this patch. Assuming thatAT91_VA_BASE_SYSfor at91x40 (which at a quick glance it is not), then the old and the new version of the code are not writing to the same address.Was it previously incorrect, or is it incorrect now?
it's as we update
+#define AT91_PS 0xffff4000 /* Power Save */
Best Regards,
J.
Re: [PATCH v2 02/19] ARM: at91/at91x40: remove use of at91_sys_read/write
Quoted 54 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 53 lines · Ryan Mallon
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 26 lines · Ryan Mallon
Quoted 15 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>--- arch/arm/mach-at91/at91x40.c | 2 +- arch/arm/mach-at91/at91x40_time.c | 28 +++++++++++++++++----------- arch/arm/mach-at91/include/mach/at91x40.h | 18 +++++++++--------- 3 files changed, 27 insertions(+), 21 deletions(-)arch/arm/mach-at91/at91x40.c +0
-0arch/arm/mach-at91/at91x40.c static void at91x40_idle(void) · line 47
Quoted 5 lines
arch/arm/mach-at91/at91x40.c +1
-1@@ -44,7 +44,7 @@ static void at91x40_idle(void)* Disable the processor clock. The processor will be automatically * re-enabled by an interrupt or by a reset. */ -at91_sys_write (AT91_PS_CR ,AT91_PS_CR_CPU ); +__raw_writel (AT91_PS_CR_CPU ,AT91_PS_CR );This doesn't seem to be equivalent,
at91_sys_writedoes:Quoted 7 lines
Quoted 5 lines
void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS; __raw_writel(value, addr + reg_offset);and this patch doesn't redefine
AT91_PS_CR. Was it broken before this patch? What am I missing?this is right
#defineAT91_PS_CR(AT91_PS+ 0) /* PS Control register */That doesn't answer my question.
The old,
at91_sys_write, version was writing to (using__raw_writel):
AT91_VA_BASE_SYS+AT91_PS_CRThe new version is writing, also using
__raw_writel, to:
AT91_PS_CRThe value of
AT91_PS_CRis not changed in this patch. Assuming thatAT91_VA_BASE_SYSfor at91x40 (which at a quick glance it is not), then the old and the new version of the code are not writing to the same address.
Quoted 4 lines
Quoted 1 line
Was it previously incorrect, or is it incorrect now?
it's as we update
+#define
AT91_PS0xffff4000/* Power Save */
Ah, I missed the new value of AT91_PS. Sorry for the confusion.
~Ryan
PATCH v2 3/19 ARM: at91: make matrix register base soc independent
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
--- arch/arm/mach-at91/at91sam9260.c | 1 + arch/arm/mach-at91/at91sam9260_devices.c | 9 +- arch/arm/mach-at91/at91sam9261.c | 1 + arch/arm/mach-at91/at91sam9261_devices.c | 5 +- arch/arm/mach-at91/at91sam9263.c | 1 + arch/arm/mach-at91/at91sam9263_devices.c | 9 +- arch/arm/mach-at91/at91sam9g45.c | 1 + arch/arm/mach-at91/at91sam9g45_devices.c | 5 +- arch/arm/mach-at91/at91sam9rl.c | 1 + arch/arm/mach-at91/at91sam9rl_devices.c | 5 +- arch/arm/mach-at91/board-cpu9krea.c | 5 +- arch/arm/mach-at91/generic.h | 3 + arch/arm/mach-at91/include/mach/at91_matrix.h | 23 ++++++ arch/arm/mach-at91/include/mach/at91rm9200.h | 2 - arch/arm/mach-at91/include/mach/at91sam9260.h | 2 +- .../mach-at91/include/mach/at91sam9260_matrix.h | 36 ++++---- arch/arm/mach-at91/include/mach/at91sam9261.h | 2 +- .../mach-at91/include/mach/at91sam9261_matrix.h | 18 ++-- arch/arm/mach-at91/include/mach/at91sam9263.h | 2 +- .../mach-at91/include/mach/at91sam9263_matrix.h | 74 +++++++++--------- arch/arm/mach-at91/include/mach/at91sam9g45.h | 2 +- .../mach-at91/include/mach/at91sam9g45_matrix.h | 84 ++++++++++---------- arch/arm/mach-at91/include/mach/at91sam9rl.h | 2 +- .../arm/mach-at91/include/mach/at91sam9rl_matrix.h | 42 +++++----- arch/arm/mach-at91/setup.c | 9 ++ drivers/usb/gadget/at91_udc.c | 9 +- 26 files changed, 199 insertions(+), 154 deletions(-) create mode 100644 arch/arm/mach-at91/include/mach/at91_matrix.h
arch/arm/mach-at91/at91sam9260.c +1 -0
@@ -327,6 +327,7 @@ static void __init at91sam9260_ioremap_registers(void)at91_ioremap_rstc (AT91SAM9260_BASE_RSTC );at91sam926x_ioremap_pit (AT91SAM9260_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9260_BASE_SMC ); +at91_ioremap_matrix (AT91SAM9260_BASE_MATRIX ); }static void __init at91sam9260_initialize (void )
arch/arm/mach-at91/at91sam9260_devices.c +5 -4
@@ -21,6 +21,7 @@#include <mach/cpu.h> #include <mach/at91sam9260.h> #include <mach/at91sam9260_matrix.h> +#include <mach/at91_matrix.h> #include <mach/at91sam9_smc.h> #include "generic.h"
@@ -422,8 +423,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)if (!data)return ; - csa =at91_sys_read (AT91_MATRIX_EBICSA ); -at91_sys_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_CS3A_SMC_SMARTMEDIA ); + csa =at91_matrix_read (AT91_MATRIX_EBICSA ); +at91_matrix_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_CS3A_SMC_SMARTMEDIA );/* enable pin */ if (gpio_is_valid (data->enable_pin))
@@ -1265,7 +1266,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)if (!data)return ; - csa =at91_sys_read (AT91_MATRIX_EBICSA ); + csa =at91_matrix_read (AT91_MATRIX_EBICSA );switch (data->chipselect) {case 4 :
@@ -1288,7 +1289,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)return ; } -at91_sys_write (AT91_MATRIX_EBICSA , csa); +at91_matrix_write (AT91_MATRIX_EBICSA , csa);if (gpio_is_valid (data->rst_pin)) {at91_set_multi_drive (data->rst_pin,0 );
arch/arm/mach-at91/at91sam9261.c +1 -0
@@ -285,6 +285,7 @@ static void __init at91sam9261_ioremap_registers(void)at91_ioremap_rstc (AT91SAM9261_BASE_RSTC );at91sam926x_ioremap_pit (AT91SAM9261_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9261_BASE_SMC ); +at91_ioremap_matrix (AT91SAM9261_BASE_MATRIX ); }static void __init at91sam9261_initialize (void )
arch/arm/mach-at91/at91sam9261_devices.c +3 -2
@@ -24,6 +24,7 @@#include <mach/board.h> #include <mach/at91sam9261.h> #include <mach/at91sam9261_matrix.h> +#include <mach/at91_matrix.h> #include <mach/at91sam9_smc.h> #include "generic.h"
@@ -236,8 +237,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)if (!data)return ; - csa =at91_sys_read (AT91_MATRIX_EBICSA ); -at91_sys_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_CS3A_SMC_SMARTMEDIA ); + csa =at91_matrix_read (AT91_MATRIX_EBICSA ); +at91_matrix_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_CS3A_SMC_SMARTMEDIA );/* enable pin */ if (gpio_is_valid (data->enable_pin))
arch/arm/mach-at91/at91sam9263.c +1 -0
@@ -306,6 +306,7 @@ static void __init at91sam9263_ioremap_registers(void)at91sam926x_ioremap_pit (AT91SAM9263_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9263_BASE_SMC0 );at91sam9_ioremap_smc (1 ,AT91SAM9263_BASE_SMC1 ); +at91_ioremap_matrix (AT91SAM9263_BASE_MATRIX ); }static void __init at91sam9263_initialize (void )
arch/arm/mach-at91/at91sam9263_devices.c +5 -4
@@ -23,6 +23,7 @@#include <mach/board.h> #include <mach/at91sam9263.h> #include <mach/at91sam9263_matrix.h> +#include <mach/at91_matrix.h> #include <mach/at91sam9_smc.h> #include "generic.h"
@@ -409,7 +410,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)* we assume SMC timings are configured by board code, * except True IDE where timings are controlled by driver */ - ebi0_csa =at91_sys_read (AT91_MATRIX_EBI0CSA ); + ebi0_csa =at91_matrix_read (AT91_MATRIX_EBI0CSA );switch (data->chipselect) {case 4 :at91_set_A_periph (AT91_PIN_PD6 ,0 );/* EBI0_NCS4/CFCS0 */
@@ -428,7 +429,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data) data->chipselect);return ; } -at91_sys_write (AT91_MATRIX_EBI0CSA , ebi0_csa); +at91_matrix_write (AT91_MATRIX_EBI0CSA , ebi0_csa);if (gpio_is_valid (data->det_pin)) {at91_set_gpio_input (data->det_pin,1 );
@@ -496,8 +497,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)if (!data)return ; - csa =at91_sys_read (AT91_MATRIX_EBI0CSA ); -at91_sys_write (AT91_MATRIX_EBI0CSA , csa |AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA ); + csa =at91_matrix_read (AT91_MATRIX_EBI0CSA ); +at91_matrix_write (AT91_MATRIX_EBI0CSA , csa |AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA );/* enable pin */ if (gpio_is_valid (data->enable_pin))
arch/arm/mach-at91/at91sam9g45.c +1 -0
@@ -333,6 +333,7 @@ static void __init at91sam9g45_ioremap_registers(void)at91_ioremap_rstc (AT91SAM9G45_BASE_RSTC );at91sam926x_ioremap_pit (AT91SAM9G45_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9G45_BASE_SMC ); +at91_ioremap_matrix (AT91SAM9G45_BASE_MATRIX ); }static void __init at91sam9g45_initialize (void )
arch/arm/mach-at91/at91sam9g45_devices.c +3 -2
@@ -25,6 +25,7 @@#include <mach/board.h> #include <mach/at91sam9g45.h> #include <mach/at91sam9g45_matrix.h> +#include <mach/at91_matrix.h> #include <mach/at91sam9_smc.h> #include <mach/at_hdmac.h> #include <mach/atmel-mci.h>
@@ -557,8 +558,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)if (!data)return ; - csa =at91_sys_read (AT91_MATRIX_EBICSA ); -at91_sys_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA ); + csa =at91_matrix_read (AT91_MATRIX_EBICSA ); +at91_matrix_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA );/* enable pin */ if (gpio_is_valid (data->enable_pin))
arch/arm/mach-at91/at91sam9rl.c +1 -0
@@ -290,6 +290,7 @@ static void __init at91sam9rl_ioremap_registers(void)at91_ioremap_rstc (AT91SAM9RL_BASE_RSTC );at91sam926x_ioremap_pit (AT91SAM9RL_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9RL_BASE_SMC ); +at91_ioremap_matrix (AT91SAM9RL_BASE_MATRIX ); }static void __init at91sam9rl_initialize (void )
arch/arm/mach-at91/at91sam9rl_devices.c +3 -2
@@ -20,6 +20,7 @@#include <mach/board.h> #include <mach/at91sam9rl.h> #include <mach/at91sam9rl_matrix.h> +#include <mach/at91_matrix.h> #include <mach/at91sam9_smc.h> #include <mach/at_hdmac.h>
@@ -265,8 +266,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)if (!data)return ; - csa =at91_sys_read (AT91_MATRIX_EBICSA ); -at91_sys_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_CS3A_SMC_SMARTMEDIA ); + csa =at91_matrix_read (AT91_MATRIX_EBICSA ); +at91_matrix_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_CS3A_SMC_SMARTMEDIA );/* enable pin */ if (gpio_is_valid (data->enable_pin))
arch/arm/mach-at91/board-cpu9krea.c +3 -2
@@ -43,6 +43,7 @@#include <mach/board.h> #include <mach/at91sam9_smc.h> #include <mach/at91sam9260_matrix.h> +#include <mach/at91_matrix.h> #include "sam9_smc.h" #include "generic.h"
@@ -238,8 +239,8 @@ static __init void cpu9krea_add_device_nor(void) {unsigned long csa; - csa =at91_sys_read (AT91_MATRIX_EBICSA ); -at91_sys_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_VDDIOMSEL_3_3V ); + csa =at91_matrix_read (AT91_MATRIX_EBICSA ); +at91_matrix_write (AT91_MATRIX_EBICSA , csa |AT91_MATRIX_VDDIOMSEL_3_3V );/* configure chip-select 0 (NOR) */ sam9_smc_configure (0 ,0 , &cpu9krea_nor_smc_config);
arch/arm/mach-at91/generic.h +3 -0
@@ -67,6 +67,9 @@ extern void at91sam9g45_restart(char, const char *);/* shutdown */ extern void at91_ioremap_shdwc (u32 base_addr); +/* Matrix */ +extern void at91_ioremap_matrix (u32 base_addr); +/* GPIO */ #define AT91RM9200_PQFP 3/* AT91RM9200 PQFP package has 3 banks */ #define AT91RM9200_BGA 4/* AT91RM9200 BGA package has 4 banks */
arch/arm/mach-at91/include/mach/at91_matrix.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* Under GPLv2 +*/ + +#ifndef __MACH_AT91_MATRIX_H__ +#define __MACH_AT91_MATRIX_H__ + +#ifndef __ASSEMBLY__ +extern void __iomem *at91_matrix_base; + +#define at91_matrix_read (field) \ + __raw_readl(at91_matrix_base + field) + +#define at91_matrix_write (field, value) \ + __raw_writel(value, at91_matrix_base + field); + +#else +.extern at91_matrix_base +#endif + +#endif /* __MACH_AT91_MATRIX_H__ */
arch/arm/mach-at91/include/mach/at91rm9200.h +0 -2
@@ -95,8 +95,6 @@#define AT91_USART2 AT91RM9200_BASE_US2#define AT91_USART3 AT91RM9200_BASE_US3 -#define AT91_MATRIX 0/* not supported */ -/* * Internal Memory. */
arch/arm/mach-at91/include/mach/at91sam9260.h +1 -1
@@ -81,12 +81,12 @@* System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS) -#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91SAM9260_BASE_ECC 0xffffe800#define AT91SAM9260_BASE_SMC 0xffffec00 +#define AT91SAM9260_BASE_MATRIX 0xffffee00#define AT91SAM9260_BASE_DBGU AT91_BASE_DBGU0#define AT91SAM9260_BASE_PIOA 0xfffff400#define AT91SAM9260_BASE_PIOB 0xfffff600
arch/arm/mach-at91/include/mach/at91sam9260_matrix.h +18 -18
@@ -15,12 +15,12 @@#ifndef AT91SAM9260_MATRIX_H #define AT91SAM9260_MATRIX_H -#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00)/* Master Configuration Register 0 */ -#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04)/* Master Configuration Register 1 */ -#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08)/* Master Configuration Register 2 */ -#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C)/* Master Configuration Register 3 */ -#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10)/* Master Configuration Register 4 */ -#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14)/* Master Configuration Register 5 */ +#define AT91_MATRIX_MCFG0 0x00/* Master Configuration Register 0 */ +#define AT91_MATRIX_MCFG1 0x04/* Master Configuration Register 1 */ +#define AT91_MATRIX_MCFG2 0x08/* Master Configuration Register 2 */ +#define AT91_MATRIX_MCFG3 0x0C/* Master Configuration Register 3 */ +#define AT91_MATRIX_MCFG4 0x10/* Master Configuration Register 4 */ +#define AT91_MATRIX_MCFG5 0x14/* Master Configuration Register 5 */ #define AT91_MATRIX_ULBT (7 << 0)/* Undefined Length Burst Type */ #define AT91_MATRIX_ULBT_INFINITE (0 << 0)#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -28,11 +28,11 @@#define AT91_MATRIX_ULBT_EIGHT (3 << 0)#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0) -#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40)/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44)/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48)/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C)/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50)/* Slave Configuration Register 4 */ +#define AT91_MATRIX_SCFG0 0x40/* Slave Configuration Register 0 */ +#define AT91_MATRIX_SCFG1 0x44/* Slave Configuration Register 1 */ +#define AT91_MATRIX_SCFG2 0x48/* Slave Configuration Register 2 */ +#define AT91_MATRIX_SCFG3 0x4C/* Slave Configuration Register 3 */ +#define AT91_MATRIX_SCFG4 0x50/* Slave Configuration Register 4 */ #define AT91_MATRIX_SLOT_CYCLE (0xff << 0)/* Maximum Number of Allowed Cycles for a Burst */ #define AT91_MATRIX_DEFMSTR_TYPE (3 << 16)/* Default Master Type */ #define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -43,11 +43,11 @@#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) -#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80)/* Priority Register A for Slave 0 */ -#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88)/* Priority Register A for Slave 1 */ -#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90)/* Priority Register A for Slave 2 */ -#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98)/* Priority Register A for Slave 3 */ -#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0)/* Priority Register A for Slave 4 */ +#define AT91_MATRIX_PRAS0 0x80/* Priority Register A for Slave 0 */ +#define AT91_MATRIX_PRAS1 0x88/* Priority Register A for Slave 1 */ +#define AT91_MATRIX_PRAS2 0x90/* Priority Register A for Slave 2 */ +#define AT91_MATRIX_PRAS3 0x98/* Priority Register A for Slave 3 */ +#define AT91_MATRIX_PRAS4 0xA0/* Priority Register A for Slave 4 */ #define AT91_MATRIX_M0PR (3 << 0)/* Master 0 Priority */ #define AT91_MATRIX_M1PR (3 << 4)/* Master 1 Priority */ #define AT91_MATRIX_M2PR (3 << 8)/* Master 2 Priority */
@@ -55,11 +55,11 @@#define AT91_MATRIX_M4PR (3 << 16)/* Master 4 Priority */ #define AT91_MATRIX_M5PR (3 << 20)/* Master 5 Priority */ -#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100)/* Master Remap Control Register */ +#define AT91_MATRIX_MRCR 0x100/* Master Remap Control Register */ #define AT91_MATRIX_RCB0 (1 << 0)/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ #define AT91_MATRIX_RCB1 (1 << 1)/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ -#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x11C)/* EBI Chip Select Assignment Register */ +#define AT91_MATRIX_EBICSA 0x11C/* EBI Chip Select Assignment Register */ #define AT91_MATRIX_CS1A (1 << 1)/* Chip Select 1 Assignment */ #define AT91_MATRIX_CS1A_SMC (0 << 1)#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
arch/arm/mach-at91/include/mach/at91sam9261.h +1 -1
@@ -66,11 +66,11 @@* System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS) -#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91SAM9261_BASE_SMC 0xffffec00 +#define AT91SAM9261_BASE_MATRIX 0xffffee00#define AT91SAM9261_BASE_DBGU AT91_BASE_DBGU0#define AT91SAM9261_BASE_PIOA 0xfffff400#define AT91SAM9261_BASE_PIOB 0xfffff600
arch/arm/mach-at91/include/mach/at91sam9261_matrix.h +9 -9
@@ -15,15 +15,15 @@#ifndef AT91SAM9261_MATRIX_H #define AT91SAM9261_MATRIX_H -#define AT91_MATRIX_MCFG (AT91_MATRIX + 0x00)/* Master Configuration Register */ +#define AT91_MATRIX_MCFG 0x00/* Master Configuration Register */ #define AT91_MATRIX_RCB0 (1 << 0)/* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ #define AT91_MATRIX_RCB1 (1 << 1)/* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ -#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x04)/* Slave Configuration Register 0 */ -#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x08)/* Slave Configuration Register 1 */ -#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x0C)/* Slave Configuration Register 2 */ -#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x10)/* Slave Configuration Register 3 */ -#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x14)/* Slave Configuration Register 4 */ +#define AT91_MATRIX_SCFG0 0x04/* Slave Configuration Register 0 */ +#define AT91_MATRIX_SCFG1 0x08/* Slave Configuration Register 1 */ +#define AT91_MATRIX_SCFG2 0x0C/* Slave Configuration Register 2 */ +#define AT91_MATRIX_SCFG3 0x10/* Slave Configuration Register 3 */ +#define AT91_MATRIX_SCFG4 0x14/* Slave Configuration Register 4 */ #define AT91_MATRIX_SLOT_CYCLE (0xff << 0)/* Maximum Number of Allowed Cycles for a Burst */ #define AT91_MATRIX_DEFMSTR_TYPE (3 << 16)/* Default Master Type */ #define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -31,7 +31,7 @@#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)#define AT91_MATRIX_FIXED_DEFMSTR (7 << 18)/* Fixed Index of Default Master */ -#define AT91_MATRIX_TCR (AT91_MATRIX + 0x24)/* TCM Configuration Register */ +#define AT91_MATRIX_TCR 0x24/* TCM Configuration Register */ #define AT91_MATRIX_ITCM_SIZE (0xf << 0)/* Size of ITCM enabled memory block */ #define AT91_MATRIX_ITCM_0 (0 << 0)#define AT91_MATRIX_ITCM_16 (5 << 0)
@@ -43,7 +43,7 @@#define AT91_MATRIX_DTCM_32 (6 << 4)#define AT91_MATRIX_DTCM_64 (7 << 4) -#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x30)/* EBI Chip Select Assignment Register */ +#define AT91_MATRIX_EBICSA 0x30/* EBI Chip Select Assignment Register */ #define AT91_MATRIX_CS1A (1 << 1)/* Chip Select 1 Assignment */ #define AT91_MATRIX_CS1A_SMC (0 << 1)#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
@@ -58,7 +58,7 @@#define AT91_MATRIX_CS5A_SMC_CF2 (1 << 5)#define AT91_MATRIX_DBPUC (1 << 8)/* Data Bus Pull-up Configuration */ -#define AT91_MATRIX_USBPUCR (AT91_MATRIX + 0x34)/* USB Pad Pull-Up Control Register */ +#define AT91_MATRIX_USBPUCR 0x34/* USB Pad Pull-Up Control Register */ #define AT91_MATRIX_USBPUCR_PUON (1 << 30)/* USB Device PAD Pull-up Enable */ #endif
arch/arm/mach-at91/include/mach/at91sam9263.h +1 -1
@@ -76,7 +76,6 @@*/ #define AT91_SDRAMC0 (0xffffe200 - AT91_BASE_SYS)#define AT91_SDRAMC1 (0xffffe800 - AT91_BASE_SYS) -#define AT91_MATRIX (0xffffec00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
@@ -84,6 +83,7 @@#define AT91SAM9263_BASE_SMC0 0xffffe400#define AT91SAM9263_BASE_ECC1 0xffffe600#define AT91SAM9263_BASE_SMC1 0xffffea00 +#define AT91SAM9263_BASE_MATRIX 0xffffec00#define AT91SAM9263_BASE_DBGU AT91_BASE_DBGU1#define AT91SAM9263_BASE_PIOA 0xfffff200#define AT91SAM9263_BASE_PIOB 0xfffff400
arch/arm/mach-at91/include/mach/at91sam9263_matrix.h +37 -37
116 lines not on this page · raw message
arch/arm/mach-at91/include/mach/at91sam9g45.h +1 -1
@@ -88,13 +88,13 @@*/ #define AT91_DDRSDRC1 (0xffffe400 - AT91_BASE_SYS)#define AT91_DDRSDRC0 (0xffffe600 - AT91_BASE_SYS) -#define AT91_MATRIX (0xffffea00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9G45_BASE_ECC 0xffffe200#define AT91SAM9G45_BASE_DMA 0xffffec00#define AT91SAM9G45_BASE_SMC 0xffffe800 +#define AT91SAM9G45_BASE_MATRIX 0xffffea00#define AT91SAM9G45_BASE_DBGU AT91_BASE_DBGU1#define AT91SAM9G45_BASE_PIOA 0xfffff200#define AT91SAM9G45_BASE_PIOB 0xfffff400
arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h +42 -42
135 lines not on this page · raw message
arch/arm/mach-at91/include/mach/at91sam9rl.h +1 -1
@@ -70,7 +70,6 @@* System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS) -#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
@@ -78,6 +77,7 @@#define AT91SAM9RL_BASE_DMA 0xffffe600#define AT91SAM9RL_BASE_ECC 0xffffe800#define AT91SAM9RL_BASE_SMC 0xffffec00 +#define AT91SAM9RL_BASE_MATRIX 0xffffee00#define AT91SAM9RL_BASE_DBGU AT91_BASE_DBGU0#define AT91SAM9RL_BASE_PIOA 0xfffff400#define AT91SAM9RL_BASE_PIOB 0xfffff600
arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h +21 -21
78 lines not on this page · raw message
arch/arm/mach-at91/setup.c +9 -0
@@ -276,6 +276,15 @@ void __init at91_ioremap_rstc(u32 base_addr)panic ("Impossible to ioremap at91_rstc_base\n" ); } +void __iomem *at91_matrix_base; + +void __init at91_ioremap_matrix (u32 base_addr) +{ + at91_matrix_base =ioremap (base_addr,512 ); +if (!at91_matrix_base) +panic ("Impossible to ioremap at91_matrix_base\n" ); +} +void __init at91_initialize (unsigned long main_clock) { at91_boot_soc.ioremap_registers ();
drivers/usb/gadget/at91_udc.c +5 -4
@@ -41,6 +41,7 @@#include <mach/board.h> #include <mach/cpu.h> #include <mach/at91sam9261_matrix.h> +#include <mach/at91_matrix.h> #include "at91_udc.h"
@@ -910,9 +911,9 @@ static void pullup(struct at91_udc *udc, int is_on) }else if (cpu_is_at91sam9261 () ||cpu_is_at91sam9g10 ()) {u32 usbpucr; - usbpucr =at91_sys_read (AT91_MATRIX_USBPUCR ); + usbpucr =at91_matrix_read (AT91_MATRIX_USBPUCR ); usbpucr |=AT91_MATRIX_USBPUCR_PUON ; -at91_sys_write (AT91_MATRIX_USBPUCR , usbpucr); +at91_matrix_write (AT91_MATRIX_USBPUCR , usbpucr); } }else {stop_activity (udc);
@@ -928,9 +929,9 @@ static void pullup(struct at91_udc *udc, int is_on) }else if (cpu_is_at91sam9261 () ||cpu_is_at91sam9g10 ()) {u32 usbpucr; - usbpucr =at91_sys_read (AT91_MATRIX_USBPUCR ); + usbpucr =at91_matrix_read (AT91_MATRIX_USBPUCR ); usbpucr &= ~AT91_MATRIX_USBPUCR_PUON ; -at91_sys_write (AT91_MATRIX_USBPUCR , usbpucr); +at91_matrix_write (AT91_MATRIX_USBPUCR , usbpucr); }clk_off (udc); }
Signature · 1 line
1.7.9
Re: [PATCH v2 03/19] ARM: at91: make matrix register base soc independent
Quoted 6 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>Cc linux-usb at vger.kernel.orgCc Greg Kroah-Hartman <[email protected]>
Looks okay, one comment (for future) below, but otherwise:
<snip>
arch/arm/mach-at91/at91sam9263.c static void __init at91sam9263_ioremap_registers(void) · line 309
Quoted 9 lines
arch/arm/mach-at91/at91sam9263.c +1
-0@@ -306,6 +306,7 @@ static void __init at91sam9263_ioremap_registers(void)at91sam926x_ioremap_pit (AT91SAM9263_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9263_BASE_SMC0 );at91sam9_ioremap_smc (1 ,AT91SAM9263_BASE_SMC1 ); +at91_ioremap_matrix (AT91SAM9263_BASE_MATRIX );
Not necessarily for this patch set, but this list of functions is getting long enough that it could be abstracted away by a table. Something like:
struct at91_sys_device {
const char *name;
void __iomem **base;
const unsigned long mem_start;
const unsigned long mem_size;};
...
static const struct
at91_sys_device at91sam9263_sys_devices[] __initconst = {
{"PIT", &at91_pit_base,
AT91SAM9263_BASE_PIT, AT91_PIT_SIZE},
...
{"matrix", &at91_matrix_base,
AT91SAM9263_BASE_MATRIX, AT91_MATRIX_SIZE},}
...
void __init
at91_ioremap_sys_devices(const struct at91_sys_device *devices,
int nr_devices)
{
int i;
for (i = 0; i < nr_devices; i++) {
void __iomem *base = *(dev[i].base);
base = ioremap(dev[i].mem_start, dev[i].mem_size);
if (!base)
panic("Impossible to ioremap AT91 %s\n",
dev[i].name);}
~Ryan
Re: [PATCH v2 03/19] ARM: at91: make matrix register base soc independent
Quoted 64 lines · Ryan Mallon
Quoted 6 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>Cc linux-usb at vger.kernel.orgCc Greg Kroah-Hartman <[email protected]>Looks okay, one comment (for future) below, but otherwise:
Reviewed-by Ryan Mallon <[email protected]><snip>
arch/arm/mach-at91/at91sam9263.c static void __init at91sam9263_ioremap_registers(void) · line 309
Quoted 9 lines
arch/arm/mach-at91/at91sam9263.c +1
-0@@ -306,6 +306,7 @@ static void __init at91sam9263_ioremap_registers(void)at91sam926x_ioremap_pit (AT91SAM9263_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9263_BASE_SMC0 );at91sam9_ioremap_smc (1 ,AT91SAM9263_BASE_SMC1 ); +at91_ioremap_matrix (AT91SAM9263_BASE_MATRIX );Not necessarily for this patch set, but this list of functions is getting long enough that it could be abstracted away by a table. Something like:
struct at91_sys_device { const char *name; void __iomem **base; const unsigned long mem_start; const unsigned long mem_size;};
...
static const struct
at91_sys_device at91sam9263_sys_devices[] __initconst = { {"PIT", &at91_pit_base, AT91SAM9263_BASE_PIT, AT91_PIT_SIZE}, ... {"matrix", &at91_matrix_base, AT91SAM9263_BASE_MATRIX, AT91_MATRIX_SIZE},}
...
void
__init
at91_ioremap_sys_devices(const structat91_sys_device*devices,
intnr_devices){ int i; for (i = 0; i < nr_devices; i++) { void __iomem *base = *(dev[i].base); base = ioremap(dev[i].mem_start, dev[i].mem_size); if (!base) panic("Impossible to ioremap AT91 %s\n", dev[i].name);
Quoted 1 line
}
we switch to the DT no need
Best Regards,
J.
PATCH v2 4/19 ARM: at91: make ST (System Timer) soc independent
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
--- arch/arm/mach-at91/at91rm9200.c | 5 ++- arch/arm/mach-at91/at91rm9200_time.c | 37 ++++++++++++++++---------- arch/arm/mach-at91/generic.h | 1 + arch/arm/mach-at91/include/mach/at91_st.h | 32 +++++++++++++++------- arch/arm/mach-at91/include/mach/at91rm9200.h | 2 +- drivers/watchdog/at91rm9200_wdt.c | 8 +++--- 6 files changed, 54 insertions(+), 31 deletions(-)
arch/arm/mach-at91/at91rm9200.c +3 -2
@@ -303,8 +303,8 @@ static void at91rm9200_restart(char mode, const char *cmd)/* * Perform a hardware reset with the use of the Watchdog timer. */ -at91_sys_write (AT91_ST_WDMR ,AT91_ST_RSTEN |AT91_ST_EXTEN |1 ); -at91_sys_write (AT91_ST_CR ,AT91_ST_WDRST ); +at91_st_write (AT91_ST_WDMR ,AT91_ST_RSTEN |AT91_ST_EXTEN |1 ); +at91_st_write (AT91_ST_CR ,AT91_ST_WDRST ); }/* --------------------------------------------------------------------
@@ -319,6 +319,7 @@ static void __init at91rm9200_map_io(void)static void __init at91rm9200_ioremap_registers (void ) { +at91rm9200_ioremap_st (AT91RM9200_BASE_ST ); }static void __init at91rm9200_initialize (void )
arch/arm/mach-at91/at91rm9200_time.c +23 -14
@@ -43,9 +43,9 @@ static inline unsigned long read_CRTR(void) {unsigned long x1, x2; - x1 =at91_sys_read (AT91_ST_CRTR ); + x1 =at91_st_read (AT91_ST_CRTR ); do { - x2 = at91_sys_read(AT91_ST_CRTR); + x2 = at91_st_read(AT91_ST_CRTR); if (x1 == x2) break; x1 = x2;
@@ -58,7 +58,7 @@ static inline unsigned long read_CRTR(void)*/ static irqreturn_t at91rm9200_timer_interrupt (int irq,void *dev_id) { -u32 sr =at91_sys_read (AT91_ST_SR ) & irqmask; +u32 sr =at91_st_read (AT91_ST_SR ) & irqmask;/* * irqs should be disabled here, but as the irq is shared they are only
@@ -110,22 +110,22 @@ static void clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) {/* Disable and flush pending timer interrupts */ - at91_sys_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); - (void )at91_sys_read (AT91_ST_SR ); + at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); + (void )at91_st_read (AT91_ST_SR ); last_crtr =read_CRTR ();switch (mode) {case CLOCK_EVT_MODE_PERIODIC :/* PIT for periodic irqs; fixed rate of 1/HZ */ irqmask =AT91_ST_PITS ; -at91_sys_write (AT91_ST_PIMR ,RM9200_TIMER_LATCH ); +at91_st_write (AT91_ST_PIMR ,RM9200_TIMER_LATCH );break ;case CLOCK_EVT_MODE_ONESHOT :/* ALM for oneshot irqs, set by next_event() * before 32 seconds have passed */ irqmask =AT91_ST_ALMS ; -at91_sys_write (AT91_ST_RTAR , last_crtr); +at91_st_write (AT91_ST_RTAR , last_crtr);break ;case CLOCK_EVT_MODE_SHUTDOWN :case CLOCK_EVT_MODE_UNUSED :
@@ -133,7 +133,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) irqmask =0 ;break ; } -at91_sys_write (AT91_ST_IER , irqmask); +at91_st_write (AT91_ST_IER , irqmask); } static int
@@ -156,12 +156,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev) alm =read_CRTR ();/* Cancel any pending alarm; flush any pending IRQ */ -at91_sys_write (AT91_ST_RTAR , alm); - (void )at91_sys_read (AT91_ST_SR ); +at91_st_write (AT91_ST_RTAR , alm); + (void )at91_st_read (AT91_ST_SR );/* Schedule alarm by writing RTAR. */ alm += delta; -at91_sys_write (AT91_ST_RTAR , alm); +at91_st_write (AT91_ST_RTAR , alm);return status; }
@@ -175,15 +175,24 @@ static struct clock_event_device clkevt = { .set_mode = clkevt32k_mode, }; +void __iomem *at91_st_base; + +void __init at91rm9200_ioremap_st (u32 addr) +{ + at91_st_base =ioremap (addr,256 ); +if (!at91_st_base) +panic ("Impossible to ioremap ST\n" ); +} +/* * ST (system timer) module supports both clockevents and clocksource. */ void __init at91rm9200_timer_init (void ) {/* Disable all timer interrupts, and clear any pending ones */ -at91_sys_write (AT91_ST_IDR , +at91_st_write (AT91_ST_IDR ,AT91_ST_PITS |AT91_ST_WDOVF |AT91_ST_RTTINC |AT91_ST_ALMS ); - (void )at91_sys_read (AT91_ST_SR ); + (void )at91_st_read (AT91_ST_SR );/* Make IRQs happen for the system timer */ setup_irq (AT91_ID_SYS , &at91rm9200_timer_irq);
@@ -192,7 +201,7 @@ void __init at91rm9200_timer_init(void)* directly for the clocksource and all clockevents, after adjusting * its prescaler from the 1 Hz default. */ -at91_sys_write (AT91_ST_RTMR ,1 ); +at91_st_write (AT91_ST_RTMR ,1 );/* Setup timer clockevent, with minimum of two ticks (important!!) */ clkevt.mult =div_sc (AT91_SLOW_CLOCK ,NSEC_PER_SEC , clkevt.shift);
arch/arm/mach-at91/generic.h +1 -0
@@ -28,6 +28,7 @@ extern void __init at91_aic_init(unsigned int priority[]);/* Timer */ struct sys_timer ; +extern void at91rm9200_ioremap_st (u32 addr);extern struct sys_timer at91rm9200_timer;extern void at91sam926x_ioremap_pit (u32 addr);extern struct sys_timer at91sam926x_timer;
arch/arm/mach-at91/include/mach/at91_st.h +22 -10
@@ -16,34 +16,46 @@#ifndef AT91_ST_H #define AT91_ST_H -#define AT91_ST_CR (AT91_ST + 0x00)/* Control Register */ +#ifndef __ASSEMBLY__ +extern void __iomem *at91_st_base; + +#define at91_st_read (field) \ + __raw_readl(at91_st_base + field) + +#define at91_st_write (field, value) \ + __raw_writel(value, at91_st_base + field); +#else +.extern at91_st_base +#endif + +#define AT91_ST_CR 0x00/* Control Register */ #define AT91_ST_WDRST (1 << 0)/* Watchdog Timer Restart */ -#define AT91_ST_PIMR (AT91_ST + 0x04)/* Period Interval Mode Register */ +#define AT91_ST_PIMR 0x04/* Period Interval Mode Register */ #define AT91_ST_PIV (0xffff << 0)/* Period Interval Value */ -#define AT91_ST_WDMR (AT91_ST + 0x08)/* Watchdog Mode Register */ +#define AT91_ST_WDMR 0x08/* Watchdog Mode Register */ #define AT91_ST_WDV (0xffff << 0)/* Watchdog Counter Value */ #define AT91_ST_RSTEN (1 << 16)/* Reset Enable */ #define AT91_ST_EXTEN (1 << 17)/* External Signal Assertion Enable */ -#define AT91_ST_RTMR (AT91_ST + 0x0c)/* Real-time Mode Register */ +#define AT91_ST_RTMR 0x0c/* Real-time Mode Register */ #define AT91_ST_RTPRES (0xffff << 0)/* Real-time Prescalar Value */ -#define AT91_ST_SR (AT91_ST + 0x10)/* Status Register */ +#define AT91_ST_SR 0x10/* Status Register */ #define AT91_ST_PITS (1 << 0)/* Period Interval Timer Status */ #define AT91_ST_WDOVF (1 << 1)/* Watchdog Overflow */ #define AT91_ST_RTTINC (1 << 2)/* Real-time Timer Increment */ #define AT91_ST_ALMS (1 << 3)/* Alarm Status */ -#define AT91_ST_IER (AT91_ST + 0x14)/* Interrupt Enable Register */ -#define AT91_ST_IDR (AT91_ST + 0x18)/* Interrupt Disable Register */ -#define AT91_ST_IMR (AT91_ST + 0x1c)/* Interrupt Mask Register */ +#define AT91_ST_IER 0x14/* Interrupt Enable Register */ +#define AT91_ST_IDR 0x18/* Interrupt Disable Register */ +#define AT91_ST_IMR 0x1c/* Interrupt Mask Register */ -#define AT91_ST_RTAR (AT91_ST + 0x20)/* Real-time Alarm Register */ +#define AT91_ST_RTAR 0x20/* Real-time Alarm Register */ #define AT91_ST_ALMV (0xfffff << 0)/* Alarm Value */ -#define AT91_ST_CRTR (AT91_ST + 0x24)/* Current Real-time Register */ +#define AT91_ST_CRTR 0x24/* Current Real-time Register */ #define AT91_ST_CRTV (0xfffff << 0)/* Current Real-Time Value */ #endif
arch/arm/mach-at91/include/mach/at91rm9200.h +1 -1
@@ -80,7 +80,6 @@* System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)/* Power Management Controller */ -#define AT91_ST (0xfffffd00 - AT91_BASE_SYS)/* System Timer */ #define AT91_MC (0xffffff00 - AT91_BASE_SYS)/* Memory Controllers */ #define AT91RM9200_BASE_DBGU AT91_BASE_DBGU0/* Debug Unit */
@@ -88,6 +87,7 @@#define AT91RM9200_BASE_PIOB 0xfffff600/* PIO Controller B */ #define AT91RM9200_BASE_PIOC 0xfffff800/* PIO Controller C */ #define AT91RM9200_BASE_PIOD 0xfffffa00/* PIO Controller D */ +#define AT91RM9200_BASE_ST 0xfffffd00/* System Timer */ #define AT91RM9200_BASE_RTC 0xfffffe00/* Real-Time Clock */ #define AT91_USART0 AT91RM9200_BASE_US0
drivers/watchdog/at91rm9200_wdt.c +4 -4
@@ -51,7 +51,7 @@ static unsigned long at91wdt_busy;*/ static inline void at91_wdt_stop (void ) { -at91_sys_write (AT91_ST_WDMR ,AT91_ST_EXTEN ); +at91_st_write (AT91_ST_WDMR ,AT91_ST_EXTEN ); }/*
@@ -59,9 +59,9 @@ static inline void at91_wdt_stop(void)*/ static inline void at91_wdt_start (void ) { -at91_sys_write (AT91_ST_WDMR ,AT91_ST_EXTEN |AT91_ST_RSTEN | +at91_st_write (AT91_ST_WDMR ,AT91_ST_EXTEN |AT91_ST_RSTEN | (((65536 * wdt_time) >>8 ) &AT91_ST_WDV )); -at91_sys_write (AT91_ST_CR ,AT91_ST_WDRST ); +at91_st_write (AT91_ST_CR ,AT91_ST_WDRST ); }/*
@@ -69,7 +69,7 @@ static inline void at91_wdt_start(void)*/ static inline void at91_wdt_reload (void ) { -at91_sys_write (AT91_ST_CR ,AT91_ST_WDRST ); +at91_st_write (AT91_ST_CR ,AT91_ST_WDRST ); }/* ......................................................................... */
Signature · 1 line
1.7.9
Re: [PATCH v2 04/19] ARM: at91: make ST (System Timer) soc independent
Quoted 4 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>
Looks okay to me:
Quoted 272 lines
--- arch/arm/mach-at91/at91rm9200.c | 5 ++- arch/arm/mach-at91/at91rm9200_time.c | 37 ++++++++++++++++---------- arch/arm/mach-at91/generic.h | 1 + arch/arm/mach-at91/include/mach/at91_st.h | 32 +++++++++++++++------- arch/arm/mach-at91/include/mach/at91rm9200.h | 2 +- drivers/watchdog/at91rm9200_wdt.c | 8 +++--- 6 files changed, 54 insertions(+), 31 deletions(-)arch/arm/mach-at91/at91rm9200.c +3
-2@@ -303,8 +303,8 @@ static void at91rm9200_restart(char mode, const char *cmd)/* * Perform a hardware reset with the use of the Watchdog timer. */ -at91_sys_write (AT91_ST_WDMR ,AT91_ST_RSTEN |AT91_ST_EXTEN |1 ); -at91_sys_write (AT91_ST_CR ,AT91_ST_WDRST ); +at91_st_write (AT91_ST_WDMR ,AT91_ST_RSTEN |AT91_ST_EXTEN |1 ); +at91_st_write (AT91_ST_CR ,AT91_ST_WDRST ); }/* -------------------------------------------------------------------- @@ -319,6 +319,7 @@ static void __init at91rm9200_map_io(void)static void __init at91rm9200_ioremap_registers (void ) { +at91rm9200_ioremap_st (AT91RM9200_BASE_ST ); }static void __init at91rm9200_initialize (void )arch/arm/mach-at91/at91rm9200_time.c +23
-14@@ -43,9 +43,9 @@ static inline unsigned long read_CRTR(void) {unsigned long x1, x2; - x1 =at91_sys_read (AT91_ST_CRTR ); + x1 =at91_st_read (AT91_ST_CRTR ); do { - x2 = at91_sys_read(AT91_ST_CRTR); + x2 = at91_st_read(AT91_ST_CRTR); if (x1 == x2) break; x1 = x2;@@ -58,7 +58,7 @@ static inline unsigned long read_CRTR(void)*/ static irqreturn_t at91rm9200_timer_interrupt (int irq,void *dev_id) { -u32 sr =at91_sys_read (AT91_ST_SR ) & irqmask; +u32 sr =at91_st_read (AT91_ST_SR ) & irqmask;/* * irqs should be disabled here, but as the irq is shared they are only @@ -110,22 +110,22 @@ static void clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) {/* Disable and flush pending timer interrupts */ - at91_sys_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); - (void )at91_sys_read (AT91_ST_SR ); + at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); + (void )at91_st_read (AT91_ST_SR ); last_crtr =read_CRTR ();switch (mode) {case CLOCK_EVT_MODE_PERIODIC :/* PIT for periodic irqs; fixed rate of 1/HZ */ irqmask =AT91_ST_PITS ; -at91_sys_write (AT91_ST_PIMR ,RM9200_TIMER_LATCH ); +at91_st_write (AT91_ST_PIMR ,RM9200_TIMER_LATCH );break ;case CLOCK_EVT_MODE_ONESHOT :/* ALM for oneshot irqs, set by next_event() * before 32 seconds have passed */ irqmask =AT91_ST_ALMS ; -at91_sys_write (AT91_ST_RTAR , last_crtr); +at91_st_write (AT91_ST_RTAR , last_crtr);break ;case CLOCK_EVT_MODE_SHUTDOWN :case CLOCK_EVT_MODE_UNUSED :@@ -133,7 +133,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) irqmask =0 ;break ; } -at91_sys_write (AT91_ST_IER , irqmask); +at91_st_write (AT91_ST_IER , irqmask); } static int@@ -156,12 +156,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev) alm =read_CRTR ();/* Cancel any pending alarm; flush any pending IRQ */ -at91_sys_write (AT91_ST_RTAR , alm); - (void )at91_sys_read (AT91_ST_SR ); +at91_st_write (AT91_ST_RTAR , alm); + (void )at91_st_read (AT91_ST_SR );/* Schedule alarm by writing RTAR. */ alm += delta; -at91_sys_write (AT91_ST_RTAR , alm); +at91_st_write (AT91_ST_RTAR , alm);return status; }@@ -175,15 +175,24 @@ static struct clock_event_device clkevt = { .set_mode = clkevt32k_mode, }; +void __iomem *at91_st_base; + +void __init at91rm9200_ioremap_st (u32 addr) +{ + at91_st_base =ioremap (addr,256 ); +if (!at91_st_base) +panic ("Impossible to ioremap ST\n" ); +} +/* * ST (system timer) module supports both clockevents and clocksource. */ void __init at91rm9200_timer_init (void ) {/* Disable all timer interrupts, and clear any pending ones */ -at91_sys_write (AT91_ST_IDR , +at91_st_write (AT91_ST_IDR ,AT91_ST_PITS |AT91_ST_WDOVF |AT91_ST_RTTINC |AT91_ST_ALMS ); - (void )at91_sys_read (AT91_ST_SR ); + (void )at91_st_read (AT91_ST_SR );/* Make IRQs happen for the system timer */ setup_irq (AT91_ID_SYS , &at91rm9200_timer_irq);@@ -192,7 +201,7 @@ void __init at91rm9200_timer_init(void)* directly for the clocksource and all clockevents, after adjusting * its prescaler from the 1 Hz default. */ -at91_sys_write (AT91_ST_RTMR ,1 ); +at91_st_write (AT91_ST_RTMR ,1 );/* Setup timer clockevent, with minimum of two ticks (important!!) */ clkevt.mult =div_sc (AT91_SLOW_CLOCK ,NSEC_PER_SEC , clkevt.shift);arch/arm/mach-at91/generic.h +1
-0@@ -28,6 +28,7 @@ extern void __init at91_aic_init(unsigned int priority[]);/* Timer */ struct sys_timer ; +extern void at91rm9200_ioremap_st (u32 addr);extern struct sys_timer at91rm9200_timer;extern void at91sam926x_ioremap_pit (u32 addr);extern struct sys_timer at91sam926x_timer;arch/arm/mach-at91/include/mach/at91_st.h +22
-10@@ -16,34 +16,46 @@#ifndef AT91_ST_H #define AT91_ST_H -#define AT91_ST_CR (AT91_ST + 0x00)/* Control Register */ +#ifndef __ASSEMBLY__ +extern void __iomem *at91_st_base; + +#define at91_st_read (field) \ + __raw_readl(at91_st_base + field) + +#define at91_st_write (field, value) \ + __raw_writel(value, at91_st_base + field); +#else +.extern at91_st_base +#endif + +#define AT91_ST_CR 0x00/* Control Register */ #define AT91_ST_WDRST (1 << 0)/* Watchdog Timer Restart */ -#define AT91_ST_PIMR (AT91_ST + 0x04)/* Period Interval Mode Register */ +#define AT91_ST_PIMR 0x04/* Period Interval Mode Register */ #define AT91_ST_PIV (0xffff << 0)/* Period Interval Value */ -#define AT91_ST_WDMR (AT91_ST + 0x08)/* Watchdog Mode Register */ +#define AT91_ST_WDMR 0x08/* Watchdog Mode Register */ #define AT91_ST_WDV (0xffff << 0)/* Watchdog Counter Value */ #define AT91_ST_RSTEN (1 << 16)/* Reset Enable */ #define AT91_ST_EXTEN (1 << 17)/* External Signal Assertion Enable */ -#define AT91_ST_RTMR (AT91_ST + 0x0c)/* Real-time Mode Register */ +#define AT91_ST_RTMR 0x0c/* Real-time Mode Register */ #define AT91_ST_RTPRES (0xffff << 0)/* Real-time Prescalar Value */ -#define AT91_ST_SR (AT91_ST + 0x10)/* Status Register */ +#define AT91_ST_SR 0x10/* Status Register */ #define AT91_ST_PITS (1 << 0)/* Period Interval Timer Status */ #define AT91_ST_WDOVF (1 << 1)/* Watchdog Overflow */ #define AT91_ST_RTTINC (1 << 2)/* Real-time Timer Increment */ #define AT91_ST_ALMS (1 << 3)/* Alarm Status */ -#define AT91_ST_IER (AT91_ST + 0x14)/* Interrupt Enable Register */ -#define AT91_ST_IDR (AT91_ST + 0x18)/* Interrupt Disable Register */ -#define AT91_ST_IMR (AT91_ST + 0x1c)/* Interrupt Mask Register */ +#define AT91_ST_IER 0x14/* Interrupt Enable Register */ +#define AT91_ST_IDR 0x18/* Interrupt Disable Register */ +#define AT91_ST_IMR 0x1c/* Interrupt Mask Register */ -#define AT91_ST_RTAR (AT91_ST + 0x20)/* Real-time Alarm Register */ +#define AT91_ST_RTAR 0x20/* Real-time Alarm Register */ #define AT91_ST_ALMV (0xfffff << 0)/* Alarm Value */ -#define AT91_ST_CRTR (AT91_ST + 0x24)/* Current Real-time Register */ +#define AT91_ST_CRTR 0x24/* Current Real-time Register */ #define AT91_ST_CRTV (0xfffff << 0)/* Current Real-Time Value */ #endif arch/arm/mach-at91/include/mach/at91rm9200.h +1
-1@@ -80,7 +80,6 @@* System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)/* Power Management Controller */ -#define AT91_ST (0xfffffd00 - AT91_BASE_SYS)/* System Timer */ #define AT91_MC (0xffffff00 - AT91_BASE_SYS)/* Memory Controllers */ #define AT91RM9200_BASE_DBGU AT91_BASE_DBGU0/* Debug Unit */ @@ -88,6 +87,7 @@#define AT91RM9200_BASE_PIOB 0xfffff600/* PIO Controller B */ #define AT91RM9200_BASE_PIOC 0xfffff800/* PIO Controller C */ #define AT91RM9200_BASE_PIOD 0xfffffa00/* PIO Controller D */ +#define AT91RM9200_BASE_ST 0xfffffd00/* System Timer */ #define AT91RM9200_BASE_RTC 0xfffffe00/* Real-Time Clock */ #define AT91_USART0 AT91RM9200_BASE_US0drivers/watchdog/at91rm9200_wdt.c +4
-4@@ -51,7 +51,7 @@ static unsigned long at91wdt_busy;*/ static inline void at91_wdt_stop (void ) { -at91_sys_write (AT91_ST_WDMR ,AT91_ST_EXTEN ); +at91_st_write (AT91_ST_WDMR ,AT91_ST_EXTEN ); }/* @@ -59,9 +59,9 @@ static inline void at91_wdt_stop(void)*/ static inline void at91_wdt_start (void ) { -at91_sys_write (AT91_ST_WDMR ,AT91_ST_EXTEN |AT91_ST_RSTEN | +at91_st_write (AT91_ST_WDMR ,AT91_ST_EXTEN |AT91_ST_RSTEN | (((65536 * wdt_time) >>8 ) &AT91_ST_WDV )); -at91_sys_write (AT91_ST_CR ,AT91_ST_WDRST ); +at91_st_write (AT91_ST_CR ,AT91_ST_WDRST ); }/* @@ -69,7 +69,7 @@ static inline void at91_wdt_start(void)*/ static inline void at91_wdt_reload (void ) { -at91_sys_write (AT91_ST_CR ,AT91_ST_WDRST ); +at91_st_write (AT91_ST_CR ,AT91_ST_WDRST ); }/* ......................................................................... */
PATCH v2 5/19 ARM: at91/ST: remove not needed casts
In reply to Nicolas FerreRemove the unnecessary (void) cast on at91_st_read() return value.
--- arch/arm/mach-at91/at91rm9200_time.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-at91/at91rm9200_time.c +3 -3
@@ -111,7 +111,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) {/* Disable and flush pending timer interrupts */ at91_st_write (AT91_ST_IDR ,AT91_ST_PITS |AT91_ST_ALMS ); - (void )at91_st_read (AT91_ST_SR ); +at91_st_read (AT91_ST_SR ); last_crtr =read_CRTR ();switch (mode) {
@@ -157,7 +157,7 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)/* Cancel any pending alarm; flush any pending IRQ */ at91_st_write (AT91_ST_RTAR , alm); - (void )at91_st_read (AT91_ST_SR ); +at91_st_read (AT91_ST_SR );/* Schedule alarm by writing RTAR. */ alm += delta;
@@ -192,7 +192,7 @@ void __init at91rm9200_timer_init(void)/* Disable all timer interrupts, and clear any pending ones */ at91_st_write (AT91_ST_IDR ,AT91_ST_PITS |AT91_ST_WDOVF |AT91_ST_RTTINC |AT91_ST_ALMS ); - (void )at91_st_read (AT91_ST_SR ); +at91_st_read (AT91_ST_SR );/* Make IRQs happen for the system timer */ setup_irq (AT91_ID_SYS , &at91rm9200_timer_irq);
Signature · 1 line
1.7.9
Re: [PATCH v2 05/19] ARM: at91/ST: remove not needed casts
Quoted 4 lines · Nicolas Ferre
Remove the unnecessary (void) cast on
at91_st_read()return value.Signed-off-by Nicolas Ferre <[email protected]>
Thanks Nicolas.
Quoted 35 lines
--- arch/arm/mach-at91/at91rm9200_time.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)arch/arm/mach-at91/at91rm9200_time.c +3
-3@@ -111,7 +111,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) {/* Disable and flush pending timer interrupts */ at91_st_write (AT91_ST_IDR ,AT91_ST_PITS |AT91_ST_ALMS ); - (void )at91_st_read (AT91_ST_SR ); +at91_st_read (AT91_ST_SR ); last_crtr =read_CRTR ();switch (mode) {@@ -157,7 +157,7 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)/* Cancel any pending alarm; flush any pending IRQ */ at91_st_write (AT91_ST_RTAR , alm); - (void )at91_st_read (AT91_ST_SR ); +at91_st_read (AT91_ST_SR );/* Schedule alarm by writing RTAR. */ alm += delta;@@ -192,7 +192,7 @@ void __init at91rm9200_timer_init(void)/* Disable all timer interrupts, and clear any pending ones */ at91_st_write (AT91_ST_IDR ,AT91_ST_PITS |AT91_ST_WDOVF |AT91_ST_RTTINC |AT91_ST_ALMS ); - (void )at91_st_read (AT91_ST_SR ); +at91_st_read (AT91_ST_SR );/* Make IRQs happen for the system timer */ setup_irq (AT91_ID_SYS , &at91rm9200_timer_irq);
PATCH v2 6/19 ARM: at91/pm_slowclock: rename register to named define
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This patch will give a name to ARM registers in the assembly source code (using #defines). It is done to simplify the code reading and the passing of parameters to functions.
--- arch/arm/mach-at91/pm_slowclock.S | 177 +++++++++++++++++++------------------ 1 files changed, 91 insertions(+), 86 deletions(-)
arch/arm/mach-at91/pm_slowclock.S +91 -86
@@ -46,17 +46,22 @@ #define PLLALOCK_TIMEOUT 1000 #define PLLBLOCK_TIMEOUT 1000 +#define pmc r1 +#define sdramc r2 +#define tmp1 r3 +#define tmp2 r4 +#define ramc1 r5 /* * Wait until master clock is ready (after switching master clock source) */ .macro wait_mckrdy - mov r4, #MCKRDY_TIMEOUT -1: sub r4, r4, #1 - cmp r4, #0 + mov tmp2, #MCKRDY_TIMEOUT +1: sub tmp2, tmp2, #1 + cmp tmp2, #0 beq 2f - ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] - tst r3, #AT91_PMC_MCKRDY + ldr tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)] + tst tmp1, #AT91_PMC_MCKRDY beq 1b 2: .endm
@@ -65,12 +70,12 @@ * Wait until master oscillator has stabilized. */ .macro wait_moscrdy - mov r4, #MOSCRDY_TIMEOUT -1: sub r4, r4, #1 - cmp r4, #0 + mov tmp2, #MOSCRDY_TIMEOUT +1: sub tmp2, tmp2, #1 + cmp tmp2, #0 beq 2f - ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] - tst r3, #AT91_PMC_MOSCS + ldr tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)] + tst tmp1, #AT91_PMC_MOSCS beq 1b 2: .endm
@@ -79,12 +84,12 @@ * Wait until PLLA has locked. */ .macro wait_pllalock - mov r4, #PLLALOCK_TIMEOUT -1: sub r4, r4, #1 - cmp r4, #0 + mov tmp2, #PLLALOCK_TIMEOUT +1: sub tmp2, tmp2, #1 + cmp tmp2, #0 beq 2f - ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] - tst r3, #AT91_PMC_LOCKA + ldr tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)] + tst tmp1, #AT91_PMC_LOCKA beq 1b 2: .endm
@@ -93,12 +98,12 @@ * Wait until PLLB has locked. */ .macro wait_pllblock - mov r4, #PLLBLOCK_TIMEOUT -1: sub r4, r4, #1 - cmp r4, #0 + mov tmp2, #PLLBLOCK_TIMEOUT +1: sub tmp2, tmp2, #1 + cmp tmp2, #0 beq 2f - ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] - tst r3, #AT91_PMC_LOCKB + ldr tmp1, [pmc, #(AT91_PMC_SR - AT91_PMC)] + tst tmp1, #AT91_PMC_LOCKB beq 1b 2: .endm
@@ -117,55 +122,55 @@ ENTRY(at91_slow_clock) * R4 = temporary register * R5 = Base address of second RAM Controller or 0 if not present */ - ldr r1, .at91_va_base_pmc - ldr r2, .at91_va_base_sdramc - ldr r5, .at91_va_base_ramc1 + ldr pmc, .at91_va_base_pmc + ldr sdramc, .at91_va_base_sdramc + ldr ramc1, .at91_va_base_ramc1 /* Drain write buffer */ - mov r0, #0 - mcr p15, 0, r0, c7, c10, 4 + mov tmp1, #0 + mcr p15, 0, tmp1, c7, c10, 4 #ifdef CONFIG_ARCH_AT91RM9200 /* Put SDRAM in self-refresh mode */ - mov r3, #1 - str r3, [r2, #AT91_SDRAMC_SRR] + mov tmp1, #1 + str tmp1, [sdramc, #AT91_SDRAMC_SRR] #elif defined(CONFIG_ARCH_AT91SAM9G45) /* prepare for DDRAM self-refresh mode */ - ldr r3, [r2, #AT91_DDRSDRC_LPR] - str r3, .saved_sam9_lpr - bic r3, #AT91_DDRSDRC_LPCB - orr r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH + ldr tmp1, [sdramc, #AT91_DDRSDRC_LPR] + str tmp1, .saved_sam9_lpr + bic tmp1, #AT91_DDRSDRC_LPCB + orr tmp1, #AT91_DDRSDRC_LPCB_SELF_REFRESH /* figure out if we use the second ram controller */ - cmp r5, #0 - ldrne r4, [r5, #AT91_DDRSDRC_LPR] - strne r4, .saved_sam9_lpr1 - bicne r4, #AT91_DDRSDRC_LPCB - orrne r4, #AT91_DDRSDRC_LPCB_SELF_REFRESH + cmp ramc1, #0 + ldrne tmp2, [ramc1, #AT91_DDRSDRC_LPR] + strne tmp2, .saved_sam9_lpr1 + bicne tmp2, #AT91_DDRSDRC_LPCB + orrne tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH /* Enable DDRAM self-refresh mode */ - str r3, [r2, #AT91_DDRSDRC_LPR] - strne r4, [r5, #AT91_DDRSDRC_LPR] + str tmp1, [sdramc, #AT91_DDRSDRC_LPR] + strne tmp2, [ramc1, #AT91_DDRSDRC_LPR] #else /* Enable SDRAM self-refresh mode */ - ldr r3, [r2, #AT91_SDRAMC_LPR] - str r3, .saved_sam9_lpr + ldr tmp1, [sdramc, #AT91_SDRAMC_LPR] + str tmp1, .saved_sam9_lpr - bic r3, #AT91_SDRAMC_LPCB - orr r3, #AT91_SDRAMC_LPCB_SELF_REFRESH - str r3, [r2, #AT91_SDRAMC_LPR] + bic tmp1, #AT91_SDRAMC_LPCB + orr tmp1, #AT91_SDRAMC_LPCB_SELF_REFRESH + str tmp1, [sdramc, #AT91_SDRAMC_LPR] #endif /* Save Master clock setting */ - ldr r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] - str r3, .saved_mckr + ldr tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)] + str tmp1, .saved_mckr /* * Set the Master clock source to slow clock */ - bic r3, r3, #AT91_PMC_CSS - str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] + bic tmp1, tmp1, #AT91_PMC_CSS + str tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)] wait_mckrdy
@@ -175,61 +180,61 @@ ENTRY(at91_slow_clock) * * See AT91RM9200 errata #27 and #28 for details. */ - mov r3, #0 - str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] + mov tmp1, #0 + str tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)] wait_mckrdy #endif /* Save PLLA setting and disable it */ - ldr r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] - str r3, .saved_pllar + ldr tmp1, [pmc, #(AT91_CKGR_PLLAR - AT91_PMC)] + str tmp1, .saved_pllar - mov r3, #AT91_PMC_PLLCOUNT - orr r3, r3, #(1 << 29) /* bit 29 always set */ - str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] + mov tmp1, #AT91_PMC_PLLCOUNT + orr tmp1, tmp1, #(1 << 29) /* bit 29 always set */ + str tmp1, [pmc, #(AT91_CKGR_PLLAR - AT91_PMC)] /* Save PLLB setting and disable it */ - ldr r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] - str r3, .saved_pllbr + ldr tmp1, [pmc, #(AT91_CKGR_PLLBR - AT91_PMC)] + str tmp1, .saved_pllbr - mov r3, #AT91_PMC_PLLCOUNT - str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] + mov tmp1, #AT91_PMC_PLLCOUNT + str tmp1, [pmc, #(AT91_CKGR_PLLBR - AT91_PMC)] /* Turn off the main oscillator */ - ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] - bic r3, r3, #AT91_PMC_MOSCEN - str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] + ldr tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)] + bic tmp1, tmp1, #AT91_PMC_MOSCEN + str tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)] /* Wait for interrupt */ - mcr p15, 0, r0, c7, c0, 4 + mcr p15, 0, tmp1, c7, c0, 4 /* Turn on the main oscillator */ - ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] - orr r3, r3, #AT91_PMC_MOSCEN - str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] + ldr tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)] + orr tmp1, tmp1, #AT91_PMC_MOSCEN + str tmp1, [pmc, #(AT91_CKGR_MOR - AT91_PMC)] wait_moscrdy /* Restore PLLB setting */ - ldr r3, .saved_pllbr - str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] + ldr tmp1, .saved_pllbr + str tmp1, [pmc, #(AT91_CKGR_PLLBR - AT91_PMC)] - tst r3, #(AT91_PMC_MUL & 0xff0000) + tst tmp1, #(AT91_PMC_MUL & 0xff0000) bne 1f - tst r3, #(AT91_PMC_MUL & ~0xff0000) + tst tmp1, #(AT91_PMC_MUL & ~0xff0000) beq 2f 1: wait_pllblock 2: /* Restore PLLA setting */ - ldr r3, .saved_pllar - str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] + ldr tmp1, .saved_pllar + str tmp1, [pmc, #(AT91_CKGR_PLLAR - AT91_PMC)] - tst r3, #(AT91_PMC_MUL & 0xff0000) + tst tmp1, #(AT91_PMC_MUL & 0xff0000) bne 3f - tst r3, #(AT91_PMC_MUL & ~0xff0000) + tst tmp1, #(AT91_PMC_MUL & ~0xff0000) beq 4f 3: wait_pllalock
@@ -242,11 +247,11 @@ ENTRY(at91_slow_clock) * * See AT91RM9200 errata #27 and #28 for details. */ - ldr r3, .saved_mckr - tst r3, #AT91_PMC_PRES + ldr tmp1, .saved_mckr + tst tmp1, #AT91_PMC_PRES beq 2f - and r3, r3, #AT91_PMC_PRES - str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] + and tmp1, tmp1, #AT91_PMC_PRES + str tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)] wait_mckrdy #endif
@@ -254,8 +259,8 @@ ENTRY(at91_slow_clock) /* * Restore master clock setting */ -2: ldr r3, .saved_mckr - str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] +2: ldr tmp1, .saved_mckr + str tmp1, [pmc, #(AT91_PMC_MCKR - AT91_PMC)] wait_mckrdy
@@ -263,18 +268,18 @@ ENTRY(at91_slow_clock) /* Do nothing - self-refresh is automatically disabled. */ #elif defined(CONFIG_ARCH_AT91SAM9G45) /* Restore LPR on AT91 with DDRAM */ - ldr r3, .saved_sam9_lpr - str r3, [r2, #AT91_DDRSDRC_LPR] + ldr tmp1, .saved_sam9_lpr + str tmp1, [sdramc, #AT91_DDRSDRC_LPR] /* if we use the second ram controller */ - cmp r5, #0 - ldrne r4, .saved_sam9_lpr1 - strne r4, [r5, #AT91_DDRSDRC_LPR] + cmp ramc1, #0 + ldrne tmp2, .saved_sam9_lpr1 + strne tmp2, [ramc1, #AT91_DDRSDRC_LPR] #else /* Restore LPR on AT91 with SDRAM */ - ldr r3, .saved_sam9_lpr - str r3, [r2, #AT91_SDRAMC_LPR] + ldr tmp1, .saved_sam9_lpr + str tmp1, [sdramc, #AT91_SDRAMC_LPR] #endif /* Restore registers, and return */
Signature · 1 line
1.7.9
Re: [PATCH v2 06/19] ARM: at91/pm_slowclock: rename register to named define
Quoted 4 lines · Nicolas Ferre
#define
PLLALOCK_TIMEOUT1000
#definePLLBLOCK_TIMEOUT1000+#define pmc r1
pmc .req r1
sdramc .req r2
etc.
Re: [PATCH v2 06/19] ARM: at91/pm_slowclock: rename register to named define
Quoted 10 lines · Russell King - ARM Linux
Quoted 4 lines · Nicolas Ferre
#define
PLLALOCK_TIMEOUT1000
#definePLLBLOCK_TIMEOUT1000+#define pmc r1
pmc .req r1
sdramc .req r2etc.
done
update
[PATCH v3 07/20] ARM: at91/pm_slowclock: function slow_clock() accepts parameters [PATCH v3 06/20] ARM: at91/pm_slowclock: rename register to named define [PATCH v3 10/20] ARM: at91/pm_slowclock: add runtime detection of memory contoller
we will see if we need to resend the full series
Best Regards,
J.
PATCH v2 7/19 ARM: at91/pm_slowclock: function slow_clock() accepts parameters
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Change slow_clock()/at91_slow_clock() prototype to accept the PMC base address and one or two RAM controller addresses by parameters. The r0, r1 and r2 registers are used differently and preserved during function call.
Those values are defined in pm.c and slow_clock() function is called from there with its new parameters.
This will allow to have a soc independent pm_slowclock.
--- arch/arm/mach-at91/pm.c | 20 +++++++++++++++-- arch/arm/mach-at91/pm_slowclock.S | 41 ++++++++---------------------------- 2 files changed, 26 insertions(+), 35 deletions(-)
arch/arm/mach-at91/pm.c +17 -3
@@ -188,13 +188,27 @@ int at91_suspend_entering_slow_clock(void)EXPORT_SYMBOL (at91_suspend_entering_slow_clock); -static void (*slow_clock)(void ); +static void (*slow_clock)(void __iomem *pmc,void __iomem *ramc0,void __iomem *ramc1);#ifdef CONFIG_AT91_SLOW_CLOCK -extern void at91_slow_clock (void ); +extern void at91_slow_clock (void __iomem *pmc,void __iomem *ramc0,void __iomem *ramc1);extern u32 at91_slow_clock_sz;#endif +static void __iomem *at91_pmc_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_PMC ); +#ifdef CONFIG_ARCH_AT91RM9200 +static void __iomem *at91_ramc0_base = (void __iomem *)AT91_VA_BASE_SYS ; +#elif defined(CONFIG_ARCH_AT91SAM9G45 ) +static void __iomem *at91_ramc0_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_DDRSDRC0 ); +#else +static void __iomem *at91_ramc0_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_SDRAMC0 ); +#endif + +#if defined(CONFIG_ARCH_AT91SAM9G45 ) +static void __iomem *at91_ramc1_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_DDRSDRC1 ); +#else +static void __iomem *at91_ramc1_base =NULL ; +#endif static int at91_pm_enter (suspend_state_t state) {
@@ -232,7 +246,7 @@ static int at91_pm_enter(suspend_state_t state)/* copy slow_clock handler to SRAM, and call it */ memcpy (slow_clock, at91_slow_clock, at91_slow_clock_sz);#endif -slow_clock (); +slow_clock (at91_pmc_base, at91_ramc0_base, at91_ramc1_base);break ; }else {pr_info ("AT91: PM - no slow clock mode enabled ...\n" );
arch/arm/mach-at91/pm_slowclock.S +9 -32
74 lines not on this page · raw message
Signature · 1 line
1.7.9
Re: [PATCH v2 07/19] ARM: at91/pm_slowclock: function slow_clock() accepts parameters
arch/arm/mach-at91/pm.c static int at91_pm_enter(suspend_state_t state) · line 249
Quoted 6 lines · Nicolas Ferre
arch/arm/mach-at91/pm.c +1
-1@@ -232,7 +246,7 @@ static int at91_pm_enter(suspend_state_t state)/* copy slow_clock handler to SRAM, and call it */ memcpy (slow_clock, at91_slow_clock, at91_slow_clock_sz);#endif -slow_clock (); +slow_clock (at91_pmc_base, at91_ramc0_base, at91_ramc1_base);
This should be updated to use the fncpy() stuff if there's any chance that you'll be supporting Thumb-2. Using fncpy() is probably a good idea even if you aren't. See asm/fncpy.h
Re: [PATCH v2 07/19] ARM: at91/pm_slowclock: function slow_clock() accepts parameters
Quoted 11 lines · Russell King - ARM Linux
arch/arm/mach-at91/pm.c static int at91_pm_enter(suspend_state_t state) · line 249
Quoted 6 lines · Nicolas Ferre
arch/arm/mach-at91/pm.c +1
-1@@ -232,7 +246,7 @@ static int at91_pm_enter(suspend_state_t state)/* copy slow_clock handler to SRAM, and call it */ memcpy (slow_clock, at91_slow_clock, at91_slow_clock_sz);#endif -slow_clock (); +slow_clock (at91_pmc_base, at91_ramc0_base, at91_ramc1_base);This should be updated to use the
fncpy()stuff if there's any chance that you'll be supporting Thumb-2. Usingfncpy()is probably a good idea even if you aren't. Seeasm/fncpy.h
Yes I agree and I plan to do it
but I'm work first on the update of the genalloc api to use it here to allocate the address in sram
If it's ok with you I'll do it after
Btw I'm looking on a way to switch the assembly funciton to C but I didn,t find a good way to calculate the function size except by touching at the linker script. Which I don;t want to do.
Do you have any idea?
Best Regards,
J.
Re: [PATCH v2 07/19] ARM: at91/pm_slowclock: function slow_clock() accepts parameters
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
Btw I'm looking on a way to switch the assembly funciton to C but I didn,t find a good way to calculate the function size except by touching at the linker script. Which I don;t want to do.
Forget doing it in C. C is too complicated, because either you have to keep its relocations and fix them up, or you have to compile and link it to run at a specific location and then copy it to that location. You also have literal pools to think about.
Assembly is much better controlled and you can write it so that you don't end up with any of that stuff. You have absolute control over the code and associated data.
Re: [PATCH v2 07/19] ARM: at91/pm_slowclock: function slow_clock() accepts parameters
Quoted 5 lines · Russell King - ARM Linux
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
Btw I'm looking on a way to switch the assembly funciton to C but I didn,t find a good way to calculate the function size except by touching at the linker script. Which I don;t want to do.
Quoted 8 lines
Forget doing it in C. C is too complicated, because either you have to keep its relocations and fix them up, or you have to compile and link it to run at a specific location and then copy it to that location. You also have literal pools to think about.
Assembly is much better controlled and you can write it so that you don't end up with any of that stuff. You have absolute control over the code and associated data.
ok
Best Regards,
J.
PATCH v2 8/19 ARM: at91: move at91rm9200 sdramc defines to at91rm9200_sdramc.h
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This cleanup is done to allow to have multiple SoC in the same image.
--- arch/arm/mach-at91/include/mach/at91rm9200_mc.h | 44 -------------- .../arm/mach-at91/include/mach/at91rm9200_sdramc.h | 63 ++++++++++++++++++++ arch/arm/mach-at91/pm.c | 2 +- arch/arm/mach-at91/pm.h | 7 +- arch/arm/mach-at91/pm_slowclock.S | 3 +- 5 files changed, 70 insertions(+), 49 deletions(-) create mode 100644 arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
arch/arm/mach-at91/include/mach/at91rm9200_mc.h +0 -44
@@ -87,50 +87,6 @@#define AT91_SMC_RWHOLD (7 << 28)/* Read & Write Signal Hold Time */ #define AT91_SMC_RWHOLD_ (x) ((x) << 28) -/* SDRAM Controller registers */ -#define AT91_SDRAMC_MR (AT91_MC + 0x90)/* Mode Register */ -#define AT91_SDRAMC_MODE (0xf << 0)/* Command Mode */ -#define AT91_SDRAMC_MODE_NORMAL (0 << 0) -#define AT91_SDRAMC_MODE_NOP (1 << 0) -#define AT91_SDRAMC_MODE_PRECHARGE (2 << 0) -#define AT91_SDRAMC_MODE_LMR (3 << 0) -#define AT91_SDRAMC_MODE_REFRESH (4 << 0) -#define AT91_SDRAMC_DBW (1 << 4)/* Data Bus Width */ -#define AT91_SDRAMC_DBW_32 (0 << 4) -#define AT91_SDRAMC_DBW_16 (1 << 4) - -#define AT91_SDRAMC_TR (AT91_MC + 0x94)/* Refresh Timer Register */ -#define AT91_SDRAMC_COUNT (0xfff << 0)/* Refresh Timer Count */ - -#define AT91_SDRAMC_CR (AT91_MC + 0x98)/* Configuration Register */ -#define AT91_SDRAMC_NC (3 << 0)/* Number of Column Bits */ -#define AT91_SDRAMC_NC_8 (0 << 0) -#define AT91_SDRAMC_NC_9 (1 << 0) -#define AT91_SDRAMC_NC_10 (2 << 0) -#define AT91_SDRAMC_NC_11 (3 << 0) -#define AT91_SDRAMC_NR (3 << 2)/* Number of Row Bits */ -#define AT91_SDRAMC_NR_11 (0 << 2) -#define AT91_SDRAMC_NR_12 (1 << 2) -#define AT91_SDRAMC_NR_13 (2 << 2) -#define AT91_SDRAMC_NB (1 << 4)/* Number of Banks */ -#define AT91_SDRAMC_NB_2 (0 << 4) -#define AT91_SDRAMC_NB_4 (1 << 4) -#define AT91_SDRAMC_CAS (3 << 5)/* CAS Latency */ -#define AT91_SDRAMC_CAS_2 (2 << 5) -#define AT91_SDRAMC_TWR (0xf << 7)/* Write Recovery Delay */ -#define AT91_SDRAMC_TRC (0xf << 11)/* Row Cycle Delay */ -#define AT91_SDRAMC_TRP (0xf << 15)/* Row Precharge Delay */ -#define AT91_SDRAMC_TRCD (0xf << 19)/* Row to Column Delay */ -#define AT91_SDRAMC_TRAS (0xf << 23)/* Active to Precharge Delay */ -#define AT91_SDRAMC_TXSR (0xf << 27)/* Exit Self Refresh to Active Delay */ - -#define AT91_SDRAMC_SRR (AT91_MC + 0x9c)/* Self Refresh Register */ -#define AT91_SDRAMC_LPR (AT91_MC + 0xa0)/* Low Power Register */ -#define AT91_SDRAMC_IER (AT91_MC + 0xa4)/* Interrupt Enable Register */ -#define AT91_SDRAMC_IDR (AT91_MC + 0xa8)/* Interrupt Disable Register */ -#define AT91_SDRAMC_IMR (AT91_MC + 0xac)/* Interrupt Mask Register */ -#define AT91_SDRAMC_ISR (AT91_MC + 0xb0)/* Interrupt Status Register */ -/* Burst Flash Controller register */ #define AT91_BFC_MR (AT91_MC + 0xc0)/* Mode Register */ #define AT91_BFC_BFCOM (3 << 0)/* Burst Flash Controller Operating Mode */
arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h new file +63 -0
63 lines not on this page · raw message
arch/arm/mach-at91/pm.c +1 -1
@@ -315,7 +315,7 @@ static int __init at91_pm_init(void)#ifdef CONFIG_ARCH_AT91RM9200 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ -at91_sys_write (AT91_SDRAMC_LPR ,0 ); +at91_sys_write (AT91RM9200_SDRAMC_LPR ,0 );#endif suspend_set_ops (&at91_pm_ops);
arch/arm/mach-at91/pm.h +4 -3
@@ -13,6 +13,7 @@#ifdef CONFIG_ARCH_AT91RM9200 #include <mach/at91rm9200_mc.h> +#include <mach/at91rm9200_sdramc.h> /* * The AT91RM9200 goes into self-refresh mode with this command, and will
@@ -26,7 +27,7 @@static inline void at91rm9200_standby (void ) { -u32 lpr =at91_sys_read (AT91_SDRAMC_LPR ); +u32 lpr =at91_sys_read (AT91RM9200_SDRAMC_LPR ); asmvolatile ( "b 1f\n\t"
@@ -37,8 +38,8 @@ static inline void at91rm9200_standby(void) " mcr p15, 0, %0, c7, c0, 4\n\t" " str %5, [%1, %2]" : - : "r" (0), "r" (AT91_BASE_SYS), "r" (AT91_SDRAMC_LPR), -"r" (1 ),"r" (AT91_SDRAMC_SRR ), + : "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR), +"r" (1 ),"r" (AT91RM9200_SDRAMC_SRR ), "r" (lpr)); }
arch/arm/mach-at91/pm_slowclock.S +2 -1
@@ -18,6 +18,7 @@ #if defined(CONFIG_ARCH_AT91RM9200) #include <mach/at91rm9200_mc.h> +#include <mach/at91rm9200_sdramc.h> #elif defined(CONFIG_ARCH_AT91SAM9G45) #include <mach/at91sam9_ddrsdr.h> #else
@@ -131,7 +132,7 @@ ENTRY(at91_slow_clock) #ifdef CONFIG_ARCH_AT91RM9200 /* Put SDRAM in self-refresh mode */ mov tmp1, #1 - str tmp1, [sdramc, #AT91_SDRAMC_SRR] + str tmp1, [sdramc, #AT91RM9200_SDRAMC_SRR] #elif defined(CONFIG_ARCH_AT91SAM9G45) /* prepare for DDRAM self-refresh mode */
Signature · 1 line
1.7.9
PATCH v2 9/19 ARM: at91: make sdram/ddr register base soc independent
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
--- arch/arm/mach-at91/at91rm9200.c | 1 + arch/arm/mach-at91/at91rm9200_devices.c | 13 ++++---- arch/arm/mach-at91/at91sam9260.c | 1 + arch/arm/mach-at91/at91sam9261.c | 1 + arch/arm/mach-at91/at91sam9263.c | 2 + arch/arm/mach-at91/at91sam9_alt_reset.S | 12 +++---- arch/arm/mach-at91/at91sam9g45.c | 2 + arch/arm/mach-at91/at91sam9g45_reset.S | 12 +++---- arch/arm/mach-at91/at91sam9rl.c | 1 + arch/arm/mach-at91/at91sam9x5.c | 1 + arch/arm/mach-at91/board-cpuat91.c | 1 + arch/arm/mach-at91/board-eco920.c | 5 ++- arch/arm/mach-at91/board-kb9202.c | 1 + arch/arm/mach-at91/board-picotux200.c | 1 + arch/arm/mach-at91/board-rm9200dk.c | 1 + arch/arm/mach-at91/board-rm9200ek.c | 1 + arch/arm/mach-at91/board-yl-9200.c | 3 +- arch/arm/mach-at91/generic.h | 3 ++ arch/arm/mach-at91/include/mach/at91_ramc.h | 31 ++++++++++++++++++++ arch/arm/mach-at91/include/mach/at91rm9200.h | 2 +- arch/arm/mach-at91/include/mach/at91rm9200_mc.h | 14 ++++---- .../arm/mach-at91/include/mach/at91rm9200_sdramc.h | 18 ++++++------ arch/arm/mach-at91/include/mach/at91sam9260.h | 2 +- arch/arm/mach-at91/include/mach/at91sam9261.h | 2 +- arch/arm/mach-at91/include/mach/at91sam9263.h | 4 +- arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h | 6 ---- arch/arm/mach-at91/include/mach/at91sam9_sdramc.h | 6 ---- arch/arm/mach-at91/include/mach/at91sam9g45.h | 4 +- arch/arm/mach-at91/include/mach/at91sam9rl.h | 2 +- arch/arm/mach-at91/include/mach/at91sam9x5.h | 2 +- arch/arm/mach-at91/pm.c | 27 ++++++++--------- arch/arm/mach-at91/pm.h | 6 +-- arch/arm/mach-at91/pm_slowclock.S | 10 +------ drivers/pcmcia/at91_cf.c | 5 ++- 34 files changed, 114 insertions(+), 89 deletions(-) create mode 100644 arch/arm/mach-at91/include/mach/at91_ramc.h
arch/arm/mach-at91/at91rm9200.c +1 -0
@@ -320,6 +320,7 @@ static void __init at91rm9200_map_io(void)static void __init at91rm9200_ioremap_registers (void ) {at91rm9200_ioremap_st (AT91RM9200_BASE_ST ); +at91_ioremap_ramc (0 ,AT91RM9200_BASE_MC ,256 ); }static void __init at91rm9200_initialize (void )
arch/arm/mach-at91/at91rm9200_devices.c +7 -6
@@ -21,6 +21,7 @@#include <mach/board.h> #include <mach/at91rm9200.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include "generic.h"
@@ -241,15 +242,15 @@ void __init at91_add_device_cf(struct at91_cf_data *data) data->chipselect =4 ;/* can only use EBI ChipSelect 4 */ /* CF takes over CS4, CS5, CS6 */ - csa =at91_sys_read (AT91_EBI_CSA ); -at91_sys_write (AT91_EBI_CSA , csa |AT91_EBI_CS4A_SMC_COMPACTFLASH ); + csa =at91_ramc_read (0 ,AT91_EBI_CSA ); +at91_ramc_write (0 ,AT91_EBI_CSA , csa |AT91_EBI_CS4A_SMC_COMPACTFLASH );/* * Static memory controller timing adjustments. * REVISIT: these timings are in terms of MCK cycles, so * when MCK changes (cpufreq etc) so must these values... */ -at91_sys_write (AT91_SMC_CSR (4 ), +at91_ramc_write (0 ,AT91_SMC_CSR (4 ),AT91_SMC_ACSS_STD |AT91_SMC_DBW_16 | AT91_SMC_BAT
@@ -407,11 +408,11 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)return ;/* enable the address range of CS3 */ - csa =at91_sys_read (AT91_EBI_CSA ); -at91_sys_write (AT91_EBI_CSA , csa |AT91_EBI_CS3A_SMC_SMARTMEDIA ); + csa =at91_ramc_read (0 ,AT91_EBI_CSA ); +at91_ramc_write (0 ,AT91_EBI_CSA , csa |AT91_EBI_CS3A_SMC_SMARTMEDIA );/* set the bus interface characteristics */ -at91_sys_write (AT91_SMC_CSR (3 ),AT91_SMC_ACSS_STD |AT91_SMC_DBW_8 |AT91_SMC_WSEN +at91_ramc_write (0 ,AT91_SMC_CSR (3 ),AT91_SMC_ACSS_STD |AT91_SMC_DBW_8 |AT91_SMC_WSEN |AT91_SMC_NWS_ (5 ) |AT91_SMC_TDF_ (1 ) | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
arch/arm/mach-at91/at91sam9260.c +1 -0
@@ -325,6 +325,7 @@ static void __init at91sam9260_ioremap_registers(void) {at91_ioremap_shdwc (AT91SAM9260_BASE_SHDWC );at91_ioremap_rstc (AT91SAM9260_BASE_RSTC ); +at91_ioremap_ramc (0 ,AT91SAM9260_BASE_SDRAMC ,512 );at91sam926x_ioremap_pit (AT91SAM9260_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9260_BASE_SMC );at91_ioremap_matrix (AT91SAM9260_BASE_MATRIX );
arch/arm/mach-at91/at91sam9261.c +1 -0
@@ -283,6 +283,7 @@ static void __init at91sam9261_ioremap_registers(void) {at91_ioremap_shdwc (AT91SAM9261_BASE_SHDWC );at91_ioremap_rstc (AT91SAM9261_BASE_RSTC ); +at91_ioremap_ramc (0 ,AT91SAM9261_BASE_SDRAMC ,512 );at91sam926x_ioremap_pit (AT91SAM9261_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9261_BASE_SMC );at91_ioremap_matrix (AT91SAM9261_BASE_MATRIX );
arch/arm/mach-at91/at91sam9263.c +2 -0
@@ -303,6 +303,8 @@ static void __init at91sam9263_ioremap_registers(void) {at91_ioremap_shdwc (AT91SAM9263_BASE_SHDWC );at91_ioremap_rstc (AT91SAM9263_BASE_RSTC ); +at91_ioremap_ramc (0 ,AT91SAM9263_BASE_SDRAMC0 ,512 ); +at91_ioremap_ramc (1 ,AT91SAM9263_BASE_SDRAMC1 ,512 );at91sam926x_ioremap_pit (AT91SAM9263_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9263_BASE_SMC0 );at91sam9_ioremap_smc (1 ,AT91SAM9263_BASE_SMC1 );
arch/arm/mach-at91/at91sam9_alt_reset.S +5 -7
@@ -15,16 +15,17 @@ #include <linux/linkage.h> #include <mach/hardware.h> -#include <mach/at91sam9_sdramc.h> +#include <mach/at91_ramc.h> #include <mach/at91_rstc.h> .arm .globl at91sam9_alt_restart -at91sam9_alt_restart: ldr r0, .at91_va_base_sdramc @ preload constants - ldr r1, =at91_rstc_base - ldr r1, [r1] +at91sam9_alt_restart: ldr r0, =at91_ramc_base @ preload constants + ldr r0, [r0] + ldr r4, =at91_rstc_base + ldr r1, [r4] mov r2, #1 mov r3, #AT91_SDRAMC_LPCB_POWER_DOWN
@@ -37,6 +38,3 @@ at91sam9_alt_restart: ldr r0, .at91_va_base_sdramc @ preload constants str r4, [r1, #AT91_RSTC_CR] @ reset processor b . - -.at91_va_base_sdramc: - .word AT91_VA_BASE_SYS + AT91_SDRAMC0
arch/arm/mach-at91/at91sam9g45.c +2 -0
@@ -331,6 +331,8 @@ static void __init at91sam9g45_ioremap_registers(void) {at91_ioremap_shdwc (AT91SAM9G45_BASE_SHDWC );at91_ioremap_rstc (AT91SAM9G45_BASE_RSTC ); +at91_ioremap_ramc (0 ,AT91SAM9G45_BASE_DDRSDRC1 ,512 ); +at91_ioremap_ramc (1 ,AT91SAM9G45_BASE_DDRSDRC0 ,512 );at91sam926x_ioremap_pit (AT91SAM9G45_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9G45_BASE_SMC );at91_ioremap_matrix (AT91SAM9G45_BASE_MATRIX );
arch/arm/mach-at91/at91sam9g45_reset.S +5 -7
@@ -12,7 +12,7 @@ #include <linux/linkage.h> #include <mach/hardware.h> -#include <mach/at91sam9_ddrsdr.h> +#include <mach/at91_ramc.h> #include <mach/at91_rstc.h> .arm
@@ -20,9 +20,10 @@ .globl at91sam9g45_restart at91sam9g45_restart: - ldr r0, .at91_va_base_sdramc0 @ preload constants - ldr r1, =at91_rstc_base - ldr r1, [r1] + ldr r5, =at91_ramc_base @ preload constants + ldr r0, [r5] + ldr r4, =at91_rstc_base + ldr r1, [r4] mov r2, #1 mov r3, #AT91_DDRSDRC_LPCB_POWER_DOWN
@@ -35,6 +36,3 @@ at91sam9g45_restart: str r4, [r1, #AT91_RSTC_CR] @ reset processor b . - -.at91_va_base_sdramc0: - .word AT91_VA_BASE_SYS + AT91_DDRSDRC0
arch/arm/mach-at91/at91sam9rl.c +1 -0
@@ -288,6 +288,7 @@ static void __init at91sam9rl_ioremap_registers(void) {at91_ioremap_shdwc (AT91SAM9RL_BASE_SHDWC );at91_ioremap_rstc (AT91SAM9RL_BASE_RSTC ); +at91_ioremap_ramc (0 ,AT91SAM9RL_BASE_SDRAMC ,512 );at91sam926x_ioremap_pit (AT91SAM9RL_BASE_PIT );at91sam9_ioremap_smc (0 ,AT91SAM9RL_BASE_SMC );at91_ioremap_matrix (AT91SAM9RL_BASE_MATRIX );
arch/arm/mach-at91/at91sam9x5.c +1 -0
@@ -303,6 +303,7 @@ static void __init at91sam9x5_ioremap_registers(void) {if (of_at91sam926x_pit_init () <0 )panic ("Impossible to find PIT\n" ); +at91_ioremap_ramc (0 ,AT91SAM9X5_BASE_DDRSDRC0 ,512 ); }void __init at91sam9x5_initialize (void )
arch/arm/mach-at91/board-cpuat91.c +1 -0
@@ -38,6 +38,7 @@#include <mach/board.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include <mach/cpu.h> #include "generic.h"
arch/arm/mach-at91/board-eco920.c +3 -2
@@ -26,6 +26,7 @@#include <mach/board.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include <mach/cpu.h> #include "generic.h"
@@ -110,7 +111,7 @@ static void __init eco920_board_init(void)at91_add_device_mmc (0 , &eco920_mmc_data);platform_device_register (&eco920_flash); -at91_sys_write (AT91_SMC_CSR (7 ),AT91_SMC_RWHOLD_ (1 ) +at91_ramc_write (0 ,AT91_SMC_CSR (7 ),AT91_SMC_RWHOLD_ (1 ) |AT91_SMC_RWSETUP_ (1 ) |AT91_SMC_DBW_8 | AT91_SMC_WSEN
@@ -122,7 +123,7 @@ static void __init eco920_board_init(void)at91_set_deglitch (AT91_PIN_PA23 ,1 );/* Initialization of the Static Memory Controller for Chip Select 3 */ - at91_sys_write(AT91_SMC_CSR(3), + at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_DBW_16 | /* 16 bit */ AT91_SMC_WSEN | AT91_SMC_NWS_(5) | /* wait states */
arch/arm/mach-at91/board-kb9202.c +1 -0
@@ -38,6 +38,7 @@#include <mach/board.h> #include <mach/cpu.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include "generic.h"
arch/arm/mach-at91/board-picotux200.c +1 -0
@@ -39,6 +39,7 @@#include <mach/board.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include "generic.h"
arch/arm/mach-at91/board-rm9200dk.c +1 -0
@@ -41,6 +41,7 @@#include <mach/hardware.h> #include <mach/board.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include "generic.h"
arch/arm/mach-at91/board-rm9200ek.c +1 -0
@@ -41,6 +41,7 @@#include <mach/hardware.h> #include <mach/board.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include "generic.h"
arch/arm/mach-at91/board-yl-9200.c +2 -1
@@ -45,6 +45,7 @@#include <mach/hardware.h> #include <mach/board.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> #include <mach/cpu.h> #include "generic.h"
@@ -393,7 +394,7 @@ static void yl9200_init_video(void)at91_set_A_periph (AT91_PIN_PC6 ,0 );/* Initialization of the Static Memory Controller for Chip Select 2 */ -at91_sys_write (AT91_SMC_CSR (2 ),AT91_SMC_DBW_16 /* 16 bit */ +at91_ramc_write (0 ,AT91_SMC_CSR (2 ),AT91_SMC_DBW_16 /* 16 bit */ |AT91_SMC_WSEN |AT91_SMC_NWS_ (0x4 )/* wait states */ |AT91_SMC_TDF_ (0x100 )/* float time */ );
arch/arm/mach-at91/generic.h +3 -0
@@ -71,6 +71,9 @@ extern void at91_ioremap_shdwc(u32 base_addr);/* Matrix */ extern void at91_ioremap_matrix (u32 base_addr); +/* Ram Controler */ +extern void at91_ioremap_ramc (int id,u32 addr,u32 size); +/* GPIO */ #define AT91RM9200_PQFP 3/* AT91RM9200 PQFP package has 3 banks */ #define AT91RM9200_BGA 4/* AT91RM9200 BGA package has 4 banks */
arch/arm/mach-at91/include/mach/at91_ramc.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* Header file for the Atmel RAM Controller +* +* Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* Under GPLv2 only +*/ + +#ifndef __AT91_RAMC_H__ +#define __AT91_RAMC_H__ + +#ifndef __ASSEMBLY__ +extern void __iomem *at91_ramc_base[]; + +#define at91_ramc_read (id, field) \ + __raw_readl(at91_ramc_base[id] + field) + +#define at91_ramc_write (id, field, value) \ + __raw_writel(value, at91_ramc_base[id] + field) +#else +.extern at91_ramc_base +#endif + +#ifdef CONFIG_ARCH_AT91RM9200 +#include <mach/at91rm9200_mc.h> +#else +#include <mach/at91sam9_ddrsdr.h> +#include <mach/at91sam9_sdramc.h> +#endif + +#endif /* __AT91_RAMC_H__ */
arch/arm/mach-at91/include/mach/at91rm9200.h +1 -1
@@ -80,7 +80,6 @@* System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)/* Power Management Controller */ -#define AT91_MC (0xffffff00 - AT91_BASE_SYS)/* Memory Controllers */ #define AT91RM9200_BASE_DBGU AT91_BASE_DBGU0/* Debug Unit */ #define AT91RM9200_BASE_PIOA 0xfffff400/* PIO Controller A */
@@ -89,6 +88,7 @@#define AT91RM9200_BASE_PIOD 0xfffffa00/* PIO Controller D */ #define AT91RM9200_BASE_ST 0xfffffd00/* System Timer */ #define AT91RM9200_BASE_RTC 0xfffffe00/* Real-Time Clock */ +#define AT91RM9200_BASE_MC 0xffffff00/* Memory Controllers */ #define AT91_USART0 AT91RM9200_BASE_US0#define AT91_USART1 AT91RM9200_BASE_US1
arch/arm/mach-at91/include/mach/at91rm9200_mc.h +7 -7
@@ -17,10 +17,10 @@#define AT91RM9200_MC_H /* Memory Controller */ -#define AT91_MC_RCR (AT91_MC + 0x00)/* MC Remap Control Register */ +#define AT91_MC_RCR 0x00/* MC Remap Control Register */ #define AT91_MC_RCB (1 << 0)/* Remap Command Bit */ -#define AT91_MC_ASR (AT91_MC + 0x04)/* MC Abort Status Register */ +#define AT91_MC_ASR 0x04/* MC Abort Status Register */ #define AT91_MC_UNADD (1 << 0)/* Undefined Address Abort Status */ #define AT91_MC_MISADD (1 << 1)/* Misaligned Address Abort Status */ #define AT91_MC_ABTSZ (3 << 8)/* Abort Size Status */
@@ -40,16 +40,16 @@#define AT91_MC_SVMST2 (1 << 26)/* Saved UHP Abort Source */ #define AT91_MC_SVMST3 (1 << 27)/* Saved EMAC Abort Source */ -#define AT91_MC_AASR (AT91_MC + 0x08)/* MC Abort Address Status Register */ +#define AT91_MC_AASR 0x08/* MC Abort Address Status Register */ -#define AT91_MC_MPR (AT91_MC + 0x0c)/* MC Master Priority Register */ +#define AT91_MC_MPR 0x0c/* MC Master Priority Register */ #define AT91_MPR_MSTP0 (7 << 0)/* ARM920T Priority */ #define AT91_MPR_MSTP1 (7 << 4)/* PDC Priority */ #define AT91_MPR_MSTP2 (7 << 8)/* UHP Priority */ #define AT91_MPR_MSTP3 (7 << 12)/* EMAC Priority */ /* External Bus Interface (EBI) registers */ -#define AT91_EBI_CSA (AT91_MC + 0x60)/* Chip Select Assignment Register */ +#define AT91_EBI_CSA 0x60/* Chip Select Assignment Register */ #define AT91_EBI_CS0A (1 << 0)/* Chip Select 0 Assignment */ #define AT91_EBI_CS0A_SMC (0 << 0)#define AT91_EBI_CS0A_BFC (1 << 0)
@@ -66,7 +66,7 @@#define AT91_EBI_DBPUC (1 << 0)/* Data Bus Pull-Up Configuration */ /* Static Memory Controller (SMC) registers */ -#define AT91_SMC_CSR (n) (AT91_MC + 0x70 + ((n) * 4))/* SMC Chip Select Register */ +#define AT91_SMC_CSR (n) (0x70 + ((n) * 4))/* SMC Chip Select Register */ #define AT91_SMC_NWS (0x7f << 0)/* Number of Wait States */ #define AT91_SMC_NWS_ (x) ((x) << 0)#define AT91_SMC_WSEN (1 << 7)/* Wait State Enable */
@@ -88,7 +88,7 @@#define AT91_SMC_RWHOLD_ (x) ((x) << 28)/* Burst Flash Controller register */ -#define AT91_BFC_MR (AT91_MC + 0xc0)/* Mode Register */ +#define AT91_BFC_MR 0xc0/* Mode Register */ #define AT91_BFC_BFCOM (3 << 0)/* Burst Flash Controller Operating Mode */ #define AT91_BFC_BFCOM_DISABLED (0 << 0)#define AT91_BFC_BFCOM_ASYNC (1 << 0)
arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h +9 -9
@@ -17,7 +17,7 @@#define AT91RM9200_SDRAMC_H /* SDRAM Controller registers */ -#define AT91RM9200_SDRAMC_MR (AT91_MC + 0x90)/* Mode Register */ +#define AT91RM9200_SDRAMC_MR 0x90/* Mode Register */ #define AT91RM9200_SDRAMC_MODE (0xf << 0)/* Command Mode */ #define AT91RM9200_SDRAMC_MODE_NORMAL (0 << 0)#define AT91RM9200_SDRAMC_MODE_NOP (1 << 0)
@@ -28,10 +28,10 @@#define AT91RM9200_SDRAMC_DBW_32 (0 << 4)#define AT91RM9200_SDRAMC_DBW_16 (1 << 4) -#define AT91RM9200_SDRAMC_TR (AT91_MC + 0x94)/* Refresh Timer Register */ +#define AT91RM9200_SDRAMC_TR 0x94/* Refresh Timer Register */ #define AT91RM9200_SDRAMC_COUNT (0xfff << 0)/* Refresh Timer Count */ -#define AT91RM9200_SDRAMC_CR (AT91_MC + 0x98)/* Configuration Register */ +#define AT91RM9200_SDRAMC_CR 0x98/* Configuration Register */ #define AT91RM9200_SDRAMC_NC (3 << 0)/* Number of Column Bits */ #define AT91RM9200_SDRAMC_NC_8 (0 << 0)#define AT91RM9200_SDRAMC_NC_9 (1 << 0)
@@ -53,11 +53,11 @@#define AT91RM9200_SDRAMC_TRAS (0xf << 23)/* Active to Precharge Delay */ #define AT91RM9200_SDRAMC_TXSR (0xf << 27)/* Exit Self Refresh to Active Delay */ -#define AT91RM9200_SDRAMC_SRR (AT91_MC + 0x9c)/* Self Refresh Register */ -#define AT91RM9200_SDRAMC_LPR (AT91_MC + 0xa0)/* Low Power Register */ -#define AT91RM9200_SDRAMC_IER (AT91_MC + 0xa4)/* Interrupt Enable Register */ -#define AT91RM9200_SDRAMC_IDR (AT91_MC + 0xa8)/* Interrupt Disable Register */ -#define AT91RM9200_SDRAMC_IMR (AT91_MC + 0xac)/* Interrupt Mask Register */ -#define AT91RM9200_SDRAMC_ISR (AT91_MC + 0xb0)/* Interrupt Status Register */ +#define AT91RM9200_SDRAMC_SRR 0x9c/* Self Refresh Register */ +#define AT91RM9200_SDRAMC_LPR 0xa0/* Low Power Register */ +#define AT91RM9200_SDRAMC_IER 0xa4/* Interrupt Enable Register */ +#define AT91RM9200_SDRAMC_IDR 0xa8/* Interrupt Disable Register */ +#define AT91RM9200_SDRAMC_IMR 0xac/* Interrupt Mask Register */ +#define AT91RM9200_SDRAMC_ISR 0xb0/* Interrupt Status Register */ #endif
arch/arm/mach-at91/include/mach/at91sam9260.h +1 -1
@@ -80,11 +80,11 @@/* * System Peripherals (offset from AT91_BASE_SYS) */ -#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91SAM9260_BASE_ECC 0xffffe800 +#define AT91SAM9260_BASE_SDRAMC 0xffffea00#define AT91SAM9260_BASE_SMC 0xffffec00#define AT91SAM9260_BASE_MATRIX 0xffffee00#define AT91SAM9260_BASE_DBGU AT91_BASE_DBGU0
arch/arm/mach-at91/include/mach/at91sam9261.h +1 -1
@@ -65,12 +65,12 @@/* * System Peripherals (offset from AT91_BASE_SYS) */ -#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91SAM9261_BASE_SMC 0xffffec00#define AT91SAM9261_BASE_MATRIX 0xffffee00 +#define AT91SAM9261_BASE_SDRAMC 0xffffea00#define AT91SAM9261_BASE_DBGU AT91_BASE_DBGU0#define AT91SAM9261_BASE_PIOA 0xfffff400#define AT91SAM9261_BASE_PIOB 0xfffff600
arch/arm/mach-at91/include/mach/at91sam9263.h +2 -2
@@ -74,14 +74,14 @@/* * System Peripherals (offset from AT91_BASE_SYS) */ -#define AT91_SDRAMC0 (0xffffe200 - AT91_BASE_SYS) -#define AT91_SDRAMC1 (0xffffe800 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9263_BASE_ECC0 0xffffe000 +#define AT91SAM9263_BASE_SDRAMC0 0xffffe200#define AT91SAM9263_BASE_SMC0 0xffffe400#define AT91SAM9263_BASE_ECC1 0xffffe600 +#define AT91SAM9263_BASE_SDRAMC1 0xffffe800#define AT91SAM9263_BASE_SMC1 0xffffea00#define AT91SAM9263_BASE_MATRIX 0xffffec00#define AT91SAM9263_BASE_DBGU AT91_BASE_DBGU1
arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h +0 -6
@@ -121,10 +121,4 @@#define AT91_DDRSDRC_WPVS (1 << 0)/* Write protect violation status */ #define AT91_DDRSDRC_WPVSRC (0xffff << 8)/* Write protect violation source */ -/* Register access macros */ -#define at91_ramc_read (num, reg) \ - at91_sys_read(AT91_DDRSDRC##num + reg) -#define at91_ramc_write (num, reg, value) \ - at91_sys_write(AT91_DDRSDRC##num + reg, value) -#endif
arch/arm/mach-at91/include/mach/at91sam9_sdramc.h +0 -6
@@ -82,10 +82,4 @@#define AT91_SDRAMC_MD_SDRAM 0#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1 -/* Register access macros */ -#define at91_ramc_read (num, reg) \ - at91_sys_read(AT91_SDRAMC##num + reg) -#define at91_ramc_write (num, reg, value) \ - at91_sys_write(AT91_SDRAMC##num + reg, value) -#endif
arch/arm/mach-at91/include/mach/at91sam9g45.h +2 -2
@@ -86,12 +86,12 @@/* * System Peripherals (offset from AT91_BASE_SYS) */ -#define AT91_DDRSDRC1 (0xffffe400 - AT91_BASE_SYS) -#define AT91_DDRSDRC0 (0xffffe600 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9G45_BASE_ECC 0xffffe200 +#define AT91SAM9G45_BASE_DDRSDRC1 0xffffe400 +#define AT91SAM9G45_BASE_DDRSDRC0 0xffffe600#define AT91SAM9G45_BASE_DMA 0xffffec00#define AT91SAM9G45_BASE_SMC 0xffffe800#define AT91SAM9G45_BASE_MATRIX 0xffffea00
arch/arm/mach-at91/include/mach/at91sam9rl.h +1 -1
@@ -69,13 +69,13 @@/* * System Peripherals (offset from AT91_BASE_SYS) */ -#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9RL_BASE_DMA 0xffffe600#define AT91SAM9RL_BASE_ECC 0xffffe800 +#define AT91SAM9RL_BASE_SDRAMC 0xffffea00#define AT91SAM9RL_BASE_SMC 0xffffec00#define AT91SAM9RL_BASE_MATRIX 0xffffee00#define AT91SAM9RL_BASE_DBGU AT91_BASE_DBGU0
arch/arm/mach-at91/include/mach/at91sam9x5.h +1 -1
@@ -57,7 +57,7 @@/* * System Peripherals (offset from AT91_BASE_SYS) */ -#define AT91_DDRSDRC0 (0xffffe800 - AT91_BASE_SYS) +#define AT91SAM9X5_BASE_DDRSDRC0 0xffffe800#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)/*
arch/arm/mach-at91/pm.c +13 -14
@@ -196,19 +196,18 @@ extern u32 at91_slow_clock_sz;#endif static void __iomem *at91_pmc_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_PMC ); -#ifdef CONFIG_ARCH_AT91RM9200 -static void __iomem *at91_ramc0_base = (void __iomem *)AT91_VA_BASE_SYS ; -#elif defined(CONFIG_ARCH_AT91SAM9G45 ) -static void __iomem *at91_ramc0_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_DDRSDRC0 ); -#else -static void __iomem *at91_ramc0_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_SDRAMC0 ); -#endif +void __iomem *at91_ramc_base[2 ]; -#if defined(CONFIG_ARCH_AT91SAM9G45 ) -static void __iomem *at91_ramc1_base = (void __iomem *)(AT91_VA_BASE_SYS +AT91_DDRSDRC1 ); -#else -static void __iomem *at91_ramc1_base =NULL ; -#endif +void __init at91_ioremap_ramc (int id,u32 addr,u32 size) +{ +if (id >1 ) { +pr_warn ("%s: id > 2\n" , __func__); +return ; + } + at91_ramc_base[id] =ioremap (addr, size); +if (!at91_ramc_base[id]) +pr_warn ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); +}static int at91_pm_enter (suspend_state_t state) {
@@ -246,7 +245,7 @@ static int at91_pm_enter(suspend_state_t state)/* copy slow_clock handler to SRAM, and call it */ memcpy (slow_clock, at91_slow_clock, at91_slow_clock_sz);#endif -slow_clock (at91_pmc_base, at91_ramc0_base, at91_ramc1_base); +slow_clock (at91_pmc_base, at91_ramc_base[0 ], at91_ramc_base[1 ]);break ; }else {pr_info ("AT91: PM - no slow clock mode enabled ...\n" );
@@ -315,7 +314,7 @@ static int __init at91_pm_init(void)#ifdef CONFIG_ARCH_AT91RM9200 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ -at91_sys_write (AT91RM9200_SDRAMC_LPR ,0 ); +at91_ramc_write (0 ,AT91RM9200_SDRAMC_LPR ,0 );#endif suspend_set_ops (&at91_pm_ops);
arch/arm/mach-at91/pm.h +2 -4
@@ -11,8 +11,8 @@#ifndef __ARCH_ARM_MACH_AT91_PM#define __ARCH_ARM_MACH_AT91_PM +#include <mach/at91_ramc.h> #ifdef CONFIG_ARCH_AT91RM9200 -#include <mach/at91rm9200_mc.h> #include <mach/at91rm9200_sdramc.h> /*
@@ -27,7 +27,7 @@static inline void at91rm9200_standby (void ) { -u32 lpr =at91_sys_read (AT91RM9200_SDRAMC_LPR ); +u32 lpr =at91_ramc_read (0 ,AT91RM9200_SDRAMC_LPR ); asmvolatile ( "b 1f\n\t"
@@ -46,7 +46,6 @@ static inline void at91rm9200_standby(void)#define at91_standby at91rm9200_standby#elif defined(CONFIG_ARCH_AT91SAM9G45 ) -#include <mach/at91sam9_ddrsdr.h> /* We manage both DDRAM/SDRAM controllers, we need more than one value to * remember.
@@ -79,7 +78,6 @@ static inline void at91sam9g45_standby(void)#define at91_standby at91sam9g45_standby#else -#include <mach/at91sam9_sdramc.h> #ifdef CONFIG_ARCH_AT91SAM9263 /*
arch/arm/mach-at91/pm_slowclock.S +1 -9
@@ -15,15 +15,7 @@ #include <linux/linkage.h> #include <mach/hardware.h> #include <mach/at91_pmc.h> - -#if defined(CONFIG_ARCH_AT91RM9200) -#include <mach/at91rm9200_mc.h> -#include <mach/at91rm9200_sdramc.h> -#elif defined(CONFIG_ARCH_AT91SAM9G45) -#include <mach/at91sam9_ddrsdr.h> -#else -#include <mach/at91sam9_sdramc.h> -#endif +#include <mach/at91_ramc.h> #ifdef CONFIG_ARCH_AT91SAM9263
drivers/pcmcia/at91_cf.c +3 -2
@@ -26,6 +26,7 @@#include <mach/board.h> #include <mach/at91rm9200_mc.h> +#include <mach/at91_ramc.h> /*
@@ -156,7 +157,7 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)/* * Use 16 bit accesses unless/until we need 8-bit i/o space. */ - csr =at91_sys_read (AT91_SMC_CSR (cf->board->chipselect)) & ~AT91_SMC_DBW ; + csr =at91_ramc_read (0 ,AT91_SMC_CSR (cf->board->chipselect)) & ~AT91_SMC_DBW ;/* * NOTE: this CF controller ignores IOIS16, so we can't really do
@@ -175,7 +176,7 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) csr |=AT91_SMC_DBW_16 ;pr_debug ("%s: 16bit i/o bus\n" , driver_name); } -at91_sys_write (AT91_SMC_CSR (cf->board->chipselect), csr); +at91_ramc_write (0 ,AT91_SMC_CSR (cf->board->chipselect), csr); io->start = cf->socket.io_offset; io->stop = io->start +SZ_2K -1 ;
Signature · 1 line
1.7.9
Re: [PATCH v2 09/19] ARM: at91: make sdram/ddr register base soc independent
Quoted 5 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>---
<snip>
arch/arm/mach-at91/pm.c extern u32 at91_slow_clock_sz; · line 210
Quoted 10 lines
arch/arm/mach-at91/pm.c +10
-0+void __init at91_ioremap_ramc (int id,u32 addr,u32 size) +{ +if (id >1 ) { +pr_warn ("%s: id > 2\n" , __func__); +return ; + } + at91_ramc_base[id] =ioremap (addr, size); +if (!at91_ramc_base[id]) +pr_warn ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); +}
If this fails then you will oops if you call either at91_ramc_read or at91_ramc_write since they don't check if at91_ramc_base[id] is a valid pointer. Either this function should panic, like the other at91_ioremap functions, or the at91_ramc_read/write functions should check for a valid pointer.
Nitpick: The id check should probably also be BUG() or WARN() since it indicates a bug in the core AT91 code. pr_warn is likely to missed and not reported by users. Since the value is int, the check should be:
if (id < 0 || id > 1)
Obviously the chance of this error happening are slim, but if you are going to check and warn for it, it should be done properly :-).
~Ryan
Re: [PATCH v2 09/19] ARM: at91: make sdram/ddr register base soc independent
On 02/22/2012 11:33 PM, Ryan Mallon :
Quoted 19 lines · Nicolas Ferre
Quoted 6 lines
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>---
<snip>
Quoted 9 lines
arch/arm/mach-at91/pm.c +9
-0+void __init at91_ioremap_ramc (int id,u32 addr,u32 size) +{ +if (id >1 ) { +pr_warn ("%s: id > 2\n" , __func__); +return ; + } + at91_ramc_base[id] =ioremap (addr, size); +if (!at91_ramc_base[id]) +pr_warn ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr);
Quoted 8 lines
Quoted 1 line
+}
If this fails then you will oops if you call either
at91_ramc_readorat91_ramc_writesince they don't check if at91_ramc_base[id] is a valid pointer. Either this function should panic, like the otherat91_ioremapfunctions, or the at91_ramc_read/write functions should check for a valid pointer.
Yes, as you pointed out, it is done in a not-related following patch. I will bring the code here.
Quoted 8 lines
Nitpick: The id check should probably also be
BUG()orWARN()since it indicates a bug in the core AT91 code.pr_warnis likely to missed and not reported by users. Since the value is int, the check should be:if (id < 0 || id > 1)Obviously the chance of this error happening are slim, but if you are going to check and warn for it, it should be done properly :-).
Yes, I agree and modify it at the very moment.
thanks, best regards,
Signature · 1 line
Nicolas Ferre
Re: [PATCH v2 09/19] ARM: at91: make sdram/ddr register base soc independent
On 02/23/2012 09:56 AM, Nicolas Ferre :
Quoted 37 lines
On 02/22/2012 11:33 PM, Ryan Mallon :
Quoted 19 lines · Nicolas Ferre
Quoted 6 lines
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>---
<snip>
Quoted 9 lines
(quoted diff) +9
-0+void __init at91_ioremap_ramc(int id, u32 addr, u32 size) +{ + if (id > 1) { + pr_warn("%s: id > 2\n", __func__); + return; + } + at91_ramc_base[id] = ioremap(addr, size); + if (!at91_ramc_base[id]) + pr_warn("Impossible to ioremap ramc.%d 0x%x\n", id, addr);Quoted 8 lines
Quoted 1 line
+}
If this fails then you will oops if you call either
at91_ramc_readorat91_ramc_writesince they don't check if at91_ramc_base[id] is a valid pointer. Either this function should panic, like the otherat91_ioremapfunctions, or the at91_ramc_read/write functions should check for a valid pointer.Yes, as you pointed out, it is done in a not-related following patch. I will bring the code here.
Quoted 4 lines
Nitpick: The id check should probably also be
BUG()orWARN()since it indicates a bug in the core AT91 code.pr_warnis likely to missed and not reported by users. Since the value is int, the check should be:
Quoted 6 lines
Quoted 4 lines
if (id < 0 || id > 1)Obviously the chance of this error happening are slim, but if you are going to check and warn for it, it should be done properly :-).
Yes, I agree and modify it at the very moment.
What do you think about that:
If id is not setup properly, I try to find a way out by using id = 0... Then, a panic is added if the iremap() fails.
arch/arm/mach-at91/pm.c +5 -4
@@ -200,13 +200,14 @@ void __iomem *at91_ramc_base[2];void __init at91_ioremap_ramc (int id,u32 addr,u32 size) { -if (id >1 ) { -pr_warn ("%s: id > 2\n" , __func__); -return ; +if (id <0 || id >1 ) { +WARN (1 ,"%s: Wrong RAM controller id (%d), set it to 0\n" , + __func__, id); + id =0 ; } at91_ramc_base[id] =ioremap (addr, size);if (!at91_ramc_base[id]) -pr_warn ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); +panic ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); }static int at91_pm_enter (suspend_state_t state)
Best regards,
Signature · 1 line
Nicolas Ferre
Re: [PATCH v2 09/19] ARM: at91: make sdram/ddr register base soc independent
Quoted 54 lines · Nicolas Ferre
On 02/23/2012 09:56 AM, Nicolas Ferre :
Quoted 37 lines
On 02/22/2012 11:33 PM, Ryan Mallon :
Quoted 19 lines · Nicolas Ferre
Quoted 6 lines
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>---
<snip>
Quoted 9 lines
(quoted diff) +9
-0+void __init at91_ioremap_ramc(int id, u32 addr, u32 size) +{ + if (id > 1) { + pr_warn("%s: id > 2\n", __func__); + return; + } + at91_ramc_base[id] = ioremap(addr, size); + if (!at91_ramc_base[id]) + pr_warn("Impossible to ioremap ramc.%d 0x%x\n", id, addr);Quoted 8 lines
Quoted 1 line
+}
If this fails then you will oops if you call either
at91_ramc_readorat91_ramc_writesince they don't check if at91_ramc_base[id] is a valid pointer. Either this function should panic, like the otherat91_ioremapfunctions, or the at91_ramc_read/write functions should check for a valid pointer.Yes, as you pointed out, it is done in a not-related following patch. I will bring the code here.
Quoted 4 lines
Nitpick: The id check should probably also be
BUG()orWARN()since it indicates a bug in the core AT91 code.pr_warnis likely to missed and not reported by users. Since the value is int, the check should be:Quoted 6 lines
Quoted 4 lines
if (id < 0 || id > 1)Obviously the chance of this error happening are slim, but if you are going to check and warn for it, it should be done properly :-).
Yes, I agree and modify it at the very moment.
What do you think about that:
If id is not setup properly, I try to find a way out by using id = 0... Then, a panic is added if theiremap()fails.
arch/arm/mach-at91/pm.c void __iomem *at91_ramc_base[2]; · line 206
Quoted 10 lines
arch/arm/mach-at91/pm.c +4
-3@@ -200,13 +200,14 @@ void __iomem *at91_ramc_base[2];void __init at91_ioremap_ramc (int id,u32 addr,u32 size) { -if (id >1 ) { -pr_warn ("%s: id > 2\n" , __func__); -return ; +if (id <0 || id >1 ) { +WARN (1 ,"%s: Wrong RAM controller id (%d), set it to 0\n" , + __func__, id); + id =0 ;
I don't think you should try to fix the id, just issue the warning and return.
~Ryan
Re: [PATCH v2 09/19] ARM: at91: make sdram/ddr register base soc independent
On 02/23/2012 11:51 AM, Ryan Mallon :
Quoted 57 lines · Nicolas Ferre
Quoted 56 lines
On 02/23/2012 09:56 AM, Nicolas Ferre :
Quoted 37 lines
On 02/22/2012 11:33 PM, Ryan Mallon :
Quoted 19 lines · Nicolas Ferre
Quoted 6 lines
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>---
<snip>
Quoted 9 lines
(quoted diff) +9
-0+void __init at91_ioremap_ramc(int id, u32 addr, u32 size) +{ + if (id > 1) { + pr_warn("%s: id > 2\n", __func__); + return; + } + at91_ramc_base[id] = ioremap(addr, size); + if (!at91_ramc_base[id]) + pr_warn("Impossible to ioremap ramc.%d 0x%x\n", id, addr);Quoted 8 lines
Quoted 1 line
+}
If this fails then you will oops if you call either
at91_ramc_readorat91_ramc_writesince they don't check if at91_ramc_base[id] is a valid pointer. Either this function should panic, like the otherat91_ioremapfunctions, or the at91_ramc_read/write functions should check for a valid pointer.Yes, as you pointed out, it is done in a not-related following patch. I will bring the code here.
Quoted 4 lines
Nitpick: The id check should probably also be
BUG()orWARN()since it indicates a bug in the core AT91 code.pr_warnis likely to missed and not reported by users. Since the value is int, the check should be:Quoted 6 lines
Quoted 4 lines
if (id < 0 || id > 1)Obviously the chance of this error happening are slim, but if you are going to check and warn for it, it should be done properly :-).
Yes, I agree and modify it at the very moment.
What do you think about that:
If id is not setup properly, I try to find a way out by using id = 0... Then, a panic is added if theiremap()fails.arch/arm/mach-at91/pm.c +0
-0@@ -200,13 +200,14 @@ void __iomem *at91_ramc_base[2];
Quoted 13 lines
arch/arm/mach-at91/pm.c void __iomem *at91_ramc_base[2]; · line 206
Quoted 9 lines
arch/arm/mach-at91/pm.c +4
-3void __init at91_ioremap_ramc (int id,u32 addr,u32 size) { -if (id >1 ) { -pr_warn ("%s: id > 2\n" , __func__); -return ; +if (id <0 || id >1 ) { +WARN (1 ,"%s: Wrong RAM controller id (%d), set it to 0\n" , + __func__, id); + id =0 ;I don't think you should try to fix the id, just issue the warning and return.
Well, I was trying hard to find a way out: but you may be right: a plain and good-old BUG() should be a safer solution!
Bye,
Signature · 1 line
Nicolas Ferre
PATCH v2 10/19 ARM: at91/pm_slowclock: add runtime detection of memory contoller
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This will allow to have all SoC in one kernel image.
--- arch/arm/mach-at91/include/mach/at91_ramc.h | 9 ++-- arch/arm/mach-at91/pm.c | 15 +++++- arch/arm/mach-at91/pm_slowclock.S | 66 +++++++++++++++++++++------ 3 files changed, 68 insertions(+), 22 deletions(-)
arch/arm/mach-at91/include/mach/at91_ramc.h +5 -4
@@ -21,11 +21,12 @@ extern void __iomem *at91_ramc_base[]; .extern at91_ramc_base#endif -#ifdef CONFIG_ARCH_AT91RM9200 -#include <mach/at91rm9200_mc.h> -#else +#define AT91_MEMCTRL_MC 0 +#define AT91_MEMCTRL_SDRAMC 1 +#define AT91_MEMCTRL_DDRSDR 2 + +#include <mach/at91rm9200_sdramc.h> #include <mach/at91sam9_ddrsdr.h> #include <mach/at91sam9_sdramc.h> -#endif #endif /* __AT91_RAMC_H__ */
arch/arm/mach-at91/pm.c +12 -3
@@ -188,10 +188,12 @@ int at91_suspend_entering_slow_clock(void)EXPORT_SYMBOL (at91_suspend_entering_slow_clock); -static void (*slow_clock)(void __iomem *pmc,void __iomem *ramc0,void __iomem *ramc1); +static void (*slow_clock)(void __iomem *pmc,void __iomem *ramc0, +void __iomem *ramc1,int memctrl);#ifdef CONFIG_AT91_SLOW_CLOCK -extern void at91_slow_clock (void __iomem *pmc,void __iomem *ramc0,void __iomem *ramc1); +extern void at91_slow_clock (void __iomem *pmc,void __iomem *ramc0, +void __iomem *ramc1,int memctrl);extern u32 at91_slow_clock_sz;#endif
@@ -241,11 +243,18 @@ static int at91_pm_enter(suspend_state_t state)* turning off the main oscillator; reverse on wakeup. */ if (slow_clock) { +int memctrl =AT91_MEMCTRL_SDRAMC ; + +if (cpu_is_at91rm9200 ()) + memctrl =AT91_MEMCTRL_MC ; +else if (cpu_is_at91sam9g45 ()) + memctrl =AT91_MEMCTRL_DDRSDR ;#ifdef CONFIG_AT91_SLOW_CLOCK /* copy slow_clock handler to SRAM, and call it */ memcpy (slow_clock, at91_slow_clock, at91_slow_clock_sz);#endif -slow_clock (at91_pmc_base, at91_ramc_base[0 ], at91_ramc_base[1 ]); +slow_clock (at91_pmc_base, at91_ramc_base[0 ], + at91_ramc_base[1 ], memctrl);break ; }else {pr_info ("AT91: PM - no slow clock mode enabled ...\n" );
arch/arm/mach-at91/pm_slowclock.S +51 -15
126 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH v2 11/19 ARM: at91/PMC: make register base soc independent
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
--- arch/arm/mach-at91/at91rm9200.c | 2 +- arch/arm/mach-at91/clock.c | 75 +++++++++++++------------ arch/arm/mach-at91/include/mach/at91_pmc.h | 56 +++++++++++------- arch/arm/mach-at91/include/mach/at91rm9200.h | 4 +- arch/arm/mach-at91/include/mach/at91sam9260.h | 1 - arch/arm/mach-at91/include/mach/at91sam9261.h | 1 - arch/arm/mach-at91/include/mach/at91sam9263.h | 1 - arch/arm/mach-at91/include/mach/at91sam9g45.h | 1 - arch/arm/mach-at91/include/mach/at91sam9rl.h | 1 - arch/arm/mach-at91/include/mach/at91sam9x5.h | 3 +- arch/arm/mach-at91/include/mach/hardware.h | 3 +- arch/arm/mach-at91/pm.c | 9 +-- arch/arm/mach-at91/pm_slowclock.S | 38 ++++++------ drivers/usb/gadget/atmel_usba_udc.c | 6 +- 14 files changed, 105 insertions(+), 96 deletions(-)
arch/arm/mach-at91/at91rm9200.c +1 -1
@@ -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)
arch/arm/mach-at91/clock.c +40 -35
208 lines not on this page · raw message
arch/arm/mach-at91/include/mach/at91_pmc.h +34 -22
125 lines not on this page · raw message
arch/arm/mach-at91/include/mach/at91rm9200.h +1 -3
@@ -77,10 +77,8 @@/* -* 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 */
arch/arm/mach-at91/include/mach/at91sam9260.h +0 -1
@@ -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
arch/arm/mach-at91/include/mach/at91sam9261.h +0 -1
@@ -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
arch/arm/mach-at91/include/mach/at91sam9263.h +0 -1
@@ -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
arch/arm/mach-at91/include/mach/at91sam9g45.h +0 -1
@@ -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
arch/arm/mach-at91/include/mach/at91sam9rl.h +0 -1
@@ -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)
arch/arm/mach-at91/include/mach/at91sam9x5.h +1 -2
@@ -55,10 +55,9 @@#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)
arch/arm/mach-at91/include/mach/hardware.h +2 -1
@@ -59,9 +59,10 @@/* * On all at91 have the Advanced Interrupt Controller starts at address -* 0xfffff000 +* 0xfffff000 and the Power Management Controller starts@0xfffffc00 */ #define AT91_AIC 0xfffff000 +#define AT91_PMC 0xfffffc00/* * Peripheral identifiers/interrupts.
arch/arm/mach-at91/pm.c +4 -5
@@ -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)
@@ -208,7 +207,7 @@ void __init at91_ioremap_ramc(int id, u32 addr, u32 size) } at91_ramc_base[id] =ioremap (addr, size);if (!at91_ramc_base[id]) -pr_warn ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); +panic ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); }static int at91_pm_enter (suspend_state_t state)
@@ -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))
arch/arm/mach-at91/pm_slowclock.S +19 -19
@@ -54,7 +54,7 @@ 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 @@ 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 @@ 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 @@ 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
drivers/usb/gadget/atmel_usba_udc.c +3 -3
@@ -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
Signature · 1 line
1.7.9
Re: [PATCH v2 11/19] ARM: at91/PMC: make register base soc independent
Quoted 6 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>Reviewed-by Ryan Mallon <[email protected]>---
<snip>
arch/arm/mach-at91/clock.c static int at91_clk_show(struct seq_file *s, void *unused) · line 437
Quoted 7 lines
arch/arm/mach-at91/clock.c +2
-5-seq_printf (s,"SCSR = %8x\n" , scsr =at91_sys_read (AT91_PMC_SCSR )); -seq_printf (s,"PCSR = %8x\n" , pcsr =at91_sys_read (AT91_PMC_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,"SCSR = %8x\n" , scsr =at91_pmc_read (AT91_PMC_SCSR )); +seq_printf (s,"PCSR = %8x\n" , pcsr =at91_pmc_read (AT91_PMC_PCSR ));
I realise the original code is wrong, so doesn't need to be fixed in this patch, but can we please move the assignments out of the seq_printf calls.
<snip>
arch/arm/mach-at91/pm.c void __init at91_ioremap_ramc(int id, u32 addr, u32 size) · line 210
Quoted 7 lines
void
__initat91_ioremap_ramc(int id, u32 addr, u32 size)arch/arm/mach-at91/pm.c +1
-1@@ -208,7 +207,7 @@ void __init at91_ioremap_ramc(int id, u32 addr, u32 size) } at91_ramc_base[id] =ioremap (addr, size);if (!at91_ramc_base[id]) -pr_warn ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); +panic ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr);
This is in the wrong patch, and should be folded into the correct patch.
~Ryan
Re: [PATCH v2 11/19] ARM: at91/PMC: make register base soc independent
On 02/22/2012 11:50 PM, Ryan Mallon :
Quoted 11 lines · Nicolas Ferre
Quoted 7 lines
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>Reviewed-by Ryan Mallon <[email protected]>---
<snip>
Quoted 12 lines
arch/arm/mach-at91/clock.c static int at91_clk_show(struct seq_file *s, void *unused) · line 437
Quoted 7 lines
arch/arm/mach-at91/clock.c +2
-5-seq_printf (s,"SCSR = %8x\n" , scsr =at91_sys_read (AT91_PMC_SCSR )); -seq_printf (s,"PCSR = %8x\n" , pcsr =at91_sys_read (AT91_PMC_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,"SCSR = %8x\n" , scsr =at91_pmc_read (AT91_PMC_SCSR )); +seq_printf (s,"PCSR = %8x\n" , pcsr =at91_pmc_read (AT91_PMC_PCSR ));I realise the original code is wrong, so doesn't need to be fixed in this patch, but can we please move the assignments out of the
seq_printfcalls.
Well, I would not say "wrong". But ugly, for sure. I queue a patch to correct this just before this one.
Quoted 12 lines
<snip>
arch/arm/mach-at91/pm.c void __init at91_ioremap_ramc(int id, u32 addr, u32 size) · line 210
Quoted 7 lines
void
__initat91_ioremap_ramc(int id, u32 addr, u32 size)arch/arm/mach-at91/pm.c +1
-1@@ -208,7 +207,7 @@ void __init at91_ioremap_ramc(int id, u32 addr, u32 size) } at91_ramc_base[id] =ioremap (addr, size);if (!at91_ramc_base[id]) -pr_warn ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr); +panic ("Impossible to ioremap ramc.%d 0x%x\n" , id, addr);This is in the wrong patch, and should be folded into the correct patch.
Absolutely, this belongs to the previous patch. Thanks for highlighting this.
Best regards,
Signature · 1 line
Nicolas Ferre
Re: [PATCH v2 11/19] ARM: at91/PMC: make register base soc independent
Quoted 25 lines · Nicolas Ferre
On 02/22/2012 11:50 PM, Ryan Mallon :
Quoted 11 lines · Nicolas Ferre
Quoted 7 lines
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>Reviewed-by Ryan Mallon <[email protected]>---
<snip>
Quoted 12 lines
arch/arm/mach-at91/clock.c static int at91_clk_show(struct seq_file *s, void *unused) · line 437
Quoted 7 lines
arch/arm/mach-at91/clock.c +2
-5-seq_printf (s,"SCSR = %8x\n" , scsr =at91_sys_read (AT91_PMC_SCSR )); -seq_printf (s,"PCSR = %8x\n" , pcsr =at91_sys_read (AT91_PMC_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,"SCSR = %8x\n" , scsr =at91_pmc_read (AT91_PMC_SCSR )); +seq_printf (s,"PCSR = %8x\n" , pcsr =at91_pmc_read (AT91_PMC_PCSR ));I realise the original code is wrong, so doesn't need to be fixed in this patch, but can we please move the assignments out of the
seq_printfcalls.
Quoted 2 lines
Well, I would not say "wrong". But ugly, for sure. I queue a patch to correct this just before this one.
Sorry, I meant ugly rather than wrong. When I first saw it, I thought your replace script had made a mistake :-).
~Ryan
PATCH v2 12/19 ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
For the RTT as RTC driver rtc-at91sam9, the platform_device structure is filled during SoC initialization. This will allow to convert this RTC driver as a standard platform driver.
--- arch/arm/mach-at91/at91sam9260_devices.c | 11 +++++ arch/arm/mach-at91/at91sam9261_devices.c | 10 +++++ arch/arm/mach-at91/at91sam9263_devices.c | 25 ++++++++++++ arch/arm/mach-at91/at91sam9g45_devices.c | 10 +++++ arch/arm/mach-at91/at91sam9rl_devices.c | 10 +++++ drivers/rtc/rtc-at91sam9.c | 61 ++++------------------------- 6 files changed, 75 insertions(+), 52 deletions(-)
arch/arm/mach-at91/at91sam9260_devices.c +11 -0
@@ -728,8 +728,19 @@ static struct platform_device at91sam9260_rtt_device = { .num_resources = ARRAY_SIZE(rtt_resources), }; + +#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 ) +static void __init at91_add_device_rtt_rtc (void ) +{ + at91sam9260_rtt_device.name ="rtc-at91sam9" ; +} +#else +static void __init at91_add_device_rtt_rtc (void ) {} +#endif +static void __init at91_add_device_rtt (void ) { +at91_add_device_rtt_rtc ();platform_device_register (&at91sam9260_rtt_device); }
arch/arm/mach-at91/at91sam9261_devices.c +10 -0
@@ -614,8 +614,18 @@ static struct platform_device at91sam9261_rtt_device = { .num_resources = ARRAY_SIZE(rtt_resources), }; +#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 ) +static void __init at91_add_device_rtt_rtc (void ) +{ + at91sam9261_rtt_device.name ="rtc-at91sam9" ; +} +#else +static void __init at91_add_device_rtt_rtc (void ) {} +#endif +static void __init at91_add_device_rtt (void ) { +at91_add_device_rtt_rtc ();platform_device_register (&at91sam9261_rtt_device); }
arch/arm/mach-at91/at91sam9263_devices.c +25 -0
@@ -992,8 +992,33 @@ static struct platform_device at91sam9263_rtt1_device = { .num_resources = ARRAY_SIZE(rtt1_resources), }; +#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 ) +static void __init at91_add_device_rtt_rtc (void ) +{ +struct platform_device *pdev; + +switch (CONFIG_RTC_DRV_AT91SAM9_RTT ) { +case 0 : + pdev = &at91sam9263_rtt0_device; +break ; +case 1 : + pdev = &at91sam9263_rtt1_device; +break ; +default : +pr_err ("at91sam9263: support only 2 RTT (%d)\n" , +CONFIG_RTC_DRV_AT91SAM9_RTT ); +return ; + } + + pdev->name ="rtc-at91sam9" ; +} +#else +static void __init at91_add_device_rtt_rtc (void ) {} +#endif +static void __init at91_add_device_rtt (void ) { +at91_add_device_rtt_rtc ();platform_device_register (&at91sam9263_rtt0_device);platform_device_register (&at91sam9263_rtt1_device); }
arch/arm/mach-at91/at91sam9g45_devices.c +10 -0
@@ -1204,8 +1204,18 @@ static struct platform_device at91sam9g45_rtt_device = { .num_resources = ARRAY_SIZE(rtt_resources), }; +#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 ) +static void __init at91_add_device_rtt_rtc (void ) +{ + at91sam9g45_rtt_device.name ="rtc-at91sam9" ; +} +#else +static void __init at91_add_device_rtt_rtc (void ) {} +#endif +static void __init at91_add_device_rtt (void ) { +at91_add_device_rtt_rtc ();platform_device_register (&at91sam9g45_rtt_device); }
arch/arm/mach-at91/at91sam9rl_devices.c +10 -0
@@ -693,8 +693,18 @@ static struct platform_device at91sam9rl_rtt_device = { .num_resources = ARRAY_SIZE(rtt_resources), }; +#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 ) +static void __init at91_add_device_rtt_rtc (void ) +{ + at91sam9rl_rtt_device.name ="rtc-at91sam9" ; +} +#else +static void __init at91_add_device_rtt_rtc (void ) {} +#endif +static void __init at91_add_device_rtt (void ) { +at91_add_device_rtt_rtc ();platform_device_register (&at91sam9rl_rtt_device); }
drivers/rtc/rtc-at91sam9.c +9 -52
86 lines not on this page · raw message
Signature · 1 line
1.7.9
Re: [PATCH v2 12/19] ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
Quoted 5 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
For the RTT as RTC driver rtc-at91sam9, the
platform_devicestructure is filled during SoC initialization. This will allow to convert this RTC driver as a standard platform driver.
Can you make this more elaborate? I don't see from this or the code why you don't just always register the RTT as "rtc-at91sam9". There seems to be no driver for the "at91_rtt" in tree, so I don't know if there is an out of tree driver binding to it.
Would it be possible to remove the compile time #if and the resetting of the device name if both drivers bind to the rtc name and the other rtt driver binds to both names?
Quoted 6 lines
static int
__initat91_rtc_init(void)
{drivers/rtc/rtc-at91sam9.c +0
-4-int status; -struct device *rtc; - - status =platform_driver_register (&at91_rtc_driver);
drivers/rtc/rtc-at91sam9.c static int at91_rtc_resume(struct platform_device *pdev) · line 451
Quoted 10 lines
drivers/rtc/rtc-at91sam9.c +1
-7-if (status) -return status; - rtc =bus_find_device (&platform_bus_type,NULL , -NULL , at91_rtc_match); -if (!rtc) -platform_driver_unregister (&at91_rtc_driver); -return rtc ?0 : -ENODEV ; +return platform_driver_register (&at91_rtc_driver); }module_init (at91_rtc_init);
This can become module_platform_driver().
Arnd
Re: [PATCH v2 12/19] ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
Quoted 7 lines · Arnd Bergmann
Quoted 5 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
For the RTT as RTC driver rtc-at91sam9, the
platform_devicestructure is filled during SoC initialization. This will allow to convert this RTC driver as a standard platform driver.
Quoted 8 lines
Can you make this more elaborate? I don't see from this or the code why you don't just always register the RTT as "rtc-at91sam9". There seems to be no driver for the "
at91_rtt" in tree, so I don't know if there is an out of tree driver binding to it.Would it be possible to remove the compile time #if and the resetting of the device name if both drivers bind to the rtc name and the other rtt driver binds to both names?
because I see a quite some people use the rtt for something else
so I don't want to change on existing kernel
Best Regards,
J.
Re: [PATCH v2 12/19] ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
Quoted 13 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 12 lines · Arnd Bergmann
Quoted 5 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
For the RTT as RTC driver rtc-at91sam9, the
platform_devicestructure is filled during SoC initialization. This will allow to convert this RTC driver as a standard platform driver.Can you make this more elaborate? I don't see from this or the code why you don't just always register the RTT as "rtc-at91sam9". There seems to be no driver for the "
at91_rtt" in tree, so I don't know if there is an out of tree driver binding to it.
Quoted 6 lines
Quoted 3 lines
Would it be possible to remove the compile time #if and the resetting of the device name if both drivers bind to the rtc name and the other rtt driver binds to both names?
because I see a quite some people use the rtt for something else
so I don't want to change on existing kernel
But if you change the rtc driver to always bind to the existing "at91_rtt" platform_device and fail the probe() function for the case that you are on at91sam9263 probing the non-RTC device, you should get the exact same result without any extra code in the per-soc files.
I guess it also makes sense to specify a device tree property that lets you detect whether the RTT is used as RTC or something else.
Arnd
Re: [PATCH v2 12/19] ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
Quoted 19 lines · Arnd Bergmann
Quoted 18 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 7 lines · Arnd Bergmann
Quoted 5 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
For the RTT as RTC driver rtc-at91sam9, the
platform_devicestructure is filled during SoC initialization. This will allow to convert this RTC driver as a standard platform driver.Quoted 8 lines
Can you make this more elaborate? I don't see from this or the code why you don't just always register the RTT as "rtc-at91sam9". There seems to be no driver for the "
at91_rtt" in tree, so I don't know if there is an out of tree driver binding to it.Would it be possible to remove the compile time #if and the resetting of the device name if both drivers bind to the rtc name and the other rtt driver binds to both names?
because I see a quite some people use the rtt for something else
Quoted 7 lines
Quoted 1 line
so I don't want to change on existing kernel
But if you change the rtc driver to always bind to the existing "
at91_rtt"platform_deviceand fail theprobe()function for the case that you are on at91sam9263 probing the non-RTC device, you should get the exact same result without any extra code in the per-soc files.
agreed but as on at91sam9263 you have 2 RTTs so you can have 2 drivers at the same time that use the RTT. So we can not do this except if we set the second RTT to an other device name.
Quoted 5 lines
I guess it also makes sense to specify a device tree property that lets you detect whether the RTT is used as RTC or something else.
agreed for DT I think of something like this with a phandle maybe
but today not all the soc are DT and will not be switch to DT at first
Best Regards,
J.
Re: [PATCH v2 12/19] ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines
But if you change the rtc driver to always bind to the existing "
at91_rtt"platform_deviceand fail theprobe()function for the case that you are on at91sam9263 probing the non-RTC device, you should get the exact same result without any extra code in the per-soc files.agreed but as on at91sam9263 you have 2 RTTs so you can have 2 drivers at the same time that use the RTT. So we can not do this except if we set the second RTT to an other device name.
Let me rephrase what I meant then:
The first driver should in its probe function do:
if (pdev->id != CONFIG_RTC_DRV_AT91SAM9_RTT) return -ENODEV;
while the other driver does
if (pdev->id == CONFIG_RTC_DRV_AT91SAM9_RTT) return -ENODEV;
This way, each driver binds to one device but not the other. It should even work with an unmodified second driver, as long as you guarantee that it's loaded after the first one.
Any reason why this won't work?
Arnd
Re: [PATCH v2 12/19] ARM: at91/rtc-at91sam9: each SoC can select the RTT device to use
Quoted 20 lines · Arnd Bergmann
Quoted 9 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines
But if you change the rtc driver to always bind to the existing "
at91_rtt"platform_deviceand fail theprobe()function for the case that you are on at91sam9263 probing the non-RTC device, you should get the exact same result without any extra code in the per-soc files.agreed but as on at91sam9263 you have 2 RTTs so you can have 2 drivers at the same time that use the RTT. So we can not do this except if we set the second RTT to an other device name.
Let me rephrase what I meant then:
The first driver should in its probe function do:
if (pdev->id != CONFIG_RTC_DRV_AT91SAM9_RTT) return -ENODEV;while the other driver does
Quoted 8 lines
if (pdev->id == CONFIG_RTC_DRV_AT91SAM9_RTT) return -ENODEV;This way, each driver binds to one device but not the other. It should even work with an unmodified second driver, as long as you guarantee that it's loaded after the first one.
Any reason why this won't work?
just one other issue I need to pass the GPBR ressource to the RTC driver only
Best Regards,
J.
PATCH v2 13/19 ARM: at91:rtc/rtc-at91sam9: ioremap register bank
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Instead of computing virtual address with AT91_VA_BASE_SYS, use the appropriate ioremap() call on the driver "memory" resource.
--- drivers/rtc/rtc-at91sam9.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
drivers/rtc/rtc-at91sam9.c +10 -3
@@ -307,8 +307,12 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)device_init_wakeup (&pdev->dev,1 );platform_set_drvdata (pdev, rtc); - rtc->rtt = (void __force __iomem *) (AT91_VA_BASE_SYS -AT91_BASE_SYS ); - rtc->rtt += r->start; + rtc->rtt =ioremap (r->start,resource_size (r)); +if (!rtc->rtt) { +dev_err (&pdev->dev,"failed to map registers, aborting.\n" ); + ret = -ENOMEM ; + goto fail; + } mr =rtt_readl (rtc,MR );
@@ -326,7 +330,7 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev) &at91_rtc_ops, THIS_MODULE);if (IS_ERR (rtc->rtcdev)) { ret =PTR_ERR (rtc->rtcdev); - goto fail; + goto fail_register; }/* register irq handler after we know what name we'll use */
@@ -351,6 +355,8 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)return 0 ; +fail_register: +iounmap (rtc->rtt); fail:platform_set_drvdata (pdev,NULL );kfree (rtc);
@@ -371,6 +377,7 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)rtc_device_unregister (rtc->rtcdev); +iounmap (rtc->rtt);platform_set_drvdata (pdev,NULL );kfree (rtc);return 0 ;
Signature · 1 line
1.7.9
PATCH v2 14/19 ARM: at91/rtc-at91sam9: pass the GPBR to use via resources
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
The GPBR registers are used for storing RTC values. The GPBR registers to use are now provided using standard resource entry. The array is filled in SoC specific code.
rtc-at91sam9 RTT as RTC driver is modified to retrieve this information.
--- arch/arm/mach-at91/at91sam9260_devices.c | 19 +++++++++++++-- arch/arm/mach-at91/at91sam9261_devices.c | 17 ++++++++++++- arch/arm/mach-at91/at91sam9263_devices.c | 30 ++++++++++++++++++++---- arch/arm/mach-at91/at91sam9g45_devices.c | 17 ++++++++++++- arch/arm/mach-at91/at91sam9rl_devices.c | 17 ++++++++++++- arch/arm/mach-at91/include/mach/at91sam9260.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9261.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9263.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9g45.h | 5 +-- arch/arm/mach-at91/include/mach/at91sam9rl.h | 2 +- drivers/rtc/rtc-at91sam9.c | 24 +++++++++++++++---- 11 files changed, 114 insertions(+), 32 deletions(-)
arch/arm/mach-at91/at91sam9260_devices.c +16 -3
@@ -718,14 +718,15 @@ static struct resource rtt_resources[] = { .start = AT91SAM9260_BASE_RTT, .end = AT91SAM9260_BASE_RTT + SZ_16 - 1, .flags = IORESOURCE_MEM, - } + }, { + .flags = IORESOURCE_MEM, + }, };static struct platform_device at91sam9260_rtt_device = { .name ="at91_rtt" , .id =0 , .resource = rtt_resources, - .num_resources =ARRAY_SIZE (rtt_resources), };
@@ -733,9 +734,21 @@ static struct platform_device at91sam9260_rtt_device = {static void __init at91_add_device_rtt_rtc (void ) { at91sam9260_rtt_device.name ="rtc-at91sam9" ; +/* +* The second resource is needed: +* GPBR will serve as the storage for RTC time offset +*/ + at91sam9260_rtt_device.num_resources =2 ; + rtt_resources[1 ].start =AT91SAM9260_BASE_GPBR + +4 *CONFIG_RTC_DRV_AT91SAM9_GPBR ; + rtt_resources[1 ].end = rtt_resources[1 ].start +3 ; }#else -static void __init at91_add_device_rtt_rtc (void ) {} +static void __init at91_add_device_rtt_rtc (void ) +{ +/* Only one resource is needed: RTT not used as RTC */ + at91sam9260_rtt_device.num_resources =1 ; +}#endif static void __init at91_add_device_rtt (void )
arch/arm/mach-at91/at91sam9261_devices.c +15 -2
@@ -604,6 +604,8 @@ static struct resource rtt_resources[] = { .start = AT91SAM9261_BASE_RTT, .end = AT91SAM9261_BASE_RTT + SZ_16 - 1, .flags = IORESOURCE_MEM, + }, { + .flags = IORESOURCE_MEM, } };
@@ -611,16 +613,27 @@ static struct platform_device at91sam9261_rtt_device = { .name = "at91_rtt", .id = 0, .resource = rtt_resources, - .num_resources = ARRAY_SIZE(rtt_resources), };#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 )static void __init at91_add_device_rtt_rtc (void ) { at91sam9261_rtt_device.name ="rtc-at91sam9" ; +/* +* The second resource is needed: +* GPBR will serve as the storage for RTC time offset +*/ + at91sam9261_rtt_device.num_resources =2 ; + rtt_resources[1 ].start =AT91SAM9261_BASE_GPBR + +4 *CONFIG_RTC_DRV_AT91SAM9_GPBR ; + rtt_resources[1 ].end = rtt_resources[1 ].start +3 ; }#else -static void __init at91_add_device_rtt_rtc (void ) {} +static void __init at91_add_device_rtt_rtc (void ) +{ +/* Only one resource is needed: RTT not used as RTC */ + at91sam9261_rtt_device.num_resources =1 ; +}#endif static void __init at91_add_device_rtt (void )
arch/arm/mach-at91/at91sam9263_devices.c +25 -5
@@ -967,6 +967,8 @@ static struct resource rtt0_resources[] = { .start = AT91SAM9263_BASE_RTT0, .end = AT91SAM9263_BASE_RTT0 + SZ_16 - 1, .flags = IORESOURCE_MEM, + }, { + .flags = IORESOURCE_MEM, } };
@@ -974,7 +976,6 @@ static struct platform_device at91sam9263_rtt0_device = { .name = "at91_rtt", .id = 0, .resource = rtt0_resources, - .num_resources = ARRAY_SIZE(rtt0_resources), };static struct resource rtt1_resources[] = {
@@ -982,6 +983,8 @@ static struct resource rtt1_resources[] = { .start = AT91SAM9263_BASE_RTT1, .end = AT91SAM9263_BASE_RTT1 + SZ_16 - 1, .flags = IORESOURCE_MEM, + }, { + .flags = IORESOURCE_MEM, } };
@@ -989,31 +992,48 @@ static struct platform_device at91sam9263_rtt1_device = { .name = "at91_rtt", .id = 1, .resource = rtt1_resources, - .num_resources = ARRAY_SIZE(rtt1_resources), };#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 )static void __init at91_add_device_rtt_rtc (void ) {struct platform_device *pdev; +struct resource *r;switch (CONFIG_RTC_DRV_AT91SAM9_RTT ) {case 0 : +/* +* The second resource is needed only for the chosen RTT: +* GPBR will serve as the storage for RTC time offset +*/ + at91sam9263_rtt0_device.num_resources =2 ; + at91sam9263_rtt1_device.num_resources =1 ; pdev = &at91sam9263_rtt0_device; + r = rtt0_resources;break ;case 1 : + at91sam9263_rtt0_device.num_resources =1 ; + at91sam9263_rtt1_device.num_resources =2 ; pdev = &at91sam9263_rtt1_device; + r = rtt1_resources;break ;default : -pr_err ("at91sam9263: support only 2 RTT (%d)\n" , -CONFIG_RTC_DRV_AT91SAM9_RTT ); +pr_err ("at91sam9263: only supports 2 RTT (%d)\n" , +CONFIG_RTC_DRV_AT91SAM9_RTT );return ; } pdev->name ="rtc-at91sam9" ; + r[1 ].start =AT91SAM9263_BASE_GPBR +4 *CONFIG_RTC_DRV_AT91SAM9_GPBR ; + r[1 ].end = r[1 ].start +3 ; }#else -static void __init at91_add_device_rtt_rtc (void ) {} +static void __init at91_add_device_rtt_rtc (void ) +{ +/* Only one resource is needed: RTT not used as RTC */ + at91sam9263_rtt0_device.num_resources =1 ; + at91sam9263_rtt1_device.num_resources =1 ; +}#endif static void __init at91_add_device_rtt (void )
arch/arm/mach-at91/at91sam9g45_devices.c +15 -2
@@ -1194,6 +1194,8 @@ static struct resource rtt_resources[] = { .start = AT91SAM9G45_BASE_RTT, .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1, .flags = IORESOURCE_MEM, + }, { + .flags = IORESOURCE_MEM, } };
@@ -1201,16 +1203,27 @@ static struct platform_device at91sam9g45_rtt_device = { .name = "at91_rtt", .id = 0, .resource = rtt_resources, - .num_resources = ARRAY_SIZE(rtt_resources), };#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 )static void __init at91_add_device_rtt_rtc (void ) { at91sam9g45_rtt_device.name ="rtc-at91sam9" ; +/* +* The second resource is needed: +* GPBR will serve as the storage for RTC time offset +*/ + at91sam9g45_rtt_device.num_resources =2 ; + rtt_resources[1 ].start =AT91SAM9G45_BASE_GPBR + +4 *CONFIG_RTC_DRV_AT91SAM9_GPBR ; + rtt_resources[1 ].end = rtt_resources[1 ].start +3 ; }#else -static void __init at91_add_device_rtt_rtc (void ) {} +static void __init at91_add_device_rtt_rtc (void ) +{ +/* Only one resource is needed: RTT not used as RTC */ + at91sam9g45_rtt_device.num_resources =1 ; +}#endif static void __init at91_add_device_rtt (void )
arch/arm/mach-at91/at91sam9rl_devices.c +15 -2
@@ -683,6 +683,8 @@ static struct resource rtt_resources[] = { .start = AT91SAM9RL_BASE_RTT, .end = AT91SAM9RL_BASE_RTT + SZ_16 - 1, .flags = IORESOURCE_MEM, + }, { + .flags = IORESOURCE_MEM, } };
@@ -690,16 +692,27 @@ static struct platform_device at91sam9rl_rtt_device = { .name = "at91_rtt", .id = 0, .resource = rtt_resources, - .num_resources = ARRAY_SIZE(rtt_resources), };#if IS_ENABLED (CONFIG_RTC_DRV_AT91SAM9 )static void __init at91_add_device_rtt_rtc (void ) { at91sam9rl_rtt_device.name ="rtc-at91sam9" ; +/* +* The second resource is needed: +* GPBR will serve as the storage for RTC time offset +*/ + at91sam9rl_rtt_device.num_resources =2 ; + rtt_resources[1 ].start =AT91SAM9RL_BASE_GPBR + +4 *CONFIG_RTC_DRV_AT91SAM9_GPBR ; + rtt_resources[1 ].end = rtt_resources[1 ].start +3 ; }#else -static void __init at91_add_device_rtt_rtc (void ) {} +static void __init at91_add_device_rtt_rtc (void ) +{ +/* Only one resource is needed: RTT not used as RTC */ + at91sam9rl_rtt_device.num_resources =1 ; +}#endif static void __init at91_add_device_rtt (void )
arch/arm/mach-at91/include/mach/at91sam9260.h +2 -3
@@ -78,10 +78,8 @@#define AT91SAM9260_BASE_ADC 0xfffe0000/* -* System Peripherals (offset from AT91_BASE_SYS) +* System Peripherals */ -#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS) -#define AT91SAM9260_BASE_ECC 0xffffe800#define AT91SAM9260_BASE_SDRAMC 0xffffea00#define AT91SAM9260_BASE_SMC 0xffffec00
@@ -95,6 +93,7 @@#define AT91SAM9260_BASE_RTT 0xfffffd20#define AT91SAM9260_BASE_PIT 0xfffffd30#define AT91SAM9260_BASE_WDT 0xfffffd40 +#define AT91SAM9260_BASE_GPBR 0xfffffd50#define AT91_USART0 AT91SAM9260_BASE_US0#define AT91_USART1 AT91SAM9260_BASE_US1
arch/arm/mach-at91/include/mach/at91sam9261.h +2 -3
@@ -63,10 +63,8 @@/* -* System Peripherals (offset from AT91_BASE_SYS) +* System Peripherals */ -#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS) -#define AT91SAM9261_BASE_SMC 0xffffec00#define AT91SAM9261_BASE_MATRIX 0xffffee00#define AT91SAM9261_BASE_SDRAMC 0xffffea00
@@ -79,6 +77,7 @@#define AT91SAM9261_BASE_RTT 0xfffffd20#define AT91SAM9261_BASE_PIT 0xfffffd30#define AT91SAM9261_BASE_WDT 0xfffffd40 +#define AT91SAM9261_BASE_GPBR 0xfffffd50#define AT91_USART0 AT91SAM9261_BASE_US0#define AT91_USART1 AT91SAM9261_BASE_US1
arch/arm/mach-at91/include/mach/at91sam9263.h +2 -3
@@ -72,10 +72,8 @@#define AT91SAM9263_BASE_2DGE 0xfffc8000/* -* System Peripherals (offset from AT91_BASE_SYS) +* System Peripherals */ -#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS) -#define AT91SAM9263_BASE_ECC0 0xffffe000#define AT91SAM9263_BASE_SDRAMC0 0xffffe200#define AT91SAM9263_BASE_SMC0 0xffffe400
@@ -95,6 +93,7 @@#define AT91SAM9263_BASE_PIT 0xfffffd30#define AT91SAM9263_BASE_WDT 0xfffffd40#define AT91SAM9263_BASE_RTT1 0xfffffd50 +#define AT91SAM9263_BASE_GPBR 0xfffffd60#define AT91_USART0 AT91SAM9263_BASE_US0#define AT91_USART1 AT91SAM9263_BASE_US1
arch/arm/mach-at91/include/mach/at91sam9g45.h +2 -3
@@ -84,10 +84,8 @@#define AT91SAM9G45_BASE_TC5 0xfffd4080/* -* System Peripherals (offset from AT91_BASE_SYS) +* System Peripherals */ -#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS) -#define AT91SAM9G45_BASE_ECC 0xffffe200#define AT91SAM9G45_BASE_DDRSDRC1 0xffffe400#define AT91SAM9G45_BASE_DDRSDRC0 0xffffe600
@@ -106,6 +104,7 @@#define AT91SAM9G45_BASE_PIT 0xfffffd30#define AT91SAM9G45_BASE_WDT 0xfffffd40#define AT91SAM9G45_BASE_RTC 0xfffffdb0 +#define AT91SAM9G45_BASE_GPBR 0xfffffd60#define AT91_USART0 AT91SAM9G45_BASE_US0#define AT91_USART1 AT91SAM9G45_BASE_US1
arch/arm/mach-at91/include/mach/at91sam9rl.h +1 -1
@@ -70,7 +70,6 @@* System Peripherals (offset from AT91_BASE_SYS) */ #define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS) -#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9RL_BASE_DMA 0xffffe600#define AT91SAM9RL_BASE_ECC 0xffffe800
@@ -87,6 +86,7 @@#define AT91SAM9RL_BASE_RTT 0xfffffd20#define AT91SAM9RL_BASE_PIT 0xfffffd30#define AT91SAM9RL_BASE_WDT 0xfffffd40 +#define AT91SAM9RL_BASE_GPBR 0xfffffd60#define AT91SAM9RL_BASE_RTC 0xfffffe00#define AT91_USART0 AT91SAM9RL_BASE_US0
drivers/rtc/rtc-at91sam9.c +19 -5
@@ -57,6 +57,7 @@ struct sam9_rtc {void __iomem *rtt;struct rtc_device *rtcdev;u32 imr; +void __iomem *gpbr; };#define rtt_readl (rtc, field) \
@@ -65,9 +66,9 @@ struct sam9_rtc { __raw_writel((val), (rtc)->rtt + AT91_RTT_ ## field)#define gpbr_readl (rtc) \ - at91_sys_read(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR) + __raw_readl((rtc)->gpbr)#define gpbr_writel (rtc, val) \ - at91_sys_write(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR, (val)) + __raw_writel((val), (rtc)->gpbr)/* * Read current time and date in RTC
@@ -289,14 +290,17 @@ static const struct rtc_class_ops at91_rtc_ops = {*/ static int __devinit at91_rtc_probe (struct platform_device *pdev) { -struct resource *r; +struct resource *r, *r_gpbr;struct sam9_rtc *rtc;int ret;u32 mr; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!r) + r_gpbr =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +if (!r || !r_gpbr) { +dev_err (&pdev->dev,"need 2 ressources\n" );return -ENODEV ; + } rtc =kzalloc (sizeof *rtc,GFP_KERNEL );if (!rtc)
@@ -314,6 +318,13 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev) goto fail; } + rtc->gpbr =ioremap (r_gpbr->start,resource_size (r_gpbr)); +if (!rtc->gpbr) { +dev_err (&pdev->dev,"failed to map gpbr registers, aborting.\n" ); + ret = -ENOMEM ; + goto fail_gpbr; + } + mr =rtt_readl (rtc,MR );/* unless RTT is counting at 1 Hz, re-initialize it */
@@ -340,7 +351,7 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)if (ret) {dev_dbg (&pdev->dev,"can't share IRQ %d?\n" ,AT91_ID_SYS );rtc_device_unregister (rtc->rtcdev); - goto fail; + goto fail_register; }/* NOTE: sam9260 rev A silicon has a ROM bug which resets the
@@ -356,6 +367,8 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)return 0 ; fail_register: +iounmap (rtc->gpbr); +fail_gpbr:iounmap (rtc->rtt); fail:platform_set_drvdata (pdev,NULL );
@@ -377,6 +390,7 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)rtc_device_unregister (rtc->rtcdev); +iounmap (rtc->gpbr);iounmap (rtc->rtt);platform_set_drvdata (pdev,NULL );kfree (rtc);
Signature · 1 line
1.7.9
PATCH v2 15/19 ARM: at91: finally drop at91_sys_read/write
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Remove at91_sys_read/write() from io.h file. This function is not used anymore and was a stopper on the way to single zImage kernel for AT91.
--- arch/arm/mach-at91/include/mach/io.h | 18 ------------------ 1 files changed, 0 insertions(+), 18 deletions(-)
arch/arm/mach-at91/include/mach/io.h +0 -18
@@ -28,22 +28,4 @@#define __io (a) __typesafe_io(a)#define __mem_pci (a) (a) -#ifndef __ASSEMBLY__ - -static inline unsigned int at91_sys_read (unsigned int reg_offset) -{ -void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS ; - -return __raw_readl (addr + reg_offset); -} - -static inline void at91_sys_write (unsigned int reg_offset,unsigned long value) -{ -void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS ; - -__raw_writel (value, addr + reg_offset); -} - -#endif -#endif
Signature · 1 line
1.7.9
PATCH v2 16/19 ARM: at91: merge SRAM Memory banks thanks to mirroring
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
On at91sam9260 and at91sam9g20 the SRAM banks are mirrored. We can merge them together to be able to have bigger and continuous internal RAM.
--- arch/arm/mach-at91/at91sam9260.c | 13 +++++-------- arch/arm/mach-at91/include/mach/at91sam9260.h | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-)
arch/arm/mach-at91/at91sam9260.c +5 -8
@@ -310,15 +310,12 @@ static void __init at91sam9xe_map_io(void)static void __init at91sam9260_map_io (void ) { -if (cpu_is_at91sam9xe ()) { +if (cpu_is_at91sam9xe ())at91sam9xe_map_io (); - }else if (cpu_is_at91sam9g20 ()) { -at91_init_sram (0 ,AT91SAM9G20_SRAM0_BASE ,AT91SAM9G20_SRAM0_SIZE ); -at91_init_sram (1 ,AT91SAM9G20_SRAM1_BASE ,AT91SAM9G20_SRAM1_SIZE ); - }else { -at91_init_sram (0 ,AT91SAM9260_SRAM0_BASE ,AT91SAM9260_SRAM0_SIZE ); -at91_init_sram (1 ,AT91SAM9260_SRAM1_BASE ,AT91SAM9260_SRAM1_SIZE ); - } +else if (cpu_is_at91sam9g20 ()) +at91_init_sram (0 ,AT91SAM9G20_SRAM_BASE ,AT91SAM9G20_SRAM_SIZE ); +else +at91_init_sram (0 ,AT91SAM9260_SRAM_BASE ,AT91SAM9260_SRAM_SIZE ); }static void __init at91sam9260_ioremap_registers (void )
arch/arm/mach-at91/include/mach/at91sam9260.h +4 -0
@@ -113,6 +113,8 @@#define AT91SAM9260_SRAM0_SIZE SZ_4K/* Internal SRAM 0 size (4Kb) */ #define AT91SAM9260_SRAM1_BASE 0x00300000/* Internal SRAM 1 base address */ #define AT91SAM9260_SRAM1_SIZE SZ_4K/* Internal SRAM 1 size (4Kb) */ +#define AT91SAM9260_SRAM_BASE 0x002FF000/* Internal SRAM base address */ +#define AT91SAM9260_SRAM_SIZE SZ_8K/* Internal SRAM size (8Kb) */ #define AT91SAM9260_UHP_BASE 0x00500000/* USB Host controller */
@@ -126,6 +128,8 @@#define AT91SAM9G20_SRAM0_SIZE SZ_16K/* Internal SRAM 0 size (16Kb) */ #define AT91SAM9G20_SRAM1_BASE 0x00300000/* Internal SRAM 1 base address */ #define AT91SAM9G20_SRAM1_SIZE SZ_16K/* Internal SRAM 1 size (16Kb) */ +#define AT91SAM9G20_SRAM_BASE 0x002FC000/* Internal SRAM base address */ +#define AT91SAM9G20_SRAM_SIZE SZ_32K/* Internal SRAM size (32Kb) */ #define AT91SAM9G20_UHP_BASE 0x00500000/* USB Host controller */
Signature · 1 line
1.7.9
Re: [PATCH v2 16/19] ARM: at91: merge SRAM Memory banks thanks to mirroring
Quoted 53 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
On at91sam9260 and at91sam9g20 the SRAM banks are mirrored. We can merge them together to be able to have bigger and continuous internal RAM.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>--- arch/arm/mach-at91/at91sam9260.c | 13 +++++-------- arch/arm/mach-at91/include/mach/at91sam9260.h | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-)arch/arm/mach-at91/at91sam9260.c +5
-8@@ -310,15 +310,12 @@ static void __init at91sam9xe_map_io(void)static void __init at91sam9260_map_io (void ) { -if (cpu_is_at91sam9xe ()) { +if (cpu_is_at91sam9xe ())at91sam9xe_map_io (); - }else if (cpu_is_at91sam9g20 ()) { -at91_init_sram (0 ,AT91SAM9G20_SRAM0_BASE ,AT91SAM9G20_SRAM0_SIZE ); -at91_init_sram (1 ,AT91SAM9G20_SRAM1_BASE ,AT91SAM9G20_SRAM1_SIZE ); - }else { -at91_init_sram (0 ,AT91SAM9260_SRAM0_BASE ,AT91SAM9260_SRAM0_SIZE ); -at91_init_sram (1 ,AT91SAM9260_SRAM1_BASE ,AT91SAM9260_SRAM1_SIZE ); - } +else if (cpu_is_at91sam9g20 ()) +at91_init_sram (0 ,AT91SAM9G20_SRAM_BASE ,AT91SAM9G20_SRAM_SIZE ); +else +at91_init_sram (0 ,AT91SAM9260_SRAM_BASE ,AT91SAM9260_SRAM_SIZE ); }static void __init at91sam9260_ioremap_registers (void )arch/arm/mach-at91/include/mach/at91sam9260.h +2
-0@@ -113,6 +113,8 @@#define AT91SAM9260_SRAM0_SIZE SZ_4K/* Internal SRAM 0 size (4Kb) */ #define AT91SAM9260_SRAM1_BASE 0x00300000/* Internal SRAM 1 base address */ #define AT91SAM9260_SRAM1_SIZE SZ_4K/* Internal SRAM 1 size (4Kb) */ +#define AT91SAM9260_SRAM_BASE 0x002FF000/* Internal SRAM base address */ +#define AT91SAM9260_SRAM_SIZE SZ_8K/* Internal SRAM size (8Kb) */ #define AT91SAM9260_UHP_BASE 0x00500000/* USB Host controller */
arch/arm/mach-at91/include/mach/at91sam9260.h line 132
Quoted 5 lines
arch/arm/mach-at91/include/mach/at91sam9260.h +2
-0@@ -126,6 +128,8 @@#define AT91SAM9G20_SRAM0_SIZE SZ_16K/* Internal SRAM 0 size (16Kb) */ #define AT91SAM9G20_SRAM1_BASE 0x00300000/* Internal SRAM 1 base address */ #define AT91SAM9G20_SRAM1_SIZE SZ_16K/* Internal SRAM 1 size (16Kb) */ +#define AT91SAM9G20_SRAM_BASE 0x002FC000/* Internal SRAM base address */ +#define AT91SAM9G20_SRAM_SIZE SZ_32K/* Internal SRAM size (32Kb) */
Where does the SRAM_BASE value come from? The at91sam9g20 guide says that the region 0x204000 - 0x2fffff is reserved, and I can't find any information in the at91sam9g20 guide about the sram being mirrored. Can you point me to some documentation for this?
~Ryan
Re: [PATCH v2 16/19] ARM: at91: merge SRAM Memory banks thanks to mirroring
Quoted 54 lines · Ryan Mallon
Quoted 52 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
On at91sam9260 and at91sam9g20 the SRAM banks are mirrored. We can merge them together to be able to have bigger and continuous internal RAM.
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>--- arch/arm/mach-at91/at91sam9260.c | 13 +++++-------- arch/arm/mach-at91/include/mach/at91sam9260.h | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-)arch/arm/mach-at91/at91sam9260.c +5
-8@@ -310,15 +310,12 @@ static void __init at91sam9xe_map_io(void)static void __init at91sam9260_map_io (void ) { -if (cpu_is_at91sam9xe ()) { +if (cpu_is_at91sam9xe ())at91sam9xe_map_io (); - }else if (cpu_is_at91sam9g20 ()) { -at91_init_sram (0 ,AT91SAM9G20_SRAM0_BASE ,AT91SAM9G20_SRAM0_SIZE ); -at91_init_sram (1 ,AT91SAM9G20_SRAM1_BASE ,AT91SAM9G20_SRAM1_SIZE ); - }else { -at91_init_sram (0 ,AT91SAM9260_SRAM0_BASE ,AT91SAM9260_SRAM0_SIZE ); -at91_init_sram (1 ,AT91SAM9260_SRAM1_BASE ,AT91SAM9260_SRAM1_SIZE ); - } +else if (cpu_is_at91sam9g20 ()) +at91_init_sram (0 ,AT91SAM9G20_SRAM_BASE ,AT91SAM9G20_SRAM_SIZE ); +else +at91_init_sram (0 ,AT91SAM9260_SRAM_BASE ,AT91SAM9260_SRAM_SIZE ); }static void __init at91sam9260_ioremap_registers (void )arch/arm/mach-at91/include/mach/at91sam9260.h +2
-0@@ -113,6 +113,8 @@#define AT91SAM9260_SRAM0_SIZE SZ_4K/* Internal SRAM 0 size (4Kb) */ #define AT91SAM9260_SRAM1_BASE 0x00300000/* Internal SRAM 1 base address */ #define AT91SAM9260_SRAM1_SIZE SZ_4K/* Internal SRAM 1 size (4Kb) */ +#define AT91SAM9260_SRAM_BASE 0x002FF000/* Internal SRAM base address */ +#define AT91SAM9260_SRAM_SIZE SZ_8K/* Internal SRAM size (8Kb) */ #define AT91SAM9260_UHP_BASE 0x00500000/* USB Host controller */
Quoted 12 lines
arch/arm/mach-at91/include/mach/at91sam9260.h line 132
Quoted 6 lines
arch/arm/mach-at91/include/mach/at91sam9260.h +2
-0@@ -126,6 +128,8 @@#define AT91SAM9G20_SRAM0_SIZE SZ_16K/* Internal SRAM 0 size (16Kb) */ #define AT91SAM9G20_SRAM1_BASE 0x00300000/* Internal SRAM 1 base address */ #define AT91SAM9G20_SRAM1_SIZE SZ_16K/* Internal SRAM 1 size (16Kb) */ +#define AT91SAM9G20_SRAM_BASE 0x002FC000/* Internal SRAM base address */ +#define AT91SAM9G20_SRAM_SIZE SZ_32K/* Internal SRAM size (32Kb) */ Where does the
SRAM_BASEvalue come from? The at91sam9g20 guide says that the region0x204000-0x2fffffis reserved, and I can't find any information in the at91sam9g20 guide about the sram being mirrored. Can you point me to some documentation for this?
This is not documented but it's correct
Best Regards,
J.
PATCH v2 17/19 Atmel: move console default platform_device to serial driver
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This variable spread on every SoC that is using the atmel_serial.c driver can be included directly into the latter.
This will allow to compile multiple soc in the same kernel.
--- arch/arm/mach-at91/at91rm9200_devices.c | 1 - arch/arm/mach-at91/at91sam9260_devices.c | 1 - arch/arm/mach-at91/at91sam9261_devices.c | 1 - arch/arm/mach-at91/at91sam9263_devices.c | 1 - arch/arm/mach-at91/at91sam9g45_devices.c | 1 - arch/arm/mach-at91/at91sam9rl_devices.c | 1 - arch/arm/mach-at91/at91sam9x5.c | 1 - arch/avr32/mach-at32ap/at32ap700x.c | 2 -- drivers/tty/serial/atmel_serial.c | 2 ++ 9 files changed, 2 insertions(+), 9 deletions(-)
arch/arm/mach-at91/at91rm9200_devices.c +0 -1
@@ -1115,7 +1115,6 @@ static inline void configure_usart3_pins(unsigned pins) }static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART ];/* the UARTs to use */ -struct platform_device *atmel_default_console_device;/* the serial console device */ void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {
arch/arm/mach-at91/at91sam9260_devices.c +0 -1
@@ -1164,7 +1164,6 @@ static inline void configure_usart5_pins(void) }static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART ];/* the UARTs to use */ -struct platform_device *atmel_default_console_device;/* the serial console device */ void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {
arch/arm/mach-at91/at91sam9261_devices.c +0 -1
@@ -1015,7 +1015,6 @@ static inline void configure_usart2_pins(unsigned pins) }static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART ];/* the UARTs to use */ -struct platform_device *atmel_default_console_device;/* the serial console device */ void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {
arch/arm/mach-at91/at91sam9263_devices.c +0 -1
@@ -1424,7 +1424,6 @@ static inline void configure_usart2_pins(unsigned pins) }static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART ];/* the UARTs to use */ -struct platform_device *atmel_default_console_device;/* the serial console device */ void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {
arch/arm/mach-at91/at91sam9g45_devices.c +0 -1
@@ -1683,7 +1683,6 @@ static inline void configure_usart3_pins(unsigned pins) }static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART ];/* the UARTs to use */ -struct platform_device *atmel_default_console_device;/* the serial console device */ void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {
arch/arm/mach-at91/at91sam9rl_devices.c +0 -1
@@ -1152,7 +1152,6 @@ static inline void configure_usart3_pins(unsigned pins) }static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART ];/* the UARTs to use */ -struct platform_device *atmel_default_console_device;/* the serial console device */ void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {
arch/arm/mach-at91/at91sam9x5.c +0 -1
@@ -320,7 +320,6 @@ void __init at91sam9x5_initialize(void)* -------------------------------------------------------------------- */ void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {}void __init at91_set_serial_console (unsigned portnr) {} -struct platform_device *atmel_default_console_device =NULL ;void __init at91_add_device_nand (struct atmel_nand_data *data) {}
arch/avr32/mach-at32ap/at32ap700x.c +0 -2
@@ -1055,8 +1055,6 @@ struct platform_device *__init at32_add_device_usart(unsigned int id)return at32_usarts[id]; } -struct platform_device *atmel_default_console_device; -void __init at32_setup_serial_console (unsigned int usart_id) { atmel_default_console_device = at32_usarts[usart_id];
drivers/tty/serial/atmel_serial.c +2 -0
@@ -1526,6 +1526,8 @@ void __init atmel_register_uart_fns(struct atmel_port_fns *fns) atmel_pops.set_wake = fns->set_wake; } +struct platform_device *atmel_default_console_device;/* the serial console device */ +#ifdef CONFIG_SERIAL_ATMEL_CONSOLE static void atmel_console_putchar (struct uart_port *port,int ch) {
Signature · 1 line
1.7.9
PATCH v2 18/19 ARM: at91/board-dt: drop default console
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
This default console mechanism is not used if the console is selected by command line (console= parameter).
Dropping this will simplify the compilation of multiple SoC in the same kernel image.
--- arch/arm/mach-at91/at91sam9x5.c | 3 --- arch/arm/mach-at91/board-dt.c | 6 ------ 2 files changed, 0 insertions(+), 9 deletions(-)
arch/arm/mach-at91/at91sam9x5.c +0 -3
@@ -318,9 +318,6 @@ void __init at91sam9x5_initialize(void)/* -------------------------------------------------------------------- * AT91SAM9x5 devices (temporary before modification of code) * -------------------------------------------------------------------- */ -void __init at91_register_uart (unsigned id,unsigned portnr,unsigned pins) {} -void __init at91_set_serial_console (unsigned portnr) {} -void __init at91_add_device_nand (struct atmel_nand_data *data) {}/* --------------------------------------------------------------------
arch/arm/mach-at91/board-dt.c +0 -6
@@ -38,12 +38,6 @@ static void __init ek_init_early(void) {/* Initialize processor: 12.000 MHz crystal */ at91_initialize (12000000 ); - -/* DGBU on ttyS0. (Rx & Tx only) */ -at91_register_uart (0 ,0 ,0 ); - -/* set serial console to ttyS0 (ie, DBGU) */ -at91_set_serial_console (0 ); }/* det_pin is not connected */
Signature · 1 line
1.7.9
PATCH v2 19/19 ARM: at91/board-dt: move at91_initialize() to init_irq()
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Remove the need for at91_initialize() to be called at init_early(). We move it to init_irq() function as we still need it before the timer initialization.
--- arch/arm/mach-at91/board-dt.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-at91/board-dt.c +3 -7
@@ -34,12 +34,6 @@#include "generic.h" -static void __init ek_init_early (void ) -{ -/* Initialize processor: 12.000 MHz crystal */ -at91_initialize (12000000 ); -} -/* det_pin is not connected */ static struct atmel_nand_data __initdata ek_nand_data = { .ale =21 ,
@@ -89,6 +83,9 @@ static const struct of_device_id aic_of_match[] __initconst = {static void __init at91_dt_init_irq (void ) { +/* Initialize processor: 12.000 MHz crystal */ +at91_initialize (12000000 ); +irq_domain_generate_simple (aic_of_match,0xfffff000 ,0 );at91_init_irq_default (); }
@@ -112,7 +109,6 @@ DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")/* Maintainer: Atmel */ .timer = &at91sam926x_timer, .map_io = at91_map_io, - .init_early = ek_init_early, .init_irq = at91_dt_init_irq, .init_machine = at91_dt_device_init, .dt_compat = at91_dt_board_compat,
Signature · 1 line
1.7.9
Re: [PATCH v2 19/19] ARM: at91/board-dt: move at91_initialize() to init_irq()
Quoted 8 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Remove the need for
at91_initialize()to be called atinit_early(). We move it toinit_irq()function as we still need it before the timer initialization.Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>
NAK. Keep the callback methods pure. The whole point of the init_early is so that soc people don't end up polluting things like the IRQ initialization and timer initialization with stuff like this.
So this is a backwards step.
Re: [PATCH v2 19/19] ARM: at91/board-dt: move at91_initialize() to init_irq()
Quoted 7 lines · Russell King - ARM Linux
Quoted 6 lines · Nicolas Ferre
From: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Remove the need for
at91_initialize()to be called atinit_early(). We move it toinit_irq()function as we still need it before the timer initialization.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>Acked-by Nicolas Ferre <[email protected]>NAK. Keep the callback methods pure. The whole point of the
init_earlyis so that soc people don't end up polluting things like the IRQ initialization and timer initialization with stuff like this.So this is a backwards step.
ok we drop it in the pull
Best Regards,
J.
cover ARM: at91: two additional patches to cleanup series
In reply to Nicolas FerreHi,
I queue up two little paches for this cleanup series. They are dealing with Makefile.boot file and are more a kind of cosmetic modifications.
Those two will go just after the patch:
"[PATCH v2 18/19] ARM: at91/board-dt: drop default console" as the patch 19/19 will be dropped in the final draft of this series.
Best regards,
PATCH 1/2 ARM: at91: add at91sam9g25ek.dts in Makefile.boot
--- arch/arm/mach-at91/Makefile.boot | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/mach-at91/Makefile.boot +1 -0
@@ -14,3 +14,4 @@ initrd_phys-y := 0x20410000 endif dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9m10g45ek.dtb usb_a9g20.dtb +dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9g25ek.dtb
Signature · 1 line
1.7.9
PATCH 2/2 ARM: at91: properly sort dtb files in Makefile.boot
In reply to Nicolas FerreFrom: Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
--- arch/arm/mach-at91/Makefile.boot | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
arch/arm/mach-at91/Makefile.boot +6 -1
@@ -13,5 +13,10 @@ params_phys-y := 0x20000100 initrd_phys-y := 0x20410000 endif -dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9m10g45ek.dtb usb_a9g20.dtb +# Keep dtb files sorted alphabetically for each SoC +# sam9g20 +dtb-$(CONFIG_MACH_AT91SAM_DT) += usb_a9g20.dtb +# sam9g45 +dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9m10g45ek.dtb +# sam9x5 dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9g25ek.dtb
Signature · 1 line
1.7.9