Lines Matching +full:semi +full:- +full:static
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2006-2007 PA Semi, Inc
35 static const char driver_name[] = "pasemi-nand";
37 static void pasemi_read_buf(struct nand_chip *chip, u_char *buf, int len) in pasemi_read_buf()
40 memcpy_fromio(buf, chip->legacy.IO_ADDR_R, 0x800); in pasemi_read_buf()
42 len -= 0x800; in pasemi_read_buf()
44 memcpy_fromio(buf, chip->legacy.IO_ADDR_R, len); in pasemi_read_buf()
47 static void pasemi_write_buf(struct nand_chip *chip, const u_char *buf, in pasemi_write_buf()
51 memcpy_toio(chip->legacy.IO_ADDR_R, buf, 0x800); in pasemi_write_buf()
53 len -= 0x800; in pasemi_write_buf()
55 memcpy_toio(chip->legacy.IO_ADDR_R, buf, len); in pasemi_write_buf()
58 static void pasemi_hwcontrol(struct nand_chip *chip, int cmd, in pasemi_hwcontrol()
67 out_8(chip->legacy.IO_ADDR_W + (1 << CLE_PIN_CTL), cmd); in pasemi_hwcontrol()
69 out_8(chip->legacy.IO_ADDR_W + (1 << ALE_PIN_CTL), cmd); in pasemi_hwcontrol()
73 inl(ddata->lpcctl); in pasemi_hwcontrol()
76 static int pasemi_device_ready(struct nand_chip *chip) in pasemi_device_ready()
80 return !!(inl(ddata->lpcctl) & LBICTRL_LPCCTL_NR); in pasemi_device_ready()
83 static int pasemi_attach_chip(struct nand_chip *chip) in pasemi_attach_chip()
85 if (chip->ecc.engine_type == NAND_ECC_ENGINE_TYPE_SOFT && in pasemi_attach_chip()
86 chip->ecc.algo == NAND_ECC_ALGO_UNKNOWN) in pasemi_attach_chip()
87 chip->ecc.algo = NAND_ECC_ALGO_HAMMING; in pasemi_attach_chip()
92 static const struct nand_controller_ops pasemi_ops = {
96 static int pasemi_nand_probe(struct platform_device *ofdev) in pasemi_nand_probe()
98 struct device *dev = &ofdev->dev; in pasemi_nand_probe()
100 struct device_node *np = dev->of_node; in pasemi_nand_probe()
111 return -EINVAL; in pasemi_nand_probe()
118 err = -ENOMEM; in pasemi_nand_probe()
122 chip = &ddata->chip; in pasemi_nand_probe()
123 controller = &ddata->controller; in pasemi_nand_probe()
125 controller->ops = &pasemi_ops; in pasemi_nand_probe()
127 chip->controller = controller; in pasemi_nand_probe()
132 pasemi_nand_mtd->dev.parent = dev; in pasemi_nand_probe()
134 chip->legacy.IO_ADDR_R = of_iomap(np, 0); in pasemi_nand_probe()
135 chip->legacy.IO_ADDR_W = chip->legacy.IO_ADDR_R; in pasemi_nand_probe()
137 if (!chip->legacy.IO_ADDR_R) { in pasemi_nand_probe()
138 err = -EIO; in pasemi_nand_probe()
144 err = -ENODEV; in pasemi_nand_probe()
148 ddata->lpcctl = pci_resource_start(pdev, 0); in pasemi_nand_probe()
151 if (!request_region(ddata->lpcctl, 4, driver_name)) { in pasemi_nand_probe()
152 err = -EBUSY; in pasemi_nand_probe()
156 chip->legacy.cmd_ctrl = pasemi_hwcontrol; in pasemi_nand_probe()
157 chip->legacy.dev_ready = pasemi_device_ready; in pasemi_nand_probe()
158 chip->legacy.read_buf = pasemi_read_buf; in pasemi_nand_probe()
159 chip->legacy.write_buf = pasemi_write_buf; in pasemi_nand_probe()
160 chip->legacy.chip_delay = 0; in pasemi_nand_probe()
163 chip->bbt_options = NAND_BBT_USE_FLASH; in pasemi_nand_probe()
167 * Set ->engine_type before registering the NAND devices in order to in pasemi_nand_probe()
170 chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT; in pasemi_nand_probe()
179 err = -ENODEV; in pasemi_nand_probe()
183 dev_info(dev, "PA Semi NAND flash at %pR, control at I/O %x\n", &res, in pasemi_nand_probe()
184 ddata->lpcctl); in pasemi_nand_probe()
191 release_region(ddata->lpcctl, 4); in pasemi_nand_probe()
193 iounmap(chip->legacy.IO_ADDR_R); in pasemi_nand_probe()
200 static void pasemi_nand_remove(struct platform_device *ofdev) in pasemi_nand_remove()
207 chip = &ddata->chip; in pasemi_nand_remove()
215 release_region(ddata->lpcctl, 4); in pasemi_nand_remove()
217 iounmap(chip->legacy.IO_ADDR_R); in pasemi_nand_remove()
223 static const struct of_device_id pasemi_nand_match[] =
226 .compatible = "pasemi,localbus-nand",
233 static struct platform_driver pasemi_nand_driver =
247 MODULE_DESCRIPTION("NAND flash interface driver for PA Semi PWRficient");