Skip to content

Commit

Permalink
Merge tag 'at91-fixes-non-critical' of git://github.com/at91linux/lin…
Browse files Browse the repository at this point in the history
…ux-at91 into fixes

From Nicolas Ferre, fixes for early boot hangs on at91:

Fixes for RTT & RTC interrupts that can fire early during boot process
and kill the system.

* tag 'at91-fixes-non-critical' of git://github.com/at91linux/linux-at91:
  ARM: at91: fix hanged boot due to early rtt-interrupt
  ARM: at91: fix hanged boot due to early rtc-interrupt
  • Loading branch information
Olof Johansson committed Nov 15, 2013
2 parents ba52b7d + 94c4c79 commit ca439c9
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion arch/arm/mach-at91/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Makefile for the linux kernel.
#

obj-y := irq.o gpio.o setup.o
obj-y := irq.o gpio.o setup.o sysirq_mask.o
obj-m :=
obj-n :=
obj- :=
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-at91/at91sam9260.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ static void __init at91sam9260_initialize(void)
arm_pm_idle = at91sam9_idle;
arm_pm_restart = at91sam9_alt_restart;

at91_sysirq_mask_rtt(AT91SAM9260_BASE_RTT);

/* Register GPIO subsystem */
at91_gpio_init(at91sam9260_gpio, 3);
}
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-at91/at91sam9261.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ static void __init at91sam9261_initialize(void)
arm_pm_idle = at91sam9_idle;
arm_pm_restart = at91sam9_alt_restart;

at91_sysirq_mask_rtt(AT91SAM9261_BASE_RTT);

/* Register GPIO subsystem */
at91_gpio_init(at91sam9261_gpio, 3);
}
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/mach-at91/at91sam9263.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ static void __init at91sam9263_initialize(void)
arm_pm_idle = at91sam9_idle;
arm_pm_restart = at91sam9_alt_restart;

at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT0);
at91_sysirq_mask_rtt(AT91SAM9263_BASE_RTT1);

/* Register GPIO subsystem */
at91_gpio_init(at91sam9263_gpio, 5);
}
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/mach-at91/at91sam9g45.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ static void __init at91sam9g45_initialize(void)
arm_pm_idle = at91sam9_idle;
arm_pm_restart = at91sam9g45_restart;

at91_sysirq_mask_rtc(AT91SAM9G45_BASE_RTC);
at91_sysirq_mask_rtt(AT91SAM9G45_BASE_RTT);

/* Register GPIO subsystem */
at91_gpio_init(at91sam9g45_gpio, 5);
}
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/mach-at91/at91sam9n12.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@ static void __init at91sam9n12_map_io(void)
at91_init_sram(0, AT91SAM9N12_SRAM_BASE, AT91SAM9N12_SRAM_SIZE);
}

static void __init at91sam9n12_initialize(void)
{
at91_sysirq_mask_rtc(AT91SAM9N12_BASE_RTC);
}

AT91_SOC_START(at91sam9n12)
.map_io = at91sam9n12_map_io,
.register_clocks = at91sam9n12_register_clocks,
.init = at91sam9n12_initialize,
AT91_SOC_END
3 changes: 3 additions & 0 deletions arch/arm/mach-at91/at91sam9rl.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ static void __init at91sam9rl_initialize(void)
arm_pm_idle = at91sam9_idle;
arm_pm_restart = at91sam9_alt_restart;

at91_sysirq_mask_rtc(AT91SAM9RL_BASE_RTC);
at91_sysirq_mask_rtt(AT91SAM9RL_BASE_RTT);

/* Register GPIO subsystem */
at91_gpio_init(at91sam9rl_gpio, 4);
}
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/mach-at91/at91sam9x5.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,17 @@ static void __init at91sam9x5_map_io(void)
at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE);
}

static void __init at91sam9x5_initialize(void)
{
at91_sysirq_mask_rtc(AT91SAM9X5_BASE_RTC);
}

/* --------------------------------------------------------------------
* Interrupt initialization
* -------------------------------------------------------------------- */

