Commit Graph

5125 Commits

Author SHA1 Message Date
Andriy Gapon
c3a7328be8 aw_clk_nm: fix incorrect use of abs()
abs() takes a (signed) int as input.
Instead, it was used with unsigned 64-bit integers.

So, add and use a new helper function to calculate a difference between
two uint64_t-s.

Reviewed by:	manu
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D26307
2020-09-07 06:27:18 +00:00
Mark Johnston
847ab36bf2 Include the psind in data returned by mincore(2).
Currently we use a single bit to indicate whether the virtual page is
part of a superpage.  To support a forthcoming implementation of
non-transparent 1GB superpages, it is useful to provide more detailed
information about large page sizes.

The change converts MINCORE_SUPER into a mask for MINCORE_PSIND(psind)
values, indicating a mapping of size psind, where psind is an index into
the pagesizes array returned by getpagesizes(3), which in turn comes
from the hw.pagesizes sysctl.  MINCORE_PSIND(1) is equal to the old
value of MINCORE_SUPER.

For now, two bits are used to record the page size, permitting values
of MAXPAGESIZES up to 4.

Reviewed by:	alc, kib
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D26238
2020-09-02 18:16:43 +00:00
Mark Johnston
2d838cd867 Add the MEM_EXTRACT_PADDR ioctl to /dev/mem.
This allows privileged userspace processes to find information about the
physical page backing a given mapping.  It is useful in applications
such as DPDK which perform some of their own memory management.

Reviewed by:	kib, jhb (previous version)
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D26237
2020-09-02 18:12:47 +00:00
Mateusz Guzik
654548838b arm: clean up empty lines in .c and .h files 2020-09-01 21:17:24 +00:00
Emmanuel Vadot
b46b3ba72c Fix arm64 build after r364927
Reported by:	jenkins, dch
Pointy hat to:	manu
2020-08-29 11:39:53 +00:00
Warner Losh
887611b122 Retire devctl_notify_f()
devctl_notify_f isn't needed, so retire it. The flags argument is now
unused, so rather than keep it around, retire it. Convert all old
users of it to devctl_notify(). This path no longer sleeps, so is safe
to call from any context. Since it doesn't sleep, it doesn't need to
know if it is OK to sleep or not.

Reviewed by: markj@
Differential Revision: https://reviews.freebsd.org/D26140
2020-08-29 04:30:06 +00:00
Emmanuel Vadot
341ccc993c arm: allwinner: clk: Add printfs when we cannot set the correct freq
For some unknown reason this seems to fix this function when we printf
the best variable. This isn't a delay problem as doing a printf without
it doesn't solve this problem.
This is way above my pay grade so add some printf that shouldn't be printed
in 99% of the case anyway.
Fix booting on most Allwinner boards as the mmc IP uses a NM clock.

Reported by:	Alexander Mishin <mishin@mh.net.ru>
MFC after:	3 days
X-MFC-With:	363887
2020-08-28 18:25:45 +00:00
Emmanuel Vadot
27998f7a02 arm: ti: Fix Beaglebone black MMC after DTS update
After DTS sync with Linux kernel 5.8 this patch was included:
"ARM: dts: Move am33xx and am43xx mmc nodes to sdhci-omap driver"
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/arm/boot/dts/am33xx-l4.dtsi?h=v5.9-rc2&id=0b4edf111870b83ea77b1d7e16b8ceac29f9f388

Current will not load any driver for MMC and not mount the rootfs.
Simple patch add "ti,am335-sdhci" to compability strings in ti_sdhci.c

Submitted by:	oskar.holmlund@ohdata.se
Reported by:	phk
X-MFC-With:	363853
2020-08-27 08:08:49 +00:00
Konstantin Belousov
0cad2aa2dd Pass pointers to info parsed from notes, to brandinfo->header_supported filter.
Currently, we parse notes for the values of ELF FreeBSD feature flags
and osrel.  Knowing these values, or knowing that image does not carry
the note if pointers are NULL, is useful to decide which ABI variant
(brand) we want to activate for the image.

Right now this is only a plumbing change

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D25273
2020-08-23 20:06:55 +00:00
Warner Losh
80bd2aad68 None of system, subsystem, or type may have spaces in them. Convert the spaces
to dashes.

Approved by: manu@
2020-08-18 20:20:45 +00:00
Andriy Gapon
d9fe3aed75 aw_cir: in the pulse encoding the actual length is one greater than value
While here change type of some variables from long to int, it's sufficient.
Also, add length reporting to a couple of debug printfs.

