Commit Graph

2005 Commits

Author SHA1 Message Date
Stanislav Galabov
8173c81630 mtk_spi cleanup commented printfs
Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6223
2016-05-06 05:24:10 +00:00
Stanislav Galabov
025f79a5cd mtk_gpio fixes
Allow output pins to be read and input pins to be set.
Fix bugs where we were trying to access the gpio softc before doing
device_get_softc.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6222
2016-05-06 05:22:25 +00:00
Ruslan Bukin
d7dc6bae03 Implement FBT provider (MD part) for DTrace on MIPS.
Tested on MIPS64.

Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-05-05 13:54:50 +00:00
Svatopluk Kraus
cd642c88a1 INTRNG - redefine struct intr_map_data to avoid headers pollution. Each
struct associated with some type defined in enum intr_map_data_type
must have struct intr_map_data on the top of its own definition now.
When such structs are used, correct type and size must be filled in.

There are three such structs defined in sys/intr.h now. Their
definitions should be moved to corresponding headers by follow-up
commits.

While this change was propagated to all INTRNG like PICs,
pic_map_intr() method implementations were corrected on some places.
For this specific method, it's ensured by a caller that the 'data'
argument passed to this method is never NULL. Also, the return error
values were standardized there.
2016-05-05 13:31:19 +00:00
Robert Watson
a75a7d90e9 When attempting to satisfy mmap() requests for superpage alignment on
64-bit MIPS, use superpage rather than physical-segment constants, or
we may improperly fail to apply suitable alignment -- yet still allow
mmap() to appear to succeed.

Reviewed by:	sson
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2016-04-30 19:29:03 +00:00
Pedro F. Giffuni
4ed3c0e713 sys: Make use of our rounddown() macro when sys/param.h is available.
No functional change.
2016-04-30 14:41:18 +00:00
John Baldwin
e240255ffc Add a bus_null_rescan() method that always fails with an error.
Use this in place of kobj_error_method to disable BUS_RESCAN() on
PCI drivers that do not use the "standard" scanning algorithm.
2016-04-27 17:49:42 +00:00
John Baldwin
3d0338a092 Implement a PCI bus rescan method.
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
2016-04-27 16:31:12 +00:00
Adrian Chadd
959f9e0f5d [mips] correctly represent memory region allocations >> 2^^31
Without this, it'd get promoted incorrectly and fail allocation.

Submitted by:	Mori Hiroki <yamori813@yahoo.co.jp>
Reviewed by:	imp
2016-04-26 16:40:04 +00:00
Stanislav Galabov
83089b1b11 Remove uart_dev_mtk_ns8250
The purpose of this file was to simply detect the UART speed before
attaching the actual ns8250 driver so that we don't have to specify the
UART speed in DTS files.

