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

Merge tag 'arm-apple-m1-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull ARM Apple M1 platform support from Arnd Bergmann:
"The Apple M1 is the processor used it all current generation Apple
Macintosh computers. Support for this platform so far is rudimentary,
but it boots and can use framebuffer and serial console over a special
USB cable.

Support for several essential on-chip devices (USB, PCIe, IOMMU, NVMe)
is work in progress but was not ready in time.

A very detailed description of what works is in the commit message of
commit 1bb2fd3880d4 ("Merge tag 'm1-soc-bringup-v5' [..]") and on the
AsahiLinux wiki"

Link: https://lore.kernel.org/linux-arm-kernel/bdb18e9f-fcd7-1e31-2224-19c0e5090706@marcan.st/

* tag 'arm-apple-m1-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
asm-generic/io.h: Unbork ioremap_np() declaration
arm64: apple: Add initial Apple Mac mini (M1, 2020) devicetree
dt-bindings: display: Add apple,simple-framebuffer
arm64: Kconfig: Introduce CONFIG_ARCH_APPLE
irqchip/apple-aic: Add support for the Apple Interrupt Controller
dt-bindings: interrupt-controller: Add DT bindings for apple-aic
arm64: Move ICH_ sysreg bits from arm-gic-v3.h to sysreg.h
of/address: Add infrastructure to declare MMIO as non-posted
asm-generic/io.h: implement pci_remap_cfgspace using ioremap_np
arm64: Implement ioremap_np() to map MMIO as nGnRnE
docs: driver-api: device-io: Document ioremap() variants & access funcs
docs: driver-api: device-io: Document I/O access functions
asm-generic/io.h: Add a non-posted variant of ioremap()
arm64: arch_timer: Implement support for interrupt-names
dt-bindings: timer: arm,arch_timer: Add interrupt-names support
arm64: cputype: Add CPU implementor & types for the Apple M1 cores
dt-bindings: arm: cpus: Add apple,firestorm & icestorm compatibles
dt-bindings: arm: apple: Add bindings for Apple ARM platforms
dt-bindings: vendor-prefixes: Add apple prefix