AT91_SOC_START(at91sam9x5)
.map_io = at91sam9x5_map_io,
.register_clocks = at91sam9x5_register_clocks,
.init = at91sam9x5_initialize,
AT91_SOC_END
2 changes: 2 additions & 0 deletions arch/arm/mach-at91/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ extern int __init at91_aic_of_init(struct device_node *node,
struct device_node *parent);
extern int __init at91_aic5_of_init(struct device_node *node,
struct device_node *parent);
extern void __init at91_sysirq_mask_rtc(u32 rtc_base);
extern void __init at91_sysirq_mask_rtt(u32 rtt_base);


/* Timer */
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/mach-at91/include/mach/at91sam9n12.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
#define AT91SAM9N12_BASE_USART2 0xf8024000
#define AT91SAM9N12_BASE_USART3 0xf8028000

/*
* System Peripherals
*/
#define AT91SAM9N12_BASE_RTC 0xfffffeb0

/*
* Internal Memory.
*/
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/mach-at91/include/mach/at91sam9x5.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
#define AT91SAM9X5_BASE_USART1 0xf8020000
#define AT91SAM9X5_BASE_USART2 0xf8024000

/*
* System Peripherals
*/
#define AT91SAM9X5_BASE_RTC 0xfffffeb0

/*
* Internal Memory.
*/
Expand Down
5 changes: 5 additions & 0 deletions arch/arm/mach-at91/include/mach/sama5d3.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
#define SAMA5D3_BASE_USART2 0xf8020000
#define SAMA5D3_BASE_USART3 0xf8024000

/*
* System Peripherals
*/
#define SAMA5D3_BASE_RTC 0xfffffeb0

/*
* Internal Memory
*/
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/mach-at91/sama5d3.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,13 @@ static void __init sama5d3_map_io(void)
at91_init_sram(0, SAMA5D3_SRAM_BASE, SAMA5D3_SRAM_SIZE);
}

static void __init sama5d3_initialize(void)
{
at91_sysirq_mask_rtc(SAMA5D3_BASE_RTC);
}

AT91_SOC_START(sama5d3)
.map_io = sama5d3_map_io,
.register_clocks = sama5d3_register_clocks,
.init = sama5d3_initialize,
AT91_SOC_END
71 changes: 71 additions & 0 deletions arch/arm/mach-at91/sysirq_mask.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* sysirq_mask.c - System-interrupt masking
*
* Copyright (C) 2013 Johan Hovold <jhovold@gmail.com>
*
* Functions to disable system interrupts from backup-powered peripherals.
*
* The RTC and RTT-peripherals are generally powered by backup power (VDDBU)
* and are not reset on wake-up, user, watchdog or software reset. This means
* that their interrupts may be enabled during early boot (e.g. after a user
* reset).
*
* As the RTC and RTT share the system-interrupt line with the PIT, an
* interrupt occurring before a handler has been installed would lead to the
* system interrupt being disabled and prevent the system from booting.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/

#include <linux/io.h>
#include <mach/at91_rtt.h>

#include "generic.h"

#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */

void __init at91_sysirq_mask_rtc(u32 rtc_base)
{
void __iomem *base;
u32 mask;

base = ioremap(rtc_base, 64);
if (!base)
return;

mask = readl_relaxed(base + AT91_RTC_IMR);
if (mask) {
pr_info("AT91: Disabling rtc irq\n");
writel_relaxed(mask, base + AT91_RTC_IDR);
(void)readl_relaxed(base + AT91_RTC_IMR); /* flush */
}

iounmap(base);
}

void __init at91_sysirq_mask_rtt(u32 rtt_base)
{
void __iomem *base;
void __iomem *reg;
u32 mode;

base = ioremap(rtt_base, 16);
if (!base)
return;

reg = base + AT91_RTT_MR;

mode = readl_relaxed(reg);
if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) {
pr_info("AT91: Disabling rtt irq\n");
mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
writel_relaxed(mode, reg);
(void)readl_relaxed(reg); /* flush */
}

iounmap(base);
}

0 comments on commit ca439c9

Please sign in to comment.