Skip to contentSkip to conversation

MinnowBoard Support V2 (Serial and Ethernet)

PATCH In review Darren Hart 5 participants 19 messages Jul 13, 2013 – Jul 18, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover MinnowBoard Support V2 (Serial and Ethernet)

Use the DMI interface to detect the board for UART_CLOCK selection per Greg K-H.

Resend PCH_GBE_PHY_REGS_LEN define cleanup.

Rewrite of PCH_GBE MinnowBoard support to be completely independent from any platform or board files. It requests the GPIO line in the pch_gbe driver and minimizes the pch_gbe_privdata (PCI driver_data) structure.

Tested on 3.8, 3.10, and current master. Patches to lpc_sch and gpio_sch required for 3.8, included in stable Cc lines.

#1 lore raw

PATCH 1/3 pch_uart: Use DMI interface for board detection

Use the DMI interface rather than manually matching DMI strings.

Cc Michael Brunner <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/tty/serial/pch_uart.c | 71 +++++++++++++++++++++++++++++--------------
 1 file changed, 49 insertions(+), 22 deletions(-)
drivers/tty/serial/pch_uart.c +49 -22
index 572d481..271cc73 100644
@@ -373,35 +373,62 @@ static const struct file_operations port_regs_ops = {
 };
 #endif	/* CONFIG_DEBUG_FS */
 
+static struct dmi_system_id __initdata pch_uart_dmi_table[] = {
+	{
+		.ident = "CM-iTC",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "CM-iTC"),
+		},
+		(void *)CMITC_UARTCLK,
+	},
+	{
+		.ident = "FRI2",
+		{
+			DMI_MATCH(DMI_BIOS_VERSION, "FRI2"),
+		},
+		(void *)FRI2_64_UARTCLK,
+	},
+	{
+		.ident = "Fish River Island II",
+		{
+			DMI_MATCH(DMI_PRODUCT_NAME, "Fish River Island II"),
+		},
+		(void *)FRI2_48_UARTCLK,
+	},
+	{
+		.ident = "COMe-mTT",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "COMe-mTT"),
+		},
+		(void *)NTC1_UARTCLK,
+	},
+	{
+		.ident = "nanoETXexpress-TT",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "nanoETXexpress-TT"),
+		},
+		(void *)NTC1_UARTCLK,
+	},
+	{
+		.ident = "MinnowBoard",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "MinnowBoard"),
+		},
+		(void *)MINNOW_UARTCLK,
+	},
+};
+
 /* Return UART clock, checking for board specific clocks. */
 static int pch_uart_get_uartclk(void)
 {
-	const char *cmp;
+	const struct dmi_system_id *d;
 
 	if (user_uartclk)
 		return user_uartclk;
 
-	cmp = dmi_get_system_info(DMI_BOARD_NAME);
-	if (cmp && strstr(cmp, "CM-iTC"))
-		return CMITC_UARTCLK;
-
-	cmp = dmi_get_system_info(DMI_BIOS_VERSION);
-	if (cmp && strnstr(cmp, "FRI2", 4))
-		return FRI2_64_UARTCLK;
-
-	cmp = dmi_get_system_info(DMI_PRODUCT_NAME);
-	if (cmp && strstr(cmp, "Fish River Island II"))
-		return FRI2_48_UARTCLK;
-
-	/* Kontron COMe-mTT10 (nanoETXexpress-TT) */
-	cmp = dmi_get_system_info(DMI_BOARD_NAME);
-	if (cmp && (strstr(cmp, "COMe-mTT") ||
-		    strstr(cmp, "nanoETXexpress-TT")))
-		return NTC1_UARTCLK;
-
-	cmp = dmi_get_system_info(DMI_BOARD_NAME);
-	if (cmp && strstr(cmp, "MinnowBoard"))
-		return MINNOW_UARTCLK;
+	d = dmi_first_match(pch_uart_dmi_table);
+	if (d)
+		return (int)d->driver_data;
 
 	return DEFAULT_UARTCLK;
 }
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH 1/3] pch_uart: Use DMI interface for board detection

Quoted 1 line · Darren Hart

Use the DMI interface rather than manually matching DMI strings.

Greg,

The rest of this series is either being dropped or has moved on to netdev. This patch however remains unchanged. Would you like me to resend individually or can you pull in this one?

Thanks,

Darren

Quoted 97 lines
Cc Michael Brunner <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/tty/serial/pch_uart.c | 71 +++++++++++++++++++++++++++++--------------
 1 file changed, 49 insertions(+), 22 deletions(-)
drivers/tty/serial/pch_uart.c +49 -22
index 572d481..271cc73 100644
@@ -373,35 +373,62 @@ static const struct file_operations port_regs_ops = {
 };
 #endif	/* CONFIG_DEBUG_FS */
 
