2008-07-14 15:03:10 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 by Maurus Cuelenaere
|
|
|
|
*
|
|
|
|
* 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2008-07-17 10:13:56 +00:00
|
|
|
|
|
|
|
#ifndef __SYSTEM_TARGET_H_
|
|
|
|
#define __SYSTEM_TARGET_H_
|
|
|
|
|
2010-07-15 17:15:20 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
2008-07-14 15:03:10 +00:00
|
|
|
#include "config.h"
|
2018-06-28 10:24:26 +00:00
|
|
|
#include "cpu.h"
|
2008-07-14 15:03:10 +00:00
|
|
|
#include "mipsregs.h"
|
|
|
|
|
2009-02-13 00:45:49 +00:00
|
|
|
#define CACHE_SIZE 16*1024
|
|
|
|
#define CACHE_LINE_SIZE 32
|
|
|
|
#include "mmu-mips.h"
|
2008-07-14 15:03:10 +00:00
|
|
|
|
2010-07-15 22:01:06 +00:00
|
|
|
/* no optimized byteswap functions implemented for mips, yet */
|
|
|
|
#define NEED_GENERIC_BYTESWAPS
|
|
|
|
|
2018-06-28 10:24:26 +00:00
|
|
|
#define STORAGE_WANTS_ALIGN
|
|
|
|
|
2009-02-13 00:45:49 +00:00
|
|
|
/* This one returns the old status */
|
2008-07-14 15:03:10 +00:00
|
|
|
static inline int set_interrupt_status(int status, int mask)
|
|
|
|
{
|
2009-11-26 16:57:30 +00:00
|
|
|
unsigned int res, oldstatus;
|
|
|
|
|
|
|
|
res = oldstatus = read_c0_status();
|
|
|
|
res &= ~mask;
|
|
|
|
res |= (status & mask);
|
|
|
|
write_c0_status(res);
|
|
|
|
|
|
|
|
return oldstatus;
|
2008-07-14 15:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void enable_interrupt(void)
|
|
|
|
{
|
|
|
|
/* Set IE bit */
|
|
|
|
set_c0_status(ST0_IE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void disable_interrupt(void)
|
|
|
|
{
|
|
|
|
/* Clear IE bit */
|
|
|
|
clear_c0_status(ST0_IE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int disable_interrupt_save(int mask)
|
|
|
|
{
|
2009-02-13 00:45:49 +00:00
|
|
|
return set_interrupt_status(0, mask);
|
2008-07-14 15:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void restore_interrupt(int status)
|
|
|
|
{
|
|
|
|
write_c0_status(status);
|
|
|
|
}
|
|
|
|
|
2009-02-13 00:45:49 +00:00
|
|
|
#define disable_irq() disable_interrupt()
|
|
|
|
#define enable_irq() enable_interrupt()
|
|
|
|
#define HIGHEST_IRQ_LEVEL 0
|
|
|
|
#define set_irq_level(status) set_interrupt_status((status), ST0_IE)
|
|
|
|
#define disable_irq_save() disable_interrupt_save(ST0_IE)
|
|
|
|
#define restore_irq(c0_status) restore_interrupt(c0_status)
|
2008-07-17 10:13:56 +00:00
|
|
|
#define UNCACHED_ADDRESS(addr) ((unsigned int)(addr) | 0xA0000000)
|
2009-02-09 10:02:38 +00:00
|
|
|
#define UNCACHED_ADDR(x) UNCACHED_ADDRESS((x))
|
2008-08-06 20:39:02 +00:00
|
|
|
#define PHYSADDR(x) ((x) & 0x1fffffff)
|
2008-07-17 10:13:56 +00:00
|
|
|
|
2008-08-10 21:44:48 +00:00
|
|
|
void system_enable_irq(unsigned int irq);
|
|
|
|
void udelay(unsigned int usec);
|
|
|
|
void mdelay(unsigned int msec);
|
2008-12-20 01:48:46 +00:00
|
|
|
void dma_enable(void);
|
|
|
|
void dma_disable(void);
|
2008-07-16 15:29:03 +00:00
|
|
|
|
2018-06-28 10:24:26 +00:00
|
|
|
#if CONFIG_CPU == JZ4732
|
2009-05-26 22:57:49 +00:00
|
|
|
#define DMA_AIC_TX_CHANNEL 0
|
2008-11-04 20:30:01 +00:00
|
|
|
#define DMA_NAND_CHANNEL 1
|
|
|
|
#define DMA_USB_CHANNEL 2
|
2009-05-26 22:57:49 +00:00
|
|
|
#define DMA_LCD_CHANNEL 3
|
2018-06-28 10:24:26 +00:00
|
|
|
#elif CONFIG_CPU == JZ4760B
|
|
|
|
#define DMA_AIC_TX_CHANNEL 0
|
|
|
|
#define DMA_NAND_CHANNEL 1
|
|
|
|
#define DMA_USB_CHANNEL 2
|
2020-08-25 03:34:34 +00:00
|
|
|
#define DMA_SD_RX_CHANNEL0 3
|
|
|
|
#define DMA_SD_RX_CHANNEL1 4
|
|
|
|
// Note: channel 5 and 11 cannot be used!
|
|
|
|
#define DMA_SD_TX_CHANNEL0 6
|
|
|
|
#define DMA_SD_TX_CHANNEL1 7
|
|
|
|
#define DMA_SD_RX_CHANNEL(n) 3+n
|
|
|
|
#define DMA_SD_TX_CHANNEL(n) 6+n
|
2018-06-28 10:24:26 +00:00
|
|
|
#endif
|
2008-07-17 10:13:56 +00:00
|
|
|
|
2008-12-04 18:26:19 +00:00
|
|
|
#define XDMA_CALLBACK(n) DMA ## n
|
|
|
|
#define DMA_CALLBACK(n) XDMA_CALLBACK(n)
|
|
|
|
|
2009-11-26 16:57:30 +00:00
|
|
|
#define DMA_IRQ(n) (IRQ_DMA_0 + (n))
|
|
|
|
#define GPIO_IRQ(n) (IRQ_GPIO_0 + (n))
|
2008-12-20 01:48:46 +00:00
|
|
|
|
2012-01-04 17:07:21 +00:00
|
|
|
/*---------------------------------------------------------------------------
|
|
|
|
* Put core in a power-saving state.
|
|
|
|
*---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static inline void core_sleep(void)
|
|
|
|
{
|
2018-06-28 10:24:26 +00:00
|
|
|
#if CONFIG_CPU == JZ4732 || CONFIG_CPU == JZ4760B
|
2012-01-04 17:07:21 +00:00
|
|
|
__cpm_idle_mode();
|
|
|
|
#endif
|
|
|
|
asm volatile(".set mips32r2 \n"
|
|
|
|
"mfc0 $8, $12 \n" /* mfc t0, $12 */
|
|
|
|
"move $9, $8 \n" /* move t1, t0 */
|
|
|
|
"la $10, 0x8000000 \n" /* la t2, 0x8000000 */
|
|
|
|
"or $8, $8, $10 \n" /* Enable reduced power mode */
|
|
|
|
"mtc0 $8, $12 \n" /* mtc t0, $12 */
|
|
|
|
"wait \n"
|
|
|
|
"mtc0 $9, $12 \n" /* mtc t1, $12 */
|
|
|
|
".set mips0 \n"
|
|
|
|
::: "t0", "t1", "t2"
|
|
|
|
);
|
|
|
|
enable_irq();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-04 20:30:01 +00:00
|
|
|
#endif /* __SYSTEM_TARGET_H_ */
|