14 #include <linux/kernel.h>
15 #include <linux/module.h>
24 #include <linux/slab.h>
27 #define FSL_UPM_WAIT_RUN_PATTERN 0x1
28 #define FSL_UPM_WAIT_WRITE_BYTE 0x2
29 #define FSL_UPM_WAIT_WRITE_BUFFER 0x4
70 while (--cnt && !fun_chip_ready(&fun->
mtd))
79 static void fun_cmd_ctrl(
struct mtd_info *mtd,
int cmd,
unsigned int ctrl)
86 fsl_upm_end_pattern(&fun->
upm);
101 mar = (cmd << (32 - fun->
upm.width)) |
109 static void fun_select_chip(
struct mtd_info *mtd,
int mchip_nr)
114 if (mchip_nr == -1) {
137 for (i = 0; i < len; i++)
141 static void fun_write_buf(
struct mtd_info *mtd,
const uint8_t *buf,
int len)
146 for (i = 0; i < len; i++) {
165 fun->
chip.cmd_ctrl = fun_cmd_ctrl;
167 fun->
chip.read_byte = fun_read_byte;
168 fun->
chip.read_buf = fun_read_buf;
169 fun->
chip.write_buf = fun_write_buf;
172 fun->
chip.select_chip = fun_select_chip;
175 fun->
chip.dev_ready = fun_chip_ready;
186 if (!fun->
mtd.name) {
195 ppdata.of_node = flash_np;
198 of_node_put(flash_np);
232 if (!prop || size !=
sizeof(
uint32_t)) {
233 dev_err(&ofdev->
dev,
"can't get UPM address offset\n");
240 if (!prop || size !=
sizeof(
uint32_t)) {
241 dev_err(&ofdev->
dev,
"can't get UPM command offset\n");
248 "fsl,upm-addr-line-cs-offsets", &size);
249 if (prop && (size /
sizeof(
uint32_t)) > 0) {
252 dev_err(&ofdev->
dev,
"too much multiple chips\n");
263 rnb_gpio = of_get_gpio(ofdev->
dev.of_node, i);
268 "can't request RNB gpio #%d\n", i);
273 }
else if (rnb_gpio == -
EINVAL) {
274 dev_err(&ofdev->
dev,
"RNB gpio #%d is invalid\n", i);
286 if (prop && size ==
sizeof(
uint32_t))
293 resource_size(&io_res));
302 ret = fun_chip_init(fun, ofdev->
dev.of_node, &io_res);
341 { .compatible =
"fsl,upm-nand" },
348 .name =
"fsl,upm-nand",
350 .of_match_table = of_fun_match,
361 "LocalBus User-Programmable Machine");