aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/mcbsp.c
diff options
context:
space:
mode:
authorKishon Vijay Abraham I <kishon@ti.com>2011-02-24 15:51:45 -0500
committerTony Lindgren <tony@atomide.com>2011-02-24 15:51:45 -0500
commit3cf32bba8ca0e0052ca41d74d455a5805b7fea85 (patch)
treef985fb7169d528e40fa94c475d64b03dbfdc6c92 /arch/arm/plat-omap/mcbsp.c
parentcd5038024d6c92fbe4bf67af91eea5c6fb24a192 (diff)
OMAP: McBSP: Convert McBSP to platform device model
Implement McBSP as platform device and add support for registering through platform device layer using resource structures. Later in this patch series, OMAP2+ McBSP driver would be modified to use hwmod framework after populating the omap2+ hwmod database. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Acked-by: Jarkko Nikula <jhnikula@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/plat-omap/mcbsp.c')
-rw-r--r--arch/arm/plat-omap/mcbsp.c59
1 files changed, 49 insertions, 10 deletions
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index b5a6e178a7f9..5f25ae5f9c1d 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -1649,7 +1649,8 @@ static const struct attribute_group sidetone_attr_group = {
1649 1649
1650static int __devinit omap_st_add(struct omap_mcbsp *mcbsp) 1650static int __devinit omap_st_add(struct omap_mcbsp *mcbsp)
1651{ 1651{
1652 struct omap_mcbsp_platform_data *pdata = mcbsp->pdata; 1652 struct platform_device *pdev;
1653 struct resource *res;
1653 struct omap_mcbsp_st_data *st_data; 1654 struct omap_mcbsp_st_data *st_data;
1654 int err; 1655 int err;
1655 1656
@@ -1659,7 +1660,10 @@ static int __devinit omap_st_add(struct omap_mcbsp *mcbsp)
1659 goto err1; 1660 goto err1;
1660 } 1661 }
1661 1662
1662 st_data->io_base_st = ioremap(pdata->phys_base_st, SZ_4K); 1663 pdev = container_of(mcbsp->dev, struct platform_device, dev);
1664
1665 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sidetone");
1666 st_data->io_base_st = ioremap(res->start, resource_size(res));
1663 if (!st_data->io_base_st) { 1667 if (!st_data->io_base_st) {
1664 err = -ENOMEM; 1668 err = -ENOMEM;
1665 goto err2; 1669 goto err2;
@@ -1748,6 +1752,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1748 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; 1752 struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data;
1749 struct omap_mcbsp *mcbsp; 1753 struct omap_mcbsp *mcbsp;
1750 int id = pdev->id - 1; 1754 int id = pdev->id - 1;
1755 struct resource *res;
1751 int ret = 0; 1756 int ret = 0;
1752 1757
1753 if (!pdata) { 1758 if (!pdata) {
@@ -1777,25 +1782,59 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1777 mcbsp->dma_tx_lch = -1; 1782 mcbsp->dma_tx_lch = -1;
1778 mcbsp->dma_rx_lch = -1; 1783 mcbsp->dma_rx_lch = -1;
1779 1784
1780 mcbsp->phys_base = pdata->phys_base; 1785 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu");
1781 mcbsp->io_base = ioremap(pdata->phys_base, SZ_4K); 1786 if (!res) {
1787 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1788 if (!res) {
1789 dev_err(&pdev->dev, "%s:mcbsp%d has invalid memory"
1790 "resource\n", __func__, pdev->id);
1791 ret = -ENOMEM;
1792 goto exit;
1793 }
1794 }
1795 mcbsp->phys_base = res->start;
1796 omap_mcbsp_cache_size = resource_size(res);
1797 mcbsp->io_base = ioremap(res->start, resource_size(res));
1782 if (!mcbsp->io_base) { 1798 if (!mcbsp->io_base) {
1783 ret = -ENOMEM; 1799 ret = -ENOMEM;
1784 goto err_ioremap; 1800 goto err_ioremap;
1785 } 1801 }
1786 1802
1803 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma");
1804 if (!res)
1805 mcbsp->phys_dma_base = mcbsp->phys_base;
1806 else
1807 mcbsp->phys_dma_base = res->start;
1808
1787 /* Default I/O is IRQ based */ 1809 /* Default I/O is IRQ based */
1788 mcbsp->io_type = OMAP_MCBSP_IRQ_IO; 1810 mcbsp->io_type = OMAP_MCBSP_IRQ_IO;
1789 mcbsp->tx_irq = pdata->tx_irq; 1811
1790 mcbsp->rx_irq = pdata->rx_irq; 1812 mcbsp->tx_irq = platform_get_irq_byname(pdev, "tx");
1791 mcbsp->dma_rx_sync = pdata->dma_rx_sync; 1813 mcbsp->rx_irq = platform_get_irq_byname(pdev, "rx");
1792 mcbsp->dma_tx_sync = pdata->dma_tx_sync; 1814
1815 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
1816 if (!res) {
1817 dev_err(&pdev->dev, "%s:mcbsp%d has invalid rx DMA channel\n",
1818 __func__, pdev->id);
1819 ret = -ENODEV;
1820 goto err_res;
1821 }
1822 mcbsp->dma_rx_sync = res->start;
1823
1824 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
1825 if (!res) {
1826 dev_err(&pdev->dev, "%s:mcbsp%d has invalid tx DMA channel\n",
1827 __func__, pdev->id);
1828 ret = -ENODEV;
1829 goto err_res;
1830 }
1831 mcbsp->dma_tx_sync = res->start;
1793 1832
1794 mcbsp->iclk = clk_get(&pdev->dev, "ick"); 1833 mcbsp->iclk = clk_get(&pdev->dev, "ick");
1795 if (IS_ERR(mcbsp->iclk)) { 1834 if (IS_ERR(mcbsp->iclk)) {
1796 ret = PTR_ERR(mcbsp->iclk); 1835 ret = PTR_ERR(mcbsp->iclk);
1797 dev_err(&pdev->dev, "unable to get ick: %d\n", ret); 1836 dev_err(&pdev->dev, "unable to get ick: %d\n", ret);
1798 goto err_iclk; 1837 goto err_res;
1799 } 1838 }
1800 1839
1801 mcbsp->fclk = clk_get(&pdev->dev, "fck"); 1840 mcbsp->fclk = clk_get(&pdev->dev, "fck");
@@ -1817,7 +1856,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
1817 1856
1818err_fclk: 1857err_fclk:
1819 clk_put(mcbsp->iclk); 1858 clk_put(mcbsp->iclk);
1820err_iclk: 1859err_res:
1821 iounmap(mcbsp->io_base); 1860 iounmap(mcbsp->io_base);
1822err_ioremap: 1861err_ioremap:
1823 kfree(mcbsp); 1862 kfree(mcbsp);