Commit 9e52ba61 authored by Timur Tabi's avatar Timur Tabi Committed by Florian Tobias Schandinat

drivers/video: fsl-diu-fb: improve device tree usage

Implement various improvements to the way the Freescale DIU framebuffer
driver access the device tree.

1) Use of_iomap() instead of of_address_to_resource() and ioremap()

2) Use be32_to_cpup() instead of directly dereferencing the device_node
   pointer.

3) Rename variable 'ofdev' to 'pdev' to avoid any confusion that it's
   a platform_device pointer, not an of_device pointer (of_device no
   longer exists).
Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
Signed-off-by: default avatarFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
parent 89f08e3e
...@@ -1425,13 +1425,12 @@ static ssize_t show_monitor(struct device *device, ...@@ -1425,13 +1425,12 @@ static ssize_t show_monitor(struct device *device,
return 0; return 0;
} }
static int __devinit fsl_diu_probe(struct platform_device *ofdev) static int __devinit fsl_diu_probe(struct platform_device *pdev)
{ {
struct device_node *np = ofdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct mfb_info *mfbi; struct mfb_info *mfbi;
phys_addr_t dummy_ad_addr = 0; phys_addr_t dummy_ad_addr = 0;
int ret, i, error = 0; int ret, i, error = 0;
struct resource res;
struct fsl_diu_data *machine_data; struct fsl_diu_data *machine_data;
int diu_mode; int diu_mode;
...@@ -1441,9 +1440,9 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev) ...@@ -1441,9 +1440,9 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev)
for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) { for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) {
machine_data->fsl_diu_info[i] = machine_data->fsl_diu_info[i] =
framebuffer_alloc(sizeof(struct mfb_info), &ofdev->dev); framebuffer_alloc(sizeof(struct mfb_info), &pdev->dev);
if (!machine_data->fsl_diu_info[i]) { if (!machine_data->fsl_diu_info[i]) {
dev_err(&ofdev->dev, "cannot allocate memory\n"); dev_err(&pdev->dev, "cannot allocate memory\n");
ret = -ENOMEM; ret = -ENOMEM;
goto error2; goto error2;
} }
...@@ -1463,19 +1462,9 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev) ...@@ -1463,19 +1462,9 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev)
} }
} }
ret = of_address_to_resource(np, 0, &res); dr.diu_reg = of_iomap(np, 0);
if (ret) {
dev_err(&ofdev->dev, "could not obtain DIU address\n");
goto error;
}
if (!res.start) {
dev_err(&ofdev->dev, "invalid DIU address\n");
goto error;
}
dr.diu_reg = ioremap(res.start, sizeof(struct diu));
if (!dr.diu_reg) { if (!dr.diu_reg) {
dev_err(&ofdev->dev, "Err: can't map DIU registers!\n"); dev_err(&pdev->dev, "cannot map DIU registers\n");
ret = -EFAULT; ret = -EFAULT;
goto error2; goto error2;
} }
...@@ -1488,25 +1477,25 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev) ...@@ -1488,25 +1477,25 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev)
machine_data->irq = irq_of_parse_and_map(np, 0); machine_data->irq = irq_of_parse_and_map(np, 0);
if (!machine_data->irq) { if (!machine_data->irq) {
dev_err(&ofdev->dev, "could not get DIU IRQ\n"); dev_err(&pdev->dev, "could not get DIU IRQ\n");
ret = -EINVAL; ret = -EINVAL;
goto error; goto error;
} }
machine_data->monitor_port = monitor_port; machine_data->monitor_port = monitor_port;
/* Area descriptor memory pool aligns to 64-bit boundary */ /* Area descriptor memory pool aligns to 64-bit boundary */
if (allocate_buf(&ofdev->dev, &pool.ad, if (allocate_buf(&pdev->dev, &pool.ad,
sizeof(struct diu_ad) * FSL_AOI_NUM, 8)) sizeof(struct diu_ad) * FSL_AOI_NUM, 8))
return -ENOMEM; return -ENOMEM;
/* Get memory for Gamma Table - 32-byte aligned memory */ /* Get memory for Gamma Table - 32-byte aligned memory */
if (allocate_buf(&ofdev->dev, &pool.gamma, 768, 32)) { if (allocate_buf(&pdev->dev, &pool.gamma, 768, 32)) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto error;
} }
/* For performance, cursor bitmap buffer aligns to 32-byte boundary */ /* For performance, cursor bitmap buffer aligns to 32-byte boundary */
if (allocate_buf(&ofdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2, if (allocate_buf(&pdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2,
32)) { 32)) {
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto error;
...@@ -1548,16 +1537,13 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev) ...@@ -1548,16 +1537,13 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev)
mfbi->ad->paddr = pool.ad.paddr + i * sizeof(struct diu_ad); mfbi->ad->paddr = pool.ad.paddr + i * sizeof(struct diu_ad);
ret = install_fb(machine_data->fsl_diu_info[i]); ret = install_fb(machine_data->fsl_diu_info[i]);
if (ret) { if (ret) {
dev_err(&ofdev->dev, dev_err(&pdev->dev, "could not register fb %d\n", i);
"Failed to register framebuffer %d\n",
i);
goto error; goto error;
} }
} }
if (request_irq_local(machine_data->irq)) { if (request_irq_local(machine_data->irq)) {
dev_err(machine_data->fsl_diu_info[0]->dev, dev_err(&pdev->dev, "could not claim irq\n");
"could not request irq for diu.");
goto error; goto error;
} }
...@@ -1569,12 +1555,11 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev) ...@@ -1569,12 +1555,11 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev)
error = device_create_file(machine_data->fsl_diu_info[0]->dev, error = device_create_file(machine_data->fsl_diu_info[0]->dev,
&machine_data->dev_attr); &machine_data->dev_attr);
if (error) { if (error) {
dev_err(machine_data->fsl_diu_info[0]->dev, dev_err(&pdev->dev, "could not create sysfs file %s\n",
"could not create sysfs %s file\n",
machine_data->dev_attr.attr.name); machine_data->dev_attr.attr.name);
} }
dev_set_drvdata(&ofdev->dev, machine_data); dev_set_drvdata(&pdev->dev, machine_data);
return 0; return 0;
error: error:
...@@ -1582,12 +1567,12 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev) ...@@ -1582,12 +1567,12 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev)
i > 0; i--) i > 0; i--)
uninstall_fb(machine_data->fsl_diu_info[i - 1]); uninstall_fb(machine_data->fsl_diu_info[i - 1]);
if (pool.ad.vaddr) if (pool.ad.vaddr)
free_buf(&ofdev->dev, &pool.ad, free_buf(&pdev->dev, &pool.ad,
sizeof(struct diu_ad) * FSL_AOI_NUM, 8); sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
if (pool.gamma.vaddr) if (pool.gamma.vaddr)
free_buf(&ofdev->dev, &pool.gamma, 768, 32); free_buf(&pdev->dev, &pool.gamma, 768, 32);
if (pool.cursor.vaddr) if (pool.cursor.vaddr)
free_buf(&ofdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2, free_buf(&pdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2,
32); 32);
if (machine_data->dummy_aoi_virt) if (machine_data->dummy_aoi_virt)
fsl_diu_free(machine_data->dummy_aoi_virt, 64); fsl_diu_free(machine_data->dummy_aoi_virt, 64);
...@@ -1602,25 +1587,23 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev) ...@@ -1602,25 +1587,23 @@ static int __devinit fsl_diu_probe(struct platform_device *ofdev)
return ret; return ret;
} }
static int fsl_diu_remove(struct platform_device *pdev)
static int fsl_diu_remove(struct platform_device *ofdev)
{ {
struct fsl_diu_data *machine_data; struct fsl_diu_data *machine_data;
int i; int i;
machine_data = dev_get_drvdata(&ofdev->dev); machine_data = dev_get_drvdata(&pdev->dev);
disable_lcdc(machine_data->fsl_diu_info[0]); disable_lcdc(machine_data->fsl_diu_info[0]);
free_irq_local(machine_data->irq); free_irq_local(machine_data->irq);
for (i = ARRAY_SIZE(machine_data->fsl_diu_info); i > 0; i--) for (i = ARRAY_SIZE(machine_data->fsl_diu_info); i > 0; i--)
uninstall_fb(machine_data->fsl_diu_info[i - 1]); uninstall_fb(machine_data->fsl_diu_info[i - 1]);
if (pool.ad.vaddr) if (pool.ad.vaddr)
free_buf(&ofdev->dev, &pool.ad, free_buf(&pdev->dev, &pool.ad,
sizeof(struct diu_ad) * FSL_AOI_NUM, 8); sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
if (pool.gamma.vaddr) if (pool.gamma.vaddr)
free_buf(&ofdev->dev, &pool.gamma, 768, 32); free_buf(&pdev->dev, &pool.gamma, 768, 32);
if (pool.cursor.vaddr) if (pool.cursor.vaddr)
free_buf(&ofdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2, free_buf(&pdev->dev, &pool.cursor, MAX_CURS * MAX_CURS * 2, 32);
32);
if (machine_data->dummy_aoi_virt) if (machine_data->dummy_aoi_virt)
fsl_diu_free(machine_data->dummy_aoi_virt, 64); fsl_diu_free(machine_data->dummy_aoi_virt, 64);
iounmap(dr.diu_reg); iounmap(dr.diu_reg);
...@@ -1722,7 +1705,7 @@ static int __init fsl_diu_init(void) ...@@ -1722,7 +1705,7 @@ static int __init fsl_diu_init(void)
* Freescale PLRU requires 13/8 times the cache size to do a proper * Freescale PLRU requires 13/8 times the cache size to do a proper
* displacement flush * displacement flush
*/ */
coherence_data_size = *prop * 13; coherence_data_size = be32_to_cpup(prop) * 13;
coherence_data_size /= 8; coherence_data_size /= 8;
prop = of_get_property(np, "d-cache-line-size", NULL); prop = of_get_property(np, "d-cache-line-size", NULL);
...@@ -1732,7 +1715,7 @@ static int __init fsl_diu_init(void) ...@@ -1732,7 +1715,7 @@ static int __init fsl_diu_init(void)
of_node_put(np); of_node_put(np);
return -ENODEV; return -ENODEV;
} }
d_cache_line_size = *prop; d_cache_line_size = be32_to_cpup(prop);
of_node_put(np); of_node_put(np);
coherence_data = vmalloc(coherence_data_size); coherence_data = vmalloc(coherence_data_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment