clk: meson: meson8b: use the HHI syscon if available

The clock controller is located in a register range (called "HHI") which
contains more than just registers for the clock controller. Known
consumers of the HHI register range are:
- the clock controller
- a reset controller
- temperature sensor calibration coefficient (TSC) (only on Meson8b and
  Meson8m2)
- HDMI controller

The main reason for using a syscon is the "temperature sensor
calibration coefficient" which has to be set for the built-in temperature
sensor to work correctly. Four TSC bits are located in the SAR ADC's
register space. However on Meson8b and Meson8m2 there is a fifth TSC bit
which is unfortunately located in the HHI register space. To be more
precise, bit 9 of the HHI_DPLL_TOP_0 register (which sits right between
the HHI_SYS_PLL and HHI_VID_PLL registers).

Get the regmap from the parent (HHI syscon) node to support all
functionality of the HHI register range. Backwards compatibility with
old .dtbs is ensured by falling back to parsing the registers just like
before this change.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lkml.kernel.org/r/20181028120859.5735-3-martin.blumenstingl@googlemail.com
This commit is contained in:
Martin Blumenstingl 2018-10-28 13:08:58 +01:00 committed by Neil Armstrong
parent 6c76307716
commit bb6eddd1d2
1 changed files with 15 additions and 9 deletions

View File

@ -10,6 +10,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mfd/syscon.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/reset-controller.h> #include <linux/reset-controller.h>
#include <linux/slab.h> #include <linux/slab.h>
@ -1114,6 +1115,10 @@ static void __init meson8b_clkc_init(struct device_node *np)
struct regmap *map; struct regmap *map;
int i, ret; int i, ret;
map = syscon_node_to_regmap(of_get_parent(np));
if (IS_ERR(map)) {
pr_info("failed to get HHI regmap - Trying obsolete regs\n");
/* Generic clocks, PLLs and some of the reset-bits */ /* Generic clocks, PLLs and some of the reset-bits */
clk_base = of_iomap(np, 1); clk_base = of_iomap(np, 1);
if (!clk_base) { if (!clk_base) {
@ -1124,6 +1129,7 @@ static void __init meson8b_clkc_init(struct device_node *np)
map = regmap_init_mmio(NULL, clk_base, &clkc_regmap_config); map = regmap_init_mmio(NULL, clk_base, &clkc_regmap_config);
if (IS_ERR(map)) if (IS_ERR(map))
return; return;
}
rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
if (!rstc) if (!rstc)