+static struct dmi_system_id __initdata pch_uart_dmi_table[] = {
+	{
+		.ident = "CM-iTC",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "CM-iTC"),
+		},
+		(void *)CMITC_UARTCLK,
+	},
+	{
+		.ident = "FRI2",
+		{
+			DMI_MATCH(DMI_BIOS_VERSION, "FRI2"),
+		},
+		(void *)FRI2_64_UARTCLK,
+	},
+	{
+		.ident = "Fish River Island II",
+		{
+			DMI_MATCH(DMI_PRODUCT_NAME, "Fish River Island II"),
+		},
+		(void *)FRI2_48_UARTCLK,
+	},
+	{
+		.ident = "COMe-mTT",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "COMe-mTT"),
+		},
+		(void *)NTC1_UARTCLK,
+	},
+	{
+		.ident = "nanoETXexpress-TT",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "nanoETXexpress-TT"),
+		},
+		(void *)NTC1_UARTCLK,
+	},
+	{
+		.ident = "MinnowBoard",
+		{
+			DMI_MATCH(DMI_BOARD_NAME, "MinnowBoard"),
+		},
+		(void *)MINNOW_UARTCLK,
+	},
+};
+
 /* Return UART clock, checking for board specific clocks. */
 static int pch_uart_get_uartclk(void)
 {
-	const char *cmp;
+	const struct dmi_system_id *d;
 
 	if (user_uartclk)
 		return user_uartclk;
 
-	cmp = dmi_get_system_info(DMI_BOARD_NAME);
-	if (cmp && strstr(cmp, "CM-iTC"))
-		return CMITC_UARTCLK;
-
-	cmp = dmi_get_system_info(DMI_BIOS_VERSION);
-	if (cmp && strnstr(cmp, "FRI2", 4))
-		return FRI2_64_UARTCLK;
-
-	cmp = dmi_get_system_info(DMI_PRODUCT_NAME);
-	if (cmp && strstr(cmp, "Fish River Island II"))
-		return FRI2_48_UARTCLK;
-
-	/* Kontron COMe-mTT10 (nanoETXexpress-TT) */
-	cmp = dmi_get_system_info(DMI_BOARD_NAME);
-	if (cmp && (strstr(cmp, "COMe-mTT") ||
-		    strstr(cmp, "nanoETXexpress-TT")))
-		return NTC1_UARTCLK;
-
-	cmp = dmi_get_system_info(DMI_BOARD_NAME);
-	if (cmp && strstr(cmp, "MinnowBoard"))
-		return MINNOW_UARTCLK;
+	d = dmi_first_match(pch_uart_dmi_table);
+	if (d)
+		return (int)d->driver_data;
 
 	return DEFAULT_UARTCLK;
 }
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
#3 lore raw

Re: [PATCH 1/3] pch_uart: Use DMI interface for board detection

Quoted 8 lines · Darren Hart
Quoted 1 line · Darren Hart

Use the DMI interface rather than manually matching DMI strings.

Greg,

The rest of this series is either being dropped or has moved on to netdev. This patch however remains unchanged. Would you like me to resend individually or can you pull in this one?

No need, it's still in my "todo" queue. I'm trying to get the 3.11 patches merged first, before the 3.12 stuff hits my trees. I only have 1549 more patches to get through...

greg k-h

#4 lore raw

PATCH 2/3 pch_gbe: Use PCH_GBE_PHY_REGS_LEN instead of 32

In reply to Darren Hart

Avoid using magic numbers when we have perfectly good defines just lying around.

Cc "David S. Miller" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Peter Waskiewicz <[email protected]>
Cc Andy Shevchenko <[email protected]>
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +1 -1
index ab1039a..749ddd9 100644
@@ -682,7 +682,7 @@ static int pch_gbe_init_phy(struct pch_gbe_adapter *adapter)
 	}
 	adapter->hw.phy.addr = adapter->mii.phy_id;
 	netdev_dbg(netdev, "phy_addr = %d\n", adapter->mii.phy_id);
-	if (addr == 32)
+	if (addr == PCH_GBE_PHY_REGS_LEN)
 		return -EAGAIN;
 	/* Selected the phy and isolate the rest */
 	for (addr = 0; addr < PCH_GBE_PHY_REGS_LEN; addr++) {
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 3/3 pch_gbe: Add MinnowBoard support

In reply to Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Cc "David S. Miller" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Peter Waskiewicz <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc <[email protected]> # 3.8.x: 5829e9b mfd: lpc_sch: Accomodate partial
Cc <[email protected]> # 3.8.x: 3cbf182 gpio-sch: Allow for more than 8
Cc <[email protected]> # 3.8.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.8.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.8.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.8.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.8.x
Cc <[email protected]> # 3.10.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.10.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.10.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.10.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.10.x
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    | 15 ++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 48 +++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c    | 98 ++++++++++++++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h    |  2 +
 4 files changed, 163 insertions(+)
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +15 -0
index 7779036..d7d71cd 100644
@@ -582,6 +582,19 @@ struct pch_gbe_hw_stats {
 };
 
 /**
+ * struct pch_gbe_privdata - PCI Device ID driver data
+ * @phy_tx_clk_delay:		Bool, configure the PHY TX delay in software
+ * @phy_disable_hibernate:	Bool, disable PHY hibernation
+ * @platform_init:		Platform initialization callback, called from
+ *				probe, prio to PHY initialization.
+ */
+struct pch_gbe_privdata {
+	bool phy_tx_clk_delay;
+	bool phy_disable_hibernate;
+	int(*platform_init)(struct pci_dev *pdev);
+};
+
+/**
  * struct pch_gbe_adapter - board specific private data structure
  * @stats_lock:	Spinlock structure for status
  * @ethtool_lock:	Spinlock structure for ethtool
@@ -604,6 +617,7 @@ struct pch_gbe_hw_stats {
  * @rx_buffer_len:	Receive buffer length
  * @tx_queue_len:	Transmit queue length
  * @have_msi:		PCI MSI mode flag
+ * @pch_gbe_privdata	PCI Device ID driver_data
  */
 
 struct pch_gbe_adapter {
@@ -631,6 +645,7 @@ struct pch_gbe_adapter {
 	int hwts_tx_en;
 	int hwts_rx_en;
 	struct pci_dev *ptp_pdev;
+	struct pch_gbe_privdata *pdata;
 };
 
 #define pch_gbe_hw_to_adapter(hw)	container_of(hw, struct pch_gbe_adapter, hw)
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +48 -0

81 lines not on this page · raw message

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +98 -0

108 lines not on this page · raw message

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h +2 -0
index 03264dc..e3e4bc9 100644
@@ -33,5 +33,7 @@ void pch_gbe_phy_power_up(struct pch_gbe_hw *hw);
 void pch_gbe_phy_power_down(struct pch_gbe_hw *hw);
 void pch_gbe_phy_set_rgmii(struct pch_gbe_hw *hw);
 void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw);
+int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw);
+int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw);
 
 #endif /* _PCH_GBE_PHY_H_ */
