From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB1AB187353 for ; Fri, 23 Aug 2024 08:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403458; cv=none; b=hG8Xa+97pmAX8Q3A9l2q5HtWgPKYagrIqYsOZvGt1Dls5ivHX+IgNmpGGn1A1Y0qW1QGgFS1rxdbAnOwMK8/So4HwBCr7sImSRI0bgbQNbkkZf1YFv3RSbefFTkKYIR8IEwWj82z6RqJoi/VG/g0piyPGnEuC1LtAEkgxMQfVHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403458; c=relaxed/simple; bh=8lnr6Y8CYYR/tsZAaXobHIHOJeKtPwwM0WSm4dTdVDA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZQHdBgEqJ7BVOeobTPIbgiE95R3pnnX1cWwTyhCU0J3xrDy5D2f/ThdZEF3vMHFb4Qf3fWPjPI6oqipgSEuDKDIeXfa4TL1LeTy+0shV3z/WGrHEoyjqXv5MvE+TbX8uFGh8BwPnJ8PE6f64LVuqYQaTg10i4qkKYUdYjZh4rQI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=VhVBZE5L; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="VhVBZE5L" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5bec4fc82b0so4929187a12.1 for ; Fri, 23 Aug 2024 01:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1724403454; x=1725008254; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=/VK+R1YErGMIO7vYDEQLL4B3Ghiw/eVr2mZ+qQpA7ME=; b=VhVBZE5L/aEEE2/7LjYy06WdCtsSgxaG+d6aA7NeA94fGwTS5kX1ydoD8o2qTuYP/B IvT5TJ87fAAQybiZKAeGQvZpM/3q4Ca9eXDLUzzDxqxp0M/IKV0POPl4ZTyhVNjyNLxp tu7hN056Gk/pr+OwRiZrugubbh89cjJ5rf5U7+c3MjsJRP+pS5VRHhQIb+XizvykEjHo LlL+H2lI+kd3hE1Izzz/M7ju5MpUbKzvGK6Yoq1p0q9qs0faP6t3zmyqjCIZTrzs8FdF XCin7p/7dHOa0BH9cTIrsjetG1CKTvEg19UyWqtp+wW4hu8G+FdwMkYBn9LH6N+AvelU 4IOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724403454; x=1725008254; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/VK+R1YErGMIO7vYDEQLL4B3Ghiw/eVr2mZ+qQpA7ME=; b=BrdEbcJws+ZJo3eu04RjMI+kLNKOZbz7B0Y82AQxIZOY/Y4MZ9Kwd/jpvUO8+561p1 P+31mBlLkTkD8teR/5jIK2NgajUKPRVdrdZbPQpUrpHmjUmU3gijd9yI+IjK5hhPyVqh GGPd9Epnf+R8CLnhDt9B2bI6J1G3L27Qmbsk+ikdRI/Y5S0qrZUW4WdQrHbGdAgDS5RH w4lwU9CexPassoWcJt/DyT5yAkvXn4/l2kJowgWE3L5BI4mHPmENtFdO8s6+hOmBMCCe YRVhZ++jvB0IxibNltHjS70zShXJ5ro6uzd0wOOZ4fh2BoMOH1bOOXhW3XOSdB8sIr/Y STBg== X-Forwarded-Encrypted: i=1; AJvYcCX3l/eWmFV4V8vcUtauS9EbzFnZzz4YVpCOG46vFa+/vgm6lYr5kfltxcsLKL4WaELWn3g6/be80COC@vger.kernel.org X-Gm-Message-State: AOJu0Yw/O9JeU2aCN169tPrMMyEeqPxi3ErmhnciSRKvQ/nXZgb5OUXH B+MNMu/Tke+adixO0WkB9K0Kbhc+SQa8R9DQmdSwn1RqhXXOkFaGuzymIfv38xg= X-Google-Smtp-Source: AGHT+IEuOD6mMoOYP1+ZXn8J654fsnrlqdSXKZuQL602YsnGpaYCCO0kwwL9QjY/ps2l0W7ExxRiUw== X-Received: by 2002:a17:906:c144:b0:a86:91a5:4d09 with SMTP id a640c23a62f3a-a86a309ae59mr140738466b.26.1724403454000; Fri, 23 Aug 2024 01:57:34 -0700 (PDT) Received: from [192.168.50.4] ([82.78.167.177]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a868f299e28sm230756866b.56.2024.08.23.01.57.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Aug 2024 01:57:33 -0700 (PDT) Message-ID: <8faa6b6d-a013-4a71-a8b7-af02ac92d94b@tuxon.dev> Date: Fri, 23 Aug 2024 11:57:30 +0300 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 10/16] phy: renesas: rcar-gen3-usb2: Add support to initialize the bus Content-Language: en-US To: Biju Das , "vkoul@kernel.org" , "kishon@kernel.org" , "robh@kernel.org" , "krzk+dt@kernel.org" , "conor+dt@kernel.org" , "p.zabel@pengutronix.de" , "geert+renesas@glider.be" , "magnus.damm@gmail.com" , "gregkh@linuxfoundation.org" , "mturquette@baylibre.com" , "sboyd@kernel.org" , Yoshihiro Shimoda , "ulf.hansson@linaro.org" Cc: "linux-phy@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-clk@vger.kernel.org" , "linux-pm@vger.kernel.org" , Claudiu Beznea References: <20240822152801.602318-1-claudiu.beznea.uj@bp.renesas.com> <20240822152801.602318-11-claudiu.beznea.uj@bp.renesas.com> From: claudiu beznea In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, Biju, On 23.08.2024 10:35, Biju Das wrote: > Hi Claudiu, > >> -----Original Message----- >> From: Claudiu >> Sent: Thursday, August 22, 2024 4:28 PM >> Subject: [PATCH 10/16] phy: renesas: rcar-gen3-usb2: Add support to initialize the bus >> >> From: Claudiu Beznea >> >> The Renesas RZ/G3S need to initialize the USB BUS before transferring data due to hardware limitation. >> As the register that need to be touched for this is in the address space of the USB PHY, and the UBS >> PHY need to be initialized before any other USB drivers handling data transfer, add support to >> initialize the USB BUS. >> >> As the USB PHY is probed before any other USB drivers that enables clocks and de-assert the reset >> signals and the BUS initialization is done in the probe phase, we need to add code to de-assert reset >> signal and runtime resume the device (which enables its clocks) before accessing the registers. >> >> As the reset signals are not required by the USB PHY driver for the other USB PHY hardware variants, >> the reset signals and runtime PM was handled only in the function that initialize the USB BUS. >> >> The PHY initialization was done right after runtime PM enable to have all in place when the PHYs are >> registered. > > There is no user for this patch. The first user is RZ/G3S and you should merge this patch with > next one. I think this is a matter of taste... This is how I usually format the patches (for scenarios like this) and got no request for squashing. Anyway, I can do it your way, too. Thank you, Claudiu Beznea > > Cheers, > Biju > >> >> Signed-off-by: Claudiu Beznea >> --- >> drivers/phy/renesas/phy-rcar-gen3-usb2.c | 50 ++++++++++++++++++++++-- >> 1 file changed, 47 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c >> index 7594f64eb737..cf4299cea579 100644 >> --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c >> +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c >> @@ -19,12 +19,14 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> >> /******* USB2.0 Host registers (original offset is +0x200) *******/ >> #define USB2_INT_ENABLE 0x000 >> +#define USB2_AHB_BUS_CTR 0x008 >> #define USB2_USBCTR 0x00c >> #define USB2_SPD_RSM_TIMSET 0x10c >> #define USB2_OC_TIMSET 0x110 >> @@ -40,6 +42,10 @@ >> #define USB2_INT_ENABLE_USBH_INTB_EN BIT(2) /* For EHCI */ >> #define USB2_INT_ENABLE_USBH_INTA_EN BIT(1) /* For OHCI */ >> >> +/* AHB_BUS_CTR */ >> +#define USB2_AHB_BUS_CTR_MBL_MASK GENMASK(1, 0) >> +#define USB2_AHB_BUS_CTR_MBL_INCR4 2 >> + >> /* USBCTR */ >> #define USB2_USBCTR_DIRPD BIT(2) >> #define USB2_USBCTR_PLL_RST BIT(1) >> @@ -111,6 +117,7 @@ struct rcar_gen3_chan { >> struct extcon_dev *extcon; >> struct rcar_gen3_phy rphys[NUM_OF_PHYS]; >> struct regulator *vbus; >> + struct reset_control *rstc; >> struct work_struct work; >> struct mutex lock; /* protects rphys[...].powered */ >> enum usb_dr_mode dr_mode; >> @@ -125,6 +132,7 @@ struct rcar_gen3_chan { struct rcar_gen3_phy_drv_data { >> const struct phy_ops *phy_usb2_ops; >> bool no_adp_ctrl; >> + bool init_bus; >> }; >> >> /* >> @@ -650,6 +658,35 @@ static enum usb_dr_mode rcar_gen3_get_dr_mode(struct device_node *np) >> return candidate; >> } >> >> +static int rcar_gen3_phy_usb2_init_bus(struct rcar_gen3_chan *channel) >> +{ >> + struct device *dev = channel->dev; >> + int ret; >> + u32 val; >> + >> + channel->rstc = devm_reset_control_array_get_shared(dev); >> + if (IS_ERR(channel->rstc)) >> + return PTR_ERR(channel->rstc); >> + >> + ret = pm_runtime_resume_and_get(dev); >> + if (ret) >> + return ret; >> + >> + ret = reset_control_deassert(channel->rstc); >> + if (ret) >> + goto rpm_put; >> + >> + val = readl(channel->base + USB2_AHB_BUS_CTR); >> + val &= ~USB2_AHB_BUS_CTR_MBL_MASK; >> + val |= USB2_AHB_BUS_CTR_MBL_INCR4; >> + writel(val, channel->base + USB2_AHB_BUS_CTR); >> + >> +rpm_put: >> + pm_runtime_put(dev); >> + >> + return ret; >> +} >> + >> static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) { >> const struct rcar_gen3_phy_drv_data *phy_data; @@ -703,6 +740,15 @@ static int >> rcar_gen3_phy_usb2_probe(struct platform_device *pdev) >> goto error; >> } >> >> + platform_set_drvdata(pdev, channel); >> + channel->dev = dev; >> + >> + if (phy_data->init_bus) { >> + ret = rcar_gen3_phy_usb2_init_bus(channel); >> + if (ret) >> + goto error; >> + } >> + >> channel->soc_no_adp_ctrl = phy_data->no_adp_ctrl; >> if (phy_data->no_adp_ctrl) >> channel->obint_enable_bits = USB2_OBINT_IDCHG_EN; @@ -733,9 +779,6 @@ static int >> rcar_gen3_phy_usb2_probe(struct platform_device *pdev) >> channel->vbus = NULL; >> } >> >> - platform_set_drvdata(pdev, channel); >> - channel->dev = dev; >> - >> provider = devm_of_phy_provider_register(dev, rcar_gen3_phy_usb2_xlate); >> if (IS_ERR(provider)) { >> dev_err(dev, "Failed to register PHY provider\n"); @@ -762,6 +805,7 @@ static void >> rcar_gen3_phy_usb2_remove(struct platform_device *pdev) >> if (channel->is_otg_channel) >> device_remove_file(&pdev->dev, &dev_attr_role); >> >> + reset_control_assert(channel->rstc); >> pm_runtime_disable(&pdev->dev); >> }; >> >> -- >> 2.39.2 >