From patchwork Tue Apr 24 15:21:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 903583 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="FxTttJLA"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40VnLd3DZxz9s02 for ; Wed, 25 Apr 2018 01:29:29 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1E296C21F1D; Tue, 24 Apr 2018 15:28:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 22ACAC21F99; Tue, 24 Apr 2018 15:22:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3BD9DC21E42; Tue, 24 Apr 2018 15:21:44 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 5CE57C21E6A for ; Tue, 24 Apr 2018 15:21:44 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 2332062F2A; Tue, 24 Apr 2018 17:21:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1524583304; bh=G9vM+CrmG59N97rDLZfPPjgg6FIs5zO0lh1AuXC5PdY=; h=From:To:Date; b=FxTttJLApceEHpkHDbfZsm8Nqszyg4Yfry3aCpSJdc6IRmkJwXiS6gIOfnMdvclvr Fcc988N9lOzHSyXV6BBjCn/5ApD89ADNPWTG+RLTcyh3tR8b4uJPAjzm3xolrvn1WF bP8eG8GTyBnjetT+oc1z5ZkZbAH+f9qu0eI2Vxjw= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Tue, 24 Apr 2018 17:21:28 +0200 Message-Id: <20180424152131.20375-18-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180424152131.20375-1-marek.behun@nic.cz> References: <20180424152131.20375-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Tomas Hlavacek , Stefan Roese Subject: [U-Boot] [PATCH v2 17/20] phy: marvell: core: Cosmetic fixes X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Move the reg_set* functions into comphy.h as static inline functions. Change return type of get_*_string to const char *. Signed-off-by: Marek Behun Reviewed-by: Stefan Roese --- drivers/phy/marvell/comphy.h | 41 ++++++++++++++++++++++--- drivers/phy/marvell/comphy_core.c | 64 +++++++++------------------------------ 2 files changed, 52 insertions(+), 53 deletions(-) diff --git a/drivers/phy/marvell/comphy.h b/drivers/phy/marvell/comphy.h index 32e0a1e652..176bc89cac 100644 --- a/drivers/phy/marvell/comphy.h +++ b/drivers/phy/marvell/comphy.h @@ -102,10 +102,43 @@ struct chip_serdes_phy_config { }; /* Register helper functions */ -void reg_set(void __iomem *addr, u32 data, u32 mask); -void reg_set_silent(void __iomem *addr, u32 data, u32 mask); -void reg_set16(void __iomem *addr, u16 data, u16 mask); -void reg_set_silent16(void __iomem *addr, u16 data, u16 mask); +static inline void reg_set_silent(void __iomem *addr, u32 data, u32 mask) +{ + u32 reg_data; + + reg_data = readl(addr); + reg_data &= ~mask; + reg_data |= data; + writel(reg_data, addr); +} + +static inline void reg_set(void __iomem *addr, u32 data, u32 mask) +{ + debug("Write to address = %#010lx, data = %#010x (mask = %#010x) - ", + (unsigned long)addr, data, mask); + debug("old value = %#010x ==> ", readl(addr)); + reg_set_silent(addr, data, mask); + debug("new value %#010x\n", readl(addr)); +} + +static inline void reg_set_silent16(void __iomem *addr, u16 data, u16 mask) +{ + u16 reg_data; + + reg_data = readw(addr); + reg_data &= ~mask; + reg_data |= data; + writew(reg_data, addr); +} + +static inline void reg_set16(void __iomem *addr, u16 data, u16 mask) +{ + debug("Write to address = %#010lx, data = %#06x (mask = %#06x) - ", + (unsigned long)addr, data, mask); + debug("old value = %#06x ==> ", readw(addr)); + reg_set_silent16(addr, data, mask); + debug("new value %#06x\n", readw(addr)); +} /* SoC specific init functions */ #ifdef CONFIG_ARMADA_3700 diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c index 1e5664c435..500005f1d5 100644 --- a/drivers/phy/marvell/comphy_core.c +++ b/drivers/phy/marvell/comphy_core.c @@ -18,11 +18,13 @@ DECLARE_GLOBAL_DATA_PTR; -static char *get_speed_string(u32 speed) +static const char *get_speed_string(u32 speed) { - char *speed_strings[] = {"1.25 Gbps", "1.5 Gbps", "2.5 Gbps", - "3.0 Gbps", "3.125 Gbps", "5 Gbps", "6 Gbps", - "6.25 Gbps", "10.31 Gbps" }; + static const char * const speed_strings[] = { + "1.25 Gbps", "1.5 Gbps", "2.5 Gbps", + "3.0 Gbps", "3.125 Gbps", "5 Gbps", "6 Gbps", + "6.25 Gbps", "10.31 Gbps" + }; if (speed < 0 || speed > PHY_SPEED_MAX) return "invalid"; @@ -30,14 +32,16 @@ static char *get_speed_string(u32 speed) return speed_strings[speed]; } -static char *get_type_string(u32 type) +static const char *get_type_string(u32 type) { - char *type_strings[] = {"UNCONNECTED", "PEX0", "PEX1", "PEX2", "PEX3", - "SATA0", "SATA1", "SATA2", "SATA3", "SGMII0", - "SGMII1", "SGMII2", "SGMII3", "QSGMII", - "USB3_HOST0", "USB3_HOST1", "USB3_DEVICE", - "XAUI0", "XAUI1", "XAUI2", "XAUI3", - "RXAUI0", "RXAUI1", "SFI", "IGNORE"}; + static const char * const type_strings[] = { + "UNCONNECTED", "PEX0", "PEX1", "PEX2", "PEX3", + "SATA0", "SATA1", "SATA2", "SATA3", "SGMII0", + "SGMII1", "SGMII2", "SGMII3", "QSGMII", + "USB3_HOST0", "USB3_HOST1", "USB3_DEVICE", + "XAUI0", "XAUI1", "XAUI2", "XAUI3", + "RXAUI0", "RXAUI1", "SFI", "IGNORE" + }; if (type < 0 || type > PHY_TYPE_MAX) return "invalid"; @@ -45,44 +49,6 @@ static char *get_type_string(u32 type) return type_strings[type]; } -void reg_set(void __iomem *addr, u32 data, u32 mask) -{ - debug("Write to address = %#010lx, data = %#010x (mask = %#010x) - ", - (unsigned long)addr, data, mask); - debug("old value = %#010x ==> ", readl(addr)); - reg_set_silent(addr, data, mask); - debug("new value %#010x\n", readl(addr)); -} - -void reg_set_silent(void __iomem *addr, u32 data, u32 mask) -{ - u32 reg_data; - - reg_data = readl(addr); - reg_data &= ~mask; - reg_data |= data; - writel(reg_data, addr); -} - -void reg_set16(void __iomem *addr, u16 data, u16 mask) -{ - debug("Write to address = %#010lx, data = %#06x (mask = %#06x) - ", - (unsigned long)addr, data, mask); - debug("old value = %#06x ==> ", readw(addr)); - reg_set_silent16(addr, data, mask); - debug("new value %#06x\n", readw(addr)); -} - -void reg_set_silent16(void __iomem *addr, u16 data, u16 mask) -{ - u16 reg_data; - - reg_data = readw(addr); - reg_data &= ~mask; - reg_data |= data; - writew(reg_data, addr); -} - void comphy_print(struct chip_serdes_phy_config *chip_cfg, struct comphy_map *comphy_map_data) {