Signature · 1 line
1.8.3.1
#6 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 4 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

trivial comments only:

Please use scripts/checkpatch.pl

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c[] renamed from drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +0 -0

[]

Quoted 1 line

+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)

[]

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (ret){

Missing space before brace

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 1 line
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +0 -0

[]

Quoted 1 line

+int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw)

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+	case PHY_AR803X_ID:
+		netdev_dbg(adapter->netdev,
+			   "Configuring AR803X PHY for 2ns TX clock delay\n"); 

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+		netdev_err(adapter->netdev,
+			   "Unknown PHY (%x), could not set TX clock delay.\n",
+			   hw->phy.id);

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 2 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +2 -0
+		netdev_err(adapter->netdev,
+			   "Could not configure tx clock delay for PHY.\n");

[]

Quoted 1 line

+int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw)

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+	case PHY_AR803X_ID:
+		netdev_dbg(adapter->netdev,
+			   "Disabling hibernation for AR803X PHY\n");

It'd be nice if no period before newline were used everywhere.

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+		netdev_err(adapter->netdev,
+			   "Unknown PHY (%x), could not disable hibernation\n",
+			   hw->phy.id);

[]

Quoted 2 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +2 -0
+		netdev_err(adapter->netdev,
+			   "Could not disable PHY hibernation.\n");
#7 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 9 lines · Joe Perches
Quoted 4 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

trivial comments only:

Please use scripts/checkpatch.pl

Always good advice. I did actually do that. Some of the reports conflict with existing formatting throughout the file. I opted for consistency.

The others.... sigh, I did a last minute cleanup and somehow introduced the whitespace errors. I do know better and should have waited until tonight instead of sending them out when I was rushed. Apologies.

Fixed in V3 and awaiting additional feedback.

Quoted 10 lines

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c[] renamed from drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +0 -0

[]

Quoted 1 line

+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)

[]

Review

Quoted 1 line
(quoted diff) +1 -0
+	if (ret){

Missing space before brace

Fixed.

Quoted 16 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 2 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +0 -0

[]

Quoted 1 line

+int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw)

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+	case PHY_AR803X_ID:
+		netdev_dbg(adapter->netdev,
+			   "Configuring AR803X PHY for 2ns TX clock delay\n"); 

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+		netdev_err(adapter->netdev,
+			   "Unknown PHY (%x), could not set TX clock delay.\n",
+			   hw->phy.id);

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 2 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +2 -0
+		netdev_err(adapter->netdev,
+			   "Could not configure tx clock delay for PHY.\n");

[]

Quoted 8 lines
Quoted 1 line

+int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw)

[]

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+	case PHY_AR803X_ID:
+		netdev_dbg(adapter->netdev,
+			   "Disabling hibernation for AR803X PHY\n");

It'd be nice if no period before newline were used everywhere.

Indeed, fixed.

Thank you for the review.

Quoted 9 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c

Quoted 4 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+		netdev_err(adapter->netdev,
+			   "Unknown PHY (%x), could not disable hibernation\n",
+			   hw->phy.id);

[]

Quoted 2 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +2 -0
+		netdev_err(adapter->netdev,
+			   "Could not disable PHY hibernation.\n");
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#8 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

In reply to Darren Hart
Quoted 33 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Cc "David S. Miller" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Peter Waskiewicz <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc <[email protected]> # 3.8.x: 5829e9b mfd: lpc_sch: Accomodate partial
Cc <[email protected]> # 3.8.x: 3cbf182 gpio-sch: Allow for more than 8
Cc <[email protected]> # 3.8.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.8.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.8.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.8.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.8.x
Cc <[email protected]> # 3.10.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.10.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.10.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.10.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.10.x
Quoted 6 lines
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    | 15 ++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 48 +++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c    | 98 ++++++++++++++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h    |  2 +
 4 files changed, 163 insertions(+)

This is _far_ more than just a simple "add a new device id" for a stable
kernel update. Please go read Documentation/stable_kernel_rules.txt
again for why there's no way I can take this type of thing.

You know better than this.

greg k-h

#9 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 41 lines · Greg KH
Quoted 33 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Cc "David S. Miller" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Peter Waskiewicz <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc <[email protected]> # 3.8.x: 5829e9b mfd: lpc_sch: Accomodate partial
Cc <[email protected]> # 3.8.x: 3cbf182 gpio-sch: Allow for more than 8
Cc <[email protected]> # 3.8.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.8.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.8.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.8.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.8.x
Cc <[email protected]> # 3.10.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.10.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.10.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.10.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.10.x
Quoted 6 lines
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    | 15 ++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 48 +++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c    | 98 ++++++++++++++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h    |  2 +
 4 files changed, 163 insertions(+)
Quoted 5 lines

This is _far_ more than just a simple "add a new device id" for a stable
kernel update. Please go read Documentation/stable_kernel_rules.txt
again for why there's no way I can take this type of thing.

You know better than this.

I do appreciate the documentation that is there, and I have read it (several times). The first two for 3.8 should be acceptable. The three pre-reqs from pch_gbe are very unfortunate, but Andy pushed his in response to my initial patch and they were merged first, making things unnecessarily complicated for stable. This left me with the option of massaging the patch (easy enough to do - I did this first actually) or including them as pre-reqs, and I opted for the latter after re-reading the stable docs and various threads on -stable to try and figure out what was preferable, and there you had agreed to take a 120 patch series. I've also seen patches longer than the 100 line limit go in, so despite the documentation, sometimes it's difficult to tell what is preferred, and if I don't include stable initially, it takes a lot of effort and time to get things in afterward. I don't intend this as a criticism, just an explanation of how I arrived here.

