netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support
@ 2015-01-27 19:44 Andy Shevchenko
  2015-01-27 19:44 ` [PATCH v3 1/3] stmmac: pci: add support for Intel Quark X1000 Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-01-27 19:44 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, David S . Miller; +Cc: Andy Shevchenko

This is third version of the patch series [1] to bring network card support to
Intel Quark SoC.

The series has been tested on Intel Galileo board.

Changelog v3:
 - rebase on top of recent net-next
 - rework an approach to get the custom configuration
 - rework an approach how to get unique bus_id
 - improve DMI lookup function

[1] http://www.spinics.net/lists/netdev/msg296010.html

Andy Shevchenko (1):
  stmmac: pci: introduce Intel Quark X1000 runtime detection

Kweh, Hock Leong (2):
  stmmac: pci: add support for Intel Quark X1000
  stmmac: pci: add MSI support for Intel Quark X1000

 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 113 ++++++++++++++++++++++-
 1 file changed, 112 insertions(+), 1 deletion(-)

-- 
2.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/3] stmmac: pci: add support for Intel Quark X1000
  2015-01-27 19:44 [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support Andy Shevchenko
@ 2015-01-27 19:44 ` Andy Shevchenko
  2015-01-27 19:44 ` [PATCH v3 2/3] stmmac: pci: introduce Intel Quark X1000 runtime detection Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-01-27 19:44 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, David S . Miller
  Cc: Kweh, Hock Leong, Andy Shevchenko

From: "Kweh, Hock Leong" <hock.leong.kweh@intel.com>

The Intel Quark SoC X1000 provides two 10/100 Mbps Ethernet MAC
controllers which may or may not be connected to PHY on board.
This MAC controller only supports RMII PHY. This patch add Quark
PCI ID as well as Quark default platform data info to this driver.

Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 51 +++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 054520d..a316187 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -26,6 +26,12 @@
 #include <linux/pci.h>
 #include "stmmac.h"
 
+struct stmmac_pci_info {
+	struct pci_dev *pdev;
+	int (*setup)(struct plat_stmmacenet_data *plat,
+		     struct stmmac_pci_info *info);
+};
+
 static void stmmac_default_data(struct plat_stmmacenet_data *plat)
 {
 	plat->bus_id = 1;
@@ -48,6 +54,38 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
 	plat->unicast_filter_entries = 1;
 }
 
+static int quark_default_data(struct plat_stmmacenet_data *plat,
+			      struct stmmac_pci_info *info)
+{
+	struct pci_dev *pdev = info->pdev;
+
+	plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
+	plat->phy_addr = 1;
+	plat->interface = PHY_INTERFACE_MODE_RMII;
+	plat->clk_csr = 2;
+	plat->has_gmac = 1;
+	plat->force_sf_dma_mode = 1;
+
+	plat->mdio_bus_data->phy_reset = NULL;
+	plat->mdio_bus_data->phy_mask = 0;
+
+	plat->dma_cfg->pbl = 16;
+	plat->dma_cfg->burst_len = DMA_AXI_BLEN_256;
+	plat->dma_cfg->fixed_burst = 1;
+
+	/* Set default value for multicast hash bins */
+	plat->multicast_filter_bins = HASH_TABLE_SIZE;
+
+	/* Set default value for unicast filter entries */
+	plat->unicast_filter_entries = 1;
+
+	return 0;
+}
+
+static struct stmmac_pci_info quark_pci_info = {
+	.setup = quark_default_data,
+};
+
 /**
  * stmmac_pci_probe
  *
@@ -63,6 +101,7 @@ static void stmmac_default_data(struct plat_stmmacenet_data *plat)
 static int stmmac_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *id)
 {
+	struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
 	struct plat_stmmacenet_data *plat;
 	struct stmmac_priv *priv;
 	int i;
@@ -103,7 +142,15 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 
 	pci_set_master(pdev);
 
-	stmmac_default_data(plat);
+	if (info) {
+		info->pdev = pdev;
+		if (info->setup) {
+			ret = info->setup(plat, info);
+			if (ret)
+				return ret;
+		}
+	} else
+		stmmac_default_data(plat);
 
 	priv = stmmac_dvr_probe(&pdev->dev, plat, pcim_iomap_table(pdev)[i]);
 	if (IS_ERR(priv)) {
@@ -155,11 +202,13 @@ static int stmmac_pci_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(stmmac_pm_ops, stmmac_pci_suspend, stmmac_pci_resume);
 
 #define STMMAC_VENDOR_ID 0x700
+#define STMMAC_QUARK_ID  0x0937
 #define STMMAC_DEVICE_ID 0x1108
 
 static const struct pci_device_id stmmac_id_table[] = {
 	{PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)},
 	{PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC)},
+	{PCI_VDEVICE(INTEL, STMMAC_QUARK_ID), (kernel_ulong_t)&quark_pci_info},
 	{}
 };
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/3] stmmac: pci: introduce Intel Quark X1000 runtime detection
  2015-01-27 19:44 [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support Andy Shevchenko
  2015-01-27 19:44 ` [PATCH v3 1/3] stmmac: pci: add support for Intel Quark X1000 Andy Shevchenko
