Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bartosz Golaszewski and committed by
Santosh Shilimkar
8af70cd2 f12cb8e2

+63 -20
+38 -20
drivers/memory/ti-aemif.c
··· 339 339 struct aemif_platform_data *pdata; 340 340 struct of_dev_auxdata *dev_lookup; 341 341 342 - if (np == NULL) 343 - return 0; 344 - 345 342 aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL); 346 343 if (!aemif) 347 344 return -ENOMEM; ··· 360 363 361 364 aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC; 362 365 363 - if (of_device_is_compatible(np, "ti,da850-aemif")) 366 + if (np && of_device_is_compatible(np, "ti,da850-aemif")) 364 367 aemif->cs_offset = 2; 368 + else if (pdata) 369 + aemif->cs_offset = pdata->cs_offset; 365 370 366 371 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 367 372 aemif->base = devm_ioremap_resource(dev, res); ··· 372 373 goto error; 373 374 } 374 375 375 - /* 376 - * For every controller device node, there is a cs device node that 377 - * describe the bus configuration parameters. This functions iterate 378 - * over these nodes and update the cs data array. 379 - */ 380 - for_each_available_child_of_node(np, child_np) { 381 - ret = of_aemif_parse_abus_config(pdev, child_np); 382 - if (ret < 0) 383 - goto error; 376 + if (np) { 377 + /* 378 + * For every controller device node, there is a cs device node 379 + * that describe the bus configuration parameters. This 380 + * functions iterate over these nodes and update the cs data 381 + * array. 382 + */ 383 + for_each_available_child_of_node(np, child_np) { 384 + ret = of_aemif_parse_abus_config(pdev, child_np); 385 + if (ret < 0) 386 + goto error; 387 + } 388 + } else if (pdata && pdata->num_abus_data > 0) { 389 + for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) { 390 + aemif->cs_data[i].cs = pdata->abus_data[i].cs; 391 + aemif_get_hw_params(pdev, i); 392 + } 384 393 } 385 394 386 395 for (i = 0; i < aemif->num_cs; i++) { ··· 401 394 } 402 395 403 396 /* 404 - * Create a child devices explicitly from here to 405 - * guarantee that the child will be probed after the AEMIF timing 406 - * parameters are set. 397 + * Create a child devices explicitly from here to guarantee that the 398 + * child will be probed after the AEMIF timing parameters are set. 407 399 */ 408 - for_each_available_child_of_node(np, child_np) { 409 - ret = of_platform_populate(child_np, NULL, dev_lookup, dev); 410 - if (ret < 0) 411 - goto error; 400 + if (np) { 401 + for_each_available_child_of_node(np, child_np) { 402 + ret = of_platform_populate(child_np, NULL, 403 + dev_lookup, dev); 404 + if (ret < 0) 405 + goto error; 406 + } 407 + } else { 408 + for (i = 0; i < pdata->num_sub_devices; i++) { 409 + pdata->sub_devices[i].dev.parent = dev; 410 + ret = platform_device_register(&pdata->sub_devices[i]); 411 + if (ret) { 412 + dev_warn(dev, "Error register sub device %s\n", 413 + pdata->sub_devices[i].name); 414 + } 415 + } 412 416 } 413 417 414 418 return 0;
+25
include/linux/platform_data/ti-aemif.h
··· 16 16 17 17 #include <linux/of_platform.h> 18 18 19 + /** 20 + * struct aemif_abus_data - Async bus configuration parameters. 21 + * 22 + * @cs - Chip-select number. 23 + */ 24 + struct aemif_abus_data { 25 + u32 cs; 26 + }; 27 + 28 + /** 29 + * struct aemif_platform_data - Data to set up the TI aemif driver. 30 + * 31 + * @dev_lookup: of_dev_auxdata passed to of_platform_populate() for aemif 32 + * subdevices. 33 + * @cs_offset: Lowest allowed chip-select number. 34 + * @abus_data: Array of async bus configuration entries. 35 + * @num_abus_data: Number of abus entries. 36 + * @sub_devices: Array of platform subdevices. 37 + * @num_sub_devices: Number of subdevices. 38 + */ 19 39 struct aemif_platform_data { 20 40 struct of_dev_auxdata *dev_lookup; 41 + u32 cs_offset; 42 + struct aemif_abus_data *abus_data; 43 + size_t num_abus_data; 44 + struct platform_device *sub_devices; 45 + size_t num_sub_devices; 21 46 }; 22 47 23 48 #endif /* __TI_DAVINCI_AEMIF_DATA_H__ */