MFC after:	3 weeks
2020-08-12 09:57:28 +00:00
Andriy Gapon
852d135791 aw_cir: lower activation threshold to support NECx protocol
In NECx the leading mark has length of 8T as opposed to 16T in NEC,
where T is  562.5 us.  So, 4.5 ms.
Our threshold was set to 128 * 42.7 us (derived from the sampling
frequency of 3/128 MHz).  So, ~5.5 ms.

The new threshold is set to AW_IR_L1_MIN.  I think that's a good enough
lower bound for detecting the leading pulse.

Also, calculations of active_delay (which is activation delay) are fixed.
Previously they would be wrong if AW_IR_ACTIVE_T was anything but zero,
because the value was already bit-shifted.

Finally, I am not sure why the activation delay was divided by two when
calculating the initial pulse length.  I have not found anything that
would explain or justify it.  So, I removed that division.

MFC after:	3 weeks
2020-08-12 09:56:21 +00:00
Andriy Gapon
8b616b263d aw_cir: minor cleanups
MFC after:	1 week
2020-08-12 09:52:39 +00:00
Andriy Gapon
012fba460a aw_cir: add support for allwinner,sun6i-a31-ir (found, e.g., on h3)
MFC after:	1 week
2020-08-12 09:52:12 +00:00
Andriy Gapon
a89b0586a3 ccu_sun8i_r: minor comment update
MFC after:	1 week
2020-08-06 11:18:06 +00:00
Emmanuel Vadot
738fc84a7a allwinner: clk: Fix nm clock calculation
Use the right factor when finding the best frequency and compare the
absolute value of the result.

Submitted by:	kibab
MFC after:	3 days
2020-08-05 08:31:26 +00:00
Andrew Turner
9ca3eaf0bd Add a GPIO driver for the Raspberry Pi firmware GPIOs
These exist on the Raspberry Pi 3 and 4 and control and external IO
expander.

Reviewed by:	manu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D25858
2020-08-03 17:18:12 +00:00
Andrew Turner
7e077ed00c Allow the Raspberry Pi firmware driver to be a bus
There are child nodes in the device tree, e.g. the Raspberry Pi firmware
GPIO device. Add support for this to be a bus so we can attach these
children.

Reviewed by:	manu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D25848
2020-08-03 16:43:40 +00:00
Andrew Turner
31e34625ca Handle Raspberry Pi 4 xhci firmware loading.
The newer hardware revisions of the Raspberry Pi 4 removed the ability of
the VIA VL805 xhci controller to load its own firmware. Instead the
firmware must be installed at the appropriate time by the VideoCore
coprocessor.

Submitted by:	Robert Crowston <crowston_protonmail.com>
Differential Revision:	https://reviews.freebsd.org/D25261
2020-08-03 10:19:50 +00:00
Michal Meloun
0050ea2415 Move Ti AM335x to dev/extres/clk framework.
Re-implement clocks for these SoC by using now standard extres/clk framework.
This is necessary for future expansion of these. The new  implementation
is (due to the size of the patch) only the initial (minimum) version.
It will be updated/expanded with a subsequent set of particular patches.

This patch is also not tested on OMAP4 based boards (BeagleBone),
so all possible issues should be (and will be) fixed by ASAP once
identified.

Submited by:		Oskar Holmlund (oskar.holmlund@ohdata.se)
Differential Revision:  https://reviews.freebsd.org/D25118
2020-07-30 14:45:05 +00:00
Andrew Turner
65e305af3d Only try managing the regulator when EXT_RESOURCES is defined
Not all Raspberry Pi kernel configs define EXT_RESOURCES. Check for this
before trying to manage the regulator.

Sponsored by:	Innovate UK
2020-07-29 08:24:40 +00:00
Andrew Turner
ce69217c7b Add a workaround for a bug when setting the Raspberry GIO config and state
The Raspberry Pi GPIO config and state messages incorrectly return with
the tag length set to 0. We then check this value to have the response
flag set. Work around this by setting the response flag when setting the
GPIO config or state and this value is zero.

Sponsored by:	Innovate UK
2020-07-28 11:32:45 +00:00
Andrew Turner
d9501cbab5 Aadd Raspberry Pi firmware messages to manage GPIOs
Some GPIOs are managed by an external IO expaandder through the firmware.
Add the message details for these.

Sponsored by:	Innovate UK
2020-07-28 11:13:37 +00:00
Andrew Turner
7413ae0ee5 Switch the bcm2835 cpufreq driver to use the firmware interface
Use the new Raspberry Pi firmware driver in the cpufreq driver. It is
intended all drivers that need to interact with the firmware will move to
use the firmware driver, this is the first.

Reviewed by:	manu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D25609
2020-07-28 10:45:29 +00:00
Andrew Turner
0083fb5d49 Move the bcm2835 firmware driver earlier in the boot.
It will be needed by other eaarly drivers.

While here make the dependency of the mailbox formal with MODULE_DEPEND.

