Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc

* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc:
powerpc/mm: Lockless get_user_pages_fast() for 64-bit (v3)
powerpc: Don't use the wrong thread_struct for ptrace get/set VSX regs
powerpc: Fix ptrace buffer size for VSX
powerpc: Correctly hookup PTRACE_GET/SETVSRREGS for 32 bit processes
ide/powermac: Fix use of uninitialized pointer on media-bay
powerpc: Allow non-hcall return values for lparcfg writes
ipmi/powerpc: Use linux/of_{device,platform}.h instead of asm
powerpc/fsl: proliferate simple-bus compatibility to soc nodes
Documentation: remove old sbc8260 board specific information
cpm2: Rework baud rate generators configuration to support external clocks.
powerpc: rtc_cmos_setup: assign interrupts only if there is i8259 PIC
cpm_uart: Add generic clock API support to set baudrates
cpm_uart: Modem control lines support
powerpc: implement GPIO LIB API on CPM1 Freescale SoC.
cpm2: Implement GPIO LIB API on CPM2 Freescale SoC.
powerpc: Fix 8xx build failure
powerpc: clean up the Book-E HW watchpoint support

+907 -290
-2
Documentation/powerpc/00-INDEX
··· 20 20 - MPC5200 Device Tree Bindings 21 21 ppc_htab.txt 22 22 - info about the Linux/PPC /proc/ppc_htab entry 23 - SBC8260_memory_mapping.txt 24 - - EST SBC8260 board info 25 23 smp.txt 26 24 - use and state info about Linux/PPC on MP machines 27 25 sound.txt
-197
Documentation/powerpc/SBC8260_memory_mapping.txt
··· 1 - Please mail me (Jon Diekema, diekema_jon@si.com or diekema@cideas.com) 2 - if you have questions, comments or corrections. 3 - 4 - * EST SBC8260 Linux memory mapping rules 5 - 6 - http://www.estc.com/ 7 - http://www.estc.com/products/boards/SBC8260-8240_ds.html 8 - 9 - Initial conditions: 10 - ------------------- 11 - 12 - Tasks that need to be perform by the boot ROM before control is 13 - transferred to zImage (compressed Linux kernel): 14 - 15 - - Define the IMMR to 0xf0000000 16 - 17 - - Initialize the memory controller so that RAM is available at 18 - physical address 0x00000000. On the SBC8260 is this 16M (64M) 19 - SDRAM. 20 - 21 - - The boot ROM should only clear the RAM that it is using. 22 - 23 - The reason for doing this is to enhances the chances of a 24 - successful post mortem on a Linux panic. One of the first 25 - items to examine is the 16k (LOG_BUF_LEN) circular console 26 - buffer called log_buf which is defined in kernel/printk.c. 27 - 28 - - To enhance boot ROM performance, the I-cache can be enabled. 29 - 30 - Date: Mon, 22 May 2000 14:21:10 -0700 31 - From: Neil Russell <caret@c-side.com> 32 - 33 - LiMon (LInux MONitor) runs with and starts Linux with MMU 34 - off, I-cache enabled, D-cache disabled. The I-cache doesn't 35 - need hints from the MMU to work correctly as the D-cache 36 - does. No D-cache means no special code to handle devices in 37 - the presence of cache (no snooping, etc). The use of the 38 - I-cache means that the monitor can run acceptably fast 39 - directly from ROM, rather than having to copy it to RAM. 40 - 41 - - Build the board information structure (see 42 - include/asm-ppc/est8260.h for its definition) 43 - 44 - - The compressed Linux kernel (zImage) contains a bootstrap loader 45 - that is position independent; you can load it into any RAM, 46 - ROM or FLASH memory address >= 0x00500000 (above 5 MB), or 47 - at its link address of 0x00400000 (4 MB). 48 - 49 - Note: If zImage is loaded at its link address of 0x00400000 (4 MB), 50 - then zImage will skip the step of moving itself to 51 - its link address. 52 - 53 - - Load R3 with the address of the board information structure 54 - 55 - - Transfer control to zImage 56 - 57 - - The Linux console port is SMC1, and the baud rate is controlled 58 - from the bi_baudrate field of the board information structure. 59 - On thing to keep in mind when picking the baud rate, is that 60 - there is no flow control on the SMC ports. I would stick 61 - with something safe and standard like 19200. 62 - 63 - On the EST SBC8260, the SMC1 port is on the COM1 connector of 64 - the board. 65 - 66 - 67 - EST SBC8260 defaults: 68 - --------------------- 69 - 70 - Chip 71 - Memory Sel Bus Use 72 - --------------------- --- --- ---------------------------------- 73 - 0x00000000-0x03FFFFFF CS2 60x (16M or 64M)/64M SDRAM 74 - 0x04000000-0x04FFFFFF CS4 local 4M/16M SDRAM (soldered to the board) 75 - 0x21000000-0x21000000 CS7 60x 1B/64K Flash present detect (from the flash SIMM) 76 - 0x21000001-0x21000001 CS7 60x 1B/64K Switches (read) and LEDs (write) 77 - 0x22000000-0x2200FFFF CS5 60x 8K/64K EEPROM 78 - 0xFC000000-0xFCFFFFFF CS6 60x 2M/16M flash (8 bits wide, soldered to the board) 79 - 0xFE000000-0xFFFFFFFF CS0 60x 4M/16M flash (SIMM) 80 - 81 - Notes: 82 - ------ 83 - 84 - - The chip selects can map 32K blocks and up (powers of 2) 85 - 86 - - The SDRAM machine can handled up to 128Mbytes per chip select 87 - 88 - - Linux uses the 60x bus memory (the SDRAM DIMM) for the 89 - communications buffers. 90 - 91 - - BATs can map 128K-256Mbytes each. There are four data BATs and 92 - four instruction BATs. Generally the data and instruction BATs 93 - are mapped the same. 94 - 95 - - The IMMR must be set above the kernel virtual memory addresses, 96 - which start at 0xC0000000. Otherwise, the kernel may crash as 97 - soon as you start any threads or processes due to VM collisions 98 - in the kernel or user process space. 99 - 100 - 101 - Details from Dan Malek <dan_malek@mvista.com> on 10/29/1999: 102 - 103 - The user application virtual space consumes the first 2 Gbytes 104 - (0x00000000 to 0x7FFFFFFF). The kernel virtual text starts at 105 - 0xC0000000, with data following. There is a "protection hole" 106 - between the end of kernel data and the start of the kernel 107 - dynamically allocated space, but this space is still within 108 - 0xCxxxxxxx. 109 - 110 - Obviously the kernel can't map any physical addresses 1:1 in 111 - these ranges. 112 - 113 - 114 - Details from Dan Malek <dan_malek@mvista.com> on 5/19/2000: 115 - 116 - During the early kernel initialization, the kernel virtual 117 - memory allocator is not operational. Prior to this KVM 118 - initialization, we choose to map virtual to physical addresses 119 - 1:1. That is, the kernel virtual address exactly matches the 120 - physical address on the bus. These mappings are typically done 121 - in arch/ppc/kernel/head.S, or arch/ppc/mm/init.c. Only 122 - absolutely necessary mappings should be done at this time, for 123 - example board control registers or a serial uart. Normal device 124 - driver initialization should map resources later when necessary. 125 - 126 - Although platform dependent, and certainly the case for embedded 127 - 8xx, traditionally memory is mapped at physical address zero, 128 - and I/O devices above physical address 0x80000000. The lowest 129 - and highest (above 0xf0000000) I/O addresses are traditionally 130 - used for devices or registers we need to map during kernel 131 - initialization and prior to KVM operation. For this reason, 132 - and since it followed prior PowerPC platform examples, I chose 133 - to map the embedded 8xx kernel to the 0xc0000000 virtual address. 134 - This way, we can enable the MMU to map the kernel for proper 135 - operation, and still map a few windows before the KVM is operational. 136 - 137 - On some systems, you could possibly run the kernel at the 138 - 0x80000000 or any other virtual address. It just depends upon 139 - mapping that must be done prior to KVM operational. You can never 140 - map devices or kernel spaces that overlap with the user virtual 141 - space. This is why default IMMR mapping used by most BDM tools 142 - won't work. They put the IMMR at something like 0x10000000 or 143 - 0x02000000 for example. You simply can't map these addresses early 144 - in the kernel, and continue proper system operation. 145 - 146 - The embedded 8xx/82xx kernel is mature enough that all you should 147 - need to do is map the IMMR someplace at or above 0xf0000000 and it 148 - should boot far enough to get serial console messages and KGDB 149 - connected on any platform. There are lots of other subtle memory 150 - management design features that you simply don't need to worry 151 - about. If you are changing functions related to MMU initialization, 152 - you are likely breaking things that are known to work and are 153 - heading down a path of disaster and frustration. Your changes 154 - should be to make the flexibility of the processor fit Linux, 155 - not force arbitrary and non-workable memory mappings into Linux. 156 - 157 - - You don't want to change KERNELLOAD or KERNELBASE, otherwise the 158 - virtual memory and MMU code will get confused. 159 - 160 - arch/ppc/Makefile:KERNELLOAD = 0xc0000000 161 - 162 - include/asm-ppc/page.h:#define PAGE_OFFSET 0xc0000000 163 - include/asm-ppc/page.h:#define KERNELBASE PAGE_OFFSET 164 - 165 - - RAM is at physical address 0x00000000, and gets mapped to 166 - virtual address 0xC0000000 for the kernel. 167 - 168 - 169 - Physical addresses used by the Linux kernel: 170 - -------------------------------------------- 171 - 172 - 0x00000000-0x3FFFFFFF 1GB reserved for RAM 173 - 0xF0000000-0xF001FFFF 128K IMMR 64K used for dual port memory, 174 - 64K for 8260 registers 175 - 176 - 177 - Logical addresses used by the Linux kernel: 178 - ------------------------------------------- 179 - 180 - 0xF0000000-0xFFFFFFFF 256M BAT0 (IMMR: dual port RAM, registers) 181 - 0xE0000000-0xEFFFFFFF 256M BAT1 (I/O space for custom boards) 182 - 0xC0000000-0xCFFFFFFF 256M BAT2 (RAM) 183 - 0xD0000000-0xDFFFFFFF 256M BAT3 (if RAM > 256MByte) 184 - 185 - 186 - EST SBC8260 Linux mapping: 187 - -------------------------- 188 - 189 - DBAT0, IBAT0, cache inhibited: 190 - 191 - Chip 192 - Memory Sel Use 193 - --------------------- --- --------------------------------- 194 - 0xF0000000-0xF001FFFF n/a IMMR: dual port RAM, registers 195 - 196 - DBAT1, IBAT1, cache inhibited: 197 -
+11
Documentation/powerpc/dts-bindings/fsl/cpm_qe/serial.txt
··· 7 7 - fsl,cpm2-scc-uart 8 8 - fsl,qe-uart 9 9 10 + Modem control lines connected to GPIO controllers are listed in the gpios 11 + property as described in booting-without-of.txt, section IX.1 in the following 12 + order: 13 + 14 + CTS, RTS, DCD, DSR, DTR, and RI. 15 + 16 + The gpios property is optional and can be left out when control lines are 17 + not used. 18 + 10 19 Example: 11 20 12 21 serial@11a00 { ··· 27 18 interrupt-parent = <&PIC>; 28 19 fsl,cpm-brg = <1>; 29 20 fsl,cpm-command = <00800000>; 21 + gpios = <&gpio_c 15 0 22 + &gpio_d 29 0>; 30 23 };
+3
arch/powerpc/Kconfig
··· 42 42 bool 43 43 default y 44 44 45 + config HAVE_GET_USER_PAGES_FAST 46 + def_bool PPC64 47 + 45 48 config HAVE_SETUP_PER_CPU_AREA 46 49 def_bool PPC64 47 50
+1
arch/powerpc/boot/dts/mpc832x_mds.dts
··· 68 68 #address-cells = <1>; 69 69 #size-cells = <1>; 70 70 device_type = "soc"; 71 + compatible = "simple-bus"; 71 72 ranges = <0x0 0xe0000000 0x00100000>; 72 73 reg = <0xe0000000 0x00000200>; 73 74 bus-frequency = <132000000>;
+1
arch/powerpc/boot/dts/mpc832x_rdb.dts
··· 51 51 #address-cells = <1>; 52 52 #size-cells = <1>; 53 53 device_type = "soc"; 54 + compatible = "simple-bus"; 54 55 ranges = <0x0 0xe0000000 0x00100000>; 55 56 reg = <0xe0000000 0x00000200>; 56 57 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8349emitx.dts
··· 52 52 #address-cells = <1>; 53 53 #size-cells = <1>; 54 54 device_type = "soc"; 55 + compatible = "simple-bus"; 55 56 ranges = <0x0 0xe0000000 0x00100000>; 56 57 reg = <0xe0000000 0x00000200>; 57 58 bus-frequency = <0>; // from bootloader
+1
arch/powerpc/boot/dts/mpc8349emitxgp.dts
··· 50 50 #address-cells = <1>; 51 51 #size-cells = <1>; 52 52 device_type = "soc"; 53 + compatible = "simple-bus"; 53 54 ranges = <0x0 0xe0000000 0x00100000>; 54 55 reg = <0xe0000000 0x00000200>; 55 56 bus-frequency = <0>; // from bootloader
+1
arch/powerpc/boot/dts/mpc834x_mds.dts
··· 57 57 #address-cells = <1>; 58 58 #size-cells = <1>; 59 59 device_type = "soc"; 60 + compatible = "simple-bus"; 60 61 ranges = <0x0 0xe0000000 0x00100000>; 61 62 reg = <0xe0000000 0x00000200>; 62 63 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc836x_mds.dts
··· 61 61 #address-cells = <1>; 62 62 #size-cells = <1>; 63 63 device_type = "soc"; 64 + compatible = "simple-bus"; 64 65 ranges = <0x0 0xe0000000 0x00100000>; 65 66 reg = <0xe0000000 0x00000200>; 66 67 bus-frequency = <264000000>;
+6 -10
arch/powerpc/boot/dts/mpc836x_rdk.dts
··· 149 149 }; 150 150 151 151 crypto@30000 { 152 - compatible = "fsl,sec2-crypto"; 152 + compatible = "fsl,sec2.0"; 153 153 reg = <0x30000 0x10000>; 154 - interrupts = <11 8>; 154 + interrupts = <11 0x8>; 155 155 interrupt-parent = <&ipic>; 156 - num-channels = <4>; 157 - channel-fifo-len = <24>; 158 - exec-units-mask = <0x7e>; 159 - /* 160 - * desc mask is for rev1.x, we need runtime fixup 161 - * for >=2.x 162 - */ 163 - descriptor-types-mask = <0x1010ebf>; 156 + fsl,num-channels = <4>; 157 + fsl,channel-fifo-len = <24>; 158 + fsl,exec-units-mask = <0x7e>; 159 + fsl,descriptor-types-mask = <0x01010ebf>; 164 160 }; 165 161 166 162 ipic: interrupt-controller@700 {
+1
arch/powerpc/boot/dts/mpc8377_mds.dts
··· 117 117 #address-cells = <1>; 118 118 #size-cells = <1>; 119 119 device_type = "soc"; 120 + compatible = "simple-bus"; 120 121 ranges = <0x0 0xe0000000 0x00100000>; 121 122 reg = <0xe0000000 0x00000200>; 122 123 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8378_mds.dts
··· 117 117 #address-cells = <1>; 118 118 #size-cells = <1>; 119 119 device_type = "soc"; 120 + compatible = "simple-bus"; 120 121 ranges = <0x0 0xe0000000 0x00100000>; 121 122 reg = <0xe0000000 0x00000200>; 122 123 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8379_mds.dts
··· 117 117 #address-cells = <1>; 118 118 #size-cells = <1>; 119 119 device_type = "soc"; 120 + compatible = "simple-bus"; 120 121 ranges = <0x0 0xe0000000 0x00100000>; 121 122 reg = <0xe0000000 0x00000200>; 122 123 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8536ds.dts
··· 49 49 #address-cells = <1>; 50 50 #size-cells = <1>; 51 51 device_type = "soc"; 52 + compatible = "simple-bus"; 52 53 ranges = <0x0 0xffe00000 0x100000>; 53 54 reg = <0xffe00000 0x1000>; 54 55 bus-frequency = <0>; // Filled out by uboot.
+1
arch/powerpc/boot/dts/mpc8540ads.dts
··· 53 53 #address-cells = <1>; 54 54 #size-cells = <1>; 55 55 device_type = "soc"; 56 + compatible = "simple-bus"; 56 57 ranges = <0x0 0xe0000000 0x100000>; 57 58 reg = <0xe0000000 0x100000>; // CCSRBAR 1M 58 59 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8541cds.dts
··· 53 53 #address-cells = <1>; 54 54 #size-cells = <1>; 55 55 device_type = "soc"; 56 + compatible = "simple-bus"; 56 57 ranges = <0x0 0xe0000000 0x100000>; 57 58 reg = <0xe0000000 0x1000>; // CCSRBAR 1M 58 59 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8544ds.dts
··· 54 54 #address-cells = <1>; 55 55 #size-cells = <1>; 56 56 device_type = "soc"; 57 + compatible = "simple-bus"; 57 58 58 59 ranges = <0x0 0xe0000000 0x100000>; 59 60 reg = <0xe0000000 0x1000>; // CCSRBAR 1M
+1
arch/powerpc/boot/dts/mpc8548cds.dts
··· 58 58 #address-cells = <1>; 59 59 #size-cells = <1>; 60 60 device_type = "soc"; 61 + compatible = "simple-bus"; 61 62 ranges = <0x0 0xe0000000 0x100000>; 62 63 reg = <0xe0000000 0x1000>; // CCSRBAR 63 64 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8555cds.dts
··· 53 53 #address-cells = <1>; 54 54 #size-cells = <1>; 55 55 device_type = "soc"; 56 + compatible = "simple-bus"; 56 57 ranges = <0x0 0xe0000000 0x100000>; 57 58 reg = <0xe0000000 0x1000>; // CCSRBAR 1M 58 59 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8560ads.dts
··· 53 53 #address-cells = <1>; 54 54 #size-cells = <1>; 55 55 device_type = "soc"; 56 + compatible = "simple-bus"; 56 57 ranges = <0x0 0xe0000000 0x100000>; 57 58 reg = <0xe0000000 0x200>; 58 59 bus-frequency = <330000000>;
+1
arch/powerpc/boot/dts/mpc8568mds.dts
··· 60 60 #address-cells = <1>; 61 61 #size-cells = <1>; 62 62 device_type = "soc"; 63 + compatible = "simple-bus"; 63 64 ranges = <0x0 0xe0000000 0x100000>; 64 65 reg = <0xe0000000 0x1000>; 65 66 bus-frequency = <0>;
+1
arch/powerpc/boot/dts/mpc8572ds.dts
··· 68 68 #address-cells = <1>; 69 69 #size-cells = <1>; 70 70 device_type = "soc"; 71 + compatible = "simple-bus"; 71 72 ranges = <0x0 0xffe00000 0x100000>; 72 73 reg = <0xffe00000 0x1000>; // CCSRBAR & soc regs, remove once parse code for immrbase fixed 73 74 bus-frequency = <0>; // Filled out by uboot.
-4
arch/powerpc/kernel/lparcfg.c
··· 636 636 retval = -EIO; 637 637 } else if (retval == H_PARAMETER) { 638 638 retval = -EINVAL; 639 - } else { 640 - printk(KERN_WARNING "%s: received unknown hv return code %ld", 641 - __func__, retval); 642 - retval = -EIO; 643 639 } 644 640 645 641 return retval;
+4 -6
arch/powerpc/kernel/ptrace.c
··· 375 375 flush_vsx_to_thread(target); 376 376 377 377 for (i = 0; i < 32 ; i++) 378 - buf[i] = current->thread.fpr[i][TS_VSRLOWOFFSET]; 378 + buf[i] = target->thread.fpr[i][TS_VSRLOWOFFSET]; 379 379 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 380 380 buf, 0, 32 * sizeof(double)); 381 381 ··· 394 394 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 395 395 buf, 0, 32 * sizeof(double)); 396 396 for (i = 0; i < 32 ; i++) 397 - current->thread.fpr[i][TS_VSRLOWOFFSET] = buf[i]; 397 + target->thread.fpr[i][TS_VSRLOWOFFSET] = buf[i]; 398 398 399 399 400 400 return ret; ··· 975 975 case PTRACE_GETVSRREGS: 976 976 return copy_regset_to_user(child, &user_ppc_native_view, 977 977 REGSET_VSX, 978 - 0, (32 * sizeof(vector128) + 979 - sizeof(u32)), 978 + 0, 32 * sizeof(double), 980 979 (void __user *) data); 981 980 982 981 case PTRACE_SETVSRREGS: 983 982 return copy_regset_from_user(child, &user_ppc_native_view, 984 983 REGSET_VSX, 985 - 0, (32 * sizeof(vector128) + 986 - sizeof(u32)), 984 + 0, 32 * sizeof(double), 987 985 (const void __user *) data); 988 986 #endif 989 987 #ifdef CONFIG_SPE
+2
arch/powerpc/kernel/ptrace32.c
··· 294 294 case PTRACE_SETFPREGS: 295 295 case PTRACE_GETVRREGS: 296 296 case PTRACE_SETVRREGS: 297 + case PTRACE_GETVSRREGS: 298 + case PTRACE_SETVSRREGS: 297 299 case PTRACE_GETREGS64: 298 300 case PTRACE_SETREGS64: 299 301 case PPC_PTRACE_GETFPREGS:
+2 -1
arch/powerpc/mm/Makefile
··· 12 12 mmu_context_$(CONFIG_WORD_SIZE).o 13 13 hash-$(CONFIG_PPC_NATIVE) := hash_native_64.o 14 14 obj-$(CONFIG_PPC64) += hash_utils_64.o \ 15 - slb_low.o slb.o stab.o mmap.o $(hash-y) 15 + slb_low.o slb.o stab.o \ 16 + gup.o mmap.o $(hash-y) 16 17 obj-$(CONFIG_PPC_STD_MMU_32) += ppc_mmu_32.o 17 18 obj-$(CONFIG_PPC_STD_MMU) += hash_low_$(CONFIG_WORD_SIZE).o \ 18 19 tlb_$(CONFIG_WORD_SIZE).o
+280
arch/powerpc/mm/gup.c
··· 1 + /* 2 + * Lockless get_user_pages_fast for powerpc 3 + * 4 + * Copyright (C) 2008 Nick Piggin 5 + * Copyright (C) 2008 Novell Inc. 6 + */ 7 + #undef DEBUG 8 + 9 + #include <linux/sched.h> 10 + #include <linux/mm.h> 11 + #include <linux/hugetlb.h> 12 + #include <linux/vmstat.h> 13 + #include <linux/pagemap.h> 14 + #include <linux/rwsem.h> 15 + #include <asm/pgtable.h> 16 + 17 + /* 18 + * The performance critical leaf functions are made noinline otherwise gcc 19 + * inlines everything into a single function which results in too much 20 + * register pressure. 21 + */ 22 + static noinline int gup_pte_range(pmd_t pmd, unsigned long addr, 23 + unsigned long end, int write, struct page **pages, int *nr) 24 + { 25 + unsigned long mask, result; 26 + pte_t *ptep; 27 + 28 + result = _PAGE_PRESENT|_PAGE_USER; 29 + if (write) 30 + result |= _PAGE_RW; 31 + mask = result | _PAGE_SPECIAL; 32 + 33 + ptep = pte_offset_kernel(&pmd, addr); 34 + do { 35 + pte_t pte = *ptep; 36 + struct page *page; 37 + 38 + if ((pte_val(pte) & mask) != result) 39 + return 0; 40 + VM_BUG_ON(!pfn_valid(pte_pfn(pte))); 41 + page = pte_page(pte); 42 + if (!page_cache_get_speculative(page)) 43 + return 0; 44 + if (unlikely(pte != *ptep)) { 45 + put_page(page); 46 + return 0; 47 + } 48 + pages[*nr] = page; 49 + (*nr)++; 50 + 51 + } while (ptep++, addr += PAGE_SIZE, addr != end); 52 + 53 + return 1; 54 + } 55 + 56 + #ifdef CONFIG_HUGETLB_PAGE 57 + static noinline int gup_huge_pte(pte_t *ptep, struct hstate *hstate, 58 + unsigned long *addr, unsigned long end, 59 + int write, struct page **pages, int *nr) 60 + { 61 + unsigned long mask; 62 + unsigned long pte_end; 63 + struct page *head, *page; 64 + pte_t pte; 65 + int refs; 66 + 67 + pte_end = (*addr + huge_page_size(hstate)) & huge_page_mask(hstate); 68 + if (pte_end < end) 69 + end = pte_end; 70 + 71 + pte = *ptep; 72 + mask = _PAGE_PRESENT|_PAGE_USER; 73 + if (write) 74 + mask |= _PAGE_RW; 75 + if ((pte_val(pte) & mask) != mask) 76 + return 0; 77 + /* hugepages are never "special" */ 78 + VM_BUG_ON(!pfn_valid(pte_pfn(pte))); 79 + 80 + refs = 0; 81 + head = pte_page(pte); 82 + page = head + ((*addr & ~huge_page_mask(hstate)) >> PAGE_SHIFT); 83 + do { 84 + VM_BUG_ON(compound_head(page) != head); 85 + pages[*nr] = page; 86 + (*nr)++; 87 + page++; 88 + refs++; 89 + } while (*addr += PAGE_SIZE, *addr != end); 90 + 91 + if (!page_cache_add_speculative(head, refs)) { 92 + *nr -= refs; 93 + return 0; 94 + } 95 + if (unlikely(pte != *ptep)) { 96 + /* Could be optimized better */ 97 + while (*nr) { 98 + put_page(page); 99 + (*nr)--; 100 + } 101 + } 102 + 103 + return 1; 104 + } 105 + #endif /* CONFIG_HUGETLB_PAGE */ 106 + 107 + static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end, 108 + int write, struct page **pages, int *nr) 109 + { 110 + unsigned long next; 111 + pmd_t *pmdp; 112 + 113 + pmdp = pmd_offset(&pud, addr); 114 + do { 115 + pmd_t pmd = *pmdp; 116 + 117 + next = pmd_addr_end(addr, end); 118 + if (pmd_none(pmd)) 119 + return 0; 120 + if (!gup_pte_range(pmd, addr, next, write, pages, nr)) 121 + return 0; 122 + } while (pmdp++, addr = next, addr != end); 123 + 124 + return 1; 125 + } 126 + 127 + static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end, 128 + int write, struct page **pages, int *nr) 129 + { 130 + unsigned long next; 131 + pud_t *pudp; 132 + 133 + pudp = pud_offset(&pgd, addr); 134 + do { 135 + pud_t pud = *pudp; 136 + 137 + next = pud_addr_end(addr, end); 138 + if (pud_none(pud)) 139 + return 0; 140 + if (!gup_pmd_range(pud, addr, next, write, pages, nr)) 141 + return 0; 142 + } while (pudp++, addr = next, addr != end); 143 + 144 + return 1; 145 + } 146 + 147 + int get_user_pages_fast(unsigned long start, int nr_pages, int write, 148 + struct page **pages) 149 + { 150 + struct mm_struct *mm = current->mm; 151 + unsigned long addr, len, end; 152 + unsigned long next; 153 + pgd_t *pgdp; 154 + int psize, nr = 0; 155 + unsigned int shift; 156 + 157 + pr_debug("%s(%lx,%x,%s)\n", __func__, start, nr_pages, write ? "write" : "read"); 158 + 159 + start &= PAGE_MASK; 160 + addr = start; 161 + len = (unsigned long) nr_pages << PAGE_SHIFT; 162 + end = start + len; 163 + 164 + if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ, 165 + start, len))) 166 + goto slow_irqon; 167 + 168 + pr_debug(" aligned: %lx .. %lx\n", start, end); 169 + 170 + #ifdef CONFIG_HUGETLB_PAGE 171 + /* We bail out on slice boundary crossing when hugetlb is 172 + * enabled in order to not have to deal with two different 173 + * page table formats 174 + */ 175 + if (addr < SLICE_LOW_TOP) { 176 + if (end > SLICE_LOW_TOP) 177 + goto slow_irqon; 178 + 179 + if (unlikely(GET_LOW_SLICE_INDEX(addr) != 180 + GET_LOW_SLICE_INDEX(end - 1))) 181 + goto slow_irqon; 182 + } else { 183 + if (unlikely(GET_HIGH_SLICE_INDEX(addr) != 184 + GET_HIGH_SLICE_INDEX(end - 1))) 185 + goto slow_irqon; 186 + } 187 + #endif /* CONFIG_HUGETLB_PAGE */ 188 + 189 + /* 190 + * XXX: batch / limit 'nr', to avoid large irq off latency 191 + * needs some instrumenting to determine the common sizes used by 192 + * important workloads (eg. DB2), and whether limiting the batch size 193 + * will decrease performance. 194 + * 195 + * It seems like we're in the clear for the moment. Direct-IO is 196 + * the main guy that batches up lots of get_user_pages, and even 197 + * they are limited to 64-at-a-time which is not so many. 198 + */ 199 + /* 200 + * This doesn't prevent pagetable teardown, but does prevent 201 + * the pagetables from being freed on powerpc. 202 + * 203 + * So long as we atomically load page table pointers versus teardown, 204 + * we can follow the address down to the the page and take a ref on it. 205 + */ 206 + local_irq_disable(); 207 + 208 + psize = get_slice_psize(mm, addr); 209 + shift = mmu_psize_defs[psize].shift; 210 + 211 + #ifdef CONFIG_HUGETLB_PAGE 212 + if (unlikely(mmu_huge_psizes[psize])) { 213 + pte_t *ptep; 214 + unsigned long a = addr; 215 + unsigned long sz = ((1UL) << shift); 216 + struct hstate *hstate = size_to_hstate(sz); 217 + 218 + BUG_ON(!hstate); 219 + /* 220 + * XXX: could be optimized to avoid hstate 221 + * lookup entirely (just use shift) 222 + */ 223 + 224 + do { 225 + VM_BUG_ON(shift != mmu_psize_defs[get_slice_psize(mm, a)].shift); 226 + ptep = huge_pte_offset(mm, a); 227 + pr_debug(" %016lx: huge ptep %p\n", a, ptep); 228 + if (!ptep || !gup_huge_pte(ptep, hstate, &a, end, write, pages, 229 + &nr)) 230 + goto slow; 231 + } while (a != end); 232 + } else 233 + #endif /* CONFIG_HUGETLB_PAGE */ 234 + { 235 + pgdp = pgd_offset(mm, addr); 236 + do { 237 + pgd_t pgd = *pgdp; 238 + 239 + VM_BUG_ON(shift != mmu_psize_defs[get_slice_psize(mm, addr)].shift); 240 + pr_debug(" %016lx: normal pgd %p\n", addr, (void *)pgd); 241 + next = pgd_addr_end(addr, end); 242 + if (pgd_none(pgd)) 243 + goto slow; 244 + if (!gup_pud_range(pgd, addr, next, write, pages, &nr)) 245 + goto slow; 246 + } while (pgdp++, addr = next, addr != end); 247 + } 248 + local_irq_enable(); 249 + 250 + VM_BUG_ON(nr != (end - start) >> PAGE_SHIFT); 251 + return nr; 252 + 253 + { 254 + int ret; 255 + 256 + slow: 257 + local_irq_enable(); 258 + slow_irqon: 259 + pr_debug(" slow path ! nr = %d\n", nr); 260 + 261 + /* Try to get the remaining pages with get_user_pages */ 262 + start += nr << PAGE_SHIFT; 263 + pages += nr; 264 + 265 + down_read(&mm->mmap_sem); 266 + ret = get_user_pages(current, mm, start, 267 + (end - start) >> PAGE_SHIFT, write, 0, pages, NULL); 268 + up_read(&mm->mmap_sem); 269 + 270 + /* Have to be a bit careful with return values */ 271 + if (nr > 0) { 272 + if (ret < 0) 273 + ret = nr; 274 + else 275 + ret += nr; 276 + } 277 + 278 + return ret; 279 + } 280 + }
+1
arch/powerpc/platforms/83xx/mpc832x_mds.c
··· 105 105 static struct of_device_id mpc832x_ids[] = { 106 106 { .type = "soc", }, 107 107 { .compatible = "soc", }, 108 + { .compatible = "simple-bus", }, 108 109 { .type = "qe", }, 109 110 { .compatible = "fsl,qe", }, 110 111 {},
+1
arch/powerpc/platforms/83xx/mpc832x_rdb.c
··· 115 115 static struct of_device_id mpc832x_ids[] = { 116 116 { .type = "soc", }, 117 117 { .compatible = "soc", }, 118 + { .compatible = "simple-bus", }, 118 119 { .type = "qe", }, 119 120 { .compatible = "fsl,qe", }, 120 121 {},
+1
arch/powerpc/platforms/83xx/mpc834x_itx.c
··· 41 41 42 42 static struct of_device_id __initdata mpc834x_itx_ids[] = { 43 43 { .compatible = "fsl,pq2pro-localbus", }, 44 + { .compatible = "simple-bus", }, 44 45 {}, 45 46 }; 46 47
+1
arch/powerpc/platforms/83xx/mpc834x_mds.c
··· 111 111 static struct of_device_id mpc834x_ids[] = { 112 112 { .type = "soc", }, 113 113 { .compatible = "soc", }, 114 + { .compatible = "simple-bus", }, 114 115 {}, 115 116 }; 116 117
+1
arch/powerpc/platforms/83xx/mpc836x_mds.c
··· 136 136 static struct of_device_id mpc836x_ids[] = { 137 137 { .type = "soc", }, 138 138 { .compatible = "soc", }, 139 + { .compatible = "simple-bus", }, 139 140 { .type = "qe", }, 140 141 { .compatible = "fsl,qe", }, 141 142 {},
+1
arch/powerpc/platforms/83xx/sbc834x.c
··· 83 83 static struct __initdata of_device_id sbc834x_ids[] = { 84 84 { .type = "soc", }, 85 85 { .compatible = "soc", }, 86 + { .compatible = "simple-bus", }, 86 87 {}, 87 88 }; 88 89
+1
arch/powerpc/platforms/85xx/ksi8560.c
··· 222 222 223 223 static struct of_device_id __initdata of_bus_ids[] = { 224 224 { .type = "soc", }, 225 + { .type = "simple-bus", }, 225 226 { .name = "cpm", }, 226 227 { .name = "localbus", }, 227 228 {},
+1
arch/powerpc/platforms/85xx/mpc8536_ds.c
··· 91 91 static struct of_device_id __initdata mpc8536_ds_ids[] = { 92 92 { .type = "soc", }, 93 93 { .compatible = "soc", }, 94 + { .compatible = "simple-bus", }, 94 95 {}, 95 96 }; 96 97
+1
arch/powerpc/platforms/85xx/mpc85xx_ads.c
··· 230 230 { .type = "soc", }, 231 231 { .name = "cpm", }, 232 232 { .name = "localbus", }, 233 + { .compatible = "simple-bus", }, 233 234 {}, 234 235 }; 235 236
+1
arch/powerpc/platforms/85xx/mpc85xx_ds.c
··· 186 186 static struct of_device_id __initdata mpc85xxds_ids[] = { 187 187 { .type = "soc", }, 188 188 { .compatible = "soc", }, 189 + { .compatible = "simple-bus", }, 189 190 {}, 190 191 }; 191 192
+1
arch/powerpc/platforms/85xx/mpc85xx_mds.c
··· 260 260 static struct of_device_id mpc85xx_ids[] = { 261 261 { .type = "soc", }, 262 262 { .compatible = "soc", }, 263 + { .compatible = "simple-bus", }, 263 264 { .type = "qe", }, 264 265 { .compatible = "fsl,qe", }, 265 266 {},
+1
arch/powerpc/platforms/85xx/sbc8560.c
··· 217 217 { .type = "soc", }, 218 218 { .name = "cpm", }, 219 219 { .name = "localbus", }, 220 + { .compatible = "simple-bus", }, 220 221 {}, 221 222 }; 222 223
+10
arch/powerpc/platforms/8xx/Kconfig
··· 105 105 106 106 If in doubt, say Y here. 107 107 108 + config 8xx_GPIO 109 + bool "GPIO API Support" 110 + select GENERIC_GPIO 111 + select ARCH_REQUIRE_GPIOLIB 112 + help 113 + Saying Y here will cause the ports on an MPC8xx processor to be used 114 + with the GPIO API. If you say N here, the kernel needs less memory. 115 + 116 + If in doubt, say Y here. 117 + 108 118 config 8xx_CPU6 109 119 bool "CPU6 Silicon Errata (860 Pre Rev. C)" 110 120 help
+3
arch/powerpc/platforms/Kconfig
··· 254 254 select CPM 255 255 select PPC_LIB_RHEAP 256 256 select PPC_PCI_CHOICE 257 + select ARCH_REQUIRE_GPIOLIB 258 + select GENERIC_GPIO 257 259 help 258 260 The CPM2 (Communications Processor Module) is a coprocessor on 259 261 embedded CPUs made by Freescale. Selecting this option means that ··· 283 281 284 282 config CPM 285 283 bool 284 + select PPC_CLOCK 286 285 287 286 config OF_RTC 288 287 bool
+262 -5
arch/powerpc/sysdev/cpm1.c
··· 30 30 #include <linux/interrupt.h> 31 31 #include <linux/irq.h> 32 32 #include <linux/module.h> 33 + #include <linux/spinlock.h> 33 34 #include <asm/page.h> 34 35 #include <asm/pgtable.h> 35 36 #include <asm/8xx_immap.h> ··· 42 41 #include <asm/cpm.h> 43 42 44 43 #include <asm/fs_pd.h> 44 + 45 + #ifdef CONFIG_8xx_GPIO 46 + #include <linux/of_gpio.h> 47 + #endif 45 48 46 49 #define CPM_MAP_SIZE (0x4000) 47 50 ··· 295 290 __be16 res[3]; 296 291 }; 297 292 298 - struct cpm_ioport32 { 299 - __be32 dir, par, sor; 293 + struct cpm_ioport32b { 294 + __be32 dir, par, odr, dat; 295 + }; 296 + 297 + struct cpm_ioport32e { 298 + __be32 dir, par, sor, odr, dat; 300 299 }; 301 300 302 301 static void cpm1_set_pin32(int port, int pin, int flags) 303 302 { 304 - struct cpm_ioport32 __iomem *iop; 303 + struct cpm_ioport32e __iomem *iop; 305 304 pin = 1 << (31 - pin); 306 305 307 306 if (port == CPM_PORTB) 308 - iop = (struct cpm_ioport32 __iomem *) 307 + iop = (struct cpm_ioport32e __iomem *) 309 308 &mpc8xx_immr->im_cpm.cp_pbdir; 310 309 else 311 - iop = (struct cpm_ioport32 __iomem *) 310 + iop = (struct cpm_ioport32e __iomem *) 312 311 &mpc8xx_immr->im_cpm.cp_pedir; 313 312 314 313 if (flags & CPM_PIN_OUTPUT) ··· 507 498 508 499 return 0; 509 500 } 501 + 502 + /* 503 + * GPIO LIB API implementation 504 + */ 505 + #ifdef CONFIG_8xx_GPIO 506 + 507 + struct cpm1_gpio16_chip { 508 + struct of_mm_gpio_chip mm_gc; 509 + spinlock_t lock; 510 + 511 + /* shadowed data register to clear/set bits safely */ 512 + u16 cpdata; 513 + }; 514 + 515 + static inline struct cpm1_gpio16_chip * 516 + to_cpm1_gpio16_chip(struct of_mm_gpio_chip *mm_gc) 517 + { 518 + return container_of(mm_gc, struct cpm1_gpio16_chip, mm_gc); 519 + } 520 + 521 + static void cpm1_gpio16_save_regs(struct of_mm_gpio_chip *mm_gc) 522 + { 523 + struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); 524 + struct cpm_ioport16 __iomem *iop = mm_gc->regs; 525 + 526 + cpm1_gc->cpdata = in_be16(&iop->dat); 527 + } 528 + 529 + static int cpm1_gpio16_get(struct gpio_chip *gc, unsigned int gpio) 530 + { 531 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 532 + struct cpm_ioport16 __iomem *iop = mm_gc->regs; 533 + u16 pin_mask; 534 + 535 + pin_mask = 1 << (15 - gpio); 536 + 537 + return !!(in_be16(&iop->dat) & pin_mask); 538 + } 539 + 540 + static void cpm1_gpio16_set(struct gpio_chip *gc, unsigned int gpio, int value) 541 + { 542 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 543 + struct cpm1_gpio16_chip *cpm1_gc = to_cpm1_gpio16_chip(mm_gc); 544 + struct cpm_ioport16 __iomem *iop = mm_gc->regs; 545 + unsigned long flags; 546 + u16 pin_mask = 1 << (15 - gpio); 547 + 548 + spin_lock_irqsave(&cpm1_gc->lock, flags); 549 + 550 + if (value) 551 + cpm1_gc->cpdata |= pin_mask; 552 + else 553 + cpm1_gc->cpdata &= ~pin_mask; 554 + 555 + out_be16(&iop->dat, cpm1_gc->cpdata); 556 + 557 + spin_unlock_irqrestore(&cpm1_gc->lock, flags); 558 + } 559 + 560 + static int cpm1_gpio16_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 561 + { 562 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 563 + struct cpm_ioport16 __iomem *iop = mm_gc->regs; 564 + u16 pin_mask; 565 + 566 + pin_mask = 1 << (15 - gpio); 567 + 568 + setbits16(&iop->dir, pin_mask); 569 + 570 + cpm1_gpio16_set(gc, gpio, val); 571 + 572 + return 0; 573 + } 574 + 575 + static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio) 576 + { 577 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 578 + struct cpm_ioport16 __iomem *iop = mm_gc->regs; 579 + u16 pin_mask; 580 + 581 + pin_mask = 1 << (15 - gpio); 582 + 583 + clrbits16(&iop->dir, pin_mask); 584 + 585 + return 0; 586 + } 587 + 588 + int cpm1_gpiochip_add16(struct device_node *np) 589 + { 590 + struct cpm1_gpio16_chip *cpm1_gc; 591 + struct of_mm_gpio_chip *mm_gc; 592 + struct of_gpio_chip *of_gc; 593 + struct gpio_chip *gc; 594 + 595 + cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); 596 + if (!cpm1_gc) 597 + return -ENOMEM; 598 + 599 + spin_lock_init(&cpm1_gc->lock); 600 + 601 + mm_gc = &cpm1_gc->mm_gc; 602 + of_gc = &mm_gc->of_gc; 603 + gc = &of_gc->gc; 604 + 605 + mm_gc->save_regs = cpm1_gpio16_save_regs; 606 + of_gc->gpio_cells = 2; 607 + gc->ngpio = 16; 608 + gc->direction_input = cpm1_gpio16_dir_in; 609 + gc->direction_output = cpm1_gpio16_dir_out; 610 + gc->get = cpm1_gpio16_get; 611 + gc->set = cpm1_gpio16_set; 612 + 613 + return of_mm_gpiochip_add(np, mm_gc); 614 + } 615 + 616 + struct cpm1_gpio32_chip { 617 + struct of_mm_gpio_chip mm_gc; 618 + spinlock_t lock; 619 + 620 + /* shadowed data register to clear/set bits safely */ 621 + u32 cpdata; 622 + }; 623 + 624 + static inline struct cpm1_gpio32_chip * 625 + to_cpm1_gpio32_chip(struct of_mm_gpio_chip *mm_gc) 626 + { 627 + return container_of(mm_gc, struct cpm1_gpio32_chip, mm_gc); 628 + } 629 + 630 + static void cpm1_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 631 + { 632 + struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); 633 + struct cpm_ioport32b __iomem *iop = mm_gc->regs; 634 + 635 + cpm1_gc->cpdata = in_be32(&iop->dat); 636 + } 637 + 638 + static int cpm1_gpio32_get(struct gpio_chip *gc, unsigned int gpio) 639 + { 640 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 641 + struct cpm_ioport32b __iomem *iop = mm_gc->regs; 642 + u32 pin_mask; 643 + 644 + pin_mask = 1 << (31 - gpio); 645 + 646 + return !!(in_be32(&iop->dat) & pin_mask); 647 + } 648 + 649 + static void cpm1_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value) 650 + { 651 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 652 + struct cpm1_gpio32_chip *cpm1_gc = to_cpm1_gpio32_chip(mm_gc); 653 + struct cpm_ioport32b __iomem *iop = mm_gc->regs; 654 + unsigned long flags; 655 + u32 pin_mask = 1 << (31 - gpio); 656 + 657 + spin_lock_irqsave(&cpm1_gc->lock, flags); 658 + 659 + if (value) 660 + cpm1_gc->cpdata |= pin_mask; 661 + else 662 + cpm1_gc->cpdata &= ~pin_mask; 663 + 664 + out_be32(&iop->dat, cpm1_gc->cpdata); 665 + 666 + spin_unlock_irqrestore(&cpm1_gc->lock, flags); 667 + } 668 + 669 + static int cpm1_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 670 + { 671 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 672 + struct cpm_ioport32b __iomem *iop = mm_gc->regs; 673 + u32 pin_mask; 674 + 675 + pin_mask = 1 << (31 - gpio); 676 + 677 + setbits32(&iop->dir, pin_mask); 678 + 679 + cpm1_gpio32_set(gc, gpio, val); 680 + 681 + return 0; 682 + } 683 + 684 + static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio) 685 + { 686 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 687 + struct cpm_ioport32b __iomem *iop = mm_gc->regs; 688 + u32 pin_mask; 689 + 690 + pin_mask = 1 << (31 - gpio); 691 + 692 + clrbits32(&iop->dir, pin_mask); 693 + 694 + return 0; 695 + } 696 + 697 + int cpm1_gpiochip_add32(struct device_node *np) 698 + { 699 + struct cpm1_gpio32_chip *cpm1_gc; 700 + struct of_mm_gpio_chip *mm_gc; 701 + struct of_gpio_chip *of_gc; 702 + struct gpio_chip *gc; 703 + 704 + cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL); 705 + if (!cpm1_gc) 706 + return -ENOMEM; 707 + 708 + spin_lock_init(&cpm1_gc->lock); 709 + 710 + mm_gc = &cpm1_gc->mm_gc; 711 + of_gc = &mm_gc->of_gc; 712 + gc = &of_gc->gc; 713 + 714 + mm_gc->save_regs = cpm1_gpio32_save_regs; 715 + of_gc->gpio_cells = 2; 716 + gc->ngpio = 32; 717 + gc->direction_input = cpm1_gpio32_dir_in; 718 + gc->direction_output = cpm1_gpio32_dir_out; 719 + gc->get = cpm1_gpio32_get; 720 + gc->set = cpm1_gpio32_set; 721 + 722 + return of_mm_gpiochip_add(np, mm_gc); 723 + } 724 + 725 + static int cpm_init_par_io(void) 726 + { 727 + struct device_node *np; 728 + 729 + for_each_compatible_node(np, NULL, "fsl,cpm1-pario-bank-a") 730 + cpm1_gpiochip_add16(np); 731 + 732 + for_each_compatible_node(np, NULL, "fsl,cpm1-pario-bank-b") 733 + cpm1_gpiochip_add32(np); 734 + 735 + for_each_compatible_node(np, NULL, "fsl,cpm1-pario-bank-c") 736 + cpm1_gpiochip_add16(np); 737 + 738 + for_each_compatible_node(np, NULL, "fsl,cpm1-pario-bank-d") 739 + cpm1_gpiochip_add16(np); 740 + 741 + /* Port E uses CPM2 layout */ 742 + for_each_compatible_node(np, NULL, "fsl,cpm1-pario-bank-e") 743 + cpm2_gpiochip_add32(np); 744 + return 0; 745 + } 746 + arch_initcall(cpm_init_par_io); 747 + 748 + #endif /* CONFIG_8xx_GPIO */
+15 -30
arch/powerpc/sysdev/cpm2.c
··· 115 115 * Baud rate clocks are zero-based in the driver code (as that maps 116 116 * to port numbers). Documentation uses 1-based numbering. 117 117 */ 118 - #define BRG_INT_CLK (get_brgfreq()) 119 - #define BRG_UART_CLK (BRG_INT_CLK/16) 120 - 121 - /* This function is used by UARTS, or anything else that uses a 16x 122 - * oversampled clock. 123 - */ 124 - void 125 - cpm_setbrg(uint brg, uint rate) 118 + void __cpm2_setbrg(uint brg, uint rate, uint clk, int div16, int src) 126 119 { 127 120 u32 __iomem *bp; 121 + u32 val; 128 122 129 123 /* This is good enough to get SMCs running..... 130 124 */ ··· 129 135 brg -= 4; 130 136 } 131 137 bp += brg; 132 - out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN); 133 - 134 - cpm2_unmap(bp); 135 - } 136 - 137 - /* This function is used to set high speed synchronous baud rate 138 - * clocks. 139 - */ 140 - void 141 - cpm2_fastbrg(uint brg, uint rate, int div16) 142 - { 143 - u32 __iomem *bp; 144 - u32 val; 145 - 146 - if (brg < 4) { 147 - bp = cpm2_map_size(im_brgc1, 16); 148 - } else { 149 - bp = cpm2_map_size(im_brgc5, 16); 150 - brg -= 4; 151 - } 152 - bp += brg; 153 - val = ((BRG_INT_CLK / rate) << 1) | CPM_BRG_EN; 138 + val = (((clk / rate) - 1) << 1) | CPM_BRG_EN | src; 154 139 if (div16) 155 140 val |= CPM_BRG_DIV16; 156 141 157 142 out_be32(bp, val); 158 143 cpm2_unmap(bp); 159 144 } 145 + EXPORT_SYMBOL(__cpm2_setbrg); 160 146 161 147 int cpm2_clk_setup(enum cpm_clk_target target, int clock, int mode) 162 148 { ··· 351 377 else 352 378 clrbits32(&iop[port].odr, pin); 353 379 } 380 + 381 + static int cpm_init_par_io(void) 382 + { 383 + struct device_node *np; 384 + 385 + for_each_compatible_node(np, NULL, "fsl,cpm2-pario-bank") 386 + cpm2_gpiochip_add32(np); 387 + return 0; 388 + } 389 + arch_initcall(cpm_init_par_io); 390 +
+123
arch/powerpc/sysdev/cpm_common.c
··· 19 19 20 20 #include <linux/init.h> 21 21 #include <linux/of_device.h> 22 + #include <linux/spinlock.h> 23 + #include <linux/of.h> 22 24 23 25 #include <asm/udbg.h> 24 26 #include <asm/io.h> ··· 29 27 #include <asm/cpm.h> 30 28 31 29 #include <mm/mmu_decl.h> 30 + 31 + #if defined(CONFIG_CPM2) || defined(CONFIG_8xx_GPIO) 32 + #include <linux/of_gpio.h> 33 + #endif 32 34 33 35 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM 34 36 static u32 __iomem *cpm_udbg_txdesc = ··· 213 207 return muram_pbase + ((u8 __iomem *)addr - muram_vbase); 214 208 } 215 209 EXPORT_SYMBOL(cpm_muram_dma); 210 + 211 + #if defined(CONFIG_CPM2) || defined(CONFIG_8xx_GPIO) 212 + 213 + struct cpm2_ioports { 214 + u32 dir, par, sor, odr, dat; 215 + u32 res[3]; 216 + }; 217 + 218 + struct cpm2_gpio32_chip { 219 + struct of_mm_gpio_chip mm_gc; 220 + spinlock_t lock; 221 + 222 + /* shadowed data register to clear/set bits safely */ 223 + u32 cpdata; 224 + }; 225 + 226 + static inline struct cpm2_gpio32_chip * 227 + to_cpm2_gpio32_chip(struct of_mm_gpio_chip *mm_gc) 228 + { 229 + return container_of(mm_gc, struct cpm2_gpio32_chip, mm_gc); 230 + } 231 + 232 + static void cpm2_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc) 233 + { 234 + struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); 235 + struct cpm2_ioports __iomem *iop = mm_gc->regs; 236 + 237 + cpm2_gc->cpdata = in_be32(&iop->dat); 238 + } 239 + 240 + static int cpm2_gpio32_get(struct gpio_chip *gc, unsigned int gpio) 241 + { 242 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 243 + struct cpm2_ioports __iomem *iop = mm_gc->regs; 244 + u32 pin_mask; 245 + 246 + pin_mask = 1 << (31 - gpio); 247 + 248 + return !!(in_be32(&iop->dat) & pin_mask); 249 + } 250 + 251 + static void cpm2_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value) 252 + { 253 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 254 + struct cpm2_gpio32_chip *cpm2_gc = to_cpm2_gpio32_chip(mm_gc); 255 + struct cpm2_ioports __iomem *iop = mm_gc->regs; 256 + unsigned long flags; 257 + u32 pin_mask = 1 << (31 - gpio); 258 + 259 + spin_lock_irqsave(&cpm2_gc->lock, flags); 260 + 261 + if (value) 262 + cpm2_gc->cpdata |= pin_mask; 263 + else 264 + cpm2_gc->cpdata &= ~pin_mask; 265 + 266 + out_be32(&iop->dat, cpm2_gc->cpdata); 267 + 268 + spin_unlock_irqrestore(&cpm2_gc->lock, flags); 269 + } 270 + 271 + static int cpm2_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) 272 + { 273 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 274 + struct cpm2_ioports __iomem *iop = mm_gc->regs; 275 + u32 pin_mask; 276 + 277 + pin_mask = 1 << (31 - gpio); 278 + 279 + setbits32(&iop->dir, pin_mask); 280 + 281 + cpm2_gpio32_set(gc, gpio, val); 282 + 283 + return 0; 284 + } 285 + 286 + static int cpm2_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio) 287 + { 288 + struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 289 + struct cpm2_ioports __iomem *iop = mm_gc->regs; 290 + u32 pin_mask; 291 + 292 + pin_mask = 1 << (31 - gpio); 293 + 294 + clrbits32(&iop->dir, pin_mask); 295 + 296 + return 0; 297 + } 298 + 299 + int cpm2_gpiochip_add32(struct device_node *np) 300 + { 301 + struct cpm2_gpio32_chip *cpm2_gc; 302 + struct of_mm_gpio_chip *mm_gc; 303 + struct of_gpio_chip *of_gc; 304 + struct gpio_chip *gc; 305 + 306 + cpm2_gc = kzalloc(sizeof(*cpm2_gc), GFP_KERNEL); 307 + if (!cpm2_gc) 308 + return -ENOMEM; 309 + 310 + spin_lock_init(&cpm2_gc->lock); 311 + 312 + mm_gc = &cpm2_gc->mm_gc; 313 + of_gc = &mm_gc->of_gc; 314 + gc = &of_gc->gc; 315 + 316 + mm_gc->save_regs = cpm2_gpio32_save_regs; 317 + of_gc->gpio_cells = 2; 318 + gc->ngpio = 32; 319 + gc->direction_input = cpm2_gpio32_dir_in; 320 + gc->direction_output = cpm2_gpio32_dir_out; 321 + gc->get = cpm2_gpio32_get; 322 + gc->set = cpm2_gpio32_set; 323 + 324 + return of_mm_gpiochip_add(np, mm_gc); 325 + } 326 + #endif /* CONFIG_CPM2 || CONFIG_8xx_GPIO */
+17 -6
arch/powerpc/sysdev/rtc_cmos_setup.c
··· 21 21 struct device_node *np; 22 22 struct platform_device *pd; 23 23 struct resource res[2]; 24 + unsigned int num_res = 1; 24 25 int ret; 25 26 26 27 memset(&res, 0, sizeof(res)); ··· 42 41 if (res[0].start != RTC_PORT(0)) 43 42 return -EINVAL; 44 43 45 - /* Use a fixed interrupt value of 8 since on PPC if we are using this 46 - * its off an i8259 which we ensure has interrupt numbers 0..15. */ 47 - res[1].start = 8; 48 - res[1].end = 8; 49 - res[1].flags = IORESOURCE_IRQ; 44 + np = of_find_compatible_node(NULL, NULL, "chrp,iic"); 45 + if (!np) 46 + np = of_find_compatible_node(NULL, NULL, "pnpPNP,000"); 47 + if (np) { 48 + of_node_put(np); 49 + /* 50 + * Use a fixed interrupt value of 8 since on PPC if we are 51 + * using this its off an i8259 which we ensure has interrupt 52 + * numbers 0..15. 53 + */ 54 + res[1].start = 8; 55 + res[1].end = 8; 56 + res[1].flags = IORESOURCE_IRQ; 57 + num_res++; 58 + } 50 59 51 60 pd = platform_device_register_simple("rtc_cmos", -1, 52 - &res[0], 2); 61 + &res[0], num_res); 53 62 54 63 if (IS_ERR(pd)) 55 64 return PTR_ERR(pd);
+2 -2
drivers/char/ipmi/ipmi_si_intf.c
··· 66 66 #include <linux/ctype.h> 67 67 68 68 #ifdef CONFIG_PPC_OF 69 - #include <asm/of_device.h> 70 - #include <asm/of_platform.h> 69 + #include <linux/of_device.h> 70 + #include <linux/of_platform.h> 71 71 #endif 72 72 73 73 #define PFX "ipmi_si: "
+9 -4
drivers/ide/ppc/pmac.c
··· 1086 1086 /* Make sure we have sane timings */ 1087 1087 sanitize_timings(pmif); 1088 1088 1089 + host = ide_host_alloc(&d, hws); 1090 + if (host == NULL) 1091 + return -ENOMEM; 1092 + hwif = host->ports[0]; 1093 + 1089 1094 #ifndef CONFIG_PPC64 1090 1095 /* XXX FIXME: Media bay stuff need re-organizing */ 1091 1096 if (np->parent && np->parent->name ··· 1124 1119 pmif->mdev ? "macio" : "PCI", pmif->aapl_bus_id, 1125 1120 pmif->mediabay ? " (mediabay)" : "", hw->irq); 1126 1121 1127 - rc = ide_host_add(&d, hws, &host); 1128 - if (rc) 1122 + rc = ide_host_register(host, &d, hws); 1123 + if (rc) { 1124 + ide_host_free(host); 1129 1125 return rc; 1130 - 1131 - hwif = host->ports[0]; 1126 + } 1132 1127 1133 1128 return 0; 1134 1129 }
+11
drivers/serial/cpm_uart/cpm_uart.h
··· 50 50 51 51 #define SCC_WAIT_CLOSING 100 52 52 53 + #define GPIO_CTS 0 54 + #define GPIO_RTS 1 55 + #define GPIO_DCD 2 56 + #define GPIO_DSR 3 57 + #define GPIO_DTR 4 58 + #define GPIO_RI 5 59 + 60 + #define NUM_GPIOS (GPIO_RI+1) 61 + 53 62 struct uart_cpm_port { 54 63 struct uart_port port; 55 64 u16 rx_nrfifos; ··· 77 68 unsigned char *rx_buf; 78 69 u32 flags; 79 70 void (*set_lineif)(struct uart_cpm_port *); 71 + struct clk *clk; 80 72 u8 brg; 81 73 uint dp_addr; 82 74 void *mem_addr; ··· 92 82 int wait_closing; 93 83 /* value to combine with opcode to form cpm command */ 94 84 u32 command; 85 + int gpios[NUM_GPIOS]; 95 86 }; 96 87 97 88 extern int cpm_uart_nr;
+56 -10
drivers/serial/cpm_uart/cpm_uart_core.c
··· 43 43 #include <linux/dma-mapping.h> 44 44 #include <linux/fs_uart_pd.h> 45 45 #include <linux/of_platform.h> 46 + #include <linux/gpio.h> 47 + #include <linux/of_gpio.h> 48 + #include <linux/clk.h> 46 49 47 50 #include <asm/io.h> 48 51 #include <asm/irq.h> ··· 99 96 100 97 static void cpm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 101 98 { 102 - /* Whee. Do nothing. */ 99 + struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 100 + 101 + if (pinfo->gpios[GPIO_RTS] >= 0) 102 + gpio_set_value(pinfo->gpios[GPIO_RTS], !(mctrl & TIOCM_RTS)); 103 + 104 + if (pinfo->gpios[GPIO_DTR] >= 0) 105 + gpio_set_value(pinfo->gpios[GPIO_DTR], !(mctrl & TIOCM_DTR)); 103 106 } 104 107 105 108 static unsigned int cpm_uart_get_mctrl(struct uart_port *port) 106 109 { 107 - /* Whee. Do nothing. */ 108 - return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; 110 + struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; 111 + unsigned int mctrl = TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; 112 + 113 + if (pinfo->gpios[GPIO_CTS] >= 0) { 114 + if (gpio_get_value(pinfo->gpios[GPIO_CTS])) 115 + mctrl &= ~TIOCM_CTS; 116 + } 117 + 118 + if (pinfo->gpios[GPIO_DSR] >= 0) { 119 + if (gpio_get_value(pinfo->gpios[GPIO_DSR])) 120 + mctrl &= ~TIOCM_DSR; 121 + } 122 + 123 + if (pinfo->gpios[GPIO_DCD] >= 0) { 124 + if (gpio_get_value(pinfo->gpios[GPIO_DCD])) 125 + mctrl &= ~TIOCM_CAR; 126 + } 127 + 128 + if (pinfo->gpios[GPIO_RI] >= 0) { 129 + if (!gpio_get_value(pinfo->gpios[GPIO_RI])) 130 + mctrl |= TIOCM_RNG; 131 + } 132 + 133 + return mctrl; 109 134 } 110 135 111 136 /* ··· 597 566 out_be16(&sccp->scc_psmr, (sbits << 12) | scval); 598 567 } 599 568 600 - cpm_set_brg(pinfo->brg - 1, baud); 569 + if (pinfo->clk) 570 + clk_set_rate(pinfo->clk, baud); 571 + else 572 + cpm_set_brg(pinfo->brg - 1, baud); 601 573 spin_unlock_irqrestore(&port->lock, flags); 602 574 } 603 575 ··· 1025 991 void __iomem *mem, *pram; 1026 992 int len; 1027 993 int ret; 994 + int i; 1028 995 1029 - data = of_get_property(np, "fsl,cpm-brg", &len); 1030 - if (!data || len != 4) { 1031 - printk(KERN_ERR "CPM UART %s has no/invalid " 1032 - "fsl,cpm-brg property.\n", np->name); 1033 - return -EINVAL; 996 + data = of_get_property(np, "clock", NULL); 997 + if (data) { 998 + struct clk *clk = clk_get(NULL, (const char*)data); 999 + if (!IS_ERR(clk)) 1000 + pinfo->clk = clk; 1034 1001 } 1035 - pinfo->brg = *data; 1002 + if (!pinfo->clk) { 1003 + data = of_get_property(np, "fsl,cpm-brg", &len); 1004 + if (!data || len != 4) { 1005 + printk(KERN_ERR "CPM UART %s has no/invalid " 1006 + "fsl,cpm-brg property.\n", np->name); 1007 + return -EINVAL; 1008 + } 1009 + pinfo->brg = *data; 1010 + } 1036 1011 1037 1012 data = of_get_property(np, "fsl,cpm-command", &len); 1038 1013 if (!data || len != 4) { ··· 1092 1049 ret = -EINVAL; 1093 1050 goto out_pram; 1094 1051 } 1052 + 1053 + for (i = 0; i < NUM_GPIOS; i++) 1054 + pinfo->gpios[i] = of_get_gpio(np, i); 1095 1055 1096 1056 return cpm_uart_request_port(&pinfo->port); 1097 1057
+3
include/asm-powerpc/cpm.h
··· 3 3 4 4 #include <linux/compiler.h> 5 5 #include <linux/types.h> 6 + #include <linux/of.h> 6 7 7 8 /* Opcodes common to CPM1 and CPM2 8 9 */ ··· 100 99 unsigned long cpm_muram_offset(void __iomem *addr); 101 100 dma_addr_t cpm_muram_dma(void __iomem *addr); 102 101 int cpm_command(u32 command, u8 opcode); 102 + 103 + int cpm2_gpiochip_add32(struct device_node *np); 103 104 104 105 #endif
+33 -13
include/asm-powerpc/cpm2.h
··· 12 12 13 13 #include <asm/immap_cpm2.h> 14 14 #include <asm/cpm.h> 15 + #include <sysdev/fsl_soc.h> 15 16 16 17 #ifdef CONFIG_PPC_85xx 17 18 #define CPM_MAP_ADDR (get_immrbase() + 0x80000) ··· 94 93 #define cpm_dpfree cpm_muram_free 95 94 #define cpm_dpram_addr cpm_muram_addr 96 95 97 - extern void cpm_setbrg(uint brg, uint rate); 98 - extern void cpm2_fastbrg(uint brg, uint rate, int div16); 99 96 extern void cpm2_reset(void); 97 + 98 + /* Baud rate generators. 99 + */ 100 + #define CPM_BRG_RST ((uint)0x00020000) 101 + #define CPM_BRG_EN ((uint)0x00010000) 102 + #define CPM_BRG_EXTC_INT ((uint)0x00000000) 103 + #define CPM_BRG_EXTC_CLK3_9 ((uint)0x00004000) 104 + #define CPM_BRG_EXTC_CLK5_15 ((uint)0x00008000) 105 + #define CPM_BRG_ATB ((uint)0x00002000) 106 + #define CPM_BRG_CD_MASK ((uint)0x00001ffe) 107 + #define CPM_BRG_DIV16 ((uint)0x00000001) 108 + 109 + #define CPM2_BRG_INT_CLK (get_brgfreq()) 110 + #define CPM2_BRG_UART_CLK (CPM2_BRG_INT_CLK/16) 111 + 112 + extern void __cpm2_setbrg(uint brg, uint rate, uint clk, int div16, int src); 113 + 114 + /* This function is used by UARTS, or anything else that uses a 16x 115 + * oversampled clock. 116 + */ 117 + static inline void cpm_setbrg(uint brg, uint rate) 118 + { 119 + __cpm2_setbrg(brg, rate, CPM2_BRG_UART_CLK, 0, CPM_BRG_EXTC_INT); 120 + } 121 + 122 + /* This function is used to set high speed synchronous baud rate 123 + * clocks. 124 + */ 125 + static inline void cpm2_fastbrg(uint brg, uint rate, int div16) 126 + { 127 + __cpm2_setbrg(brg, rate, CPM2_BRG_INT_CLK, div16, CPM_BRG_EXTC_INT); 128 + } 100 129 101 130 /* Function code bits, usually generic to devices. 102 131 */ ··· 225 194 #define SMCM_BSY ((unsigned char)0x04) 226 195 #define SMCM_TX ((unsigned char)0x02) 227 196 #define SMCM_RX ((unsigned char)0x01) 228 - 229 - /* Baud rate generators. 230 - */ 231 - #define CPM_BRG_RST ((uint)0x00020000) 232 - #define CPM_BRG_EN ((uint)0x00010000) 233 - #define CPM_BRG_EXTC_INT ((uint)0x00000000) 234 - #define CPM_BRG_EXTC_CLK3_9 ((uint)0x00004000) 235 - #define CPM_BRG_EXTC_CLK5_15 ((uint)0x00008000) 236 - #define CPM_BRG_ATB ((uint)0x00002000) 237 - #define CPM_BRG_CD_MASK ((uint)0x00001ffe) 238 - #define CPM_BRG_DIV16 ((uint)0x00000001) 239 197 240 198 /* SCCs. 241 199 */
+2
include/asm-powerpc/pgtable-ppc64.h
··· 461 461 return pt; 462 462 } 463 463 464 + pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long address); 465 + 464 466 #endif /* __ASSEMBLY__ */ 465 467 466 468 #endif /* _ASM_POWERPC_PGTABLE_PPC64_H_ */
+23
include/linux/pagemap.h
··· 143 143 return 1; 144 144 } 145 145 146 + /* 147 + * Same as above, but add instead of inc (could just be merged) 148 + */ 149 + static inline int page_cache_add_speculative(struct page *page, int count) 150 + { 151 + VM_BUG_ON(in_interrupt()); 152 + 153 + #if !defined(CONFIG_SMP) && defined(CONFIG_CLASSIC_RCU) 154 + # ifdef CONFIG_PREEMPT 155 + VM_BUG_ON(!in_atomic()); 156 + # endif 157 + VM_BUG_ON(page_count(page) == 0); 158 + atomic_add(count, &page->_count); 159 + 160 + #else 161 + if (unlikely(!atomic_add_unless(&page->_count, count, 0))) 162 + return 0; 163 + #endif 164 + VM_BUG_ON(PageCompound(page) && page != compound_head(page)); 165 + 166 + return 1; 167 + } 168 + 146 169 static inline int page_freeze_refs(struct page *page, int count) 147 170 { 148 171 return likely(atomic_cmpxchg(&page->_count, count, 0) == count);