linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcma: support for PCIe Gen 2 as host platform
@ 2014-07-06 11:11 Rafał Miłecki
  2014-07-06 12:19 ` Arend van Spriel
  0 siblings, 1 reply; 5+ messages in thread
From: Rafał Miłecki @ 2014-07-06 11:11 UTC (permalink / raw)
  To: linux-wireless, John W. Linville; +Cc: b43-dev, Rafał Miłecki

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
I got reply from Bjorn, that we should *not* depend on PCI_EXP_LNKCAP:
http://marc.info/?l=linux-pci&m=140457671930896&w=2

So the change since RFC is adding a list of PCIe 1.0 and 2.0 devices.
Use PCI_EXP_LNKCAP only as a fallback, in case someone tries sth like:
echo "14e4 4360" > /sys/bus/pci/drivers/bcma-pci-bridge/new_id
---
 drivers/bcma/host_pci.c        | 32 ++++++++++++++++++++++++++++++--
 include/linux/bcma/bcma.h      |  1 +
 include/linux/bcma/bcma_regs.h |  2 ++
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index e3333053..df20a50 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -13,10 +13,12 @@
 
 static void bcma_host_pci_switch_core(struct bcma_device *core)
 {
+	int win2 = core->bus->host_is_pcie2 ?
+		BCMA_PCIE2_BAR0_WIN2 : BCMA_PCI_BAR0_WIN2;
+
 	pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN,
 			       core->addr);
-	pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN2,
-			       core->wrap);
+	pci_write_config_dword(core->bus->host_pci, win2, core->wrap);
 	core->bus->mapped_core = core;
 	bcma_debug(core->bus, "Switched to core: 0x%X\n", core->id.id);
 }
@@ -194,6 +196,32 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
 		goto err_pci_release_regions;
 	}
 
+	/* PCIe Gen 2 has some regs different */
+	switch (dev->device) {
+	case 0x0576:
+	case 0x4313:
+	case 43224:
+	case 0x4331:
+	case 0x4353:
+	case 0x4357:
+	case 0x4358:
+	case 0x4359:
+	case 0x4365:
+	case 0x4727:
+		bus->host_is_pcie2 = false;
+		break;
+	case 0x4360:
+	case 0x43a0:
+	case 0x43b1:
+		bus->host_is_pcie2 = true;
+		break;
+	default:
+		/* Fallback, e.g. if someone uses bcma-pci-bridge/new_id */
+		pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &val);
+		bus->host_is_pcie2 = !!(val & PCI_EXP_LNKCAP_SLS_5_0GB);
+		break;
+	}
+
 	/* Map MMIO */
 	err = -ENOMEM;
 	bus->mmio = pci_iomap(dev, 0, ~0UL);
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 452286a..9f98e2f 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -315,6 +315,7 @@ struct bcma_bus {
 	const struct bcma_host_ops *ops;
 
 	enum bcma_hosttype hosttype;
+	bool host_is_pcie2; /* Valid for BCMA_HOSTTYPE_PCI only */
 	union {
 		/* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
 		struct pci_dev *host_pci;
diff --git a/include/linux/bcma/bcma_regs.h b/include/linux/bcma/bcma_regs.h
index 917dcd7..d02f8b5 100644
--- a/include/linux/bcma/bcma_regs.h
+++ b/include/linux/bcma/bcma_regs.h
@@ -59,6 +59,8 @@
 #define  BCMA_PCI_GPIO_XTAL		0x40	/* PCI config space GPIO 14 for Xtal powerup */
 #define  BCMA_PCI_GPIO_PLL		0x80	/* PCI config space GPIO 15 for PLL powerdown */
 
+#define BCMA_PCIE2_BAR0_WIN2		0x70
+
 /* SiliconBackplane Address Map.
  * All regions may not exist on all chips.
  */
-- 
1.8.4.5


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

* Re: [PATCH] bcma: support for PCIe Gen 2 as host platform
  2014-07-06 11:11 [PATCH] bcma: support for PCIe Gen 2 as host platform Rafał Miłecki
@ 2014-07-06 12:19 ` Arend van Spriel
  2014-07-07  9:38   ` Rafał Miłecki
  0 siblings, 1 reply; 5+ messages in thread
From: Arend van Spriel @ 2014-07-06 12:19 UTC (permalink / raw)
  To: Rafał Miłecki, linux-wireless, John W. Linville; +Cc: b43-dev

On 06-07-14 13:11, Rafał Miłecki wrote:
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
> I got reply from Bjorn, that we should *not* depend on PCI_EXP_LNKCAP:
> http://marc.info/?l=linux-pci&m=140457671930896&w=2
> 
> So the change since RFC is adding a list of PCIe 1.0 and 2.0 devices.
> Use PCI_EXP_LNKCAP only as a fallback, in case someone tries sth like:
> echo "14e4 4360" > /sys/bus/pci/drivers/bcma-pci-bridge/new_id

Do you have to know this before or after enumerating the cores? They
have a different core id, right?

Regards,
Arend

> ---
>  drivers/bcma/host_pci.c        | 32 ++++++++++++++++++++++++++++++--
>  include/linux/bcma/bcma.h      |  1 +
>  include/linux/bcma/bcma_regs.h |  2 ++
>  3 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
> index e3333053..df20a50 100644
> --- a/drivers/bcma/host_pci.c
> +++ b/drivers/bcma/host_pci.c
> @@ -13,10 +13,12 @@
>  
>  static void bcma_host_pci_switch_core(struct bcma_device *core)
>  {
> +	int win2 = core->bus->host_is_pcie2 ?
> +		BCMA_PCIE2_BAR0_WIN2 : BCMA_PCI_BAR0_WIN2;
> +
>  	pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN,
>  			       core->addr);
> -	pci_write_config_dword(core->bus->host_pci, BCMA_PCI_BAR0_WIN2,
> -			       core->wrap);
> +	pci_write_config_dword(core->bus->host_pci, win2, core->wrap);
>  	core->bus->mapped_core = core;
>  	bcma_debug(core->bus, "Switched to core: 0x%X\n", core->id.id);
>  }
> @@ -194,6 +196,32 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
>  		goto err_pci_release_regions;
>  	}
>  
> +	/* PCIe Gen 2 has some regs different */
> +	switch (dev->device) {
> +	case 0x0576:
> +	case 0x4313:
> +	case 43224:
> +	case 0x4331:
> +	case 0x4353:
> +	case 0x4357:
> +	case 0x4358:
> +	case 0x4359:
> +	case 0x4365:
> +	case 0x4727:
> +		bus->host_is_pcie2 = false;
> +		break;
> +	case 0x4360:
> +	case 0x43a0:
> +	case 0x43b1:
> +		bus->host_is_pcie2 = true;
> +		break;
> +	default:
> +		/* Fallback, e.g. if someone uses bcma-pci-bridge/new_id */
> +		pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &val);
> +		bus->host_is_pcie2 = !!(val & PCI_EXP_LNKCAP_SLS_5_0GB);
> +		break;
> +	}
> +
>  	/* Map MMIO */
>  	err = -ENOMEM;
>  	bus->mmio = pci_iomap(dev, 0, ~0UL);
> diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
> index 452286a..9f98e2f 100644
> --- a/include/linux/bcma/bcma.h
> +++ b/include/linux/bcma/bcma.h
> @@ -315,6 +315,7 @@ struct bcma_bus {
>  	const struct bcma_host_ops *ops;
>  
>  	enum bcma_hosttype hosttype;
> +	bool host_is_pcie2; /* Valid for BCMA_HOSTTYPE_PCI only */
>  	union {
>  		/* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
>  		struct pci_dev *host_pci;
> diff --git a/include/linux/bcma/bcma_regs.h b/include/linux/bcma/bcma_regs.h
> index 917dcd7..d02f8b5 100644
> --- a/include/linux/bcma/bcma_regs.h
> +++ b/include/linux/bcma/bcma_regs.h
> @@ -59,6 +59,8 @@
>  #define  BCMA_PCI_GPIO_XTAL		0x40	/* PCI config space GPIO 14 for Xtal powerup */
>  #define  BCMA_PCI_GPIO_PLL		0x80	/* PCI config space GPIO 15 for PLL powerdown */
>  
> +#define BCMA_PCIE2_BAR0_WIN2		0x70
> +
>  /* SiliconBackplane Address Map.
>   * All regions may not exist on all chips.
>   */
> 


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

* Re: [PATCH] bcma: support for PCIe Gen 2 as host platform
  2014-07-06 12:19 ` Arend van Spriel
