Commit Graph

368 Commits

Author SHA1 Message Date
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
Justin Hibbits
3d9df07abf Move imx_sdhci driver over to a dev/sdhci in preparation for QorIQ support.
Freescale uses eSDHC in both i.MX (ARM) and QorIQ (PowerPC), with slight
differences.  This is part one in unifying the drivers.

Reviewed by:	imp
2016-11-02 00:51:09 +00:00
Michal Meloun
c7264b2dfa ARM: Remove unused includes.
MFC after: 1 week
2016-10-09 10:25:47 +00:00
Michal Meloun
7cc70732a3 ARM: SEV/WFE instructions are implemented starting from ARMv6K,
use it directly.

MFC after: 1 week
2016-10-06 13:18:18 +00:00
Andrew Turner
1834282de6 Split CPU_CORTEXA into CPU_CORTEXA8, for the Cortex-A8, and CPU_CORTEXA_MP,
for later Cortex-A CPUs that support the Multiprocessor Extensions. This
will be needed to support both in a single GENERIC kernel while still
being able to only build for a single SoC.

Reviewed by:	mmel
Relnotes:	yes
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D8138
2016-10-04 12:25:44 +00:00
Andrew Turner
0a4c0732a9 Restrict where we need to define fdt_fixup_table to just PowerPC and
Marvell.

Sponsored by:	ABT Systems Ltd
2016-09-23 14:11:23 +00:00
Andrew Turner
0dbb8873c8 Move cpu_reset to be a platform method to allow multiple implementations.
Reviewed by:	mmel
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D8010
2016-09-23 13:08:15 +00:00
Andrew Turner
c35b5d8372 Remove bus_dma_get_range and bus_dma_get_range_nb on armv6. We only need
this on a few earlier arm SoCs.

Reviewed by:	manu (earlier version)
Sponsored by:	ABT Systems Ltd
2016-09-23 12:38:05 +00:00
Svatopluk Kraus
4d7f3703e2 Postpone allocation of IRQ resource to the time when interrupt
controller devices are attached. This has already been done for
bus_setup_intr().

There was no doubt that if someone wants to setup an interrupt,
corresponding interrupt controller device must already be attached.
However, the same must be valid for allocation of an interrupt resource
unless the allocation is done blindly, without any information that
such interrupt even exists. While it was done this blind way before,
it won't be possible after next INTRNG change.
2016-06-03 11:05:55 +00:00
Ian Lepore
e3f2d7af0e Add support for triggering interrupts on both rising and falling edges.
Also, EOI a gpio interrupt in the post_ithread routine before re-enabling.
2016-05-26 22:34:25 +00:00
Ian Lepore
183d468536 Another round of changes to add compatibility with the older ESHDC variety
of hardware.  Mostly this focuses on the big changes needed for setting the
bus clock, because ESDHC is SDHCI v2.0 and USDHC is 3.0, and the number,
location, and interpretation of clock divisor bits is vastly different
between the two.  This doesn't get the device all the way to functioning
on ESDHC hardware yet, but it's much closer, now getting through all the
card detection and negotiation of capabilties and speed (but it eventually
hangs on what appears to be a missing interrupt).

Another missing chunk of code for handling ESDHC's 32 bit command-and-mode
register using sdhci's pair of 16 bit writes is added.

This also does some leading whitespace cleanups and sorts some softc
struct members by size, and adds some comments (because when do I ever
touch code without adding comments?).
2016-05-26 03:55:27 +00:00
Svatopluk Kraus
f7b9669629 INTRNG - support new interrupt mapping type INTR_MAP_DATA_GPIO
introduced in r298738.

