Commit Graph

368 Commits

Author SHA1 Message Date
Ed Maste
8573e2c388 use -m ${LD_EMULATION} for binary->elf link invocation
r306041 changed ld invocations for converting binary files to kernel
ELF objects to pass -m, but missed bespoke ld invocations in a pair of
arm file configs (one of which has since been removed).

This is needed to support some external toolchains and lld.

Sponsored by:	The FreeBSD Foundation
2018-11-09 19:16:01 +00:00
Alan Cox
49bfa624ac Eliminate the arena parameter to kmem_free(). Implicitly this corrects an
error in the function hypercall_memfree(), where the wrong arena was being
passed to kmem_free().

Introduce a per-page flag, VPO_KMEM_EXEC, to mark physical pages that are
mapped in kmem with execute permissions.  Use this flag to determine which
arena the kmem virtual addresses are returned to.

Eliminate UMA_SLAB_KRWX.  The introduction of VPO_KMEM_EXEC makes it
redundant.

Update the nearby comment for UMA_SLAB_KERNEL.

Reviewed by:	kib, markj
Discussed with:	jeff
Approved by:	re (marius)
Differential Revision:	https://reviews.freebsd.org/D16845
2018-08-25 19:38:08 +00:00
Alan Cox
44d0efb215 Eliminate kmem_alloc_contig()'s unused arena parameter.
Reviewed by:	hselasky, kib, markj
Discussed with:	jeff
Differential Revision:	https://reviews.freebsd.org/D16799
2018-08-20 15:57:27 +00:00
Andrew Turner
e4c66ddabd Remove IPI_IRQ_START and IPI_IRQ_END from the arm kernel config files.
These are unneeded with INTRNG.
2018-07-28 06:46:10 +00:00
Ian Lepore
4c2b439617 Add pnp info to the imx_spi driver. 2018-07-09 19:00:39 +00:00
Ian Lepore
638a5afda9 Move device statements out of std.imx* and into kernel config files.
In the armv4/5 world device statements in these files were common, but in
the v6/7 world, other socs don't put device statements into those files, so
this just brings imx5 and imx6 into line with the current conventions.
2018-07-08 21:09:52 +00:00
Ian Lepore
9b4738cf7b Make the imx6_snvs driver usable as a module, add pnp info. Add a manpage. 2018-07-08 19:35:41 +00:00
Ian Lepore
952dd10db4 Catch up with improvements in RTC handling... It's no longer necessary to
ignore the timestamp passed in to settime() due to inaccuracy, the core
routines now pass in a nanosecond-accurate time freshly-obtained before
calling each driver's settime() method.  Also, add calls to the new
debugging output helpers.
2018-07-08 18:44:42 +00:00
Ian Lepore
cf2cec68bd Add pnp info to imx6_ahci, and add a module makefile, and a manpage for it. 2018-07-08 00:27:28 +00:00
Ian Lepore
31ff8defe3 Add support to the imx watchdog for the FDT "timeout-sec" property, by
automatically initializing the watchdog using the given value.  Also,
attach at BUS_PASS_TIMER to extend watchdog protection to more of the
kernel init process.
2018-07-07 19:10:00 +00:00
Ian Lepore
a4db01f7c6 Correctly calculate the value to put in the imx wdog countdown register.
The correct value is seconds*2-1.  The code was using just seconds*2, which
led to being off by a half-second -- usually not a big deal, except when the
value was the max (128) it overflowed so zero would get written to the
countdown register, which equates to a timeout of a half second.
2018-07-07 19:03:38 +00:00
Ian Lepore
2b352b736d Add pnp info and a module makefile for the imx_wdog watchdog driver. 2018-07-07 17:25:09 +00:00
Ian Lepore
80c8ba2869 Add a missing call to usb_bus_mem_free_all() when detaching. 2018-07-05 15:52:26 +00:00
Ian Lepore
0b8530659c Remove a test and early-out which just can't possibly be right. It causes
detach() to do nothing if attach() succeeded, which is the opposite of
what's needed.  Also, move device_delete_children() from the end to the
beginning of detach(), so that children won't be trying to make use of the
hardware we're in the process of shutting down.

PR:		229510
2018-07-05 15:34:16 +00:00
Ian Lepore
333559f2f1 Fix an out-of-bounds array access... the irq data for teardown is in two
arrays, as elements 0 and 1 of one array and elements 1 and 2 of the other.
Run the loop 0..1 instead of 1..2 and use named constants to offset into
one of the arrays.

