aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bus/ti-sysc.c
AgeCommit message (Collapse)Author
2020-09-04bus: ti-sysc: Add missing quirk flags for usb_host_hsTony Lindgren
commit 4254632dba27271f6de66efd87e444ee405dee29 upstream. 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> [PG: use -1 vs. -ENODEV ; see v5.7-rc1~99^2~5^2~11.] Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2020-07-16bus: ti-sysc: Flush posted write on enable and disableTony Lindgren
commit 5ce8aee81be6c8bc19051d7c7b0d3cbb7ac5fc3f upstream. 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> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2020-04-12bus: ti-sysc: Fix iterating over clocksTony Lindgren
commit 2c81f0f6d3f52ac222a5dc07a6e5c06e1543e88b upstream. 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> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2019-09-21bus: ti-sysc: Simplify cleanup upon failures in sysc_probe()Suman Anna
[ Upstream commit a304f483b6b00d42bde41c45ca52c670945348e2 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-09-21ARM: dts: Fix incorrect dcan register mapping for am3, am4 and dra7Tony Lindgren
[ Upstream commit 89bbc6f1eb90809b1538b3a9c54030c558180e3b ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-09-21bus: ti-sysc: Fix using configured sysc mask valueTony Lindgren
[ Upstream commit e212abd452a4af3174fcd469d46656f83e135a19 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-09-21bus: ti-sysc: Fix handling of forced idleTony Lindgren
[ Upstream commit 6ee8241d17c68b94a91efabfd6bdfe63bb1b79c1 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-02bus: ti-sysc: Handle devices with no control registersTony Lindgren
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>
2019-04-09bus: ti-sysc: Add generic enable/disable functionsRoger Quadros
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>
2019-04-05bus: ti-sysc: Detect DMIC for debuggingTony Lindgren
Detect DMIC to see what we have connected if config DEBUG is enabled. Signed-off-by: Tony Lindgren <tony@atomide.com>
2019-04-05bus: ti-sysc: Handle swsup idle mode quirksTony Lindgren
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>
2019-04-03bus: ti-sysc: Add quirk handling for external optional functional clockTony Lindgren
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>
2019-04-03bus: ti-sysc: Add support for early quirks based on register addressTony Lindgren
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>
2019-04-03bus: ti-sysc: Move rstctrl reset to happen laterTony Lindgren
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>
2019-04-03bus: ti-sysc: Manage clocks for the interconnect target module in all casesTony Lindgren
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>
2019-04-03bus: ti-sysc: Allocate mdata as needed and do platform data based init laterTony Lindgren
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>
2019-04-03bus: ti-sysc: Enable all clocks directly during init to read revisionTony Lindgren
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>
2019-04-01bus: ti-sysc: Add separate functions for handling clocksTony Lindgren
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>
2019-04-01bus: ti-sysc: Move legacy platform data idling into separate functionsTony Lindgren
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>
2019-04-01bus: ti-sysc: Make functions staticTony Lindgren
We can make sysc_write() and sysc_child_pm_domain static as noted by sparse. Signed-off-by: Tony Lindgren <tony@atomide.com>
2019-04-01bus: ti-sysc: Handle missed no-idle property in addition to no-idle-on-initTony Lindgren
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>
2019-04-01bus: ti-sysc: Fix sysc_unprepare() when no clocks have been allocatedTony Lindgren
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>
2019-01-29Merge branch 'pwm-dmtimer-fixes' into omap-for-v5.0/fixes-v2Tony Lindgren
2019-01-29bus: ti-sysc: Fix timer handling with drop pm_runtime_irq_safe()Tony Lindgren
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>
2018-12-10bus: ti-sysc: Check for no-reset and no-idle flags at the child levelTony Lindgren
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>
2018-11-15bus: ti-sysc: Detect devices for debug on omap5Tony Lindgren
We want to see the names of detected devices when DEBUG is enabled. Signed-off-by: Tony Lindgren <tony@atomide.com>
2018-11-15bus: ti-sysc: Add mcasp optional clocks flagTony Lindgren
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>
2018-11-15bus: ti-sysc: Fix getting optional clocks in clock_rolesTony Lindgren
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>
2018-10-01bus: ti-sysc: Just use SET_NOIRQ_SYSTEM_SLEEP_PM_OPSTony Lindgren
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>
2018-09-28bus: ti-sysc: Make some warnings debug onlyTony Lindgren
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>
2018-09-28bus: ti-sysc: Detect devices for debug on dra7Tony Lindgren
We want to see the names of detected devices when DEBUG is enabled. Signed-off-by: Tony Lindgren <tony@atomide.com>
2018-09-28bus: ti-sysc: Detect timer and gpio on dra7Tony Lindgren
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>
2018-09-28Merge commit '4f3530f4a41d49c41015020cd9a5ed5c95b5d2db' into ↵Tony Lindgren
omap-for-v4.20/ti-sysc
2018-09-24bus: ti-sysc: Detect devices on am335x when DEBUG is enabledTony Lindgren
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>
2018-09-24bus: ti-sysc: Detect more devices on am473x for debuggingTony Lindgren
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>
2018-09-24bus: ti-sysc: Update revision masks to support am437xTony Lindgren
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>
2018-09-24bus: ti-sysc: Defer suspend as neededTony Lindgren
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>
2018-08-28Merge branch 'perm-fix' into omap-for-v4.19/fixes-v2Tony Lindgren
2018-08-22bus: ti-sysc: Fix no_console_suspend handlingTony Lindgren
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>
2018-08-17bus: ti-sysc: Fix module register ioremap for larger offsetsTony Lindgren
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>
2018-07-09bus: ti-sysc: Add support for software resetFaiz Abbas
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>
2018-07-09bus: ti-sysc: Add support for using ti-sysc for MCAN on dra76xFaiz Abbas
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>
2018-07-02bus: ti-sysc: Use 2-factor allocator argumentsKees Cook
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>
2018-05-18bus: ti-sysc: Fix optional clocks array accessTony Lindgren
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>
2018-05-01bus: ti-sysc: Show module information for suspend if DEBUG is enabledTony Lindgren
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>
2018-05-01bus: ti-sysc: Tag sdio and wdt with legacy mode for suspendTony Lindgren
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>
2018-05-01bus: ti-sysc: Detect UARTs for SYSC_QUIRK_LEGACY_IDLE quirk on omap4Tony Lindgren
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>
2018-05-01bus: ti-sysc: Detect omap4 type timers for quirkTony Lindgren
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>
2018-05-01bus: ti-sysc: Add initial support for external resetsTony Lindgren
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>
2018-05-01bus: ti-sysc: Improve suspend and resume handlingTony Lindgren
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>