Lines Matching +full:single +full:- +full:chip

1 // SPDX-License-Identifier: GPL-2.0-only
38 static uint8_t oxnas_nand_read_byte(struct nand_chip *chip) in oxnas_nand_read_byte() argument
40 struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); in oxnas_nand_read_byte()
42 return readb(oxnas->io_base); in oxnas_nand_read_byte()
45 static void oxnas_nand_read_buf(struct nand_chip *chip, u8 *buf, int len) in oxnas_nand_read_buf() argument
47 struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); in oxnas_nand_read_buf()
49 ioread8_rep(oxnas->io_base, buf, len); in oxnas_nand_read_buf()
52 static void oxnas_nand_write_buf(struct nand_chip *chip, const u8 *buf, in oxnas_nand_write_buf() argument
55 struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); in oxnas_nand_write_buf()
57 iowrite8_rep(oxnas->io_base, buf, len); in oxnas_nand_write_buf()
60 /* Single CS command control */
61 static void oxnas_nand_cmd_ctrl(struct nand_chip *chip, int cmd, in oxnas_nand_cmd_ctrl() argument
64 struct oxnas_nand_ctrl *oxnas = nand_get_controller_data(chip); in oxnas_nand_cmd_ctrl()
67 writeb(cmd, oxnas->io_base + OXNAS_NAND_CMD_CLE); in oxnas_nand_cmd_ctrl()
69 writeb(cmd, oxnas->io_base + OXNAS_NAND_CMD_ALE); in oxnas_nand_cmd_ctrl()
77 struct device_node *np = pdev->dev.of_node; in oxnas_nand_probe()
80 struct nand_chip *chip; in oxnas_nand_probe() local
88 oxnas = devm_kzalloc(&pdev->dev, sizeof(*oxnas), in oxnas_nand_probe()
91 return -ENOMEM; in oxnas_nand_probe()
93 nand_controller_init(&oxnas->base); in oxnas_nand_probe()
96 oxnas->io_base = devm_ioremap_resource(&pdev->dev, res); in oxnas_nand_probe()
97 if (IS_ERR(oxnas->io_base)) in oxnas_nand_probe()
98 return PTR_ERR(oxnas->io_base); in oxnas_nand_probe()
100 oxnas->clk = devm_clk_get(&pdev->dev, NULL); in oxnas_nand_probe()
101 if (IS_ERR(oxnas->clk)) in oxnas_nand_probe()
102 oxnas->clk = NULL; in oxnas_nand_probe()
104 /* Only a single chip node is supported */ in oxnas_nand_probe()
107 return -EINVAL; in oxnas_nand_probe()
109 err = clk_prepare_enable(oxnas->clk); in oxnas_nand_probe()
113 device_reset_optional(&pdev->dev); in oxnas_nand_probe()
116 chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip), in oxnas_nand_probe()
118 if (!chip) { in oxnas_nand_probe()
119 err = -ENOMEM; in oxnas_nand_probe()
123 chip->controller = &oxnas->base; in oxnas_nand_probe()
125 nand_set_flash_node(chip, nand_np); in oxnas_nand_probe()
126 nand_set_controller_data(chip, oxnas); in oxnas_nand_probe()
128 mtd = nand_to_mtd(chip); in oxnas_nand_probe()
129 mtd->dev.parent = &pdev->dev; in oxnas_nand_probe()
130 mtd->priv = chip; in oxnas_nand_probe()
132 chip->legacy.cmd_ctrl = oxnas_nand_cmd_ctrl; in oxnas_nand_probe()
133 chip->legacy.read_buf = oxnas_nand_read_buf; in oxnas_nand_probe()
134 chip->legacy.read_byte = oxnas_nand_read_byte; in oxnas_nand_probe()
135 chip->legacy.write_buf = oxnas_nand_write_buf; in oxnas_nand_probe()
136 chip->legacy.chip_delay = 30; in oxnas_nand_probe()
139 err = nand_scan(chip, 1); in oxnas_nand_probe()
147 oxnas->chips[oxnas->nchips++] = chip; in oxnas_nand_probe()
151 if (!oxnas->nchips) { in oxnas_nand_probe()
152 err = -ENODEV; in oxnas_nand_probe()
161 nand_cleanup(chip); in oxnas_nand_probe()
165 for (i = 0; i < oxnas->nchips; i++) { in oxnas_nand_probe()
166 chip = oxnas->chips[i]; in oxnas_nand_probe()
167 WARN_ON(mtd_device_unregister(nand_to_mtd(chip))); in oxnas_nand_probe()
168 nand_cleanup(chip); in oxnas_nand_probe()
172 clk_disable_unprepare(oxnas->clk); in oxnas_nand_probe()
179 struct nand_chip *chip; in oxnas_nand_remove() local
182 for (i = 0; i < oxnas->nchips; i++) { in oxnas_nand_remove()
183 chip = oxnas->chips[i]; in oxnas_nand_remove()
184 WARN_ON(mtd_device_unregister(nand_to_mtd(chip))); in oxnas_nand_remove()
185 nand_cleanup(chip); in oxnas_nand_remove()
188 clk_disable_unprepare(oxnas->clk); in oxnas_nand_remove()
194 { .compatible = "oxsemi,ox820-nand" },