mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 21:02:19 +00:00
8ec6d93508
Add support for the Lantiq XWAY family of Mips24KEc SoCs. * Danube (PSB50702) * Twinpass (PSB4000) * AR9 (PSB50802) * Amazon SE (PSB5061) The Amazon SE is a lightweight SoC and has no PCI as well as a different clock. We split the code out into seperate files to handle this. The GPIO pins on the SoCs are multi function and there are several bits we can use to configure the pins. To be as compatible as possible to GPIOLIB we add a function int lq_gpio_request(unsigned int pin, unsigned int alt0, unsigned int alt1, unsigned int dir, const char *name); which lets you configure the 2 "alternate function" bits. This way drivers like PCI can make use of GPIOLIB without a cubersome wrapper. The PLL code inside arch/mips/lantiq/xway/clk-xway.c is voodoo to me. It was taken from a 2.4.20 source tree and was never really changed by me since then. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: Ralph Hempel <ralph.hempel@lantiq.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/2249/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
92 lines
2.2 KiB
C
92 lines
2.2 KiB
C
/*
|
|
* 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.
|
|
*
|
|
* Copyright (C) 2010 John Crispin <blogic@openwrt.org>
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/io.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/pm.h>
|
|
#include <linux/module.h>
|
|
#include <asm/reboot.h>
|
|
|
|
#include <lantiq_soc.h>
|
|
|
|
#define ltq_rcu_w32(x, y) ltq_w32((x), ltq_rcu_membase + (y))
|
|
#define ltq_rcu_r32(x) ltq_r32(ltq_rcu_membase + (x))
|
|
|
|
/* register definitions */
|
|
#define LTQ_RCU_RST 0x0010
|
|
#define LTQ_RCU_RST_ALL 0x40000000
|
|
|
|
#define LTQ_RCU_RST_STAT 0x0014
|
|
#define LTQ_RCU_STAT_SHIFT 26
|
|
|
|
static struct resource ltq_rcu_resource = {
|
|
.name = "rcu",
|
|
.start = LTQ_RCU_BASE_ADDR,
|
|
.end = LTQ_RCU_BASE_ADDR + LTQ_RCU_SIZE - 1,
|
|
.flags = IORESOURCE_MEM,
|
|
};
|
|
|
|
/* remapped base addr of the reset control unit */
|
|
static void __iomem *ltq_rcu_membase;
|
|
|
|
/* This function is used by the watchdog driver */
|
|
int ltq_reset_cause(void)
|
|
{
|
|
u32 val = ltq_rcu_r32(LTQ_RCU_RST_STAT);
|
|
return val >> LTQ_RCU_STAT_SHIFT;
|
|
}
|
|
EXPORT_SYMBOL_GPL(ltq_reset_cause);
|
|
|
|
static void ltq_machine_restart(char *command)
|
|
{
|
|
pr_notice("System restart\n");
|
|
local_irq_disable();
|
|
ltq_rcu_w32(ltq_rcu_r32(LTQ_RCU_RST) | LTQ_RCU_RST_ALL, LTQ_RCU_RST);
|
|
unreachable();
|
|
}
|
|
|
|
static void ltq_machine_halt(void)
|
|
{
|
|
pr_notice("System halted.\n");
|
|
local_irq_disable();
|
|
unreachable();
|
|
}
|
|
|
|
static void ltq_machine_power_off(void)
|
|
{
|
|
pr_notice("Please turn off the power now.\n");
|
|
local_irq_disable();
|
|
unreachable();
|
|
}
|
|
|
|
static int __init mips_reboot_setup(void)
|
|
{
|
|
/* insert and request the memory region */
|
|
if (insert_resource(&iomem_resource, <q_rcu_resource) < 0)
|
|
panic("Failed to insert rcu memory\n");
|
|
|
|
if (request_mem_region(ltq_rcu_resource.start,
|
|
resource_size(<q_rcu_resource), "rcu") < 0)
|
|
panic("Failed to request rcu memory\n");
|
|
|
|
/* remap rcu register range */
|
|
ltq_rcu_membase = ioremap_nocache(ltq_rcu_resource.start,
|
|
resource_size(<q_rcu_resource));
|
|
if (!ltq_rcu_membase)
|
|
panic("Failed to remap rcu memory\n");
|
|
|
|
_machine_restart = ltq_machine_restart;
|
|
_machine_halt = ltq_machine_halt;
|
|
pm_power_off = ltq_machine_power_off;
|
|
|
|
return 0;
|
|
}
|
|
|
|
arch_initcall(mips_reboot_setup);
|