Commit graph

225 commits

Author SHA1 Message Date
John F. Carr 97ab935d56 rk_pinctrl: fix error check
The parse_bias method returns a signed int, with a value of -1 when
the device tree reports nothing of the bias configuration. Convert the
local 'bias' from unsigned to signed to properly check this condition.

PR:		229721
Reviewed by:	mhorne
MFC after:	3 days
2024-06-14 13:42:27 -03:00
Andrew Turner 4f012d7a7a arm64/rockchip: Fix the build with GCC
We were missing brackets in GPIO_FLAGS_PINCTRL. Without them GCC
complains a use is ambiguous. Fix by adding the needed brackets.

Reviewed by:	manu, brooks, imp, jhb, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45264
2024-05-22 08:19:19 +00:00
rilysh cba889e63c sys/arm64/rockchip/rk_gpio.c: remove an extra semicolon
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/959
2024-02-02 18:35:01 -07:00
Andriy Gapon 89cb925fdd rk_i2s: remove unused definition 2024-01-28 13:37:25 +02:00
Andriy Gapon 406e959d07 rk_i2s: change interrupt type from MISC to AV (audio/video)
This gives a higher priority to the interrupt handling thread.
We need it because its work (filling the hardware FIFO) is time sensitive.
2024-01-28 13:36:19 +02:00
Andriy Gapon 408a9efd75 rk3328_codec: remove diagostic printfs
Most likeyly there were intended as reminders for unimplemented functions,
but they do not seem to be useful.

Also, a small style nit.
2024-01-28 13:33:16 +02:00
Emmanuel Vadot 62e8ccc3a4 syscon: Move syscon code in dev/syscon
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	mhorne
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43196
2024-01-10 19:20:37 +01:00
Emmanuel Vadot 950a6087ec phy: Move phy code in dev/phy
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	emaste, imp
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43195
2024-01-10 19:20:34 +01:00
Emmanuel Vadot b2f0caf160 regulator: Move regulator code in dev/regulator
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	emaste, imp
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43194
2024-01-10 19:20:32 +01:00
Emmanuel Vadot 1f469a9fc4 hwreset: Move reset code in dev/hwreset
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	imp
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43192
2024-01-10 19:20:28 +01:00
Emmanuel Vadot be82b3a0bf clk: Move clock code in dev/clk
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	mhorne
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43191
2024-01-10 19:20:26 +01:00
Emmanuel Vadot fe75646a02 usb: dwc3: Move driver under a subdirectory
dwc3 is big enough to have its own subdirectory.
While here only make it depend on kernel option dwc3 and rk_dwc3
without any SOC options.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43190
2024-01-10 19:20:24 +01:00
Emmanuel Vadot 77f2224158 clk: Move rockchip driver into the common directory
No need to keep it under sys/arm64/rockchip/clk
It's easier to find which controller we support by looking under one directory.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43189
2024-01-10 19:20:22 +01:00
Emmanuel Vadot 2e3507c25e pwm: Move rockchip driver into the common directory
No need to keep it under sys/arm64/rockchip
It's easier to find which controller we support by looking under one directory.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43186
2024-01-10 19:20:17 +01:00
Emmanuel Vadot 994c943a00 spibus: Move rockchip driver into the common directory
No need to keep it under sys/arm64/rockchip
It's easier to find which controller we support by looking under one directory.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
2024-01-10 19:20:13 +01:00
Emmanuel Vadot 3c2b2a28b9 iicbus: Move rockchip driver into the common directory
No need to keep it under sys/arm64/rockchip
It's easier to find which controller we support by looking under one directory.
While here remove the condition on SOC option, device rk_i2c is enough as all
Rockchip SoC that we support have this controller.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43184
2024-01-10 19:20:10 +01:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Emmanuel Vadot 432ae724e6 dwc: Move every sub drivers to dev/dwc
It makes it easier to find all the sub drivers and change them if needed.
While here do not gate dwc_rk with soc options, dwc_rk is made for all rockchip
SoCs. Same thing for dwc_socfpga
2023-10-05 17:34:38 +02:00
Emmanuel Vadot db34f02028 arm64: rockchip: rk_clk_composite: Remove gate code
It was a bad idea to have composite clock directly managing gates.
All clocks drivers have been rewrite to not use this functionality
and directly export the gate. We can now remove this code.
2023-09-21 17:49:33 +02:00
Emmanuel Vadot 829b06ad8f arm64: rockchip: rk3399_pmucru: Finish exporting all clocks
- All used clocks are now exported.
- Use the macros from rk_cru.h so code is similar to other rk clock drivers.
2023-09-21 17:49:33 +02:00
Emmanuel Vadot 5b7fe78032 arm64: rockchip: Remove CRU_GATE macro
It's unused now
2023-09-21 17:49:32 +02:00
Emmanuel Vadot 3d2ccc352d arm64: rockchip: rk3399_pmucru: Use GATE macro
It make it easier to read the code and the register number
2023-09-21 17:49:32 +02:00
Emmanuel Vadot 7c6c426f29 arm64: rockchip: rk3328_cru: Use GATE macro
It make it easier to read the code and the register number
2023-09-21 17:49:32 +02:00
Emmanuel Vadot 50a0f1ce28 arm64: rockchip: rk3568_cru: Rewrite
Rewrite correctly the clocks for cru :
- Export all clocks
- Use names from the TRM
- Respect clock topology

Fixes:  a48301a5e0 ("Add initial clocks support for Rockchip RK3568 SoC.")
2023-09-21 17:49:06 +02:00
Emmanuel Vadot 7b6ae431cf arm64: rockchip: rk3568_pmucru: Rewrite
Rewrite correctly the clocks for pmucru :
- Export all clocks
- Use names from the TRM
- Respect clock topology

