phy: simplified phy lookup
Subsystems (11)
v2 cover phy: simplified phy lookup
Hi,
So the idea with these is that they should help to make it possible to request phys without caring about how they are mapped to the consumers, meaning, was is the mapping done in DT, ACPI, etc. Mapping phys to consumers can be now done with lookups similarly how clocks can be mapped in clkdev.c.
Vivek needs to handle the phys of dwc3 also in xhci driver on Exynos5420 SoC, so I'm resending these now.
Heikki Krogerus (6):
phy: safer to_phy() macro
phy: improved lookup method
arm: omap3: twl: use the new lookup method with usb phy
phy: remove the old lookup method
base: platform: name the device already during allocation
usb: dwc3: host: convey the PHYs to xhci
Documentation/phy.txt | 66 +++++---------- arch/arm/mach-omap2/twl-common.c | 18 ++--- drivers/base/platform.c | 77 +++++++++++------- drivers/phy/phy-bcm-kona-usb2.c | 2 +- drivers/phy/phy-core.c | 156 +++++++++++++++++++++++++++++------- drivers/phy/phy-exynos-dp-video.c | 2 +- drivers/phy/phy-exynos-mipi-video.c | 2 +- drivers/phy/phy-exynos5-usbdrd.c | 3 +- drivers/phy/phy-exynos5250-sata.c | 2 +- drivers/phy/phy-mvebu-sata.c | 2 +- drivers/phy/phy-omap-usb2.c | 2 +- drivers/phy/phy-samsung-usb2.c | 2 +- drivers/phy/phy-sun4i-usb.c | 2 +- drivers/phy/phy-ti-pipe3.c | 2 +- drivers/phy/phy-twl4030-usb.c | 4 +- drivers/phy/phy-xgene.c | 2 +- drivers/usb/dwc3/host.c | 22 +++-- include/linux/phy/phy.h | 60 +++++++------- 18 files changed, 259 insertions(+), 167 deletions(-)
Signature · 1 line
2.0.0.rc4
PATCH v2 1/6 phy: safer to_phy() macro
This makes to_phy() macro work with other variable names besides "dev".
--- include/linux/phy/phy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/phy/phy.h +1 -1
@@ -108,7 +108,7 @@ struct phy_init_data { .port = _port, \ } -#define to_phy (dev) (container_of((dev), struct phy, dev)) +#define to_phy (a) (container_of((a), struct phy, dev))#define of_phy_provider_register (dev, xlate) \ __of_phy_provider_register((dev), THIS_MODULE, (xlate))
Signature · 1 line
2.0.0.rc4
PATCH v2 2/6 phy: improved lookup method
In reply to Heikki KrogerusRemoves the need for the phys to be aware of their users even when not using DT. The method is copied from clkdev.c.
--- Documentation/phy.txt | 66 ++++++++--------------- drivers/phy/phy-core.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++- include/linux/phy/phy.h | 27 ++++++++++ 3 files changed, 183 insertions(+), 45 deletions(-)
Documentation/phy.txt +22 -44
@@ -53,17 +53,13 @@ unregister the PHY. The PHY driver should create the PHY in order for other peripheral controllers to make use of it. The PHY framework provides 2 APIs to create the PHY. -struct phy *phy_create(struct device *dev, const struct phy_ops *ops, - struct phy_init_data *init_data); -struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops, - struct phy_init_data *init_data); +struct phy *phy_create(struct device *dev, const struct phy_ops *ops); +struct phy *devm_phy_create(struct device *dev, const struct phy_ops *ops); The PHY drivers can use one of the above 2 APIs to create the PHY by passing -the device pointer, phy ops and init_data. +the device pointer and phy ops. phy_ops is a set of function pointers for performing PHY operations such as -init, exit, power_on and power_off. *init_data* is mandatory to get a reference -to the PHY in the case of non-dt boot. See section *Board File Initialization* -on how init_data should be used. +init, exit, power_on and power_off. Inorder to dereference the private data (in phy_ops), the phy provider driver can use phy_set_drvdata() after creating the PHY and use phy_get_drvdata() in
@@ -135,42 +131,24 @@ There are exported APIs like phy_pm_runtime_get, phy_pm_runtime_get_sync, phy_pm_runtime_put, phy_pm_runtime_put_sync, phy_pm_runtime_allow and phy_pm_runtime_forbid for performing PM operations. -8. Board File Initialization - -Certain board file initialization is necessary in order to get a reference -to the PHY in the case of non-dt boot. -Say we have a single device that implements 3 PHYs that of USB, SATA and PCIe, -then in the board file the following initialization should be done. - -struct phy_consumer consumers[] = { - PHY_CONSUMER("dwc3.0", "usb"), - PHY_CONSUMER("pcie.0", "pcie"), - PHY_CONSUMER("sata.0", "sata"), -}; -PHY_CONSUMER takes 2 parameters, first is the device name of the controller -(PHY consumer) and second is the port name. - -struct phy_init_data init_data = { - .consumers = consumers, - .num_consumers = ARRAY_SIZE(consumers), -}; - -static const struct platform_device pipe3_phy_dev = { - .name = "pipe3-phy", - .id = -1, - .dev = { - .platform_data = { - .init_data = &init_data, - }, - }, -}; - -then, while doing phy_create, the PHY driver should pass this init_data - phy_create(dev, ops, pdata->init_data); - -and the controller driver (phy consumer) should pass the port name along with -the device to get a reference to the PHY - phy_get(dev, "pcie"); +8. PHY Mappings + +In order to get reference to a PHY without help from DeviceTree, the framework +offers lookups which can be compared to clkdev that allow clk structures to be +bound to devices. A lookup can be made statically by directly registering +phy_lookup structure which contains the name of the PHY device, the name of the +device which the PHY will be bind to and Connection ID string. Alternatively a +lookup can be made during runtime when a handle to the struct phy already +exists. + +The framework offers the following APIs for registering and unregistering the +lookups. + +void phy_register_lookup(struct phy_lookup *pl); +int phy_create_lookup(struct phy *phy, const char *con_id, const char *dev_id); + +void phy_unregister_lookup(struct phy_lookup *pl); +void phy_remove_lookup(struct phy *phy, const char *con_id, const char *dev_id); 9. DeviceTree Binding
drivers/phy/phy-core.c +134 -1
153 lines not on this page · raw message
include/linux/phy/phy.h +27 -0
@@ -108,6 +108,20 @@ struct phy_init_data { .port = _port, \ } +struct phy_lookup { +struct list_head node; +const char *phy_name; +const char *dev_id; +const char *con_id; +}; + +#define PHY_LOOKUP (a, b, c) \ + { \ + .phy_name = a, \ + .dev_id = b, \ + .con_id = c, \ + } +#define to_phy (a) (container_of((a), struct phy, dev))#define of_phy_provider_register (dev, xlate) \
@@ -171,6 +185,10 @@ struct phy_provider *__devm_of_phy_provider_register(struct device *dev,void of_phy_provider_unregister (struct phy_provider *phy_provider);void devm_of_phy_provider_unregister (struct device *dev,struct phy_provider *phy_provider); +void phy_register_lookup (struct phy_lookup *pl); +void phy_unregister_lookup (struct phy_lookup *pl); +int phy_create_lookup (struct phy *phy,const char *con_id,const char *dev_id); +void phy_remove_lookup (struct phy *phy,const char *con_id,const char *dev_id);#else static inline int phy_pm_runtime_get (struct phy *phy) {
@@ -338,6 +356,15 @@ static inline void devm_of_phy_provider_unregister(struct device *dev, struct phy_provider *phy_provider) { } +static inline void phy_register_lookup (struct phy_lookup *pl) { } +static inline void phy_unregister_lookup (struct phy_lookup *pl) { } +static inline int +phy_create_lookup (struct phy *phy,const char *con_id,const char *dev_id) +{ +return 0 ; +} +static inline void phy_remove_lookup (struct phy *phy,const char *con_id, +const char *dev_id) { }#endif #endif /* __DRIVERS_PHY_H */
Signature · 1 line
2.0.0.rc4
PATCH v2 3/6 arm: omap3: twl: use the new lookup method with usb phy
In reply to Heikki KrogerusProvide complete association for the phy and it's user (musb) with the new phy lookup method.
--- arch/arm/mach-omap2/twl-common.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
arch/arm/mach-omap2/twl-common.c +8 -10
@@ -91,18 +91,14 @@ void __init omap_pmic_late_init(void) }#if defined(CONFIG_ARCH_OMAP3 ) -struct phy_consumer consumers[] = { -PHY_CONSUMER ("musb-hdrc.0" ,"usb" ), -}; - -struct phy_init_data init_data = { - .consumers = consumers, - .num_consumers =ARRAY_SIZE (consumers), +static struct phy_lookup twl4030_usb_lookup = { + .phy_name ="phy-twl4030_usb.0" , + .dev_id ="musb-hdrc.0" , + .con_id ="usb" , };static struct twl4030_usb_data omap3_usb_pdata = { - .usb_mode =T2_USB_MODE_ULPI , - .init_data = &init_data, + .usb_mode =T2_USB_MODE_ULPI , }; static int omap3_batt_table[] = {
@@ -225,8 +221,10 @@ void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, }/* Common platform data configurations */ -if (pdata_flags &TWL_COMMON_PDATA_USB && !pmic_data->usb) +if (pdata_flags &TWL_COMMON_PDATA_USB && !pmic_data->usb) { +phy_register_lookup (&twl4030_usb_lookup); pmic_data->usb = &omap3_usb_pdata; + }if (pdata_flags &TWL_COMMON_PDATA_BCI && !pmic_data->bci) pmic_data->bci = &omap3_bci_pdata;
Signature · 1 line
2.0.0.rc4
Re: [PATCHv2 3/6] arm: omap3: twl: use the new lookup method with usb phy
Hi Tony,
Quoted 2 lines · Heikki Krogerus
Provide complete association for the phy and it's user (musb) with the new phy lookup method.
I can take this patch with your Ack or if you want to take it
Thanks
Kishon
Quoted 48 lines
Signed-off-by Heikki Krogerus <[email protected]>Cc Tony Lindgren <[email protected]>--- arch/arm/mach-omap2/twl-common.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)arch/arm/mach-omap2/twl-common.c +8
-10@@ -91,18 +91,14 @@ void __init omap_pmic_late_init(void) }#if defined(CONFIG_ARCH_OMAP3 ) -struct phy_consumer consumers[] = { -PHY_CONSUMER ("musb-hdrc.0" ,"usb" ), -}; - -struct phy_init_data init_data = { - .consumers = consumers, - .num_consumers =ARRAY_SIZE (consumers), +static struct phy_lookup twl4030_usb_lookup = { + .phy_name ="phy-twl4030_usb.0" , + .dev_id ="musb-hdrc.0" , + .con_id ="usb" , };static struct twl4030_usb_data omap3_usb_pdata = { - .usb_mode =T2_USB_MODE_ULPI , - .init_data = &init_data, + .usb_mode =T2_USB_MODE_ULPI , }; static int omap3_batt_table[] = {@@ -225,8 +221,10 @@ void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data, }/* Common platform data configurations */ -if (pdata_flags &TWL_COMMON_PDATA_USB && !pmic_data->usb) +if (pdata_flags &TWL_COMMON_PDATA_USB && !pmic_data->usb) { +phy_register_lookup (&twl4030_usb_lookup); pmic_data->usb = &omap3_usb_pdata; + }if (pdata_flags &TWL_COMMON_PDATA_BCI && !pmic_data->bci) pmic_data->bci = &omap3_bci_pdata;
PATCH v2 4/6 phy: remove the old lookup method
In reply to Heikki KrogerusThe users of the old method are now converted to the new one.
--- drivers/phy/phy-bcm-kona-usb2.c | 2 +- drivers/phy/phy-core.c | 45 +++---------------------------------- drivers/phy/phy-exynos-dp-video.c | 2 +- drivers/phy/phy-exynos-mipi-video.c | 2 +- drivers/phy/phy-exynos5-usbdrd.c | 3 +-- drivers/phy/phy-exynos5250-sata.c | 2 +- drivers/phy/phy-mvebu-sata.c | 2 +- drivers/phy/phy-omap-usb2.c | 2 +- drivers/phy/phy-samsung-usb2.c | 2 +- drivers/phy/phy-sun4i-usb.c | 2 +- drivers/phy/phy-ti-pipe3.c | 2 +- drivers/phy/phy-twl4030-usb.c | 4 +--- drivers/phy/phy-xgene.c | 2 +- include/linux/phy/phy.h | 37 ++++-------------------------- 14 files changed, 19 insertions(+), 90 deletions(-)
drivers/phy/phy-bcm-kona-usb2.c +1 -1
@@ -117,7 +117,7 @@ static int bcm_kona_usb2_probe(struct platform_device *pdev)platform_set_drvdata (pdev, phy); - gphy =devm_phy_create (dev, &ops,NULL ); + gphy =devm_phy_create (dev, &ops);if (IS_ERR (gphy))return PTR_ERR (gphy);
drivers/phy/phy-core.c +3 -42
90 lines not on this page · raw message
drivers/phy/phy-exynos-dp-video.c +1 -1
@@ -76,7 +76,7 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)if (IS_ERR (state->regs))return PTR_ERR (state->regs); - phy =devm_phy_create (dev, &exynos_dp_video_phy_ops,NULL ); + phy =devm_phy_create (dev, &exynos_dp_video_phy_ops);if (IS_ERR (phy)) {dev_err (dev,"failed to create Display Port PHY\n" );return PTR_ERR (phy);
drivers/phy/phy-exynos-mipi-video.c +1 -1
@@ -136,7 +136,7 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)for (i =0 ; i <EXYNOS_MIPI_PHYS_NUM ; i++) {struct phy *phy =devm_phy_create (dev, - &exynos_mipi_video_phy_ops,NULL ); + &exynos_mipi_video_phy_ops);if (IS_ERR (phy)) {dev_err (dev,"failed to create PHY %d\n" , i);return PTR_ERR (phy);
drivers/phy/phy-exynos5-usbdrd.c +1 -2
@@ -635,8 +635,7 @@ static int exynos5_usbdrd_phy_probe(struct platform_device *pdev)dev_vdbg (dev,"Creating usbdrd_phy phy\n" );for (i =0 ; i <EXYNOS5_DRDPHYS_NUM ; i++) { -struct phy *phy =devm_phy_create (dev, &exynos5_usbdrd_phy_ops, -NULL ); +struct phy *phy =devm_phy_create (dev, &exynos5_usbdrd_phy_ops);if (IS_ERR (phy)) {dev_err (dev,"Failed to create usbdrd_phy phy\n" );return PTR_ERR (phy);
drivers/phy/phy-exynos5250-sata.c +1 -1
@@ -210,7 +210,7 @@ static int exynos_sata_phy_probe(struct platform_device *pdev)return ret; } - sata_phy->phy =devm_phy_create (dev, &exynos_sata_phy_ops,NULL ); + sata_phy->phy =devm_phy_create (dev, &exynos_sata_phy_ops);if (IS_ERR (sata_phy->phy)) {clk_disable_unprepare (sata_phy->phyclk);dev_err (dev,"failed to create PHY\n" );
drivers/phy/phy-mvebu-sata.c +1 -1
@@ -99,7 +99,7 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev)if (IS_ERR (priv->clk))return PTR_ERR (priv->clk); - phy =devm_phy_create (&pdev->dev, &phy_mvebu_sata_ops,NULL ); + phy =devm_phy_create (&pdev->dev, &phy_mvebu_sata_ops);if (IS_ERR (phy))return PTR_ERR (phy);
drivers/phy/phy-omap-usb2.c +1 -1
@@ -264,7 +264,7 @@ static int omap_usb2_probe(struct platform_device *pdev)platform_set_drvdata (pdev, phy);pm_runtime_enable (phy->dev); - generic_phy =devm_phy_create (phy->dev, &ops,NULL ); + generic_phy =devm_phy_create (phy->dev, &ops);if (IS_ERR (generic_phy))return PTR_ERR (generic_phy);
drivers/phy/phy-samsung-usb2.c +1 -1
@@ -189,7 +189,7 @@ static int samsung_usb2_phy_probe(struct platform_device *pdev)struct samsung_usb2_phy_instance *p = &drv->instances[i];dev_dbg (dev,"Creating phy \"%s\"\n" , label); - p->phy =devm_phy_create (dev, &samsung_usb2_phy_ops,NULL ); + p->phy =devm_phy_create (dev, &samsung_usb2_phy_ops);if (IS_ERR (p->phy)) {dev_err (drv->dev,"Failed to create usb2_phy \"%s\"\n" , label);
drivers/phy/phy-sun4i-usb.c +1 -1
@@ -294,7 +294,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)return PTR_ERR (phy->pmu); } - phy->phy =devm_phy_create (dev, &sun4i_usb_phy_ops,NULL ); + phy->phy =devm_phy_create (dev, &sun4i_usb_phy_ops);if (IS_ERR (phy->phy)) {dev_err (dev,"failed to create PHY %d\n" , i);return PTR_ERR (phy->phy);
drivers/phy/phy-ti-pipe3.c +1 -1
@@ -353,7 +353,7 @@ static int ti_pipe3_probe(struct platform_device *pdev)platform_set_drvdata (pdev, phy);pm_runtime_enable (phy->dev); - generic_phy =devm_phy_create (phy->dev, &ops,NULL ); + generic_phy =devm_phy_create (phy->dev, &ops);if (IS_ERR (generic_phy))return PTR_ERR (generic_phy);
drivers/phy/phy-twl4030-usb.c +1 -3
@@ -659,7 +659,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)struct usb_otg *otg;struct device_node *np = pdev->dev.of_node;struct phy_provider *phy_provider; -struct phy_init_data *init_data =NULL ; twl =devm_kzalloc (&pdev->dev,sizeof (*twl),GFP_KERNEL );if (!twl)
@@ -670,7 +669,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) (enum twl4030_usb_mode *)&twl->usb_mode); else if (pdata) { twl->usb_mode = pdata->usb_mode; - init_data = pdata->init_data; } else {dev_err (&pdev->dev,"twl4030 initialized without pdata\n" );return -EINVAL ;
@@ -695,7 +693,7 @@ static int twl4030_usb_probe(struct platform_device *pdev) otg->set_host = twl4030_set_host; otg->set_peripheral = twl4030_set_peripheral; - phy =devm_phy_create (twl->dev, &ops, init_data); + phy =devm_phy_create (twl->dev, &ops);if (IS_ERR (phy)) {dev_dbg (&pdev->dev,"Failed to create PHY\n" );return PTR_ERR (phy);
drivers/phy/phy-xgene.c +1 -1
@@ -1707,7 +1707,7 @@ static int xgene_phy_probe(struct platform_device *pdev) ctx->dev = &pdev->dev;platform_set_drvdata (pdev, ctx); - ctx->phy =devm_phy_create (ctx->dev, &xgene_phy_ops,NULL ); + ctx->phy =devm_phy_create (ctx->dev, &xgene_phy_ops);if (IS_ERR (ctx->phy)) {dev_dbg (&pdev->dev,"Failed to create PHY\n" ); rc =PTR_ERR (ctx->phy);
include/linux/phy/phy.h +4 -33
@@ -60,7 +60,6 @@ struct phy {struct device dev;int id;const struct phy_ops *ops; -struct phy_init_data *init_data;struct mutex mutex;int init_count;int power_count;
@@ -82,32 +81,6 @@ struct phy_provider { struct of_phandle_args *args); }; -/** -* struct phy_consumer - represents the phy consumer -* @dev_name: the device name of the controller that will use this PHY device -* @port: name given to the consumer port -*/ -struct phy_consumer { -const char *dev_name; -const char *port; -}; - -/** -* struct phy_init_data - contains the list of PHY consumers -* @num_consumers: number of consumers for this PHY device -* @consumers: list of PHY consumers -*/ -struct phy_init_data { -unsigned int num_consumers; -struct phy_consumer *consumers; -}; - -#define PHY_CONSUMER (_dev_name, _port) \ -{ \ - .dev_name = _dev_name, \ - .port = _port, \ -} -struct phy_lookup {struct list_head node;const char *phy_name;
@@ -170,10 +143,8 @@ void devm_phy_put(struct device *dev, struct phy *phy);struct phy *of_phy_get (struct device_node *np,const char *con_id);struct phy *of_phy_simple_xlate (struct device *dev,struct of_phandle_args *args); -struct phy *phy_create (struct device *dev,const struct phy_ops *ops, -struct phy_init_data *init_data); -struct phy *devm_phy_create (struct device *dev, -const struct phy_ops *ops,struct phy_init_data *init_data); +struct phy *phy_create (struct device *dev,const struct phy_ops *ops); +struct phy *devm_phy_create (struct device *dev,const struct phy_ops *ops);void phy_destroy (struct phy *phy);void devm_phy_destroy (struct device *dev,struct phy *phy); struct phy_provider *__of_phy_provider_register(struct device *dev,
@@ -315,13 +286,13 @@ static inline struct phy *of_phy_simple_xlate(struct device *dev, }static inline struct phy *phy_create (struct device *dev, -const struct phy_ops *ops,struct phy_init_data *init_data) +const struct phy_ops *ops) {return ERR_PTR (-ENOSYS ); }static inline struct phy *devm_phy_create (struct device *dev, -const struct phy_ops *ops,struct phy_init_data *init_data) +const struct phy_ops *ops) {return ERR_PTR (-ENOSYS ); }
Signature · 1 line
2.0.0.rc4
PATCH v2 5/6 base: platform: name the device already during allocation
In reply to Heikki KrogerusThis allows resources such as GPIOs and clocks, which can be matched based on the device name when requested, to be assigned even when PLATFORM_DEVID_AUTO is used.
--- drivers/base/platform.c | 77 ++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 30 deletions(-)
drivers/base/platform.c +47 -30
@@ -177,11 +177,45 @@ struct platform_object {*/ void platform_device_put (struct platform_device *pdev) { -if (pdev) -put_device (&pdev->dev); +if (!pdev) +return ; + +if (pdev->id_auto) { +ida_simple_remove (&platform_devid_ida, pdev->id); + pdev->id =PLATFORM_DEVID_AUTO ; + } + +put_device (&pdev->dev); }EXPORT_SYMBOL_GPL (platform_device_put); +static int pdev_set_name (struct platform_device *pdev) +{ +int ret; + +switch (pdev->id) { +default : +return dev_set_name (&pdev->dev,"%s.%d" , pdev->name, pdev->id); +case PLATFORM_DEVID_NONE : +return dev_set_name (&pdev->dev,"%s" , pdev->name); +case PLATFORM_DEVID_AUTO : +/* +* Automatically allocated device ID. We mark it as such so +* that we remember it must be freed, and we append a suffix +* to avoid namespace collision with explicit IDs. +*/ + ret =ida_simple_get (&platform_devid_ida,0 ,0 ,GFP_KERNEL ); +if (ret <0 ) +return ret; + pdev->id = ret; + pdev->id_auto = true; +return dev_set_name (&pdev->dev,"%s.%d.auto" , pdev->name, + pdev->id); + } + +return 0 ; +} +static void platform_device_release (struct device *dev) { struct platform_object *pa = container_of(dev, struct platform_object,
@@ -214,6 +248,10 @@ struct platform_device *platform_device_alloc(const char *name, int id)device_initialize (&pa->pdev.dev); pa->pdev.dev.release = platform_device_release;arch_setup_pdev_archdata (&pa->pdev); +if (pdev_set_name (&pa->pdev)) { +kfree (pa); +return NULL ; + } }return pa ? &pa->pdev :NULL ;
@@ -294,28 +332,6 @@ int platform_device_add(struct platform_device *pdev) pdev->dev.bus = &platform_bus_type; -switch (pdev->id) { -default : -dev_set_name (&pdev->dev,"%s.%d" , pdev->name, pdev->id); -break ; -case PLATFORM_DEVID_NONE : -dev_set_name (&pdev->dev,"%s" , pdev->name); -break ; -case PLATFORM_DEVID_AUTO : -/* -* Automatically allocated device ID. We mark it as such so -* that we remember it must be freed, and we append a suffix -* to avoid namespace collision with explicit IDs. -*/ - ret =ida_simple_get (&platform_devid_ida,0 ,0 ,GFP_KERNEL ); -if (ret <0 ) - goto err_out; - pdev->id = ret; - pdev->id_auto = true; -dev_set_name (&pdev->dev,"%s.%d.auto" , pdev->name, pdev->id); -break ; - } -for (i =0 ; i < pdev->num_resources; i++) {struct resource *p, *r = &pdev->resource[i];
@@ -358,7 +374,6 @@ int platform_device_add(struct platform_device *pdev)release_resource (r); } - err_out:return ret; }EXPORT_SYMBOL_GPL (platform_device_add);
@@ -378,11 +393,6 @@ void platform_device_del(struct platform_device *pdev)if (pdev) {device_del (&pdev->dev); -if (pdev->id_auto) { -ida_simple_remove (&platform_devid_ida, pdev->id); - pdev->id =PLATFORM_DEVID_AUTO ; - } -for (i =0 ; i < pdev->num_resources; i++) {struct resource *r = &pdev->resource[i];unsigned long type =resource_type (r);
@@ -400,8 +410,15 @@ EXPORT_SYMBOL_GPL(platform_device_del);*/ int platform_device_register (struct platform_device *pdev) { +int ret; +device_initialize (&pdev->dev);arch_setup_pdev_archdata (pdev); + + ret =pdev_set_name (pdev); +if (ret) +return ret; +return platform_device_add (pdev); }EXPORT_SYMBOL_GPL (platform_device_register);
Signature · 1 line
2.0.0.rc4
Re: [PATCHv2 5/6] base: platform: name the device already during allocation
Greg,
Quoted 3 lines · Heikki Krogerus
This allows resources such as GPIOs and clocks, which can be matched based on the device name when requested, to be assigned even when
PLATFORM_DEVID_AUTOis used.
Any comments on this patch?
Thanks
Kishon
Quoted 136 lines
Signed-off-by Heikki Krogerus <[email protected]>Cc Greg Kroah-Hartman <[email protected]>--- drivers/base/platform.c | 77 ++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 30 deletions(-)drivers/base/platform.c +47
-30@@ -177,11 +177,45 @@ struct platform_object {*/ void platform_device_put (struct platform_device *pdev) { -if (pdev) -put_device (&pdev->dev); +if (!pdev) +return ; + +if (pdev->id_auto) { +ida_simple_remove (&platform_devid_ida, pdev->id); + pdev->id =PLATFORM_DEVID_AUTO ; + } + +put_device (&pdev->dev); }EXPORT_SYMBOL_GPL (platform_device_put); +static int pdev_set_name (struct platform_device *pdev) +{ +int ret; + +switch (pdev->id) { +default : +return dev_set_name (&pdev->dev,"%s.%d" , pdev->name, pdev->id); +case PLATFORM_DEVID_NONE : +return dev_set_name (&pdev->dev,"%s" , pdev->name); +case PLATFORM_DEVID_AUTO : +/* +* Automatically allocated device ID. We mark it as such so +* that we remember it must be freed, and we append a suffix +* to avoid namespace collision with explicit IDs. +*/ + ret =ida_simple_get (&platform_devid_ida,0 ,0 ,GFP_KERNEL ); +if (ret <0 ) +return ret; + pdev->id = ret; + pdev->id_auto = true; +return dev_set_name (&pdev->dev,"%s.%d.auto" , pdev->name, + pdev->id); + } + +return 0 ; +} +static void platform_device_release (struct device *dev) { struct platform_object *pa = container_of(dev, struct platform_object,@@ -214,6 +248,10 @@ struct platform_device *platform_device_alloc(const char *name, int id)device_initialize (&pa->pdev.dev); pa->pdev.dev.release = platform_device_release;arch_setup_pdev_archdata (&pa->pdev); +if (pdev_set_name (&pa->pdev)) { +kfree (pa); +return NULL ; + } }return pa ? &pa->pdev :NULL ;@@ -294,28 +332,6 @@ int platform_device_add(struct platform_device *pdev) pdev->dev.bus = &platform_bus_type; -switch (pdev->id) { -default : -dev_set_name (&pdev->dev,"%s.%d" , pdev->name, pdev->id); -break ; -case PLATFORM_DEVID_NONE : -dev_set_name (&pdev->dev,"%s" , pdev->name); -break ; -case PLATFORM_DEVID_AUTO : -/* -* Automatically allocated device ID. We mark it as such so -* that we remember it must be freed, and we append a suffix -* to avoid namespace collision with explicit IDs. -*/ - ret =ida_simple_get (&platform_devid_ida,0 ,0 ,GFP_KERNEL ); -if (ret <0 ) - goto err_out; - pdev->id = ret; - pdev->id_auto = true; -dev_set_name (&pdev->dev,"%s.%d.auto" , pdev->name, pdev->id); -break ; - } -for (i =0 ; i < pdev->num_resources; i++) {struct resource *p, *r = &pdev->resource[i];@@ -358,7 +374,6 @@ int platform_device_add(struct platform_device *pdev)release_resource (r); } - err_out:return ret; }EXPORT_SYMBOL_GPL (platform_device_add);@@ -378,11 +393,6 @@ void platform_device_del(struct platform_device *pdev)if (pdev) {device_del (&pdev->dev); -if (pdev->id_auto) { -ida_simple_remove (&platform_devid_ida, pdev->id); - pdev->id =PLATFORM_DEVID_AUTO ; - } -for (i =0 ; i < pdev->num_resources; i++) {struct resource *r = &pdev->resource[i];unsigned long type =resource_type (r);@@ -400,8 +410,15 @@ EXPORT_SYMBOL_GPL(platform_device_del);*/ int platform_device_register (struct platform_device *pdev) { +int ret; +device_initialize (&pdev->dev);arch_setup_pdev_archdata (pdev); + + ret =pdev_set_name (pdev); +if (ret) +return ret; +return platform_device_add (pdev); }EXPORT_SYMBOL_GPL (platform_device_register);
Greg Kroah-Hartman
maintainerRe: [PATCHv2 5/6] base: platform: name the device already during allocation
Quoted 8 lines · Kishon Vijay Abraham I
Greg,
Quoted 3 lines · Heikki Krogerus
This allows resources such as GPIOs and clocks, which can be matched based on the device name when requested, to be assigned even when
PLATFORM_DEVID_AUTOis used.Any comments on this patch?
I thought I rejected it in the past, don't have my email archives around at the moment, sorry.
Quoted 19 lines
Quoted 19 lines
Signed-off-by Heikki Krogerus <[email protected]>Cc Greg Kroah-Hartman <[email protected]>--- drivers/base/platform.c | 77 ++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 30 deletions(-)drivers/base/platform.c +3
-2@@ -177,11 +177,45 @@ struct platform_object {*/ void platform_device_put (struct platform_device *pdev) { -if (pdev) -put_device (&pdev->dev); +if (!pdev) +return ; +
Quoted 8 lines
drivers/base/platform.c struct platform_object { · line 190
Quoted 8 lines
drivers/base/platform.c +6
-0+if (pdev->id_auto) { +ida_simple_remove (&platform_devid_ida, pdev->id); + pdev->id =PLATFORM_DEVID_AUTO ; + } + +put_device (&pdev->dev); }EXPORT_SYMBOL_GPL (platform_device_put);
Why would a single call to this function remove an id? That seems really wrong, you should be able to call get and put on a device numerous times, only the "last" reference should cause the device to be cleaned up.
Shouldn't this be in the release function instead?
thanks,
greg k-h
Re: [PATCHv2 5/6] base: platform: name the device already during allocation
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines · Kishon Vijay Abraham I
Greg,
On Thursday 05 June 2014 06:22 PM, Heikki Krogerus wrote:
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines
This allows resources such as GPIOs and clocks, which can be matched based on the device name when requested, to be assigned even when
PLATFORM_DEVID_AUTOis used.Any comments on this patch?
I thought I rejected it in the past, don't have my email archives around at the moment, sorry.
Quoted 1 line
Quoted 1 line
Signed-off-by Heikki Krogerus <[email protected]>
Are we planning a different approach for this ?
Since we are basing the phy-calibration patches for phy-exynos5-usbdrd on this series
and we need to register the phy lookup table in DWC3, and get the PHYs in xhci-plat.
The following patch in this series (which is based on this change) help us achieve that :
[PATCHv2 6/6] usb: dwc3: host: convey the PHYs to xhci
(https://lkml.org/lkml/2014/6/5/585)
Quoted 41 lines
Quoted 18 lines
Quoted 18 lines
Cc Greg Kroah-Hartman <[email protected]>--- drivers/base/platform.c | 77 ++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 30 deletions(-)drivers/base/platform.c +3
-2@@ -177,11 +177,45 @@ struct platform_object {*/ void platform_device_put (struct platform_device *pdev) { -if (pdev) -put_device (&pdev->dev); +if (!pdev) +return ; +Quoted 8 lines
drivers/base/platform.c struct platform_object { · line 190
Quoted 8 lines
drivers/base/platform.c +6
-0+if (pdev->id_auto) { +ida_simple_remove (&platform_devid_ida, pdev->id); + pdev->id =PLATFORM_DEVID_AUTO ; + } + +put_device (&pdev->dev); }EXPORT_SYMBOL_GPL (platform_device_put);Why would a single call to this function remove an id? That seems really wrong, you should be able to call get and put on a device numerous times, only the "last" reference should cause the device to be cleaned up.
Shouldn't this be in the release function instead?
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India
Re: [PATCHv2 5/6] base: platform: name the device already during allocation
In reply to Greg Kroah-HartmanQuoted 27 lines · Greg Kroah-Hartman
Quoted 13 lines
Quoted 13 lines
drivers/base/platform.c +3
-2@@ -177,11 +177,45 @@ struct platform_object {*/ void platform_device_put (struct platform_device *pdev) { -if (pdev) -put_device (&pdev->dev); +if (!pdev) +return ; +Quoted 8 lines
drivers/base/platform.c struct platform_object { · line 190
Quoted 8 lines
drivers/base/platform.c +6
-0+if (pdev->id_auto) { +ida_simple_remove (&platform_devid_ida, pdev->id); + pdev->id =PLATFORM_DEVID_AUTO ; + } + +put_device (&pdev->dev); }EXPORT_SYMBOL_GPL (platform_device_put);Why would a single call to this function remove an id? That seems really wrong, you should be able to call get and put on a device numerous times, only the "last" reference should cause the device to be cleaned up.
Quoted 1 line
Shouldn't this be in the release function instead?
I'll fix this.
Thanks Greg.
Signature · 1 line
heikki
PATCH v2 6/6 usb: dwc3: host: convey the PHYs to xhci
In reply to Heikki KrogerusOn some platforms a PHY may need to be handled also in the host controller driver. Exynos5420 SoC requires some "PHY tuning" based on the USB speed. This patch delivers dwc3's PHYs to the xhci platform device when it's created.
--- drivers/usb/dwc3/host.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/usb/dwc3/host.c +16 -6
@@ -27,8 +27,7 @@ int dwc3_host_init(struct dwc3 *dwc) xhci =platform_device_alloc ("xhci-hcd" ,PLATFORM_DEVID_AUTO );if (!xhci) {dev_err (dwc->dev,"couldn't allocate xHCI device\n" ); - ret = -ENOMEM ; - goto err0; +return -ENOMEM ; }dma_set_coherent_mask (&xhci->dev, dwc->dev->coherent_dma_mask);
@@ -46,22 +45,33 @@ int dwc3_host_init(struct dwc3 *dwc) goto err1; } +phy_create_lookup (dwc->usb2_generic_phy,"usb2-phy" , +dev_name (&xhci->dev)); +phy_create_lookup (dwc->usb3_generic_phy,"usb3-phy" , +dev_name (&xhci->dev)); + ret =platform_device_add (xhci);if (ret) {dev_err (dwc->dev,"failed to register xHCI device\n" ); - goto err1; + goto err2; }return 0 ; - +err2: +phy_remove_lookup (dwc->usb2_generic_phy,"usb2-phy" , +dev_name (&xhci->dev)); +phy_remove_lookup (dwc->usb3_generic_phy,"usb3-phy" , +dev_name (&xhci->dev)); err1:platform_device_put (xhci); - -err0:return ret; }void dwc3_host_exit (struct dwc3 *dwc) { +phy_remove_lookup (dwc->usb2_generic_phy,"usb2-phy" , +dev_name (&dwc->xhci->dev)); +phy_remove_lookup (dwc->usb3_generic_phy,"usb3-phy" , +dev_name (&dwc->xhci->dev));platform_device_unregister (dwc->xhci); }
Signature · 1 line
2.0.0.rc4
Re: [PATCHv2 6/6] usb: dwc3: host: convey the PHYs to xhci
Quoted 7 lines · Heikki Krogerus
On some platforms a PHY may need to be handled also in the host controller driver. Exynos5420 SoC requires some "PHY tuning" based on the USB speed. This patch delivers dwc3's PHYs to the xhci platform device when it's created.
Signed-off-by Heikki Krogerus <[email protected]>Cc Felipe Balbi <[email protected]>
if the rest of the series gets applied, I'm fine with this change
Signature · 1 line
balbi
Hi Heikki,
Quoted 10 lines · Heikki Krogerus
Hi,
So the idea with these is that they should help to make it possible to request phys without caring about how they are mapped to the consumers, meaning, was is the mapping done in DT, ACPI, etc. Mapping phys to consumers can be now done with lookups similarly how clocks can be mapped in
clkdev.c.Vivek needs to handle the phys of dwc3 also in xhci driver on Exynos5420 SoC, so I'm resending these now.
Thank you so much for your efforts.
This will greatly help me in preparing the patches for PHY tuning.
Quoted 37 lines
Heikki Krogerus (6):
phy: saferto_phy()macro
phy: improved lookup method
arm: omap3: twl: use the new lookup method with usb phy
phy: remove the old lookup method
base: platform: name the device already during allocation
usb: dwc3: host: convey the PHYs to xhciDocumentation/phy.txt | 66 +++++---------- arch/arm/mach-omap2/twl-common.c | 18 ++--- drivers/base/platform.c | 77 +++++++++++------- drivers/phy/phy-bcm-kona-usb2.c | 2 +- drivers/phy/phy-core.c | 156 +++++++++++++++++++++++++++++------- drivers/phy/phy-exynos-dp-video.c | 2 +- drivers/phy/phy-exynos-mipi-video.c | 2 +- drivers/phy/phy-exynos5-usbdrd.c | 3 +- drivers/phy/phy-exynos5250-sata.c | 2 +- drivers/phy/phy-mvebu-sata.c | 2 +- drivers/phy/phy-omap-usb2.c | 2 +- drivers/phy/phy-samsung-usb2.c | 2 +- drivers/phy/phy-sun4i-usb.c | 2 +- drivers/phy/phy-ti-pipe3.c | 2 +- drivers/phy/phy-twl4030-usb.c | 4 +- drivers/phy/phy-xgene.c | 2 +- drivers/usb/dwc3/host.c | 22 +++-- include/linux/phy/phy.h | 60 +++++++------- 18 files changed, 259 insertions(+), 167 deletions(-)--
2.0.0.rc4--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India
Hi,
Quoted 13 lines · Vivek Gautam
Hi Heikki,
Quoted 8 lines · Heikki Krogerus
Hi,
So the idea with these is that they should help to make it possible to request phys without caring about how they are mapped to the consumers, meaning, was is the mapping done in DT, ACPI, etc. Mapping phys to consumers can be now done with lookups similarly how clocks can be mapped in
clkdev.c.
Quoted 5 lines
Quoted 2 lines
Vivek needs to handle the phys of dwc3 also in xhci driver on Exynos5420 SoC, so I'm resending these now.
Thank you so much for your efforts.
This will greatly help me in preparing the patches for PHY tuning.
Can I get Tested-by please?
Cheers
Kishon
Vivek Gautam
Tested-byHi,
Quoted 16 lines · Kishon Vijay Abraham I
Hi,
Quoted 13 lines · Vivek Gautam
Hi Heikki,
Quoted 8 lines · Heikki Krogerus
Hi,
So the idea with these is that they should help to make it possible to request phys without caring about how they are mapped to the consumers, meaning, was is the mapping done in DT, ACPI, etc. Mapping phys to consumers can be now done with lookups similarly how clocks can be mapped in
clkdev.c.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Vivek needs to handle the phys of dwc3 also in xhci driver on Exynos5420 SoC, so I'm resending these now.
Thank you so much for your efforts.
This will greatly help me in preparing the patches for PHY tuning.Can I get Tested-by please?
Sure,
I have tested this series with my phy-calibration patches. [1] The entire lookup method looks fine.
Although i am re-working on my patches, but for this series -
[1] https://lkml.org/lkml/2014/6/6/202
Signature · 4 lines
Best Regards Vivek Gautam Samsung R&D Institute, Bangalore India