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
87 oxnas = devm_kzalloc(&pdev->dev, sizeof(*oxnas), in oxnas_nand_probe()
90 return -ENOMEM; in oxnas_nand_probe()
92 nand_controller_init(&oxnas->base); in oxnas_nand_probe()
94 oxnas->io_base = devm_platform_ioremap_resource(pdev, 0); in oxnas_nand_probe()
95 if (IS_ERR(oxnas->io_base)) in oxnas_nand_probe()
96 return PTR_ERR(oxnas->io_base); in oxnas_nand_probe()
98 oxnas->clk = devm_clk_get(&pdev->dev, NULL); in oxnas_nand_probe()
99 if (IS_ERR(oxnas->clk)) in oxnas_nand_probe()
100 oxnas->clk = NULL; in oxnas_nand_probe()
102 /* Only a single chip node is supported */ in oxnas_nand_probe()
105 return -EINVAL; in oxnas_nand_probe()
107 err = clk_prepare_enable(oxnas->clk); in oxnas_nand_probe()
111 device_reset_optional(&pdev->dev); in oxnas_nand_probe()
114 chip = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip), in oxnas_nand_probe()
116 if (!chip) { in oxnas_nand_probe()
117 err = -ENOMEM; in oxnas_nand_probe()
121 chip->controller = &oxnas->base; in oxnas_nand_probe()
123 nand_set_flash_node(chip, nand_np); in oxnas_nand_probe()
124 nand_set_controller_data(chip, oxnas); in oxnas_nand_probe()
126 mtd = nand_to_mtd(chip); in oxnas_nand_probe()
127 mtd->dev.parent = &pdev->dev; in oxnas_nand_probe()
128 mtd->priv = chip; in oxnas_nand_probe()
130 chip->legacy.cmd_ctrl = oxnas_nand_cmd_ctrl; in oxnas_nand_probe()
131 chip->legacy.read_buf = oxnas_nand_read_buf; in oxnas_nand_probe()
132 chip->legacy.read_byte = oxnas_nand_read_byte; in oxnas_nand_probe()
133 chip->legacy.write_buf = oxnas_nand_write_buf; in oxnas_nand_probe()
134 chip->legacy.chip_delay = 30; in oxnas_nand_probe()
137 err = nand_scan(chip, 1); in oxnas_nand_probe()
145 oxnas->chips[oxnas->nchips++] = chip; in oxnas_nand_probe()
149 if (!oxnas->nchips) { in oxnas_nand_probe()
150 err = -ENODEV; in oxnas_nand_probe()
159 nand_cleanup(chip); in oxnas_nand_probe()
163 for (i = 0; i < oxnas->nchips; i++) { in oxnas_nand_probe()
164 chip = oxnas->chips[i]; in oxnas_nand_probe()
165 WARN_ON(mtd_device_unregister(nand_to_mtd(chip))); in oxnas_nand_probe()
166 nand_cleanup(chip); in oxnas_nand_probe()
170 clk_disable_unprepare(oxnas->clk); in oxnas_nand_probe()
177 struct nand_chip *chip; in oxnas_nand_remove() local
180 for (i = 0; i < oxnas->nchips; i++) { in oxnas_nand_remove()
181 chip = oxnas->chips[i]; in oxnas_nand_remove()
182 WARN_ON(mtd_device_unregister(nand_to_mtd(chip))); in oxnas_nand_remove()
183 nand_cleanup(chip); in oxnas_nand_remove()
186 clk_disable_unprepare(oxnas->clk); in oxnas_nand_remove()
192 { .compatible = "oxsemi,ox820-nand" },