diff options
Diffstat (limited to 'arch/powerpc/sysdev')
| -rw-r--r-- | arch/powerpc/sysdev/Makefile | 1 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/dart.h | 59 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/mmio_nvram.c | 118 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/u3_iommu.c | 5 |
4 files changed, 181 insertions, 2 deletions
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile index 8acd21dee05d..6b7efcfc352a 100644 --- a/arch/powerpc/sysdev/Makefile +++ b/arch/powerpc/sysdev/Makefile | |||
| @@ -5,3 +5,4 @@ obj-$(CONFIG_PPC_MPC106) += grackle.o | |||
| 5 | obj-$(CONFIG_BOOKE) += dcr.o | 5 | obj-$(CONFIG_BOOKE) += dcr.o |
| 6 | obj-$(CONFIG_40x) += dcr.o | 6 | obj-$(CONFIG_40x) += dcr.o |
| 7 | obj-$(CONFIG_U3_DART) += u3_iommu.o | 7 | obj-$(CONFIG_U3_DART) += u3_iommu.o |
| 8 | obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o | ||
diff --git a/arch/powerpc/sysdev/dart.h b/arch/powerpc/sysdev/dart.h new file mode 100644 index 000000000000..ea8f0d9eed8a --- /dev/null +++ b/arch/powerpc/sysdev/dart.h | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2004 Olof Johansson <olof@austin.ibm.com>, IBM Corporation | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #ifndef _POWERPC_SYSDEV_DART_H | ||
| 20 | #define _POWERPC_SYSDEV_DART_H | ||
| 21 | |||
| 22 | |||
| 23 | /* physical base of DART registers */ | ||
| 24 | #define DART_BASE 0xf8033000UL | ||
| 25 | |||
| 26 | /* Offset from base to control register */ | ||
| 27 | #define DARTCNTL 0 | ||
| 28 | /* Offset from base to exception register */ | ||
| 29 | #define DARTEXCP 0x10 | ||
| 30 | /* Offset from base to TLB tag registers */ | ||
| 31 | #define DARTTAG 0x1000 | ||
| 32 | |||
| 33 | |||
| 34 | /* Control Register fields */ | ||
| 35 | |||
| 36 | /* base address of table (pfn) */ | ||
| 37 | #define DARTCNTL_BASE_MASK 0xfffff | ||
| 38 | #define DARTCNTL_BASE_SHIFT 12 | ||
| 39 | |||
| 40 | #define DARTCNTL_FLUSHTLB 0x400 | ||
| 41 | #define DARTCNTL_ENABLE 0x200 | ||
| 42 | |||
| 43 | /* size of table in pages */ | ||
| 44 | #define DARTCNTL_SIZE_MASK 0x1ff | ||
| 45 | #define DARTCNTL_SIZE_SHIFT 0 | ||
| 46 | |||
| 47 | |||
| 48 | /* DART table fields */ | ||
| 49 | |||
| 50 | #define DARTMAP_VALID 0x80000000 | ||
| 51 | #define DARTMAP_RPNMASK 0x00ffffff | ||
| 52 | |||
| 53 | |||
| 54 | #define DART_PAGE_SHIFT 12 | ||
| 55 | #define DART_PAGE_SIZE (1 << DART_PAGE_SHIFT) | ||
| 56 | #define DART_PAGE_FACTOR (PAGE_SHIFT - DART_PAGE_SHIFT) | ||
| 57 | |||
| 58 | |||
| 59 | #endif /* _POWERPC_SYSDEV_DART_H */ | ||
diff --git a/arch/powerpc/sysdev/mmio_nvram.c b/arch/powerpc/sysdev/mmio_nvram.c new file mode 100644 index 000000000000..74e0d31a3559 --- /dev/null +++ b/arch/powerpc/sysdev/mmio_nvram.c | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | /* | ||
| 2 | * memory mapped NVRAM | ||
| 3 | * | ||
| 4 | * (C) Copyright IBM Corp. 2005 | ||
| 5 | * | ||
| 6 | * Authors : Utz Bacher <utz.bacher@de.ibm.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 11 | * any later version. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * You should have received a copy of the GNU General Public License | ||
| 19 | * along with this program; if not, write to the Free Software | ||
| 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <linux/fs.h> | ||
| 24 | #include <linux/init.h> | ||
| 25 | #include <linux/kernel.h> | ||
| 26 | #include <linux/spinlock.h> | ||
| 27 | #include <linux/types.h> | ||
| 28 | |||
| 29 | #include <asm/machdep.h> | ||
| 30 | #include <asm/nvram.h> | ||
| 31 | #include <asm/prom.h> | ||
| 32 | |||
| 33 | static void __iomem *mmio_nvram_start; | ||
| 34 | static long mmio_nvram_len; | ||
| 35 | static spinlock_t mmio_nvram_lock = SPIN_LOCK_UNLOCKED; | ||
| 36 | |||
| 37 | static ssize_t mmio_nvram_read(char *buf, size_t count, loff_t *index) | ||
| 38 | { | ||
| 39 | unsigned long flags; | ||
| 40 | |||
| 41 | if (*index >= mmio_nvram_len) | ||
| 42 | return 0; | ||
| 43 | if (*index + count > mmio_nvram_len) | ||
| 44 | count = mmio_nvram_len - *index; | ||
| 45 | |||
| 46 | spin_lock_irqsave(&mmio_nvram_lock, flags); | ||
| 47 | |||
| 48 | memcpy_fromio(buf, mmio_nvram_start + *index, count); | ||
| 49 | |||
| 50 | spin_unlock_irqrestore(&mmio_nvram_lock, flags); | ||
| 51 | |||
| 52 | *index += count; | ||
| 53 | return count; | ||
| 54 | } | ||
| 55 | |||
| 56 | static ssize_t mmio_nvram_write(char *buf, size_t count, loff_t *index) | ||
| 57 | { | ||
| 58 | unsigned long flags; | ||
| 59 | |||
| 60 | if (*index >= mmio_nvram_len) | ||
| 61 | return 0; | ||
| 62 | if (*index + count > mmio_nvram_len) | ||
| 63 | count = mmio_nvram_len - *index; | ||
| 64 | |||
| 65 | spin_lock_irqsave(&mmio_nvram_lock, flags); | ||
| 66 | |||
| 67 | memcpy_toio(mmio_nvram_start + *index, buf, count); | ||
| 68 | |||
| 69 | spin_unlock_irqrestore(&mmio_nvram_lock, flags); | ||
| 70 | |||
| 71 | *index += count; | ||
| 72 | return count; | ||
| 73 | } | ||
| 74 | |||
| 75 | static ssize_t mmio_nvram_get_size(void) | ||
| 76 | { | ||
| 77 | return mmio_nvram_len; | ||
| 78 | } | ||
| 79 | |||
| 80 | int __init mmio_nvram_init(void) | ||
| 81 | { | ||
| 82 | struct device_node *nvram_node; | ||
| 83 | unsigned long *buffer; | ||
| 84 | int proplen; | ||
| 85 | unsigned long nvram_addr; | ||
| 86 | int ret; | ||
| 87 | |||
| 88 | ret = -ENODEV; | ||
| 89 | nvram_node = of_find_node_by_type(NULL, "nvram"); | ||
| 90 | if (!nvram_node) | ||
| 91 | goto out; | ||
| 92 | |||
| 93 | ret = -EIO; | ||
| 94 | buffer = (unsigned long *)get_property(nvram_node, "reg", &proplen); | ||
| 95 | if (proplen != 2*sizeof(unsigned long)) | ||
| 96 | goto out; | ||
| 97 | |||
| 98 | ret = -ENODEV; | ||
| 99 | nvram_addr = buffer[0]; | ||
| 100 | mmio_nvram_len = buffer[1]; | ||
| 101 | if ( (!mmio_nvram_len) || (!nvram_addr) ) | ||
| 102 | goto out; | ||
| 103 | |||
| 104 | mmio_nvram_start = ioremap(nvram_addr, mmio_nvram_len); | ||
| 105 | if (!mmio_nvram_start) | ||
| 106 | goto out; | ||
| 107 | |||
| 108 | printk(KERN_INFO "mmio NVRAM, %luk mapped to %p\n", | ||
| 109 | mmio_nvram_len >> 10, mmio_nvram_start); | ||
| 110 | |||
| 111 | ppc_md.nvram_read = mmio_nvram_read; | ||
| 112 | ppc_md.nvram_write = mmio_nvram_write; | ||
| 113 | ppc_md.nvram_size = mmio_nvram_get_size; | ||
| 114 | |||
| 115 | out: | ||
| 116 | of_node_put(nvram_node); | ||
| 117 | return ret; | ||
| 118 | } | ||
diff --git a/arch/powerpc/sysdev/u3_iommu.c b/arch/powerpc/sysdev/u3_iommu.c index fba871a1bda5..607722178c1a 100644 --- a/arch/powerpc/sysdev/u3_iommu.c +++ b/arch/powerpc/sysdev/u3_iommu.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * arch/ppc64/kernel/u3_iommu.c | 2 | * arch/powerpc/sysdev/u3_iommu.c |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2004 Olof Johansson <olof@austin.ibm.com>, IBM Corporation | 4 | * Copyright (C) 2004 Olof Johansson <olof@austin.ibm.com>, IBM Corporation |
| 5 | * | 5 | * |
| @@ -44,9 +44,10 @@ | |||
| 44 | #include <asm/abs_addr.h> | 44 | #include <asm/abs_addr.h> |
| 45 | #include <asm/cacheflush.h> | 45 | #include <asm/cacheflush.h> |
| 46 | #include <asm/lmb.h> | 46 | #include <asm/lmb.h> |
| 47 | #include <asm/dart.h> | ||
| 48 | #include <asm/ppc-pci.h> | 47 | #include <asm/ppc-pci.h> |
| 49 | 48 | ||
| 49 | #include "dart.h" | ||
| 50 | |||
| 50 | extern int iommu_force_on; | 51 | extern int iommu_force_on; |
| 51 | 52 | ||
| 52 | /* Physical base address and size of the DART table */ | 53 | /* Physical base address and size of the DART table */ |
