Skip to content

Commit 4000b00

Browse files
committed
Merge branch 'for-4.7/phy' into for-4.7/pci
2 parents f55532a + 87d66f2 commit 4000b00

File tree

18 files changed

+6173
-34
lines changed

18 files changed

+6173
-34
lines changed

Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.txt

Lines changed: 733 additions & 0 deletions
Large diffs are not rendered by default.

Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-xusb-padctl.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Device tree binding for NVIDIA Tegra XUSB pad controller
22
========================================================
33

4+
NOTE: It turns out that this binding isn't an accurate description of the XUSB
5+
pad controller. While the description is good enough for the functional subset
6+
required for PCIe and SATA, it lacks the flexibility to represent the features
7+
needed for USB. For the new binding, see ../phy/nvidia,tegra-xusb-padctl.txt.
8+
The binding described in this file is deprecated and should not be used.
9+
410
The Tegra XUSB pad controller manages a set of lanes, each of which can be
511
assigned to one out of a set of different pads. Some of these pads have an
612
associated PHY that must be powered up before the pad can be used.

Documentation/phy.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,28 @@ should provide its own implementation of of_xlate. of_xlate is used only for
3131
dt boot case.
3232

3333
#define of_phy_provider_register(dev, xlate) \
34-
__of_phy_provider_register((dev), THIS_MODULE, (xlate))
34+
__of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
3535

3636
#define devm_of_phy_provider_register(dev, xlate) \
37-
__devm_of_phy_provider_register((dev), THIS_MODULE, (xlate))
37+
__devm_of_phy_provider_register((dev), NULL, THIS_MODULE, (xlate))
3838

3939
of_phy_provider_register and devm_of_phy_provider_register macros can be used to
4040
register the phy_provider and it takes device and of_xlate as
4141
arguments. For the dt boot case, all PHY providers should use one of the above
4242
2 macros to register the PHY provider.
4343

44+
Often the device tree nodes associated with a PHY provider will contain a set
45+
of children that each represent a single PHY. Some bindings may nest the child
46+
nodes within extra levels for context and extensibility, in which case the low
47+
level of_phy_provider_register_full() and devm_of_phy_provider_register_full()
48+
macros can be used to override the node containing the children.
49+
50+
#define of_phy_provider_register_full(dev, children, xlate) \
51+
__of_phy_provider_register(dev, children, THIS_MODULE, xlate)
52+
53+
#define devm_of_phy_provider_register_full(dev, children, xlate) \
54+
__devm_of_phy_provider_register_full(dev, children, THIS_MODULE, xlate)
55+
4456
void devm_of_phy_provider_unregister(struct device *dev,
4557
struct phy_provider *phy_provider);
4658
void of_phy_provider_unregister(struct phy_provider *phy_provider);

drivers/clk/tegra/clk-tegra210.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,19 @@
175175
#define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14)
176176
#define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12)
177177

