From 7538ec7d1e5990f719538aeec9c021ba694040d9 Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Tue, 21 Oct 2014 14:16:54 +0200 Subject: ARM: at91: remove no-MMU at91x40 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As there is currently no-one to take care of this old !MMU target and as its support in recent kernels is a bit rotten, remove this at91x40 support and the board file associated with it (at91eb01). There are modern ARM !MMU in Mainline now so this target is not interesting for building tests anymore. It would be better to start from these modern ARM !MMU platforms to reintroduce at91x40 support if needed. Signed-off-by: Nicolas Ferre Acked-by: Arnd Bergmann Acked-by: Greg Ungerer Acked-by: Uwe Kleine-König --- arch/arm/mach-at91/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arm/mach-at91/setup.c') diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index 961079250b83..a78fbb7b13c9 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c @@ -418,7 +418,7 @@ void __init at91_ioremap_matrix(u32 base_addr) panic(pr_fmt("Impossible to ioremap at91_matrix_base\n")); } -#if defined(CONFIG_OF) && !defined(CONFIG_ARCH_AT91X40) +#if defined(CONFIG_OF) static struct of_device_id ramc_ids[] = { { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby }, { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby }, -- cgit v1.2.3 From ff78a189b0ae55f258f020a428c834250eb8f834 Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Wed, 26 Nov 2014 17:19:14 +0100 Subject: ARM: at91: remove old at91-specific clock driver This clock driver collection was specific to AT91 and only used in !DT cases. All clocks and the clock trees for all Atmel SoCs are now described by drivers using the common clock framework. Signed-off-by: Nicolas Ferre Acked-by: Boris BREZILLON --- arch/arm/mach-at91/Makefile | 1 - arch/arm/mach-at91/clock.c | 977 ------------------------------------------- arch/arm/mach-at91/clock.h | 49 --- arch/arm/mach-at91/generic.h | 11 - arch/arm/mach-at91/setup.c | 9 - 5 files changed, 1047 deletions(-) delete mode 100644 arch/arm/mach-at91/clock.c delete mode 100644 arch/arm/mach-at91/clock.h (limited to 'arch/arm/mach-at91/setup.c') diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index edc5b21f2157..b486c7760ac4 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -5,7 +5,6 @@ obj-y := gpio.o setup.o sysirq_mask.o obj-$(CONFIG_OLD_IRQ_AT91) += irq.o -obj-$(CONFIG_OLD_CLK_AT91) += clock.o obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o # CPU-specific support diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c deleted file mode 100644 index d66f102c352a..000000000000 --- a/arch/arm/mach-at91/clock.c +++ /dev/null @@ -1,977 +0,0 @@ -/* - * linux/arch/arm/mach-at91/clock.c - * - * Copyright (C) 2005 David Brownell - * Copyright (C) 2005 Ivan Kokshaysky - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "clock.h" -#include "generic.h" - -void __iomem *at91_pmc_base; -EXPORT_SYMBOL_GPL(at91_pmc_base); - -/* - * There's a lot more which can be done with clocks, including cpufreq - * integration, slow clock mode support (for system suspend), letting - * PLLB be used at other rates (on boards that don't need USB), etc. - */ - -#define clk_is_primary(x) ((x)->type & CLK_TYPE_PRIMARY) -#define clk_is_programmable(x) ((x)->type & CLK_TYPE_PROGRAMMABLE) -#define clk_is_peripheral(x) ((x)->type & CLK_TYPE_PERIPHERAL) -#define clk_is_sys(x) ((x)->type & CLK_TYPE_SYSTEM) - - -/* - * Chips have some kind of clocks : group them by functionality - */ -#define cpu_has_utmi() ( cpu_is_at91sam9rl() \ - || cpu_is_at91sam9g45() \ - || cpu_is_at91sam9x5() \ - || cpu_is_sama5d3()) - -#define cpu_has_1056M_plla() (cpu_is_sama5d3()) - -#define cpu_has_800M_plla() ( cpu_is_at91sam9g20() \ - || cpu_is_at91sam9g45() \ - || cpu_is_at91sam9x5() \ - || cpu_is_at91sam9n12()) - -#define cpu_has_300M_plla() (cpu_is_at91sam9g10()) - -#define cpu_has_240M_plla() (cpu_is_at91sam9261() \ - || cpu_is_at91sam9263() \ - || cpu_is_at91sam9rl()) - -#define cpu_has_210M_plla() (cpu_is_at91sam9260()) - -#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \ - || cpu_is_at91sam9g45() \ - || cpu_is_at91sam9x5() \ - || cpu_is_sama5d3())) - -#define cpu_has_upll() (cpu_is_at91sam9g45() \ - || cpu_is_at91sam9x5() \ - || cpu_is_sama5d3()) - -/* USB host HS & FS */ -#define cpu_has_uhp() (!cpu_is_at91sam9rl()) - -/* USB device FS only */ -#define cpu_has_udpfs() (!(cpu_is_at91sam9rl() \ - || cpu_is_at91sam9g45() \ - || cpu_is_at91sam9x5() \ - || cpu_is_sama5d3())) - -#define cpu_has_plladiv2() (cpu_is_at91sam9g45() \ - || cpu_is_at91sam9x5() \ - || cpu_is_at91sam9n12() \ - || cpu_is_sama5d3()) - -#define cpu_has_mdiv3() (cpu_is_at91sam9g45() \ - || cpu_is_at91sam9x5() \ - || cpu_is_at91sam9n12() \ - || cpu_is_sama5d3()) - -#define cpu_has_alt_prescaler() (cpu_is_at91sam9x5() \ - || cpu_is_at91sam9n12() \ - || cpu_is_sama5d3()) - -static LIST_HEAD(clocks); -static DEFINE_SPINLOCK(clk_lock); - -static u32 at91_pllb_usb_init; - -/* - * Four primary clock sources: two crystal oscillators (32K, main), and - * two PLLs. PLLA usually runs the master clock; and PLLB must run at - * 48 MHz (unless no USB function clocks are needed). The main clock and - * both PLLs are turned off to run in "slow clock mode" (system suspend). - */ -static struct clk clk32k = { - .name = "clk32k", - .rate_hz = AT91_SLOW_CLOCK, - .users = 1, /* always on */ - .id = 0, - .type = CLK_TYPE_PRIMARY, -}; -static struct clk main_clk = { - .name = "main", - .pmc_mask = AT91_PMC_MOSCS, /* in PMC_SR */ - .id = 1, - .type = CLK_TYPE_PRIMARY, -}; -static struct clk plla = { - .name = "plla", - .parent = &main_clk, - .pmc_mask = AT91_PMC_LOCKA, /* in PMC_SR */ - .id = 2, - .type = CLK_TYPE_PRIMARY | CLK_TYPE_PLL, -}; - -static void pllb_mode(struct clk *clk, int is_on) -{ - u32 value; - - if (is_on) { - is_on = AT91_PMC_LOCKB; - value = at91_pllb_usb_init; - } else - value = 0; - - // REVISIT: Add work-around for AT91RM9200 Errata #26 ? - at91_pmc_write(AT91_CKGR_PLLBR, value); - - do { - cpu_relax(); - } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on); -} - -static struct clk pllb = { - .name = "pllb", - .parent = &main_clk, - .pmc_mask = AT91_PMC_LOCKB, /* in PMC_SR */ - .mode = pllb_mode, - .id = 3, - .type = CLK_TYPE_PRIMARY | CLK_TYPE_PLL, -}; - -static void pmc_sys_mode(struct clk *clk, int is_on) -{ - if (is_on) - at91_pmc_write(AT91_PMC_SCER, clk->pmc_mask); - else - at91_pmc_write(AT91_PMC_SCDR, clk->pmc_mask); -} - -static void pmc_uckr_mode(struct clk *clk, int is_on) -{ - unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR); - - if (is_on) { - is_on = AT91_PMC_LOCKU; - at91_pmc_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask); - } else - at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask)); - - do { - cpu_relax(); - } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on); -} - -/* USB function clocks (PLLB must be 48 MHz) */ -static struct clk udpck = { - .name = "udpck", - .parent = &pllb, - .mode = pmc_sys_mode, -}; -struct clk utmi_clk = { - .name = "utmi_clk", - .parent = &main_clk, - .pmc_mask = AT91_PMC_UPLLEN, /* in CKGR_UCKR */ - .mode = pmc_uckr_mode, - .type = CLK_TYPE_PLL, -}; -static struct clk uhpck = { - .name = "uhpck", - /*.parent = ... we choose parent at runtime */ - .mode = pmc_sys_mode, -}; - - -/* - * The master clock is divided from the CPU clock (by 1-4). It's used for - * memory, interfaces to on-chip peripherals, the AIC, and sometimes more - * (e.g baud rate generation). It's sourced from one of the primary clocks. - */ -struct clk mck = { - .name = "mck", - .pmc_mask = AT91_PMC_MCKRDY, /* in PMC_SR */ -}; - -static void pmc_periph_mode(struct clk *clk, int is_on) -{ - u32 regval = 0; - - /* - * With sama5d3 devices, we are managing clock division so we have to - * use the Peripheral Control Register introduced from at91sam9x5 - * devices. - */ - if (cpu_is_sama5d3()) { - regval |= AT91_PMC_PCR_CMD; /* write command */ - regval |= clk->pid & AT91_PMC_PCR_PID; /* peripheral selection */ - regval |= AT91_PMC_PCR_DIV(clk->div); - if (is_on) - regval |= AT91_PMC_PCR_EN; /* enable clock */ - at91_pmc_write(AT91_PMC_PCR, regval); - } else { - if (is_on) - at91_pmc_write(AT91_PMC_PCER, clk->pmc_mask); - else - at91_pmc_write(AT91_PMC_PCDR, clk->pmc_mask); - } -} - -static struct clk __init *at91_css_to_clk(unsigned long css) -{ - switch (css) { - case AT91_PMC_CSS_SLOW: - return &clk32k; - case AT91_PMC_CSS_MAIN: - return &main_clk; - case AT91_PMC_CSS_PLLA: - return &plla; - case AT91_PMC_CSS_PLLB: - if (cpu_has_upll()) - /* CSS_PLLB == CSS_UPLL */ - return &utmi_clk; - else if (cpu_has_pllb()) - return &pllb; - break; - /* alternate PMC: can use master clock */ - case AT91_PMC_CSS_MASTER: - return &mck; - } - - return NULL; -} - -static int pmc_prescaler_divider(u32 reg) -{ - if (cpu_has_alt_prescaler()) { - return 1 << ((reg & AT91_PMC_ALT_PRES) >> PMC_ALT_PRES_OFFSET); - } else { - return 1 << ((reg & AT91_PMC_PRES) >> PMC_PRES_OFFSET); - } -} - -static void __clk_enable(struct clk *clk) -{ - if (clk->parent) - __clk_enable(clk->parent); - if (clk->users++ == 0 && clk->mode) - clk->mode(clk, 1); -} - -int clk_enable(struct clk *clk) -{ - unsigned long flags; - - spin_lock_irqsave(&clk_lock, flags); - __clk_enable(clk); - spin_unlock_irqrestore(&clk_lock, flags); - return 0; -} -EXPORT_SYMBOL(clk_enable); - -static void __clk_disable(struct clk *clk) -{ - BUG_ON(clk->users == 0); - if (--clk->users == 0 && clk->mode) - clk->mode(clk, 0); - if (clk->parent) - __clk_disable(clk->parent); -} - -void clk_disable(struct clk *clk) -{ - unsigned long flags; - - spin_lock_irqsave(&clk_lock, flags); - __clk_disable(clk); - spin_unlock_irqrestore(&clk_lock, flags); -} -EXPORT_SYMBOL(clk_disable); - -unsigned long clk_get_rate(struct clk *clk) -{ - unsigned long flags; - unsigned long rate; - - spin_lock_irqsave(&clk_lock, flags); - for (;;) { - rate = clk->rate_hz; - if (rate || !clk->parent) - break; - clk = clk->parent; - } - spin_unlock_irqrestore(&clk_lock, flags); - return rate; -} -EXPORT_SYMBOL(clk_get_rate); - -/*------------------------------------------------------------------------*/ - -/* - * For now, only the programmable clocks support reparenting (MCK could - * do this too, with care) or rate changing (the PLLs could do this too, - * ditto MCK but that's more for cpufreq). Drivers may reparent to get - * a better rate match; we don't. - */ - -long clk_round_rate(struct clk *clk, unsigned long rate) -{ - unsigned long flags; - unsigned prescale; - unsigned long actual; - unsigned long prev = ULONG_MAX; - - if (!clk_is_programmable(clk)) - return -EINVAL; - spin_lock_irqsave(&clk_lock, flags); - - actual = clk->parent->rate_hz; - for (prescale = 0; prescale < 7; prescale++) { - if (actual > rate) - prev = actual; - - if (actual && actual <= rate) { - if ((prev - rate) < (rate - actual)) { - actual = prev; - prescale--; - } - break; - } - actual >>= 1; - } - - spin_unlock_irqrestore(&clk_lock, flags); - return (prescale < 7) ? actual : -ENOENT; -} -EXPORT_SYMBOL(clk_round_rate); - -int clk_set_rate(struct clk *clk, unsigned long rate) -{ - unsigned long flags; - unsigned prescale; - unsigned long prescale_offset, css_mask; - unsigned long actual; - - if (!clk_is_programmable(clk)) - return -EINVAL; - if (clk->users) - return -EBUSY; - - if (cpu_has_alt_prescaler()) { - prescale_offset = PMC_ALT_PRES_OFFSET; - css_mask = AT91_PMC_ALT_PCKR_CSS; - } else { - prescale_offset = PMC_PRES_OFFSET; - css_mask = AT91_PMC_CSS; - } - - spin_lock_irqsave(&clk_lock, flags); - - actual = clk->parent->rate_hz; - for (prescale = 0; prescale < 7; prescale++) { - if (actual && actual <= rate) { - u32 pckr; - - pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id)); - pckr &= css_mask; /* keep clock selection */ - pckr |= prescale << prescale_offset; - at91_pmc_write(AT91_PMC_PCKR(clk->id), pckr); - clk->rate_hz = actual; - break; - } - actual >>= 1; - } - - spin_unlock_irqrestore(&clk_lock, flags); - return (prescale < 7) ? actual : -ENOENT; -} -EXPORT_SYMBOL(clk_set_rate); - -struct clk *clk_get_parent(struct clk *clk) -{ - return clk->parent; -} -EXPORT_SYMBOL(clk_get_parent); - -int clk_set_parent(struct clk *clk, struct clk *parent) -{ - unsigned long flags; - - if (clk->users) - return -EBUSY; - if (!clk_is_primary(parent) || !clk_is_programmable(clk)) - return -EINVAL; - - if (cpu_is_at91sam9rl() && parent->id == AT91_PMC_CSS_PLLB) - return -EINVAL; - - spin_lock_irqsave(&clk_lock, flags); - - clk->rate_hz = parent->rate_hz; - clk->parent = parent; - at91_pmc_write(AT91_PMC_PCKR(clk->id), parent->id); - - spin_unlock_irqrestore(&clk_lock, flags); - return 0; -} -EXPORT_SYMBOL(clk_set_parent); - -/* establish PCK0..PCKN parentage and rate */ -static void __init init_programmable_clock(struct clk *clk) -{ - struct clk *parent; - u32 pckr; - unsigned int css_mask; - - if (cpu_has_alt_prescaler()) - css_mask = AT91_PMC_ALT_PCKR_CSS; - else - css_mask = AT91_PMC_CSS; - - pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id)); - parent = at91_css_to_clk(pckr & css_mask); - clk->parent = parent; - clk->rate_hz = parent->rate_hz / pmc_prescaler_divider(pckr); -} - -/*------------------------------------------------------------------------*/ - -#ifdef CONFIG_DEBUG_FS - -static int at91_clk_show(struct seq_file *s, void *unused) -{ - u32 scsr, pcsr, pcsr1 = 0, uckr = 0, sr; - struct clk *clk; - - scsr = at91_pmc_read(AT91_PMC_SCSR); - pcsr = at91_pmc_read(AT91_PMC_PCSR); - if (cpu_is_sama5d3()) - pcsr1 = at91_pmc_read(AT91_PMC_PCSR1); - sr = at91_pmc_read(AT91_PMC_SR); - seq_printf(s, "SCSR = %8x\n", scsr); - seq_printf(s, "PCSR = %8x\n", pcsr); - if (cpu_is_sama5d3()) - seq_printf(s, "PCSR1 = %8x\n", pcsr1); - seq_printf(s, "MOR = %8x\n", at91_pmc_read(AT91_CKGR_MOR)); - seq_printf(s, "MCFR = %8x\n", at91_pmc_read(AT91_CKGR_MCFR)); - seq_printf(s, "PLLA = %8x\n", at91_pmc_read(AT91_CKGR_PLLAR)); - if (cpu_has_pllb()) - seq_printf(s, "PLLB = %8x\n", at91_pmc_read(AT91_CKGR_PLLBR)); - if (cpu_has_utmi()) { - uckr = at91_pmc_read(AT91_CKGR_UCKR); - seq_printf(s, "UCKR = %8x\n", uckr); - } - seq_printf(s, "MCKR = %8x\n", at91_pmc_read(AT91_PMC_MCKR)); - if (cpu_has_upll() || cpu_is_at91sam9n12()) - seq_printf(s, "USB = %8x\n", at91_pmc_read(AT91_PMC_USB)); - seq_printf(s, "SR = %8x\n", sr); - - seq_printf(s, "\n"); - - list_for_each_entry(clk, &clocks, node) { - char *state; - - if (clk->mode == pmc_sys_mode) { - state = (scsr & clk->pmc_mask) ? "on" : "off"; - } else if (clk->mode == pmc_periph_mode) { - if (cpu_is_sama5d3()) { - u32 pmc_mask = 1 << (clk->pid % 32); - - if (clk->pid > 31) - state = (pcsr1 & pmc_mask) ? "on" : "off"; - else - state = (pcsr & pmc_mask) ? "on" : "off"; - } else { - state = (pcsr & clk->pmc_mask) ? "on" : "off"; - } - } else if (clk->mode == pmc_uckr_mode) { - state = (uckr & clk->pmc_mask) ? "on" : "off"; - } else if (clk->pmc_mask) { - state = (sr & clk->pmc_mask) ? "on" : "off"; - } else if (clk == &clk32k || clk == &main_clk) { - state = "on"; - } else { - state = ""; - } - - seq_printf(s, "%-10s users=%2d %-3s %9lu Hz %s\n", - clk->name, clk->users, state, clk_get_rate(clk), - clk->parent ? clk->parent->name : ""); - } - return 0; -} - -static int at91_clk_open(struct inode *inode, struct file *file) -{ - return single_open(file, at91_clk_show, NULL); -} - -static const struct file_operations at91_clk_operations = { - .open = at91_clk_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int __init at91_clk_debugfs_init(void) -{ - /* /sys/kernel/debug/at91_clk */ - (void) debugfs_create_file("at91_clk", S_IFREG | S_IRUGO, NULL, NULL, &at91_clk_operations); - - return 0; -} -postcore_initcall(at91_clk_debugfs_init); - -#endif - -/*------------------------------------------------------------------------*/ - -/* Register a new clock */ -static void __init at91_clk_add(struct clk *clk) -{ - list_add_tail(&clk->node, &clocks); - - clk->cl.con_id = clk->name; - clk->cl.clk = clk; - clkdev_add(&clk->cl); -} - -int __init clk_register(struct clk *clk) -{ - if (clk_is_peripheral(clk)) { - if (!clk->parent) - clk->parent = &mck; - if (cpu_is_sama5d3()) - clk->rate_hz = DIV_ROUND_UP(clk->parent->rate_hz, - 1 << clk->div); - clk->mode = pmc_periph_mode; - } - else if (clk_is_sys(clk)) { - clk->parent = &mck; - clk->mode = pmc_sys_mode; - } - else if (clk_is_programmable(clk)) { - clk->mode = pmc_sys_mode; - init_programmable_clock(clk); - } - - at91_clk_add(clk); - - return 0; -} - -/*------------------------------------------------------------------------*/ - -static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg) -{ - unsigned mul, div; - - div = reg & 0xff; - if (cpu_is_sama5d3()) - mul = AT91_PMC3_MUL_GET(reg); - else - mul = AT91_PMC_MUL_GET(reg); - - if (div && mul) { - freq /= div; - freq *= mul + 1; - } else - freq = 0; - - return freq; -} - -static u32 __init at91_usb_rate(struct clk *pll, u32 freq, u32 reg) -{ - if (pll == &pllb && (reg & AT91_PMC_USB96M)) - return freq / 2; - else if (pll == &utmi_clk || cpu_is_at91sam9n12()) - return freq / (1 + ((reg & AT91_PMC_OHCIUSBDIV) >> 8)); - else - return freq; -} - -static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq) -{ - unsigned i, div = 0, mul = 0, diff = 1 << 30; - unsigned ret = (out_freq > 155000000) ? 0xbe00 : 0x3e00; - - /* PLL output max 240 MHz (or 180 MHz per errata) */ - if (out_freq > 240000000) - goto fail; - - for (i = 1; i < 256; i++) { - int diff1; - unsigned input, mul1; - - /* - * PLL input between 1MHz and 32MHz per spec, but lower - * frequences seem necessary in some cases so allow 100K. - * Warning: some newer products need 2MHz min. - */ - input = main_freq / i; - if (cpu_is_at91sam9g20() && input < 2000000) - continue; - if (input < 100000) - continue; - if (input > 32000000) - continue; - - mul1 = out_freq / input; - if (cpu_is_at91sam9g20() && mul > 63) - continue; - if (mul1 > 2048) - continue; - if (mul1 < 2) - goto fail; - - diff1 = out_freq - input * mul1; - if (diff1 < 0) - diff1 = -diff1; - if (diff > diff1) { - diff = diff1; - div = i; - mul = mul1; - if (diff == 0) - break; - } - } - if (i == 256 && diff > (out_freq >> 5)) - goto fail; - return ret | ((mul - 1) << 16) | div; -fail: - return 0; -} - -static struct clk *const standard_pmc_clocks[] __initconst = { - /* four primary clocks */ - &clk32k, - &main_clk, - &plla, - - /* MCK */ - &mck -}; - -/* PLLB generated USB full speed clock init */ -static void __init at91_pllb_usbfs_clock_init(unsigned long main_clock) -{ - unsigned int reg; - - /* - * USB clock init: choose 48 MHz PLLB value, - * disable 48MHz clock during usb peripheral suspend. - * - * REVISIT: assumes MCK doesn't derive from PLLB! - */ - uhpck.parent = &pllb; - - reg = at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2); - pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init); - if (cpu_is_at91rm9200()) { - reg = at91_pllb_usb_init |= AT91_PMC_USB96M; - uhpck.pmc_mask = AT91RM9200_PMC_UHP; - udpck.pmc_mask = AT91RM9200_PMC_UDP; - at91_pmc_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); - } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || - cpu_is_at91sam9263() || cpu_is_at91sam9g20() || - cpu_is_at91sam9g10()) { - reg = at91_pllb_usb_init |= AT91_PMC_USB96M; - uhpck.pmc_mask = AT91SAM926x_PMC_UHP; - udpck.pmc_mask = AT91SAM926x_PMC_UDP; - } else if (cpu_is_at91sam9n12()) { - /* Divider for USB clock is in USB clock register for 9n12 */ - reg = AT91_PMC_USBS_PLLB; - - /* For PLLB output 96M, set usb divider 2 (USBDIV + 1) */ - reg |= AT91_PMC_OHCIUSBDIV_2; - at91_pmc_write(AT91_PMC_USB, reg); - - /* Still setup masks */ - uhpck.pmc_mask = AT91SAM926x_PMC_UHP; - udpck.pmc_mask = AT91SAM926x_PMC_UDP; - } - at91_pmc_write(AT91_CKGR_PLLBR, 0); - - udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, reg); - uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, reg); -} - -/* UPLL generated USB full speed clock init */ -static void __init at91_upll_usbfs_clock_init(unsigned long main_clock) -{ - /* - * USB clock init: choose 480 MHz from UPLL, - */ - unsigned int usbr = AT91_PMC_USBS_UPLL; - - /* Setup divider by 10 to reach 48 MHz */ - usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV; - - at91_pmc_write(AT91_PMC_USB, usbr); - - /* Now set uhpck values */ - uhpck.parent = &utmi_clk; - uhpck.pmc_mask = AT91SAM926x_PMC_UHP; - uhpck.rate_hz = at91_usb_rate(&utmi_clk, utmi_clk.rate_hz, usbr); -} - -static int __init at91_pmc_init(unsigned long main_clock) -{ - unsigned tmp, freq, mckr; - int i; - int pll_overclock = false; - - /* - * When the bootloader initialized the main oscillator correctly, - * there's no problem using the cycle counter. But if it didn't, - * or when using oscillator bypass mode, we must be told the speed - * of the main clock. - */ - if (!main_clock) { - do { - tmp = at91_pmc_read(AT91_CKGR_MCFR); - } while (!(tmp & AT91_PMC_MAINRDY)); - main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16); - } - main_clk.rate_hz = main_clock; - - /* report if PLLA is more than mildly overclocked */ - plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_pmc_read(AT91_CKGR_PLLAR)); - if (cpu_has_1056M_plla()) { - if (plla.rate_hz > 1056000000) - pll_overclock = true; - } else if (cpu_has_800M_plla()) { - if (plla.rate_hz > 800000000) - pll_overclock = true; - } else if (cpu_has_300M_plla()) { - if (plla.rate_hz > 300000000) - pll_overclock = true; - } else if (cpu_has_240M_plla()) { - if (plla.rate_hz > 240000000) - pll_overclock = true; - } else if (cpu_has_210M_plla()) { - if (plla.rate_hz > 210000000) - pll_overclock = true; - } else { - if (plla.rate_hz > 209000000) - pll_overclock = true; - } - if (pll_overclock) - pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); - - if (cpu_has_plladiv2()) { - mckr = at91_pmc_read(AT91_PMC_MCKR); - plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12)); /* plla divisor by 2 */ - } - - if (!cpu_has_pllb() && cpu_has_upll()) { - /* setup UTMI clock as the fourth primary clock - * (instead of pllb) */ - utmi_clk.type |= CLK_TYPE_PRIMARY; - utmi_clk.id = 3; - } - - - /* - * USB HS clock init - */ - if (cpu_has_utmi()) { - /* - * multiplier is hard-wired to 40 - * (obtain the USB High Speed 480 MHz when input is 12 MHz) - */ - utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz; - - /* UTMI bias and PLL are managed at the same time */ - if (cpu_has_upll()) - utmi_clk.pmc_mask |= AT91_PMC_BIASEN; - } - - /* - * USB FS clock init - */ - if (cpu_has_pllb()) - at91_pllb_usbfs_clock_init(main_clock); - if (cpu_has_upll()) - /* assumes that we choose UPLL for USB and not PLLA */ - at91_upll_usbfs_clock_init(main_clock); - - /* - * MCK and CPU derive from one of those primary clocks. - * For now, assume this parentage won't change. - */ - mckr = at91_pmc_read(AT91_PMC_MCKR); - mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS); - freq = mck.parent->rate_hz; - freq /= pmc_prescaler_divider(mckr); /* prescale */ - if (cpu_is_at91rm9200()) { - mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ - } else if (cpu_is_at91sam9g20()) { - mck.rate_hz = (mckr & AT91_PMC_MDIV) ? - freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */ - if (mckr & AT91_PMC_PDIV) - freq /= 2; /* processor clock division */ - } else if (cpu_has_mdiv3()) { - mck.rate_hz = (mckr & AT91_PMC_MDIV) == AT91SAM9_PMC_MDIV_3 ? - freq / 3 : freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ - } else { - mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ - } - - if (cpu_has_alt_prescaler()) { - /* Programmable clocks can use MCK */ - mck.type |= CLK_TYPE_PRIMARY; - mck.id = 4; - } - - /* Register the PMC's standard clocks */ - for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) - at91_clk_add(standard_pmc_clocks[i]); - - if (cpu_has_pllb()) - at91_clk_add(&pllb); - - if (cpu_has_uhp()) - at91_clk_add(&uhpck); - - if (cpu_has_udpfs()) - at91_clk_add(&udpck); - - if (cpu_has_utmi()) - at91_clk_add(&utmi_clk); - - /* MCK and CPU clock are "always on" */ - clk_enable(&mck); - - printk("Clocks: CPU %u MHz, master %u MHz, main %u.%03u MHz\n", - freq / 1000000, (unsigned) mck.rate_hz / 1000000, - (unsigned) main_clock / 1000000, - ((unsigned) main_clock % 1000000) / 1000); - - return 0; -} - -#if defined(CONFIG_OF) -static struct of_device_id pmc_ids[] = { - { .compatible = "atmel,at91rm9200-pmc" }, - { .compatible = "atmel,at91sam9260-pmc" }, - { .compatible = "atmel,at91sam9g45-pmc" }, - { .compatible = "atmel,at91sam9n12-pmc" }, - { .compatible = "atmel,at91sam9x5-pmc" }, - { .compatible = "atmel,sama5d3-pmc" }, - { /*sentinel*/ } -}; - -static struct of_device_id osc_ids[] = { - { .compatible = "atmel,osc" }, - { /*sentinel*/ } -}; - -int __init at91_dt_clock_init(void) -{ - struct device_node *np; - u32 main_clock = 0; - - np = of_find_matching_node(NULL, pmc_ids); - if (!np) - panic("unable to find compatible pmc node in dtb\n"); - - at91_pmc_base = of_iomap(np, 0); - if (!at91_pmc_base) - panic("unable to map pmc cpu registers\n"); - - of_node_put(np); - - /* retrieve the freqency of fixed clocks from device tree */ - np = of_find_matching_node(NULL, osc_ids); - if (np) { - u32 rate; - if (!of_property_read_u32(np, "clock-frequency", &rate)) - main_clock = rate; - } - - of_node_put(np); - - return at91_pmc_init(main_clock); -} -#endif - -int __init at91_clock_init(unsigned long main_clock) -{ - at91_pmc_base = ioremap(AT91_PMC, 256); - if (!at91_pmc_base) - panic("Impossible to ioremap AT91_PMC 0x%x\n", AT91_PMC); - - return at91_pmc_init(main_clock); -} - -/* - * Several unused clocks may be active. Turn them off. - */ -static int __init at91_clock_reset(void) -{ - unsigned long pcdr = 0; - unsigned long pcdr1 = 0; - unsigned long scdr = 0; - struct clk *clk; - - list_for_each_entry(clk, &clocks, node) { - if (clk->users > 0) - continue; - - if (clk->mode == pmc_periph_mode) { - if (cpu_is_sama5d3()) { - u32 pmc_mask = 1 << (clk->pid % 32); - - if (clk->pid > 31) - pcdr1 |= pmc_mask; - else - pcdr |= pmc_mask; - } else - pcdr |= clk->pmc_mask; - } - - if (clk->mode == pmc_sys_mode) - scdr |= clk->pmc_mask; - - pr_debug("Clocks: disable unused %s\n", clk->name); - } - - at91_pmc_write(AT91_PMC_SCDR, scdr); - at91_pmc_write(AT91_PMC_PCDR, pcdr); - if (cpu_is_sama5d3()) - at91_pmc_write(AT91_PMC_PCDR1, pcdr1); - - return 0; -} -late_initcall(at91_clock_reset); - -void at91sam9_idle(void) -{ - at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK); - cpu_do_idle(); -} diff --git a/arch/arm/mach-at91/clock.h b/arch/arm/mach-at91/clock.h deleted file mode 100644 index a98a39bbd883..000000000000 --- a/arch/arm/mach-at91/clock.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * linux/arch/arm/mach-at91/clock.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include - -#define CLK_TYPE_PRIMARY 0x1 -#define CLK_TYPE_PLL 0x2 -#define CLK_TYPE_PROGRAMMABLE 0x4 -#define CLK_TYPE_PERIPHERAL 0x8 -#define CLK_TYPE_SYSTEM 0x10 - - -struct clk { - struct list_head node; - const char *name; /* unique clock name */ - struct clk_lookup cl; - unsigned long rate_hz; - unsigned div; /* parent clock divider */ - struct clk *parent; - unsigned pid; /* peripheral ID */ - u32 pmc_mask; - void (*mode)(struct clk *, int); - unsigned id:3; /* PCK0..4, or 32k/main/a/b */ - unsigned type; /* clock type */ - u16 users; -}; - - -extern int __init clk_register(struct clk *clk); -extern struct clk mck; -extern struct clk utmi_clk; - -#define CLKDEV_CON_ID(_id, _clk) \ - { \ - .con_id = _id, \ - .clk = _clk, \ - } - -#define CLKDEV_CON_DEV_ID(_con_id, _dev_id, _clk) \ - { \ - .con_id = _con_id, \ - .dev_id = _dev_id, \ - .clk = _clk, \ - } diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index 464b08e9830a..1ec9b011b6a9 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -11,7 +11,6 @@ #ifndef _AT91_GENERIC_H #define _AT91_GENERIC_H -#include #include #include @@ -49,16 +48,6 @@ extern void at91rm9200_timer_init(void); extern void at91sam926x_ioremap_pit(u32 addr); extern void at91sam926x_pit_init(int irq); - /* Clocks */ -#ifdef CONFIG_OLD_CLK_AT91 -extern int __init at91_clock_init(unsigned long main_clock); -extern int __init at91_dt_clock_init(void); -#else -static int inline at91_clock_init(unsigned long main_clock) { return 0; } -static int inline at91_dt_clock_init(void) { return 0; } -#endif -struct device; - /* Power Management */ extern void at91_irq_suspend(void); extern void at91_irq_resume(void); diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index a78fbb7b13c9..98b0c1a62899 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c @@ -460,9 +460,6 @@ void __init at91rm9200_dt_initialize(void) { at91_dt_ramc(); - /* Init clock subsystem */ - at91_dt_clock_init(); - /* Register the processor-specific clocks */ if (at91_boot_soc.register_clocks) at91_boot_soc.register_clocks(); @@ -474,9 +471,6 @@ void __init at91_dt_initialize(void) { at91_dt_ramc(); - /* Init clock subsystem */ - at91_dt_clock_init(); - /* Register the processor-specific clocks */ if (at91_boot_soc.register_clocks) at91_boot_soc.register_clocks(); @@ -490,9 +484,6 @@ void __init at91_initialize(unsigned long main_clock) { at91_boot_soc.ioremap_registers(); - /* Init clock subsystem */ - at91_clock_init(main_clock); - /* Register the processor-specific clocks */ at91_boot_soc.register_clocks(); -- cgit v1.2.3 From 1ccdde057b03a2446eeee7b7a63306c4d9c68d61 Mon Sep 17 00:00:00 2001 From: Nicolas Ferre Date: Thu, 27 Nov 2014 16:10:06 +0100 Subject: ARM: at91: remove legacy IRQ driver and related code Remove irc.c and associated header file. The related code was idendified by the CONFIG_OLD_IRQ_AT91 option that was removed previously. It has been spotted by following coccinelle semantic match: @rule1@ expression E; statement S; @@ ( - if (IS_ENABLED(CONFIG_OLD_IRQ_AT91)) S | - if (IS_ENABLED(CONFIG_OLD_IRQ_AT91) && E) S ) Cc: Julia Lawall Signed-off-by: Nicolas Ferre Acked-by: Boris BREZILLON --- arch/arm/mach-at91/Makefile | 1 - arch/arm/mach-at91/at91_aic.h | 99 ------------ arch/arm/mach-at91/board-dt-rm9200.c | 1 - arch/arm/mach-at91/board-dt-sam9.c | 1 - arch/arm/mach-at91/board-dt-sama5.c | 1 - arch/arm/mach-at91/generic.h | 2 - arch/arm/mach-at91/irq.c | 296 ----------------------------------- arch/arm/mach-at91/pm.c | 22 --- arch/arm/mach-at91/setup.c | 4 - 9 files changed, 427 deletions(-) delete mode 100644 arch/arm/mach-at91/at91_aic.h delete mode 100644 arch/arm/mach-at91/irq.c (limited to 'arch/arm/mach-at91/setup.c') diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index b486c7760ac4..2371b8845bf5 100644 --- a/arch/arm/mach-at91/Makefile +++ b/arch/arm/mach-at91/Makefile @@ -4,7 +4,6 @@ obj-y := gpio.o setup.o sysirq_mask.o -obj-$(CONFIG_OLD_IRQ_AT91) += irq.o obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o # CPU-specific support diff --git a/arch/arm/mach-at91/at91_aic.h b/arch/arm/mach-at91/at91_aic.h deleted file mode 100644 index eaea66197fa1..000000000000 --- a/arch/arm/mach-at91/at91_aic.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * arch/arm/mach-at91/include/mach/at91_aic.h - * - * Copyright (C) 2005 Ivan Kokshaysky - * Copyright (C) SAN People - * - * Advanced Interrupt Controller (AIC) - System peripherals registers. - * Based on AT91RM9200 datasheet revision E. - * - * 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. - */ - -#ifndef AT91_AIC_H -#define AT91_AIC_H - -#ifndef __ASSEMBLY__ -extern void __iomem *at91_aic_base; - -#define at91_aic_read(field) \ - __raw_readl(at91_aic_base + field) - -#define at91_aic_write(field, value) \ - __raw_writel(value, at91_aic_base + field) -#else -.extern at91_aic_base -#endif - -/* Number of irq lines managed by AIC */ -#define NR_AIC_IRQS 32 -#define NR_AIC5_IRQS 128 - -#define AT91_AIC5_SSR 0x0 /* Source Select Register [AIC5] */ -#define AT91_AIC5_INTSEL_MSK (0x7f << 0) /* Interrupt Line Selection Mask */ - -#define AT91_AIC_IRQ_MIN_PRIORITY 0 -#define AT91_AIC_IRQ_MAX_PRIORITY 7 - -#define AT91_AIC_SMR(n) ((n) * 4) /* Source Mode Registers 0-31 */ -#define AT91_AIC5_SMR 0x4 /* Source Mode Register [AIC5] */ -#define AT91_AIC_PRIOR (7 << 0) /* Priority Level */ -#define AT91_AIC_SRCTYPE (3 << 5) /* Interrupt Source Type */ -#define AT91_AIC_SRCTYPE_LOW (0 << 5) -#define AT91_AIC_SRCTYPE_FALLING (1 << 5) -#define AT91_AIC_SRCTYPE_HIGH (2 << 5) -#define AT91_AIC_SRCTYPE_RISING (3 << 5) - -#define AT91_AIC_SVR(n) (0x80 + ((n) * 4)) /* Source Vector Registers 0-31 */ -#define AT91_AIC5_SVR 0x8 /* Source Vector Register [AIC5] */ -#define AT91_AIC_IVR 0x100 /* Interrupt Vector Register */ -#define AT91_AIC5_IVR 0x10 /* Interrupt Vector Register [AIC5] */ -#define AT91_AIC_FVR 0x104 /* Fast Interrupt Vector Register */ -#define AT91_AIC5_FVR 0x14 /* Fast Interrupt Vector Register [AIC5] */ -#define AT91_AIC_ISR 0x108 /* Interrupt Status Register */ -#define AT91_AIC5_ISR 0x18 /* Interrupt Status Register [AIC5] */ -#define AT91_AIC_IRQID (0x1f << 0) /* Current Interrupt Identifier */ - -#define AT91_AIC_IPR 0x10c /* Interrupt Pending Register */ -#define AT91_AIC5_IPR0 0x20 /* Interrupt Pending Register 0 [AIC5] */ -#define AT91_AIC5_IPR1 0x24 /* Interrupt Pending Register 1 [AIC5] */ -#define AT91_AIC5_IPR2 0x28 /* Interrupt Pending Register 2 [AIC5] */ -#define AT91_AIC5_IPR3 0x2c /* Interrupt Pending Register 3 [AIC5] */ -#define AT91_AIC_IMR 0x110 /* Interrupt Mask Register */ -#define AT91_AIC5_IMR 0x30 /* Interrupt Mask Register [AIC5] */ -#define AT91_AIC_CISR 0x114 /* Core Interrupt Status Register */ -#define AT91_AIC5_CISR 0x34 /* Core Interrupt Status Register [AIC5] */ -#define AT91_AIC_NFIQ (1 << 0) /* nFIQ Status */ -#define AT91_AIC_NIRQ (1 << 1) /* nIRQ Status */ - -#define AT91_AIC_IECR 0x120 /* Interrupt Enable Command Register */ -#define AT91_AIC5_IECR 0x40 /* Interrupt Enable Command Register [AIC5] */ -#define AT91_AIC_IDCR 0x124 /* Interrupt Disable Command Register */ -#define AT91_AIC5_IDCR 0x44 /* Interrupt Disable Command Register [AIC5] */ -#define AT91_AIC_ICCR 0x128 /* Interrupt Clear Command Register */ -#define AT91_AIC5_ICCR 0x48 /* Interrupt Clear Command Register [AIC5] */ -#define AT91_AIC_ISCR 0x12c /* Interrupt Set Command Register */ -#define AT91_AIC5_ISCR 0x4c /* Interrupt Set Command Register [AIC5] */ -#define AT91_AIC_EOICR 0x130 /* End of Interrupt Command Register */ -#define AT91_AIC5_EOICR 0x38 /* End of Interrupt Command Register [AIC5] */ -#define AT91_AIC_SPU 0x134 /* Spurious Interrupt Vector Register */ -#define AT91_AIC5_SPU 0x3c /* Spurious Interrupt Vector Register [AIC5] */ -#define AT91_AIC_DCR 0x138 /* Debug Control Register */ -#define AT91_AIC5_DCR 0x6c /* Debug Control Register [AIC5] */ -#define AT91_AIC_DCR_PROT (1 << 0) /* Protection Mode */ -#define AT91_AIC_DCR_GMSK (1 << 1) /* General Mask */ - -#define AT91_AIC_FFER 0x140 /* Fast Forcing Enable Register [SAM9 only] */ -#define AT91_AIC5_FFER 0x50 /* Fast Forcing Enable Register [AIC5] */ -#define AT91_AIC_FFDR 0x144 /* Fast Forcing Disable Register [SAM9 only] */ -#define AT91_AIC5_FFDR 0x54 /* Fast Forcing Disable Register [AIC5] */ -#define AT91_AIC_FFSR 0x148 /* Fast Forcing Status Register [SAM9 only] */ -#define AT91_AIC5_FFSR 0x58 /* Fast Forcing Status Register [AIC5] */ - -void at91_aic_handle_irq(struct pt_regs *regs); -void at91_aic5_handle_irq(struct pt_regs *regs); - -#endif diff --git a/arch/arm/mach-at91/board-dt-rm9200.c b/arch/arm/mach-at91/board-dt-rm9200.c index 226563f850b8..feeb1a0f258e 100644 --- a/arch/arm/mach-at91/board-dt-rm9200.c +++ b/arch/arm/mach-at91/board-dt-rm9200.c @@ -22,7 +22,6 @@ #include #include -#include "at91_aic.h" #include "generic.h" static void __init at91rm9200_dt_timer_init(void) diff --git a/arch/arm/mach-at91/board-dt-sam9.c b/arch/arm/mach-at91/board-dt-sam9.c index d3048ccdc41f..67c1bcbf0ed9 100644 --- a/arch/arm/mach-at91/board-dt-sam9.c +++ b/arch/arm/mach-at91/board-dt-sam9.c @@ -21,7 +21,6 @@ #include #include -#include "at91_aic.h" #include "board.h" #include "generic.h" diff --git a/arch/arm/mach-at91/board-dt-sama5.c b/arch/arm/mach-at91/board-dt-sama5.c index 129e2917506b..8fb9ef5333f1 100644 --- a/arch/arm/mach-at91/board-dt-sama5.c +++ b/arch/arm/mach-at91/board-dt-sama5.c @@ -24,7 +24,6 @@ #include #include -#include "at91_aic.h" #include "generic.h" static void __init sama5_dt_device_init(void) diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index 1ec9b011b6a9..713d1d9e50a1 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -29,8 +29,6 @@ extern void __init at91_dt_initialize(void); /* Interrupts */ extern void __init at91_init_irq_default(void); extern void __init at91_init_interrupts(unsigned int priority[]); -extern void __init at91_aic_init(unsigned int priority[], - unsigned int ext_irq_mask); 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, diff --git a/arch/arm/mach-at91/irq.c b/arch/arm/mach-at91/irq.c deleted file mode 100644 index cdb3ec9efd2b..000000000000 --- a/arch/arm/mach-at91/irq.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * linux/arch/arm/mach-at91/irq.c - * - * Copyright (C) 2004 SAN People - * Copyright (C) 2004 ATMEL - * Copyright (C) Rick Bronson - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "at91_aic.h" - -void __iomem *at91_aic_base; -static struct irq_domain *at91_aic_domain; -static struct device_node *at91_aic_np; -static unsigned int n_irqs = NR_AIC_IRQS; - -#ifdef CONFIG_PM - -static unsigned long *wakeups; -static unsigned long *backups; - -#define set_backup(bit) set_bit(bit, backups) -#define clear_backup(bit) clear_bit(bit, backups) - -static int at91_aic_pm_init(void) -{ - backups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL); - if (!backups) - return -ENOMEM; - - wakeups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL); - if (!wakeups) { - kfree(backups); - return -ENOMEM; - } - - return 0; -} - -static int at91_aic_set_wake(struct irq_data *d, unsigned value) -{ - if (unlikely(d->hwirq >= n_irqs)) - return -EINVAL; - - if (value) - set_bit(d->hwirq, wakeups); - else - clear_bit(d->hwirq, wakeups); - - return 0; -} - -void at91_irq_suspend(void) -{ - at91_aic_write(AT91_AIC_IDCR, *backups); - at91_aic_write(AT91_AIC_IECR, *wakeups); -} - -void at91_irq_resume(void) -{ - at91_aic_write(AT91_AIC_IDCR, *wakeups); - at91_aic_write(AT91_AIC_IECR, *backups); -} - -#else -static inline int at91_aic_pm_init(void) -{ - return 0; -} - -#define set_backup(bit) -#define clear_backup(bit) -#define at91_aic_set_wake NULL - -#endif /* CONFIG_PM */ - -asmlinkage void __exception_irq_entry -at91_aic_handle_irq(struct pt_regs *regs) -{ - u32 irqnr; - u32 irqstat; - - irqnr = at91_aic_read(AT91_AIC_IVR); - irqstat = at91_aic_read(AT91_AIC_ISR); - - /* - * ISR value is 0 when there is no current interrupt or when there is - * a spurious interrupt - */ - if (!irqstat) - at91_aic_write(AT91_AIC_EOICR, 0); - else - handle_IRQ(irqnr, regs); -} - -static void at91_aic_mask_irq(struct irq_data *d) -{ - /* Disable interrupt on AIC */ - at91_aic_write(AT91_AIC_IDCR, 1 << d->hwirq); - /* Update ISR cache */ - clear_backup(d->hwirq); -} - -static void at91_aic_unmask_irq(struct irq_data *d) -{ - /* Enable interrupt on AIC */ - at91_aic_write(AT91_AIC_IECR, 1 << d->hwirq); - /* Update ISR cache */ - set_backup(d->hwirq); -} - -static void at91_aic_eoi(struct irq_data *d) -{ - /* - * Mark end-of-interrupt on AIC, the controller doesn't care about - * the value written. Moreover it's a write-only register. - */ - at91_aic_write(AT91_AIC_EOICR, 0); -} - -static unsigned long *at91_extern_irq; - -u32 at91_get_extern_irq(void) -{ - if (!at91_extern_irq) - return 0; - return *at91_extern_irq; -} - -#define is_extern_irq(hwirq) test_bit(hwirq, at91_extern_irq) - -static int at91_aic_compute_srctype(struct irq_data *d, unsigned type) -{ - int srctype; - - switch (type) { - case IRQ_TYPE_LEVEL_HIGH: - srctype = AT91_AIC_SRCTYPE_HIGH; - break; - case IRQ_TYPE_EDGE_RISING: - srctype = AT91_AIC_SRCTYPE_RISING; - break; - case IRQ_TYPE_LEVEL_LOW: - if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */ - srctype = AT91_AIC_SRCTYPE_LOW; - else - srctype = -EINVAL; - break; - case IRQ_TYPE_EDGE_FALLING: - if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */ - srctype = AT91_AIC_SRCTYPE_FALLING; - else - srctype = -EINVAL; - break; - default: - srctype = -EINVAL; - } - - return srctype; -} - -static int at91_aic_set_type(struct irq_data *d, unsigned type) -{ - unsigned int smr; - int srctype; - - srctype = at91_aic_compute_srctype(d, type); - if (srctype < 0) - return srctype; - - smr = at91_aic_read(AT91_AIC_SMR(d->hwirq)) & ~AT91_AIC_SRCTYPE; - at91_aic_write(AT91_AIC_SMR(d->hwirq), smr | srctype); - - return 0; -} - -static struct irq_chip at91_aic_chip = { - .name = "AIC", - .irq_mask = at91_aic_mask_irq, - .irq_unmask = at91_aic_unmask_irq, - .irq_set_type = at91_aic_set_type, - .irq_set_wake = at91_aic_set_wake, - .irq_eoi = at91_aic_eoi, -}; - -static void __init at91_aic_hw_init(unsigned int spu_vector) -{ - int i; - - /* - * Perform 8 End Of Interrupt Command to make sure AIC - * will not Lock out nIRQ - */ - for (i = 0; i < 8; i++) - at91_aic_write(AT91_AIC_EOICR, 0); - - /* - * Spurious Interrupt ID in Spurious Vector Register. - * When there is no current interrupt, the IRQ Vector Register - * reads the value stored in AIC_SPU - */ - at91_aic_write(AT91_AIC_SPU, spu_vector); - - /* No debugging in AIC: Debug (Protect) Control Register */ - at91_aic_write(AT91_AIC_DCR, 0); - - /* Disable and clear all interrupts initially */ - at91_aic_write(AT91_AIC_IDCR, 0xFFFFFFFF); - at91_aic_write(AT91_AIC_ICCR, 0xFFFFFFFF); -} - -/* - * Initialize the AIC interrupt controller. - */ -void __init at91_aic_init(unsigned int *priority, unsigned int ext_irq_mask) -{ - unsigned int i; - int irq_base; - - at91_extern_irq = kzalloc(BITS_TO_LONGS(n_irqs) - * sizeof(*at91_extern_irq), GFP_KERNEL); - - if (at91_aic_pm_init() || at91_extern_irq == NULL) - panic("Unable to allocate bit maps\n"); - - *at91_extern_irq = ext_irq_mask; - - at91_aic_base = ioremap(AT91_AIC, 512); - if (!at91_aic_base) - panic("Unable to ioremap AIC registers\n"); - - /* Add irq domain for AIC */ - irq_base = irq_alloc_descs(-1, 0, n_irqs, 0); - if (irq_base < 0) { - WARN(1, "Cannot allocate irq_descs, assuming pre-allocated\n"); - irq_base = 0; - } - at91_aic_domain = irq_domain_add_legacy(at91_aic_np, n_irqs, - irq_base, 0, - &irq_domain_simple_ops, NULL); - - if (!at91_aic_domain) - panic("Unable to add AIC irq domain\n"); - - irq_set_default_host(at91_aic_domain); - - /* - * The IVR is used by macro get_irqnr_and_base to read and verify. - * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred. - */ - for (i = 0; i < n_irqs; i++) { - /* Put hardware irq number in Source Vector Register: */ - at91_aic_write(AT91_AIC_SVR(i), NR_IRQS_LEGACY + i); - /* Active Low interrupt, with the specified priority */ - at91_aic_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]); - irq_set_chip_and_handler(NR_IRQS_LEGACY + i, &at91_aic_chip, handle_fasteoi_irq); - set_irq_flags(i, IRQF_VALID | IRQF_PROBE); - } - - at91_aic_hw_init(n_irqs); -} diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index 4073ab7f38f3..a42360f69127 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -29,7 +29,6 @@ #include #include -#include "at91_aic.h" #include "generic.h" #include "pm.h" #include "gpio.h" @@ -136,19 +135,6 @@ static int at91_pm_enter(suspend_state_t state) else at91_gpio_suspend(); - if (IS_ENABLED(CONFIG_OLD_IRQ_AT91) && at91_aic_base) { - at91_irq_suspend(); - - pr_debug("AT91: PM - wake mask %08x, pm state %d\n", - /* remember all the always-wake irqs */ - (at91_pmc_read(AT91_PMC_PCSR) - | (1 << AT91_ID_FIQ) - | (1 << AT91_ID_SYS) - | (at91_get_extern_irq())) - & at91_aic_read(AT91_AIC_IMR), - state); - } - switch (state) { /* * Suspend-to-RAM is like STANDBY plus slow clock mode, so @@ -212,17 +198,9 @@ static int at91_pm_enter(suspend_state_t state) goto error; } - if (IS_ENABLED(CONFIG_OLD_IRQ_AT91) && at91_aic_base) - pr_debug("AT91: PM - wakeup %08x\n", - at91_aic_read(AT91_AIC_IPR) & - at91_aic_read(AT91_AIC_IMR)); - error: target_state = PM_SUSPEND_ON; - if (IS_ENABLED(CONFIG_OLD_IRQ_AT91) && at91_aic_base) - at91_irq_resume(); - if (of_have_populated_dt()) at91_pinctrl_gpio_resume(); else diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index 98b0c1a62899..6c3013e3309b 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c @@ -49,10 +49,6 @@ void __init at91_init_irq_default(void) void __init at91_init_interrupts(unsigned int *priority) { - /* Initialize the AIC interrupt controller */ - if (IS_ENABLED(CONFIG_OLD_IRQ_AT91)) - at91_aic_init(priority, at91_boot_soc.extern_irq); - /* Enable GPIO interrupts */ at91_gpio_irq_setup(); } -- cgit v1.2.3 From 865a381223cff0d6d976d9bbe1d57a9288ba147b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 2 Dec 2014 12:54:57 +0100 Subject: ARM: at91: cleanup initilisation code by removing dead code The AT91-specific SoC strucutre "struct at91_init_soc" was filled with specific !DT initilisation functions. Now that we got rid of the !DT board file description, remove unneeded functions. Signed-off-by: Arnd Bergmann [nicolas.ferre@atmel.com: split patch] Signed-off-by: Nicolas Ferre --- arch/arm/mach-at91/generic.h | 13 ----------- arch/arm/mach-at91/setup.c | 54 -------------------------------------------- arch/arm/mach-at91/soc.h | 6 ----- 3 files changed, 73 deletions(-) (limited to 'arch/arm/mach-at91/setup.c') diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index eb81940f9848..6c5e67b0edfe 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h @@ -22,19 +22,13 @@ extern void __init at91_init_sram(int bank, unsigned long base, /* Processors */ extern void __init at91rm9200_set_type(int type); -extern void __init at91_initialize(unsigned long main_clock); extern void __init at91rm9200_dt_initialize(void); extern void __init at91_dt_initialize(void); /* Interrupts */ -extern void __init at91_init_irq_default(void); -extern void __init at91_init_interrupts(unsigned int priority[]); extern void __init at91_sysirq_mask_rtc(u32 rtc_base); extern void __init at91_sysirq_mask_rtt(u32 rtt_base); - /* Devices */ -extern void __init at91_register_devices(void); - /* Timer */ extern void __init at91_init_time(void); extern void at91rm9200_ioremap_st(u32 addr); @@ -42,19 +36,12 @@ extern void at91rm9200_timer_init(void); extern void at91sam926x_ioremap_pit(u32 addr); extern void at91sam926x_pit_init(int irq); - /* Power Management */ -extern void at91_irq_suspend(void); -extern void at91_irq_resume(void); - /* idle */ extern void at91sam9_idle(void); /* 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 */ diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index 6c3013e3309b..ce25e85720fb 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c @@ -42,31 +42,9 @@ void __init at91rm9200_set_type(int type) at91_get_soc_subtype(&at91_soc_initdata)); } -void __init at91_init_irq_default(void) -{ - at91_init_interrupts(at91_boot_soc.default_irq_priority); -} - -void __init at91_init_interrupts(unsigned int *priority) -{ - /* Enable GPIO interrupts */ - at91_gpio_irq_setup(); -} - void __iomem *at91_ramc_base[2]; EXPORT_SYMBOL_GPL(at91_ramc_base); -void __init at91_ioremap_ramc(int id, u32 addr, u32 size) -{ - if (id < 0 || id > 1) { - pr_emerg("Wrong RAM controller id (%d), cannot continue\n", id); - BUG(); - } - at91_ramc_base[id] = ioremap(addr, size); - if (!at91_ramc_base[id]) - panic(pr_fmt("Impossible to ioremap ramc.%d 0x%x\n"), id, addr); -} - static struct map_desc sram_desc[2] __initdata; void __init at91_init_sram(int bank, unsigned long base, unsigned int length) @@ -414,7 +392,6 @@ void __init at91_ioremap_matrix(u32 base_addr) panic(pr_fmt("Impossible to ioremap at91_matrix_base\n")); } -#if defined(CONFIG_OF) static struct of_device_id ramc_ids[] = { { .compatible = "atmel,at91rm9200-sdramc", .data = at91rm9200_standby }, { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby }, @@ -456,10 +433,6 @@ void __init at91rm9200_dt_initialize(void) { at91_dt_ramc(); - /* Register the processor-specific clocks */ - if (at91_boot_soc.register_clocks) - at91_boot_soc.register_clocks(); - at91_boot_soc.init(); } @@ -467,33 +440,6 @@ void __init at91_dt_initialize(void) { at91_dt_ramc(); - /* Register the processor-specific clocks */ - if (at91_boot_soc.register_clocks) - at91_boot_soc.register_clocks(); - if (at91_boot_soc.init) at91_boot_soc.init(); } -#endif - -void __init at91_initialize(unsigned long main_clock) -{ - at91_boot_soc.ioremap_registers(); - - /* Register the processor-specific clocks */ - at91_boot_soc.register_clocks(); - - at91_boot_soc.init(); - - pinctrl_provide_dummies(); -} - -void __init at91_register_devices(void) -{ - at91_boot_soc.register_devices(); -} - -void __init at91_init_time(void) -{ - at91_boot_soc.init_time(); -} diff --git a/arch/arm/mach-at91/soc.h b/arch/arm/mach-at91/soc.h index 9a8fd97a8bef..ae6c0b2f1146 100644 --- a/arch/arm/mach-at91/soc.h +++ b/arch/arm/mach-at91/soc.h @@ -6,14 +6,8 @@ struct at91_init_soc { int builtin; - u32 extern_irq; - unsigned int *default_irq_priority; void (*map_io)(void); - void (*ioremap_registers)(void); - void (*register_clocks)(void); - void (*register_devices)(void); void (*init)(void); - void (*init_time)(void); }; extern struct at91_init_soc at91_boot_soc; -- cgit v1.2.3