What would you prefer I do with this? I can break up the patch into infrastructure and then MinnowBoard specific bits (I didn't think the infrastructure-only patches would be well received on netdev, but maybe I'm wrong there). I could massage the patch around Andy's three pch_gbe cleanups which indeed are not stable candidates on their own. Or I could drop the idea of trying to get Ethernet working on the MinnowBoard outside of vendor trees and the next upstream release (I'd rather not do that).

Thanks,

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#10 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 42 lines · Darren Hart
Quoted 41 lines · Greg KH
Quoted 39 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Cc "David S. Miller" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Peter Waskiewicz <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc <[email protected]> # 3.8.x: 5829e9b mfd: lpc_sch: Accomodate partial
Cc <[email protected]> # 3.8.x: 3cbf182 gpio-sch: Allow for more than 8
Cc <[email protected]> # 3.8.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.8.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.8.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.8.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.8.x
Cc <[email protected]> # 3.10.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.10.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.10.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.10.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.10.x
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    | 15 ++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 48 +++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c    | 98 ++++++++++++++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h    |  2 +
 4 files changed, 163 insertions(+)
Quoted 8 lines
Quoted 5 lines

This is _far_ more than just a simple "add a new device id" for a stable
kernel update. Please go read Documentation/stable_kernel_rules.txt
again for why there's no way I can take this type of thing.

You know better than this.

I do appreciate the documentation that is there, and I have read it (several times). The first two for 3.8 should be acceptable.

I didn't even look at those other patches (and hint, 3.8 is dead and burried, no stable releases are happening for it that really matter.)

I'm talking about _this_ patch. Look at it. How big it is. How it's not just "add a new device id." Now please explain how _this_ patch meets the stable kernel rules as documented? Let alone the pr_* conversions, ick, don't get me started...

Would you really send something like this to Linus after -rc4? If not, then it's not a stable patch. See the 3.10.1-rc1 thread on lkml for the details as to why I now need to push back and be harsher for this.

Just have users use 3.11, it's not like you have shipping hardware yet, and again, who cares about 3.8. Heck, who cares about 3.9 or even 3.10 for brand-new hardware. Just use 3.11 or 3.12 and don't worry about backport hell.

This isn't going to land in Linus's tree until 3.12 anyway, so what's the rush?

greg k-h

#11 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 52 lines · Greg KH
Quoted 42 lines · Darren Hart
Quoted 41 lines · Greg KH
Quoted 39 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Cc "David S. Miller" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Peter Waskiewicz <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc <[email protected]> # 3.8.x: 5829e9b mfd: lpc_sch: Accomodate partial
Cc <[email protected]> # 3.8.x: 3cbf182 gpio-sch: Allow for more than 8
Cc <[email protected]> # 3.8.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.8.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.8.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.8.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.8.x
Cc <[email protected]> # 3.10.x: 91bbe92: PCI: Add CircuitCo vendor ID
Cc <[email protected]> # 3.10.x: bd79680: pch_gbe: remove inline keyword
Cc <[email protected]> # 3.10.x: 453ca93: pch_gbe: convert pr_* to
Cc <[email protected]> # 3.10.x: 29cc436: pch_gbe: use managed functions
Cc <[email protected]> # 3.10.x
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    | 15 ++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 48 +++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c    | 98 ++++++++++++++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h    |  2 +
 4 files changed, 163 insertions(+)
Quoted 8 lines
Quoted 5 lines

This is _far_ more than just a simple "add a new device id" for a stable
kernel update. Please go read Documentation/stable_kernel_rules.txt
again for why there's no way I can take this type of thing.

You know better than this.

I do appreciate the documentation that is there, and I have read it (several times). The first two for 3.8 should be acceptable.

Quoted 7 lines

I didn't even look at those other patches (and hint, 3.8 is dead and burried, no stable releases are happening for it that really matter.)

I'm talking about _this_ patch. Look at it. How big it is. How it's not just "add a new device id." Now please explain how _this_ patch meets the stable kernel rules as documented? Let alone the pr_* conversions, ick, don't get me started...

I was looking at it as a quirk:

" - New device IDs and quirks are also accepted."

I even considered implementation as a pci quirk. I didn't because the PHY work needed to happen too late during probe. The frustrating thing is there is probably 15 lines of code that are needed to get it to work, all the rest is infrastructure to make it generic.

I get the size argument. It's too big. The docs say 100 lines with context, I've seen much larger go in... I just wasn't sure where the line is. It seems things are getting more strict here, not less. OK. Lesson learned.

Quoted 3 lines

Would you really send something like this to Linus after -rc4? If not, then it's not a stable patch. See the 3.10.1-rc1 thread on lkml for the details as to why I now need to push back and be harsher for this.

Wow, good thread. I don't appear to be the only one unsure of the rules. I'll keep watching that thread for a definitive policy as you and Linus do appear to be saying slightly different things.

Quoted 1 line

Just have users use 3.11, it's not like you have shipping hardware yet,

We're talking days here, but yes.

Quoted 6 lines

and again, who cares about 3.8. Heck, who cares about 3.9 or even 3.10 for brand-new hardware. Just use 3.11 or 3.12 and don't worry about backport hell.

This isn't going to land in Linus's tree until 3.12 anyway, so what's the rush?

My reasoning is that the BSP for this is based on 3.8. I would like to bring 3.8 in sync with master for support of this board so I can update the release BSP to use the same sources. People can use my code from the linux-yocto_3.8 standard/minnow branch, but it would be preferable if that code was also destined for upstream. Not the end of the world, and I certainly don't mind directing people to 3.12 and ensuring the next BSP release is fully aligned with mainline. And yes, none of the above qualifies it for stable - it's only the "and quirks" that I felt qualified this patch for stable, and I recognize it as a "freakish giant" of a patch for stable. See, I really did read that entire thread.

