2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-pxa/pxa25x.c
|
|
|
|
*
|
|
|
|
* Author: Nicolas Pitre
|
|
|
|
* Created: Jun 15, 2001
|
|
|
|
* Copyright: MontaVista Software Inc.
|
|
|
|
*
|
|
|
|
* Code specific to PXA21x/25x/26x variants.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Since this file should be linked before any other machine specific file,
|
|
|
|
* the __initcall() here will be executed first. This serves as default
|
|
|
|
* initialization stuff for PXA machines which can be overridden later if
|
|
|
|
* need be.
|
|
|
|
*/
|
2011-07-26 17:53:52 +08:00
|
|
|
#include <linux/gpio.h>
|
2011-10-17 20:37:52 +08:00
|
|
|
#include <linux/gpio-pxa.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
2007-05-15 17:39:49 +08:00
|
|
|
#include <linux/platform_device.h>
|
2007-10-18 18:04:39 +08:00
|
|
|
#include <linux/suspend.h>
|
2011-04-23 04:03:11 +08:00
|
|
|
#include <linux/syscore_ops.h>
|
2010-11-29 18:18:26 +08:00
|
|
|
#include <linux/irq.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-10-11 08:20:19 +08:00
|
|
|
#include <asm/mach/map.h>
|
2011-06-23 00:41:48 +08:00
|
|
|
#include <asm/suspend.h>
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/hardware.h>
|
|
|
|
#include <mach/irqs.h>
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "pxa25x.h"
|
2008-08-07 18:05:25 +08:00
|
|
|
#include <mach/reset.h>
|
2015-01-30 17:45:33 +08:00
|
|
|
#include "pm.h"
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/dma.h>
|
2010-11-03 23:29:35 +08:00
|
|
|
#include <mach/smemc.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "generic.h"
|
2007-05-15 22:39:36 +08:00
|
|
|
#include "devices.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Various clock factors driven by the CCCR register.
|
|
|
|
*/
|
|
|
|
|
2005-06-14 05:35:41 +08:00
|
|
|
#ifdef CONFIG_PM
|
2005-06-04 03:52:27 +08:00
|
|
|
|
2007-07-18 18:38:45 +08:00
|
|
|
#define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
|
|
|
|
#define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
|
|
|
|
|
|
|
|
/*
|
|
|
|
* List of global PXA peripheral registers to preserve.
|
|
|
|
* More ones like CP and general purpose register values are preserved
|
|
|
|
* with the stack pointer in sleep.S.
|
|
|
|
*/
|
2008-09-03 18:06:34 +08:00
|
|
|
enum {
|
2007-07-18 18:38:45 +08:00
|
|
|
SLEEP_SAVE_PSTR,
|
2008-05-03 04:17:06 +08:00
|
|
|
SLEEP_SAVE_COUNT
|
2007-07-18 18:38:45 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void pxa25x_cpu_pm_save(unsigned long *sleep_save)
|
|
|
|
{
|
|
|
|
SAVE(PSTR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pxa25x_cpu_pm_restore(unsigned long *sleep_save)
|
|
|
|
{
|
|
|
|
RESTORE(PSTR);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pxa25x_cpu_pm_enter(suspend_state_t state)
|
2005-06-04 03:52:27 +08:00
|
|
|
{
|
2008-05-08 23:50:39 +08:00
|
|
|
/* Clear reset status */
|
|
|
|
RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
|
|
|
|
|
2005-06-04 03:52:27 +08:00
|
|
|
switch (state) {
|
|
|
|
case PM_SUSPEND_MEM:
|
2011-06-23 00:41:48 +08:00
|
|
|
cpu_suspend(PWRMODE_SLEEP, pxa25x_finish_suspend);
|
2005-06-04 03:52:27 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-06-14 05:35:41 +08:00
|
|
|
|
2008-08-27 19:55:04 +08:00
|
|
|
static int pxa25x_cpu_pm_prepare(void)
|
|
|
|
{
|
|
|
|
/* set resume return address */
|
2011-02-07 01:41:26 +08:00
|
|
|
PSPR = virt_to_phys(cpu_resume);
|
2008-08-27 19:55:04 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pxa25x_cpu_pm_finish(void)
|
|
|
|
{
|
|
|
|
/* ensure not to come back here if it wasn't intended */
|
|
|
|
PSPR = 0;
|
|
|
|
}
|
|
|
|
|
2007-07-18 18:38:45 +08:00
|
|
|
static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns = {
|
2008-05-03 04:17:06 +08:00
|
|
|
.save_count = SLEEP_SAVE_COUNT,
|
2007-10-18 18:04:40 +08:00
|
|
|
.valid = suspend_valid_only_mem,
|
2007-07-18 18:38:45 +08:00
|
|
|
.save = pxa25x_cpu_pm_save,
|
|
|
|
.restore = pxa25x_cpu_pm_restore,
|
|
|
|
.enter = pxa25x_cpu_pm_enter,
|
2008-08-27 19:55:04 +08:00
|
|
|
.prepare = pxa25x_cpu_pm_prepare,
|
|
|
|
.finish = pxa25x_cpu_pm_finish,
|
2007-05-15 18:16:10 +08:00
|
|
|
};
|
2007-07-18 18:38:45 +08:00
|
|
|
|
|
|
|
static void __init pxa25x_init_pm(void)
|
|
|
|
{
|
|
|
|
pxa_cpu_pm_fns = &pxa25x_cpu_pm_fns;
|
|
|
|
}
|
2008-01-02 08:24:49 +08:00
|
|
|
#else
|
|
|
|
static inline void pxa25x_init_pm(void) {}
|
2005-06-14 05:35:41 +08:00
|
|
|
#endif
|
2007-05-15 18:16:10 +08:00
|
|
|
|
2007-08-29 17:22:17 +08:00
|
|
|
/* PXA25x: supports wakeup from GPIO0..GPIO15 and RTC alarm
|
|
|
|
*/
|
|
|
|
|
2010-11-29 18:18:26 +08:00
|
|
|
static int pxa25x_set_wake(struct irq_data *d, unsigned int on)
|
2007-08-29 17:22:17 +08:00
|
|
|
{
|
2011-10-10 16:03:51 +08:00
|
|
|
int gpio = pxa_irq_to_gpio(d->irq);
|
2008-03-11 09:46:28 +08:00
|
|
|
uint32_t mask = 0;
|
|
|
|
|
|
|
|
if (gpio >= 0 && gpio < 85)
|
|
|
|
return gpio_set_wake(gpio, on);
|
2007-08-29 17:22:17 +08:00
|
|
|
|
2010-11-29 18:18:26 +08:00
|
|
|
if (d->irq == IRQ_RTCAlrm) {
|
2007-08-29 17:22:17 +08:00
|
|
|
mask = PWER_RTC;
|
|
|
|
goto set_pwer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
set_pwer:
|
|
|
|
if (on)
|
|
|
|
PWER |= mask;
|
|
|
|
else
|
|
|
|
PWER &=~mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-06-22 11:14:09 +08:00
|
|
|
void __init pxa25x_init_irq(void)
|
|
|
|
{
|
2008-03-04 14:19:58 +08:00
|
|
|
pxa_init_irq(32, pxa25x_set_wake);
|
2007-06-22 11:14:09 +08:00
|
|
|
}
|
|
|
|
|
2008-11-26 18:12:04 +08:00
|
|
|
#ifdef CONFIG_CPU_PXA26x
|
|
|
|
void __init pxa26x_init_irq(void)
|
|
|
|
{
|
|
|
|
pxa_init_irq(32, pxa25x_set_wake);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-10-11 08:20:19 +08:00
|
|
|
static struct map_desc pxa25x_io_desc[] __initdata = {
|
|
|
|
{ /* Mem Ctl */
|
2011-10-02 04:03:45 +08:00
|
|
|
.virtual = (unsigned long)SMEMC_VIRT,
|
2010-11-03 23:29:35 +08:00
|
|
|
.pfn = __phys_to_pfn(PXA2XX_SMEMC_BASE),
|
2014-07-11 19:00:36 +08:00
|
|
|
.length = SMEMC_SIZE,
|
2010-10-11 08:20:19 +08:00
|
|
|
.type = MT_DEVICE
|
2014-07-11 19:00:37 +08:00
|
|
|
}, { /* UNCACHED_PHYS_0 */
|
|
|
|
.virtual = UNCACHED_PHYS_0,
|
|
|
|
.pfn = __phys_to_pfn(0x00000000),
|
|
|
|
.length = UNCACHED_PHYS_0_SIZE,
|
|
|
|
.type = MT_DEVICE
|
2010-10-11 08:20:19 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
void __init pxa25x_map_io(void)
|
|
|
|
{
|
|
|
|
pxa_map_io();
|
|
|
|
iotable_init(ARRAY_AND_SIZE(pxa25x_io_desc));
|
|
|
|
pxa25x_get_clk_frequency_khz(1);
|
|
|
|
}
|
|
|
|
|
2012-11-21 08:37:25 +08:00
|
|
|
static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = {
|
2013-04-09 18:12:04 +08:00
|
|
|
.irq_base = PXA_GPIO_TO_IRQ(0),
|
|
|
|
.gpio_set_wake = gpio_set_wake,
|
2012-11-21 08:37:25 +08:00
|
|
|
};
|
|
|
|
|
2007-05-15 17:39:49 +08:00
|
|
|
static struct platform_device *pxa25x_devices[] __initdata = {
|
2008-06-23 06:36:39 +08:00
|
|
|
&pxa25x_device_udc,
|
2010-06-14 00:43:00 +08:00
|
|
|
&pxa_device_pmu,
|
2007-07-17 17:45:58 +08:00
|
|
|
&pxa_device_i2s,
|
2008-11-14 06:50:56 +08:00
|
|
|
&sa1100_device_rtc,
|
2007-12-10 17:54:36 +08:00
|
|
|
&pxa25x_device_ssp,
|
|
|
|
&pxa25x_device_nssp,
|
|
|
|
&pxa25x_device_assp,
|
2008-04-14 04:44:04 +08:00
|
|
|
&pxa25x_device_pwm0,
|
|
|
|
&pxa25x_device_pwm1,
|
2011-02-23 07:29:09 +08:00
|
|
|
&pxa_device_asoc_platform,
|
2007-05-15 17:39:49 +08:00
|
|
|
};
|
|
|
|
|
2007-05-15 18:16:10 +08:00
|
|
|
static int __init pxa25x_init(void)
|
|
|
|
{
|
2011-04-23 04:03:11 +08:00
|
|
|
int ret = 0;
|
2007-06-22 12:40:17 +08:00
|
|
|
|
2008-09-11 10:27:30 +08:00
|
|
|
if (cpu_is_pxa25x()) {
|
2008-07-29 14:26:00 +08:00
|
|
|
|
|
|
|
reset_status = RCSR;
|
|
|
|
|
2009-01-02 16:26:33 +08:00
|
|
|
if ((ret = pxa_init_dma(IRQ_DMA, 16)))
|
2007-06-22 12:40:17 +08:00
|
|
|
return ret;
|
2008-01-02 08:24:49 +08:00
|
|
|
|
2007-07-18 18:38:45 +08:00
|
|
|
pxa25x_init_pm();
|
2008-01-02 08:24:49 +08:00
|
|
|
|
2011-04-23 04:03:11 +08:00
|
|
|
register_syscore_ops(&pxa_irq_syscore_ops);
|
|
|
|
register_syscore_ops(&pxa2xx_mfp_syscore_ops);
|
2008-01-29 07:00:02 +08:00
|
|
|
|
2016-02-16 04:57:47 +08:00
|
|
|
pxa2xx_set_dmac_info(16, 40);
|
2013-04-07 16:44:33 +08:00
|
|
|
pxa_register_device(&pxa25x_device_gpio, &pxa25x_gpio_info);
|
2007-05-15 17:39:49 +08:00
|
|
|
ret = platform_add_devices(pxa25x_devices,
|
|
|
|
ARRAY_SIZE(pxa25x_devices));
|
2008-01-29 07:00:02 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2007-05-15 18:16:10 +08:00
|
|
|
}
|
2008-01-29 07:00:02 +08:00
|
|
|
|
2007-05-15 17:39:49 +08:00
|
|
|
return ret;
|
2007-05-15 18:16:10 +08:00
|
|
|
}
|
|
|
|
|
2008-04-19 17:59:24 +08:00
|
|
|
postcore_initcall(pxa25x_init);
|