|
@@ -115,130 +115,6 @@ static void wl1251_spi_reset_wake(struct wl1251 *wl)
|
|
|
wl1251_spi_init(wl);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-/* Set the SPI partitions to access the chip addresses
|
|
|
- *
|
|
|
- * There are two VIRTUAL (SPI) partitions (the memory partition and the
|
|
|
- * registers partition), which are mapped to two different areas of the
|
|
|
- * PHYSICAL (hardware) memory. This function also makes other checks to
|
|
|
- * ensure that the partitions are not overlapping. In the diagram below, the
|
|
|
- * memory partition comes before the register partition, but the opposite is
|
|
|
- * also supported.
|
|
|
- *
|
|
|
- * PHYSICAL address
|
|
|
- * space
|
|
|
- *
|
|
|
- * | |
|
|
|
- * ...+----+--> mem_start
|
|
|
- * VIRTUAL address ... | |
|
|
|
- * space ... | | [PART_0]
|
|
|
- * ... | |
|
|
|
- * 0x00000000 <--+----+... ...+----+--> mem_start + mem_size
|
|
|
- * | | ... | |
|
|
|
- * |MEM | ... | |
|
|
|
- * | | ... | |
|
|
|
- * part_size <--+----+... | | {unused area)
|
|
|
- * | | ... | |
|
|
|
- * |REG | ... | |
|
|
|
- * part_size | | ... | |
|
|
|
- * + <--+----+... ...+----+--> reg_start
|
|
|
- * reg_size ... | |
|
|
|
- * ... | | [PART_1]
|
|
|
- * ... | |
|
|
|
- * ...+----+--> reg_start + reg_size
|
|
|
- * | |
|
|
|
- *
|
|
|
- */
|
|
|
-int wl1251_set_partition(struct wl1251 *wl,
|
|
|
- u32 mem_start, u32 mem_size,
|
|
|
- u32 reg_start, u32 reg_size)
|
|
|
-{
|
|
|
- struct wl1251_partition *partition;
|
|
|
- struct spi_transfer t;
|
|
|
- struct spi_message m;
|
|
|
- size_t len, cmd_len;
|
|
|
- u32 *cmd;
|
|
|
- int addr;
|
|
|
-
|
|
|
- cmd_len = sizeof(u32) + 2 * sizeof(struct wl1251_partition);
|
|
|
- cmd = kzalloc(cmd_len, GFP_KERNEL);
|
|
|
- if (!cmd)
|
|
|
- return -ENOMEM;
|
|
|
-
|
|
|
- spi_message_init(&m);
|
|
|
- memset(&t, 0, sizeof(t));
|
|
|
-
|
|
|
- partition = (struct wl1251_partition *) (cmd + 1);
|
|
|
- addr = HW_ACCESS_PART0_SIZE_ADDR;
|
|
|
- len = 2 * sizeof(struct wl1251_partition);
|
|
|
-
|
|
|
- *cmd |= WSPI_CMD_WRITE;
|
|
|
- *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
|
|
|
- *cmd |= addr & WSPI_CMD_BYTE_ADDR;
|
|
|
-
|
|
|
- wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
|
|
|
- mem_start, mem_size);
|
|
|
- wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
|
|
|
- reg_start, reg_size);
|
|
|
-
|
|
|
- /* Make sure that the two partitions together don't exceed the
|
|
|
- * address range */
|
|
|
- if ((mem_size + reg_size) > HW_ACCESS_MEMORY_MAX_RANGE) {
|
|
|
- wl1251_debug(DEBUG_SPI, "Total size exceeds maximum virtual"
|
|
|
- " address range. Truncating partition[0].");
|
|
|
- mem_size = HW_ACCESS_MEMORY_MAX_RANGE - reg_size;
|
|
|
- wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
|
|
|
- mem_start, mem_size);
|
|
|
- wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
|
|
|
- reg_start, reg_size);
|
|
|
- }
|
|
|
-
|
|
|
- if ((mem_start < reg_start) &&
|
|
|
- ((mem_start + mem_size) > reg_start)) {
|
|
|
- /* Guarantee that the memory partition doesn't overlap the
|
|
|
- * registers partition */
|
|
|
- wl1251_debug(DEBUG_SPI, "End of partition[0] is "
|
|
|
- "overlapping partition[1]. Adjusted.");
|
|
|
- mem_size = reg_start - mem_start;
|
|
|
- wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
|
|
|
- mem_start, mem_size);
|
|
|
- wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
|
|
|
- reg_start, reg_size);
|
|
|
- } else if ((reg_start < mem_start) &&
|
|
|
- ((reg_start + reg_size) > mem_start)) {
|
|
|
- /* Guarantee that the register partition doesn't overlap the
|
|
|
- * memory partition */
|
|
|
- wl1251_debug(DEBUG_SPI, "End of partition[1] is"
|
|
|
- " overlapping partition[0]. Adjusted.");
|
|
|
- reg_size = mem_start - reg_start;
|
|
|
- wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
|
|
|
- mem_start, mem_size);
|
|
|
- wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
|
|
|
- reg_start, reg_size);
|
|
|
- }
|
|
|
-
|
|
|
- partition[0].start = mem_start;
|
|
|
- partition[0].size = mem_size;
|
|
|
- partition[1].start = reg_start;
|
|
|
- partition[1].size = reg_size;
|
|
|
-
|
|
|
- wl->physical_mem_addr = mem_start;
|
|
|
- wl->physical_reg_addr = reg_start;
|
|
|
-
|
|
|
- wl->virtual_mem_addr = 0;
|
|
|
- wl->virtual_reg_addr = mem_size;
|
|
|
-
|
|
|
- t.tx_buf = cmd;
|
|
|
- t.len = cmd_len;
|
|
|
- spi_message_add_tail(&t, &m);
|
|
|
-
|
|
|
- spi_sync(wl->spi, &m);
|
|
|
-
|
|
|
- kfree(cmd);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf,
|
|
|
size_t len)
|
|
|
{
|