summaryrefslogtreecommitdiffstats
path: root/drivers/memory
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2018-04-20 13:14:27 -0400
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>2018-04-20 13:14:27 -0400
commit8af70cd2ca508061088d5059ba8a8218aca7ddf1 (patch)
tree8dc44c76fc576f3d010e519f66a2994da7ebd72a /drivers/memory
parentf12cb8e274c33a5402fbdbdf4326211c3358623f (diff)
memory: aemif: add support for board files
Currently aemif is supported in two places separately. By the platform driver in drivers/memory and by a hand crafted driver in mach-davinci. We want to drop the latter but also keep the legacy mode. Add support for board files to the aemif driver. The new structure in platform data currently only contains the chip select number, since currently existing users don't require anything else, but it can be extended in the future. While extending the platform data struct, add kernel docs describing its members. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Diffstat (limited to 'drivers/memory')
-rw-r--r--drivers/memory/ti-aemif.c58
1 files changed, 38 insertions, 20 deletions
diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c
index 588e58d40d1b..31112f622b88 100644
--- a/drivers/memory/ti-aemif.c
+++ b/drivers/memory/ti-aemif.c
@@ -339,9 +339,6 @@ static int aemif_probe(struct platform_device *pdev)
339 struct aemif_platform_data *pdata; 339 struct aemif_platform_data *pdata;
340 struct of_dev_auxdata *dev_lookup; 340 struct of_dev_auxdata *dev_lookup;
341 341
342 if (np == NULL)
343 return 0;
344
345 aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL); 342 aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL);
346 if (!aemif) 343 if (!aemif)
347 return -ENOMEM; 344 return -ENOMEM;
@@ -363,8 +360,10 @@ static int aemif_probe(struct platform_device *pdev)
363 360
364 aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC; 361 aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC;
365 362
366 if (of_device_is_compatible(np, "ti,da850-aemif")) 363 if (np && of_device_is_compatible(np, "ti,da850-aemif"))
367 aemif->cs_offset = 2; 364 aemif->cs_offset = 2;
365 else if (pdata)
366 aemif->cs_offset = pdata->cs_offset;
368 367
369 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 368 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
370 aemif->base = devm_ioremap_resource(dev, res); 369 aemif->base = devm_ioremap_resource(dev, res);
@@ -373,15 +372,23 @@ static int aemif_probe(struct platform_device *pdev)
373 goto error; 372 goto error;
374 } 373 }
375 374
376 /* 375 if (np) {
377 * For every controller device node, there is a cs device node that 376 /*
378 * describe the bus configuration parameters. This functions iterate 377 * For every controller device node, there is a cs device node
379 * over these nodes and update the cs data array. 378 * that describe the bus configuration parameters. This
380 */ 379 * functions iterate over these nodes and update the cs data
381 for_each_available_child_of_node(np, child_np) { 380 * array.
382 ret = of_aemif_parse_abus_config(pdev, child_np); 381 */
383 if (ret < 0) 382 for_each_available_child_of_node(np, child_np) {
384 goto error; 383 ret = of_aemif_parse_abus_config(pdev, child_np);
384 if (ret < 0)
385 goto error;
386 }
387 } else if (pdata && pdata->num_abus_data > 0) {
388 for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
389 aemif->cs_data[i].cs = pdata->abus_data[i].cs;
390 aemif_get_hw_params(pdev, i);
391 }
385 } 392 }
386 393
387 for (i = 0; i < aemif->num_cs; i++) { 394 for (i = 0; i < aemif->num_cs; i++) {
@@ -394,14 +401,25 @@ static int aemif_probe(struct platform_device *pdev)
394 } 401 }
395 402
396 /* 403 /*
397 * Create a child devices explicitly from here to 404 * Create a child devices explicitly from here to guarantee that the
398 * guarantee that the child will be probed after the AEMIF timing 405 * child will be probed after the AEMIF timing parameters are set.
399 * parameters are set.
400 */ 406 */
401 for_each_available_child_of_node(np, child_np) { 407 if (np) {
402 ret = of_platform_populate(child_np, NULL, dev_lookup, dev); 408 for_each_available_child_of_node(np, child_np) {
403 if (ret < 0) 409 ret = of_platform_populate(child_np, NULL,
404 goto error; 410 dev_lookup, dev);
411 if (ret < 0)
412 goto error;
413 }
414 } else {
415 for (i = 0; i < pdata->num_sub_devices; i++) {
416 pdata->sub_devices[i].dev.parent = dev;
417 ret = platform_device_register(&pdata->sub_devices[i]);
418 if (ret) {
419 dev_warn(dev, "Error register sub device %s\n",
420 pdata->sub_devices[i].name);
421 }
422 }
405 } 423 }
406 424
407 return 0; 425 return 0;