From patchwork Thu Jan 21 13:55:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 571152 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B3943140BF7 for ; Fri, 22 Jan 2016 00:56:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=DvB6Xu2c; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 94FC428C60A; Thu, 21 Jan 2016 14:55:24 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, T_DKIM_INVALID autolearn=no version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 86BEE28BEFA for ; Thu, 21 Jan 2016 14:55:04 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 21 Jan 2016 14:54:59 +0100 (CET) Received: by mail-lb0-f172.google.com with SMTP id bc4so23594450lbc.2 for ; Thu, 21 Jan 2016 05:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=WHrdwiJylIq79PLhrbdo+0xCilqUnvJ1Xq2JbIjGm9o=; b=DvB6Xu2ckhRIQDKLy4emOX2GmyN++b4ySvEYw2wlOvpUQCPRXSu5y66ZfVPEXO7Fyo JuGp7WRr/C9FdqNDVH172QghtWepEfDcmCK4XzMB811GCGi5iIgbTowI2xqnlJwW93H2 /v5z5Yzh/YbqJ4Fz4UyhkX1x9OZJgdBtP2m6jua2qald+tmesc0GNpeKzR9Bd8yQ+NYe pfZ0FMtyYvInuIDHU89uNOtwMfFXXpKbVLhiV4NB4odf/bpVSfM1rF+u/hScBq4w7j/B ZQys4KsMX2AvCwzVPQHLL2joJ3MMXjL4jvVKg0QXX2y8sR8t7Zec8LQ0nHVjJPrwErDp a7aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=WHrdwiJylIq79PLhrbdo+0xCilqUnvJ1Xq2JbIjGm9o=; b=Q9p8jFtSGAJ0uF21NeZ+VOhtsX2BNI7sFhrt4UJq5xObxv/XNRYvaE9gyA7W4zR7N7 YPu8Am3jAMv57prQl2e4GpE+tni2qtI7tehDfCmzc1CR0jTl6Eerd6b+dpcUQQ2bsTmK p3fYYlaQAW7d/b8nidlyDLz8zY2Khg4rKNbJoLk+PV/OuaUdHACKaqj2hEAnjt83ucvl 8J/7DkfoAAyoPywOocFEpUGaa36CWge8nnIGdq68edXgR2kukkM25IeY6S1NVyaflWSG L3IflGDhdgj8jNSBzmT8W5U/H7DcKs7s0uPkl1OlCOc5F4YGhYlA7neuu7G7OTQM6zyE AEVQ== X-Gm-Message-State: ALoCoQk9wfkLwbDCm4Nl1OWjZq/XeTK8eR31j9cTD01dHOSlGnYLY3K/68Ty0DmdH4KgU0I+Zaqa/SNFRluCDn7imUjgceZyYA== X-Received: by 10.112.167.130 with SMTP id zo2mr12740140lbb.129.1453384539641; Thu, 21 Jan 2016 05:55:39 -0800 (PST) Received: from linux-samsung.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id l204sm203888lfg.49.2016.01.21.05.55.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2016 05:55:39 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: openwrt-devel@lists.openwrt.org, Jonas Gorski Date: Thu, 21 Jan 2016 14:55:29 +0100 Message-Id: <1453384529-17814-2-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1453384529-17814-1-git-send-email-zajec5@gmail.com> References: <1453384529-17814-1-git-send-email-zajec5@gmail.com> MIME-Version: 1.0 Subject: [OpenWrt-Devel] [PATCH 2/2] b53: provide PHY access to swconfig X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Thanks to this swconfig can access port PHYs and set link state using its generic implementation. Signed-off-by: Rafał Miłecki --- .../generic/files/drivers/net/phy/b53/b53_common.c | 26 ++++++++++++++++++++++ .../generic/files/drivers/net/phy/b53/b53_mdio.c | 20 +++++++++++++++++ .../generic/files/drivers/net/phy/b53/b53_priv.h | 2 ++ 3 files changed, 48 insertions(+) diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c index 859d8d1..41b5ae9 100644 --- a/target/linux/generic/files/drivers/net/phy/b53/b53_common.c +++ b/target/linux/generic/files/drivers/net/phy/b53/b53_common.c @@ -794,6 +794,26 @@ static int b53_port_get_link(struct switch_dev *dev, int port, } +static int b53_phy_read16(struct switch_dev *dev, int addr, u8 reg, u16 *value) +{ + struct b53_device *priv = sw_to_b53(dev); + + if (priv->ops->phy_read16) + return priv->ops->phy_read16(priv, addr, reg, value); + + return b53_read16(priv, B53_PORT_MII_PAGE(addr), reg, value); +} + +static int b53_phy_write16(struct switch_dev *dev, int addr, u8 reg, u16 value) +{ + struct b53_device *priv = sw_to_b53(dev); + + if (priv->ops->phy_write16) + return priv->ops->phy_write16(priv, addr, reg, value); + + return b53_write16(priv, B53_PORT_MII_PAGE(addr), reg, value); +} + static int b53_global_reset_switch(struct switch_dev *dev) { struct b53_device *priv = sw_to_b53(dev); @@ -1002,6 +1022,8 @@ static const struct switch_dev_ops b53_switch_ops_25 = { .apply_config = b53_global_apply_config, .reset_switch = b53_global_reset_switch, .get_port_link = b53_port_get_link, + .phy_read16 = b53_phy_read16, + .phy_write16 = b53_phy_write16, }; static const struct switch_dev_ops b53_switch_ops_65 = { @@ -1025,6 +1047,8 @@ static const struct switch_dev_ops b53_switch_ops_65 = { .apply_config = b53_global_apply_config, .reset_switch = b53_global_reset_switch, .get_port_link = b53_port_get_link, + .phy_read16 = b53_phy_read16, + .phy_write16 = b53_phy_write16, }; static const struct switch_dev_ops b53_switch_ops = { @@ -1048,6 +1072,8 @@ static const struct switch_dev_ops b53_switch_ops = { .apply_config = b53_global_apply_config, .reset_switch = b53_global_reset_switch, .get_port_link = b53_port_get_link, + .phy_read16 = b53_phy_read16, + .phy_write16 = b53_phy_write16, }; struct b53_chip_data { diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c b/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c index 3c25f0e..185c95f 100644 --- a/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c +++ b/target/linux/generic/files/drivers/net/phy/b53/b53_mdio.c @@ -238,6 +238,24 @@ static int b53_mdio_write64(struct b53_device *dev, u8 page, u8 reg, return b53_mdio_op(dev, page, reg, REG_MII_ADDR_WRITE); } +static int b53_mdio_phy_read16(struct b53_device *dev, int addr, u8 reg, + u16 *value) +{ + struct mii_bus *bus = dev->priv; + + *value = mdiobus_read(bus, addr, reg); + + return 0; +} + +static int b53_mdio_phy_write16(struct b53_device *dev, int addr, u8 reg, + u16 value) +{ + struct mii_bus *bus = dev->priv; + + return mdiobus_write(bus, addr, reg, value); +} + static struct b53_io_ops b53_mdio_ops = { .read8 = b53_mdio_read8, .read16 = b53_mdio_read16, @@ -249,6 +267,8 @@ static struct b53_io_ops b53_mdio_ops = { .write32 = b53_mdio_write32, .write48 = b53_mdio_write48, .write64 = b53_mdio_write64, + .phy_read16 = b53_mdio_phy_read16, + .phy_write16 = b53_mdio_phy_write16, }; static int b53_phy_probe(struct phy_device *phydev) diff --git a/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h b/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h index 0c4c394..53da97e 100644 --- a/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h +++ b/target/linux/generic/files/drivers/net/phy/b53/b53_priv.h @@ -36,6 +36,8 @@ struct b53_io_ops { int (*write32)(struct b53_device *dev, u8 page, u8 reg, u32 value); int (*write48)(struct b53_device *dev, u8 page, u8 reg, u64 value); int (*write64)(struct b53_device *dev, u8 page, u8 reg, u64 value); + int (*phy_read16)(struct b53_device *dev, int addr, u8 reg, u16 *value); + int (*phy_write16)(struct b53_device *dev, int addr, u8 reg, u16 value); }; enum {