Skip to contentSkip to conversation

ssb: add support for ssb over sdio

RFC PATCH In review Albert Herranz 2 participants 2 messages Sep 7, 2009 Sonics silicon backplane driver (ssb)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 3/3 ssb: add support for ssb over sdio

From c0f5e5002b69d5cc226a0c31d791bccefc2c92e3 Mon Sep 17 00:00:00 2001
From: Albert Herranz <[email protected]>
Date: Tue, 18 Aug 2009 21:39:06 +0200
Subject: [PATCH] ssb: add support for ssb over sdio

Add support for communicating with a Sonics Silicon Backplane through a SDIO interface, as found in the Nintendo Wii WLAN daughter card.

The Nintendo Wii WLAN card includes a custom Broadcom 4318 chip with a SDIO host interface.

---
 drivers/ssb/Kconfig       |   14 +
 drivers/ssb/Makefile      |    1 +
 drivers/ssb/main.c        |   58 +++++-
 drivers/ssb/scan.c        |   11 +
 drivers/ssb/sdio.c        |  611 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/ssb/ssb_private.h |   40 +++
 include/linux/ssb/ssb.h   |   32 +++
 7 files changed, 766 insertions(+), 1 deletions(-)
 create mode 100644 drivers/ssb/sdio.c
drivers/ssb/Kconfig +14 -0
index 540a294..2d8cc45 100644
@@ -66,6 +66,20 @@ config SSB_PCMCIAHOST
 
 	  If unsure, say N
 
+config SSB_SDIOHOST_POSSIBLE
+	bool
+	depends on SSB && (MMC = y || MMC = SSB)
+	default y
+
+config SSB_SDIOHOST
+	bool "Support for SSB on SDIO-bus host"
+	depends on SSB_SDIOHOST_POSSIBLE
+	help
+	  Support for a Sonics Silicon Backplane on top
+	  of a SDIO device.
+
+	  If unsure, say N
+
 config SSB_SILENT
 	bool "No SSB kernel messages"
 	depends on SSB && EMBEDDED
drivers/ssb/Makefile +1 -0
index cfbb74f..656e58b 100644
@@ -6,6 +6,7 @@ ssb-$(CONFIG_SSB_SPROM)			+= sprom.o
 # host support
 ssb-$(CONFIG_SSB_PCIHOST)		+= pci.o pcihost_wrapper.o
 ssb-$(CONFIG_SSB_PCMCIAHOST)		+= pcmcia.o
+ssb-$(CONFIG_SSB_SDIOHOST)		+= sdio.o
 
 # built-in drivers
 ssb-y					+= driver_chipcommon.o
drivers/ssb/main.c +57 -1

99 lines not on this page · raw message

drivers/ssb/scan.c +11 -0
index 63ee5cf..b74212d 100644
@@ -175,6 +175,9 @@ static u32 scan_read32(struct ssb_bus *bus, u8 current_coreidx,
 		} else
 			ssb_pcmcia_switch_segment(bus, 0);
 		break;
+	case SSB_BUSTYPE_SDIO:
+		offset += current_coreidx * SSB_CORE_SIZE;
+		return ssb_sdio_scan_read32(bus, offset);
 	}
 	return readl(bus->mmio + offset);
 }
@@ -188,6 +191,8 @@ static int scan_switchcore(struct ssb_bus *bus, u8 coreidx)
 		return ssb_pci_switch_coreidx(bus, coreidx);
 	case SSB_BUSTYPE_PCMCIA:
 		return ssb_pcmcia_switch_coreidx(bus, coreidx);
+	case SSB_BUSTYPE_SDIO:
+		return ssb_sdio_scan_switch_coreidx(bus, coreidx);
 	}
 	return 0;
 }
@@ -206,6 +211,8 @@ void ssb_iounmap(struct ssb_bus *bus)
 		SSB_BUG_ON(1); /* Can't reach this code. */
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		break;
 	}
 	bus->mmio = NULL;
 	bus->mapped_device = NULL;
@@ -230,6 +237,10 @@ static void __iomem *ssb_ioremap(struct ssb_bus *bus,
 		SSB_BUG_ON(1); /* Can't reach this code. */
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* Nothing to ioremap in the SDIO case, just fake it */
+		mmio = (void __iomem *)baseaddr;
+		break;
 	}
 
 	return mmio;
drivers/ssb/sdio.c new file +611 -0

611 lines not on this page · raw message

drivers/ssb/ssb_private.h +40 -0
index 57fa482..2543356 100644
@@ -114,6 +114,46 @@ static inline int ssb_pcmcia_init(struct ssb_bus *bus)
 }
 #endif /* CONFIG_SSB_PCMCIAHOST */
 
