Lines Matching refs:fun

59 	struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);  in fun_chip_ready()  local
61 if (gpio_get_value(fun->rnb_gpio[fun->mchip_number])) in fun_chip_ready()
64 dev_vdbg(fun->dev, "busy\n"); in fun_chip_ready()
68 static void fun_wait_rnb(struct fsl_upm_nand *fun) in fun_wait_rnb() argument
70 if (fun->rnb_gpio[fun->mchip_number] >= 0) { in fun_wait_rnb()
73 while (--cnt && !fun_chip_ready(&fun->mtd)) in fun_wait_rnb()
76 dev_err(fun->dev, "tired waiting for RNB\n"); in fun_wait_rnb()
85 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); in fun_cmd_ctrl() local
88 if (!(ctrl & fun->last_ctrl)) { in fun_cmd_ctrl()
89 fsl_upm_end_pattern(&fun->upm); in fun_cmd_ctrl()
94 fun->last_ctrl = ctrl & (NAND_ALE | NAND_CLE); in fun_cmd_ctrl()
99 fsl_upm_start_pattern(&fun->upm, fun->upm_addr_offset); in fun_cmd_ctrl()
101 fsl_upm_start_pattern(&fun->upm, fun->upm_cmd_offset); in fun_cmd_ctrl()
104 mar = (cmd << (32 - fun->upm.width)) | in fun_cmd_ctrl()
105 fun->mchip_offsets[fun->mchip_number]; in fun_cmd_ctrl()
106 fsl_upm_run_pattern(&fun->upm, chip->IO_ADDR_R, mar); in fun_cmd_ctrl()
108 if (fun->wait_flags & FSL_UPM_WAIT_RUN_PATTERN) in fun_cmd_ctrl()
109 fun_wait_rnb(fun); in fun_cmd_ctrl()
115 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); in fun_select_chip() local
120 fun->mchip_number = mchip_nr; in fun_select_chip()
121 chip->IO_ADDR_R = fun->io_base + fun->mchip_offsets[mchip_nr]; in fun_select_chip()
130 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); in fun_read_byte() local
132 return in_8(fun->chip.IO_ADDR_R); in fun_read_byte()
137 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); in fun_read_buf() local
141 buf[i] = in_8(fun->chip.IO_ADDR_R); in fun_read_buf()
146 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); in fun_write_buf() local
150 out_8(fun->chip.IO_ADDR_W, buf[i]); in fun_write_buf()
151 if (fun->wait_flags & FSL_UPM_WAIT_WRITE_BYTE) in fun_write_buf()
152 fun_wait_rnb(fun); in fun_write_buf()
154 if (fun->wait_flags & FSL_UPM_WAIT_WRITE_BUFFER) in fun_write_buf()
155 fun_wait_rnb(fun); in fun_write_buf()
158 static int __devinit fun_chip_init(struct fsl_upm_nand *fun, in fun_chip_init() argument
168 fun->chip.IO_ADDR_R = fun->io_base; in fun_chip_init()
169 fun->chip.IO_ADDR_W = fun->io_base; in fun_chip_init()
170 fun->chip.cmd_ctrl = fun_cmd_ctrl; in fun_chip_init()
171 fun->chip.chip_delay = fun->chip_delay; in fun_chip_init()
172 fun->chip.read_byte = fun_read_byte; in fun_chip_init()
173 fun->chip.read_buf = fun_read_buf; in fun_chip_init()
174 fun->chip.write_buf = fun_write_buf; in fun_chip_init()
175 fun->chip.ecc.mode = NAND_ECC_SOFT; in fun_chip_init()
176 if (fun->mchip_count > 1) in fun_chip_init()
177 fun->chip.select_chip = fun_select_chip; in fun_chip_init()
179 if (fun->rnb_gpio[0] >= 0) in fun_chip_init()
180 fun->chip.dev_ready = fun_chip_ready; in fun_chip_init()
182 fun->mtd.priv = &fun->chip; in fun_chip_init()
183 fun->mtd.owner = THIS_MODULE; in fun_chip_init()
189 fun->mtd.name = kasprintf(GFP_KERNEL, "0x%llx.%s", (u64)io_res->start, in fun_chip_init()
191 if (!fun->mtd.name) { in fun_chip_init()
196 ret = nand_scan(&fun->mtd, fun->mchip_count); in fun_chip_init()
201 ret = parse_mtd_partitions(&fun->mtd, part_types, &fun->parts, 0); in fun_chip_init()
205 ret = of_mtd_parse_partitions(fun->dev, flash_np, &fun->parts); in fun_chip_init()
211 ret = add_mtd_partitions(&fun->mtd, fun->parts, ret); in fun_chip_init()
214 ret = add_mtd_device(&fun->mtd); in fun_chip_init()
222 struct fsl_upm_nand *fun; in fun_probe() local
230 fun = kzalloc(sizeof(*fun), GFP_KERNEL); in fun_probe()
231 if (!fun) in fun_probe()
240 ret = fsl_upm_find(io_res.start, &fun->upm); in fun_probe()
253 fun->upm_addr_offset = *prop; in fun_probe()
261 fun->upm_cmd_offset = *prop; in fun_probe()
266 fun->mchip_count = size / sizeof(uint32_t); in fun_probe()
267 if (fun->mchip_count >= NAND_MAX_CHIPS) { in fun_probe()
271 for (i = 0; i < fun->mchip_count; i++) in fun_probe()
272 fun->mchip_offsets[i] = be32_to_cpu(prop[i]); in fun_probe()
274 fun->mchip_count = 1; in fun_probe()
277 for (i = 0; i < fun->mchip_count; i++) { in fun_probe()
278 fun->rnb_gpio[i] = -1; in fun_probe()
288 fun->rnb_gpio[i] = rnb_gpio; in fun_probe()
297 fun->chip_delay = be32_to_cpup(prop); in fun_probe()
299 fun->chip_delay = 50; in fun_probe()
303 fun->wait_flags = be32_to_cpup(prop); in fun_probe()
305 fun->wait_flags = FSL_UPM_WAIT_RUN_PATTERN | in fun_probe()
308 fun->io_base = devm_ioremap_nocache(&ofdev->dev, io_res.start, in fun_probe()
310 if (!fun->io_base) { in fun_probe()
315 fun->dev = &ofdev->dev; in fun_probe()
316 fun->last_ctrl = NAND_CLE; in fun_probe()
318 ret = fun_chip_init(fun, ofdev->dev.of_node, &io_res); in fun_probe()
322 dev_set_drvdata(&ofdev->dev, fun); in fun_probe()
326 for (i = 0; i < fun->mchip_count; i++) { in fun_probe()
327 if (fun->rnb_gpio[i] < 0) in fun_probe()
329 gpio_free(fun->rnb_gpio[i]); in fun_probe()
332 kfree(fun); in fun_probe()
339 struct fsl_upm_nand *fun = dev_get_drvdata(&ofdev->dev); in fun_remove() local
342 nand_release(&fun->mtd); in fun_remove()
343 kfree(fun->mtd.name); in fun_remove()
345 for (i = 0; i < fun->mchip_count; i++) { in fun_remove()
346 if (fun->rnb_gpio[i] < 0) in fun_remove()
348 gpio_free(fun->rnb_gpio[i]); in fun_remove()
351 kfree(fun); in fun_remove()