mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 18:09:57 +00:00
Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
* 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus: (47 commits) MIPS: Add hibernation support MIPS: Move Cavium CP0 hwrena impl bits to cpu-feature-overrides.h MIPS: Allow CPU specific overriding of CP0 hwrena impl bits. MIPS: Kconfig Add SYS_SUPPORTS_HUGETLBFS and enable it for some systems. Hugetlbfs: Enable hugetlbfs for more systems in Kconfig. MIPS: TLB support for hugetlbfs. MIPS: Add hugetlbfs page defines. MIPS: Add support files for hugetlbfs. MIPS: Remove unused parameters from iPTE_LW. Staging: Add octeon-ethernet driver files. MIPS: Export erratum function needed by octeon-ethernet driver. MIPS: Cavium-Octeon: Add more chip specific feature tests. MIPS: Cavium-Octeon: Add more board type constants. MIPS: Export cvmx_sysinfo_get needed by octeon-ethernet driver. MIPS: Add named alloc functions to OCTEON boot monitor memory allocator. MIPS: Alchemy: devboards: Convert to gpio calls. MIPS: Alchemy: xxs1500: use linux gpio api. MIPS: Alchemy: MTX-1: Use linux gpio api. MIPS: Alchemy: Rewrite GPIO support. MIPS: Alchemy: Remove unused au1000_gpio.h header ...
This commit is contained in:
commit
9cb0fbf7f8
184 changed files with 42641 additions and 676 deletions
|
@ -618,6 +618,8 @@ config CAVIUM_OCTEON_REFERENCE_BOARD
|
|||
select SYS_HAS_EARLY_PRINTK
|
||||
select SYS_HAS_CPU_CAVIUM_OCTEON
|
||||
select SWAP_IO_SPACE
|
||||
select HW_HAS_PCI
|
||||
select ARCH_SUPPORTS_MSI
|
||||
help
|
||||
This option supports all of the Octeon reference boards from Cavium
|
||||
Networks. It builds a kernel that dynamically determines the Octeon
|
||||
|
@ -851,6 +853,11 @@ config SYS_SUPPORTS_BIG_ENDIAN
|
|||
config SYS_SUPPORTS_LITTLE_ENDIAN
|
||||
bool
|
||||
|
||||
config SYS_SUPPORTS_HUGETLBFS
|
||||
bool
|
||||
depends on CPU_SUPPORTS_HUGEPAGES && 64BIT
|
||||
default y
|
||||
|
||||
config IRQ_CPU
|
||||
bool
|
||||
|
||||
|
@ -1055,6 +1062,7 @@ config CPU_MIPS64_R1
|
|||
select CPU_SUPPORTS_32BIT_KERNEL
|
||||
select CPU_SUPPORTS_64BIT_KERNEL
|
||||
select CPU_SUPPORTS_HIGHMEM
|
||||
select CPU_SUPPORTS_HUGEPAGES
|
||||
help
|
||||
Choose this option to build a kernel for release 1 or later of the
|
||||
MIPS64 architecture. Many modern embedded systems with a 64-bit
|
||||
|
@ -1074,6 +1082,7 @@ config CPU_MIPS64_R2
|
|||
select CPU_SUPPORTS_32BIT_KERNEL
|
||||
select CPU_SUPPORTS_64BIT_KERNEL
|
||||
select CPU_SUPPORTS_HIGHMEM
|
||||
select CPU_SUPPORTS_HUGEPAGES
|
||||
help
|
||||
Choose this option to build a kernel for release 2 or later of the
|
||||
MIPS64 architecture. Many modern embedded systems with a 64-bit
|
||||
|
@ -1160,6 +1169,7 @@ config CPU_R5500
|
|||
select CPU_HAS_LLSC
|
||||
select CPU_SUPPORTS_32BIT_KERNEL
|
||||
select CPU_SUPPORTS_64BIT_KERNEL
|
||||
select CPU_SUPPORTS_HUGEPAGES
|
||||
help
|
||||
NEC VR5500 and VR5500A series processors implement 64-bit MIPS IV
|
||||
instruction set.
|
||||
|
@ -1245,6 +1255,7 @@ config CPU_CAVIUM_OCTEON
|
|||
select WEAK_ORDERING
|
||||
select WEAK_REORDERING_BEYOND_LLSC
|
||||
select CPU_SUPPORTS_HIGHMEM
|
||||
select CPU_SUPPORTS_HUGEPAGES
|
||||
help
|
||||
The Cavium Octeon processor is a highly integrated chip containing
|
||||
many ethernet hardware widgets for networking tasks. The processor
|
||||
|
@ -1364,6 +1375,8 @@ config CPU_SUPPORTS_32BIT_KERNEL
|
|||
bool
|
||||
config CPU_SUPPORTS_64BIT_KERNEL
|
||||
bool
|
||||
config CPU_SUPPORTS_HUGEPAGES
|
||||
bool
|
||||
|
||||
#
|
||||
# Set to y for ptrace access to watch registers.
|
||||
|
@ -2121,6 +2134,10 @@ endmenu
|
|||
|
||||
menu "Power management options"
|
||||
|
||||
config ARCH_HIBERNATION_POSSIBLE
|
||||
def_bool y
|
||||
depends on !SMP
|
||||
|
||||
config ARCH_SUSPEND_POSSIBLE
|
||||
def_bool y
|
||||
depends on !SMP
|
||||
|
|
|
@ -167,7 +167,6 @@ libs-$(CONFIG_ARC) += arch/mips/fw/arc/
|
|||
libs-$(CONFIG_CFE) += arch/mips/fw/cfe/
|
||||
libs-$(CONFIG_SNIPROM) += arch/mips/fw/sni/
|
||||
libs-y += arch/mips/fw/lib/
|
||||
libs-$(CONFIG_SIBYTE_CFE) += arch/mips/sibyte/cfe/
|
||||
|
||||
#
|
||||
# Board-dependent options and extra files
|
||||
|
@ -184,7 +183,6 @@ load-$(CONFIG_MACH_JAZZ) += 0xffffffff80080000
|
|||
# Common Alchemy Au1x00 stuff
|
||||
#
|
||||
core-$(CONFIG_SOC_AU1X00) += arch/mips/alchemy/common/
|
||||
cflags-$(CONFIG_SOC_AU1X00) += -I$(srctree)/arch/mips/include/asm/mach-au1x00
|
||||
|
||||
#
|
||||
# AMD Alchemy Pb1000 eval board
|
||||
|
@ -282,6 +280,10 @@ load-$(CONFIG_MIPS_MTX1) += 0xffffffff80100000
|
|||
libs-$(CONFIG_MIPS_XXS1500) += arch/mips/alchemy/xxs1500/
|
||||
load-$(CONFIG_MIPS_XXS1500) += 0xffffffff80100000
|
||||
|
||||
# must be last for Alchemy systems for GPIO to work properly
|
||||
cflags-$(CONFIG_SOC_AU1X00) += -I$(srctree)/arch/mips/include/asm/mach-au1x00
|
||||
|
||||
|
||||
#
|
||||
# Cobalt Server
|
||||
#
|
||||
|
@ -675,6 +677,9 @@ core-y += arch/mips/kernel/ arch/mips/mm/ arch/mips/math-emu/
|
|||
|
||||
drivers-$(CONFIG_OPROFILE) += arch/mips/oprofile/
|
||||
|
||||
# suspend and hibernation support
|
||||
drivers-$(CONFIG_PM) += arch/mips/power/
|
||||
|
||||
ifdef CONFIG_LASAT
|
||||
rom.bin rom.sw: vmlinux
|
||||
$(Q)$(MAKE) $(build)=arch/mips/lasat/image $@
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
# au1000-style gpio
|
||||
config ALCHEMY_GPIO_AU1000
|
||||
bool
|
||||
|
||||
# select this in your board config if you don't want to use the gpio
|
||||
# namespace as documented in the manuals. In this case however you need
|
||||
# to create the necessary gpio_* functions in your board code/headers!
|
||||
# see arch/mips/include/asm/mach-au1x00/gpio.h for more information.
|
||||
config ALCHEMY_GPIO_INDIRECT
|
||||
def_bool n
|
||||
|
||||
choice
|
||||
prompt "Machine type"
|
||||
depends on MACH_ALCHEMY
|
||||
|
@ -108,22 +119,27 @@ endchoice
|
|||
config SOC_AU1000
|
||||
bool
|
||||
select SOC_AU1X00
|
||||
select ALCHEMY_GPIO_AU1000
|
||||
|
||||
config SOC_AU1100
|
||||
bool
|
||||
select SOC_AU1X00
|
||||
select ALCHEMY_GPIO_AU1000
|
||||
|
||||
config SOC_AU1500
|
||||
bool
|
||||
select SOC_AU1X00
|
||||
select ALCHEMY_GPIO_AU1000
|
||||
|
||||
config SOC_AU1550
|
||||
bool
|
||||
select SOC_AU1X00
|
||||
select ALCHEMY_GPIO_AU1000
|
||||
|
||||
config SOC_AU1200
|
||||
bool
|
||||
select SOC_AU1X00
|
||||
select ALCHEMY_GPIO_AU1000
|
||||
|
||||
config SOC_AU1X00
|
||||
bool
|
||||
|
@ -134,4 +150,5 @@ config SOC_AU1X00
|
|||
select SYS_HAS_CPU_MIPS32_R1
|
||||
select SYS_SUPPORTS_32BIT_KERNEL
|
||||
select SYS_SUPPORTS_APM_EMULATION
|
||||
select ARCH_REQUIRE_GPIOLIB
|
||||
select GENERIC_GPIO
|
||||
select ARCH_WANT_OPTIONAL_GPIOLIB
|
||||
|
|
|
@ -7,7 +7,14 @@
|
|||
|
||||
obj-y += prom.o irq.o puts.o time.o reset.o \
|
||||
clocks.o platform.o power.o setup.o \
|
||||
sleeper.o dma.o dbdma.o gpio.o
|
||||
sleeper.o dma.o dbdma.o
|
||||
|
||||
# optional gpiolib support
|
||||
ifeq ($(CONFIG_ALCHEMY_GPIO_INDIRECT),)
|
||||
ifeq ($(CONFIG_GPIOLIB),y)
|
||||
obj-$(CONFIG_ALCHEMY_GPIO_AU1000) += gpiolib-au1000.o
|
||||
endif
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_PCI) += pci.o
|
||||
|
||||
|
|
|
@ -1,201 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009, OpenWrt.org, Florian Fainelli <florian@openwrt.org>
|
||||
* Architecture specific GPIO support
|
||||
*
|
||||
* 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 PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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.,
|
||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Notes :
|
||||
* au1000 SoC have only one GPIO line : GPIO1
|
||||
* others have a second one : GPIO2
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
struct au1000_gpio_chip {
|
||||
struct gpio_chip chip;
|
||||
void __iomem *regbase;
|
||||
};
|
||||
|
||||
#if !defined(CONFIG_SOC_AU1000)
|
||||
static int au1000_gpio2_get(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
u32 mask = 1 << offset;
|
||||
struct au1000_gpio_chip *gpch;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
return readl(gpch->regbase + AU1000_GPIO2_ST) & mask;
|
||||
}
|
||||
|
||||
static void au1000_gpio2_set(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
u32 mask = ((GPIO2_OUT_EN_MASK << offset) | (!!value << offset));
|
||||
struct au1000_gpio_chip *gpch;
|
||||
unsigned long flags;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
|
||||
local_irq_save(flags);
|
||||
writel(mask, gpch->regbase + AU1000_GPIO2_OUT);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static int au1000_gpio2_direction_input(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
u32 mask = 1 << offset;
|
||||
u32 tmp;
|
||||
struct au1000_gpio_chip *gpch;
|
||||
unsigned long flags;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
|
||||
local_irq_save(flags);
|
||||
tmp = readl(gpch->regbase + AU1000_GPIO2_DIR);
|
||||
tmp &= ~mask;
|
||||
writel(tmp, gpch->regbase + AU1000_GPIO2_DIR);
|
||||
local_irq_restore(flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int au1000_gpio2_direction_output(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
u32 mask = 1 << offset;
|
||||
u32 out_mask = ((GPIO2_OUT_EN_MASK << offset) | (!!value << offset));
|
||||
u32 tmp;
|
||||
struct au1000_gpio_chip *gpch;
|
||||
unsigned long flags;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
|
||||
local_irq_save(flags);
|
||||
tmp = readl(gpch->regbase + AU1000_GPIO2_DIR);
|
||||
tmp |= mask;
|
||||
writel(tmp, gpch->regbase + AU1000_GPIO2_DIR);
|
||||
writel(out_mask, gpch->regbase + AU1000_GPIO2_OUT);
|
||||
local_irq_restore(flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* !defined(CONFIG_SOC_AU1000) */
|
||||
|
||||
static int au1000_gpio1_get(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
u32 mask = 1 << offset;
|
||||
struct au1000_gpio_chip *gpch;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
return readl(gpch->regbase + AU1000_GPIO1_ST) & mask;
|
||||
}
|
||||
|
||||
static void au1000_gpio1_set(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
u32 mask = 1 << offset;
|
||||
u32 reg_offset;
|
||||
struct au1000_gpio_chip *gpch;
|
||||
unsigned long flags;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
|
||||
if (value)
|
||||
reg_offset = AU1000_GPIO1_OUT;
|
||||
else
|
||||
reg_offset = AU1000_GPIO1_CLR;
|
||||
|
||||
local_irq_save(flags);
|
||||
writel(mask, gpch->regbase + reg_offset);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
static int au1000_gpio1_direction_input(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
u32 mask = 1 << offset;
|
||||
struct au1000_gpio_chip *gpch;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
writel(mask, gpch->regbase + AU1000_GPIO1_ST);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int au1000_gpio1_direction_output(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
u32 mask = 1 << offset;
|
||||
struct au1000_gpio_chip *gpch;
|
||||
|
||||
gpch = container_of(chip, struct au1000_gpio_chip, chip);
|
||||
|
||||
writel(mask, gpch->regbase + AU1000_GPIO1_TRI_OUT);
|
||||
au1000_gpio1_set(chip, offset, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct au1000_gpio_chip au1000_gpio_chip[] = {
|
||||
[0] = {
|
||||
.regbase = (void __iomem *)SYS_BASE,
|
||||
.chip = {
|
||||
.label = "au1000-gpio1",
|
||||
.direction_input = au1000_gpio1_direction_input,
|
||||
.direction_output = au1000_gpio1_direction_output,
|
||||
.get = au1000_gpio1_get,
|
||||
.set = au1000_gpio1_set,
|
||||
.base = 0,
|
||||
.ngpio = 32,
|
||||
},
|
||||
},
|
||||
#if !defined(CONFIG_SOC_AU1000)
|
||||
[1] = {
|
||||
.regbase = (void __iomem *)GPIO2_BASE,
|
||||
.chip = {
|
||||
.label = "au1000-gpio2",
|
||||
.direction_input = au1000_gpio2_direction_input,
|
||||
.direction_output = au1000_gpio2_direction_output,
|
||||
.get = au1000_gpio2_get,
|
||||
.set = au1000_gpio2_set,
|
||||
.base = AU1XXX_GPIO_BASE,
|
||||
.ngpio = 32,
|
||||
},
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
static int __init au1000_gpio_init(void)
|
||||
{
|
||||
gpiochip_add(&au1000_gpio_chip[0].chip);
|
||||
#if !defined(CONFIG_SOC_AU1000)
|
||||
gpiochip_add(&au1000_gpio_chip[1].chip);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
arch_initcall(au1000_gpio_init);
|
||||
|
130
arch/mips/alchemy/common/gpiolib-au1000.c
Normal file
130
arch/mips/alchemy/common/gpiolib-au1000.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2009, OpenWrt.org, Florian Fainelli <florian@openwrt.org>
|
||||
* GPIOLIB support for Au1000, Au1500, Au1100, Au1550 and Au12x0.
|
||||
*
|
||||
* 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 PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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.,
|
||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Notes :
|
||||
* au1000 SoC have only one GPIO block : GPIO1
|
||||
* Au1100, Au15x0, Au12x0 have a second one : GPIO2
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
#include <asm/mach-au1x00/gpio.h>
|
||||
|
||||
#if !defined(CONFIG_SOC_AU1000)
|
||||
static int gpio2_get(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
return alchemy_gpio2_get_value(offset + ALCHEMY_GPIO2_BASE);
|
||||
}
|
||||
|
||||
static void gpio2_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
{
|
||||
alchemy_gpio2_set_value(offset + ALCHEMY_GPIO2_BASE, value);
|
||||
}
|
||||
|
||||
static int gpio2_direction_input(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
return alchemy_gpio2_direction_input(offset + ALCHEMY_GPIO2_BASE);
|
||||
}
|
||||
|
||||
static int gpio2_direction_output(struct gpio_chip *chip, unsigned offset,
|
||||
int value)
|
||||
{
|
||||
return alchemy_gpio2_direction_output(offset + ALCHEMY_GPIO2_BASE,
|
||||
value);
|
||||
}
|
||||
|
||||
static int gpio2_to_irq(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
return alchemy_gpio2_to_irq(offset + ALCHEMY_GPIO2_BASE);
|
||||
}
|
||||
#endif /* !defined(CONFIG_SOC_AU1000) */
|
||||
|
||||
static int gpio1_get(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
return alchemy_gpio1_get_value(offset + ALCHEMY_GPIO1_BASE);
|
||||
}
|
||||
|
||||
static void gpio1_set(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
alchemy_gpio1_set_value(offset + ALCHEMY_GPIO1_BASE, value);
|
||||
}
|
||||
|
||||
static int gpio1_direction_input(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
return alchemy_gpio1_direction_input(offset + ALCHEMY_GPIO1_BASE);
|
||||
}
|
||||
|
||||
static int gpio1_direction_output(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
return alchemy_gpio1_direction_output(offset + ALCHEMY_GPIO1_BASE,
|
||||
value);
|
||||
}
|
||||
|
||||
static int gpio1_to_irq(struct gpio_chip *chip, unsigned offset)
|
||||
{
|
||||
return alchemy_gpio1_to_irq(offset + ALCHEMY_GPIO1_BASE);
|
||||
}
|
||||
|
||||
struct gpio_chip alchemy_gpio_chip[] = {
|
||||
[0] = {
|
||||
.label = "alchemy-gpio1",
|
||||
.direction_input = gpio1_direction_input,
|
||||
.direction_output = gpio1_direction_output,
|
||||
.get = gpio1_get,
|
||||
.set = gpio1_set,
|
||||
.to_irq = gpio1_to_irq,
|
||||
.base = ALCHEMY_GPIO1_BASE,
|
||||
.ngpio = ALCHEMY_GPIO1_NUM,
|
||||
},
|
||||
#if !defined(CONFIG_SOC_AU1000)
|
||||
[1] = {
|
||||
.label = "alchemy-gpio2",
|
||||
.direction_input = gpio2_direction_input,
|
||||
.direction_output = gpio2_direction_output,
|
||||
.get = gpio2_get,
|
||||
.set = gpio2_set,
|
||||
.to_irq = gpio2_to_irq,
|
||||
.base = ALCHEMY_GPIO2_BASE,
|
||||
.ngpio = ALCHEMY_GPIO2_NUM,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
static int __init alchemy_gpiolib_init(void)
|
||||
{
|
||||
gpiochip_add(&alchemy_gpio_chip[0]);
|
||||
#if !defined(CONFIG_SOC_AU1000)
|
||||
gpiochip_add(&alchemy_gpio_chip[1]);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
arch_initcall(alchemy_gpiolib_init);
|
|
@ -27,8 +27,9 @@
|
|||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <asm/cacheflush.h>
|
||||
#include <linux/gpio.h>
|
||||
|
||||
#include <asm/cacheflush.h>
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
|
||||
void au1000_restart(char *command)
|
||||
|
@ -161,7 +162,7 @@ void au1000_halt(void)
|
|||
#else
|
||||
printk(KERN_NOTICE "\n** You can safely turn off the power\n");
|
||||
#ifdef CONFIG_MIPS_MIRAGE
|
||||
au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT);
|
||||
gpio_direction_output(210, 1);
|
||||
#endif
|
||||
#ifdef CONFIG_MIPS_DB1200
|
||||
au_writew(au_readw(0xB980001C) | (1 << 14), 0xB980001C);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
|
@ -94,12 +95,12 @@ void __init board_setup(void)
|
|||
#endif
|
||||
bcsr->pcmcia = 0x0000; /* turn off PCMCIA power */
|
||||
|
||||
#ifdef CONFIG_MIPS_MIRAGE
|
||||
/* Enable GPIO[31:0] inputs */
|
||||
au_writel(0, SYS_PININPUTEN);
|
||||
alchemy_gpio1_input_enable();
|
||||
|
||||
/* GPIO[20] is output, tristate the other input primary GPIOs */
|
||||
au_writel(~(1 << 20), SYS_TRIOUTCLR);
|
||||
#ifdef CONFIG_MIPS_MIRAGE
|
||||
/* GPIO[20] is output */
|
||||
alchemy_gpio_direction_output(20, 0);
|
||||
|
||||
/* Set GPIO[210:208] instead of SSI_0 */
|
||||
pin_func = au_readl(SYS_PINFUNC) | SYS_PF_S0;
|
||||
|
@ -118,8 +119,7 @@ void __init board_setup(void)
|
|||
* Enable speaker amplifier. This should
|
||||
* be part of the audio driver.
|
||||
*/
|
||||
au_writel(au_readl(GPIO2_DIR) | 0x200, GPIO2_DIR);
|
||||
au_writel(0x02000200, GPIO2_OUTPUT);
|
||||
alchemy_gpio_direction_output(209, 1);
|
||||
#endif
|
||||
|
||||
au_sync();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
|
@ -130,8 +131,11 @@ void __init board_setup(void)
|
|||
pin_func |= SYS_PF_USB;
|
||||
|
||||
au_writel(pin_func, SYS_PINFUNC);
|
||||
au_writel(0x2800, SYS_TRIOUTCLR);
|
||||
au_writel(0x0030, SYS_OUTPUTCLR);
|
||||
|
||||
alchemy_gpio_direction_input(11);
|
||||
alchemy_gpio_direction_input(13);
|
||||
alchemy_gpio_direction_output(4, 0);
|
||||
alchemy_gpio_direction_output(5, 0);
|
||||
#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
|
||||
|
||||
/* Make GPIO 15 an input (for interrupt line) */
|
||||
|
@ -140,7 +144,7 @@ void __init board_setup(void)
|
|||
pin_func |= SYS_PF_I2S;
|
||||
au_writel(pin_func, SYS_PINFUNC);
|
||||
|
||||
au_writel(0x8000, SYS_TRIOUTCLR);
|
||||
alchemy_gpio_direction_input(15);
|
||||
|
||||
static_cfg0 = au_readl(MEM_STCFG0) & ~0xc00;
|
||||
au_writel(static_cfg0, MEM_STCFG0);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
@ -88,7 +89,7 @@ void __init board_setup(void)
|
|||
|
||||
/* Set AUX clock to 12 MHz * 8 = 96 MHz */
|
||||
au_writel(8, SYS_AUXPLL);
|
||||
au_writel(0, SYS_PININPUTEN);
|
||||
alchemy_gpio1_input_enable();
|
||||
udelay(100);
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
|
@ -90,11 +91,12 @@ void __init board_setup(void)
|
|||
au_writel(0, SYS_PINSTATERD);
|
||||
udelay(100);
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
|
||||
|
||||
/* GPIO201 is input for PCMCIA card detect */
|
||||
/* GPIO203 is input for PCMCIA interrupt request */
|
||||
au_writel(au_readl(GPIO2_DIR) & ~((1 << 1) | (1 << 3)), GPIO2_DIR);
|
||||
alchemy_gpio_direction_input(201);
|
||||
alchemy_gpio_direction_input(203);
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
|
||||
|
||||
/* Zero and disable FREQ2 */
|
||||
sys_freqctrl = au_readl(SYS_FREQCTRL0);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <linux/suspend.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
#include <asm/mach-au1x00/gpio.h>
|
||||
|
||||
/*
|
||||
* Generic suspend userspace interface for Alchemy development boards.
|
||||
|
@ -26,7 +27,7 @@ static unsigned long db1x_pm_last_wakesrc;
|
|||
static int db1x_pm_enter(suspend_state_t state)
|
||||
{
|
||||
/* enable GPIO based wakeup */
|
||||
au_writel(1, SYS_PININPUTEN);
|
||||
alchemy_gpio1_input_enable();
|
||||
|
||||
/* clear and setup wake cause and source */
|
||||
au_writel(0, SYS_WAKEMSK);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
|
@ -55,10 +56,11 @@ void __init board_setup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
alchemy_gpio2_enable();
|
||||
|
||||
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
|
||||
/* Enable USB power switch */
|
||||
au_writel(au_readl(GPIO2_DIR) | 0x10, GPIO2_DIR);
|
||||
au_writel(0x100000, GPIO2_OUTPUT);
|
||||
alchemy_gpio_direction_output(204, 0);
|
||||
#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
|
@ -74,14 +76,14 @@ void __init board_setup(void)
|
|||
|
||||
/* Initialize GPIO */
|
||||
au_writel(0xFFFFFFFF, SYS_TRIOUTCLR);
|
||||
au_writel(0x00000001, SYS_OUTPUTCLR); /* set M66EN (PCI 66MHz) to OFF */
|
||||
au_writel(0x00000008, SYS_OUTPUTSET); /* set PCI CLKRUN# to OFF */
|
||||
au_writel(0x00000002, SYS_OUTPUTSET); /* set EXT_IO3 ON */
|
||||
au_writel(0x00000020, SYS_OUTPUTCLR); /* set eth PHY TX_ER to OFF */
|
||||
alchemy_gpio_direction_output(0, 0); /* Disable M66EN (PCI 66MHz) */
|
||||
alchemy_gpio_direction_output(3, 1); /* Disable PCI CLKRUN# */
|
||||
alchemy_gpio_direction_output(1, 1); /* Enable EXT_IO3 */
|
||||
alchemy_gpio_direction_output(5, 0); /* Disable eth PHY TX_ER */
|
||||
|
||||
/* Enable LED and set it to green */
|
||||
au_writel(au_readl(GPIO2_DIR) | 0x1800, GPIO2_DIR);
|
||||
au_writel(0x18000800, GPIO2_OUTPUT);
|
||||
alchemy_gpio_direction_output(211, 1); /* green on */
|
||||
alchemy_gpio_direction_output(212, 0); /* red off */
|
||||
|
||||
board_pci_idsel = mtx1_pci_idsel;
|
||||
|
||||
|
@ -101,10 +103,10 @@ mtx1_pci_idsel(unsigned int devsel, int assert)
|
|||
|
||||
if (assert && devsel != 0)
|
||||
/* Suppress signal to Cardbus */
|
||||
au_writel(0x00000002, SYS_OUTPUTCLR); /* set EXT_IO3 OFF */
|
||||
gpio_set_value(1, 0); /* set EXT_IO3 OFF */
|
||||
else
|
||||
au_writel(0x00000002, SYS_OUTPUTSET); /* set EXT_IO3 ON */
|
||||
gpio_set_value(1, 1); /* set EXT_IO3 ON */
|
||||
|
||||
au_sync_udelay(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
|
@ -50,6 +51,9 @@ void __init board_setup(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
alchemy_gpio1_input_enable();
|
||||
alchemy_gpio2_enable();
|
||||
|
||||
/* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
|
||||
pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3;
|
||||
pin_func |= SYS_PF_UR3;
|
||||
|
@ -65,20 +69,19 @@ void __init board_setup(void)
|
|||
au_writel(0x01, UART3_ADDR + UART_MCR); /* UART_MCR_DTR is 0x01??? */
|
||||
|
||||
#ifdef CONFIG_PCMCIA_XXS1500
|
||||
/* Setup PCMCIA signals */
|
||||
au_writel(0, SYS_PININPUTEN);
|
||||
|
||||
/* GPIO 0, 1, and 4 are inputs */
|
||||
au_writel(1 | (1 << 1) | (1 << 4), SYS_TRIOUTCLR);
|
||||
alchemy_gpio_direction_input(0);
|
||||
alchemy_gpio_direction_input(1);
|
||||
alchemy_gpio_direction_input(4);
|
||||
|
||||
/* Enable GPIO2 if not already enabled */
|
||||
au_writel(1, GPIO2_ENABLE);
|
||||
/* GPIO2 208/9/10/11 are inputs */
|
||||
au_writel((1 << 8) | (1 << 9) | (1 << 10) | (1 << 11), GPIO2_DIR);
|
||||
alchemy_gpio_direction_input(208);
|
||||
alchemy_gpio_direction_input(209);
|
||||
alchemy_gpio_direction_input(210);
|
||||
alchemy_gpio_direction_input(211);
|
||||
|
||||
/* Turn off power */
|
||||
au_writel((au_readl(GPIO2_PINSTATE) & ~(1 << 14)) | (1 << 30),
|
||||
GPIO2_OUTPUT);
|
||||
alchemy_gpio_direction_output(214, 0);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
|
|
|
@ -14,5 +14,9 @@ obj-y += dma-octeon.o flash_setup.o
|
|||
obj-y += octeon-memcpy.o
|
||||
|
||||
obj-$(CONFIG_SMP) += smp.o
|
||||
obj-$(CONFIG_PCI) += pci-common.o
|
||||
obj-$(CONFIG_PCI) += pci.o
|
||||
obj-$(CONFIG_PCI) += pcie.o
|
||||
obj-$(CONFIG_PCI_MSI) += msi.o
|
||||
|
||||
EXTRA_CFLAGS += -Werror
|
||||
|
|
|
@ -13,20 +13,327 @@
|
|||
*/
|
||||
#include <linux/types.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/scatterlist.h>
|
||||
|
||||
#include <linux/cache.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
#include <asm/octeon/octeon.h>
|
||||
#include <asm/octeon/cvmx-npi-defs.h>
|
||||
#include <asm/octeon/cvmx-pci-defs.h>
|
||||
|
||||
#include <dma-coherence.h>
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
#include "pci-common.h"
|
||||
#endif
|
||||
|
||||
#define BAR2_PCI_ADDRESS 0x8000000000ul
|
||||
|
||||
struct bar1_index_state {
|
||||
int16_t ref_count; /* Number of PCI mappings using this index */
|
||||
uint16_t address_bits; /* Upper bits of physical address. This is
|
||||
shifted 22 bits */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
static DEFINE_SPINLOCK(bar1_lock);
|
||||
static struct bar1_index_state bar1_state[32];
|
||||
#endif
|
||||
|
||||
dma_addr_t octeon_map_dma_mem(struct device *dev, void *ptr, size_t size)
|
||||
{
|
||||
#ifndef CONFIG_PCI
|
||||
/* Without PCI/PCIe this function can be called for Octeon internal
|
||||
devices such as USB. These devices all support 64bit addressing */
|
||||
mb();
|
||||
return virt_to_phys(ptr);
|
||||
#else
|
||||
unsigned long flags;
|
||||
uint64_t dma_mask;
|
||||
int64_t start_index;
|
||||
dma_addr_t result = -1;
|
||||
uint64_t physical = virt_to_phys(ptr);
|
||||
int64_t index;
|
||||
|
||||
mb();
|
||||
/*
|
||||
* Use the DMA masks to determine the allowed memory
|
||||
* region. For us it doesn't limit the actual memory, just the
|
||||
* address visible over PCI. Devices with limits need to use
|
||||
* lower indexed Bar1 entries.
|
||||
*/
|
||||
if (dev) {
|
||||
dma_mask = dev->coherent_dma_mask;
|
||||
if (dev->dma_mask)
|
||||
dma_mask = *dev->dma_mask;
|
||||
} else {
|
||||
dma_mask = 0xfffffffful;
|
||||
}
|
||||
|
||||
/*
|
||||
* Platform devices, such as the internal USB, skip all
|
||||
* translation and use Octeon physical addresses directly.
|
||||
*/
|
||||
if (!dev || dev->bus == &platform_bus_type)
|
||||
return physical;
|
||||
|
||||
switch (octeon_dma_bar_type) {
|
||||
case OCTEON_DMA_BAR_TYPE_PCIE:
|
||||
if (unlikely(physical < (16ul << 10)))
|
||||
panic("dma_map_single: Not allowed to map first 16KB."
|
||||
" It interferes with BAR0 special area\n");
|
||||
else if ((physical + size >= (256ul << 20)) &&
|
||||
(physical < (512ul << 20)))
|
||||
panic("dma_map_single: Not allowed to map bootbus\n");
|
||||
else if ((physical + size >= 0x400000000ull) &&
|
||||
physical < 0x410000000ull)
|
||||
panic("dma_map_single: "
|
||||
"Attempt to map illegal memory address 0x%llx\n",
|
||||
physical);
|
||||
else if (physical >= 0x420000000ull)
|
||||
panic("dma_map_single: "
|
||||
"Attempt to map illegal memory address 0x%llx\n",
|
||||
physical);
|
||||
else if ((physical + size >=
|
||||
(4ull<<30) - (OCTEON_PCI_BAR1_HOLE_SIZE<<20))
|
||||
&& physical < (4ull<<30))
|
||||
pr_warning("dma_map_single: Warning: "
|
||||
"Mapping memory address that might "
|
||||
"conflict with devices 0x%llx-0x%llx\n",
|
||||
physical, physical+size-1);
|
||||
/* The 2nd 256MB is mapped at 256<<20 instead of 0x410000000 */
|
||||
if ((physical >= 0x410000000ull) && physical < 0x420000000ull)
|
||||
result = physical - 0x400000000ull;
|
||||
else
|
||||
result = physical;
|
||||
if (((result+size-1) & dma_mask) != result+size-1)
|
||||
panic("dma_map_single: Attempt to map address "
|
||||
"0x%llx-0x%llx, which can't be accessed "
|
||||
"according to the dma mask 0x%llx\n",
|
||||
physical, physical+size-1, dma_mask);
|
||||
goto done;
|
||||
|
||||
case OCTEON_DMA_BAR_TYPE_BIG:
|
||||
#ifdef CONFIG_64BIT
|
||||
/* If the device supports 64bit addressing, then use BAR2 */
|
||||
if (dma_mask > BAR2_PCI_ADDRESS) {
|
||||
result = physical + BAR2_PCI_ADDRESS;
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
if (unlikely(physical < (4ul << 10))) {
|
||||
panic("dma_map_single: Not allowed to map first 4KB. "
|
||||
"It interferes with BAR0 special area\n");
|
||||
} else if (physical < (256ul << 20)) {
|
||||
if (unlikely(physical + size > (256ul << 20)))
|
||||
panic("dma_map_single: Requested memory spans "
|
||||
"Bar0 0:256MB and bootbus\n");
|
||||
result = physical;
|
||||
goto done;
|
||||
} else if (unlikely(physical < (512ul << 20))) {
|
||||
panic("dma_map_single: Not allowed to map bootbus\n");
|
||||
} else if (physical < (2ul << 30)) {
|
||||
if (unlikely(physical + size > (2ul << 30)))
|
||||
panic("dma_map_single: Requested memory spans "
|
||||
"Bar0 512MB:2GB and BAR1\n");
|
||||
result = physical;
|
||||
goto done;
|
||||
} else if (physical < (2ul << 30) + (128 << 20)) {
|
||||
/* Fall through */
|
||||
} else if (physical <
|
||||
(4ul << 30) - (OCTEON_PCI_BAR1_HOLE_SIZE << 20)) {
|
||||
if (unlikely
|
||||
(physical + size >
|
||||
(4ul << 30) - (OCTEON_PCI_BAR1_HOLE_SIZE << 20)))
|
||||
panic("dma_map_single: Requested memory "
|
||||
"extends past Bar1 (4GB-%luMB)\n",
|
||||
OCTEON_PCI_BAR1_HOLE_SIZE);
|
||||
result = physical;
|
||||
goto done;
|
||||
} else if ((physical >= 0x410000000ull) &&
|
||||
(physical < 0x420000000ull)) {
|
||||
if (unlikely(physical + size > 0x420000000ull))
|
||||
panic("dma_map_single: Requested memory spans "
|
||||
"non existant memory\n");
|
||||
/* BAR0 fixed mapping 256MB:512MB ->
|
||||
* 16GB+256MB:16GB+512MB */
|
||||
result = physical - 0x400000000ull;
|
||||
goto done;
|
||||
} else {
|
||||
/* Continued below switch statement */
|
||||
}
|
||||
break;
|
||||
|
||||
case OCTEON_DMA_BAR_TYPE_SMALL:
|
||||
#ifdef CONFIG_64BIT
|
||||
/* If the device supports 64bit addressing, then use BAR2 */
|
||||
if (dma_mask > BAR2_PCI_ADDRESS) {
|
||||
result = physical + BAR2_PCI_ADDRESS;
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
/* Continued below switch statement */
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("dma_map_single: Invalid octeon_dma_bar_type\n");
|
||||
}
|
||||
|
||||
/* Don't allow mapping to span multiple Bar entries. The hardware guys
|
||||
won't guarantee that DMA across boards work */
|
||||
if (unlikely((physical >> 22) != ((physical + size - 1) >> 22)))
|
||||
panic("dma_map_single: "
|
||||
"Requested memory spans more than one Bar1 entry\n");
|
||||
|
||||
if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG)
|
||||
start_index = 31;
|
||||
else if (unlikely(dma_mask < (1ul << 27)))
|
||||
start_index = (dma_mask >> 22);
|
||||
else
|
||||
start_index = 31;
|
||||
|
||||
/* Only one processor can access the Bar register at once */
|
||||
spin_lock_irqsave(&bar1_lock, flags);
|
||||
|
||||
/* Look through Bar1 for existing mapping that will work */
|
||||
for (index = start_index; index >= 0; index--) {
|
||||
if ((bar1_state[index].address_bits == physical >> 22) &&
|
||||
(bar1_state[index].ref_count)) {
|
||||
/* An existing mapping will work, use it */
|
||||
bar1_state[index].ref_count++;
|
||||
if (unlikely(bar1_state[index].ref_count < 0))
|
||||
panic("dma_map_single: "
|
||||
"Bar1[%d] reference count overflowed\n",
|
||||
(int) index);
|
||||
result = (index << 22) | (physical & ((1 << 22) - 1));
|
||||
/* Large BAR1 is offset at 2GB */
|
||||
if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG)
|
||||
result += 2ul << 30;
|
||||
goto done_unlock;
|
||||
}
|
||||
}
|
||||
|
||||
/* No existing mappings, look for a free entry */
|
||||
for (index = start_index; index >= 0; index--) {
|
||||
if (unlikely(bar1_state[index].ref_count == 0)) {
|
||||
union cvmx_pci_bar1_indexx bar1_index;
|
||||
/* We have a free entry, use it */
|
||||
bar1_state[index].ref_count = 1;
|
||||
bar1_state[index].address_bits = physical >> 22;
|
||||
bar1_index.u32 = 0;
|
||||
/* Address bits[35:22] sent to L2C */
|
||||
bar1_index.s.addr_idx = physical >> 22;
|
||||
/* Don't put PCI accesses in L2. */
|
||||
bar1_index.s.ca = 1;
|
||||
/* Endian Swap Mode */
|
||||
bar1_index.s.end_swp = 1;
|
||||
/* Set '1' when the selected address range is valid. */
|
||||
bar1_index.s.addr_v = 1;
|
||||
octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index),
|
||||
bar1_index.u32);
|
||||
/* An existing mapping will work, use it */
|
||||
result = (index << 22) | (physical & ((1 << 22) - 1));
|
||||
/* Large BAR1 is offset at 2GB */
|
||||
if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG)
|
||||
result += 2ul << 30;
|
||||
goto done_unlock;
|
||||
}
|
||||
}
|
||||
|
||||
pr_err("dma_map_single: "
|
||||
"Can't find empty BAR1 index for physical mapping 0x%llx\n",
|
||||
(unsigned long long) physical);
|
||||
|
||||
done_unlock:
|
||||
spin_unlock_irqrestore(&bar1_lock, flags);
|
||||
done:
|
||||
pr_debug("dma_map_single 0x%llx->0x%llx\n", physical, result);
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
void octeon_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr)
|
||||
{
|
||||
/* Without PCI/PCIe this function can be called for Octeon internal
|
||||
* devices such as USB. These devices all support 64bit addressing */
|
||||
#ifndef CONFIG_PCI
|
||||
/*
|
||||
* Without PCI/PCIe this function can be called for Octeon internal
|
||||
* devices such as USB. These devices all support 64bit addressing.
|
||||
*/
|
||||
return;
|
||||
#else
|
||||
unsigned long flags;
|
||||
uint64_t index;
|
||||
|
||||
/*
|
||||
* Platform devices, such as the internal USB, skip all
|
||||
* translation and use Octeon physical addresses directly.
|
||||
*/
|
||||
if (dev->bus == &platform_bus_type)
|
||||
return;
|
||||
|
||||
switch (octeon_dma_bar_type) {
|
||||
case OCTEON_DMA_BAR_TYPE_PCIE:
|
||||
/* Nothing to do, all mappings are static */
|
||||
goto done;
|
||||
|
||||
case OCTEON_DMA_BAR_TYPE_BIG:
|
||||
#ifdef CONFIG_64BIT
|
||||
/* Nothing to do for addresses using BAR2 */
|
||||
if (dma_addr >= BAR2_PCI_ADDRESS)
|
||||
goto done;
|
||||
#endif
|
||||
if (unlikely(dma_addr < (4ul << 10)))
|
||||
panic("dma_unmap_single: Unexpect DMA address 0x%llx\n",
|
||||
dma_addr);
|
||||
else if (dma_addr < (2ul << 30))
|
||||
/* Nothing to do for addresses using BAR0 */
|
||||
goto done;
|
||||
else if (dma_addr < (2ul << 30) + (128ul << 20))
|
||||
/* Need to unmap, fall through */
|
||||
index = (dma_addr - (2ul << 30)) >> 22;
|
||||
else if (dma_addr <
|
||||
(4ul << 30) - (OCTEON_PCI_BAR1_HOLE_SIZE << 20))
|
||||
goto done; /* Nothing to do for the rest of BAR1 */
|
||||
else
|
||||
panic("dma_unmap_single: Unexpect DMA address 0x%llx\n",
|
||||
dma_addr);
|
||||
/* Continued below switch statement */
|
||||
break;
|
||||
|
||||
case OCTEON_DMA_BAR_TYPE_SMALL:
|
||||
#ifdef CONFIG_64BIT
|
||||
/* Nothing to do for addresses using BAR2 */
|
||||
if (dma_addr >= BAR2_PCI_ADDRESS)
|
||||
goto done;
|
||||
#endif
|
||||
index = dma_addr >> 22;
|
||||
/* Continued below switch statement */
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("dma_unmap_single: Invalid octeon_dma_bar_type\n");
|
||||
}
|
||||
|
||||
if (unlikely(index > 31))
|
||||
panic("dma_unmap_single: "
|
||||
"Attempt to unmap an invalid address (0x%llx)\n",
|
||||
dma_addr);
|
||||
|
||||
spin_lock_irqsave(&bar1_lock, flags);
|
||||
bar1_state[index].ref_count--;
|
||||
if (bar1_state[index].ref_count == 0)
|
||||
octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index), 0);
|
||||
else if (unlikely(bar1_state[index].ref_count < 0))
|
||||
panic("dma_unmap_single: Bar1[%u] reference count < 0\n",
|
||||
(int) index);
|
||||
spin_unlock_irqrestore(&bar1_lock, flags);
|
||||
done:
|
||||
pr_debug("dma_unmap_single 0x%llx\n", dma_addr);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -11,3 +11,4 @@
|
|||
|
||||
obj-y += cvmx-bootmem.o cvmx-l2c.o cvmx-sysinfo.o octeon-model.o
|
||||
|
||||
obj-$(CONFIG_PCI) += cvmx-helper-errata.o cvmx-helper-jtag.o
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <asm/octeon/cvmx.h>
|
||||
#include <asm/octeon/cvmx-spinlock.h>
|
||||
|
@ -97,6 +98,33 @@ void *cvmx_bootmem_alloc(uint64_t size, uint64_t alignment)
|
|||
return cvmx_bootmem_alloc_range(size, alignment, 0, 0);
|
||||
}
|
||||
|
||||
void *cvmx_bootmem_alloc_named_range(uint64_t size, uint64_t min_addr,
|
||||
uint64_t max_addr, uint64_t align,
|
||||
char *name)
|
||||
{
|
||||
int64_t addr;
|
||||
|
||||
addr = cvmx_bootmem_phy_named_block_alloc(size, min_addr, max_addr,
|
||||
align, name, 0);
|
||||
if (addr >= 0)
|
||||
return cvmx_phys_to_ptr(addr);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *cvmx_bootmem_alloc_named_address(uint64_t size, uint64_t address,
|
||||
char *name)
|
||||
{
|
||||
return cvmx_bootmem_alloc_named_range(size, address, address + size,
|
||||
0, name);
|
||||
}
|
||||
|
||||
void *cvmx_bootmem_alloc_named(uint64_t size, uint64_t alignment, char *name)
|
||||
{
|
||||
return cvmx_bootmem_alloc_named_range(size, 0, 0, alignment, name);
|
||||
}
|
||||
EXPORT_SYMBOL(cvmx_bootmem_alloc_named);
|
||||
|
||||
int cvmx_bootmem_free_named(char *name)
|
||||
{
|
||||
return cvmx_bootmem_phy_named_block_free(name, 0);
|
||||
|
@ -106,6 +134,7 @@ struct cvmx_bootmem_named_block_desc *cvmx_bootmem_find_named_block(char *name)
|
|||
{
|
||||
return cvmx_bootmem_phy_named_block_find(name, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(cvmx_bootmem_find_named_block);
|
||||
|
||||
void cvmx_bootmem_lock(void)
|
||||
{
|
||||
|
@ -584,3 +613,78 @@ int cvmx_bootmem_phy_named_block_free(char *name, uint32_t flags)
|
|||
cvmx_bootmem_unlock();
|
||||
return named_block_ptr != NULL; /* 0 on failure, 1 on success */
|
||||
}
|
||||
|
||||
int64_t cvmx_bootmem_phy_named_block_alloc(uint64_t size, uint64_t min_addr,
|
||||
uint64_t max_addr,
|
||||
uint64_t alignment,
|
||||
char *name,
|
||||
uint32_t flags)
|
||||
{
|
||||
int64_t addr_allocated;
|
||||
struct cvmx_bootmem_named_block_desc *named_block_desc_ptr;
|
||||
|
||||
#ifdef DEBUG
|
||||
cvmx_dprintf("cvmx_bootmem_phy_named_block_alloc: size: 0x%llx, min: "
|
||||
"0x%llx, max: 0x%llx, align: 0x%llx, name: %s\n",
|
||||
(unsigned long long)size,
|
||||
(unsigned long long)min_addr,
|
||||
(unsigned long long)max_addr,
|
||||
(unsigned long long)alignment,
|
||||
name);
|
||||
#endif
|
||||
if (cvmx_bootmem_desc->major_version != 3) {
|
||||
cvmx_dprintf("ERROR: Incompatible bootmem descriptor version: "
|
||||
"%d.%d at addr: %p\n",
|
||||
(int)cvmx_bootmem_desc->major_version,
|
||||
(int)cvmx_bootmem_desc->minor_version,
|
||||
cvmx_bootmem_desc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Take lock here, as name lookup/block alloc/name add need to
|
||||
* be atomic.
|
||||
*/
|
||||
if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
|
||||
cvmx_spinlock_lock((cvmx_spinlock_t *)&(cvmx_bootmem_desc->lock));
|
||||
|
||||
/* Get pointer to first available named block descriptor */
|
||||
named_block_desc_ptr =
|
||||
cvmx_bootmem_phy_named_block_find(NULL,
|
||||
flags | CVMX_BOOTMEM_FLAG_NO_LOCKING);
|
||||
|
||||
/*
|
||||
* Check to see if name already in use, return error if name
|
||||
* not available or no more room for blocks.
|
||||
*/
|
||||
if (cvmx_bootmem_phy_named_block_find(name,
|
||||
flags | CVMX_BOOTMEM_FLAG_NO_LOCKING) || !named_block_desc_ptr) {
|
||||
if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
|
||||
cvmx_spinlock_unlock((cvmx_spinlock_t *)&(cvmx_bootmem_desc->lock));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Round size up to mult of minimum alignment bytes We need
|
||||
* the actual size allocated to allow for blocks to be
|
||||
* coallesced when they are freed. The alloc routine does the
|
||||
* same rounding up on all allocations.
|
||||
*/
|
||||
size = __ALIGN_MASK(size, (CVMX_BOOTMEM_ALIGNMENT_SIZE - 1));
|
||||
|
||||
addr_allocated = cvmx_bootmem_phy_alloc(size, min_addr, max_addr,
|
||||
alignment,
|
||||
flags | CVMX_BOOTMEM_FLAG_NO_LOCKING);
|
||||
if (addr_allocated >= 0) {
|
||||
named_block_desc_ptr->base_addr = addr_allocated;
|
||||
named_block_desc_ptr->size = size;
|
||||
strncpy(named_block_desc_ptr->name, name,
|
||||
cvmx_bootmem_desc->named_block_name_len);
|
||||
named_block_desc_ptr->name[cvmx_bootmem_desc->named_block_name_len - 1] = 0;
|
||||
}
|
||||
|
||||
if (!(flags & CVMX_BOOTMEM_FLAG_NO_LOCKING))
|
||||
cvmx_spinlock_unlock((cvmx_spinlock_t *)&(cvmx_bootmem_desc->lock));
|
||||
return addr_allocated;
|
||||
}
|
||||
|
|
73
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c
Normal file
73
arch/mips/cavium-octeon/executive/cvmx-helper-errata.c
Normal file
|
@ -0,0 +1,73 @@
|
|||
/***********************license start***************
|
||||
* Author: Cavium Networks
|
||||
*
|
||||
* Contact: support@caviumnetworks.com
|
||||
* This file is part of the OCTEON SDK
|
||||
*
|
||||
* Copyright (c) 2003-2008 Cavium Networks
|
||||
*
|
||||
* This file 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.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
|
||||
* NONINFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this file; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* or visit http://www.gnu.org/licenses/.
|
||||
*
|
||||
* This file may also be available under a different license from Cavium.
|
||||
* Contact Cavium Networks for more information
|
||||
***********************license end**************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
* Fixes and workaround for Octeon chip errata. This file
|
||||
* contains functions called by cvmx-helper to workaround known
|
||||
* chip errata. For the most part, code doesn't need to call
|
||||
* these functions directly.
|
||||
*
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <asm/octeon/octeon.h>
|
||||
|
||||
#include <asm/octeon/cvmx-helper-jtag.h>
|
||||
|
||||
/**
|
||||
* Due to errata G-720, the 2nd order CDR circuit on CN52XX pass
|
||||
* 1 doesn't work properly. The following code disables 2nd order
|
||||
* CDR for the specified QLM.
|
||||
*
|
||||
* @qlm: QLM to disable 2nd order CDR for.
|
||||
*/
|
||||
void __cvmx_helper_errata_qlm_disable_2nd_order_cdr(int qlm)
|
||||
{
|
||||
int lane;
|
||||
cvmx_helper_qlm_jtag_init();
|
||||
/* We need to load all four lanes of the QLM, a total of 1072 bits */
|
||||
for (lane = 0; lane < 4; lane++) {
|
||||
/*
|
||||
* Each lane has 268 bits. We need to set
|
||||
* cfg_cdr_incx<67:64> = 3 and cfg_cdr_secord<77> =
|
||||
* 1. All other bits are zero. Bits go in LSB first,
|
||||
* so start off with the zeros for bits <63:0>.
|
||||
*/
|
||||
cvmx_helper_qlm_jtag_shift_zeros(qlm, 63 - 0 + 1);
|
||||
/* cfg_cdr_incx<67:64>=3 */
|
||||
cvmx_helper_qlm_jtag_shift(qlm, 67 - 64 + 1, 3);
|
||||
/* Zeros for bits <76:68> */
|
||||
cvmx_helper_qlm_jtag_shift_zeros(qlm, 76 - 68 + 1);
|
||||
/* cfg_cdr_secord<77>=1 */
|
||||
cvmx_helper_qlm_jtag_shift(qlm, 77 - 77 + 1, 1);
|
||||
/* Zeros for bits <267:78> */
|
||||
cvmx_helper_qlm_jtag_shift_zeros(qlm, 267 - 78 + 1);
|
||||
}
|
||||
cvmx_helper_qlm_jtag_update(qlm);
|
||||
}
|
||||
EXPORT_SYMBOL(__cvmx_helper_errata_qlm_disable_2nd_order_cdr);
|
144
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c
Normal file
144
arch/mips/cavium-octeon/executive/cvmx-helper-jtag.c
Normal file
|
@ -0,0 +1,144 @@
|
|||
|
||||
/***********************license start***************
|
||||
* Author: Cavium Networks
|
||||
*
|
||||
* Contact: support@caviumnetworks.com
|
||||
* This file is part of the OCTEON SDK
|
||||
*
|
||||
* Copyright (c) 2003-2008 Cavium Networks
|
||||
*
|
||||
* This file 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.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
|
||||
* NONINFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this file; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* or visit http://www.gnu.org/licenses/.
|
||||
*
|
||||
* This file may also be available under a different license from Cavium.
|
||||
* Contact Cavium Networks for more information
|
||||
***********************license end**************************************/
|
||||
|
||||
/**
|
||||
*
|
||||
* Helper utilities for qlm_jtag.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <asm/octeon/octeon.h>
|
||||
#include <asm/octeon/cvmx-helper-jtag.h>
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the internal QLM JTAG logic to allow programming
|
||||
* of the JTAG chain by the cvmx_helper_qlm_jtag_*() functions.
|
||||
* These functions should only be used at the direction of Cavium
|
||||
* Networks. Programming incorrect values into the JTAG chain
|
||||
* can cause chip damage.
|
||||
*/
|
||||
void cvmx_helper_qlm_jtag_init(void)
|
||||
{
|
||||
union cvmx_ciu_qlm_jtgc jtgc;
|
||||
uint32_t clock_div = 0;
|
||||
uint32_t divisor = cvmx_sysinfo_get()->cpu_clock_hz / (25 * 1000000);
|
||||
divisor = (divisor - 1) >> 2;
|
||||
/* Convert the divisor into a power of 2 shift */
|
||||
while (divisor) {
|
||||
clock_div++;
|
||||
divisor = divisor >> 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock divider for QLM JTAG operations. eclk is divided by
|
||||
* 2^(CLK_DIV + 2)
|
||||
*/
|
||||
jtgc.u64 = 0;
|
||||
jtgc.s.clk_div = clock_div;
|
||||
jtgc.s.mux_sel = 0;
|
||||
if (OCTEON_IS_MODEL(OCTEON_CN52XX))
|
||||
jtgc.s.bypass = 0x3;
|
||||
else
|
||||
jtgc.s.bypass = 0xf;
|
||||
cvmx_write_csr(CVMX_CIU_QLM_JTGC, jtgc.u64);
|
||||
cvmx_read_csr(CVMX_CIU_QLM_JTGC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write up to 32bits into the QLM jtag chain. Bits are shifted
|
||||
* into the MSB and out the LSB, so you should shift in the low
|
||||
* order bits followed by the high order bits. The JTAG chain is
|
||||
* 4 * 268 bits long, or 1072.
|
||||
*
|
||||
* @qlm: QLM to shift value into
|
||||
* @bits: Number of bits to shift in (1-32).
|
||||
* @data: Data to shift in. Bit 0 enters the chain first, followed by
|
||||
* bit 1, etc.
|
||||
*
|
||||
* Returns The low order bits of the JTAG chain that shifted out of the
|
||||
* circle.
|
||||
*/
|
||||
uint32_t cvmx_helper_qlm_jtag_shift(int qlm, int bits, uint32_t data)
|
||||
{
|
||||
union cvmx_ciu_qlm_jtgd jtgd;
|
||||
jtgd.u64 = 0;
|
||||
jtgd.s.shift = 1;
|
||||
jtgd.s.shft_cnt = bits - 1;
|
||||
jtgd.s.shft_reg = data;
|
||||
if (!OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X))
|
||||
jtgd.s.select = 1 << qlm;
|
||||
cvmx_write_csr(CVMX_CIU_QLM_JTGD, jtgd.u64);
|
||||
do {
|
||||
jtgd.u64 = cvmx_read_csr(CVMX_CIU_QLM_JTGD);
|
||||
} while (jtgd.s.shift);
|
||||
return jtgd.s.shft_reg >> (32 - bits);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift long sequences of zeros into the QLM JTAG chain. It is
|
||||
* common to need to shift more than 32 bits of zeros into the
|
||||
* chain. This function is a convience wrapper around
|
||||
* cvmx_helper_qlm_jtag_shift() to shift more than 32 bits of
|
||||
* zeros at a time.
|
||||
*
|
||||
* @qlm: QLM to shift zeros into
|
||||
* @bits:
|
||||
*/
|
||||
void cvmx_helper_qlm_jtag_shift_zeros(int qlm, int bits)
|
||||
{
|
||||
while (bits > 0) {
|
||||
int n = bits;
|
||||
if (n > 32)
|
||||
n = 32;
|
||||
cvmx_helper_qlm_jtag_shift(qlm, n, 0);
|
||||
bits -= n;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Program the QLM JTAG chain into all lanes of the QLM. You must
|
||||
* have already shifted in 268*4, or 1072 bits into the JTAG
|
||||
* chain. Updating invalid values can possibly cause chip damage.
|
||||
*
|
||||
* @qlm: QLM to program
|
||||
*/
|
||||
void cvmx_helper_qlm_jtag_update(int qlm)
|
||||
{
|
||||
union cvmx_ciu_qlm_jtgd jtgd;
|
||||
|
||||
/* Update the new data */
|
||||
jtgd.u64 = 0;
|
||||
jtgd.s.update = 1;
|
||||
if (!OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X))
|
||||
jtgd.s.select = 1 << qlm;
|
||||
cvmx_write_csr(CVMX_CIU_QLM_JTGD, jtgd.u64);
|
||||
do {
|
||||
jtgd.u64 = cvmx_read_csr(CVMX_CIU_QLM_JTGD);
|
||||
} while (jtgd.s.update);
|
||||
}
|
|
@ -29,6 +29,7 @@
|
|||
* This module provides system/board/application information obtained
|
||||
* by the bootloader.
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <asm/octeon/cvmx.h>
|
||||
#include <asm/octeon/cvmx-spinlock.h>
|
||||
|
@ -69,6 +70,7 @@ struct cvmx_sysinfo *cvmx_sysinfo_get(void)
|
|||
{
|
||||
return &(state.sysinfo);
|
||||
}
|
||||
EXPORT_SYMBOL(cvmx_sysinfo_get);
|
||||
|
||||
/**
|
||||
* This function is used in non-simple executive environments (such as
|
||||
|
|
288
arch/mips/cavium-octeon/msi.c
Normal file
288
arch/mips/cavium-octeon/msi.c
Normal file
|
@ -0,0 +1,288 @@
|
|||
/*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2005-2007 Cavium Networks
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/msi.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include <asm/octeon/octeon.h>
|
||||
#include <asm/octeon/cvmx-npi-defs.h>
|
||||
#include <asm/octeon/cvmx-pci-defs.h>
|
||||
#include <asm/octeon/cvmx-npei-defs.h>
|
||||
#include <asm/octeon/cvmx-pexp-defs.h>
|
||||
|
||||
#include "pci-common.h"
|
||||
|
||||
/*
|
||||
* Each bit in msi_free_irq_bitmask represents a MSI interrupt that is
|
||||
* in use.
|
||||
*/
|
||||
static uint64_t msi_free_irq_bitmask;
|
||||
|
||||
/*
|
||||
* Each bit in msi_multiple_irq_bitmask tells that the device using
|
||||
* this bit in msi_free_irq_bitmask is also using the next bit. This
|
||||
* is used so we can disable all of the MSI interrupts when a device
|
||||
* uses multiple.
|
||||
*/
|
||||
static uint64_t msi_multiple_irq_bitmask;
|
||||
|
||||
/*
|
||||
* This lock controls updates to msi_free_irq_bitmask and
|
||||
* msi_multiple_irq_bitmask.
|
||||
*/
|
||||
static DEFINE_SPINLOCK(msi_free_irq_bitmask_lock);
|
||||
|
||||
|
||||
/**
|
||||
* Called when a driver request MSI interrupts instead of the
|
||||
* legacy INT A-D. This routine will allocate multiple interrupts
|
||||
* for MSI devices that support them. A device can override this by
|
||||
* programming the MSI control bits [6:4] before calling
|
||||
* pci_enable_msi().
|
||||
*
|
||||
* @param dev Device requesting MSI interrupts
|
||||
* @param desc MSI descriptor
|
||||
*
|
||||
* Returns 0 on success.
|
||||
*/
|
||||
int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
|
||||
{
|
||||
struct msi_msg msg;
|
||||
uint16_t control;
|
||||
int configured_private_bits;
|
||||
int request_private_bits;
|
||||
int irq;
|
||||
int irq_step;
|
||||
uint64_t search_mask;
|
||||
|
||||
/*
|
||||
* Read the MSI config to figure out how many IRQs this device
|
||||
* wants. Most devices only want 1, which will give
|
||||
* configured_private_bits and request_private_bits equal 0.
|
||||
*/
|
||||
pci_read_config_word(dev, desc->msi_attrib.pos + PCI_MSI_FLAGS,
|
||||
&control);
|
||||
|
||||
/*
|
||||
* If the number of private bits has been configured then use
|
||||
* that value instead of the requested number. This gives the
|
||||
* driver the chance to override the number of interrupts
|
||||
* before calling pci_enable_msi().
|
||||
*/
|
||||
configured_private_bits = (control & PCI_MSI_FLAGS_QSIZE) >> 4;
|
||||
if (configured_private_bits == 0) {
|
||||
/* Nothing is configured, so use the hardware requested size */
|
||||
request_private_bits = (control & PCI_MSI_FLAGS_QMASK) >> 1;
|
||||
} else {
|
||||
/*
|
||||
* Use the number of configured bits, assuming the
|
||||
* driver wanted to override the hardware request
|
||||
* value.
|
||||
*/
|
||||
request_private_bits = configured_private_bits;
|
||||
}
|
||||
|
||||
/*
|
||||
* The PCI 2.3 spec mandates that there are at most 32
|
||||
* interrupts. If this device asks for more, only give it one.
|
||||
*/
|
||||
if (request_private_bits > 5)
|
||||
request_private_bits = 0;
|
||||
|
||||
try_only_one:
|
||||
/*
|
||||
* The IRQs have to be aligned on a power of two based on the
|
||||
* number being requested.
|
||||
*/
|
||||
irq_step = 1 << request_private_bits;
|
||||
|
||||
/* Mask with one bit for each IRQ */
|
||||
search_mask = (1 << irq_step) - 1;
|
||||
|
||||
/*
|
||||
* We're going to search msi_free_irq_bitmask_lock for zero
|
||||
* bits. This represents an MSI interrupt number that isn't in
|
||||
* use.
|
||||
*/
|
||||
spin_lock(&msi_free_irq_bitmask_lock);
|
||||
for (irq = 0; irq < 64; irq += irq_step) {
|
||||
if ((msi_free_irq_bitmask & (search_mask << irq)) == 0) {
|
||||
msi_free_irq_bitmask |= search_mask << irq;
|
||||
msi_multiple_irq_bitmask |= (search_mask >> 1) << irq;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock(&msi_free_irq_bitmask_lock);
|
||||
|
||||
/* Make sure the search for available interrupts didn't fail */
|
||||
if (irq >= 64) {
|
||||
if (request_private_bits) {
|
||||
pr_err("arch_setup_msi_irq: Unable to find %d free "
|
||||
"interrupts, trying just one",
|
||||
1 << request_private_bits);
|
||||
request_private_bits = 0;
|
||||
goto try_only_one;
|
||||
} else
|
||||
panic("arch_setup_msi_irq: Unable to find a free MSI "
|
||||
"interrupt");
|
||||
}
|
||||
|
||||
/* MSI interrupts start at logical IRQ OCTEON_IRQ_MSI_BIT0 */
|
||||
irq += OCTEON_IRQ_MSI_BIT0;
|
||||
|
||||
switch (octeon_dma_bar_type) {
|
||||
case OCTEON_DMA_BAR_TYPE_SMALL:
|
||||
/* When not using big bar, Bar 0 is based at 128MB */
|
||||
msg.address_lo =
|
||||
((128ul << 20) + CVMX_PCI_MSI_RCV) & 0xffffffff;
|
||||
msg.address_hi = ((128ul << 20) + CVMX_PCI_MSI_RCV) >> 32;
|
||||
case OCTEON_DMA_BAR_TYPE_BIG:
|
||||
/* When using big bar, Bar 0 is based at 0 */
|
||||
msg.address_lo = (0 + CVMX_PCI_MSI_RCV) & 0xffffffff;
|
||||
msg.address_hi = (0 + CVMX_PCI_MSI_RCV) >> 32;
|
||||
break;
|
||||
case OCTEON_DMA_BAR_TYPE_PCIE:
|
||||
/* When using PCIe, Bar 0 is based at 0 */
|
||||
/* FIXME CVMX_NPEI_MSI_RCV* other than 0? */
|
||||
msg.address_lo = (0 + CVMX_NPEI_PCIE_MSI_RCV) & 0xffffffff;
|
||||
msg.address_hi = (0 + CVMX_NPEI_PCIE_MSI_RCV) >> 32;
|
||||
break;
|
||||
default:
|
||||
panic("arch_setup_msi_irq: Invalid octeon_dma_bar_type\n");
|
||||
}
|
||||
msg.data = irq - OCTEON_IRQ_MSI_BIT0;
|
||||
|
||||
/* Update the number of IRQs the device has available to it */
|
||||
control &= ~PCI_MSI_FLAGS_QSIZE;
|
||||
control |= request_private_bits << 4;
|
||||
pci_write_config_word(dev, desc->msi_attrib.pos + PCI_MSI_FLAGS,
|
||||
control);
|
||||
|
||||
set_irq_msi(irq, desc);
|
||||
write_msi_msg(irq, &msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a device no longer needs its MSI interrupts. All
|
||||
* MSI interrupts for the device are freed.
|
||||
*
|
||||
* @irq: The devices first irq number. There may be multple in sequence.
|
||||
*/
|
||||
void arch_teardown_msi_irq(unsigned int irq)
|
||||
{
|
||||
int number_irqs;
|
||||
uint64_t bitmask;
|
||||
|
||||
if ((irq < OCTEON_IRQ_MSI_BIT0) || (irq > OCTEON_IRQ_MSI_BIT63))
|
||||
panic("arch_teardown_msi_irq: Attempted to teardown illegal "
|
||||
"MSI interrupt (%d)", irq);
|
||||
irq -= OCTEON_IRQ_MSI_BIT0;
|
||||
|
||||
/*
|
||||
* Count the number of IRQs we need to free by looking at the
|
||||
* msi_multiple_irq_bitmask. Each bit set means that the next
|
||||
* IRQ is also owned by this device.
|
||||
*/
|
||||
number_irqs = 0;
|
||||
while ((irq+number_irqs < 64) &&
|
||||
(msi_multiple_irq_bitmask & (1ull << (irq + number_irqs))))
|
||||
number_irqs++;
|
||||
number_irqs++;
|
||||
/* Mask with one bit for each IRQ */
|
||||
bitmask = (1 << number_irqs) - 1;
|
||||
/* Shift the mask to the correct bit location */
|
||||
bitmask <<= irq;
|
||||
if ((msi_free_irq_bitmask & bitmask) != bitmask)
|
||||
panic("arch_teardown_msi_irq: Attempted to teardown MSI "
|
||||
"interrupt (%d) not in use", irq);
|
||||
|
||||
/* Checks are done, update the in use bitmask */
|
||||
spin_lock(&msi_free_irq_bitmask_lock);
|
||||
msi_free_irq_bitmask &= ~bitmask;
|
||||
msi_multiple_irq_bitmask &= ~bitmask;
|
||||
spin_unlock(&msi_free_irq_bitmask_lock);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called by the interrupt handling code when an MSI interrupt
|
||||
* occurs.
|
||||
*
|
||||
* @param cpl
|
||||
* @param dev_id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static irqreturn_t octeon_msi_interrupt(int cpl, void *dev_id)
|
||||
{
|
||||
uint64_t msi_bits;
|
||||
int irq;
|
||||
|
||||
if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_PCIE)
|
||||
msi_bits = cvmx_read_csr(CVMX_PEXP_NPEI_MSI_RCV0);
|
||||
else
|
||||
msi_bits = cvmx_read_csr(CVMX_NPI_NPI_MSI_RCV);
|
||||
irq = fls64(msi_bits);
|
||||
if (irq) {
|
||||
irq += OCTEON_IRQ_MSI_BIT0 - 1;
|
||||
if (irq_desc[irq].action) {
|
||||
do_IRQ(irq);
|
||||
return IRQ_HANDLED;
|
||||
} else {
|
||||
pr_err("Spurious MSI interrupt %d\n", irq);
|
||||
if (octeon_has_feature(OCTEON_FEATURE_PCIE)) {
|
||||
/* These chips have PCIe */
|
||||
cvmx_write_csr(CVMX_PEXP_NPEI_MSI_RCV0,
|
||||
1ull << (irq -
|
||||
OCTEON_IRQ_MSI_BIT0));
|
||||
} else {
|
||||
/* These chips have PCI */
|
||||
cvmx_write_csr(CVMX_NPI_NPI_MSI_RCV,
|
||||
1ull << (irq -
|
||||
OCTEON_IRQ_MSI_BIT0));
|
||||
}
|
||||
}
|
||||
}
|
||||
return IRQ_NONE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the MSI interrupt handling code
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int octeon_msi_initialize(void)
|
||||
{
|
||||
int r;
|
||||
if (octeon_has_feature(OCTEON_FEATURE_PCIE)) {
|
||||
r = request_irq(OCTEON_IRQ_PCI_MSI0, octeon_msi_interrupt,
|
||||
IRQF_SHARED,
|
||||
"MSI[0:63]", octeon_msi_interrupt);
|
||||
} else if (octeon_is_pci_host()) {
|
||||
r = request_irq(OCTEON_IRQ_PCI_MSI0, octeon_msi_interrupt,
|
||||
IRQF_SHARED,
|
||||
"MSI[0:15]", octeon_msi_interrupt);
|
||||
r += request_irq(OCTEON_IRQ_PCI_MSI1, octeon_msi_interrupt,
|
||||
IRQF_SHARED,
|
||||
"MSI[16:31]", octeon_msi_interrupt);
|
||||
r += request_irq(OCTEON_IRQ_PCI_MSI2, octeon_msi_interrupt,
|
||||
IRQF_SHARED,
|
||||
"MSI[32:47]", octeon_msi_interrupt);
|
||||
r += request_irq(OCTEON_IRQ_PCI_MSI3, octeon_msi_interrupt,
|
||||
IRQF_SHARED,
|
||||
"MSI[48:63]", octeon_msi_interrupt);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
subsys_initcall(octeon_msi_initialize);
|
|
@ -10,6 +10,8 @@
|
|||
#include <linux/hardirq.h>
|
||||
|
||||
#include <asm/octeon/octeon.h>
|
||||
#include <asm/octeon/cvmx-pexp-defs.h>
|
||||
#include <asm/octeon/cvmx-npi-defs.h>
|
||||
|
||||
DEFINE_RWLOCK(octeon_irq_ciu0_rwlock);
|
||||
DEFINE_RWLOCK(octeon_irq_ciu1_rwlock);
|
||||
|
|
137
arch/mips/cavium-octeon/pci-common.c
Normal file
137
arch/mips/cavium-octeon/pci-common.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2005-2007 Cavium Networks
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/delay.h>
|
||||
#include "pci-common.h"
|
||||
|
||||
typeof(pcibios_map_irq) *octeon_pcibios_map_irq;
|
||||
enum octeon_dma_bar_type octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_INVALID;
|
||||
|
||||
/**
|
||||
* Map a PCI device to the appropriate interrupt line
|
||||
*
|
||||
* @param dev The Linux PCI device structure for the device to map
|
||||
* @param slot The slot number for this device on __BUS 0__. Linux
|
||||
* enumerates through all the bridges and figures out the
|
||||
* slot on Bus 0 where this device eventually hooks to.
|
||||
* @param pin The PCI interrupt pin read from the device, then swizzled
|
||||
* as it goes through each bridge.
|
||||
* @return Interrupt number for the device
|
||||
*/
|
||||
int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
||||
{
|
||||
if (octeon_pcibios_map_irq)
|
||||
return octeon_pcibios_map_irq(dev, slot, pin);
|
||||
else
|
||||
panic("octeon_pcibios_map_irq doesn't point to a "
|
||||
"pcibios_map_irq() function");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called to perform platform specific PCI setup
|
||||
*
|
||||
* @param dev
|
||||
* @return
|
||||
*/
|
||||
int pcibios_plat_dev_init(struct pci_dev *dev)
|
||||
{
|
||||
uint16_t config;
|
||||
uint32_t dconfig;
|
||||
int pos;
|
||||
/*
|
||||
* Force the Cache line setting to 64 bytes. The standard
|
||||
* Linux bus scan doesn't seem to set it. Octeon really has
|
||||
* 128 byte lines, but Intel bridges get really upset if you
|
||||
* try and set values above 64 bytes. Value is specified in
|
||||
* 32bit words.
|
||||
*/
|
||||
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 64 / 4);
|
||||
/* Set latency timers for all devices */
|
||||
pci_write_config_byte(dev, PCI_LATENCY_TIMER, 48);
|
||||
|
||||
/* Enable reporting System errors and parity errors on all devices */
|
||||
/* Enable parity checking and error reporting */
|
||||
pci_read_config_word(dev, PCI_COMMAND, &config);
|
||||
config |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
|
||||
pci_write_config_word(dev, PCI_COMMAND, config);
|
||||
|
||||
if (dev->subordinate) {
|
||||
/* Set latency timers on sub bridges */
|
||||
pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 48);
|
||||
/* More bridge error detection */
|
||||
pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &config);
|
||||
config |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
|
||||
pci_write_config_word(dev, PCI_BRIDGE_CONTROL, config);
|
||||
}
|
||||
|
||||
/* Enable the PCIe normal error reporting */
|
||||
pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
|
||||
if (pos) {
|
||||
/* Update Device Control */
|
||||
pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config);
|
||||
/* Correctable Error Reporting */
|
||||
config |= PCI_EXP_DEVCTL_CERE;
|
||||
/* Non-Fatal Error Reporting */
|
||||
config |= PCI_EXP_DEVCTL_NFERE;
|
||||
/* Fatal Error Reporting */
|
||||
config |= PCI_EXP_DEVCTL_FERE;
|
||||
/* Unsupported Request */
|
||||
config |= PCI_EXP_DEVCTL_URRE;
|
||||
pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config);
|
||||
}
|
||||
|
||||
/* Find the Advanced Error Reporting capability */
|
||||
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
|
||||
if (pos) {
|
||||
/* Clear Uncorrectable Error Status */
|
||||
pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
|
||||
&dconfig);
|
||||
pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
|
||||
dconfig);
|
||||
/* Enable reporting of all uncorrectable errors */
|
||||
/* Uncorrectable Error Mask - turned on bits disable errors */
|
||||
pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
|
||||
/*
|
||||
* Leave severity at HW default. This only controls if
|
||||
* errors are reported as uncorrectable or
|
||||
* correctable, not if the error is reported.
|
||||
*/
|
||||
/* PCI_ERR_UNCOR_SEVER - Uncorrectable Error Severity */
|
||||
/* Clear Correctable Error Status */
|
||||
pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &dconfig);
|
||||
pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, dconfig);
|
||||
/* Enable reporting of all correctable errors */
|
||||
/* Correctable Error Mask - turned on bits disable errors */
|
||||
pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, 0);
|
||||
/* Advanced Error Capabilities */
|
||||
pci_read_config_dword(dev, pos + PCI_ERR_CAP, &dconfig);
|
||||
/* ECRC Generation Enable */
|
||||
if (config & PCI_ERR_CAP_ECRC_GENC)
|
||||
config |= PCI_ERR_CAP_ECRC_GENE;
|
||||
/* ECRC Check Enable */
|
||||
if (config & PCI_ERR_CAP_ECRC_CHKC)
|
||||
config |= PCI_ERR_CAP_ECRC_CHKE;
|
||||
pci_write_config_dword(dev, pos + PCI_ERR_CAP, dconfig);
|
||||
/* PCI_ERR_HEADER_LOG - Header Log Register (16 bytes) */
|
||||
/* Report all errors to the root complex */
|
||||
pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND,
|
||||
PCI_ERR_ROOT_CMD_COR_EN |
|
||||
PCI_ERR_ROOT_CMD_NONFATAL_EN |
|
||||
PCI_ERR_ROOT_CMD_FATAL_EN);
|
||||
/* Clear the Root status register */
|
||||
pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &dconfig);
|
||||
pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
39
arch/mips/cavium-octeon/pci-common.h
Normal file
39
arch/mips/cavium-octeon/pci-common.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2005-2007 Cavium Networks
|
||||
*/
|
||||
#ifndef __OCTEON_PCI_COMMON_H__
|
||||
#define __OCTEON_PCI_COMMON_H__
|
||||
|
||||
#include <linux/pci.h>
|
||||
|
||||
/* Some PCI cards require delays when accessing config space. */
|
||||
#define PCI_CONFIG_SPACE_DELAY 10000
|
||||
|
||||
/* pcibios_map_irq() is defined inside pci-common.c. All it does is call the
|
||||
Octeon specific version pointed to by this variable. This function needs to
|
||||
change for PCI or PCIe based hosts */
|
||||
extern typeof(pcibios_map_irq) *octeon_pcibios_map_irq;
|
||||
|
||||
/* The following defines are only used when octeon_dma_bar_type =
|
||||
OCTEON_DMA_BAR_TYPE_BIG */
|
||||
#define OCTEON_PCI_BAR1_HOLE_BITS 5
|
||||
#define OCTEON_PCI_BAR1_HOLE_SIZE (1ul<<(OCTEON_PCI_BAR1_HOLE_BITS+3))
|
||||
|
||||
enum octeon_dma_bar_type {
|
||||
OCTEON_DMA_BAR_TYPE_INVALID,
|
||||
OCTEON_DMA_BAR_TYPE_SMALL,
|
||||
OCTEON_DMA_BAR_TYPE_BIG,
|
||||
OCTEON_DMA_BAR_TYPE_PCIE
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a variable to tell the DMA mapping system in dma-octeon.c
|
||||
* how to map PCI DMA addresses.
|
||||
*/
|
||||
extern enum octeon_dma_bar_type octeon_dma_bar_type;
|
||||
|
||||
#endif
|
568
arch/mips/cavium-octeon/pci.c
Normal file
568
arch/mips/cavium-octeon/pci.c
Normal file
|
@ -0,0 +1,568 @@
|
|||
/*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2005-2007 Cavium Networks
|
||||
*/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include <asm/time.h>
|
||||
|
||||
#include <asm/octeon/octeon.h>
|
||||
#include <asm/octeon/cvmx-npi-defs.h>
|
||||
#include <asm/octeon/cvmx-pci-defs.h>
|
||||
|
||||
#include "pci-common.h"
|
||||
|
||||
#define USE_OCTEON_INTERNAL_ARBITER
|
||||
|
||||
/*
|
||||
* Octeon's PCI controller uses did=3, subdid=2 for PCI IO
|
||||
* addresses. Use PCI endian swapping 1 so no address swapping is
|
||||
* necessary. The Linux io routines will endian swap the data.
|
||||
*/
|
||||
#define OCTEON_PCI_IOSPACE_BASE 0x80011a0400000000ull
|
||||
#define OCTEON_PCI_IOSPACE_SIZE (1ull<<32)
|
||||
|
||||
/* Octeon't PCI controller uses did=3, subdid=3 for PCI memory. */
|
||||
#define OCTEON_PCI_MEMSPACE_OFFSET (0x00011b0000000000ull)
|
||||
|
||||
/**
|
||||
* This is the bit decoding used for the Octeon PCI controller addresses
|
||||
*/
|
||||
union octeon_pci_address {
|
||||
uint64_t u64;
|
||||
struct {
|
||||
uint64_t upper:2;
|
||||
uint64_t reserved:13;
|
||||
uint64_t io:1;
|
||||
uint64_t did:5;
|
||||
uint64_t subdid:3;
|
||||
uint64_t reserved2:4;
|
||||
uint64_t endian_swap:2;
|
||||
uint64_t reserved3:10;
|
||||
uint64_t bus:8;
|
||||
uint64_t dev:5;
|
||||
uint64_t func:3;
|
||||
uint64_t reg:8;
|
||||
} s;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the mapping of PCI device number to IRQ line. Each
|
||||
* character in the return string represents the interrupt
|
||||
* line for the device at that position. Device 1 maps to the
|
||||
* first character, etc. The characters A-D are used for PCI
|
||||
* interrupts.
|
||||
*
|
||||
* Returns PCI interrupt mapping
|
||||
*/
|
||||
const char *octeon_get_pci_interrupts(void)
|
||||
{
|
||||
/*
|
||||
* Returning an empty string causes the interrupts to be
|
||||
* routed based on the PCI specification. From the PCI spec:
|
||||
*
|
||||
* INTA# of Device Number 0 is connected to IRQW on the system
|
||||
* board. (Device Number has no significance regarding being
|
||||
* located on the system board or in a connector.) INTA# of
|
||||
* Device Number 1 is connected to IRQX on the system
|
||||
* board. INTA# of Device Number 2 is connected to IRQY on the
|
||||
* system board. INTA# of Device Number 3 is connected to IRQZ
|
||||
* on the system board. The table below describes how each
|
||||
* agent's INTx# lines are connected to the system board
|
||||
* interrupt lines. The following equation can be used to
|
||||
* determine to which INTx# signal on the system board a given
|
||||
* device's INTx# line(s) is connected.
|
||||
*
|
||||
* MB = (D + I) MOD 4 MB = System board Interrupt (IRQW = 0,
|
||||
* IRQX = 1, IRQY = 2, and IRQZ = 3) D = Device Number I =
|
||||
* Interrupt Number (INTA# = 0, INTB# = 1, INTC# = 2, and
|
||||
* INTD# = 3)
|
||||
*/
|
||||
switch (octeon_bootinfo->board_type) {
|
||||
case CVMX_BOARD_TYPE_NAO38:
|
||||
/* This is really the NAC38 */
|
||||
return "AAAAADABAAAAAAAAAAAAAAAAAAAAAAAA";
|
||||
case CVMX_BOARD_TYPE_THUNDER:
|
||||
return "";
|
||||
case CVMX_BOARD_TYPE_EBH3000:
|
||||
return "";
|
||||
case CVMX_BOARD_TYPE_EBH3100:
|
||||
case CVMX_BOARD_TYPE_CN3010_EVB_HS5:
|
||||
case CVMX_BOARD_TYPE_CN3005_EVB_HS5:
|
||||
return "AAABAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
||||
case CVMX_BOARD_TYPE_BBGW_REF:
|
||||
return "AABCD";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map a PCI device to the appropriate interrupt line
|
||||
*
|
||||
* @dev: The Linux PCI device structure for the device to map
|
||||
* @slot: The slot number for this device on __BUS 0__. Linux
|
||||
* enumerates through all the bridges and figures out the
|
||||
* slot on Bus 0 where this device eventually hooks to.
|
||||
* @pin: The PCI interrupt pin read from the device, then swizzled
|
||||
* as it goes through each bridge.
|
||||
* Returns Interrupt number for the device
|
||||
*/
|
||||
int __init octeon_pci_pcibios_map_irq(const struct pci_dev *dev,
|
||||
u8 slot, u8 pin)
|
||||
{
|
||||
int irq_num;
|
||||
const char *interrupts;
|
||||
int dev_num;
|
||||
|
||||
/* Get the board specific interrupt mapping */
|
||||
interrupts = octeon_get_pci_interrupts();
|
||||
|
||||
dev_num = dev->devfn >> 3;
|
||||
if (dev_num < strlen(interrupts))
|
||||
irq_num = ((interrupts[dev_num] - 'A' + pin - 1) & 3) +
|
||||
OCTEON_IRQ_PCI_INT0;
|
||||
else
|
||||
irq_num = ((slot + pin - 3) & 3) + OCTEON_IRQ_PCI_INT0;
|
||||
return irq_num;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a value from configuration space
|
||||
*
|
||||
*/
|
||||
static int octeon_read_config(struct pci_bus *bus, unsigned int devfn,
|
||||
int reg, int size, u32 *val)
|
||||
{
|
||||
union octeon_pci_address pci_addr;
|
||||
|
||||
pci_addr.u64 = 0;
|
||||
pci_addr.s.upper = 2;
|
||||
pci_addr.s.io = 1;
|
||||
pci_addr.s.did = 3;
|
||||
pci_addr.s.subdid = 1;
|
||||
pci_addr.s.endian_swap = 1;
|
||||
pci_addr.s.bus = bus->number;
|
||||
pci_addr.s.dev = devfn >> 3;
|
||||
pci_addr.s.func = devfn & 0x7;
|
||||
pci_addr.s.reg = reg;
|
||||
|
||||
#if PCI_CONFIG_SPACE_DELAY
|
||||
udelay(PCI_CONFIG_SPACE_DELAY);
|
||||
#endif
|
||||
switch (size) {
|
||||
case 4:
|
||||
*val = le32_to_cpu(cvmx_read64_uint32(pci_addr.u64));
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
case 2:
|
||||
*val = le16_to_cpu(cvmx_read64_uint16(pci_addr.u64));
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
case 1:
|
||||
*val = cvmx_read64_uint8(pci_addr.u64);
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
}
|
||||
return PCIBIOS_FUNC_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write a value to PCI configuration space
|
||||
*
|
||||
* @bus:
|
||||
* @devfn:
|
||||
* @reg:
|
||||
* @size:
|
||||
* @val:
|
||||
* Returns
|
||||
*/
|
||||
static int octeon_write_config(struct pci_bus *bus, unsigned int devfn,
|
||||
int reg, int size, u32 val)
|
||||
{
|
||||
union octeon_pci_address pci_addr;
|
||||
|
||||
pci_addr.u64 = 0;
|
||||
pci_addr.s.upper = 2;
|
||||
pci_addr.s.io = 1;
|
||||
pci_addr.s.did = 3;
|
||||
pci_addr.s.subdid = 1;
|
||||
pci_addr.s.endian_swap = 1;
|
||||
pci_addr.s.bus = bus->number;
|
||||
pci_addr.s.dev = devfn >> 3;
|
||||
pci_addr.s.func = devfn & 0x7;
|
||||
pci_addr.s.reg = reg;
|
||||
|
||||
#if PCI_CONFIG_SPACE_DELAY
|
||||
udelay(PCI_CONFIG_SPACE_DELAY);
|
||||
#endif
|
||||
switch (size) {
|
||||
case 4:
|
||||
cvmx_write64_uint32(pci_addr.u64, cpu_to_le32(val));
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
case 2:
|
||||
cvmx_write64_uint16(pci_addr.u64, cpu_to_le16(val));
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
case 1:
|
||||
cvmx_write64_uint8(pci_addr.u64, val);
|
||||
return PCIBIOS_SUCCESSFUL;
|
||||
}
|
||||
return PCIBIOS_FUNC_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
static struct pci_ops octeon_pci_ops = {
|
||||
octeon_read_config,
|
||||
octeon_write_config,
|
||||
};
|
||||
|
||||
static struct resource octeon_pci_mem_resource = {
|
||||
.start = 0,
|
||||
.end = 0,
|
||||
.name = "Octeon PCI MEM",
|
||||
.flags = IORESOURCE_MEM,
|
||||
};
|
||||
|
||||
/*
|
||||
* PCI ports must be above 16KB so the ISA bus filtering in the PCI-X to PCI
|
||||
* bridge
|
||||
*/
|
||||
static struct resource octeon_pci_io_resource = {
|
||||
.start = 0x4000,
|
||||
.end = OCTEON_PCI_IOSPACE_SIZE - 1,
|
||||
.name = "Octeon PCI IO",
|
||||
.flags = IORESOURCE_IO,
|
||||
};
|
||||
|
||||
static struct pci_controller octeon_pci_controller = {
|
||||
.pci_ops = &octeon_pci_ops,
|
||||
.mem_resource = &octeon_pci_mem_resource,
|
||||
.mem_offset = OCTEON_PCI_MEMSPACE_OFFSET,
|
||||
.io_resource = &octeon_pci_io_resource,
|
||||
.io_offset = 0,
|
||||
.io_map_base = OCTEON_PCI_IOSPACE_BASE,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Low level initialize the Octeon PCI controller
|
||||
*
|
||||
* Returns
|
||||
*/
|
||||
static void octeon_pci_initialize(void)
|
||||
{
|
||||
union cvmx_pci_cfg01 cfg01;
|
||||
union cvmx_npi_ctl_status ctl_status;
|
||||
union cvmx_pci_ctl_status_2 ctl_status_2;
|
||||
union cvmx_pci_cfg19 cfg19;
|
||||
union cvmx_pci_cfg16 cfg16;
|
||||
union cvmx_pci_cfg22 cfg22;
|
||||
union cvmx_pci_cfg56 cfg56;
|
||||
|
||||
/* Reset the PCI Bus */
|
||||
cvmx_write_csr(CVMX_CIU_SOFT_PRST, 0x1);
|
||||
cvmx_read_csr(CVMX_CIU_SOFT_PRST);
|
||||
|
||||
udelay(2000); /* Hold PCI reset for 2 ms */
|
||||
|
||||
ctl_status.u64 = 0; /* cvmx_read_csr(CVMX_NPI_CTL_STATUS); */
|
||||
ctl_status.s.max_word = 1;
|
||||
ctl_status.s.timer = 1;
|
||||
cvmx_write_csr(CVMX_NPI_CTL_STATUS, ctl_status.u64);
|
||||
|
||||
/* Deassert PCI reset and advertize PCX Host Mode Device Capability
|
||||
(64b) */
|
||||
cvmx_write_csr(CVMX_CIU_SOFT_PRST, 0x4);
|
||||
cvmx_read_csr(CVMX_CIU_SOFT_PRST);
|
||||
|
||||
udelay(2000); /* Wait 2 ms after deasserting PCI reset */
|
||||
|
||||
ctl_status_2.u32 = 0;
|
||||
ctl_status_2.s.tsr_hwm = 1; /* Initializes to 0. Must be set
|
||||
before any PCI reads. */
|
||||
ctl_status_2.s.bar2pres = 1; /* Enable BAR2 */
|
||||
ctl_status_2.s.bar2_enb = 1;
|
||||
ctl_status_2.s.bar2_cax = 1; /* Don't use L2 */
|
||||
ctl_status_2.s.bar2_esx = 1;
|
||||
ctl_status_2.s.pmo_amod = 1; /* Round robin priority */
|
||||
if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG) {
|
||||
/* BAR1 hole */
|
||||
ctl_status_2.s.bb1_hole = OCTEON_PCI_BAR1_HOLE_BITS;
|
||||
ctl_status_2.s.bb1_siz = 1; /* BAR1 is 2GB */
|
||||
ctl_status_2.s.bb_ca = 1; /* Don't use L2 with big bars */
|
||||
ctl_status_2.s.bb_es = 1; /* Big bar in byte swap mode */
|
||||
ctl_status_2.s.bb1 = 1; /* BAR1 is big */
|
||||
ctl_status_2.s.bb0 = 1; /* BAR0 is big */
|
||||
}
|
||||
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CTL_STATUS_2, ctl_status_2.u32);
|
||||
udelay(2000); /* Wait 2 ms before doing PCI reads */
|
||||
|
||||
ctl_status_2.u32 = octeon_npi_read32(CVMX_NPI_PCI_CTL_STATUS_2);
|
||||
pr_notice("PCI Status: %s %s-bit\n",
|
||||
ctl_status_2.s.ap_pcix ? "PCI-X" : "PCI",
|
||||
ctl_status_2.s.ap_64ad ? "64" : "32");
|
||||
|
||||
if (OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN50XX)) {
|
||||
union cvmx_pci_cnt_reg cnt_reg_start;
|
||||
union cvmx_pci_cnt_reg cnt_reg_end;
|
||||
unsigned long cycles, pci_clock;
|
||||
|
||||
cnt_reg_start.u64 = cvmx_read_csr(CVMX_NPI_PCI_CNT_REG);
|
||||
cycles = read_c0_cvmcount();
|
||||
udelay(1000);
|
||||
cnt_reg_end.u64 = cvmx_read_csr(CVMX_NPI_PCI_CNT_REG);
|
||||
cycles = read_c0_cvmcount() - cycles;
|
||||
pci_clock = (cnt_reg_end.s.pcicnt - cnt_reg_start.s.pcicnt) /
|
||||
(cycles / (mips_hpt_frequency / 1000000));
|
||||
pr_notice("PCI Clock: %lu MHz\n", pci_clock);
|
||||
}
|
||||
|
||||
/*
|
||||
* TDOMC must be set to one in PCI mode. TDOMC should be set to 4
|
||||
* in PCI-X mode to allow four oustanding splits. Otherwise,
|
||||
* should not change from its reset value. Don't write PCI_CFG19
|
||||
* in PCI mode (0x82000001 reset value), write it to 0x82000004
|
||||
* after PCI-X mode is known. MRBCI,MDWE,MDRE -> must be zero.
|
||||
* MRBCM -> must be one.
|
||||
*/
|
||||
if (ctl_status_2.s.ap_pcix) {
|
||||
cfg19.u32 = 0;
|
||||
/*
|
||||
* Target Delayed/Split request outstanding maximum
|
||||
* count. [1..31] and 0=32. NOTE: If the user
|
||||
* programs these bits beyond the Designed Maximum
|
||||
* outstanding count, then the designed maximum table
|
||||
* depth will be used instead. No additional
|
||||
* Deferred/Split transactions will be accepted if
|
||||
* this outstanding maximum count is
|
||||
* reached. Furthermore, no additional deferred/split
|
||||
* transactions will be accepted if the I/O delay/ I/O
|
||||
* Split Request outstanding maximum is reached.
|
||||
*/
|
||||
cfg19.s.tdomc = 4;
|
||||
/*
|
||||
* Master Deferred Read Request Outstanding Max Count
|
||||
* (PCI only). CR4C[26:24] Max SAC cycles MAX DAC
|
||||
* cycles 000 8 4 001 1 0 010 2 1 011 3 1 100 4 2 101
|
||||
* 5 2 110 6 3 111 7 3 For example, if these bits are
|
||||
* programmed to 100, the core can support 2 DAC
|
||||
* cycles, 4 SAC cycles or a combination of 1 DAC and
|
||||
* 2 SAC cycles. NOTE: For the PCI-X maximum
|
||||
* outstanding split transactions, refer to
|
||||
* CRE0[22:20].
|
||||
*/
|
||||
cfg19.s.mdrrmc = 2;
|
||||
/*
|
||||
* Master Request (Memory Read) Byte Count/Byte Enable
|
||||
* select. 0 = Byte Enables valid. In PCI mode, a
|
||||
* burst transaction cannot be performed using Memory
|
||||
* Read command=4?h6. 1 = DWORD Byte Count valid
|
||||
* (default). In PCI Mode, the memory read byte
|
||||
* enables are automatically generated by the
|
||||
* core. Note: N3 Master Request transaction sizes are
|
||||
* always determined through the
|
||||
* am_attr[<35:32>|<7:0>] field.
|
||||
*/
|
||||
cfg19.s.mrbcm = 1;
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG19, cfg19.u32);
|
||||
}
|
||||
|
||||
|
||||
cfg01.u32 = 0;
|
||||
cfg01.s.msae = 1; /* Memory Space Access Enable */
|
||||
cfg01.s.me = 1; /* Master Enable */
|
||||
cfg01.s.pee = 1; /* PERR# Enable */
|
||||
cfg01.s.see = 1; /* System Error Enable */
|
||||
cfg01.s.fbbe = 1; /* Fast Back to Back Transaction Enable */
|
||||
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG01, cfg01.u32);
|
||||
|
||||
#ifdef USE_OCTEON_INTERNAL_ARBITER
|
||||
/*
|
||||
* When OCTEON is a PCI host, most systems will use OCTEON's
|
||||
* internal arbiter, so must enable it before any PCI/PCI-X
|
||||
* traffic can occur.
|
||||
*/
|
||||
{
|
||||
union cvmx_npi_pci_int_arb_cfg pci_int_arb_cfg;
|
||||
|
||||
pci_int_arb_cfg.u64 = 0;
|
||||
pci_int_arb_cfg.s.en = 1; /* Internal arbiter enable */
|
||||
cvmx_write_csr(CVMX_NPI_PCI_INT_ARB_CFG, pci_int_arb_cfg.u64);
|
||||
}
|
||||
#endif /* USE_OCTEON_INTERNAL_ARBITER */
|
||||
|
||||
/*
|
||||
* Preferrably written to 1 to set MLTD. [RDSATI,TRTAE,
|
||||
* TWTAE,TMAE,DPPMR -> must be zero. TILT -> must not be set to
|
||||
* 1..7.
|
||||
*/
|
||||
cfg16.u32 = 0;
|
||||
cfg16.s.mltd = 1; /* Master Latency Timer Disable */
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG16, cfg16.u32);
|
||||
|
||||
/*
|
||||
* Should be written to 0x4ff00. MTTV -> must be zero.
|
||||
* FLUSH -> must be 1. MRV -> should be 0xFF.
|
||||
*/
|
||||
cfg22.u32 = 0;
|
||||
/* Master Retry Value [1..255] and 0=infinite */
|
||||
cfg22.s.mrv = 0xff;
|
||||
/*
|
||||
* AM_DO_FLUSH_I control NOTE: This bit MUST BE ONE for proper
|
||||
* N3K operation.
|
||||
*/
|
||||
cfg22.s.flush = 1;
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG22, cfg22.u32);
|
||||
|
||||
/*
|
||||
* MOST Indicates the maximum number of outstanding splits (in -1
|
||||
* notation) when OCTEON is in PCI-X mode. PCI-X performance is
|
||||
* affected by the MOST selection. Should generally be written
|
||||
* with one of 0x3be807, 0x2be807, 0x1be807, or 0x0be807,
|
||||
* depending on the desired MOST of 3, 2, 1, or 0, respectively.
|
||||
*/
|
||||
cfg56.u32 = 0;
|
||||
cfg56.s.pxcid = 7; /* RO - PCI-X Capability ID */
|
||||
cfg56.s.ncp = 0xe8; /* RO - Next Capability Pointer */
|
||||
cfg56.s.dpere = 1; /* Data Parity Error Recovery Enable */
|
||||
cfg56.s.roe = 1; /* Relaxed Ordering Enable */
|
||||
cfg56.s.mmbc = 1; /* Maximum Memory Byte Count
|
||||
[0=512B,1=1024B,2=2048B,3=4096B] */
|
||||
cfg56.s.most = 3; /* Maximum outstanding Split transactions [0=1
|
||||
.. 7=32] */
|
||||
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG56, cfg56.u32);
|
||||
|
||||
/*
|
||||
* Affects PCI performance when OCTEON services reads to its
|
||||
* BAR1/BAR2. Refer to Section 10.6.1. The recommended values are
|
||||
* 0x22, 0x33, and 0x33 for PCI_READ_CMD_6, PCI_READ_CMD_C, and
|
||||
* PCI_READ_CMD_E, respectively. Unfortunately due to errata DDR-700,
|
||||
* these values need to be changed so they won't possibly prefetch off
|
||||
* of the end of memory if PCI is DMAing a buffer at the end of
|
||||
* memory. Note that these values differ from their reset values.
|
||||
*/
|
||||
octeon_npi_write32(CVMX_NPI_PCI_READ_CMD_6, 0x21);
|
||||
octeon_npi_write32(CVMX_NPI_PCI_READ_CMD_C, 0x31);
|
||||
octeon_npi_write32(CVMX_NPI_PCI_READ_CMD_E, 0x31);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the Octeon PCI controller
|
||||
*
|
||||
* Returns
|
||||
*/
|
||||
static int __init octeon_pci_setup(void)
|
||||
{
|
||||
union cvmx_npi_mem_access_subidx mem_access;
|
||||
int index;
|
||||
|
||||
/* Only these chips have PCI */
|
||||
if (octeon_has_feature(OCTEON_FEATURE_PCIE))
|
||||
return 0;
|
||||
|
||||
/* Point pcibios_map_irq() to the PCI version of it */
|
||||
octeon_pcibios_map_irq = octeon_pci_pcibios_map_irq;
|
||||
|
||||
/* Only use the big bars on chips that support it */
|
||||
if (OCTEON_IS_MODEL(OCTEON_CN31XX) ||
|
||||
OCTEON_IS_MODEL(OCTEON_CN38XX_PASS2) ||
|
||||
OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
|
||||
octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_SMALL;
|
||||
else
|
||||
octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_BIG;
|
||||
|
||||
/* PCI I/O and PCI MEM values */
|
||||
set_io_port_base(OCTEON_PCI_IOSPACE_BASE);
|
||||
ioport_resource.start = 0;
|
||||
ioport_resource.end = OCTEON_PCI_IOSPACE_SIZE - 1;
|
||||
if (!octeon_is_pci_host()) {
|
||||
pr_notice("Not in host mode, PCI Controller not initialized\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pr_notice("%s Octeon big bar support\n",
|
||||
(octeon_dma_bar_type ==
|
||||
OCTEON_DMA_BAR_TYPE_BIG) ? "Enabling" : "Disabling");
|
||||
|
||||
octeon_pci_initialize();
|
||||
|
||||
mem_access.u64 = 0;
|
||||
mem_access.s.esr = 1; /* Endian-Swap on read. */
|
||||
mem_access.s.esw = 1; /* Endian-Swap on write. */
|
||||
mem_access.s.nsr = 0; /* No-Snoop on read. */
|
||||
mem_access.s.nsw = 0; /* No-Snoop on write. */
|
||||
mem_access.s.ror = 0; /* Relax Read on read. */
|
||||
mem_access.s.row = 0; /* Relax Order on write. */
|
||||
mem_access.s.ba = 0; /* PCI Address bits [63:36]. */
|
||||
cvmx_write_csr(CVMX_NPI_MEM_ACCESS_SUBID3, mem_access.u64);
|
||||
|
||||
/*
|
||||
* Remap the Octeon BAR 2 above all 32 bit devices
|
||||
* (0x8000000000ul). This is done here so it is remapped
|
||||
* before the readl()'s below. We don't want BAR2 overlapping
|
||||
* with BAR0/BAR1 during these reads.
|
||||
*/
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG08, 0);
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG09, 0x80);
|
||||
|
||||
/* Disable the BAR1 movable mappings */
|
||||
for (index = 0; index < 32; index++)
|
||||
octeon_npi_write32(CVMX_NPI_PCI_BAR1_INDEXX(index), 0);
|
||||
|
||||
if (octeon_dma_bar_type == OCTEON_DMA_BAR_TYPE_BIG) {
|
||||
/* Remap the Octeon BAR 0 to 0-2GB */
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG04, 0);
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG05, 0);
|
||||
|
||||
/*
|
||||
* Remap the Octeon BAR 1 to map 2GB-4GB (minus the
|
||||
* BAR 1 hole).
|
||||
*/
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG06, 2ul << 30);
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG07, 0);
|
||||
|
||||
/* Devices go after BAR1 */
|
||||
octeon_pci_mem_resource.start =
|
||||
OCTEON_PCI_MEMSPACE_OFFSET + (4ul << 30) -
|
||||
(OCTEON_PCI_BAR1_HOLE_SIZE << 20);
|
||||
octeon_pci_mem_resource.end =
|
||||
octeon_pci_mem_resource.start + (1ul << 30);
|
||||
} else {
|
||||
/* Remap the Octeon BAR 0 to map 128MB-(128MB+4KB) */
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG04, 128ul << 20);
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG05, 0);
|
||||
|
||||
/* Remap the Octeon BAR 1 to map 0-128MB */
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG06, 0);
|
||||
octeon_npi_write32(CVMX_NPI_PCI_CFG07, 0);
|
||||
|
||||
/* Devices go after BAR0 */
|
||||
octeon_pci_mem_resource.start =
|
||||
OCTEON_PCI_MEMSPACE_OFFSET + (128ul << 20) +
|
||||
(4ul << 10);
|
||||
octeon_pci_mem_resource.end =
|
||||
octeon_pci_mem_resource.start + (1ul << 30);
|
||||
}
|
||||
|
||||
register_pci_controller(&octeon_pci_controller);
|
||||
|
||||
/*
|
||||
* Clear any errors that might be pending from before the bus
|
||||
* was setup properly.
|
||||
*/
|
||||
cvmx_write_csr(CVMX_NPI_PCI_INT_SUM2, -1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
arch_initcall(octeon_pci_setup);
|
1370
arch/mips/cavium-octeon/pcie.c
Normal file
1370
arch/mips/cavium-octeon/pcie.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -147,6 +147,10 @@
|
|||
#define cpu_has_mips_r (cpu_has_mips32r1 | cpu_has_mips32r2 | \
|
||||
cpu_has_mips64r1 | cpu_has_mips64r2)
|
||||
|
||||
#ifndef cpu_has_mips_r2_exec_hazard
|
||||
#define cpu_has_mips_r2_exec_hazard cpu_has_mips_r2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* MIPS32, MIPS64, VR5500, IDT32332, IDT32334 and maybe a few other
|
||||
* pre-MIPS32/MIPS53 processors have CLO, CLZ. For 64-bit kernels
|
||||
|
@ -230,4 +234,8 @@
|
|||
#define cpu_scache_line_size() cpu_data[0].scache.linesz
|
||||
#endif
|
||||
|
||||
#ifndef cpu_hwrena_impl_bits
|
||||
#define cpu_hwrena_impl_bits 0
|
||||
#endif
|
||||
|
||||
#endif /* __ASM_CPU_FEATURES_H */
|
||||
|
|
|
@ -15,7 +15,7 @@ extern void __delay(unsigned int loops);
|
|||
extern void __ndelay(unsigned int ns);
|
||||
extern void __udelay(unsigned int us);
|
||||
|
||||
#define ndelay(ns) __udelay(ns)
|
||||
#define ndelay(ns) __ndelay(ns)
|
||||
#define udelay(us) __udelay(us)
|
||||
|
||||
/* make sure "usecs *= ..." in udelay do not overflow. */
|
||||
|
|
114
arch/mips/include/asm/hugetlb.h
Normal file
114
arch/mips/include/asm/hugetlb.h
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2008, 2009 Cavium Networks, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_HUGETLB_H
|
||||
#define __ASM_HUGETLB_H
|
||||
|
||||
#include <asm/page.h>
|
||||
|
||||
|
||||
static inline int is_hugepage_only_range(struct mm_struct *mm,
|
||||
unsigned long addr,
|
||||
unsigned long len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int prepare_hugepage_range(struct file *file,
|
||||
unsigned long addr,
|
||||
unsigned long len)
|
||||
{
|
||||
unsigned long task_size = STACK_TOP;
|
||||
struct hstate *h = hstate_file(file);
|
||||
|
||||
if (len & ~huge_page_mask(h))
|
||||
return -EINVAL;
|
||||
if (addr & ~huge_page_mask(h))
|
||||
return -EINVAL;
|
||||
if (len > task_size)
|
||||
return -ENOMEM;
|
||||
if (task_size - len < addr)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void hugetlb_prefault_arch_hook(struct mm_struct *mm)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void hugetlb_free_pgd_range(struct mmu_gather *tlb,
|
||||
unsigned long addr,
|
||||
unsigned long end,
|
||||
unsigned long floor,
|
||||
unsigned long ceiling)
|
||||
{
|
||||
free_pgd_range(tlb, addr, end, floor, ceiling);
|
||||
}
|
||||
|
||||
static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
|
||||
pte_t *ptep, pte_t pte)
|
||||
{
|
||||
set_pte_at(mm, addr, ptep, pte);
|
||||
}
|
||||
|
||||
static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
|
||||
unsigned long addr, pte_t *ptep)
|
||||
{
|
||||
pte_t clear;
|
||||
pte_t pte = *ptep;
|
||||
|
||||
pte_val(clear) = (unsigned long)invalid_pte_table;
|
||||
set_pte_at(mm, addr, ptep, clear);
|
||||
return pte;
|
||||
}
|
||||
|
||||
static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
|
||||
unsigned long addr, pte_t *ptep)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int huge_pte_none(pte_t pte)
|
||||
{
|
||||
unsigned long val = pte_val(pte) & ~_PAGE_GLOBAL;
|
||||
return !val || (val == (unsigned long)invalid_pte_table);
|
||||
}
|
||||
|
||||
static inline pte_t huge_pte_wrprotect(pte_t pte)
|
||||
{
|
||||
return pte_wrprotect(pte);
|
||||
}
|
||||
|
||||
static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
|
||||
unsigned long addr, pte_t *ptep)
|
||||
{
|
||||
ptep_set_wrprotect(mm, addr, ptep);
|
||||
}
|
||||
|
||||
static inline int huge_ptep_set_access_flags(struct vm_area_struct *vma,
|
||||
unsigned long addr,
|
||||
pte_t *ptep, pte_t pte,
|
||||
int dirty)
|
||||
{
|
||||
return ptep_set_access_flags(vma, addr, ptep, pte, dirty);
|
||||
}
|
||||
|
||||
static inline pte_t huge_ptep_get(pte_t *ptep)
|
||||
{
|
||||
return *ptep;
|
||||
}
|
||||
|
||||
static inline int arch_prepare_hugepage(struct page *page)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void arch_release_hugepage(struct page *page)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* __ASM_HUGETLB_H */
|
|
@ -3,40 +3,16 @@
|
|||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 1995, 96, 99, 2001 Ralf Baechle
|
||||
* Copyright (C) 1995, 96, 99, 2001 Ralf Baechle <ralf@linux-mips.org>
|
||||
* Copyright (C) 2009 Wind River Systems
|
||||
* Written by Ralf Baechle <ralf@linux-mips.org>
|
||||
*/
|
||||
#ifndef _ASM_IOCTL_H
|
||||
#define _ASM_IOCTL_H
|
||||
#ifndef __ASM_IOCTL_H
|
||||
#define __ASM_IOCTL_H
|
||||
|
||||
/*
|
||||
* The original linux ioctl numbering scheme was just a general
|
||||
* "anything goes" setup, where more or less random numbers were
|
||||
* assigned. Sorry, I was clueless when I started out on this.
|
||||
*
|
||||
* On the alpha, we'll try to clean it up a bit, using a more sane
|
||||
* ioctl numbering, and also trying to be compatible with OSF/1 in
|
||||
* the process. I'd like to clean it up for the i386 as well, but
|
||||
* it's so painful recognizing both the new and the old numbers..
|
||||
*
|
||||
* The same applies for for the MIPS ABI; in fact even the macros
|
||||
* from Linux/Alpha fit almost perfectly.
|
||||
*/
|
||||
|
||||
#define _IOC_NRBITS 8
|
||||
#define _IOC_TYPEBITS 8
|
||||
#define _IOC_SIZEBITS 13
|
||||
#define _IOC_DIRBITS 3
|
||||
|
||||
#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
|
||||
#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
|
||||
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
|
||||
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
|
||||
|
||||
#define _IOC_NRSHIFT 0
|
||||
#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
|
||||
#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
|
||||
#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
|
||||
|
||||
/*
|
||||
* Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
|
||||
* And this turns out useful to catch old ioctl numbers in header
|
||||
|
@ -46,53 +22,6 @@
|
|||
#define _IOC_READ 2U
|
||||
#define _IOC_WRITE 4U
|
||||
|
||||
/*
|
||||
* The following are included for compatibility
|
||||
*/
|
||||
#define _IOC_VOID 0x20000000
|
||||
#define _IOC_OUT 0x40000000
|
||||
#define _IOC_IN 0x80000000
|
||||
#define _IOC_INOUT (IOC_IN|IOC_OUT)
|
||||
#include <asm-generic/ioctl.h>
|
||||
|
||||
#define _IOC(dir, type, nr, size) \
|
||||
(((dir) << _IOC_DIRSHIFT) | \
|
||||
((type) << _IOC_TYPESHIFT) | \
|
||||
((nr) << _IOC_NRSHIFT) | \
|
||||
((size) << _IOC_SIZESHIFT))
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/* provoke compile error for invalid uses of size argument */
|
||||
extern unsigned int __invalid_size_argument_for_IOC;
|
||||
#define _IOC_TYPECHECK(t) \
|
||||
((sizeof(t) == sizeof(t[1]) && \
|
||||
sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
|
||||
sizeof(t) : __invalid_size_argument_for_IOC)
|
||||
#else
|
||||
#define _IOC_TYPECHECK(t) (sizeof(t))
|
||||
#endif
|
||||
|
||||
/* used to create numbers */
|
||||
#define _IO(type, nr) _IOC(_IOC_NONE, (type), (nr), 0)
|
||||
#define _IOR(type, nr, size) _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size)))
|
||||
#define _IOW(type, nr, size) _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
|
||||
#define _IOWR(type, nr, size) _IOC(_IOC_READ|_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size)))
|
||||
#define _IOR_BAD(type, nr, size) _IOC(_IOC_READ, (type), (nr), sizeof(size))
|
||||
#define _IOW_BAD(type, nr, size) _IOC(_IOC_WRITE, (type), (nr), sizeof(size))
|
||||
#define _IOWR_BAD(type, nr, size) _IOC(_IOC_READ|_IOC_WRITE, (type), (nr), sizeof(size))
|
||||
|
||||
|
||||
/* used to decode them.. */
|
||||
#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
|
||||
#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
|
||||
#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
|
||||
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
|
||||
|
||||
/* ...and for the drivers/sound files... */
|
||||
|
||||
#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
|
||||
#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
|
||||
#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
|
||||
#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
|
||||
#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
|
||||
|
||||
#endif /* _ASM_IOCTL_H */
|
||||
#endif /* __ASM_IOCTL_H */
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* FILE NAME au1000_gpio.h
|
||||
*
|
||||
* BRIEF MODULE DESCRIPTION
|
||||
* API to Alchemy Au1xx0 GPIO device.
|
||||
*
|
||||
* Author: MontaVista Software, Inc. <source@mvista.com>
|
||||
* Steve Longerbeam
|
||||
*
|
||||
* Copyright 2001, 2008 MontaVista Software Inc.
|
||||
*
|
||||
* 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 PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* 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.,
|
||||
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __AU1000_GPIO_H
|
||||
#define __AU1000_GPIO_H
|
||||
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
#define AU1000GPIO_IOC_MAGIC 'A'
|
||||
|
||||
#define AU1000GPIO_IN _IOR(AU1000GPIO_IOC_MAGIC, 0, int)
|
||||
#define AU1000GPIO_SET _IOW(AU1000GPIO_IOC_MAGIC, 1, int)
|
||||
#define AU1000GPIO_CLEAR _IOW(AU1000GPIO_IOC_MAGIC, 2, int)
|
||||
#define AU1000GPIO_OUT _IOW(AU1000GPIO_IOC_MAGIC, 3, int)
|
||||
#define AU1000GPIO_TRISTATE _IOW(AU1000GPIO_IOC_MAGIC, 4, int)
|
||||
#define AU1000GPIO_AVAIL_MASK _IOR(AU1000GPIO_IOC_MAGIC, 5, int)
|
||||
|
||||
#ifdef __KERNEL__
|
||||
extern u32 get_au1000_avail_gpio_mask(void);
|
||||
extern int au1000gpio_tristate(u32 data);
|
||||
extern int au1000gpio_in(u32 *data);
|
||||
extern int au1000gpio_set(u32 data);
|
||||
extern int au1000gpio_clear(u32 data);
|
||||
extern int au1000gpio_out(u32 data);
|
||||
#endif
|
||||
|
||||
#endif
|
604
arch/mips/include/asm/mach-au1x00/gpio-au1000.h
Normal file
604
arch/mips/include/asm/mach-au1x00/gpio-au1000.h
Normal file
|
@ -0,0 +1,604 @@
|
|||
/*
|
||||
* GPIO functions for Au1000, Au1500, Au1100, Au1550, Au1200
|
||||
*
|
||||
* Copyright (c) 2009 Manuel Lauss.
|
||||
*
|
||||
* Licensed under the terms outlined in the file COPYING.
|
||||
*/
|
||||
|
||||
#ifndef _ALCHEMY_GPIO_AU1000_H_
|
||||
#define _ALCHEMY_GPIO_AU1000_H_
|
||||
|
||||
#include <asm/mach-au1x00/au1000.h>
|
||||
|
||||
/* The default GPIO numberspace as documented in the Alchemy manuals.
|
||||
* GPIO0-31 from GPIO1 block, GPIO200-215 from GPIO2 block.
|
||||
*/
|
||||
#define ALCHEMY_GPIO1_BASE 0
|
||||
#define ALCHEMY_GPIO2_BASE 200
|
||||
|
||||
#define ALCHEMY_GPIO1_NUM 32
|
||||
#define ALCHEMY_GPIO2_NUM 16
|
||||
#define ALCHEMY_GPIO1_MAX (ALCHEMY_GPIO1_BASE + ALCHEMY_GPIO1_NUM - 1)
|
||||
#define ALCHEMY_GPIO2_MAX (ALCHEMY_GPIO2_BASE + ALCHEMY_GPIO2_NUM - 1)
|
||||
|
||||
#define MAKE_IRQ(intc, off) (AU1000_INTC##intc##_INT_BASE + (off))
|
||||
|
||||
|
||||
static inline int au1000_gpio1_to_irq(int gpio)
|
||||
{
|
||||
return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE);
|
||||
}
|
||||
|
||||
static inline int au1000_gpio2_to_irq(int gpio)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_AU1000
|
||||
static inline int au1000_irq_to_gpio(int irq)
|
||||
{
|
||||
if ((irq >= AU1000_GPIO_0) && (irq <= AU1000_GPIO_31))
|
||||
return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0;
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int au1500_gpio1_to_irq(int gpio)
|
||||
{
|
||||
gpio -= ALCHEMY_GPIO1_BASE;
|
||||
|
||||
switch (gpio) {
|
||||
case 0 ... 15:
|
||||
case 20:
|
||||
case 23 ... 28: return MAKE_IRQ(1, gpio);
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline int au1500_gpio2_to_irq(int gpio)
|
||||
{
|
||||
gpio -= ALCHEMY_GPIO2_BASE;
|
||||
|
||||
switch (gpio) {
|
||||
case 0 ... 3: return MAKE_IRQ(1, 16 + gpio - 0);
|
||||
case 4 ... 5: return MAKE_IRQ(1, 21 + gpio - 4);
|
||||
case 6 ... 7: return MAKE_IRQ(1, 29 + gpio - 6);
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_AU1500
|
||||
static inline int au1500_irq_to_gpio(int irq)
|
||||
{
|
||||
switch (irq) {
|
||||
case AU1000_GPIO_0 ... AU1000_GPIO_15:
|
||||
case AU1500_GPIO_20:
|
||||
case AU1500_GPIO_23 ... AU1500_GPIO_28:
|
||||
return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0;
|
||||
case AU1500_GPIO_200 ... AU1500_GPIO_203:
|
||||
return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_200) + 0;
|
||||
case AU1500_GPIO_204 ... AU1500_GPIO_205:
|
||||
return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_204) + 4;
|
||||
case AU1500_GPIO_206 ... AU1500_GPIO_207:
|
||||
return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_206) + 6;
|
||||
case AU1500_GPIO_208_215:
|
||||
return ALCHEMY_GPIO2_BASE + 8;
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int au1100_gpio1_to_irq(int gpio)
|
||||
{
|
||||
return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE);
|
||||
}
|
||||
|
||||
static inline int au1100_gpio2_to_irq(int gpio)
|
||||
{
|
||||
gpio -= ALCHEMY_GPIO2_BASE;
|
||||
|
||||
if ((gpio >= 8) && (gpio <= 15))
|
||||
return MAKE_IRQ(0, 29); /* shared GPIO208_215 */
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_AU1100
|
||||
static inline int au1100_irq_to_gpio(int irq)
|
||||
{
|
||||
switch (irq) {
|
||||
case AU1000_GPIO_0 ... AU1000_GPIO_31:
|
||||
return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0;
|
||||
case AU1100_GPIO_208_215:
|
||||
return ALCHEMY_GPIO2_BASE + 8;
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int au1550_gpio1_to_irq(int gpio)
|
||||
{
|
||||
gpio -= ALCHEMY_GPIO1_BASE;
|
||||
|
||||
switch (gpio) {
|
||||
case 0 ... 15:
|
||||
case 20 ... 28: return MAKE_IRQ(1, gpio);
|
||||
case 16 ... 17: return MAKE_IRQ(1, 18 + gpio - 16);
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
static inline int au1550_gpio2_to_irq(int gpio)
|
||||
{
|
||||
gpio -= ALCHEMY_GPIO2_BASE;
|
||||
|
||||
switch (gpio) {
|
||||
case 0: return MAKE_IRQ(1, 16);
|
||||
case 1 ... 5: return MAKE_IRQ(1, 17); /* shared GPIO201_205 */
|
||||
case 6 ... 7: return MAKE_IRQ(1, 29 + gpio - 6);
|
||||
case 8 ... 15: return MAKE_IRQ(1, 31); /* shared GPIO208_215 */
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_AU1550
|
||||
static inline int au1550_irq_to_gpio(int irq)
|
||||
{
|
||||
switch (irq) {
|
||||
case AU1000_GPIO_0 ... AU1000_GPIO_15:
|
||||
return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0;
|
||||
case AU1550_GPIO_200:
|
||||
case AU1500_GPIO_201_205:
|
||||
return ALCHEMY_GPIO2_BASE + (irq - AU1550_GPIO_200) + 0;
|
||||
case AU1500_GPIO_16 ... AU1500_GPIO_28:
|
||||
return ALCHEMY_GPIO1_BASE + (irq - AU1500_GPIO_16) + 16;
|
||||
case AU1500_GPIO_206 ... AU1500_GPIO_208_218:
|
||||
return ALCHEMY_GPIO2_BASE + (irq - AU1500_GPIO_206) + 6;
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int au1200_gpio1_to_irq(int gpio)
|
||||
{
|
||||
return MAKE_IRQ(1, gpio - ALCHEMY_GPIO1_BASE);
|
||||
}
|
||||
|
||||
static inline int au1200_gpio2_to_irq(int gpio)
|
||||
{
|
||||
gpio -= ALCHEMY_GPIO2_BASE;
|
||||
|
||||
switch (gpio) {
|
||||
case 0 ... 2: return MAKE_IRQ(0, 5 + gpio - 0);
|
||||
case 3: return MAKE_IRQ(0, 22);
|
||||
case 4 ... 7: return MAKE_IRQ(0, 24 + gpio - 4);
|
||||
case 8 ... 15: return MAKE_IRQ(0, 28); /* shared GPIO208_215 */
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SOC_AU1200
|
||||
static inline int au1200_irq_to_gpio(int irq)
|
||||
{
|
||||
switch (irq) {
|
||||
case AU1000_GPIO_0 ... AU1000_GPIO_31:
|
||||
return ALCHEMY_GPIO1_BASE + (irq - AU1000_GPIO_0) + 0;
|
||||
case AU1200_GPIO_200 ... AU1200_GPIO_202:
|
||||
return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO_200) + 0;
|
||||
case AU1200_GPIO_203:
|
||||
return ALCHEMY_GPIO2_BASE + 3;
|
||||
case AU1200_GPIO_204 ... AU1200_GPIO_208_215:
|
||||
return ALCHEMY_GPIO2_BASE + (irq - AU1200_GPIO_204) + 4;
|
||||
}
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* GPIO1 block macros for common linux gpio functions.
|
||||
*/
|
||||
static inline void alchemy_gpio1_set_value(int gpio, int v)
|
||||
{
|
||||
unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
|
||||
unsigned long r = v ? SYS_OUTPUTSET : SYS_OUTPUTCLR;
|
||||
au_writel(mask, r);
|
||||
au_sync();
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio1_get_value(int gpio)
|
||||
{
|
||||
unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
|
||||
return au_readl(SYS_PINSTATERD) & mask;
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio1_direction_input(int gpio)
|
||||
{
|
||||
unsigned long mask = 1 << (gpio - ALCHEMY_GPIO1_BASE);
|
||||
au_writel(mask, SYS_TRIOUTCLR);
|
||||
au_sync();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio1_direction_output(int gpio, int v)
|
||||
{
|
||||
/* hardware switches to "output" mode when one of the two
|
||||
* "set_value" registers is accessed.
|
||||
*/
|
||||
alchemy_gpio1_set_value(gpio, v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio1_is_valid(int gpio)
|
||||
{
|
||||
return ((gpio >= ALCHEMY_GPIO1_BASE) && (gpio <= ALCHEMY_GPIO1_MAX));
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio1_to_irq(int gpio)
|
||||
{
|
||||
#if defined(CONFIG_SOC_AU1000)
|
||||
return au1000_gpio1_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1100)
|
||||
return au1100_gpio1_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1500)
|
||||
return au1500_gpio1_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1550)
|
||||
return au1550_gpio1_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1200)
|
||||
return au1200_gpio1_to_irq(gpio);
|
||||
#else
|
||||
return -ENXIO;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* GPIO2 block macros for common linux GPIO functions. The 'gpio'
|
||||
* parameter must be in range of ALCHEMY_GPIO2_BASE..ALCHEMY_GPIO2_MAX.
|
||||
*/
|
||||
static inline void __alchemy_gpio2_mod_dir(int gpio, int to_out)
|
||||
{
|
||||
unsigned long mask = 1 << (gpio - ALCHEMY_GPIO2_BASE);
|
||||
unsigned long d = au_readl(GPIO2_DIR);
|
||||
if (to_out)
|
||||
d |= mask;
|
||||
else
|
||||
d &= ~mask;
|
||||
au_writel(d, GPIO2_DIR);
|
||||
au_sync();
|
||||
}
|
||||
|
||||
static inline void alchemy_gpio2_set_value(int gpio, int v)
|
||||
{
|
||||
unsigned long mask;
|
||||
mask = ((v) ? 0x00010001 : 0x00010000) << (gpio - ALCHEMY_GPIO2_BASE);
|
||||
au_writel(mask, GPIO2_OUTPUT);
|
||||
au_sync();
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio2_get_value(int gpio)
|
||||
{
|
||||
return au_readl(GPIO2_PINSTATE) & (1 << (gpio - ALCHEMY_GPIO2_BASE));
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio2_direction_input(int gpio)
|
||||
{
|
||||
unsigned long flags;
|
||||
local_irq_save(flags);
|
||||
__alchemy_gpio2_mod_dir(gpio, 0);
|
||||
local_irq_restore(flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio2_direction_output(int gpio, int v)
|
||||
{
|
||||
unsigned long flags;
|
||||
alchemy_gpio2_set_value(gpio, v);
|
||||
local_irq_save(flags);
|
||||
__alchemy_gpio2_mod_dir(gpio, 1);
|
||||
local_irq_restore(flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio2_is_valid(int gpio)
|
||||
{
|
||||
return ((gpio >= ALCHEMY_GPIO2_BASE) && (gpio <= ALCHEMY_GPIO2_MAX));
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio2_to_irq(int gpio)
|
||||
{
|
||||
#if defined(CONFIG_SOC_AU1000)
|
||||
return au1000_gpio2_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1100)
|
||||
return au1100_gpio2_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1500)
|
||||
return au1500_gpio2_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1550)
|
||||
return au1550_gpio2_to_irq(gpio);
|
||||
#elif defined(CONFIG_SOC_AU1200)
|
||||
return au1200_gpio2_to_irq(gpio);
|
||||
#else
|
||||
return -ENXIO;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* On Au1000, Au1500 and Au1100 GPIOs won't work as inputs before
|
||||
* SYS_PININPUTEN is written to at least once. On Au1550/Au1200 this
|
||||
* register enables use of GPIOs as wake source.
|
||||
*/
|
||||
static inline void alchemy_gpio1_input_enable(void)
|
||||
{
|
||||
au_writel(0, SYS_PININPUTEN); /* the write op is key */
|
||||
au_sync();
|
||||
}
|
||||
|
||||
/* GPIO2 shared interrupts and control */
|
||||
|
||||
static inline void __alchemy_gpio2_mod_int(int gpio2, int en)
|
||||
{
|
||||
unsigned long r = au_readl(GPIO2_INTENABLE);
|
||||
if (en)
|
||||
r |= 1 << gpio2;
|
||||
else
|
||||
r &= ~(1 << gpio2);
|
||||
au_writel(r, GPIO2_INTENABLE);
|
||||
au_sync();
|
||||
}
|
||||
|
||||
/**
|
||||
* alchemy_gpio2_enable_int - Enable a GPIO2 pins' shared irq contribution.
|
||||
* @gpio2: The GPIO2 pin to activate (200...215).
|
||||
*
|
||||
* GPIO208-215 have one shared interrupt line to the INTC. They are
|
||||
* and'ed with a per-pin enable bit and finally or'ed together to form
|
||||
* a single irq request (useful for active-high sources).
|
||||
* With this function, a pins' individual contribution to the int request
|
||||
* can be enabled. As with all other GPIO-based interrupts, the INTC
|
||||
* must be programmed to accept the GPIO208_215 interrupt as well.
|
||||
*
|
||||
* NOTE: Calling this macro is only necessary for GPIO208-215; all other
|
||||
* GPIO2-based interrupts have their own request to the INTC. Please
|
||||
* consult your Alchemy databook for more information!
|
||||
*
|
||||
* NOTE: On the Au1550, GPIOs 201-205 also have a shared interrupt request
|
||||
* line to the INTC, GPIO201_205. This function can be used for those
|
||||
* as well.
|
||||
*
|
||||
* NOTE: 'gpio2' parameter must be in range of the GPIO2 numberspace
|
||||
* (200-215 by default). No sanity checks are made,
|
||||
*/
|
||||
static inline void alchemy_gpio2_enable_int(int gpio2)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
gpio2 -= ALCHEMY_GPIO2_BASE;
|
||||
|
||||
#if defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500)
|
||||
/* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
|
||||
gpio2 -= 8;
|
||||
#endif
|
||||
local_irq_save(flags);
|
||||
__alchemy_gpio2_mod_int(gpio2, 1);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* alchemy_gpio2_disable_int - Disable a GPIO2 pins' shared irq contribution.
|
||||
* @gpio2: The GPIO2 pin to activate (200...215).
|
||||
*
|
||||
* see function alchemy_gpio2_enable_int() for more information.
|
||||
*/
|
||||
static inline void alchemy_gpio2_disable_int(int gpio2)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
gpio2 -= ALCHEMY_GPIO2_BASE;
|
||||
|
||||
#if defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500)
|
||||
/* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
|
||||
gpio2 -= 8;
|
||||
#endif
|
||||
local_irq_save(flags);
|
||||
__alchemy_gpio2_mod_int(gpio2, 0);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* alchemy_gpio2_enable - Activate GPIO2 block.
|
||||
*
|
||||
* The GPIO2 block must be enabled excplicitly to work. On systems
|
||||
* where this isn't done by the bootloader, this macro can be used.
|
||||
*/
|
||||
static inline void alchemy_gpio2_enable(void)
|
||||
{
|
||||
au_writel(3, GPIO2_ENABLE); /* reset, clock enabled */
|
||||
au_sync();
|
||||
au_writel(1, GPIO2_ENABLE); /* clock enabled */
|
||||
au_sync();
|
||||
}
|
||||
|
||||
/**
|
||||
* alchemy_gpio2_disable - disable GPIO2 block.
|
||||
*
|
||||
* Disable and put GPIO2 block in low-power mode.
|
||||
*/
|
||||
static inline void alchemy_gpio2_disable(void)
|
||||
{
|
||||
au_writel(2, GPIO2_ENABLE); /* reset, clock disabled */
|
||||
au_sync();
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* wrappers for on-chip gpios; can be used before gpio chips have been
|
||||
* registered with gpiolib.
|
||||
*/
|
||||
static inline int alchemy_gpio_direction_input(int gpio)
|
||||
{
|
||||
return (gpio >= ALCHEMY_GPIO2_BASE) ?
|
||||
alchemy_gpio2_direction_input(gpio) :
|
||||
alchemy_gpio1_direction_input(gpio);
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio_direction_output(int gpio, int v)
|
||||
{
|
||||
return (gpio >= ALCHEMY_GPIO2_BASE) ?
|
||||
alchemy_gpio2_direction_output(gpio, v) :
|
||||
alchemy_gpio1_direction_output(gpio, v);
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio_get_value(int gpio)
|
||||
{
|
||||
return (gpio >= ALCHEMY_GPIO2_BASE) ?
|
||||
alchemy_gpio2_get_value(gpio) :
|
||||
alchemy_gpio1_get_value(gpio);
|
||||
}
|
||||
|
||||
static inline void alchemy_gpio_set_value(int gpio, int v)
|
||||
{
|
||||
if (gpio >= ALCHEMY_GPIO2_BASE)
|
||||
alchemy_gpio2_set_value(gpio, v);
|
||||
else
|
||||
alchemy_gpio1_set_value(gpio, v);
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio_is_valid(int gpio)
|
||||
{
|
||||
return (gpio >= ALCHEMY_GPIO2_BASE) ?
|
||||
alchemy_gpio2_is_valid(gpio) :
|
||||
alchemy_gpio1_is_valid(gpio);
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio_cansleep(int gpio)
|
||||
{
|
||||
return 0; /* Alchemy never gets tired */
|
||||
}
|
||||
|
||||
static inline int alchemy_gpio_to_irq(int gpio)
|
||||
{
|
||||
return (gpio >= ALCHEMY_GPIO2_BASE) ?
|
||||
alchemy_gpio2_to_irq(gpio) :
|
||||
alchemy_gpio1_to_irq(gpio);
|
||||
}
|
||||
|
||||
static inline int alchemy_irq_to_gpio(int irq)
|
||||
{
|
||||
#if defined(CONFIG_SOC_AU1000)
|
||||
return au1000_irq_to_gpio(irq);
|
||||
#elif defined(CONFIG_SOC_AU1100)
|
||||
return au1100_irq_to_gpio(irq);
|
||||
#elif defined(CONFIG_SOC_AU1500)
|
||||
return au1500_irq_to_gpio(irq);
|
||||
#elif defined(CONFIG_SOC_AU1550)
|
||||
return au1550_irq_to_gpio(irq);
|
||||
#elif defined(CONFIG_SOC_AU1200)
|
||||
return au1200_irq_to_gpio(irq);
|
||||
#else
|
||||
return -ENXIO;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* Linux gpio framework integration.
|
||||
*
|
||||
* 4 use cases of Au1000-Au1200 GPIOS:
|
||||
*(1) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=y:
|
||||
* Board must register gpiochips.
|
||||
*(2) GPIOLIB=y, ALCHEMY_GPIO_INDIRECT=n:
|
||||
* 2 (1 for Au1000) gpio_chips are registered.
|
||||
*
|
||||
*(3) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=y:
|
||||
* the boards' gpio.h must provide the linux gpio wrapper functions,
|
||||
*
|
||||
*(4) GPIOLIB=n, ALCHEMY_GPIO_INDIRECT=n:
|
||||
* inlinable gpio functions are provided which enable access to the
|
||||
* Au1000 gpios only by using the numbers straight out of the data-
|
||||
* sheets.
|
||||
|
||||
* Cases 1 and 3 are intended for boards which want to provide their own
|
||||
* GPIO namespace and -operations (i.e. for example you have 8 GPIOs
|
||||
* which are in part provided by spare Au1000 GPIO pins and in part by
|
||||
* an external FPGA but you still want them to be accssible in linux
|
||||
* as gpio0-7. The board can of course use the alchemy_gpioX_* functions
|
||||
* as required).
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_GPIOLIB
|
||||
|
||||
|
||||
#ifndef CONFIG_ALCHEMY_GPIO_INDIRECT /* case (4) */
|
||||
|
||||
static inline int gpio_direction_input(int gpio)
|
||||
{
|
||||
return alchemy_gpio_direction_input(gpio);
|
||||
}
|
||||
|
||||
static inline int gpio_direction_output(int gpio, int v)
|
||||
{
|
||||
return alchemy_gpio_direction_output(gpio, v);
|
||||
}
|
||||
|
||||
static inline int gpio_get_value(int gpio)
|
||||
{
|
||||
return alchemy_gpio_get_value(gpio);
|
||||
}
|
||||
|
||||
static inline void gpio_set_value(int gpio, int v)
|
||||
{
|
||||
alchemy_gpio_set_value(gpio, v);
|
||||
}
|
||||
|
||||
static inline int gpio_is_valid(int gpio)
|
||||
{
|
||||
return alchemy_gpio_is_valid(gpio);
|
||||
}
|
||||
|
||||
static inline int gpio_cansleep(int gpio)
|
||||
{
|
||||
return alchemy_gpio_cansleep(gpio);
|
||||
}
|
||||
|
||||
static inline int gpio_to_irq(int gpio)
|
||||
{
|
||||
return alchemy_gpio_to_irq(gpio);
|
||||
}
|
||||
|
||||
static inline int irq_to_gpio(int irq)
|
||||
{
|
||||
return alchemy_irq_to_gpio(irq);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */
|
||||
|
||||
|
||||
#else /* CONFIG GPIOLIB */
|
||||
|
||||
|
||||
/* using gpiolib to provide up to 2 gpio_chips for on-chip gpios */
|
||||
#ifndef CONFIG_ALCHEMY_GPIO_INDIRECT /* case (2) */
|
||||
|
||||
/* get everything through gpiolib */
|
||||
#define gpio_to_irq __gpio_to_irq
|
||||
#define gpio_get_value __gpio_get_value
|
||||
#define gpio_set_value __gpio_set_value
|
||||
#define gpio_cansleep __gpio_cansleep
|
||||
#define irq_to_gpio alchemy_irq_to_gpio
|
||||
|
||||
#include <asm-generic/gpio.h>
|
||||
|
||||
#endif /* !CONFIG_ALCHEMY_GPIO_INDIRECT */
|
||||
|
||||
|
||||
#endif /* !CONFIG_GPIOLIB */
|
||||
|
||||
#endif /* _ALCHEMY_GPIO_AU1000_H_ */
|
|
@ -1,33 +1,10 @@
|
|||
#ifndef _AU1XXX_GPIO_H_
|
||||
#define _AU1XXX_GPIO_H_
|
||||
#ifndef _ALCHEMY_GPIO_H_
|
||||
#define _ALCHEMY_GPIO_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
#if defined(CONFIG_ALCHEMY_GPIO_AU1000)
|
||||
|
||||
#define AU1XXX_GPIO_BASE 200
|
||||
#include <asm/mach-au1x00/gpio-au1000.h>
|
||||
|
||||
/* GPIO bank 1 offsets */
|
||||
#define AU1000_GPIO1_TRI_OUT 0x0100
|
||||
#define AU1000_GPIO1_OUT 0x0108
|
||||
#define AU1000_GPIO1_ST 0x0110
|
||||
#define AU1000_GPIO1_CLR 0x010C
|
||||
#endif
|
||||
|
||||
/* GPIO bank 2 offsets */
|
||||
#define AU1000_GPIO2_DIR 0x00
|
||||
#define AU1000_GPIO2_RSVD 0x04
|
||||
#define AU1000_GPIO2_OUT 0x08
|
||||
#define AU1000_GPIO2_ST 0x0C
|
||||
#define AU1000_GPIO2_INT 0x10
|
||||
#define AU1000_GPIO2_EN 0x14
|
||||
|
||||
#define GPIO2_OUT_EN_MASK 0x00010000
|
||||
|
||||
#define gpio_to_irq(gpio) NULL
|
||||
|
||||
#define gpio_get_value __gpio_get_value
|
||||
#define gpio_set_value __gpio_set_value
|
||||
|
||||
#define gpio_cansleep __gpio_cansleep
|
||||
|
||||
#include <asm-generic/gpio.h>
|
||||
|
||||
#endif /* _AU1XXX_GPIO_H_ */
|
||||
#endif /* _ALCHEMY_GPIO_H_ */
|
||||
|
|
|
@ -37,6 +37,9 @@ static inline int gpio_direction_input(unsigned gpio)
|
|||
|
||||
static inline int gpio_direction_output(unsigned gpio, int value)
|
||||
{
|
||||
/* first set the gpio out value */
|
||||
ssb_gpio_out(&ssb_bcm47xx, 1 << gpio, value ? 1 << gpio : 0);
|
||||
/* then set the gpio mode */
|
||||
ssb_gpio_outen(&ssb_bcm47xx, 1 << gpio, 1 << gpio);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -47,11 +47,13 @@
|
|||
#define cpu_has_mips32r2 0
|
||||
#define cpu_has_mips64r1 0
|
||||
#define cpu_has_mips64r2 1
|
||||
#define cpu_has_mips_r2_exec_hazard 0
|
||||
#define cpu_has_dsp 0
|
||||
#define cpu_has_mipsmt 0
|
||||
#define cpu_has_userlocal 0
|
||||
#define cpu_has_vint 0
|
||||
#define cpu_has_veic 0
|
||||
#define cpu_hwrena_impl_bits 0xc0000000
|
||||
#define ARCH_HAS_READ_CURRENT_TIMER 1
|
||||
#define ARCH_HAS_IRQ_PER_CPU 1
|
||||
#define ARCH_HAS_SPINLOCK_PREFETCH 1
|
||||
|
|
|
@ -30,12 +30,14 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
|
|||
return octeon_map_dma_mem(dev, page_address(page), PAGE_SIZE);
|
||||
}
|
||||
|
||||
static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
|
||||
static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
return dma_addr;
|
||||
}
|
||||
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr)
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
|
||||
size_t size, enum dma_data_direction direction)
|
||||
{
|
||||
octeon_unmap_dma_mem(dev, dma_addr);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,14 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
|
|||
return page_to_phys(page);
|
||||
}
|
||||
|
||||
static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
|
||||
static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
return dma_addr;
|
||||
}
|
||||
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr)
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
|
||||
size_t size, enum dma_data_direction direction)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,14 @@ static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
|
|||
return pa;
|
||||
}
|
||||
|
||||
static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
|
||||
static unsigned long plat_dma_addr_to_phys(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
return dma_addr & ~(0xffUL << 56);
|
||||
}
|
||||
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr)
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
|
||||
size_t size, enum dma_data_direction direction)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
|
|||
}
|
||||
|
||||
/* This is almost certainly wrong but it's what dma-ip32.c used to use */
|
||||
static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
|
||||
static unsigned long plat_dma_addr_to_phys(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
unsigned long addr = dma_addr & RAM_OFFSET_MASK;
|
||||
|
||||
|
@ -60,7 +61,8 @@ static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
|
|||
return addr;
|
||||
}
|
||||
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr)
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
|
||||
size_t size, enum dma_data_direction direction)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,14 @@ static dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
|
|||
return vdma_alloc(page_to_phys(page), PAGE_SIZE);
|
||||
}
|
||||
|
||||
static unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
|
||||
static unsigned long plat_dma_addr_to_phys(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
return vdma_log2phys(dma_addr);
|
||||
}
|
||||
|
||||
static void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr)
|
||||
static void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
|
||||
size_t size, enum dma_data_direction direction)
|
||||
{
|
||||
vdma_free(dma_addr);
|
||||
}
|
||||
|
|
|
@ -25,12 +25,14 @@ static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,
|
|||
return page_to_phys(page) | 0x80000000;
|
||||
}
|
||||
|
||||
static inline unsigned long plat_dma_addr_to_phys(dma_addr_t dma_addr)
|
||||
static inline unsigned long plat_dma_addr_to_phys(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
return dma_addr & 0x7fffffff;
|
||||
}
|
||||
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr)
|
||||
static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
|
||||
size_t size, enum dma_data_direction direction)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -53,11 +53,6 @@
|
|||
#define cpu_has_smartmips 0
|
||||
|
||||
#define cpu_has_vtag_icache 0
|
||||
/* #define cpu_has_dc_aliases ? */
|
||||
/* #define cpu_has_ic_fills_f_dc ? */
|
||||
/* #define cpu_has_pindexed_dcache ? */
|
||||
|
||||
/* #define cpu_icache_snoops_remote_store ? */
|
||||
|
||||
#define cpu_has_mips32r1 1
|
||||
#define cpu_has_mips32r2 0
|
||||
|
|
|
@ -220,6 +220,22 @@
|
|||
#error Bad page size configuration!
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default huge tlb size for a given kernel configuration
|
||||
*/
|
||||
#ifdef CONFIG_PAGE_SIZE_4KB
|
||||
#define PM_HUGE_MASK PM_1M
|
||||
#elif defined(CONFIG_PAGE_SIZE_8KB)
|
||||
#define PM_HUGE_MASK PM_4M
|
||||
#elif defined(CONFIG_PAGE_SIZE_16KB)
|
||||
#define PM_HUGE_MASK PM_16M
|
||||
#elif defined(CONFIG_PAGE_SIZE_32KB)
|
||||
#define PM_HUGE_MASK PM_64M
|
||||
#elif defined(CONFIG_PAGE_SIZE_64KB)
|
||||
#define PM_HUGE_MASK PM_256M
|
||||
#elif defined(CONFIG_HUGETLB_PAGE)
|
||||
#error Bad page size configuration for hugetlbfs!
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Values used for computation of new tlb entries
|
||||
|
|
|
@ -157,6 +157,13 @@ enum cvmx_board_types_enum {
|
|||
CVMX_BOARD_TYPE_NIC_XLE_4G = 21,
|
||||
CVMX_BOARD_TYPE_EBT5600 = 22,
|
||||
CVMX_BOARD_TYPE_EBH5201 = 23,
|
||||
CVMX_BOARD_TYPE_EBT5200 = 24,
|
||||
CVMX_BOARD_TYPE_CB5600 = 25,
|
||||
CVMX_BOARD_TYPE_CB5601 = 26,
|
||||
CVMX_BOARD_TYPE_CB5200 = 27,
|
||||
/* Special 'generic' board type, supports many boards */
|
||||
CVMX_BOARD_TYPE_GENERIC = 28,
|
||||
CVMX_BOARD_TYPE_EBH5610 = 29,
|
||||
CVMX_BOARD_TYPE_MAX,
|
||||
|
||||
/*
|
||||
|
@ -228,6 +235,12 @@ static inline const char *cvmx_board_type_to_string(enum
|
|||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_NIC_XLE_4G)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBT5600)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH5201)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBT5200)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CB5600)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CB5601)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CB5200)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_GENERIC)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_EBH5610)
|
||||
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_MAX)
|
||||
|
||||
/* Customer boards listed here */
|
||||
|
|
|
@ -183,6 +183,64 @@ extern void *cvmx_bootmem_alloc_range(uint64_t size, uint64_t alignment,
|
|||
* Returns 0 on failure,
|
||||
* !0 on success
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Allocate a block of memory from the free list that was passed
|
||||
* to the application by the bootloader, and assign it a name in the
|
||||
* global named block table. (part of the cvmx_bootmem_descriptor_t structure)
|
||||
* Named blocks can later be freed.
|
||||
*
|
||||
* @size: Size in bytes of block to allocate
|
||||
* @alignment: Alignment required - must be power of 2
|
||||
* @name: name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
|
||||
*
|
||||
* Returns a pointer to block of memory, NULL on error
|
||||
*/
|
||||
extern void *cvmx_bootmem_alloc_named(uint64_t size, uint64_t alignment,
|
||||
char *name);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allocate a block of memory from the free list that was passed
|
||||
* to the application by the bootloader, and assign it a name in the
|
||||
* global named block table. (part of the cvmx_bootmem_descriptor_t structure)
|
||||
* Named blocks can later be freed.
|
||||
*
|
||||
* @size: Size in bytes of block to allocate
|
||||
* @address: Physical address to allocate memory at. If this
|
||||
* memory is not available, the allocation fails.
|
||||
* @name: name of block - must be less than CVMX_BOOTMEM_NAME_LEN
|
||||
* bytes
|
||||
*
|
||||
* Returns a pointer to block of memory, NULL on error
|
||||
*/
|
||||
extern void *cvmx_bootmem_alloc_named_address(uint64_t size, uint64_t address,
|
||||
char *name);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allocate a block of memory from a specific range of the free list
|
||||
* that was passed to the application by the bootloader, and assign it
|
||||
* a name in the global named block table. (part of the
|
||||
* cvmx_bootmem_descriptor_t structure) Named blocks can later be
|
||||
* freed. If request cannot be satisfied within the address range
|
||||
* specified, NULL is returned
|
||||
*
|
||||
* @size: Size in bytes of block to allocate
|
||||
* @min_addr: minimum address of range
|
||||
* @max_addr: maximum address of range
|
||||
* @align: Alignment of memory to be allocated. (must be a power of 2)
|
||||
* @name: name of block - must be less than CVMX_BOOTMEM_NAME_LEN bytes
|
||||
*
|
||||
* Returns a pointer to block of memory, NULL on error
|
||||
*/
|
||||
extern void *cvmx_bootmem_alloc_named_range(uint64_t size, uint64_t min_addr,
|
||||
uint64_t max_addr, uint64_t align,
|
||||
char *name);
|
||||
|
||||
extern int cvmx_bootmem_free_named(char *name);
|
||||
|
||||
/**
|
||||
|
@ -223,6 +281,33 @@ int64_t cvmx_bootmem_phy_alloc(uint64_t req_size, uint64_t address_min,
|
|||
uint64_t address_max, uint64_t alignment,
|
||||
uint32_t flags);
|
||||
|
||||
/**
|
||||
* Allocates a named block of physical memory from the free list, at
|
||||
* (optional) requested address and alignment.
|
||||
*
|
||||
* @param size size of region to allocate. All requests are rounded
|
||||
* up to be a multiple CVMX_BOOTMEM_ALIGNMENT_SIZE
|
||||
* bytes size
|
||||
* @param min_addr Minimum address that block can occupy.
|
||||
* @param max_addr Specifies the maximum address_min (inclusive) that
|
||||
* the allocation can use.
|
||||
* @param alignment Requested alignment of the block. If this
|
||||
* alignment cannot be met, the allocation fails.
|
||||
* This must be a power of 2. (Note: Alignment of
|
||||
* CVMX_BOOTMEM_ALIGNMENT_SIZE bytes is required, and
|
||||
* internally enforced. Requested alignments of less
|
||||
* than CVMX_BOOTMEM_ALIGNMENT_SIZE are set to
|
||||
* CVMX_BOOTMEM_ALIGNMENT_SIZE.)
|
||||
* @param name name to assign to named block
|
||||
* @param flags Flags to control options for the allocation.
|
||||
*
|
||||
* @return physical address of block allocated, or -1 on failure
|
||||
*/
|
||||
int64_t cvmx_bootmem_phy_named_block_alloc(uint64_t size, uint64_t min_addr,
|
||||
uint64_t max_addr,
|
||||
uint64_t alignment,
|
||||
char *name, uint32_t flags);
|
||||
|
||||
/**
|
||||
* Finds a named memory block by name.
|
||||
* Also used for finding an unused entry in the named block table.
|
||||
|
|
33
arch/mips/include/asm/octeon/cvmx-helper-errata.h
Normal file
33
arch/mips/include/asm/octeon/cvmx-helper-errata.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/***********************license start***************
|
||||
* Author: Cavium Networks
|
||||
*
|
||||
* Contact: support@caviumnetworks.com
|
||||
* This file is part of the OCTEON SDK
|
||||
*
|
||||
* Copyright (c) 2003-2008 Cavium Networks
|
||||
*
|
||||
* This file 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.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
|
||||
* NONINFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this file; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* or visit http://www.gnu.org/licenses/.
|
||||
*
|
||||
* This file may also be available under a different license from Cavium.
|
||||
* Contact Cavium Networks for more information
|
||||
***********************license end**************************************/
|
||||
|
||||
#ifndef __CVMX_HELPER_ERRATA_H__
|
||||
#define __CVMX_HELPER_ERRATA_H__
|
||||
|
||||
extern void __cvmx_helper_errata_qlm_disable_2nd_order_cdr(int qlm);
|
||||
|
||||
#endif
|
43
arch/mips/include/asm/octeon/cvmx-helper-jtag.h
Normal file
43
arch/mips/include/asm/octeon/cvmx-helper-jtag.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/***********************license start***************
|
||||
* Author: Cavium Networks
|
||||
*
|
||||
* Contact: support@caviumnetworks.com
|
||||
* This file is part of the OCTEON SDK
|
||||
*
|
||||
* Copyright (c) 2003-2008 Cavium Networks
|
||||
*
|
||||
* This file 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.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
|
||||
* NONINFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this file; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* or visit http://www.gnu.org/licenses/.
|
||||
*
|
||||
* This file may also be available under a different license from Cavium.
|
||||
* Contact Cavium Networks for more information
|
||||
***********************license end**************************************/
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* Helper utilities for qlm_jtag.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __CVMX_HELPER_JTAG_H__
|
||||
#define __CVMX_HELPER_JTAG_H__
|
||||
|
||||
extern void cvmx_helper_qlm_jtag_init(void);
|
||||
extern uint32_t cvmx_helper_qlm_jtag_shift(int qlm, int bits, uint32_t data);
|
||||
extern void cvmx_helper_qlm_jtag_shift_zeros(int qlm, int bits);
|
||||
extern void cvmx_helper_qlm_jtag_update(int qlm);
|
||||
|
||||
#endif /* __CVMX_HELPER_JTAG_H__ */
|
2560
arch/mips/include/asm/octeon/cvmx-npei-defs.h
Normal file
2560
arch/mips/include/asm/octeon/cvmx-npei-defs.h
Normal file
File diff suppressed because it is too large
Load diff
1735
arch/mips/include/asm/octeon/cvmx-npi-defs.h
Normal file
1735
arch/mips/include/asm/octeon/cvmx-npi-defs.h
Normal file
File diff suppressed because it is too large
Load diff
1645
arch/mips/include/asm/octeon/cvmx-pci-defs.h
Normal file
1645
arch/mips/include/asm/octeon/cvmx-pci-defs.h
Normal file
File diff suppressed because it is too large
Load diff
1365
arch/mips/include/asm/octeon/cvmx-pcieep-defs.h
Normal file
1365
arch/mips/include/asm/octeon/cvmx-pcieep-defs.h
Normal file
File diff suppressed because it is too large
Load diff
1397
arch/mips/include/asm/octeon/cvmx-pciercx-defs.h
Normal file
1397
arch/mips/include/asm/octeon/cvmx-pciercx-defs.h
Normal file
File diff suppressed because it is too large
Load diff
410
arch/mips/include/asm/octeon/cvmx-pescx-defs.h
Normal file
410
arch/mips/include/asm/octeon/cvmx-pescx-defs.h
Normal file
|
@ -0,0 +1,410 @@
|
|||
/***********************license start***************
|
||||
* Author: Cavium Networks
|
||||
*
|
||||
* Contact: support@caviumnetworks.com
|
||||
* This file is part of the OCTEON SDK
|
||||
*
|
||||
* Copyright (c) 2003-2008 Cavium Networks
|
||||
*
|
||||
* This file 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.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
|
||||
* NONINFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this file; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* or visit http://www.gnu.org/licenses/.
|
||||
*
|
||||
* This file may also be available under a different license from Cavium.
|
||||
* Contact Cavium Networks for more information
|
||||
***********************license end**************************************/
|
||||
|
||||
#ifndef __CVMX_PESCX_DEFS_H__
|
||||
#define __CVMX_PESCX_DEFS_H__
|
||||
|
||||
#define CVMX_PESCX_BIST_STATUS(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000018ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_BIST_STATUS2(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000418ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_CFG_RD(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000030ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_CFG_WR(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000028ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_CPL_LUT_VALID(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000098ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_CTL_STATUS(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000000ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_CTL_STATUS2(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000400ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_DBG_INFO(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000008ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_DBG_INFO_EN(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C80000A0ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_DIAG_STATUS(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000020ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_P2N_BAR0_START(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000080ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_P2N_BAR1_START(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000088ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_P2N_BAR2_START(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000090ull + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_P2P_BARX_END(offset, block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000048ull + (((offset) & 3) * 16) + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_P2P_BARX_START(offset, block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000040ull + (((offset) & 3) * 16) + (((block_id) & 1) * 0x8000000ull))
|
||||
#define CVMX_PESCX_TLP_CREDITS(block_id) \
|
||||
CVMX_ADD_IO_SEG(0x00011800C8000038ull + (((block_id) & 1) * 0x8000000ull))
|
||||
|
||||
union cvmx_pescx_bist_status {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_bist_status_s {
|
||||
uint64_t reserved_13_63:51;
|
||||
uint64_t rqdata5:1;
|
||||
uint64_t ctlp_or:1;
|
||||
uint64_t ntlp_or:1;
|
||||
uint64_t ptlp_or:1;
|
||||
uint64_t retry:1;
|
||||
uint64_t rqdata0:1;
|
||||
uint64_t rqdata1:1;
|
||||
uint64_t rqdata2:1;
|
||||
uint64_t rqdata3:1;
|
||||
uint64_t rqdata4:1;
|
||||
uint64_t rqhdr1:1;
|
||||
uint64_t rqhdr0:1;
|
||||
uint64_t sot:1;
|
||||
} s;
|
||||
struct cvmx_pescx_bist_status_s cn52xx;
|
||||
struct cvmx_pescx_bist_status_cn52xxp1 {
|
||||
uint64_t reserved_12_63:52;
|
||||
uint64_t ctlp_or:1;
|
||||
uint64_t ntlp_or:1;
|
||||
uint64_t ptlp_or:1;
|
||||
uint64_t retry:1;
|
||||
uint64_t rqdata0:1;
|
||||
uint64_t rqdata1:1;
|
||||
uint64_t rqdata2:1;
|
||||
uint64_t rqdata3:1;
|
||||
uint64_t rqdata4:1;
|
||||
uint64_t rqhdr1:1;
|
||||
uint64_t rqhdr0:1;
|
||||
uint64_t sot:1;
|
||||
} cn52xxp1;
|
||||
struct cvmx_pescx_bist_status_s cn56xx;
|
||||
struct cvmx_pescx_bist_status_cn52xxp1 cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_bist_status2 {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_bist_status2_s {
|
||||
uint64_t reserved_14_63:50;
|
||||
uint64_t cto_p2e:1;
|
||||
uint64_t e2p_cpl:1;
|
||||
uint64_t e2p_n:1;
|
||||
uint64_t e2p_p:1;
|
||||
uint64_t e2p_rsl:1;
|
||||
uint64_t dbg_p2e:1;
|
||||
uint64_t peai_p2e:1;
|
||||
uint64_t rsl_p2e:1;
|
||||
uint64_t pef_tpf1:1;
|
||||
uint64_t pef_tpf0:1;
|
||||
uint64_t pef_tnf:1;
|
||||
uint64_t pef_tcf1:1;
|
||||
uint64_t pef_tc0:1;
|
||||
uint64_t ppf:1;
|
||||
} s;
|
||||
struct cvmx_pescx_bist_status2_s cn52xx;
|
||||
struct cvmx_pescx_bist_status2_s cn52xxp1;
|
||||
struct cvmx_pescx_bist_status2_s cn56xx;
|
||||
struct cvmx_pescx_bist_status2_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_cfg_rd {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_cfg_rd_s {
|
||||
uint64_t data:32;
|
||||
uint64_t addr:32;
|
||||
} s;
|
||||
struct cvmx_pescx_cfg_rd_s cn52xx;
|
||||
struct cvmx_pescx_cfg_rd_s cn52xxp1;
|
||||
struct cvmx_pescx_cfg_rd_s cn56xx;
|
||||
struct cvmx_pescx_cfg_rd_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_cfg_wr {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_cfg_wr_s {
|
||||
uint64_t data:32;
|
||||
uint64_t addr:32;
|
||||
} s;
|
||||
struct cvmx_pescx_cfg_wr_s cn52xx;
|
||||
struct cvmx_pescx_cfg_wr_s cn52xxp1;
|
||||
struct cvmx_pescx_cfg_wr_s cn56xx;
|
||||
struct cvmx_pescx_cfg_wr_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_cpl_lut_valid {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_cpl_lut_valid_s {
|
||||
uint64_t reserved_32_63:32;
|
||||
uint64_t tag:32;
|
||||
} s;
|
||||
struct cvmx_pescx_cpl_lut_valid_s cn52xx;
|
||||
struct cvmx_pescx_cpl_lut_valid_s cn52xxp1;
|
||||
struct cvmx_pescx_cpl_lut_valid_s cn56xx;
|
||||
struct cvmx_pescx_cpl_lut_valid_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_ctl_status {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_ctl_status_s {
|
||||
uint64_t reserved_28_63:36;
|
||||
uint64_t dnum:5;
|
||||
uint64_t pbus:8;
|
||||
uint64_t qlm_cfg:2;
|
||||
uint64_t lane_swp:1;
|
||||
uint64_t pm_xtoff:1;
|
||||
uint64_t pm_xpme:1;
|
||||
uint64_t ob_p_cmd:1;
|
||||
uint64_t reserved_7_8:2;
|
||||
uint64_t nf_ecrc:1;
|
||||
uint64_t dly_one:1;
|
||||
uint64_t lnk_enb:1;
|
||||
uint64_t ro_ctlp:1;
|
||||
uint64_t reserved_2_2:1;
|
||||
uint64_t inv_ecrc:1;
|
||||
uint64_t inv_lcrc:1;
|
||||
} s;
|
||||
struct cvmx_pescx_ctl_status_s cn52xx;
|
||||
struct cvmx_pescx_ctl_status_s cn52xxp1;
|
||||
struct cvmx_pescx_ctl_status_cn56xx {
|
||||
uint64_t reserved_28_63:36;
|
||||
uint64_t dnum:5;
|
||||
uint64_t pbus:8;
|
||||
uint64_t qlm_cfg:2;
|
||||
uint64_t reserved_12_12:1;
|
||||
uint64_t pm_xtoff:1;
|
||||
uint64_t pm_xpme:1;
|
||||
uint64_t ob_p_cmd:1;
|
||||
uint64_t reserved_7_8:2;
|
||||
uint64_t nf_ecrc:1;
|
||||
uint64_t dly_one:1;
|
||||
uint64_t lnk_enb:1;
|
||||
uint64_t ro_ctlp:1;
|
||||
uint64_t reserved_2_2:1;
|
||||
uint64_t inv_ecrc:1;
|
||||
uint64_t inv_lcrc:1;
|
||||
} cn56xx;
|
||||
struct cvmx_pescx_ctl_status_cn56xx cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_ctl_status2 {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_ctl_status2_s {
|
||||
uint64_t reserved_2_63:62;
|
||||
uint64_t pclk_run:1;
|
||||
uint64_t pcierst:1;
|
||||
} s;
|
||||
struct cvmx_pescx_ctl_status2_s cn52xx;
|
||||
struct cvmx_pescx_ctl_status2_cn52xxp1 {
|
||||
uint64_t reserved_1_63:63;
|
||||
uint64_t pcierst:1;
|
||||
} cn52xxp1;
|
||||
struct cvmx_pescx_ctl_status2_s cn56xx;
|
||||
struct cvmx_pescx_ctl_status2_cn52xxp1 cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_dbg_info {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_dbg_info_s {
|
||||
uint64_t reserved_31_63:33;
|
||||
uint64_t ecrc_e:1;
|
||||
uint64_t rawwpp:1;
|
||||
uint64_t racpp:1;
|
||||
uint64_t ramtlp:1;
|
||||
uint64_t rarwdns:1;
|
||||
uint64_t caar:1;
|
||||
uint64_t racca:1;
|
||||
uint64_t racur:1;
|
||||
uint64_t rauc:1;
|
||||
uint64_t rqo:1;
|
||||
uint64_t fcuv:1;
|
||||
uint64_t rpe:1;
|
||||
uint64_t fcpvwt:1;
|
||||
uint64_t dpeoosd:1;
|
||||
uint64_t rtwdle:1;
|
||||
uint64_t rdwdle:1;
|
||||
uint64_t mre:1;
|
||||
uint64_t rte:1;
|
||||
uint64_t acto:1;
|
||||
uint64_t rvdm:1;
|
||||
uint64_t rumep:1;
|
||||
uint64_t rptamrc:1;
|
||||
uint64_t rpmerc:1;
|
||||
uint64_t rfemrc:1;
|
||||
uint64_t rnfemrc:1;
|
||||
uint64_t rcemrc:1;
|
||||
uint64_t rpoison:1;
|
||||
uint64_t recrce:1;
|
||||
uint64_t rtlplle:1;
|
||||
uint64_t rtlpmal:1;
|
||||
uint64_t spoison:1;
|
||||
} s;
|
||||
struct cvmx_pescx_dbg_info_s cn52xx;
|
||||
struct cvmx_pescx_dbg_info_s cn52xxp1;
|
||||
struct cvmx_pescx_dbg_info_s cn56xx;
|
||||
struct cvmx_pescx_dbg_info_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_dbg_info_en {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_dbg_info_en_s {
|
||||
uint64_t reserved_31_63:33;
|
||||
uint64_t ecrc_e:1;
|
||||
uint64_t rawwpp:1;
|
||||
uint64_t racpp:1;
|
||||
uint64_t ramtlp:1;
|
||||
uint64_t rarwdns:1;
|
||||
uint64_t caar:1;
|
||||
uint64_t racca:1;
|
||||
uint64_t racur:1;
|
||||
uint64_t rauc:1;
|
||||
uint64_t rqo:1;
|
||||
uint64_t fcuv:1;
|
||||
uint64_t rpe:1;
|
||||
uint64_t fcpvwt:1;
|
||||
uint64_t dpeoosd:1;
|
||||
uint64_t rtwdle:1;
|
||||
uint64_t rdwdle:1;
|
||||
uint64_t mre:1;
|
||||
uint64_t rte:1;
|
||||
uint64_t acto:1;
|
||||
uint64_t rvdm:1;
|
||||
uint64_t rumep:1;
|
||||
uint64_t rptamrc:1;
|
||||
uint64_t rpmerc:1;
|
||||
uint64_t rfemrc:1;
|
||||
uint64_t rnfemrc:1;
|
||||
uint64_t rcemrc:1;
|
||||
uint64_t rpoison:1;
|
||||
uint64_t recrce:1;
|
||||
uint64_t rtlplle:1;
|
||||
uint64_t rtlpmal:1;
|
||||
uint64_t spoison:1;
|
||||
} s;
|
||||
struct cvmx_pescx_dbg_info_en_s cn52xx;
|
||||
struct cvmx_pescx_dbg_info_en_s cn52xxp1;
|
||||
struct cvmx_pescx_dbg_info_en_s cn56xx;
|
||||
struct cvmx_pescx_dbg_info_en_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_diag_status {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_diag_status_s {
|
||||
uint64_t reserved_4_63:60;
|
||||
uint64_t pm_dst:1;
|
||||
uint64_t pm_stat:1;
|
||||
uint64_t pm_en:1;
|
||||
uint64_t aux_en:1;
|
||||
} s;
|
||||
struct cvmx_pescx_diag_status_s cn52xx;
|
||||
struct cvmx_pescx_diag_status_s cn52xxp1;
|
||||
struct cvmx_pescx_diag_status_s cn56xx;
|
||||
struct cvmx_pescx_diag_status_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_p2n_bar0_start {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_p2n_bar0_start_s {
|
||||
uint64_t addr:50;
|
||||
uint64_t reserved_0_13:14;
|
||||
} s;
|
||||
struct cvmx_pescx_p2n_bar0_start_s cn52xx;
|
||||
struct cvmx_pescx_p2n_bar0_start_s cn52xxp1;
|
||||
struct cvmx_pescx_p2n_bar0_start_s cn56xx;
|
||||
struct cvmx_pescx_p2n_bar0_start_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_p2n_bar1_start {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_p2n_bar1_start_s {
|
||||
uint64_t addr:38;
|
||||
uint64_t reserved_0_25:26;
|
||||
} s;
|
||||
struct cvmx_pescx_p2n_bar1_start_s cn52xx;
|
||||
struct cvmx_pescx_p2n_bar1_start_s cn52xxp1;
|
||||
struct cvmx_pescx_p2n_bar1_start_s cn56xx;
|
||||
struct cvmx_pescx_p2n_bar1_start_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_p2n_bar2_start {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_p2n_bar2_start_s {
|
||||
uint64_t addr:25;
|
||||
uint64_t reserved_0_38:39;
|
||||
} s;
|
||||
struct cvmx_pescx_p2n_bar2_start_s cn52xx;
|
||||
struct cvmx_pescx_p2n_bar2_start_s cn52xxp1;
|
||||
struct cvmx_pescx_p2n_bar2_start_s cn56xx;
|
||||
struct cvmx_pescx_p2n_bar2_start_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_p2p_barx_end {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_p2p_barx_end_s {
|
||||
uint64_t addr:52;
|
||||
uint64_t reserved_0_11:12;
|
||||
} s;
|
||||
struct cvmx_pescx_p2p_barx_end_s cn52xx;
|
||||
struct cvmx_pescx_p2p_barx_end_s cn52xxp1;
|
||||
struct cvmx_pescx_p2p_barx_end_s cn56xx;
|
||||
struct cvmx_pescx_p2p_barx_end_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_p2p_barx_start {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_p2p_barx_start_s {
|
||||
uint64_t addr:52;
|
||||
uint64_t reserved_0_11:12;
|
||||
} s;
|
||||
struct cvmx_pescx_p2p_barx_start_s cn52xx;
|
||||
struct cvmx_pescx_p2p_barx_start_s cn52xxp1;
|
||||
struct cvmx_pescx_p2p_barx_start_s cn56xx;
|
||||
struct cvmx_pescx_p2p_barx_start_s cn56xxp1;
|
||||
};
|
||||
|
||||
union cvmx_pescx_tlp_credits {
|
||||
uint64_t u64;
|
||||
struct cvmx_pescx_tlp_credits_s {
|
||||
uint64_t reserved_0_63:64;
|
||||
} s;
|
||||
struct cvmx_pescx_tlp_credits_cn52xx {
|
||||
uint64_t reserved_56_63:8;
|
||||
uint64_t peai_ppf:8;
|
||||
uint64_t pesc_cpl:8;
|
||||
uint64_t pesc_np:8;
|
||||
uint64_t pesc_p:8;
|
||||
uint64_t npei_cpl:8;
|
||||
uint64_t npei_np:8;
|
||||
uint64_t npei_p:8;
|
||||
} cn52xx;
|
||||
struct cvmx_pescx_tlp_credits_cn52xxp1 {
|
||||
uint64_t reserved_38_63:26;
|
||||
uint64_t peai_ppf:8;
|
||||
uint64_t pesc_cpl:5;
|
||||
uint64_t pesc_np:5;
|
||||
uint64_t pesc_p:5;
|
||||
uint64_t npei_cpl:5;
|
||||
uint64_t npei_np:5;
|
||||
uint64_t npei_p:5;
|
||||
} cn52xxp1;
|
||||
struct cvmx_pescx_tlp_credits_cn52xx cn56xx;
|
||||
struct cvmx_pescx_tlp_credits_cn52xxp1 cn56xxp1;
|
||||
};
|
||||
|
||||
#endif
|
229
arch/mips/include/asm/octeon/cvmx-pexp-defs.h
Normal file
229
arch/mips/include/asm/octeon/cvmx-pexp-defs.h
Normal file
|
@ -0,0 +1,229 @@
|
|||
/***********************license start***************
|
||||
* Author: Cavium Networks
|
||||
*
|
||||
* Contact: support@caviumnetworks.com
|
||||
* This file is part of the OCTEON SDK
|
||||
*
|
||||
* Copyright (c) 2003-2008 Cavium Networks
|
||||
*
|
||||
* This file 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.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
|
||||
* NONINFRINGEMENT. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this file; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
* or visit http://www.gnu.org/licenses/.
|
||||
*
|
||||
* This file may also be available under a different license from Cavium.
|
||||
* Contact Cavium Networks for more information
|
||||
***********************license end**************************************/
|
||||
|
||||
/**
|
||||
* cvmx-pexp-defs.h
|
||||
*
|
||||
* Configuration and status register (CSR) definitions for
|
||||
* OCTEON PEXP.
|
||||
*
|
||||
*/
|
||||
#ifndef __CVMX_PEXP_DEFS_H__
|
||||
#define __CVMX_PEXP_DEFS_H__
|
||||
|
||||
#define CVMX_PEXP_NPEI_BAR1_INDEXX(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008000ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_BIST_STATUS \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008580ull)
|
||||
#define CVMX_PEXP_NPEI_BIST_STATUS2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008680ull)
|
||||
#define CVMX_PEXP_NPEI_CTL_PORT0 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008250ull)
|
||||
#define CVMX_PEXP_NPEI_CTL_PORT1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008260ull)
|
||||
#define CVMX_PEXP_NPEI_CTL_STATUS \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008570ull)
|
||||
#define CVMX_PEXP_NPEI_CTL_STATUS2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC00ull)
|
||||
#define CVMX_PEXP_NPEI_DATA_OUT_CNT \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000085F0ull)
|
||||
#define CVMX_PEXP_NPEI_DBG_DATA \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008510ull)
|
||||
#define CVMX_PEXP_NPEI_DBG_SELECT \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008500ull)
|
||||
#define CVMX_PEXP_NPEI_DMA0_INT_LEVEL \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000085C0ull)
|
||||
#define CVMX_PEXP_NPEI_DMA1_INT_LEVEL \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000085D0ull)
|
||||
#define CVMX_PEXP_NPEI_DMAX_COUNTS(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008450ull + (((offset) & 7) * 16))
|
||||
#define CVMX_PEXP_NPEI_DMAX_DBELL(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000083B0ull + (((offset) & 7) * 16))
|
||||
#define CVMX_PEXP_NPEI_DMAX_IBUFF_SADDR(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008400ull + (((offset) & 7) * 16))
|
||||
#define CVMX_PEXP_NPEI_DMAX_NADDR(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000084A0ull + (((offset) & 7) * 16))
|
||||
#define CVMX_PEXP_NPEI_DMA_CNTS \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000085E0ull)
|
||||
#define CVMX_PEXP_NPEI_DMA_CONTROL \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000083A0ull)
|
||||
#define CVMX_PEXP_NPEI_INT_A_ENB \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008560ull)
|
||||
#define CVMX_PEXP_NPEI_INT_A_ENB2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BCE0ull)
|
||||
#define CVMX_PEXP_NPEI_INT_A_SUM \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008550ull)
|
||||
#define CVMX_PEXP_NPEI_INT_ENB \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008540ull)
|
||||
#define CVMX_PEXP_NPEI_INT_ENB2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BCD0ull)
|
||||
#define CVMX_PEXP_NPEI_INT_INFO \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008590ull)
|
||||
#define CVMX_PEXP_NPEI_INT_SUM \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008530ull)
|
||||
#define CVMX_PEXP_NPEI_INT_SUM2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BCC0ull)
|
||||
#define CVMX_PEXP_NPEI_LAST_WIN_RDATA0 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008600ull)
|
||||
#define CVMX_PEXP_NPEI_LAST_WIN_RDATA1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008610ull)
|
||||
#define CVMX_PEXP_NPEI_MEM_ACCESS_CTL \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000084F0ull)
|
||||
#define CVMX_PEXP_NPEI_MEM_ACCESS_SUBIDX(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008280ull + (((offset) & 31) * 16) - 16 * 12)
|
||||
#define CVMX_PEXP_NPEI_MSI_ENB0 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC50ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_ENB1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC60ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_ENB2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC70ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_ENB3 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC80ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_RCV0 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC10ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_RCV1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC20ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_RCV2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC30ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_RCV3 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC40ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_RD_MAP \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BCA0ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1C_ENB0 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BCF0ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1C_ENB1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD00ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1C_ENB2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD10ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1C_ENB3 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD20ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1S_ENB0 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD30ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1S_ENB1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD40ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1S_ENB2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD50ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_W1S_ENB3 \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD60ull)
|
||||
#define CVMX_PEXP_NPEI_MSI_WR_MAP \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BC90ull)
|
||||
#define CVMX_PEXP_NPEI_PCIE_CREDIT_CNT \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BD70ull)
|
||||
#define CVMX_PEXP_NPEI_PCIE_MSI_RCV \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000BCB0ull)
|
||||
#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008650ull)
|
||||
#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008660ull)
|
||||
#define CVMX_PEXP_NPEI_PCIE_MSI_RCV_B3 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008670ull)
|
||||
#define CVMX_PEXP_NPEI_PKTX_CNTS(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000A400ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_INSTR_BADDR(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000A800ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_INSTR_BAOFF_DBELL(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000AC00ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_INSTR_FIFO_RSIZE(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000B000ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_INSTR_HEADER(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000B400ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_IN_BP(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000B800ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_SLIST_BADDR(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009400ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_SLIST_BAOFF_DBELL(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009800ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKTX_SLIST_FIFO_RSIZE(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009C00ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKT_CNT_INT \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009110ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_CNT_INT_ENB \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009130ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_DATA_OUT_ES \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000090B0ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_DATA_OUT_NS \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000090A0ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_DATA_OUT_ROR \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009090ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_DPADDR \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009080ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_INPUT_CONTROL \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009150ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_INSTR_ENB \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009000ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_INSTR_RD_SIZE \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009190ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_INSTR_SIZE \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009020ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_INT_LEVELS \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009100ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_IN_BP \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000086B0ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_IN_DONEX_CNTS(offset) \
|
||||
CVMX_ADD_IO_SEG(0x00011F000000A000ull + (((offset) & 31) * 16))
|
||||
#define CVMX_PEXP_NPEI_PKT_IN_INSTR_COUNTS \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000086A0ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_IN_PCIE_PORT \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000091A0ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_IPTR \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009070ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_OUTPUT_WMARK \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009160ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_OUT_BMODE \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000090D0ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_OUT_ENB \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009010ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_PCIE_PORT \
|
||||
CVMX_ADD_IO_SEG(0x00011F00000090E0ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_PORT_IN_RST \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008690ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_SLIST_ES \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009050ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_SLIST_ID_SIZE \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009180ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_SLIST_NS \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009040ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_SLIST_ROR \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009030ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_TIME_INT \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009120ull)
|
||||
#define CVMX_PEXP_NPEI_PKT_TIME_INT_ENB \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000009140ull)
|
||||
#define CVMX_PEXP_NPEI_RSL_INT_BLOCKS \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008520ull)
|
||||
#define CVMX_PEXP_NPEI_SCRATCH_1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008270ull)
|
||||
#define CVMX_PEXP_NPEI_STATE1 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008620ull)
|
||||
#define CVMX_PEXP_NPEI_STATE2 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008630ull)
|
||||
#define CVMX_PEXP_NPEI_STATE3 \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008640ull)
|
||||
#define CVMX_PEXP_NPEI_WINDOW_CTL \
|
||||
CVMX_ADD_IO_SEG(0x00011F0000008380ull)
|
||||
|
||||
#endif
|
|
@ -375,6 +375,18 @@ static inline uint64_t cvmx_get_cycle(void)
|
|||
return cycle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the specified number of cycle
|
||||
*
|
||||
*/
|
||||
static inline void cvmx_wait(uint64_t cycles)
|
||||
{
|
||||
uint64_t done = cvmx_get_cycle() + cycles;
|
||||
|
||||
while (cvmx_get_cycle() < done)
|
||||
; /* Spin */
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a chip global cycle counter. This counts CPU cycles since
|
||||
* chip reset. The counter is 64 bit.
|
||||
|
|
|
@ -57,6 +57,13 @@ enum octeon_feature {
|
|||
OCTEON_FEATURE_RAID,
|
||||
/* Octeon has a builtin USB */
|
||||
OCTEON_FEATURE_USB,
|
||||
/* Octeon IPD can run without using work queue entries */
|
||||
OCTEON_FEATURE_NO_WPTR,
|
||||
/* Octeon has DFA state machines */
|
||||
OCTEON_FEATURE_DFA,
|
||||
/* Octeon MDIO block supports clause 45 transactions for 10
|
||||
* Gig support */
|
||||
OCTEON_FEATURE_MDIO_CLAUSE_45,
|
||||
};
|
||||
|
||||
static inline int cvmx_fuse_read(int fuse);
|
||||
|
@ -112,6 +119,26 @@ static inline int octeon_has_feature(enum octeon_feature feature)
|
|||
case OCTEON_FEATURE_USB:
|
||||
return !(OCTEON_IS_MODEL(OCTEON_CN38XX)
|
||||
|| OCTEON_IS_MODEL(OCTEON_CN58XX));
|
||||
case OCTEON_FEATURE_NO_WPTR:
|
||||
return (OCTEON_IS_MODEL(OCTEON_CN56XX)
|
||||
|| OCTEON_IS_MODEL(OCTEON_CN52XX))
|
||||
&& !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
|
||||
&& !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X);
|
||||
case OCTEON_FEATURE_DFA:
|
||||
if (!OCTEON_IS_MODEL(OCTEON_CN38XX)
|
||||
&& !OCTEON_IS_MODEL(OCTEON_CN31XX)
|
||||
&& !OCTEON_IS_MODEL(OCTEON_CN58XX))
|
||||
return 0;
|
||||
else if (OCTEON_IS_MODEL(OCTEON_CN3020))
|
||||
return 0;
|
||||
else if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
|
||||
return 1;
|
||||
else
|
||||
return !cvmx_fuse_read(120);
|
||||
case OCTEON_FEATURE_MDIO_CLAUSE_45:
|
||||
return !(OCTEON_IS_MODEL(OCTEON_CN3XXX)
|
||||
|| OCTEON_IS_MODEL(OCTEON_CN58XX)
|
||||
|| OCTEON_IS_MODEL(OCTEON_CN50XX));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -245,4 +245,6 @@ static inline uint32_t octeon_npi_read32(uint64_t address)
|
|||
return cvmx_read64_uint32(address ^ 4);
|
||||
}
|
||||
|
||||
extern struct cvmx_bootinfo *octeon_bootinfo;
|
||||
|
||||
#endif /* __ASM_OCTEON_OCTEON_H */
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
#define PAGE_SIZE (1UL << PAGE_SHIFT)
|
||||
#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
|
||||
|
||||
#define HPAGE_SHIFT (PAGE_SHIFT + PAGE_SHIFT - 3)
|
||||
#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
|
||||
#define HPAGE_MASK (~(HPAGE_SIZE - 1))
|
||||
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#include <linux/pfn.h>
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#else
|
||||
|
||||
#define _PAGE_R4KBUG (1<<5) /* workaround for r4k bug */
|
||||
#define _PAGE_HUGE (1<<5) /* huge tlb page */
|
||||
#define _PAGE_GLOBAL (1<<6)
|
||||
#define _PAGE_VALID (1<<7)
|
||||
#define _PAGE_SILENT_READ (1<<7) /* synonym */
|
||||
|
|
|
@ -292,6 +292,16 @@ static inline pte_t pte_mkyoung(pte_t pte)
|
|||
pte_val(pte) |= _PAGE_SILENT_READ;
|
||||
return pte;
|
||||
}
|
||||
|
||||
#ifdef _PAGE_HUGE
|
||||
static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_HUGE; }
|
||||
|
||||
static inline pte_t pte_mkhuge(pte_t pte)
|
||||
{
|
||||
pte_val(pte) |= _PAGE_HUGE;
|
||||
return pte;
|
||||
}
|
||||
#endif /* _PAGE_HUGE */
|
||||
#endif
|
||||
static inline int pte_special(pte_t pte) { return 0; }
|
||||
static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
|
||||
|
|
|
@ -399,6 +399,7 @@ __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16)
|
|||
__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32)
|
||||
__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32)
|
||||
__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32)
|
||||
__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 64)
|
||||
__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
|
||||
__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
|
||||
__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
|
||||
|
|
9
arch/mips/include/asm/suspend.h
Normal file
9
arch/mips/include/asm/suspend.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef __ASM_SUSPEND_H
|
||||
#define __ASM_SUSPEND_H
|
||||
|
||||
static inline int arch_prepare_suspend(void) { return 0; }
|
||||
|
||||
/* References to section boundaries */
|
||||
extern const void __nosave_begin, __nosave_end;
|
||||
|
||||
#endif /* __ASM_SUSPEND_H */
|
51
arch/mips/include/asm/txx9/dmac.h
Normal file
51
arch/mips/include/asm/txx9/dmac.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* TXx9 SoC DMA Controller
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_TXX9_DMAC_H
|
||||
#define __ASM_TXX9_DMAC_H
|
||||
|
||||
#include <linux/dmaengine.h>
|
||||
|
||||
#define TXX9_DMA_MAX_NR_CHANNELS 4
|
||||
|
||||
/**
|
||||
* struct txx9dmac_platform_data - Controller configuration parameters
|
||||
* @memcpy_chan: Channel used for DMA_MEMCPY
|
||||
* @have_64bit_regs: DMAC have 64 bit registers
|
||||
*/
|
||||
struct txx9dmac_platform_data {
|
||||
int memcpy_chan;
|
||||
bool have_64bit_regs;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct txx9dmac_chan_platform_data - Channel configuration parameters
|
||||
* @dmac_dev: A platform device for DMAC
|
||||
*/
|
||||
struct txx9dmac_chan_platform_data {
|
||||
struct platform_device *dmac_dev;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct txx9dmac_slave - Controller-specific information about a slave
|
||||
* @tx_reg: physical address of data register used for
|
||||
* memory-to-peripheral transfers
|
||||
* @rx_reg: physical address of data register used for
|
||||
* peripheral-to-memory transfers
|
||||
* @reg_width: peripheral register width
|
||||
*/
|
||||
struct txx9dmac_slave {
|
||||
u64 tx_reg;
|
||||
u64 rx_reg;
|
||||
unsigned int reg_width;
|
||||
};
|
||||
|
||||
void txx9_dmac_init(int id, unsigned long baseaddr, int irq,
|
||||
const struct txx9dmac_platform_data *pdata);
|
||||
|
||||
#endif /* __ASM_TXX9_DMAC_H */
|
|
@ -91,4 +91,10 @@ void txx9_7segled_init(unsigned int num,
|
|||
void (*putc)(unsigned int pos, unsigned char val));
|
||||
int txx9_7segled_putc(unsigned int pos, char c);
|
||||
|
||||
void __init txx9_aclc_init(unsigned long baseaddr, int irq,
|
||||
unsigned int dmac_id,
|
||||
unsigned int dma_chan_out,
|
||||
unsigned int dma_chan_in);
|
||||
void __init txx9_sramc_init(struct resource *r);
|
||||
|
||||
#endif /* __ASM_TXX9_GENERIC_H */
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#define TX4927_SDRAMC_REG (TX4927_REG_BASE + 0x8000)
|
||||
#define TX4927_EBUSC_REG (TX4927_REG_BASE + 0x9000)
|
||||
#define TX4927_DMA_REG (TX4927_REG_BASE + 0xb000)
|
||||
#define TX4927_PCIC_REG (TX4927_REG_BASE + 0xd000)
|
||||
#define TX4927_CCFG_REG (TX4927_REG_BASE + 0xe000)
|
||||
#define TX4927_IRC_REG (TX4927_REG_BASE + 0xf600)
|
||||
|
@ -49,6 +50,7 @@
|
|||
#define TX4927_NR_SIO 2
|
||||
#define TX4927_SIO_REG(ch) (TX4927_REG_BASE + 0xf300 + (ch) * 0x100)
|
||||
#define TX4927_PIO_REG (TX4927_REG_BASE + 0xf500)
|
||||
#define TX4927_ACLC_REG (TX4927_REG_BASE + 0xf700)
|
||||
|
||||
#define TX4927_IR_ECCERR 0
|
||||
#define TX4927_IR_WTOERR 1
|
||||
|
@ -265,5 +267,7 @@ int tx4927_pciclk66_setup(void);
|
|||
void tx4927_setup_pcierr_irq(void);
|
||||
void tx4927_irq_init(void);
|
||||
void tx4927_mtd_init(int ch);
|
||||
void tx4927_dmac_init(int memcpy_chan);
|
||||
void tx4927_aclc_init(unsigned int dma_chan_out, unsigned int dma_chan_in);
|
||||
|
||||
#endif /* __ASM_TXX9_TX4927_H */
|
||||
|
|
|
@ -305,5 +305,8 @@ struct tx4938ide_platform_info {
|
|||
};
|
||||
|
||||
void tx4938_ata_init(unsigned int irq, unsigned int shift, int tune);
|
||||
void tx4938_dmac_init(int memcpy_chan0, int memcpy_chan1);
|
||||
void tx4938_aclc_init(void);
|
||||
void tx4938_sramc_init(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#define TX4939_RTC_REG (TX4939_REG_BASE + 0xfb00)
|
||||
#define TX4939_CIR_REG (TX4939_REG_BASE + 0xfc00)
|
||||
|
||||
#define TX4939_RNG_REG (TX4939_CRYPTO_REG + 0xb0)
|
||||
|
||||
struct tx4939_le_reg {
|
||||
__u32 r;
|
||||
__u32 unused;
|
||||
|
@ -544,5 +546,9 @@ void tx4939_ata_init(void);
|
|||
void tx4939_rtc_init(void);
|
||||
void tx4939_ndfmc_init(unsigned int hold, unsigned int spw,
|
||||
unsigned char ch_mask, unsigned char wide_mask);
|
||||
void tx4939_dmac_init(int memcpy_chan0, int memcpy_chan1);
|
||||
void tx4939_aclc_init(void);
|
||||
void tx4939_sramc_init(void);
|
||||
void tx4939_rng_init(void);
|
||||
|
||||
#endif /* __ASM_TXX9_TX4939_H */
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <linux/mm.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/kbuild.h>
|
||||
#include <linux/suspend.h>
|
||||
#include <asm/ptrace.h>
|
||||
#include <asm/processor.h>
|
||||
|
||||
|
@ -326,3 +327,15 @@ void output_octeon_cop2_state_defines(void)
|
|||
BLANK();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HIBERNATION
|
||||
void output_pbe_defines(void)
|
||||
{
|
||||
COMMENT(" Linux struct pbe offsets. ");
|
||||
OFFSET(PBE_ADDRESS, pbe, address);
|
||||
OFFSET(PBE_ORIG_ADDRESS, pbe, orig_address);
|
||||
OFFSET(PBE_NEXT, pbe, next);
|
||||
DEFINE(PBE_SIZE, sizeof(struct pbe));
|
||||
BLANK();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -20,22 +20,29 @@
|
|||
#define TIMER_CCD 0 /* 1/2 */
|
||||
#define TIMER_CLK(imclk) ((imclk) / (2 << TIMER_CCD))
|
||||
|
||||
static struct txx9_tmr_reg __iomem *txx9_cs_tmrptr;
|
||||
struct txx9_clocksource {
|
||||
struct clocksource cs;
|
||||
struct txx9_tmr_reg __iomem *tmrptr;
|
||||
};
|
||||
|
||||
static cycle_t txx9_cs_read(struct clocksource *cs)
|
||||
{
|
||||
return __raw_readl(&txx9_cs_tmrptr->trr);
|
||||
struct txx9_clocksource *txx9_cs =
|
||||
container_of(cs, struct txx9_clocksource, cs);
|
||||
return __raw_readl(&txx9_cs->tmrptr->trr);
|
||||
}
|
||||
|
||||
/* Use 1 bit smaller width to use full bits in that width */
|
||||
#define TXX9_CLOCKSOURCE_BITS (TXX9_TIMER_BITS - 1)
|
||||
|
||||
static struct clocksource txx9_clocksource = {
|
||||
.name = "TXx9",
|
||||
.rating = 200,
|
||||
.read = txx9_cs_read,
|
||||
.mask = CLOCKSOURCE_MASK(TXX9_CLOCKSOURCE_BITS),
|
||||
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
|
||||
static struct txx9_clocksource txx9_clocksource = {
|
||||
.cs = {
|
||||
.name = "TXx9",
|
||||
.rating = 200,
|
||||
.read = txx9_cs_read,
|
||||
.mask = CLOCKSOURCE_MASK(TXX9_CLOCKSOURCE_BITS),
|
||||
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
|
||||
},
|
||||
};
|
||||
|
||||
void __init txx9_clocksource_init(unsigned long baseaddr,
|
||||
|
@ -43,8 +50,8 @@ void __init txx9_clocksource_init(unsigned long baseaddr,
|
|||
{
|
||||
struct txx9_tmr_reg __iomem *tmrptr;
|
||||
|
||||
clocksource_set_clock(&txx9_clocksource, TIMER_CLK(imbusclk));
|
||||
clocksource_register(&txx9_clocksource);
|
||||
clocksource_set_clock(&txx9_clocksource.cs, TIMER_CLK(imbusclk));
|
||||
clocksource_register(&txx9_clocksource.cs);
|
||||
|
||||
tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg));
|
||||
__raw_writel(TCR_BASE, &tmrptr->tcr);
|
||||
|
@ -53,10 +60,13 @@ void __init txx9_clocksource_init(unsigned long baseaddr,
|
|||
__raw_writel(TXx9_TMITMR_TZCE, &tmrptr->itmr);
|
||||
__raw_writel(1 << TXX9_CLOCKSOURCE_BITS, &tmrptr->cpra);
|
||||
__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
|
||||
txx9_cs_tmrptr = tmrptr;
|
||||
txx9_clocksource.tmrptr = tmrptr;
|
||||
}
|
||||
|
||||
static struct txx9_tmr_reg __iomem *txx9_tmrptr;
|
||||
struct txx9_clock_event_device {
|
||||
struct clock_event_device cd;
|
||||
struct txx9_tmr_reg __iomem *tmrptr;
|
||||
};
|
||||
|
||||
static void txx9tmr_stop_and_clear(struct txx9_tmr_reg __iomem *tmrptr)
|
||||
{
|
||||
|
@ -69,7 +79,9 @@ static void txx9tmr_stop_and_clear(struct txx9_tmr_reg __iomem *tmrptr)
|
|||
static void txx9tmr_set_mode(enum clock_event_mode mode,
|
||||
struct clock_event_device *evt)
|
||||
{
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_tmrptr;
|
||||
struct txx9_clock_event_device *txx9_cd =
|
||||
container_of(evt, struct txx9_clock_event_device, cd);
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||
|
||||
txx9tmr_stop_and_clear(tmrptr);
|
||||
switch (mode) {
|
||||
|
@ -99,7 +111,9 @@ static void txx9tmr_set_mode(enum clock_event_mode mode,
|
|||
static int txx9tmr_set_next_event(unsigned long delta,
|
||||
struct clock_event_device *evt)
|
||||
{
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_tmrptr;
|
||||
struct txx9_clock_event_device *txx9_cd =
|
||||
container_of(evt, struct txx9_clock_event_device, cd);
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||
|
||||
txx9tmr_stop_and_clear(tmrptr);
|
||||
/* start timer */
|
||||
|
@ -108,18 +122,22 @@ static int txx9tmr_set_next_event(unsigned long delta,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct clock_event_device txx9tmr_clock_event_device = {
|
||||
.name = "TXx9",
|
||||
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
|
||||
.rating = 200,
|
||||
.set_mode = txx9tmr_set_mode,
|
||||
.set_next_event = txx9tmr_set_next_event,
|
||||
static struct txx9_clock_event_device txx9_clock_event_device = {
|
||||
.cd = {
|
||||
.name = "TXx9",
|
||||
.features = CLOCK_EVT_FEAT_PERIODIC |
|
||||
CLOCK_EVT_FEAT_ONESHOT,
|
||||
.rating = 200,
|
||||
.set_mode = txx9tmr_set_mode,
|
||||
.set_next_event = txx9tmr_set_next_event,
|
||||
},
|
||||
};
|
||||
|
||||
static irqreturn_t txx9tmr_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
struct clock_event_device *cd = &txx9tmr_clock_event_device;
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_tmrptr;
|
||||
struct txx9_clock_event_device *txx9_cd = dev_id;
|
||||
struct clock_event_device *cd = &txx9_cd->cd;
|
||||
struct txx9_tmr_reg __iomem *tmrptr = txx9_cd->tmrptr;
|
||||
|
||||
__raw_writel(0, &tmrptr->tisr); /* ack interrupt */
|
||||
cd->event_handler(cd);
|
||||
|
@ -130,19 +148,20 @@ static struct irqaction txx9tmr_irq = {
|
|||
.handler = txx9tmr_interrupt,
|
||||
.flags = IRQF_DISABLED | IRQF_PERCPU,
|
||||
.name = "txx9tmr",
|
||||
.dev_id = &txx9_clock_event_device,
|
||||
};
|
||||
|
||||
void __init txx9_clockevent_init(unsigned long baseaddr, int irq,
|
||||
unsigned int imbusclk)
|
||||
{
|
||||
struct clock_event_device *cd = &txx9tmr_clock_event_device;
|
||||
struct clock_event_device *cd = &txx9_clock_event_device.cd;
|
||||
struct txx9_tmr_reg __iomem *tmrptr;
|
||||
|
||||
tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg));
|
||||
txx9tmr_stop_and_clear(tmrptr);
|
||||
__raw_writel(TIMER_CCD, &tmrptr->ccdr);
|
||||
__raw_writel(0, &tmrptr->itmr);
|
||||
txx9_tmrptr = tmrptr;
|
||||
txx9_clock_event_device.tmrptr = tmrptr;
|
||||
|
||||
clockevent_set_clock(cd, TIMER_CLK(imbusclk));
|
||||
cd->max_delta_ns =
|
||||
|
|
|
@ -924,6 +924,7 @@ void ipi_decode(struct smtc_ipi *pipi)
|
|||
int irq = MIPS_CPU_IRQ_BASE + 1;
|
||||
|
||||
smtc_ipi_nq(&freeIPIq, pipi);
|
||||
|
||||
switch (type_copy) {
|
||||
case SMTC_CLOCK_TICK:
|
||||
irq_enter();
|
||||
|
|
|
@ -1502,7 +1502,7 @@ void __cpuinit per_cpu_trap_init(void)
|
|||
status_set);
|
||||
|
||||
if (cpu_has_mips_r2) {
|
||||
unsigned int enable = 0x0000000f;
|
||||
unsigned int enable = 0x0000000f | cpu_hwrena_impl_bits;
|
||||
|
||||
if (!noulri && cpu_has_userlocal)
|
||||
enable |= (1 << 29);
|
||||
|
@ -1510,10 +1510,6 @@ void __cpuinit per_cpu_trap_init(void)
|
|||
write_c0_hwrena(enable);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CPU_CAVIUM_OCTEON
|
||||
write_c0_hwrena(0xc000000f); /* Octeon has register 30 and 31 */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_MIPS_MT_SMTC
|
||||
if (!secondaryTC) {
|
||||
#endif /* CONFIG_MIPS_MT_SMTC */
|
||||
|
|
|
@ -43,7 +43,7 @@ void __udelay(unsigned long us)
|
|||
{
|
||||
unsigned int lpj = current_cpu_data.udelay_val;
|
||||
|
||||
__delay((us * 0x000010c7 * HZ * lpj) >> 32);
|
||||
__delay((us * 0x000010c7ull * HZ * lpj) >> 32);
|
||||
}
|
||||
EXPORT_SYMBOL(__udelay);
|
||||
|
||||
|
@ -51,6 +51,6 @@ void __ndelay(unsigned long ns)
|
|||
{
|
||||
unsigned int lpj = current_cpu_data.udelay_val;
|
||||
|
||||
__delay((us * 0x00000005 * HZ * lpj) >> 32);
|
||||
__delay((ns * 0x00000005ull * HZ * lpj) >> 32);
|
||||
}
|
||||
EXPORT_SYMBOL(__ndelay);
|
||||
|
|
|
@ -8,6 +8,7 @@ obj-y += cache.o dma-default.o extable.o fault.o \
|
|||
obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o
|
||||
obj-$(CONFIG_64BIT) += pgtable-64.o
|
||||
obj-$(CONFIG_HIGHMEM) += highmem.o
|
||||
obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
|
||||
|
||||
obj-$(CONFIG_CPU_LOONGSON2) += c-r4k.o cex-gen.o tlb-r4k.o
|
||||
obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o tlb-r4k.o
|
||||
|
|
|
@ -100,6 +100,12 @@ static inline void r4k_blast_dcache_page_dc32(unsigned long addr)
|
|||
blast_dcache32_page(addr);
|
||||
}
|
||||
|
||||
static inline void r4k_blast_dcache_page_dc64(unsigned long addr)
|
||||
{
|
||||
R4600_HIT_CACHEOP_WAR_IMPL;
|
||||
blast_dcache64_page(addr);
|
||||
}
|
||||
|
||||
static void __cpuinit r4k_blast_dcache_page_setup(void)
|
||||
{
|
||||
unsigned long dc_lsize = cpu_dcache_line_size();
|
||||
|
@ -110,6 +116,8 @@ static void __cpuinit r4k_blast_dcache_page_setup(void)
|
|||
r4k_blast_dcache_page = blast_dcache16_page;
|
||||
else if (dc_lsize == 32)
|
||||
r4k_blast_dcache_page = r4k_blast_dcache_page_dc32;
|
||||
else if (dc_lsize == 64)
|
||||
r4k_blast_dcache_page = r4k_blast_dcache_page_dc64;
|
||||
}
|
||||
|
||||
static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
|
||||
|
@ -124,6 +132,8 @@ static void __cpuinit r4k_blast_dcache_page_indexed_setup(void)
|
|||
r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed;
|
||||
else if (dc_lsize == 32)
|
||||
r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed;
|
||||
else if (dc_lsize == 64)
|
||||
r4k_blast_dcache_page_indexed = blast_dcache64_page_indexed;
|
||||
}
|
||||
|
||||
static void (* r4k_blast_dcache)(void);
|
||||
|
@ -138,6 +148,8 @@ static void __cpuinit r4k_blast_dcache_setup(void)
|
|||
r4k_blast_dcache = blast_dcache16;
|
||||
else if (dc_lsize == 32)
|
||||
r4k_blast_dcache = blast_dcache32;
|
||||
else if (dc_lsize == 64)
|
||||
r4k_blast_dcache = blast_dcache64;
|
||||
}
|
||||
|
||||
/* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */
|
||||
|
|
|
@ -20,9 +20,10 @@
|
|||
|
||||
#include <dma-coherence.h>
|
||||
|
||||
static inline unsigned long dma_addr_to_virt(dma_addr_t dma_addr)
|
||||
static inline unsigned long dma_addr_to_virt(struct device *dev,
|
||||
dma_addr_t dma_addr)
|
||||
{
|
||||
unsigned long addr = plat_dma_addr_to_phys(dma_addr);
|
||||
unsigned long addr = plat_dma_addr_to_phys(dev, dma_addr);
|
||||
|
||||
return (unsigned long)phys_to_virt(addr);
|
||||
}
|
||||
|
@ -111,7 +112,7 @@ EXPORT_SYMBOL(dma_alloc_coherent);
|
|||
void dma_free_noncoherent(struct device *dev, size_t size, void *vaddr,
|
||||
dma_addr_t dma_handle)
|
||||
{
|
||||
plat_unmap_dma_mem(dev, dma_handle);
|
||||
plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
|
||||
free_pages((unsigned long) vaddr, get_order(size));
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
|
|||
{
|
||||
unsigned long addr = (unsigned long) vaddr;
|
||||
|
||||
plat_unmap_dma_mem(dev, dma_handle);
|
||||
plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
|
||||
|
||||
if (!plat_device_is_coherent(dev))
|
||||
addr = CAC_ADDR(addr);
|
||||
|
@ -170,10 +171,10 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
|
|||
enum dma_data_direction direction)
|
||||
{
|
||||
if (cpu_is_noncoherent_r10000(dev))
|
||||
__dma_sync(dma_addr_to_virt(dma_addr), size,
|
||||
__dma_sync(dma_addr_to_virt(dev, dma_addr), size,
|
||||
direction);
|
||||
|
||||
plat_unmap_dma_mem(dev, dma_addr);
|
||||
plat_unmap_dma_mem(dev, dma_addr, size, direction);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dma_unmap_single);
|
||||
|
@ -232,7 +233,7 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
|
|||
if (addr)
|
||||
__dma_sync(addr, sg->length, direction);
|
||||
}
|
||||
plat_unmap_dma_mem(dev, sg->dma_address);
|
||||
plat_unmap_dma_mem(dev, sg->dma_address, sg->length, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +247,7 @@ void dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
|
|||
if (cpu_is_noncoherent_r10000(dev)) {
|
||||
unsigned long addr;
|
||||
|
||||
addr = dma_addr_to_virt(dma_handle);
|
||||
addr = dma_addr_to_virt(dev, dma_handle);
|
||||
__dma_sync(addr, size, direction);
|
||||
}
|
||||
}
|
||||
|
@ -262,7 +263,7 @@ void dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
|
|||
if (!plat_device_is_coherent(dev)) {
|
||||
unsigned long addr;
|
||||
|
||||
addr = dma_addr_to_virt(dma_handle);
|
||||
addr = dma_addr_to_virt(dev, dma_handle);
|
||||
__dma_sync(addr, size, direction);
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +278,7 @@ void dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
|
|||
if (cpu_is_noncoherent_r10000(dev)) {
|
||||
unsigned long addr;
|
||||
|
||||
addr = dma_addr_to_virt(dma_handle);
|
||||
addr = dma_addr_to_virt(dev, dma_handle);
|
||||
__dma_sync(addr + offset, size, direction);
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +294,7 @@ void dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
|
|||
if (!plat_device_is_coherent(dev)) {
|
||||
unsigned long addr;
|
||||
|
||||
addr = dma_addr_to_virt(dma_handle);
|
||||
addr = dma_addr_to_virt(dev, dma_handle);
|
||||
__dma_sync(addr + offset, size, direction);
|
||||
}
|
||||
}
|
||||
|
|
101
arch/mips/mm/hugetlbpage.c
Normal file
101
arch/mips/mm/hugetlbpage.c
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* MIPS Huge TLB Page Support for Kernel.
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2002, Rohit Seth <rohit.seth@intel.com>
|
||||
* Copyright 2005, Embedded Alley Solutions, Inc.
|
||||
* Matt Porter <mporter@embeddedalley.com>
|
||||
* Copyright (C) 2008, 2009 Cavium Networks, Inc.
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/hugetlb.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/smp_lock.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <asm/mman.h>
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/tlbflush.h>
|
||||
|
||||
pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr,
|
||||
unsigned long sz)
|
||||
{
|
||||
pgd_t *pgd;
|
||||
pud_t *pud;
|
||||
pte_t *pte = NULL;
|
||||
|
||||
pgd = pgd_offset(mm, addr);
|
||||
pud = pud_alloc(mm, pgd, addr);
|
||||
if (pud)
|
||||
pte = (pte_t *)pmd_alloc(mm, pud, addr);
|
||||
|
||||
return pte;
|
||||
}
|
||||
|
||||
pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
|
||||
{
|
||||
pgd_t *pgd;
|
||||
pud_t *pud;
|
||||
pmd_t *pmd = NULL;
|
||||
|
||||
pgd = pgd_offset(mm, addr);
|
||||
if (pgd_present(*pgd)) {
|
||||
pud = pud_offset(pgd, addr);
|
||||
if (pud_present(*pud))
|
||||
pmd = pmd_offset(pud, addr);
|
||||
}
|
||||
return (pte_t *) pmd;
|
||||
}
|
||||
|
||||
int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function checks for proper alignment of input addr and len parameters.
|
||||
*/
|
||||
int is_aligned_hugepage_range(unsigned long addr, unsigned long len)
|
||||
{
|
||||
if (len & ~HPAGE_MASK)
|
||||
return -EINVAL;
|
||||
if (addr & ~HPAGE_MASK)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct page *
|
||||
follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
|
||||
{
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
int pmd_huge(pmd_t pmd)
|
||||
{
|
||||
return (pmd_val(pmd) & _PAGE_HUGE) != 0;
|
||||
}
|
||||
|
||||
int pud_huge(pud_t pud)
|
||||
{
|
||||
return (pud_val(pud) & _PAGE_HUGE) != 0;
|
||||
}
|
||||
|
||||
struct page *
|
||||
follow_huge_pmd(struct mm_struct *mm, unsigned long address,
|
||||
pmd_t *pmd, int write)
|
||||
{
|
||||
struct page *page;
|
||||
|
||||
page = pte_page(*(pte_t *)pmd);
|
||||
if (page)
|
||||
page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT);
|
||||
return page;
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/hugetlb.h>
|
||||
|
||||
#include <asm/cpu.h>
|
||||
#include <asm/bootinfo.h>
|
||||
|
@ -295,21 +296,41 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
|
|||
pudp = pud_offset(pgdp, address);
|
||||
pmdp = pmd_offset(pudp, address);
|
||||
idx = read_c0_index();
|
||||
ptep = pte_offset_map(pmdp, address);
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
/* this could be a huge page */
|
||||
if (pmd_huge(*pmdp)) {
|
||||
unsigned long lo;
|
||||
write_c0_pagemask(PM_HUGE_MASK);
|
||||
ptep = (pte_t *)pmdp;
|
||||
lo = pte_val(*ptep) >> 6;
|
||||
write_c0_entrylo0(lo);
|
||||
write_c0_entrylo1(lo + (HPAGE_SIZE >> 7));
|
||||
|
||||
mtc0_tlbw_hazard();
|
||||
if (idx < 0)
|
||||
tlb_write_random();
|
||||
else
|
||||
tlb_write_indexed();
|
||||
write_c0_pagemask(PM_DEFAULT_MASK);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ptep = pte_offset_map(pmdp, address);
|
||||
|
||||
#if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
|
||||
write_c0_entrylo0(ptep->pte_high);
|
||||
ptep++;
|
||||
write_c0_entrylo1(ptep->pte_high);
|
||||
write_c0_entrylo0(ptep->pte_high);
|
||||
ptep++;
|
||||
write_c0_entrylo1(ptep->pte_high);
|
||||
#else
|
||||
write_c0_entrylo0(pte_val(*ptep++) >> 6);
|
||||
write_c0_entrylo1(pte_val(*ptep) >> 6);
|
||||
write_c0_entrylo0(pte_val(*ptep++) >> 6);
|
||||
write_c0_entrylo1(pte_val(*ptep) >> 6);
|
||||
#endif
|
||||
mtc0_tlbw_hazard();
|
||||
if (idx < 0)
|
||||
tlb_write_random();
|
||||
else
|
||||
tlb_write_indexed();
|
||||
mtc0_tlbw_hazard();
|
||||
if (idx < 0)
|
||||
tlb_write_random();
|
||||
else
|
||||
tlb_write_indexed();
|
||||
}
|
||||
tlbw_use_hazard();
|
||||
FLUSH_ITLB_VM(vma);
|
||||
EXIT_CRITICAL(flags);
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
* Synthesize TLB refill handlers at runtime.
|
||||
*
|
||||
* Copyright (C) 2004, 2005, 2006, 2008 Thiemo Seufer
|
||||
* Copyright (C) 2005, 2007 Maciej W. Rozycki
|
||||
* Copyright (C) 2005, 2007, 2008, 2009 Maciej W. Rozycki
|
||||
* Copyright (C) 2006 Ralf Baechle (ralf@linux-mips.org)
|
||||
* Copyright (C) 2008, 2009 Cavium Networks, Inc.
|
||||
*
|
||||
* ... and the days got worse and worse and now you see
|
||||
* I've gone completly out of my mind.
|
||||
|
@ -19,6 +20,7 @@
|
|||
* (Condolences to Napoleon XIV)
|
||||
*/
|
||||
|
||||
#include <linux/bug.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/string.h>
|
||||
|
@ -82,6 +84,9 @@ enum label_id {
|
|||
label_nopage_tlbm,
|
||||
label_smp_pgtable_change,
|
||||
label_r3000_write_probe_fail,
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
label_tlb_huge_update,
|
||||
#endif
|
||||
};
|
||||
|
||||
UASM_L_LA(_second_part)
|
||||
|
@ -98,6 +103,9 @@ UASM_L_LA(_nopage_tlbs)
|
|||
UASM_L_LA(_nopage_tlbm)
|
||||
UASM_L_LA(_smp_pgtable_change)
|
||||
UASM_L_LA(_r3000_write_probe_fail)
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
UASM_L_LA(_tlb_huge_update)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* For debug purposes.
|
||||
|
@ -125,6 +133,7 @@ static inline void dump_handler(const u32 *handler, int count)
|
|||
#define C0_TCBIND 2, 2
|
||||
#define C0_ENTRYLO1 3, 0
|
||||
#define C0_CONTEXT 4, 0
|
||||
#define C0_PAGEMASK 5, 0
|
||||
#define C0_BADVADDR 8, 0
|
||||
#define C0_ENTRYHI 10, 0
|
||||
#define C0_EPC 14, 0
|
||||
|
@ -258,7 +267,8 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
|
|||
}
|
||||
|
||||
if (cpu_has_mips_r2) {
|
||||
uasm_i_ehb(p);
|
||||
if (cpu_has_mips_r2_exec_hazard)
|
||||
uasm_i_ehb(p);
|
||||
tlbw(p);
|
||||
return;
|
||||
}
|
||||
|
@ -310,7 +320,6 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
|
|||
case CPU_BCM3302:
|
||||
case CPU_BCM4710:
|
||||
case CPU_LOONGSON2:
|
||||
case CPU_CAVIUM_OCTEON:
|
||||
case CPU_R5500:
|
||||
if (m4kc_tlbp_war())
|
||||
uasm_i_nop(p);
|
||||
|
@ -382,6 +391,98 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
static __cpuinit void build_huge_tlb_write_entry(u32 **p,
|
||||
struct uasm_label **l,
|
||||
struct uasm_reloc **r,
|
||||
unsigned int tmp,
|
||||
enum tlb_write_entry wmode)
|
||||
{
|
||||
/* Set huge page tlb entry size */
|
||||
uasm_i_lui(p, tmp, PM_HUGE_MASK >> 16);
|
||||
uasm_i_ori(p, tmp, tmp, PM_HUGE_MASK & 0xffff);
|
||||
uasm_i_mtc0(p, tmp, C0_PAGEMASK);
|
||||
|
||||
build_tlb_write_entry(p, l, r, wmode);
|
||||
|
||||
/* Reset default page size */
|
||||
if (PM_DEFAULT_MASK >> 16) {
|
||||
uasm_i_lui(p, tmp, PM_DEFAULT_MASK >> 16);
|
||||
uasm_i_ori(p, tmp, tmp, PM_DEFAULT_MASK & 0xffff);
|
||||
uasm_il_b(p, r, label_leave);
|
||||
uasm_i_mtc0(p, tmp, C0_PAGEMASK);
|
||||
} else if (PM_DEFAULT_MASK) {
|
||||
uasm_i_ori(p, tmp, 0, PM_DEFAULT_MASK);
|
||||
uasm_il_b(p, r, label_leave);
|
||||
uasm_i_mtc0(p, tmp, C0_PAGEMASK);
|
||||
} else {
|
||||
uasm_il_b(p, r, label_leave);
|
||||
uasm_i_mtc0(p, 0, C0_PAGEMASK);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if Huge PTE is present, if so then jump to LABEL.
|
||||
*/
|
||||
static void __cpuinit
|
||||
build_is_huge_pte(u32 **p, struct uasm_reloc **r, unsigned int tmp,
|
||||
unsigned int pmd, int lid)
|
||||
{
|
||||
UASM_i_LW(p, tmp, 0, pmd);
|
||||
uasm_i_andi(p, tmp, tmp, _PAGE_HUGE);
|
||||
uasm_il_bnez(p, r, tmp, lid);
|
||||
}
|
||||
|
||||
static __cpuinit void build_huge_update_entries(u32 **p,
|
||||
unsigned int pte,
|
||||
unsigned int tmp)
|
||||
{
|
||||
int small_sequence;
|
||||
|
||||
/*
|
||||
* A huge PTE describes an area the size of the
|
||||
* configured huge page size. This is twice the
|
||||
* of the large TLB entry size we intend to use.
|
||||
* A TLB entry half the size of the configured
|
||||
* huge page size is configured into entrylo0
|
||||
* and entrylo1 to cover the contiguous huge PTE
|
||||
* address space.
|
||||
*/
|
||||
small_sequence = (HPAGE_SIZE >> 7) < 0x10000;
|
||||
|
||||
/* We can clobber tmp. It isn't used after this.*/
|
||||
if (!small_sequence)
|
||||
uasm_i_lui(p, tmp, HPAGE_SIZE >> (7 + 16));
|
||||
|
||||
UASM_i_SRL(p, pte, pte, 6); /* convert to entrylo */
|
||||
uasm_i_mtc0(p, pte, C0_ENTRYLO0); /* load it */
|
||||
/* convert to entrylo1 */
|
||||
if (small_sequence)
|
||||
UASM_i_ADDIU(p, pte, pte, HPAGE_SIZE >> 7);
|
||||
else
|
||||
UASM_i_ADDU(p, pte, pte, tmp);
|
||||
|
||||
uasm_i_mtc0(p, pte, C0_ENTRYLO1); /* load it */
|
||||
}
|
||||
|
||||
static __cpuinit void build_huge_handler_tail(u32 **p,
|
||||
struct uasm_reloc **r,
|
||||
struct uasm_label **l,
|
||||
unsigned int pte,
|
||||
unsigned int ptr)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
UASM_i_SC(p, pte, 0, ptr);
|
||||
uasm_il_beqz(p, r, pte, label_tlb_huge_update);
|
||||
UASM_i_LW(p, pte, 0, ptr); /* Needed because SC killed our PTE */
|
||||
#else
|
||||
UASM_i_SW(p, pte, 0, ptr);
|
||||
#endif
|
||||
build_huge_update_entries(p, pte, ptr);
|
||||
build_huge_tlb_write_entry(p, l, r, pte, tlb_indexed);
|
||||
}
|
||||
#endif /* CONFIG_HUGETLB_PAGE */
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
/*
|
||||
* TMP and PTR are scratch.
|
||||
|
@ -649,6 +750,14 @@ static void __cpuinit build_update_entries(u32 **p, unsigned int tmp,
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* For a 64-bit kernel, we are using the 64-bit XTLB refill exception
|
||||
* because EXL == 0. If we wrap, we can also use the 32 instruction
|
||||
* slots before the XTLB refill exception handler which belong to the
|
||||
* unused TLB refill exception.
|
||||
*/
|
||||
#define MIPS64_REFILL_INSNS 32
|
||||
|
||||
static void __cpuinit build_r4000_tlb_refill_handler(void)
|
||||
{
|
||||
u32 *p = tlb_handler;
|
||||
|
@ -680,12 +789,23 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
|
|||
build_get_pgde32(&p, K0, K1); /* get pgd in K1 */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
build_is_huge_pte(&p, &r, K0, K1, label_tlb_huge_update);
|
||||
#endif
|
||||
|
||||
build_get_ptep(&p, K0, K1);
|
||||
build_update_entries(&p, K0, K1);
|
||||
build_tlb_write_entry(&p, &l, &r, tlb_random);
|
||||
uasm_l_leave(&l, p);
|
||||
uasm_i_eret(&p); /* return from trap */
|
||||
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
uasm_l_tlb_huge_update(&l, p);
|
||||
UASM_i_LW(&p, K0, 0, K1);
|
||||
build_huge_update_entries(&p, K0, K1);
|
||||
build_huge_tlb_write_entry(&p, &l, &r, K0, tlb_random);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
build_get_pgd_vmalloc64(&p, &l, &r, K0, K1);
|
||||
#endif
|
||||
|
@ -702,9 +822,10 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
|
|||
if ((p - tlb_handler) > 64)
|
||||
panic("TLB refill handler space exceeded");
|
||||
#else
|
||||
if (((p - tlb_handler) > 63)
|
||||
|| (((p - tlb_handler) > 61)
|
||||
&& uasm_insn_has_bdelay(relocs, tlb_handler + 29)))
|
||||
if (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 1)
|
||||
|| (((p - tlb_handler) > (MIPS64_REFILL_INSNS * 2) - 3)
|
||||
&& uasm_insn_has_bdelay(relocs,
|
||||
tlb_handler + MIPS64_REFILL_INSNS - 3)))
|
||||
panic("TLB refill handler space exceeded");
|
||||
#endif
|
||||
|
||||
|
@ -717,39 +838,74 @@ static void __cpuinit build_r4000_tlb_refill_handler(void)
|
|||
uasm_copy_handler(relocs, labels, tlb_handler, p, f);
|
||||
final_len = p - tlb_handler;
|
||||
#else /* CONFIG_64BIT */
|
||||
f = final_handler + 32;
|
||||
if ((p - tlb_handler) <= 32) {
|
||||
f = final_handler + MIPS64_REFILL_INSNS;
|
||||
if ((p - tlb_handler) <= MIPS64_REFILL_INSNS) {
|
||||
/* Just copy the handler. */
|
||||
uasm_copy_handler(relocs, labels, tlb_handler, p, f);
|
||||
final_len = p - tlb_handler;
|
||||
} else {
|
||||
u32 *split = tlb_handler + 30;
|
||||
#if defined(CONFIG_HUGETLB_PAGE)
|
||||
const enum label_id ls = label_tlb_huge_update;
|
||||
#elif defined(MODULE_START)
|
||||
const enum label_id ls = label_module_alloc;
|
||||
#else
|
||||
const enum label_id ls = label_vmalloc;
|
||||
#endif
|
||||
u32 *split;
|
||||
int ov = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(labels) && labels[i].lab != ls; i++)
|
||||
;
|
||||
BUG_ON(i == ARRAY_SIZE(labels));
|
||||
split = labels[i].addr;
|
||||
|
||||
/*
|
||||
* Find the split point.
|
||||
* See if we have overflown one way or the other.
|
||||
*/
|
||||
if (uasm_insn_has_bdelay(relocs, split - 1))
|
||||
split--;
|
||||
if (split > tlb_handler + MIPS64_REFILL_INSNS ||
|
||||
split < p - MIPS64_REFILL_INSNS)
|
||||
ov = 1;
|
||||
|
||||
if (ov) {
|
||||
/*
|
||||
* Split two instructions before the end. One
|
||||
* for the branch and one for the instruction
|
||||
* in the delay slot.
|
||||
*/
|
||||
split = tlb_handler + MIPS64_REFILL_INSNS - 2;
|
||||
|
||||
/*
|
||||
* If the branch would fall in a delay slot,
|
||||
* we must back up an additional instruction
|
||||
* so that it is no longer in a delay slot.
|
||||
*/
|
||||
if (uasm_insn_has_bdelay(relocs, split - 1))
|
||||
split--;
|
||||
}
|
||||
/* Copy first part of the handler. */
|
||||
uasm_copy_handler(relocs, labels, tlb_handler, split, f);
|
||||
f += split - tlb_handler;
|
||||
|
||||
/* Insert branch. */
|
||||
uasm_l_split(&l, final_handler);
|
||||
uasm_il_b(&f, &r, label_split);
|
||||
if (uasm_insn_has_bdelay(relocs, split))
|
||||
uasm_i_nop(&f);
|
||||
else {
|
||||
uasm_copy_handler(relocs, labels, split, split + 1, f);
|
||||
uasm_move_labels(labels, f, f + 1, -1);
|
||||
f++;
|
||||
split++;
|
||||
if (ov) {
|
||||
/* Insert branch. */
|
||||
uasm_l_split(&l, final_handler);
|
||||
uasm_il_b(&f, &r, label_split);
|
||||
if (uasm_insn_has_bdelay(relocs, split))
|
||||
uasm_i_nop(&f);
|
||||
else {
|
||||
uasm_copy_handler(relocs, labels,
|
||||
split, split + 1, f);
|
||||
uasm_move_labels(labels, f, f + 1, -1);
|
||||
f++;
|
||||
split++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy the rest of the handler. */
|
||||
uasm_copy_handler(relocs, labels, split, p, final_handler);
|
||||
final_len = (f - (final_handler + 32)) + (p - split);
|
||||
final_len = (f - (final_handler + MIPS64_REFILL_INSNS)) +
|
||||
(p - split);
|
||||
}
|
||||
#endif /* CONFIG_64BIT */
|
||||
|
||||
|
@ -782,7 +938,7 @@ u32 handle_tlbs[FASTPATH_SIZE] __cacheline_aligned;
|
|||
u32 handle_tlbm[FASTPATH_SIZE] __cacheline_aligned;
|
||||
|
||||
static void __cpuinit
|
||||
iPTE_LW(u32 **p, struct uasm_label **l, unsigned int pte, unsigned int ptr)
|
||||
iPTE_LW(u32 **p, unsigned int pte, unsigned int ptr)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
# ifdef CONFIG_64BIT_PHYS_ADDR
|
||||
|
@ -862,13 +1018,13 @@ iPTE_SW(u32 **p, struct uasm_reloc **r, unsigned int pte, unsigned int ptr,
|
|||
* with it's original value.
|
||||
*/
|
||||
static void __cpuinit
|
||||
build_pte_present(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
|
||||
build_pte_present(u32 **p, struct uasm_reloc **r,
|
||||
unsigned int pte, unsigned int ptr, enum label_id lid)
|
||||
{
|
||||
uasm_i_andi(p, pte, pte, _PAGE_PRESENT | _PAGE_READ);
|
||||
uasm_i_xori(p, pte, pte, _PAGE_PRESENT | _PAGE_READ);
|
||||
uasm_il_bnez(p, r, pte, lid);
|
||||
iPTE_LW(p, l, pte, ptr);
|
||||
iPTE_LW(p, pte, ptr);
|
||||
}
|
||||
|
||||
/* Make PTE valid, store result in PTR. */
|
||||
|
@ -886,13 +1042,13 @@ build_make_valid(u32 **p, struct uasm_reloc **r, unsigned int pte,
|
|||
* restore PTE with value from PTR when done.
|
||||
*/
|
||||
static void __cpuinit
|
||||
build_pte_writable(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
|
||||
build_pte_writable(u32 **p, struct uasm_reloc **r,
|
||||
unsigned int pte, unsigned int ptr, enum label_id lid)
|
||||
{
|
||||
uasm_i_andi(p, pte, pte, _PAGE_PRESENT | _PAGE_WRITE);
|
||||
uasm_i_xori(p, pte, pte, _PAGE_PRESENT | _PAGE_WRITE);
|
||||
uasm_il_bnez(p, r, pte, lid);
|
||||
iPTE_LW(p, l, pte, ptr);
|
||||
iPTE_LW(p, pte, ptr);
|
||||
}
|
||||
|
||||
/* Make PTE writable, update software status bits as well, then store
|
||||
|
@ -913,12 +1069,12 @@ build_make_write(u32 **p, struct uasm_reloc **r, unsigned int pte,
|
|||
* restore PTE with value from PTR when done.
|
||||
*/
|
||||
static void __cpuinit
|
||||
build_pte_modifiable(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
|
||||
build_pte_modifiable(u32 **p, struct uasm_reloc **r,
|
||||
unsigned int pte, unsigned int ptr, enum label_id lid)
|
||||
{
|
||||
uasm_i_andi(p, pte, pte, _PAGE_WRITE);
|
||||
uasm_il_beqz(p, r, pte, lid);
|
||||
iPTE_LW(p, l, pte, ptr);
|
||||
iPTE_LW(p, pte, ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -994,7 +1150,7 @@ static void __cpuinit build_r3000_tlb_load_handler(void)
|
|||
memset(relocs, 0, sizeof(relocs));
|
||||
|
||||
build_r3000_tlbchange_handler_head(&p, K0, K1);
|
||||
build_pte_present(&p, &l, &r, K0, K1, label_nopage_tlbl);
|
||||
build_pte_present(&p, &r, K0, K1, label_nopage_tlbl);
|
||||
uasm_i_nop(&p); /* load delay */
|
||||
build_make_valid(&p, &r, K0, K1);
|
||||
build_r3000_tlb_reload_write(&p, &l, &r, K0, K1);
|
||||
|
@ -1024,7 +1180,7 @@ static void __cpuinit build_r3000_tlb_store_handler(void)
|
|||
memset(relocs, 0, sizeof(relocs));
|
||||
|
||||
build_r3000_tlbchange_handler_head(&p, K0, K1);
|
||||
build_pte_writable(&p, &l, &r, K0, K1, label_nopage_tlbs);
|
||||
build_pte_writable(&p, &r, K0, K1, label_nopage_tlbs);
|
||||
uasm_i_nop(&p); /* load delay */
|
||||
build_make_write(&p, &r, K0, K1);
|
||||
build_r3000_tlb_reload_write(&p, &l, &r, K0, K1);
|
||||
|
@ -1054,7 +1210,7 @@ static void __cpuinit build_r3000_tlb_modify_handler(void)
|
|||
memset(relocs, 0, sizeof(relocs));
|
||||
|
||||
build_r3000_tlbchange_handler_head(&p, K0, K1);
|
||||
build_pte_modifiable(&p, &l, &r, K0, K1, label_nopage_tlbm);
|
||||
build_pte_modifiable(&p, &r, K0, K1, label_nopage_tlbm);
|
||||
uasm_i_nop(&p); /* load delay */
|
||||
build_make_write(&p, &r, K0, K1);
|
||||
build_r3000_pte_reload_tlbwi(&p, K0, K1);
|
||||
|
@ -1087,6 +1243,15 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
|
|||
build_get_pgde32(p, pte, ptr); /* get pgd in ptr */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
/*
|
||||
* For huge tlb entries, pmd doesn't contain an address but
|
||||
* instead contains the tlb pte. Check the PAGE_HUGE bit and
|
||||
* see if we need to jump to huge tlb processing.
|
||||
*/
|
||||
build_is_huge_pte(p, r, pte, ptr, label_tlb_huge_update);
|
||||
#endif
|
||||
|
||||
UASM_i_MFC0(p, pte, C0_BADVADDR);
|
||||
UASM_i_LW(p, ptr, 0, ptr);
|
||||
UASM_i_SRL(p, pte, pte, PAGE_SHIFT + PTE_ORDER - PTE_T_LOG2);
|
||||
|
@ -1096,7 +1261,7 @@ build_r4000_tlbchange_handler_head(u32 **p, struct uasm_label **l,
|
|||
#ifdef CONFIG_SMP
|
||||
uasm_l_smp_pgtable_change(l, *p);
|
||||
#endif
|
||||
iPTE_LW(p, l, pte, ptr); /* get even pte */
|
||||
iPTE_LW(p, pte, ptr); /* get even pte */
|
||||
if (!m4kc_tlbp_war())
|
||||
build_tlb_probe_entry(p);
|
||||
}
|
||||
|
@ -1138,12 +1303,25 @@ static void __cpuinit build_r4000_tlb_load_handler(void)
|
|||
}
|
||||
|
||||
build_r4000_tlbchange_handler_head(&p, &l, &r, K0, K1);
|
||||
build_pte_present(&p, &l, &r, K0, K1, label_nopage_tlbl);
|
||||
build_pte_present(&p, &r, K0, K1, label_nopage_tlbl);
|
||||
if (m4kc_tlbp_war())
|
||||
build_tlb_probe_entry(&p);
|
||||
build_make_valid(&p, &r, K0, K1);
|
||||
build_r4000_tlbchange_handler_tail(&p, &l, &r, K0, K1);
|
||||
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
/*
|
||||
* This is the entry point when build_r4000_tlbchange_handler_head
|
||||
* spots a huge page.
|
||||
*/
|
||||
uasm_l_tlb_huge_update(&l, p);
|
||||
iPTE_LW(&p, K0, K1);
|
||||
build_pte_present(&p, &r, K0, K1, label_nopage_tlbl);
|
||||
build_tlb_probe_entry(&p);
|
||||
uasm_i_ori(&p, K0, K0, (_PAGE_ACCESSED | _PAGE_VALID));
|
||||
build_huge_handler_tail(&p, &r, &l, K0, K1);
|
||||
#endif
|
||||
|
||||
uasm_l_nopage_tlbl(&l, p);
|
||||
uasm_i_j(&p, (unsigned long)tlb_do_page_fault_0 & 0x0fffffff);
|
||||
uasm_i_nop(&p);
|
||||
|
@ -1169,12 +1347,26 @@ static void __cpuinit build_r4000_tlb_store_handler(void)
|
|||
memset(relocs, 0, sizeof(relocs));
|
||||
|
||||
build_r4000_tlbchange_handler_head(&p, &l, &r, K0, K1);
|
||||
build_pte_writable(&p, &l, &r, K0, K1, label_nopage_tlbs);
|
||||
build_pte_writable(&p, &r, K0, K1, label_nopage_tlbs);
|
||||
if (m4kc_tlbp_war())
|
||||
build_tlb_probe_entry(&p);
|
||||
build_make_write(&p, &r, K0, K1);
|
||||
build_r4000_tlbchange_handler_tail(&p, &l, &r, K0, K1);
|
||||
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
/*
|
||||
* This is the entry point when
|
||||
* build_r4000_tlbchange_handler_head spots a huge page.
|
||||
*/
|
||||
uasm_l_tlb_huge_update(&l, p);
|
||||
iPTE_LW(&p, K0, K1);
|
||||
build_pte_writable(&p, &r, K0, K1, label_nopage_tlbs);
|
||||
build_tlb_probe_entry(&p);
|
||||
uasm_i_ori(&p, K0, K0,
|
||||
_PAGE_ACCESSED | _PAGE_MODIFIED | _PAGE_VALID | _PAGE_DIRTY);
|
||||
build_huge_handler_tail(&p, &r, &l, K0, K1);
|
||||
#endif
|
||||
|
||||
uasm_l_nopage_tlbs(&l, p);
|
||||
uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff);
|
||||
uasm_i_nop(&p);
|
||||
|
@ -1200,13 +1392,27 @@ static void __cpuinit build_r4000_tlb_modify_handler(void)
|
|||
memset(relocs, 0, sizeof(relocs));
|
||||
|
||||
build_r4000_tlbchange_handler_head(&p, &l, &r, K0, K1);
|
||||
build_pte_modifiable(&p, &l, &r, K0, K1, label_nopage_tlbm);
|
||||
build_pte_modifiable(&p, &r, K0, K1, label_nopage_tlbm);
|
||||
if (m4kc_tlbp_war())
|
||||
build_tlb_probe_entry(&p);
|
||||
/* Present and writable bits set, set accessed and dirty bits. */
|
||||
build_make_write(&p, &r, K0, K1);
|
||||
build_r4000_tlbchange_handler_tail(&p, &l, &r, K0, K1);
|
||||
|
||||
#ifdef CONFIG_HUGETLB_PAGE
|
||||
/*
|
||||
* This is the entry point when
|
||||
* build_r4000_tlbchange_handler_head spots a huge page.
|
||||
*/
|
||||
uasm_l_tlb_huge_update(&l, p);
|
||||
iPTE_LW(&p, K0, K1);
|
||||
build_pte_modifiable(&p, &r, K0, K1, label_nopage_tlbm);
|
||||
build_tlb_probe_entry(&p);
|
||||
uasm_i_ori(&p, K0, K0,
|
||||
_PAGE_ACCESSED | _PAGE_MODIFIED | _PAGE_VALID | _PAGE_DIRTY);
|
||||
build_huge_handler_tail(&p, &r, &l, K0, K1);
|
||||
#endif
|
||||
|
||||
uasm_l_nopage_tlbm(&l, p);
|
||||
uasm_i_j(&p, (unsigned long)tlb_do_page_fault_1 & 0x0fffffff);
|
||||
uasm_i_nop(&p);
|
||||
|
|
1
arch/mips/power/Makefile
Normal file
1
arch/mips/power/Makefile
Normal file
|
@ -0,0 +1 @@
|
|||
obj-$(CONFIG_HIBERNATION) += cpu.o hibernate.o
|
43
arch/mips/power/cpu.c
Normal file
43
arch/mips/power/cpu.c
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Suspend support specific for mips.
|
||||
*
|
||||
* Licensed under the GPLv2
|
||||
*
|
||||
* Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
|
||||
* Author: Hu Hongbing <huhb@lemote.com>
|
||||
* Wu Zhangjin <wuzj@lemote.com>
|
||||
*/
|
||||
#include <asm/suspend.h>
|
||||
#include <asm/fpu.h>
|
||||
#include <asm/dsp.h>
|
||||
|
||||
static u32 saved_status;
|
||||
struct pt_regs saved_regs;
|
||||
|
||||
void save_processor_state(void)
|
||||
{
|
||||
saved_status = read_c0_status();
|
||||
|
||||
if (is_fpu_owner())
|
||||
save_fp(current);
|
||||
if (cpu_has_dsp)
|
||||
save_dsp(current);
|
||||
}
|
||||
|
||||
void restore_processor_state(void)
|
||||
{
|
||||
write_c0_status(saved_status);
|
||||
|
||||
if (is_fpu_owner())
|
||||
restore_fp(current);
|
||||
if (cpu_has_dsp)
|
||||
restore_dsp(current);
|
||||
}
|
||||
|
||||
int pfn_is_nosave(unsigned long pfn)
|
||||
{
|
||||
unsigned long nosave_begin_pfn = PFN_DOWN(__pa(&__nosave_begin));
|
||||
unsigned long nosave_end_pfn = PFN_UP(__pa(&__nosave_end));
|
||||
|
||||
return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn);
|
||||
}
|
70
arch/mips/power/hibernate.S
Normal file
70
arch/mips/power/hibernate.S
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Hibernation support specific for mips - temporary page tables
|
||||
*
|
||||
* Licensed under the GPLv2
|
||||
*
|
||||
* Copyright (C) 2009 Lemote Inc. & Insititute of Computing Technology
|
||||
* Author: Hu Hongbing <huhb@lemote.com>
|
||||
* Wu Zhangjin <wuzj@lemote.com>
|
||||
*/
|
||||
#include <asm/asm-offsets.h>
|
||||
#include <asm/regdef.h>
|
||||
#include <asm/asm.h>
|
||||
|
||||
.text
|
||||
LEAF(swsusp_arch_suspend)
|
||||
PTR_LA t0, saved_regs
|
||||
PTR_S ra, PT_R31(t0)
|
||||
PTR_S sp, PT_R29(t0)
|
||||
PTR_S fp, PT_R30(t0)
|
||||
PTR_S gp, PT_R28(t0)
|
||||
PTR_S s0, PT_R16(t0)
|
||||
PTR_S s1, PT_R17(t0)
|
||||
PTR_S s2, PT_R18(t0)
|
||||
PTR_S s3, PT_R19(t0)
|
||||
PTR_S s4, PT_R20(t0)
|
||||
PTR_S s5, PT_R21(t0)
|
||||
PTR_S s6, PT_R22(t0)
|
||||
PTR_S s7, PT_R23(t0)
|
||||
j swsusp_save
|
||||
END(swsusp_arch_suspend)
|
||||
|
||||
LEAF(swsusp_arch_resume)
|
||||
PTR_L t0, restore_pblist
|
||||
0:
|
||||
PTR_L t1, PBE_ADDRESS(t0) /* source */
|
||||
PTR_L t2, PBE_ORIG_ADDRESS(t0) /* destination */
|
||||
PTR_ADDIU t3, t1, _PAGE_SIZE
|
||||
1:
|
||||
REG_L t8, (t1)
|
||||
REG_S t8, (t2)
|
||||
PTR_ADDIU t1, t1, SZREG
|
||||
PTR_ADDIU t2, t2, SZREG
|
||||
bne t1, t3, 1b
|
||||
PTR_L t0, PBE_NEXT(t0)
|
||||
bnez t0, 0b
|
||||
/* flush caches to make sure context is in memory */
|
||||
PTR_L t0, __flush_cache_all
|
||||
jalr t0
|
||||
/* flush tlb entries */
|
||||
#ifdef CONFIG_SMP
|
||||
jal flush_tlb_all
|
||||
#else
|
||||
jal local_flush_tlb_all
|
||||
#endif
|
||||
PTR_LA t0, saved_regs
|
||||
PTR_L ra, PT_R31(t0)
|
||||
PTR_L sp, PT_R29(t0)
|
||||
PTR_L fp, PT_R30(t0)
|
||||
PTR_L gp, PT_R28(t0)
|
||||
PTR_L s0, PT_R16(t0)
|
||||
PTR_L s1, PT_R17(t0)
|
||||
PTR_L s2, PT_R18(t0)
|
||||
PTR_L s3, PT_R19(t0)
|
||||
PTR_L s4, PT_R20(t0)
|
||||
PTR_L s5, PT_R21(t0)
|
||||
PTR_L s6, PT_R22(t0)
|
||||
PTR_L s7, PT_R23(t0)
|
||||
PTR_LI v0, 0x0
|
||||
jr ra
|
||||
END(swsusp_arch_resume)
|
|
@ -151,7 +151,8 @@ static void rb532_disable_irq(unsigned int irq_nr)
|
|||
mask |= intr_bit;
|
||||
WRITE_MASK(addr, mask);
|
||||
|
||||
if (group == GPIO_MAPPED_IRQ_GROUP)
|
||||
/* There is a maximum of 14 GPIO interrupts */
|
||||
if (group == GPIO_MAPPED_IRQ_GROUP && irq_nr <= (GROUP4_IRQ_BASE + 13))
|
||||
rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
|
||||
|
||||
/*
|
||||
|
@ -174,7 +175,7 @@ static int rb532_set_type(unsigned int irq_nr, unsigned type)
|
|||
int gpio = irq_nr - GPIO_MAPPED_IRQ_BASE;
|
||||
int group = irq_to_group(irq_nr);
|
||||
|
||||
if (group != GPIO_MAPPED_IRQ_GROUP)
|
||||
if (group != GPIO_MAPPED_IRQ_GROUP || irq_nr > (GROUP4_IRQ_BASE + 13))
|
||||
return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
|
||||
|
||||
switch (type) {
|
||||
|
|
|
@ -75,6 +75,8 @@ config SIBYTE_SB1xxx_SOC
|
|||
select SWAP_IO_SPACE
|
||||
select SYS_SUPPORTS_32BIT_KERNEL
|
||||
select SYS_SUPPORTS_64BIT_KERNEL
|
||||
select CFE
|
||||
select SYS_HAS_EARLY_PRINTK
|
||||
|
||||
choice
|
||||
prompt "SiByte SOC Stepping"
|
||||
|
@ -128,13 +130,6 @@ config SIBYTE_ENABLE_LDT_IF_PCI
|
|||
bool
|
||||
select SIBYTE_HAS_LDT if PCI
|
||||
|
||||
config SIMULATION
|
||||
bool "Running under simulation"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
help
|
||||
Build a kernel suitable for running under the GDB simulator.
|
||||
Primarily adjusts the kernel's notion of time.
|
||||
|
||||
config SB1_CEX_ALWAYS_FATAL
|
||||
bool "All cache exceptions considered fatal (no recovery attempted)"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
|
@ -143,34 +138,14 @@ config SB1_CERR_STALL
|
|||
bool "Stall (rather than panic) on fatal cache error"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
|
||||
config SIBYTE_CFE
|
||||
bool "Booting from CFE"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
select CFE
|
||||
select SYS_HAS_EARLY_PRINTK
|
||||
help
|
||||
Make use of the CFE API for enumerating available memory,
|
||||
controlling secondary CPUs, and possibly console output.
|
||||
|
||||
config SIBYTE_CFE_CONSOLE
|
||||
bool "Use firmware console"
|
||||
depends on SIBYTE_CFE
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
help
|
||||
Use the CFE API's console write routines during boot. Other console
|
||||
options (VT console, sb1250 duart console, etc.) should not be
|
||||
configured.
|
||||
|
||||
config SIBYTE_STANDALONE
|
||||
bool
|
||||
depends on SIBYTE_SB1xxx_SOC && !SIBYTE_CFE
|
||||
select SYS_HAS_EARLY_PRINTK
|
||||
default y
|
||||
|
||||
config SIBYTE_STANDALONE_RAM_SIZE
|
||||
int "Memory size (in megabytes)"
|
||||
depends on SIBYTE_STANDALONE
|
||||
default "32"
|
||||
|
||||
config SIBYTE_BUS_WATCHER
|
||||
bool "Support for Bus Watcher statistics"
|
||||
depends on SIBYTE_SB1xxx_SOC
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
lib-y = setup.o
|
||||
lib-$(CONFIG_SIBYTE_CFE_CONSOLE) += console.o
|
|
@ -1,5 +1,5 @@
|
|||
obj-y :=
|
||||
|
||||
obj-y := cfe.o
|
||||
obj-$(CONFIG_SIBYTE_CFE_CONSOLE) += cfe_console.o
|
||||
obj-$(CONFIG_SIBYTE_TBPROF) += sb_tbprof.o
|
||||
|
||||
EXTRA_CFLAGS += -Werror
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
obj-y := setup.o irq.o time.o
|
||||
|
||||
obj-$(CONFIG_SMP) += smp.o
|
||||
obj-$(CONFIG_SIBYTE_STANDALONE) += prom.o
|
||||
obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o
|
||||
|
||||
EXTRA_CFLAGS += -Werror
|
||||
|
|
|
@ -111,11 +111,6 @@ static int sb1250_set_affinity(unsigned int irq, const struct cpumask *mask)
|
|||
|
||||
i = cpumask_first(mask);
|
||||
|
||||
if (cpumask_weight(mask) > 1) {
|
||||
printk("attempted to set irq affinity for irq %d to multiple CPUs\n", irq);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Convert logical CPU to physical CPU */
|
||||
cpu = cpu_logical_map(i);
|
||||
|
||||
|
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2000, 2001 Broadcom Corporation
|
||||
*
|
||||
* 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 <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/bootmem.h>
|
||||
#include <linux/smp.h>
|
||||
#include <linux/initrd.h>
|
||||
#include <linux/pm.h>
|
||||
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/reboot.h>
|
||||
|
||||
#define MAX_RAM_SIZE ((CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024) - 1)
|
||||
|
||||
static __init void prom_meminit(void)
|
||||
{
|
||||
#ifdef CONFIG_BLK_DEV_INITRD
|
||||
unsigned long initrd_pstart;
|
||||
unsigned long initrd_pend;
|
||||
|
||||
initrd_pstart = __pa(initrd_start);
|
||||
initrd_pend = __pa(initrd_end);
|
||||
if (initrd_start &&
|
||||
((initrd_pstart > MAX_RAM_SIZE)
|
||||
|| (initrd_pend > MAX_RAM_SIZE))) {
|
||||
panic("initrd out of addressable memory");
|
||||
}
|
||||
|
||||
add_memory_region(0, initrd_pstart,
|
||||
BOOT_MEM_RAM);
|
||||
add_memory_region(initrd_pstart, initrd_pend - initrd_pstart,
|
||||
BOOT_MEM_RESERVED);
|
||||
add_memory_region(initrd_pend,
|
||||
(CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024) - initrd_pend,
|
||||
BOOT_MEM_RAM);
|
||||
#else
|
||||
add_memory_region(0, CONFIG_SIBYTE_STANDALONE_RAM_SIZE * 1024 * 1024,
|
||||
BOOT_MEM_RAM);
|
||||
#endif
|
||||
}
|
||||
|
||||
void prom_cpu0_exit(void *unused)
|
||||
{
|
||||
while (1) ;
|
||||
}
|
||||
|
||||
static void prom_linux_exit(void)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
if (smp_processor_id()) {
|
||||
smp_call_function(prom_cpu0_exit, NULL, 1);
|
||||
}
|
||||
#endif
|
||||
while(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* prom_init is called just after the cpu type is determined, from setup_arch()
|
||||
*/
|
||||
void __init prom_init(void)
|
||||
{
|
||||
_machine_restart = (void (*)(char *))prom_linux_exit;
|
||||
_machine_halt = prom_linux_exit;
|
||||
pm_power_off = prom_linux_exit;
|
||||
|
||||
strcpy(arcs_cmdline, "root=/dev/ram0 ");
|
||||
|
||||
prom_meminit();
|
||||
}
|
||||
|
||||
void __init prom_free_prom_memory(void)
|
||||
{
|
||||
/* Not sure what I'm supposed to do here. Nothing, I think */
|
||||
}
|
||||
|
||||
void prom_putchar(char c)
|
||||
{
|
||||
}
|
|
@ -136,20 +136,6 @@ void __init plat_mem_setup(void)
|
|||
if (m41t81_probe())
|
||||
swarm_rtc_type = RTC_M4LT81;
|
||||
|
||||
printk("This kernel optimized for "
|
||||
#ifdef CONFIG_SIMULATION
|
||||
"simulation"
|
||||
#else
|
||||
"board"
|
||||
#endif
|
||||
" runs "
|
||||
#ifdef CONFIG_SIBYTE_CFE
|
||||
"with"
|
||||
#else
|
||||
"without"
|
||||
#endif
|
||||
" CFE\n");
|
||||
|
||||
#ifdef CONFIG_VT
|
||||
screen_info = (struct screen_info) {
|
||||
0, 0, /* orig-x, orig-y */
|
||||
|
|
|
@ -69,6 +69,7 @@ config SOC_TX4927
|
|||
select IRQ_TXX9
|
||||
select PCI_TX4927
|
||||
select GPIO_TXX9
|
||||
select HAS_TXX9_ACLC
|
||||
|
||||
config SOC_TX4938
|
||||
bool
|
||||
|
@ -78,6 +79,7 @@ config SOC_TX4938
|
|||
select IRQ_TXX9
|
||||
select PCI_TX4927
|
||||
select GPIO_TXX9
|
||||
select HAS_TXX9_ACLC
|
||||
|
||||
config SOC_TX4939
|
||||
bool
|
||||
|
@ -85,6 +87,7 @@ config SOC_TX4939
|
|||
select HAS_TXX9_SERIAL
|
||||
select HW_HAS_PCI
|
||||
select PCI_TX4927
|
||||
select HAS_TXX9_ACLC
|
||||
|
||||
config TXX9_7SEGLED
|
||||
bool
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <linux/serial_core.h>
|
||||
#include <linux/mtd/physmap.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/sysdev.h>
|
||||
#include <asm/bootinfo.h>
|
||||
#include <asm/time.h>
|
||||
#include <asm/reboot.h>
|
||||
|
@ -33,6 +34,7 @@
|
|||
#include <asm/txx9/pci.h>
|
||||
#include <asm/txx9tmr.h>
|
||||
#include <asm/txx9/ndfmc.h>
|
||||
#include <asm/txx9/dmac.h>
|
||||
#ifdef CONFIG_CPU_TX49XX
|
||||
#include <asm/txx9/tx4938.h>
|
||||
#endif
|
||||
|
@ -821,3 +823,176 @@ void __init txx9_iocled_init(unsigned long baseaddr,
|
|||
{
|
||||
}
|
||||
#endif /* CONFIG_LEDS_GPIO */
|
||||
|
||||
void __init txx9_dmac_init(int id, unsigned long baseaddr, int irq,
|
||||
const struct txx9dmac_platform_data *pdata)
|
||||
{
|
||||
#if defined(CONFIG_TXX9_DMAC) || defined(CONFIG_TXX9_DMAC_MODULE)
|
||||
struct resource res[] = {
|
||||
{
|
||||
.start = baseaddr,
|
||||
.end = baseaddr + 0x800 - 1,
|
||||
.flags = IORESOURCE_MEM,
|
||||
#ifndef CONFIG_MACH_TX49XX
|
||||
}, {
|
||||
.start = irq,
|
||||
.flags = IORESOURCE_IRQ,
|
||||
#endif
|
||||
}
|
||||
};
|
||||
#ifdef CONFIG_MACH_TX49XX
|
||||
struct resource chan_res[] = {
|
||||
{
|
||||
.flags = IORESOURCE_IRQ,
|
||||
}
|
||||
};
|
||||
#endif
|
||||
struct platform_device *pdev = platform_device_alloc("txx9dmac", id);
|
||||
struct txx9dmac_chan_platform_data cpdata;
|
||||
int i;
|
||||
|
||||
if (!pdev ||
|
||||
platform_device_add_resources(pdev, res, ARRAY_SIZE(res)) ||
|
||||
platform_device_add_data(pdev, pdata, sizeof(*pdata)) ||
|
||||
platform_device_add(pdev)) {
|
||||
platform_device_put(pdev);
|
||||
return;
|
||||
}
|
||||
memset(&cpdata, 0, sizeof(cpdata));
|
||||
cpdata.dmac_dev = pdev;
|
||||
for (i = 0; i < TXX9_DMA_MAX_NR_CHANNELS; i++) {
|
||||
#ifdef CONFIG_MACH_TX49XX
|
||||
chan_res[0].start = irq + i;
|
||||
#endif
|
||||
pdev = platform_device_alloc("txx9dmac-chan",
|
||||
id * TXX9_DMA_MAX_NR_CHANNELS + i);
|
||||
if (!pdev ||
|
||||
#ifdef CONFIG_MACH_TX49XX
|
||||
platform_device_add_resources(pdev, chan_res,
|
||||
ARRAY_SIZE(chan_res)) ||
|
||||
#endif
|
||||
platform_device_add_data(pdev, &cpdata, sizeof(cpdata)) ||
|
||||
platform_device_add(pdev))
|
||||
platform_device_put(pdev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void __init txx9_aclc_init(unsigned long baseaddr, int irq,
|
||||
unsigned int dmac_id,
|
||||
unsigned int dma_chan_out,
|
||||
unsigned int dma_chan_in)
|
||||
{
|
||||
#if defined(CONFIG_SND_SOC_TXX9ACLC) || \
|
||||
defined(CONFIG_SND_SOC_TXX9ACLC_MODULE)
|
||||
unsigned int dma_base = dmac_id * TXX9_DMA_MAX_NR_CHANNELS;
|
||||
struct resource res[] = {
|
||||
{
|
||||
.start = baseaddr,
|
||||
.end = baseaddr + 0x100 - 1,
|
||||
.flags = IORESOURCE_MEM,
|
||||
}, {
|
||||
.start = irq,
|
||||
.flags = IORESOURCE_IRQ,
|
||||
}, {
|
||||
.name = "txx9dmac-chan",
|
||||
.start = dma_base + dma_chan_out,
|
||||
.flags = IORESOURCE_DMA,
|
||||
}, {
|
||||
.name = "txx9dmac-chan",
|
||||
.start = dma_base + dma_chan_in,
|
||||
.flags = IORESOURCE_DMA,
|
||||
}
|
||||
};
|
||||
struct platform_device *pdev =
|
||||
platform_device_alloc("txx9aclc-ac97", -1);
|
||||
|
||||
if (!pdev ||
|
||||
platform_device_add_resources(pdev, res, ARRAY_SIZE(res)) ||
|
||||
platform_device_add(pdev))
|
||||
platform_device_put(pdev);
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct sysdev_class txx9_sramc_sysdev_class;
|
||||
|
||||
struct txx9_sramc_sysdev {
|
||||
struct sys_device dev;
|
||||
struct bin_attribute bindata_attr;
|
||||
void __iomem *base;
|
||||
};
|
||||
|
||||
static ssize_t txx9_sram_read(struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
char *buf, loff_t pos, size_t size)
|
||||
{
|
||||
struct txx9_sramc_sysdev *dev = bin_attr->private;
|
||||
size_t ramsize = bin_attr->size;
|
||||
|
||||
if (pos >= ramsize)
|
||||
return 0;
|
||||
if (pos + size > ramsize)
|
||||
size = ramsize - pos;
|
||||
memcpy_fromio(buf, dev->base + pos, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
static ssize_t txx9_sram_write(struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
char *buf, loff_t pos, size_t size)
|
||||
{
|
||||
struct txx9_sramc_sysdev *dev = bin_attr->private;
|
||||
size_t ramsize = bin_attr->size;
|
||||
|
||||
if (pos >= ramsize)
|
||||
return 0;
|
||||
if (pos + size > ramsize)
|
||||
size = ramsize - pos;
|
||||
memcpy_toio(dev->base + pos, buf, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
void __init txx9_sramc_init(struct resource *r)
|
||||
{
|
||||
struct txx9_sramc_sysdev *dev;
|
||||
size_t size;
|
||||
int err;
|
||||
|
||||
if (!txx9_sramc_sysdev_class.name) {
|
||||
txx9_sramc_sysdev_class.name = "txx9_sram";
|
||||
err = sysdev_class_register(&txx9_sramc_sysdev_class);
|
||||
if (err) {
|
||||
txx9_sramc_sysdev_class.name = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (!dev)
|
||||
return;
|
||||
size = resource_size(r);
|
||||
dev->base = ioremap(r->start, size);
|
||||
if (!dev->base)
|
||||
goto exit;
|
||||
dev->dev.cls = &txx9_sramc_sysdev_class;
|
||||
dev->bindata_attr.attr.name = "bindata";
|
||||
dev->bindata_attr.attr.mode = S_IRUSR | S_IWUSR;
|
||||
dev->bindata_attr.read = txx9_sram_read;
|
||||
dev->bindata_attr.write = txx9_sram_write;
|
||||
dev->bindata_attr.size = size;
|
||||
dev->bindata_attr.private = dev;
|
||||
err = sysdev_register(&dev->dev);
|
||||
if (err)
|
||||
goto exit;
|
||||
err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
|
||||
if (err) {
|
||||
sysdev_unregister(&dev->dev);
|
||||
goto exit;
|
||||
}
|
||||
return;
|
||||
exit:
|
||||
if (dev) {
|
||||
if (dev->base)
|
||||
iounmap(dev->base);
|
||||
kfree(dev);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <asm/txx9tmr.h>
|
||||
#include <asm/txx9pio.h>
|
||||
#include <asm/txx9/generic.h>
|
||||
#include <asm/txx9/dmac.h>
|
||||
#include <asm/txx9/tx4927.h>
|
||||
|
||||
static void __init tx4927_wdr_init(void)
|
||||
|
@ -253,6 +254,60 @@ void __init tx4927_mtd_init(int ch)
|
|||
txx9_physmap_flash_init(ch, start, size, &pdata);
|
||||
}
|
||||
|
||||
void __init tx4927_dmac_init(int memcpy_chan)
|
||||
{
|
||||
struct txx9dmac_platform_data plat_data = {
|
||||
.memcpy_chan = memcpy_chan,
|
||||
.have_64bit_regs = true,
|
||||
};
|
||||
|
||||
txx9_dmac_init(0, TX4927_DMA_REG & 0xfffffffffULL,
|
||||
TXX9_IRQ_BASE + TX4927_IR_DMA(0), &plat_data);
|
||||
}
|
||||
|
||||
void __init tx4927_aclc_init(unsigned int dma_chan_out,
|
||||
unsigned int dma_chan_in)
|
||||
{
|
||||
u64 pcfg = __raw_readq(&tx4927_ccfgptr->pcfg);
|
||||
__u64 dmasel_mask = 0, dmasel = 0;
|
||||
unsigned long flags;
|
||||
|
||||
if (!(pcfg & TX4927_PCFG_SEL2))
|
||||
return;
|
||||
/* setup DMASEL (playback:ACLC ch0, capture:ACLC ch1) */
|
||||
switch (dma_chan_out) {
|
||||
case 0:
|
||||
dmasel_mask |= TX4927_PCFG_DMASEL0_MASK;
|
||||
dmasel |= TX4927_PCFG_DMASEL0_ACL0;
|
||||
break;
|
||||
case 2:
|
||||
dmasel_mask |= TX4927_PCFG_DMASEL2_MASK;
|
||||
dmasel |= TX4927_PCFG_DMASEL2_ACL0;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
switch (dma_chan_in) {
|
||||
case 1:
|
||||
dmasel_mask |= TX4927_PCFG_DMASEL1_MASK;
|
||||
dmasel |= TX4927_PCFG_DMASEL1_ACL1;
|
||||
break;
|
||||
case 3:
|
||||
dmasel_mask |= TX4927_PCFG_DMASEL3_MASK;
|
||||
dmasel |= TX4927_PCFG_DMASEL3_ACL1;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
local_irq_save(flags);
|
||||
txx9_clear64(&tx4927_ccfgptr->pcfg, dmasel_mask);
|
||||
txx9_set64(&tx4927_ccfgptr->pcfg, dmasel);
|
||||
local_irq_restore(flags);
|
||||
txx9_aclc_init(TX4927_ACLC_REG & 0xfffffffffULL,
|
||||
TXX9_IRQ_BASE + TX4927_IR_ACLC,
|
||||
0, dma_chan_out, dma_chan_in);
|
||||
}
|
||||
|
||||
static void __init tx4927_stop_unused_modules(void)
|
||||
{
|
||||
__u64 pcfg, rst = 0, ckd = 0;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <asm/txx9pio.h>
|
||||
#include <asm/txx9/generic.h>
|
||||
#include <asm/txx9/ndfmc.h>
|
||||
#include <asm/txx9/dmac.h>
|
||||
#include <asm/txx9/tx4938.h>
|
||||
|
||||
static void __init tx4938_wdr_init(void)
|
||||
|
@ -239,11 +240,6 @@ void __init tx4938_setup(void)
|
|||
for (i = 0; i < TX4938_NR_TMR; i++)
|
||||
txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL);
|
||||
|
||||
/* DMA */
|
||||
for (i = 0; i < 2; i++)
|
||||
____raw_writeq(TX4938_DMA_MCR_MSTEN,
|
||||
(void __iomem *)(TX4938_DMA_REG(i) + 0x50));
|
||||
|
||||
/* PIO */
|
||||
txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, TX4938_NUM_PIO);
|
||||
__raw_writel(0, &tx4938_pioptr->maskcpu);
|
||||
|
@ -403,6 +399,38 @@ void __init tx4938_ndfmc_init(unsigned int hold, unsigned int spw)
|
|||
txx9_ndfmc_init(baseaddr, &plat_data);
|
||||
}
|
||||
|
||||
void __init tx4938_dmac_init(int memcpy_chan0, int memcpy_chan1)
|
||||
{
|
||||
struct txx9dmac_platform_data plat_data = {
|
||||
.have_64bit_regs = true,
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
plat_data.memcpy_chan = i ? memcpy_chan1 : memcpy_chan0;
|
||||
txx9_dmac_init(i, TX4938_DMA_REG(i) & 0xfffffffffULL,
|
||||
TXX9_IRQ_BASE + TX4938_IR_DMA(i, 0),
|
||||
&plat_data);
|
||||
}
|
||||
}
|
||||
|
||||
void __init tx4938_aclc_init(void)
|
||||
{
|
||||
u64 pcfg = __raw_readq(&tx4938_ccfgptr->pcfg);
|
||||
|
||||
if ((pcfg & TX4938_PCFG_SEL2) &&
|
||||
!(pcfg & TX4938_PCFG_ETH0_SEL))
|
||||
txx9_aclc_init(TX4938_ACLC_REG & 0xfffffffffULL,
|
||||
TXX9_IRQ_BASE + TX4938_IR_ACLC,
|
||||
1, 0, 1);
|
||||
}
|
||||
|
||||
void __init tx4938_sramc_init(void)
|
||||
{
|
||||
if (tx4938_sram_resource.start)
|
||||
txx9_sramc_init(&tx4938_sram_resource);
|
||||
}
|
||||
|
||||
static void __init tx4938_stop_unused_modules(void)
|
||||
{
|
||||
__u64 pcfg, rst = 0, ckd = 0;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <asm/txx9tmr.h>
|
||||
#include <asm/txx9/generic.h>
|
||||
#include <asm/txx9/ndfmc.h>
|
||||
#include <asm/txx9/dmac.h>
|
||||
#include <asm/txx9/tx4939.h>
|
||||
|
||||
static void __init tx4939_wdr_init(void)
|
||||
|
@ -259,11 +260,6 @@ void __init tx4939_setup(void)
|
|||
for (i = 0; i < TX4939_NR_TMR; i++)
|
||||
txx9_tmr_init(TX4939_TMR_REG(i) & 0xfffffffffULL);
|
||||
|
||||
/* DMA */
|
||||
for (i = 0; i < 2; i++)
|
||||
____raw_writeq(TX4938_DMA_MCR_MSTEN,
|
||||
(void __iomem *)(TX4939_DMA_REG(i) + 0x50));
|
||||
|
||||
/* set PCIC1 reset (required to prevent hangup on BIST) */
|
||||
txx9_set64(&tx4939_ccfgptr->clkctr, TX4939_CLKCTR_PCI1RST);
|
||||
pcfg = ____raw_readq(&tx4939_ccfgptr->pcfg);
|
||||
|
@ -474,6 +470,53 @@ void __init tx4939_ndfmc_init(unsigned int hold, unsigned int spw,
|
|||
txx9_ndfmc_init(TX4939_NDFMC_REG & 0xfffffffffULL, &plat_data);
|
||||
}
|
||||
|
||||
void __init tx4939_dmac_init(int memcpy_chan0, int memcpy_chan1)
|
||||
{
|
||||
struct txx9dmac_platform_data plat_data = {
|
||||
.have_64bit_regs = true,
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
plat_data.memcpy_chan = i ? memcpy_chan1 : memcpy_chan0;
|
||||
txx9_dmac_init(i, TX4939_DMA_REG(i) & 0xfffffffffULL,
|
||||
TXX9_IRQ_BASE + TX4939_IR_DMA(i, 0),
|
||||
&plat_data);
|
||||
}
|
||||
}
|
||||
|
||||
void __init tx4939_aclc_init(void)
|
||||
{
|
||||
u64 pcfg = __raw_readq(&tx4939_ccfgptr->pcfg);
|
||||
|
||||
if ((pcfg & TX4939_PCFG_I2SMODE_MASK) == TX4939_PCFG_I2SMODE_ACLC)
|
||||
txx9_aclc_init(TX4939_ACLC_REG & 0xfffffffffULL,
|
||||
TXX9_IRQ_BASE + TX4939_IR_ACLC, 1, 0, 1);
|
||||
}
|
||||
|
||||
void __init tx4939_sramc_init(void)
|
||||
{
|
||||
if (tx4939_sram_resource.start)
|
||||
txx9_sramc_init(&tx4939_sram_resource);
|
||||
}
|
||||
|
||||
void __init tx4939_rng_init(void)
|
||||
{
|
||||
static struct resource res = {
|
||||
.start = TX4939_RNG_REG & 0xfffffffffULL,
|
||||
.end = (TX4939_RNG_REG & 0xfffffffffULL) + 0x30 - 1,
|
||||
.flags = IORESOURCE_MEM,
|
||||
};
|
||||
static struct platform_device pdev = {
|
||||
.name = "tx4939-rng",
|
||||
.id = -1,
|
||||
.num_resources = 1,
|
||||
.resource = &res,
|
||||
};
|
||||
|
||||
platform_device_register(&pdev);
|
||||
}
|
||||
|
||||
static void __init tx4939_stop_unused_modules(void)
|
||||
{
|
||||
__u64 pcfg, rst = 0, ckd = 0;
|
||||
|
|
|
@ -337,6 +337,14 @@ static void __init rbtx4927_device_init(void)
|
|||
rbtx4927_ne_init();
|
||||
tx4927_wdt_init();
|
||||
rbtx4927_mtd_init();
|
||||
if (TX4927_REV_PCODE() == 0x4927) {
|
||||
tx4927_dmac_init(2);
|
||||
tx4927_aclc_init(0, 1);
|
||||
} else {
|
||||
tx4938_dmac_init(0, 2);
|
||||
tx4938_aclc_init();
|
||||
}
|
||||
platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
|
||||
txx9_iocled_init(RBTX4927_LED_ADDR - IO_BASE, -1, 3, 1, "green", NULL);
|
||||
rbtx4927_gpioled_init();
|
||||
}
|
||||
|
|
|
@ -355,6 +355,10 @@ static void __init rbtx4938_device_init(void)
|
|||
/* TC58DVM82A1FT: tDH=10ns, tWP=tRP=tREADID=35ns */
|
||||
tx4938_ndfmc_init(10, 35);
|
||||
tx4938_ata_init(RBTX4938_IRQ_IOC_ATA, 0, 1);
|
||||
tx4938_dmac_init(0, 2);
|
||||
tx4938_aclc_init();
|
||||
platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
|
||||
tx4938_sramc_init();
|
||||
txx9_iocled_init(RBTX4938_LED_ADDR - IO_BASE, -1, 8, 1, "green", NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -498,6 +498,11 @@ static void __init rbtx4939_device_init(void)
|
|||
tx4939_wdt_init();
|
||||
tx4939_ata_init();
|
||||
tx4939_rtc_init();
|
||||
tx4939_dmac_init(0, 2);
|
||||
tx4939_aclc_init();
|
||||
platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
|
||||
tx4939_sramc_init();
|
||||
tx4939_rng_init();
|
||||
}
|
||||
|
||||
static void __init rbtx4939_setup(void)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue