aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2015-01-27 14:44:48 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-28 00:08:08 -0500
commit0763d955b46e9b4c875cf1a7ab8576fb79fd1398 (patch)
treeab632ad8c169552a44be1545d6587a9f8d2efba1
parent5b99a6b6cc563e29265502b2b3df39c872022c22 (diff)
stmmac: pci: introduce Intel Quark X1000 runtime detection
This patch introduces run-time board detection through DMI and MAC-PHY configuration function used by quark_default_data() during initialization. It fills up the phy_addr for Galileo and Galileo Gen2 boards to indicate that the Ethernet MAC controller is or is not connected to any PHY. The implementation takes into consideration for future expansion in Quark series boards that may have different PHY address that is linked to its MAC controllers. This piece of work is derived from Bryan O'Donoghue's initial work for Quark X1000 enabling. Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index a316187967ea..50f3c50852fb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -24,14 +24,50 @@
24*******************************************************************************/ 24*******************************************************************************/
25 25
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/dmi.h>
28
27#include "stmmac.h" 29#include "stmmac.h"
28 30
31/*
32 * This struct is used to associate PCI Function of MAC controller on a board,
33 * discovered via DMI, with the address of PHY connected to the MAC. The
34 * negative value of the address means that MAC controller is not connected
35 * with PHY.
36 */
37struct stmmac_pci_dmi_data {
38 const char *name;
39 unsigned int func;
40 int phy_addr;
41};
42
29struct stmmac_pci_info { 43struct stmmac_pci_info {
30 struct pci_dev *pdev; 44 struct pci_dev *pdev;
31 int (*setup)(struct plat_stmmacenet_data *plat, 45 int (*setup)(struct plat_stmmacenet_data *plat,
32 struct stmmac_pci_info *info); 46 struct stmmac_pci_info *info);
47 struct stmmac_pci_dmi_data *dmi;
33}; 48};
34 49
50static int stmmac_pci_find_phy_addr(struct stmmac_pci_info *info)
51{
52 const char *name = dmi_get_system_info(DMI_BOARD_NAME);
53 unsigned int func = PCI_FUNC(info->pdev->devfn);
54 struct stmmac_pci_dmi_data *dmi;
55
56 /*
57 * Galileo boards with old firmware don't support DMI. We always return
58 * 1 here, so at least first found MAC controller would be probed.
59 */
60 if (!name)
61 return 1;
62
63 for (dmi = info->dmi; dmi->name && *dmi->name; dmi++) {
64 if (!strcmp(dmi->name, name) && dmi->func == func)
65 return dmi->phy_addr;
66 }
67
68 return -ENODEV;
69}
70
35static void stmmac_default_data(struct plat_stmmacenet_data *plat) 71static void stmmac_default_data(struct plat_stmmacenet_data *plat)
36{ 72{
37 plat->bus_id = 1; 73 plat->bus_id = 1;
@@ -58,9 +94,18 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
58 struct stmmac_pci_info *info) 94 struct stmmac_pci_info *info)
59{ 95{
60 struct pci_dev *pdev = info->pdev; 96 struct pci_dev *pdev = info->pdev;
97 int ret;
98
99 /*
100 * Refuse to load the driver and register net device if MAC controller
101 * does not connect to any PHY interface.
102 */
103 ret = stmmac_pci_find_phy_addr(info);
104 if (ret < 0)
105 return ret;
61 106
62 plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn); 107 plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
63 plat->phy_addr = 1; 108 plat->phy_addr = ret;
64 plat->interface = PHY_INTERFACE_MODE_RMII; 109 plat->interface = PHY_INTERFACE_MODE_RMII;
65 plat->clk_csr = 2; 110 plat->clk_csr = 2;
66 plat->has_gmac = 1; 111 plat->has_gmac = 1;
@@ -82,8 +127,23 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
82 return 0; 127 return 0;
83} 128}
84 129
130static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
131 {
132 .name = "Galileo",
133 .func = 6,
134 .phy_addr = 1,
135 },
136 {
137 .name = "GalileoGen2",
138 .func = 6,
139 .phy_addr = 1,
140 },
141 {}
142};
143
85static struct stmmac_pci_info quark_pci_info = { 144static struct stmmac_pci_info quark_pci_info = {
86 .setup = quark_default_data, 145 .setup = quark_default_data,
146 .dmi = quark_pci_dmi_data,
87}; 147};
88 148
89/** 149/**