clocks = <&clkc CLKID_USB_GENERAL
&clkc CLKID_PCIE_PLL
+ &clkc CLKID_MIPI_ENABLE_GATE
+ &clkc CLKID_MIPI_BANDGAP_GATE
&clkc CLKID_PCIE_A
&clkc CLKID_PCIE_CML_EN0>;
clock-names = "pcie_general",
"pcie_refpll",
+ "pcie_mipi_enable_gate",
+ "pcie_mipi_bandgap_gate",
"pcie",
"port";
/*reset-gpio-type 0:Shared pad(no reset)1:OD pad2:Normal pad*/
clocks = <&clkc CLKID_USB_GENERAL
&clkc CLKID_PCIE_PLL
+ &clkc CLKID_MIPI_ENABLE_GATE
+ &clkc CLKID_MIPI_BANDGAP_GATE
&clkc CLKID_PCIE_B
&clkc CLKID_PCIE_CML_EN1>;
clock-names = "pcie_general",
"pcie_refpll",
+ "pcie_mipi_enable_gate",
+ "pcie_mipi_bandgap_gate",
"pcie",
"port";
/*reset-gpio-type 0:Shared pad(no reset)1:OD pad2:Normal pad*/
clocks = <&clkc CLKID_USB_GENERAL
&clkc CLKID_PCIE_PLL
+ &clkc CLKID_MIPI_ENABLE_GATE
+ &clkc CLKID_MIPI_BANDGAP_GATE
&clkc CLKID_PCIE_A
&clkc CLKID_PCIE_CML_EN0>;
clock-names = "pcie_general",
"pcie_refpll",
+ "pcie_mipi_enable_gate",
+ "pcie_mipi_bandgap_gate",
"pcie",
"port";
/*reset-gpio-type 0:Shared pad(no reset)1:OD pad2:Normal pad*/
clocks = <&clkc CLKID_USB_GENERAL
&clkc CLKID_PCIE_PLL
+ &clkc CLKID_MIPI_ENABLE_GATE
+ &clkc CLKID_MIPI_BANDGAP_GATE
&clkc CLKID_PCIE_B
&clkc CLKID_PCIE_CML_EN1>;
clock-names = "pcie_general",
"pcie_refpll",
+ "pcie_mipi_enable_gate",
+ "pcie_mipi_bandgap_gate",
"pcie",
"port";
/*reset-gpio-type 0:Shared pad(no reset)1:OD pad2:Normal pad*/
clocks = <&clkc CLKID_USB_GENERAL
&clkc CLKID_PCIE_PLL
+ &clkc CLKID_MIPI_ENABLE_GATE
+ &clkc CLKID_MIPI_BANDGAP_GATE
&clkc CLKID_PCIE_A
&clkc CLKID_PCIE_CML_EN0>;
clock-names = "pcie_general",
"pcie_refpll",
+ "pcie_mipi_enable_gate",
+ "pcie_mipi_bandgap_gate",
"pcie",
"port";
/*reset-gpio-type 0:Shared pad(no reset)1:OD pad2:Normal pad*/
clocks = <&clkc CLKID_USB_GENERAL
&clkc CLKID_PCIE_PLL
+ &clkc CLKID_MIPI_ENABLE_GATE
+ &clkc CLKID_MIPI_BANDGAP_GATE
&clkc CLKID_PCIE_B
&clkc CLKID_PCIE_CML_EN1>;
clock-names = "pcie_general",
"pcie_refpll",
+ "pcie_mipi_enable_gate",
+ "pcie_mipi_bandgap_gate",
"pcie",
"port";
/*reset-gpio-type 0:Shared pad(no reset)1:OD pad2:Normal pad*/
if (pll->lock)
spin_unlock_irqrestore(pll->lock, flags);
- /*pcie pll: mipi enable and bandgap share with mipi clk */
- if (!strcmp(clk_hw_get_name(hw), "pcie_pll")) {
- clk_prepare_enable(clks[CLKID_MIPI_ENABLE_GATE]);
- clk_prepare_enable(clks[CLKID_MIPI_BANDGAP_GATE]);
- }
ret = meson_axg_pll_set_rate(hw, rate, clk_get_rate(parent));
if (pll->lock)
spin_unlock_irqrestore(pll->lock, flags);
}
- /*pcie pll: mipi enable and bandgap share with mipi clk */
- if (!strcmp(clk_hw_get_name(hw), "pcie_pll")) {
- clk_disable_unprepare(clks[CLKID_MIPI_ENABLE_GATE]);
- clk_disable_unprepare(clks[CLKID_MIPI_BANDGAP_GATE]);
- };
+
}
const struct clk_ops meson_axg_pll_ops = {
#include "../drivers/pci/host/pcie-designware.h"
#include "pcie-amlogic.h"
+#include <dt-bindings/clock/amlogic,axg-clkc.h>
+#include <linux/clk-provider.h>
+#include "../clk/clkc.h"
struct amlogic_pcie {
int reset_gpio;
struct clk *clk;
struct clk *bus_clk;
+ struct clk *mipi_gate;
+ struct clk *mipi_bandgap_gate;
struct clk *port_clk;
struct clk *general_clk;
int pcie_num;
dev_err(pp->dev, "link timeout, disable PCIE PLL\n");
clk_disable_unprepare(amlogic_pcie->port_clk);
clk_disable_unprepare(amlogic_pcie->general_clk);
+ clk_disable_unprepare(amlogic_pcie->mipi_bandgap_gate);
+ clk_disable_unprepare(amlogic_pcie->mipi_gate);
clk_disable_unprepare(amlogic_pcie->bus_clk);
clk_disable_unprepare(amlogic_pcie->clk);
if (amlogic_pcie->pcie_num == 2) {
if (ret)
goto fail_pcie;
+ amlogic_pcie->mipi_gate = devm_clk_get(dev, "pcie_mipi_enable_gate");
+ if (IS_ERR(amlogic_pcie->mipi_gate)) {
+ dev_err(dev, "Failed to get pcie mipi gate clock\n");
+ ret = PTR_ERR(amlogic_pcie->mipi_gate);
+ goto fail_bus_clk;
+ }
+ /*pcie pll: mipi enable and bandgap share with mipi clk */
+ ret = clk_prepare_enable(amlogic_pcie->mipi_gate);
+ if (ret)
+ goto fail_bus_clk;
+
+ amlogic_pcie->mipi_bandgap_gate = devm_clk_get(dev,
+ "pcie_mipi_bandgap_gate");
+ if (IS_ERR(amlogic_pcie->mipi_bandgap_gate)) {
+ dev_err(dev, "Failed to get pcie mipi bandgap gate clock\n");
+ ret = PTR_ERR(amlogic_pcie->mipi_bandgap_gate);
+ goto fail_mipi_gate;
+ }
+ /*pcie pll: mipi enable and bandgap share with mipi clk */
+ ret = clk_prepare_enable(amlogic_pcie->mipi_bandgap_gate);
+ if (ret)
+ goto fail_mipi_gate;
/*RESET0[6,7] = 1*/
if (!amlogic_pcie->phy->reset_state) {
if (IS_ERR(amlogic_pcie->general_clk)) {
dev_err(dev, "Failed to get pcie general clock\n");
ret = PTR_ERR(amlogic_pcie->general_clk);
- goto fail_bus_clk;
+ goto fail_mipi_bandgap_gate;
}
ret = clk_prepare_enable(amlogic_pcie->general_clk);
if (ret)
- goto fail_bus_clk;
+ goto fail_mipi_bandgap_gate;
amlogic_pcie->clk = devm_clk_get(dev, "pcie");
if (IS_ERR(amlogic_pcie->clk)) {
clk_disable_unprepare(amlogic_pcie->clk);
fail_general_clk:
clk_disable_unprepare(amlogic_pcie->general_clk);
+fail_mipi_bandgap_gate:
+ clk_disable_unprepare(amlogic_pcie->mipi_bandgap_gate);
+fail_mipi_gate:
+ clk_disable_unprepare(amlogic_pcie->mipi_gate);
fail_bus_clk:
clk_disable_unprepare(amlogic_pcie->bus_clk);
fail_pcie:
port_num--;
+
return ret;
}
clk_disable_unprepare(amlogic_pcie->port_clk);
clk_disable_unprepare(amlogic_pcie->clk);
clk_disable_unprepare(amlogic_pcie->general_clk);
+ clk_disable_unprepare(amlogic_pcie->mipi_bandgap_gate);
+ clk_disable_unprepare(amlogic_pcie->mipi_gate);
clk_disable_unprepare(amlogic_pcie->bus_clk);
return 0;
clk_disable_unprepare(amlogic_pcie->port_clk);
clk_disable_unprepare(amlogic_pcie->clk);
clk_disable_unprepare(amlogic_pcie->general_clk);
+ clk_disable_unprepare(amlogic_pcie->mipi_bandgap_gate);
+ clk_disable_unprepare(amlogic_pcie->mipi_gate);
clk_disable_unprepare(amlogic_pcie->bus_clk);
amlogic_pcie->phy->reset_state = 0;
amlogic_pcie->phy->reset_state = 1;
clk_prepare_enable(amlogic_pcie->bus_clk);
+ clk_prepare_enable(amlogic_pcie->mipi_gate);
+ clk_prepare_enable(amlogic_pcie->mipi_bandgap_gate);
clk_prepare_enable(amlogic_pcie->general_clk);
clk_prepare_enable(amlogic_pcie->clk);
clk_prepare_enable(amlogic_pcie->port_clk);