+1815 -80
+64
Documentation/devicetree/bindings/arm/apple.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/arm/apple.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Apple ARM Machine Device Tree Bindings 8 + 9 + maintainers: 10 + - Hector Martin <marcan@marcan.st> 11 + 12 + description: | 13 + ARM platforms using SoCs designed by Apple Inc., branded "Apple Silicon". 14 + 15 + This currently includes devices based on the "M1" SoC, starting with the 16 + three Mac models released in late 2020: 17 + 18 + - Mac mini (M1, 2020) 19 + - MacBook Pro (13-inch, M1, 2020) 20 + - MacBook Air (M1, 2020) 21 + 22 + The compatible property should follow this format: 23 + 24 + compatible = "apple,<targettype>", "apple,<socid>", "apple,arm-platform"; 25 + 26 + <targettype> represents the board/device and comes from the `target-type` 27 + property of the root node of the Apple Device Tree, lowercased. It can be 28 + queried on macOS using the following command: 29 + 30 + $ ioreg -d2 -l | grep target-type 31 + 32 + <socid> is the lowercased SoC ID. Apple uses at least *five* different 33 + names for their SoCs: 34 + 35 + - Marketing name ("M1") 36 + - Internal name ("H13G") 37 + - Codename ("Tonga") 38 + - SoC ID ("T8103") 39 + - Package/IC part number ("APL1102") 40 + 41 + Devicetrees should use the lowercased SoC ID, to avoid confusion if 42 + multiple SoCs share the same marketing name. This can be obtained from 43 + the `compatible` property of the arm-io node of the Apple Device Tree, 44 + which can be queried as follows on macOS: 45 + 46 + $ ioreg -n arm-io | grep compatible 47 + 48 + properties: 49 + $nodename: 50 + const: "/" 51 + compatible: 52 + oneOf: 53 + - description: Apple M1 SoC based platforms 54 + items: 55 + - enum: 56 + - apple,j274 # Mac mini (M1, 2020) 57 + - apple,j293 # MacBook Pro (13-inch, M1, 2020) 58 + - apple,j313 # MacBook Air (M1, 2020) 59 + - const: apple,t8103 60 + - const: apple,arm-platform 61 + 62 + additionalProperties: true 63 + 64 + ...
+2
Documentation/devicetree/bindings/arm/cpus.yaml
··· 85 85 86 86 compatible: 87 87 enum: 88 + - apple,icestorm 89 + - apple,firestorm 88 90 - arm,arm710t 89 91 - arm,arm720t 90 92 - arm,arm740t
+5
Documentation/devicetree/bindings/display/simple-framebuffer.yaml
··· 54 54 compatible: 55 55 items: 56 56 - enum: 57 + - apple,simple-framebuffer 57 58 - allwinner,simple-framebuffer 58 59 - amlogic,simple-framebuffer 59 60 - const: simple-framebuffer ··· 85 84 Format of the framebuffer: 86 85 * `a8b8g8r8` - 32-bit pixels, d[31:24]=a, d[23:16]=b, d[15:8]=g, d[7:0]=r 87 86 * `r5g6b5` - 16-bit pixels, d[15:11]=r, d[10:5]=g, d[4:0]=b 87 + * `x2r10g10b10` - 32-bit pixels, d[29:20]=r, d[19:10]=g, d[9:0]=b 88 + * `x8r8g8b8` - 32-bit pixels, d[23:16]=r, d[15:8]=g, d[7:0]=b 88 89 enum: 89 90 - a8b8g8r8 90 91 - r5g6b5 92 + - x2r10g10b10 93 + - x8r8g8b8 91 94 92 95 display: 93 96 $ref: /schemas/types.yaml#/definitions/phandle
+88
Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/interrupt-controller/apple,aic.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Apple Interrupt Controller 8 + 9 + maintainers: 10 + - Hector Martin <marcan@marcan.st> 11 + 12 + description: | 13 + The Apple Interrupt Controller is a simple interrupt controller present on 14 + Apple ARM SoC platforms, including various iPhone and iPad devices and the 15 + "Apple Silicon" Macs. 16 + 17 + It provides the following features: 18 + 19 + - Level-triggered hardware IRQs wired to SoC blocks 20 + - Single mask bit per IRQ 21 + - Per-IRQ affinity setting 22 + - Automatic masking on event delivery (auto-ack) 23 + - Software triggering (ORed with hw line) 24 + - 2 per-CPU IPIs (meant as "self" and "other", but they are interchangeable 25 + if not symmetric) 26 + - Automatic prioritization (single event/ack register per CPU, lower IRQs = 27 + higher priority) 28 + - Automatic masking on ack 29 + - Default "this CPU" register view and explicit per-CPU views 30 + 31 + This device also represents the FIQ interrupt sources on platforms using AIC, 32 + which do not go through a discrete interrupt controller. 33 + 34 + allOf: 35 + - $ref: /schemas/interrupt-controller.yaml# 36 + 37 + properties: 38 + compatible: 39 + items: 40 + - const: apple,t8103-aic 41 + - const: apple,aic 42 + 43 + interrupt-controller: true 44 + 45 + '#interrupt-cells': 46 + const: 3 47 + description: | 48 + The 1st cell contains the interrupt type: 49 + - 0: Hardware IRQ 50 + - 1: FIQ 51 + 52 + The 2nd cell contains the interrupt number. 53 + - HW IRQs: interrupt number 54 + - FIQs: 55 + - 0: physical HV timer 56 + - 1: virtual HV timer 57 + - 2: physical guest timer 58 + - 3: virtual guest timer 59 + 60 + The 3rd cell contains the interrupt flags. This is normally 61 + IRQ_TYPE_LEVEL_HIGH (4). 62 + 63 + reg: 64 + description: | 65 + Specifies base physical address and size of the AIC registers. 66 + maxItems: 1 67 + 68 + required: 69 + - compatible 70 + - '#interrupt-cells' 71 + - interrupt-controller 72 + - reg 73 + 74 + additionalProperties: false 75 + 76 + examples: 77 + - | 78 + soc { 79 + #address-cells = <2>; 80 + #size-cells = <2>; 81 + 82 + aic: interrupt-controller@23b100000 { 83 + compatible = "apple,t8103-aic", "apple,aic"; 84 + #interrupt-cells = <3>; 85 + interrupt-controller; 86 + reg = <0x2 0x3b100000 0x0 0x8000>; 87 + }; 88 + };
+19
Documentation/devicetree/bindings/timer/arm,arch_timer.yaml
··· 34 34 - arm,armv8-timer 35 35 36 36 interrupts: 37 + minItems: 1 38 + maxItems: 5 37 39 items: 38 40 - description: secure timer irq 39 41 - description: non-secure timer irq 40 42 - description: virtual timer irq 41 43 - description: hypervisor timer irq 44 + - description: hypervisor virtual timer irq 45 + 46 + interrupt-names: 47 + oneOf: 48 + - minItems: 2 49 + items: 50 + - const: phys 51 + - const: virt 52 + - const: hyp-phys 53 + - const: hyp-virt 54 + - minItems: 3 55 + items: 56 + - const: sec-phys 57 + - const: phys 58 + - const: virt 59 + - const: hyp-phys 60 + - const: hyp-virt 42 61 43 62 clock-frequency: 44 63 description: The frequency of the main counter, in Hz. Should be present
+2
Documentation/devicetree/bindings/vendor-prefixes.yaml
··· 103 103 description: Anvo-Systems Dresden GmbH 104 104 "^apm,.*": 105 105 description: Applied Micro Circuits Corporation (APM) 106 + "^apple,.*": 107 + description: Apple Inc. 106 108 "^aptina,.*": 107 109 description: Aptina Imaging 108 110 "^arasan,.*":
+356
Documentation/driver-api/device-io.rst
··· 146 146 outs() functions copy bytes, words or longs to the given 147 147 port. 148 148 149 + __iomem pointer tokens 150 + ====================== 151 + 152 + The data type for an MMIO address is an ``__iomem`` qualified pointer, such as 153 + ``void __iomem *reg``. On most architectures it is a regular pointer that 154 + points to a virtual memory address and can be offset or dereferenced, but in 155 + portable code, it must only be passed from and to functions that explicitly 156 + operated on an ``__iomem`` token, in particular the ioremap() and 157 + readl()/writel() functions. The 'sparse' semantic code checker can be used to 158 + verify that this is done correctly. 159 + 160 + While on most architectures, ioremap() creates a page table entry for an 161 + uncached virtual address pointing to the physical MMIO address, some 162 + architectures require special instructions for MMIO, and the ``__iomem`` pointer 163 + just encodes the physical address or an offsettable cookie that is interpreted 164 + by readl()/writel(). 165 + 166 + Differences between I/O access functions 167 + ======================================== 168 + 169 + readq(), readl(), readw(), readb(), writeq(), writel(), writew(), writeb() 170 + 171 + These are the most generic accessors, providing serialization against other 172 + MMIO accesses and DMA accesses as well as fixed endianness for accessing 173 + little-endian PCI devices and on-chip peripherals. Portable device drivers 174 + should generally use these for any access to ``__iomem`` pointers. 175 + 176 + Note that posted writes are not strictly ordered against a spinlock, see 177 + Documentation/driver-api/io_ordering.rst. 178 + 179 + readq_relaxed(), readl_relaxed(), readw_relaxed(), readb_relaxed(), 180 + writeq_relaxed(), writel_relaxed(), writew_relaxed(), writeb_relaxed() 181 + 182 + On architectures that require an expensive barrier for serializing against 183 + DMA, these "relaxed" versions of the MMIO accessors only serialize against 184 + each other, but contain a less expensive barrier operation. A device driver 185 + might use these in a particularly performance sensitive fast path, with a 186 + comment that explains why the usage in a specific location is safe without 187 + the extra barriers. 188 + 189 + See memory-barriers.txt for a more detailed discussion on the precise ordering 190 + guarantees of the non-relaxed and relaxed versions. 191 + 192 + ioread64(), ioread32(), ioread16(), ioread8(), 193 + iowrite64(), iowrite32(), iowrite16(), iowrite8() 194 + 195 + These are an alternative to the normal readl()/writel() functions, with almost 196 + identical behavior, but they can also operate on ``__iomem`` tokens returned 197 + for mapping PCI I/O space with pci_iomap() or ioport_map(). On architectures 198 + that require special instructions for I/O port access, this adds a small 199 + overhead for an indirect function call implemented in lib/iomap.c, while on 200 + other architectures, these are simply aliases. 201 + 202 + ioread64be(), ioread32be(), ioread16be() 203 + iowrite64be(), iowrite32be(), iowrite16be() 204 + 205 + These behave in the same way as the ioread32()/iowrite32() family, but with 206 + reversed byte order, for accessing devices with big-endian MMIO registers. 207 + Device drivers that can operate on either big-endian or little-endian 208 + registers may have to implement a custom wrapper function that picks one or 209 + the other depending on which device was found. 210 + 211 + Note: On some architectures, the normal readl()/writel() functions 212 + traditionally assume that devices are the same endianness as the CPU, while 213 + using a hardware byte-reverse on the PCI bus when running a big-endian kernel. 214 + Drivers that use readl()/writel() this way are generally not portable, but 215 + tend to be limited to a particular SoC. 216 + 217 + hi_lo_readq(), lo_hi_readq(), hi_lo_readq_relaxed(), lo_hi_readq_relaxed(), 218 + ioread64_lo_hi(), ioread64_hi_lo(), ioread64be_lo_hi(), ioread64be_hi_lo(), 219 + hi_lo_writeq(), lo_hi_writeq(), hi_lo_writeq_relaxed(), lo_hi_writeq_relaxed(), 220 + iowrite64_lo_hi(), iowrite64_hi_lo(), iowrite64be_lo_hi(), iowrite64be_hi_lo() 221 + 222 + Some device drivers have 64-bit registers that cannot be accessed atomically 223 + on 32-bit architectures but allow two consecutive 32-bit accesses instead. 224 + Since it depends on the particular device which of the two halves has to be 225 + accessed first, a helper is provided for each combination of 64-bit accessors 226 + with either low/high or high/low word ordering. A device driver must include 227 + either <linux/io-64-nonatomic-lo-hi.h> or <linux/io-64-nonatomic-hi-lo.h> to 228 + get the function definitions along with helpers that redirect the normal 229 + readq()/writeq() to them on architectures that do not provide 64-bit access 230 + natively. 231 + 232 + __raw_readq(), __raw_readl(), __raw_readw(), __raw_readb(), 233 + __raw_writeq(), __raw_writel(), __raw_writew(), __raw_writeb() 234 + 235 + These are low-level MMIO accessors without barriers or byteorder changes and 236 + architecture specific behavior. Accesses are usually atomic in the sense that 237 + a four-byte __raw_readl() does not get split into individual byte loads, but 238 + multiple consecutive accesses can be combined on the bus. In portable code, it 239 + is only safe to use these to access memory behind a device bus but not MMIO 240 + registers, as there are no ordering guarantees with regard to other MMIO 241 + accesses or even spinlocks. The byte order is generally the same as for normal 242 + memory, so unlike the other functions, these can be used to copy data between 243 + kernel memory and device memory. 244 + 245 + inl(), inw(), inb(), outl(), outw(), outb() 246 + 247 + PCI I/O port resources traditionally require separate helpers as they are 248 + implemented using special instructions on the x86 architecture. On most other 249 + architectures, these are mapped to readl()/writel() style accessors 250 + internally, usually pointing to a fixed area in virtual memory. Instead of an 251 + ``__iomem`` pointer, the address is a 32-bit integer token to identify a port 252 + number. PCI requires I/O port access to be non-posted, meaning that an outb() 253 + must complete before the following code executes, while a normal writeb() may 254 + still be in progress. On architectures that correctly implement this, I/O port 255 + access is therefore ordered against spinlocks. Many non-x86 PCI host bridge 256 + implementations and CPU architectures however fail to implement non-posted I/O 257 + space on PCI, so they can end up being posted on such hardware. 258 + 259 + In some architectures, the I/O port number space has a 1:1 mapping to 260 + ``__iomem`` pointers, but this is not recommended and device drivers should 261 + not rely on that for portability. Similarly, an I/O port number as described 262 + in a PCI base address register may not correspond to the port number as seen 263 + by a device driver. Portable drivers need to read the port number for the 264 + resource provided by the kernel. 265 + 266 + There are no direct 64-bit I/O port accessors, but pci_iomap() in combination 267 + with ioread64/iowrite64 can be used instead. 268 + 269 + inl_p(), inw_p(), inb_p(), outl_p(), outw_p(), outb_p() 270 + 271 + On ISA devices that require specific timing, the _p versions of the I/O 272 + accessors add a small delay. On architectures that do not have ISA buses, 273 + these are aliases to the normal inb/outb helpers. 274 + 275 + readsq, readsl, readsw, readsb 276 + writesq, writesl, writesw, writesb 277 + ioread64_rep, ioread32_rep, ioread16_rep, ioread8_rep 278 + iowrite64_rep, iowrite32_rep, iowrite16_rep, iowrite8_rep 279 + insl, insw, insb, outsl, outsw, outsb 280 + 281 + These are helpers that access the same address multiple times, usually to copy 282 + data between kernel memory byte stream and a FIFO buffer. Unlike the normal 283 + MMIO accessors, these do not perform a byteswap on big-endian kernels, so the 284 + first byte in the FIFO register corresponds to the first byte in the memory 285 + buffer regardless of the architecture. 286 + 287 + Device memory mapping modes 288 + =========================== 289 + 290 + Some architectures support multiple modes for mapping device memory. 291 + ioremap_*() variants provide a common abstraction around these 292 + architecture-specific modes, with a shared set of semantics. 293 + 294 + ioremap() is the most common mapping type, and is applicable to typical device 295 + memory (e.g. I/O registers). Other modes can offer weaker or stronger 296 + guarantees, if supported by the architecture. From most to least common, they 297 + are as follows: 298 + 299 + ioremap() 300 + --------- 301 + 302 + The default mode, suitable for most memory-mapped devices, e.g. control 303 + registers. Memory mapped using ioremap() has the following characteristics: 304 + 305 + * Uncached - CPU-side caches are bypassed, and all reads and writes are handled 306 + directly by the device 307 + * No speculative operations - the CPU may not issue a read or write to this 308 + memory, unless the instruction that does so has been reached in committed 309 + program flow. 310 + * No reordering - The CPU may not reorder accesses to this memory mapping with 311 + respect to each other. On some architectures, this relies on barriers in 312 + readl_relaxed()/writel_relaxed(). 313 + * No repetition - The CPU may not issue multiple reads or writes for a single 314 + program instruction. 315 + * No write-combining - Each I/O operation results in one discrete read or write 316 + being issued to the device, and multiple writes are not combined into larger 317 + writes. This may or may not be enforced when using __raw I/O accessors or 318 + pointer dereferences. 319 + * Non-executable - The CPU is not allowed to speculate instruction execution 320 + from this memory (it probably goes without saying, but you're also not 321 + allowed to jump into device memory). 322 + 323 + On many platforms and buses (e.g. PCI), writes issued through ioremap() 324 + mappings are posted, which means that the CPU does not wait for the write to 325 + actually reach the target device before retiring the write instruction. 326 + 327 + On many platforms, I/O accesses must be aligned with respect to the access 328 + size; failure to do so will result in an exception or unpredictable results. 329 + 330 + ioremap_wc() 331 + ------------ 332 + 333 + Maps I/O memory as normal memory with write combining. Unlike ioremap(), 334 + 335 + * The CPU may speculatively issue reads from the device that the program 336 + didn't actually execute, and may choose to basically read whatever it wants. 337 + * The CPU may reorder operations as long as the result is consistent from the 338 + program's point of view. 339 + * The CPU may write to the same location multiple times, even when the program 340 + issued a single write. 341 + * The CPU may combine several writes into a single larger write. 342 + 343 + This mode is typically used for video framebuffers, where it can increase 344 + performance of writes. It can also be used for other blocks of memory in 345 + devices (e.g. buffers or shared memory), but care must be taken as accesses are 346 + not guaranteed to be ordered with respect to normal ioremap() MMIO register 347 + accesses without explicit barriers. 348 + 349 + On a PCI bus, it is usually safe to use ioremap_wc() on MMIO areas marked as 350 + ``IORESOURCE_PREFETCH``, but it may not be used on those without the flag. 351 + For on-chip devices, there is no corresponding flag, but a driver can use 352 + ioremap_wc() on a device that is known to be safe. 353 + 354 + ioremap_wt() 355 + ------------ 356 + 357 + Maps I/O memory as normal memory with write-through caching. Like ioremap_wc(), 358 + but also, 359 + 360 + * The CPU may cache writes issued to and reads from the device, and serve reads 361 + from that cache. 362 + 363 + This mode is sometimes used for video framebuffers, where drivers still expect 364 + writes to reach the device in a timely manner (and not be stuck in the CPU 365 + cache), but reads may be served from the cache for efficiency. However, it is 366 + rarely useful these days, as framebuffer drivers usually perform writes only, 367 + for which ioremap_wc() is more efficient (as it doesn't needlessly trash the 368 + cache). Most drivers should not use this. 369 + 370 + ioremap_np() 371 + ------------ 372 + 373 + Like ioremap(), but explicitly requests non-posted write semantics. On some 374 + architectures and buses, ioremap() mappings have posted write semantics, which 375 + means that writes can appear to "complete" from the point of view of the 376 + CPU before the written data actually arrives at the target device. Writes are 377 + still ordered with respect to other writes and reads from the same device, but 378 + due to the posted write semantics, this is not the case with respect to other 379 + devices. ioremap_np() explicitly requests non-posted semantics, which means 380 + that the write instruction will not appear to complete until the device has 381 + received (and to some platform-specific extent acknowledged) the written data. 382 + 383 + This mapping mode primarily exists to cater for platforms with bus fabrics that 384 + require this particular mapping mode to work correctly. These platforms set the 385 + ``IORESOURCE_MEM_NONPOSTED`` flag for a resource that requires ioremap_np() 386 + semantics and portable drivers should use an abstraction that automatically 387 + selects it where appropriate (see the `Higher-level ioremap abstractions`_ 388 + section below). 389 + 390 + The bare ioremap_np() is only available on some architectures; on others, it 391 + always returns NULL. Drivers should not normally use it, unless they are 392 + platform-specific or they derive benefit from non-posted writes where 393 + supported, and can fall back to ioremap() otherwise. The normal approach to 394 + ensure posted write completion is to do a dummy read after a write as 395 + explained in `Accessing the device`_, which works with ioremap() on all 396 + platforms. 397 + 398 + ioremap_np() should never be used for PCI drivers. PCI memory space writes are 399 + always posted, even on architectures that otherwise implement ioremap_np(). 400 + Using ioremap_np() for PCI BARs will at best result in posted write semantics, 401 + and at worst result in complete breakage. 402 + 403 + Note that non-posted write semantics are orthogonal to CPU-side ordering 404 + guarantees. A CPU may still choose to issue other reads or writes before a 405 + non-posted write instruction retires. See the previous section on MMIO access 406 + functions for details on the CPU side of things. 407 + 408 + ioremap_uc() 409 + ------------ 410 + 411 + ioremap_uc() behaves like ioremap() except that on the x86 architecture without 412 + 'PAT' mode, it marks memory as uncached even when the MTRR has designated 413 + it as cacheable, see Documentation/x86/pat.rst. 414 + 415 + Portable drivers should avoid the use of ioremap_uc(). 416 + 417 + ioremap_cache() 418 + --------------- 419 + 420 + ioremap_cache() effectively maps I/O memory as normal RAM. CPU write-back 421 + caches can be used, and the CPU is free to treat the device as if it were a 422 + block of RAM. This should never be used for device memory which has side 423 + effects of any kind, or which does not return the data previously written on 424 + read. 425 + 426 + It should also not be used for actual RAM, as the returned pointer is an 427 + ``__iomem`` token. memremap() can be used for mapping normal RAM that is outside 428 + of the linear kernel memory area to a regular pointer. 429 + 430 + Portable drivers should avoid the use of ioremap_cache(). 431 + 432 + Architecture example 433 + -------------------- 434 + 435 + Here is how the above modes map to memory attribute settings on the ARM64 436 + architecture: 437 + 438 + +------------------------+--------------------------------------------+ 439 + | API | Memory region type and cacheability | 440 + +------------------------+--------------------------------------------+ 441 + | ioremap_np() | Device-nGnRnE | 442 + +------------------------+--------------------------------------------+ 443 + | ioremap() | Device-nGnRE | 444 + +------------------------+--------------------------------------------+ 445 + | ioremap_uc() | (not implemented) | 446 + +------------------------+--------------------------------------------+ 447 + | ioremap_wc() | Normal-Non Cacheable | 448 + +------------------------+--------------------------------------------+ 449 + | ioremap_wt() | (not implemented; fallback to ioremap) | 450 + +------------------------+--------------------------------------------+ 451 + | ioremap_cache() | Normal-Write-Back Cacheable | 452 + +------------------------+--------------------------------------------+ 453 + 454 + Higher-level ioremap abstractions 455 + ================================= 456 + 457 + Instead of using the above raw ioremap() modes, drivers are encouraged to use 458 + higher-level APIs. These APIs may implement platform-specific logic to 459 + automatically choose an appropriate ioremap mode on any given bus, allowing for 460 + a platform-agnostic driver to work on those platforms without any special 461 + cases. At the time of this writing, the following ioremap() wrappers have such 462 + logic: 463 + 464 + devm_ioremap_resource() 465 + 466 + Can automatically select ioremap_np() over ioremap() according to platform 467 + requirements, if the ``IORESOURCE_MEM_NONPOSTED`` flag is set on the struct 468 + resource. Uses devres to automatically unmap the resource when the driver 469 + probe() function fails or a device in unbound from its driver. 470 + 471 + Documented in Documentation/driver-api/driver-model/devres.rst. 472 + 473 + of_address_to_resource() 474 + 475 + Automatically sets the ``IORESOURCE_MEM_NONPOSTED`` flag for platforms that 476 + require non-posted writes for certain buses (see the nonposted-mmio and 477 + posted-mmio device tree properties). 478 + 479 + of_iomap() 480 + 481 + Maps the resource described in a ``reg`` property in the device tree, doing 482 + all required translations. Automatically selects ioremap_np() according to 483 + platform requirements, as above. 484 + 485 + pci_ioremap_bar(), pci_ioremap_wc_bar() 486 + 487 + Maps the resource described in a PCI base address without having to extract 488 + the physical address first. 489 + 490 + pci_iomap(), pci_iomap_wc() 491 + 492 + Like pci_ioremap_bar()/pci_ioremap_bar(), but also works on I/O space when 493 + used together with ioread32()/iowrite32() and similar accessors 494 + 495 + pcim_iomap() 496 + 497 + Like pci_iomap(), but uses devres to automatically unmap the resource when 498 + the driver probe() function fails or a device in unbound from its driver 499 + 500 + Documented in Documentation/driver-api/driver-model/devres.rst. 501 + 502 + Not using these wrappers may make drivers unusable on certain platforms with 503 + stricter rules for mapping I/O memory. 504 + 149 505 Public Functions Provided 150 506 ========================= 151 507
+1
Documentation/driver-api/driver-model/devres.rst
··· 310 310 devm_ioremap() 311 311 devm_ioremap_uc() 312 312 devm_ioremap_wc() 313 + devm_ioremap_np() 313 314 devm_ioremap_resource() : checks resource, requests memory region, ioremaps 314 315 devm_ioremap_resource_wc() 315 316 devm_platform_ioremap_resource() : calls devm_ioremap_resource() for platform device
+14
MAINTAINERS
··· 1649 1649 F: arch/arm64/boot/dts/amazon/ 1650 1650 F: drivers/*/*alpine* 1651 1651 1652 + ARM/APPLE MACHINE SUPPORT 1653 + M: Hector Martin <marcan@marcan.st> 1654 + L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 1655 + S: Maintained 1656 + W: https://asahilinux.org 1657 + B: https://github.com/AsahiLinux/linux/issues 1658 + C: irc://chat.freenode.net/asahi-dev 1659 + T: git https://github.com/AsahiLinux/linux.git 1660 + F: Documentation/devicetree/bindings/arm/apple.yaml 1661 + F: Documentation/devicetree/bindings/interrupt-controller/apple,aic.yaml 1662 + F: arch/arm64/boot/dts/apple/ 1663 + F: drivers/irqchip/irq-apple-aic.c 1664 + F: include/dt-bindings/interrupt-controller/apple-aic.h 1665 + 1652 1666 ARM/ARTPEC MACHINE SUPPORT 1653 1667 M: Jesper Nilsson <jesper.nilsson@axis.com> 1654 1668 M: Lars Persson <lars.persson@axis.com>
+7
arch/arm64/Kconfig.platforms
··· 26 26 This enables support for the Annapurna Labs Alpine 27 27 Soc family. 28 28 29 + config ARCH_APPLE 30 + bool "Apple Silicon SoC family" 31 + select APPLE_AIC 32 + help 33 + This enables support for Apple's in-house ARM SoC family, starting 34 + with the Apple M1. 35 + 29 36 config ARCH_BCM2835 30 37 bool "Broadcom BCM2835 family" 31 38 select TIMER_OF
+1
arch/arm64/boot/dts/Makefile
··· 6 6 subdir-y += amd 7 7 subdir-y += amlogic 8 8 subdir-y += apm 9 + subdir-y += apple 9 10 subdir-y += arm 10 11 subdir-y += bitmain 11 12 subdir-y += broadcom
+2
arch/arm64/boot/dts/apple/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + dtb-$(CONFIG_ARCH_APPLE) += t8103-j274.dtb
+45
arch/arm64/boot/dts/apple/t8103-j274.dts
··· 1 + // SPDX-License-Identifier: GPL-2.0+ OR MIT 2 + /* 3 + * Apple Mac mini (M1, 2020) 4 + * 5 + * target-type: J274 6 + * 7 + * Copyright The Asahi Linux Contributors 8 + */ 9 + 10 + /dts-v1/; 11 + 12 + #include "t8103.dtsi" 13 + 14 + / { 15 + compatible = "apple,j274", "apple,t8103", "apple,arm-platform"; 16 + model = "Apple Mac mini (M1, 2020)"; 17 + 18 + aliases { 19 + serial0 = &serial0; 20 + }; 21 + 22 + chosen { 23 + #address-cells = <2>; 24 + #size-cells = <2>; 25 + ranges; 26 + 27 + stdout-path = "serial0"; 28 + 29 + framebuffer0: framebuffer@0 { 30 + compatible = "apple,simple-framebuffer", "simple-framebuffer"; 31 + reg = <0 0 0 0>; /* To be filled by loader */ 32 + /* Format properties will be added by loader */ 33 + status = "disabled"; 34 + }; 35 + }; 36 + 37 + memory@800000000 { 38 + device_type = "memory"; 39 + reg = <0x8 0 0x2 0>; /* To be filled by loader */ 40 + }; 41 + }; 42 + 43 + &serial0 { 44 + status = "okay"; 45 + };
+135
arch/arm64/boot/dts/apple/t8103.dtsi
··· 1 + // SPDX-License-Identifier: GPL-2.0+ OR MIT 2 + /* 3 + * Apple T8103 "M1" SoC 4 + * 5 + * Other names: H13G, "Tonga" 6 + * 7 + * Copyright The Asahi Linux Contributors 8 + */ 9 + 10 + #include <dt-bindings/interrupt-controller/apple-aic.h> 11 + #include <dt-bindings/interrupt-controller/irq.h> 12 + 13 + / { 14 + compatible = "apple,t8103", "apple,arm-platform"; 15 + 16 + #address-cells = <2>; 17 + #size-cells = <2>; 18 + 19 + cpus { 20 + #address-cells = <2>; 21 + #size-cells = <0>; 22 + 23 + cpu0: cpu@0 { 24 + compatible = "apple,icestorm"; 25 + device_type = "cpu"; 26 + reg = <0x0 0x0>; 27 + enable-method = "spin-table"; 28 + cpu-release-addr = <0 0>; /* To be filled by loader */ 29 + }; 30 + 31 + cpu1: cpu@1 { 32 + compatible = "apple,icestorm"; 33 + device_type = "cpu"; 34 + reg = <0x0 0x1>; 35 + enable-method = "spin-table"; 36 + cpu-release-addr = <0 0>; /* To be filled by loader */ 37 + }; 38 + 39 + cpu2: cpu@2 { 40 + compatible = "apple,icestorm"; 41 + device_type = "cpu"; 42 + reg = <0x0 0x2>; 43 + enable-method = "spin-table"; 44 + cpu-release-addr = <0 0>; /* To be filled by loader */ 45 + }; 46 + 47 + cpu3: cpu@3 { 48 + compatible = "apple,icestorm"; 49 + device_type = "cpu"; 50 + reg = <0x0 0x3>; 51 + enable-method = "spin-table"; 52 + cpu-release-addr = <0 0>; /* To be filled by loader */ 53 + }; 54 + 55 + cpu4: cpu@10100 { 56 + compatible = "apple,firestorm"; 57 + device_type = "cpu"; 58 + reg = <0x0 0x10100>; 59 + enable-method = "spin-table"; 60 + cpu-release-addr = <0 0>; /* To be filled by loader */ 61 + }; 62 + 63 + cpu5: cpu@10101 { 64 + compatible = "apple,firestorm"; 65 + device_type = "cpu"; 66 + reg = <0x0 0x10101>; 67 + enable-method = "spin-table"; 68 + cpu-release-addr = <0 0>; /* To be filled by loader */ 69 + }; 70 + 71 + cpu6: cpu@10102 { 72 + compatible = "apple,firestorm"; 73 + device_type = "cpu"; 74 + reg = <0x0 0x10102>; 75 + enable-method = "spin-table"; 76 + cpu-release-addr = <0 0>; /* To be filled by loader */ 77 + }; 78 + 79 + cpu7: cpu@10103 { 80 + compatible = "apple,firestorm"; 81 + device_type = "cpu"; 82 + reg = <0x0 0x10103>; 83 + enable-method = "spin-table"; 84 + cpu-release-addr = <0 0>; /* To be filled by loader */ 85 + }; 86 + }; 87 + 88 + timer { 89 + compatible = "arm,armv8-timer"; 90 + interrupt-parent = <&aic>; 91 + interrupt-names = "phys", "virt", "hyp-phys", "hyp-virt"; 92 + interrupts = <AIC_FIQ AIC_TMR_GUEST_PHYS IRQ_TYPE_LEVEL_HIGH>, 93 + <AIC_FIQ AIC_TMR_GUEST_VIRT IRQ_TYPE_LEVEL_HIGH>, 94 + <AIC_FIQ AIC_TMR_HV_PHYS IRQ_TYPE_LEVEL_HIGH>, 95 + <AIC_FIQ AIC_TMR_HV_VIRT IRQ_TYPE_LEVEL_HIGH>; 96 + }; 97 + 98 + clk24: clock-24m { 99 + compatible = "fixed-clock"; 100 + #clock-cells = <0>; 101 + clock-frequency = <24000000>; 102 + clock-output-names = "clk24"; 103 + }; 104 + 105 + soc { 106 + compatible = "simple-bus"; 107 + #address-cells = <2>; 108 + #size-cells = <2>; 109 + 110 + ranges; 111 + nonposted-mmio; 112 + 113 + serial0: serial@235200000 { 114 + compatible = "apple,s5l-uart"; 115 + reg = <0x2 0x35200000 0x0 0x1000>; 116 + reg-io-width = <4>; 117 + interrupt-parent = <&aic>; 118 + interrupts = <AIC_IRQ 605 IRQ_TYPE_LEVEL_HIGH>; 119 + /* 120 + * TODO: figure out the clocking properly, there may 121 + * be a third selectable clock. 122 + */ 123 + clocks = <&clk24>, <&clk24>; 124 + clock-names = "uart", "clk_uart_baud0"; 125 + status = "disabled"; 126 + }; 127 + 128 + aic: interrupt-controller@23b100000 { 129 + compatible = "apple,t8103-aic", "apple,aic"; 130 + #interrupt-cells = <3>; 131 + interrupt-controller; 132 + reg = <0x2 0x3b100000 0x0 0x8000>; 133 + }; 134 + }; 135 + };
+1
arch/arm64/configs/defconfig
··· 32 32 CONFIG_ARCH_N5X=y 33 33 CONFIG_ARCH_SUNXI=y 34 34 CONFIG_ARCH_ALPINE=y 35 + CONFIG_ARCH_APPLE=y 35 36 CONFIG_ARCH_BCM2835=y 36 37 CONFIG_ARCH_BCM4908=y 37 38 CONFIG_ARCH_BCM_IPROC=y
+6
arch/arm64/include/asm/cputype.h
··· 59 59 #define ARM_CPU_IMP_NVIDIA 0x4E 60 60 #define ARM_CPU_IMP_FUJITSU 0x46 61 61 #define ARM_CPU_IMP_HISI 0x48 62 + #define ARM_CPU_IMP_APPLE 0x61 62 63 63 64 #define ARM_CPU_PART_AEM_V8 0xD0F 64 65 #define ARM_CPU_PART_FOUNDATION 0xD00 ··· 100 99 101 100 #define HISI_CPU_PART_TSV110 0xD01 102 101 102 + #define APPLE_CPU_PART_M1_ICESTORM 0x022 103 + #define APPLE_CPU_PART_M1_FIRESTORM 0x023 104 + 103 105 #define MIDR_CORTEX_A53 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A53) 104 106 #define MIDR_CORTEX_A57 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A57) 105 107 #define MIDR_CORTEX_A72 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A72) ··· 131 127 #define MIDR_NVIDIA_CARMEL MIDR_CPU_MODEL(ARM_CPU_IMP_NVIDIA, NVIDIA_CPU_PART_CARMEL) 132 128 #define MIDR_FUJITSU_A64FX MIDR_CPU_MODEL(ARM_CPU_IMP_FUJITSU, FUJITSU_CPU_PART_A64FX) 133 129 #define MIDR_HISI_TSV110 MIDR_CPU_MODEL(ARM_CPU_IMP_HISI, HISI_CPU_PART_TSV110) 130 + #define MIDR_APPLE_M1_ICESTORM MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_ICESTORM) 131 + #define MIDR_APPLE_M1_FIRESTORM MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM) 134 132 135 133 /* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */ 136 134 #define MIDR_FUJITSU_ERRATUM_010001 MIDR_FUJITSU_A64FX
+1 -10
arch/arm64/include/asm/io.h
··· 169 169 170 170 #define ioremap(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE)) 171 171 #define ioremap_wc(addr, size) __ioremap((addr), (size), __pgprot(PROT_NORMAL_NC)) 172 - 173 - /* 174 - * PCI configuration space mapping function. 175 - * 176 - * The PCI specification disallows posted write configuration transactions. 177 - * Add an arch specific pci_remap_cfgspace() definition that is implemented 178 - * through nGnRnE device memory attribute as recommended by the ARM v8 179 - * Architecture reference manual Issue A.k B2.8.2 "Device memory". 180 - */ 181 - #define pci_remap_cfgspace(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE)) 172 + #define ioremap_np(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRnE)) 182 173 183 174 /* 184 175 * io{read,write}{16,32,64}be() macros
+60
arch/arm64/include/asm/sysreg.h
··· 1041 1041 #define TRFCR_ELx_ExTRE BIT(1) 1042 1042 #define TRFCR_ELx_E0TRE BIT(0) 1043 1043 1044 + 1045 + /* GIC Hypervisor interface registers */ 1046 + /* ICH_MISR_EL2 bit definitions */ 1047 + #define ICH_MISR_EOI (1 << 0) 1048 + #define ICH_MISR_U (1 << 1) 1049 + 1050 + /* ICH_LR*_EL2 bit definitions */ 1051 + #define ICH_LR_VIRTUAL_ID_MASK ((1ULL << 32) - 1) 1052 + 1053 + #define ICH_LR_EOI (1ULL << 41) 1054 + #define ICH_LR_GROUP (1ULL << 60) 1055 + #define ICH_LR_HW (1ULL << 61) 1056 + #define ICH_LR_STATE (3ULL << 62) 1057 + #define ICH_LR_PENDING_BIT (1ULL << 62) 1058 + #define ICH_LR_ACTIVE_BIT (1ULL << 63) 1059 + #define ICH_LR_PHYS_ID_SHIFT 32 1060 + #define ICH_LR_PHYS_ID_MASK (0x3ffULL << ICH_LR_PHYS_ID_SHIFT) 1061 + #define ICH_LR_PRIORITY_SHIFT 48 1062 + #define ICH_LR_PRIORITY_MASK (0xffULL << ICH_LR_PRIORITY_SHIFT) 1063 + 1064 + /* ICH_HCR_EL2 bit definitions */ 1065 + #define ICH_HCR_EN (1 << 0) 1066 + #define ICH_HCR_UIE (1 << 1) 1067 + #define ICH_HCR_NPIE (1 << 3) 1068 + #define ICH_HCR_TC (1 << 10) 1069 + #define ICH_HCR_TALL0 (1 << 11) 1070 + #define ICH_HCR_TALL1 (1 << 12) 1071 + #define ICH_HCR_EOIcount_SHIFT 27 1072 + #define ICH_HCR_EOIcount_MASK (0x1f << ICH_HCR_EOIcount_SHIFT) 1073 + 1074 + /* ICH_VMCR_EL2 bit definitions */ 1075 + #define ICH_VMCR_ACK_CTL_SHIFT 2 1076 + #define ICH_VMCR_ACK_CTL_MASK (1 << ICH_VMCR_ACK_CTL_SHIFT) 1077 + #define ICH_VMCR_FIQ_EN_SHIFT 3 1078 + #define ICH_VMCR_FIQ_EN_MASK (1 << ICH_VMCR_FIQ_EN_SHIFT) 1079 + #define ICH_VMCR_CBPR_SHIFT 4 1080 + #define ICH_VMCR_CBPR_MASK (1 << ICH_VMCR_CBPR_SHIFT) 1081 + #define ICH_VMCR_EOIM_SHIFT 9 1082 + #define ICH_VMCR_EOIM_MASK (1 << ICH_VMCR_EOIM_SHIFT) 1083 + #define ICH_VMCR_BPR1_SHIFT 18 1084 + #define ICH_VMCR_BPR1_MASK (7 << ICH_VMCR_BPR1_SHIFT) 1085 + #define ICH_VMCR_BPR0_SHIFT 21 1086 + #define ICH_VMCR_BPR0_MASK (7 << ICH_VMCR_BPR0_SHIFT) 1087 + #define ICH_VMCR_PMR_SHIFT 24 1088 + #define ICH_VMCR_PMR_MASK (0xffUL << ICH_VMCR_PMR_SHIFT) 1089 + #define ICH_VMCR_ENG0_SHIFT 0 1090 + #define ICH_VMCR_ENG0_MASK (1 << ICH_VMCR_ENG0_SHIFT) 1091 + #define ICH_VMCR_ENG1_SHIFT 1 1092 + #define ICH_VMCR_ENG1_MASK (1 << ICH_VMCR_ENG1_SHIFT) 1093 + 1094 + /* ICH_VTR_EL2 bit definitions */ 1095 + #define ICH_VTR_PRI_BITS_SHIFT 29 1096 + #define ICH_VTR_PRI_BITS_MASK (7 << ICH_VTR_PRI_BITS_SHIFT) 1097 + #define ICH_VTR_ID_BITS_SHIFT 23 1098 + #define ICH_VTR_ID_BITS_MASK (7 << ICH_VTR_ID_BITS_SHIFT) 1099 + #define ICH_VTR_SEIS_SHIFT 22 1100 + #define ICH_VTR_SEIS_MASK (1 << ICH_VTR_SEIS_SHIFT) 1101 + #define ICH_VTR_A3V_SHIFT 21 1102 + #define ICH_VTR_A3V_MASK (1 << ICH_VTR_A3V_SHIFT) 1103 + 1044 1104 #ifdef __ASSEMBLY__ 1045 1105 1046 1106 .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
+4
arch/sparc/include/asm/io_64.h
··· 409 409 #define ioremap_uc(X,Y) ioremap((X),(Y)) 410 410 #define ioremap_wc(X,Y) ioremap((X),(Y)) 411 411 #define ioremap_wt(X,Y) ioremap((X),(Y)) 412 + static inline void __iomem *ioremap_np(unsigned long offset, unsigned long size) 413 + { 414 + return NULL; 415 + } 412 416 413 417 static inline void iounmap(volatile void __iomem *addr) 414 418 {
+21 -3
drivers/clocksource/arm_arch_timer.c
··· 64 64 u32 arch_timer_rate1 __ro_after_init; 65 65 static int arch_timer_ppi[ARCH_TIMER_MAX_TIMER_PPI] __ro_after_init; 66 66 67 + static const char *arch_timer_ppi_names[ARCH_TIMER_MAX_TIMER_PPI] = { 68 + [ARCH_TIMER_PHYS_SECURE_PPI] = "sec-phys", 69 + [ARCH_TIMER_PHYS_NONSECURE_PPI] = "phys", 70 + [ARCH_TIMER_VIRT_PPI] = "virt", 71 + [ARCH_TIMER_HYP_PPI] = "hyp-phys", 72 + [ARCH_TIMER_HYP_VIRT_PPI] = "hyp-virt", 73 + }; 74 + 67 75 static struct clock_event_device __percpu *arch_timer_evt; 68 76 69 77 static enum arch_timer_ppi_nr arch_timer_uses_ppi __ro_after_init = ARCH_TIMER_VIRT_PPI; ··· 1289 1281 1290 1282 static int __init arch_timer_of_init(struct device_node *np) 1291 1283 { 1292 - int i, ret; 1284 + int i, irq, ret; 1293 1285 u32 rate; 1286 + bool has_names; 1294 1287 1295 1288 if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { 1296 1289 pr_warn("multiple nodes in dt, skipping\n"); ··· 1299 1290 } 1300 1291 1301 1292 arch_timers_present |= ARCH_TIMER_TYPE_CP15; 1302 - for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) 1303 - arch_timer_ppi[i] = irq_of_parse_and_map(np, i); 1293 + 1294 + has_names = of_property_read_bool(np, "interrupt-names"); 1295 + 1296 + for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) { 1297 + if (has_names) 1298 + irq = of_irq_get_byname(np, arch_timer_ppi_names[i]); 1299 + else 1300 + irq = of_irq_get(np, i); 1301 + if (irq > 0) 1302 + arch_timer_ppi[i] = irq; 1303 + } 1304 1304 1305 1305 arch_timer_populate_kvm_info(); 1306 1306
+8
drivers/irqchip/Kconfig
··· 593 593 select GENERIC_IRQ_CHIP 594 594 select IRQ_DOMAIN 595 595 596 + config APPLE_AIC 597 + bool "Apple Interrupt Controller (AIC)" 598 + depends on ARM64 599 + default ARCH_APPLE 600 + help 601 + Support for the Apple Interrupt Controller found on Apple Silicon SoCs, 602 + such as the M1. 603 + 596 604 endmenu
+1
drivers/irqchip/Makefile
··· 115 115 obj-$(CONFIG_MACH_REALTEK_RTL) += irq-realtek-rtl.o 116 116 obj-$(CONFIG_WPCM450_AIC) += irq-wpcm450-aic.o 117 117 obj-$(CONFIG_IRQ_IDT3243X) += irq-idt3243x.o 118 + obj-$(CONFIG_APPLE_AIC) += irq-apple-aic.o
+852
drivers/irqchip/irq-apple-aic.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Copyright The Asahi Linux Contributors 4 + * 5 + * Based on irq-lpc32xx: 6 + * Copyright 2015-2016 Vladimir Zapolskiy <vz@mleia.com> 7 + * Based on irq-bcm2836: 8 + * Copyright 2015 Broadcom 9 + */ 10 + 11 + /* 12 + * AIC is a fairly simple interrupt controller with the following features: 13 + * 14 + * - 896 level-triggered hardware IRQs 15 + * - Single mask bit per IRQ 16 + * - Per-IRQ affinity setting 17 + * - Automatic masking on event delivery (auto-ack) 18 + * - Software triggering (ORed with hw line) 19 + * - 2 per-CPU IPIs (meant as "self" and "other", but they are 20 + * interchangeable if not symmetric) 21 + * - Automatic prioritization (single event/ack register per CPU, lower IRQs = 22 + * higher priority) 23 + * - Automatic masking on ack 24 + * - Default "this CPU" register view and explicit per-CPU views 25 + * 26 + * In addition, this driver also handles FIQs, as these are routed to the same 27 + * IRQ vector. These are used for Fast IPIs (TODO), the ARMv8 timer IRQs, and 28 + * performance counters (TODO). 29 + * 30 + * Implementation notes: 31 + * 32 + * - This driver creates two IRQ domains, one for HW IRQs and internal FIQs, 33 + * and one for IPIs. 34 + * - Since Linux needs more than 2 IPIs, we implement a software IRQ controller 35 + * and funnel all IPIs into one per-CPU IPI (the second "self" IPI is unused). 36 + * - FIQ hwirq numbers are assigned after true hwirqs, and are per-cpu. 37 + * - DT bindings use 3-cell form (like GIC): 38 + * - <0 nr flags> - hwirq #nr 39 + * - <1 nr flags> - FIQ #nr 40 + * - nr=0 Physical HV timer 41 + * - nr=1 Virtual HV timer 42 + * - nr=2 Physical guest timer 43 + * - nr=3 Virtual guest timer 44 + */ 45 + 46 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 47 + 48 + #include <linux/bits.h> 49 + #include <linux/bitfield.h> 50 + #include <linux/cpuhotplug.h> 51 + #include <linux/io.h> 52 + #include <linux/irqchip.h> 53 + #include <linux/irqdomain.h> 54 + #include <linux/limits.h> 55 + #include <linux/of_address.h> 56 + #include <linux/slab.h> 57 + #include <asm/exception.h> 58 + #include <asm/sysreg.h> 59 + #include <asm/virt.h> 60 + 61 + #include <dt-bindings/interrupt-controller/apple-aic.h> 62 + 63 + /* 64 + * AIC registers (MMIO) 65 + */ 66 + 67 + #define AIC_INFO 0x0004 68 + #define AIC_INFO_NR_HW GENMASK(15, 0) 69 + 70 + #define AIC_CONFIG 0x0010 71 + 72 + #define AIC_WHOAMI 0x2000 73 + #define AIC_EVENT 0x2004 74 + #define AIC_EVENT_TYPE GENMASK(31, 16) 75 + #define AIC_EVENT_NUM GENMASK(15, 0) 76 + 77 + #define AIC_EVENT_TYPE_HW 1 78 + #define AIC_EVENT_TYPE_IPI 4 79 + #define AIC_EVENT_IPI_OTHER 1 80 + #define AIC_EVENT_IPI_SELF 2 81 + 82 + #define AIC_IPI_SEND 0x2008 83 + #define AIC_IPI_ACK 0x200c 84 + #define AIC_IPI_MASK_SET 0x2024 85 + #define AIC_IPI_MASK_CLR 0x2028 86 + 87 + #define AIC_IPI_SEND_CPU(cpu) BIT(cpu) 88 + 89 + #define AIC_IPI_OTHER BIT(0) 90 + #define AIC_IPI_SELF BIT(31) 91 + 92 + #define AIC_TARGET_CPU 0x3000 93 + #define AIC_SW_SET 0x4000 94 + #define AIC_SW_CLR 0x4080 95 + #define AIC_MASK_SET 0x4100 96 + #define AIC_MASK_CLR 0x4180 97 + 98 + #define AIC_CPU_IPI_SET(cpu) (0x5008 + ((cpu) << 7)) 99 + #define AIC_CPU_IPI_CLR(cpu) (0x500c + ((cpu) << 7)) 100 + #define AIC_CPU_IPI_MASK_SET(cpu) (0x5024 + ((cpu) << 7)) 101 + #define AIC_CPU_IPI_MASK_CLR(cpu) (0x5028 + ((cpu) << 7)) 102 + 103 + #define MASK_REG(x) (4 * ((x) >> 5)) 104 + #define MASK_BIT(x) BIT((x) & GENMASK(4, 0)) 105 + 106 + /* 107 + * IMP-DEF sysregs that control FIQ sources 108 + * Note: sysreg-based IPIs are not supported yet. 109 + */ 110 + 111 + /* Core PMC control register */ 112 + #define SYS_IMP_APL_PMCR0_EL1 sys_reg(3, 1, 15, 0, 0) 113 + #define PMCR0_IMODE GENMASK(10, 8) 114 + #define PMCR0_IMODE_OFF 0 115 + #define PMCR0_IMODE_PMI 1 116 + #define PMCR0_IMODE_AIC 2 117 + #define PMCR0_IMODE_HALT 3 118 + #define PMCR0_IMODE_FIQ 4 119 + #define PMCR0_IACT BIT(11) 120 + 121 + /* IPI request registers */ 122 + #define SYS_IMP_APL_IPI_RR_LOCAL_EL1 sys_reg(3, 5, 15, 0, 0) 123 + #define SYS_IMP_APL_IPI_RR_GLOBAL_EL1 sys_reg(3, 5, 15, 0, 1) 124 + #define IPI_RR_CPU GENMASK(7, 0) 125 + /* Cluster only used for the GLOBAL register */ 126 + #define IPI_RR_CLUSTER GENMASK(23, 16) 127 + #define IPI_RR_TYPE GENMASK(29, 28) 128 + #define IPI_RR_IMMEDIATE 0 129 + #define IPI_RR_RETRACT 1 130 + #define IPI_RR_DEFERRED 2 131 + #define IPI_RR_NOWAKE 3 132 + 133 + /* IPI status register */ 134 + #define SYS_IMP_APL_IPI_SR_EL1 sys_reg(3, 5, 15, 1, 1) 135 + #define IPI_SR_PENDING BIT(0) 136 + 137 + /* Guest timer FIQ enable register */ 138 + #define SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2 sys_reg(3, 5, 15, 1, 3) 139 + #define VM_TMR_FIQ_ENABLE_V BIT(0) 140 + #define VM_TMR_FIQ_ENABLE_P BIT(1) 141 + 142 + /* Deferred IPI countdown register */ 143 + #define SYS_IMP_APL_IPI_CR_EL1 sys_reg(3, 5, 15, 3, 1) 144 + 145 + /* Uncore PMC control register */ 146 + #define SYS_IMP_APL_UPMCR0_EL1 sys_reg(3, 7, 15, 0, 4) 147 + #define UPMCR0_IMODE GENMASK(18, 16) 148 + #define UPMCR0_IMODE_OFF 0 149 + #define UPMCR0_IMODE_AIC 2 150 + #define UPMCR0_IMODE_HALT 3 151 + #define UPMCR0_IMODE_FIQ 4 152 + 153 + /* Uncore PMC status register */ 154 + #define SYS_IMP_APL_UPMSR_EL1 sys_reg(3, 7, 15, 6, 4) 155 + #define UPMSR_IACT BIT(0) 156 + 157 + #define AIC_NR_FIQ 4 158 + #define AIC_NR_SWIPI 32 159 + 160 + /* 161 + * FIQ hwirq index definitions: FIQ sources use the DT binding defines 162 + * directly, except that timers are special. At the irqchip level, the 163 + * two timer types are represented by their access method: _EL0 registers 164 + * or _EL02 registers. In the DT binding, the timers are represented 165 + * by their purpose (HV or guest). This mapping is for when the kernel is 166 + * running at EL2 (with VHE). When the kernel is running at EL1, the 167 + * mapping differs and aic_irq_domain_translate() performs the remapping. 168 + */ 169 + 170 + #define AIC_TMR_EL0_PHYS AIC_TMR_HV_PHYS 171 + #define AIC_TMR_EL0_VIRT AIC_TMR_HV_VIRT 172 + #define AIC_TMR_EL02_PHYS AIC_TMR_GUEST_PHYS 173 + #define AIC_TMR_EL02_VIRT AIC_TMR_GUEST_VIRT 174 + 175 + struct aic_irq_chip { 176 + void __iomem *base; 177 + struct irq_domain *hw_domain; 178 + struct irq_domain *ipi_domain; 179 + int nr_hw; 180 + int ipi_hwirq; 181 + }; 182 + 183 + static DEFINE_PER_CPU(uint32_t, aic_fiq_unmasked); 184 + 185 + static DEFINE_PER_CPU(atomic_t, aic_vipi_flag); 186 + static DEFINE_PER_CPU(atomic_t, aic_vipi_enable); 187 + 188 + static struct aic_irq_chip *aic_irqc; 189 + 190 + static void aic_handle_ipi(struct pt_regs *regs); 191 + 192 + static u32 aic_ic_read(struct aic_irq_chip *ic, u32 reg) 193 + { 194 + return readl_relaxed(ic->base + reg); 195 + } 196 + 197 + static void aic_ic_write(struct aic_irq_chip *ic, u32 reg, u32 val) 198 + { 199 + writel_relaxed(val, ic->base + reg); 200 + } 201 + 202 + /* 203 + * IRQ irqchip 204 + */ 205 + 206 + static void aic_irq_mask(struct irq_data *d) 207 + { 208 + struct aic_irq_chip *ic = irq_data_get_irq_chip_data(d); 209 + 210 + aic_ic_write(ic, AIC_MASK_SET + MASK_REG(irqd_to_hwirq(d)), 211 + MASK_BIT(irqd_to_hwirq(d))); 212 + } 213 + 214 + static void aic_irq_unmask(struct irq_data *d) 215 + { 216 + struct aic_irq_chip *ic = irq_data_get_irq_chip_data(d); 217 + 218 + aic_ic_write(ic, AIC_MASK_CLR + MASK_REG(d->hwirq), 219 + MASK_BIT(irqd_to_hwirq(d))); 220 + } 221 + 222 + static void aic_irq_eoi(struct irq_data *d) 223 + { 224 + /* 225 + * Reading the interrupt reason automatically acknowledges and masks 226 + * the IRQ, so we just unmask it here if needed. 227 + */ 228 + if (!irqd_irq_disabled(d) && !irqd_irq_masked(d)) 229 + aic_irq_unmask(d); 230 + } 231 + 232 + static void __exception_irq_entry aic_handle_irq(struct pt_regs *regs) 233 + { 234 + struct aic_irq_chip *ic = aic_irqc; 235 + u32 event, type, irq; 236 + 237 + do { 238 + /* 239 + * We cannot use a relaxed read here, as reads from DMA buffers 240 + * need to be ordered after the IRQ fires. 241 + */ 242 + event = readl(ic->base + AIC_EVENT); 243 + type = FIELD_GET(AIC_EVENT_TYPE, event); 244 + irq = FIELD_GET(AIC_EVENT_NUM, event); 245 + 246 + if (type == AIC_EVENT_TYPE_HW) 247 + handle_domain_irq(aic_irqc->hw_domain, irq, regs); 248 + else if (type == AIC_EVENT_TYPE_IPI && irq == 1) 249 + aic_handle_ipi(regs); 250 + else if (event != 0) 251 + pr_err_ratelimited("Unknown IRQ event %d, %d\n", type, irq); 252 + } while (event); 253 + 254 + /* 255 + * vGIC maintenance interrupts end up here too, so we need to check 256 + * for them separately. This should never trigger if KVM is working 257 + * properly, because it will have already taken care of clearing it 258 + * on guest exit before this handler runs. 259 + */ 260 + if (is_kernel_in_hyp_mode() && (read_sysreg_s(SYS_ICH_HCR_EL2) & ICH_HCR_EN) && 261 + read_sysreg_s(SYS_ICH_MISR_EL2) != 0) { 262 + pr_err_ratelimited("vGIC IRQ fired and not handled by KVM, disabling.\n"); 263 + sysreg_clear_set_s(SYS_ICH_HCR_EL2, ICH_HCR_EN, 0); 264 + } 265 + } 266 + 267 + static int aic_irq_set_affinity(struct irq_data *d, 268 + const struct cpumask *mask_val, bool force) 269 + { 270 + irq_hw_number_t hwirq = irqd_to_hwirq(d); 271 + struct aic_irq_chip *ic = irq_data_get_irq_chip_data(d); 272 + int cpu; 273 + 274 + if (force) 275 + cpu = cpumask_first(mask_val); 276 + else 277 + cpu = cpumask_any_and(mask_val, cpu_online_mask); 278 + 279 + aic_ic_write(ic, AIC_TARGET_CPU + hwirq * 4, BIT(cpu)); 280 + irq_data_update_effective_affinity(d, cpumask_of(cpu)); 281 + 282 + return IRQ_SET_MASK_OK; 283 + } 284 + 285 + static int aic_irq_set_type(struct irq_data *d, unsigned int type) 286 + { 287 + /* 288 + * Some IRQs (e.g. MSIs) implicitly have edge semantics, and we don't 289 + * have a way to find out the type of any given IRQ, so just allow both. 290 + */ 291 + return (type == IRQ_TYPE_LEVEL_HIGH || type == IRQ_TYPE_EDGE_RISING) ? 0 : -EINVAL; 292 + } 293 + 294 + static struct irq_chip aic_chip = { 295 + .name = "AIC", 296 + .irq_mask = aic_irq_mask, 297 + .irq_unmask = aic_irq_unmask, 298 + .irq_eoi = aic_irq_eoi, 299 + .irq_set_affinity = aic_irq_set_affinity, 300 + .irq_set_type = aic_irq_set_type, 301 + }; 302 + 303 + /* 304 + * FIQ irqchip 305 + */ 306 + 307 + static unsigned long aic_fiq_get_idx(struct irq_data *d) 308 + { 309 + struct aic_irq_chip *ic = irq_data_get_irq_chip_data(d); 310 + 311 + return irqd_to_hwirq(d) - ic->nr_hw; 312 + } 313 + 314 + static void aic_fiq_set_mask(struct irq_data *d) 315 + { 316 + /* Only the guest timers have real mask bits, unfortunately. */ 317 + switch (aic_fiq_get_idx(d)) { 318 + case AIC_TMR_EL02_PHYS: 319 + sysreg_clear_set_s(SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2, VM_TMR_FIQ_ENABLE_P, 0); 320 + isb(); 321 + break; 322 + case AIC_TMR_EL02_VIRT: 323 + sysreg_clear_set_s(SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2, VM_TMR_FIQ_ENABLE_V, 0); 324 + isb(); 325 + break; 326 + default: 327 + break; 328 + } 329 + } 330 + 331 + static void aic_fiq_clear_mask(struct irq_data *d) 332 + { 333 + switch (aic_fiq_get_idx(d)) { 334 + case AIC_TMR_EL02_PHYS: 335 + sysreg_clear_set_s(SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2, 0, VM_TMR_FIQ_ENABLE_P); 336 + isb(); 337 + break; 338 + case AIC_TMR_EL02_VIRT: 339 + sysreg_clear_set_s(SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2, 0, VM_TMR_FIQ_ENABLE_V); 340 + isb(); 341 + break; 342 + default: 343 + break; 344 + } 345 + } 346 + 347 + static void aic_fiq_mask(struct irq_data *d) 348 + { 349 + aic_fiq_set_mask(d); 350 + __this_cpu_and(aic_fiq_unmasked, ~BIT(aic_fiq_get_idx(d))); 351 + } 352 + 353 + static void aic_fiq_unmask(struct irq_data *d) 354 + { 355 + aic_fiq_clear_mask(d); 356 + __this_cpu_or(aic_fiq_unmasked, BIT(aic_fiq_get_idx(d))); 357 + } 358 + 359 + static void aic_fiq_eoi(struct irq_data *d) 360 + { 361 + /* We mask to ack (where we can), so we need to unmask at EOI. */ 362 + if (__this_cpu_read(aic_fiq_unmasked) & BIT(aic_fiq_get_idx(d))) 363 + aic_fiq_clear_mask(d); 364 + } 365 + 366 + #define TIMER_FIRING(x) \ 367 + (((x) & (ARCH_TIMER_CTRL_ENABLE | ARCH_TIMER_CTRL_IT_MASK | \ 368 + ARCH_TIMER_CTRL_IT_STAT)) == \ 369 + (ARCH_TIMER_CTRL_ENABLE | ARCH_TIMER_CTRL_IT_STAT)) 370 + 371 + static void __exception_irq_entry aic_handle_fiq(struct pt_regs *regs) 372 + { 373 + /* 374 + * It would be really nice if we had a system register that lets us get 375 + * the FIQ source state without having to peek down into sources... 376 + * but such a register does not seem to exist. 377 + * 378 + * So, we have these potential sources to test for: 379 + * - Fast IPIs (not yet used) 380 + * - The 4 timers (CNTP, CNTV for each of HV and guest) 381 + * - Per-core PMCs (not yet supported) 382 + * - Per-cluster uncore PMCs (not yet supported) 383 + * 384 + * Since not dealing with any of these results in a FIQ storm, 385 + * we check for everything here, even things we don't support yet. 386 + */ 387 + 388 + if (read_sysreg_s(SYS_IMP_APL_IPI_SR_EL1) & IPI_SR_PENDING) { 389 + pr_err_ratelimited("Fast IPI fired. Acking.\n"); 390 + write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); 391 + } 392 + 393 + if (TIMER_FIRING(read_sysreg(cntp_ctl_el0))) 394 + handle_domain_irq(aic_irqc->hw_domain, 395 + aic_irqc->nr_hw + AIC_TMR_EL0_PHYS, regs); 396 + 397 + if (TIMER_FIRING(read_sysreg(cntv_ctl_el0))) 398 + handle_domain_irq(aic_irqc->hw_domain, 399 + aic_irqc->nr_hw + AIC_TMR_EL0_VIRT, regs); 400 + 401 + if (is_kernel_in_hyp_mode()) { 402 + uint64_t enabled = read_sysreg_s(SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2); 403 + 404 + if ((enabled & VM_TMR_FIQ_ENABLE_P) && 405 + TIMER_FIRING(read_sysreg_s(SYS_CNTP_CTL_EL02))) 406 + handle_domain_irq(aic_irqc->hw_domain, 407 + aic_irqc->nr_hw + AIC_TMR_EL02_PHYS, regs); 408 + 409 + if ((enabled & VM_TMR_FIQ_ENABLE_V) && 410 + TIMER_FIRING(read_sysreg_s(SYS_CNTV_CTL_EL02))) 411 + handle_domain_irq(aic_irqc->hw_domain, 412 + aic_irqc->nr_hw + AIC_TMR_EL02_VIRT, regs); 413 + } 414 + 415 + if ((read_sysreg_s(SYS_IMP_APL_PMCR0_EL1) & (PMCR0_IMODE | PMCR0_IACT)) == 416 + (FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_FIQ) | PMCR0_IACT)) { 417 + /* 418 + * Not supported yet, let's figure out how to handle this when 419 + * we implement these proprietary performance counters. For now, 420 + * just mask it and move on. 421 + */ 422 + pr_err_ratelimited("PMC FIQ fired. Masking.\n"); 423 + sysreg_clear_set_s(SYS_IMP_APL_PMCR0_EL1, PMCR0_IMODE | PMCR0_IACT, 424 + FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_OFF)); 425 + } 426 + 427 + if (FIELD_GET(UPMCR0_IMODE, read_sysreg_s(SYS_IMP_APL_UPMCR0_EL1)) == UPMCR0_IMODE_FIQ && 428 + (read_sysreg_s(SYS_IMP_APL_UPMSR_EL1) & UPMSR_IACT)) { 429 + /* Same story with uncore PMCs */ 430 + pr_err_ratelimited("Uncore PMC FIQ fired. Masking.\n"); 431 + sysreg_clear_set_s(SYS_IMP_APL_UPMCR0_EL1, UPMCR0_IMODE, 432 + FIELD_PREP(UPMCR0_IMODE, UPMCR0_IMODE_OFF)); 433 + } 434 + } 435 + 436 + static int aic_fiq_set_type(struct irq_data *d, unsigned int type) 437 + { 438 + return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL; 439 + } 440 + 441 + static struct irq_chip fiq_chip = { 442 + .name = "AIC-FIQ", 443 + .irq_mask = aic_fiq_mask, 444 + .irq_unmask = aic_fiq_unmask, 445 + .irq_ack = aic_fiq_set_mask, 446 + .irq_eoi = aic_fiq_eoi, 447 + .irq_set_type = aic_fiq_set_type, 448 + }; 449 + 450 + /* 451 + * Main IRQ domain 452 + */ 453 + 454 + static int aic_irq_domain_map(struct irq_domain *id, unsigned int irq, 455 + irq_hw_number_t hw) 456 + { 457 + struct aic_irq_chip *ic = id->host_data; 458 + 459 + if (hw < ic->nr_hw) { 460 + irq_domain_set_info(id, irq, hw, &aic_chip, id->host_data, 461 + handle_fasteoi_irq, NULL, NULL); 462 + irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(irq))); 463 + } else { 464 + irq_set_percpu_devid(irq); 465 + irq_domain_set_info(id, irq, hw, &fiq_chip, id->host_data, 466 + handle_percpu_devid_irq, NULL, NULL); 467 + } 468 + 469 + return 0; 470 + } 471 + 472 + static int aic_irq_domain_translate(struct irq_domain *id, 473 + struct irq_fwspec *fwspec, 474 + unsigned long *hwirq, 475 + unsigned int *type) 476 + { 477 + struct aic_irq_chip *ic = id->host_data; 478 + 479 + if (fwspec->param_count != 3 || !is_of_node(fwspec->fwnode)) 480 + return -EINVAL; 481 + 482 + switch (fwspec->param[0]) { 483 + case AIC_IRQ: 484 + if (fwspec->param[1] >= ic->nr_hw) 485 + return -EINVAL; 486 + *hwirq = fwspec->param[1]; 487 + break; 488 + case AIC_FIQ: 489 + if (fwspec->param[1] >= AIC_NR_FIQ) 490 + return -EINVAL; 491 + *hwirq = ic->nr_hw + fwspec->param[1]; 492 + 493 + /* 494 + * In EL1 the non-redirected registers are the guest's, 495 + * not EL2's, so remap the hwirqs to match. 496 + */ 497 + if (!is_kernel_in_hyp_mode()) { 498 + switch (fwspec->param[1]) { 499 + case AIC_TMR_GUEST_PHYS: 500 + *hwirq = ic->nr_hw + AIC_TMR_EL0_PHYS; 501 + break; 502 + case AIC_TMR_GUEST_VIRT: 503 + *hwirq = ic->nr_hw + AIC_TMR_EL0_VIRT; 504 + break; 505 + case AIC_TMR_HV_PHYS: 506 + case AIC_TMR_HV_VIRT: 507 + return -ENOENT; 508 + default: 509 + break; 510 + } 511 + } 512 + break; 513 + default: 514 + return -EINVAL; 515 + } 516 + 517 + *type = fwspec->param[2] & IRQ_TYPE_SENSE_MASK; 518 + 519 + return 0; 520 + } 521 + 522 + static int aic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, 523 + unsigned int nr_irqs, void *arg) 524 + { 525 + unsigned int type = IRQ_TYPE_NONE; 526 + struct irq_fwspec *fwspec = arg; 527 + irq_hw_number_t hwirq; 528 + int i, ret; 529 + 530 + ret = aic_irq_domain_translate(domain, fwspec, &hwirq, &type); 531 + if (ret) 532 + return ret; 533 + 534 + for (i = 0; i < nr_irqs; i++) { 535 + ret = aic_irq_domain_map(domain, virq + i, hwirq + i); 536 + if (ret) 537 + return ret; 538 + } 539 + 540 + return 0; 541 + } 542 + 543 + static void aic_irq_domain_free(struct irq_domain *domain, unsigned int virq, 544 + unsigned int nr_irqs) 545 + { 546 + int i; 547 + 548 + for (i = 0; i < nr_irqs; i++) { 549 + struct irq_data *d = irq_domain_get_irq_data(domain, virq + i); 550 + 551 + irq_set_handler(virq + i, NULL); 552 + irq_domain_reset_irq_data(d); 553 + } 554 + } 555 + 556 + static const struct irq_domain_ops aic_irq_domain_ops = { 557 + .translate = aic_irq_domain_translate, 558 + .alloc = aic_irq_domain_alloc, 559 + .free = aic_irq_domain_free, 560 + }; 561 + 562 + /* 563 + * IPI irqchip 564 + */ 565 + 566 + static void aic_ipi_mask(struct irq_data *d) 567 + { 568 + u32 irq_bit = BIT(irqd_to_hwirq(d)); 569 + 570 + /* No specific ordering requirements needed here. */ 571 + atomic_andnot(irq_bit, this_cpu_ptr(&aic_vipi_enable)); 572 + } 573 + 574 + static void aic_ipi_unmask(struct irq_data *d) 575 + { 576 + struct aic_irq_chip *ic = irq_data_get_irq_chip_data(d); 577 + u32 irq_bit = BIT(irqd_to_hwirq(d)); 578 + 579 + atomic_or(irq_bit, this_cpu_ptr(&aic_vipi_enable)); 580 + 581 + /* 582 + * The atomic_or() above must complete before the atomic_read() 583 + * below to avoid racing aic_ipi_send_mask(). 584 + */ 585 + smp_mb__after_atomic(); 586 + 587 + /* 588 + * If a pending vIPI was unmasked, raise a HW IPI to ourselves. 589 + * No barriers needed here since this is a self-IPI. 590 + */ 591 + if (atomic_read(this_cpu_ptr(&aic_vipi_flag)) & irq_bit) 592 + aic_ic_write(ic, AIC_IPI_SEND, AIC_IPI_SEND_CPU(smp_processor_id())); 593 + } 594 + 595 + static void aic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask) 596 + { 597 + struct aic_irq_chip *ic = irq_data_get_irq_chip_data(d); 598 + u32 irq_bit = BIT(irqd_to_hwirq(d)); 599 + u32 send = 0; 600 + int cpu; 601 + unsigned long pending; 602 + 603 + for_each_cpu(cpu, mask) { 604 + /* 605 + * This sequence is the mirror of the one in aic_ipi_unmask(); 606 + * see the comment there. Additionally, release semantics 607 + * ensure that the vIPI flag set is ordered after any shared 608 + * memory accesses that precede it. This therefore also pairs 609 + * with the atomic_fetch_andnot in aic_handle_ipi(). 610 + */ 611 + pending = atomic_fetch_or_release(irq_bit, per_cpu_ptr(&aic_vipi_flag, cpu)); 612 + 613 + /* 614 + * The atomic_fetch_or_release() above must complete before the 615 + * atomic_read() below to avoid racing aic_ipi_unmask(). 616 + */ 617 + smp_mb__after_atomic(); 618 + 619 + if (!(pending & irq_bit) && 620 + (atomic_read(per_cpu_ptr(&aic_vipi_enable, cpu)) & irq_bit)) 621 + send |= AIC_IPI_SEND_CPU(cpu); 622 + } 623 + 624 + /* 625 + * The flag writes must complete before the physical IPI is issued 626 + * to another CPU. This is implied by the control dependency on 627 + * the result of atomic_read_acquire() above, which is itself 628 + * already ordered after the vIPI flag write. 629 + */ 630 + if (send) 631 + aic_ic_write(ic, AIC_IPI_SEND, send); 632 + } 633 + 634 + static struct irq_chip ipi_chip = { 635 + .name = "AIC-IPI", 636 + .irq_mask = aic_ipi_mask, 637 + .irq_unmask = aic_ipi_unmask, 638 + .ipi_send_mask = aic_ipi_send_mask, 639 + }; 640 + 641 + /* 642 + * IPI IRQ domain 643 + */ 644 + 645 + static void aic_handle_ipi(struct pt_regs *regs) 646 + { 647 + int i; 648 + unsigned long enabled, firing; 649 + 650 + /* 651 + * Ack the IPI. We need to order this after the AIC event read, but 652 + * that is enforced by normal MMIO ordering guarantees. 653 + */ 654 + aic_ic_write(aic_irqc, AIC_IPI_ACK, AIC_IPI_OTHER); 655 + 656 + /* 657 + * The mask read does not need to be ordered. Only we can change 658 + * our own mask anyway, so no races are possible here, as long as 659 + * we are properly in the interrupt handler (which is covered by 660 + * the barrier that is part of the top-level AIC handler's readl()). 661 + */ 662 + enabled = atomic_read(this_cpu_ptr(&aic_vipi_enable)); 663 + 664 + /* 665 + * Clear the IPIs we are about to handle. This pairs with the 666 + * atomic_fetch_or_release() in aic_ipi_send_mask(), and needs to be 667 + * ordered after the aic_ic_write() above (to avoid dropping vIPIs) and 668 + * before IPI handling code (to avoid races handling vIPIs before they 669 + * are signaled). The former is taken care of by the release semantics 670 + * of the write portion, while the latter is taken care of by the 671 + * acquire semantics of the read portion. 672 + */ 673 + firing = atomic_fetch_andnot(enabled, this_cpu_ptr(&aic_vipi_flag)) & enabled; 674 + 675 + for_each_set_bit(i, &firing, AIC_NR_SWIPI) 676 + handle_domain_irq(aic_irqc->ipi_domain, i, regs); 677 + 678 + /* 679 + * No ordering needed here; at worst this just changes the timing of 680 + * when the next IPI will be delivered. 681 + */ 682 + aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); 683 + } 684 + 685 + static int aic_ipi_alloc(struct irq_domain *d, unsigned int virq, 686 + unsigned int nr_irqs, void *args) 687 + { 688 + int i; 689 + 690 + for (i = 0; i < nr_irqs; i++) { 691 + irq_set_percpu_devid(virq + i); 692 + irq_domain_set_info(d, virq + i, i, &ipi_chip, d->host_data, 693 + handle_percpu_devid_irq, NULL, NULL); 694 + } 695 + 696 + return 0; 697 + } 698 + 699 + static void aic_ipi_free(struct irq_domain *d, unsigned int virq, unsigned int nr_irqs) 700 + { 701 + /* Not freeing IPIs */ 702 + } 703 + 704 + static const struct irq_domain_ops aic_ipi_domain_ops = { 705 + .alloc = aic_ipi_alloc, 706 + .free = aic_ipi_free, 707 + }; 708 + 709 + static int aic_init_smp(struct aic_irq_chip *irqc, struct device_node *node) 710 + { 711 + struct irq_domain *ipi_domain; 712 + int base_ipi; 713 + 714 + ipi_domain = irq_domain_create_linear(irqc->hw_domain->fwnode, AIC_NR_SWIPI, 715 + &aic_ipi_domain_ops, irqc); 716 + if (WARN_ON(!ipi_domain)) 717 + return -ENODEV; 718 + 719 + ipi_domain->flags |= IRQ_DOMAIN_FLAG_IPI_SINGLE; 720 + irq_domain_update_bus_token(ipi_domain, DOMAIN_BUS_IPI); 721 + 722 + base_ipi = __irq_domain_alloc_irqs(ipi_domain, -1, AIC_NR_SWIPI, 723 + NUMA_NO_NODE, NULL, false, NULL); 724 + 725 + if (WARN_ON(!base_ipi)) { 726 + irq_domain_remove(ipi_domain); 727 + return -ENODEV; 728 + } 729 + 730 + set_smp_ipi_range(base_ipi, AIC_NR_SWIPI); 731 + 732 + irqc->ipi_domain = ipi_domain; 733 + 734 + return 0; 735 + } 736 + 737 + static int aic_init_cpu(unsigned int cpu) 738 + { 739 + /* Mask all hard-wired per-CPU IRQ/FIQ sources */ 740 + 741 + /* Pending Fast IPI FIQs */ 742 + write_sysreg_s(IPI_SR_PENDING, SYS_IMP_APL_IPI_SR_EL1); 743 + 744 + /* Timer FIQs */ 745 + sysreg_clear_set(cntp_ctl_el0, 0, ARCH_TIMER_CTRL_IT_MASK); 746 + sysreg_clear_set(cntv_ctl_el0, 0, ARCH_TIMER_CTRL_IT_MASK); 747 + 748 + /* EL2-only (VHE mode) IRQ sources */ 749 + if (is_kernel_in_hyp_mode()) { 750 + /* Guest timers */ 751 + sysreg_clear_set_s(SYS_IMP_APL_VM_TMR_FIQ_ENA_EL2, 752 + VM_TMR_FIQ_ENABLE_V | VM_TMR_FIQ_ENABLE_P, 0); 753 + 754 + /* vGIC maintenance IRQ */ 755 + sysreg_clear_set_s(SYS_ICH_HCR_EL2, ICH_HCR_EN, 0); 756 + } 757 + 758 + /* PMC FIQ */ 759 + sysreg_clear_set_s(SYS_IMP_APL_PMCR0_EL1, PMCR0_IMODE | PMCR0_IACT, 760 + FIELD_PREP(PMCR0_IMODE, PMCR0_IMODE_OFF)); 761 + 762 + /* Uncore PMC FIQ */ 763 + sysreg_clear_set_s(SYS_IMP_APL_UPMCR0_EL1, UPMCR0_IMODE, 764 + FIELD_PREP(UPMCR0_IMODE, UPMCR0_IMODE_OFF)); 765 + 766 + /* Commit all of the above */ 767 + isb(); 768 + 769 + /* 770 + * Make sure the kernel's idea of logical CPU order is the same as AIC's 771 + * If we ever end up with a mismatch here, we will have to introduce 772 + * a mapping table similar to what other irqchip drivers do. 773 + */ 774 + WARN_ON(aic_ic_read(aic_irqc, AIC_WHOAMI) != smp_processor_id()); 775 + 776 + /* 777 + * Always keep IPIs unmasked at the hardware level (except auto-masking 778 + * by AIC during processing). We manage masks at the vIPI level. 779 + */ 780 + aic_ic_write(aic_irqc, AIC_IPI_ACK, AIC_IPI_SELF | AIC_IPI_OTHER); 781 + aic_ic_write(aic_irqc, AIC_IPI_MASK_SET, AIC_IPI_SELF); 782 + aic_ic_write(aic_irqc, AIC_IPI_MASK_CLR, AIC_IPI_OTHER); 783 + 784 + /* Initialize the local mask state */ 785 + __this_cpu_write(aic_fiq_unmasked, 0); 786 + 787 + return 0; 788 + } 789 + 790 + static int __init aic_of_ic_init(struct device_node *node, struct device_node *parent) 791 + { 792 + int i; 793 + void __iomem *regs; 794 + u32 info; 795 + struct aic_irq_chip *irqc; 796 + 797 + regs = of_iomap(node, 0); 798 + if (WARN_ON(!regs)) 799 + return -EIO; 800 + 801 + irqc = kzalloc(sizeof(*irqc), GFP_KERNEL); 802 + if (!irqc) 803 + return -ENOMEM; 804 + 805 + aic_irqc = irqc; 806 + irqc->base = regs; 807 + 808 + info = aic_ic_read(irqc, AIC_INFO); 809 + irqc->nr_hw = FIELD_GET(AIC_INFO_NR_HW, info); 810 + 811 + irqc->hw_domain = irq_domain_create_linear(of_node_to_fwnode(node), 812 + irqc->nr_hw + AIC_NR_FIQ, 813 + &aic_irq_domain_ops, irqc); 814 + if (WARN_ON(!irqc->hw_domain)) { 815 + iounmap(irqc->base); 816 + kfree(irqc); 817 + return -ENODEV; 818 + } 819 + 820 + irq_domain_update_bus_token(irqc->hw_domain, DOMAIN_BUS_WIRED); 821 + 822 + if (aic_init_smp(irqc, node)) { 823 + irq_domain_remove(irqc->hw_domain); 824 + iounmap(irqc->base); 825 + kfree(irqc); 826 + return -ENODEV; 827 + } 828 + 829 + set_handle_irq(aic_handle_irq); 830 + set_handle_fiq(aic_handle_fiq); 831 + 832 + for (i = 0; i < BITS_TO_U32(irqc->nr_hw); i++) 833 + aic_ic_write(irqc, AIC_MASK_SET + i * 4, U32_MAX); 834 + for (i = 0; i < BITS_TO_U32(irqc->nr_hw); i++) 835 + aic_ic_write(irqc, AIC_SW_CLR + i * 4, U32_MAX); 836 + for (i = 0; i < irqc->nr_hw; i++) 837 + aic_ic_write(irqc, AIC_TARGET_CPU + i * 4, 1); 838 + 839 + if (!is_kernel_in_hyp_mode()) 840 + pr_info("Kernel running in EL1, mapping interrupts"); 841 + 842 + cpuhp_setup_state(CPUHP_AP_IRQ_APPLE_AIC_STARTING, 843 + "irqchip/apple-aic/ipi:starting", 844 + aic_init_cpu, NULL); 845 + 846 + pr_info("Initialized with %d IRQs, %d FIQs, %d vIPIs\n", 847 + irqc->nr_hw, AIC_NR_FIQ, AIC_NR_SWIPI); 848 + 849 + return 0; 850 + } 851 + 852 + IRQCHIP_DECLARE(apple_m1_aic, "apple,aic", aic_of_ic_init);
+41 -2
drivers/of/address.c
··· 26 26 static int __of_address_to_resource(struct device_node *dev, 27 27 const __be32 *addrp, u64 size, unsigned int flags, 28 28 const char *name, struct resource *r); 29 + static bool of_mmio_is_nonposted(struct device_node *np); 29 30 30 31 /* Debug utility */ 31 32 #ifdef DEBUG ··· 848 847 return -EINVAL; 849 848 memset(r, 0, sizeof(struct resource)); 850 849 850 + if (of_mmio_is_nonposted(dev)) 851 + flags |= IORESOURCE_MEM_NONPOSTED; 852 + 851 853 r->start = taddr; 852 854 r->end = taddr + size - 1; 853 855 r->flags = flags; ··· 900 896 if (of_address_to_resource(np, index, &res)) 901 897 return NULL; 902 898 903 - return ioremap(res.start, resource_size(&res)); 899 + if (res.flags & IORESOURCE_MEM_NONPOSTED) 900 + return ioremap_np(res.start, resource_size(&res)); 901 + else 902 + return ioremap(res.start, resource_size(&res)); 904 903 } 905 904 EXPORT_SYMBOL(of_iomap); 906 905 ··· 935 928 if (!request_mem_region(res.start, resource_size(&res), name)) 936 929 return IOMEM_ERR_PTR(-EBUSY); 937 930 938 - mem = ioremap(res.start, resource_size(&res)); 931 + if (res.flags & IORESOURCE_MEM_NONPOSTED) 932 + mem = ioremap_np(res.start, resource_size(&res)); 933 + else 934 + mem = ioremap(res.start, resource_size(&res)); 935 + 939 936 if (!mem) { 940 937 release_mem_region(res.start, resource_size(&res)); 941 938 return IOMEM_ERR_PTR(-ENOMEM); ··· 1105 1094 return false; 1106 1095 } 1107 1096 EXPORT_SYMBOL_GPL(of_dma_is_coherent); 1097 + 1098 + /** 1099 + * of_mmio_is_nonposted - Check if device uses non-posted MMIO 1100 + * @np: device node 1101 + * 1102 + * Returns true if the "nonposted-mmio" property was found for 1103 + * the device's bus. 1104 + * 1105 + * This is currently only enabled on builds that support Apple ARM devices, as 1106 + * an optimization. 1107 + */ 1108 + static bool of_mmio_is_nonposted(struct device_node *np) 1109 + { 1110 + struct device_node *parent; 1111 + bool nonposted; 1112 + 1113 + if (!IS_ENABLED(CONFIG_ARCH_APPLE)) 1114 + return false; 1115 + 1116 + parent = of_get_parent(np); 1117 + if (!parent) 1118 + return false; 1119 + 1120 + nonposted = of_property_read_bool(parent, "nonposted-mmio"); 1121 + 1122 + of_node_put(parent); 1123 + return nonposted; 1124 + }
+20 -1
include/asm-generic/io.h
··· 942 942 * 943 943 * ioremap_wc() and ioremap_wt() can provide more relaxed caching attributes 944 944 * for specific drivers if the architecture choses to implement them. If they 945 - * are not implemented we fall back to plain ioremap. 945 + * are not implemented we fall back to plain ioremap. Conversely, ioremap_np() 946 + * can provide stricter non-posted write semantics if the architecture 947 + * implements them. 946 948 */ 947 949 #ifndef CONFIG_MMU 948 950 #ifndef ioremap ··· 992 990 #ifndef ioremap_uc 993 991 #define ioremap_uc ioremap_uc 994 992 static inline void __iomem *ioremap_uc(phys_addr_t offset, size_t size) 993 + { 994 + return NULL; 995 + } 996 + #endif 997 + 998 + /* 999 + * ioremap_np needs an explicit architecture implementation, as it 1000 + * requests stronger semantics than regular ioremap(). Portable drivers 1001 + * should instead use one of the higher-level abstractions, like 1002 + * devm_ioremap_resource(), to choose the correct variant for any given 1003 + * device and bus. Portable drivers with a good reason to want non-posted 1004 + * write semantics should always provide an ioremap() fallback in case 1005 + * ioremap_np() is not available. 1006 + */ 1007 + #ifndef ioremap_np 1008 + #define ioremap_np ioremap_np 1009 + static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size) 995 1010 { 996 1011 return NULL; 997 1012 }
+9
include/asm-generic/iomap.h
··· 101 101 #define ioremap_wt ioremap 102 102 #endif 103 103 104 + #ifndef ARCH_HAS_IOREMAP_NP 105 + /* See the comment in asm-generic/io.h about ioremap_np(). */ 106 + #define ioremap_np ioremap_np 107 + static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size) 108 + { 109 + return NULL; 110 + } 111 + #endif 112 + 104 113 #ifdef CONFIG_PCI 105 114 /* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */ 106 115 struct pci_dev;
+1
include/clocksource/arm_arch_timer.h
··· 32 32 ARCH_TIMER_PHYS_NONSECURE_PPI, 33 33 ARCH_TIMER_VIRT_PPI, 34 34 ARCH_TIMER_HYP_PPI, 35 + ARCH_TIMER_HYP_VIRT_PPI, 35 36 ARCH_TIMER_MAX_TIMER_PPI 36 37 }; 37 38
+15
include/dt-bindings/interrupt-controller/apple-aic.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ OR MIT */ 2 + #ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_APPLE_AIC_H 3 + #define _DT_BINDINGS_INTERRUPT_CONTROLLER_APPLE_AIC_H 4 + 5 + #include <dt-bindings/interrupt-controller/irq.h> 6 + 7 + #define AIC_IRQ 0 8 + #define AIC_FIQ 1 9 + 10 + #define AIC_TMR_HV_PHYS 0 11 + #define AIC_TMR_HV_VIRT 1 12 + #define AIC_TMR_GUEST_PHYS 2 13 + #define AIC_TMR_GUEST_VIRT 3 14 + 15 + #endif
+1
include/linux/cpuhotplug.h
··· 100 100 CPUHP_AP_CPU_PM_STARTING, 101 101 CPUHP_AP_IRQ_GIC_STARTING, 102 102 CPUHP_AP_IRQ_HIP04_STARTING, 103 + CPUHP_AP_IRQ_APPLE_AIC_STARTING, 103 104 CPUHP_AP_IRQ_ARMADA_XP_STARTING, 104 105 CPUHP_AP_IRQ_BCM2836_STARTING, 105 106 CPUHP_AP_IRQ_MIPS_GIC_STARTING,
+10 -8
include/linux/io.h
··· 68 68 resource_size_t size); 69 69 void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset, 70 70 resource_size_t size); 71 + void __iomem *devm_ioremap_np(struct device *dev, resource_size_t offset, 72 + resource_size_t size); 71 73 void devm_iounmap(struct device *dev, void __iomem *addr); 72 74 int check_signature(const volatile void __iomem *io_addr, 73 75 const unsigned char *signature, int length); ··· 82 80 #ifdef CONFIG_PCI 83 81 /* 84 82 * The PCI specifications (Rev 3.0, 3.2.5 "Transaction Ordering and 85 - * Posting") mandate non-posted configuration transactions. There is 86 - * no ioremap API in the kernel that can guarantee non-posted write 87 - * semantics across arches so provide a default implementation for 88 - * mapping PCI config space that defaults to ioremap(); arches 89 - * should override it if they have memory mapping implementations that 90 - * guarantee non-posted writes semantics to make the memory mapping 91 - * compliant with the PCI specification. 83 + * Posting") mandate non-posted configuration transactions. This default 84 + * implementation attempts to use the ioremap_np() API to provide this 85 + * on arches that support it, and falls back to ioremap() on those that 86 + * don't. Overriding this function is deprecated; arches that properly 87 + * support non-posted accesses should implement ioremap_np() instead, which 88 + * this default implementation can then use to return mappings compliant with 89 + * the PCI specification. 92 90 */ 93 91 #ifndef pci_remap_cfgspace 94 92 #define pci_remap_cfgspace pci_remap_cfgspace 95 93 static inline void __iomem *pci_remap_cfgspace(phys_addr_t offset, 96 94 size_t size) 97 95 { 98 - return ioremap(offset, size); 96 + return ioremap_np(offset, size) ?: ioremap(offset, size); 99 97 } 100 98 #endif 101 99 #endif
+1
include/linux/ioport.h
··· 108 108 #define IORESOURCE_MEM_32BIT (3<<3) 109 109 #define IORESOURCE_MEM_SHADOWABLE (1<<5) /* dup: IORESOURCE_SHADOWABLE */ 110 110 #define IORESOURCE_MEM_EXPANSIONROM (1<<6) 111 + #define IORESOURCE_MEM_NONPOSTED (1<<7) 111 112 112 113 /* PnP I/O specific bits (IORESOURCE_BITS) */ 113 114 #define IORESOURCE_IO_16BIT_ADDR (1<<0)
-56
include/linux/irqchip/arm-gic-v3.h
··· 575 575 #define ICC_SRE_EL1_DFB (1U << 1) 576 576 #define ICC_SRE_EL1_SRE (1U << 0) 577 577 578 - /* 579 - * Hypervisor interface registers (SRE only) 580 - */ 581 - #define ICH_LR_VIRTUAL_ID_MASK ((1ULL << 32) - 1) 582 - 583 - #define ICH_LR_EOI (1ULL << 41) 584 - #define ICH_LR_GROUP (1ULL << 60) 585 - #define ICH_LR_HW (1ULL << 61) 586 - #define ICH_LR_STATE (3ULL << 62) 587 - #define ICH_LR_PENDING_BIT (1ULL << 62) 588 - #define ICH_LR_ACTIVE_BIT (1ULL << 63) 589 - #define ICH_LR_PHYS_ID_SHIFT 32 590 - #define ICH_LR_PHYS_ID_MASK (0x3ffULL << ICH_LR_PHYS_ID_SHIFT) 591 - #define ICH_LR_PRIORITY_SHIFT 48 592 - #define ICH_LR_PRIORITY_MASK (0xffULL << ICH_LR_PRIORITY_SHIFT) 593 - 594 578 /* These are for GICv2 emulation only */ 595 579 #define GICH_LR_VIRTUALID (0x3ffUL << 0) 596 580 #define GICH_LR_PHYSID_CPUID_SHIFT (10) 597 581 #define GICH_LR_PHYSID_CPUID (7UL << GICH_LR_PHYSID_CPUID_SHIFT) 598 - 599 - #define ICH_MISR_EOI (1 << 0) 600 - #define ICH_MISR_U (1 << 1) 601 - 602 - #define ICH_HCR_EN (1 << 0) 603 - #define ICH_HCR_UIE (1 << 1) 604 - #define ICH_HCR_NPIE (1 << 3) 605 - #define ICH_HCR_TC (1 << 10) 606 - #define ICH_HCR_TALL0 (1 << 11) 607 - #define ICH_HCR_TALL1 (1 << 12) 608 - #define ICH_HCR_EOIcount_SHIFT 27 609 - #define ICH_HCR_EOIcount_MASK (0x1f << ICH_HCR_EOIcount_SHIFT) 610 - 611 - #define ICH_VMCR_ACK_CTL_SHIFT 2 612 - #define ICH_VMCR_ACK_CTL_MASK (1 << ICH_VMCR_ACK_CTL_SHIFT) 613 - #define ICH_VMCR_FIQ_EN_SHIFT 3 614 - #define ICH_VMCR_FIQ_EN_MASK (1 << ICH_VMCR_FIQ_EN_SHIFT) 615 - #define ICH_VMCR_CBPR_SHIFT 4 616 - #define ICH_VMCR_CBPR_MASK (1 << ICH_VMCR_CBPR_SHIFT) 617 - #define ICH_VMCR_EOIM_SHIFT 9 618 - #define ICH_VMCR_EOIM_MASK (1 << ICH_VMCR_EOIM_SHIFT) 619 - #define ICH_VMCR_BPR1_SHIFT 18 620 - #define ICH_VMCR_BPR1_MASK (7 << ICH_VMCR_BPR1_SHIFT) 621 - #define ICH_VMCR_BPR0_SHIFT 21 622 - #define ICH_VMCR_BPR0_MASK (7 << ICH_VMCR_BPR0_SHIFT) 623 - #define ICH_VMCR_PMR_SHIFT 24 624 - #define ICH_VMCR_PMR_MASK (0xffUL << ICH_VMCR_PMR_SHIFT) 625 - #define ICH_VMCR_ENG0_SHIFT 0 626 - #define ICH_VMCR_ENG0_MASK (1 << ICH_VMCR_ENG0_SHIFT) 627 - #define ICH_VMCR_ENG1_SHIFT 1 628 - #define ICH_VMCR_ENG1_MASK (1 << ICH_VMCR_ENG1_SHIFT) 629 - 630 - #define ICH_VTR_PRI_BITS_SHIFT 29 631 - #define ICH_VTR_PRI_BITS_MASK (7 << ICH_VTR_PRI_BITS_SHIFT) 632 - #define ICH_VTR_ID_BITS_SHIFT 23 633 - #define ICH_VTR_ID_BITS_MASK (7 << ICH_VTR_ID_BITS_SHIFT) 634 - #define ICH_VTR_SEIS_SHIFT 22 635 - #define ICH_VTR_SEIS_MASK (1 << ICH_VTR_SEIS_SHIFT) 636 - #define ICH_VTR_A3V_SHIFT 21 637 - #define ICH_VTR_A3V_MASK (1 << ICH_VTR_A3V_SHIFT) 638 582 639 583 #define ICC_IAR1_EL1_SPURIOUS 0x3ff 640 584
+22
lib/devres.c
··· 10 10 DEVM_IOREMAP = 0, 11 11 DEVM_IOREMAP_UC, 12 12 DEVM_IOREMAP_WC, 13 + DEVM_IOREMAP_NP, 13 14 }; 14 15 15 16 void devm_ioremap_release(struct device *dev, void *res) ··· 42 41 break; 43 42 case DEVM_IOREMAP_WC: 44 43 addr = ioremap_wc(offset, size); 44 + break; 45 + case DEVM_IOREMAP_NP: 46 + addr = ioremap_np(offset, size); 45 47 break; 46 48 } 47 49 ··· 103 99 EXPORT_SYMBOL(devm_ioremap_wc); 104 100 105 101 /** 102 + * devm_ioremap_np - Managed ioremap_np() 103 + * @dev: Generic device to remap IO address for 104 + * @offset: Resource address to map 105 + * @size: Size of map 106 + * 107 + * Managed ioremap_np(). Map is automatically unmapped on driver detach. 108 + */ 109 + void __iomem *devm_ioremap_np(struct device *dev, resource_size_t offset, 110 + resource_size_t size) 111 + { 112 + return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_NP); 113 + } 114 + EXPORT_SYMBOL(devm_ioremap_np); 115 + 116 + /** 106 117 * devm_iounmap - Managed iounmap() 107 118 * @dev: Generic device to unmap for 108 119 * @addr: Address to unmap ··· 146 127 dev_err(dev, "invalid resource\n"); 147 128 return IOMEM_ERR_PTR(-EINVAL); 148 129 } 130 + 131 + if (type == DEVM_IOREMAP && res->flags & IORESOURCE_MEM_NONPOSTED) 132 + type = DEVM_IOREMAP_NP; 149 133 150 134 size = resource_size(res); 151 135