Lines Matching +full:controller +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0
3 * Technologic Systems TS72xx NAND controller driver
33 struct nand_controller controller; member
47 switch (chip->ecc.engine_type) { in ts72xx_nand_attach_chip()
49 return -EINVAL; in ts72xx_nand_attach_chip()
51 if (chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN) in ts72xx_nand_attach_chip()
52 chip->ecc.algo = NAND_ECC_ALGO_HAMMING; in ts72xx_nand_attach_chip()
53 chip->ecc.algo = NAND_ECC_ALGO_HAMMING; in ts72xx_nand_attach_chip()
62 struct ts72xx_nand_data *data = chip_to_ts72xx(chip); in ts72xx_nand_ctrl() local
63 unsigned char bits = ioread8(data->ctrl) & ~GENMASK(2, 0); in ts72xx_nand_ctrl()
65 iowrite8(bits | value, data->ctrl); in ts72xx_nand_ctrl()
71 struct ts72xx_nand_data *data = chip_to_ts72xx(chip); in ts72xx_nand_exec_instr() local
76 switch (instr->type) { in ts72xx_nand_exec_instr()
79 iowrite8(instr->ctx.cmd.opcode, data->base); in ts72xx_nand_exec_instr()
85 iowrite8_rep(data->base, instr->ctx.addr.addrs, instr->ctx.addr.naddrs); in ts72xx_nand_exec_instr()
90 ioread8_rep(data->base, instr->ctx.data.buf.in, instr->ctx.data.len); in ts72xx_nand_exec_instr()
94 iowrite8_rep(data->base, instr->ctx.data.buf.in, instr->ctx.data.len); in ts72xx_nand_exec_instr()
98 timeout_us = instr->ctx.waitrdy.timeout_ms * 1000; in ts72xx_nand_exec_instr()
99 ret = readb_poll_timeout(data->busy, status, status & BIT(5), 0, timeout_us); in ts72xx_nand_exec_instr()
106 if (instr->delay_ns) in ts72xx_nand_exec_instr()
107 ndelay(instr->delay_ns); in ts72xx_nand_exec_instr()
121 for (i = 0; i < op->ninstrs; i++) { in ts72xx_nand_exec_op()
122 ret = ts72xx_nand_exec_instr(chip, &op->instrs[i]); in ts72xx_nand_exec_op()
137 struct ts72xx_nand_data *data; in ts72xx_nand_probe() local
142 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); in ts72xx_nand_probe()
143 if (!data) in ts72xx_nand_probe()
144 return -ENOMEM; in ts72xx_nand_probe()
146 nand_controller_init(&data->controller); in ts72xx_nand_probe()
147 data->controller.ops = &ts72xx_nand_ops; in ts72xx_nand_probe()
148 data->chip.controller = &data->controller; in ts72xx_nand_probe()
150 data->base = devm_platform_ioremap_resource(pdev, 0); in ts72xx_nand_probe()
151 if (IS_ERR(data->base)) in ts72xx_nand_probe()
152 return PTR_ERR(data->base); in ts72xx_nand_probe()
153 data->ctrl = data->base + TS72XX_NAND_CONTROL_ADDR_LINE; in ts72xx_nand_probe()
154 data->busy = data->base + TS72XX_NAND_BUSY_ADDR_LINE; in ts72xx_nand_probe()
156 child = fwnode_get_next_child_node(dev_fwnode(&pdev->dev), NULL); in ts72xx_nand_probe()
158 return dev_err_probe(&pdev->dev, -ENXIO, in ts72xx_nand_probe()
159 "ts72xx controller node should have exactly one child\n"); in ts72xx_nand_probe()
161 nand_set_flash_node(&data->chip, to_of_node(child)); in ts72xx_nand_probe()
162 mtd = nand_to_mtd(&data->chip); in ts72xx_nand_probe()
163 mtd->dev.parent = &pdev->dev; in ts72xx_nand_probe()
164 platform_set_drvdata(pdev, data); in ts72xx_nand_probe()
168 * Set ->engine_type before registering the NAND devices in order to in ts72xx_nand_probe()
171 data->chip.ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; in ts72xx_nand_probe()
174 err = nand_scan(&data->chip, 1); in ts72xx_nand_probe()
185 nand_cleanup(&data->chip); in ts72xx_nand_probe()
193 struct ts72xx_nand_data *data = platform_get_drvdata(pdev); in ts72xx_nand_remove() local
194 struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); in ts72xx_nand_remove()
195 struct nand_chip *chip = &data->chip; in ts72xx_nand_remove()
205 { .compatible = "technologic,ts7200-nand" },
212 .name = "ts72xx-nand",
221 MODULE_DESCRIPTION("Technologic Systems TS72xx NAND controller driver");