Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754987AbbK3Q2K (ORCPT ); Mon, 30 Nov 2015 11:28:10 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:8544 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754639AbbK3Q2I (ORCPT ); Mon, 30 Nov 2015 11:28:08 -0500 From: Paul Burton To: CC: Paul Burton , , Subject: [PATCH 24/28] net: pch_gbe: add device tree support Date: Mon, 30 Nov 2015 16:21:49 +0000 Message-ID: <1448900513-20856-25-git-send-email-paul.burton@imgtec.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1448900513-20856-1-git-send-email-paul.burton@imgtec.com> References: <1448900513-20856-1-git-send-email-paul.burton@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.100.200.236] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2824 Lines: 92 Introduce support for retrieving the PHY reset GPIO from device tree, which will be used on the MIPS Boston development board. This requires support for probe deferral in order to work correctly, since the order of device probe is not guaranteed & typically the EG20T GPIO controller device will be probed after the ethernet MAC. Signed-off-by: Paul Burton --- .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index 824ff9e..f2a9a38 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #define DRV_VERSION "1.01" const char pch_driver_version[] = DRV_VERSION; @@ -2594,13 +2596,41 @@ static void pch_gbe_remove(struct pci_dev *pdev) free_netdev(netdev); } +static int pch_gbe_parse_dt(struct pci_dev *pdev, + struct pch_gbe_privdata **pdata) +{ + struct device_node *np = pdev->dev.of_node; + struct gpio_desc *gpio; + + if (!config_enabled(CONFIG_OF) || !np) + return 0; + + if (!*pdata) + *pdata = devm_kzalloc(&pdev->dev, sizeof(**pdata), GFP_KERNEL); + if (!*pdata) + return -ENOMEM; + + gpio = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_ASIS); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); + + (*pdata)->phy_reset_gpio = gpio; + return 0; +} + static int pch_gbe_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) { struct net_device *netdev; struct pch_gbe_adapter *adapter; + struct pch_gbe_privdata *pdata; int ret; + pdata = (struct pch_gbe_privdata *)pci_id->driver_data; + ret = pch_gbe_parse_dt(pdev, &pdata); + if (ret) + goto err_out; + ret = pcim_enable_device(pdev); if (ret) return ret; @@ -2638,7 +2668,7 @@ static int pch_gbe_probe(struct pci_dev *pdev, adapter->pdev = pdev; adapter->hw.back = adapter; adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR]; - adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data; + adapter->pdata = pdata; if (adapter->pdata && adapter->pdata->platform_init) adapter->pdata->platform_init(pdev, pdata); @@ -2729,6 +2759,7 @@ err_free_adapter: pch_gbe_hal_phy_hw_reset(&adapter->hw); err_free_netdev: free_netdev(netdev); +err_out: return ret; } -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/