Lines Matching refs:gpiomtd

30 struct gpiomtd {  struct
43 static inline struct gpiomtd *gpio_nand_getpriv(struct mtd_info *mtd) in gpio_nand_getpriv() argument
45 return container_of(mtd_to_nand(mtd), struct gpiomtd, nand_chip); in gpio_nand_getpriv()
57 static void gpio_nand_dosync(struct gpiomtd *gpiomtd) in gpio_nand_dosync() argument
61 if (gpiomtd->io_sync) { in gpio_nand_dosync()
67 tmp = readl(gpiomtd->io_sync); in gpio_nand_dosync()
72 static inline void gpio_nand_dosync(struct gpiomtd *gpiomtd) {} in gpio_nand_dosync() argument
78 struct gpiomtd *gpiomtd = gpio_nand_getpriv(nand_to_mtd(chip)); in gpio_nand_exec_instr() local
83 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
84 gpiod_set_value(gpiomtd->cle, 1); in gpio_nand_exec_instr()
85 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
86 writeb(instr->ctx.cmd.opcode, gpiomtd->io); in gpio_nand_exec_instr()
87 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
88 gpiod_set_value(gpiomtd->cle, 0); in gpio_nand_exec_instr()
92 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
93 gpiod_set_value(gpiomtd->ale, 1); in gpio_nand_exec_instr()
94 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
96 writeb(instr->ctx.addr.addrs[i], gpiomtd->io); in gpio_nand_exec_instr()
97 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
98 gpiod_set_value(gpiomtd->ale, 0); in gpio_nand_exec_instr()
102 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
105 ioread16_rep(gpiomtd->io, instr->ctx.data.buf.in, in gpio_nand_exec_instr()
108 ioread8_rep(gpiomtd->io, instr->ctx.data.buf.in, in gpio_nand_exec_instr()
113 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_instr()
116 iowrite16_rep(gpiomtd->io, instr->ctx.data.buf.out, in gpio_nand_exec_instr()
119 iowrite8_rep(gpiomtd->io, instr->ctx.data.buf.out, in gpio_nand_exec_instr()
124 if (!gpiomtd->rdy) in gpio_nand_exec_instr()
127 return nand_gpio_waitrdy(chip, gpiomtd->rdy, in gpio_nand_exec_instr()
141 struct gpiomtd *gpiomtd = gpio_nand_getpriv(nand_to_mtd(chip)); in gpio_nand_exec_op() local
148 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_op()
149 gpiod_set_value(gpiomtd->nce, 0); in gpio_nand_exec_op()
158 gpio_nand_dosync(gpiomtd); in gpio_nand_exec_op()
159 gpiod_set_value(gpiomtd->nce, 1); in gpio_nand_exec_op()
270 struct gpiomtd *gpiomtd = platform_get_drvdata(pdev); in gpio_nand_remove() local
271 struct nand_chip *chip = &gpiomtd->nand_chip; in gpio_nand_remove()
279 if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) in gpio_nand_remove()
280 gpiod_set_value(gpiomtd->nwp, 0); in gpio_nand_remove()
281 if (gpiomtd->nce && !IS_ERR(gpiomtd->nce)) in gpio_nand_remove()
282 gpiod_set_value(gpiomtd->nce, 0); in gpio_nand_remove()
287 struct gpiomtd *gpiomtd; in gpio_nand_probe() local
297 gpiomtd = devm_kzalloc(dev, sizeof(*gpiomtd), GFP_KERNEL); in gpio_nand_probe()
298 if (!gpiomtd) in gpio_nand_probe()
301 chip = &gpiomtd->nand_chip; in gpio_nand_probe()
303 gpiomtd->io = devm_platform_ioremap_resource(pdev, 0); in gpio_nand_probe()
304 if (IS_ERR(gpiomtd->io)) in gpio_nand_probe()
305 return PTR_ERR(gpiomtd->io); in gpio_nand_probe()
309 gpiomtd->io_sync = devm_ioremap_resource(dev, res); in gpio_nand_probe()
310 if (IS_ERR(gpiomtd->io_sync)) in gpio_nand_probe()
311 return PTR_ERR(gpiomtd->io_sync); in gpio_nand_probe()
314 ret = gpio_nand_get_config(dev, &gpiomtd->plat); in gpio_nand_probe()
319 gpiomtd->nce = devm_gpiod_get_optional(dev, "nce", GPIOD_OUT_HIGH); in gpio_nand_probe()
320 if (IS_ERR(gpiomtd->nce)) in gpio_nand_probe()
321 return PTR_ERR(gpiomtd->nce); in gpio_nand_probe()
324 gpiomtd->nwp = devm_gpiod_get_optional(dev, "nwp", GPIOD_OUT_LOW); in gpio_nand_probe()
325 if (IS_ERR(gpiomtd->nwp)) { in gpio_nand_probe()
326 ret = PTR_ERR(gpiomtd->nwp); in gpio_nand_probe()
330 gpiomtd->ale = devm_gpiod_get(dev, "ale", GPIOD_OUT_LOW); in gpio_nand_probe()
331 if (IS_ERR(gpiomtd->ale)) { in gpio_nand_probe()
332 ret = PTR_ERR(gpiomtd->ale); in gpio_nand_probe()
336 gpiomtd->cle = devm_gpiod_get(dev, "cle", GPIOD_OUT_LOW); in gpio_nand_probe()
337 if (IS_ERR(gpiomtd->cle)) { in gpio_nand_probe()
338 ret = PTR_ERR(gpiomtd->cle); in gpio_nand_probe()
342 gpiomtd->rdy = devm_gpiod_get_optional(dev, "rdy", GPIOD_IN); in gpio_nand_probe()
343 if (IS_ERR(gpiomtd->rdy)) { in gpio_nand_probe()
344 ret = PTR_ERR(gpiomtd->rdy); in gpio_nand_probe()
348 nand_controller_init(&gpiomtd->base); in gpio_nand_probe()
349 gpiomtd->base.ops = &gpio_nand_ops; in gpio_nand_probe()
352 chip->options = gpiomtd->plat.options; in gpio_nand_probe()
353 chip->controller = &gpiomtd->base; in gpio_nand_probe()
358 platform_set_drvdata(pdev, gpiomtd); in gpio_nand_probe()
361 if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) in gpio_nand_probe()
362 gpiod_direction_output(gpiomtd->nwp, 1); in gpio_nand_probe()
375 if (gpiomtd->plat.adjust_parts) in gpio_nand_probe()
376 gpiomtd->plat.adjust_parts(&gpiomtd->plat, mtd->size); in gpio_nand_probe()
378 ret = mtd_device_register(mtd, gpiomtd->plat.parts, in gpio_nand_probe()
379 gpiomtd->plat.num_parts); in gpio_nand_probe()
384 if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) in gpio_nand_probe()
385 gpiod_set_value(gpiomtd->nwp, 0); in gpio_nand_probe()
387 if (gpiomtd->nce && !IS_ERR(gpiomtd->nce)) in gpio_nand_probe()
388 gpiod_set_value(gpiomtd->nce, 0); in gpio_nand_probe()