ARM: at91: Further PIT improvements
Subsystems (4)
cover ARM: at91: Further PIT improvements
Hi,
These patches are meant to address Arnd comments and are based on Nicolas' at91-3.18-drivers2 branch.
They basically just remove the early_platform devices, and keep the old mechanism with a function exported by the PIT timer and called by the board files.
Thanks!
Maxime
Maxime Ripard (2):
ARM: at91: Revert "ARM: at91: PIT: Convert to an
early_platform_device"
ARM: at91: Give the PIT irq as an argument of at91sam926x_pit_init
arch/arm/mach-at91/at91sam9260.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9261.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9263.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9g45.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9rl.c | 30 ++------------------------- arch/arm/mach-at91/generic.h | 2 ++ drivers/clocksource/timer-atmel-pit.c | 38 ++++++++++++++--------------------- 7 files changed, 27 insertions(+), 163 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/2 ARM: at91: Revert "ARM: at91: PIT: Convert to an early_platform_device"
This reverts commit e3304055287e7e620439e89db9e3fdf107684de2.
The early_platform_device mechanism shouldn't be used anymore, and since that code is supposed to be removed soon, let's just rely on the at91sam926x_pit_init function.
Eventually, we will be able to kill the last global variable from this driver when we will remove at91sam926x_ioremap_pit and at91sam926x_pit_init.
--- arch/arm/mach-at91/at91sam9260.c | 30 ++------------------------ arch/arm/mach-at91/at91sam9261.c | 30 ++------------------------ arch/arm/mach-at91/at91sam9263.c | 30 ++------------------------ arch/arm/mach-at91/at91sam9g45.c | 30 ++------------------------ arch/arm/mach-at91/at91sam9rl.c | 30 ++------------------------ arch/arm/mach-at91/generic.h | 2 ++ drivers/clocksource/timer-atmel-pit.c | 40 +++++++++++++++-------------------- 7 files changed, 29 insertions(+), 163 deletions(-)
arch/arm/mach-at91/at91sam9260.c +2 -28
@@ -343,6 +343,7 @@ static void __init at91sam9260_map_io(void)static void __init at91sam9260_ioremap_registers (void ) {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 );at91_pm_set_standby (at91sam9_sdram_standby);
@@ -439,36 +440,9 @@ static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = { 0, /* Advanced Interrupt Controller */ }; -static struct resource pit_resources[] = { - [0 ] = { - .start =AT91SAM9260_BASE_PIT , - .end =AT91SAM9260_BASE_PIT +SZ_16 -1 , - .flags =IORESOURCE_MEM , - }, - [1 ] = { - .start =NR_IRQS_LEGACY +AT91_ID_SYS , - .end =NR_IRQS_LEGACY +AT91_ID_SYS , - .flags =IORESOURCE_IRQ , - }, -}; - -static struct platform_device pit_device = { - .name ="at91_pit" , - .resource = pit_resources, - .num_resources =ARRAY_SIZE (pit_resources), -}; - -static struct platform_device *at91sam9260_early_devices[]__initdata = { - &pit_device, -}; -static void __init at91sam9260_init_time (void ) { -early_platform_add_devices (at91sam9260_early_devices, -ARRAY_SIZE (at91sam9260_early_devices)); - -early_platform_driver_register_all ("earlytimer" ); -early_platform_driver_probe ("earlytimer" ,1 ,0 ); +at91sam926x_pit_init (); }AT91_SOC_START (at91sam9260)
arch/arm/mach-at91/at91sam9261.c +2 -28
@@ -302,6 +302,7 @@ static void __init at91sam9261_map_io(void)static void __init at91sam9261_ioremap_registers (void ) {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 );at91_pm_set_standby (at91sam9_sdram_standby);
@@ -398,36 +399,9 @@ static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = { 0, /* Advanced Interrupt Controller */ }; -static struct resource pit_resources[] = { - [0 ] = { - .start =AT91SAM9261_BASE_PIT , - .end =AT91SAM9261_BASE_PIT +SZ_16 -1 , - .flags =IORESOURCE_MEM , - }, - [1 ] = { - .start =NR_IRQS_LEGACY +AT91_ID_SYS , - .end =NR_IRQS_LEGACY +AT91_ID_SYS , - .flags =IORESOURCE_IRQ , - }, -}; - -static struct platform_device pit_device = { - .name ="at91_pit" , - .resource = pit_resources, - .num_resources =ARRAY_SIZE (pit_resources), -}; - -static struct platform_device *at91sam9261_early_devices[]__initdata = { - &pit_device, -}; -static void __init at91sam9261_init_time (void ) { -early_platform_add_devices (at91sam9261_early_devices, -ARRAY_SIZE (at91sam9261_early_devices)); - -early_platform_driver_register_all ("earlytimer" ); -early_platform_driver_probe ("earlytimer" ,1 ,0 ); +at91sam926x_pit_init (); }AT91_SOC_START (at91sam9261)
arch/arm/mach-at91/at91sam9263.c +2 -28
@@ -323,6 +323,7 @@ static void __init at91sam9263_ioremap_registers(void) {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 );at91_ioremap_matrix (AT91SAM9263_BASE_MATRIX );
@@ -421,36 +422,9 @@ static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = { 0, /* Advanced Interrupt Controller (IRQ1) */ }; -static struct resource pit_resources[] = { - [0 ] = { - .start =AT91SAM9263_BASE_PIT , - .end =AT91SAM9263_BASE_PIT +SZ_16 -1 , - .flags =IORESOURCE_MEM , - }, - [1 ] = { - .start =NR_IRQS_LEGACY +AT91_ID_SYS , - .end =NR_IRQS_LEGACY +AT91_ID_SYS , - .flags =IORESOURCE_IRQ , - }, -}; - -static struct platform_device pit_device = { - .name ="at91_pit" , - .resource = pit_resources, - .num_resources =ARRAY_SIZE (pit_resources), -}; - -static struct platform_device *at91sam9263_early_devices[]__initdata = { - &pit_device, -}; -static void __init at91sam9263_init_time (void ) { -early_platform_add_devices (at91sam9263_early_devices, -ARRAY_SIZE (at91sam9263_early_devices)); - -early_platform_driver_register_all ("earlytimer" ); -early_platform_driver_probe ("earlytimer" ,1 ,0 ); +at91sam926x_pit_init (); }AT91_SOC_START (at91sam9263)
arch/arm/mach-at91/at91sam9g45.c +2 -28
@@ -374,6 +374,7 @@ static void __init at91sam9g45_ioremap_registers(void) {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 );at91_pm_set_standby (at91_ddr_standby);
@@ -476,36 +477,9 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = { 0, /* Advanced Interrupt Controller (IRQ0) */ }; -static struct resource pit_resources[] = { - [0 ] = { - .start =AT91SAM9G45_BASE_PIT , - .end =AT91SAM9G45_BASE_PIT +SZ_16 -1 , - .flags =IORESOURCE_MEM , - }, - [1 ] = { - .start =NR_IRQS_LEGACY +AT91_ID_SYS , - .end =NR_IRQS_LEGACY +AT91_ID_SYS , - .flags =IORESOURCE_IRQ , - }, -}; - -static struct platform_device pit_device = { - .name ="at91_pit" , - .resource = pit_resources, - .num_resources =ARRAY_SIZE (pit_resources), -}; - -static struct platform_device *at91sam9g45_early_devices[]__initdata = { - &pit_device, -}; -static void __init at91sam9g45_init_time (void ) { -early_platform_add_devices (at91sam9g45_early_devices, -ARRAY_SIZE (at91sam9g45_early_devices)); - -early_platform_driver_register_all ("earlytimer" ); -early_platform_driver_probe ("earlytimer" ,1 ,0 ); +at91sam926x_pit_init (); }AT91_SOC_START (at91sam9g45)
arch/arm/mach-at91/at91sam9rl.c +2 -28
@@ -312,6 +312,7 @@ static void __init at91sam9rl_map_io(void)static void __init at91sam9rl_ioremap_registers (void ) {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 );at91_pm_set_standby (at91sam9_sdram_standby);
@@ -409,36 +410,9 @@ static unsigned int at91sam9rl_default_irq_priority[NR_AIC_IRQS] __initdata = { 0, /* Advanced Interrupt Controller */ }; -static struct resource pit_resources[] = { - [0 ] = { - .start =AT91SAM9RL_BASE_PIT , - .end =AT91SAM9RL_BASE_PIT +SZ_16 -1 , - .flags =IORESOURCE_MEM , - }, - [1 ] = { - .start =NR_IRQS_LEGACY +AT91_ID_SYS , - .end =NR_IRQS_LEGACY +AT91_ID_SYS , - .flags =IORESOURCE_IRQ , - }, -}; - -static struct platform_device pit_device = { - .name ="at91_pit" , - .resource = pit_resources, - .num_resources =ARRAY_SIZE (pit_resources), -}; - -static struct platform_device *at91sam9rl_early_devices[]__initdata = { - &pit_device, -}; -static void __init at91sam9rl_init_time (void ) { -early_platform_add_devices (at91sam9rl_early_devices, -ARRAY_SIZE (at91sam9rl_early_devices)); - -early_platform_driver_register_all ("earlytimer" ); -early_platform_driver_probe ("earlytimer" ,1 ,0 ); +at91sam926x_pit_init (); }AT91_SOC_START (at91sam9rl)
arch/arm/mach-at91/generic.h +2 -0
@@ -47,6 +47,8 @@ extern void __init at91_register_devices(void);extern void __init at91_init_time (void );extern void at91rm9200_ioremap_st (u32 addr);extern void at91rm9200_timer_init (void ); +extern void at91sam926x_ioremap_pit (u32 addr); +extern void at91sam926x_pit_init (void );extern void at91x40_timer_init (void );/* Clocks */
drivers/clocksource/timer-atmel-pit.c +17 -23
@@ -15,15 +15,15 @@#include <linux/clk.h> #include <linux/clockchips.h> #include <linux/interrupt.h> -#include <linux/ioport.h> #include <linux/irq.h> #include <linux/kernel.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> -#include <linux/platform_device.h> #include <linux/slab.h> +#include <mach/hardware.h> +#define AT91_PIT_MR 0x00/* Mode Register */ #define AT91_PIT_PITIEN BIT(25)/* Timer Interrupt Enable */ #define AT91_PIT_PITEN BIT(24)/* Timer Enabled */
@@ -265,40 +265,34 @@ static void __init at91sam926x_pit_dt_init(struct device_node *node)CLOCKSOURCE_OF_DECLARE (at91sam926x_pit,"atmel,at91sam9260-pit" , at91sam926x_pit_dt_init); -static int __init pit_early_probe (struct platform_device *pdev) +static void __iomem *pit_base_addr; + +void __init at91sam926x_pit_init (void ) {struct pit_data *data; -struct resource *res; data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)panic (pr_fmt ("Unable to allocate memory\n" )); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!request_mem_region (res->start,resource_size (res),"at91_pit" )) -panic (pr_fmt ("Unable to request memory region\n" )); - - data->base =ioremap (res->start,resource_size (res)); -if (!data->base) -panic (pr_fmt ("Impossible to ioremap PIT\n" )); + data->base = pit_base_addr; data->mck =clk_get (NULL ,"mck" );if (IS_ERR (data->mck))panic (pr_fmt ("Unable to get mck clk\n" )); - data->irq =platform_get_irq (pdev,0 ); -if (data->irq <0 ) -panic (pr_fmt ("Unable to get IRQ from resources\n" )); + data->irq =NR_IRQS_LEGACY +AT91_ID_SYS ;at91sam926x_pit_common_init (data); - -return 0 ; } -static struct platform_driver pit_driver__initdata = { - .probe = pit_early_probe, - .driver = { - .name ="at91_pit" , - }, -}; -early_platform_init ("earlytimer" , &pit_driver); +void __init at91sam926x_ioremap_pit (u32 addr) +{ +if (of_have_populated_dt ()) +return ; + + pit_base_addr =ioremap (addr,16 ); + +if (!pit_base_addr) +panic (pr_fmt ("Impossible to ioremap PIT\n" )); +}
Signature · 1 line
2.1.0
PATCH 2/2 ARM: at91: Give the PIT irq as an argument of at91sam926x_pit_init
In reply to Maxime RipardThis allows to remove the dependency of the timer driver on mach/hardware.h and having an hardcoded interrupt number in the driver itself.
--- arch/arm/mach-at91/at91sam9260.c | 2 +- arch/arm/mach-at91/at91sam9261.c | 2 +- arch/arm/mach-at91/at91sam9263.c | 2 +- arch/arm/mach-at91/at91sam9g45.c | 2 +- arch/arm/mach-at91/at91sam9rl.c | 2 +- arch/arm/mach-at91/generic.h | 2 +- drivers/clocksource/timer-atmel-pit.c | 6 ++---- 7 files changed, 8 insertions(+), 10 deletions(-)
arch/arm/mach-at91/at91sam9260.c +1 -1
@@ -442,7 +442,7 @@ static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {static void __init at91sam9260_init_time (void ) { -at91sam926x_pit_init (); +at91sam926x_pit_init (NR_IRQS_LEGACY +AT91_ID_SYS ); }AT91_SOC_START (at91sam9260)
arch/arm/mach-at91/at91sam9261.c +1 -1
@@ -401,7 +401,7 @@ static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {static void __init at91sam9261_init_time (void ) { -at91sam926x_pit_init (); +at91sam926x_pit_init (NR_IRQS_LEGACY +AT91_ID_SYS ); }AT91_SOC_START (at91sam9261)
arch/arm/mach-at91/at91sam9263.c +1 -1
@@ -424,7 +424,7 @@ static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = {static void __init at91sam9263_init_time (void ) { -at91sam926x_pit_init (); +at91sam926x_pit_init (NR_IRQS_LEGACY +AT91_ID_SYS ); }AT91_SOC_START (at91sam9263)
arch/arm/mach-at91/at91sam9g45.c +1 -1
@@ -479,7 +479,7 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = {static void __init at91sam9g45_init_time (void ) { -at91sam926x_pit_init (); +at91sam926x_pit_init (NR_IRQS_LEGACY +AT91_ID_SYS ); }AT91_SOC_START (at91sam9g45)
arch/arm/mach-at91/at91sam9rl.c +1 -1
@@ -412,7 +412,7 @@ static unsigned int at91sam9rl_default_irq_priority[NR_AIC_IRQS] __initdata = {static void __init at91sam9rl_init_time (void ) { -at91sam926x_pit_init (); +at91sam926x_pit_init (NR_IRQS_LEGACY +AT91_ID_SYS ); }AT91_SOC_START (at91sam9rl)
arch/arm/mach-at91/generic.h +1 -1
@@ -48,7 +48,7 @@ extern void __init at91_init_time(void);extern void at91rm9200_ioremap_st (u32 addr);extern void at91rm9200_timer_init (void );extern void at91sam926x_ioremap_pit (u32 addr); -extern void at91sam926x_pit_init (void ); +extern void at91sam926x_pit_init (int irq);extern void at91x40_timer_init (void );/* Clocks */
drivers/clocksource/timer-atmel-pit.c +2 -4
@@ -22,8 +22,6 @@#include <linux/of_irq.h> #include <linux/slab.h> -#include <mach/hardware.h> -#define AT91_PIT_MR 0x00/* Mode Register */ #define AT91_PIT_PITIEN BIT(25)/* Timer Interrupt Enable */ #define AT91_PIT_PITEN BIT(24)/* Timer Enabled */
@@ -267,7 +265,7 @@ CLOCKSOURCE_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",static void __iomem *pit_base_addr; -void __init at91sam926x_pit_init (void ) +void __init at91sam926x_pit_init (int irq) {struct pit_data *data;
@@ -281,7 +279,7 @@ void __init at91sam926x_pit_init(void)if (IS_ERR (data->mck))panic (pr_fmt ("Unable to get mck clk\n" )); - data->irq =NR_IRQS_LEGACY +AT91_ID_SYS ; + data->irq = irq;at91sam926x_pit_common_init (data); }
Signature · 1 line
2.1.0
cover ARM: at91: Further PIT improvements
In reply to Maxime RipardQuoted 7 lines · Maxime Ripard
These patches are meant to address Arnd comments and are based on Nicolas' at91-3.18-drivers2 branch.
They basically just remove the
early_platformdevices, and keep the old mechanism with a function exported by the PIT timer and called by the board files.
Looks good to me,
cover ARM: at91: Further PIT improvements
On 15/09/2014 18:52, Arnd Bergmann :
Quoted 10 lines · Maxime Ripard
Quoted 7 lines
These patches are meant to address Arnd comments and are based on Nicolas' at91-3.18-drivers2 branch.
They basically just remove the
early_platformdevices, and keep the old mechanism with a function exported by the PIT timer and called by the board files.
Quoted 3 lines
Looks good to me,
Acked-by Arnd Bergmann <[email protected]>
Thanks Arnd: feel free to add your tag to the patches in the pull-request that I've sent ([GIT PULL] at91: drivers for 3.18 #2 (bis)).
Best regards,
Signature · 1 line
Nicolas Ferre
cover ARM: at91: Further PIT improvements
In reply to Maxime RipardOn 15/09/2014 16:02, Maxime Ripard :
Quoted 9 lines
Hi,
These patches are meant to address Arnd comments and are based on Nicolas' at91-3.18-drivers2 branch.
They basically just remove the
early_platformdevices, and keep the old mechanism with a function exported by the PIT timer and called by the board files.
Quoted 7 lines
Thanks!
MaximeMaxime Ripard (2):
ARM: at91: Revert "ARM: at91: PIT: Convert to an
early_platform_device"
ARM: at91: Give the PIT irq as an argument ofat91sam926x_pit_init
Ok, I squash these modifications in your previous series and resend a PR right now.
Thanks, best regards,
Quoted 9 lines
arch/arm/mach-at91/at91sam9260.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9261.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9263.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9g45.c | 30 ++------------------------- arch/arm/mach-at91/at91sam9rl.c | 30 ++------------------------- arch/arm/mach-at91/generic.h | 2 ++ drivers/clocksource/timer-atmel-pit.c | 38 ++++++++++++++--------------------- 7 files changed, 27 insertions(+), 163 deletions(-)
Signature · 1 line
Nicolas Ferre