Lines Matching +full:host +full:- +full:to +full:- +full:chip

1 // SPDX-License-Identifier: GPL-2.0-only
33 * socrates_nand_write_buf - write buffer to chip
34 * @this: NAND chip object
36 * @len: number of bytes to write
42 struct socrates_nand_host *host = nand_get_controller_data(this); in socrates_nand_write_buf() local
45 out_be32(host->io_base, FPGA_NAND_ENABLE | in socrates_nand_write_buf()
52 * socrates_nand_read_buf - read chip data into buffer
53 * @this: NAND chip object
54 * @buf: buffer to store date
55 * @len: number of bytes to read
61 struct socrates_nand_host *host = nand_get_controller_data(this); in socrates_nand_read_buf() local
66 out_be32(host->io_base, val); in socrates_nand_read_buf()
68 buf[i] = (in_be32(host->io_base) >> in socrates_nand_read_buf()
74 * socrates_nand_read_byte - read one byte from the chip
85 * Hardware specific access to control-lines
90 struct socrates_nand_host *host = nand_get_controller_data(nand_chip); in socrates_nand_cmd_ctrl() local
106 out_be32(host->io_base, val); in socrates_nand_cmd_ctrl()
114 struct socrates_nand_host *host = nand_get_controller_data(nand_chip); in socrates_nand_device_ready() local
116 if (in_be32(host->io_base) & FPGA_NAND_BUSY) in socrates_nand_device_ready()
121 static int socrates_attach_chip(struct nand_chip *chip) in socrates_attach_chip() argument
123 if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT && in socrates_attach_chip()
124 chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN) in socrates_attach_chip()
125 chip->ecc.algo = NAND_ECC_ALGO_HAMMING; in socrates_attach_chip()
139 struct socrates_nand_host *host; in socrates_nand_probe() local
145 host = devm_kzalloc(&ofdev->dev, sizeof(*host), GFP_KERNEL); in socrates_nand_probe()
146 if (!host) in socrates_nand_probe()
147 return -ENOMEM; in socrates_nand_probe()
149 host->io_base = of_iomap(ofdev->dev.of_node, 0); in socrates_nand_probe()
150 if (host->io_base == NULL) { in socrates_nand_probe()
151 dev_err(&ofdev->dev, "ioremap failed\n"); in socrates_nand_probe()
152 return -EIO; in socrates_nand_probe()
155 nand_chip = &host->nand_chip; in socrates_nand_probe()
157 host->dev = &ofdev->dev; in socrates_nand_probe()
159 nand_controller_init(&host->controller); in socrates_nand_probe()
160 host->controller.ops = &socrates_ops; in socrates_nand_probe()
161 nand_chip->controller = &host->controller; in socrates_nand_probe()
164 nand_set_controller_data(nand_chip, host); in socrates_nand_probe()
165 nand_set_flash_node(nand_chip, ofdev->dev.of_node); in socrates_nand_probe()
166 mtd->name = "socrates_nand"; in socrates_nand_probe()
167 mtd->dev.parent = &ofdev->dev; in socrates_nand_probe()
169 nand_chip->legacy.cmd_ctrl = socrates_nand_cmd_ctrl; in socrates_nand_probe()
170 nand_chip->legacy.read_byte = socrates_nand_read_byte; in socrates_nand_probe()
171 nand_chip->legacy.write_buf = socrates_nand_write_buf; in socrates_nand_probe()
172 nand_chip->legacy.read_buf = socrates_nand_read_buf; in socrates_nand_probe()
173 nand_chip->legacy.dev_ready = socrates_nand_device_ready; in socrates_nand_probe()
176 nand_chip->legacy.chip_delay = 20; /* 20us command delay time */ in socrates_nand_probe()
180 * Set ->engine_type before registering the NAND devices in order to in socrates_nand_probe()
183 nand_chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; in socrates_nand_probe()
185 dev_set_drvdata(&ofdev->dev, host); in socrates_nand_probe()
198 iounmap(host->io_base); in socrates_nand_probe()
207 struct socrates_nand_host *host = dev_get_drvdata(&ofdev->dev); in socrates_nand_remove() local
208 struct nand_chip *chip = &host->nand_chip; in socrates_nand_remove() local
211 ret = mtd_device_unregister(nand_to_mtd(chip)); in socrates_nand_remove()
213 nand_cleanup(chip); in socrates_nand_remove()
215 iounmap(host->io_base); in socrates_nand_remove()
221 .compatible = "abb,socrates-nand",