178+
#define SATA_PLL_CFG0 0x490
179+
#define SATA_PLL_CFG0_PADPLL_RESET_SWCTL BIT(0)
180+
#define SATA_PLL_CFG0_PADPLL_USE_LOCKDET BIT(2)
181+
#define SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ BIT(13)
182+
#define SATA_PLL_CFG0_SEQ_ENABLE BIT(24)
183+
184+
#define XUSBIO_PLL_CFG0 0x51c
185+
#define XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL BIT(0)
186+
#define XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL BIT(2)
187+
#define XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET BIT(6)
188+
#define XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ BIT(13)
189+
#define XUSBIO_PLL_CFG0_SEQ_ENABLE BIT(24)
190+
178191
#define UTMIPLL_HW_PWRDN_CFG0 0x52c
179192
#define UTMIPLL_HW_PWRDN_CFG0_UTMIPLL_LOCK BIT(31)
180193
#define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25)
@@ -416,6 +429,51 @@ static const char *mux_pllmcp_clkm[] = {
416429
#define PLLU_MISC0_WRITE_MASK 0xbfffffff
417430
#define PLLU_MISC1_WRITE_MASK 0x00000007
418431

432+
void tegra210_xusb_pll_hw_control_enable(void)
433+
{
434+
u32 val;
435+
436+
val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0);
437+
val &= ~(XUSBIO_PLL_CFG0_CLK_ENABLE_SWCTL |
438+
XUSBIO_PLL_CFG0_PADPLL_RESET_SWCTL);
439+
val |= XUSBIO_PLL_CFG0_PADPLL_USE_LOCKDET |
440+
XUSBIO_PLL_CFG0_PADPLL_SLEEP_IDDQ;
441+
writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0);
442+
}
443+
EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_control_enable);
444+
445+
void tegra210_xusb_pll_hw_sequence_start(void)
446+
{
447+
u32 val;
448+
449+
val = readl_relaxed(clk_base + XUSBIO_PLL_CFG0);
450+
val |= XUSBIO_PLL_CFG0_SEQ_ENABLE;
451+
writel_relaxed(val, clk_base + XUSBIO_PLL_CFG0);
452+
}
453+
EXPORT_SYMBOL_GPL(tegra210_xusb_pll_hw_sequence_start);
454+
455+
void tegra210_sata_pll_hw_control_enable(void)
456+
{
457+
u32 val;
458+
459+
val = readl_relaxed(clk_base + SATA_PLL_CFG0);
460+
val &= ~SATA_PLL_CFG0_PADPLL_RESET_SWCTL;
461+
val |= SATA_PLL_CFG0_PADPLL_USE_LOCKDET |
462+
SATA_PLL_CFG0_PADPLL_SLEEP_IDDQ;
463+
writel_relaxed(val, clk_base + SATA_PLL_CFG0);
464+
}
465+
EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_control_enable);
466+
467+
void tegra210_sata_pll_hw_sequence_start(void)
468+
{
469+
u32 val;
470+
471+
val = readl_relaxed(clk_base + SATA_PLL_CFG0);
472+
val |= SATA_PLL_CFG0_SEQ_ENABLE;
473+
writel_relaxed(val, clk_base + SATA_PLL_CFG0);
474+
}
475+
EXPORT_SYMBOL_GPL(tegra210_sata_pll_hw_sequence_start);
476+
419477
static inline void _pll_misc_chk_default(void __iomem *base,
420478
struct tegra_clk_pll_params *params,
421479
u8 misc_num, u32 default_val, u32 mask)

drivers/phy/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,6 @@ config PHY_CYGNUS_PCIE
421421
Enable this to support the Broadcom Cygnus PCIe PHY.
422422
If unsure, say N.
423423

424+
source "drivers/phy/tegra/Kconfig"
425+
424426
endmenu

drivers/phy/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
5252
obj-$(CONFIG_PHY_BRCMSTB_SATA) += phy-brcmstb-sata.o
5353
obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
5454
obj-$(CONFIG_PHY_CYGNUS_PCIE) += phy-bcm-cygnus-pcie.o
55+
56+
obj-$(CONFIG_ARCH_TEGRA) += tegra/

drivers/phy/phy-core.c

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
141141
if (phy_provider->dev->of_node == node)
142142
return phy_provider;
143143

