linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] bcma: move code for core registration into separate function
@ 2014-09-04 22:18 Rafał Miłecki
  2014-09-04 22:18 ` [PATCH 2/2] bcma: register NAND and QSPI cores early Rafał Miłecki
  2014-09-07 19:25 ` [PATCH 1/2] bcma: move code for core registration into separate function Hauke Mehrtens
  0 siblings, 2 replies; 4+ messages in thread
From: Rafał Miłecki @ 2014-09-04 22:18 UTC (permalink / raw)
  To: linux-wireless, John W. Linville; +Cc: Hauke Mehrtens, Rafał Miłecki

This cleans code a bit and will us to register cores in other places as
well. The only difference with this patch is using "core_index" for
setting device name.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/bcma/main.c | 67 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 36 insertions(+), 31 deletions(-)

diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 9f6b0cb..9a86352 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -120,10 +120,42 @@ static void bcma_release_core_dev(struct device *dev)
 	kfree(core);
 }
 
-static int bcma_register_cores(struct bcma_bus *bus)
+static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
+{
+	int err;
+
+	core->dev.release = bcma_release_core_dev;
+	core->dev.bus = &bcma_bus_type;
+	dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
+
+	switch (bus->hosttype) {
+	case BCMA_HOSTTYPE_PCI:
+		core->dev.parent = &bus->host_pci->dev;
+		core->dma_dev = &bus->host_pci->dev;
+		core->irq = bus->host_pci->irq;
+		break;
+	case BCMA_HOSTTYPE_SOC:
+		core->dev.dma_mask = &core->dev.coherent_dma_mask;
+		core->dma_dev = &core->dev;
+		break;
+	case BCMA_HOSTTYPE_SDIO:
+		break;
+	}
+
+	err = device_register(&core->dev);
+	if (err) {
+		bcma_err(bus, "Could not register dev for core 0x%03X\n",
+			 core->id.id);
+		put_device(&core->dev);
+		return;
+	}
+	core->dev_registered = true;
+}
+
+static int bcma_register_devices(struct bcma_bus *bus)
 {
 	struct bcma_device *core;
-	int err, dev_id = 0;
+	int err;
 
 	list_for_each_entry(core, &bus->cores, list) {
 		/* We support that cores ourself */
@@ -143,34 +175,7 @@ static int bcma_register_cores(struct bcma_bus *bus)
 		    core->core_unit > 0)
 			continue;
 
-		core->dev.release = bcma_release_core_dev;
-		core->dev.bus = &bcma_bus_type;
-		dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
-
-		switch (bus->hosttype) {
-		case BCMA_HOSTTYPE_PCI:
-			core->dev.parent = &bus->host_pci->dev;
-			core->dma_dev = &bus->host_pci->dev;
-			core->irq = bus->host_pci->irq;
-			break;
-		case BCMA_HOSTTYPE_SOC:
-			core->dev.dma_mask = &core->dev.coherent_dma_mask;
-			core->dma_dev = &core->dev;
-			break;
-		case BCMA_HOSTTYPE_SDIO:
-			break;
-		}
-
-		err = device_register(&core->dev);
-		if (err) {
-			bcma_err(bus,
-				 "Could not register dev for core 0x%03X\n",
-				 core->id.id);
-			put_device(&core->dev);
-			continue;
-		}
-		core->dev_registered = true;
-		dev_id++;
+		bcma_register_core(bus, core);
 	}
 
 #ifdef CONFIG_BCMA_DRIVER_MIPS
@@ -297,7 +302,7 @@ int bcma_bus_register(struct bcma_bus *bus)
 	}
 
 	/* Register found cores */
-	bcma_register_cores(bus);
+	bcma_register_devices(bus);
 
 	bcma_info(bus, "Bus registered\n");
 
-- 
1.8.4.5


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

* [PATCH 2/2] bcma: register NAND and QSPI cores early
  2014-09-04 22:18 [PATCH 1/2] bcma: move code for core registration into separate function Rafał Miłecki
