Skip to content

Commit

Permalink
Merge tag 'memory-controller-drv-tegra-5.11-3' of git://git.kernel.or…
Browse files Browse the repository at this point in the history
…g/pub/scm/linux/kernel/git/krzk/linux-mem-ctrl into arm/drivers

Memory controller drivers for v5.11 - Tegra SoC, part two

Continuation of work on Tegra SoC memory controllers towards adding
interconnect support and integration with devfreq.

This brings few more patches including one which removes/fixes annoying
warning if the DTS patches get applied.  This is expected and only
informs that new features of Tegra memory controller drivers will not be
enabled however the warning itself could look worrying.

* tag 'memory-controller-drv-tegra-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-mem-ctrl:
  memory: tegra30: Support interconnect framework
  memory: tegra20: Support hardware versioning and clean up OPP table initialization
  dt-bindings: memory: tegra20-emc: Document opp-supported-hw property

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnd Bergmann <[email protected]>
  • Loading branch information
arndb committed Dec 8, 2020
2 parents c35ffce + d76fa3f commit 694a5b5
Show file tree
Hide file tree
Showing 5 changed files with 522 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Properties:
- #interconnect-cells : Should be 0.
- operating-points-v2: See ../bindings/opp/opp.txt for details.

For each opp entry in 'operating-points-v2' table:
- opp-supported-hw: One bitfield indicating SoC process ID mask

A bitwise AND is performed against this value and if any bit
matches, the OPP gets enabled.

Optional properties:
- core-supply: Phandle of voltage regulator of the SoC "core" power domain.

Expand Down
1 change: 1 addition & 0 deletions drivers/memory/tegra/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ config TEGRA30_EMC
tristate "NVIDIA Tegra30 External Memory Controller driver"
default y
depends on TEGRA_MC && ARCH_TEGRA_3x_SOC
select PM_OPP
help
This driver is for the External Memory Controller (EMC) found on
Tegra30 chips. The EMC controls the external DRAM on the board.
Expand Down
48 changes: 20 additions & 28 deletions drivers/memory/tegra/tegra20-emc.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,43 +910,36 @@ static int tegra_emc_interconnect_init(struct tegra_emc *emc)

static int tegra_emc_opp_table_init(struct tegra_emc *emc)
{
struct opp_table *reg_opp_table = NULL, *clk_opp_table;
const char *rname = "core";
u32 hw_version = BIT(tegra_sku_info.soc_process_id);
struct opp_table *clk_opp_table, *hw_opp_table;
int err;

/*
* Legacy device-trees don't have OPP table and EMC driver isn't
* useful in this case.
*/
if (!device_property_present(emc->dev, "operating-points-v2")) {
dev_err(emc->dev,
"OPP table not found, please update your device tree\n");
return -ENODEV;
}

/* voltage scaling is optional */
if (device_property_present(emc->dev, "core-supply")) {
reg_opp_table = dev_pm_opp_set_regulators(emc->dev, &rname, 1);
if (IS_ERR(reg_opp_table))
return dev_err_probe(emc->dev, PTR_ERR(reg_opp_table),
"failed to set OPP regulator\n");
}

clk_opp_table = dev_pm_opp_set_clkname(emc->dev, NULL);
err = PTR_ERR_OR_ZERO(clk_opp_table);
if (err) {
dev_err(emc->dev, "failed to set OPP clk: %d\n", err);
goto put_reg_table;
return err;
}

err = dev_pm_opp_of_add_table(emc->dev);
hw_opp_table = dev_pm_opp_set_supported_hw(emc->dev, &hw_version, 1);
err = PTR_ERR_OR_ZERO(hw_opp_table);
if (err) {
dev_err(emc->dev, "failed to add OPP table: %d\n", err);
dev_err(emc->dev, "failed to set OPP supported HW: %d\n", err);
goto put_clk_table;
}

dev_info(emc->dev, "current clock rate %lu MHz\n",
clk_get_rate(emc->clk) / 1000000);
err = dev_pm_opp_of_add_table(emc->dev);
if (err) {
if (err == -ENODEV)
dev_err(emc->dev, "OPP table not found, please update your device tree\n");
else
dev_err(emc->dev, "failed to add OPP table: %d\n", err);

goto put_hw_table;
}

dev_info(emc->dev, "OPP HW ver. 0x%x, current clock rate %lu MHz\n",
hw_version, clk_get_rate(emc->clk) / 1000000);

/* first dummy rate-set initializes voltage state */
err = dev_pm_opp_set_rate(emc->dev, clk_get_rate(emc->clk));
Expand All @@ -959,11 +952,10 @@ static int tegra_emc_opp_table_init(struct tegra_emc *emc)

remove_table:
dev_pm_opp_of_remove_table(emc->dev);
put_hw_table:
dev_pm_opp_put_supported_hw(hw_opp_table);
put_clk_table:
dev_pm_opp_put_clkname(clk_opp_table);
put_reg_table:
if (reg_opp_table)
dev_pm_opp_put_regulators(reg_opp_table);

return err;
}
Expand Down
Loading

0 comments on commit 694a5b5

Please sign in to comment.