ion: msm: Clean up DT parsing
Many of the DT options for reserving memory are no longer used at all. Simply the reading of bases/sizes from the DT and convert to the new format. Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
This commit is contained in:
parent
2e3f26f069
commit
44e7c99081
1 changed files with 15 additions and 112 deletions
|
@ -450,120 +450,30 @@ static void free_pdata(const struct ion_platform_data *pdata)
|
||||||
kfree(pdata);
|
kfree(pdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void msm_ion_get_heap_align(struct device_node *node,
|
static void msm_ion_get_heap_dt_data(struct device_node *node,
|
||||||
struct ion_platform_heap *heap)
|
|
||||||
{
|
|
||||||
unsigned int val;
|
|
||||||
|
|
||||||
int ret = of_property_read_u32(node, "qcom,heap-align", &val);
|
|
||||||
if (!ret) {
|
|
||||||
switch ((int) heap->type) {
|
|
||||||
case ION_HEAP_TYPE_CARVEOUT:
|
|
||||||
{
|
|
||||||
struct ion_co_heap_pdata *extra =
|
|
||||||
heap->extra_data;
|
|
||||||
extra->align = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
pr_err("ION-heap %s: Cannot specify alignment for this type of heap\n",
|
|
||||||
heap->name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int msm_ion_get_heap_size(struct device_node *node,
|
|
||||||
struct ion_platform_heap *heap)
|
struct ion_platform_heap *heap)
|
||||||
{
|
{
|
||||||
unsigned int val;
|
|
||||||
int ret = 0;
|
|
||||||
u32 out_values[2];
|
|
||||||
struct device_node *pnode;
|
struct device_node *pnode;
|
||||||
|
|
||||||
ret = of_property_read_u32(node, "qcom,memory-reservation-size", &val);
|
pnode = of_parse_phandle(node, "memory-region", 0);
|
||||||
if (!ret)
|
|
||||||
heap->size = val;
|
|
||||||
|
|
||||||
ret = of_property_read_u32_array(node, "qcom,memory-fixed",
|
|
||||||
out_values, 2);
|
|
||||||
if (!ret) {
|
|
||||||
heap->size = out_values[1];
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
pnode = of_parse_phandle(node, "linux,contiguous-region", 0);
|
|
||||||
if (pnode != NULL) {
|
if (pnode != NULL) {
|
||||||
const u32 *addr;
|
const __be32 *basep;
|
||||||
u64 size;
|
u64 size;
|
||||||
|
u64 base;
|
||||||
|
|
||||||
addr = of_get_address(pnode, 0, &size, NULL);
|
basep = of_get_address(pnode, 0, &size, NULL);
|
||||||
if (!addr) {
|
if (!basep) {
|
||||||
of_node_put(pnode);
|
base = cma_get_base(dev_get_cma_area(heap->priv));
|
||||||
ret = -EINVAL;
|
size = cma_get_size(dev_get_cma_area(heap->priv));
|
||||||
goto out;
|
} else {
|
||||||
|
base = of_translate_address(pnode, basep);
|
||||||
|
WARN(base == OF_BAD_ADDR, "Failed to parse DT node for heap %s\n",
|
||||||
|
heap->name);
|
||||||
}
|
}
|
||||||
heap->size = (u32) size;
|
heap->base = base;
|
||||||
ret = 0;
|
heap->size = size;
|
||||||
of_node_put(pnode);
|
of_node_put(pnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void msm_ion_get_heap_base(struct device_node *node,
|
|
||||||
struct ion_platform_heap *heap)
|
|
||||||
{
|
|
||||||
u32 out_values[2];
|
|
||||||
int ret = 0;
|
|
||||||
struct device_node *pnode;
|
|
||||||
|
|
||||||
ret = of_property_read_u32_array(node, "qcom,memory-fixed",
|
|
||||||
out_values, 2);
|
|
||||||
if (!ret)
|
|
||||||
heap->base = out_values[0];
|
|
||||||
|
|
||||||
pnode = of_parse_phandle(node, "linux,contiguous-region", 0);
|
|
||||||
if (pnode != NULL) {
|
|
||||||
heap->base = cma_get_base(heap->priv);
|
|
||||||
of_node_put(pnode);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void msm_ion_get_heap_adjacent(struct device_node *node,
|
|
||||||
struct ion_platform_heap *heap)
|
|
||||||
{
|
|
||||||
unsigned int val;
|
|
||||||
int ret = of_property_read_u32(node, "qcom,heap-adjacent", &val);
|
|
||||||
if (!ret) {
|
|
||||||
switch (heap->type) {
|
|
||||||
case ION_HEAP_TYPE_CARVEOUT:
|
|
||||||
{
|
|
||||||
struct ion_co_heap_pdata *extra = heap->extra_data;
|
|
||||||
extra->adjacent_mem_id = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
pr_err("ION-heap %s: Cannot specify adjcent mem id for this type of heap\n",
|
|
||||||
heap->name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (heap->type) {
|
|
||||||
case ION_HEAP_TYPE_CARVEOUT:
|
|
||||||
{
|
|
||||||
struct ion_co_heap_pdata *extra = heap->extra_data;
|
|
||||||
extra->adjacent_mem_id = INVALID_HEAP_ID;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
|
static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
|
||||||
|
@ -621,14 +531,7 @@ static struct ion_platform_data *msm_ion_parse_dt(struct platform_device *pdev)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_heaps;
|
goto free_heaps;
|
||||||
|
|
||||||
msm_ion_get_heap_base(node, &pdata->heaps[idx]);
|
msm_ion_get_heap_dt_data(node, &pdata->heaps[idx]);
|
||||||
msm_ion_get_heap_align(node, &pdata->heaps[idx]);
|
|
||||||
|
|
||||||
ret = msm_ion_get_heap_size(node, &pdata->heaps[idx]);
|
|
||||||
if (ret)
|
|
||||||
goto free_heaps;
|
|
||||||
|
|
||||||
msm_ion_get_heap_adjacent(node, &pdata->heaps[idx]);
|
|
||||||
|
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue