Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b9334ac authored by Pawel Moll's avatar Pawel Moll
Browse files

mfd: vexpress: Convert custom func API to regmap



Components of the Versatile Express platform (configuration
microcontrollers on motherboard and daughterboards in particular)
talk to each other over a custom configuration bus. They
provide miscellaneous functions (from clock generator control
to energy sensors) which are represented as platform devices
(and Device Tree nodes). The transactions on the bus can
be generated by different "bridges" in the system, some
of which are universal for the whole platform (for the price
of high transfer latencies), others restricted to a subsystem
(but much faster).

Until now drivers for such functions were using custom "func"
API, which is being replaced in this patch by regmap calls.
This required:

* a rework (and move to drivers/bus directory, as suggested
  by Samuel and Arnd) of the config bus core, which is much
  simpler now and uses device model infrastructure (class)
  to keep track of the bridges; non-DT case (soon to be
  retired anyway) is simply covered by a special device
  registration function

* the new config-bus driver also takes over device population,
  so there is no need for special matching table for
  of_platform_populate nor "simple-bus" hack in the arm64
  model dtsi file (relevant bindings documentation has
  been updated); this allows all the vexpress devices
  fit into normal device model, making it possible
  to remove plenty of early inits and other hacks in
  the near future

* adaptation of the syscfg bridge implementation in the
  sysreg driver, again making it much simpler; there is
  a special case of the "energy" function spanning two
  registers, where they should be both defined in the tree
  now, but backward compatibility is maintained in the code

* modification of the relevant drivers:

  * hwmon - just a straight-forward API change
  * power/reset driver - API change
  * regulator - API change plus error handling
    simplification
  * osc clock driver - this one required larger rework
    in order to turn in into a standard platform driver

Signed-off-by: default avatarPawel Moll <pawel.moll@arm.com>
Acked-by: default avatarMark Brown <broonie@linaro.org>
Acked-by: default avatarLee Jones <lee.jones@linaro.org>
Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
Acked-by: default avatarMike Turquette <mturquette@linaro.org>
parent c6e126de
Loading
Loading
Loading
Loading
+32 −11
Original line number Diff line number Diff line
@@ -27,24 +27,45 @@ Example:
This block also can also act a bridge to the platform's configuration
bus via "system control" interface, addressing devices with site number,
position in the board stack, config controller, function and device
numbers - see motherboard's TRM for more details.

The node describing a config device must refer to the sysreg node via
"arm,vexpress,config-bridge" phandle (can be also defined in the node's
parent) and relies on the board topology properties - see main vexpress
node documentation for more details. It must also define the following
property:
- arm,vexpress-sysreg,func : must contain two cells:
  - first cell defines function number (eg. 1 for clock generator,
    2 for voltage regulators etc.)
  - device number (eg. osc 0, osc 1 etc.)
numbers - see motherboard's TRM for more details. All configuration
controller accessible via this interface must reference the sysreg
node via "arm,vexpress,config-bridge" phandle and define appropriate
topology properties - see main vexpress node documentation for more
details. Each child of such node describes one function and must
define the following properties:
- compatible value : must be one of (corresponding to the TRM):
	"arm,vexpress-amp"
	"arm,vexpress-dvimode"
	"arm,vexpress-energy"
	"arm,vexpress-muxfpga"
	"arm,vexpress-osc"
	"arm,vexpress-power"
	"arm,vexpress-reboot"
	"arm,vexpress-reset"
	"arm,vexpress-scc"
	"arm,vexpress-shutdown"
	"arm,vexpress-temp"
	"arm,vexpress-volt"
- arm,vexpress-sysreg,func : must contain a set of two cells long groups:
  - first cell of each group defines the function number
    (eg. 1 for clock generator, 2 for voltage regulators etc.)
  - second cell of each group defines device number (eg. osc 0,
    osc 1 etc.)
  - some functions (eg. energy meter, with its 64 bit long counter)
    are using more than one function/device number pair

Example:
	mcc {
		compatible = "arm,vexpress,config-bus";
		arm,vexpress,config-bridge = <&v2m_sysreg>;

		osc@0 {
			compatible = "arm,vexpress-osc";
			arm,vexpress-sysreg,func = <1 0>;
		};

		energy@0 {
			compatible = "arm,vexpress-energy";
			arm,vexpress-sysreg,func = <13 0>, <13 1>;
		};
	};
+10 −5
Original line number Diff line number Diff line
@@ -80,12 +80,17 @@ but also control clock generators, voltage regulators, gather
environmental data like temperature, power consumption etc. Even
the video output switch (FPGA) is controlled that way.

