History log of /linux-master/drivers/bus/ti-sysc.c
Revision Date Author Comments
# 097948af 19-Feb-2024 Ricardo B. Marliere <ricardo@marliere.net>

bus: ti-sysc: constify the struct device_type usage

Since commit aed65af1cc2f ("drivers: make device_type const"), the driver
core can properly handle constant struct device_type. Move the
sysc_device_type variable to be a constant structure as well, placing it
into read-only memory which can not be modified at runtime.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Message-ID: <20240219-device_cleanup-ti-sysc-v1-1-13b53177d0a5@marliere.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 999f052e 09-Nov-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

bus: ti-sysc: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Reviewed-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20231109202830.4124591-12-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>


# f71f6ff8 24-Nov-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Flush posted write only after srst_udelay

Commit 34539b442b3b ("bus: ti-sysc: Flush posted write on enable before
reset") caused a regression reproducable on omap4 duovero where the ISS
target module can produce interconnect errors on boot. Turns out the
registers are not accessible until after a delay for devices needing
a ti,sysc-delay-us value.

Let's fix this by flushing the posted write only after the reset delay.
We do flushing also for ti,sysc-delay-us using devices as that should
trigger an interconnect error if the delay is not properly configured.

Let's also add some comments while at it.

Fixes: 34539b442b3b ("bus: ti-sysc: Flush posted write on enable before reset")
Cc: stable@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e5deb8f7 06-Sep-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix SYSC_QUIRK_SWSUP_SIDLE_ACT handling for uart wake-up

The uarts should be tagged with SYSC_QUIRK_SWSUP_SIDLE instead of
SYSC_QUIRK_SWSUP_SIDLE_ACT. The difference is that SYSC_QUIRK_SWSUP_SIDLE
is used to force idle target modules rather than block idle during usage.

The SYSC_QUIRK_SWSUP_SIDLE_ACT should disable autoidle and wake-up when
a target module is active, and configure autoidle and wake-up when a
target module is inactive. We are missing configuring the target module
on sysc_disable_module(), and missing toggling of the wake-up bit.

Let's fix the issue to allow uart wake-up to work.

Fixes: fb685f1c190e ("bus: ti-sysc: Handle swsup idle mode quirks")
Tested-by: Dhruva Gole <d-gole@ti.com>
Tested-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 11729caa 06-Sep-2023 Adam Ford <aford173@gmail.com>

bus: ti-sysc: Fix missing AM35xx SoC matching

Commit feaa8baee82a ("bus: ti-sysc: Implement SoC revision handling")
created a list of SoC types searching for strings based on names
and wildcards which associates the SoC to different families.

The OMAP34xx and OMAP35xx are treated as SOC_3430 while
OMAP36xx and OMAP37xx are treated as SOC_3630, but the AM35xx
isn't listed.

The AM35xx is mostly an OMAP3430, and a later commit a12315d6d270
("bus: ti-sysc: Make omap3 gpt12 quirk handling SoC specific") looks
for the SOC type and behaves in a certain way if it's SOC_3430.

This caused a regression on the AM3517 causing it to return two
errors:

ti-sysc: probe of 48318000.target-module failed with error -16
ti-sysc: probe of 49032000.target-module failed with error -16

Fix this by treating the creating SOC_AM35 and inserting it between
the SOC_3430 and SOC_3630. If it is treaed the same way as the
SOC_3430 when checking the status of sysc_check_active_timer,
the error conditions will disappear.

Fixes: a12315d6d270 ("bus: ti-sysc: Make omap3 gpt12 quirk handling SoC specific")
Fixes: feaa8baee82a ("bus: ti-sysc: Implement SoC revision handling")
Signed-off-by: Adam Ford <aford173@gmail.com>
Message-ID: <20230906233442.270835-1-aford173@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# d929b2b7 21-Aug-2023 Julien Panis <jpanis@baylibre.com>

bus: ti-sysc: Use fsleep() instead of usleep_range() in sysc_reset()

The am335x-evm started producing boot errors because of subtle timing
changes:

Unhandled fault: external abort on non-linefetch (0x1008) at 0xf03c1010
...
sysc_reset from sysc_probe+0xf60/0x1514
sysc_probe from platform_probe+0x5c/0xbc
...

The fix consists in using the appropriate sleep function in sysc reset.
For flexible sleeping, fsleep is recommended. Here, sysc delay parameter
can take any value in [0 - 255] us range. As a result, fsleep() should
be used, calling udelay() for a sysc delay lower than 10 us.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
Fixes: e709ed70d122 ("bus: ti-sysc: Fix missing reset delay handling")
Message-ID: <20230821-fix-ti-sysc-reset-v1-1-5a0a5d8fae55@baylibre.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# de44bf2f 14-Aug-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix cast to enum warning

Fix warning for "cast to smaller integer type 'enum sysc_soc' from 'const
void *'".

Cc: Nishanth Menon <nm@ti.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308150723.ziuGCdM3-lkp@intel.com/
Fixes: e1e1e9bb9d94 ("bus: ti-sysc: Fix build warning for 64-bit build")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 40a4f49c 08-Aug-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix a build warning with W=1 for sysconfig

Dhruva reported a build warning with W=1 for "Function parameter or member
'sysconfig' not described in 'sysc'". Let's document sysconfig to fix this.

Reported-by: Dhruva Gole <d-gole@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 03a711d3 04-Aug-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Configure uart quirks for k3 SoC

Enable the uart quirks similar to the earlier SoCs. Let's assume we are
likely going to need a k3 specific quirk mask separate from the earlier
SoCs, so let's not start changing the revision register mask at this point.

Note that SYSC_QUIRK_LEGACY_IDLE will be needed until we can remove the
need for pm_runtime_irq_safe() from 8250_omap driver.

Reviewed-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e1e1e9bb 04-Aug-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix build warning for 64-bit build

Fix "warning: cast from pointer to integer of different size" on 64-bit
builds.

Note that this is a cosmetic fix at this point as the driver is not yet
used for 64-bit systems.

Fixes: feaa8baee82a ("bus: ti-sysc: Implement SoC revision handling")
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Reviewed-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 34539b44 14-Jun-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Flush posted write on enable before reset

The am335x devices started producing boot errors for resetting musb module
in because of subtle timing changes:

Unhandled fault: external abort on non-linefetch (0x1008)
...
sysc_poll_reset_sysconfig from sysc_reset+0x109/0x12
sysc_reset from sysc_probe+0xa99/0xeb0
...

The fix is to flush posted write after enable before reset during
probe. Note that some devices also need to specify the delay after enable
with ti,sysc-delay-us, but this is not needed for musb on am335x based on
my tests.

Reported-by: kernelci.org bot <bot@kernelci.org>
Closes: https://storage.kernelci.org/next/master/next-20230614/arm/multi_v7_defconfig+CONFIG_THUMB2_KERNEL=y/gcc-10/lab-cip/baseline-beaglebone-black.html
Fixes: 596e7955692b ("bus: ti-sysc: Add support for software reset")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# f620596f 17-May-2023 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix dispc quirk masking bool variables

Fix warning drivers/bus/ti-sysc.c:1806 sysc_quirk_dispc()
warn: masking a bool.

While at it let's add a comment for what were doing to make
the code a bit easier to follow.

Fixes: 7324a7a0d5e2 ("bus: ti-sysc: Implement display subsystem reset quirk")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-omap/a8ec8a68-9c2c-4076-bf47-09fccce7659f@kili.mountain/
Signed-off-by: Tony Lindgren <tony@atomide.com>


# b79ad230 11-Aug-2022 Jason Wang <wangborong@cdjrlc.com>

bus: ti-sysc: Fix comment typo

The double `the' is duplicated in the comment, remove one.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
Message-Id: <20220811121119.20288-1-wangborong@cdjrlc.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# d4f1d01d 27-Aug-2022 Yang Yingliang <yangyingliang@huawei.com>

bus: ti-sysc: Use list_for_each_entry() helper

Convert list_for_each() to list_for_each_entry() where applicable.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Message-Id: <20220827094604.3325887-1-yangyingliang@huawei.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 2ee1bdd3 10-Mar-2023 Rob Herring <robh@kernel.org>

bus: ti-sysc: Use of_property_present() for testing DT property presence

It is preferred to use typed property access functions (i.e.
of_property_read_<type> functions) rather than low-level
of_get_property/of_find_property functions for reading properties. As
part of this, convert of_get_property/of_find_property calls to the
recently added of_property_present() helper when we just want to test
for presence of a property and nothing more.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20230310144734.1546656-1-robh@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 41e4f807 01-Feb-2023 Rob Herring <robh@kernel.org>

bus: ti-sysc: Remove open coded "ranges" parsing

"ranges" is a standard property and we have common helper functions for
parsing it, so let's use them.

Signed-off-by: Rob Herring <robh@kernel.org>
Message-Id: <20230201220002.246907-1-robh@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 41c3b936 22-Nov-2022 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add otg quirk flags for omap3 musb

To prepare for probing omap3 musb with ti-sysc, these quirk flags are
needed similar to what we have for omap4.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Tested-by: Sicelo A. Mhlongo <absicsz@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# c337125b 11-May-2022 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix warnings for unbind for serial

We can get "failed to disable" clock_unprepare warnings on unbind at least
for the serial console device if the unbind is done before the device has
been idled.

As some devices are using deferred idle, we must check the status for
pending idle work to idle the device.

Fixes: 76f0f772e469 ("bus: ti-sysc: Improve handling for no-reset-on-init and no-idle-on-init")
Cc: Romain Naour <romain.naour@smile.fr>
Reviewed-by: Romain Naour <romain.naour@smile.fr>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20220512053021.61650-1-tony@atomide.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b6cd9be3 03-Mar-2022 Geert Uytterhoeven <geert+renesas@glider.be>

bus: ti-sysc: Drop commas after SoC match table sentinels

It does not make sense to have a comma after a sentinel, as any new
elements must be added before the sentinel.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Message-Id: <602f74030dc746eaa9f82f115acc46e62c6be165.1646311501.git.geert+renesas@glider.be>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# a12315d6 11-Apr-2022 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Make omap3 gpt12 quirk handling SoC specific

On beagleboard revisions A to B4 we need to use gpt12 as the system timer.
However, the quirk handling added for gpt12 caused a regression for system
suspend for am335x as the PM coprocessor needs the timers idled for
suspend.

Let's make the gpt12 quirk specific to omap34xx, other SoCs don't need
it. Beagleboard revisions C and later no longer need to use the gpt12
related quirk. Then at some point, if we decide to drop support for the old
beagleboard revisions A to B4, we can also drop the gpt12 related quirks
completely.

Fixes: 3ff340e24c9d ("bus: ti-sysc: Fix gpt12 system timer issue with reserved status")
Reported-by: Kevin Hilman <khilman@baylibre.com>
Suggested-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 1b1da99b 05-Oct-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix variable set but not used warning for reinit_modules

Fix drivers/bus/ti-sysc.c:2494:13: error: variable 'error' set but not
used introduced by commit 9d881361206e ("bus: ti-sysc: Add quirk handling
for reinit on context lost").

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# ce7b4323 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Drop legacy quirk flag for sham

There is no need for the legacy flag any longer for gpio as the omap-sham
driver has been fixed to not rely on pm_runtime_irq_safe().

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 1b99c1ee 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Drop legacy quirk flag for gpio

There is no need for the legacy flag any longer for gpio as the gpio-omap
driver has been fixed to not rely on pm_runtime_irq_safe().

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 5c99fa73 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle otg force idle quirk

Let's add handling the otg force idle quirk for the old omap2430 glue layer
used up to omap4 as the musb driver quirk only works if the driver is
loaded. Unlike with the am335x glue layer, looks like we don't need the
quirk handling for SYSC_QUIRK_REINIT_ON_CTX_LOST.

Eventually when all the musb using SoCs are booting with device tree based
configuration, we can just remove the related quirk handling from the
musb driver.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 9067839f 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Use context lost quirk for otg

Let's use SYSC_QUIRK_REINIT_ON_CTX_LOST quirk for am335x otg instead of
SYSC_QUIRK_REINIT_ON_RESUME quirk as we can now handle the context loss
in a more generic way.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# d48dca51 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Use context lost quirks for gpmc

At least on am335x, the gpmc module needs a re-init and reset if context
has been lost on resume. We can enable this for all gpmc revisions as we
check if the context was lost before restoring it.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 6a52bc2b 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add quirk handling for reset on re-init

At least am335x gpmc module needs a reset in addition to re-init on resume.
Let's add a quirk handling for reset on re-init.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 9d881361 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add quirk handling for reinit on context lost

Some interconnect target modules such as otg and gpmc on am335x need a
re-init after resume. As we also have PM runtime cases where the context
may be lost, let's handle these all with cpu_pm.

For the am335x resume path, we already have cpu_pm_resume() call
cpu_pm_cluster_exit().

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 95ec14fa 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Check for lost context in sysc_reinit_module()

There is no need to restore context if it was not lost. Let's add a new
function sysc_check_context() to check for lost context. To make use of it,
we need to save the sysconfig register status on enable and disable.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# b3e94318 20-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix timekeeping_suspended warning on resume

On resume we can get a warning at kernel/time/timekeeping.c:824 for
timekeeping_suspended.

Let's fix this by adding separate functions for sysc_poll_reset_sysstatus()
and sysc_poll_reset_sysconfig() and have the new functions handle also
timekeeping_suspended.

If iopoll at some point supports timekeeping_suspended, we can just drop
the custom handling from these functions.

Fixes: d46f9fbec719 ("bus: ti-sysc: Use optional clocks on for enable and wait for softreset bit")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# b13a270a 07-Sep-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Use CLKDM_NOAUTO for dra7 dcan1 for errata i893

Commit 94f6345712b3 ("bus: ti-sysc: Implement quirk handling for
CLKDM_NOAUTO") should have also added the quirk for dra7 dcan1 in
addition to dcan2 for errata i893 handling.

Let's also pass the quirk flag for legacy mode booting for if "ti,hwmods"
dts property is used with related dcan hwmod data. This should be only
needed if anybody needs to git bisect earlier stable trees though.

Fixes: 94f6345712b3 ("bus: ti-sysc: Implement quirk handling for CLKDM_NOAUTO")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e879f855 15-Aug-2021 Nathan Chancellor <nathan@kernel.org>

bus: ti-sysc: Add break in switch statement in sysc_init_soc()

After commit a6d90e9f2232 ("bus: ti-sysc: AM3: RNG is GP only"), clang
with -Wimplicit-fallthrough enabled warns:

drivers/bus/ti-sysc.c:2958:3: warning: unannotated fall-through between
switch labels [-Wimplicit-fallthrough]
default:
^
drivers/bus/ti-sysc.c:2958:3: note: insert 'break;' to avoid
fall-through
default:
^
break;
1 warning generated.

Clang's version of this warning is a little bit more pedantic than
GCC's. Add the missing break to satisfy it to match what has been done
all over the kernel tree.

Fixes: a6d90e9f2232 ("bus: ti-sysc: AM3: RNG is GP only")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# ed4520d6 09-Aug-2021 Tony Lindgren <tony@atomide.com>

soc: ti: Remove pm_runtime_irq_safe() usage for smartreflex

For the smartreflex device, we need to disable smartreflex on SoC idle,
and have been using pm_runtime_irq_safe() to do that. But we want to
remove the irq_safe usage as PM runtime takes a permanent usage count
on the parent device with it.

In order to remove the need for pm_runtime_irq_safe(), let's gate
the clock directly in the driver. This removes the need to call PM runtime
during idle, and allows us to switch to using CPU_PM in the following
patch.

Note that the smartreflex interconnect target module is configured for smart
idle, but the clock does not have autoidle capability, and needs to be gated
manually. If the clock supported autoidle, we would not need to even gate
the clock.

With this change, we can now remove the related quirk flags for ti-sysc
also.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>


# 8122dc58 17-Jul-2021 Peter Ujfalusi <peter.ujfalusi@gmail.com>

bus: ti-sysc: Add quirk for OMAP4 McASP to disable SIDLE mode

The McASP module in OMAP4 does not work if the SIDLE mode is enabled, most
like due to module integration issue that the signaling is not working
correctly.
Add a quirk for the module to select only NOIDLE mode when it is in use.

Suggested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# cea08169 31-May-2021 Zhang Qilong <zhangqilong3@huawei.com>

bus: ti-sysc: using pm_runtime_resume_and_get instead of pm_runtime_get_sync

Using pm_runtime_resume_and_get is more appropriate
for simplifing code.

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4e001853 26-May-2021 Lee Jones <lee.jones@linaro.org>

bus: ti-sysc: Correct misdocumentation of 'sysc_ioremap()'

Fixes the following W=1 kernel build warning(s):

drivers/bus/ti-sysc.c:867: warning: expecting prototype for syc_ioremap(). Prototype was for sysc_ioremap() instead

Cc: Tony Lindgren <tony@atomide.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 06a089ef 10-Aug-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix error handling for sysc_check_active_timer()

We have changed the return type for sysc_check_active_timer() from -EBUSY
to -ENXIO, but the gpt12 system timer fix still checks for -EBUSY. We are
also not returning on other errors like we did earlier as noted by
Pavel Machek <pavel@denx.de>.

Commit 3ff340e24c9d ("bus: ti-sysc: Fix gpt12 system timer issue with
reserved status") should have been updated for commit 65fb73676112
("bus: ti-sysc: suppress err msg for timers used as clockevent/source").

Let's fix the issue by checking for -ENXIO and returning on any other
errors as suggested by Pavel Machek <pavel@denx.de>.

Fixes: 3ff340e24c9d ("bus: ti-sysc: Fix gpt12 system timer issue with reserved status")
Depends-on: 65fb73676112 ("bus: ti-sysc: suppress err msg for timers used as clockevent/source")
Reported-by: Pavel Machek <pavel@denx.de>
Reviewed-by: Pavel Machek (CIP) <pavel@denx.de>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Jarkko Nikula <jarkko.nikula@bitmer.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# a6d90e9f 20-Jul-2021 Kevin Hilman <khilman@baylibre.com>

bus: ti-sysc: AM3: RNG is GP only

Make the RNG on AM3 GP only.

Based on this patch from TI v5.4 tree which is based on hwmod data
which are now removed:

| ARM: AM43xx: hwmod: Move RNG to a GP only links table
|
| On non-GP devices the RNG is controlled by the secure-side software,
| like in DRA7xx hwmod we should not control this IP when we are not
| a GP device.
|
| Signed-off-by: Andrew F. Davis <afd@ti.com>

Cc: stable@vger.kernel.org # v5.10+
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 3ff340e2 10-Jun-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix gpt12 system timer issue with reserved status

Jarkko Nikula <jarkko.nikula@bitmer.com> reported that Beagleboard
revision c2 stopped booting. Jarkko bisected the issue down to
commit 6cfcd5563b4f ("clocksource/drivers/timer-ti-dm: Fix suspend
and resume for am3 and am4").

Let's fix the issue by tagging system timers as reserved rather than
ignoring them. And let's not probe any interconnect target module child
devices for reserved modules.

This allows PM runtime to keep track of clocks and clockdomains for
the interconnect target module, and prevent the system timer from idling
as we already have SYSC_QUIRK_NO_IDLE and SYSC_QUIRK_NO_IDLE_ON_INIT
flags set for system timers.

Fixes: 6cfcd5563b4f ("clocksource/drivers/timer-ti-dm: Fix suspend and resume for am3 and am4")
Reported-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Tested-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# c8692ad4 25-May-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix flakey idling of uarts and stop using swsup_sidle_act

Looks like the swsup_sidle_act quirk handling is unreliable for serial
ports. The serial ports just eventually stop idling until woken up and
re-idled again. As the serial port not idling blocks any deeper SoC idle
states, it's adds an annoying random flakeyness for power management.

Let's just switch to swsup_sidle quirk instead like we already do for
omap3 uarts. This means we manually idle the port instead of trying to
use the hardware autoidle features when not in use.

For more details on why the serial ports have been using swsup_idle_act,
see commit 66dde54e978a ("ARM: OMAP2+: hwmod-data: UART IP needs software
control to manage sidle modes"). It seems that the swsup_idle_act quirk
handling is not enough though, and for example the TI Android kernel
changed to using swsup_sidle with commit 77c34c84e1e0 ("OMAP4: HWMOD:
UART1: disable smart-idle.").

Fixes: b4a9a7a38917 ("bus: ti-sysc: Handle swsup idle mode quirks")
Cc: Carl Philipp Klemm <philipp@uvos.xyz>
Cc: Ivan Jelincic <parazyd@dyne.org>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Sicelo A. Mhlongo <absicsz@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4d7b324e 18-May-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix am335x resume hang for usb otg module

On am335x, suspend and resume only works once, and the system hangs if
suspend is attempted again. However, turns out suspend and resume works
fine multiple times if the USB OTG driver for musb controller is loaded.

The issue is caused my the interconnect target module losing context
during suspend, and it needs a restore on resume to be reconfigure again
as debugged earlier by Dave Gerlach <d-gerlach@ti.com>.

There are also other modules that need a restore on resume, like gpmc as
noted by Dave. So let's add a common way to restore an interconnect
target module based on a quirk flag. For now, let's enable the quirk for
am335x otg only to fix the suspend and resume issue.

As gpmc is not causing hangs based on tests with BeagleBone, let's patch
gpmc separately. For gpmc, we also need a hardware reset done before
restore according to Dave.

To reinit the modules, we decouple system suspend from PM runtime. We
replace calls to pm_runtime_force_suspend() and pm_runtime_force_resume()
with direct calls to internal functions and rely on the driver internal
state. There no point trying to handle complex system suspend and resume
quirks via PM runtime.

This is issue should have already been noticed with commit 1819ef2e2d12
("bus: ti-sysc: Use swsup quirks also for am335x musb") when quirk
handling was added for am335x otg for swsup. But the issue went unnoticed
as having musb driver loaded hides the issue, and suspend and resume works
once without the driver loaded.

Fixes: 1819ef2e2d12 ("bus: ti-sysc: Use swsup quirks also for am335x musb")
Suggested-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# db8e712e 06-May-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix missing quirk flags for sata

Naresh Kamboju <naresh.kamboju@linaro.org> reported that Beaglebone-X15
does not detect sata drives any longer after dra7 was flipped to boot with
device tree data only. Turns out we are now missing the sata related quirk
flags in ti-sysc that we used to have earlier.

Fixes: 98feab31ac49 ("ARM: OMAP2+: Drop legacy platform data for dra7 sata")
Fixes: 21206c8f2cb5 ("ARM: OMAP2+: Drop legacy platform data for omap5 sata")
Link: https://lore.kernel.org/regressions/CA+G9fYtTN6ug3eBAW3wMcDeESUo+ebj7L5HBe5_fj4uqDExFQg@mail.gmail.com/
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# d995d3d0 29-Dec-2020 Zheng Yongjun <zhengyongjun3@huawei.com>

bus: ti-sysc: Use kzalloc for allocating only one thing

Use kzalloc rather than kcalloc(1,...)

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
@@

- kcalloc(1,
+ kzalloc(
...)
// </smpl>

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 52fbb5aa 02-Feb-2021 Yang Li <yang.lee@linux.alibaba.com>

bus: ti-sysc: remove unneeded semicolon

Eliminate the following coccicheck warning:
./drivers/bus/ti-sysc.c:1595:2-3: Unneeded semicolon
./drivers/bus/ti-sysc.c:2833:3-4: Unneeded semicolon

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4adcf4c2 12-Mar-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Warn about old dtb for dra7 and omap4/5

Let's warn if an old incomplete dtb is detected. We now assume the dtb
is complete and does not depend on the legacy platform data.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 5f7259a5 08-Mar-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Check for old incomplete dtb

Let's be nice and show an error on the SoCs about old imcomplete devicetree
if the dtb is still using "simple-bus" instead of "simple-pm-bus" for the
root OCP node.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# f2dc0755 08-Mar-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect more modules for debugging

We want to see what the interconnect target module names are for
debugging.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4700a007 08-Mar-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Probe for l4_wkup and l4_cfg interconnect devices first

We want to probe l4_wkup and l4_cfg interconnect devices first to avoid
issues with missing resources. Otherwise we attempt to probe l4_per
devices first causing pointless deferred probe and also annoyingh
renumbering of the MMC devices for example.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 7bad5af8 08-Mar-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix initializing module_pa for modules without sysc register

We have interconnect target modules with no known registers using only
clocks and resets, but we still want to detect them based on the module
IO range. So let's call sysc_parse_and_check_child_range() earlier so we
have module_pa properly initialized.

Fixes: 2928135c93f8 ("bus: ti-sysc: Support modules without control registers")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# a7b5d7c4 18-Feb-2021 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix warning on unbind if reset is not deasserted

We currently get thefollowing on driver unbind if a reset is configured
and asserted:

WARNING: CPU: 0 PID: 993 at drivers/reset/core.c:432 reset_control_assert
...
(reset_control_assert) from [<c0fecda8>] (sysc_remove+0x190/0x1e4)
(sysc_remove) from [<c0a2bb58>] (platform_remove+0x24/0x3c)
(platform_remove) from [<c0a292fc>] (__device_release_driver+0x154/0x214)
(__device_release_driver) from [<c0a2a210>] (device_driver_detach+0x3c/0x8c)
(device_driver_detach) from [<c0a27d64>] (unbind_store+0x60/0xd4)
(unbind_store) from [<c0546bec>] (kernfs_fop_write_iter+0x10c/0x1cc)

Let's fix it by checking the reset status.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 65fb7367 18-Nov-2020 Grygorii Strashko <grygorii.strashko@ti.com>

bus: ti-sysc: suppress err msg for timers used as clockevent/source

GP Timers used as clockevent/source are not available for ti-sysc bus and
handled by Kernel timekeeping core. Now ti-sysc produces error message
every time such timer is detected:

"ti-sysc: probe of 48040000.target-module failed with error -16"

Such messages are not necessary, so suppress them by returning -ENXIO
instead of -EBUSY.

Fixes: 6cfcd5563b4f ("clocksource/drivers/timer-ti-dm: Fix suspend and resume for am3 and am4")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# cfeeea60 15-Nov-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Implement GPMC debug quirk to drop platform data

We need to enable no-reset-on-init quirk for GPMC if the config
option for CONFIG_OMAP_GPMC_DEBUG is set. Otherwise the GPMC
driver code is unable to show the bootloader configured timings.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 2928135c 15-Nov-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Support modules without control registers

Some modules like MPU have a powerdomain and functional clock but not
necessarily any control registers. Let's allow configuring interconnect
target modules with no control registers.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4097c9a6 15-Nov-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Assert reset only after disabling clocks

The rstctrl reset must be asserted after gating the module clock as
described in the TRM at least for IVA. Otherwise the rstctrl reset
done with module clock enabled can hang the system.

Note that this issue is has been only seen with related IVA changes
that we do not currently have merged. So probably no need to apply
this patch as a fix.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# e7ae08d3 26-Oct-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix bogus resetdone warning on enable for cpsw

Bail out early from sysc_wait_softreset() just like we do in sysc_reset()
if there's no sysstatus srst_shift to fix a bogus resetdone warning on
enable as suggested by Grygorii Strashko <grygorii.strashko@ti.com>.

We do not currently handle resets for modules that need writing to the
sysstatus register. If we at some point add that, we also need to add
SYSS_QUIRK_RESETDONE_INVERTED flag for cpsw as the sysstatus bit is low
when reset is done as described in the am335x TRM "Table 14-202
SOFT_RESET Register Field Descriptions"

Fixes: d46f9fbec719 ("bus: ti-sysc: Use optional clocks on for enable and wait for softreset bit")
Suggested-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e275d210 26-Oct-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix reset status check for modules with quirks

Commit d46f9fbec719 ("bus: ti-sysc: Use optional clocks on for enable and
wait for softreset bit") started showing a "OCP softreset timed out"
warning on enable if the interconnect target module is not out of reset.
This caused the warning to be often triggered for i2c and hdq while the
devices are working properly.

Turns out that some interconnect target modules seem to have an unusable
reset status bits unless the module specific reset quirks are activated.

Let's just skip the reset status check for those modules as we only want
to activate the reset quirks when doing a reset, and not on enable. This
way we don't see the bogus "OCP softreset timed out" warnings during boot.

Fixes: d46f9fbec719 ("bus: ti-sysc: Use optional clocks on for enable and wait for softreset bit")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# df561f66 23-Aug-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

treewide: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>


# 6cfcd556 13-Jul-2020 Tony Lindgren <tony@atomide.com>

clocksource/drivers/timer-ti-dm: Fix suspend and resume for am3 and am4

Carlos Hernandez <ceh@ti.com> reported that we now have a suspend and
resume regresssion on am3 and am4 compared to the earlier kernels. While
suspend and resume works with v5.8-rc3, we now get errors with rtcwake:

pm33xx pm33xx: PM: Could not transition all powerdomains to target state
...
rtcwake: write error

This is because we now fail to idle the system timer clocks that the
idle code checks and the error gets propagated to the rtcwake.

Turns out there are several issues that need to be fixed:

1. Ignore no-idle and no-reset configured timers for the ti-sysc
interconnect target driver as otherwise it will keep the system timer
clocks enabled

2. Toggle the system timer functional clock for suspend for am3 and am4
(but not for clocksource on am3)

3. Only reconfigure type1 timers in dmtimer_systimer_disable()

4. Use of_machine_is_compatible() instead of of_device_is_compatible()
for checking the SoC type

Fixes: 52762fbd1c47 ("clocksource/drivers/timer-ti-dm: Add clockevent and clocksource support")
Reported-by: Carlos Hernandez <ceh@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Tested-by: Carlos Hernandez <ceh@ti.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200713162601.6829-1-tony@atomide.com


# 4254632d 13-Jul-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add missing quirk flags for usb_host_hs

Similar to what we have for the legacy platform data, we need to
configure SWSUP_SIDLE and SWSUP_MSTANDBY quirks for usb_host_hs.

These are needed to drop the legacy platform data for usb_host_hs.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# a55de412 02-Jul-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Do not disable on suspend for no-idle

If we have "ti,no-idle" specified for a module we must not disable
the the module on suspend to keep things backwards compatible.

Fixes: 386cb76681ca ("bus: ti-sysc: Handle missed no-idle property in addition to no-idle-on-init")
Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# afe6f1ee 02-Jul-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix sleeping function called from invalid context for RTC quirk

With CONFIG_DEBUG_ATOMIC_SLEEP enabled we can see the following with RTC probe:

BUG: sleeping function called from invalid context at drivers/bus/ti-sysc.c:1736
...
(sysc_quirk_rtc) from [<c060d01c>] (sysc_write_sysconfig+0x1c/0x60)
(sysc_write_sysconfig) from [<c060d9f4>] (sysc_enable_module+0x11c/0x274)
(sysc_enable_module) from [<c060f37c>] (sysc_probe+0xe9c/0x1380)
(sysc_probe) from [<c06e9384>] (platform_drv_probe+0x48/0x98)

Fixes: e8639e1c986a ("bus: ti-sysc: Handle module unlock quirk needed for some RTC")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 9f911392 02-Jul-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix wakeirq sleeping function called from invalid context

With CONFIG_DEBUG_ATOMIC_SLEEP enabled we can see the following with
wakeirqs and serial console idled:

BUG: sleeping function called from invalid context at drivers/bus/ti-sysc.c:242
...
(sysc_wait_softreset) from [<c0606894>] (sysc_enable_module+0x48/0x274)
(sysc_enable_module) from [<c0606c5c>] (sysc_runtime_resume+0x19c/0x1d8)
(sysc_runtime_resume) from [<c0606cf0>] (sysc_child_runtime_resume+0x58/0x84)
(sysc_child_runtime_resume) from [<c06eb7bc>] (__rpm_callback+0x30/0x12c)
(__rpm_callback) from [<c06eb8d8>] (rpm_callback+0x20/0x80)
(rpm_callback) from [<c06eb434>] (rpm_resume+0x638/0x7fc)
(rpm_resume) from [<c06eb658>] (__pm_runtime_resume+0x60/0x9c)
(__pm_runtime_resume) from [<c06edc08>] (handle_threaded_wake_irq+0x24/0x60)
(handle_threaded_wake_irq) from [<c01befec>] (irq_thread_fn+0x1c/0x78)
(irq_thread_fn) from [<c01bf30c>] (irq_thread+0x140/0x26c)

We have __pm_runtime_resume() call the sysc_runtime_resume() with spinlock
held and interrupts disabled.

Fixes: d46f9fbec719 ("bus: ti-sysc: Use optional clocks on for enable and wait for softreset bit")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e4a8fc05 10-Jun-2020 Tony Lindgren <tony@atomide.com>

Revert "bus: ti-sysc: Increase max softreset wait"

This reverts commit 636338d7968e47c7f2e0b772a2a825ad932883fb.

This patch is not a proper fixes the i2c2 timeouts are still
happening in some cases.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 636338d7 03-Jun-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Increase max softreset wait

Otherwise we can get "OCP softreset timed out" warnings occasionally
at least for i2c2 on omap4 now that we check the OCP softreset completed
bit on enable.

Reported-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 085bc0e5 31-May-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix uninitialized framedonetv_irq

We are currently only setting the framedonetv_irq disabled for the SoCs
that don't have it. But we are never setting it enabled for the SoCs that
have it. Let's initialized it to true by default.

Fixes: 7324a7a0d5e2 ("bus: ti-sysc: Implement display subsystem reset quirk")
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 08b91dd6 31-May-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Ignore clockactivity unless specified as a quirk

We must ignore the clockactivity bit for most modules and not set it
unless specified for the module with SYSC_QUIRK_USE_CLOCKACT. Otherwise
the interface clock can be automatically gated constantly causing
unexpected performance issues.

Fixes: ae9ae12e9daa ("bus: ti-sysc: Handle clockactivity for enable and disable")
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# d46f9fbe 31-May-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Use optional clocks on for enable and wait for softreset bit

Some modules reset automatically when idled, and when re-enabled, we must
wait for the automatic OCP softreset to complete. And if optional clocks
are configured, we need to keep the clocks on while waiting for the reset
to complete.

Let's fix the issue by moving the OCP softreset code to a separate
function sysc_wait_softreset(), and call it also from sysc_enable_module()
with the optional clocks enabled.

This is based on what we're already doing for legacy platform data booting
in _enable_sysc().

Fixes: 7324a7a0d5e2 ("bus: ti-sysc: Implement display subsystem reset quirk")
Reported-by: Faiz Abbas <faiz_abbas@ti.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 5ce8aee8 27-May-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Flush posted write on enable and disable

Looks like we're missing flush of posted write after module enable and
disable. I've seen occasional errors accessing various modules, and it
is suspected that the lack of posted writes can also cause random reboots.

The errors we can see are similar to the one below from spi for example:

44000000.ocp:L3 Custom Error: MASTER MPU TARGET L4CFG (Read): Data Access
in User mode during Functional access
...
mcspi_wait_for_reg_bit
omap2_mcspi_transfer_one
spi_transfer_one_message
...

We also want to also flush posted write for disable. The clkctrl clock
disable happens after module disable, and we don't want to have the
module potentially stay active while we're trying to disable the clock.

Fixes: d59b60564cbf ("bus: ti-sysc: Add generic enable/disable functions")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 1a542811 07-May-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Timers no longer need legacy quirk handling

As timers no longer need legacy quirk handling, let's move them to
the CONFIG_DEBUG section to make it easier to see which drivers still
need more work.

Let's also add detection for few more older timer revisions while at
it as that makes CONFIG_DEBUG output easier to read with proper names.

Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Keerthy <j-keerthy@ti.com>
Cc: Lokesh Vutla <lokeshvutla@ti.com>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4bba9bf0 07-May-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Ignore timer12 on secure omap3

Some early omap3 boards use timer12 for system timer, but for secure
SoCs like on n900 it's not accessible. Likely we will be configuring
unavailable devices for other SoCs too based on runtime SoC detection,
so let's use a switch to start with.

Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Keerthy <j-keerthy@ti.com>
Cc: Lokesh Vutla <lokeshvutla@ti.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# cfaf6051 09-Mar-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix quirk flags for lcdc on am335x

Commit adb72394e2ab ("ARM: OMAP2+: Drop legacy platform data for am3
lcdc") dropped legacy platform data but we never added the quirks for
SWSUP_SIDLE and SWSUP_MSTANDBY for lcdc for ti-sysc driver.

This breaks suspend/resume. Let's fix the issue by enabling the same
quirks for ti-sysc driver as we had earlier with platform data.

Fixes: adb72394e2ab ("ARM: OMAP2+: Drop legacy platform data for am3 lcdc")
Fixes: 23731eac9848 ("bus: ti-sysc: Detect devices on am335x when DEBUG is enabled")
Reported-by: Keerthy <j-keerthy@ti.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Keerthy <j-keerthy@ti.com>
Cc: Dave Gerlach <d-gerlach@ti.com>
Cc: Tero Kristo <t-kristo@ti.com>
Tested-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# b2745d92 27-Feb-2020 Suman Anna <s-anna@ti.com>

bus: ti-sysc: Add support for PRUSS SYSC type

The PRU-ICSS present on AM33xx/AM43xx/AM57xx has a very unique
SYSCFG register. The register follows the OMAP4-style SYSC_TYPE3
for Master Standby and Slave Idle, but also has two additional
unique fields - STANDBY_INIT and SUB_MWAIT. The STANDBY_INIT is
a control bit that is used to initiate a Standby sequence (when
set) and trigger a MStandby request to the SoC's PRCM module. This
same bit is also used to enable the OCP master ports (when cleared)
to allow the PRU cores to access any peripherals or memory beyond
the PRU subsystem. The SUB_MWAIT is a ready status field for the
external access.

Add support for this SYSC type. The STANDBY_INIT has to be set
during suspend, without which it results in a hang in the resume
sequence on AM33xx/AM43xx boards and requires a board reset to
come out of the hang. Any PRU applications requiring external
access are supposed to clear the STANDBY_INIT bit. Note that
the PRUSS context is lost during a suspend sequence because the
PRUSS module is reset and/or disabled.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
[tony@atomide.com: updated quirk define number and to use -ENODEV]
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 25bfaaa7 03-Mar-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect EDMA and set quirk flags for tptc

In order to probe EDMA with ti-sysc interconnect target module and with
device tree data, we need to properly detect EDMA and set the flags for
SYSC_QUIRK_SWSUP_SIDLE | SYSC_QUIRK_SWSUP_MSTANDBY for tptc.

We have these flags currently set for am4 and dra7, but not for am335x.
Let's set them for all the SoCs as the tptc module should behave the
same for all of them. It's likely that am335x was never tested to idle
EDMA tptc.

Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 69e60903 03-Mar-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix wrong offset for display subsystem reset quirk

Commit 7324a7a0d5e2 ("bus: ti-sysc: Implement display subsystem reset
quirk") added support for DSS reset, but is using dispc offset also for
DSS also registers as reported by Tomi Valkeinen <tomi.valkeinen@ti.com>.
Also, we're not using dispc_offset for dispc IRQSTATUS register so let's
fix that too.

Fixes: 7324a7a0d5e2 ("bus: ti-sysc: Implement display subsystem reset quirk")
Reported-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 7324a7a0 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Implement display subsystem reset quirk

The display subsystem (DSS) needs the child outputs disabled for reset.
In order to prepare to probe DSS without legacy platform data, let's
implement sysc_pre_reset_quirk_dss() similar to what we have for the
platform data with omap_dss_reset().

Note that we cannot directly use the old omap_dss_reset() without
platform data callbacks and updating omap_dss_reset() to understand
struct device. And we will be dropping omap_dss_reset() anyways when
all the SoCs are probing with device tree, so let's not mess with the
legacy code at all.

Cc: Jyri Sarha <jsarha@ti.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# aec551c7 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix 1-wire reset quirk

Because of the i2c quirk we have the reset quirks named in a confusing
way. Let's fix the 1-wire quirk accordinlyg. Then let's switch to using
better naming later on.

Fixes: 4e23be473e30 ("bus: ti-sysc: Add support for module specific reset quirks")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 77dfece2 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect display subsystem related devices

In order to prepare probing display subsystem (DSS) with ti-sysc
interconnect target module driver and device tree data, let's
detect DSS related modules.

We need to also add reset quirk handling for DSS, but until that's
done, let's just enable the optional clock quirks for DSS and
omap4 HDMI. The rest is just naming of modules if CONFIG_DEBUG
is set.

Cc: Jyri Sarha <jsarha@ti.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e8639e1c 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle module unlock quirk needed for some RTC

The RTC modules on am3 and am4 need quirk handling to unlock and lock
them for reset so let's add the quirk handling based on what we already
have for legacy platform data. In later patches we will simply drop the
RTC related platform data and the old quirk handling.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# feaa8bae 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Implement SoC revision handling

We need to know SoC type and features for cases where the same SoC
may be installed in various versions on the same board and would need
a separate dts file otherwise for the different variants.

For example, am3703 is pin compatible with omap3630, but has sgx and
iva accelerators disabled. We must not try to access the sgx or iva
module registers on am3703, and need to set the unavailable devices
disabled early.

Let's also detect omap3430 as that is needed for display subsystem
(DSS) reset later on, and GP vs EMU or HS devices. Further SoC
specific disabled device detection can be added as needed, such as
dra71x vs dra76x rtc and usb4.

Cc: Adam Ford <aford173@gmail.com>
Cc: André Hentschel <nerv@dawncrow.de>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 7320fd32 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Don't warn about legacy property for nested ti-sysc devices

In some cases we can have nested ti-sysc instances that may still use the
legacy "ti,hwmods" property. Let's not warn if that's the case.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 590e15c7 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Consider non-existing registers too when matching quirks

We are currently setting -1 for non-existing sysconfig related registers
for quirks, but setting -ENODEV elsewhere. And for matching the quirks,
we're now just ignoring the non-existing registers. This will cause issues
with misdetecting DSS registers as the hardware revision numbers can have
duplicates.

To avoid this, let's standardize on using -ENODEV also for the quirks
instead of -1. That way we can always just test for a match without adding
any more complicated logic.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# ab4d309d 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Improve reset to work with modules with no sysconfig

At least display susbsystem (DSS) has modules with no sysconfig registers
and rely on custom function for module reset handling. Let's make reset
work with that too.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# e64c021f 24-Feb-2020 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Rename clk related quirks to pre_reset and post_reset quirks

The clk_disable_quirk and clk_enable_quirk should really be called
pre_reset_quirk and post_reset_quirk to avoid confusion like we had
with hdq1w reset.

Let's also rename the related functions so the code is easier to follow.
Note that we also have reset_done_quirk that is needed in some cases
after checking the separate register for reset done bit.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 2c81f0f6 16-Dec-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix iterating over clocks

Commit d878970f6ce1 ("bus: ti-sysc: Add separate functions for handling
clocks") separated handling of optional clocks from the main clocks, but
introduced an issue where we do not necessarily allocate a slot for both
fck and ick clocks, but still assume fixed slots for enumerating over the
clocks.

Let's fix the issue by ensuring we always have slots for both fck and ick
even if we don't use ick, and don't attempt to enumerate optional clocks
if not allocated.

In the long run we might want to simplify things a bit by only allocating
space only for the optional clocks as we have only few devices with
optional clocks.

Fixes: d878970f6ce1 ("bus: ti-sysc: Add separate functions for handling clocks")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 3f2c4205 18-Nov-2019 zhengbin <zhengbin13@huawei.com>

bus: ti-sysc: Use PTR_ERR_OR_ZERO() to simplify code

Fixes coccicheck warning:

drivers/bus/ti-sysc.c:506:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 426d4447 12-Dec-2019 Suman Anna <s-anna@ti.com>

bus: ti-sysc: Drop MMU quirks

The OMAP IOMMU driver no longer uses the pm_runtime_irq_safe() API
after commit 1432ebbd6003 ("iommu/omap: remove pm_runtime_irq_safe
flag for OMAP IOMMUs"), so the SYSC_QUIRK_LEGACY_IDLE quirk is no
longer needed for MMU devices. Drop the same.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 94f63457 12-Dec-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Implement quirk handling for CLKDM_NOAUTO

For dra7 dcan and dwc3 instances we need to block clockdomain autoidle.
Let's do this with CLKDM_NOAUTO quirk flag and enable it for dcan and
dwc3.

Cc: Keerthy <j-keerthy@ti.com>
Cc: Roger Quadros <rogerq@ti.com>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e709ed70 12-Dec-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix missing reset delay handling

We have dts property for "ti,sysc-delay-us", and we're using it, but the
wait after OCP softreset only happens if devices are probed in legacy mode.

Let's add a delay after writing the OCP softreset when specified.

Fixes: e0db94fe87da ("bus: ti-sysc: Make OCP reset work for sysstatus and sysconfig reset bits")
Cc: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 93c60483 09-Dec-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix missing force mstandby quirk handling

Commit 03856e928b0e ("bus: ti-sysc: Handle mstandby quirk and use it for
musb") added quirk handling for mstandby quirk but did not consider that
we also need a quirk variant for SYSC_QUIRK_FORCE_MSTANDBY.

We need to use forced idle mode for both SYSC_QUIRK_SWSUP_MSTANDBY and
SYSC_QUIRK_FORCE_MSTANDBY, but SYSC_QUIRK_SWSUP_MSTANDBY also need to
additionally also configure no-idle mode when enabled.

Fixes: 03856e928b0e ("bus: ti-sysc: Handle mstandby quirk and use it for musb")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# cb6cfe2e 06-Nov-2019 Markus Elfring <elfring@users.sourceforge.net>

bus: ti-sysc: Adjust exception handling in sysc_child_add_named_clock()

Add a jump target so that a call of the function “clk_put”
can be better reused at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 020003f7 14-Nov-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add module enable quirk for audio AESS

We must set the autogating bit on enable for AESS (Audio Engine SubSystem)
when probed with ti-sysc interconnect target module driver. Otherwise it
won't idle properly.

Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 1819ef2e 21-Oct-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Use swsup quirks also for am335x musb

Also on am335x we need the swsup quirks for musb.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 03856e92 21-Oct-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle mstandby quirk and use it for musb

We need swsup quirks for sidle and mstandby for musb to work
properly.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# c7d8669f 17-Oct-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix watchdog quirk handling

I noticed that when probed with ti-sysc, watchdog can trigger on am3, am4
and dra7 causing a device reset.

Turns out I made several mistakes implementing the watchdog quirk handling:

1. We must do both writes to spr register

2. We must also call the reset quirk on disable

3. On am3 and am4 we need to also set swsup quirk flag

I probably only tested this earlier with watchdog service running when the
watchdog never gets disabled.

Fixes: 4e23be473e30 ("bus: ti-sysc: Add support for module specific reset quirks")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# cdc56c11 07-Oct-2019 Tero Kristo <t-kristo@ti.com>

bus: ti-sysc: avoid toggling power state of module during probe

Current implementation for ti-sysc powers down the module once module
init is complete. However, right after power is disabled, it is enabled
via runtime PM. This is unnecessary so avoid it by re-ordering the
events a bit; move powering down of the module post runtime PM enable
which makes sure the use counts are maintained properly and there is
no extra power down/up sequence for the module.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# df4f3459 07-Oct-2019 Tero Kristo <t-kristo@ti.com>

bus: ti-sysc: drop the extra hardreset during init

There seems to be unnecessary extra hardreset line toggling applied
during module init. This is unnecessary, as the reset lines are already
asserted during boot, and it can cause certain modules to hang (iommus,
remoteprocs.) Remove the extra hardreset toggle, and remove the now
redundant function to handle this also.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# bf59ebbe 07-Oct-2019 Tero Kristo <t-kristo@ti.com>

bus: ti-sysc: re-order reset and main clock controls

The main clocks and reset controls have a hardware level dependency,
where one can't transition state without the other one transitioning.
Because we don't have the dependency implemented in software, we must
ensure the ordering of these two is done properly; they way this is
handled is that clocks transition on software level without delay,
and the status is only polled on reset side. Because of this, we must
re-order the main clock and reset handling on the ti-sysc driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# a4c8723a 06-Sep-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Remove unpaired sysc_clkdm_deny_idle()

Commit d098913a10f8 ("bus: ti-sysc: Fix clock handling for no-idle
quirks") fixed handling for no-idle quirk modules that are not enabled
by the bootloader.

But it also caused unpaired clockdomain calls that won't allow idling
the system. That's because clkdm_allow_idle_nolock() and
clkdm_deny_idle_nolock() have usage count with clkdm->forcewake_count.

Let's drop the unpaired sysc_clkdm_deny_idle() to fix idling of devices.

Fixes: d098913a10f8 ("bus: ti-sysc: Fix clock handling for no-idle quirks")
Cc: Keerthy <j-keerthy@ti.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 2783d063 05-Sep-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix handling of invalid clocks

We can currently get "Unable to handle kernel paging request at
virtual address" for invalid clocks with dts node but no driver:

(__clk_get_hw) from [<c0138ebc>] (ti_sysc_find_one_clockdomain+0x18/0x34)
(ti_sysc_find_one_clockdomain) from [<c0138f0c>] (ti_sysc_clkdm_init+0x34/0xdc)
(ti_sysc_clkdm_init) from [<c0584660>] (sysc_probe+0xa50/0x10e8)
(sysc_probe) from [<c065c6ac>] (platform_drv_probe+0x58/0xa8)

Let's add IS_ERR checks to ti_sysc_clkdm_init() as And let's start treating
clk_get() with -ENOENT as a proper error. If the clock name is specified
in device tree we must succeed with clk_get() to continue. For modules with
no clock names specified in device tree we will just ignore the clocks.

Fixes: 2b2f7def058a ("bus: ti-sysc: Add support for missing clockdomain handling")
Acked-by: Roger Quadros <rogerq@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# d098913a 05-Sep-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix clock handling for no-idle quirks

NFSroot can fail on dra7 when cpsw is probed using ti-sysc interconnect
target module driver as reported by Keerthy.

Device clocks and the interconnect target module may or may not be
enabled by the bootloader on init, but we currently assume the clocks
and module are on from the bootloader for "ti,no-idle" and
"ti,no-idle-on-init" quirks as reported by Grygorii Strashko.

Let's fix the issue by always enabling clocks init, and
never disable them for "ti,no-idle" quirk. For "ti,no-idle-on-init"
quirk, we must decrement the usage count later on to allow PM
runtime to idle the module if requested.

Fixes: 1a5cd7c23cc5 ("bus: ti-sysc: Enable all clocks directly during init to read revision")
Cc: Keerthy <j-keerthy@ti.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Reported-by: Keerthy <j-keerthy@ti.com>
Reported-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 7edd00f7 14-Aug-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect d2d when debug is enabled

We want to see what modules probe when debug is enabled.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# d7f563db 14-Aug-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add module enable quirk for SGX on omap36xx

Add module enable quirk for SGX needed on omap36xx.

Cc: Adam Ford <aford173@gmail.com>
Cc: Filip Matijević <filip.matijevic.pz@gmail.com>
Cc: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Cc: moaz korena <moaz@korena.xyz>
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
Cc: Philipp Rossak <embed3d@gmail.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# c6e78d70 14-Aug-2019 Nishka Dasgupta <nishkadg.linux@gmail.com>

bus: ti-sysc: Change return types of functions

Change return type of functions sysc_check_one_child() and
sysc_check_children() from int to void as neither ever returns an error.
Modify call sites of both functions accordingly.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# c8a738f4 27-Jun-2019 YueHaibing <yuehaibing@huawei.com>

bus: ti-sysc: remove set but not used variable 'quirks'

Fixes gcc '-Wunused-but-set-variable' warning:

drivers/bus/ti-sysc.c: In function sysc_reset:
drivers/bus/ti-sysc.c:1452:50: warning: variable quirks set but not used [-Wunused-but-set-variable]

It is never used since commit e0db94fe87da ("bus: ti-sysc: Make
OCP reset work for sysstatus and sysconfig reset bits")

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# bb88b86c 07-Aug-2019 Tero Kristo <t-kristo@ti.com>

bus: ti-sysc: allow reset sharing across devices

Some devices need to share their reset signals, like DSP MMUs, thus drop
the exclusive notation from reset request. Also, balance the init time
reset count, otherwise the resets will never be applied post boot.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4345f0dc 07-Aug-2019 Tero Kristo <t-kristo@ti.com>

bus: ti-sysc: rework the reset handling

If reset controllers are assigned to the ti-sysc target-module, only
ti-sysc is going to be able to control these. Thus, remove all the
disable_on_idle flag usage, and assert/de-assert the reset always
in the idle path. Otherwise the reset signal will always just be
de-asserted.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# b6036314 07-Aug-2019 Tero Kristo <t-kristo@ti.com>

bus: ti-sysc: re-order the clkdm control around reset handling

Parenting clockdomain for the IP should be enabled during the reset
handling logic, otherwise the reset may not finish properly. Re-order
the clockdomain control logic to avoid this.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# b58056da 13-Aug-2019 Suman Anna <s-anna@ti.com>

bus: ti-sysc: Add missing kerneldoc comments

A few fields in various structures is missing the corresponding
kerneldoc comments. Add them. Also, fixed the comment for sidlemodes.

Signed-off-by: Suman Anna <s-anna@ti.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 54d66222 13-Aug-2019 Suman Anna <s-anna@ti.com>

bus: ti-sysc: Switch to SPDX license identifier

Use the appropriate SPDX license identifier in the TI sysc
interconnect target driver source files and drop the previous
boilerplate license text. Also, add the the SPDX license
identifier in the associated ti-sysc header files.

Signed-off-by: Suman Anna <s-anna@ti.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# a304f483 25-Jun-2019 Suman Anna <s-anna@ti.com>

bus: ti-sysc: Simplify cleanup upon failures in sysc_probe()

The clocks are not yet parsed and prepared until after a successful
sysc_get_clocks(), so there is no need to unprepare the clocks upon
any failure of any of the prior functions in sysc_probe(). The current
code path would have been a no-op because of the clock validity checks
within sysc_unprepare(), but let's just simplify the cleanup path by
returning the error directly.

While at this, also fix the cleanup path for a sysc_init_resets()
failure which is executed after the clocks are prepared.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 89bbc6f1 22-Jul-2019 Tony Lindgren <tony@atomide.com>

ARM: dts: Fix incorrect dcan register mapping for am3, am4 and dra7

We are currently using a wrong register for dcan revision. Although
this is currently only used for detecting the dcan module, let's
fix it to avoid confusion.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e212abd4 22-Jul-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix using configured sysc mask value

We have cases where there are no softreset bits like with am335x lcdc.
In that case ti,sysc-mask = <0> needs to be handled properly.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 6ee8241d 22-Jul-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix handling of forced idle

For some devices we can get the following warning on boot:

ti-sysc 48485200.target-module: sysc_disable_module: invalid midlemode

Fix this by treating SYSC_IDLE_FORCE like we do for the other bits
for idlemodes mask.

Fixes: d59b60564cbf ("bus: ti-sysc: Add generic enable/disable functions")
Cc: Roger Quadros <rogerq@ti.com>
Reviewed-by: Suman Anna <s-anna@ti.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4e23be47 10-Jun-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add support for module specific reset quirks

Some older interconnect target modules need module internal clock
toggling quirks to reset properly. We've been doing this in the
platform code earlier, but need to be able to it directly in the
ti-sysc driver when we no longer rely on on the platform code.

Let's add reset handling for 1-wire, i2c and watchdog. Later on
we can add more modules like msdi and dss as they get tested.
For dra7 pcie, we should be able to just use the rstctrl reset
driver when available.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# b6a53c4c 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect uarts also on omap34xx

Looks like we currently only detect UART on omap36xx, let's also
add support for omap34xx. And let's also fix the SWSUP mode, it should
be SWSUP_SIDLE for omap3, not SWSUP_SIDLE_ACT like for omap4 and later.

Note that we are still booting omap3 for most part without ti-sysc,
so no need to treat this change as a fix.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# ea5a2e4d 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Do rstctrl reset handling in two phases

We need to deassert rstctrl resets before enabling clocks to avoid clock
"failed to enable" errors. For asserting rstctrl reset, the clocks need
to be enabled.

As the reset controller status is not available for arrays, let's use
devm_reset_control_get_optional() so we can get the status after reset.

Note that depends on a proper PRM rstctrl driver, so far I've only
tested this with earlier reset-simple patches.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 8383e259 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add support for disabling module without legacy mode

We must not assert reset for modules with no child device drivers
until in runtime_suspend. Otherwise register access will fail without
legacy mode helping us.

Let's add a flag for disable_on_idle and move the reset driver
handling to runtime suspend and resume. We can then also use the
disable_on_idle flag to reconfigure sysconfig register for PM
modes requesting it.

Let's also make the other flags use bitfield while at it instead of
bool.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 6e09f497 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Set ENAWAKEUP if available

Some modules have ENAWAKEUP bit that we need to configure when not
relying on platform data callbacks.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# fb685f1c 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle swsup idle mode quirks

Some modules have idlemodes wired, but not completely functional. We have
quirks for SWSUP_SIDLE and SWSUP_SIDLE_ACT to manage interconnect target
modules without hardware support, but we've been only using them so far
in legacy mode. Let's add support for SWSUP quirks in non-legacy mode too.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# ae9ae12e 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle clockactivity for enable and disable

Modules with clockactivity need it configured during enable.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# eec26555 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Enable interconnect target module autoidle bit on enable

For interconnect target modules with autoidle bit wired, we need to manage
it for enable and disable.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# bd808f9a 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Allow QUIRK_LEGACY_IDLE even if legacy_mode is not set

We need to specify QUIRK_LEGACY_IDLE for device drivers that still have
pm_runtime_irq_safe() set like 8250.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e0db94fe 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Make OCP reset work for sysstatus and sysconfig reset bits

We've had minimal OCP softreset support in ti-sysc interconnect target
module driver only used for MCAN driver so far. But it turns out that
MCAN has the sysstatus register resetdone bit inverted compared to most
other modules.

Let's make OCP softreset work for other typical cases with reset status
in sysstatus or sysconfig register so we can use the new functions for
sysc_enable_module() and sysc_disable_module() without "ti,hwmods"
property in the following patches.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 5aa91295 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Support 16-bit writes too

We need to also support 16-bit writes for i2c in addition to the reads
when we start configuring the sysconfig register for reset and idle modes.

Note that only i2c revision register has LO and HI registers, so let's
add a check also for 16-bit register read. This change is currently cosmetic
and does not affect anything until we enable the module specific quirk
handling for i2c reset and enable later on.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 2b2f7def 27-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add support for missing clockdomain handling

We need to let ti-sysc driver manage clockdomain autoidle for the
duration of of reset, enable and idle. And we need to do it before we
enable the clock and after we disable it. Currently we are still
relying on platform callbacks indirectly managing clockdomain autoidle.
But I noticed that for device tree only probed drivers it now happens
only after we enabling the clocks and before we disable the clocks,
while it should be the other way around. So far I have not noticed
any issues with this though.

Let's add new ti_sysc_clkdm_deny_idle() and ti_sysc_clkdm_allow_idle()
functions for ti-sysc driver to use to manage clockdomains directly via
platform data callbacks. Note that we can implement the clockdomain
functions in pdata-quirks.c as for probing devices without "ti,hwmods"
custom property we don't need to use the other platform data callbacks.

Let's do this in one patch as there's is still an unlikely chance we
may need to apply this as a fix for v5.2 for dropping legacy platform
data for some devices. We also do have the option of adding back the
platform data if needed in case of trouble.

Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# e4f50c8d 01-May-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle devices with no control registers

Some interconnect target modules have no module control registers at
all, such as d_can on am335x and am437x.

The d_can register offset at 0 is CTL register with 0x401 as the default
value. I guess I mistook the 0x401 value for a revision register as the
value happens to look similar to what the revision registers typically
have for other modules.

To handle modules with no control registers, we need to improve the
ti-sysc driver a bit to bail out with errors on no control registers,
and then we can remove the bogus revision registers for d_can.

Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# d59b6056 07-Apr-2019 Roger Quadros <rogerq@ti.com>

bus: ti-sysc: Add generic enable/disable functions

For non legacy cases, add generic sysc_enable_module()
and sysc_disable_module() functions.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 13aad519 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect DMIC for debugging

Detect DMIC to see what we have connected if config DEBUG is enabled.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# b4a9a7a3 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle swsup idle mode quirks

In preparation of dropping interconnect target module platform data in
favor of devicetree based data, we must pass swsup idle quirks to the
platform data functions.

For now, let's only tag the UART modules with the SWSUP_SIDLE_ACT quirk.
The other modules will get tagged with swsup quirks as we drop the
platform data and test the changes.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# a54275f4 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add quirk handling for external optional functional clock

We cannot access mcpdm registers at all unless there is an optional pdmclk
configured. As this is currently only needed for mcpdm, let's check for
mcpdm in sysc_get_clocks(). If it turns out to be needed for other modules
too, we can add more flags to the quirks table for this.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 42b9c5c9 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add support for early quirks based on register address

At least mcpdm needs an optional external clock enabled to function and
this clock typically comes from the PMIC. We can detect mcpdm based on
the interconnect target module address and set a quirk flag early.

To do this, let's initialize the clocks a bit later and add a new
function for sysc_init_early_quirks(). Note that we cannot yet enable
the early quirks for mcpdm until the optional external clocks are
handled in the in the following patch.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# b11c1ea1 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Move rstctrl reset to happen later

We can do the rsstctrl a bit later, but need to deassert rstctrl reset
before the clocks are enabled if asserted. Let's only init restctrl
in sysc_init_resets() and do the reset later on just before we enable
the device clocks.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 93de83a2 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Manage clocks for the interconnect target module in all cases

We are currently not managing interconnect target module clocks in the
for legacy platform data based case. This causes a problem for using the
platform data based functions when dropping the platform data for the
interconnect target module configuration.

To avoid a situation where we need to populate the main and optional
clocks also for the platform data based functions, let's just manage the
clocks directly in ti-sysc driver. This means that until the interconnect
target module confugration platform data is dropped our use count for
clk_enable() will be 2 instead of 1.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# a3e92e7b 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Allocate mdata as needed and do platform data based init later

The platform data based init functions typically reset the interconnect
target module configure the registers. As we may need the interconnect
target module specific quirks configured based on the revision register,
we want to move the platform data based init to happen later.

Let's allocate mdata as needed so it's available for sysc_legacy_init()
that we call with module clocks enabled from sysc_init_module().

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 1a5cd7c2 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Enable all clocks directly during init to read revision

The first thing we want to do is just read the module revision register to
be able to configure the module specific quirks and configure the module
registers.

As the interconnect target module may not yet be properly configured and
may need a reset first, we don't want to use pm_runtime_get() at this
point.

To read the revision register, let's just enable the all the clocks for
the interconnect target module during init even if the optional clocks
are not needed. That way we can read the revision register to configure
the quirks needed for PM runtime.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# d878970f 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add separate functions for handling clocks

At least McPDM module depends on an external optional clock to be
usable. To make handling of the McPDM clock easier in the following
patches, let's add separate functions for handling the main clocks
and the optional clocks.

Let's also add error handling to shut down already enabled clocks
while at it.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# ff43728c 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Move legacy platform data idling into separate functions

Let's move the legacy idle and enable into separate functions to simplify
PM runtime functions a bit.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# b7182b42 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Make functions static

We can make sysc_write() and sysc_child_pm_domain static as noted by
sparse.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 386cb766 22-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle missed no-idle property in addition to no-idle-on-init

We have ti,no-idle in use in addition to ti,no-idle-on-init but we're
missing handling for it in the ti-sysc interconnect target module driver.

Let's also group the idle defines together and update the binding
documentation for it.

Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# aaa29bb0 21-Mar-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix sysc_unprepare() when no clocks have been allocated

If we return early before ddata->clocks have been allocated we will get a
NULL pointer dereference in sysc_unprepare(). Let's fix this by returning
early when no clocks are allocated.

Fixes: 0eecc636e5a2 ("bus: ti-sysc: Add minimal TI sysc interconnect target driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 9bd34c63 22-Jan-2019 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix timer handling with drop pm_runtime_irq_safe()

Commit 84badc5ec5fc ("ARM: dts: omap4: Move l4 child devices to probe
them with ti-sysc") started producing a warning for pwm-omap-dmtimer:

WARNING: CPU: 0 PID: 77 at drivers/bus/omap_l3_noc.c:147
l3_interrupt_handler+0x2f8/0x388
44000000.ocp:L3 Custom Error: MASTER MPU TARGET L4PER2 (Idle):
Data Access in Supervisor mode during Functional access
...
__pm_runtime_idle
omap_dm_timer_disable
pwm_omap_dmtimer_start
pwm_omap_dmtimer_enable
pwm_apply_state
pwm_vibrator_start
pwm_vibrator_play_work

This is because the timer that pwm-omap-dmtimer is using is now being
probed with ti-sysc interconnect target module instead of omap_device
and the ti-sysc quirk for SYSC_QUIRK_LEGACY_IDLE is not fully
compatible with what omap_device has been doing.

We could fix this by reverting the timer changes and have the timer
probe again with omap_device. Or we could add more quirk handling to
ti-sysc driver. But as these options don't work nicely as longer term
solutions, let's just make timers probe with ti-sysc without any
quirks.

To do this, all we need to do is remove quirks for timers for ti-sysc,
and drop the bogus pm_runtime_irq_safe() flag for timer-ti-dm.

We should not use pm_runtime_irq_safe() anyways for drivers as it will
take a permanent use count on the parent device blocking the parent
devices from idling and has been forcing ti-sysc driver to use a
quirk flag.

Note that we will move the timer data to DEBUG section later on in
clean-up patches.

Fixes: 84badc5ec5fc ("ARM: dts: omap4: Move l4 child devices to probe them with ti-sysc")
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Keerthy <j-keerthy@ti.com>
Cc: Ladislav Michl <ladis@linux-mips.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Tero Kristo <t-kristo@ti.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Tested-By: Andreas Kemnade <andreas@kemnade.info>
Tested-By: H. Nikolaus Schaller <hns@goldelico.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4014c08b 10-Dec-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Check for no-reset and no-idle flags at the child level

With ti-sysc, we need to now have the device tree properties for
ti,no-reset-on-init and ti,no-idle-on-init at the module level instead
of the child device level.

Let's check for these properties at the child device level to enable
quirks, and warn about moving the properties to the module level.

Otherwise am335x-evm based boards tagging gpio1 with ti,no-reset-on-init
will have their DDR power disabled if wired up in such a tricky way.

Note that this should not be an issue for earlier kernels as we don't
rely on this until the dts files have been updated to probe with ti-sysc
interconnect target driver.

Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reported-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# f0106700 15-Nov-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect devices for debug on omap5

We want to see the names of detected devices when DEBUG is enabled.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 2c63a833 15-Nov-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add mcasp optional clocks flag

We have OPT_CLKS_NEEDED in legacy platform data, but it's missing
from the ti-sysc driver for device tree based configuration.

In order to pass OPT_CLKS_NEEDED quirk flag we need to update omap4 module
data and add a new compatible for dra7 as the module layout is different
from sysc_regbits_omap4_mcasp.

Fixes: 70a65240efb1 ("bus: ti-sysc: Add register bits for interconnect
target modules")
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 7b4f8ac2 15-Nov-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix getting optional clocks in clock_roles

We can have holes in clock_roles with interface clock missing for
example. Currently getting an optional clock will fail if there are
only a functional clock and an optional clock.

Fixes: 09dfe5810762 ("bus: ti-sysc: Add handling for clkctrl opt clocks")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# f5e80203 01-Oct-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Just use SET_NOIRQ_SYSTEM_SLEEP_PM_OPS

As Grygorii Strashko pointed out, the runtime PM use count of the
children can be whatever at suspend and we should not use it. So
let's just suspend ti-sysc at noirq level and get rid of some code.

Let's also remove the PM_SLEEP ifdef and use __maybe_unused as the
PM code already deals with the ifdefs.

Suggested-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# f9490783 28-Sep-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Make some warnings debug only

We're currently warning about busy children on suspend in
sysc_child_suspend_noirq() but the legacy code omap_device does
not do that. Let's just make it dev_dbg() instead of dev_warn().

Signed-off-by: Tony Lindgren <tony@atomide.com>


# c6eb4af3 27-Sep-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect devices for debug on dra7

We want to see the names of detected devices when DEBUG is enabled.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 3a3d802b 27-Sep-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect timer and gpio on dra7

We need to detect timer and gpio on dra7 because of the
SYSC_QUIRK_LEGACY_IDLE flag for suspend and resume.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 23731eac 24-Sep-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect devices on am335x when DEBUG is enabled

When debug is enabled, we want to see what devices we're detecting
to make things a bit easier for us.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 1ba30693 24-Sep-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect more devices on am473x for debugging

When debug is enabled, we want to see what devices we're detecting
to make things a bit easier for us. Many of these devices will also
be available on am335x and dra7, and some just need updating the
revision register mask.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# b82beef5 24-Sep-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Update revision masks to support am437x

We need to detect few new devices to tag for noirq_suspend and
pm_runtime_irq_safe to avoid causing regressions compared to
legacy platform data booting.

Let's update i2c, gpio, uart and wdt revision masks to detect
them on am437x. Note that we can remove the second wdt entry
with the updated mask. Note that we also have some uarts with
a different revision register.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 40d9f912 24-Sep-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Defer suspend as needed

We don't care when we suspend but some our children do. In order to
avoid tagging various modules with SYSC_QUIRK_RESOURCE_PROVIDER, let's
do it automatically by tagging modules that are busy on suspend for
noirq suspend. This way we can just do module detection on define DEBUG.

Note that we still need to keep SYSC_QUIRK_LEGACY_IDLE flag around so
the our legacy single-child devices that set pm_runtime_irq_safe() can
manage the interconnect target module themselves.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 4f3530f4 08-Aug-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix no_console_suspend handling

If no_console_suspend is set, we should keep console enabled during suspend.
Lets fix this by only producing a warning if we can't idle hardware during
suspend.

Fixes: ef55f8215a78 ("bus: ti-sysc: Improve suspend and resume handling")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 0ef8e3bb 08-Aug-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix module register ioremap for larger offsets

We can have the interconnect target module control registers pretty
much anywhere within the module range. The current code attempts an
incomplete optimization of the ioremap size but does it wrong and
it only works for registers at the beginning of the module.

Let's just use the largest control register to calculate the ioremap
size. The ioremapped range is for most part cached anyways so there
is no need for size optimization. Let's also update the comments
accordingly.

Fixes: 0eecc636e5a2 ("bus: ti-sysc: Add minimal TI sysc interconnect
target driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 596e7955 09-Jul-2018 Faiz Abbas <faiz_abbas@ti.com>

bus: ti-sysc: Add support for software reset

Add support for the software reset of a target interconnect
module using its sysconfig and sysstatus registers.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
[tony@atomide.com: updated to check if sysconfig exists]
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 7f35e63d 09-Jul-2018 Faiz Abbas <faiz_abbas@ti.com>

bus: ti-sysc: Add support for using ti-sysc for MCAN on dra76x

The dra76x MCAN generic interconnect module has a its own
format for the bits in the control registers.

Therefore add a new module type, new regbits and new capabilities
specific to the MCAN module.

Acked-by: Rob Herring <robh@kernel.org>
CC: Tony Lindgren <tony@atomide.com>
Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 20749051 18-Jun-2018 Kees Cook <keescook@chromium.org>

bus: ti-sysc: Use 2-factor allocator arguments

This adjusts the allocator calls to use 2-factor argument call style, as
done treewide already for improved defense against allocation overflows.

Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# c97c8620 18-May-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix optional clocks array access

We should be checking ddata->clocks[i] instead of clock_names[i]
for the optional clocks. Currently this just happens to work for
the typical case of one fck and one optional clock.

Fixes: 09dfe5810762 ("bus: ti-sysc: Add handling for clkctrl opt clocks")
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# dc4c85ea 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Show module information for suspend if DEBUG is enabled

Let's show module info if DEBUG is enabled to make it easier to follow
what happens on the suspend and resume path.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 7e27e5d0 20-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Tag sdio and wdt with legacy mode for suspend

Looks like these two device drivers don't yet behave properly for suspend
unless configured with the legacy option.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# d708bb14 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect UARTs for SYSC_QUIRK_LEGACY_IDLE quirk on omap4

Starting with omap4, UARTs have different revision register that we need to
detect to enable SYSC_QUIRK_LEGACY_IDLE. Otherwise UARTs won't idle properly.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 8cde5d5f 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect omap4 type timers for quirk

Starting with omap4 some timers have different sysc registers (type2) compared
to the omap2 timers (type1). We need to detect these to enable the quirk for
SYSC_QUIRK_LEGACY_IDLE, otherwise these won't be idling properly.

Siganed-off-by: Tony Lindgren <tony@atomide.com>


# 5062236e 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add initial support for external resets

Some modules need to use external resets in the rstctrl bits. Typically
only one of the rstctrl bits is for the interconnect target module while
the others are for various child devices.

For ti-sysc driver, we just need the module rstctrl bit mapped. The rest
of the rstctrl bits can be directly mapped to the child devices.

Cc: Suman Anna <s-anna@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# ef55f821 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Improve suspend and resume handling

Based on testing with more devices I noticed that some devices
don't suspend or resume properly. We need to PM runtime suspend
and resume devices if we have ddata->needs_resume set.

Let's also improve the error handling and add few debug statements
to make it easier to notice suspend and resume related issues if
DEBUG is set.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# e7420c2d 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Tag some modules resource providers for noirq suspend

Modules that provide resources for other modules need to be suspended
and resumed in the noirq calls. Tag the resource providing modules.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 09dfe581 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add handling for clkctrl opt clocks

There can be up to eight optional device functional gate gate clocks for
each clkctrl instance in clkctrl register bits 8 to 15. Some of them are
only needed for module level reset while others may always be needed
during use. Let's add support for those and update the binding doc
accordingly.

Note that the optional clkctrl mux and divider clocks starting at bit 20
can be directly mapped to the child devices, and ti-sysc does not need to
manage those.

And as GPIOs need the optional clocks for reset, we can now add it with
SYSC_QUIRK_OPT_CLKS_IN_RESET.

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Tero Kristo <t-kristo@ti.com>
Cc: devicetree@vger.kernel.org
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 8b2830ba 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Make child clock alias handling more generic

In order to prepare supporting clkctrl optional clocks, we need to
make the current child clock handling more generic so we can use the
clock role names for the optional clocks in the following patch.

Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# c4bebea8 16-Apr-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle simple-bus for nested children

Otherwise child devices that some interconnect target module devices
have won't probe using simple-bus.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# a885f0fe 22-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle some devices in omap_device compatible way

Now that ti-sysc can manage child devices, we must also be backwards
compatible with the current omap_device code. With omap_device, we
assume that the child device manages the interconnect target module
directly.

The drivers needing special handling are the ones that still set
pm_runtime_irq_safe(). In the long run we want to update those drivers
as otherwise they will cause problems with genpd as a permanent PM
runtime usage count is set on the parent device.

We can handle omap_device these devices by improving the ti-sysc quirk
handling to detect the devices needing special handling based on
register map and revision register if usable. We also need to implement
dev_pm_domain for these child devices just like omap_device does.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# ef70b0bd 22-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add support for platform data callbacks

We want to pass the device tree configuration for interconnect target
modules from ti-sysc driver to the existing platform hwmod code.

This allows us to first validate the dts data against the existing
platform data before we start dropping the platform data in favor of
device tree data.

To do this, let's add platform data callbacks for PM runtime functions
to call for the interconnect target modules if platform data is
available.

Note that as ti-sysc driver can rebind, omap_auxdata_lookup and related
functions can no longer be __init.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# dd57ac1e 22-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Remove unnecessary debugging statements

We already show the status for the interconnect target module
when debugging is enabled, there's no need to be more verbose
about that. So let's just cut down the noise and remove the
extra debug statements.

Signed-off-by: Tony Lindgren <tony@atomide.coM>


# 76f0f772 23-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Improve handling for no-reset-on-init and no-idle-on-init

At least earlycon needs a delayed idle before the 8250 driver probes
to avoid glitches in the console output. Let's handle the delayed idle
for devices tagged with ti,no-reset-on-init and ti,no-idle-on-init with
delayed_work. Others don't need it, and there should be no need to use
runtime PM autosuspend for the interconnect target driver as it's the
child device drivers that should configure it.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 3bb37c8e 22-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle stdout-path for debug console

If we have stdout-path specified for earlycon, we must prevent
the debug console from idling until runtime PM kicks in.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 62020f23 22-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add suspend and resume handling

This allows us to idle the module on suspend after the children
are suspended.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 2c355ff6 22-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add fck clock alias for children with notifier_block

The functional clock is used by several child device drivers to query
the rate for the child device internal configuration. The functional
clock is really for the whole interconnect target module, and not just
for the child device, and can also be shared across multiple children.
At least the timers, i2c and mmc driver query the fck for rate.

So let's just create a clock alias for the child fck if it does not
yet exits. We can do this with the BUS_NOTIFY_ADD_DEVICE before the
child is probed.

Note that we need to now also remove the legacy mode check for getting
the dts clocks in ti-sysc driver.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# d39b6ea4 15-Feb-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix checking of no-reset-on-init quirk

We are currently only checking for the first entry in the table while
we should check them all. Usual no-idle-on-init is together with
no-reset-on-init, so this has gone unnoticed.

Fixes: 566a9b05e1fa ("bus: ti-sysc: Handle module quirks based dts
configuration")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 3267c081 22-Jan-2018 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix smartreflex sysc mask

The enawakeup bit is in a different location for smartreflex compared
to the "ti,sysc-omap2" compatible.

Fixes: 70a65240efb1 ("bus: ti-sysc: Add register bits for interconnect
target modules")
Signed-off-by: Tony Lindgren <tony@atomide.com>


# c5a2de97 15-Dec-2017 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add parsing of module capabilities

We need to configure the interconnect target module based on the
device three configuration.

Let's also add a new quirk for SYSC_QUIRK_RESET_STATUS to indicate
that the SYSCONFIG reset bit changes after the reset is done.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 566a9b05 15-Dec-2017 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Handle module quirks based dts configuration

Let's configure few module quirks via device tree using the
properties for "ti,no-idle-on-init", "ti,no-reset-on-init"
and "ti,sysc-delay-us".

Let's also reorder the probe a bit so we have pdata available
earlier, and move the PM runtime calls to sysc_init_module()
from sysc_read_revision().

Signed-off-by: Tony Lindgren <tony@atomide.com>


# a7199e2b 15-Dec-2017 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Detect i2c interconnect target module based on register layout

We can easily detect i2c based on it's non-standard module registers that
consist of two 32-bit registers accessed in 16-bit mode.

So far we don't have other 16-bit modules, so there's currently no need
to add a custom property for 16-bit register access.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 70a65240 15-Dec-2017 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add register bits for interconnect target modules

Let's add data for the known interconnect target module types by mapping
their register bits.

Note that we can handle many quirks for the older omap2 type1 modules
directly in the driver without a need for adding custom properties.

Signed-off-by: Tony Lindgren <tony@atomide.com>


# 684be5a4 13-Oct-2017 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Fix unbalanced pm_runtime_enable by adding remove

Looks like we're missing remove() that's needed if a driver instance
rebound. Otherwise we will get "Unbalanced pm_runtime_enable!".

Signed-off-by: Tony Lindgren <tony@atomide.com>


# a4a5d493 13-Oct-2017 Arnd Bergmann <arnd@arndb.de>

bus: ti-sysc: mark PM functions as __maybe_unused

The new bus driver causes a harmless compile-time warning when
CONFIG_PM is disabled:

drivers/bus/ti-sysc.c:440:12: error: 'sysc_runtime_resume' defined but not used [-Werror=unused-function]
static int sysc_runtime_resume(struct device *dev)
^~~~~~~~~~~~~~~~~~~
drivers/bus/ti-sysc.c:421:12: error: 'sysc_runtime_suspend' defined but not used [-Werror=unused-function]
static int sysc_runtime_suspend(struct device *dev)
^~~~~~~~~~~~~~~~~~~~

This marks the two unused functions as __maybe_unused to shut up
that warning.

Fixes: 0eecc636e5a2 ("bus: ti-sysc: Add minimal TI sysc interconnect target driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Tony Lindgren <tony@atomide.com>


# 0eecc636 10-Oct-2017 Tony Lindgren <tony@atomide.com>

bus: ti-sysc: Add minimal TI sysc interconnect target driver

We can handle the sysc interconnect target module in a generic way
for many TI SoCs. Initially let's just enable runtime PM with
autosuspend, and probe the children. This can already be used for
idling interconnect target modules that don't have any device driver
available for the child devices.

For now, the "ti,hwmods" custom binding is still required. That will
be eventually deprecated in later patches. And more features will be
added, such as parsing for sysc capabilities so we can continue
removing the legacy platform data.

Cc: Benoît Cousson <bcousson@baylibre.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Matthijs van Duin <matthijsvanduin@gmail.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Tero Kristo <t-kristo@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Tony Lindgren <tony@atomide.com>