From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5133CC43217 for ; Sun, 27 Nov 2022 15:29:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EF0D7851B2; Sun, 27 Nov 2022 16:26:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="QyDqOwhz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82A0B8502B; Sun, 27 Nov 2022 16:26:05 +0100 (CET) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7EA7284D54 for ; Sun, 27 Nov 2022 16:26:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-ej1-x62c.google.com with SMTP id b2so4048059eja.7 for ; Sun, 27 Nov 2022 07:26:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=j1+uug8gk0WNbrvWbBnIzlpG+2tA9iFN1jKG8clEFV4=; b=QyDqOwhznzQEZWGik/FBu0XQTr7fWDGANuwhaxbPaxhokK7MNp6ff4L6QOtocYnhzk PtslfRcqpX9RRujabX9FizEYdVbejqKDZKBvonofR1Vsg7Nqk0JdIyI6rTZUoRviwqzd F3SRmIQdgssOaXY6mUNB7GLZMHZXDhPRogrJs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j1+uug8gk0WNbrvWbBnIzlpG+2tA9iFN1jKG8clEFV4=; b=eyobCApSyqDTaBNzpBQiHhhMQp0x5P7PcFNvPDkD44CPxeZ93eFBbws6uIt6f4/a9F LPSceikundAMWh7u2nteDd2LDEI1JzFXgoF1gGllii6gZsB/XHfmFtzca/SEuKkt0rdE OHTWyHaLIFfRLX1OPps45qY+JeZuRu/TRj/uPJvnobE2Bp65eITMVv21LSxTeSkVlJRG QkmHVRNqtqJZGaEhRIomCS/F4gET7f3L3DvU27vJq/cUtTCBbjI+C86GWQeRgv4Ag9do NwC0rjZRnlXQUEwVsCJca4ZH2l5yjDccN64hkfF9xfbstG3i4DT+PeobDTaUlrt9QiJs g1QA== X-Gm-Message-State: ANoB5pkhdGO6FhiksOlePIVaM8cIfHyQZsl0wtxL/GHZtciYrjFHM9bh jcAYZCQMorihrLBHL6Ap/E6rC9MfOr78VQ== X-Google-Smtp-Source: AA0mqf5JMHJfIPFRSXqnUP+T2oKMkIH/eRDJHVC/HI4gi0TlWo12shdllYINQ/SryFMgbIMyguGHEQ== X-Received: by 2002:a17:906:2e96:b0:7ad:8f76:17c7 with SMTP id o22-20020a1709062e9600b007ad8f7617c7mr28696220eji.315.1669562760656; Sun, 27 Nov 2022 07:26:00 -0800 (PST) Received: from bill-the-cat.lan (2603-6081-7b00-6400-dc2c-1c0a-ea3e-04dc.res6.spectrum.com. [2603:6081:7b00:6400:dc2c:1c0a:ea3e:4dc]) by smtp.gmail.com with ESMTPSA id tb6-20020a1709078b8600b007b47749838asm3853036ejc.45.2022.11.27.07.25.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 07:26:00 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Subject: [PATCH 20/41] net: macb: Remove non-DM_ETH code Date: Sun, 27 Nov 2022 10:25:15 -0500 Message-Id: <20221127152536.1556469-20-trini@konsulko.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221127152536.1556469-1-trini@konsulko.com> References: <20221119234545.404563-38-trini@konsulko.com> <20221127152536.1556469-1-trini@konsulko.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini --- drivers/net/macb.c | 194 +-------------------------------------------- 1 file changed, 2 insertions(+), 192 deletions(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index e02a57b4114c..57d7bb753ff8 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -33,9 +33,6 @@ */ #include -#ifndef CONFIG_DM_ETH -#include -#endif #include #include @@ -128,21 +125,16 @@ struct macb_device { unsigned long dummy_desc_dma; const struct device *dev; -#ifndef CONFIG_DM_ETH - struct eth_device netdev; -#endif unsigned short phy_addr; struct mii_dev *bus; #ifdef CONFIG_PHYLIB struct phy_device *phydev; #endif -#ifdef CONFIG_DM_ETH #ifdef CONFIG_CLK unsigned long pclk_rate; #endif phy_interface_t phy_interface; -#endif }; struct macb_usrio_cfg { @@ -161,10 +153,6 @@ struct macb_config { const struct macb_usrio_cfg *usrio; }; -#ifndef CONFIG_DM_ETH -#define to_macb(_nd) container_of(_nd, struct macb_device, netdev) -#endif - static int macb_is_gem(struct macb_device *macb) { return MACB_BFEXT(IDNUM, macb_readl(macb, MID)) >= 0x2; @@ -255,13 +243,8 @@ void __weak arch_get_mdio_control(const char *name) int macb_miiphy_read(struct mii_dev *bus, int phy_adr, int devad, int reg) { u16 value = 0; -#ifdef CONFIG_DM_ETH struct udevice *dev = eth_get_dev_by_name(bus->name); struct macb_device *macb = dev_get_priv(dev); -#else - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct macb_device *macb = to_macb(dev); -#endif arch_get_mdio_control(bus->name); value = macb_mdio_read(macb, phy_adr, reg); @@ -272,13 +255,8 @@ int macb_miiphy_read(struct mii_dev *bus, int phy_adr, int devad, int reg) int macb_miiphy_write(struct mii_dev *bus, int phy_adr, int devad, int reg, u16 value) { -#ifdef CONFIG_DM_ETH struct udevice *dev = eth_get_dev_by_name(bus->name); struct macb_device *macb = dev_get_priv(dev); -#else - struct eth_device *dev = eth_get_dev_by_name(bus->name); - struct macb_device *macb = to_macb(dev); -#endif arch_get_mdio_control(bus->name); macb_mdio_write(macb, phy_adr, reg, value); @@ -571,7 +549,6 @@ static int macb_phy_find(struct macb_device *macb, const char *name) * Returns 0 when operation success and negative errno number * when operation failed. */ -#ifdef CONFIG_DM_ETH static int macb_sifive_clk_init(struct udevice *dev, ulong rate) { void *gemgxl_regs; @@ -651,22 +628,10 @@ int __weak macb_linkspd_cb(struct udevice *dev, unsigned int speed) return 0; } -#else -int __weak macb_linkspd_cb(void *regs, unsigned int speed) -{ - return 0; -} -#endif -#ifdef CONFIG_DM_ETH static int macb_phy_init(struct udevice *dev, const char *name) -#else -static int macb_phy_init(struct macb_device *macb, const char *name) -#endif { -#ifdef CONFIG_DM_ETH struct macb_device *macb = dev_get_priv(dev); -#endif u32 ncfgr; u16 phy_id, status, adv, lpa; int media, speed, duplex; @@ -687,14 +652,8 @@ static int macb_phy_init(struct macb_device *macb, const char *name) } #ifdef CONFIG_PHYLIB -#ifdef CONFIG_DM_ETH macb->phydev = phy_connect(macb->bus, macb->phy_addr, dev, macb->phy_interface); -#else - /* need to consider other phy interface mode */ - macb->phydev = phy_connect(macb->bus, macb->phy_addr, &macb->netdev, - PHY_INTERFACE_MODE_RGMII); -#endif if (!macb->phydev) { printf("phy_connect failed\n"); return -ENODEV; @@ -751,11 +710,7 @@ static int macb_phy_init(struct macb_device *macb, const char *name) macb_writel(macb, NCFGR, ncfgr); -#ifdef CONFIG_DM_ETH ret = macb_linkspd_cb(dev, _1000BASET); -#else - ret = macb_linkspd_cb(macb->regs, _1000BASET); -#endif if (ret) return ret; @@ -780,17 +735,9 @@ static int macb_phy_init(struct macb_device *macb, const char *name) ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD) | GEM_BIT(GBE)); if (speed) { ncfgr |= MACB_BIT(SPD); -#ifdef CONFIG_DM_ETH ret = macb_linkspd_cb(dev, _100BASET); -#else - ret = macb_linkspd_cb(macb->regs, _100BASET); -#endif } else { -#ifdef CONFIG_DM_ETH ret = macb_linkspd_cb(dev, _10BASET); -#else - ret = macb_linkspd_cb(macb->regs, _10BASET); -#endif } if (ret) @@ -864,16 +811,10 @@ static void gmac_configure_dma(struct macb_device *macb) gem_writel(macb, DMACFG, dmacfg); } -#ifdef CONFIG_DM_ETH static int _macb_init(struct udevice *dev, const char *name) -#else -static int _macb_init(struct macb_device *macb, const char *name) -#endif { -#ifdef CONFIG_DM_ETH struct macb_device *macb = dev_get_priv(dev); unsigned int val = 0; -#endif unsigned long paddr; int ret; int i; @@ -942,7 +883,6 @@ static int _macb_init(struct macb_device *macb, const char *name) * When the GMAC IP without GE feature, this bit is used * to select interface between RMII and MII. */ -#ifdef CONFIG_DM_ETH if (macb->phy_interface == PHY_INTERFACE_MODE_RGMII || macb->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || macb->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID || @@ -964,16 +904,8 @@ static int _macb_init(struct macb_device *macb, const char *name) ncfgr |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL); macb_writel(macb, NCFGR, ncfgr); } -#else -#if defined(CONFIG_RGMII) || defined(CONFIG_RMII) - gem_writel(macb, USRIO, macb->config->usrio->rgmii); -#else - gem_writel(macb, USRIO, 0); -#endif -#endif } else { /* choose RMII or MII mode. This depends on the board */ -#ifdef CONFIG_DM_ETH #ifdef CONFIG_AT91FAMILY if (macb->phy_interface == PHY_INTERFACE_MODE_RMII) { macb_writel(macb, USRIO, @@ -987,30 +919,10 @@ static int _macb_init(struct macb_device *macb, const char *name) macb_writel(macb, USRIO, 0); else macb_writel(macb, USRIO, macb->config->usrio->mii); -#endif -#else -#ifdef CONFIG_RMII -#ifdef CONFIG_AT91FAMILY - macb_writel(macb, USRIO, macb->config->usrio->rmii | - macb->config->usrio->clken); -#else - macb_writel(macb, USRIO, 0); -#endif -#else -#ifdef CONFIG_AT91FAMILY - macb_writel(macb, USRIO, macb->config->usrio->clken); -#else - macb_writel(macb, USRIO, macb->config->usrio->mii); -#endif -#endif /* CONFIG_RMII */ #endif } -#ifdef CONFIG_DM_ETH ret = macb_phy_init(dev, name); -#else - ret = macb_phy_init(macb, name); -#endif if (ret) return ret; @@ -1054,7 +966,7 @@ static int _macb_write_hwaddr(struct macb_device *macb, unsigned char *enetaddr) static u32 macb_mdc_clk_div(int id, struct macb_device *macb) { u32 config; -#if defined(CONFIG_DM_ETH) && defined(CONFIG_CLK) +#if defined(CONFIG_CLK) unsigned long macb_hz = macb->pclk_rate; #else unsigned long macb_hz = get_macb_pclk_rate(id); @@ -1076,7 +988,7 @@ static u32 gem_mdc_clk_div(int id, struct macb_device *macb) { u32 config; -#if defined(CONFIG_DM_ETH) && defined(CONFIG_CLK) +#if defined(CONFIG_CLK) unsigned long macb_hz = macb->pclk_rate; #else unsigned long macb_hz = get_macb_pclk_rate(id); @@ -1155,106 +1067,6 @@ static void _macb_eth_initialize(struct macb_device *macb) macb_writel(macb, NCFGR, ncfgr); } -#ifndef CONFIG_DM_ETH -static int macb_send(struct eth_device *netdev, void *packet, int length) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_send(macb, netdev->name, packet, length); -} - -static int macb_recv(struct eth_device *netdev) -{ - struct macb_device *macb = to_macb(netdev); - uchar *packet; - int length; - - macb->wrapped = false; - for (;;) { - macb->next_rx_tail = macb->rx_tail; - length = _macb_recv(macb, &packet); - if (length >= 0) { - net_process_received_packet(packet, length); - reclaim_rx_buffers(macb, macb->next_rx_tail); - } else { - return length; - } - } -} - -static int macb_init(struct eth_device *netdev, struct bd_info *bd) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_init(macb, netdev->name); -} - -static void macb_halt(struct eth_device *netdev) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_halt(macb); -} - -static int macb_write_hwaddr(struct eth_device *netdev) -{ - struct macb_device *macb = to_macb(netdev); - - return _macb_write_hwaddr(macb, netdev->enetaddr); -} - -int macb_eth_initialize(int id, void *regs, unsigned int phy_addr) -{ - struct macb_device *macb; - struct eth_device *netdev; - - macb = malloc(sizeof(struct macb_device)); - if (!macb) { - printf("Error: Failed to allocate memory for MACB%d\n", id); - return -1; - } - memset(macb, 0, sizeof(struct macb_device)); - - netdev = &macb->netdev; - - macb->regs = regs; - macb->phy_addr = phy_addr; - - if (macb_is_gem(macb)) - sprintf(netdev->name, "gmac%d", id); - else - sprintf(netdev->name, "macb%d", id); - - netdev->init = macb_init; - netdev->halt = macb_halt; - netdev->send = macb_send; - netdev->recv = macb_recv; - netdev->write_hwaddr = macb_write_hwaddr; - - _macb_eth_initialize(macb); - - eth_register(netdev); - -#if defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) - int retval; - struct mii_dev *mdiodev = mdio_alloc(); - if (!mdiodev) - return -ENOMEM; - strlcpy(mdiodev->name, netdev->name, MDIO_NAME_LEN); - mdiodev->read = macb_miiphy_read; - mdiodev->write = macb_miiphy_write; - - retval = mdio_register(mdiodev); - if (retval < 0) - return retval; - macb->bus = miiphy_get_dev_by_name(netdev->name); -#endif - return 0; -} -#endif /* !CONFIG_DM_ETH */ - -#ifdef CONFIG_DM_ETH - static int macb_start(struct udevice *dev) { return _macb_init(dev, dev->name); @@ -1509,5 +1321,3 @@ U_BOOT_DRIVER(eth_macb) = { .plat_auto = sizeof(struct eth_pdata), }; #endif - -#endif -- 2.25.1