Reviewed by:	ian
2016-05-23 18:16:21 +00:00
Svatopluk Kraus
e2ff80bcb7 INTRNG - use gpio generic interrupt modes definitions added in r298738.
Reviewed by:	ian
2016-05-23 18:12:52 +00:00
Luiz Otavio O Souza
9d6672e13b Fix the deciKelvin to Celsius conversion in kernel.
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)
2016-05-22 13:58:32 +00:00
Svatopluk Kraus
143d397317 Fix some format strings to make them either correct or uniform.
No functional change.
2016-05-22 09:59:43 +00:00
Eitan Adler
cef367e6a1 Don't repeat the the word 'the'
(one manual change to fix grammar)

Confirmed With: db
Approved by: secteam (not really, but this is a comment typo fix)
2016-05-17 12:52:31 +00:00
Oleksandr Tymoshenko
bb307f247a Use OF_prop_free instead of direct call to free(9) 2016-05-13 22:05:16 +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
Pedro F. Giffuni
255eff3b0d sys/arm: Minor spelling fixes.
Only affects comments: no functional change.
2016-05-04 15:48:59 +00:00
Andrew Turner
cca48a59de Add a MULTIDELAY option to allow the ARM kernel to have multiple DELAY
implementations. Early in the boot the kernel will use an approximate,
however after the timer has been probed it will switch to a more accurate
implementation.

Reviewed by:	manu
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5762
2016-04-30 17:27:33 +00:00
Pedro F. Giffuni
f0e561112f sys/arm: make use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 14:47:52 +00:00
Ruslan Bukin
30b72b6871 Move arm's devmap to some generic place, so it can be used
by other architectures.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D6091
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
2016-04-26 11:53:37 +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
Pedro F. Giffuni
74b8d63dcc Cleanup unnecessary semicolons from the kernel.
Found with devel/coccinelle.
2016-04-10 23:07:00 +00:00
Ian Lepore
bcfa4e676b Remove unecessary locking, mostly from places where a read is done of a
value that can't ever be in an inconsistant intermediate state even when
some other thread is in the middle of writing the value/register.

Locking of the hardware remains in the few places that do r-m-w operations.
Locking of metadata access is restricted to places using memcpy or sprintf
to modify the metadata.
2016-04-07 19:51:27 +00:00
Ian Lepore
0dbb1fc87c Code cleanup: stop searching for a pin in the array and just use the pin
number directly as an index.  We create the array ourselves and nothing
can change the order of items in it, it's a simple 1:1 mapping.
2016-04-07 19:17:47 +00:00
Ian Lepore
8294827ab6 Comestic changes; when INTRNG support was added, some functions became
oddly separated from related functionality.  This just moves some blocks
of code around so that setup_intr and teardown_intr are near each other
again, and likewise for enable/disable_intr.  No functional changes.
2016-04-07 17:45:01 +00:00
Svatopluk Kraus
bff6be3e9b Remove FDT specific parts from INTRNG. Change its interface to make it
universal.

(1) New struct intr_map_data is defined as a container for arbitrary
description of an interrupt used by a device. Typically, an interrupt
number and configuration relevant to an interrupt controller is encoded
in such description. However, any additional information may be encoded
too like a set of cpus on which an interrupt should be enabled or vendor
specific data needed for setup of an interrupt in controller. The struct
intr_map_data itself is meant to be opaque for INTRNG.

(2) An intr_map_irq() function is created which takes an interrupt
controller identification and struct intr_map_data as arguments and
returns global interrupt number which identifies an interrupt.

(3) A set of functions to be used by bus drivers is created as well as
a corresponding set of methods for interrupt controller drivers. These
sets take both struct resource and struct intr_map_data as one of the
arguments. There is a goal to keep struct intr_map_data in struct
resource, however, this way a final solution is not limited to that.

(4) Other small changes are done to reflect new situation.

This is only first step aiming to create stable interface for interrupt
controller drivers. Thus, some temporary solution is taken. Interrupt
descriptions for devices are stored in INTRNG and two specific mapping
function are created to be temporary used by bus drivers. That's why
the struct intr_map_data is not opaque for INTRNG now. This temporary
solution will be replaced by final one in next step.

