Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp611962ybg; Wed, 23 Oct 2019 03:11:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJ74OUf4oGltJkawthC9pE+ZA6Hx9fCRJcY096efFIexk6MPsVjL3ViZhXXUnEhTgduieO X-Received: by 2002:a50:cb85:: with SMTP id k5mr36275870edi.131.1571825503677; Wed, 23 Oct 2019 03:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571825503; cv=none; d=google.com; s=arc-20160816; b=pTk/dPEplWygr7uJ6NaThnBx3VaOZkbq4GTut8D/tJJuu7qktoFlmB/gTDqRO51FE6 QhP78pDD2HMV9Mx/HCwLEHSNoPb0Xr5yjiQLNC+Hb0hVCS+fL3anCQOdZ+TKycf+lF8A biGO5Rp6PgqDr4ehngAg41alXVyIUfxEjQRKkn0ORg5u+8H5QZCG1nouSGml9gzNIQdh Ba/JiDTS50Ic+GzoPpNvfDK0U72AceAaIHRt5tb5sfLM0F/9Q6VeYQDXaP5t8vL+0k4B K478qtC9CibG5rNxS6dfmGvdNBjj58pSUYYARU1aoXUjkm62tBgdQ22bIFo8oq9edTt9 YMDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9uAybyicxo2gw3uVW8b5qH4zjAAO2fuhAA7FE9Cx2o4=; b=BhYuIJ95iIxFPG3ViL2auYP/rvwDeJ4gF23HVdw4Bovg8zgDA0yZ6DlUFwN/0IVbNm gnGpEPnuTw8Wrzi/OSF6dMtMh/9/L82CASJSI8HbaQA1LZbVDv6n+GKNwiAiviXG9jfj IBa9Vh5Tm2Jogji4U716QtbB6YN4gx9V/T5veA5ub0ZcRLh4YZpslgoLHnWkHvz60ALy pHTHG1+hedsngrxLBrU+NCh6FktVA69MsVK1eesyQYrOF4RelUOtFJ79VqAuJzqrytC3 SE2KoSMymtLfSYDAHAKVpTGgQyjPEgWZsxzcJHAaoudBGuRWqXF28/aBpIJS/QrCJpJq R7rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si1169692ejk.376.2019.10.23.03.11.19; Wed, 23 Oct 2019 03:11:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391034AbfJWKKD (ORCPT + 99 others); Wed, 23 Oct 2019 06:10:03 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:36707 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390933AbfJWKKD (ORCPT ); Wed, 23 Oct 2019 06:10:03 -0400 Received: by mail-ed1-f67.google.com with SMTP id h2so15311461edn.3; Wed, 23 Oct 2019 03:10:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9uAybyicxo2gw3uVW8b5qH4zjAAO2fuhAA7FE9Cx2o4=; b=dNmhHMJLR/jF1JPq6L+rAJM5ZPx/ySXEUThPVyLrz3yPlRvfF84MkWOVPARfXBs54W 7Wx4CgWJ1lsVLnS9Rk+DDxm+yuwT7YwxgrdnjhwKX2f8+G0Lq+BB1J0dfSgds5Ds3PvU PtpbtffSQ77SYFKzXfFI0a+E7BS0pJC9etE5XXxp4Gz/7KA+m3wWxKxSkhk1wu7iL3qM oDbIZqgglTpJ49H7mA/4nJ9t0AERmdrnk1NSnA6xya8Ss1Sjm/c6J48CdGx3jSAFwsCa u4tEOu/LCoGJHPGRsq5mGgGzGvvOJPLaQzUZAiYtT+48eorLJodOSA9gc0EhcJAnKNm2 tJkQ== X-Gm-Message-State: APjAAAXW4MMex+GLYFZ+Fzu0yFzd2742uV6EQgX+OzZO7oaxc9MFRylQ yqgsWOBZQHi45ysKNQ9E5ZmupudC X-Received: by 2002:a50:fb0d:: with SMTP id d13mr13099867edq.200.1571825401263; Wed, 23 Oct 2019 03:10:01 -0700 (PDT) Received: from pi3 ([194.230.155.217]) by smtp.googlemail.com with ESMTPSA id o31sm851700edd.17.2019.10.23.03.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 03:10:00 -0700 (PDT) Date: Wed, 23 Oct 2019 12:09:58 +0200 From: Krzysztof Kozlowski To: Arnd Bergmann Cc: Kukjin Kim , Felipe Balbi , Greg Kroah-Hartman , linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH 04/36] usb: gadget: s3c-hsudc: remove platform header dependency Message-ID: <20191023100958.GB10630@pi3> References: <20191010202802.1132272-1-arnd@arndb.de> <20191010203043.1241612-1-arnd@arndb.de> <20191010203043.1241612-4-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191010203043.1241612-4-arnd@arndb.de> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 10, 2019 at 10:29:48PM +0200, Arnd Bergmann wrote: > There is no real phy driver, so s3c-hsudc just pokes the registers > itself. Improve this a little by making it a platform data callback > like we do for gpios. > > There is only one board using this driver, and it's unlikely > that another would be added, so this is a minimal workaround. > > Signed-off-by: Arnd Bergmann > --- > .../include/mach/regs-s3c2443-clock.h | 49 +++++++++++++++++ > arch/arm/plat-samsung/devs.c | 3 + > drivers/usb/gadget/udc/s3c-hsudc.c | 55 ++----------------- > include/linux/platform_data/s3c-hsudc.h | 2 + > 4 files changed, 58 insertions(+), 51 deletions(-) > > diff --git a/arch/arm/mach-s3c24xx/include/mach/regs-s3c2443-clock.h b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2443-clock.h > index 6bf924612b06..682759549e63 100644 > --- a/arch/arm/mach-s3c24xx/include/mach/regs-s3c2443-clock.h > +++ b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2443-clock.h > @@ -10,6 +10,8 @@ > #ifndef __ASM_ARM_REGS_S3C2443_CLOCK > #define __ASM_ARM_REGS_S3C2443_CLOCK > > +#include > + > #define S3C2443_CLKREG(x) ((x) + S3C24XX_VA_CLKPWR) > > #define S3C2443_PLLCON_MDIVSHIFT 16 > @@ -184,5 +186,52 @@ s3c2443_get_epll(unsigned int pllval, unsigned int baseclk) > return (unsigned int)fvco; > } > > +static inline void s3c_hsudc_init_phy(void) > +{ > + u32 cfg; > + > + cfg = readl(S3C2443_PWRCFG) | S3C2443_PWRCFG_USBPHY; > + writel(cfg, S3C2443_PWRCFG); > + > + cfg = readl(S3C2443_URSTCON); > + cfg |= (S3C2443_URSTCON_FUNCRST | S3C2443_URSTCON_PHYRST); > + writel(cfg, S3C2443_URSTCON); > + mdelay(1); > + > + cfg = readl(S3C2443_URSTCON); > + cfg &= ~(S3C2443_URSTCON_FUNCRST | S3C2443_URSTCON_PHYRST); > + writel(cfg, S3C2443_URSTCON); > + > + cfg = readl(S3C2443_PHYCTRL); > + cfg &= ~(S3C2443_PHYCTRL_CLKSEL | S3C2443_PHYCTRL_DSPORT); > + cfg |= (S3C2443_PHYCTRL_EXTCLK | S3C2443_PHYCTRL_PLLSEL); > + writel(cfg, S3C2443_PHYCTRL); > + > + cfg = readl(S3C2443_PHYPWR); > + cfg &= ~(S3C2443_PHYPWR_FSUSPEND | S3C2443_PHYPWR_PLL_PWRDN | > + S3C2443_PHYPWR_XO_ON | S3C2443_PHYPWR_PLL_REFCLK | > + S3C2443_PHYPWR_ANALOG_PD); > + cfg |= S3C2443_PHYPWR_COMMON_ON; > + writel(cfg, S3C2443_PHYPWR); > + > + cfg = readl(S3C2443_UCLKCON); > + cfg |= (S3C2443_UCLKCON_DETECT_VBUS | S3C2443_UCLKCON_FUNC_CLKEN | > + S3C2443_UCLKCON_TCLKEN); > + writel(cfg, S3C2443_UCLKCON); > +} > + > +static inline void s3c_hsudc_uninit_phy(void) > +{ > + u32 cfg; > + > + cfg = readl(S3C2443_PWRCFG) & ~S3C2443_PWRCFG_USBPHY; > + writel(cfg, S3C2443_PWRCFG); > + > + writel(S3C2443_PHYPWR_FSUSPEND, S3C2443_PHYPWR); > + > + cfg = readl(S3C2443_UCLKCON) & ~S3C2443_UCLKCON_FUNC_CLKEN; > + writel(cfg, S3C2443_UCLKCON); > +} > + > #endif /* __ASM_ARM_REGS_S3C2443_CLOCK */ > > diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c > index 1d1fa068d228..6e4c1cb07104 100644 > --- a/arch/arm/plat-samsung/devs.c > +++ b/arch/arm/plat-samsung/devs.c > @@ -40,6 +40,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -1038,6 +1039,8 @@ struct platform_device s3c_device_usb_hsudc = { > void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd) > { > s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usb_hsudc); > + pd->phy_init = s3c_hsudc_init_phy; > + pd->phy_uninit = s3c_hsudc_uninit_phy; > } > #endif /* CONFIG_PLAT_S3C24XX */ > > diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c > index 858993c73442..d482cbb4bb4d 100644 > --- a/drivers/usb/gadget/udc/s3c-hsudc.c > +++ b/drivers/usb/gadget/udc/s3c-hsudc.c > @@ -30,8 +30,6 @@ > #include > #include > > -#include > - > #define S3C_HSUDC_REG(x) (x) > > /* Non-Indexed Registers */ > @@ -186,53 +184,6 @@ static inline void __orr32(void __iomem *ptr, u32 val) > writel(readl(ptr) | val, ptr); > } > > -static void s3c_hsudc_init_phy(void) > -{ > - u32 cfg; > - > - cfg = readl(S3C2443_PWRCFG) | S3C2443_PWRCFG_USBPHY; > - writel(cfg, S3C2443_PWRCFG); > - > - cfg = readl(S3C2443_URSTCON); > - cfg |= (S3C2443_URSTCON_FUNCRST | S3C2443_URSTCON_PHYRST); > - writel(cfg, S3C2443_URSTCON); > - mdelay(1); > - > - cfg = readl(S3C2443_URSTCON); > - cfg &= ~(S3C2443_URSTCON_FUNCRST | S3C2443_URSTCON_PHYRST); > - writel(cfg, S3C2443_URSTCON); > - > - cfg = readl(S3C2443_PHYCTRL); > - cfg &= ~(S3C2443_PHYCTRL_CLKSEL | S3C2443_PHYCTRL_DSPORT); > - cfg |= (S3C2443_PHYCTRL_EXTCLK | S3C2443_PHYCTRL_PLLSEL); > - writel(cfg, S3C2443_PHYCTRL); > - > - cfg = readl(S3C2443_PHYPWR); > - cfg &= ~(S3C2443_PHYPWR_FSUSPEND | S3C2443_PHYPWR_PLL_PWRDN | > - S3C2443_PHYPWR_XO_ON | S3C2443_PHYPWR_PLL_REFCLK | > - S3C2443_PHYPWR_ANALOG_PD); > - cfg |= S3C2443_PHYPWR_COMMON_ON; > - writel(cfg, S3C2443_PHYPWR); > - > - cfg = readl(S3C2443_UCLKCON); > - cfg |= (S3C2443_UCLKCON_DETECT_VBUS | S3C2443_UCLKCON_FUNC_CLKEN | > - S3C2443_UCLKCON_TCLKEN); > - writel(cfg, S3C2443_UCLKCON); > -} > - > -static void s3c_hsudc_uninit_phy(void) > -{ > - u32 cfg; > - > - cfg = readl(S3C2443_PWRCFG) & ~S3C2443_PWRCFG_USBPHY; > - writel(cfg, S3C2443_PWRCFG); > - > - writel(S3C2443_PHYPWR_FSUSPEND, S3C2443_PHYPWR); > - > - cfg = readl(S3C2443_UCLKCON) & ~S3C2443_UCLKCON_FUNC_CLKEN; > - writel(cfg, S3C2443_UCLKCON); > -} > - > /** > * s3c_hsudc_complete_request - Complete a transfer request. > * @hsep: Endpoint to which the request belongs. > @@ -1188,7 +1139,8 @@ static int s3c_hsudc_start(struct usb_gadget *gadget, > > pm_runtime_get_sync(hsudc->dev); > > - s3c_hsudc_init_phy(); > + if (hsudc->pd->phy_init) > + hsudc->pd->gpio_init(); Copy paste error - phy_init(). Are here (and in previous usb gadget patch) any dependencies? If so, I would need an ack to take it through samsung-soc. Best regards, Krzysztof > if (hsudc->pd->gpio_init) > hsudc->pd->gpio_init(); > > @@ -1210,7 +1162,8 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget) > > spin_lock_irqsave(&hsudc->lock, flags); > hsudc->gadget.speed = USB_SPEED_UNKNOWN; > - s3c_hsudc_uninit_phy(); > + if (hsudc->pd->phy_uninit) > + hsudc->pd->phy_uninit(); > > pm_runtime_put(hsudc->dev); > > diff --git a/include/linux/platform_data/s3c-hsudc.h b/include/linux/platform_data/s3c-hsudc.h > index 4dc9b8760166..a170939832d5 100644 > --- a/include/linux/platform_data/s3c-hsudc.h > +++ b/include/linux/platform_data/s3c-hsudc.h > @@ -26,6 +26,8 @@ struct s3c24xx_hsudc_platdata { > unsigned int epnum; > void (*gpio_init)(void); > void (*gpio_uninit)(void); > + void (*phy_init)(void); > + void (*phy_uninit)(void); > }; > > #endif /* __LINUX_USB_S3C_HSUDC_H */ > -- > 2.20.0 >