4
4
* Author: Jerome Brunet <[email protected] >
5
5
*/
6
6
7
+ #include <linux/auxiliary_bus.h>
7
8
#include <linux/clk.h>
8
9
#include <linux/clk-provider.h>
9
10
#include <linux/init.h>
12
13
#include <linux/platform_device.h>
13
14
#include <linux/regmap.h>
14
15
#include <linux/reset.h>
15
- #include <linux/reset-controller.h>
16
16
#include <linux/slab.h>
17
17
18
18
#include "meson-clkc-utils.h"
@@ -1678,84 +1678,6 @@ static struct clk_regmap *const sm1_clk_regmaps[] = {
1678
1678
& sm1_earcrx_dmac_clk ,
1679
1679
};
1680
1680
1681
- struct axg_audio_reset_data {
1682
- struct reset_controller_dev rstc ;
1683
- struct regmap * map ;
1684
- unsigned int offset ;
1685
- };
1686
-
1687
- static void axg_audio_reset_reg_and_bit (struct axg_audio_reset_data * rst ,
1688
- unsigned long id ,
1689
- unsigned int * reg ,
1690
- unsigned int * bit )
1691
- {
1692
- unsigned int stride = regmap_get_reg_stride (rst -> map );
1693
-
1694
- * reg = (id / (stride * BITS_PER_BYTE )) * stride ;
1695
- * reg += rst -> offset ;
1696
- * bit = id % (stride * BITS_PER_BYTE );
1697
- }
1698
-
1699
- static int axg_audio_reset_update (struct reset_controller_dev * rcdev ,
1700
- unsigned long id , bool assert )
1701
- {
1702
- struct axg_audio_reset_data * rst =
1703
- container_of (rcdev , struct axg_audio_reset_data , rstc );
1704
- unsigned int offset , bit ;
1705
-
1706
- axg_audio_reset_reg_and_bit (rst , id , & offset , & bit );
1707
-
1708
- regmap_update_bits (rst -> map , offset , BIT (bit ),
1709
- assert ? BIT (bit ) : 0 );
1710
-
1711
- return 0 ;
1712
- }
1713
-
1714
- static int axg_audio_reset_status (struct reset_controller_dev * rcdev ,
1715
- unsigned long id )
1716
- {
1717
- struct axg_audio_reset_data * rst =
1718
- container_of (rcdev , struct axg_audio_reset_data , rstc );
1719
- unsigned int val , offset , bit ;
1720
-
1721
- axg_audio_reset_reg_and_bit (rst , id , & offset , & bit );
1722
-
1723
- regmap_read (rst -> map , offset , & val );
1724
-
1725
- return !!(val & BIT (bit ));
1726
- }
1727
-
1728
- static int axg_audio_reset_assert (struct reset_controller_dev * rcdev ,
1729
- unsigned long id )
1730
- {
1731
- return axg_audio_reset_update (rcdev , id , true);
1732
- }
1733
-
1734
- static int axg_audio_reset_deassert (struct reset_controller_dev * rcdev ,
1735
- unsigned long id )
1736
- {
1737
- return axg_audio_reset_update (rcdev , id , false);
1738
- }
1739
-
1740
- static int axg_audio_reset_toggle (struct reset_controller_dev * rcdev ,
1741
- unsigned long id )
1742
- {
1743
- int ret ;
1744
-
1745
- ret = axg_audio_reset_assert (rcdev , id );
1746
- if (ret )
1747
- return ret ;
1748
-
1749
- return axg_audio_reset_deassert (rcdev , id );
1750
- }
1751
-
1752
- static const struct reset_control_ops axg_audio_rstc_ops = {
1753
- .assert = axg_audio_reset_assert ,
1754
- .deassert = axg_audio_reset_deassert ,
1755
- .reset = axg_audio_reset_toggle ,
1756
- .status = axg_audio_reset_status ,
1757
- };
1758
-
1759
1681
static struct regmap_config axg_audio_regmap_cfg = {
1760
1682
.reg_bits = 32 ,
1761
1683
.val_bits = 32 ,
@@ -1766,16 +1688,15 @@ struct audioclk_data {
1766
1688
struct clk_regmap * const * regmap_clks ;
1767
1689
unsigned int regmap_clk_num ;
1768
1690
struct meson_clk_hw_data hw_clks ;
1769
- unsigned int reset_offset ;
1770
- unsigned int reset_num ;
1691
+ const char * rst_drvname ;
1771
1692
unsigned int max_register ;
1772
1693
};
1773
1694
1774
1695
static int axg_audio_clkc_probe (struct platform_device * pdev )
1775
1696
{
1776
1697
struct device * dev = & pdev -> dev ;
1777
1698
const struct audioclk_data * data ;
1778
- struct axg_audio_reset_data * rst ;
1699
+ struct auxiliary_device * auxdev ;
1779
1700
struct regmap * map ;
1780
1701
void __iomem * regs ;
1781
1702
struct clk_hw * hw ;
@@ -1834,22 +1755,15 @@ static int axg_audio_clkc_probe(struct platform_device *pdev)
1834
1755
if (ret )
1835
1756
return ret ;
1836
1757
1837
- /* Stop here if there is no reset */
1838
- if (!data -> reset_num )
1839
- return 0 ;
1840
-
1841
- rst = devm_kzalloc (dev , sizeof (* rst ), GFP_KERNEL );
1842
- if (!rst )
1843
- return - ENOMEM ;
1844
-
1845
- rst -> map = map ;
1846
- rst -> offset = data -> reset_offset ;
1847
- rst -> rstc .nr_resets = data -> reset_num ;
1848
- rst -> rstc .ops = & axg_audio_rstc_ops ;
1849
- rst -> rstc .of_node = dev -> of_node ;
1850
- rst -> rstc .owner = THIS_MODULE ;
1758
+ /* Register auxiliary reset driver when applicable */
1759
+ if (data -> rst_drvname ) {
1760
+ auxdev = __devm_auxiliary_device_create (dev , dev -> driver -> name ,
1761
+ data -> rst_drvname , NULL , 0 );
1762
+ if (!auxdev )
1763
+ return - ENODEV ;
1764
+ }
1851
1765
1852
- return devm_reset_controller_register ( dev , & rst -> rstc ) ;
1766
+ return 0 ;
1853
1767
}
1854
1768
1855
1769
static const struct audioclk_data axg_audioclk_data = {
@@ -1869,8 +1783,7 @@ static const struct audioclk_data g12a_audioclk_data = {
1869
1783
.hws = g12a_audio_hw_clks ,
1870
1784
.num = ARRAY_SIZE (g12a_audio_hw_clks ),
1871
1785
},
1872
- .reset_offset = AUDIO_SW_RESET ,
1873
- .reset_num = 26 ,
1786
+ .rst_drvname = "rst-g12a" ,
1874
1787
.max_register = AUDIO_CLK_SPDIFOUT_B_CTRL ,
1875
1788
};
1876
1789
@@ -1881,8 +1794,7 @@ static const struct audioclk_data sm1_audioclk_data = {
1881
1794
.hws = sm1_audio_hw_clks ,
1882
1795
.num = ARRAY_SIZE (sm1_audio_hw_clks ),
1883
1796
},
1884
- .reset_offset = AUDIO_SM1_SW_RESET0 ,
1885
- .reset_num = 39 ,
1797
+ .rst_drvname = "rst-sm1" ,
1886
1798
.max_register = AUDIO_EARCRX_DMAC_CLK_CTRL ,
1887
1799
};
1888
1800
0 commit comments