If you still feel this doesn't qualify as a "quirk", I'll drop the stable push. If you can see that argument, I can look at breaking it up into smaller chunks, or possibly reducing some of the generic bits and doing the bare minimum to get it working and follow-up in master with more generic bits.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#12 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 27 lines · Darren Hart
Quoted 18 lines · Greg KH
Quoted 8 lines · Darren Hart
Quoted 7 lines · Greg KH
Quoted 6 lines
---
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h    | 15 ++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c   | 48 +++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c    | 98 ++++++++++++++++++++++
 .../net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.h    |  2 +
 4 files changed, 163 insertions(+)
Quoted 8 lines
Quoted 5 lines

This is _far_ more than just a simple "add a new device id" for a stable
kernel update. Please go read Documentation/stable_kernel_rules.txt
again for why there's no way I can take this type of thing.

You know better than this.

I do appreciate the documentation that is there, and I have read it (several times). The first two for 3.8 should be acceptable.

Quoted 7 lines

I didn't even look at those other patches (and hint, 3.8 is dead and burried, no stable releases are happening for it that really matter.)

I'm talking about _this_ patch. Look at it. How big it is. How it's not just "add a new device id." Now please explain how _this_ patch meets the stable kernel rules as documented? Let alone the pr_* conversions, ick, don't get me started...

Quoted 8 lines

I was looking at it as a quirk:

" - New device IDs and quirks are also accepted."

I even considered implementation as a pci quirk. I didn't because the PHY work needed to happen too late during probe. The frustrating thing is there is probably 15 lines of code that are needed to get it to work, all the rest is infrastructure to make it generic.

163 lines of code is not a "quirk" I can accept. When I wrote, "new device ids or quirks can be accpted for stable", I meant things like commit 9e9dd0e889c76c786e8f2e164c825c3c06dea30c. That's acceptable. Not thing huge thing.

Quoted 4 lines

I get the size argument. It's too big. The docs say 100 lines with context, I've seen much larger go in... I just wasn't sure where the line is. It seems things are getting more strict here, not less. OK. Lesson learned.

You have seen larger "quirks" than this go into the stable tree? Examples for where I've been sleeping on the job would be good.