144-
for_each_child_of_node(phy_provider->dev->of_node, child)
144+
for_each_child_of_node(phy_provider->children, child)
145145
if (child == node)
146146
return phy_provider;
147147
}
@@ -811,24 +811,59 @@ EXPORT_SYMBOL_GPL(devm_phy_destroy);
811811
/**
812812
* __of_phy_provider_register() - create/register phy provider with the framework
813813
* @dev: struct device of the phy provider
814+
* @children: device node containing children (if different from dev->of_node)
814815
* @owner: the module owner containing of_xlate
815816
* @of_xlate: function pointer to obtain phy instance from phy provider
816817
*
817818
* Creates struct phy_provider from dev and of_xlate function pointer.
818819
* This is used in the case of dt boot for finding the phy instance from
819820
* phy provider.
821+
*
822+
* If the PHY provider doesn't nest children directly but uses a separate
823+
* child node to contain the individual children, the @children parameter
824+
* can be used to override the default. If NULL, the default (dev->of_node)
825+
* will be used. If non-NULL, the device node must be a child (or further
826+
* descendant) of dev->of_node. Otherwise an ERR_PTR()-encoded -EINVAL
827+
* error code is returned.
820828
*/
821829
struct phy_provider *__of_phy_provider_register(struct device *dev,
822-
struct module *owner, struct phy * (*of_xlate)(struct device *dev,
823-
struct of_phandle_args *args))
830+
struct device_node *children, struct module *owner,
831+
struct phy * (*of_xlate)(struct device *dev,
832+
struct of_phandle_args *args))
824833
{
825834
struct phy_provider *phy_provider;
826835

836+
/*
837+
* If specified, the device node containing the children must itself
838+
* be the provider's device node or a child (or further descendant)
839+
* thereof.
840+
*/
841+
if (children) {
842+
struct device_node *parent = of_node_get(children), *next;
843+
844+
while (parent) {
845+
if (parent == dev->of_node)
846+
break;
847+
848+
next = of_get_parent(parent);
849+
of_node_put(parent);
850+
parent = next;
851+
}
852+
853+
if (!parent)
854+
return ERR_PTR(-EINVAL);
855+
856+
of_node_put(parent);
857+
} else {
858+
children = dev->of_node;
859+
}
860+
827861
phy_provider = kzalloc(sizeof(*phy_provider), GFP_KERNEL);
828862
if (!phy_provider)
829863
return ERR_PTR(-ENOMEM);
830864

831865
phy_provider->dev = dev;
866+
phy_provider->children = of_node_get(children);
832867
phy_provider->owner = owner;
833868
phy_provider->of_xlate = of_xlate;
834869

@@ -854,16 +889,18 @@ EXPORT_SYMBOL_GPL(__of_phy_provider_register);
854889
* on the devres data, then, devres data is freed.
855890
*/
856891
struct phy_provider *__devm_of_phy_provider_register(struct device *dev,
857-
struct module *owner, struct phy * (*of_xlate)(struct device *dev,
858-
struct of_phandle_args *args))
892+
struct device_node *children, struct module *owner,
893+
struct phy * (*of_xlate)(struct device *dev,
894+
struct of_phandle_args *args))
859895
{
860896
struct phy_provider **ptr, *phy_provider;
861897

862898
ptr = devres_alloc(devm_phy_provider_release, sizeof(*ptr), GFP_KERNEL);
863899
if (!ptr)
864900
return ERR_PTR(-ENOMEM);
865901

866-
phy_provider = __of_phy_provider_register(dev, owner, of_xlate);
902+
phy_provider = __of_phy_provider_register(dev, children, owner,
903+
of_xlate);
867904
if (!IS_ERR(phy_provider)) {
868905
*ptr = phy_provider;
869906
devres_add(dev, ptr);
@@ -888,6 +925,7 @@ void of_phy_provider_unregister(struct phy_provider *phy_provider)
888925

889926
mutex_lock(&phy_provider_mutex);
890927
list_del(&phy_provider->list);
928+
of_node_put(phy_provider->children);
891929
kfree(phy_provider);
892930
mutex_unlock(&phy_provider_mutex);
893931
}

drivers/phy/tegra/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
config PHY_TEGRA_XUSB
2+
tristate "NVIDIA Tegra XUSB pad controller driver"
3+
depends on ARCH_TEGRA
4+
help
5+
Choose this option if you have an NVIDIA Tegra SoC.
6+
7+
To compile this driver as a module, choose M here: the module will
8+
be called phy-tegra-xusb.

drivers/phy/tegra/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
obj-$(CONFIG_PHY_TEGRA_XUSB) += phy-tegra-xusb.o
2+
3+
phy-tegra-xusb-y += xusb.o
4+
phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_124_SOC) += xusb-tegra124.o
5+
phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_132_SOC) += xusb-tegra124.o
6+
phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_210_SOC) += xusb-tegra210.o

0 commit comments

Comments
 (0)