diff options
Diffstat (limited to 'arch/arm/plat-omap/mcbsp.c')
-rw-r--r-- | arch/arm/plat-omap/mcbsp.c | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c index f2401a831f99..e5842e30e534 100644 --- a/arch/arm/plat-omap/mcbsp.c +++ b/arch/arm/plat-omap/mcbsp.c | |||
@@ -214,6 +214,7 @@ EXPORT_SYMBOL(omap_mcbsp_set_io_type); | |||
214 | int omap_mcbsp_request(unsigned int id) | 214 | int omap_mcbsp_request(unsigned int id) |
215 | { | 215 | { |
216 | struct omap_mcbsp *mcbsp; | 216 | struct omap_mcbsp *mcbsp; |
217 | int i; | ||
217 | int err; | 218 | int err; |
218 | 219 | ||
219 | if (!omap_mcbsp_check_valid_id(id)) { | 220 | if (!omap_mcbsp_check_valid_id(id)) { |
@@ -225,7 +226,8 @@ int omap_mcbsp_request(unsigned int id) | |||
225 | if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) | 226 | if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request) |
226 | mcbsp->pdata->ops->request(id); | 227 | mcbsp->pdata->ops->request(id); |
227 | 228 | ||
228 | clk_enable(mcbsp->clk); | 229 | for (i = 0; i < mcbsp->num_clks; i++) |
230 | clk_enable(mcbsp->clks[i]); | ||
229 | 231 | ||
230 | spin_lock(&mcbsp->lock); | 232 | spin_lock(&mcbsp->lock); |
231 | if (!mcbsp->free) { | 233 | if (!mcbsp->free) { |
@@ -276,6 +278,7 @@ EXPORT_SYMBOL(omap_mcbsp_request); | |||
276 | void omap_mcbsp_free(unsigned int id) | 278 | void omap_mcbsp_free(unsigned int id) |
277 | { | 279 | { |
278 | struct omap_mcbsp *mcbsp; | 280 | struct omap_mcbsp *mcbsp; |
281 | int i; | ||
279 | 282 | ||
280 | if (!omap_mcbsp_check_valid_id(id)) { | 283 | if (!omap_mcbsp_check_valid_id(id)) { |
281 | printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); | 284 | printk(KERN_ERR "%s: Invalid id (%d)\n", __func__, id + 1); |
@@ -286,7 +289,8 @@ void omap_mcbsp_free(unsigned int id) | |||
286 | if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) | 289 | if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->free) |
287 | mcbsp->pdata->ops->free(id); | 290 | mcbsp->pdata->ops->free(id); |
288 | 291 | ||
289 | clk_disable(mcbsp->clk); | 292 | for (i = mcbsp->num_clks - 1; i >= 0; i--) |
293 | clk_disable(mcbsp->clks[i]); | ||
290 | 294 | ||
291 | spin_lock(&mcbsp->lock); | 295 | spin_lock(&mcbsp->lock); |
292 | if (mcbsp->free) { | 296 | if (mcbsp->free) { |
@@ -872,6 +876,7 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) | |||
872 | struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; | 876 | struct omap_mcbsp_platform_data *pdata = pdev->dev.platform_data; |
873 | struct omap_mcbsp *mcbsp; | 877 | struct omap_mcbsp *mcbsp; |
874 | int id = pdev->id - 1; | 878 | int id = pdev->id - 1; |
879 | int i; | ||
875 | int ret = 0; | 880 | int ret = 0; |
876 | 881 | ||
877 | if (!pdata) { | 882 | if (!pdata) { |
@@ -916,14 +921,25 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) | |||
916 | mcbsp->dma_rx_sync = pdata->dma_rx_sync; | 921 | mcbsp->dma_rx_sync = pdata->dma_rx_sync; |
917 | mcbsp->dma_tx_sync = pdata->dma_tx_sync; | 922 | mcbsp->dma_tx_sync = pdata->dma_tx_sync; |
918 | 923 | ||
919 | if (pdata->clk_name) | 924 | if (pdata->num_clks) { |
920 | mcbsp->clk = clk_get(&pdev->dev, pdata->clk_name); | 925 | mcbsp->num_clks = pdata->num_clks; |
921 | if (IS_ERR(mcbsp->clk)) { | 926 | mcbsp->clks = kzalloc(mcbsp->num_clks * sizeof(struct clk *), |
922 | dev_err(&pdev->dev, | 927 | GFP_KERNEL); |
923 | "Invalid clock configuration for McBSP%d.\n", | 928 | if (!mcbsp->clks) { |
924 | mcbsp->id); | 929 | ret = -ENOMEM; |
925 | ret = PTR_ERR(mcbsp->clk); | 930 | goto exit; |
926 | goto err_clk; | 931 | } |
932 | for (i = 0; i < mcbsp->num_clks; i++) { | ||
933 | mcbsp->clks[i] = clk_get(&pdev->dev, pdata->clk_names[i]); | ||
934 | if (IS_ERR(mcbsp->clks[i])) { | ||
935 | dev_err(&pdev->dev, | ||
936 | "Invalid %s configuration for McBSP%d.\n", | ||
937 | pdata->clk_names[i], mcbsp->id); | ||
938 | ret = PTR_ERR(mcbsp->clks[i]); | ||
939 | goto err_clk; | ||
940 | } | ||
941 | } | ||
942 | |||
927 | } | 943 | } |
928 | 944 | ||
929 | mcbsp->pdata = pdata; | 945 | mcbsp->pdata = pdata; |
@@ -932,6 +948,9 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev) | |||
932 | return 0; | 948 | return 0; |
933 | 949 | ||
934 | err_clk: | 950 | err_clk: |
951 | while (i--) | ||
952 | clk_put(mcbsp->clks[i]); | ||
953 | kfree(mcbsp->clks); | ||
935 | iounmap(mcbsp->io_base); | 954 | iounmap(mcbsp->io_base); |
936 | err_ioremap: | 955 | err_ioremap: |
937 | mcbsp->free = 0; | 956 | mcbsp->free = 0; |
@@ -942,6 +961,7 @@ exit: | |||
942 | static int __devexit omap_mcbsp_remove(struct platform_device *pdev) | 961 | static int __devexit omap_mcbsp_remove(struct platform_device *pdev) |
943 | { | 962 | { |
944 | struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); | 963 | struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); |
964 | int i; | ||
945 | 965 | ||
946 | platform_set_drvdata(pdev, NULL); | 966 | platform_set_drvdata(pdev, NULL); |
947 | if (mcbsp) { | 967 | if (mcbsp) { |
@@ -950,12 +970,18 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev) | |||
950 | mcbsp->pdata->ops->free) | 970 | mcbsp->pdata->ops->free) |
951 | mcbsp->pdata->ops->free(mcbsp->id); | 971 | mcbsp->pdata->ops->free(mcbsp->id); |
952 | 972 | ||
953 | clk_disable(mcbsp->clk); | 973 | for (i = mcbsp->num_clks - 1; i >= 0; i--) { |
954 | clk_put(mcbsp->clk); | 974 | clk_disable(mcbsp->clks[i]); |
975 | clk_put(mcbsp->clks[i]); | ||
976 | } | ||
955 | 977 | ||
956 | iounmap(mcbsp->io_base); | 978 | iounmap(mcbsp->io_base); |
957 | 979 | ||
958 | mcbsp->clk = NULL; | 980 | if (mcbsp->num_clks) { |
981 | kfree(mcbsp->clks); | ||
982 | mcbsp->clks = NULL; | ||
983 | mcbsp->num_clks = 0; | ||
984 | } | ||
959 | mcbsp->free = 0; | 985 | mcbsp->free = 0; |
960 | mcbsp->dev = NULL; | 986 | mcbsp->dev = NULL; |
961 | } | 987 | } |