Nodes describing devices controlled by this infrastructure should
point at the bridge device node:
The controllers are not mapped into normal memory address space
and must be accessed through bridges - other devices capable
of generating transactions on the configuration bus.

The nodes describing configuration controllers must define
the following properties:
- compatible value:
	compatible = "arm,vexpress,config-bus";
- bridge phandle:
	arm,vexpress,config-bridge = <phandle>;
This property can be also defined in a parent node (eg. for a DCC)
and is effective for all children.
and children describing available functions.


Platform topology
@@ -197,7 +202,7 @@ Example of a VE tile description (simplified)
	};

	dcc {
		compatible = "simple-bus";
		compatible = "arm,vexpress,config-bus";
		arm,vexpress,config-bridge = <&v2m_sysreg>;

		osc@0 {
+3 −2
Original line number Diff line number Diff line
@@ -312,6 +312,7 @@
			arm,vexpress-sysreg,func = <12 0>;
			label = "A15 Pcore";
		};

		power@1 {
			/* Total power for the three A7 cores */
			compatible = "arm,vexpress-power";
@@ -322,14 +323,14 @@
		energy@0 {
			/* Total energy for the two A15 cores */
			compatible = "arm,vexpress-energy";
			arm,vexpress-sysreg,func = <13 0>;
			arm,vexpress-sysreg,func = <13 0>, <13 1>;
			label = "A15 Jcore";
		};

		energy@2 {
			/* Total energy for the three A7 cores */
			compatible = "arm,vexpress-energy";
			arm,vexpress-sysreg,func = <13 2>;
			arm,vexpress-sysreg,func = <13 2>, <13 3>;
			label = "A7 Jcore";
		};
	};
+6 −4
Original line number Diff line number Diff line
@@ -128,6 +128,10 @@ static struct platform_device pmu_device = {
	.resource	= pmu_resources,
};

static struct clk_lookup osc1_lookup = {
	.dev_id		= "ct:clcd",
};

static struct platform_device osc1_device = {
	.name		= "vexpress-osc",
	.id		= 1,
@@ -135,6 +139,7 @@ static struct platform_device osc1_device = {
	.resource	= (struct resource []) {
		VEXPRESS_RES_FUNC(0xf, 1),
	},
	.dev.platform_data = &osc1_lookup,
};

static void __init ct_ca9x4_init(void)
@@ -155,10 +160,7 @@ static void __init ct_ca9x4_init(void)
		amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);

	platform_device_register(&pmu_device);
	platform_device_register(&osc1_device);

	WARN_ON(clk_register_clkdev(vexpress_osc_setup(&osc1_device.dev),
			NULL, "ct:clcd"));
	vexpress_sysreg_config_device_register(&osc1_device);
}

#ifdef CONFIG_SMP
+6 −12
Original line number Diff line number Diff line
@@ -340,11 +340,6 @@ static void __init v2m_init(void)
	regulator_register_fixed(0, v2m_eth_supplies,
			ARRAY_SIZE(v2m_eth_supplies));

	platform_device_register(&v2m_muxfpga_device);
	platform_device_register(&v2m_shutdown_device);
	platform_device_register(&v2m_reboot_device);
	platform_device_register(&v2m_dvimode_device);

	platform_device_register(&v2m_sysreg_device);
	platform_device_register(&v2m_pcie_i2c_device);
	platform_device_register(&v2m_ddc_i2c_device);
@@ -356,6 +351,11 @@ static void __init v2m_init(void)
	for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
		amba_device_register(v2m_amba_devs[i], &iomem_resource);

	vexpress_sysreg_config_device_register(&v2m_muxfpga_device);
	vexpress_sysreg_config_device_register(&v2m_shutdown_device);
	vexpress_sysreg_config_device_register(&v2m_reboot_device);
	vexpress_sysreg_config_device_register(&v2m_dvimode_device);

	ct_desc->init_tile();
}

@@ -423,17 +423,11 @@ void __init v2m_dt_init_early(void)
	versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000);
}

static const struct of_device_id v2m_dt_bus_match[] __initconst = {
	{ .compatible = "simple-bus", },
	{ .compatible = "arm,amba-bus", },
	{ .compatible = "arm,vexpress,config-bus", },
	{}
};

static void __init v2m_dt_init(void)
{
	l2x0_of_init(0x00400000, 0xfe0fffff);
	of_platform_populate(NULL, v2m_dt_bus_match, NULL, NULL);
	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}

static const char * const v2m_dt_match[] __initconst = {
Loading