However, OpenWRT DTS files specify ns16550a as a compatible string in
their DTS files and this makes the original ns8250 driver attach to
the device. So we would have to edit the DTS files anyway and since this
is only the case for MT7621 and MT7628/MT7688 for now, it's better to
just add the clock-frequency property to those (UART is always clocked
by the same clock in both these SoCs, so that's fine) instead of having
a separate driver and still having to change the DTS files.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6044
2016-04-23 04:27:01 +00:00
Stanislav Galabov
92484f4d4a Use cpu_establish_hardintr in mtk_intr_gic
This allows us to come closer to OpenWRT vanilla DTS files.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6045
2016-04-23 04:22:38 +00:00
Stanislav Galabov
1d37e1c409 Introduce palmbus for Mediatek/Ralink SoCs
This allows us to get closer to OpenWRT DTS files and minimize the diffs
a little more.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6042
2016-04-23 04:21:18 +00:00
Stanislav Galabov
523ac7c716 Minor pinctrl fixes for Mediatek/Ralink
Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6041
2016-04-23 04:19:42 +00:00
Pedro F. Giffuni
d9c9c81c08 sys: use our roundup2/rounddown2() macros when param.h is available.
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.
2016-04-21 19:57:40 +00:00
Pedro F. Giffuni
323b076e9c sys: use our nitems() macro when param.h is available.
This should cover all the remaining cases in the kernel.

Discussed in:	freebsd-current
2016-04-21 19:40:10 +00:00
Pedro F. Giffuni
8dfea46460 Remove slightly used const values that can be replaced with nitems().
Suggested by:	jhb
2016-04-21 15:38:28 +00:00
Stanislav Galabov
f506fee29c Rework Mediatek/Ralink configuration files
Only compile what each SoC needs and get rid of MEDIATEK generic config.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5996
2016-04-21 07:40:03 +00:00
Pedro F. Giffuni
33495e5daf Use our nitems() macro when param.h is available.
Replacements specific to arm, mips, pc98, powerpc and sparc64.

Discussed in:	freebsd-current
2016-04-20 15:45:55 +00:00
Stanislav Galabov
d478c9fe53 Add compat strings used by OpenWRT to some Mediatek/Ralink drivers
Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5995
2016-04-20 14:47:16 +00:00
Stanislav Galabov
680354a7a4 Rework mtk_gpio_v1 driver
This revision makes the mtk_gpio_v1 driver read its register map property
from the OpenWRT dts files.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D6029
2016-04-20 14:36:45 +00:00
Stanislav Galabov
f2880faaf0 Introduce OpenWRT compatible pinctrl driver for Mediatek/Ralink SoCs
The driver can read and parse the OpenWRT pinctrl dts entries.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5999
2016-04-20 14:35:00 +00:00
Stanislav Galabov
3378bfdb23 Allow RT3350 CPU clock to be detected as part of RT3050/RT3052 detection
OpenWRT's dts files treat RT3050/RT3052/RT3350 within the same SoC dtsi
file, so we need to distinguish between the three dynamically, mainly
because the bit we use to determine the clock speed on RT3050/RT3052
can actually be floating on RT3350 and RT3350 is always at 320MHz.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5983
2016-04-18 06:15:58 +00:00
Stanislav Galabov
70a157d7f5 Add support for boot arguments specification via fdt
Add suppport for passing boot arguments via FDT for mediatek/ralink SoCs.
This was taken from kan's work on CI20.

Since most OpenWRT dts files have bootargs defined, we use bsdbootargs
to specify FreeBSD specific arguments.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5979
2016-04-16 19:44:41 +00:00
Stanislav Galabov
302b3e7dc4 Change MIPS_INTRNG to INTRNG in MEDIATEK_BASE config
Revision 298068 changed MIPS_INTRNG and ARM_INTRNG to simply INTRNG.
MEDIATEK_BASE config was missed by this revision, so we change
MIPS_INTRNG to INTRNG here.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5978
2016-04-16 19:42:54 +00:00
Andrew Turner
59c3cb81c1 Rename ARM_INTRNG and MIPS_INTRNG to INTRNG. This will help with machine
independent code that needs to know about INTRNG such as PCI drivers.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-04-15 16:05:41 +00:00
Stanislav Galabov
915c6043b0 Make NIRQ configurable for MIPS
Submitted by:	kan
Reviewed by:	kan
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5964
2016-04-15 15:44:02 +00:00
Stanislav Galabov
c1300b5e37 Mediatek/Ralink: Get our drivers closer to OpenWRT dts definitions
This revision gets our Mediatek/Ralink drivers closer to OpenWRT's dts
definitions, so we can reuse them with less modifications later in order
to bring support for a lot of boards at once.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5961
2016-04-15 15:24:42 +00:00
Stanislav Galabov
913b41b84e Remove unneeded initialization in mtk_xhci.c
This is actually initialized properly within xhci.c, so it's better to
not initialize it in mtk_xhci.c

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5935
2016-04-15 15:22:28 +00:00
Stanislav Galabov
3e4b91800a In order to build a kernel with one of these configs the user should do
the following:

1. Give the appropriate board dts file to be used by either:
1.1. edit the SoC kernel config required (e.g., MT7620A_FDT) and include
the required FDT_DTS_FILE makeoption; or
1.2. simply supply FDT_DTS_FILE="xx.dts" on the command line when building
the kernel
Of course, the user can also create a completely new kernel config to
match the desired board and include the SoC kernel config from within
it.

If required, edit the MEDIATEK config file, which includes optional
drivers and comment out the unneeded ones.
2.1. this would only make sense if kernel size is a concern. Even if we
build the kernel with all drivers, if we lzma it and package it as a uImage,
its size is still around 1.1MiB.

The user will have to choose a dts file (or create a new one) from
sys/gnu/dts/mips , where all Mediatek/Ralink dts files will be imported via
a later revision.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5966
2016-04-15 15:20:41 +00:00
Pedro F. Giffuni
7b6cea2b01 mips: for pointers replace 0 with NULL.
These are mostly cosmetical, no functional change.

Found with devel/coccinelle.

Reviewed by:	adrian
2016-04-15 14:26:24 +00:00
John Baldwin
6cd99ae86d Add a new PCI bus interface method to alloc the ivars (dinfo) for a device.
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
2016-04-15 03:42:12 +00:00
Stanislav Galabov
6573205a07 Move Mediatek/Ralink PCIe to NEW_PCIB
This revision fixes minor issues and moves the Mediatek/Ralink PCIe
support to use NEW_PCIB.

https://svnweb.freebsd.org/changeset/base/297849 is the other part of
this changeset.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5908
2016-04-12 07:21:22 +00:00
Stanislav Galabov
a82ccc6f1e Define PCI_RES_BUS for MIPS.
This is done as part of the work on D5908, but as a separate commit.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
2016-04-12 07:18:48 +00:00
Pedro F. Giffuni
74b8d63dcc Cleanup unnecessary semicolons from the kernel.
Found with devel/coccinelle.
2016-04-10 23:07:00 +00:00
Stanislav Galabov
368449816e Fix MIPS INTRNG omissions, add soft/hard interrupts with different names
Reviewed by:	kan
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5888
2016-04-08 15:48:10 +00:00
Stanislav Galabov
33311df141 Introduce better locking for mtk_gpio_v[12] drivers
Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5887
2016-04-08 15:28:12 +00:00
Stanislav Galabov
1b3142aaae Introduce Mediatek/Ralink PCIe support
This revision introduces PCIe support for the relevant Mediatek/Ralink
SoCs.
Currently the PCIe support is not converted to INTRNG, this may be a
task for the future.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5886
2016-04-08 15:26:49 +00:00
Stanislav Galabov
b37b38e9ab Introduce XHCI support for MT7621 SoC
Tested on a MT7621 board, similar to the WiTi board.
More testing will be required to confirm everything is fine, but things
look good so far.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5885
2016-04-08 15:22:30 +00:00
Stanislav Galabov
1e7745b401 Disable USB PHY slew rate calibration for Mediatek SoCs for now
USB on both MT7621 and MT7688 seems to work much better without doing
slew rate calibration.
These are the only two SoCs, apart from MT7628, which actually make
use of the slew rate calibration routines implemented in the mtk_usb_phy
driver. Since MT7628 is actually a superset of MT7688 things should be
the same for it as well.

We do not remove the code, we simply define it out.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5884
2016-04-08 15:20:58 +00:00
Stanislav Galabov
1ccd15cac7 Fix wrong memory mapping
In mtk_soc.c memory is mapped incorrectly for MT7621. This revision fixes
this.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5882
2016-04-08 15:13:38 +00:00
Ian Lepore
be0f9b70cd Fix a copyright glitch before it gets copy-pasted again. I think this must
have started as collateral damage in a global search-replace, then it got
copied around when I cloned a file to begin creating a new file.
2016-04-07 18:19:09 +00:00
Stanislav Galabov
ab68acd8c0 Initial import of Ralink/Mediatek MIPS SoC support #7
GPIO controller drivers import.

As with other Ralink/Mediatek work, there are 2 versions of the GPIO
controller driver, depending on the type of SoC.
This revision introduces initial support for these.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5877
2016-04-07 15:11:24 +00:00
Stanislav Galabov
7af87ea720 Initial import of Ralink/Mediatek MIPS SoC support #6
SPI drivers for the various Ralink/Mediatek SoCs. There are 2 versions of
the SPI controller (so far) present in the supported SoCs, hence v1 and v2
drivers.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5842
2016-04-07 11:21:42 +00:00
Stanislav Galabov
d09031f528 Initial import of Ralink/Mediatek MIPS SoC support #5
USB support

This revision adds USB (EHCI/OHCI/OTG, depending on SoC type) support for
various Ralink/Mediatek SoCs.
Currently USB is not supported on MT7621, this will be a future addition.

A USB PHY driver is also included, so that we can properly initialize the
USB PHY (e.g., clocks, resets, registers where needed), before attempting
to initialize EHCI/OHCI/OTG functionality.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5841
2016-04-07 11:20:03 +00:00
Stanislav Galabov
dc0996af4e Initial import of Ralink/Mediatek MIPS SoC support #4
UART drivers.

- uart_dev_mtk.[ch] are the old-style Mediatek/Ralink-specific UART driver
  as also found in sys/mips/rt305x/uart_dev_rt305x.c, with minor improvements
  and FDT attachment enabled for the appropriate SoCs.
- uart_dev_mtk_ns8250.c is the new-style ns16550a-compatible UART driver
  found in newer Mediatek SoCs. It uses the uart_dev_ns8250.c driver
  indirectly and is basically just a wrapper around it and only overrides its
  probe method.
  The reason I am not using the uart_dev_ns8250.c driver directly is because
  I have some code that does UART clock detection before initializing the
  UART, so that we don't need to hard-code the UART clock frequency in the
  dts files for each board.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5840
2016-04-07 11:16:32 +00:00
Stanislav Galabov
e56e179d55 Initial import of Ralink/Mediatek MIPS SoC support #3
Interrupt controllers found in various Mediatek/Ralink SoCs.

mtk_intr_v1 and mtk_intr_v2 are basically the same at the moment, with
just different register mappings.

However, v1 interrupt controller has a subset of the functionality of the
v2 interrupt controller, so in the future the v2 interrupt controller driver
may be enhanced, if needed, with things like level/edge interrupts and soft
interrupts. So, for the moment I suggest we keep them as 2 separate files.

mtk_intr_gic provides very basic (similar to v1 and v2) support for MIPS GIC
controllers, which currently maps all interrupts to a single core and sets
them to type level, active high. In the future this may be developed into a
generic GIC controller to support any new MIPS SoCs that include it. The GIC
is a standard MTI interrupt controller in their multi-core line-up (e.g.,
1004K, 1074K, etc.), rather than a SoC-specific controller.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5839
2016-04-07 11:12:37 +00:00
Stanislav Galabov
b74b6b0a82 Initial import of Ralink/Mediatek MIPS SoC support #2
This revision adds the following to the Mediatek/Ralink support:

- initial support for "clocks" FDT property, currently based on fdt_clock
- initial support for "resets" FDT property, currently based on the
  fdt_reset interface from D5826
- initial support for "pinctrl,bits" functionality via FDT. May be extended
  in the future to cover a better and fuller pinctrl implementation

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5827
2016-04-07 11:08:50 +00:00
Stanislav Galabov
10998af48d This revision adds the following parts:
- machine dependent low level init code
- SoC clocks detection and some utility functions
- Common interface to read/write/modify SoC system control registers, used
  by some of the other drivers and utility functions
- simple FDT resets support, based on the fdt_clock implementation already
  in the tree. For the moment resets and clocks are managed using these
  implementations. I am planning to port those to the new extres framework
  in the future, but currently I simply don't have time to do this part too.

Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5826
2016-04-07 11:02:49 +00:00
Stanislav Galabov
55275a5bbe Bring MIPS INTRNG support back up again, in line with D5370
Reviewed by:	kan
Approved by:	adrian (mentor)
Sponsored by:	Smartcom - Bulgaria AD
Differential Revision:	https://reviews.freebsd.org/D5838
2016-04-07 10:48:26 +00:00
Justin Hibbits
f8fd3fb518 Fix the resource_list_print_type() calls to use uintmax_t.
Missed a bunch from r297000.
2016-03-22 22:25:08 +00:00