PR:		229508
2018-07-05 14:09:48 +00:00
Ian Lepore
d8cf9c4f8b Properly support the GPIO_PIN_PRESET_{LOW,HIGH} options when configuring
a gpio pin.  If neither of the options is specified, pre-set the pin's
output value to the pin's current input value, to achieve glitch-free
transitions to output mode on pins that are pulled up or down at reset
or via fdt pinctrl data.
2018-05-04 19:28:05 +00:00
Ian Lepore
e780d0fc82 Make reading imx6 gpio pins work correctly whether the pin is in open-drain
mode or not.  An earlier attempt to make this work was done in r320456, by
always reading the pad status register (PSR) instead of the data register.
But it turns out the values in PSR only reflect the electrical level of an
output pin if the pad is configured with the SION (Set Input On) bit in the
pinmux config, and most output gpio pads are not configured that way.

So now a gpio read is done by returning the value from the data register,
which works right whether the pin is configured for input or output, unless
the pin has been set for OPENDRAIN mode, in which case the PSR is read
instead.  For this to work, the pin must also be configured with SION turned
on in the fdt pinmux data, which is a reasonable thing to require for the
unusual case of reading an open-drain output pin.
2018-05-04 16:23:54 +00:00
Emmanuel Vadot
7f7d3ba77c arm: Fix duplicate ehci DRIVER_MODULE
Name each ehci driver uniquely.
This remove the warning printed at each arm boot :
module_register: cannot register simplebus/ehci from kernel; already loaded from kernel
2018-04-27 21:05:58 +00:00
Emmanuel Vadot
fe7cc38a38 arm: Fix duplicate ahci DRIVER_MODULE
Name each ahci driver uniquely.
This remove the warning printed at each arm boot :
module_register: cannot register simplebus/ahci from kernel; already loaded from kernel
2018-04-27 21:05:18 +00:00
Oleksandr Tymoshenko
f7604b1b27 Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc
Change OF_getencprop_alloc semantics to be combination of malloc and
OF_getencprop and return size of the property, not number of elements
allocated.

For the use cases where number of elements is preferred introduce
OF_getencprop_alloc_multi helper function that copies semantics
of OF_getencprop_alloc prior to this change.

This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
function signatures consistent with OF_getencprop_alloc and
OF_getencprop_alloc_multi.

Functionality-wise this patch is mostly rename of OF_getencprop_alloc
to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
where 1 was used as a block size.
2018-04-09 22:06:16 +00:00
Oleksandr Tymoshenko
217d17bcd3 Clean up OF_getprop_alloc API
OF_getprop_alloc takes element size argument and returns number of
elements in the property. There are valid use cases for such behavior
but mostly API consumers pass 1 as element size to get string
properties. What API users would expect from OF_getprop_alloc is to be
a combination of malloc + OF_getprop with the same semantic of return
value. This patch modifies API signature to match these expectations.

For the valid use cases with element size != 1 and to reduce
modification scope new OF_getprop_alloc_multi function has been
introduced that behaves the same way OF_getprop_alloc behaved prior to
this patch.

Reviewed by:	ian, manu
Differential Revision:	https://reviews.freebsd.org/D14850
2018-04-08 22:59:34 +00:00
Andrew Turner
7bc28467ef Switch users of fdt_is_enabled to use ofw_bus_node_status_okay. These are
equivalent, so to prepare to remove the former move users to call the
latter.

Sponsored by:	DARPA, AFRL
2018-04-03 11:01:50 +00:00
Oleksandr Tymoshenko
108117cc22 [ofw] fix errneous checks for OF_finddevice(9) return value
OF_finddevices returns ((phandle_t)-1) in case of failure. Some code
in existing drivers checked return value to be equal to 0 or
less/equal to 0 which is also wrong because phandle_t is unsigned
type. Most of these checks were for negative cases that were never
triggered so trhere was no impact on functionality.

Reviewed by:	nwhitehorn
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14645
2018-03-20 00:03:49 +00:00
Ian Lepore
286f5b4a29 Switch imx_gpio to attach at BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE.
Pretty much any other device might need to manipulate a gpio pin during its
probe or attach routines, so these devices must be available as early as
possible.