@ 2014-07-07  9:38   ` Rafał Miłecki
  2014-07-07 19:37     ` Rafał Miłecki
  0 siblings, 1 reply; 5+ messages in thread
From: Rafał Miłecki @ 2014-07-07  9:38 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: linux-wireless@vger.kernel.org, John W. Linville, b43-dev

On 6 July 2014 14:19, Arend van Spriel <arend@broadcom.com> wrote:
> On 06-07-14 13:11, Rafał Miłecki wrote:
>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
>> ---
>> I got reply from Bjorn, that we should *not* depend on PCI_EXP_LNKCAP:
>> http://marc.info/?l=linux-pci&m=140457671930896&w=2
>>
>> So the change since RFC is adding a list of PCIe 1.0 and 2.0 devices.
>> Use PCI_EXP_LNKCAP only as a fallback, in case someone tries sth like:
>> echo "14e4 4360" > /sys/bus/pci/drivers/bcma-pci-bridge/new_id
>
> Do you have to know this before or after enumerating the cores? They
> have a different core id, right?

Sure, having a list of cores would allow me to determine PCIe revision.

Unfortunately right now we have only this single bcma_bus_register
call that does both: scanning and initialization. I'd need to first
scan cores, then determine PCIe revision and finally initialize cores.

I wonder if I could try to use bcma_bus_scan_early that was developer
for SoC needs...

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