Reviewed by:	manu
Sponsored by:	Innovate UK
2020-07-28 10:43:52 +00:00
Andrew Turner
73d0751a81 Revert r363639 so I can use a more correct commit message 2020-07-28 10:41:43 +00:00
Andrew Turner
4b24f9a0a8 Move the bcm2835 mailbox driver earlier in the boot
This will be needed before the firmware driver is loaded
2020-07-28 10:40:00 +00:00
Andrew Turner
feecedb1c6 Have the bcm2835 firmware driver depend on the mailbox driver
The firmware driver uses the mailbox driver to communicate with the
firmware. Make this a more formal dependency.

Reviewed by:	manu
Sponsored by:	Innovate UK
2020-07-28 10:37:58 +00:00
Andrew Turner
b77fd84692 Enable use of the regulator in the Broadcom SDHCI controller
This will be needed before a future GPIO controller driver is added
as the later enables regulators that leave the SDHCI controller disabled.

Reviewed by:	manu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D25834
2020-07-28 09:46:58 +00:00
John Baldwin
91371fbcf6 Set si_trapno to the fault index from fsr.
Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25772
2020-07-27 16:29:21 +00:00
Andriy Gapon
062528c5f2 actually enable gate control for allwinner's r-ccu ir clock
The gate control bit offset was correctly specified, but AW_CLK_HAS_GATE
flag was not set.
Tested with (C)IR receiver on Orange Pi PC Plus.

Reviewed by:	manu
MFC after:	1 week
2020-07-27 09:10:02 +00:00
Emmanuel Vadot
a6d9c9257c mmccam: aw_mmc: Only print the new ios value under bootverbose 2020-07-24 18:44:50 +00:00
Emmanuel Vadot
9bca466745 aw_mmc: Start a mmccam discovery when the CD handler is called.
Submitted by:	kibab
2020-07-22 18:33:36 +00:00
Mark Johnston
e64080e79c Switch from SCTP to SCTP_SUPPORT in GENERIC configs.
This removes SCTP from in-tree kernel configuration files.  Now, SCTP
can be enabled by simply loading the module, as discussed on
freebsd-net@.

Reviewed by:	tuexen
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D25611
2020-07-16 15:09:04 +00:00
Michal Meloun
6e9862526a Fix the module name for some arm drivers.
Module name (unlike of the of driver name) must be system wide unique.

Reported by:	Mark Millard(bcm_pci), andrew(mvebu_gpio)
MFC with:	r362954, r362385
2020-07-12 07:27:21 +00:00
Andrew Turner
0d266dedf7 Split long lines in the Raspberry Pi FB driver
Sponsored by:	Innovate UK
2020-07-10 09:34:47 +00:00
Andrew Turner
201a1f34da Add a driver to talk to the Raspberry Pi firmware
Communicating with the Raspberry Pi firmware is currently handled by each
driver calling into the mbox driver, however the device tree is structured
such that they should be calling into a firmware driver.

Add a driver for this node with an interface to communicate to the firmware
via the mbox interface.

There is a sysctl to get the firmware revision. This is a unix date so can
be parsed with:

root@generic:~ # date -j -f '%s' sysctl -n dev.bcm2835_firmware.0.revision
Tue Nov 19 16:40:28 UTC 2019

Reviewed by:	manu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D25572
2020-07-09 16:28:13 +00:00
Andrew Turner
eed8b80f64 Add a driver for bcm2838 PCI express controller
This adds support for the Broadcom bcm2711 PCI express controller, found
on the Raspberry Pi 4 (aka the bcm2838 SoC). The driver has only been
developed against the soldered-on VIA XHCI controller and not tested
with other end points.

Submitted by:	Robert Crowston <crowston_protonmail.com>
Differential Revision:	https://reviews.freebsd.org/D25068
2020-07-06 08:51:55 +00:00
Oleksandr Tymoshenko
94bc2117b4 Add i.MX 8M Quad support
- Add CCM driver and clocks implementations for i.MX 8M
- Add GPC driver for iMX8
- Add clock tree for i.MX 8M Quad
- Add clocks support and new compat strings (where required) for existing i.MX 6 UART, I2C, and GPIO drivers
- Enable aarch64-compatible drivers form i.MX 6 in arm64 GENERIC kernel config
- Add dtb/imx8 kernel module with DTBs for Nitrogen8M and iMX8MQ EVK

With this patch both Nitrogen8M and iMX8MQ EVK boot with NFS root up to multiuser login prompt

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D25274
2020-07-01 00:33:16 +00:00
Andrew Turner
fc0804f18b Fix reboot command on the Raspberry Pi series.
The Raspbery Pi computers do not properly implement PSCI. The canonical
way to reset them is to set a watchdog timer and allow it to expire.