@ 2014-09-04 22:18 ` Rafał Miłecki
  2014-09-07 19:28   ` Hauke Mehrtens
  2014-09-07 19:25 ` [PATCH 1/2] bcma: move code for core registration into separate function Hauke Mehrtens
  1 sibling, 1 reply; 4+ messages in thread
From: Rafał Miłecki @ 2014-09-04 22:18 UTC (permalink / raw)
  To: linux-wireless, John W. Linville; +Cc: Hauke Mehrtens, Rafał Miłecki

On Northstar (ARM arch) we will use MTD subsystem to access NVRAM and
SPROM. To get access to flash device we need to register these cores
first.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/bcma/main.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 9a86352..297a2d4 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -120,6 +120,17 @@ static void bcma_release_core_dev(struct device *dev)
 	kfree(core);
 }
 
+static bool bcma_is_core_needed_early(u16 core_id)
+{
+	switch (core_id) {
+	case BCMA_CORE_NS_NAND:
+	case BCMA_CORE_NS_QSPI:
+		return true;
+	}
+
+	return false;
+}
+
 static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
 {
 	int err;
@@ -170,6 +181,10 @@ static int bcma_register_devices(struct bcma_bus *bus)
 			continue;
 		}
 
+		/* Early cores were already registered */
+		if (bcma_is_core_needed_early(core->id.id))
+			continue;
+
 		/* Only first GMAC core on BCM4706 is connected and working */
 		if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
 		    core->core_unit > 0)
@@ -252,6 +267,12 @@ int bcma_bus_register(struct bcma_bus *bus)
 		bcma_core_chipcommon_early_init(&bus->drv_cc);
 	}
 
+	/* Cores providing flash access go before SPROM init */
+	list_for_each_entry(core, &bus->cores, list) {
+		if (bcma_is_core_needed_early(core->id.id))
+			bcma_register_core(bus, core);
+	}
+
 	/* Try to get SPROM */
 	err = bcma_sprom_get(bus);
 	if (err == -ENOENT) {
-- 
1.8.4.5


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

* Re: [PATCH 1/2] bcma: move code for core registration into separate function
  2014-09-04 22:18 [PATCH 1/2] bcma: move code for core registration into separate function Rafał Miłecki
  2014-09-04 22:18 ` [PATCH 2/2] bcma: register NAND and QSPI cores early Rafał Miłecki
@ 2014-09-07 19:25 ` Hauke Mehrtens
  1 sibling, 0 replies; 4+ messages in thread
From: Hauke Mehrtens @ 2014-09-07 19:25 UTC (permalink / raw)
  To: Rafał Miłecki, linux-wireless, John W. Linville

On 09/05/2014 12:18 AM, Rafał Miłecki wrote:
> This cleans code a bit and will us to register cores in other places as
> well. The only difference with this patch is using "core_index" for
> setting device name.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

> ---
>  drivers/bcma/main.c | 67 ++++++++++++++++++++++++++++-------------------------
>  1 file changed, 36 insertions(+), 31 deletions(-)
> 


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

* Re: [PATCH 2/2] bcma: register NAND and QSPI cores early
  2014-09-04 22:18 ` [PATCH 2/2] bcma: register NAND and QSPI cores early Rafał Miłecki
@ 2014-09-07 19:28   ` Hauke Mehrtens
  0 siblings, 0 replies; 4+ messages in thread
From: Hauke Mehrtens @ 2014-09-07 19:28 UTC (permalink / raw)
  To: Rafał Miłecki, linux-wireless, John W. Linville

On 09/05/2014 12:18 AM, Rafał Miłecki wrote:
> On Northstar (ARM arch) we will use MTD subsystem to access NVRAM and
> SPROM. To get access to flash device we need to register these cores
> first.
> 
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

> ---
>  drivers/bcma/main.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 


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

end of thread, other threads:[~2014-09-07 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-04 22:18 [PATCH 1/2] bcma: move code for core registration into separate function Rafał Miłecki
2014-09-04 22:18 ` [PATCH 2/2] bcma: register NAND and QSPI cores early Rafał Miłecki
2014-09-07 19:28   ` Hauke Mehrtens
2014-09-07 19:25 ` [PATCH 1/2] bcma: move code for core registration into separate function Hauke Mehrtens

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