From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 B4DC115E5D2 for ; Thu, 29 Aug 2024 08:30:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724920255; cv=none; b=M0vhNDC/+arIAJr6lFpxBSA/rzcfwczED6jPL0AxT4Zsnvs+ltZShRN5kDfWBc72r9cdV5A+NENox+2B29mcZ9GPOH/cdmVBR23WMbOQQXX9mLZiWIhmp8aYjfTFLxgsibBKQXYBuTn4E0ZiXcT9PebzynoSGT2ZeTMbrENMNwM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724920255; c=relaxed/simple; bh=zsRlTwTVxlGdUebG4U9l/6351oc6rYJx9FuwhzGC6rE=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=K17UaHjbQWgJiGAkRGLPApUxex7PIDUjCiLvd2yXWFGW5/HEoh14Ossqqrx3ZbO9uwnF2kzEZ7uD2pqvd5AkQnxBmT5C8eU33YpSQsUBOeweQY9q7Ivdy3CRttfVgABR2kuHjGNXdmzDtDrJyDrwhfunErWzc5EQniOM8FRNQSk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hZUzzT2X; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hZUzzT2X" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42bac9469e8so3286095e9.3 for ; Thu, 29 Aug 2024 01:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724920252; x=1725525052; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=/fW71FS0lmTuV1wHWmHmOLHgNUvex8iYSoVrr1nHB6s=; b=hZUzzT2X/mV4DMzsi9yoJEMQUFCpeE07A4XhcJXheGoBBL1/ZgA3di7X9fwYJCU+dF uFpI6mqw4CNrdw4BzMCalI/nAv42Al5cHcqcgllmZmSTr5YmsrHvqWdvfIHih4D9vW3N T+7+nalypG5mCyIQXZoyYtTCWpiAd/A4kMCYVi/QEb5F/JRD8b6wHzzWs6+bHWoLX5rO y5DidyEd89N4QJUsp8Mh5XhmZx2693yJoNxS93xz3TJmyBLmpZMCfs101Jqggtvmeg1C VGIDWXCqG+nB2fydzx7IuAEiqyQJBJpOZQ4jafwrX3CvuAEi2ttyqgHheNYiv2/6b15b D3vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724920252; x=1725525052; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=/fW71FS0lmTuV1wHWmHmOLHgNUvex8iYSoVrr1nHB6s=; b=hHiGA5fC60bubWyLb/cM7QBF4PiAE9+24ux4KeDIr6GmQVkfk8VHhkSf3cPwkA1vxg urzsr6TsiZz7iGf0BpmjeSAqsGF7RXgQi4C6E1jlgeHwtOBJKueHPGXs35a6/NbqS2qv 0T67c/FipZA7Lz9gREWKkHCIqzxNcAA/pjzIZOKSQtmezalf3ZZ4fohIZFr5udVRCvKO f2oVBxVo9C1TlSFS1AMzPPhns2pR7BAdC1wyv9u3+/OVztRs0USRI2TMke+b1BHhKHl1 9b7JcfeWOBvVfhkpyQld+r4VMF0xSNsr4DdL/O0yOB5N+9JtGN8l/8GSXEu+VGUGy7xL BfHw== X-Forwarded-Encrypted: i=1; AJvYcCURnIUyU8NuiST9FPJVjxQ6qkWEgUrSBW+mdd+ppxmB5hDBrUBSFRY30KeNFNqKF9liYO/hLmZbWwdF8h26@vger.kernel.org X-Gm-Message-State: AOJu0YzQrtq2YRIZfc7pVnn/ItYo0Z5H0tjiwNGwds8S0vLAfxjBQ0v0 DHRbwTcSKOskSc4Fkd+SezSNrcBPga+UjYFMaYqs4cLcaxstXoWCZ5fFbNlwa/w= X-Google-Smtp-Source: AGHT+IHGuznT7s9K3x5HeSkF7fCIjIIH9qT4bN2dkHvKGxtIsO2SxucelcGw+Ke16+3q8DaHNkERJA== X-Received: by 2002:a05:600c:5110:b0:426:6696:9e50 with SMTP id 5b1f17b1804b1-42bb02591d1mr12515665e9.14.1724920251352; Thu, 29 Aug 2024 01:30:51 -0700 (PDT) Received: from ?IPV6:2a01:e0a:982:cbb0:12f5:c9c:a0e1:6915? ([2a01:e0a:982:cbb0:12f5:c9c:a0e1:6915]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba639652esm44084155e9.2.2024.08.29.01.30.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Aug 2024 01:30:50 -0700 (PDT) Message-ID: <79a643de-9808-4866-9e41-8bd5ab55ffed@linaro.org> Date: Thu, 29 Aug 2024 10:30:49 +0200 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: neil.armstrong@linaro.org Reply-To: neil.armstrong@linaro.org Subject: Re: [PATCH 2/2] phy: add NXP PTN3222 eUSB2 to USB2 redriver To: Dmitry Baryshkov , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Konrad Dybcio , linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20240829-nxp-ptn3222-v1-0-46906bc4747a@linaro.org> <20240829-nxp-ptn3222-v1-2-46906bc4747a@linaro.org> Content-Language: en-US, fr Autocrypt: addr=neil.armstrong@linaro.org; keydata= xsBNBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB AAHNKk5laWwgQXJtc3Ryb25nIDxuZWlsLmFybXN0cm9uZ0BsaW5hcm8ub3JnPsLAkQQTAQoA OwIbIwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgBYhBInsPQWERiF0UPIoSBaat7Gkz/iuBQJk Q5wSAhkBAAoJEBaat7Gkz/iuyhMIANiD94qDtUTJRfEW6GwXmtKWwl/mvqQtaTtZID2dos04 YqBbshiJbejgVJjy+HODcNUIKBB3PSLaln4ltdsV73SBcwUNdzebfKspAQunCM22Mn6FBIxQ GizsMLcP/0FX4en9NaKGfK6ZdKK6kN1GR9YffMJd2P08EO8mHowmSRe/ExAODhAs9W7XXExw UNCY4pVJyRPpEhv373vvff60bHxc1k/FF9WaPscMt7hlkbFLUs85kHtQAmr8pV5Hy9ezsSRa GzJmiVclkPc2BY592IGBXRDQ38urXeM4nfhhvqA50b/nAEXc6FzqgXqDkEIwR66/Gbp0t3+r yQzpKRyQif3OwE0ETVkGzwEIALyKDN/OGURaHBVzwjgYq+ZtifvekdrSNl8TIDH8g1xicBYp QTbPn6bbSZbdvfeQPNCcD4/EhXZuhQXMcoJsQQQnO4vwVULmPGgtGf8PVc7dxKOeta+qUh6+ SRh3vIcAUFHDT3f/Zdspz+e2E0hPV2hiSvICLk11qO6cyJE13zeNFoeY3ggrKY+IzbFomIZY 4yG6xI99NIPEVE9lNBXBKIlewIyVlkOaYvJWSV+p5gdJXOvScNN1epm5YHmf9aE2ZjnqZGoM Mtsyw18YoX9BqMFInxqYQQ3j/HpVgTSvmo5ea5qQDDUaCsaTf8UeDcwYOtgI8iL4oHcsGtUX oUk33HEAEQEAAcLAXwQYAQIACQUCTVkGzwIbDAAKCRAWmrexpM/4rrXiB/sGbkQ6itMrAIfn M7IbRuiSZS1unlySUVYu3SD6YBYnNi3G5EpbwfBNuT3H8//rVvtOFK4OD8cRYkxXRQmTvqa3 3eDIHu/zr1HMKErm+2SD6PO9umRef8V82o2oaCLvf4WeIssFjwB0b6a12opuRP7yo3E3gTCS KmbUuLv1CtxKQF+fUV1cVaTPMyT25Od+RC1K+iOR0F54oUJvJeq7fUzbn/KdlhA8XPGzwGRy 4zcsPWvwnXgfe5tk680fEKZVwOZKIEuJC3v+/yZpQzDvGYJvbyix0lHnrCzq43WefRHI5XTT QbM0WUIBIcGmq38+OgUsMYu4NzLu7uZFAcmp6h8g Organization: Linaro In-Reply-To: <20240829-nxp-ptn3222-v1-2-46906bc4747a@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 29/08/2024 10:21, Dmitry Baryshkov wrote: > The NXP PTN3222 is the single-port eUSB2 to USB2 redriver that performs > translation between eUSB2 and USB2 signalling schemes. It supports all > three data rates: Low Speed, Full Speed and High Speed. > > The reset state enables autonegotiation of the PHY role and of the data > rate, so no additional programming is required. > > Signed-off-by: Dmitry Baryshkov > --- > drivers/phy/Kconfig | 11 ++++ > drivers/phy/Makefile | 1 + > drivers/phy/phy-nxp-ptn3222.c | 119 ++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 131 insertions(+) > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig > index dfab1c66b3e5..cb06a7f79740 100644 > --- a/drivers/phy/Kconfig > +++ b/drivers/phy/Kconfig > @@ -82,6 +82,17 @@ config PHY_AIROHA_PCIE > This driver create the basic PHY instance and provides initialize > callback for PCIe GEN3 port. > > +config PHY_NXP_PTN3222 > + tristate "NXP PTN3222 1-port eUSB2 to USB2 redriver" > + depends on I2C > + depends on OF > + select GENERIC_PHY > + help > + Enable this to support NXP PTN3222 1-port eUSB2 to USB2 Redriver. > + This redriver performs translation between eUSB2 and USB2 signalling > + schemes. It supports all three USB 2.0 data rates: Low Speed, Full > + Speed and High Speed. > + > source "drivers/phy/allwinner/Kconfig" > source "drivers/phy/amlogic/Kconfig" > source "drivers/phy/broadcom/Kconfig" > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile > index 5fcbce5f9ab1..b64247046575 100644 > --- a/drivers/phy/Makefile > +++ b/drivers/phy/Makefile > @@ -11,6 +11,7 @@ obj-$(CONFIG_PHY_XGENE) += phy-xgene.o > obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o > obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o > obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o > +obj-$(CONFIG_PHY_NXP_PTN3222) += phy-nxp-ptn3222.o > obj-y += allwinner/ \ > amlogic/ \ > broadcom/ \ > diff --git a/drivers/phy/phy-nxp-ptn3222.c b/drivers/phy/phy-nxp-ptn3222.c > new file mode 100644 > index 000000000000..429a91910f14 > --- /dev/null > +++ b/drivers/phy/phy-nxp-ptn3222.c > @@ -0,0 +1,119 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2024, Linaro Limited > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define NUM_SUPPLIES 2 > + > +struct ptn3222 { > + struct i2c_client *client; > + struct phy *phy; > + struct gpio_desc *reset_gpio; > + struct regulator_bulk_data supplies[NUM_SUPPLIES]; > +}; > + > +static int ptn3222_init(struct phy *phy) > +{ > + struct ptn3222 *ptn3222 = phy_get_drvdata(phy); > + int ret; > + > + ret = regulator_bulk_enable(NUM_SUPPLIES, ptn3222->supplies); > + if (ret) > + return ret; > + > + gpiod_set_value_cansleep(ptn3222->reset_gpio, 0); > + > + return 0; > +} > + > +static int ptn3222_exit(struct phy *phy) > +{ > + struct ptn3222 *ptn3222 = phy_get_drvdata(phy); > + > + gpiod_set_value_cansleep(ptn3222->reset_gpio, 1); > + > + return regulator_bulk_disable(NUM_SUPPLIES, ptn3222->supplies); > +} > + > +static const struct phy_ops ptn3222_ops = { > + .init = ptn3222_init, > + .exit = ptn3222_exit, > + .owner = THIS_MODULE, > +}; > + > +static int ptn3222_probe(struct i2c_client *client) > +{ > + struct device *dev = &client->dev; > + struct phy_provider *phy_provider; > + struct ptn3222 *ptn3222; > + int ret; > + > + ptn3222 = devm_kzalloc(dev, sizeof(*ptn3222), GFP_KERNEL); > + if (!ptn3222) > + return -ENOMEM; > + > + ptn3222->client = client; > + > + ptn3222->reset_gpio = devm_gpiod_get_optional(dev, "reset", > + GPIOD_OUT_HIGH); > + if (IS_ERR(ptn3222->reset_gpio)) > + return dev_err_probe(dev, PTR_ERR(ptn3222->reset_gpio), > + "unable to acquire reset gpio\n"); > + > + ptn3222->supplies[0].supply = "vdd3v3"; > + ptn3222->supplies[0].init_load_uA = 11000; > + ptn3222->supplies[1].supply = "vdd1v8"; > + ptn3222->supplies[1].init_load_uA = 55000; > + > + ret = devm_regulator_bulk_get(dev, > + NUM_SUPPLIES, > + ptn3222->supplies); Suggestion only, you could switch to devm_regulator_bulk_get_const() > + if (ret) > + return ret; > + > + ptn3222->phy = devm_phy_create(dev, dev->of_node, &ptn3222_ops); > + if (IS_ERR(ptn3222->phy)) { > + dev_err(dev, "failed to create PHY: %d\n", ret); > + return PTR_ERR(ptn3222->phy); > + } > + > + phy_set_drvdata(ptn3222->phy, ptn3222); > + > + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); > + > + return PTR_ERR_OR_ZERO(phy_provider); > +} > + > +static const struct i2c_device_id ptn3222_table[] = { > + { "ptn3222" }, > + { } > +}; > +MODULE_DEVICE_TABLE(i2c, ptn3222_table); > + > +static const struct of_device_id ptn3222_of_table[] = { > + { .compatible = "nxp,ptn3222" }, > + { } > +}; > +MODULE_DEVICE_TABLE(of, ptn3222_of_table); > + > +static struct i2c_driver ptn3222_driver = { > + .driver = { > + .name = "ptn3222", > + .of_match_table = ptn3222_of_table, > + }, > + .probe = ptn3222_probe, > + .id_table = ptn3222_table, > +}; > + > +module_i2c_driver(ptn3222_driver); > + > +MODULE_DESCRIPTION("NXP PTN3222 eUSB2 Redriver driver"); > +MODULE_LICENSE("GPL"); > Apart that, it looks fine, please add my: Reviewed-by: Neil Armstrong