* Re: [PATCH] bcma: support for PCIe Gen 2 as host platform
  2014-07-07  9:38   ` Rafał Miłecki
@ 2014-07-07 19:37     ` Rafał Miłecki
  2014-07-07 20:48       ` John W. Linville
  0 siblings, 1 reply; 5+ messages in thread
From: Rafał Miłecki @ 2014-07-07 19:37 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: linux-wireless@vger.kernel.org, John W. Linville, b43-dev

On 7 July 2014 11:38, Rafał Miłecki <zajec5@gmail.com> wrote:
> On 6 July 2014 14:19, Arend van Spriel <arend@broadcom.com> wrote:
>> On 06-07-14 13:11, Rafał Miłecki wrote:
>>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
>>> ---
>>> I got reply from Bjorn, that we should *not* depend on PCI_EXP_LNKCAP:
>>> http://marc.info/?l=linux-pci&m=140457671930896&w=2
>>>
>>> So the change since RFC is adding a list of PCIe 1.0 and 2.0 devices.
>>> Use PCI_EXP_LNKCAP only as a fallback, in case someone tries sth like:
>>> echo "14e4 4360" > /sys/bus/pci/drivers/bcma-pci-bridge/new_id
>>
>> Do you have to know this before or after enumerating the cores? They
>> have a different core id, right?
>
> Sure, having a list of cores would allow me to determine PCIe revision.
>
> Unfortunately right now we have only this single bcma_bus_register
> call that does both: scanning and initialization. I'd need to first
> scan cores, then determine PCIe revision and finally initialize cores.
>
> I wonder if I could try to use bcma_bus_scan_early that was developer
> for SoC needs...

John: please kindly drop this patch for now. All other bcma/b43
patches are unaffected.

-- 
Rafał

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

* Re: [PATCH] bcma: support for PCIe Gen 2 as host platform
  2014-07-07 19:37     ` Rafał Miłecki
@ 2014-07-07 20:48       ` John W. Linville
  0 siblings, 0 replies; 5+ messages in thread
From: John W. Linville @ 2014-07-07 20:48 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Arend van Spriel, linux-wireless@vger.kernel.org, b43-dev

On Mon, Jul 07, 2014 at 09:37:10PM +0200, Rafał Miłecki wrote:
> On 7 July 2014 11:38, Rafał Miłecki <zajec5@gmail.com> wrote:
> > On 6 July 2014 14:19, Arend van Spriel <arend@broadcom.com> wrote:
> >> On 06-07-14 13:11, Rafał Miłecki wrote:
> >>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> >>> ---
> >>> I got reply from Bjorn, that we should *not* depend on PCI_EXP_LNKCAP:
> >>> http://marc.info/?l=linux-pci&m=140457671930896&w=2
> >>>
> >>> So the change since RFC is adding a list of PCIe 1.0 and 2.0 devices.
> >>> Use PCI_EXP_LNKCAP only as a fallback, in case someone tries sth like:
> >>> echo "14e4 4360" > /sys/bus/pci/drivers/bcma-pci-bridge/new_id
> >>
> >> Do you have to know this before or after enumerating the cores? They
> >> have a different core id, right?
> >
> > Sure, having a list of cores would allow me to determine PCIe revision.
> >
> > Unfortunately right now we have only this single bcma_bus_register
> > call that does both: scanning and initialization. I'd need to first
> > scan cores, then determine PCIe revision and finally initialize cores.
> >
> > I wonder if I could try to use bcma_bus_scan_early that was developer
> > for SoC needs...
> 
> John: please kindly drop this patch for now. All other bcma/b43
> patches are unaffected.

OK

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

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

end of thread, other threads:[~2014-07-07 21:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-06 11:11 [PATCH] bcma: support for PCIe Gen 2 as host platform Rafał Miłecki
2014-07-06 12:19 ` Arend van Spriel
2014-07-07  9:38   ` Rafał Miłecki
2014-07-07 19:37     ` Rafał Miłecki
2014-07-07 20:48       ` John W. Linville

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).