AT91: Convert WDT driver to be independent of processor base-address
Subsystems (4)
For supporting multiple AT91 processors in a single kernel image, the following changes to the WDT driver support:
* pass base addresses via platform resources
* replace calls to at91_sys_read() / at91_sys_write()
* rename AT91_WDT to AT91xxx_WDT to denote they are processor-specific
definitions.
arch/arm/mach-at91/at572d940hf_devices.c +11 -1
@@ -628,10 +628,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT572D940HF_WDT , + .end =AT91_VA_BASE_SYS +AT572D940HF_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at572d940hf_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )
arch/arm/mach-at91/at91cap9_devices.c +11 -1
@@ -698,10 +698,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91CAP9_WDT , + .end =AT91_VA_BASE_SYS +AT91CAP9_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91cap9_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )
arch/arm/mach-at91/at91sam9260_devices.c +11 -1
@@ -740,10 +740,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9260_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9260_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9260_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )
arch/arm/mach-at91/at91sam9261_devices.c +11 -1
@@ -622,10 +622,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9261_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9261_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9261_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )
arch/arm/mach-at91/at91sam9263_devices.c +11 -1
@@ -996,10 +996,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9263_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9263_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9263_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )
arch/arm/mach-at91/at91sam9g45_devices.c +11 -1
@@ -1120,10 +1120,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9G45_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9G45_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9g45_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )
arch/arm/mach-at91/at91sam9rl_devices.c +11 -1
@@ -726,10 +726,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9RL_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9RL_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9rl_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )
arch/arm/mach-at91/include/mach/at572d940hf.h +1 -1
@@ -101,7 +101,7 @@#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)#define AT572D940HF_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT572D940HF_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_USART0 AT572D940HF_ID_US0#define AT91_USART1 AT572D940HF_ID_US1
arch/arm/mach-at91/include/mach/at91_wdt.h +3 -3
@@ -16,11 +16,11 @@#ifndef AT91_WDT_H #define AT91_WDT_H -#define AT91_WDT_CR (AT91_WDT + 0x00)/* Watchdog Control Register */ +#define AT91_WDT_CR 0x00/* Watchdog Control Register */ #define AT91_WDT_WDRSTT (1 << 0)/* Restart */ #define AT91_WDT_KEY (0xa5 << 24)/* KEY Password */ -#define AT91_WDT_MR (AT91_WDT + 0x04)/* Watchdog Mode Register */ +#define AT91_WDT_MR 0x04/* Watchdog Mode Register */ #define AT91_WDT_WDV (0xfff << 0)/* Counter Value */ #define AT91_WDT_WDFIEN (1 << 12)/* Fault Interrupt Enable */ #define AT91_WDT_WDRSTEN (1 << 13)/* Reset Processor */
@@ -30,7 +30,7 @@#define AT91_WDT_WDDBGHLT (1 << 28)/* Debug Halt */ #define AT91_WDT_WDIDLEHLT (1 << 29)/* Idle Halt */ -#define AT91_WDT_SR (AT91_WDT + 0x08)/* Watchdog Status Register */ +#define AT91_WDT_SR 0x08/* Watchdog Status Register */ #define AT91_WDT_WDUNF (1 << 0)/* Watchdog Underflow */ #define AT91_WDT_WDERR (1 << 1)/* Watchdog Error */
arch/arm/mach-at91/include/mach/at91cap9.h +1 -1
@@ -100,7 +100,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91CAP9_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91CAP9_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (cpu_is_at91cap9_revB() ? \ (0xfffffd50 - AT91_BASE_SYS) : \ (0xfffffd60 - AT91_BASE_SYS))
arch/arm/mach-at91/include/mach/at91sam9260.h +1 -1
@@ -98,7 +98,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9260_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9260_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91_USART0 AT91SAM9260_BASE_US0
arch/arm/mach-at91/include/mach/at91sam9261.h +1 -1
@@ -81,7 +81,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9261_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9261_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91_USART0 AT91SAM9261_BASE_US0
arch/arm/mach-at91/include/mach/at91sam9263.h +1 -1
@@ -97,7 +97,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9263_RTT0 (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9263_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91SAM9263_RTT1 (0xfffffd50 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
arch/arm/mach-at91/include/mach/at91sam9g45.h +1 -1
@@ -107,7 +107,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9G45_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9G45_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9G45_RTC (0xfffffdb0 - AT91_BASE_SYS)
arch/arm/mach-at91/include/mach/at91sam9rl.h +1 -1
@@ -89,7 +89,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9RL_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9RL_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9RL_RTC (0xfffffe00 - AT91_BASE_SYS)
drivers/watchdog/at91sam9_wdt.c +11 -3
@@ -67,6 +67,7 @@ static struct {unsigned long open;char expect_close;struct timer_list timer;/* The timer that pings the watchdog */ +void __iomem *regbase;/* base address of WDT */ } at91wdt_private;/* ......................................................................... */
@@ -77,7 +78,8 @@ static struct {*/ static inline void at91_wdt_reset (void ) { -at91_sys_write (AT91_WDT_CR ,AT91_WDT_KEY |AT91_WDT_WDRSTT ); +__raw_writel (AT91_WDT_KEY |AT91_WDT_WDRSTT , + at91wdt_private.regbase +AT91_WDT_CR ); }/*
@@ -132,7 +134,7 @@ static int at91_wdt_settimeout(unsigned int timeout)unsigned int mr;/* Check if disabled */ - mr =at91_sys_read (AT91_WDT_MR ); + mr =__raw_readl (at91wdt_private.regbase +AT91_WDT_MR );if (mr &AT91_WDT_WDDIS ) { printk(KERN_ERR DRV_NAME": sorry, watchdog is disabled\n");return -EIO ;
@@ -149,7 +151,7 @@ static int at91_wdt_settimeout(unsigned int timeout) | AT91_WDT_WDDBGHLT /* disabled in debug mode */ |AT91_WDT_WDD /* restart@any time */ | (timeout &AT91_WDT_WDV );/* timer value */ -at91_sys_write (AT91_WDT_MR , reg); +__raw_writel (reg, at91wdt_private.regbase +AT91_WDT_MR );return 0 ; }
@@ -248,11 +250,17 @@ static struct miscdevice at91wdt_miscdev = {static int __init at91wdt_probe (struct platform_device *pdev) { +struct resource *r;int res; + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) +return -ENODEV ; +if (at91wdt_miscdev.parent)return -EBUSY ; at91wdt_miscdev.parent = &pdev->dev; + at91wdt_private.regbase = (void __force __iomem *) r->start;/* Set watchdog */ res =at91_wdt_settimeout (ms_to_ticks (WDT_HW_TIMEOUT *1000 ));
Ryan Mallon
Acked-byQuoted 8 lines · Andrew Victor
For supporting multiple AT91 processors in a single kernel image, the following changes to the WDT driver support:
* pass base addresses via platform resources
* replace calls toat91_sys_read()/at91_sys_write()
* renameAT91_WDTtoAT91xxx_WDTto denote they are processor-specific
definitions.Signed-off-by Andrew Victor <[email protected]>
Quoted 365 lines
arch/arm/mach-at91/at572d940hf_devices.c +11
-1@@ -628,10 +628,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT572D940HF_WDT , + .end =AT91_VA_BASE_SYS +AT572D940HF_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at572d940hf_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )arch/arm/mach-at91/at91cap9_devices.c +11
-1@@ -698,10 +698,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91CAP9_WDT , + .end =AT91_VA_BASE_SYS +AT91CAP9_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91cap9_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )arch/arm/mach-at91/at91sam9260_devices.c +11
-1@@ -740,10 +740,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9260_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9260_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9260_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )arch/arm/mach-at91/at91sam9261_devices.c +11
-1@@ -622,10 +622,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9261_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9261_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9261_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )arch/arm/mach-at91/at91sam9263_devices.c +11
-1@@ -996,10 +996,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9263_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9263_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9263_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )arch/arm/mach-at91/at91sam9g45_devices.c +11
-1@@ -1120,10 +1120,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9G45_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9G45_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9g45_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )arch/arm/mach-at91/at91sam9rl_devices.c +11
-1@@ -726,10 +726,20 @@ static void __init at91_add_device_rtt(void)* -------------------------------------------------------------------- */ #if defined(CONFIG_AT91SAM9X_WATCHDOG ) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE ) + +static struct resource wdt_resources[] = { + { + .start =AT91_VA_BASE_SYS +AT91SAM9RL_WDT , + .end =AT91_VA_BASE_SYS +AT91SAM9RL_WDT +SZ_16 -1 , + .flags =IORESOURCE_MEM , + } +}; +static struct platform_device at91sam9rl_wdt_device = { .name ="at91_wdt" , .id =-1 , - .num_resources =0 , + .resource = wdt_resources, + .num_resources =ARRAY_SIZE (wdt_resources), };static void __init at91_add_device_watchdog (void )arch/arm/mach-at91/include/mach/at572d940hf.h +1
-1@@ -101,7 +101,7 @@#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)#define AT572D940HF_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT572D940HF_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_USART0 AT572D940HF_ID_US0#define AT91_USART1 AT572D940HF_ID_US1arch/arm/mach-at91/include/mach/at91_wdt.h +3
-3@@ -16,11 +16,11 @@#ifndef AT91_WDT_H #define AT91_WDT_H -#define AT91_WDT_CR (AT91_WDT + 0x00)/* Watchdog Control Register */ +#define AT91_WDT_CR 0x00/* Watchdog Control Register */ #define AT91_WDT_WDRSTT (1 << 0)/* Restart */ #define AT91_WDT_KEY (0xa5 << 24)/* KEY Password */ -#define AT91_WDT_MR (AT91_WDT + 0x04)/* Watchdog Mode Register */ +#define AT91_WDT_MR 0x04/* Watchdog Mode Register */ #define AT91_WDT_WDV (0xfff << 0)/* Counter Value */ #define AT91_WDT_WDFIEN (1 << 12)/* Fault Interrupt Enable */ #define AT91_WDT_WDRSTEN (1 << 13)/* Reset Processor */ @@ -30,7 +30,7 @@#define AT91_WDT_WDDBGHLT (1 << 28)/* Debug Halt */ #define AT91_WDT_WDIDLEHLT (1 << 29)/* Idle Halt */ -#define AT91_WDT_SR (AT91_WDT + 0x08)/* Watchdog Status Register */ +#define AT91_WDT_SR 0x08/* Watchdog Status Register */ #define AT91_WDT_WDUNF (1 << 0)/* Watchdog Underflow */ #define AT91_WDT_WDERR (1 << 1)/* Watchdog Error */ arch/arm/mach-at91/include/mach/at91cap9.h +1
-1@@ -100,7 +100,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91CAP9_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91CAP9_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (cpu_is_at91cap9_revB() ? \ (0xfffffd50 - AT91_BASE_SYS) : \ (0xfffffd60 - AT91_BASE_SYS))arch/arm/mach-at91/include/mach/at91sam9260.h +1
-1@@ -98,7 +98,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9260_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9260_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91_USART0 AT91SAM9260_BASE_US0arch/arm/mach-at91/include/mach/at91sam9261.h +1
-1@@ -81,7 +81,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9261_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9261_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)#define AT91_USART0 AT91SAM9261_BASE_US0arch/arm/mach-at91/include/mach/at91sam9263.h +1
-1@@ -97,7 +97,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9263_RTT0 (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9263_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91SAM9263_RTT1 (0xfffffd50 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)arch/arm/mach-at91/include/mach/at91sam9g45.h +1
-1@@ -107,7 +107,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9G45_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9G45_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9G45_RTC (0xfffffdb0 - AT91_BASE_SYS)arch/arm/mach-at91/include/mach/at91sam9rl.h +1
-1@@ -89,7 +89,7 @@#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)#define AT91SAM9RL_RTT (0xfffffd20 - AT91_BASE_SYS)#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS) -#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS) +#define AT91SAM9RL_WDT (0xfffffd40 - AT91_BASE_SYS)#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS)#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)#define AT91SAM9RL_RTC (0xfffffe00 - AT91_BASE_SYS)drivers/watchdog/at91sam9_wdt.c +11
-3@@ -67,6 +67,7 @@ static struct {unsigned long open;char expect_close;struct timer_list timer;/* The timer that pings the watchdog */ +void __iomem *regbase;/* base address of WDT */ } at91wdt_private;/* ......................................................................... */ @@ -77,7 +78,8 @@ static struct {*/ static inline void at91_wdt_reset (void ) { -at91_sys_write (AT91_WDT_CR ,AT91_WDT_KEY |AT91_WDT_WDRSTT ); +__raw_writel (AT91_WDT_KEY |AT91_WDT_WDRSTT , + at91wdt_private.regbase +AT91_WDT_CR ); }/* @@ -132,7 +134,7 @@ static int at91_wdt_settimeout(unsigned int timeout)unsigned int mr;/* Check if disabled */ - mr =at91_sys_read (AT91_WDT_MR ); + mr =__raw_readl (at91wdt_private.regbase +AT91_WDT_MR );if (mr &AT91_WDT_WDDIS ) { printk(KERN_ERR DRV_NAME": sorry, watchdog is disabled\n");return -EIO ;@@ -149,7 +151,7 @@ static int at91_wdt_settimeout(unsigned int timeout) | AT91_WDT_WDDBGHLT /* disabled in debug mode */ |AT91_WDT_WDD /* restart at any time */ | (timeout &AT91_WDT_WDV );/* timer value */ -at91_sys_write (AT91_WDT_MR , reg); +__raw_writel (reg, at91wdt_private.regbase +AT91_WDT_MR );return 0 ; }@@ -248,11 +250,17 @@ static struct miscdevice at91wdt_miscdev = {static int __init at91wdt_probe (struct platform_device *pdev) { +struct resource *r;int res; + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) +return -ENODEV ; +if (at91wdt_miscdev.parent)return -EBUSY ; at91wdt_miscdev.parent = &pdev->dev; + at91wdt_private.regbase = (void __force __iomem *) r->start;/* Set watchdog */ res =at91_wdt_settimeout (ms_to_ticks (WDT_HW_TIMEOUT *1000 ));_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 7 lines
Bluewater Systems Ltd - ARM Technology Solution Centre Ryan Mallon 5 Amuri Park, 404 Barbadoes St ryan at bluewatersys.com PO Box 13 889, Christchurch 8013 http://www.bluewatersys.com New Zealand Phone: +64 3 3779127 Freecall: Australia 1800 148 751 Fax: +64 3 3779135 USA 1800 261 2934
Quoted 5 lines · Andrew Victor
drivers/watchdog/at91sam9_wdt.c +1
-0@@ -248,11 +250,17 @@ static struct miscdevice at91wdt_miscdev = {static int __init at91wdt_probe (struct platform_device *pdev) { +struct resource *r;
drivers/watchdog/at91sam9_wdt.c static struct miscdevice at91wdt_miscdev = { · line 263
Quoted 10 lines
drivers/watchdog/at91sam9_wdt.c +5
-0int res; + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) +return -ENODEV ; +if (at91wdt_miscdev.parent)return -EBUSY ; at91wdt_miscdev.parent = &pdev->dev; + at91wdt_private.regbase = (void __force __iomem *) r->start;
Passing virtual addresses through iomem resources really isn't nice - they get added to the resource tree as bus addresses, which actually being virtual addresses can conflict with real bus addresses.
The proper way to handle this is like every other platform driver, and to use ioremap() on the resource to obtain a virtual mapping for the device.
If you wish to reuse your fixed io mapping, then override ioremap() in a similar way to OMAP and arrange for bus addresses in the fixed io mapping to return an appropriate iomem pointer for those.
Quoted 21 lines · Russell King - ARM Linux
Quoted 5 lines · Andrew Victor
drivers/watchdog/at91sam9_wdt.c +1
-0@@ -248,11 +250,17 @@ static struct miscdevice at91wdt_miscdev = {static int __init at91wdt_probe (struct platform_device *pdev) { +struct resource *r;drivers/watchdog/at91sam9_wdt.c static struct miscdevice at91wdt_miscdev = { · line 263
Quoted 10 lines
drivers/watchdog/at91sam9_wdt.c +5
-0int res; + r =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!r) +return -ENODEV ; +if (at91wdt_miscdev.parent)return -EBUSY ; at91wdt_miscdev.parent = &pdev->dev; + at91wdt_private.regbase = (void __force __iomem *) r->start;Passing virtual addresses through iomem resources really isn't nice - they get added to the resource tree as bus addresses, which actually being virtual addresses can conflict with real bus addresses.
Quoted 6 lines
The proper way to handle this is like every other platform driver, and to use
ioremap()on the resource to obtain a virtual mapping for the device.If you wish to reuse your fixed io mapping, then override
ioremap()in a similar way to OMAP and arrange for bus addresses in the fixed io mapping to return an appropriate iomem pointer for those.
ok will update
Best Regards,
J.