Fixes:	a48301a5e0 ("Add initial clocks support for Rockchip RK3568 SoC.")
2023-09-21 17:49:04 +02:00
Emmanuel Vadot 8ae54db639 arm64: rockchip: clk: Define PLIST macro in rk_cru.h
We use it in all clock drivers so no need to define it everywhere
2023-09-21 17:49:02 +02:00
Warner Losh 031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Emmanuel Vadot 393387820b arm64: rockchip: rk_i2c: Probe again at ORDER_LATE
The gic driver is also probed at this pass and depending on the order of
the nodes in the dts rk_i2c can be probed first and will fail, this is the
case for the rk3328 SoC.
The PMIC drivers are also probed at this pass but on the iicbus which is created
in rk_i2c so there is no order conflict here.

Fixes:		ddefad7c4f ("arm64: rockchip: Tweak i2c, pmic and iodomain order")
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-08-09 10:50:04 +02:00
Emmanuel Vadot ddefad7c4f arm64: rockchip: Tweak i2c, pmic and iodomain order
We need i2c first to set it to MIDDLE, then we need one of the pmics
so set them to LATE, only then we can attach iodomain which needs some
regulators exposed by the pmic so set it to LAST.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-08-08 15:58:26 +02:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Ganbold Tsagaankhuu 37d97b10ff Fix style. 2023-04-07 03:18:42 +00:00
Ganbold Tsagaankhuu 4720afaffe Improve RK3568 pcie phy handling codes a bit.
Move phy bifurcation code to a separate function
that can be called during the attach phase.
Also initialize both pcie lanes accordingly.
2023-04-07 02:54:13 +00:00
Ganbold Tsagaankhuu 396b6914c9 Fix pcie phy enabling codes for RK3568 SoC.
Handle data-lanes property for pcie phy and set it accordingly.
This makes devices attached to pcie3 work properly.
For some RK3568 based boards, RTL8125B based device is
connected it. So with this, realtek-re-kmod driver attaches
and works.

Partially obtained from OpenBSD.
Tested on NanoPI-R5S, FireFly Station P2 boards.
2023-04-04 02:50:29 +00:00
Ganbold Tsagaankhuu b98fbf3781 Fix driver name.
Submitted by:	Tyuryukanov S.Y.
2023-04-03 14:20:28 +00:00
Andrew Turner cb894f746c Map arm64 pci config memory as non-posted
On arm64 PCI config memory is expected to be mapped with a non-posted
device type. To handle this use the new bus_map_resource support in
arm64 to map memory with the new VM_MEMATTR_DEVICE_NP attribute. This
memory has already been allocated and activated, it just needs to be
mapped.

Reviewed by:	kevans, mmel
Differential Revision:	https://reviews.freebsd.org/D30079
2023-03-05 20:17:21 +00:00
Søren Schmidt 11b5b9e8a5 Add delay to have things settle. 2023-01-07 07:42:44 +00:00
Ganbold Tsagaankhuu 9427c47de6 Remove unnecessary sys/cdefs.h includes. 2023-01-07 06:05:52 +00:00
Val Packett 0b4531511e copyright: chase my name and email change
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37945
2023-01-06 15:28:42 -05:00
Ganbold Tsagaankhuu 90737b632e Use BSD-2-Clause for the SPDX license id as -FreeBSD variant has been deprecated. 2023-01-06 08:15:44 +00:00
Ganbold Tsagaankhuu 7e2600ea7b Add SPDX-License-Identifier. 2023-01-06 04:14:49 +00:00
Ganbold Tsagaankhuu 0d4a240b0d Remove unnecessary $Id string from license.
While there add SPDX-License-Identifier.
2023-01-06 04:10:09 +00:00
Søren Schmidt 5723e5ac6d Add Naneng combo PHY support for RK3568 SoC.
It can be used as pcie-phy, usb3-phy, sata-phy or sgmii-phy.
2023-01-06 03:04:53 +00:00
Søren Schmidt 7daf96523b Add PCIe driver for RK3568 SoC.
PCIe3 ports work, however PCIe2x1 is not working yet in this case as it depends on Naneng Combo Phy driver.
2023-01-05 04:15:56 +00:00
Søren Schmidt 79c6e0b31f Improve and make it more general Rockchip USB2PHY driver.
Add support for Rockchip RK3568.
2022-12-28 03:48:48 +00:00
Søren Schmidt 355cb40c3a Set RK3568 specific pin mux for GMAC1. 2022-12-28 03:00:19 +00:00
Andrew Turner 7ebc4c9bf7 Use hwreset_array in the Rockchip tsadc driver
The order of asserting/deasserting the resets doesn't matter so use
the new hwreset_array to manage them all.

Reviewed by:	manu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37358
2022-12-21 11:25:27 +00:00
Søren Schmidt a48301a5e0 Add initial clocks support for Rockchip RK3568 SoC.
Partially from:	https://reviews.freebsd.org/D36027

This can be eventually improved or simplified or fixed if necessary.

Following devices work with proper drivers and with the necessary clocks:
Native networking via eqos driver
USB3 and USB2
PCIe support is working but a bit picky about what hardware it supports (but so is Linux)
SD & (e)MMC
With the EDK2 loader video also works

Supported hardwares are Quartz64, NanoPI R5S and Firefly Station P2, more to come as DTS files gets done.
2022-12-18 12:05:29 +00:00
Søren Schmidt 0e3c99cbed Fix/add compat strings for Rockchip RK356x GRF. 2022-12-18 11:22:11 +00:00