Lines Matching +full:mtd +full:- +full:ram

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* drivers/mtd/maps/plat-ram.c
4 * (c) 2004-2005 Simtec Electronics
8 * Generic platform device based RAM map
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/map.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/mtd/plat-ram.h>
27 /* private structure for each mtd platform ram device created */
31 struct mtd_info *mtd; member
50 * to = 0 => read-only
51 * = 1 => read-write
56 if (info->pdata == NULL) in platram_setrw()
59 if (info->pdata->set_rw != NULL) in platram_setrw()
60 (info->pdata->set_rw)(info->dev, to); in platram_setrw()
72 dev_dbg(&pdev->dev, "removing device\n"); in platram_remove()
77 if (info->mtd) { in platram_remove()
78 mtd_device_unregister(info->mtd); in platram_remove()
79 map_destroy(info->mtd); in platram_remove()
82 /* ensure ram is left read-only */ in platram_remove()
102 dev_dbg(&pdev->dev, "probe entered\n"); in platram_probe()
104 if (dev_get_platdata(&pdev->dev) == NULL) { in platram_probe()
105 dev_err(&pdev->dev, "no platform data supplied\n"); in platram_probe()
106 err = -ENOENT; in platram_probe()
110 pdata = dev_get_platdata(&pdev->dev); in platram_probe()
114 err = -ENOMEM; in platram_probe()
120 info->dev = &pdev->dev; in platram_probe()
121 info->pdata = pdata; in platram_probe()
124 info->map.virt = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in platram_probe()
125 if (IS_ERR(info->map.virt)) { in platram_probe()
126 err = PTR_ERR(info->map.virt); in platram_probe()
130 dev_dbg(&pdev->dev, "got platform resource %p (0x%llx)\n", res, in platram_probe()
131 (unsigned long long)res->start); in platram_probe()
135 info->map.phys = res->start; in platram_probe()
136 info->map.size = resource_size(res); in platram_probe()
137 info->map.name = pdata->mapname != NULL ? in platram_probe()
138 (char *)pdata->mapname : (char *)pdev->name; in platram_probe()
139 info->map.bankwidth = pdata->bankwidth; in platram_probe()
141 dev_dbg(&pdev->dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size); in platram_probe()
143 simple_map_init(&info->map); in platram_probe()
145 dev_dbg(&pdev->dev, "initialised map, probing for mtd\n"); in platram_probe()
147 /* probe for the right mtd map driver in platram_probe()
150 if (pdata->map_probes) { in platram_probe()
151 const char * const *map_probes = pdata->map_probes; in platram_probe()
153 for ( ; !info->mtd && *map_probes; map_probes++) in platram_probe()
154 info->mtd = do_map_probe(*map_probes , &info->map); in platram_probe()
158 info->mtd = do_map_probe("map_ram", &info->map); in platram_probe()
160 if (info->mtd == NULL) { in platram_probe()
161 dev_err(&pdev->dev, "failed to probe for map_ram\n"); in platram_probe()
162 err = -ENOMEM; in platram_probe()
166 info->mtd->dev.parent = &pdev->dev; in platram_probe()
173 err = mtd_device_parse_register(info->mtd, pdata->probes, NULL, in platram_probe()
174 pdata->partitions, in platram_probe()
175 pdata->nr_partitions); in platram_probe()
177 dev_err(&pdev->dev, "failed to register mtd device\n"); in platram_probe()
181 dev_info(&pdev->dev, "registered mtd device\n"); in platram_probe()
183 if (pdata->nr_partitions) { in platram_probe()
185 err = mtd_device_register(info->mtd, NULL, 0); in platram_probe()
187 dev_err(&pdev->dev, in platram_probe()
204 MODULE_ALIAS("platform:mtd-ram");
210 .name = "mtd-ram",
218 MODULE_DESCRIPTION("MTD platform RAM map driver");