Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1965821rwb; Mon, 7 Nov 2022 07:42:32 -0800 (PST) X-Google-Smtp-Source: AMsMyM7XUZJndU6/7fNZGOBoVdpML80J5RDvrba7/mCr4tismNoJUwx1+Ed/SlgVM1kfI6/ieJ65 X-Received: by 2002:a05:6402:2073:b0:461:5462:9dc9 with SMTP id bd19-20020a056402207300b0046154629dc9mr51849653edb.52.1667835752645; Mon, 07 Nov 2022 07:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667835752; cv=none; d=google.com; s=arc-20160816; b=QIQsuakHXMGDr3XfJSRWIQMSdabV/2CCJ6ucpGdt+rM9mHH6Rc8k/6zVNquEpNKsup 74YCU0WUO1fJkrpemTe19Umj3BCulBhDtsqP0rOwj+wBZDfUUn9BGtSBod2QsLQRR6xr MkOu1nbESzE0hL7li3+X2GvF3OGlrLCc8y2uqov/xwkxNAQAl2D+ERvfQJ2+YUKnBeMJ 7sd5yhODROdqYXUzeVzlKdfYQ9nukvlI2+HqHuNx5gqEMN1Pzerqrh4GKqsFVOUpV1bs pj1q8JhKsl3CUZ452hF0PfieKEfH4TyIN5/YI3xHO/UhXMdnkiz3WdilLgBsKHb0ozYI ANTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=SJd93Y5HIkbd3Alvti1JPtGvDBLfYghJCCdXFuuDQuY=; b=oiqby6IXQ+34NbmkmyWX2MI91LaAhvgbRXc4KXWIAv+GaNl8FEqe8d4CHNr5fsb8HM ByCadQBHGU9S9XeEZmXVq60OD0+YODOPXWXvsBCY1HntN9Wpgy8uPjSAWQytuEpu6Xab 3bOlgTyjgqjxvEnSAsLVPsc7tBXCsyBS1Y00Ky0nIEajsYZmYXcpoHofGleNecsXzOhd OGFAyHjavKVQgV7akO0K3sKp/+NAqfxh/xvdwINyqkiXinV9sHeLDIH3WmNv9HUUDUI5 PzPLhm+cqe7SDKUqXh9W4ClJJHYlEVWRHcotL99n9nULv7Solto1s+nEacMC+9Ki/WUB MFmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oa6r8eHO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020aa7d891000000b0045d523bee48si7699482edq.178.2022.11.07.07.42.09; Mon, 07 Nov 2022 07:42:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oa6r8eHO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231461AbiKGPXc (ORCPT + 92 others); Mon, 7 Nov 2022 10:23:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231438AbiKGPX3 (ORCPT ); Mon, 7 Nov 2022 10:23:29 -0500 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A9CECD9; Mon, 7 Nov 2022 07:23:24 -0800 (PST) Received: (Authenticated sender: herve.codina@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 4F5BF240007; Mon, 7 Nov 2022 15:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1667834603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SJd93Y5HIkbd3Alvti1JPtGvDBLfYghJCCdXFuuDQuY=; b=oa6r8eHOhRqhyq8m0OyGQMeXXLO+mcrcHTch6Sxrcj+ToRz4YE1Pjfq5pgFZyZ+KoSMwf9 oZrCPxvhvmALjaTn2UyYyKJIqTOz8HEuqVpkCYHBbMjEAQ0+Q5CWMcFZ7d4np9xSjS1z8M 5ZETcxVWIiJ59CLrOBZzIuIqVfHcmEUNSrMTUfTp60LirRgQzSKMVoAQNrXSnrgPZ6i4lA b4vFUl1iCad/M8DwIiK8RcISyYi7J1BebN4suQzD4xBTVORiwfLer29EeEHbDv/3zhpb28 ykYPaKzQgdmBxAhRPtOFbMb5BlmCoSe3coP40G18XD/FOZ8eMYQP3+QNC8hR5g== Date: Mon, 7 Nov 2022 16:23:19 +0100 From: Herve Codina To: Geert Uytterhoeven Cc: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Greg Kroah-Hartman , Magnus Damm , Gareth Williams , linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Thomas Petazzoni , Miquel Raynal Subject: Re: [PATCH 5/7] usb: gadget: udc: add Renesas RZ/N1 USBF controller support Message-ID: <20221107162319.7945f241@bootlin.com> In-Reply-To: References: <20221107135825.583877-1-herve.codina@bootlin.com> <20221107135825.583877-6-herve.codina@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, On Mon, 7 Nov 2022 15:37:40 +0100 Geert Uytterhoeven wrote: > Hi Herv=C3=A9, >=20 > On Mon, Nov 7, 2022 at 3:00 PM Herve Codina wr= ote: > > Add support for the Renesas USBF controller. > > This controller is an USB2.0 UDC controller available in the > > Renesas r9a06g032 SoC (RZ/N1 family). > > > > Signed-off-by: Herve Codina =20 >=20 > > --- /dev/null > > +++ b/drivers/usb/gadget/udc/renesas_usbf.c =20 >=20 > > +struct usbf_udc { > > + struct usb_gadget gadget; > > + struct usb_gadget_driver *driver; > > + struct device *dev; > > + struct clk_bulk_data *clocks; > > + int nclocks; > > + void __iomem *regs; > > + spinlock_t lock; > > + bool is_remote_wakeup; > > + bool is_usb_suspended; > > + struct usbf_ep ep[USBF_NUM_ENDPOINTS]; > > + /* for EP0 control messages */ > > + enum usbf_ep0state ep0state; > > + struct usbf_req setup_reply; > > + u8 ep0_buf[USBF_EP0_MAX_PCKT_SIZE]; > > +}; =20 >=20 > > +static int usbf_probe(struct platform_device *pdev) > > +{ > > + struct device *dev =3D &pdev->dev; > > + struct usbf_udc *udc; > > + struct usbf_ep *ep; > > + bool h2mode; > > + int irq; > > + int ret; > > + int i; > > + > > + ret =3D r9a06g032_sysctrl_get_usb_h2mode(&h2mode); > > + if (ret) > > + return ret; > > + if (h2mode) { > > + dev_warn(dev, "Disabled in H2 (host) mode\n"); > > + return -ENODEV; > > + } > > + > > + udc =3D devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL); > > + if (!udc) > > + return -ENOMEM; > > + platform_set_drvdata(pdev, udc); > > + > > + udc->dev =3D dev; > > + spin_lock_init(&udc->lock); > > + > > + udc->regs =3D devm_platform_ioremap_resource(pdev, 0); > > + if (IS_ERR(udc->regs)) > > + return PTR_ERR(udc->regs); > > + > > + devm_pm_runtime_enable(&pdev->dev); > > + ret =3D pm_runtime_resume_and_get(&pdev->dev); > > + if (ret < 0) > > + return ret; > > + > > + ret =3D devm_clk_bulk_get_all(dev, &udc->clocks); > > + if (ret < 1) { > > + dev_err(dev, "failed to get clocks %d\n", ret); > > + return ret; > > + } > > + udc->nclocks =3D ret; > > + > > + ret =3D clk_bulk_prepare_enable(udc->nclocks, udc->clocks); > > + if (ret) { > > + dev_err(dev, "can not enable the clock\n"); > > + return ret; > > + } =20 >=20 > As this driver only enables/disables the clocks, perhaps you could > just delegate this to Runtime PM (through the clock domain pointed > by the power-domains property in DT), and drop the .clocks and > .nclocks fields? Yes, indeed. I tested it and it works. I will remove the the clocks handling from this driver in v2 series. >=20 > > +clk_disable: > > + clk_bulk_disable_unprepare(udc->nclocks, udc->clocks); > > + return ret; > > +} > > + > > +static int usbf_remove(struct platform_device *pdev) > > +{ > > + struct usbf_udc *udc =3D platform_get_drvdata(pdev); > > + > > + usb_del_gadget_udc(&udc->gadget); > > + > > + clk_bulk_disable_unprepare(udc->nclocks, udc->clocks); > > + > > + pm_runtime_put(&pdev->dev); > > + > > + return 0; > > +} =20 >=20 > > +MODULE_AUTHOR("Herve Codina "); =20 >=20 > Herv=C3=A9? ;-) Just to be consistent with other places where my email appears, I keep "Herve" :) >=20 > > +MODULE_DESCRIPTION("Renesas R-Car Gen3 & RZ/N1 USB Function driver"); > > +MODULE_LICENSE("GPL"); =20 >=20 > > -- > > 2.37.3 > > =20 >=20 >=20 > -- > Gr{oetje,eeting}s, >=20 > Geert >=20 > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m6= 8k.org >=20 > In personal conversations with technical people, I call myself a hacker. = But > when I'm talking to journalists I just say "programmer" or something like= that. > -- Linus Torvalds Thanks for this review, Herv=C3=A9 --=20 Herv=C3=A9 Codina, Bootlin Embedded Linux and Kernel engineering https://bootlin.com