Commit 0d3a966d authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Boris Brezillon

mtd: nand: denali: avoid magic numbers and rename for clarification

Introduce some macros and helpers to avoid magic numbers and
rename macros/functions for clarification.

- We see '| 2' in several places.  This means Data Cycle in MAP11 mode.
  The Denali User's Guide says bit[1:0] of MAP11 is like follows:

  b'00 = Command Cycle
  b'01 = Address Cycle
  b'10 = Data Cycle

  So, this commit added DENALI_MAP11_{CMD,ADDR,DATA} macros.

- We see 'denali->flash_mem + 0x10' in several places, but 0x10 is a
  magic number.  Actually, this accesses the data port of the Host
  Data/Command Interface.  So, this commit added DENALI_HOST_DATA.
  On the other hand, 'denali->flash_mem' gets access to the address
  port, so DENALI_HOST_ADDR was also added.

- We see 'index_addr(denali, cmd, 0x1)' in denali_erase(), but 0x1
  is a magic number.  0x1 means the erase operation.  Replace 0x1
  with DENALI_ERASE.

- Rename index_addr() to denali_host_write() for clarification

- Denali User's Guide says MAP{00,01,10,11} for access mode.  Match
  the macros with terminology in the IP document.

- Rename struct members as follows:
  flash_bank   -> active_bank    (currently selected bank)
  flash_reg    -> reg            (base address of registers)
  flash_mem    -> host           (base address of host interface)
  devnum       -> devs_per_cs    (devices connected in parallel)
  bbtskipbytes -> oob_skip_bytes (number of bytes to skip in OOB)
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 777f2d49
This diff is collapsed.
...@@ -303,18 +303,13 @@ ...@@ -303,18 +303,13 @@
#define CHNL_ACTIVE__CHANNEL2 BIT(2) #define CHNL_ACTIVE__CHANNEL2 BIT(2)
#define CHNL_ACTIVE__CHANNEL3 BIT(3) #define CHNL_ACTIVE__CHANNEL3 BIT(3)
#define MODE_00 0x00000000
#define MODE_01 0x04000000
#define MODE_10 0x08000000
#define MODE_11 0x0C000000
struct denali_nand_info { struct denali_nand_info {
struct nand_chip nand; struct nand_chip nand;
unsigned long clk_x_rate; /* bus interface clock rate */ unsigned long clk_x_rate; /* bus interface clock rate */
int flash_bank; /* currently selected chip */ int active_bank; /* currently selected bank */
struct device *dev; struct device *dev;
void __iomem *flash_reg; /* Register Interface */ void __iomem *reg; /* Register Interface */
void __iomem *flash_mem; /* Host Data/Command Interface */ void __iomem *host; /* Host Data/Command Interface */
/* elements used by ISR */ /* elements used by ISR */
struct completion complete; struct completion complete;
...@@ -326,8 +321,8 @@ struct denali_nand_info { ...@@ -326,8 +321,8 @@ struct denali_nand_info {
void *buf; void *buf;
dma_addr_t dma_addr; dma_addr_t dma_addr;
int dma_avail; int dma_avail;
int devnum; /* represent how many nands connected */ int devs_per_cs; /* devices connected in parallel */
int bbtskipbytes; int oob_skip_bytes;
int max_banks; int max_banks;
unsigned int revision; unsigned int revision;
unsigned int caps; unsigned int caps;
......
...@@ -104,14 +104,14 @@ static int denali_dt_probe(struct platform_device *pdev) ...@@ -104,14 +104,14 @@ static int denali_dt_probe(struct platform_device *pdev)
} }
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "denali_reg"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "denali_reg");
denali->flash_reg = devm_ioremap_resource(&pdev->dev, res); denali->reg = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(denali->flash_reg)) if (IS_ERR(denali->reg))
return PTR_ERR(denali->flash_reg); return PTR_ERR(denali->reg);
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_data"); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nand_data");
denali->flash_mem = devm_ioremap_resource(&pdev->dev, res); denali->host = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(denali->flash_mem)) if (IS_ERR(denali->host))
return PTR_ERR(denali->flash_mem); return PTR_ERR(denali->host);
dt->clk = devm_clk_get(&pdev->dev, NULL); dt->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dt->clk)) { if (IS_ERR(dt->clk)) {
......
...@@ -78,14 +78,14 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -78,14 +78,14 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
return ret; return ret;
} }
denali->flash_reg = ioremap_nocache(csr_base, csr_len); denali->reg = ioremap_nocache(csr_base, csr_len);
if (!denali->flash_reg) { if (!denali->reg) {
dev_err(&dev->dev, "Spectra: Unable to remap memory region\n"); dev_err(&dev->dev, "Spectra: Unable to remap memory region\n");
return -ENOMEM; return -ENOMEM;
} }
denali->flash_mem = ioremap_nocache(mem_base, mem_len); denali->host = ioremap_nocache(mem_base, mem_len);
if (!denali->flash_mem) { if (!denali->host) {
dev_err(&dev->dev, "Spectra: ioremap_nocache failed!"); dev_err(&dev->dev, "Spectra: ioremap_nocache failed!");
ret = -ENOMEM; ret = -ENOMEM;
goto failed_remap_reg; goto failed_remap_reg;
...@@ -100,9 +100,9 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ...@@ -100,9 +100,9 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
return 0; return 0;
failed_remap_mem: failed_remap_mem:
iounmap(denali->flash_mem); iounmap(denali->host);
failed_remap_reg: failed_remap_reg:
iounmap(denali->flash_reg); iounmap(denali->reg);
return ret; return ret;
} }
...@@ -112,8 +112,8 @@ static void denali_pci_remove(struct pci_dev *dev) ...@@ -112,8 +112,8 @@ static void denali_pci_remove(struct pci_dev *dev)
struct denali_nand_info *denali = pci_get_drvdata(dev); struct denali_nand_info *denali = pci_get_drvdata(dev);
denali_remove(denali); denali_remove(denali);
iounmap(denali->flash_reg); iounmap(denali->reg);
iounmap(denali->flash_mem); iounmap(denali->host);
} }
static struct pci_driver denali_pci_driver = { static struct pci_driver denali_pci_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment