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

Commit 7f2eba2e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: mark SPMI debug slave devices as can-sleep for SDM845"

parents 5245fb4a db913611
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ Optional properties for peripheral child nodes:
                   see:
                   Documentation/devicetree/bindings/spmi/qcom,spmi-pmic-arb.txt
- interrupt-names: Corresponding interrupt name to the interrupts property
- qcom,can-sleep:  Boolean flag indicating that processes waiting on SPMI
		   transactions may sleep

Each child node of SPMI slave id represents a function of the PMIC. In the
example below the rtc device node represents a peripheral of pm8941
+15 −0
Original line number Diff line number Diff line
@@ -35,6 +35,19 @@ Supported Properties:
		    the corresponding addresses are specified in the reg
		    property.

- clocks
	Usage:      optional
	Value type: <prop-encoded-array>
	Definition: Clock tuple consisting of a phandle to a clock controller
		    device and the clock ID number for the SPMI debug controller
		    clock.

- clock-names
	Usage:      required if clocks property is specified
	Value type: <string>
	Definition: Defines the name of the clock defined in the "clocks"
		    property.  This must be "core_clk".

- #address-cells
	Usage:      required
	Value type: <u32>
@@ -57,6 +70,8 @@ qcom,spmi-debug@6b22000 {
	compatible = "qcom,spmi-pmic-arb-debug";
	reg = <0x6b22000 0x60>, <0x7820A8 4>;
	reg-names = "core", "fuse";
	clocks = <&clock_aop QDSS_CLK>;
	clock-names = "core_clk";
	qcom,fuse-disable-bit = <12>;
	#address-cells = <2>;
	#size-cells = <0>;
+6 −0
Original line number Diff line number Diff line
@@ -770,6 +770,7 @@
			reg = <0x0 SPMI_USID>;
			#address-cells = <2>;
			#size-cells = <0>;
			qcom,can-sleep;
		};

		qcom,pm8998-debug@1 {
@@ -777,6 +778,7 @@
			reg = <0x1 SPMI_USID>;
			#address-cells = <2>;
			#size-cells = <0>;
			qcom,can-sleep;
		};

		qcom,pmi8998-debug@2 {
@@ -784,6 +786,7 @@
			reg = <0x2 SPMI_USID>;
			#address-cells = <2>;
			#size-cells = <0>;
			qcom,can-sleep;
		};

		qcom,pmi8998-debug@3 {
@@ -791,6 +794,7 @@
			reg = <0x3 SPMI_USID>;
			#address-cells = <2>;
			#size-cells = <0>;
			qcom,can-sleep;
		};

		qcom,pm8005-debug@4 {
@@ -798,6 +802,7 @@
			reg = <0x4 SPMI_USID>;
			#address-cells = <2>;
			#size-cells = <0>;
			qcom,can-sleep;
		};

		qcom,pm8005-debug@5 {
@@ -805,6 +810,7 @@
			reg = <0x5 SPMI_USID>;
			#address-cells = <2>;
			#size-cells = <0>;
			qcom,can-sleep;
		};
	};

+13 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2015, 2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -118,11 +118,22 @@ static const struct regmap_config spmi_regmap_config = {
	.fast_io	= true,
};

static const struct regmap_config spmi_regmap_can_sleep_config = {
	.reg_bits	= 16,
	.val_bits	= 8,
	.max_register	= 0xffff,
	.fast_io	= false,
};

static int pmic_spmi_probe(struct spmi_device *sdev)
{
	struct device_node *root = sdev->dev.of_node;
	struct regmap *regmap;

	if (of_property_read_bool(root, "qcom,can-sleep"))
		regmap = devm_regmap_init_spmi_ext(sdev,
						&spmi_regmap_can_sleep_config);
	else
		regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config);
	if (IS_ERR(regmap))
		return PTR_ERR(regmap);
+27 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
 * GNU General Public License for more details.
 */

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
@@ -69,6 +70,7 @@ enum pmic_arb_cmd_op_code {
struct spmi_pmic_arb_debug {
	void __iomem		*addr;
	raw_spinlock_t		lock;
	struct clk		*clock;
};

static inline void pmic_arb_debug_write(struct spmi_pmic_arb_debug *pa,
@@ -181,6 +183,12 @@ static int pmic_arb_debug_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
	else
		return -EINVAL;

	rc = clk_prepare_enable(pa->clock);
	if (rc) {
		pr_err("%s: failed to enable core clock, rc=%d\n",
			__func__, rc);
		return rc;
	}
	raw_spin_lock_irqsave(&pa->lock, flags);

	rc = pmic_arb_debug_issue_command(ctrl, opc, sid, addr, len);
@@ -192,6 +200,7 @@ static int pmic_arb_debug_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
		buf[i] = pmic_arb_debug_read(pa, PMIC_ARB_DEBUG_RDATA(i));
done:
	raw_spin_unlock_irqrestore(&pa->lock, flags);
	clk_disable_unprepare(pa->clock);

	return rc;
}
@@ -221,6 +230,12 @@ static int pmic_arb_debug_write_cmd(struct spmi_controller *ctrl, u8 opc,
	else
		return -EINVAL;

	rc = clk_prepare_enable(pa->clock);
	if (rc) {
		pr_err("%s: failed to enable core clock, rc=%d\n",
			__func__, rc);
		return rc;
	}
	raw_spin_lock_irqsave(&pa->lock, flags);

	/* Write data to FIFO */
@@ -230,6 +245,7 @@ static int pmic_arb_debug_write_cmd(struct spmi_controller *ctrl, u8 opc,
	rc = pmic_arb_debug_issue_command(ctrl, opc, sid, addr, len);

	raw_spin_unlock_irqrestore(&pa->lock, flags);
	clk_disable_unprepare(pa->clock);

	return rc;
}
@@ -293,6 +309,17 @@ static int spmi_pmic_arb_debug_probe(struct platform_device *pdev)
		goto err_put_ctrl;
	}

	if (of_find_property(pdev->dev.of_node, "clock-names", NULL)) {
		pa->clock = devm_clk_get(&pdev->dev, "core_clk");
		if (IS_ERR(pa->clock)) {
			rc = PTR_ERR(pa->clock);
			if (rc != -EPROBE_DEFER)
				dev_err(&pdev->dev, "unable to request core clock, rc=%d\n",
					rc);
			goto err_put_ctrl;
		}
	}

	platform_set_drvdata(pdev, ctrl);
	raw_spin_lock_init(&pa->lock);