@ 2015-01-27 19:44 ` Andy Shevchenko
  2015-01-27 19:44 ` [PATCH v3 3/3] stmmac: pci: add MSI support for Intel Quark X1000 Andy Shevchenko
  2015-01-28  5:08 ` [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-01-27 19:44 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, David S . Miller
  Cc: Andy Shevchenko, Kweh, Hock Leong

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>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 62 +++++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index a316187..50f3c50 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -24,14 +24,50 @@
 *******************************************************************************/
 
 #include <linux/pci.h>
+#include <linux/dmi.h>
+
 #include "stmmac.h"
 
+/*
+ * This struct is used to associate PCI Function of MAC controller on a board,
+ * discovered via DMI, with the address of PHY connected to the MAC. The
+ * negative value of the address means that MAC controller is not connected
+ * with PHY.
+ */
+struct stmmac_pci_dmi_data {
+	const char *name;
+	unsigned int func;
+	int phy_addr;
+};
+
 struct stmmac_pci_info {
 	struct pci_dev *pdev;
 	int (*setup)(struct plat_stmmacenet_data *plat,
 		     struct stmmac_pci_info *info);
+	struct stmmac_pci_dmi_data *dmi;
 };
 
+static int stmmac_pci_find_phy_addr(struct stmmac_pci_info *info)
+{
+	const char *name = dmi_get_system_info(DMI_BOARD_NAME);
+	unsigned int func = PCI_FUNC(info->pdev->devfn);
+	struct stmmac_pci_dmi_data *dmi;
+
+	/*
+	 * Galileo boards with old firmware don't support DMI. We always return
+	 * 1 here, so at least first found MAC controller would be probed.
+	 */
+	if (!name)
+		return 1;
+
+	for (dmi = info->dmi; dmi->name && *dmi->name; dmi++) {
+		if (!strcmp(dmi->name, name) && dmi->func == func)
+			return dmi->phy_addr;
+	}
+
+	return -ENODEV;
+}
+
 static void stmmac_default_data(struct plat_stmmacenet_data *plat)
 {
 	plat->bus_id = 1;
@@ -58,9 +94,18 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
 			      struct stmmac_pci_info *info)
 {
 	struct pci_dev *pdev = info->pdev;
+	int ret;
+
+	/*
+	 * Refuse to load the driver and register net device if MAC controller
+	 * does not connect to any PHY interface.
+	 */
+	ret = stmmac_pci_find_phy_addr(info);
+	if (ret < 0)
+		return ret;
 
 	plat->bus_id = PCI_DEVID(pdev->bus->number, pdev->devfn);
-	plat->phy_addr = 1;
+	plat->phy_addr = ret;
 	plat->interface = PHY_INTERFACE_MODE_RMII;
 	plat->clk_csr = 2;
 	plat->has_gmac = 1;
@@ -82,8 +127,23 @@ static int quark_default_data(struct plat_stmmacenet_data *plat,
 	return 0;
 }
 
+static struct stmmac_pci_dmi_data quark_pci_dmi_data[] = {
+	{
+		.name = "Galileo",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{
+		.name = "GalileoGen2",
+		.func = 6,
+		.phy_addr = 1,
+	},
+	{}
+};
+
 static struct stmmac_pci_info quark_pci_info = {
 	.setup = quark_default_data,
+	.dmi = quark_pci_dmi_data,
 };
 
 /**
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 3/3] stmmac: pci: add MSI support for Intel Quark X1000
  2015-01-27 19:44 [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support Andy Shevchenko
  2015-01-27 19:44 ` [PATCH v3 1/3] stmmac: pci: add support for Intel Quark X1000 Andy Shevchenko
  2015-01-27 19:44 ` [PATCH v3 2/3] stmmac: pci: introduce Intel Quark X1000 runtime detection Andy Shevchenko
@ 2015-01-27 19:44 ` Andy Shevchenko
  2015-01-28  5:08 ` [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2015-01-27 19:44 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev, David S . Miller
  Cc: Kweh, Hock Leong, Andy Shevchenko

From: "Kweh, Hock Leong" <hock.leong.kweh@intel.com>

In Intel Quark SoC X1000, both of the Ethernet controllers support
MSI interrupt handling. This patch enables them to use MSI interrupt
servicing in stmmac_pci for Intel Quark X1000.

Signed-off-by: Kweh, Hock Leong <hock.leong.kweh@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 50f3c50..3bca908 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -212,6 +212,8 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
 	} else
 		stmmac_default_data(plat);
 
+	pci_enable_msi(pdev);
+
 	priv = stmmac_dvr_probe(&pdev->dev, plat, pcim_iomap_table(pdev)[i]);
 	if (IS_ERR(priv)) {
 		dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support
  2015-01-27 19:44 [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support Andy Shevchenko
                   ` (2 preceding siblings ...)
  2015-01-27 19:44 ` [PATCH v3 3/3] stmmac: pci: add MSI support for Intel Quark X1000 Andy Shevchenko
@ 2015-01-28  5:08 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2015-01-28  5:08 UTC (permalink / raw)
  To: andriy.shevchenko; +Cc: peppe.cavallaro, netdev

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Tue, 27 Jan 2015 21:44:46 +0200

> This is third version of the patch series [1] to bring network card support to
> Intel Quark SoC.
> 
> The series has been tested on Intel Galileo board.
> 
> Changelog v3:
>  - rebase on top of recent net-next
>  - rework an approach to get the custom configuration
>  - rework an approach how to get unique bus_id
>  - improve DMI lookup function
> 
> [1] http://www.spinics.net/lists/netdev/msg296010.html

Series applied, thanks.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-01-28  5:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-27 19:44 [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support Andy Shevchenko
2015-01-27 19:44 ` [PATCH v3 1/3] stmmac: pci: add support for Intel Quark X1000 Andy Shevchenko
2015-01-27 19:44 ` [PATCH v3 2/3] stmmac: pci: introduce Intel Quark X1000 runtime detection Andy Shevchenko
2015-01-27 19:44 ` [PATCH v3 3/3] stmmac: pci: add MSI support for Intel Quark X1000 Andy Shevchenko
2015-01-28  5:08 ` [PATCH v3 0/3] net: stmmac: Enable Intel Quark SoC X1000 Ethernet support David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).