hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mfd/ab8500-debugfs.c
....@@ -1,8 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) ST-Ericsson SA 2010
34 *
45 * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson.
5
- * License Terms: GNU General Public License v2
66 */
77 /*
88 * AB8500 register access
....@@ -84,7 +84,6 @@
8484
8585 #include <linux/mfd/abx500.h>
8686 #include <linux/mfd/abx500/ab8500.h>
87
-#include <linux/mfd/abx500/ab8500-gpadc.h>
8887
8988 #ifdef CONFIG_DEBUG_FS
9089 #include <linux/string.h>
....@@ -102,11 +101,6 @@
102101
103102 static struct device_attribute **dev_attr;
104103 static char **event_name;
105
-
106
-static u8 avg_sample = SAMPLE_16;
107
-static u8 trig_edge = RISING_EDGE;
108
-static u8 conv_type = ADC_SW;
109
-static u8 trig_timer;
110104
111105 /**
112106 * struct ab8500_reg_range
....@@ -152,7 +146,6 @@
152146 };
153147
154148 #define AB8500_NAME_STRING "ab8500"
155
-#define AB8500_ADC_NAME_STRING "gpadc"
156149 #define AB8500_NUM_BANKS AB8500_DEBUG_FIELD_LAST
157150
158151 #define AB8500_REV_REG 0x80
....@@ -1646,633 +1639,6 @@
16461639
16471640 DEFINE_SHOW_ATTRIBUTE(ab8500_modem);
16481641
1649
-static int ab8500_gpadc_bat_ctrl_show(struct seq_file *s, void *p)
1650
-{
1651
- int bat_ctrl_raw;
1652
- int bat_ctrl_convert;
1653
- struct ab8500_gpadc *gpadc;
1654
-
1655
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1656
- bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL,
1657
- avg_sample, trig_edge, trig_timer, conv_type);
1658
- bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1659
- BAT_CTRL, bat_ctrl_raw);
1660
-
1661
- seq_printf(s, "%d,0x%X\n", bat_ctrl_convert, bat_ctrl_raw);
1662
-
1663
- return 0;
1664
-}
1665
-
1666
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_bat_ctrl);
1667
-
1668
-static int ab8500_gpadc_btemp_ball_show(struct seq_file *s, void *p)
1669
-{
1670
- int btemp_ball_raw;
1671
- int btemp_ball_convert;
1672
- struct ab8500_gpadc *gpadc;
1673
-
1674
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1675
- btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL,
1676
- avg_sample, trig_edge, trig_timer, conv_type);
1677
- btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
1678
- btemp_ball_raw);
1679
-
1680
- seq_printf(s, "%d,0x%X\n", btemp_ball_convert, btemp_ball_raw);
1681
-
1682
- return 0;
1683
-}
1684
-
1685
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_btemp_ball);
1686
-
1687
-static int ab8500_gpadc_main_charger_v_show(struct seq_file *s, void *p)
1688
-{
1689
- int main_charger_v_raw;
1690
- int main_charger_v_convert;
1691
- struct ab8500_gpadc *gpadc;
1692
-
1693
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1694
- main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V,
1695
- avg_sample, trig_edge, trig_timer, conv_type);
1696
- main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1697
- MAIN_CHARGER_V, main_charger_v_raw);
1698
-
1699
- seq_printf(s, "%d,0x%X\n", main_charger_v_convert, main_charger_v_raw);
1700
-
1701
- return 0;
1702
-}
1703
-
1704
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_main_charger_v);
1705
-
1706
-static int ab8500_gpadc_acc_detect1_show(struct seq_file *s, void *p)
1707
-{
1708
- int acc_detect1_raw;
1709
- int acc_detect1_convert;
1710
- struct ab8500_gpadc *gpadc;
1711
-
1712
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1713
- acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1,
1714
- avg_sample, trig_edge, trig_timer, conv_type);
1715
- acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
1716
- acc_detect1_raw);
1717
-
1718
- seq_printf(s, "%d,0x%X\n", acc_detect1_convert, acc_detect1_raw);
1719
-
1720
- return 0;
1721
-}
1722
-
1723
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_acc_detect1);
1724
-
1725
-static int ab8500_gpadc_acc_detect2_show(struct seq_file *s, void *p)
1726
-{
1727
- int acc_detect2_raw;
1728
- int acc_detect2_convert;
1729
- struct ab8500_gpadc *gpadc;
1730
-
1731
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1732
- acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2,
1733
- avg_sample, trig_edge, trig_timer, conv_type);
1734
- acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1735
- ACC_DETECT2, acc_detect2_raw);
1736
-
1737
- seq_printf(s, "%d,0x%X\n", acc_detect2_convert, acc_detect2_raw);
1738
-
1739
- return 0;
1740
-}
1741
-
1742
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_acc_detect2);
1743
-
1744
-static int ab8500_gpadc_aux1_show(struct seq_file *s, void *p)
1745
-{
1746
- int aux1_raw;
1747
- int aux1_convert;
1748
- struct ab8500_gpadc *gpadc;
1749
-
1750
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1751
- aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1,
1752
- avg_sample, trig_edge, trig_timer, conv_type);
1753
- aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
1754
- aux1_raw);
1755
-
1756
- seq_printf(s, "%d,0x%X\n", aux1_convert, aux1_raw);
1757
-
1758
- return 0;
1759
-}
1760
-
1761
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_aux1);
1762
-
1763
-static int ab8500_gpadc_aux2_show(struct seq_file *s, void *p)
1764
-{
1765
- int aux2_raw;
1766
- int aux2_convert;
1767
- struct ab8500_gpadc *gpadc;
1768
-
1769
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1770
- aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2,
1771
- avg_sample, trig_edge, trig_timer, conv_type);
1772
- aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
1773
- aux2_raw);
1774
-
1775
- seq_printf(s, "%d,0x%X\n", aux2_convert, aux2_raw);
1776
-
1777
- return 0;
1778
-}
1779
-
1780
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_aux2);
1781
-
1782
-static int ab8500_gpadc_main_bat_v_show(struct seq_file *s, void *p)
1783
-{
1784
- int main_bat_v_raw;
1785
- int main_bat_v_convert;
1786
- struct ab8500_gpadc *gpadc;
1787
-
1788
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1789
- main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V,
1790
- avg_sample, trig_edge, trig_timer, conv_type);
1791
- main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
1792
- main_bat_v_raw);
1793
-
1794
- seq_printf(s, "%d,0x%X\n", main_bat_v_convert, main_bat_v_raw);
1795
-
1796
- return 0;
1797
-}
1798
-
1799
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_main_bat_v);
1800
-
1801
-static int ab8500_gpadc_vbus_v_show(struct seq_file *s, void *p)
1802
-{
1803
- int vbus_v_raw;
1804
- int vbus_v_convert;
1805
- struct ab8500_gpadc *gpadc;
1806
-
1807
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1808
- vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V,
1809
- avg_sample, trig_edge, trig_timer, conv_type);
1810
- vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
1811
- vbus_v_raw);
1812
-
1813
- seq_printf(s, "%d,0x%X\n", vbus_v_convert, vbus_v_raw);
1814
-
1815
- return 0;
1816
-}
1817
-
1818
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_vbus_v);
1819
-
1820
-static int ab8500_gpadc_main_charger_c_show(struct seq_file *s, void *p)
1821
-{
1822
- int main_charger_c_raw;
1823
- int main_charger_c_convert;
1824
- struct ab8500_gpadc *gpadc;
1825
-
1826
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1827
- main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C,
1828
- avg_sample, trig_edge, trig_timer, conv_type);
1829
- main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1830
- MAIN_CHARGER_C, main_charger_c_raw);
1831
-
1832
- seq_printf(s, "%d,0x%X\n", main_charger_c_convert, main_charger_c_raw);
1833
-
1834
- return 0;
1835
-}
1836
-
1837
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_main_charger_c);
1838
-
1839
-static int ab8500_gpadc_usb_charger_c_show(struct seq_file *s, void *p)
1840
-{
1841
- int usb_charger_c_raw;
1842
- int usb_charger_c_convert;
1843
- struct ab8500_gpadc *gpadc;
1844
-
1845
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1846
- usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C,
1847
- avg_sample, trig_edge, trig_timer, conv_type);
1848
- usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1849
- USB_CHARGER_C, usb_charger_c_raw);
1850
-
1851
- seq_printf(s, "%d,0x%X\n", usb_charger_c_convert, usb_charger_c_raw);
1852
-
1853
- return 0;
1854
-}
1855
-
1856
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_usb_charger_c);
1857
-
1858
-static int ab8500_gpadc_bk_bat_v_show(struct seq_file *s, void *p)
1859
-{
1860
- int bk_bat_v_raw;
1861
- int bk_bat_v_convert;
1862
- struct ab8500_gpadc *gpadc;
1863
-
1864
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1865
- bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V,
1866
- avg_sample, trig_edge, trig_timer, conv_type);
1867
- bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
1868
- BK_BAT_V, bk_bat_v_raw);
1869
-
1870
- seq_printf(s, "%d,0x%X\n", bk_bat_v_convert, bk_bat_v_raw);
1871
-
1872
- return 0;
1873
-}
1874
-
1875
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_bk_bat_v);
1876
-
1877
-static int ab8500_gpadc_die_temp_show(struct seq_file *s, void *p)
1878
-{
1879
- int die_temp_raw;
1880
- int die_temp_convert;
1881
- struct ab8500_gpadc *gpadc;
1882
-
1883
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1884
- die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP,
1885
- avg_sample, trig_edge, trig_timer, conv_type);
1886
- die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
1887
- die_temp_raw);
1888
-
1889
- seq_printf(s, "%d,0x%X\n", die_temp_convert, die_temp_raw);
1890
-
1891
- return 0;
1892
-}
1893
-
1894
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_die_temp);
1895
-
1896
-static int ab8500_gpadc_usb_id_show(struct seq_file *s, void *p)
1897
-{
1898
- int usb_id_raw;
1899
- int usb_id_convert;
1900
- struct ab8500_gpadc *gpadc;
1901
-
1902
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1903
- usb_id_raw = ab8500_gpadc_read_raw(gpadc, USB_ID,
1904
- avg_sample, trig_edge, trig_timer, conv_type);
1905
- usb_id_convert = ab8500_gpadc_ad_to_voltage(gpadc, USB_ID,
1906
- usb_id_raw);
1907
-
1908
- seq_printf(s, "%d,0x%X\n", usb_id_convert, usb_id_raw);
1909
-
1910
- return 0;
1911
-}
1912
-
1913
-DEFINE_SHOW_ATTRIBUTE(ab8500_gpadc_usb_id);
1914
-
1915
-static int ab8540_gpadc_xtal_temp_show(struct seq_file *s, void *p)
1916
-{
1917
- int xtal_temp_raw;
1918
- int xtal_temp_convert;
1919
- struct ab8500_gpadc *gpadc;
1920
-
1921
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1922
- xtal_temp_raw = ab8500_gpadc_read_raw(gpadc, XTAL_TEMP,
1923
- avg_sample, trig_edge, trig_timer, conv_type);
1924
- xtal_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, XTAL_TEMP,
1925
- xtal_temp_raw);
1926
-
1927
- seq_printf(s, "%d,0x%X\n", xtal_temp_convert, xtal_temp_raw);
1928
-
1929
- return 0;
1930
-}
1931
-
1932
-DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_xtal_temp);
1933
-
1934
-static int ab8540_gpadc_vbat_true_meas_show(struct seq_file *s, void *p)
1935
-{
1936
- int vbat_true_meas_raw;
1937
- int vbat_true_meas_convert;
1938
- struct ab8500_gpadc *gpadc;
1939
-
1940
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1941
- vbat_true_meas_raw = ab8500_gpadc_read_raw(gpadc, VBAT_TRUE_MEAS,
1942
- avg_sample, trig_edge, trig_timer, conv_type);
1943
- vbat_true_meas_convert =
1944
- ab8500_gpadc_ad_to_voltage(gpadc, VBAT_TRUE_MEAS,
1945
- vbat_true_meas_raw);
1946
-
1947
- seq_printf(s, "%d,0x%X\n", vbat_true_meas_convert, vbat_true_meas_raw);
1948
-
1949
- return 0;
1950
-}
1951
-
1952
-DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_vbat_true_meas);
1953
-
1954
-static int ab8540_gpadc_bat_ctrl_and_ibat_show(struct seq_file *s, void *p)
1955
-{
1956
- int bat_ctrl_raw;
1957
- int bat_ctrl_convert;
1958
- int ibat_raw;
1959
- int ibat_convert;
1960
- struct ab8500_gpadc *gpadc;
1961
-
1962
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1963
- bat_ctrl_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_CTRL_AND_IBAT,
1964
- avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
1965
-
1966
- bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc, BAT_CTRL,
1967
- bat_ctrl_raw);
1968
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
1969
- ibat_raw);
1970
-
1971
- seq_printf(s,
1972
- "%d,0x%X\n"
1973
- "%d,0x%X\n",
1974
- bat_ctrl_convert, bat_ctrl_raw,
1975
- ibat_convert, ibat_raw);
1976
-
1977
- return 0;
1978
-}
1979
-
1980
-DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_bat_ctrl_and_ibat);
1981
-
1982
-static int ab8540_gpadc_vbat_meas_and_ibat_show(struct seq_file *s, void *p)
1983
-{
1984
- int vbat_meas_raw;
1985
- int vbat_meas_convert;
1986
- int ibat_raw;
1987
- int ibat_convert;
1988
- struct ab8500_gpadc *gpadc;
1989
-
1990
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
1991
- vbat_meas_raw = ab8500_gpadc_double_read_raw(gpadc, VBAT_MEAS_AND_IBAT,
1992
- avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
1993
- vbat_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
1994
- vbat_meas_raw);
1995
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
1996
- ibat_raw);
1997
-
1998
- seq_printf(s,
1999
- "%d,0x%X\n"
2000
- "%d,0x%X\n",
2001
- vbat_meas_convert, vbat_meas_raw,
2002
- ibat_convert, ibat_raw);
2003
-
2004
- return 0;
2005
-}
2006
-
2007
-DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_vbat_meas_and_ibat);
2008
-
2009
-static int ab8540_gpadc_vbat_true_meas_and_ibat_show(struct seq_file *s, void *p)
2010
-{
2011
- int vbat_true_meas_raw;
2012
- int vbat_true_meas_convert;
2013
- int ibat_raw;
2014
- int ibat_convert;
2015
- struct ab8500_gpadc *gpadc;
2016
-
2017
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2018
- vbat_true_meas_raw = ab8500_gpadc_double_read_raw(gpadc,
2019
- VBAT_TRUE_MEAS_AND_IBAT, avg_sample, trig_edge,
2020
- trig_timer, conv_type, &ibat_raw);
2021
- vbat_true_meas_convert = ab8500_gpadc_ad_to_voltage(gpadc,
2022
- VBAT_TRUE_MEAS, vbat_true_meas_raw);
2023
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
2024
- ibat_raw);
2025
-
2026
- seq_printf(s,
2027
- "%d,0x%X\n"
2028
- "%d,0x%X\n",
2029
- vbat_true_meas_convert, vbat_true_meas_raw,
2030
- ibat_convert, ibat_raw);
2031
-
2032
- return 0;
2033
-}
2034
-
2035
-DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_vbat_true_meas_and_ibat);
2036
-
2037
-static int ab8540_gpadc_bat_temp_and_ibat_show(struct seq_file *s, void *p)
2038
-{
2039
- int bat_temp_raw;
2040
- int bat_temp_convert;
2041
- int ibat_raw;
2042
- int ibat_convert;
2043
- struct ab8500_gpadc *gpadc;
2044
-
2045
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2046
- bat_temp_raw = ab8500_gpadc_double_read_raw(gpadc, BAT_TEMP_AND_IBAT,
2047
- avg_sample, trig_edge, trig_timer, conv_type, &ibat_raw);
2048
- bat_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
2049
- bat_temp_raw);
2050
- ibat_convert = ab8500_gpadc_ad_to_voltage(gpadc, IBAT_VIRTUAL_CHANNEL,
2051
- ibat_raw);
2052
-
2053
- seq_printf(s,
2054
- "%d,0x%X\n"
2055
- "%d,0x%X\n",
2056
- bat_temp_convert, bat_temp_raw,
2057
- ibat_convert, ibat_raw);
2058
-
2059
- return 0;
2060
-}
2061
-
2062
-DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_bat_temp_and_ibat);
2063
-
2064
-static int ab8540_gpadc_otp_calib_show(struct seq_file *s, void *p)
2065
-{
2066
- struct ab8500_gpadc *gpadc;
2067
- u16 vmain_l, vmain_h, btemp_l, btemp_h;
2068
- u16 vbat_l, vbat_h, ibat_l, ibat_h;
2069
-
2070
- gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
2071
- ab8540_gpadc_get_otp(gpadc, &vmain_l, &vmain_h, &btemp_l, &btemp_h,
2072
- &vbat_l, &vbat_h, &ibat_l, &ibat_h);
2073
- seq_printf(s,
2074
- "VMAIN_L:0x%X\n"
2075
- "VMAIN_H:0x%X\n"
2076
- "BTEMP_L:0x%X\n"
2077
- "BTEMP_H:0x%X\n"
2078
- "VBAT_L:0x%X\n"
2079
- "VBAT_H:0x%X\n"
2080
- "IBAT_L:0x%X\n"
2081
- "IBAT_H:0x%X\n",
2082
- vmain_l, vmain_h, btemp_l, btemp_h,
2083
- vbat_l, vbat_h, ibat_l, ibat_h);
2084
-
2085
- return 0;
2086
-}
2087
-
2088
-DEFINE_SHOW_ATTRIBUTE(ab8540_gpadc_otp_calib);
2089
-
2090
-static int ab8500_gpadc_avg_sample_print(struct seq_file *s, void *p)
2091
-{
2092
- seq_printf(s, "%d\n", avg_sample);
2093
-
2094
- return 0;
2095
-}
2096
-
2097
-static int ab8500_gpadc_avg_sample_open(struct inode *inode, struct file *file)
2098
-{
2099
- return single_open(file, ab8500_gpadc_avg_sample_print,
2100
- inode->i_private);
2101
-}
2102
-
2103
-static ssize_t ab8500_gpadc_avg_sample_write(struct file *file,
2104
- const char __user *user_buf,
2105
- size_t count, loff_t *ppos)
2106
-{
2107
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
2108
- unsigned long user_avg_sample;
2109
- int err;
2110
-
2111
- err = kstrtoul_from_user(user_buf, count, 0, &user_avg_sample);
2112
- if (err)
2113
- return err;
2114
-
2115
- if ((user_avg_sample == SAMPLE_1) || (user_avg_sample == SAMPLE_4)
2116
- || (user_avg_sample == SAMPLE_8)
2117
- || (user_avg_sample == SAMPLE_16)) {
2118
- avg_sample = (u8) user_avg_sample;
2119
- } else {
2120
- dev_err(dev,
2121
- "debugfs err input: should be egal to 1, 4, 8 or 16\n");
2122
- return -EINVAL;
2123
- }
2124
-
2125
- return count;
2126
-}
2127
-
2128
-static const struct file_operations ab8500_gpadc_avg_sample_fops = {
2129
- .open = ab8500_gpadc_avg_sample_open,
2130
- .read = seq_read,
2131
- .write = ab8500_gpadc_avg_sample_write,
2132
- .llseek = seq_lseek,
2133
- .release = single_release,
2134
- .owner = THIS_MODULE,
2135
-};
2136
-
2137
-static int ab8500_gpadc_trig_edge_print(struct seq_file *s, void *p)
2138
-{
2139
- seq_printf(s, "%d\n", trig_edge);
2140
-
2141
- return 0;
2142
-}
2143
-
2144
-static int ab8500_gpadc_trig_edge_open(struct inode *inode, struct file *file)
2145
-{
2146
- return single_open(file, ab8500_gpadc_trig_edge_print,
2147
- inode->i_private);
2148
-}
2149
-
2150
-static ssize_t ab8500_gpadc_trig_edge_write(struct file *file,
2151
- const char __user *user_buf,
2152
- size_t count, loff_t *ppos)
2153
-{
2154
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
2155
- unsigned long user_trig_edge;
2156
- int err;
2157
-
2158
- err = kstrtoul_from_user(user_buf, count, 0, &user_trig_edge);
2159
- if (err)
2160
- return err;
2161
-
2162
- if ((user_trig_edge == RISING_EDGE)
2163
- || (user_trig_edge == FALLING_EDGE)) {
2164
- trig_edge = (u8) user_trig_edge;
2165
- } else {
2166
- dev_err(dev, "Wrong input:\n"
2167
- "Enter 0. Rising edge\n"
2168
- "Enter 1. Falling edge\n");
2169
- return -EINVAL;
2170
- }
2171
-
2172
- return count;
2173
-}
2174
-
2175
-static const struct file_operations ab8500_gpadc_trig_edge_fops = {
2176
- .open = ab8500_gpadc_trig_edge_open,
2177
- .read = seq_read,
2178
- .write = ab8500_gpadc_trig_edge_write,
2179
- .llseek = seq_lseek,
2180
- .release = single_release,
2181
- .owner = THIS_MODULE,
2182
-};
2183
-
2184
-static int ab8500_gpadc_trig_timer_print(struct seq_file *s, void *p)
2185
-{
2186
- seq_printf(s, "%d\n", trig_timer);
2187
-
2188
- return 0;
2189
-}
2190
-
2191
-static int ab8500_gpadc_trig_timer_open(struct inode *inode, struct file *file)
2192
-{
2193
- return single_open(file, ab8500_gpadc_trig_timer_print,
2194
- inode->i_private);
2195
-}
2196
-
2197
-static ssize_t ab8500_gpadc_trig_timer_write(struct file *file,
2198
- const char __user *user_buf,
2199
- size_t count, loff_t *ppos)
2200
-{
2201
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
2202
- unsigned long user_trig_timer;
2203
- int err;
2204
-
2205
- err = kstrtoul_from_user(user_buf, count, 0, &user_trig_timer);
2206
- if (err)
2207
- return err;
2208
-
2209
- if (user_trig_timer & ~0xFF) {
2210
- dev_err(dev,
2211
- "debugfs error input: should be between 0 to 255\n");
2212
- return -EINVAL;
2213
- }
2214
-
2215
- trig_timer = (u8) user_trig_timer;
2216
-
2217
- return count;
2218
-}
2219
-
2220
-static const struct file_operations ab8500_gpadc_trig_timer_fops = {
2221
- .open = ab8500_gpadc_trig_timer_open,
2222
- .read = seq_read,
2223
- .write = ab8500_gpadc_trig_timer_write,
2224
- .llseek = seq_lseek,
2225
- .release = single_release,
2226
- .owner = THIS_MODULE,
2227
-};
2228
-
2229
-static int ab8500_gpadc_conv_type_print(struct seq_file *s, void *p)
2230
-{
2231
- seq_printf(s, "%d\n", conv_type);
2232
-
2233
- return 0;
2234
-}
2235
-
2236
-static int ab8500_gpadc_conv_type_open(struct inode *inode, struct file *file)
2237
-{
2238
- return single_open(file, ab8500_gpadc_conv_type_print,
2239
- inode->i_private);
2240
-}
2241
-
2242
-static ssize_t ab8500_gpadc_conv_type_write(struct file *file,
2243
- const char __user *user_buf,
2244
- size_t count, loff_t *ppos)
2245
-{
2246
- struct device *dev = ((struct seq_file *)(file->private_data))->private;
2247
- unsigned long user_conv_type;
2248
- int err;
2249
-
2250
- err = kstrtoul_from_user(user_buf, count, 0, &user_conv_type);
2251
- if (err)
2252
- return err;
2253
-
2254
- if ((user_conv_type == ADC_SW)
2255
- || (user_conv_type == ADC_HW)) {
2256
- conv_type = (u8) user_conv_type;
2257
- } else {
2258
- dev_err(dev, "Wrong input:\n"
2259
- "Enter 0. ADC SW conversion\n"
2260
- "Enter 1. ADC HW conversion\n");
2261
- return -EINVAL;
2262
- }
2263
-
2264
- return count;
2265
-}
2266
-
2267
-static const struct file_operations ab8500_gpadc_conv_type_fops = {
2268
- .open = ab8500_gpadc_conv_type_open,
2269
- .read = seq_read,
2270
- .write = ab8500_gpadc_conv_type_write,
2271
- .llseek = seq_lseek,
2272
- .release = single_release,
2273
- .owner = THIS_MODULE,
2274
-};
2275
-
22761642 /*
22771643 * return length of an ASCII numerical value, 0 is string is not a
22781644 * numerical value.
....@@ -2435,7 +1801,7 @@
24351801 int buf_size, ret;
24361802
24371803 /* Get userspace string and assure termination */
2438
- buf_size = min(count, (sizeof(buf)-1));
1804
+ buf_size = min((int)count, (int)(sizeof(buf)-1));
24391805 if (copy_from_user(buf, user_buf, buf_size))
24401806 return -EFAULT;
24411807 buf[buf_size] = 0;
....@@ -2587,7 +1953,7 @@
25871953 }
25881954
25891955 /*
2590
- * - several deubgfs nodes fops
1956
+ * - several debugfs nodes fops
25911957 */
25921958
25931959 static const struct file_operations ab8500_bank_fops = {
....@@ -2644,12 +2010,9 @@
26442010 .owner = THIS_MODULE,
26452011 };
26462012
2647
-static struct dentry *ab8500_dir;
2648
-static struct dentry *ab8500_gpadc_dir;
2649
-
26502013 static int ab8500_debug_probe(struct platform_device *plf)
26512014 {
2652
- struct dentry *file;
2015
+ struct dentry *ab8500_dir;
26532016 struct ab8500 *ab8500;
26542017 struct resource *res;
26552018
....@@ -2682,59 +2045,27 @@
26822045 irq_ab8500 = res->start;
26832046
26842047 irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
2685
- if (irq_first < 0) {
2686
- dev_err(&plf->dev, "First irq not found, err %d\n", irq_first);
2048
+ if (irq_first < 0)
26872049 return irq_first;
2688
- }
26892050
26902051 irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
2691
- if (irq_last < 0) {
2692
- dev_err(&plf->dev, "Last irq not found, err %d\n", irq_last);
2052
+ if (irq_last < 0)
26932053 return irq_last;
2694
- }
26952054
26962055 ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
2697
- if (!ab8500_dir)
2698
- goto err;
26992056
2700
- ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING,
2701
- ab8500_dir);
2702
- if (!ab8500_gpadc_dir)
2703
- goto err;
2704
-
2705
- file = debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir,
2706
- &plf->dev, &ab8500_bank_registers_fops);
2707
- if (!file)
2708
- goto err;
2709
-
2710
- file = debugfs_create_file("all-banks", S_IRUGO, ab8500_dir,
2711
- &plf->dev, &ab8500_all_banks_fops);
2712
- if (!file)
2713
- goto err;
2714
-
2715
- file = debugfs_create_file("register-bank",
2716
- (S_IRUGO | S_IWUSR | S_IWGRP),
2717
- ab8500_dir, &plf->dev, &ab8500_bank_fops);
2718
- if (!file)
2719
- goto err;
2720
-
2721
- file = debugfs_create_file("register-address",
2722
- (S_IRUGO | S_IWUSR | S_IWGRP),
2723
- ab8500_dir, &plf->dev, &ab8500_address_fops);
2724
- if (!file)
2725
- goto err;
2726
-
2727
- file = debugfs_create_file("register-value",
2728
- (S_IRUGO | S_IWUSR | S_IWGRP),
2729
- ab8500_dir, &plf->dev, &ab8500_val_fops);
2730
- if (!file)
2731
- goto err;
2732
-
2733
- file = debugfs_create_file("irq-subscribe",
2734
- (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir,
2735
- &plf->dev, &ab8500_subscribe_fops);
2736
- if (!file)
2737
- goto err;
2057
+ debugfs_create_file("all-bank-registers", S_IRUGO, ab8500_dir,
2058
+ &plf->dev, &ab8500_bank_registers_fops);
2059
+ debugfs_create_file("all-banks", S_IRUGO, ab8500_dir,
2060
+ &plf->dev, &ab8500_all_banks_fops);
2061
+ debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR | S_IWGRP),
2062
+ ab8500_dir, &plf->dev, &ab8500_bank_fops);
2063
+ debugfs_create_file("register-address", (S_IRUGO | S_IWUSR | S_IWGRP),
2064
+ ab8500_dir, &plf->dev, &ab8500_address_fops);
2065
+ debugfs_create_file("register-value", (S_IRUGO | S_IWUSR | S_IWGRP),
2066
+ ab8500_dir, &plf->dev, &ab8500_val_fops);
2067
+ debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR | S_IWGRP),
2068
+ ab8500_dir, &plf->dev, &ab8500_subscribe_fops);
27382069
27392070 if (is_ab8500(ab8500)) {
27402071 debug_ranges = ab8500_debug_ranges;
....@@ -2750,194 +2081,16 @@
27502081 num_interrupt_lines = AB8540_NR_IRQS;
27512082 }
27522083
2753
- file = debugfs_create_file("interrupts", (S_IRUGO), ab8500_dir,
2754
- &plf->dev, &ab8500_interrupts_fops);
2755
- if (!file)
2756
- goto err;
2757
-
2758
- file = debugfs_create_file("irq-unsubscribe",
2759
- (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir,
2760
- &plf->dev, &ab8500_unsubscribe_fops);
2761
- if (!file)
2762
- goto err;
2763
-
2764
- file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP),
2765
- ab8500_dir, &plf->dev, &ab8500_hwreg_fops);
2766
- if (!file)
2767
- goto err;
2768
-
2769
- file = debugfs_create_file("all-modem-registers",
2770
- (S_IRUGO | S_IWUSR | S_IWGRP),
2771
- ab8500_dir, &plf->dev, &ab8500_modem_fops);
2772
- if (!file)
2773
- goto err;
2774
-
2775
- file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR | S_IWGRP),
2776
- ab8500_gpadc_dir, &plf->dev,
2777
- &ab8500_gpadc_bat_ctrl_fops);
2778
- if (!file)
2779
- goto err;
2780
-
2781
- file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR | S_IWGRP),
2782
- ab8500_gpadc_dir,
2783
- &plf->dev, &ab8500_gpadc_btemp_ball_fops);
2784
- if (!file)
2785
- goto err;
2786
-
2787
- file = debugfs_create_file("main_charger_v",
2788
- (S_IRUGO | S_IWUSR | S_IWGRP),
2789
- ab8500_gpadc_dir, &plf->dev,
2790
- &ab8500_gpadc_main_charger_v_fops);
2791
- if (!file)
2792
- goto err;
2793
-
2794
- file = debugfs_create_file("acc_detect1",
2795
- (S_IRUGO | S_IWUSR | S_IWGRP),
2796
- ab8500_gpadc_dir, &plf->dev,
2797
- &ab8500_gpadc_acc_detect1_fops);
2798
- if (!file)
2799
- goto err;
2800
-
2801
- file = debugfs_create_file("acc_detect2",
2802
- (S_IRUGO | S_IWUSR | S_IWGRP),
2803
- ab8500_gpadc_dir, &plf->dev,
2804
- &ab8500_gpadc_acc_detect2_fops);
2805
- if (!file)
2806
- goto err;
2807
-
2808
- file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR | S_IWGRP),
2809
- ab8500_gpadc_dir, &plf->dev,
2810
- &ab8500_gpadc_aux1_fops);
2811
- if (!file)
2812
- goto err;
2813
-
2814
- file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR | S_IWGRP),
2815
- ab8500_gpadc_dir, &plf->dev,
2816
- &ab8500_gpadc_aux2_fops);
2817
- if (!file)
2818
- goto err;
2819
-
2820
- file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
2821
- ab8500_gpadc_dir, &plf->dev,
2822
- &ab8500_gpadc_main_bat_v_fops);
2823
- if (!file)
2824
- goto err;
2825
-
2826
- file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR | S_IWGRP),
2827
- ab8500_gpadc_dir, &plf->dev,
2828
- &ab8500_gpadc_vbus_v_fops);
2829
- if (!file)
2830
- goto err;
2831
-
2832
- file = debugfs_create_file("main_charger_c",
2833
- (S_IRUGO | S_IWUSR | S_IWGRP),
2834
- ab8500_gpadc_dir, &plf->dev,
2835
- &ab8500_gpadc_main_charger_c_fops);
2836
- if (!file)
2837
- goto err;
2838
-
2839
- file = debugfs_create_file("usb_charger_c",
2840
- (S_IRUGO | S_IWUSR | S_IWGRP),
2841
- ab8500_gpadc_dir,
2842
- &plf->dev, &ab8500_gpadc_usb_charger_c_fops);
2843
- if (!file)
2844
- goto err;
2845
-
2846
- file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR | S_IWGRP),
2847
- ab8500_gpadc_dir, &plf->dev,
2848
- &ab8500_gpadc_bk_bat_v_fops);
2849
- if (!file)
2850
- goto err;
2851
-
2852
- file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR | S_IWGRP),
2853
- ab8500_gpadc_dir, &plf->dev,
2854
- &ab8500_gpadc_die_temp_fops);
2855
- if (!file)
2856
- goto err;
2857
-
2858
- file = debugfs_create_file("usb_id", (S_IRUGO | S_IWUSR | S_IWGRP),
2859
- ab8500_gpadc_dir, &plf->dev,
2860
- &ab8500_gpadc_usb_id_fops);
2861
- if (!file)
2862
- goto err;
2863
-
2864
- if (is_ab8540(ab8500)) {
2865
- file = debugfs_create_file("xtal_temp",
2866
- (S_IRUGO | S_IWUSR | S_IWGRP),
2867
- ab8500_gpadc_dir, &plf->dev,
2868
- &ab8540_gpadc_xtal_temp_fops);
2869
- if (!file)
2870
- goto err;
2871
- file = debugfs_create_file("vbattruemeas",
2872
- (S_IRUGO | S_IWUSR | S_IWGRP),
2873
- ab8500_gpadc_dir, &plf->dev,
2874
- &ab8540_gpadc_vbat_true_meas_fops);
2875
- if (!file)
2876
- goto err;
2877
- file = debugfs_create_file("batctrl_and_ibat",
2878
- (S_IRUGO | S_IWUGO),
2879
- ab8500_gpadc_dir,
2880
- &plf->dev,
2881
- &ab8540_gpadc_bat_ctrl_and_ibat_fops);
2882
- if (!file)
2883
- goto err;
2884
- file = debugfs_create_file("vbatmeas_and_ibat",
2885
- (S_IRUGO | S_IWUGO),
2886
- ab8500_gpadc_dir, &plf->dev,
2887
- &ab8540_gpadc_vbat_meas_and_ibat_fops);
2888
- if (!file)
2889
- goto err;
2890
- file = debugfs_create_file("vbattruemeas_and_ibat",
2891
- (S_IRUGO | S_IWUGO),
2892
- ab8500_gpadc_dir,
2893
- &plf->dev,
2894
- &ab8540_gpadc_vbat_true_meas_and_ibat_fops);
2895
- if (!file)
2896
- goto err;
2897
- file = debugfs_create_file("battemp_and_ibat",
2898
- (S_IRUGO | S_IWUGO),
2899
- ab8500_gpadc_dir,
2900
- &plf->dev, &ab8540_gpadc_bat_temp_and_ibat_fops);
2901
- if (!file)
2902
- goto err;
2903
- file = debugfs_create_file("otp_calib",
2904
- (S_IRUGO | S_IWUSR | S_IWGRP),
2905
- ab8500_gpadc_dir,
2906
- &plf->dev, &ab8540_gpadc_otp_calib_fops);
2907
- if (!file)
2908
- goto err;
2909
- }
2910
- file = debugfs_create_file("avg_sample", (S_IRUGO | S_IWUSR | S_IWGRP),
2911
- ab8500_gpadc_dir, &plf->dev,
2912
- &ab8500_gpadc_avg_sample_fops);
2913
- if (!file)
2914
- goto err;
2915
-
2916
- file = debugfs_create_file("trig_edge", (S_IRUGO | S_IWUSR | S_IWGRP),
2917
- ab8500_gpadc_dir, &plf->dev,
2918
- &ab8500_gpadc_trig_edge_fops);
2919
- if (!file)
2920
- goto err;
2921
-
2922
- file = debugfs_create_file("trig_timer", (S_IRUGO | S_IWUSR | S_IWGRP),
2923
- ab8500_gpadc_dir, &plf->dev,
2924
- &ab8500_gpadc_trig_timer_fops);
2925
- if (!file)
2926
- goto err;
2927
-
2928
- file = debugfs_create_file("conv_type", (S_IRUGO | S_IWUSR | S_IWGRP),
2929
- ab8500_gpadc_dir, &plf->dev,
2930
- &ab8500_gpadc_conv_type_fops);
2931
- if (!file)
2932
- goto err;
2084
+ debugfs_create_file("interrupts", (S_IRUGO), ab8500_dir, &plf->dev,
2085
+ &ab8500_interrupts_fops);
2086
+ debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR | S_IWGRP),
2087
+ ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops);
2088
+ debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR | S_IWGRP), ab8500_dir,
2089
+ &plf->dev, &ab8500_hwreg_fops);
2090
+ debugfs_create_file("all-modem-registers", (S_IRUGO | S_IWUSR | S_IWGRP),
2091
+ ab8500_dir, &plf->dev, &ab8500_modem_fops);
29332092
29342093 return 0;
2935
-
2936
-err:
2937
- debugfs_remove_recursive(ab8500_dir);
2938
- dev_err(&plf->dev, "failed to create debugfs entries.\n");
2939
-
2940
- return -ENOMEM;
29412094 }
29422095
29432096 static struct platform_driver ab8500_debug_driver = {