atheros: use irq_set_chained_handler()
[openwrt.git] / target / linux / atheros / patches-3.10 / 120-spiflash.patch
index 635da88..57ab46d 100644 (file)
@@ -23,7 +23,7 @@
  
 --- /dev/null
 +++ b/drivers/mtd/devices/ar2315.c
-@@ -0,0 +1,525 @@
+@@ -0,0 +1,536 @@
 +
 +/*
 + * MTD driver for the SPI Flash Memory support on Atheros AR2315
@@ -54,9 +54,7 @@
 +#include <linux/delay.h>
 +#include <linux/io.h>
 +
-+#include <ar2315_spiflash.h>
-+#include <ar231x_platform.h>
-+#include <ar231x.h>
++#include "ar2315_spiflash.h"
 +
 +
 +#define SPIFLASH "spiflash: "
@@ -89,7 +87,7 @@
 +      u32 sector_size;
 +};
 +
-+const struct flashconfig flashconfig_tbl[] = {
++static const struct flashconfig flashconfig_tbl[] = {
 +      [FLASH_NONE] = { 0, 0, 0},
 +      [FLASH_1MB]  = { STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT,
 +                       STM_1MB_SECTOR_SIZE},
 +      __s8 rx_cnt;
 +};
 +
-+const struct opcodes stm_opcodes[] = {
++static const struct opcodes stm_opcodes[] = {
 +      [SPI_WRITE_ENABLE] = {STM_OP_WR_ENABLE, 1, 0},
 +      [SPI_WRITE_DISABLE] = {STM_OP_WR_DISABLE, 1, 0},
 +      [SPI_RD_STATUS] = {STM_OP_RD_STATUS, 1, 1},
 +/* Driver private data structure */
 +struct spiflash_priv {
 +      struct mtd_info mtd;
-+      void *readaddr; /* memory mapped data for read  */
-+      void *mmraddr;  /* memory mapped register space */
++      void __iomem *readaddr; /* memory mapped data for read  */
++      void __iomem *mmraddr;  /* memory mapped register space */
 +      wait_queue_head_t wq;
 +      spinlock_t lock;
 +      int state;
 +static u32
 +spiflash_read_reg(struct spiflash_priv *priv, int reg)
 +{
-+      return ar231x_read_reg((u32) priv->mmraddr + reg);
++      return ioread32(priv->mmraddr + reg);
 +}
 +
 +static void
 +spiflash_write_reg(struct spiflash_priv *priv, int reg, u32 data)
 +{
-+      ar231x_write_reg((u32) priv->mmraddr + reg, data);
++      iowrite32(data, priv->mmraddr + reg);
 +}
 +
 +static u32
 +            u_char *buf)
 +{
 +      struct spiflash_priv *priv = to_spiflash(mtd);
-+      u8 *read_addr;
 +
 +      if (!len)
 +              return 0;
 +      if (!spiflash_wait_ready(priv, FL_READING))
 +              return -EINTR;
 +
-+      read_addr = (u8 *)(priv->readaddr + from);
-+      memcpy_fromio(buf, read_addr, len);
++      memcpy_fromio(buf, priv->readaddr + from, len);
 +      spiflash_done(priv);
 +
 +      return 0;
 +{
 +      struct spiflash_priv *priv;
 +      struct mtd_info *mtd;
++      struct resource *res;
 +      int index;
 +      int result = 0;
 +
 +      priv->state = FL_READY;
 +      mtd = &priv->mtd;
 +
-+      priv->mmraddr = ioremap_nocache(SPI_FLASH_MMR, SPI_FLASH_MMR_SIZE);
++      res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
++      if (!res) {
++              dev_err(&pdev->dev, "No MMR resource found\n");
++              goto error;
++      }
++
++      priv->mmraddr = ioremap_nocache(res->start, resource_size(res));
 +      if (!priv->mmraddr) {
 +              dev_warn(&pdev->dev, SPIFLASH "Failed to map flash device\n");
 +              goto error;
 +              goto error;
 +      }
 +
-+      priv->readaddr = ioremap_nocache(SPI_FLASH_READ,
++      res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
++      if (!res) {
++              dev_err(&pdev->dev, "No flash readmem resource found\n");
++              goto error;
++      }
++
++      priv->readaddr = ioremap_nocache(res->start,
 +                                       flashconfig_tbl[index].byte_cnt);
 +      if (!priv->readaddr) {
 +              dev_warn(&pdev->dev, SPIFLASH "Failed to map flash device\n");
 +      mtd->_write = spiflash_write;
 +      mtd->owner = THIS_MODULE;
 +
++      dev_info(&pdev->dev, "%lld Kbytes flash detected\n", mtd->size >> 10);
++
 +#if defined CONFIG_MTD_REDBOOT_PARTS || CONFIG_MTD_MYLOADER_PARTS
 +      /* parse redboot partitions */
 +
 +      return 0;
 +}
 +
-+struct platform_driver spiflash_driver = {
-+      .driver.name = "spiflash",
++static struct platform_driver spiflash_driver = {
++      .driver.name = "ar2315-spiflash",
 +      .probe = spiflash_probe,
 +      .remove = spiflash_remove,
 +};
 +
-+int __init
++static int __init
 +spiflash_init(void)
 +{
 +      return platform_driver_register(&spiflash_driver);
 +}
 +
-+void __exit
++static void __exit
 +spiflash_exit(void)
 +{
 +      return platform_driver_unregister(&spiflash_driver);
 +MODULE_DESCRIPTION("MTD driver for SPI Flash on Atheros SOC");
 +
 --- /dev/null
-+++ b/arch/mips/include/asm/mach-ar231x/ar2315_spiflash.h
-@@ -0,0 +1,116 @@
++++ b/drivers/mtd/devices/ar2315_spiflash.h
+@@ -0,0 +1,106 @@
 +/*
-+ * SPI Flash Memory support header file.
++ * Atheros AR2315 SPI Flash Memory support header file.
 + *
 + * Copyright (c) 2005, Atheros Communications Inc.
 + * Copyright (C) 2006 FON Technology, SL.
 +/*
 + * SPI Flash Interface Registers
 + */
-+#define AR531XPLUS_SPI_READ     0x08000000
-+#define AR531XPLUS_SPI_MMR      0x11300000
-+#define AR531XPLUS_SPI_MMR_SIZE 12
-+
-+#define AR531XPLUS_SPI_CTL      0x00
-+#define AR531XPLUS_SPI_OPCODE   0x04
-+#define AR531XPLUS_SPI_DATA     0x08
-+
-+#define SPI_FLASH_READ          AR531XPLUS_SPI_READ
-+#define SPI_FLASH_MMR           AR531XPLUS_SPI_MMR
-+#define SPI_FLASH_MMR_SIZE      AR531XPLUS_SPI_MMR_SIZE
-+#define SPI_FLASH_CTL           AR531XPLUS_SPI_CTL
-+#define SPI_FLASH_OPCODE        AR531XPLUS_SPI_OPCODE
-+#define SPI_FLASH_DATA          AR531XPLUS_SPI_DATA
++
++#define SPI_FLASH_CTL           0x00
++#define SPI_FLASH_OPCODE        0x04
++#define SPI_FLASH_DATA          0x08
 +
 +#define SPI_CTL_START           0x00000100
 +#define SPI_CTL_BUSY            0x00010000