Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI/pwrctrl: Add optional slot clock for PCI slots

Add the ability to enable optional slot clock into the pwrctrl driver.
This is used to enable slot clock in split-clock topologies, where the PCIe
host/controller supply and PCIe slot supply are not provided by the same
clock. The PCIe host/controller clock should be described in the controller
node as the controller clock, while the slot clock should be described in
controller bridge/slot subnode.

Example DT snippet:

&pcicontroller {
clocks = <&clk_dif 0>; /* PCIe controller clock */

pci@0,0 {
#address-cells = <3>;
#size-cells = <2>;
reg = <0x0 0x0 0x0 0x0 0x0>;
compatible = "pciclass,0604";
device_type = "pci";
clocks = <&clk_dif 1>; /* PCIe slot clock */
vpcie3v3-supply = <&reg_3p3v>;
ranges;
};
};

Example clock topology:
____________ ____________
| PCIe host | | PCIe slot |
| | | |
| PCIe RX<|==================|>PCIe TX |
| PCIe TX<|==================|>PCIe RX |
| | | |
| PCIe CLK<|======.. ..======|>PCIe CLK |
'------------' || || '------------'
|| ||
____________ || ||
| 9FGV0441 | || ||
| | || ||
| CLK DIF0<|======'' ||
| CLK DIF1<|==========''
| CLK DIF2<|
| CLK DIF3<|
'------------'

Immutable commit for Geert Uytterhoeven <geert+renesas@glider.be>

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Anand Moon <linux.amoon@gmail.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Marek Vasut and committed by
Bjorn Helgaas
66db1d3c 19272b37

+8
+8
drivers/pci/pwrctrl/slot.c
··· 4 4 * Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 5 5 */ 6 6 7 + #include <linux/clk.h> 7 8 #include <linux/device.h> 8 9 #include <linux/mod_devicetable.h> 9 10 #include <linux/module.h> ··· 31 30 { 32 31 struct pci_pwrctrl_slot_data *slot; 33 32 struct device *dev = &pdev->dev; 33 + struct clk *clk; 34 34 int ret; 35 35 36 36 slot = devm_kzalloc(dev, sizeof(*slot), GFP_KERNEL); ··· 56 54 slot); 57 55 if (ret) 58 56 goto err_regulator_disable; 57 + 58 + clk = devm_clk_get_optional_enabled(dev, NULL); 59 + if (IS_ERR(clk)) { 60 + return dev_err_probe(dev, PTR_ERR(clk), 61 + "Failed to enable slot clock\n"); 62 + } 59 63 60 64 pci_pwrctrl_init(&slot->ctx, dev); 61 65