usb: phy: msm: Fixes and cleanups
Subsystems (3)
v2 cover usb: phy: msm: Fixes and cleanups
From: "Ivan T. Ivanov" <[email protected]>
v2
--
* Fix compilation issue in patch 1
* Separate regulator changes
* Merge devm_ related changes to one commit
* Drop Lindent patch
v1
--
Following patches make initial cleanup of usb phy found in the Qualcomm chipsets. Changes include:
* Build time error fix.
* Move driver to Managed Device Resource allocation.
* Checkpatch warnings and error fixes
* Removed usage of global regulators variables.
Ivan T. Ivanov (6):
usb: phy: msm: Move mach depndend code to platform data
usb: phy: msm: move global regulators variables to driver state
usb: phy: msm: Migrate to Managed Device Resource allocation
usb: phy: msm: Remove unnecessarily check for valid regulators.
usb: phy: msm: Fix WARNING: quoted string split across lines
usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf
arch/arm/mach-msm/board-msm7x30.c | 35 ++++ arch/arm/mach-msm/board-qsd8x50.c | 35 ++++ drivers/usb/phy/phy-msm-usb.c | 342 +++++++++++++------------------------ include/linux/usb/msm_hsusb.h | 6 + 4 files changed, 198 insertions(+), 220 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/6 usb: phy: msm: Move mach depndend code to platform data
From: "Ivan T. Ivanov" <[email protected]>
This patch fix compilation error and is an intermediate step before the addition of DeviceTree support for newer targets. Fix suggested here: https://lkml.org/lkml/2013/6/19/381
--- arch/arm/mach-msm/board-msm7x30.c | 35 +++++++++++++++++++++++ arch/arm/mach-msm/board-qsd8x50.c | 35 +++++++++++++++++++++++ drivers/usb/phy/phy-msm-usb.c | 55 ++++++++++--------------------------- include/linux/usb/msm_hsusb.h | 3 ++ 4 files changed, 87 insertions(+), 41 deletions(-)
arch/arm/mach-msm/board-msm7x30.c +35 -0
@@ -31,6 +31,7 @@#include <asm/setup.h> #include <mach/board.h> +#include <mach/clk.h> #include <mach/msm_iomap.h> #include <mach/dma.h>
@@ -61,10 +62,44 @@ static int hsusb_phy_init_seq[] = {-1 }; +static int hsusb_link_clk_reset (struct clk *link_clk,bool assert) +{ +int ret; + +if (assert) { + ret =clk_reset (link_clk,CLK_RESET_ASSERT ); +if (ret) +pr_err ("usb hs_clk assert failed\n" ); + }else { + ret =clk_reset (link_clk,CLK_RESET_DEASSERT ); +if (ret) +pr_err ("usb hs_clk deassert failed\n" ); + } +return ret; +} + +static int hsusb_phy_clk_reset (struct clk *phy_clk) +{ +int ret; + + ret =clk_reset (phy_clk,CLK_RESET_ASSERT ); +if (ret) { +pr_err ("usb phy clk assert failed\n" ); +return ret; + } +usleep_range (10000 ,12000 ); + ret =clk_reset (phy_clk,CLK_RESET_DEASSERT ); +if (ret) +pr_err ("usb phy clk deassert failed\n" ); +return ret; +} +static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, .mode =USB_PERIPHERAL , .otg_control =OTG_PHY_CONTROL , + .link_clk_reset = hsusb_link_clk_reset, + .phy_clk_reset = hsusb_phy_clk_reset, };struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = {
arch/arm/mach-msm/board-qsd8x50.c +35 -0
@@ -32,6 +32,7 @@#include <mach/irqs.h> #include <mach/sirc.h> #include <mach/vreg.h> +#include <mach/clk.h> #include <linux/platform_data/mmc-msm_sdcc.h> #include "devices.h"
@@ -82,10 +83,44 @@ static int hsusb_phy_init_seq[] = {-1 }; +static int hsusb_link_clk_reset (struct clk *link_clk,bool assert) +{ +int ret; + +if (assert) { + ret =clk_reset (link_clk,CLK_RESET_ASSERT ); +if (ret) +pr_err ("usb hs_clk assert failed\n" ); + }else { + ret =clk_reset (link_clk,CLK_RESET_DEASSERT ); +if (ret) +pr_err ("usb hs_clk deassert failed\n" ); + } +return ret; +} + +static int hsusb_phy_clk_reset (struct clk *phy_clk) +{ +int ret; + + ret =clk_reset (phy_clk,CLK_RESET_ASSERT ); +if (ret) { +pr_err ("usb phy clk assert failed\n" ); +return ret; + } +usleep_range (10000 ,12000 ); + ret =clk_reset (phy_clk,CLK_RESET_DEASSERT ); +if (ret) +pr_err ("usb phy clk deassert failed\n" ); +return ret; +} +static struct msm_otg_platform_data msm_otg_pdata = { .phy_init_seq = hsusb_phy_init_seq, .mode =USB_PERIPHERAL , .otg_control =OTG_PHY_CONTROL , + .link_clk_reset = hsusb_link_clk_reset, + .phy_clk_reset = hsusb_phy_clk_reset, };static struct platform_device *devices[]__initdata = {
drivers/usb/phy/phy-msm-usb.c +14 -41
110 lines not on this page · raw message
include/linux/usb/msm_hsusb.h +3 -0
@@ -20,6 +20,7 @@#include <linux/types.h> #include <linux/usb/otg.h> +#include <linux/clk.h> /** * Supported USB modes
@@ -135,6 +136,8 @@ struct msm_otg_platform_data {enum msm_usb_phy_type phy_type;void (*setup_gpio)(enum usb_otg_state state);char *pclk_src_name; +int (*link_clk_reset)(struct clk *link_clk,bool assert); +int (*phy_clk_reset)(struct clk *phy_clk); };/**
Signature · 1 line
1.7.9.5
Re: [PATCH v2 1/6] usb: phy: msm: Move mach depndend code to platform data
Hi,
Quoted 15 lines · Ivan T. Ivanov
From: "Ivan T. Ivanov" <[email protected]>
This patch fix compilation error and is an intermediate step before the addition of DeviceTree support for newer targets. Fix suggested here: https://lkml.org/lkml/2013/6/19/381
Cc David Brown <[email protected]>Cc Daniel Walker <[email protected]>Cc Bryan Huntsman <[email protected]>Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.orgCc linux-usb at vger.kernel.org
Quoted 4 lines
Signed-off-by Ivan T. Ivanov <[email protected]>--- arch/arm/mach-msm/board-msm7x30.c | 35 +++++++++++++++++++++++ arch/arm/mach-msm/board-qsd8x50.c | 35 +++++++++++++++++++++++
I need acks for these.
Quoted 17 lines
drivers/usb/phy/phy-msm-usb.c | 55 ++++++++++--------------------------- include/linux/usb/msm_hsusb.h | 3 ++ 4 files changed, 87 insertions(+), 41 deletions(-)arch/arm/mach-msm/board-msm7x30.c +1
-0@@ -31,6 +31,7 @@#include <asm/setup.h> #include <mach/board.h> +#include <mach/clk.h> #include <mach/msm_iomap.h> #include <mach/dma.h>
arch/arm/mach-msm/board-msm7x30.c static int hsusb_phy_init_seq[] = { · line 65
Quoted 4 lines
arch/arm/mach-msm/board-msm7x30.c +1
-0@@ -61,10 +62,44 @@ static int hsusb_phy_init_seq[] = { -1 }; +static int hsusb_link_clk_reset (struct clk *link_clk,bool assert)
looks like you should be using the reset controller framework ? (drivers/reset)
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130729/77f677a7/attachment-0001.sig>
Re: [PATCH v2 1/6] usb: phy: msm: Move mach depndend code to platform data
Hi,
Quoted 30 lines
Quoted 11 lines
Cc Bryan Huntsman <[email protected]>Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.orgCc linux-usb at vger.kernel.orgSigned-off-by Ivan T. Ivanov <[email protected]>--- arch/arm/mach-msm/board-msm7x30.c | 35 +++++++++++++++++++++++ arch/arm/mach-msm/board-qsd8x50.c | 35 +++++++++++++++++++++++I need acks for these.
Quoted 16 lines
drivers/usb/phy/phy-msm-usb.c | 55 ++++++++++--------------------------- include/linux/usb/msm_hsusb.h | 3 ++ 4 files changed, 87 insertions(+), 41 deletions(-)arch/arm/mach-msm/board-msm7x30.c +1
-0@@ -31,6 +31,7 @@#include <asm/setup.h> #include <mach/board.h> +#include <mach/clk.h> #include <mach/msm_iomap.h> #include <mach/dma.h>
Quoted 8 lines
arch/arm/mach-msm/board-msm7x30.c static int hsusb_phy_init_seq[] = { · line 65
Quoted 5 lines
arch/arm/mach-msm/board-msm7x30.c +1
-0@@ -61,10 +62,44 @@ static int hsusb_phy_init_seq[] = { -1 }; +static int hsusb_link_clk_reset (struct clk *link_clk,bool assert)looks like you should be using the reset controller framework ? (
drivers/reset)
Probably, but there still nothing in place in the msm, which provide this functionality. I am looking it to right now.
Regards,
Ivan
Re: [PATCH v2 1/6] usb: phy: msm: Move mach depndend code to platform data
In reply to Ivan T. IvanovQuoted 15 lines · Ivan T. Ivanov
From: "Ivan T. Ivanov" <[email protected]>
This patch fix compilation error and is an intermediate step before the addition of DeviceTree support for newer targets. Fix suggested here: https://lkml.org/lkml/2013/6/19/381
Cc David Brown <[email protected]>Cc Daniel Walker <[email protected]>Cc Bryan Huntsman <[email protected]>Cc Felipe Balbi <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.orgCc linux-usb at vger.kernel.org
Quoted 4 lines
Signed-off-by Ivan T. Ivanov <[email protected]>---
arch/arm/mach-msm/board-msm7x30.c | 35 +++++++++++++++++++++++ arch/arm/mach-msm/board-qsd8x50.c | 35 +++++++++++++++++++++++
Signature · 3 lines
sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
PATCH v2 2/6 usb: phy: msm: move global regulators variables to driver state
In reply to Ivan T. IvanovFrom: "Ivan T. Ivanov" <[email protected]>
--- drivers/usb/phy/phy-msm-usb.c | 82 ++++++++++++++++++++--------------------- include/linux/usb/msm_hsusb.h | 3 ++ 2 files changed, 42 insertions(+), 43 deletions(-)
drivers/usb/phy/phy-msm-usb.c +39 -43
@@ -58,47 +58,43 @@#define USB_PHY_VDD_DIG_VOL_MIN 1000000/* uV */ #define USB_PHY_VDD_DIG_VOL_MAX 1320000/* uV */ -static struct regulator *hsusb_3p3; -static struct regulator *hsusb_1p8; -static struct regulator *hsusb_vddcx; -static int msm_hsusb_init_vddcx (struct msm_otg *motg,int init) {int ret =0 ;if (init) { - hsusb_vddcx =regulator_get (motg->phy.dev,"HSUSB_VDDCX" ); -if (IS_ERR (hsusb_vddcx)) { + motg->vddcx =regulator_get (motg->phy.dev,"HSUSB_VDDCX" ); +if (IS_ERR (motg->vddcx)) {dev_err (motg->phy.dev,"unable to get hsusb vddcx\n" ); -return PTR_ERR (hsusb_vddcx); +return PTR_ERR (motg->vddcx); } - ret =regulator_set_voltage (hsusb_vddcx, + ret =regulator_set_voltage (motg->vddcx,USB_PHY_VDD_DIG_VOL_MIN ,USB_PHY_VDD_DIG_VOL_MAX );if (ret) {dev_err (motg->phy.dev,"unable to set the voltage " "for hsusb vddcx\n" ); -regulator_put (hsusb_vddcx); +regulator_put (motg->vddcx);return ret; } - ret =regulator_enable (hsusb_vddcx); + ret =regulator_enable (motg->vddcx);if (ret) {dev_err (motg->phy.dev,"unable to enable hsusb vddcx\n" ); -regulator_put (hsusb_vddcx); +regulator_put (motg->vddcx); } }else { - ret =regulator_set_voltage (hsusb_vddcx,0 , + ret =regulator_set_voltage (motg->vddcx,0 ,USB_PHY_VDD_DIG_VOL_MAX );if (ret)dev_err (motg->phy.dev,"unable to set the voltage " "for hsusb vddcx\n" ); - ret =regulator_disable (hsusb_vddcx); + ret =regulator_disable (motg->vddcx);if (ret)dev_err (motg->phy.dev,"unable to disable hsusb vddcx\n" ); -regulator_put (hsusb_vddcx); +regulator_put (motg->vddcx); }return ret;
@@ -109,38 +105,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)int rc =0 ;if (init) { - hsusb_3p3 =regulator_get (motg->phy.dev,"HSUSB_3p3" ); -if (IS_ERR (hsusb_3p3)) { + motg->v3p3 =regulator_get (motg->phy.dev,"HSUSB_3p3" ); +if (IS_ERR (motg->v3p3)) {dev_err (motg->phy.dev,"unable to get hsusb 3p3\n" ); -return PTR_ERR (hsusb_3p3); +return PTR_ERR (motg->v3p3); } - rc =regulator_set_voltage (hsusb_3p3,USB_PHY_3P3_VOL_MIN , + rc =regulator_set_voltage (motg->v3p3,USB_PHY_3P3_VOL_MIN ,USB_PHY_3P3_VOL_MAX );if (rc) {dev_err (motg->phy.dev,"unable to set voltage level " "for hsusb 3p3\n" ); goto put_3p3; } - rc =regulator_enable (hsusb_3p3); + rc =regulator_enable (motg->v3p3);if (rc) {dev_err (motg->phy.dev,"unable to enable the hsusb 3p3\n" ); goto put_3p3; } - hsusb_1p8 =regulator_get (motg->phy.dev,"HSUSB_1p8" ); -if (IS_ERR (hsusb_1p8)) { + motg->v1p8 =regulator_get (motg->phy.dev,"HSUSB_1p8" ); +if (IS_ERR (motg->v1p8)) {dev_err (motg->phy.dev,"unable to get hsusb 1p8\n" ); - rc =PTR_ERR (hsusb_1p8); + rc =PTR_ERR (motg->v1p8); goto disable_3p3; } - rc =regulator_set_voltage (hsusb_1p8,USB_PHY_1P8_VOL_MIN , + rc =regulator_set_voltage (motg->v1p8,USB_PHY_1P8_VOL_MIN ,USB_PHY_1P8_VOL_MAX );if (rc) {dev_err (motg->phy.dev,"unable to set voltage level " "for hsusb 1p8\n" ); goto put_1p8; } - rc =regulator_enable (hsusb_1p8); + rc =regulator_enable (motg->v1p8);if (rc) {dev_err (motg->phy.dev,"unable to enable the hsusb 1p8\n" ); goto put_1p8;
@@ -149,19 +145,19 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)return 0 ; } -regulator_disable (hsusb_1p8); +regulator_disable (motg->v1p8); put_1p8: -regulator_put (hsusb_1p8); +regulator_put (motg->v1p8); disable_3p3: -regulator_disable (hsusb_3p3); +regulator_disable (motg->v3p3); put_3p3: -regulator_put (hsusb_3p3); +regulator_put (motg->v3p3);return rc; }#ifdef CONFIG_PM_SLEEP #define USB_PHY_SUSP_DIG_VOL 500000 -static int msm_hsusb_config_vddcx (int high) +static int msm_hsusb_config_vddcx (struct msm_otg *motg,int high) {int max_vol =USB_PHY_VDD_DIG_VOL_MAX ;int min_vol;
@@ -172,7 +168,7 @@ static int msm_hsusb_config_vddcx(int high)else min_vol =USB_PHY_SUSP_DIG_VOL ; - ret =regulator_set_voltage (hsusb_vddcx, min_vol, max_vol); + ret =regulator_set_voltage (motg->vddcx, min_vol, max_vol);if (ret) {pr_err ("%s: unable to set the voltage for regulator " "HSUSB_VDDCX\n" , __func__);
@@ -185,44 +181,44 @@ static int msm_hsusb_config_vddcx(int high) }#endif -static int msm_hsusb_ldo_set_mode (int on) +static int msm_hsusb_ldo_set_mode (struct msm_otg *motg,int on) {int ret =0 ; -if (!hsusb_1p8 ||IS_ERR (hsusb_1p8)) { +if (!motg->v1p8 ||IS_ERR (motg->v1p8)) {pr_err ("%s: HSUSB_1p8 is not initialized\n" , __func__);return -ENODEV ; } -if (!hsusb_3p3 ||IS_ERR (hsusb_3p3)) { +if (!motg->v3p3 ||IS_ERR (motg->v3p3)) {pr_err ("%s: HSUSB_3p3 is not initialized\n" , __func__);return -ENODEV ; }if (on) { - ret =regulator_set_optimum_mode (hsusb_1p8, + ret =regulator_set_optimum_mode (motg->v1p8,USB_PHY_1P8_HPM_LOAD );if (ret <0 ) {pr_err ("%s: Unable to set HPM of the regulator " "HSUSB_1p8\n" , __func__);return ret; } - ret =regulator_set_optimum_mode (hsusb_3p3, + ret =regulator_set_optimum_mode (motg->v3p3,USB_PHY_3P3_HPM_LOAD );if (ret <0 ) {pr_err ("%s: Unable to set HPM of the regulator " "HSUSB_3p3\n" , __func__); -regulator_set_optimum_mode (hsusb_1p8, +regulator_set_optimum_mode (motg->v1p8,USB_PHY_1P8_LPM_LOAD );return ret; } }else { - ret =regulator_set_optimum_mode (hsusb_1p8, + ret =regulator_set_optimum_mode (motg->v1p8,USB_PHY_1P8_LPM_LOAD );if (ret <0 )pr_err ("%s: Unable to set LPM of the regulator " "HSUSB_1p8\n" , __func__); - ret =regulator_set_optimum_mode (hsusb_3p3, + ret =regulator_set_optimum_mode (motg->v3p3,USB_PHY_3P3_LPM_LOAD );if (ret <0 ) pr_err("%s: Unable to set LPM of the regulator "
@@ -491,8 +487,8 @@ static int msm_otg_suspend(struct msm_otg *motg)if (motg->pdata->phy_type ==SNPS_28NM_INTEGRATED_PHY && motg->pdata->otg_control ==OTG_PMIC_CONTROL ) { -msm_hsusb_ldo_set_mode (0 ); -msm_hsusb_config_vddcx (0 ); +msm_hsusb_ldo_set_mode (motg,0 ); +msm_hsusb_config_vddcx (motg,0 ); }if (device_may_wakeup (phy->dev))
@@ -528,8 +524,8 @@ static int msm_otg_resume(struct msm_otg *motg)if (motg->pdata->phy_type ==SNPS_28NM_INTEGRATED_PHY && motg->pdata->otg_control ==OTG_PMIC_CONTROL ) { -msm_hsusb_ldo_set_mode (1 ); -msm_hsusb_config_vddcx (1 ); +msm_hsusb_ldo_set_mode (motg,1 ); +msm_hsusb_config_vddcx (motg,1 );writel (readl (USB_PHY_CTRL ) & ~PHY_RETEN ,USB_PHY_CTRL ); }
@@ -1498,7 +1494,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)dev_err (&pdev->dev,"hsusb vreg configuration failed\n" ); goto vddcx_exit; } - ret =msm_hsusb_ldo_set_mode (1 ); + ret =msm_hsusb_ldo_set_mode (motg,1 );if (ret) {dev_err (&pdev->dev,"hsusb vreg enable failed\n" ); goto ldo_exit;
include/linux/usb/msm_hsusb.h +3 -0
@@ -183,6 +183,9 @@ struct msm_otg {enum usb_chg_state chg_state;enum usb_chg_type chg_type;u8 dcd_retries; +struct regulator *v3p3; +struct regulator *v1p8; + struct regulator *vddcx; };#endif
Signature · 1 line
1.7.9.5
PATCH v2 3/6 usb: phy: msm: Migrate to Managed Device Resource allocation
In reply to Ivan T. IvanovFrom: "Ivan T. Ivanov" <[email protected]>
Move memory, regulators, clocks and irq allocation to devm_* variants. Properly check for valid clk handles.
--- drivers/usb/phy/phy-msm-usb.c | 188 ++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 117 deletions(-)
drivers/usb/phy/phy-msm-usb.c +71 -117
@@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)int ret =0 ;if (init) { - motg->vddcx =regulator_get (motg->phy.dev,"HSUSB_VDDCX" ); -if (IS_ERR (motg->vddcx)) { -dev_err (motg->phy.dev,"unable to get hsusb vddcx\n" ); -return PTR_ERR (motg->vddcx); - } - ret =regulator_set_voltage (motg->vddcx,USB_PHY_VDD_DIG_VOL_MIN ,USB_PHY_VDD_DIG_VOL_MAX );if (ret) {dev_err (motg->phy.dev,"unable to set the voltage " "for hsusb vddcx\n" ); -regulator_put (motg->vddcx);return ret; } ret =regulator_enable (motg->vddcx); -if (ret) { +if (ret)dev_err (motg->phy.dev,"unable to enable hsusb vddcx\n" ); -regulator_put (motg->vddcx); - } }else { ret =regulator_set_voltage (motg->vddcx,0 ,USB_PHY_VDD_DIG_VOL_MAX );
@@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) ret =regulator_disable (motg->vddcx);if (ret)dev_err (motg->phy.dev,"unable to disable hsusb vddcx\n" ); - -regulator_put (motg->vddcx); }return ret;
@@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)int rc =0 ;if (init) { - motg->v3p3 =regulator_get (motg->phy.dev,"HSUSB_3p3" ); -if (IS_ERR (motg->v3p3)) { -dev_err (motg->phy.dev,"unable to get hsusb 3p3\n" ); -return PTR_ERR (motg->v3p3); - } - rc =regulator_set_voltage (motg->v3p3,USB_PHY_3P3_VOL_MIN ,USB_PHY_3P3_VOL_MAX );if (rc) {dev_err (motg->phy.dev,"unable to set voltage level " "for hsusb 3p3\n" ); - goto put_3p3; + goto exit; } rc =regulator_enable (motg->v3p3);if (rc) {dev_err (motg->phy.dev,"unable to enable the hsusb 3p3\n" ); - goto put_3p3; - } - motg->v1p8 =regulator_get (motg->phy.dev,"HSUSB_1p8" ); -if (IS_ERR (motg->v1p8)) { -dev_err (motg->phy.dev,"unable to get hsusb 1p8\n" ); - rc =PTR_ERR (motg->v1p8); - goto disable_3p3; + goto exit; } rc =regulator_set_voltage (motg->v1p8,USB_PHY_1P8_VOL_MIN ,USB_PHY_1P8_VOL_MAX );if (rc) {dev_err (motg->phy.dev,"unable to set voltage level " "for hsusb 1p8\n" ); - goto put_1p8; + goto disable_3p3; } rc =regulator_enable (motg->v1p8);if (rc) {dev_err (motg->phy.dev,"unable to enable the hsusb 1p8\n" ); - goto put_1p8; + goto disable_3p3; }return 0 ; }regulator_disable (motg->v1p8); -put_1p8: -regulator_put (motg->v1p8); disable_3p3:regulator_disable (motg->v3p3); -put_3p3: -regulator_put (motg->v3p3); +exit:return rc; }
@@ -479,7 +453,7 @@ static int msm_otg_suspend(struct msm_otg *motg)clk_disable_unprepare (motg->pclk);clk_disable_unprepare (motg->clk); -if (motg->core_clk) +if (!IS_ERR (motg->core_clk))clk_disable_unprepare (motg->core_clk);if (!IS_ERR (motg->pclk_src))
@@ -519,7 +493,7 @@ static int msm_otg_resume(struct msm_otg *motg)clk_prepare_enable (motg->pclk);clk_prepare_enable (motg->clk); -if (motg->core_clk) +if (!IS_ERR (motg->core_clk))clk_prepare_enable (motg->core_clk); if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
@@ -1393,13 +1367,14 @@ static int __init msm_otg_probe(struct platform_device *pdev)return -ENODEV ; } - motg =kzalloc (sizeof (struct msm_otg ),GFP_KERNEL ); + motg =devm_kzalloc (&pdev->dev,sizeof (struct msm_otg ),GFP_KERNEL );if (!motg) {dev_err (&pdev->dev,"unable to allocate msm_otg\n" );return -ENOMEM ; } - motg->phy.otg =kzalloc (sizeof (struct usb_otg ),GFP_KERNEL ); + motg->phy.otg =devm_kzalloc (&pdev->dev,sizeof (struct usb_otg ), +GFP_KERNEL );if (!motg->phy.otg) {dev_err (&pdev->dev,"unable to allocate msm_otg\n" );return -ENOMEM ;
@@ -1409,20 +1384,17 @@ static int __init msm_otg_probe(struct platform_device *pdev) phy = &motg->phy; phy->dev = &pdev->dev; - motg->phy_reset_clk =clk_get (&pdev->dev,"usb_phy_clk" ); + motg->phy_reset_clk =devm_clk_get (&pdev->dev,"usb_phy_clk" );if (IS_ERR (motg->phy_reset_clk)) {dev_err (&pdev->dev,"failed to get usb_phy_clk\n" ); - ret =PTR_ERR (motg->phy_reset_clk); - goto free_motg; +return PTR_ERR (motg->phy_reset_clk); } - motg->clk =clk_get (&pdev->dev,"usb_hs_clk" ); + motg->clk =devm_clk_get (&pdev->dev,"usb_hs_clk" );if (IS_ERR (motg->clk)) {dev_err (&pdev->dev,"failed to get usb_hs_clk\n" ); - ret =PTR_ERR (motg->clk); - goto put_phy_reset_clk; +return PTR_ERR (motg->clk); } -clk_set_rate (motg->clk,60000000 );/* * If USB Core is running its protocol engine based on CORE CLK,
@@ -1431,22 +1403,18 @@ static int __init msm_otg_probe(struct platform_device *pdev)* CORE CLK. For such USB cores, vote for maximum clk frequency * on pclk source */ + motg->pclk_src =ERR_PTR (-ENOENT );if (motg->pdata->pclk_src_name) { - motg->pclk_src =clk_get (&pdev->dev, + motg->pclk_src =devm_clk_get (&pdev->dev, motg->pdata->pclk_src_name);if (IS_ERR (motg->pclk_src)) - goto put_clk; -clk_set_rate (motg->pclk_src,INT_MAX ); -clk_prepare_enable (motg->pclk_src); - }else - motg->pclk_src =ERR_PTR (-ENOENT ); - +return PTR_ERR (motg->pclk_src); + } - motg->pclk =clk_get (&pdev->dev,"usb_hs_pclk" ); + motg->pclk =devm_clk_get (&pdev->dev,"usb_hs_pclk" );if (IS_ERR (motg->pclk)) {dev_err (&pdev->dev,"failed to get usb_hs_pclk\n" ); - ret =PTR_ERR (motg->pclk); - goto put_pclk_src; +return PTR_ERR (motg->pclk); }/*
@@ -1454,65 +1422,78 @@ static int __init msm_otg_probe(struct platform_device *pdev)* clock is introduced to remove the dependency on AXI * bus frequency. */ - motg->core_clk =clk_get (&pdev->dev,"usb_hs_core_clk" ); -if (IS_ERR (motg->core_clk)) - motg->core_clk =NULL ; + motg->core_clk =devm_clk_get (&pdev->dev,"usb_hs_core_clk" ); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"failed to get platform resource mem\n" ); - ret = -ENODEV ; - goto put_core_clk; - } + motg->regs =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (motg->regs)) +return PTR_ERR (motg->regs); - motg->regs =ioremap (res->start,resource_size (res)); -if (!motg->regs) { -dev_err (&pdev->dev,"ioremap failed\n" ); - ret = -ENOMEM ; - goto put_core_clk; - }dev_info (&pdev->dev,"OTG regs = %p\n" , motg->regs); motg->irq =platform_get_irq (pdev,0 ); -if (!motg->irq) { +if (motg->irq <0 ) {dev_err (&pdev->dev,"platform_get_irq failed\n" ); - ret = -ENODEV ; - goto free_regs; +return motg->irq; + } + + motg->vddcx =devm_regulator_get (motg->phy.dev,"HSUSB_VDDCX" ); +if (IS_ERR (motg->vddcx)) { +dev_err (motg->phy.dev,"unable to get hsusb vddcx\n" ); +return PTR_ERR (motg->vddcx); + } + + motg->v3p3 =devm_regulator_get (motg->phy.dev,"HSUSB_3p3" ); +if (IS_ERR (motg->v3p3)) { +dev_err (motg->phy.dev,"unable to get hsusb 3p3\n" ); +return PTR_ERR (motg->v3p3); + } + + motg->v1p8 =devm_regulator_get (motg->phy.dev,"HSUSB_1p8" ); +if (IS_ERR (motg->v1p8)) { +dev_err (motg->phy.dev,"unable to get hsusb 1p8\n" ); +return PTR_ERR (motg->v1p8); + } + +clk_set_rate (motg->clk,60000000 ); +if (IS_ERR (motg->pclk_src)) { +clk_set_rate (motg->pclk_src,INT_MAX ); +clk_prepare_enable (motg->pclk_src); }clk_prepare_enable (motg->clk);clk_prepare_enable (motg->pclk); +if (!IS_ERR (motg->core_clk)) +clk_prepare_enable (motg->core_clk); + ret =msm_hsusb_init_vddcx (motg,1 );if (ret) {dev_err (&pdev->dev,"hsusb vddcx configuration failed\n" ); - goto free_regs; + goto disable_clks; } ret =msm_hsusb_ldo_init (motg,1 );if (ret) {dev_err (&pdev->dev,"hsusb vreg configuration failed\n" ); - goto vddcx_exit; + goto disable_vddcx; } ret =msm_hsusb_ldo_set_mode (motg,1 );if (ret) {dev_err (&pdev->dev,"hsusb vreg enable failed\n" ); - goto ldo_exit; + goto disable_ldo; } -if (motg->core_clk) -clk_prepare_enable (motg->core_clk); -writel (0 ,USB_USBINTR );writel (0 ,USB_OTGSC );INIT_WORK (&motg->sm_work, msm_otg_sm_work);INIT_DELAYED_WORK (&motg->chg_work, msm_chg_detect_work); - ret =request_irq (motg->irq, msm_otg_irq,IRQF_SHARED , + ret =devm_request_irq (&pdev->dev, motg->irq, msm_otg_irq,IRQF_SHARED ,"msm_otg" , motg);if (ret) {dev_err (&pdev->dev,"request irq failed\n" ); - goto disable_clks; + goto disable_ldo; } phy->init = msm_otg_reset;
@@ -1527,7 +1508,7 @@ static int __init msm_otg_probe(struct platform_device *pdev) ret =usb_add_phy (&motg->phy,USB_PHY_TYPE_USB2 );if (ret) {dev_err (&pdev->dev,"usb_add_phy failed\n" ); - goto free_irq; + goto disable_ldo; }platform_set_drvdata (pdev, motg);
@@ -1545,33 +1526,18 @@ static int __init msm_otg_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev);return 0 ; -free_irq: -free_irq (motg->irq, motg); + +disable_ldo: +msm_hsusb_ldo_init (motg,0 ); +disable_vddcx: +msm_hsusb_init_vddcx (motg,0 ); disable_clks:clk_disable_unprepare (motg->pclk);clk_disable_unprepare (motg->clk); -ldo_exit: -msm_hsusb_ldo_init (motg,0 ); -vddcx_exit: -msm_hsusb_init_vddcx (motg,0 ); -free_regs: -iounmap (motg->regs); -put_core_clk: -if (motg->core_clk) -clk_put (motg->core_clk); -clk_put (motg->pclk); -put_pclk_src: -if (!IS_ERR (motg->pclk_src)) { +if (!IS_ERR (motg->core_clk)) +clk_disable_unprepare (motg->core_clk); +if (!IS_ERR (motg->pclk_src))clk_disable_unprepare (motg->pclk_src); -clk_put (motg->pclk_src); - } -put_clk: -clk_put (motg->clk); -put_phy_reset_clk: -clk_put (motg->phy_reset_clk); -free_motg: -kfree (motg->phy.otg); -kfree (motg);return ret; }
@@ -1594,7 +1560,6 @@ static int msm_otg_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);usb_remove_phy (phy); -free_irq (motg->irq, motg);/* * Put PHY in low power mode.
@@ -1614,26 +1579,15 @@ static int msm_otg_remove(struct platform_device *pdev)clk_disable_unprepare (motg->pclk);clk_disable_unprepare (motg->clk); -if (motg->core_clk) +if (!IS_ERR (motg->core_clk))clk_disable_unprepare (motg->core_clk); -if (!IS_ERR (motg->pclk_src)) { +if (!IS_ERR (motg->pclk_src))clk_disable_unprepare (motg->pclk_src); -clk_put (motg->pclk_src); - } +msm_hsusb_ldo_init (motg,0 ); -iounmap (motg->regs);pm_runtime_set_suspended (&pdev->dev); -clk_put (motg->phy_reset_clk); -clk_put (motg->pclk); -clk_put (motg->clk); -if (motg->core_clk) -clk_put (motg->core_clk); - -kfree (motg->phy.otg); -kfree (motg); -return 0 ; }
Signature · 1 line
1.7.9.5
Re: [PATCH v2 3/6] usb: phy: msm: Migrate to Managed Device Resource allocation
Hi,
drivers/usb/phy/phy-msm-usb.c static int __init msm_otg_probe(struct platform_device *pdev) · line 1435
Quoted 3 lines · Ivan T. Ivanov
drivers/usb/phy/phy-msm-usb.c +1
-1motg->irq =platform_get_irq (pdev,0 ); -if (!motg->irq) { +if (motg->irq <0 ) {
looks like this particular hunk isn't part of $subject.
Signature · 1 line
balbi
Re: [PATCH v2 3/6] usb: phy: msm: Migrate to Managed Device Resource allocation
Hi,
Quoted 9 lines · Felipe Balbi
Hi,
drivers/usb/phy/phy-msm-usb.c static int __init msm_otg_probe(struct platform_device *pdev) · line 1435
Quoted 3 lines · Ivan T. Ivanov
drivers/usb/phy/phy-msm-usb.c +1
-1motg->irq =platform_get_irq (pdev,0 ); -if (!motg->irq) { +if (motg->irq <0 ) {looks like this particular hunk isn't part of $subject.
Indeed. Will remove it.
Thanks,
Ivan
PATCH v2 4/6 usb: phy: msm: Remove unnecessarily check for valid regulators.
In reply to Ivan T. IvanovFrom: "Ivan T. Ivanov" <[email protected]>
Whether regulators are available or not is checked at driver probe. If they are not available driver will refuse to load, so no need to check them again.
--- drivers/usb/phy/phy-msm-usb.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/usb/phy/phy-msm-usb.c +0 -10
@@ -159,16 +159,6 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) {int ret =0 ; -if (!motg->v1p8 ||IS_ERR (motg->v1p8)) { -pr_err ("%s: HSUSB_1p8 is not initialized\n" , __func__); -return -ENODEV ; - } - -if (!motg->v3p3 ||IS_ERR (motg->v3p3)) { -pr_err ("%s: HSUSB_3p3 is not initialized\n" , __func__); -return -ENODEV ; - } -if (on) { ret =regulator_set_optimum_mode (motg->v1p8,USB_PHY_1P8_HPM_LOAD );
Signature · 1 line
1.7.9.5
PATCH v2 5/6 usb: phy: msm: Fix WARNING: quoted string split across lines
In reply to Ivan T. IvanovFrom: "Ivan T. Ivanov" <[email protected]>
This fixes checkpatch.pl warnings.
--- drivers/usb/phy/phy-msm-usb.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-)
drivers/usb/phy/phy-msm-usb.c +11 -22
@@ -67,8 +67,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)USB_PHY_VDD_DIG_VOL_MIN , USB_PHY_VDD_DIG_VOL_MAX);if (ret) { -dev_err (motg->phy.dev,"unable to set the voltage " -"for hsusb vddcx\n" ); +dev_err (motg->phy.dev,"Cannot set vddcx voltage\n" );return ret; }
@@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) ret =regulator_set_voltage (motg->vddcx,0 ,USB_PHY_VDD_DIG_VOL_MAX );if (ret) -dev_err (motg->phy.dev,"unable to set the voltage " -"for hsusb vddcx\n" ); +dev_err (motg->phy.dev,"Cannot set vddcx voltage\n" ); ret =regulator_disable (motg->vddcx);if (ret)dev_err (motg->phy.dev,"unable to disable hsusb vddcx\n" );
@@ -97,8 +95,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) rc =regulator_set_voltage (motg->v3p3,USB_PHY_3P3_VOL_MIN ,USB_PHY_3P3_VOL_MAX );if (rc) { -dev_err (motg->phy.dev,"unable to set voltage level " -"for hsusb 3p3\n" ); +dev_err (motg->phy.dev,"Cannot set v3p3 voltage\n" ); goto exit; } rc =regulator_enable (motg->v3p3);
@@ -109,8 +106,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) rc =regulator_set_voltage (motg->v1p8,USB_PHY_1P8_VOL_MIN ,USB_PHY_1P8_VOL_MAX );if (rc) { -dev_err (motg->phy.dev,"unable to set voltage level " -"for hsusb 1p8\n" ); +dev_err (motg->phy.dev,"Cannot set v1p8 voltage\n" ); goto disable_3p3; } rc =regulator_enable (motg->v1p8);
@@ -144,8 +140,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high) ret =regulator_set_voltage (motg->vddcx, min_vol, max_vol);if (ret) { -pr_err ("%s: unable to set the voltage for regulator " -"HSUSB_VDDCX\n" , __func__); +dev_err (motg->phy.dev,"Cannot set vddcx voltage\n" );return ret; }
@@ -163,15 +158,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) ret =regulator_set_optimum_mode (motg->v1p8,USB_PHY_1P8_HPM_LOAD );if (ret <0 ) { -pr_err ("%s: Unable to set HPM of the regulator " -"HSUSB_1p8\n" , __func__); +pr_err ("Could not set HPM for v1p8\n" );return ret; } ret =regulator_set_optimum_mode (motg->v3p3,USB_PHY_3P3_HPM_LOAD );if (ret <0 ) { -pr_err ("%s: Unable to set HPM of the regulator " -"HSUSB_3p3\n" , __func__); +pr_err ("Could not set HPM for v3p3\n" );regulator_set_optimum_mode (motg->v1p8,USB_PHY_1P8_LPM_LOAD );return ret;
@@ -180,13 +173,11 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on) ret =regulator_set_optimum_mode (motg->v1p8,USB_PHY_1P8_LPM_LOAD );if (ret <0 ) -pr_err ("%s: Unable to set LPM of the regulator " -"HSUSB_1p8\n" , __func__); +pr_err ("Could not set LPM for v1p8\n" ); ret =regulator_set_optimum_mode (motg->v3p3,USB_PHY_3P3_LPM_LOAD );if (ret <0 ) -pr_err ("%s: Unable to set LPM of the regulator " -"HSUSB_3p3\n" , __func__); +pr_err ("Could not set LPM for v3p3\n" ); }pr_debug ("reg (%s)\n" , on ?"HPM" :"LPM" );
@@ -519,8 +510,7 @@ static int msm_otg_resume(struct msm_otg *motg)* PHY. USB state can not be restored. Re-insertion * of USB cable is the only way to get USB working. */ -dev_err (phy->dev,"Unable to resume USB." -"Re-plugin the cable\n" ); +dev_err (phy->dev,"Unable to resume USB. Re-plugin the cable\n" );msm_otg_reset (phy); }
@@ -1508,8 +1498,7 @@ static int __init msm_otg_probe(struct platform_device *pdev) motg->pdata->otg_control == OTG_USER_CONTROL) { ret =msm_otg_debugfs_init (motg);if (ret) -dev_dbg (&pdev->dev,"mode debugfs file is" -"not available\n" ); +dev_dbg (&pdev->dev,"Can not create mode change file\n" ); }pm_runtime_set_active (&pdev->dev);
Signature · 1 line
1.7.9.5
PATCH v2 6/6 usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf
In reply to Ivan T. IvanovFrom: "Ivan T. Ivanov" <[email protected]>
This fixes checkpatch.pl warnings.
--- drivers/usb/phy/phy-msm-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/phy/phy-msm-usb.c +3 -3
@@ -1204,13 +1204,13 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)switch (otg->phy->state) {case OTG_STATE_A_HOST : -seq_printf (s,"host\n" ); +seq_puts (s,"host\n" );break ;case OTG_STATE_B_PERIPHERAL : -seq_printf (s,"peripheral\n" ); +seq_puts (s,"peripheral\n" );break ;default : -seq_printf (s,"none\n" ); +seq_puts (s,"none\n" );break ; }
Signature · 1 line
1.7.9.5