+/* sdio.c */
+#ifdef CONFIG_SSB_SDIOHOST
+extern int ssb_sdio_get_invariants(struct ssb_bus *bus,
+				     struct ssb_init_invariants *iv);
+
+extern u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset);
+extern int ssb_sdio_switch_core(struct ssb_bus *bus, struct ssb_device *dev);
+extern int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx);
+extern int ssb_sdio_hardware_setup(struct ssb_bus *bus);
+extern void ssb_sdio_exit(struct ssb_bus *bus);
+extern int ssb_sdio_init(struct ssb_bus *bus);
+
+extern const struct ssb_bus_ops ssb_sdio_ops;
+#else /* CONFIG_SSB_SDIOHOST */
+static inline u32 ssb_sdio_scan_read32(struct ssb_bus *bus, u16 offset)
+{
+	return 0;
+}
+static inline int ssb_sdio_switch_core(struct ssb_bus *bus,
+					 struct ssb_device *dev)
+{
+	return 0;
+}
+static inline int ssb_sdio_scan_switch_coreidx(struct ssb_bus *bus, u8 coreidx)
+{
+	return 0;
+}
+static inline int ssb_sdio_hardware_setup(struct ssb_bus *bus)
+{
+	return 0;
+}
+static inline void ssb_sdio_exit(struct ssb_bus *bus)
+{
+}
+static inline int ssb_sdio_init(struct ssb_bus *bus)
+{
+	return 0;
+}
+#endif /* CONFIG_SSB_SDIOHOST */
+
 
 /* scan.c */
 extern const char *ssb_core_name(u16 coreid);
include/linux/ssb/ssb.h +32 -0
index 17ffc1f..771da21 100644
@@ -238,6 +238,7 @@ enum ssb_bustype {
 	SSB_BUSTYPE_SSB,	/* This SSB bus is the system bus */
 	SSB_BUSTYPE_PCI,	/* SSB is connected to PCI bus */
 	SSB_BUSTYPE_PCMCIA,	/* SSB is connected to PCMCIA bus */
+	SSB_BUSTYPE_SDIO,	/* SSB is connected to SDIO bus */
 };
 
 /* board_vendor */
@@ -283,6 +284,17 @@ struct ssb_bus {
 	/* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
 	struct pcmcia_device *host_pcmcia;
 
+	unsigned int quirks;
+
+/* card requires performing a read after writing a 32-bit value */
+#define SSB_QUIRK_SDIO_READ_AFTER_WRITE32	(1<<0)
+
+	/* Pointer to the SDIO device (only if bustype == SSB_BUSTYPE_SDIO). */
+	struct sdio_func *sdio_func;
+
+	/* Current SSB base address window for SDIO. */
+	u32	sbaddr;
+
 #ifdef CONFIG_SSB_SPROM
 	/* Mutex to protect the SPROM writing. */
 	struct mutex sprom_mutex;
@@ -366,6 +378,12 @@ extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
 				      struct pcmcia_device *pcmcia_dev,
 				      unsigned long baseaddr);
 #endif /* CONFIG_SSB_PCMCIAHOST */
+#ifdef CONFIG_SSB_SDIOHOST
+extern int ssb_bus_sdiobus_register(struct ssb_bus *bus,
+				    struct sdio_func *sdio_func,
+				    unsigned int quirks);
+#endif /* CONFIG_SSB_SDIOHOST */
+
 
 extern void ssb_bus_unregister(struct ssb_bus *bus);
 
@@ -465,6 +483,8 @@ static inline int ssb_dma_mapping_error(struct ssb_device *dev, dma_addr_t addr)
 		return pci_dma_mapping_error(dev->bus->host_pci, addr);
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* FALL THROUGH */
 	case SSB_BUSTYPE_SSB:
 		return dma_mapping_error(dev->dev, addr);
 	default:
@@ -483,6 +503,8 @@ static inline dma_addr_t ssb_dma_map_single(struct ssb_device *dev, void *p,
 		return pci_map_single(dev->bus->host_pci, p, size, dir);
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* FALL THROUGH */
 	case SSB_BUSTYPE_SSB:
 		return dma_map_single(dev->dev, p, size, dir);
 	default:
@@ -502,6 +524,8 @@ static inline void ssb_dma_unmap_single(struct ssb_device *dev, dma_addr_t dma_a
 		return;
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* FALL THROUGH */
 	case SSB_BUSTYPE_SSB:
 		dma_unmap_single(dev->dev, dma_addr, size, dir);
 		return;
@@ -524,6 +548,8 @@ static inline void ssb_dma_sync_single_for_cpu(struct ssb_device *dev,
 		return;
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* FALL THROUGH */
 	case SSB_BUSTYPE_SSB:
 		dma_sync_single_for_cpu(dev->dev, dma_addr, size, dir);
 		return;
@@ -546,6 +572,8 @@ static inline void ssb_dma_sync_single_for_device(struct ssb_device *dev,
 		return;
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* FALL THROUGH */
 	case SSB_BUSTYPE_SSB:
 		dma_sync_single_for_device(dev->dev, dma_addr, size, dir);
 		return;
@@ -570,6 +598,8 @@ static inline void ssb_dma_sync_single_range_for_cpu(struct ssb_device *dev,
 		return;
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* FALL THROUGH */
 	case SSB_BUSTYPE_SSB:
 		dma_sync_single_range_for_cpu(dev->dev, dma_addr, offset,
 					      size, dir);
@@ -595,6 +625,8 @@ static inline void ssb_dma_sync_single_range_for_device(struct ssb_device *dev,
 		return;
 #endif
 		break;
+	case SSB_BUSTYPE_SDIO:
+		/* FALL THROUGH */
 	case SSB_BUSTYPE_SSB:
 		dma_sync_single_range_for_device(dev->dev, dma_addr, offset,
 						 size, dir);
Signature · 1 line
1.6.0.4
#1 lore raw
Quoted 2 lines · On Monday 07 September 2009 20:47:27 Albert Herranz wrote:

(next time please inline the patch)

Thanks a lot for the patch. I'll do more cleanups on it and submit it to john later.

Signature · 1 line
Greetings, Michael.