And that's the whole point of the huge thread I pointed you at, people are trying to get stuff into stable that they shouldn't be (and they are being lazy, but that's not the issue with this patch...)

Quoted 8 lines
Quoted 1 line

Just have users use 3.11, it's not like you have shipping hardware yet,

We're talking days here, but yes.

Quoted 4 lines

and again, who cares about 3.8. Heck, who cares about 3.9 or even 3.10 for brand-new hardware. Just use 3.11 or 3.12 and don't worry about backport hell.

Quoted 8 lines
Quoted 2 lines

This isn't going to land in Linus's tree until 3.12 anyway, so what's the rush?

My reasoning is that the BSP for this is based on 3.8. I would like to bring 3.8 in sync with master for support of this board so I can update the release BSP to use the same sources. People can use my code from the linux-yocto_3.8 standard/minnow branch, but it would be preferable if that code was also destined for upstream.

That's your choice to pick 3.8, not upstream's (and frankly, not something that I would have picked, but that's another topic...)

Quoted 5 lines

If you still feel this doesn't qualify as a "quirk", I'll drop the stable push. If you can see that argument, I can look at breaking it up into smaller chunks, or possibly reducing some of the generic bits and doing the bare minimum to get it working and follow-up in master with more generic bits.

You are adding functionality for new devices that take much more than a simple "add an id to a table", so no, it's not ok for stable releases.

thanks,

greg k-h

#13 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 1 line · Greg KH

On Sat, Jul 13, 2013 at 09:08:01AM -0700, Darren Hart wrote:

...

Quoted 9 lines
Quoted 8 lines

I was looking at it as a quirk:

" - New device IDs and quirks are also accepted."

I even considered implementation as a pci quirk. I didn't because the PHY work needed to happen too late during probe. The frustrating thing is there is probably 15 lines of code that are needed to get it to work, all the rest is infrastructure to make it generic.

Quoted 4 lines

163 lines of code is not a "quirk" I can accept. When I wrote, "new device ids or quirks can be accpted for stable", I meant things like commit 9e9dd0e889c76c786e8f2e164c825c3c06dea30c. That's acceptable. Not thing huge thing.

Got it. I was confused on "new device IDs and quirks" versus "support for new hardware". My fault, that's clear now.

...

Quoted 7 lines
Quoted 4 lines

I get the size argument. It's too big. The docs say 100 lines with context, I've seen much larger go in... I just wasn't sure where the line is. It seems things are getting more strict here, not less. OK. Lesson learned.

You have seen larger "quirks" than this go into the stable tree? Examples for where I've been sleeping on the job would be good.

No, sorry, I just meant patches larger than 100 lines with context, that's all.

...

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

This isn't going to land in Linus's tree until 3.12 anyway, so what's the rush?

My reasoning is that the BSP for this is based on 3.8. I would like to bring 3.8 in sync with master for support of this board so I can update the release BSP to use the same sources. People can use my code from the linux-yocto_3.8 standard/minnow branch, but it would be preferable if that code was also destined for upstream.

That's your choice to pick 3.8, not upstream's (and frankly, not something that I would have picked, but that's another topic...)

Maybe we can catch up at LPC or something, I'd like to hear your thoughts on that. Of course there are a lot of factors that go into that decision, and the bulk of it is consolidating effort on a single tree across BSPs in a project that has a 6 month release cadence.

...

Quoted 2 lines

You are adding functionality for new devices that take much more than a simple "add an id to a table", so no, it's not ok for stable releases.

Got it, I'll drop the stable lines from the subsequent versions and keep that in mind for future projects. I'm trying to think if I can polish up the docs to help clarify things, thinking on it.

Thank you Greg.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#14 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

In reply to Darren Hart
Quoted 5 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

Quoted 8 lines

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Few comments below.

Quoted 6 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +0 -0
@@ -582,6 +582,19 @@ struct pch_gbe_hw_stats {
 };
 
 /**

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h struct pch_gbe_hw_stats { · line 594

Quoted 10 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +10 -0
+ * struct pch_gbe_privdata - PCI Device ID driver data
+ * @phy_tx_clk_delay:		Bool, configure the PHY TX delay in software
+ * @phy_disable_hibernate:	Bool, disable PHY hibernation
+ * @platform_init:		Platform initialization callback, called from
+ *				probe, prio to PHY initialization.
+ */
+struct pch_gbe_privdata {
+	bool phy_tx_clk_delay;
+	bool phy_disable_hibernate;
+	int(*platform_init)(struct pci_dev *pdev);

I don't like the platform_init() approach here.
I think here should be plain GPIO line number.

I'll explain below why.

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h struct pch_gbe_hw_stats { · line 620

Quoted 5 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +1 -0
@@ -604,6 +617,7 @@ struct pch_gbe_hw_stats {
  * @rx_buffer_len:	Receive buffer length
  * @tx_queue_len:	Transmit queue length
  * @have_msi:		PCI MSI mode flag
+ * @pch_gbe_privdata	PCI Device ID driver_data

Missed colon.

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c static int pch_gbe_probe(struct pci_dev *pdev, · line 2643

Quoted 11 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +3 -0
@@ -2635,6 +2638,9 @@ 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;
+	if (adapter->pdata && adapter->pdata->platform_init)
+		adapter->pdata->platform_init(pdev);

Here perhaps you check pdata and GPIO line number (let's say != -1) and call GPIO request helper.

Quoted 14 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +10 -0
@@ -2720,9 +2730,47 @@ err_free_netdev:
 	return ret;
 }
 
+/* The AR803X PHY on the MinnowBoard requires a physical pin to be toggled to
+ * ensure it is awake for probe and init. Request the line and reset the PHY.
+ */
+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
+{
+	int ret = 0;
+	int flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
+	int gpio = MINNOW_PHY_RESET_GPIO;
+
+	ret = gpio_request_one(gpio, flags, "minnow_phy_reset");

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c err_free_netdev: · line 2752

Quoted 10 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +10 -0
+	if (ret){
+		dev_err(&pdev->dev,
+			"ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
+		return ret;
+	}
+
+	gpio_set_value(gpio, 0);
+	usleep_range(1250, 1500);
+	gpio_set_value(gpio, 1);
+	usleep_range(1250, 1500);

First of all, who is going to release gpio? Perhaps devm_gpio_request_one?

Next is the name of the function, since you are resetting PHY, what if you call it like pch_gbe_reset_by_gpio ?

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c err_free_netdev: · line 2747

Quoted 3 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +3 -0
+
+	return ret;
+}

And most important one is the ACPI case. As far as I understand Minnow board supports / will support ACPI5 variant of device enumeration. In such case the GPIO line will come in the ACPI resources. Moreover, you will have no struct pci_dev. I highly recommend to rewrite this as a generic helper, which takes GPIO line number as an input parameter and does the job.

Quoted 41 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +15 -0
+
+static struct pch_gbe_privdata pch_gbe_minnow_privdata = {
+	.phy_tx_clk_delay = true,
+	.phy_disable_hibernate = true,
+	.platform_init = pch_gbe_minnow_platform_init,
+};
+
 static DEFINE_PCI_DEVICE_TABLE(pch_gbe_pcidev_id) = {
 	{.vendor = PCI_VENDOR_ID_INTEL,
 	 .device = PCI_DEVICE_ID_INTEL_IOH1_GBE,
+	 .subvendor = PCI_VENDOR_ID_CIRCUITCO,
+	 .subdevice = PCI_SUBSYSTEM_ID_CIRCUITCO_MINNOWBOARD,
+	 .class = (PCI_CLASS_NETWORK_ETHERNET << 8),
+	 .class_mask = (0xFFFF00),
+	 .driver_data = (unsigned long) &pch_gbe_minnow_privdata
+	 },
+	{.vendor = PCI_VENDOR_ID_INTEL,
+	 .device = PCI_DEVICE_ID_INTEL_IOH1_GBE,
 	 .subvendor = PCI_ANY_ID,
 	 .subdevice = PCI_ANY_ID,
 	 .class = (PCI_CLASS_NETWORK_ETHERNET << 8),
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +12 -0
@@ -277,4 +286,93 @@ void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw)
 	pch_gbe_phy_read_reg_miic(hw, PHY_PHYSP_CONTROL, &mii_reg);
 	mii_reg |= PHYSP_CTRL_ASSERT_CRS_TX;
 	pch_gbe_phy_write_reg_miic(hw, PHY_PHYSP_CONTROL, mii_reg);
+
+	/* Setup a TX clock delay on certain platforms */
+	if (adapter->pdata->phy_tx_clk_delay)
+		pch_gbe_phy_tx_clk_delay(hw);
+}
+
+/**
+ * pch_gbe_phy_tx_clk_delay - Setup TX clock delay via the PHY
+ * @hw:	            Pointer to the HW structure
+ * Returns
+ *	0:		Successful.
+ *	-EINVAL:	Invalid argument.

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw) · line 310

Quoted 10 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +10 -0
+ */
+int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw)
+{
+	/* The RGMII interface requires a ~2ns TX clock delay. This is typically
+	 * done in layout with a longer trace or via PHY strapping, but can also
+	 * be done via PHY configuration registers.
+	 */
+	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+	u16 mii_reg;
+	int ret = 0;

No need to assign. Are you trying to shut (sparse?) warning?

Quoted 31 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +31 -0
+
+	switch (hw->phy.id) {
+	case PHY_AR803X_ID:
+		netdev_dbg(adapter->netdev,
+			   "Configuring AR803X PHY for 2ns TX clock delay\n"); 
+		pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_OFF, &mii_reg);
+		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_OFF,
+						 PHY_AR8031_SERDES);
+		if (ret)
+			break;
+
+		pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_DAT, &mii_reg);
+		mii_reg |= PHY_AR8031_SERDES_TX_CLK_DLY;
+		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_DAT,
+						 mii_reg);
+		break;
+	default:
+		netdev_err(adapter->netdev,
+			   "Unknown PHY (%x), could not set TX clock delay.\n",
+			   hw->phy.id);
+		return -EINVAL;
+	}
+
+	if (ret)
+		netdev_err(adapter->netdev,
+			   "Could not configure tx clock delay for PHY.\n");
+	return ret;
+}
+
+/**
+ * pch_gbe_phy_disable_hibernate - Disable the PHY low power state

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw) · line 351

Quoted 10 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +10 -0
+ * @hw:	            Pointer to the HW structure
+ * Returns
+ *	0:		Successful.
+ *	-EINVAL:	Invalid argument.
+ */
+int pch_gbe_phy_disable_hibernate(struct pch_gbe_hw *hw)
+{
+	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+	u16 mii_reg;
+	int ret = 0;

Ditto.

Quoted 26 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +25 -0
+	switch (hw->phy.id) {
+	case PHY_AR803X_ID:
+		netdev_dbg(adapter->netdev,
+			   "Disabling hibernation for AR803X PHY\n");
+		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_OFF,
+						 PHY_AR8031_HIBERNATE);
+		if (ret)
+			break;
+
+		pch_gbe_phy_read_reg_miic(hw, PHY_AR8031_DBG_DAT, &mii_reg);
+		mii_reg &= ~PHY_AR8031_PS_HIB_EN;
+		ret = pch_gbe_phy_write_reg_miic(hw, PHY_AR8031_DBG_DAT,
+						 mii_reg);
+		break;
+	default:
+		netdev_err(adapter->netdev,
+			   "Unknown PHY (%x), could not disable hibernation\n",
+			   hw->phy.id);
+		return -EINVAL;
+	}
+
+	if (ret)
+		netdev_err(adapter->netdev,
+			   "Could not disable PHY hibernation.\n");
+	return ret;
 }
Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#15 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

Quoted 1 line · Andy Shevchenko

On Fri, 2013-07-12 at 17:58 -0700, Darren Hart wrote:

...

Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +15 -0
+/* The AR803X PHY on the MinnowBoard requires a physical pin to be toggled to
+ * ensure it is awake for probe and init. Request the line and reset the PHY.
+ */
+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
+{
+	int ret = 0;
+	int flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
+	int gpio = MINNOW_PHY_RESET_GPIO;
+
+	ret = gpio_request_one(gpio, flags, "minnow_phy_reset");
+	if (ret){
+		dev_err(&pdev->dev,
+			"ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
+		return ret;
+	}
Quoted 8 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c err_free_netdev: · line 2752

Quoted 5 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +5 -0
+
+	gpio_set_value(gpio, 0);
+	usleep_range(1250, 1500);
+	gpio_set_value(gpio, 1);
+	usleep_range(1250, 1500);

First of all, who is going to release gpio? Perhaps devm_gpio_request_one?

Thanks for the pointer, this works and appears to be the best way to handle this.

...

Quoted 4 lines
Quoted 4 lines

+ */

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
+int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw)
+{
+	/* The RGMII interface requires a ~2ns TX clock delay. This is typically
Quoted 8 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw) · line 310

Quoted 6 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +6 -0
+	 * done in layout with a longer trace or via PHY strapping, but can also
+	 * be done via PHY configuration registers.
+	 */
+	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+	u16 mii_reg;
+	int ret = 0;

No need to assign. Are you trying to shut (sparse?) warning?

On this point, I did find one instance where I initialized init only to have my first line of executable code assign to ret, that's obviously silly, so I fixed that one.

Here, where the first assignment is nested inside case statements or skipped altogether with explicit returns of error codes, I prefer to assign it explicitly. A quick survey lists 4k initialized "int ret;" lines and 16k uninitialized. The latter appears to be the more common, but there is certainly precedent for the former.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#16 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

In reply to Andy Shevchenko

(resending as the original appears not to have made it past my sent box)

Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

Quoted 6 lines
Quoted 4 lines

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Few comments below.

Hi Andy,

Thank you for taking the time to review...

Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +0 -0
@@ -582,6 +582,19 @@ struct pch_gbe_hw_stats {
 };
 
Quoted 14 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h struct pch_gbe_hw_stats { · line 594

Quoted 11 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +10 -0
 /**
+ * struct pch_gbe_privdata - PCI Device ID driver data
+ * @phy_tx_clk_delay:		Bool, configure the PHY TX delay in software
+ * @phy_disable_hibernate:	Bool, disable PHY hibernation
+ * @platform_init:		Platform initialization callback, called from
+ *				probe, prio to PHY initialization.
+ */
+struct pch_gbe_privdata {
+	bool phy_tx_clk_delay;
+	bool phy_disable_hibernate;
+	int(*platform_init)(struct pci_dev *pdev);

I don't like the platform_init() approach here.
I think here should be plain GPIO line number.

I went around and around on this myself. I originally added several callback functions to this privdata, but ultimately felt it was more infrastructure than was necessary now, and if it became necessary (a big "if" in my opinion) I could always augment that as a follow-on patch.

Quoted 9 lines

I'll explain below why.

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h struct pch_gbe_hw_stats { · line 620

Quoted 5 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe.h +1 -0
@@ -604,6 +617,7 @@ struct pch_gbe_hw_stats {
  * @rx_buffer_len:	Receive buffer length
  * @tx_queue_len:	Transmit queue length
  * @have_msi:		PCI MSI mode flag
+ * @pch_gbe_privdata	PCI Device ID driver_data

Missed colon.

Ack, thanks.

Quoted 4 lines
Quoted 2 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +0 -0
Quoted 10 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c static int pch_gbe_probe(struct pci_dev *pdev, · line 2643

Quoted 7 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +3 -0
@@ -2635,6 +2638,9 @@ 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;
+	if (adapter->pdata && adapter->pdata->platform_init)
+		adapter->pdata->platform_init(pdev);

Here perhaps you check pdata and GPIO line number (let's say != -1) and call GPIO request helper.

I was doing exactly this in local previous version, but I decided against it for a few reasons:

o If I specific GPIO, I should also specify GPIO flags, GPIO label, GPIO assertion level, GPIO reset and rest timings (and that is assuming it's just a set, release, wait cycle).

o Setting all this in pdata makes very specific to resetting this specific PHY, while others may have any number of other methods or procedures. It also excludes other sorts of platform initialization which might necessary. Specifying GPIO here makes the interface overly specific in my opinion.

Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +15 -0
@@ -2720,9 +2730,47 @@ err_free_netdev:
 	return ret;
 }
 
+/* The AR803X PHY on the MinnowBoard requires a physical pin to be toggled to
+ * ensure it is awake for probe and init. Request the line and reset the PHY.
+ */
+static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
+{
+	int ret = 0;
+	int flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
+	int gpio = MINNOW_PHY_RESET_GPIO;
+
+	ret = gpio_request_one(gpio, flags, "minnow_phy_reset");
+	if (ret){
+		dev_err(&pdev->dev,
+			"ERR: Can't request PHY reset GPIO line '%d'\n", gpio);
+		return ret;
+	}
Quoted 8 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c err_free_netdev: · line 2752

Quoted 5 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +5 -0
+
+	gpio_set_value(gpio, 0);
+	usleep_range(1250, 1500);
+	gpio_set_value(gpio, 1);
+	usleep_range(1250, 1500);

First of all, who is going to release gpio? Perhaps devm_gpio_request_one?

Oh right, thanks for catching that. I'll need to think on that, there is no direct way to know I need to release it on module exit in this implementation.

Quoted 2 lines

Next is the name of the function, since you are resetting PHY, what if you call it like pch_gbe_reset_by_gpio ?

We would need to include PHY in here as we are not resetting the MAC, we are resetting the PHY. I think specifying it as being by gpio is also overly restrictive. If you look at my two new functions (for tx clock delay and hibernate) you can see an example of how we might go about such a function (which indeed I had in a previous version as pch_gbe_phy_physical_reset()). I dropped this as I felt it required too many fields to be added to the pdata and I was better off with platform specific init routines.

You've presented an alternative approach, but it isn't clear to me what your reservations are with the one I took here. What are the problems with it?

Quoted 11 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c err_free_netdev: · line 2747

Quoted 4 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +3 -0
+
+	return ret;
+}

And most important one is the ACPI case. As far as I understand Minnow board supports / will support ACPI5 variant of device enumeration. In such case the GPIO line will come in the ACPI resources. Moreover, you will have no struct pci_dev. I highly recommend to rewrite this as a generic helper, which takes GPIO line number as an input parameter and does the job.

While the MinnowBoard will be expanding its use of ACPI, we do not intend to rewrite existing drivers (such as this one) or firmware platform code. We are looking only to describe the Lure's (daughter cards) with additional tables.

...

Quoted 11 lines

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c err_free_netdev: · line 2764

Quoted 9 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +9 -0
+int pch_gbe_phy_tx_clk_delay(struct pch_gbe_hw *hw)
+{
+	/* The RGMII interface requires a ~2ns TX clock delay. This is typically
+	 * done in layout with a longer trace or via PHY strapping, but can also
+	 * be done via PHY configuration registers.
+	 */
+	struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
+	u16 mii_reg;
+	int ret = 0;

No need to assign. Are you trying to shut (sparse?) warning?

Personal preference I guess. When it comes to return codes I prefer an explicit assignment.

Thank you for taking the time to review!

Signature · 8 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel

-- 
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel
#17 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

In reply to Darren Hart
Quoted 20 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

Cc "David S. Miller" <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Peter Waskiewicz <[email protected]>
Cc Andy Shevchenko <[email protected]>

...

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw) · line 291

Quoted 7 lines
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_phy.c +3 -0
@@ -277,4 +286,93 @@ void pch_gbe_phy_init_setting(struct pch_gbe_hw *hw)
 	pch_gbe_phy_read_reg_miic(hw, PHY_PHYSP_CONTROL, &mii_reg);
 	mii_reg |= PHYSP_CTRL_ASSERT_CRS_TX;
 	pch_gbe_phy_write_reg_miic(hw, PHY_PHYSP_CONTROL, mii_reg);
+
+	/* Setup a TX clock delay on certain platforms */
+	if (adapter->pdata->phy_tx_clk_delay)

This is missing an adapter->pdata !NULL test. Fixed in V3. Holding off a bit more on that in case Dave M. has anything he wants to see changed in the next revision.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel
#18 lore raw

Re: [PATCH 3/3] pch_gbe: Add MinnowBoard support

In reply to Darren Hart
Quoted 5 lines · Darren Hart

The MinnowBoard uses an AR803x PHY with the PCH GBE which requires special handling. Use the MinnowBoard PCI Subsystem ID to detect this and add a pci_device_id.driver_data structure and functions to handle platform setup.

Quoted 8 lines

The AR803x does not implement the RGMII 2ns TX clock delay in the trace routing nor via strapping. Add a detection method for the board and the PHY and enable the TX clock delay via the registers.

This PHY will hibernate without link for 10 seconds. Ensure the PHY is awake for probe and then disable hibernation. A future improvement would be to convert pch_gbe to using PHYLIB and making sure we can wake the PHY at the necessary times rather than permanently disabling it.

If anyone is following along to see where this goes, I have made this change independent of the minnowboard platform drivers and have resent it with all the collected feedback on to netdev following the netdev rules I was recently made aware of. Please follow along there if you are interested.

Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Linux Kernel