Submitted by:	Robert Crowston <crowston_protonmail.com>
Differential Revision:	https://reviews.freebsd.org/D25268
2020-06-22 08:12:21 +00:00
Brandon Bergren
40b664f64b [PowerPC] More relocation fixes
It turns out relocating the symbol table itself can cause issues, like fbt
crashing because it applies the offsets to the kernel twice.

This had been previously brought up in rS333447 when the stoffs hack was
added, but I had been unaware of this and reimplemented symtab relocation.

Instead of relocating the symbol table, keep track of the relocation base
in ddb, so the ddb symbols behave like the kernel linker-provided symbols.

This is intended to be NFC on platforms other than PowerPC, which do not
use fully relocatable kernels. (The relbase will always be 0)

 * Remove the rest of the stoffs hack.
 * Remove my half-baked displace_symbol_table() function.
 * Extend ddb initialization to cope with having a relocation offset on the
   kernel symbol table.
 * Fix my kernel-as-initrd hack to work with booke64 by using a temporary
   mapping to access the data.
 * Fix another instance of __powerpc__ that is actually RELOCATABLE_KERNEL.
 * Change the behavior or X_db_symbol_values to apply the relocation base
   when updating valp, to match link_elf_symbol_values() behavior.

Reviewed by:	jhibbits
Sponsored by:	Tag1 Consulting, Inc.
Differential Revision:	https://reviews.freebsd.org/D25223
2020-06-21 03:39:26 +00:00
Kyle Evans
e245e555fa raspberry pi 4: cpufreq support
The submitter notes that the bcm2835_cpufreq driver really just needs the
rpi4 compat string added to it; powerd subsequently works and the dev.cpu.0
sysctl values look sane and can be successfully manipulated.

Submitted by:	James Mintram <me@jamesrm.com>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D25349
2020-06-20 04:07:58 +00:00
Michal Meloun
188aee740f Finish renaming in if_dwc.
By using DWC TRM terminology, normal descriptor format should be named
extended and alternate descriptor format should be named normal.

Should not been functional change.

MFC after:	4 weeks
2020-06-19 18:34:27 +00:00
Michal Meloun
d5d4dd38b4 Add specific stub for ARMADA 8k SoC to Marvell RTC driver.
The AXI bridge is different between ARMADA 38x and 8K, and both platforms
needs specific setup to mitigate HW issues with accessing RTC registers.

MFC after:	2 weeks
2020-06-19 15:32:55 +00:00
Michal Meloun
5e2e692c94 Add specialized gpio driver for ARMADA 8k SoC.
Older marvell gpio blocks are to different for reusing/enhancing
existing frivers.

MFC after:	2 weeks
2020-06-19 15:21:33 +00:00
John Baldwin
ad54157b5e Simplify MACHINE_ARCH to be a single string.
Big endian and armv4 mean that we are now down to only two supported
variants.  A future change will use MACHINE_ARCH in assembly which
does not support C-style string concatentation and thus needs
MACHINE_ARCH defined as a single string.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D25211
2020-06-15 18:57:43 +00:00
Michal Meloun
3e13ea16a6 Fix grabbing of tegra uart.
An attempt to write to FCR register may corrupt transmit FIFO,
so we should wait for the FIFO to be empty before we can modify it.

MFC after:	1 week
2020-06-11 12:53:22 +00:00
Oleksandr Tymoshenko
da21a623dd Add mode selection to iMX6 IPU driver
- Configure ipu1_di0 tob e sourced from the VIDEO_PLL(PLL5) and hardcode
  frequency to (455000000/3)Mhz. This value, further divided, can yield
  frequencies close enough to support 1080p, 720p, 1024x768, and 640x480
  modes. This is not ideal but it's an improvement comparing to the only
  hardcoded 1024x768 mode.

- Fix memory leaks if attach method failed
- Print EDID when -v passed to the kernel
2020-06-10 22:00:31 +00:00
Andreas Tobler
c76b8bda0b Fix boot of wandquad after DTS update
In the recent dts sync the name of the aips-bus@ changed to bus@. Reflect
this change and add an additional OF_finddevice in fix_fdt_interrupt_data()
and in fix_fdt_iomuxc_data() with bus@ only. Iow, keep the old naming for
compatibility.

Discussed with:	ian@
2020-06-09 20:27:35 +00:00
Mitchell Horne
cd9207569f Remove remnant of arm's ELF trampoline
The trampoline code used for loading gzipped a.out kernels on arm was
removed in r350436. A portion of this code allowed for DDB to find the
symbol tables when booting without loader(8), and some of this was
untouched in the removal. Remove it now.

Differential Revision:	https://reviews.freebsd.org/D24950
2020-05-31 14:43:04 +00:00