atheros[ar2315-spiflash]: make local variables and functions static
[openwrt/svn-archive/archive.git] / target / linux / atheros / patches-3.10 / 120-spiflash.patch
index 7f8acd095eec74e89b1817049fef57805171d4b9..580a5038dc1b711116c497eb7d99691d2e8d9815 100644 (file)
@@ -23,7 +23,7 @@
  
 --- /dev/null
 +++ b/drivers/mtd/devices/ar2315.c
-@@ -0,0 +1,519 @@
+@@ -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: "
 +      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},
-+      [FLASH_2MB]  = { STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT, STM_2MB_SECTOR_SIZE},
-+      [FLASH_4MB]  = { STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT, STM_4MB_SECTOR_SIZE},
-+      [FLASH_8MB]  = { STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT, STM_8MB_SECTOR_SIZE},
-+      [FLASH_16MB] = { STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT, STM_16MB_SECTOR_SIZE}
++      [FLASH_1MB]  = { STM_1MB_BYTE_COUNT, STM_1MB_SECTOR_COUNT,
++                       STM_1MB_SECTOR_SIZE},
++      [FLASH_2MB]  = { STM_2MB_BYTE_COUNT, STM_2MB_SECTOR_COUNT,
++                       STM_2MB_SECTOR_SIZE},
++      [FLASH_4MB]  = { STM_4MB_BYTE_COUNT, STM_4MB_SECTOR_COUNT,
++                       STM_4MB_SECTOR_SIZE},
++      [FLASH_8MB]  = { STM_8MB_BYTE_COUNT, STM_8MB_SECTOR_COUNT,
++                       STM_8MB_SECTOR_SIZE},
++      [FLASH_16MB] = { STM_16MB_BYTE_COUNT, STM_16MB_SECTOR_COUNT,
++                       STM_16MB_SECTOR_SIZE}
 +};
 +
 +/* Mapping of generic opcodes to STM serial flash opcodes */
 +      __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;
 +      FL_WRITING
 +};
 +
-+/***************************************************************************************************/
++/*****************************************************************************/
 +
 +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, flashconfig_tbl[index].byte_cnt);
++      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");
 +              goto error;
 +      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 = {
++static struct platform_driver spiflash_driver = {
 +      .driver.name = "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
++++ b/drivers/mtd/devices/ar2315_spiflash.h
 @@ -0,0 +1,116 @@
 +/*
-+ * 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.