Differential Revision:	https://reviews.freebsd.org/D5730
2016-04-04 09:15:25 +00:00
Ian Lepore
dec4873723 Fix fallout from r292180 (Dec 2015)... ensure that every driver which has
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.)
2016-03-21 00:52:24 +00:00
Andrew Turner
7133fe0f33 Almost all copies of platform_mp_init_secondary just called
intr_pic_init_secondary. Replace them with a direct call. On BCM2836
and ARMADA XP we need to add this function, but it can be empty.

Reviewed by:	ian, imp
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5460
2016-02-26 16:04:47 +00:00
Andrew Turner
3210b87554 Remove platform_mp_probe as it's almost identical on most ARM SoCs, and
slightly wrong on the others. We should just check if mp_ncpus is set to
more than one CPU as we may wish to run on a single core even when SMP is
available.

Reviewed by:	ian
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5458
2016-02-26 15:54:34 +00:00
Andrew Turner
243b36c321 Remove platform_ipi_send, it's an unneeded as all implementations are
identical.

Sponsored by:	 ABT Systems Ltd
2016-02-25 20:48:23 +00:00
Ian Lepore
e28fbecafb Make imx6 systems work again after recent import of new dts files.
Linux-driven changes to the way the chip's two interrupt controllers are
defined (we only support one of them) led to no interrupt processing, so
the system would hang after device instantiation.  This workaround just
rewrites the FDT data on the fly to get interrupt handling back under the
control of the main GIC device.

If/when we ever support deep sleep modes that involve powering down the
main GIC, we'll have to undo this change, write a driver for the GPC-PIC,
and somehow manage the handoff of responsibilities between the two drivers
as the chip transitions in/out of deep sleep mode.
2016-02-23 01:08:39 +00:00
Svatopluk Kraus
7758916f44 Move ARM_L2_PIPT option to std.armv6 for all armv6 platforms.
Only L2 PIPT cache is supported for __ARM_ARCH >= 6.

In fact, this is just a pure proclamation as this option is used
only in armv4 specific files now.
2016-02-22 11:47:28 +00:00
Svatopluk Kraus
1413a3ab64 Remove pd_prot and pd_cache members from struct arm_devmap_entry.
The struct is used for definition of static device mappings which
should always have same protection and attributes.
2016-02-17 12:36:24 +00:00
Andrew Turner
647a3bac7e Stop defining fdt_pic_table when building for ARM_INTRNG. 2016-02-11 11:49:27 +00:00
Michal Meloun
a89156f53f ARM: Use new ARMv6 naming conventions for cache and TLB functions
in all but ARMv4 specific files.
Expand ARMv6 compatibility stubs in cpu-v4.h. Use physical address
in L2 cache functions if ARM_L2_PIPT is defined.
2016-02-05 14:57:41 +00:00
Michal Meloun
cdf4ec6873 EHCI: Make core reset and port speed reading more generic.
Use driver settable callbacks for handling of:
- core post reset
- reading actual port speed

Typically, OTG enabled EHCI cores wants setting of USBMODE register,
but this register is not defined in EHCI specification and different
cores can have it on different offset.

Also, for cores with TT extension, actual port speed must be determinable.
But again, EHCI specification not covers this so this patch provides
function for two most common variant of speed bits layout.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D5088
2016-01-28 14:11:59 +00:00
Justin Hibbits
02630b085c Quick exit after setting the clock control register.
Discussed with:	ian
2016-01-17 23:03:21 +00:00
Oleksandr Tymoshenko
dfbf5e4bbf Add i.MX 6 IPU driver and enable it in IMX6 config
Current functionality is somewhat limited: driver assumes that there
is only one active IPU unit (IPU1) and that video output is DI0 and
video mode is 1024x768. For more advanced functionality driver requires
proper clock management which is work in progress. At the moment driver
assumes that pixel clock is configured by u-boot for 1026x768 mode.

