]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/mtd/fsmc.h
mtd: fsmc_nand: add pm callbacks to support hibernation
[mirror_ubuntu-artful-kernel.git] / include / linux / mtd / fsmc.h
CommitLineData
6c009ab8
LW
1/*
2 * incude/mtd/fsmc.h
3 *
4 * ST Microelectronics
5 * Flexible Static Memory Controller (FSMC)
6 * platform data interface and header file
7 *
8 * Copyright © 2010 ST Microelectronics
9 * Vipin Kumar <vipin.kumar@st.com>
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 */
15
16#ifndef __MTD_FSMC_H
17#define __MTD_FSMC_H
18
65ab220c 19#include <linux/io.h>
6c009ab8
LW
20#include <linux/platform_device.h>
21#include <linux/mtd/physmap.h>
22#include <linux/types.h>
23#include <linux/mtd/partitions.h>
24#include <asm/param.h>
25
26#define FSMC_NAND_BW8 1
27#define FSMC_NAND_BW16 2
28
6c009ab8
LW
29#define FSMC_MAX_NOR_BANKS 4
30#define FSMC_MAX_NAND_BANKS 4
31
32#define FSMC_FLASH_WIDTH8 1
33#define FSMC_FLASH_WIDTH16 2
34
35struct fsmc_nor_bank_regs {
36 uint32_t ctrl;
37 uint32_t ctrl_tim;
38};
39
40/* ctrl register definitions */
41#define BANK_ENABLE (1 << 0)
42#define MUXED (1 << 1)
43#define NOR_DEV (2 << 2)
44#define WIDTH_8 (0 << 4)
45#define WIDTH_16 (1 << 4)
46#define RSTPWRDWN (1 << 6)
47#define WPROT (1 << 7)
48#define WRT_ENABLE (1 << 12)
49#define WAIT_ENB (1 << 13)
50
51/* ctrl_tim register definitions */
52
b5602e86 53struct fsmc_nand_bank_regs {
6c009ab8
LW
54 uint32_t pc;
55 uint32_t sts;
56 uint32_t comm;
57 uint32_t attrib;
58 uint32_t ioata;
59 uint32_t ecc1;
60 uint32_t ecc2;
61 uint32_t ecc3;
62};
63
64#define FSMC_NOR_REG_SIZE 0x40
65
66struct fsmc_regs {
67 struct fsmc_nor_bank_regs nor_bank_regs[FSMC_MAX_NOR_BANKS];
68 uint8_t reserved_1[0x40 - 0x20];
b5602e86 69 struct fsmc_nand_bank_regs bank_regs[FSMC_MAX_NAND_BANKS];
6c009ab8
LW
70 uint8_t reserved_2[0xfe0 - 0xc0];
71 uint32_t peripid0; /* 0xfe0 */
72 uint32_t peripid1; /* 0xfe4 */
73 uint32_t peripid2; /* 0xfe8 */
74 uint32_t peripid3; /* 0xfec */
75 uint32_t pcellid0; /* 0xff0 */
76 uint32_t pcellid1; /* 0xff4 */
77 uint32_t pcellid2; /* 0xff8 */
78 uint32_t pcellid3; /* 0xffc */
79};
80
81#define FSMC_BUSY_WAIT_TIMEOUT (1 * HZ)
82
83/* pc register definitions */
84#define FSMC_RESET (1 << 0)
85#define FSMC_WAITON (1 << 1)
86#define FSMC_ENABLE (1 << 2)
87#define FSMC_DEVTYPE_NAND (1 << 3)
88#define FSMC_DEVWID_8 (0 << 4)
89#define FSMC_DEVWID_16 (1 << 4)
90#define FSMC_ECCEN (1 << 6)
91#define FSMC_ECCPLEN_512 (0 << 7)
92#define FSMC_ECCPLEN_256 (1 << 7)
93#define FSMC_TCLR_1 (1 << 9)
94#define FSMC_TAR_1 (1 << 13)
95
96/* sts register definitions */
97#define FSMC_CODE_RDY (1 << 15)
98
99/* comm register definitions */
100#define FSMC_TSET_0 (0 << 0)
101#define FSMC_TWAIT_6 (6 << 8)
102#define FSMC_THOLD_4 (4 << 16)
103#define FSMC_THIZ_1 (1 << 24)
104
6c009ab8
LW
105/*
106 * There are 13 bytes of ecc for every 512 byte block in FSMC version 8
107 * and it has to be read consecutively and immediately after the 512
108 * byte data block for hardware to generate the error bit offsets
109 * Managing the ecc bytes in the following way is easier. This way is
110 * similar to oobfree structure maintained already in u-boot nand driver
111 */
112#define MAX_ECCPLACE_ENTRIES 32
113
114struct fsmc_nand_eccplace {
115 uint8_t offset;
116 uint8_t length;
117};
118
119struct fsmc_eccplace {
120 struct fsmc_nand_eccplace eccplace[MAX_ECCPLACE_ENTRIES];
121};
122
123/**
124 * fsmc_nand_platform_data - platform specific NAND controller config
125 * @partitions: partition table for the platform, use a default fallback
126 * if this is NULL
127 * @nr_partitions: the number of partitions in the previous entry
128 * @options: different options for the driver
129 * @width: bus width
130 * @bank: default bank
131 * @select_bank: callback to select a certain bank, this is
132 * platform-specific. If the controller only supports one bank
133 * this may be set to NULL
134 */
135struct fsmc_nand_platform_data {
136 struct mtd_partition *partitions;
137 unsigned int nr_partitions;
138 unsigned int options;
139 unsigned int width;
140 unsigned int bank;
b2acc92e
SH
141
142 /* CLE, ALE offsets */
143 unsigned long cle_off;
144 unsigned long ale_off;
145
6c009ab8
LW
146 void (*select_bank)(uint32_t bank, uint32_t busw);
147};
148
149extern int __init fsmc_nor_init(struct platform_device *pdev,
150 unsigned long base, uint32_t bank, uint32_t width);
151extern void __init fsmc_init_board_info(struct platform_device *pdev,
152 struct mtd_partition *partitions, unsigned int nr_partitions,
153 unsigned int width);
154
155#endif /* __MTD_FSMC_H */