The gpio device is an interrupt controller, but I didn't choose the
INTERRUPT pass for that reason (it works fine as an interrupt controller as
long as it attaches any time before interrupts are enabled).  That just
looked like the right place in the passes to ensure that it attaches before
any type of device that might need gpio pin manipulations.
2018-03-05 02:32:23 +00:00
Ian Lepore
b1dbbe4da2 Defer attaching the spibus until timers and interrupts are working. The
driver requires interrupts to do transfers, and the drivers for the SPI
devices on the bus quite reasonably expect to be able to do IO while probing
and attaching.
2018-03-05 02:13:28 +00:00
Ian Lepore
a3389cb736 Do not stop the loop that configures gpio chipselect pins on the first
error, just ignore pins that don't configure and keep setting up the ones
that do.  (But when bootverbose is on, whine about the errors.)
2018-03-05 02:08:33 +00:00
Kyle Evans
458915bfae Move imx6_usbphy to SUPPORTDEV, massage associated comment
No objections from:	ian
2018-03-03 18:52:19 +00:00
Ian Lepore
a0fd233964 Add a SPI driver for imx5 and imx6.
It can be compiled into the kernel with "device imx_spi" or loaded as a
module, which is also named "imx_spi".
2018-02-26 02:28:32 +00:00
Ian Lepore
7efedde853 Adjust whitespace of things added in the past couple years to match the
original style of the file.  No functional changes.
2018-02-20 14:59:29 +00:00
Ian Lepore
5e2d748931 Add the MODULE_DEPEND()s needed so that the kernel linker can resolve all
the symbols at load time when iicbus is not compiled into the kernel.
2018-02-18 23:01:33 +00:00
Ian Lepore
af85a3d172 Give the imx_i2c driver its own name, set up its relationship to ofw_iicbus.
Previously it called itself 'iichb' to link up with the EARLY_DRIVER_MODULE
declaration in ofw_iicbus.c.
2018-02-18 20:08:35 +00:00
Ian Lepore
b107b904a6 Add a detach method so that this can be a kldunload-friendly module. 2018-02-18 02:01:41 +00:00
Ian Lepore
07fca7ace2 Fix fallout from the import of fresh dts source files from linux 4.15. It
appears that node names no longer include leading zeroes in the @address
qualifiers, so we have to search for the nodes involved in interrupt fixup
using both flavors of name to be compatible with old and new .dtb files.

(You know you're in a bad place when you're applying a workaround to code
that exists only as a workaround for another problem.)
2018-02-18 00:02:09 +00:00
Ian Lepore
4dbbaf2021 Add support to the imx5/6 watchdog for the external reset signal. Also, if
the "power down" watchdog used by the ROM boot code is still active when the
regular watchdog is activated, turn off the power-down watchdog.

