summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
Commit message (Collapse)AuthorAgeFilesLines
* Fix the deciKelvin to Celsius conversion in kernel.loos2016-05-223-7/+7
| | | | | | | | | | | After r285994, sysctl(8) was fixed to use 273.15 instead of 273.20 as 0C reference and as result, the temperature read in sysctl(8) now exibits a +0.1C difference. This commit fix the kernel references to match the reference value used in sysctl(8) after r285994. Sponsored by: Rubicon Communications (Netgate)
* Add macro to convert errno and use it when appropriate.dchagin2016-05-221-5/+1
| | | | MFC after: 1 week
* Use OF_prop_free instead of direct call to free(9)gonzo2016-05-142-4/+4
| | | | Reviewed by: jhibbits
* Native PCI-express HotPlug support.jhb2016-05-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PCI-express HotPlug support is implemented via bits in the slot registers of the PCI-express capability of the downstream port along with an interrupt that triggers when bits in the slot status register change. This is implemented for FreeBSD by adding HotPlug support to the PCI-PCI bridge driver which attaches to the virtual PCI-PCI bridges representing downstream ports on HotPlug slots. The PCI-PCI bridge driver registers an interrupt handler to receive HotPlug events. It also uses the slot registers to determine the current HotPlug state and drive an internal HotPlug state machine. For simplicty of implementation, the PCI-PCI bridge device detaches and deletes the child PCI device when a card is removed from a slot and creates and attaches a PCI child device when a card is inserted into the slot. The PCI-PCI bridge driver provides a bus_child_present which claims that child devices are present on HotPlug-capable slots only when a card is inserted. Rather than requiring a timeout in the RC for config accesses to not-present children, the pcib_read/write_config methods fail all requests when a card is not present (or not yet ready). These changes include support for various optional HotPlug capabilities such as a power controller, mechanical latch, electro-mechanical interlock, indicators, and an attention button. It also includes support for devices which require waiting for command completion events before initiating a subsequent HotPlug command. However, it has only been tested on ExpressCard systems which support surprise removal and have none of these optional capabilities. PCI-express HotPlug support is conditional on the PCI_HP option which is enabled by default on arm64, x86, and powerpc. Reviewed by: adrian, imp, vangyzen (older versions) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D6136
* powerpc: Replace rounddown() from r298856 with roundup().pfg2016-04-301-3/+3
| | | | | | | Both are equivalent but roundup is more logical for this case. Catch another case while here. Pointed out by: jhibbits
* powerpc: Make use of our rounddown() macro when sys/param.h is available.pfg2016-04-301-3/+3
| | | | No functional change.
* Move 'device pci' for the PCI bus driver to the MI NOTES file.jhb2016-04-291-1/+0
| | | | | The PCI bus was already listed in all of the MD NOTES files and the driver should at least compile on all platforms.
* Remove vestiges of IEEE-488/GPIB drivers removed in r276214.jhb2016-04-291-3/+0
|
* Add a bus_null_rescan() method that always fails with an error.jhb2016-04-271-1/+1
| | | | | Use this in place of kobj_error_method to disable BUS_RESCAN() on PCI drivers that do not use the "standard" scanning algorithm.
* Add a pcib_attach_child() method to manage adding the child "pci" device.jhb2016-04-271-4/+1
| | | | | | | | | | | | This allows the PCI-PCI bridge driver to save a reference to the child device in its softc. Note that this required moving the "pci" device creation out of acpi_pcib_attach(). Instead, acpi_pcib_attach() is renamed to acpi_pcib_fetch_prt() as it's sole action now is to fetch the PCI interrupt routing table. Differential Revision: https://reviews.freebsd.org/D6021
* Implement a PCI bus rescan method.jhb2016-04-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | Rescanning a PCI bus uses the following steps: - Fetch the current set of child devices and save it in the 'devlist' array. - Allocate a parallel array 'unchanged' initalized with NULL pointers. - Scan the bus checking each slot (and each function on slots with a multifunction device). - If a valid function is found, look for a matching device in the 'devlist' array. If a device is found, save the pointer in the 'unchanged' array. If a device is not found, add a new device. - After the scan has finished, walk the 'devlist' array deleting any devices that do not have a matching pointer in the 'unchanged' array. - Finally, fetch an updated set of child devices and explicitly attach any devices that are not present in the 'unchanged' array. This builds on the previous changes to move subclass data management into pci_alloc_devinfo(), pci_child_added(), and bus_child_deleted(). Subclasses of the PCI bus use custom rescan logic explicitly override the rescan method to disable rescans. Differential Revision: https://reviews.freebsd.org/D6018
* sys/powerpc: make use of the howmany() macro when available.pfg2016-04-263-4/+4
| | | | | We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read.
* OR in the unsigned form of the MCAR lower register.jhibbits2016-04-251-1/+1
| | | | | | | When ORing in a register_t to a wider integer (vm_paddr_t), it gets sign extended, so high addresses overwrite the upper word with all 0xf. Cast to the unsigned form (u_register_t), to avoid this problem, and get correct addresses printed.
* Init static compiled-in env when no metadata present.jhibbits2016-04-251-0/+1
| | | | | | With this, a static environment can be compiled in via config(5). This allows, among other things, the use of a compiled-in debug console (hw.uart.dbgport) for kgdb.
* sys: use our roundup2/rounddown2() macros when param.h is available.pfg2016-04-214-8/+8
| | | | | | | | | | rounddown2 tends to produce longer lines than the original code and when the code has a high indentation level it was not really advantageous to do the replacement. This tries to strike a balance between readability using the macros and flexibility of having the expressions, so not everything is converted.
* Use our nitems() macro when param.h is available.pfg2016-04-202-3/+3
| | | | | | Replacements specific to arm, mips, pc98, powerpc and sparc64. Discussed in: freebsd-current
* Fix SMP booting for PowerPC Book-Ejhibbits2016-04-196-207/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: PowerPC Book-E SMP is currently broken for unknown reasons. Pull in Semihalf changes made c2012 for e500mc/e5500, which enables booting SMP. This eliminates the shared software TLB1 table, replacing it with tlb1_read_entry() function. This does not yet support ePAPR SMP booting, and doesn't handle resetting CPUs already released (ePAPR boot releases APs to a spin loop waiting on a specific address). This will be addressed in the near future by using the MPIC to reset the AP into our own alternate boot address. This does include a change to the dpaa/dtsec(4) driver, to mark the portals as CPU-private. Test Plan: Tested on Amiga X5000/20 (P5020). Boots, prints the following messages: Adding CPU 0, pir=0, awake=1 Waking up CPU 1 (dev=1) Adding CPU 1, pir=20, awake=1 SMP: AP CPU #1 launched top(1) shows CPU1 active. Obtained from: Semihalf Relnotes: Yes Differential Revision: https://reviews.freebsd.org/D5945
* powerpc: for pointers replace 0 with NULL.pfg2016-04-154-5/+5
| | | | | | | | These are mostly cosmetical, no functional change. Found with devel/coccinelle. Reviewed by: jhibbits
* Add a new PCI bus interface method to alloc the ivars (dinfo) for a device.jhb2016-04-151-3/+14
| | | | | | | | | | | | | | The ACPI and OFW PCI bus drivers as well as CardBus override this to allocate the larger ivars to hold additional info beyond the stock PCI ivars. This removes the need to pass the size to functions like pci_add_iov_child() and pci_read_device() simplifying IOV and bus rescanning implementations. As a result of this and earlier changes, the ACPI PCI bus driver no longer needs its own device_attach and pci_create_iov_child methods but can use the methods in the stock PCI bus driver instead. Differential Revision: https://reviews.freebsd.org/D5891
* Cleanup unnecessary semicolons from the kernel.pfg2016-04-103-3/+3
| | | | Found with devel/coccinelle.
* VM_MAXUSER_ADDRESS is highest page start, not highest address.jhibbits2016-04-101-1/+1
| | | | | In case a single page mapping is requested first, which might overlap the user address space, fix the device map block to the next page.
* Restructure device mappings for Book-E.jhibbits2016-04-102-18/+19
| | | | | | | | | | | | | | | | | | Summary: There is currently a 1GB hole between user and kernel address spaces into which direct (1:1 PA:VA) device mappings go. This appears to go largely unused, leaving all devices to contend with the 128MB block at the end of the 32-bit space (0xf8000000-0xffffffff). This easily fills up, and needs to be densely packed. However, dense packing wastes precious TLB1 space, of which there are only 16 (e500v2) or 64(e5500) entries available. Change this by using the 1GB space for all device mappings, and allow the kernel to use the entire upper 1GB for KVA. This also allows us to use sparse device mappings, freeing up TLB entries. Test Plan: Boot tested on p5020. Differential Revision: https://reviews.freebsd.org/D5832
* Convert pci_delete_child() to a bus_child_deleted() method.jhb2016-04-061-0/+12
| | | | | | | | | | | | | | | | | | | | Instead of providing a wrapper around device_delete_child() that the PCI bus and child bus drivers must call explicitly, move the bulk of the logic from pci_delete_child() into a bus_child_deleted() method (pci_child_deleted()). This allows PCI devices to be safely deleted via device_delete_child(). - Add a bus_child_deleted method to the ACPI PCI bus which clears the device_t associated with the corresponding ACPI handle in addition to the normal PCI bus cleanup. - Change cardbus_detach_card to call device_delete_children() and move CardBus-specific delete logic into a new cardbus_child_deleted() method. - Use device_delete_child() instead of pci_delete_child() in the SRIOV code. - Add a bus_child_deleted method to the OpenFirmware PCI bus drivers which frees the OpenFirmware device info for each PCI device. Reviewed by: imp Tested on: amd64 (CardBus and PCI-e hotplug) Differential Revision: https://reviews.freebsd.org/D5831
* Make i2c device child auto-probe work for MPC85xx and QorIQ SoCs.jhibbits2016-04-051-1/+11
| | | | | | OFW i2c probing requires a new method ofw_bus_get_node(), and the bus device is assumed iichb. With these changes, i2c devices attached in fdt are probed and attached automagically.
* Reduce OFW PCI code duplication - involves ARM, PPC and SPARC64zbb2016-03-296-13/+9
| | | | | | | | | | | | | | | | | Import portions of the PowerPC OF PCI implementation into new file "ofwpci.c", common for other platforms. The files ofw_pci.c and ofw_pci.h from sys/powerpc/ofw no longer exist. All required declarations are moved to sys/dev/ofw/ofwpci.h. This creates a new ofw_pci_write_ivar() function and modifies some others methods. Most functions contain existing ppc implementations in the majority unchanged. Now there is no need to have multiple identical copies of methods for various architectures. Requested by: jhibbits Reviewed by: jhibbits, marius Submitted by: Marcin Mazurek <mma@semihalf.com> Obtained from: Semihalf Sponsored by: Annapurna Labs Differential Revision: https://reviews.freebsd.org/D4879
* Fix the resource_list_print_type() calls to use uintmax_t.jhibbits2016-03-226-14/+14
| | | | Missed a bunch from r297000.
* Fix fallout from r292180 (Dec 2015)... ensure that every driver which hasian2016-03-211-1/+1
| | | | | | | | | a DRIVER_MODULE() referencing mmc_driver has a MODULE_DEPEND() on mmc. This is because the kernel linker only searches for symbols in dependent modules, so loading sdhci_pci (and other bus-flavors of sdhci) would fail when mmc was not compiled into the kernel (even if you hand-loaded mmc first). (Thanks to jilles@ for providing the vital clue about the kernel linker.)
* Increase booke bus max address to 36-bits.jhibbits2016-03-181-0/+5
| | | | Sponsored by: Alex Perez/Inertial Computing
* Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.jhibbits2016-03-184-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some architectures, u_long isn't large enough for resource definitions. Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but type `long' is only 32-bit. This extends rman's resources to uintmax_t. With this change, any resource can feasibly be placed anywhere in physical memory (within the constraints of the driver). Why uintmax_t and not something machine dependent, or uint64_t? Though it's possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on 32-bit architectures. 64-bit architectures should have plenty of RAM to absorb the increase on resource sizes if and when this occurs, and the number of resources on memory-constrained systems should be sufficiently small as to not pose a drastic overhead. That being said, uintmax_t was chosen for source clarity. If it's specified as uint64_t, all printf()-like calls would either need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t aren't horrible, but it would also bake into the API for resource_list_print_type() either a hidden assumption that entries get cast to uintmax_t for printing, or these calls would need the PRI*64 macros. Since source code is meant to be read more often than written, I chose the clearest path of simply using uintmax_t. Tested on a PowerPC p5020-based board, which places all device resources in 0xfxxxxxxxx, and has 8GB RAM. Regression tested on qemu-system-i386 Regression tested on qemu-system-mips (malta profile) Tested PAE and devinfo on virtualbox (live CD) Special thanks to bz for his testing on ARM. Reviewed By: bz, jhb (previous) Relnotes: Yes Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D4544
* Only check for SYS_freebsd6_lseek if the syscall code is defined.bz2016-03-141-2/+5
| | | | | Whether this is the right or best solution is unclear but it fixes the build for now.
* Let rman_init() initialize the default rman range.jhibbits2016-03-031-2/+0
| | | | | If rm_start and rm_end are both 0 on input to rman_init(), rman_init() pre-initializes them to the default range. No need to set it before.
* Fix 2 bugs in the mpc85xx local bus controller driver.jhibbits2016-03-021-2/+26
| | | | | | | | | | 1) Include opt_platform.h to get QORIQ_DPAA. Otherwise the definition of OCP85XX_TGTIF_LBC is incorrect. 2) The child resources are already allocated, just activate them, instead of incorrectly remapping the memory regions (resource lists for lbc consist of the virtual address of the child's resources, not the physical address). Sponsored by: Alex Perez/Inertial Computing
* Add another compatibility check for QorIQ GPIO driver.jhibbits2016-03-011-1/+2
| | | | | | | | Some MPC85xx GPIO controllers are compatible with QorIQ. It may make more sense in the future to rename this and mpc85xx_gpio.c, as mpc85xx_gpio.c appears to only be compatible with a few mpc85xx SoCs. All other MPC85xx SoCs use the same controller as QorIQ.
* Add VM_MEMATTR_CACHEABLE support for AIM, for parity with Book-E.jhibbits2016-03-012-0/+4
| | | | Not used right now, but may be in the future anyway.
* Add support for the Freescale dTSEC DPAA-based ethernet controller.jhibbits2016-02-2913-6/+298
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Freescale's QorIQ line includes a new ethernet controller, based on their Datapath Acceleration Architecture (DPAA). This uses a combination of a Frame manager, Buffer manager, and Queue manager to improve performance across all interfaces by being able to pass data directly between hardware acceleration interfaces. As part of this import, Freescale's Netcomm Software (ncsw) driver is imported. This was an attempt by Freescale to create an OS-agnostic sub-driver for managing the hardware, using shims to interface to the OS-specific APIs. This work was abandoned, and Freescale's primary work is in the Linux driver (dual BSD/GPL license). Hence, this was imported directly to sys/contrib, rather than going through the vendor area. Going forward, FreeBSD-specific changes may be made to the ncsw code, diverging from the upstream in potentially incompatible ways. An alternative could be to import the Linux driver itself, using the linuxKPI layer, as that would maintain parity with the vendor-maintained driver. However, the Linux driver has not been evaluated for reliability yet, and may have issues with the import, whereas the ncsw-based driver in this commit was completed by Semihalf 4 years ago, and is very stable. Other SoC modules based on DPAA, which could be added in the future: * Security and Encryption engine (SEC4.x, SEC5.x) * RAID engine Additional work to be done: * Implement polling mode * Test vlan support * Add support for the Pattern Matching Engine, which can do regular expression matching on packets. This driver has been tested on the P5020 QorIQ SoC. Others listed in the dtsec(4) manual page are expected to work as the same DPAA engine is included in all. Obtained from: Semihalf Relnotes: Yes Sponsored by: Alex Perez/Inertial Computing
* Implement pmap_change_attr() for PowerPC (Book-E only for now)jhibbits2016-02-275-0/+94
| | | | | | | | | | | | | | | | | | | | | | Summary: Some drivers need special memory requirements. X86 solves this with a pmap_change_attr() API, which DRM uses for changing the mapping of the GART and other memory regions. Implement the same function for PowerPC. AIM currently does not need this, but will in the future for DRM, so a default is added for that, for business as usual. Book-E has some drivers coming down that do require non-default memory coherency. In this case, the Datapath Acceleration Architecture (DPAA) based ethernet controller has 2 regions for the buffer portals: cache-inhibited, and cache-enabled. By default, device memory is cache-inhibited. If the cache-enabled memory regions are mapped cache-inhibited, an alignment exception is thrown on access. Test Plan: Tested with a new driver to be added after this (DPAA dTSEC ethernet driver). No alignment exceptions thrown, driver works as expected with this. Reviewed By: nwhitehorn Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5471
* Move another range check to use RMAN_IS_DEFAULT_RANGE().jhibbits2016-02-271-1/+1
|
* Allow the size argument for law_enable() to be non-power-of-2.jhibbits2016-02-231-1/+2
| | | | | Although the local access windows are powers of 2 in size, allow arguments that aren't power of 2, and round up.
* As <machine/pmap.h> is included from <vm/pmap.h>, there is no need toskra2016-02-2216-16/+0
| | | | | | | include it explicitly when <vm/pmap.h> is already included. Reviewed by: alc, kib Differential Revision: https://reviews.freebsd.org/D5373
* Revert r295756:zbb2016-02-206-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | Extract common code from PowerPC's ofw_pci Import portions of the PowerPC OF PCI implementation into new file "ofw_pci.c", common for other platforms. The files ofw_pci.c and ofw_pci.h from sys/powerpc/ofw no longer exist. All required declarations are moved to sys/dev/ofw/ofw_pci.h. This creates a new ofw_pci_write_ivar() function and modifies ofw_pci_nranges(), ofw_pci_read_ivar(), ofw_pci_route_interrupt() methods. Most functions contain existing ppc implementations in the majority unchanged. Now there is no need to have multiple identical copies of methods for various architectures. Submitted by: Marcin Mazurek <mma@semihalf.com> Obtained from: Semihalf Sponsored by: Annapurna Labs Reviewed by: jhibbits, mmel Differential Revision: https://reviews.freebsd.org/D4879 This needs to return to the drawing board as it breaks both PowerPC and Sparc64 build. Pointed out by: jhibbits
* Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.jhibbits2016-02-201-1/+1
| | | | | | | | | | | This simplifies checking for default resource range for bus_alloc_resource(), and improves readability. This is part of, and related to, the migration of rman_res_t from u_long to uintmax_t. Discussed with: jhb Suggested by: marcel
* Extract common code from PowerPC's ofw_pcizbb2016-02-186-12/+5
| | | | | | | | | | | | | | | | | | | Import portions of the PowerPC OF PCI implementation into new file "ofw_pci.c", common for other platforms. The files ofw_pci.c and ofw_pci.h from sys/powerpc/ofw no longer exist. All required declarations are moved to sys/dev/ofw/ofw_pci.h. This creates a new ofw_pci_write_ivar() function and modifies ofw_pci_nranges(), ofw_pci_read_ivar(), ofw_pci_route_interrupt() methods. Most functions contain existing ppc implementations in the majority unchanged. Now there is no need to have multiple identical copies of methods for various architectures. Submitted by: Marcin Mazurek <mma@semihalf.com> Obtained from: Semihalf Sponsored by: Annapurna Labs Reviewed by: jhibbits, mmel Differential Revision: https://reviews.freebsd.org/D4879
* Introduce bus_get_bus_tag() methodzbb2016-02-181-0/+9
| | | | | | | | | | | | | | | | | | | Provide bus_get_bus_tag() for sparc64, powerpc, arm, arm64 and mips nexus and its children in order to return a platform specific default tag. This is required to ensure generic correctness of the bus_space tag. It is especially needed for arches where child bus tag does not match the parent bus tag. This solves the problem with ppc architecture where the PCI bus tag differs from parent bus tag which is big-endian. This commit is a part of the following patch: https://reviews.freebsd.org/D4879 Submitted by: Marcin Mazurek <mma@semihalf.com> Obtained from: Semihalf Sponsored by: Annapurna Labs Reviewed by: jhibbits, mmel Differential Revision: https://reviews.freebsd.org/D4879
* Another conversion u_long -> rman_res_tjhibbits2016-02-161-5/+5
|
* Allow callers of OF_decode_addr to get the size of the found mapping. Thisandrew2016-02-162-2/+5
| | | | | | | | | | | | | | will allow for code that uses the old fdt_get_range and fdt_regsize functions to find a range, map it, access, then unmap to replace this, up to and including the map, with a call to OF_decode_addr. As this function should only be used in the early boot code the unmap is mostly do document we no longer need the mapping as it's a no-op, at least on arm. Reviewed by: jhibbits Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D5258
* Fix a panic bug that cropped up in the PTE rewrite.jhibbits2016-02-162-1/+3
| | | | | | PTE was getting overwritten by just the flags. Pointy-hat to: jhibbits
* POSIX states that #include <signal.h> shall make both mcontext_t andkib2016-02-121-5/+5
| | | | | | | | | | | | | | | | | | | | ucontext_t available. Our code even has XXX comment about this. Add a bit of compliance by moving struct __ucontext definition into sys/_ucontext.h and including it into signal.h and sys/ucontext.h. Several machine/ucontext.h headers were changed to use namespace-safe types (like uint64_t->__uint64_t) to not depend on sys/types.h. struct __stack_t from sys/signal.h is made always visible in private namespace to satisfy sys/_ucontext.h requirements. Apparently mips _types.h pollutes global namespace with f_register_t type definition. This commit does not try to fix the issue. PR: 207079 Reported and tested by: Ting-Wei Lan <lantw44@gmail.com> Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Migrate the PTE format for book-e to standardize on the 'indirect PTE' formatjhibbits2016-02-114-65/+66
| | | | | | | | | | | | Summary: The revised Book-E spec, adding the specification for the MMUv2 and e6500, includes a hardware PTE layout for indirect page tables. In order to support this in the future, migrate the PTE format to match the MMUv2 hardware PTE format. Test Plan: Boot tested on a P5020 board. Booted to multiuser mode. Differential Revision: https://reviews.freebsd.org/D5224
* Include sys/_task.h into uma_int.h, so that taskqueue.h isn't aglebius2016-02-091-1/+0
| | | | | | requirement for uma_int.h. Suggested by: jhb
* Fix build of powerpc FPU emulator after changes in r295132 to restore thejhb2016-02-042-24/+24
| | | | | | | | ABI of struct fpreg. The FPU emulator operates on the "raw" FPU state stored in the pcb rather than the "cooked" fpreg state used for ptrace() and cores. Reported by: bz
OpenPOWER on IntegriCloud