| .. | .. |
|---|
| 406 | 406 | |
|---|
| 407 | 407 | static struct snd_soc_dai *fsi_get_dai(struct snd_pcm_substream *substream) |
|---|
| 408 | 408 | { |
|---|
| 409 | | - struct snd_soc_pcm_runtime *rtd = substream->private_data; |
|---|
| 409 | + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
|---|
| 410 | 410 | |
|---|
| 411 | | - return rtd->cpu_dai; |
|---|
| 411 | + return asoc_rtd_to_cpu(rtd, 0); |
|---|
| 412 | 412 | } |
|---|
| 413 | 413 | |
|---|
| 414 | 414 | static struct fsi_priv *fsi_get_priv_frm_dai(struct snd_soc_dai *dai) |
|---|
| .. | .. |
|---|
| 780 | 780 | return -EINVAL; |
|---|
| 781 | 781 | } |
|---|
| 782 | 782 | if (clock->div == clock->own) { |
|---|
| 783 | | - dev_err(dev, "cpu doens't support div clock\n"); |
|---|
| 783 | + dev_err(dev, "cpu doesn't support div clock\n"); |
|---|
| 784 | 784 | return -EINVAL; |
|---|
| 785 | 785 | } |
|---|
| 786 | 786 | } |
|---|
| .. | .. |
|---|
| 816 | 816 | return ret; |
|---|
| 817 | 817 | } |
|---|
| 818 | 818 | |
|---|
| 819 | | - clk_enable(clock->xck); |
|---|
| 820 | | - clk_enable(clock->ick); |
|---|
| 821 | | - clk_enable(clock->div); |
|---|
| 819 | + ret = clk_enable(clock->xck); |
|---|
| 820 | + if (ret) |
|---|
| 821 | + goto err; |
|---|
| 822 | + ret = clk_enable(clock->ick); |
|---|
| 823 | + if (ret) |
|---|
| 824 | + goto disable_xck; |
|---|
| 825 | + ret = clk_enable(clock->div); |
|---|
| 826 | + if (ret) |
|---|
| 827 | + goto disable_ick; |
|---|
| 822 | 828 | |
|---|
| 823 | 829 | clock->count++; |
|---|
| 824 | 830 | } |
|---|
| 825 | 831 | |
|---|
| 832 | + return ret; |
|---|
| 833 | + |
|---|
| 834 | +disable_ick: |
|---|
| 835 | + clk_disable(clock->ick); |
|---|
| 836 | +disable_xck: |
|---|
| 837 | + clk_disable(clock->xck); |
|---|
| 838 | +err: |
|---|
| 826 | 839 | return ret; |
|---|
| 827 | 840 | } |
|---|
| 828 | 841 | |
|---|
| .. | .. |
|---|
| 1632 | 1645 | struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai); |
|---|
| 1633 | 1646 | int ret; |
|---|
| 1634 | 1647 | |
|---|
| 1635 | | - /* set master/slave audio interface */ |
|---|
| 1648 | + /* set clock master audio interface */ |
|---|
| 1636 | 1649 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
|---|
| 1637 | 1650 | case SND_SOC_DAIFMT_CBM_CFM: |
|---|
| 1638 | 1651 | break; |
|---|
| 1639 | 1652 | case SND_SOC_DAIFMT_CBS_CFS: |
|---|
| 1640 | | - fsi->clk_master = 1; /* codec is slave, cpu is master */ |
|---|
| 1653 | + fsi->clk_master = 1; /* cpu is master */ |
|---|
| 1641 | 1654 | break; |
|---|
| 1642 | 1655 | default: |
|---|
| 1643 | 1656 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 1718 | 1731 | .fifo_size = 256, |
|---|
| 1719 | 1732 | }; |
|---|
| 1720 | 1733 | |
|---|
| 1721 | | -static int fsi_pcm_open(struct snd_pcm_substream *substream) |
|---|
| 1734 | +static int fsi_pcm_open(struct snd_soc_component *component, |
|---|
| 1735 | + struct snd_pcm_substream *substream) |
|---|
| 1722 | 1736 | { |
|---|
| 1723 | 1737 | struct snd_pcm_runtime *runtime = substream->runtime; |
|---|
| 1724 | 1738 | int ret = 0; |
|---|
| .. | .. |
|---|
| 1731 | 1745 | return ret; |
|---|
| 1732 | 1746 | } |
|---|
| 1733 | 1747 | |
|---|
| 1734 | | -static int fsi_hw_params(struct snd_pcm_substream *substream, |
|---|
| 1735 | | - struct snd_pcm_hw_params *hw_params) |
|---|
| 1736 | | -{ |
|---|
| 1737 | | - return snd_pcm_lib_malloc_pages(substream, |
|---|
| 1738 | | - params_buffer_bytes(hw_params)); |
|---|
| 1739 | | -} |
|---|
| 1740 | | - |
|---|
| 1741 | | -static int fsi_hw_free(struct snd_pcm_substream *substream) |
|---|
| 1742 | | -{ |
|---|
| 1743 | | - return snd_pcm_lib_free_pages(substream); |
|---|
| 1744 | | -} |
|---|
| 1745 | | - |
|---|
| 1746 | | -static snd_pcm_uframes_t fsi_pointer(struct snd_pcm_substream *substream) |
|---|
| 1748 | +static snd_pcm_uframes_t fsi_pointer(struct snd_soc_component *component, |
|---|
| 1749 | + struct snd_pcm_substream *substream) |
|---|
| 1747 | 1750 | { |
|---|
| 1748 | 1751 | struct fsi_priv *fsi = fsi_get_priv(substream); |
|---|
| 1749 | 1752 | struct fsi_stream *io = fsi_stream_get(fsi, substream); |
|---|
| 1750 | 1753 | |
|---|
| 1751 | 1754 | return fsi_sample2frame(fsi, io->buff_sample_pos); |
|---|
| 1752 | 1755 | } |
|---|
| 1753 | | - |
|---|
| 1754 | | -static const struct snd_pcm_ops fsi_pcm_ops = { |
|---|
| 1755 | | - .open = fsi_pcm_open, |
|---|
| 1756 | | - .ioctl = snd_pcm_lib_ioctl, |
|---|
| 1757 | | - .hw_params = fsi_hw_params, |
|---|
| 1758 | | - .hw_free = fsi_hw_free, |
|---|
| 1759 | | - .pointer = fsi_pointer, |
|---|
| 1760 | | -}; |
|---|
| 1761 | 1756 | |
|---|
| 1762 | 1757 | /* |
|---|
| 1763 | 1758 | * snd_soc_component |
|---|
| .. | .. |
|---|
| 1766 | 1761 | #define PREALLOC_BUFFER (32 * 1024) |
|---|
| 1767 | 1762 | #define PREALLOC_BUFFER_MAX (32 * 1024) |
|---|
| 1768 | 1763 | |
|---|
| 1769 | | -static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) |
|---|
| 1764 | +static int fsi_pcm_new(struct snd_soc_component *component, |
|---|
| 1765 | + struct snd_soc_pcm_runtime *rtd) |
|---|
| 1770 | 1766 | { |
|---|
| 1771 | | - return snd_pcm_lib_preallocate_pages_for_all( |
|---|
| 1767 | + snd_pcm_set_managed_buffer_all( |
|---|
| 1772 | 1768 | rtd->pcm, |
|---|
| 1773 | 1769 | SNDRV_DMA_TYPE_DEV, |
|---|
| 1774 | 1770 | rtd->card->snd_card->dev, |
|---|
| 1775 | 1771 | PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); |
|---|
| 1772 | + return 0; |
|---|
| 1776 | 1773 | } |
|---|
| 1777 | 1774 | |
|---|
| 1778 | 1775 | /* |
|---|
| .. | .. |
|---|
| 1816 | 1813 | |
|---|
| 1817 | 1814 | static const struct snd_soc_component_driver fsi_soc_component = { |
|---|
| 1818 | 1815 | .name = "fsi", |
|---|
| 1819 | | - .ops = &fsi_pcm_ops, |
|---|
| 1820 | | - .pcm_new = fsi_pcm_new, |
|---|
| 1816 | + .open = fsi_pcm_open, |
|---|
| 1817 | + .pointer = fsi_pointer, |
|---|
| 1818 | + .pcm_construct = fsi_pcm_new, |
|---|
| 1821 | 1819 | }; |
|---|
| 1822 | 1820 | |
|---|
| 1823 | 1821 | /* |
|---|
| .. | .. |
|---|
| 1953 | 1951 | if (!master) |
|---|
| 1954 | 1952 | return -ENOMEM; |
|---|
| 1955 | 1953 | |
|---|
| 1956 | | - master->base = devm_ioremap_nocache(&pdev->dev, |
|---|
| 1957 | | - res->start, resource_size(res)); |
|---|
| 1954 | + master->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); |
|---|
| 1958 | 1955 | if (!master->base) { |
|---|
| 1959 | 1956 | dev_err(&pdev->dev, "Unable to ioremap FSI registers.\n"); |
|---|
| 1960 | 1957 | return -ENXIO; |
|---|