This adds support for the "fsl,ext-reset-output" FDT property.  When
present, that property indicates that a chip reset is accomplished by
asserting the WDOG1_B external signal, which is supposed to trigger some
external component such as a PMIC to ready the hardware for reset (for
example, adjusting voltages from idle to full-power levels), and assert the
POR signal to SoC when ready.  To guard against misconfiguation leading to a
non-rebootable system, the external reset signal is backstopped by code
that asserts a normal internal chip reset if nothing responds to the
external reset signal within one second.
2018-01-26 17:55:17 +00:00
Ian Lepore
5b810fe4a6 Fix return style in RD2. Remove bogus return value from a void function
in WR2 (I have no idea why that didn't result in a compile error).
2018-01-25 18:08:56 +00:00
Ian Lepore
76ecefce9d Minor cleanups... Move DRIVER_MODULE() and other boilerplate stuff to the
bottom of the file, where it is in most imx5/6 drivers.  Switch from an RD2
macro using bus_space_read_2() to an inline function using bus_read_2();
likewise for WR2.  Use RESOURCE_SPEC_END to end the resource_spec list.

Net effect should be no functional changes.
2018-01-25 17:53:33 +00:00
Ian Lepore
1f23f8b0fe Make the trivial imx_soc_family() function an inline in imx_machdep.h.
The imx_machdep.c file is on the fast path to non-existance and this would
be the only thing left in it after some watchdog changes are completed.
2018-01-24 18:10:11 +00:00
Ian Lepore
2128fefb75 Reformat indentation to match other imx5/6 register definition headers, and
tweak some comments.  No functional changes.
2018-01-24 17:52:06 +00:00
Ian Lepore
2d09b07279 Make kernel option KERNVIRTADDR optional, remove it from std.<platform>
files that can use the default value.

It used to be required that the low-order bits of KERNVIRTADDR matched
the low-order bits of the physical load address for all arm platforms.
That hasn't been a requirement for armv6 platforms since FreeBSD 10.
There is no longer any relationship between load addr and KERNVIRTADDR
except that both must be aligned to a 2 MiB boundary.

This change makes the default KERNVIRTADDR value 0xc0000000, and removes the
options from all the platforms that can use the default value.  The default
is now defined in vmparam.h, and that file is now included in a few new
places that reference KERNVIRTADDR, since it may not come in via the
forced-include of opt_global.h on the compile command line.
2017-12-30 00:20:49 +00:00
Emmanuel Vadot
ee070097f2 Revert r327250 as it broke the build for some armv6 kernel and all armv4/5
Reported by:	ian
2017-12-28 07:31:14 +00:00
Emmanuel Vadot
9c4bfa00d4 arm: hdmi_if.m is already in files.arm
Do not require it in files.vendor
2017-12-27 21:58:19 +00:00
Emmanuel Vadot
d06955f9bd arm: Add kern/kern_clocksource.c to files.arm
Instead of adding it to every files.vendor, add it to the common arch file.
2017-12-27 21:39:57 +00:00
Pedro F. Giffuni
af3dc4a7ca sys/arm: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 15:04:10 +00:00
Pedro F. Giffuni
51369649b0 sys: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:43:44 +00:00
Ian Lepore
7e7ef41632 Fix imx6 hdmi init after r323553, which used a config_intrhook to defer the
attachment of i2c devices needed by hdmi.

The hdmi init also uses an intrhook callback to defer initialization, and if
the hdmi callback runs first, the i2c devices will not yet have registered
their device_t in association with their FDT phandle, which allows cross-
device references on FDT systems.

Now the hdmi deferred init checks for the i2c device registration, and if
it's not complete yet, it registers as an eventhandler watching for newbus
attach events.  When the i2c device eventually attaches, the hdmi driver
unregisters from watching further events, and continues with the hdmi init.
Because the function signatures for an intrhook callback and an event
handler callback are the same, a single function is used for both callbacks.

Reported by:	Russell Haley <russ.haley@gmail.com>
2017-10-08 18:38:22 +00:00
Warner Losh
094fc1ed0f Tag all armv7 kernels as such in their machine config line.
Transition all boards that support arm cortex CPUs to armv7. This
leaves two armv6 kernels in the tree. RPI-B, which uses the BCM2835
which has a ARM1176 core, and VERSATILEPB, which is a qemu board setup
around the time RPI-B went in. Copy std.armv6 to std.armv7, even
though that duplicates a lot of stuff. More work needs to be done to
sort out the duplication.

Differential Revision: https://reviews.freebsd.org/D12027
2017-10-05 23:01:50 +00:00
Ian Lepore
74eb18b6cc Define a single instance of ahci_devclass and reference it from all the
attachment code for various SOCs and busses.  Remove all the static and
should-have-been-static and named-differently instances of it.

This should eliminate the recently-grown build warnings about multiple
definitions when building arm kernels.
2017-10-02 02:58:28 +00:00
Andrew Turner
6b81683f9e Add i.MX6 and Xilinx to GENERIC.
Merge in the missing devices from the IMX6 and ZEDBOARD kernel configs. The
Freescale sdma device has been renamed to fslsdma to mark it as a platform
specific driver.

Reviewed by:	ian
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D11564
2017-09-24 09:33:08 +00:00
Ian Lepore
1e4042d44e Defer attaching and probing iicbus and its children until interrupts are
available, in i2c controller drivers that require interrupts for transfers.

This is the result of auditing all 22 existing drivers that attach iicbus.
These drivers were the only ones remaining that require interrupts and were
not using config_intrhook to defer attachment.  That has led, over the
years, to various i2c slave device drivers needing to use config_intrhook
themselves rather than performing bus transactions in their probe() and
attach() methods, just in case they were attached too early.
2017-09-13 16:54:27 +00:00
Ian Lepore
e1275c6805 Add gpio methods to read/write/configure up to 32 pins simultaneously.
Sometimes it is necessary to combine several gpio pins into an ad-hoc bus
and manipulate the pins as a group. In such cases manipulating the pins
individualy is not an option, because the value on the "bus" assumes
potentially-invalid intermediate values as each pin is changed in turn. Note
that the "bus" may be something as simple as a bi-color LED where changing
colors requires changing both gpio pins at once, or something as complex as
a bitbanged multiplexed address/data bus connected to a microcontroller.

In addition to the absolute requirement of simultaneously changing the
output values of driven pins, a desirable feature of these new methods is to
provide a higher-performance mechanism for reading and writing multiple
pins, especially from userland where pin-at-a-time access incurs a noticible
syscall time penalty.

These new interfaces are NOT intended to abstract away all the ugly details
of how gpio is implemented on any given platform. In fact, to use these
properly you absolutely must know something about how the gpio hardware is
organized. Typically there are "banks" of gpio pins controlled by registers
which group several pins together. A bank may be as small as 2 pins or as
big as "all the pins on the device, hundreds of them." In the latter case, a
driver might support this interface by allowing access to any 32 adjacent
pins within the overall collection. Or, more likely, any 32 adjacent pins
starting at any multiple of 32. Whatever the hardware restrictions may be,
you would need to understand them to use this interface.

In additional to defining the interfaces, two example implementations are
included here, for imx5/6, and allwinner. These represent the two primary
types of gpio hardware drivers. imx6 has multiple gpio devices, each
implementing a single bank of 32 pins. Allwinner implements a single large
gpio number space from 1-n pins, and the driver internally translates that
linear number space to a bank+pin scheme based on how the pins are grouped
into control registers. The allwinner implementation imposes the restriction
that the first_pin argument to the new functions must always be pin 0 of a
bank.

Differential Revision:	https://reviews.freebsd.org/D11810
2017-09-10 18:08:25 +00:00
Ian Lepore
854519fdd9 Add an ahci driver for imx6.
This was submitted by Rogiel Sulzbach (thank you!) but has a few last-minute
changes by me, mostly where the code interfaces to my still-utterly-deficient
imx6_ccm clocks implementation.  So blame me for any mistakes.

Submitted by:	Rogiel Sulzbach <rogiel@rogiel.com>
Differential Revision:	https://reviews.freebsd.org/D11177
2017-08-03 14:43:41 +00:00
Ian Lepore
28926d45c9 Fix the interface to imx_iomux_gpr_get/set(). The functions were defined
as taking a register number, and that would get multiplied by 4 to make
a register address.  But the header file that consumers have to reference
this stuff publishes register addresses, not numbers.  So now everything
works in terms of register addresses.

Note that the HDMI init code was writing into the wrong register before
this change.  Apparently whatever it wrote to was harmless, and apparently
HDMI was working because uboot had set up the right bits.
2017-08-02 18:28:06 +00:00
Ian Lepore
7ad88b3ce0 The imx6_snvs driver is not strictly required for the system to run, so
change it from standard to optional and add a device statement for it so
that it's included unless someone uses nodevice to eliminate it.
2017-08-02 15:15:18 +00:00
Ian Lepore
900fb59e05 Add a debug sysctl that lets you see i2c bus traffic through this device. 2017-07-26 21:20:57 +00:00
Ian Lepore
7164f27ddc Support the "disable-over-current" property for imx ehci controllers.
It turns out that this is more than a power optization.  The OTG port
won't work on boards that have this property unless this setting is honored.

Also ensure that the usb phy device attaches before ehci.
2017-07-13 02:16:15 +00:00
Andrew Turner
75f48c23ea Add external PLATFORM access on arm, and use it in the pl310 driver.
This allows multiple instances of SoCs that use the pl310 driver to be
built within the same kernel:

 * Add access to the platform_t object from outside platform.c
 * Use this with the pl310 driver

There is a new platform_pl310 interface to replace the existing code. SoCs
need to implement the init method, and if they have special requirements to
write to the two registers we care about will also need to implement the
write_ctrl and write_debug methods.

Differential Revision:	https://reviews.freebsd.org/D11546
2017-07-11 16:30:16 +00:00
Andrew Turner
3185adf0fd Start to move the arm *_mp.h to be names *_machdep.h. These will be used
by the reworked pl310 driver interface in
https://reviews.freebsd.org/D11546
2017-07-10 15:27:53 +00:00
Ian Lepore
3a28d1b6e3 Add a driver for the imx6 on-chip realtime clock.
This driver is standard rather than optional because it can always provide
time after a reboot, but it will only provide time after a power cycle if
battery power is supplied to the chip's SNVS power domain.
2017-07-04 18:38:34 +00:00
Andrew Turner
89ea89de85 Move the simple armv6 only timer drivers to require MULTIDELAY to help
move all armv6 configs it.
2017-07-04 18:07:09 +00:00
Andrew Turner
57521c21b1 Add a delay count to the last few places. This will help make MULTIDELAY
a requirement on armv6 with PLATFORM.
2017-07-04 17:15:23 +00:00
Ian Lepore
8928c2e4f5 Add bus recovery handling to the imx5/imx6 i2c driver. 2017-06-29 01:59:39 +00:00
Ian Lepore
c592231080 Implement gpio input by reading the pad state register, not the data register.
When a pin is set for input the value in the DR will be the same as the PSR.

When a pin is set for output the value in the DR is the value output to the
pad, and the value in the PSR is the actual electrical level sensed on the
pad, and they can be different if the pad is configured for open-drain mode
and some other entity on the board is driving the line low.
2017-06-28 20:28:47 +00:00
Ian Lepore
fc0dd0d307 Add a driver for the imx6 EPIT timer that can be used as the system
timecounter instead of the GPT timer, freeing up the more flexible GPT
hardware for other uses.  The EPIT driver is a standard (always in the
kernel) driver, and the existing GPT driver is now optional and included
only if you ask for device imx_gpt.
2017-06-18 18:22:52 +00:00
Andrew Turner
a29b35dd5e Start to rename files with common or generic names to be SoC specific. The
build system doesn't handle two files with the same name.
2017-06-04 09:11:14 +00:00
Andrew Turner
d9f504454a Port the Vybrid code to PLATFORM to help move it into GENERIC. 2017-06-03 20:14:46 +00:00
Andrew Turner
b32611238e Enable MULTIDELAY in the i.MX5 kernel configs. This will help adding them
to GENERIC.
2017-06-03 15:39:23 +00:00
Ian Lepore
b8255b91e7 Convert probing to use an ofw_compat_data array, and add imx6ul to the list. 2017-04-16 17:53:44 +00:00
Ian Lepore
e0427caa47 Add support for the imx6ul SoC. 2017-04-15 17:02:32 +00:00
Andrew Turner
4bd9887cd5 Port the IMX6 kernel configuration to use MULTIDELAY. This will help adding
the i.MX series of SoCs to the armv6 GENERIC kernel.

This uses updated times from ian@.

Reviewed by:	ian
Sponsored by:	ABT Systems Ltd
2017-04-10 12:35:58 +00:00
Ian Lepore
0c076be2c2 Add support for imx6ul soc. 2017-04-10 02:46:39 +00:00
Ian Lepore
c1411a76e5 Add code/constants for detecting imx6ul (ultralite) chips, a species of
imx6 based on a single cortex-a7 core.  Other changes to imx6 drivers
and support code are needed to fully support the imx6ul.

Also fix an indentation glitch committed in the prior change.
2017-04-09 20:59:12 +00:00
Ian Lepore
08efd2cde9 Update the code that compensates for the lack of a GPC interrupt controller
driver for imx6.  Some newer dts source puts the GIC node at the root
instead of under /soc, so look in both places.  Also, sometimes the GIC
node doesn't list itself as its own interrupt-parent, allow that too.
2017-04-09 20:41:00 +00:00
Ian Lepore
2216512fcb Remove some old interrupt handling workaround code from the pre-INTRNG days.
At this point, INTRNG is not going away (the option may go away, but the
code is not), so we no longer need code to support workarounds that handled
the lack of INTRNG functionality.
2017-04-09 18:31:33 +00:00
Andrew Turner
b4fca5d4a7 Use tc_priv to find the softc in the i.MX timer driver.
Sponsored by:	ABT Systems Ltd
2017-03-20 19:25:42 +00:00
Ian Lepore
928e4f221d Replace the hard-coded way-too-small minimum event timer period with a value
calculated at runtime based on how long it takes to set up an event in
hardware.  This fixes the intermittant 1-minute hang at boot on imx5
systems, and also the occasional oversleeping while running.  It doesn't
affect imx6 systems, which use different hardware for eventtimers.

It turns out that it usually takes about 30 timer ticks to set up the timer
compare register, and the old hard-coded minimum period was 10 ticks.  On
the rare occasions when a timeout event that short was set up, we'd miss
the event and have to wait about 64 seconds for counter rollover before
the compare interrupt would fire.

Instead of just hardcoding a new bigger value, the code now measures the
time it takes to do the register read/write sequence to set up the compare
register, scales it up by 1.5x to be safe, and calculates the minimum event
period from the result.  In the real world, the minimum period works out to
about 750 nanoseconds on imx5 hardware.
2017-03-19 21:53:12 +00:00
Ian Lepore
5e52290fda Eliminate unnecessary read/modify/write sequences during eventtimer setup.
It turns out to be surprisingly expensive to access the gpt hardware (on the
order of 150ns per read/write).  To cut down on the overhead of setting up
each eventtimer event, eliminate read-modify-write sequences to manage the
compare interrupt enable, by keeping a shadow copy of the hardware register
and only writing to the hardware when the enable bits really change.
2017-03-19 21:28:37 +00:00
Ian Lepore
cde8ef4d96 Convert the imx5 interrupt controller driver to INTRNG. 2017-03-19 18:30:38 +00:00
Ian Lepore
3d9df27601 Remove unreferenced global function imx_gpt_get_timerfreq() and do some
cleanups enabled by that:

 - The only thing left in imx_gptvar.h was the softc, which IMO never
   should have been in there at all.  Move it into the driver, and
   delete the header file.

 - Remove several unneeded #includes from the driver.

 - Change imx_gpt_softc from global to static (it's used by DELAY()), and
   don't redundantly static-initialize it to NULL.
2017-03-19 04:03:39 +00:00
Ian Lepore
6c23d3cf76 Remove hardcoded bootverbose=1; imx53 systems boot using loader(8) and
users can set verbose if they want to.
2017-03-18 19:54:58 +00:00
Ian Lepore
26c048c814 Make the imx5 clocks driver work with vendor-supplied dts (which does not
supply the addresses for the DPLL register blocks) by hard-coding the
addresses in the driver source code.  Yes, this is just as bad an idea as
it sounds, but we have no choice.

In the early days of using fdt data, when we were making up our own data
for each board, we defined 4 sets of memory mapped registers in the data.
The vendor-supplied data only provides the address of the CCM register
block, but not the 3 DPLL blocks.  The linux driver has the DPLL physical
addresses (which differ by SOC type) hard-coded in the driver, and we
have no choice but to do the same thing if we want to run with the vendor-
supplied fdt data.

So now we use bus_space_map() to make the DPLL blocks accessible, choosing
the set of fixed addresses to map based on the soc id.
2017-03-18 17:50:49 +00:00
Andrew Turner
0960989f8f Move the IMX6 kernels to use PLATFORM_SMP. This is the last SMP config to
be migrated to this and will allow the removal of this option.

Reviewed by:	ian
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D9907
2017-03-17 12:34:56 +00:00
Ian Lepore
5002d69f9b Change the naming of imx{5,6} gpio pins to exactly match the names used in
the chip reference manuals: GPIOn_IOnn.
2017-02-18 18:24:03 +00:00
Ian Lepore
8148f4f3d5 Enable usb low and full speed devices connected to the imx6 root hubs.
This enables the PHY circuitry for UTMI+ level 2 and 3, and sets the
flag to tell the ehci code that the root hub has a transaction translator
in it.  For imx6 we can use the standard ehci_get_port_speed_portsc()
function to find out what speed device is connected to the port.
2017-02-12 00:52:22 +00:00
Michal Meloun
93a065e749 Remake support for SMP kernel on UP cpu:
- Use new option SMP_ON_UP instead of (mis)using specific CPU type.
   By this, any SMP kernel can be compiled with SMP_ON_UP support.
 - Enable runtime detection of CPU multiprocessor extensions only
   if SMP_ON_UP option is used. In other cases (pure SMP or UP),
   statically compile only required variant.
 - Don't leak multiprocessor instructions to UP kernel.
 - Correctly handle data cache write back to point of unification.
   DCCMVAU is supported on all armv7 cpus.
 - For SMP_ON_UP kernels, detect proper TTB flags on runtime.

Differential Revision: https://reviews.freebsd.org/D9133
2017-02-02 06:14:44 +00:00
Ian Lepore
83988d944b Handle imx6 erratum ERR004346... to reboot, clear the SRS bit twice within
the same cycle of the 32khz clock.

I've never actually noticed this error happening, but it's an easy fix.
2017-01-24 02:09:30 +00:00
Conrad Meyer
db4fcadf52 "Buses" is the preferred plural of "bus"
Replace archaic "busses" with modern form "buses."

Intentionally excluded:
* Old/random drivers I didn't recognize
  * Old hardware in general
* Use of "busses" in code as identifiers

No functional change.

http://grammarist.com/spelling/buses-busses/

PR:		216099
Reported by:	bltsrc at mail.ru
Sponsored by:	Dell EMC Isilon
2017-01-15 17:54:01 +00:00
Jared McNeill
6443acaa6c Add support for audio on I2S based DesignWare HDMI controllers.
Relnotes:	yes
2016-12-29 14:08:24 +00:00
Oleksandr Tymoshenko
8ad55e0482 [iMX6] Fix SDMA driver build
- Place const modifiers where required
- Make sure sdma device is attahched before consumers like SSI

Reviewed by:	br
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D8874
2016-12-21 01:38:44 +00:00
Oleksandr Tymoshenko
bbcd5f00d0 [iMX6] Fix build for SSI driver and add dependency for SDMA driver
- Pass correct pointer to OF_getencprop
- Check the size of "dmas" property
- Add dependency on sdma driver

Reviewed by:	br
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D8873
2016-12-21 01:32:19 +00:00
Jared McNeill
06785ff66a Split the DesignWare HDMI-specific code from imx6_hdmi.c into a separate
file and add a generic DT binding that takes advantage of the extres
framework for setting up clocks.

Reviewed by:		gonzo
Differential Revision:	https://reviews.freebsd.org/D8826
2016-12-20 01:34:29 +00:00
Emmanuel Vadot
7073d12c4d ofw_spi: Parse property for the SPI mode and CS polarity.
As cs is stored in a uint32_t, use the last bit to store the
active high flag as it's unlikely that we will have that much CS.

Reviewed by:	loos
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8614
2016-12-18 14:54:20 +00:00
Andrew Turner
6c925b9c81 All armv6 platforms have the same implementation of platform_lastaddr.
Replace them with a default handler that returns devmap_lastaddr.

Reviewed by:	mmel
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D8806
2016-12-16 10:31:13 +00:00
Andrew Turner
ba9f40ca3b Use the platform_*_t typedefs to help check the platform function types are
correct.

Sponsored by:	ABT Systems Ltd
2016-12-13 13:46:09 +00:00
Andrew Turner
59249a516a Add the missing void to function signatures in much of the arm code.
Sponsored by:	ABT Systems Ltd
2016-12-13 13:43:22 +00:00
Oleksandr Tymoshenko
c85d45a5bb [iMX6] Add compatibility string for GPT timer on i.MX6 Dual
Up until r295436 GPT timer in i.MX6 Dual dts used the same compatiblity
string as i.MX6 Quad. After the sync up with Linux in r295436, GPT timer
stopped getting attached on the i.MX6 Dual

MFC after:	3 days
2016-12-13 05:09:49 +00:00
Oleksandr Tymoshenko
ec0a42e59c [iMX6] Fix platform compatibility string for i.MX6 Dual
i.MX6 Dual boot was broken since r308533 because ofw_bus_node_is_compatible
is more strict than fdt_is_compatible and does not accept partial matches
2016-12-13 03:26:12 +00:00
Andrew Turner
9783ea5c9f Use the correct OF_getencprop over OF_getprop + fdt32_to_cpu to read
integer data from the device tree.

Sponsored by:	ABT Systems Ltd
2016-11-14 12:03:08 +00:00
Andrew Turner
222102cfca Move including fdt_pinctrl.h after openfirm.h to get th edefinition of
phandle_t and remove the need for including fdt_common.h.

Sponsored by:	ABT Systems Ltd
2016-11-14 11:52:22 +00:00
Andrew Turner
df7675353e Stop including fdt_common.h from the arm code when it's unneeded.
Sponsored by:	ABT Systems Ltd
2016-11-14 11:41:22 +00:00
Andrew Turner
639e990770 Remove more unneeded users of the fdt_pic_decode_t table.
Sponsored by:	ABT Systems Ltd
2016-11-11 14:22:35 +00:00