Reviewed by:	andrew, ian, mmel
Differential Revision:	https://reviews.freebsd.org/D4168
2015-12-21 22:25:35 +00:00
Oleksandr Tymoshenko
a0becfc978 - Add driver for i.MX 6 HDMI framer
- Enable HDMI driver in IMX6 config

Reviewed by:	andrew, ian, mmel
Differential Revision:	https://reviews.freebsd.org/D4174
2015-12-21 21:40:15 +00:00
Oleksandr Tymoshenko
c0f3a6c2bb Add CCM functions to enable HDMI framer and IPU units (video controller)
Reviewed by:	andrew, ian
Differential Revision:	https://reviews.freebsd.org/D4168
2015-12-21 20:17:24 +00:00
Adrian Chadd
2b3ad18853 [intrng] Migrate the intrng code from sys/arm/arm to sys/kern/subr_intr.c.
The ci20 port (by kan@) is going to reuse almost all of the intrng code
since the SoC in question looks suspiciously like someone took an ARM
SoC design and replaced the ARM core with a MIPS core.

* migrate out the code;
* rename ARM_ -> INTR_;
* rename arm_ -> intr_;
* move the interrupt flush routine from intr.c / intrng.c into
  arm/machdep_intr.c - removing the code duplication and removing
  the ARM specific bits from here.

Thanks to the Star Wars: The Force Awakens premiere line for allowing
me a couple hours of quiet time to finish the universe builds.

Tested:

* make universe

TODO:

