From patchwork Fri Feb 21 14:31:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 11396739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9D2F930 for ; Fri, 21 Feb 2020 14:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BFB5C24650 for ; Fri, 21 Feb 2020 14:32:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cpm9gQHR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728761AbgBUOcF (ORCPT ); Fri, 21 Feb 2020 09:32:05 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34626 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbgBUOcF (ORCPT ); Fri, 21 Feb 2020 09:32:05 -0500 Received: by mail-wr1-f65.google.com with SMTP id n10so2335328wrm.1; Fri, 21 Feb 2020 06:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xgGLw2Ofj6GfI1cffanXflP+Y9NqQgqHvh8zYDPTu2Y=; b=cpm9gQHRnEkUz/R24rh6u97jy4W8Xd0lxzn7O4RNyKtFbIAR+I05wQTDBOsC72aI9w FZiASeA1MC7M0YInvjcUqLU/dVnTz+7F9vJaXdv5CSSsohVosCvucegzY4Wck6vnrDtg tH/oXWYD9aPXIjyTevZcjN0+f6v46sI97RdO+LDnzBenj5vj26n6Go7Cd/f3n7MLJkjM NqRq1qngBBcVDbT6+KNg+RQ9qmcJA3Nw7JTOM4eW/fJ8YB2m/TTEAx7xwdezsiPAo4z5 1ddyWzBI5GaFHnJOSLltF+ue8Lps+XC+b6goWeTVuTlo2OMQQymiNZCRH4D5oX5/63s7 9KXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xgGLw2Ofj6GfI1cffanXflP+Y9NqQgqHvh8zYDPTu2Y=; b=YZuKaaq5m4Xevv7uWCOdUZe/hnmBnhqAcUPVi7Qj2LFHW6CMjvy30PmcJ4C8uuLhOZ kQfYl02224M+zNZkrgOSlw/FNtT7yamOX2f2nLHb5s/uRmx2vZ9L+rLcnCwqqyRb2KQ1 i6LOp7bYmViIS256VEp+9eVUusjnmsWE18FsIpBVAoJVUS6zoan3H6i9kdWpzAswtzZS OBIW3QgkEkf63mDHGTTvlY8UVW4n5OwMzwVaGxFZxJdRIo3KCirDRciFIT2MDkTgsEsz 3eKVJfOpfC5P9stegEaxZZCdOaqwbjzR7Y6pjm/hIkQrmG7yxTtpP4frzwvNFRjq2aCZ 9dFg== X-Gm-Message-State: APjAAAX0cSMFcehtMGsPZKgSQcCio3zJFHgWOoy//V+ZmaC/iwyMd+su Rj+b9JJv4TijSj+wSdNsCOc= X-Google-Smtp-Source: APXvYqzv2vQgf1IGyMIJfPQNx+ulYro++O5RqJ+epAF8837OgkjXvTsh48vqehZQrfjY9KH0JiYZ/g== X-Received: by 2002:adf:dd0b:: with SMTP id a11mr51517827wrm.150.1582295522412; Fri, 21 Feb 2020 06:32:02 -0800 (PST) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id y185sm4291290wmg.2.2020.02.21.06.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 06:32:01 -0800 (PST) From: Ansuel Smith Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , "David S. Miller" , Rob Herring , Mark Rutland , Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/2] net: mdio: add ipq8064 mdio driver Date: Fri, 21 Feb 2020 15:31:50 +0100 Message-Id: <20200221143153.21186-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Currently ipq806x soc use generi bitbang driver to comunicate with the gmac ethernet interface. Add a dedicated driver created by chunkeey to fix this. Christian Lamparter Signed-off-by: Ansuel Smith --- drivers/net/phy/Kconfig | 8 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-ipq8064.c | 166 +++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 drivers/net/phy/mdio-ipq8064.c diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 9dabe03a668c..ec2a5493a7e8 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -157,6 +157,14 @@ config MDIO_I2C This is library mode. +config MDIO_IPQ8064 + tristate "Qualcomm IPQ8064 MDIO interface support" + depends on HAS_IOMEM && OF_MDIO + depends on MFD_SYSCON + help + This driver supports the MDIO interface found in the network + interface units of the IPQ8064 SoC + config MDIO_MOXART tristate "MOXA ART MDIO interface support" depends on ARCH_MOXART || COMPILE_TEST diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index fe5badf13b65..8f02bd2089f3 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -36,6 +36,7 @@ obj-$(CONFIG_MDIO_CAVIUM) += mdio-cavium.o obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o obj-$(CONFIG_MDIO_HISI_FEMAC) += mdio-hisi-femac.o obj-$(CONFIG_MDIO_I2C) += mdio-i2c.o +obj-$(CONFIG_MDIO_IPQ8064) += mdio-ipq8064.o obj-$(CONFIG_MDIO_MOXART) += mdio-moxart.o obj-$(CONFIG_MDIO_MSCC_MIIM) += mdio-mscc-miim.o obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o diff --git a/drivers/net/phy/mdio-ipq8064.c b/drivers/net/phy/mdio-ipq8064.c new file mode 100644 index 000000000000..74d6b92a6f48 --- /dev/null +++ b/drivers/net/phy/mdio-ipq8064.c @@ -0,0 +1,166 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Qualcomm IPQ8064 MDIO interface driver +// +// Copyright (C) 2019 Christian Lamparter + +#include +#include +#include +#include +#include +#include +#include +#include + +/* MII address register definitions */ +#define MII_ADDR_REG_ADDR 0x10 +#define MII_BUSY BIT(0) +#define MII_WRITE BIT(1) +#define MII_CLKRANGE_60_100M (0 << 2) +#define MII_CLKRANGE_100_150M (1 << 2) +#define MII_CLKRANGE_20_35M (2 << 2) +#define MII_CLKRANGE_35_60M (3 << 2) +#define MII_CLKRANGE_150_250M (4 << 2) +#define MII_CLKRANGE_250_300M (5 << 2) +#define MII_CLKRANGE_MASK GENMASK(4, 2) +#define MII_REG_SHIFT 6 +#define MII_REG_MASK GENMASK(10, 6) +#define MII_ADDR_SHIFT 11 +#define MII_ADDR_MASK GENMASK(15, 11) + +#define MII_DATA_REG_ADDR 0x14 + +#define MII_MDIO_DELAY_USEC (1000) +#define MII_MDIO_RETRY_MSEC (10) + +struct ipq8064_mdio { + struct regmap *base; /* NSS_GMAC0_BASE */ +}; + +static int +ipq8064_mdio_wait_busy(struct ipq8064_mdio *priv) +{ + u32 busy; + + return regmap_read_poll_timeout(priv->base, MII_ADDR_REG_ADDR, busy, + !(busy & MII_BUSY), MII_MDIO_DELAY_USEC, + MII_MDIO_RETRY_MSEC * USEC_PER_MSEC); +} + +static int +ipq8064_mdio_read(struct mii_bus *bus, int phy_addr, int reg_offset) +{ + struct ipq8064_mdio *priv = bus->priv; + u32 miiaddr = MII_BUSY | MII_CLKRANGE_250_300M; + u32 ret_val; + int err; + + /* Reject clause 45 */ + if (reg_offset & MII_ADDR_C45) + return -EOPNOTSUPP; + + miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) | + ((reg_offset << MII_REG_SHIFT) & MII_REG_MASK); + + regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr); + usleep_range(10, 20); + + err = ipq8064_mdio_wait_busy(priv); + if (err) + return err; + + regmap_read(priv->base, MII_DATA_REG_ADDR, &ret_val); + return (int)ret_val; +} + +static int +ipq8064_mdio_write(struct mii_bus *bus, int phy_addr, int reg_offset, u16 data) +{ + struct ipq8064_mdio *priv = bus->priv; + u32 miiaddr = MII_WRITE | MII_BUSY | MII_CLKRANGE_250_300M; + + /* Reject clause 45 */ + if (reg_offset & MII_ADDR_C45) + return -EOPNOTSUPP; + + regmap_write(priv->base, MII_DATA_REG_ADDR, data); + + miiaddr |= ((phy_addr << MII_ADDR_SHIFT) & MII_ADDR_MASK) | + ((reg_offset << MII_REG_SHIFT) & MII_REG_MASK); + + regmap_write(priv->base, MII_ADDR_REG_ADDR, miiaddr); + usleep_range(10, 20); + + return ipq8064_mdio_wait_busy(priv); +} + +static int +ipq8064_mdio_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct ipq8064_mdio *priv; + struct mii_bus *bus; + int ret; + + bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv)); + if (!bus) + return -ENOMEM; + + bus->name = "ipq8064_mdio_bus"; + bus->read = ipq8064_mdio_read; + bus->write = ipq8064_mdio_write; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(&pdev->dev)); + bus->parent = &pdev->dev; + + priv = bus->priv; + priv->base = syscon_node_to_regmap(np); + if (IS_ERR(priv->base) && priv->base != ERR_PTR(-EPROBE_DEFER)) + priv->base = syscon_regmap_lookup_by_phandle(np, "master"); + + if (priv->base == ERR_PTR(-EPROBE_DEFER)) { + return -EPROBE_DEFER; + } else if (IS_ERR(priv->base)) { + dev_err(&pdev->dev, "error getting syscon regmap, error=%pe\n", + priv->base); + return PTR_ERR(priv->base); + } + + ret = of_mdiobus_register(bus, np); + if (ret) + return ret; + + platform_set_drvdata(pdev, bus); + return 0; +} + +static int +ipq8064_mdio_remove(struct platform_device *pdev) +{ + struct mii_bus *bus = platform_get_drvdata(pdev); + + mdiobus_unregister(bus); + + return 0; +} + +static const struct of_device_id ipq8064_mdio_dt_ids[] = { + { .compatible = "qcom,ipq8064-mdio" }, + { } +}; +MODULE_DEVICE_TABLE(of, ipq8064_mdio_dt_ids); + +static struct platform_driver ipq8064_mdio_driver = { + .probe = ipq8064_mdio_probe, + .remove = ipq8064_mdio_remove, + .driver = { + .name = "ipq8064-mdio", + .of_match_table = ipq8064_mdio_dt_ids, + }, +}; + +module_platform_driver(ipq8064_mdio_driver); + +MODULE_DESCRIPTION("Qualcomm IPQ8064 MDIO interface driver"); +MODULE_AUTHOR("Christian Lamparter "); +MODULE_LICENSE("GPL"); From patchwork Fri Feb 21 14:31:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 11396737 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D828A930 for ; Fri, 21 Feb 2020 14:32:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B80EE24656 for ; Fri, 21 Feb 2020 14:32:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RSS8G86A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728974AbgBUOcK (ORCPT ); Fri, 21 Feb 2020 09:32:10 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:38963 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbgBUOcK (ORCPT ); Fri, 21 Feb 2020 09:32:10 -0500 Received: by mail-wm1-f66.google.com with SMTP id c84so2123590wme.4; Fri, 21 Feb 2020 06:32:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kGlgDo9M9XGHB0o0rwRFWRiv//bvSK3bYB5+0sd515M=; b=RSS8G86A2iOHXIt+m5SYMDSTduj+VJhaaT16v/AYbp3oc0PYHHR7O/KhHKrh/yyD2l IMxPtwG09XK/ateKXoQpKTjzLjgUeRYv2uugUkO2njJC2PZvzvTrj2XRXhS+JfA4yRmT D8TjJjSel09swB47hxOgbk7f7cyLPKPEcgYP5lppkhYRQQms71JrWfLUyiqxHpMYNedL ECwH7pYc14kQ6r7Zd2REhZ6eLcmMQ3W7JacPE1zJ/yVRyHJ083mhA6gqhwk6fj2m/itR ZsX7hTdRWwhIzU8U/phcSHdilQsqmrroddIaLwdJij4vAPvWUuOpH6g0sVPjWfELq4UV raww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kGlgDo9M9XGHB0o0rwRFWRiv//bvSK3bYB5+0sd515M=; b=rQWhMBW6SqSDYhwq96YOnjr5TOsqwNYnOkxLgNtG4jhTaWd6NV6aWpVWU6QRuiaCeA Klomzk95JqSMPyf8rhY/GZorhn+I/L/O3JbBUmrtADDYp3+geGY/TYo7hzK5BMGog3EI 8FFaoHCi04l+U57w02EWmw3BMv+YGx8Uh1X2bqtxMARzVGUoawUYTQ2BffuPgvxGorS6 WsShezaPcfzuODJPxvAzfgGqlZTnh1r42ndProotL890oOSSO3Nd6AQLKskwwhaj3QRI vlUjCRD2858ZPJgb0SOqgdSENmxSdnVBbpgwxE+X6/twO+YpzZX3tUv43eDlkprhfOY5 VX6Q== X-Gm-Message-State: APjAAAWNz3/huEirgK8n2mQCLQEX2ZjnW+NVg7FPAanShALJEPed8uOH OeboqClw+VsPL2tFDpeQOnJ1OqWQKiY= X-Google-Smtp-Source: APXvYqz8aEgYoUhbOHE6PpkLL/zuy243O+yjkamkO4hz8v9eZB0TUbtgcfvuxOlmM0MojBai/11wfQ== X-Received: by 2002:a05:600c:21c5:: with SMTP id x5mr4381037wmj.72.1582295527411; Fri, 21 Feb 2020 06:32:07 -0800 (PST) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id y185sm4291290wmg.2.2020.02.21.06.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 06:32:06 -0800 (PST) From: Ansuel Smith Cc: Ansuel Smith , Andy Gross , Bjorn Andersson , "David S. Miller" , Rob Herring , Mark Rutland , Andrew Lunn , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/2] Documentation: devictree: Add ipq806x mdio bindings Date: Fri, 21 Feb 2020 15:31:51 +0100 Message-Id: <20200221143153.21186-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200221143153.21186-1-ansuelsmth@gmail.com> References: <20200221143153.21186-1-ansuelsmth@gmail.com> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add documentations for ipq806x mdio driver. Signed-off-by: Ansuel Smith --- .../bindings/net/qcom,ipq8064-mdio.yaml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.yaml diff --git a/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.yaml b/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.yaml new file mode 100644 index 000000000000..d2254a5ff2ad --- /dev/null +++ b/Documentation/devicetree/bindings/net/qcom,ipq8064-mdio.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/qcom,ipq8064-mdio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm ipq806x MDIO bus controller + +maintainers: + - Ansuel Smith + +description: |+ + The ipq806x soc have a MDIO dedicated controller that is + used to comunicate with the gmac phy conntected. + Child nodes of this MDIO bus controller node are standard + Ethernet PHY device nodes as described in + Documentation/devicetree/bindings/net/phy.txt + +allOf: + - $ref: "mdio.yaml#" + +properties: + compatible: + const: qcom,ipq8064-mdio + reg: + maxItems: 1 + description: address and length of the register set for the device + clocks: + maxItems: 1 + description: A reference to the clock supplying the MDIO bus controller + +required: + - compatible + - reg + - clocks + - "#address-cells" + - "#size-cells" + +examples: + - | + mdio0: mdio@37000000 { + #address-cells = <1>; + #size-cells = <0>; + + compatible = "qcom,ipq8064-mdio", "syscon"; + reg = <0x37000000 0x200000>; + resets = <&gcc GMAC_CORE1_RESET>; + reset-names = "stmmaceth"; + clocks = <&gcc GMAC_CORE1_CLK>; + + switch@10 { + compatible = "qca,qca8337"; + ... + } + };