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()
289 struct gpiomtd *gpiomtd; in gpio_nand_probe() local
299 gpiomtd = devm_kzalloc(dev, sizeof(*gpiomtd), GFP_KERNEL); in gpio_nand_probe()
300 if (!gpiomtd) in gpio_nand_probe()
303 chip = &gpiomtd->nand_chip; in gpio_nand_probe()
306 gpiomtd->io = devm_ioremap_resource(dev, res); in gpio_nand_probe()
307 if (IS_ERR(gpiomtd->io)) in gpio_nand_probe()
308 return PTR_ERR(gpiomtd->io); in gpio_nand_probe()
312 gpiomtd->io_sync = devm_ioremap_resource(dev, res); in gpio_nand_probe()
313 if (IS_ERR(gpiomtd->io_sync)) in gpio_nand_probe()
314 return PTR_ERR(gpiomtd->io_sync); in gpio_nand_probe()
317 ret = gpio_nand_get_config(dev, &gpiomtd->plat); in gpio_nand_probe()
322 gpiomtd->nce = devm_gpiod_get_optional(dev, "nce", GPIOD_OUT_HIGH); in gpio_nand_probe()
323 if (IS_ERR(gpiomtd->nce)) in gpio_nand_probe()
324 return PTR_ERR(gpiomtd->nce); in gpio_nand_probe()
327 gpiomtd->nwp = devm_gpiod_get_optional(dev, "nwp", GPIOD_OUT_LOW); in gpio_nand_probe()
328 if (IS_ERR(gpiomtd->nwp)) { in gpio_nand_probe()
329 ret = PTR_ERR(gpiomtd->nwp); in gpio_nand_probe()
333 gpiomtd->ale = devm_gpiod_get(dev, "ale", GPIOD_OUT_LOW); in gpio_nand_probe()
334 if (IS_ERR(gpiomtd->ale)) { in gpio_nand_probe()
335 ret = PTR_ERR(gpiomtd->ale); in gpio_nand_probe()
339 gpiomtd->cle = devm_gpiod_get(dev, "cle", GPIOD_OUT_LOW); in gpio_nand_probe()
340 if (IS_ERR(gpiomtd->cle)) { in gpio_nand_probe()
341 ret = PTR_ERR(gpiomtd->cle); in gpio_nand_probe()
345 gpiomtd->rdy = devm_gpiod_get_optional(dev, "rdy", GPIOD_IN); in gpio_nand_probe()
346 if (IS_ERR(gpiomtd->rdy)) { in gpio_nand_probe()
347 ret = PTR_ERR(gpiomtd->rdy); in gpio_nand_probe()
351 nand_controller_init(&gpiomtd->base); in gpio_nand_probe()
352 gpiomtd->base.ops = &gpio_nand_ops; in gpio_nand_probe()
355 chip->options = gpiomtd->plat.options; in gpio_nand_probe()
356 chip->controller = &gpiomtd->base; in gpio_nand_probe()
361 platform_set_drvdata(pdev, gpiomtd); in gpio_nand_probe()
364 if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) in gpio_nand_probe()
365 gpiod_direction_output(gpiomtd->nwp, 1); in gpio_nand_probe()
378 if (gpiomtd->plat.adjust_parts) in gpio_nand_probe()
379 gpiomtd->plat.adjust_parts(&gpiomtd->plat, mtd->size); in gpio_nand_probe()
381 ret = mtd_device_register(mtd, gpiomtd->plat.parts, in gpio_nand_probe()
382 gpiomtd->plat.num_parts); in gpio_nand_probe()
387 if (gpiomtd->nwp && !IS_ERR(gpiomtd->nwp)) in gpio_nand_probe()
388 gpiod_set_value(gpiomtd->nwp, 0); in gpio_nand_probe()
390 if (gpiomtd->nce && !IS_ERR(gpiomtd->nce)) in gpio_nand_probe()
391 gpiod_set_value(gpiomtd->nce, 0); in gpio_nand_probe()