* The structure definitions in subr_intr.c still includes machine/intr.h
  which requires one duplicates all of the intrng definitions in
  the platform code (which kan has done, and I think we don't have to.)

  Instead I should break out the generic things (function declarations,
  common intr structures, etc) into a separate header.

* Kan has requested I make the PIC based IPI stuff optional.
2015-12-18 05:43:59 +00:00
Ian Lepore
db9431acb3 Fix the clock divisor calc for imx6 sdcard bus speed.
I don't know what alternate universe I was inhabiting when I wrote it
originally, but apparently the basic workings of mathematics were different
than in this universe.  I also can't explain how it ever worked, except "by
accident", because completely bogus values were being written into the
divisor register.
2015-12-18 01:25:30 +00:00
Ian Lepore
3f62727443 Move the DRIVER_MODULE() statements that declare mmc(4) to be a child of
the various bridge drivers out of dev/mmc.c and into the bridge drivers.

Requested by:	   jhb (almost two years ago; better late than never)
2015-12-14 01:09:25 +00:00
Ian Lepore
bd6b2f9bef Rename sysctl node hw.imx6 to hw.imx. Move its definition to imx_machdep.c
so that code shared between imx5 and imx6 can work with OIDs under that node.

Add last_reset_status (integer) and last_reset_reason (string) OIDs that
provide info about the last chip reset (power-on, software reset, watchdog
timeout).
2015-11-26 17:26:52 +00:00
Ian Lepore
e0848bbb0c Update the imx5/imx6 cpu_reset() implementation based on a new understanding
of the SRS (software reset) bit in the watchdog control register.  Despite
what the manual seems to imply, this bit DOES trigger an immediate reset, as
opposed to simply flagging the type of reset as software-triggered.
2015-11-21 23:30:47 +00:00
Andrew Turner
ed18006cbf Create device options for the two common ARM timers.
Sponsored by:	ABT Systems Ltd
2015-11-21 16:23:56 +00:00
Andrew Turner
210d6af74d Move more bus_space_* files to be built by files.arm. This leaves the
definition in a file.* file under sys/arm/arm in the few cases we need it
for non-fdt platforms.

Sponsored by:	ABT Systems Ltd
2015-11-21 15:30:08 +00:00
Warner Losh
c192c5d300 Makeoption ARM_LITLE_ENDIAN does nothing. Remove it since it isn't
consistently used. It was a carry over from NetBSD that FreeBSD
doesn't use.
2015-11-20 21:49:46 +00:00
Andrew Turner
805471578e Remove bus_space_asm_generic.S from the per-SoC files.* files, it's already
in files.arm.

Sponsored by:	ABT Systems Ltd
2015-11-20 19:48:32 +00:00
Andrew Turner
09f449399b Remove pl310.c from the SoC std.* files, it's in files.arm
Sponsored by:	ABT Systems Ltd
2015-11-20 16:43:21 +00:00
Andrew Turner
aeef645f92 Stop setting {KERN,}PHYSADDR on armv6, it's unneeded.
Sponsored by:	ABT Systems Ltd
2015-11-20 16:12:22 +00:00
Oleksandr Tymoshenko
183413c80c Replace magic numbers for CCGRx registers with more descriptive names 2015-11-14 22:46:50 +00:00
Oleksandr Tymoshenko
83860f69f5 - Add driver for System-Reset-Controler i.MX6 module
- Add API function to reset IPU1
2015-11-13 23:47:41 +00:00
Oleksandr Tymoshenko
acaf20cbde Enable cloks for all USDHC interfaces, previous value was USDHC 1-3 + USBOH3 2015-11-12 21:37:58 +00:00
Ian Lepore
e6c435106f Enable ARM_INTRNG on IMX6 platforms, and make the imx_gpio driver an
interrupt controller.

The latter is required for INTRNG, because of the hardware erratum
workaround installed by the linux folks into the imx6 FDT data, which remaps
an ethernet interrupt to the gpio device.  In the non-INTRNG world we
intercept the call to map the interrupt and map it back to the ethernet
hardware (because we don't need linux's workaround), but in the INTRNG world
we lose the hookpoint where that remapping was happening, but we gain the
ability to work the way linux does by having the gpio driver dispatch the
interrupt.
2015-10-18 19:54:11 +00:00
Ian Lepore
7ce00ee7b4 Rename arm_init_secondary_ic() -> arm_pic_init_secondary(). The latter is
the name the function will have when the new ARM_INTRNG code is integrated,
and doing this rename first will make it easier to toggle the new interrupt
handling code on/off with a config option for debugging.
2015-10-18 16:54:34 +00:00
Ian Lepore
d1e99670ae Use IIC_EBUSBSY and IIC_BUSERR status values consistantly across all drivers.
Make it clearer what each one means in the comments that define them.

IIC_BUSBSY was used in many places to mean two different things, either
"someone else has reserved the bus so you have to wait until they're done"
or "the signal level on the bus was not in the state I expected before/after
issuing some command".

Now IIC_BUSERR is used consistantly to refer to protocol/signaling errors,
and IIC_BUSBSY refers to ownership/reservation of the bus.
2015-10-09 22:49:50 +00:00
Ian Lepore
d2c05e201f Mostly rewrite the imx i2c driver. This started out as an attempt to fix
one specific problem: the driver didn't check for ACK/NAK after writing a
slave address byte to the bus, and some slaves signal that they are busy
(such as when completing an internal write to flash memory) by sending a
NAK in response to being addressed.

While working on that problem I discovered that the driver's handling of
error conditions in general didn't match the state transition diagram in
the reference manual, and making that right resulted in a lot of code
reorganization.

Along the way various other changes also happened...

 - Remove a mutex that wasn't protecting anything.
 - Remove some mystery DELAY()s, document the few that remain.
 - Use pause_sbt(9) to yield the processor for the bulk of the time it
   takes to transfer each byte rather than busy-polling the whole time.
 - Disable the controller when no transfers are in progress; since we
   don't operate in slave mode, there's no reason to run the hardware.
 - Remove a bunch of unecessary code from probe().
2015-10-09 22:28:56 +00:00
Ian Lepore
6da71028ad Make the imx watchdog actually work, by setting WDOG_CR_WDE (enable bit).
Also, follow the rules from watchdog(9) about what values to return in
various situations (especially, don't touch *error when asked to set a
non-zero timeout that isn't achievable on the hardware).
2015-08-19 20:50:31 +00:00
Ian Lepore
398c183874 Add compatible strings for all the hardware this driver works with.
Also, move the READ/WRITE bus space access macros from the header into the
source file, and rename them to RD2/WR2 to make it clear they're 16-bit
accessors.  (READ/WRITE just don't seem like good names to be in a public
header file.)
2015-08-19 20:31:35 +00:00
Ruslan Bukin
35e3d3621b Include a header required for vtophys(). 2015-06-06 14:26:40 +00:00
Jung-uk Kim
fd90e2ed54 CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head.  However, it is continuously misused as the mpsafe argument
for callout_init(9).  Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision:	https://reviews.freebsd.org/D2613
Reviewed by:	jhb
MFC after:	2 weeks
2015-05-22 17:05:21 +00:00
Andrew Turner
ace157c3a9 Use the new gic option on all configs that need it. 2015-05-10 12:13:27 +00:00
Ian Lepore
955691fecd Add the code necessary to run the imx6 chip at its lowest clock/power
operating point (396MHz/950mV).
2015-05-05 23:27:49 +00:00
Andrew Turner
092b8f61cd Add the SOC_IMX51, SOC_IMX53, and SOC_IMX6 options. These are used to
select which SoCs the kernel config will support.

Use these options to merge files.imx51 and files.imx53.
2015-04-23 22:20:43 +00:00
Andrew Turner
bb135ad6af Reduce the diff between files.imx51 and files.imx53 2015-04-23 21:39:32 +00:00
Andrew Turner
405ada37fb Add support for the uart classes to set their default register shift value.
This is needed with the pl011 driver. Before this change it would default
to a shift of 0, however the hardware places the registers at 4-byte
addresses meaning the value should be 2.

This patch fixes this for the pl011 when configured using the fdt. The
other drivers have a default value of 0 to keep this a no-op.

MFC after:	1 week
2015-04-11 17:16:23 +00:00
Andrew Turner
087af50ab8 Include vm/pmap.h for pmap_kextract. 2015-04-04 23:03:11 +00:00
Andrew Turner
ff3b52bb19 Stop using machine/fdt.h in the arm kernel code when we don't need it. 2015-04-04 21:34:26 +00:00
Andrew Turner
0ebebb1260 Build the cpufunc_asm_* files based on the cpu type, not which config file
we happen to be building.
2015-03-29 22:43:39 +00:00
Andrew Turner
d9d02715d3 Remove cpufunc_asm_arm11.S from the ARMv7 configs, it's not used. 2015-03-29 21:45:28 +00:00
Andrew Turner
745202c280 We don't use cpufunc_asm_armv5.S in any of these configs, remove it. 2015-03-29 18:41:43 +00:00
Andrew Turner
698234c19b Stop building unused cpuvunc_* files, we don't need anything from these. 2015-03-29 17:33:03 +00:00
Ian Lepore
3bb693af87 Move the uart_class definitions and fdt compat data into the individual
uart implementations, and export them using the new linker-set mechanism.

Differential Revision:	https://reviews.freebsd.org/D1993
Submitted by:	Michal Meloun
2015-03-07 15:24:15 +00:00
Luiz Otavio O Souza
7836352b50 Implement GPIO_GET_BUS() method for all GPIO drivers.
Add helper routines to deal with attach and detach of gpiobus and gpioc
devices that are common to all drivers.
2015-01-31 19:32:14 +00:00
Luiz Otavio O Souza
876c1bd8b0 Clean up and fix the device detach routine and the failure path on GPIO
drivers.

This paves the way for upcoming work.
2015-01-31 12:17:07 +00:00
Ruslan Bukin
f0583578a1 Add support for audio transmitting, include drivers for:
o Digital Audio Multiplexer (AUDMUX)
o Smart Direct Memory Access Controller (SDMA)
o Synchronous Serial Interface (SSI)

Disable by default as it depends on SDMA firmware.

Sponsored by:	Machdep, Inc.
2015-01-24 13:07:07 +00:00
Ian Lepore
9e8ab8f731 Add pinctrl driver support for the encoded input register config words
that the linux guys made up on the fly (but didn't document) last August.
This type of encoded config now appears in the imx6 fdt data.
2015-01-23 16:05:47 +00:00
Ian Lepore
5087ad0212 Enable all the mmc/sd controllers, because there's no telling which ones
any given board will be using.

Yes, changing source is an unusually primitive power control implementation.
2015-01-23 01:18:08 +00:00
Ian Lepore
eb8711ce16 Rename bus_space-v6.c to bus_space_base.c, because it's not v6-specific
and now some v5 Marvell systems are using it.  Only define fdt_bus_tag
if option FDT is defined.
2015-01-21 03:44:29 +00:00
Andrew Turner
3f53a2d612 Rename gic_init_secondary to arm_init_secondary_ic to help with the merge
of the arm_intrng project branch.
2015-01-11 16:46:43 +00:00
Hans Petter Selasky
b217d18412 Add 64-bit DMA support in the XHCI controller driver.
- Fix some comments and whitespace while at it.

MFC after:	1 month
Submitted by:	marius@
2015-01-05 20:22:18 +00:00
Ian Lepore
67009184e3 Remove -Wa,-march=armv7a from arm kernel configs, it makes clang 3.5 sad
and apparently isn't needed now that we're using the integrated assembler.
2015-01-01 23:21:46 +00:00
Andrew Turner
ef7eac4353 Switch i.MX to use the platform code to help with a single Freescale kernel.
Differential Revision:	https://reviews.freebsd.org/D1349
Reviewed by:	ian, rpaulo
2014-12-24 12:26:43 +00:00
Ian Lepore
88b80af731 Add -march=armv7a to the kernel compile for all ARM systems which are v7a.
Submitted by:	Michal Meloun <meloun@miracle.cz>
2014-12-21 23:48:32 +00:00
Luiz Otavio O Souza
667357dc9b Moves all the duplicate code to a single function.
Verify for invalid modes and unwanted flags before pass the new flags to
driver.
2014-11-18 17:22:08 +00:00
Warner Losh
40e6bdaf1e opt_global.h is included automatically in the build. No need to
explicitly include it in these places.

Sponsored by: Netflix
2014-11-18 17:06:56 +00:00
Ian Lepore
844aff82a6 Allow i2c bus speed to be configured via hints, FDT data, and sysctl.
The current support for controlling i2c bus speed is an inconsistant mess.
There are 4 symbolic speed values defined, UNKNOWN, SLOW, FAST, FASTEST.
It seems to be universally assumed that SLOW means the standard 100KHz
rate from the original spec.  Nothing ever calls iicbus_reset() with a
speed of FAST, although some drivers would treat it as the 400KHz standard
speed.  Mostly iicbus_reset() is called with the speed set to UNKNOWN or
FASTEST, and there's really no telling what any individual driver will do
with those.

The speed of an i2c bus is limited by the speed of the slowest device on
the bus.  This means that generally the bus speed needs to be configured
based on the board/system and the components within it.  Historically for
i2c we've configured with device hints.  Newer systems use FDT data and it
documents a clock-frequency property for i2c busses.  Hobbyists and
developers are likely to want on the fly changes.  These changes provide
all 3 methods, but do not require any existing drivers to change to use
the new facilities.

This adds an iicbus method, iicbus_get_frequency(dev, speed) that gets the
frequency for the requested symbolic speed.  If the symbolic speed is SLOW
or if there is no speed configured for the bus, the returned value is
100KHz, always.  Otherwise, if bus speed is configured by hints, fdt,
tunable, or sysctl, that speed is returned.  It also adds a helper
function, iicbus_init_frequency() that any bus driver subclassed from
iicbus can initialize the frequency from some other source of info.

Initial driver implementations are provided for Freescale and TI.

Differential Revision:        https://reviews.freebsd.org/D1174
PR:		195009
2014-11-18 01:54:31 +00:00
Ian Lepore
6eef1a334d Fix the reversed sense of the PADCONF_NONE test. 2014-11-12 02:44:27 +00:00
Ian Lepore
3a8af166a2 Bugfixes for the imx5/imx6 iomux fdt_pinctrl driver.
I originally overlooked a couple flag bits defined in the fdt binding docs.
One flag suppresses the pad configuration (pullup/pulldown/etc).  The other
one requires that the SION (set input on) flag be set in the mux register.

Also, it appears from the data involved that if the input register
address in the config tuple is zero, there is no input configuration.  The
old code was writing to register zero, which contains a collection of misc
control bits (having nothing to do with input configuration) that probably
shouldn't get overwritten arbitrarily.  The bindings doc doesn't explictly
mention this.
2014-11-12 02:37:27 +00:00
Luiz Otavio O Souza
8839e0e9f3 Make the GPIO children attach to the first unit available and not only to
unit 0.

It seems that this 'simplification' was copied to all GPIO drivers in tree.

This fix a bug where a GPIO controller could fail to attach its children
(gpioc and gpiobus) if another GPIO driver attach first.
2014-10-28 18:33:59 +00:00
Ian Lepore
2c746c6a09 Install a temporary workaround to avoid problems in fdt data with linux's
workaround for an imx6 chip erratum.  Linux works around the bug with
changes in fdt data that we can't currently handle, so to enable running
with standard vendor-supplied fdt data, this watches for an attempt to map
the gpio1_6 interrupt and remaps it back to the standard ethernet interrupt.

This can be undone when the intrng project is completed and our gpio drivers
can also be interrupt controllers.
2014-10-23 22:21:22 +00:00
Ian Lepore
2586993bf1 Unconditionally enable the clocks for all imx6 devices that we have drivers
for, or that are required to run the chip (such as busses).  Turn off all
the devices we don't yet have drivers for.

Some day we will have a fully functional imx6 clock driver so that we can
manage clocks based on fdt data.  This will have to do until then.
2014-10-23 03:13:14 +00:00
Ian Lepore
52d99877ba Attach the imx6 CCM driver during BUS_PASS_CPU. It controls the clocks
for most on-chip devices and needs to be available before other drivers
start attaching and asking to have their clocks enabled.
2014-10-20 23:34:47 +00:00
Ian Lepore
c90fadc0d2 The imx6 hardware is fast enough to make good use of however much
timecounter resolution is available, so ask for a 1 GHz frequency.  It
won't actually get one that fast, but that'll get the fastest available
clock and use a divisor of 1 (probably 132 or 66mhz on current hardware).
2014-10-20 23:32:34 +00:00
Ian Lepore
a2d27ff80e Attach this driver during BUS_PASS_BUS and move the cpu init code to a
bus_new_pass() handler so it doesn't happen until BUS_PASS_CPU.  This allows
the anatop driver to outbid the generic simplebus driver (which the FDT
data describes as compatible).

Some day when we handle power regulators, this driver may actually
become a functional simplebus and attach the regulators as children, as
described in the FDT data.
2014-10-19 18:41:22 +00:00
Ian Lepore
952ded804e Use gic_decode_fdt() rather than a local routine to parse fdt interrupt
properties.  Move fdt_pic_table and fdt_fixup_table into imx6_machdep.c,
which means imx6 doesn't need imx_common.c anymore.
2014-09-14 23:48:18 +00:00
Ian Lepore
20250ee1ab Add a comment giving an overview of the driver. Remove leftover debugging. 2014-09-14 16:12:43 +00:00
Ian Lepore
7ddf24b350 Replace the imx5 and imx6 iomux drivers with a single common driver that
uses the new fdt_pinctrl interface.
2014-09-13 20:09:34 +00:00