msm: pcie: add support for PCIe to change its GPIOs settings

The setting of a GPIO varies depending on the state
of PCIe. Therefore, add the support for PCIe to be
able to change the settings of its GPIOs.

Change-Id: If0584a3c5913230b93a7424d62c88c5a974211fa
Signed-off-by: Tony Truong <truong@codeaurora.org>
This commit is contained in:
Tony Truong 2014-12-05 15:12:32 -08:00
parent 04e700e799
commit 47811848e7
2 changed files with 51 additions and 3 deletions

View File

@ -37,10 +37,12 @@ Optional Properties:
- qcom,<supply-name>-voltage-level: specifies voltage levels for supply.
Should be specified in pairs (max, min, optimal), units uV.
- clkreq-gpio: CLKREQ GPIO specified by PCIe spec.
- pinctrl-names: The state name of the pin configuration. Only
support: "default"
- pinctrl-names: The state name of the pin configuration.
supports: "default", "sleep"
- pinctrl-0: For details of pinctrl properties, please refer to:
"Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt"
- pinctrl-1: For details of pinctrl properties, please refer to:
"Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt"
- clocks: list of clock phandles
- clock-names: list of names of clock inputs.
Should be "pcie_0_pipe_clk", "pcie_0_ref_clk_src",
@ -123,8 +125,9 @@ Example:
qcom,vreg-1.8-voltage-level = <1800000 1800000 1000>;
qcom,vreg-0.9-voltage-level = <950000 950000 24000>;
pinctrl-names = "default";
pinctrl-names = "default", "sleep";
pinctrl-0 = <&pcie0_clkreq_default &pcie0_perst_default &pcie0_wake_default>;
pinctrl-1 = <&pcie0_clkreq_sleep &pcie0_perst_sleep &pcie0_wake_sleep>;
clocks = <&clock_gcc clk_gcc_pcie_0_pipe_clk>,
<&clock_rpm clk_ln_bb_clk>,

View File

@ -524,6 +524,10 @@ struct msm_pcie_dev_t {
void *ipc_log;
void *ipc_log_long;
void *ipc_log_dump;
bool use_pinctrl;
struct pinctrl *pinctrl;
struct pinctrl_state *pins_default;
struct pinctrl_state *pins_sleep;
struct msm_pcie_device_info pcidev_table[MAX_DEVICE_NUM];
};
@ -1070,6 +1074,8 @@ static void msm_pcie_show_status(struct msm_pcie_dev_t *dev)
dev->cfg_access ? "" : "not");
pr_alert("use_msi is %d\n",
dev->use_msi);
pr_alert("use_pinctrl is %d\n",
dev->use_pinctrl);
pr_alert("user_suspend is %d\n",
dev->user_suspend);
pr_alert("disable_pc is %d",
@ -4342,6 +4348,7 @@ static int msm_pcie_probe(struct platform_device *pdev)
msm_pcie_dev[rc_idx].wake_counter = 0;
msm_pcie_dev[rc_idx].power_on = false;
msm_pcie_dev[rc_idx].use_msi = false;
msm_pcie_dev[rc_idx].use_pinctrl = false;
msm_pcie_dev[rc_idx].bridge_found = false;
memcpy(msm_pcie_dev[rc_idx].vreg, msm_pcie_vreg_info,
sizeof(msm_pcie_vreg_info));
@ -4376,6 +4383,36 @@ static int msm_pcie_probe(struct platform_device *pdev)
if (ret)
goto decrease_rc_num;
msm_pcie_dev[rc_idx].pinctrl = devm_pinctrl_get(&pdev->dev);
if (IS_ERR_OR_NULL(msm_pcie_dev[rc_idx].pinctrl))
PCIE_ERR(&msm_pcie_dev[rc_idx],
"PCIe: RC%d failed to get pinctrl\n",
rc_idx);
else
msm_pcie_dev[rc_idx].use_pinctrl = true;
if (msm_pcie_dev[rc_idx].use_pinctrl) {
msm_pcie_dev[rc_idx].pins_default =
pinctrl_lookup_state(msm_pcie_dev[rc_idx].pinctrl,
"default");
if (IS_ERR(msm_pcie_dev[rc_idx].pins_default)) {
PCIE_ERR(&msm_pcie_dev[rc_idx],
"PCIe: RC%d could not get pinctrl default state\n",
rc_idx);
msm_pcie_dev[rc_idx].pins_default = NULL;
}
msm_pcie_dev[rc_idx].pins_sleep =
pinctrl_lookup_state(msm_pcie_dev[rc_idx].pinctrl,
"sleep");
if (IS_ERR(msm_pcie_dev[rc_idx].pins_sleep)) {
PCIE_ERR(&msm_pcie_dev[rc_idx],
"PCIe: RC%d could not get pinctrl sleep state\n",
rc_idx);
msm_pcie_dev[rc_idx].pins_sleep = NULL;
}
}
ret = msm_pcie_gpio_init(&msm_pcie_dev[rc_idx]);
if (ret) {
msm_pcie_release_resources(&msm_pcie_dev[rc_idx]);
@ -4626,6 +4663,10 @@ static int msm_pcie_pm_suspend(struct pci_dev *dev,
msm_pcie_disable(pcie_dev, PM_PIPE_CLK | PM_CLK | PM_VREG);
if (pcie_dev->use_pinctrl && pcie_dev->pins_sleep)
pinctrl_select_state(pcie_dev->pinctrl,
pcie_dev->pins_sleep);
return ret;
}
@ -4673,6 +4714,10 @@ static int msm_pcie_pm_resume(struct pci_dev *dev,
PCIE_DBG(pcie_dev, "RC%d\n", pcie_dev->rc_idx);
if (pcie_dev->use_pinctrl && pcie_dev->pins_default)
pinctrl_select_state(pcie_dev->pinctrl,
pcie_dev->pins_default);
spin_lock_irqsave(&pcie_dev->cfg_lock,
pcie_dev->irqsave_flags);
pcie_dev->cfg_access = true;