Skip to content

Commit 8af70cd

Browse files
brglSantoshShilimkar
authored andcommitted
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>
1 parent f12cb8e commit 8af70cd

2 files changed

Lines changed: 63 additions & 20 deletions

File tree

‎drivers/memory/ti-aemif.c‎

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,6 @@ static int aemif_probe(struct platform_device *pdev)
339339
struct aemif_platform_data *pdata;
340340
struct of_dev_auxdata *dev_lookup;
341341

342-
if (np == NULL)
343-
return 0;
344-
345342
aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL);
346343
if (!aemif)
347344
return -ENOMEM;
@@ -363,8 +360,10 @@ static int aemif_probe(struct platform_device *pdev)
363360

364361
aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC;
365362

366-
if (of_device_is_compatible(np, "ti,da850-aemif"))
363+
if (np && of_device_is_compatible(np, "ti,da850-aemif"))
367364
aemif->cs_offset = 2;
365+
else if (pdata)
366+
aemif->cs_offset = pdata->cs_offset;
368367

369368
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
370369
aemif->base = devm_ioremap_resource(dev, res);
@@ -373,15 +372,23 @@ static int aemif_probe(struct platform_device *pdev)
373372
goto error;
374373
}
375374

376-
/*
377-
* For every controller device node, there is a cs device node that
378-
* describe the bus configuration parameters. This functions iterate
379-
* over these nodes and update the cs data array.
380-
*/
381-
for_each_available_child_of_node(np, child_np) {
382-
ret = of_aemif_parse_abus_config(pdev, child_np);
383-
if (ret < 0)
384-
goto error;
375+
if (np) {
376+
/*
377+
* For every controller device node, there is a cs device node
378+
* that describe the bus configuration parameters. This
379+
* functions iterate over these nodes and update the cs data
380+
* array.
381+
*/
382+
for_each_available_child_of_node(np, child_np) {
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+
}
385392
}
386393

387394
for (i = 0; i < aemif->num_cs; i++) {
@@ -394,14 +401,25 @@ static int aemif_probe(struct platform_device *pdev)
394401
}
395402

396403
/*
397-
* Create a child devices explicitly from here to
398-
* guarantee that the child will be probed after the AEMIF timing
399-
* parameters are set.
404+
* Create a child devices explicitly from here to guarantee that the
405+
* child will be probed after the AEMIF timing parameters are set.
400406
*/
401-
for_each_available_child_of_node(np, child_np) {
402-
ret = of_platform_populate(child_np, NULL, dev_lookup, dev);
403-
if (ret < 0)
404-
goto error;
407+
if (np) {
408+
for_each_available_child_of_node(np, child_np) {
409+
ret = of_platform_populate(child_np, NULL,
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+
}
405423
}
406424

407425
return 0;

‎include/linux/platform_data/ti-aemif.h‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,33 @@
1616

1717
#include <linux/of_platform.h>
1818

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+
*/
1939
struct aemif_platform_data {
2040
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;
2146
};
2247

2348
#endif /* __TI_DAVINCI_AEMIF_DATA_H__ */

0 commit comments

Comments
 (0)