Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mfd-for-linus-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
"Changes to existing drivers:
- Use of managed resources - omap, twl4030, ti_am335x_tscadc
- Advanced error handling - omap
- Rework clk management - omap
- Device Tree (re-)work - tc3589x, pm8921, da9055, sec
- IRC management overhaul and !BROKEN - pm8921
- Convert to regmap - ssbi, pm8921
- Use simple power-management ops - ucb1x00
- Include file clean-up - adp5520, cs5535, janz, lpc_ich,
- lpc_sch, max14577, mcp-sa11x0, pcf50633-adc, rc5t583,
rdc321x-southbridge, retu, smsc-ece1099, ti-ssp, ti_am335x_tscadc,
tps65912, vexpress-config, wm8350, ywm8350
- Various bug fixes across the subsystem
- NULL/invalid pointer dereference prevention
- Resource leak mitigation,
- Variable used initialised
- Staticise various containers
- Enforce return value checks

New drivers/supported devices:
- Add support for s2mps14 and s2mpa01 to sec
- Add support for da9063 (v5) to da9063
- Add support for atom-c2000 to gpio-ich
- Add support for come-{mbt10,cbt6,chl6} to kempld
- Add support for da9053 to da9052
- Add support for itco-wdt (v3) and baytrail to lpc_ich
- Add new drivers for tps65218, rtsx_usb, bcm590xx

(Re-)moved drivers:
- twl4030 ==> drivers/iio
- ti-ssp ==> /dev/null"

* tag 'mfd-for-linus-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (103 commits)
mfd: wm5110: Correct default for HEADPHONE_DETECT_1
mfd: arizona: Correct small errors in the DT binding documentation
mfd: arizona: Mark DSP clocking register as volatile
mfd: devicetree: bindings: Add pm8xxx RTC description
mfd: kempld-core: Fix potential hang-up during boot
mfd: sec-core: Fix uninitialized 'regmap_rtc' on S2MPA01
mfd: tps65910: Fix regmap_irq_chip_data leak on mfd_add_devices fail
mfd: tps65910: Fix possible invalid pointer dereference on regmap_add_irq_chip fail
mfd: sec-core: Fix I2C dummy device resource leak on probe failure
mfd: sec-core: Add of_compatible strings for clock MFD cells
mfd: Remove obsolete ti-ssp driver
Documentation: mfd: s2mps11: Describe S5M8767 and S2MPS14 clocks
mfd: bcm590xx: Fix type argument for module device table
mfd: lpc_ich: Add support for Intel Bay Trail SoC
mfd: lpc_ich: Add support for NM10 GPIO
mfd: lpc_ich: Change Avoton to iTCO v3
watchdog: iTCO_wdt: Add support for v3 silicon
mfd: lpc_ich: Add support for iTCO v3
mfd: lpc_ich: Remove lpc_ich_cfg struct use
mfd: lpc_ich: Only configure watchdog or GPIO when present
...

+3960 -1590
+24
Documentation/devicetree/bindings/iio/adc/twl4030-madc.txt
··· 1 + * TWL4030 Monitoring Analog to Digital Converter (MADC) 2 + 3 + The MADC subsystem in the TWL4030 consists of a 10-bit ADC 4 + combined with a 16-input analog multiplexer. 5 + 6 + Required properties: 7 + - compatible: Should contain "ti,twl4030-madc". 8 + - interrupts: IRQ line for the MADC submodule. 9 + - #io-channel-cells: Should be set to <1>. 10 + 11 + Optional properties: 12 + - ti,system-uses-second-madc-irq: boolean, set if the second madc irq register 13 + should be used, which is intended to be used 14 + by Co-Processors (e.g. a modem). 15 + 16 + Example: 17 + 18 + &twl { 19 + madc { 20 + compatible = "ti,twl4030-madc"; 21 + interrupts = <3>; 22 + #io-channel-cells = <1>; 23 + }; 24 + };
+13 -10
Documentation/devicetree/bindings/mfd/arizona.txt
··· 5 5 6 6 Required properties: 7 7 8 - - compatible : one of the following chip-specific strings: 9 - "wlf,wm5102" 10 - "wlf,wm5110" 8 + - compatible : One of the following chip-specific strings: 9 + "wlf,wm5102" 10 + "wlf,wm5110" 11 + "wlf,wm8997" 11 12 - reg : I2C slave address when connected using I2C, chip select number when 12 13 using SPI. 13 14 ··· 26 25 - #gpio-cells : Must be 2. The first cell is the pin number and the 27 26 second cell is used to specify optional parameters (currently unused). 28 27 29 - - AVDD1-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply, 30 - SPKVDDL-supply, SPKVDDR-supply : power supplies for the device, as covered 28 + - AVDD-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply (wm5102, wm5110), 29 + CPVDD-supply, SPKVDDL-supply (wm5102, wm5110), SPKVDDR-supply (wm5102, 30 + wm5110), SPKVDD-supply (wm8997) : Power supplies for the device, as covered 31 31 in Documentation/devicetree/bindings/regulator/regulator.txt 32 32 33 33 Optional properties: ··· 48 46 compatible = "wlf,wm5102"; 49 47 reg = <0x1a>; 50 48 interrupts = <347>; 49 + interrupt-controller; 51 50 #interrupt-cells = <2>; 52 51 interrupt-parent = <&gic>; 53 52 ··· 56 53 #gpio-cells = <2>; 57 54 58 55 wlf,gpio-defaults = < 59 - 0x00000000, /* AIF1TXLRCLK */ 60 - 0xffffffff, 61 - 0xffffffff, 62 - 0xffffffff, 63 - 0xffffffff, 56 + 0x00000000 /* AIF1TXLRCLK */ 57 + 0xffffffff 58 + 0xffffffff 59 + 0xffffffff 60 + 0xffffffff 64 61 >; 65 62 };
+37
Documentation/devicetree/bindings/mfd/bcm590xx.txt
··· 1 + ------------------------------- 2 + BCM590xx Power Management Units 3 + ------------------------------- 4 + 5 + Required properties: 6 + - compatible: "brcm,bcm59056" 7 + - reg: I2C slave address 8 + - interrupts: interrupt for the PMU. Generic interrupt client node bindings 9 + are described in interrupt-controller/interrupts.txt 10 + 11 + ------------------ 12 + Voltage Regulators 13 + ------------------ 14 + 15 + Optional child nodes: 16 + - regulators: container node for regulators following the generic 17 + regulator binding in regulator/regulator.txt 18 + 19 + The valid regulator node names for BCM59056 are: 20 + rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo, 21 + mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo, 22 + csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr 23 + 24 + Example: 25 + pmu: bcm59056@8 { 26 + compatible = "brcm,bcm59056"; 27 + reg = <0x08>; 28 + interrupts = <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>; 29 + regulators { 30 + rfldo_reg: rfldo { 31 + regulator-min-microvolt = <1200000>; 32 + regulator-max-microvolt = <3300000>; 33 + }; 34 + 35 + ... 36 + }; 37 + };
+72
Documentation/devicetree/bindings/mfd/da9055.txt
··· 1 + * Dialog DA9055 Power Management Integrated Circuit (PMIC) 2 + 3 + DA9055 consists of a large and varied group of sub-devices (I2C Only): 4 + 5 + Device Supply Names Description 6 + ------ ------------ ----------- 7 + da9055-gpio : : GPIOs 8 + da9055-regulator : : Regulators 9 + da9055-onkey : : On key 10 + da9055-rtc : : RTC 11 + da9055-hwmon : : ADC 12 + da9055-watchdog : : Watchdog 13 + 14 + The CODEC device in DA9055 has a separate, configurable I2C address and so 15 + is instantiated separately from the PMIC. 16 + 17 + For details on accompanying CODEC I2C device, see the following: 18 + Documentation/devicetree/bindings/sound/da9055.txt 19 + 20 + ====== 21 + 22 + Required properties: 23 + - compatible : Should be "dlg,da9055-pmic" 24 + - reg: Specifies the I2C slave address (defaults to 0x5a but can be modified) 25 + - interrupt-parent: Specifies the phandle of the interrupt controller to which 26 + the IRQs from da9055 are delivered to. 27 + - interrupts: IRQ line info for da9055 chip. 28 + - interrupt-controller: da9055 has internal IRQs (has own IRQ domain). 29 + - #interrupt-cells: Should be 1, is the local IRQ number for da9055. 30 + 31 + Sub-nodes: 32 + - regulators : Contain the regulator nodes. The DA9055 regulators are 33 + bound using their names as listed below: 34 + 35 + buck1 : regulator BUCK1 36 + buck2 : regulator BUCK2 37 + ldo1 : regulator LDO1 38 + ldo2 : regulator LDO2 39 + ldo3 : regulator LDO3 40 + ldo4 : regulator LDO4 41 + ldo5 : regulator LDO5 42 + ldo6 : regulator LDO6 43 + 44 + The bindings details of individual regulator device can be found in: 45 + Documentation/devicetree/bindings/regulator/regulator.txt 46 + 47 + 48 + Example: 49 + 50 + pmic: da9055-pmic@5a { 51 + compatible = "dlg,da9055-pmic"; 52 + reg = <0x5a>; 53 + interrupt-parent = <&intc>; 54 + interrupts = <5 IRQ_TYPE_LEVEL_LOW>; 55 + interrupt-controller; 56 + #interrupt-cells = <1>; 57 + 58 + regulators { 59 + buck1: BUCK1 { 60 + regulator-min-microvolt = <725000>; 61 + regulator-max-microvolt = <2075000>; 62 + }; 63 + buck2: BUCK2 { 64 + regulator-min-microvolt = <925000>; 65 + regulator-max-microvolt = <2500000>; 66 + }; 67 + ldo1: LDO1 { 68 + regulator-min-microvolt = <900000>; 69 + regulator-max-microvolt = <3300000>; 70 + }; 71 + }; 72 + };
+23
Documentation/devicetree/bindings/mfd/omap-usb-host.txt
··· 32 32 - single-ulpi-bypass: Must be present if the controller contains a single 33 33 ULPI bypass control bit. e.g. OMAP3 silicon <= ES2.1 34 34 35 + - clocks: a list of phandles and clock-specifier pairs, one for each entry in 36 + clock-names. 37 + 38 + - clock-names: should include: 39 + For OMAP3 40 + * "usbhost_120m_fck" - 120MHz Functional clock. 41 + 42 + For OMAP4+ 43 + * "refclk_60m_int" - 60MHz internal reference clock for UTMI clock mux 44 + * "refclk_60m_ext_p1" - 60MHz external ref. clock for Port 1's UTMI clock mux. 45 + * "refclk_60m_ext_p2" - 60MHz external ref. clock for Port 2's UTMI clock mux 46 + * "utmi_p1_gfclk" - Port 1 UTMI clock mux. 47 + * "utmi_p2_gfclk" - Port 2 UTMI clock mux. 48 + * "usb_host_hs_utmi_p1_clk" - Port 1 UTMI clock gate. 49 + * "usb_host_hs_utmi_p2_clk" - Port 2 UTMI clock gate. 50 + * "usb_host_hs_utmi_p3_clk" - Port 3 UTMI clock gate. 51 + * "usb_host_hs_hsic480m_p1_clk" - Port 1 480MHz HSIC clock gate. 52 + * "usb_host_hs_hsic480m_p2_clk" - Port 2 480MHz HSIC clock gate. 53 + * "usb_host_hs_hsic480m_p3_clk" - Port 3 480MHz HSIC clock gate. 54 + * "usb_host_hs_hsic60m_p1_clk" - Port 1 60MHz HSIC clock gate. 55 + * "usb_host_hs_hsic60m_p2_clk" - Port 2 60MHz HSIC clock gate. 56 + * "usb_host_hs_hsic60m_p3_clk" - Port 3 60MHz HSIC clock gate. 57 + 35 58 Required properties if child node exists: 36 59 37 60 - #address-cells: Must be 1
+10
Documentation/devicetree/bindings/mfd/omap-usb-tll.txt
··· 7 7 - interrupts : should contain the TLL module's interrupt 8 8 - ti,hwmod : must contain "usb_tll_hs" 9 9 10 + Optional properties: 11 + 12 + - clocks: a list of phandles and clock-specifier pairs, one for each entry in 13 + clock-names. 14 + 15 + - clock-names: should include: 16 + * "usb_tll_hs_usb_ch0_clk" - USB TLL channel 0 clock 17 + * "usb_tll_hs_usb_ch1_clk" - USB TLL channel 1 clock 18 + * "usb_tll_hs_usb_ch2_clk" - USB TLL channel 2 clock 19 + 10 20 Example: 11 21 12 22 usbhstll: usbhstll@4a062000 {
+96
Documentation/devicetree/bindings/mfd/qcom,pm8xxx.txt
··· 1 + Qualcomm PM8xxx PMIC multi-function devices 2 + 3 + The PM8xxx family of Power Management ICs are used to provide regulated 4 + voltages and other various functionality to Qualcomm SoCs. 5 + 6 + = PROPERTIES 7 + 8 + - compatible: 9 + Usage: required 10 + Value type: <string> 11 + Definition: must be one of: 12 + "qcom,pm8058" 13 + "qcom,pm8921" 14 + 15 + - #address-cells: 16 + Usage: required 17 + Value type: <u32> 18 + Definition: must be 1 19 + 20 + - #size-cells: 21 + Usage: required 22 + Value type: <u32> 23 + Definition: must be 0 24 + 25 + - interrupts: 26 + Usage: required 27 + Value type: <prop-encoded-array> 28 + Definition: specifies the interrupt that indicates a subdevice 29 + has generated an interrupt (summary interrupt). The 30 + format of the specifier is defined by the binding document 31 + describing the node's interrupt parent. 32 + 33 + - #interrupt-cells: 34 + Usage: required 35 + Value type : <u32> 36 + Definition: must be 2. Specifies the number of cells needed to encode 37 + an interrupt source. The 1st cell contains the interrupt 38 + number. The 2nd cell is the trigger type and level flags 39 + encoded as follows: 40 + 41 + 1 = low-to-high edge triggered 42 + 2 = high-to-low edge triggered 43 + 4 = active high level-sensitive 44 + 8 = active low level-sensitive 45 + 46 + - interrupt-controller: 47 + Usage: required 48 + Value type: <empty> 49 + Definition: identifies this node as an interrupt controller 50 + 51 + = SUBCOMPONENTS 52 + 53 + The PMIC contains multiple independent functions, each described in a subnode. 54 + The below bindings specify the set of valid subnodes. 55 + 56 + == Real-Time Clock 57 + 58 + - compatible: 59 + Usage: required 60 + Value type: <string> 61 + Definition: must be one of: 62 + "qcom,pm8058-rtc" 63 + "qcom,pm8921-rtc" 64 + 65 + - reg: 66 + Usage: required 67 + Value type: <prop-encoded-array> 68 + Definition: single entry specifying the base address of the RTC registers 69 + 70 + - interrupts: 71 + Usage: required 72 + Value type: <prop-encoded-array> 73 + Definition: single entry specifying the RTC's alarm interrupt 74 + 75 + - allow-set-time: 76 + Usage: optional 77 + Value type: <empty> 78 + Definition: indicates that the setting of RTC time is allowed by 79 + the host CPU 80 + 81 + = EXAMPLE 82 + 83 + pmicintc: pmic@0 { 84 + compatible = "qcom,pm8921"; 85 + interrupts = <104 8>; 86 + #interrupt-cells = <2>; 87 + interrupt-controller; 88 + #address-cells = <1>; 89 + #size-cells = <0>; 90 + 91 + rtc@11d { 92 + compatible = "qcom,pm8921-rtc"; 93 + reg = <0x11d>; 94 + interrupts = <0x27 0>; 95 + }; 96 + };
+15 -9
Documentation/devicetree/bindings/mfd/s2mps11.txt
··· 16 16 - interrupts: Interrupt specifiers for interrupt sources. 17 17 18 18 Optional nodes: 19 - - clocks: s2mps11 provides three(AP/CP/BT) buffered 32.768 KHz outputs, so to 20 - register these as clocks with common clock framework instantiate a sub-node 21 - named "clocks". It uses the common clock binding documented in : 19 + - clocks: s2mps11 and s5m8767 provide three(AP/CP/BT) buffered 32.768 KHz 20 + outputs, so to register these as clocks with common clock framework 21 + instantiate a sub-node named "clocks". It uses the common clock binding 22 + documented in : 22 23 [Documentation/devicetree/bindings/clock/clock-bindings.txt] 24 + The s2mps14 provides two (AP/BT) buffered 32.768 KHz outputs. 23 25 - #clock-cells: should be 1. 24 26 25 27 - The following is the list of clocks generated by the controller. Each clock 26 28 is assigned an identifier and client nodes use this identifier to specify 27 29 the clock which they consume. 28 - Clock ID 29 - ---------------------- 30 - 32KhzAP 0 31 - 32KhzCP 1 32 - 32KhzBT 2 30 + Clock ID Devices 31 + ---------------------------------------------------------- 32 + 32KhzAP 0 S2MPS11, S2MPS14, S5M8767 33 + 32KhzCP 1 S2MPS11, S5M8767 34 + 32KhzBT 2 S2MPS11, S2MPS14, S5M8767 35 + 36 + - compatible: Should be one of: "samsung,s2mps11-clk", "samsung,s2mps14-clk", 37 + "samsung,s5m8767-clk" 33 38 34 39 - regulators: The regulators of s2mps11 that have to be instantiated should be 35 40 included in a sub-node named 'regulators'. Regulator nodes included in this ··· 80 75 compatible = "samsung,s2mps11-pmic"; 81 76 reg = <0x66>; 82 77 83 - s2m_osc: clocks{ 78 + s2m_osc: clocks { 79 + compatible = "samsung,s2mps11-clk"; 84 80 #clock-cells = 1; 85 81 clock-output-names = "xx", "yy", "zz"; 86 82 };
+6
arch/arm/boot/dts/omap4.dtsi
··· 733 733 #address-cells = <1>; 734 734 #size-cells = <1>; 735 735 ranges; 736 + clocks = <&init_60m_fclk>, 737 + <&xclk60mhsp1_ck>, 738 + <&xclk60mhsp2_ck>; 739 + clock-names = "refclk_60m_int", 740 + "refclk_60m_ext_p1", 741 + "refclk_60m_ext_p2"; 736 742 737 743 usbhsohci: ohci@4a064800 { 738 744 compatible = "ti,ohci-omap3";
+6
arch/arm/boot/dts/omap5.dtsi
··· 814 814 #address-cells = <1>; 815 815 #size-cells = <1>; 816 816 ranges; 817 + clocks = <&l3init_60m_fclk>, 818 + <&xclk60mhsp1_ck>, 819 + <&xclk60mhsp2_ck>; 820 + clock-names = "refclk_60m_int", 821 + "refclk_60m_ext_p1", 822 + "refclk_60m_ext_p2"; 817 823 818 824 usbhsohci: ohci@4a064800 { 819 825 compatible = "ti,ohci-omap3";
-4
arch/arm/mach-omap2/cclock3xxx_data.c
··· 3497 3497 CLK(NULL, "dss_tv_fck", &dss_tv_fck), 3498 3498 CLK(NULL, "dss_96m_fck", &dss_96m_fck), 3499 3499 CLK(NULL, "dss2_alwon_fck", &dss2_alwon_fck), 3500 - CLK(NULL, "utmi_p1_gfclk", &dummy_ck), 3501 - CLK(NULL, "utmi_p2_gfclk", &dummy_ck), 3502 - CLK(NULL, "xclk60mhsp1_ck", &dummy_ck), 3503 - CLK(NULL, "xclk60mhsp2_ck", &dummy_ck), 3504 3500 CLK(NULL, "init_60m_fclk", &dummy_ck), 3505 3501 CLK(NULL, "gpt1_fck", &gpt1_fck), 3506 3502 CLK(NULL, "aes2_ick", &aes2_ick),
-6
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
··· 1955 1955 .sysc = &omap3xxx_usb_host_hs_sysc, 1956 1956 }; 1957 1957 1958 - static struct omap_hwmod_opt_clk omap3xxx_usb_host_hs_opt_clks[] = { 1959 - { .role = "ehci_logic_fck", .clk = "usbhost_120m_fck", }, 1960 - }; 1961 - 1962 1958 static struct omap_hwmod_irq_info omap3xxx_usb_host_hs_irqs[] = { 1963 1959 { .name = "ohci-irq", .irq = 76 + OMAP_INTC_START, }, 1964 1960 { .name = "ehci-irq", .irq = 77 + OMAP_INTC_START, }, ··· 1977 1981 .idlest_stdby_bit = OMAP3430ES2_ST_USBHOST_STDBY_SHIFT, 1978 1982 }, 1979 1983 }, 1980 - .opt_clks = omap3xxx_usb_host_hs_opt_clks, 1981 - .opt_clks_cnt = ARRAY_SIZE(omap3xxx_usb_host_hs_opt_clks), 1982 1984 1983 1985 /* 1984 1986 * Errata: USBHOST Configured In Smart-Idle Can Lead To a Deadlock
-4
drivers/clk/ti/clk-3xxx.c
··· 130 130 DT_CLK(NULL, "dss_tv_fck", "dss_tv_fck"), 131 131 DT_CLK(NULL, "dss_96m_fck", "dss_96m_fck"), 132 132 DT_CLK(NULL, "dss2_alwon_fck", "dss2_alwon_fck"), 133 - DT_CLK(NULL, "utmi_p1_gfclk", "dummy_ck"), 134 - DT_CLK(NULL, "utmi_p2_gfclk", "dummy_ck"), 135 - DT_CLK(NULL, "xclk60mhsp1_ck", "dummy_ck"), 136 - DT_CLK(NULL, "xclk60mhsp2_ck", "dummy_ck"), 137 133 DT_CLK(NULL, "init_60m_fclk", "dummy_ck"), 138 134 DT_CLK(NULL, "gpt1_fck", "gpt1_fck"), 139 135 DT_CLK(NULL, "aes2_ick", "aes2_ick"),
+25 -1
drivers/gpio/gpio-ich.c
··· 1 1 /* 2 - * Intel ICH6-10, Series 5 and 6 GPIO driver 2 + * Intel ICH6-10, Series 5 and 6, Atom C2000 (Avoton/Rangeley) GPIO driver 3 3 * 4 4 * Copyright (C) 2010 Extreme Engineering Solutions. 5 5 * ··· 53 53 54 54 static const u8 ichx_reglen[3] = { 55 55 0x30, 0x10, 0x10, 56 + }; 57 + 58 + static const u8 avoton_regs[4][3] = { 59 + {0x00, 0x80, 0x00}, 60 + {0x04, 0x84, 0x00}, 61 + {0x08, 0x88, 0x00}, 62 + }; 63 + 64 + static const u8 avoton_reglen[3] = { 65 + 0x10, 0x10, 0x00, 56 66 }; 57 67 58 68 #define ICHX_WRITE(val, reg, base_res) outl(val, (reg) + (base_res)->start) ··· 363 353 .reglen = ichx_reglen, 364 354 }; 365 355 356 + /* Avoton */ 357 + static struct ichx_desc avoton_desc = { 358 + /* Avoton has only 59 GPIOs, but we assume the first set of register 359 + * (Core) has 32 instead of 31 to keep gpio-ich compliance 360 + */ 361 + .ngpio = 60, 362 + .regs = avoton_regs, 363 + .reglen = avoton_reglen, 364 + .use_outlvl_cache = true, 365 + }; 366 + 366 367 static int ichx_gpio_request_regions(struct resource *res_base, 367 368 const char *name, u8 use_gpio) 368 369 { ··· 447 426 break; 448 427 case ICH_V10CONS_GPIO: 449 428 ichx_priv.desc = &ich10_cons_desc; 429 + break; 430 + case AVOTON_GPIO: 431 + ichx_priv.desc = &avoton_desc; 450 432 break; 451 433 default: 452 434 return -ENODEV;
+10
drivers/iio/adc/Kconfig
··· 193 193 Say yes here to build support for Texas Instruments ADC 194 194 driver which is also a MFD client. 195 195 196 + config TWL4030_MADC 197 + tristate "TWL4030 MADC (Monitoring A/D Converter)" 198 + depends on TWL4030_CORE 199 + help 200 + This driver provides support for Triton TWL4030-MADC. The 201 + driver supports both RT and SW conversion methods. 202 + 203 + This driver can also be built as a module. If so, the module will be 204 + called twl4030-madc. 205 + 196 206 config TWL6030_GPADC 197 207 tristate "TWL6030 GPADC (General Purpose A/D Converter) Support" 198 208 depends on TWL4030_CORE
+1
drivers/iio/adc/Makefile
··· 21 21 obj-$(CONFIG_NAU7802) += nau7802.o 22 22 obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o 23 23 obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o 24 + obj-$(CONFIG_TWL4030_MADC) += twl4030-madc.o 24 25 obj-$(CONFIG_TWL6030_GPADC) += twl6030-gpadc.o 25 26 obj-$(CONFIG_VF610_ADC) += vf610_adc.o 26 27 obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o
+1 -2
drivers/mfd/88pm800.c
··· 571 571 ret = pm800_pages_init(chip); 572 572 if (ret) { 573 573 dev_err(&client->dev, "pm800_pages_init failed!\n"); 574 - goto err_page_init; 574 + goto err_device_init; 575 575 } 576 576 577 577 ret = device_800_init(chip, pdata); ··· 587 587 588 588 err_device_init: 589 589 pm800_pages_exit(chip); 590 - err_page_init: 591 590 err_subchip_alloc: 592 591 pm80x_deinit(); 593 592 out_init:
+6
drivers/mfd/88pm860x-core.c
··· 1179 1179 chip->companion_addr = pdata->companion_addr; 1180 1180 chip->companion = i2c_new_dummy(chip->client->adapter, 1181 1181 chip->companion_addr); 1182 + if (!chip->companion) { 1183 + dev_err(&client->dev, 1184 + "Failed to allocate I2C companion device\n"); 1185 + return -ENODEV; 1186 + } 1182 1187 chip->regmap_companion = regmap_init_i2c(chip->companion, 1183 1188 &pm860x_regmap_config); 1184 1189 if (IS_ERR(chip->regmap_companion)) { 1185 1190 ret = PTR_ERR(chip->regmap_companion); 1186 1191 dev_err(&chip->companion->dev, 1187 1192 "Failed to allocate register map: %d\n", ret); 1193 + i2c_unregister_device(chip->companion); 1188 1194 return ret; 1189 1195 } 1190 1196 i2c_set_clientdata(chip->companion, chip);
+54 -44
drivers/mfd/Kconfig
··· 59 59 additional drivers must be enabled in order to use the 60 60 functionality of the device. 61 61 62 + config MFD_BCM590XX 63 + tristate "Broadcom BCM590xx PMUs" 64 + select MFD_CORE 65 + select REGMAP_I2C 66 + depends on I2C 67 + help 68 + Support for the BCM590xx PMUs from Broadcom 69 + 62 70 config MFD_CROS_EC 63 71 tristate "ChromeOS Embedded Controller" 64 72 select MFD_CORE ··· 108 100 bool "Dialog Semiconductor DA9030/DA9034 PMIC Support" 109 101 depends on I2C=y 110 102 help 111 - Say yes here to support for Dialog Semiconductor DA9030 (a.k.a 103 + Say yes here to add support for Dialog Semiconductor DA9030 (a.k.a 112 104 ARAVA) and DA9034 (a.k.a MICCO), these are Power Management IC 113 105 usually found on PXA processors-based platforms. This includes 114 106 the I2C driver and the core APIs _only_, you have to select ··· 278 270 device may provide functions like watchdog, GPIO, UART and I2C bus. 279 271 280 272 The following modules are supported: 273 + * COMe-bHL6 281 274 * COMe-bIP# 282 275 * COMe-bPC2 (ETXexpress-PC) 283 276 * COMe-bSC# (ETXexpress-SC T#) 277 + * COMe-cBT6 284 278 * COMe-cCT6 285 279 * COMe-cDC2 (microETXexpress-DC) 280 + * COMe-cHL6 286 281 * COMe-cPC2 (microETXexpress-PC) 282 + * COMe-mBT10 287 283 * COMe-mCT10 284 + * COMe-mTT10 (nanoETXexpress-TT) 288 285 * ETX-OH 289 286 290 287 This driver can also be built as a module. If so, the module ··· 335 322 depends on I2C=y 336 323 select MFD_CORE 337 324 select REGMAP_I2C 325 + select REGMAP_IRQ 338 326 select IRQ_DOMAIN 339 327 help 340 - Say yes here to support for Maxim Semiconductor MAX14577. 328 + Say yes here to add support for Maxim Semiconductor MAX14577. 341 329 This is a Micro-USB IC with Charger controls on chip. 342 330 This driver provides common support for accessing the device; 343 331 additional drivers must be enabled in order to use the functionality ··· 351 337 select REGMAP_I2C 352 338 select IRQ_DOMAIN 353 339 help 354 - Say yes here to support for Maxim Semiconductor MAX77686. 340 + Say yes here to add support for Maxim Semiconductor MAX77686. 355 341 This is a Power Management IC with RTC on chip. 356 342 This driver provides common support for accessing the device; 357 343 additional drivers must be enabled in order to use the functionality ··· 363 349 select MFD_CORE 364 350 select REGMAP_I2C 365 351 help 366 - Say yes here to support for Maxim Semiconductor MAX77693. 352 + Say yes here to add support for Maxim Semiconductor MAX77693. 367 353 This is a companion Power Management IC with Flash, Haptic, Charger, 368 354 and MUIC(Micro USB Interface Controller) controls on chip. 369 355 This driver provides common support for accessing the device; ··· 377 363 select REGMAP_I2C 378 364 select REGMAP_IRQ 379 365 help 380 - Say yes here to support for Maxim Semiconductor MAX8907. This is 366 + Say yes here to add support for Maxim Semiconductor MAX8907. This is 381 367 a Power Management IC. This driver provides common support for 382 368 accessing the device; additional drivers must be enabled in order 383 369 to use the functionality of the device. ··· 387 373 depends on I2C=y 388 374 select MFD_CORE 389 375 help 390 - Say yes here to support for Maxim Semiconductor MAX8925. This is 376 + Say yes here to add support for Maxim Semiconductor MAX8925. This is 391 377 a Power Management IC. This driver provides common support for 392 378 accessing the device, additional drivers must be enabled in order 393 379 to use the functionality of the device. ··· 398 384 select MFD_CORE 399 385 select IRQ_DOMAIN 400 386 help 401 - Say yes here to support for Maxim Semiconductor MAX8997/8966. 387 + Say yes here to add support for Maxim Semiconductor MAX8997/8966. 402 388 This is a Power Management IC with RTC, Flash, Fuel Gauge, Haptic, 403 389 MUIC controls on chip. 404 390 This driver provides common support for accessing the device; ··· 411 397 select MFD_CORE 412 398 select IRQ_DOMAIN 413 399 help 414 - Say yes here to support for Maxim Semiconductor MAX8998 and 400 + Say yes here to add support for Maxim Semiconductor MAX8998 and 415 401 National Semiconductor LP3974. This is a Power Management IC. 416 402 This driver provides common support for accessing the device, 417 403 additional drivers must be enabled in order to use the functionality ··· 487 473 488 474 config MFD_PM8921_CORE 489 475 tristate "Qualcomm PM8921 PMIC chip" 490 - depends on (ARCH_MSM || HEXAGON) 491 - depends on BROKEN 476 + depends on (ARM || HEXAGON) 477 + select IRQ_DOMAIN 492 478 select MFD_CORE 493 479 select MFD_PM8XXX 480 + select REGMAP 494 481 help 495 482 If you say yes to this option, support will be included for the 496 483 built-in PM8921 PMIC chip. ··· 501 486 502 487 Say M here if you want to include support for PM8921 chip as a module. 503 488 This will build a module called "pm8921-core". 504 - 505 - config MFD_PM8XXX_IRQ 506 - bool "Qualcomm PM8xxx IRQ features" 507 - depends on MFD_PM8XXX 508 - default y if MFD_PM8XXX 509 - help 510 - This is the IRQ driver for Qualcomm PM 8xxx PMIC chips. 511 - 512 - This is required to use certain other PM 8xxx features, such as GPIO 513 - and MPP. 514 489 515 490 config MFD_RDC321X 516 491 tristate "RDC R-321x southbridge" ··· 520 515 rts5229, rtl8411, etc. Realtek card reader supports access to many 521 516 types of memory cards, such as Memory Stick, Memory Stick Pro, 522 517 Secure Digital and MultiMediaCard. 518 + 519 + config MFD_RTSX_USB 520 + tristate "Realtek USB card reader" 521 + depends on USB 522 + select MFD_CORE 523 + help 524 + Select this option to get support for Realtek USB 2.0 card readers 525 + including RTS5129, RTS5139, RTS5179 and RTS5170. 526 + Realtek card reader supports access to many types of memory cards, 527 + such as Memory Stick Pro, Secure Digital and MultiMediaCard. 523 528 524 529 config MFD_RC5T583 525 530 bool "Ricoh RC5T583 Power Management system device" ··· 789 774 If you say yes here you get support for the Palmas 790 775 series of PMIC chips from Texas Instruments. 791 776 792 - config MFD_TI_SSP 793 - tristate "TI Sequencer Serial Port support" 794 - depends on ARCH_DAVINCI_TNETV107X 795 - select MFD_CORE 796 - ---help--- 797 - Say Y here if you want support for the Sequencer Serial Port 798 - in a Texas Instruments TNETV107X SoC. 799 - 800 - To compile this driver as a module, choose M here: the 801 - module will be called ti-ssp. 802 - 803 777 config TPS6105X 804 778 tristate "TI TPS61050/61052 Boost Converters" 805 779 depends on I2C ··· 856 852 857 853 This driver can also be built as a module. If so, the module 858 854 will be called tps65217. 855 + 856 + config MFD_TPS65218 857 + tristate "TI TPS65218 Power Management chips" 858 + depends on I2C 859 + select MFD_CORE 860 + select REGMAP_I2C 861 + select REGMAP_IRQ 862 + help 863 + If you say yes here you get support for the TPS65218 series of 864 + Power Management chips. 865 + These include voltage regulators, gpio and other features 866 + that are often used in portable devices. Only regulator 867 + component is currently supported. 868 + 869 + This driver can also be built as a module. If so, the module 870 + will be called tps65218. 859 871 860 872 config MFD_TPS6586X 861 873 bool "TI TPS6586x Power Management chips" ··· 954 934 boards, providing power management, RTC, GPIO, keypad, a 955 935 high speed USB OTG transceiver, an audio codec (on most 956 936 versions) and many other features. 957 - 958 - config TWL4030_MADC 959 - tristate "TI TWL4030 MADC" 960 - depends on TWL4030_CORE 961 - help 962 - This driver provides support for triton TWL4030-MADC. The 963 - driver supports both RT and SW conversion methods. 964 - 965 - This driver can be built as a module. If so it will be 966 - named twl4030-madc 967 937 968 938 config TWL4030_POWER 969 939 bool "TI TWL4030 power resources" ··· 1203 1193 in various ST Microelectronics and ST-Ericsson embedded 1204 1194 Nomadik series. 1205 1195 1206 - endmenu 1207 - endif 1208 - 1209 1196 menu "Multimedia Capabilities Port drivers" 1210 1197 depends on ARCH_SA1100 1211 1198 ··· 1233 1226 help 1234 1227 Platform configuration infrastructure for the ARM Ltd. 1235 1228 Versatile Express. 1229 + 1230 + endmenu 1231 + endif
+3 -3
drivers/mfd/Makefile
··· 8 8 obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o 9 9 obj-$(CONFIG_MFD_SM501) += sm501.o 10 10 obj-$(CONFIG_MFD_ASIC3) += asic3.o tmio_core.o 11 + obj-$(CONFIG_MFD_BCM590XX) += bcm590xx.o 11 12 obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o 12 13 obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o 13 14 obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o 14 15 15 16 rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o 16 17 obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o 18 + obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o 17 19 18 20 obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o 19 21 obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o ··· 23 21 24 22 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC) += davinci_voicecodec.o 25 23 obj-$(CONFIG_MFD_DM355EVM_MSP) += dm355evm_msp.o 26 - obj-$(CONFIG_MFD_TI_SSP) += ti-ssp.o 27 24 obj-$(CONFIG_MFD_TI_AM335X_TSCADC) += ti_am335x_tscadc.o 28 25 29 26 obj-$(CONFIG_MFD_STA2X11) += sta2x11-mfd.o ··· 63 62 obj-$(CONFIG_TPS65010) += tps65010.o 64 63 obj-$(CONFIG_TPS6507X) += tps6507x.o 65 64 obj-$(CONFIG_MFD_TPS65217) += tps65217.o 65 + obj-$(CONFIG_MFD_TPS65218) += tps65218.o 66 66 obj-$(CONFIG_MFD_TPS65910) += tps65910.o 67 67 tps65912-objs := tps65912-core.o tps65912-irq.o 68 68 obj-$(CONFIG_MFD_TPS65912) += tps65912.o ··· 73 71 obj-$(CONFIG_MENELAUS) += menelaus.o 74 72 75 73 obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o 76 - obj-$(CONFIG_TWL4030_MADC) += twl4030-madc.o 77 74 obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o 78 75 obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o 79 76 obj-$(CONFIG_TWL6040_CORE) += twl6040.o ··· 151 150 obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o 152 151 obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o omap-usb-tll.o 153 152 obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o ssbi.o 154 - obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o 155 153 obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o 156 154 obj-$(CONFIG_MFD_TPS65090) += tps65090.o 157 155 obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o
-1
drivers/mfd/adp5520.c
··· 20 20 #include <linux/kernel.h> 21 21 #include <linux/module.h> 22 22 #include <linux/platform_device.h> 23 - #include <linux/init.h> 24 23 #include <linux/slab.h> 25 24 #include <linux/interrupt.h> 26 25 #include <linux/irq.h>
+1
drivers/mfd/as3722.c
··· 277 277 regmap_reg_range(AS3722_ADC0_CONTROL_REG, AS3722_ADC_CONFIGURATION_REG), 278 278 regmap_reg_range(AS3722_ASIC_ID1_REG, AS3722_ASIC_ID2_REG), 279 279 regmap_reg_range(AS3722_LOCK_REG, AS3722_LOCK_REG), 280 + regmap_reg_range(AS3722_FUSE7_REG, AS3722_FUSE7_REG), 280 281 }; 281 282 282 283 static const struct regmap_access_table as3722_readable_table = {
+93
drivers/mfd/bcm590xx.c
··· 1 + /* 2 + * Broadcom BCM590xx PMU 3 + * 4 + * Copyright 2014 Linaro Limited 5 + * Author: Matt Porter <mporter@linaro.org> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + */ 12 + 13 + #include <linux/err.h> 14 + #include <linux/i2c.h> 15 + #include <linux/init.h> 16 + #include <linux/mfd/bcm590xx.h> 17 + #include <linux/mfd/core.h> 18 + #include <linux/module.h> 19 + #include <linux/moduleparam.h> 20 + #include <linux/of.h> 21 + #include <linux/of_device.h> 22 + #include <linux/regmap.h> 23 + #include <linux/slab.h> 24 + 25 + static const struct mfd_cell bcm590xx_devs[] = { 26 + { 27 + .name = "bcm590xx-vregs", 28 + }, 29 + }; 30 + 31 + static const struct regmap_config bcm590xx_regmap_config = { 32 + .reg_bits = 8, 33 + .val_bits = 8, 34 + .max_register = BCM590XX_MAX_REGISTER, 35 + .cache_type = REGCACHE_RBTREE, 36 + }; 37 + 38 + static int bcm590xx_i2c_probe(struct i2c_client *i2c, 39 + const struct i2c_device_id *id) 40 + { 41 + struct bcm590xx *bcm590xx; 42 + int ret; 43 + 44 + bcm590xx = devm_kzalloc(&i2c->dev, sizeof(*bcm590xx), GFP_KERNEL); 45 + if (!bcm590xx) 46 + return -ENOMEM; 47 + 48 + i2c_set_clientdata(i2c, bcm590xx); 49 + bcm590xx->dev = &i2c->dev; 50 + bcm590xx->i2c_client = i2c; 51 + 52 + bcm590xx->regmap = devm_regmap_init_i2c(i2c, &bcm590xx_regmap_config); 53 + if (IS_ERR(bcm590xx->regmap)) { 54 + ret = PTR_ERR(bcm590xx->regmap); 55 + dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret); 56 + return ret; 57 + } 58 + 59 + ret = mfd_add_devices(&i2c->dev, -1, bcm590xx_devs, 60 + ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL); 61 + if (ret < 0) 62 + dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret); 63 + 64 + return ret; 65 + } 66 + 67 + static const struct of_device_id bcm590xx_of_match[] = { 68 + { .compatible = "brcm,bcm59056" }, 69 + { } 70 + }; 71 + MODULE_DEVICE_TABLE(of, bcm590xx_of_match); 72 + 73 + static const struct i2c_device_id bcm590xx_i2c_id[] = { 74 + { "bcm59056" }, 75 + { } 76 + }; 77 + MODULE_DEVICE_TABLE(i2c, bcm590xx_i2c_id); 78 + 79 + static struct i2c_driver bcm590xx_i2c_driver = { 80 + .driver = { 81 + .name = "bcm590xx", 82 + .owner = THIS_MODULE, 83 + .of_match_table = of_match_ptr(bcm590xx_of_match), 84 + }, 85 + .probe = bcm590xx_i2c_probe, 86 + .id_table = bcm590xx_i2c_id, 87 + }; 88 + module_i2c_driver(bcm590xx_i2c_driver); 89 + 90 + MODULE_AUTHOR("Matt Porter <mporter@linaro.org>"); 91 + MODULE_DESCRIPTION("BCM590xx multi-function driver"); 92 + MODULE_LICENSE("GPL v2"); 93 + MODULE_ALIAS("platform:bcm590xx");
-1
drivers/mfd/cs5535-mfd.c
··· 23 23 */ 24 24 25 25 #include <linux/kernel.h> 26 - #include <linux/init.h> 27 26 #include <linux/mfd/core.h> 28 27 #include <linux/module.h> 29 28 #include <linux/pci.h>
+3
drivers/mfd/da9052-core.c
··· 279 279 case DA9052_EVENT_B_REG: 280 280 case DA9052_EVENT_C_REG: 281 281 case DA9052_EVENT_D_REG: 282 + case DA9052_CONTROL_B_REG: 283 + case DA9052_CONTROL_D_REG: 284 + case DA9052_SUPPLY_REG: 282 285 case DA9052_FAULTLOG_REG: 283 286 case DA9052_CHG_TIME_REG: 284 287 case DA9052_ADC_RES_L_REG:
+4 -1
drivers/mfd/da9052-i2c.c
··· 75 75 DA9052_PARK_REGISTER, 76 76 &val); 77 77 break; 78 + case DA9053_BC: 78 79 default: 79 80 /* 80 81 * For other chips parking of I2C register ··· 115 114 {"da9053-aa", DA9053_AA}, 116 115 {"da9053-ba", DA9053_BA}, 117 116 {"da9053-bb", DA9053_BB}, 117 + {"da9053-bc", DA9053_BC}, 118 118 {} 119 119 }; 120 120 ··· 123 121 static const struct of_device_id dialog_dt_ids[] = { 124 122 { .compatible = "dlg,da9052", .data = &da9052_i2c_id[0] }, 125 123 { .compatible = "dlg,da9053-aa", .data = &da9052_i2c_id[1] }, 126 - { .compatible = "dlg,da9053-ab", .data = &da9052_i2c_id[2] }, 124 + { .compatible = "dlg,da9053-ba", .data = &da9052_i2c_id[2] }, 127 125 { .compatible = "dlg,da9053-bb", .data = &da9052_i2c_id[3] }, 126 + { .compatible = "dlg,da9053-bc", .data = &da9052_i2c_id[4] }, 128 127 { /* sentinel */ } 129 128 }; 130 129 #endif
+1
drivers/mfd/da9052-spi.c
··· 71 71 {"da9053-aa", DA9053_AA}, 72 72 {"da9053-ba", DA9053_BA}, 73 73 {"da9053-bb", DA9053_BB}, 74 + {"da9053-bc", DA9053_BC}, 74 75 {} 75 76 }; 76 77
+8
drivers/mfd/da9055-i2c.c
··· 15 15 #include <linux/device.h> 16 16 #include <linux/i2c.h> 17 17 #include <linux/err.h> 18 + #include <linux/of.h> 19 + #include <linux/of_device.h> 18 20 19 21 #include <linux/mfd/da9055/core.h> 20 22 ··· 68 66 }; 69 67 MODULE_DEVICE_TABLE(i2c, da9055_i2c_id); 70 68 69 + static const struct of_device_id da9055_of_match[] = { 70 + { .compatible = "dlg,da9055-pmic", }, 71 + { } 72 + }; 73 + 71 74 static struct i2c_driver da9055_i2c_driver = { 72 75 .probe = da9055_i2c_probe, 73 76 .remove = da9055_i2c_remove, ··· 80 73 .driver = { 81 74 .name = "da9055-pmic", 82 75 .owner = THIS_MODULE, 76 + .of_match_table = of_match_ptr(da9055_of_match), 83 77 }, 84 78 }; 85 79
+14 -11
drivers/mfd/da9063-core.c
··· 110 110 int da9063_device_init(struct da9063 *da9063, unsigned int irq) 111 111 { 112 112 struct da9063_pdata *pdata = da9063->dev->platform_data; 113 - int model, revision; 113 + int model, variant_id, variant_code; 114 114 int ret; 115 115 116 116 if (pdata) { ··· 141 141 return -ENODEV; 142 142 } 143 143 144 - ret = regmap_read(da9063->regmap, DA9063_REG_CHIP_VARIANT, &revision); 144 + ret = regmap_read(da9063->regmap, DA9063_REG_CHIP_VARIANT, &variant_id); 145 145 if (ret < 0) { 146 - dev_err(da9063->dev, "Cannot read chip revision id.\n"); 146 + dev_err(da9063->dev, "Cannot read chip variant id.\n"); 147 147 return -EIO; 148 148 } 149 - revision >>= DA9063_CHIP_VARIANT_SHIFT; 150 - if (revision != 3) { 151 - dev_err(da9063->dev, "Unknown chip revision: %d\n", revision); 149 + 150 + variant_code = variant_id >> DA9063_CHIP_VARIANT_SHIFT; 151 + 152 + dev_info(da9063->dev, 153 + "Device detected (chip-ID: 0x%02X, var-ID: 0x%02X)\n", 154 + model, variant_id); 155 + 156 + if (variant_code != PMIC_DA9063_BB) { 157 + dev_err(da9063->dev, "Unknown chip variant code: 0x%02X\n", 158 + variant_code); 152 159 return -ENODEV; 153 160 } 154 161 155 162 da9063->model = model; 156 - da9063->revision = revision; 157 - 158 - dev_info(da9063->dev, 159 - "Device detected (model-ID: 0x%02X rev-ID: 0x%02X)\n", 160 - model, revision); 163 + da9063->variant_code = variant_code; 161 164 162 165 ret = da9063_irq_init(da9063); 163 166 if (ret) {
-1
drivers/mfd/janz-cmodio.c
··· 13 13 14 14 #include <linux/kernel.h> 15 15 #include <linux/module.h> 16 - #include <linux/init.h> 17 16 #include <linux/pci.h> 18 17 #include <linux/interrupt.h> 19 18 #include <linux/delay.h>
+29 -2
drivers/mfd/kempld-core.c
··· 322 322 return -ENODEV; 323 323 } 324 324 325 - /* Release hardware mutex if aquired */ 326 - if (!(index_reg & KEMPLD_MUTEX_KEY)) 325 + /* Release hardware mutex if acquired */ 326 + if (!(index_reg & KEMPLD_MUTEX_KEY)) { 327 327 iowrite8(KEMPLD_MUTEX_KEY, pld->io_index); 328 + /* PXT and COMe-cPC2 boards may require a second release */ 329 + iowrite8(KEMPLD_MUTEX_KEY, pld->io_index); 330 + } 328 331 329 332 mutex_unlock(&pld->lock); 330 333 ··· 441 438 .driver_data = (void *)&kempld_platform_data_generic, 442 439 .callback = kempld_create_platform_device, 443 440 }, { 441 + .ident = "CHL6", 442 + .matches = { 443 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 444 + DMI_MATCH(DMI_BOARD_NAME, "COMe-cHL6"), 445 + }, 446 + .driver_data = (void *)&kempld_platform_data_generic, 447 + .callback = kempld_create_platform_device, 448 + }, { 444 449 .ident = "CHR2", 445 450 .matches = { 446 451 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), ··· 521 510 .driver_data = (void *)&kempld_platform_data_generic, 522 511 .callback = kempld_create_platform_device, 523 512 }, { 513 + .ident = "CVV6", 514 + .matches = { 515 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 516 + DMI_MATCH(DMI_BOARD_NAME, "COMe-cBT"), 517 + }, 518 + .driver_data = (void *)&kempld_platform_data_generic, 519 + .callback = kempld_create_platform_device, 520 + }, { 524 521 .ident = "FRI2", 525 522 .matches = { 526 523 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), ··· 548 529 .matches = { 549 530 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 550 531 DMI_MATCH(DMI_BOARD_NAME, "ETX-OH"), 532 + }, 533 + .driver_data = (void *)&kempld_platform_data_generic, 534 + .callback = kempld_create_platform_device, 535 + }, { 536 + .ident = "MVV1", 537 + .matches = { 538 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 539 + DMI_MATCH(DMI_BOARD_NAME, "COMe-mBT"), 551 540 }, 552 541 .driver_data = (void *)&kempld_platform_data_generic, 553 542 .callback = kempld_create_platform_device,
+108 -43
drivers/mfd/lpc_ich.c
··· 58 58 59 59 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 60 60 61 - #include <linux/init.h> 62 61 #include <linux/kernel.h> 63 62 #include <linux/module.h> 64 63 #include <linux/errno.h> ··· 71 72 #define ACPIBASE_GPE_END 0x2f 72 73 #define ACPIBASE_SMI_OFF 0x30 73 74 #define ACPIBASE_SMI_END 0x33 75 + #define ACPIBASE_PMC_OFF 0x08 76 + #define ACPIBASE_PMC_END 0x0c 74 77 #define ACPIBASE_TCO_OFF 0x60 75 78 #define ACPIBASE_TCO_END 0x7f 76 - #define ACPICTRL 0x44 79 + #define ACPICTRL_PMCBASE 0x44 77 80 78 81 #define ACPIBASE_GCS_OFF 0x3410 79 82 #define ACPIBASE_GCS_END 0x3414 ··· 91 90 #define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i) 92 91 #define wdt_res(b, i) (&wdt_ich_res[(b) + (i)]) 93 92 94 - struct lpc_ich_cfg { 95 - int base; 96 - int ctrl; 97 - int save; 98 - }; 99 - 100 93 struct lpc_ich_priv { 101 94 int chipset; 102 - struct lpc_ich_cfg acpi; 103 - struct lpc_ich_cfg gpio; 95 + 96 + int abase; /* ACPI base */ 97 + int actrl_pbase; /* ACPI control or PMC base */ 98 + int gbase; /* GPIO base */ 99 + int gctrl; /* GPIO control */ 100 + 101 + int abase_save; /* Cached ACPI base value */ 102 + int actrl_pbase_save; /* Cached ACPI control or PMC base value */ 103 + int gctrl_save; /* Cached GPIO control value */ 104 104 }; 105 105 106 106 static struct resource wdt_ich_res[] = { ··· 113 111 { 114 112 .flags = IORESOURCE_IO, 115 113 }, 116 - /* GCS */ 114 + /* GCS or PMC */ 117 115 { 118 116 .flags = IORESOURCE_MEM, 119 117 }, ··· 213 211 LPC_LPT_LP, /* Lynx Point-LP */ 214 212 LPC_WBG, /* Wellsburg */ 215 213 LPC_AVN, /* Avoton SoC */ 214 + LPC_BAYTRAIL, /* Bay Trail SoC */ 216 215 LPC_COLETO, /* Coleto Creek */ 217 216 LPC_WPT_LP, /* Wildcat Point-LP */ 218 217 }; ··· 306 303 [LPC_NM10] = { 307 304 .name = "NM10", 308 305 .iTCO_version = 2, 306 + .gpio_version = ICH_V7_GPIO, 309 307 }, 310 308 [LPC_ICH8] = { 311 309 .name = "ICH8 or ICH8R", ··· 503 499 }, 504 500 [LPC_AVN] = { 505 501 .name = "Avoton SoC", 506 - .iTCO_version = 1, 502 + .iTCO_version = 3, 503 + .gpio_version = AVOTON_GPIO, 504 + }, 505 + [LPC_BAYTRAIL] = { 506 + .name = "Bay Trail SoC", 507 + .iTCO_version = 3, 507 508 }, 508 509 [LPC_COLETO] = { 509 510 .name = "Coleto Creek", ··· 735 726 { PCI_VDEVICE(INTEL, 0x1f39), LPC_AVN}, 736 727 { PCI_VDEVICE(INTEL, 0x1f3a), LPC_AVN}, 737 728 { PCI_VDEVICE(INTEL, 0x1f3b), LPC_AVN}, 729 + { PCI_VDEVICE(INTEL, 0x0f1c), LPC_BAYTRAIL}, 738 730 { PCI_VDEVICE(INTEL, 0x2390), LPC_COLETO}, 739 731 { PCI_VDEVICE(INTEL, 0x9cc1), LPC_WPT_LP}, 740 732 { PCI_VDEVICE(INTEL, 0x9cc2), LPC_WPT_LP}, ··· 752 742 { 753 743 struct lpc_ich_priv *priv = pci_get_drvdata(dev); 754 744 755 - if (priv->acpi.save >= 0) { 756 - pci_write_config_byte(dev, priv->acpi.ctrl, priv->acpi.save); 757 - priv->acpi.save = -1; 745 + if (priv->abase_save >= 0) { 746 + pci_write_config_byte(dev, priv->abase, priv->abase_save); 747 + priv->abase_save = -1; 758 748 } 759 749 760 - if (priv->gpio.save >= 0) { 761 - pci_write_config_byte(dev, priv->gpio.ctrl, priv->gpio.save); 762 - priv->gpio.save = -1; 750 + if (priv->actrl_pbase_save >= 0) { 751 + pci_write_config_byte(dev, priv->actrl_pbase, 752 + priv->actrl_pbase_save); 753 + priv->actrl_pbase_save = -1; 754 + } 755 + 756 + if (priv->gctrl_save >= 0) { 757 + pci_write_config_byte(dev, priv->gctrl, priv->gctrl_save); 758 + priv->gctrl_save = -1; 763 759 } 764 760 } 765 761 ··· 774 758 struct lpc_ich_priv *priv = pci_get_drvdata(dev); 775 759 u8 reg_save; 776 760 777 - pci_read_config_byte(dev, priv->acpi.ctrl, &reg_save); 778 - pci_write_config_byte(dev, priv->acpi.ctrl, reg_save | 0x10); 779 - priv->acpi.save = reg_save; 761 + switch (lpc_chipset_info[priv->chipset].iTCO_version) { 762 + case 3: 763 + /* 764 + * Some chipsets (eg Avoton) enable the ACPI space in the 765 + * ACPI BASE register. 766 + */ 767 + pci_read_config_byte(dev, priv->abase, &reg_save); 768 + pci_write_config_byte(dev, priv->abase, reg_save | 0x2); 769 + priv->abase_save = reg_save; 770 + break; 771 + default: 772 + /* 773 + * Most chipsets enable the ACPI space in the ACPI control 774 + * register. 775 + */ 776 + pci_read_config_byte(dev, priv->actrl_pbase, &reg_save); 777 + pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x80); 778 + priv->actrl_pbase_save = reg_save; 779 + break; 780 + } 780 781 } 781 782 782 783 static void lpc_ich_enable_gpio_space(struct pci_dev *dev) ··· 801 768 struct lpc_ich_priv *priv = pci_get_drvdata(dev); 802 769 u8 reg_save; 803 770 804 - pci_read_config_byte(dev, priv->gpio.ctrl, &reg_save); 805 - pci_write_config_byte(dev, priv->gpio.ctrl, reg_save | 0x10); 806 - priv->gpio.save = reg_save; 771 + pci_read_config_byte(dev, priv->gctrl, &reg_save); 772 + pci_write_config_byte(dev, priv->gctrl, reg_save | 0x10); 773 + priv->gctrl_save = reg_save; 774 + } 775 + 776 + static void lpc_ich_enable_pmc_space(struct pci_dev *dev) 777 + { 778 + struct lpc_ich_priv *priv = pci_get_drvdata(dev); 779 + u8 reg_save; 780 + 781 + pci_read_config_byte(dev, priv->actrl_pbase, &reg_save); 782 + pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x2); 783 + 784 + priv->actrl_pbase_save = reg_save; 807 785 } 808 786 809 787 static void lpc_ich_finalize_cell(struct pci_dev *dev, struct mfd_cell *cell) ··· 859 815 struct resource *res; 860 816 861 817 /* Setup power management base register */ 862 - pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg); 818 + pci_read_config_dword(dev, priv->abase, &base_addr_cfg); 863 819 base_addr = base_addr_cfg & 0x0000ff80; 864 820 if (!base_addr) { 865 821 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); ··· 885 841 886 842 gpe0_done: 887 843 /* Setup GPIO base register */ 888 - pci_read_config_dword(dev, priv->gpio.base, &base_addr_cfg); 844 + pci_read_config_dword(dev, priv->gbase, &base_addr_cfg); 889 845 base_addr = base_addr_cfg & 0x0000ff80; 890 846 if (!base_addr) { 891 847 dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n"); ··· 935 891 struct resource *res; 936 892 937 893 /* Setup power management base register */ 938 - pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg); 894 + pci_read_config_dword(dev, priv->abase, &base_addr_cfg); 939 895 base_addr = base_addr_cfg & 0x0000ff80; 940 896 if (!base_addr) { 941 897 dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); ··· 954 910 lpc_ich_enable_acpi_space(dev); 955 911 956 912 /* 913 + * iTCO v2: 957 914 * Get the Memory-Mapped GCS register. To get access to it 958 915 * we have to read RCBA from PCI Config space 0xf0 and use 959 916 * it as base. GCS = RCBA + ICH6_GCS(0x3410). 917 + * 918 + * iTCO v3: 919 + * Get the Power Management Configuration register. To get access 920 + * to it we have to read the PMC BASE from config space and address 921 + * the register at offset 0x8. 960 922 */ 961 923 if (lpc_chipset_info[priv->chipset].iTCO_version == 1) { 962 924 /* Don't register iomem for TCO ver 1 */ 963 925 lpc_ich_cells[LPC_WDT].num_resources--; 964 - } else { 926 + } else if (lpc_chipset_info[priv->chipset].iTCO_version == 2) { 965 927 pci_read_config_dword(dev, RCBABASE, &base_addr_cfg); 966 928 base_addr = base_addr_cfg & 0xffffc000; 967 929 if (!(base_addr_cfg & 1)) { ··· 976 926 ret = -ENODEV; 977 927 goto wdt_done; 978 928 } 979 - res = wdt_mem_res(ICH_RES_MEM_GCS); 929 + res = wdt_mem_res(ICH_RES_MEM_GCS_PMC); 980 930 res->start = base_addr + ACPIBASE_GCS_OFF; 981 931 res->end = base_addr + ACPIBASE_GCS_END; 932 + } else if (lpc_chipset_info[priv->chipset].iTCO_version == 3) { 933 + lpc_ich_enable_pmc_space(dev); 934 + pci_read_config_dword(dev, ACPICTRL_PMCBASE, &base_addr_cfg); 935 + base_addr = base_addr_cfg & 0xfffffe00; 936 + 937 + res = wdt_mem_res(ICH_RES_MEM_GCS_PMC); 938 + res->start = base_addr + ACPIBASE_PMC_OFF; 939 + res->end = base_addr + ACPIBASE_PMC_END; 982 940 } 983 941 984 942 lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_WDT]); ··· 1010 952 return -ENOMEM; 1011 953 1012 954 priv->chipset = id->driver_data; 1013 - priv->acpi.save = -1; 1014 - priv->acpi.base = ACPIBASE; 1015 - priv->acpi.ctrl = ACPICTRL; 1016 955 1017 - priv->gpio.save = -1; 956 + priv->actrl_pbase_save = -1; 957 + priv->abase_save = -1; 958 + 959 + priv->abase = ACPIBASE; 960 + priv->actrl_pbase = ACPICTRL_PMCBASE; 961 + 962 + priv->gctrl_save = -1; 1018 963 if (priv->chipset <= LPC_ICH5) { 1019 - priv->gpio.base = GPIOBASE_ICH0; 1020 - priv->gpio.ctrl = GPIOCTRL_ICH0; 964 + priv->gbase = GPIOBASE_ICH0; 965 + priv->gctrl = GPIOCTRL_ICH0; 1021 966 } else { 1022 - priv->gpio.base = GPIOBASE_ICH6; 1023 - priv->gpio.ctrl = GPIOCTRL_ICH6; 967 + priv->gbase = GPIOBASE_ICH6; 968 + priv->gctrl = GPIOCTRL_ICH6; 1024 969 } 1025 970 1026 971 pci_set_drvdata(dev, priv); 1027 972 1028 - ret = lpc_ich_init_wdt(dev); 1029 - if (!ret) 1030 - cell_added = true; 973 + if (lpc_chipset_info[priv->chipset].iTCO_version) { 974 + ret = lpc_ich_init_wdt(dev); 975 + if (!ret) 976 + cell_added = true; 977 + } 1031 978 1032 - ret = lpc_ich_init_gpio(dev); 1033 - if (!ret) 1034 - cell_added = true; 979 + if (lpc_chipset_info[priv->chipset].gpio_version) { 980 + ret = lpc_ich_init_gpio(dev); 981 + if (!ret) 982 + cell_added = true; 983 + } 1035 984 1036 985 /* 1037 986 * We only care if at least one or none of the cells registered
-1
drivers/mfd/lpc_sch.c
··· 23 23 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 24 24 */ 25 25 26 - #include <linux/init.h> 27 26 #include <linux/kernel.h> 28 27 #include <linux/module.h> 29 28 #include <linux/errno.h>
+5 -1
drivers/mfd/max14577.c
··· 18 18 * This driver is based on max8997.c 19 19 */ 20 20 21 + #include <linux/err.h> 21 22 #include <linux/module.h> 22 23 #include <linux/interrupt.h> 23 24 #include <linux/mfd/core.h> ··· 26 25 #include <linux/mfd/max14577-private.h> 27 26 28 27 static struct mfd_cell max14577_devs[] = { 29 - { .name = "max14577-muic", }, 28 + { 29 + .name = "max14577-muic", 30 + .of_compatible = "maxim,max14577-muic", 31 + }, 30 32 { 31 33 .name = "max14577-regulator", 32 34 .of_compatible = "maxim,max14577-regulator",
+4
drivers/mfd/max77686.c
··· 121 121 dev_info(max77686->dev, "device found\n"); 122 122 123 123 max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC); 124 + if (!max77686->rtc) { 125 + dev_err(max77686->dev, "Failed to allocate I2C device for RTC\n"); 126 + return -ENODEV; 127 + } 124 128 i2c_set_clientdata(max77686->rtc, max77686); 125 129 126 130 max77686_irq_init(max77686);
+11 -1
drivers/mfd/max77693.c
··· 148 148 dev_info(max77693->dev, "device ID: 0x%x\n", reg_data); 149 149 150 150 max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); 151 + if (!max77693->muic) { 152 + dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n"); 153 + return -ENODEV; 154 + } 151 155 i2c_set_clientdata(max77693->muic, max77693); 152 156 153 157 max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); 158 + if (!max77693->haptic) { 159 + dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n"); 160 + ret = -ENODEV; 161 + goto err_i2c_haptic; 162 + } 154 163 i2c_set_clientdata(max77693->haptic, max77693); 155 164 156 165 /* ··· 193 184 max77693_irq_exit(max77693); 194 185 err_irq: 195 186 err_regmap_muic: 196 - i2c_unregister_device(max77693->muic); 197 187 i2c_unregister_device(max77693->haptic); 188 + err_i2c_haptic: 189 + i2c_unregister_device(max77693->muic); 198 190 return ret; 199 191 } 200 192
+9
drivers/mfd/max8925-i2c.c
··· 181 181 mutex_init(&chip->io_lock); 182 182 183 183 chip->rtc = i2c_new_dummy(chip->i2c->adapter, RTC_I2C_ADDR); 184 + if (!chip->rtc) { 185 + dev_err(chip->dev, "Failed to allocate I2C device for RTC\n"); 186 + return -ENODEV; 187 + } 184 188 i2c_set_clientdata(chip->rtc, chip); 185 189 186 190 chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR); 191 + if (!chip->adc) { 192 + dev_err(chip->dev, "Failed to allocate I2C device for ADC\n"); 193 + i2c_unregister_device(chip->rtc); 194 + return -ENODEV; 195 + } 187 196 i2c_set_clientdata(chip->adc, chip); 188 197 189 198 device_init_wakeup(&client->dev, 1);
+18
drivers/mfd/max8997.c
··· 208 208 mutex_init(&max8997->iolock); 209 209 210 210 max8997->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC); 211 + if (!max8997->rtc) { 212 + dev_err(max8997->dev, "Failed to allocate I2C device for RTC\n"); 213 + return -ENODEV; 214 + } 211 215 i2c_set_clientdata(max8997->rtc, max8997); 216 + 212 217 max8997->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC); 218 + if (!max8997->haptic) { 219 + dev_err(max8997->dev, "Failed to allocate I2C device for Haptic\n"); 220 + ret = -ENODEV; 221 + goto err_i2c_haptic; 222 + } 213 223 i2c_set_clientdata(max8997->haptic, max8997); 224 + 214 225 max8997->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC); 226 + if (!max8997->muic) { 227 + dev_err(max8997->dev, "Failed to allocate I2C device for MUIC\n"); 228 + ret = -ENODEV; 229 + goto err_i2c_muic; 230 + } 215 231 i2c_set_clientdata(max8997->muic, max8997); 216 232 217 233 pm_runtime_set_active(max8997->dev); ··· 255 239 err_mfd: 256 240 mfd_remove_devices(max8997->dev); 257 241 i2c_unregister_device(max8997->muic); 242 + err_i2c_muic: 258 243 i2c_unregister_device(max8997->haptic); 244 + err_i2c_haptic: 259 245 i2c_unregister_device(max8997->rtc); 260 246 return ret; 261 247 }
+4
drivers/mfd/max8998.c
··· 215 215 mutex_init(&max8998->iolock); 216 216 217 217 max8998->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR); 218 + if (!max8998->rtc) { 219 + dev_err(&i2c->dev, "Failed to allocate I2C device for RTC\n"); 220 + return -ENODEV; 221 + } 218 222 i2c_set_clientdata(max8998->rtc, max8998); 219 223 220 224 max8998_irq_init(max8998);
+5
drivers/mfd/mc13xxx-spi.c
··· 140 140 141 141 mc13xxx->irq = spi->irq; 142 142 143 + spi->max_speed_hz = spi->max_speed_hz ? : 26000000; 144 + ret = spi_setup(spi); 145 + if (ret) 146 + return ret; 147 + 143 148 mc13xxx->regmap = devm_regmap_init(&spi->dev, &regmap_mc13xxx_bus, 144 149 &spi->dev, 145 150 &mc13xxx_regmap_spi_config);
-1
drivers/mfd/mcp-sa11x0.c
··· 12 12 * MCP read/write timeouts from Jordi Colomer, rehacked by rmk. 13 13 */ 14 14 #include <linux/module.h> 15 - #include <linux/init.h> 16 15 #include <linux/io.h> 17 16 #include <linux/errno.h> 18 17 #include <linux/kernel.h>
+91 -100
drivers/mfd/omap-usb-host.c
··· 665 665 goto err_mem; 666 666 } 667 667 668 - need_logic_fck = false; 668 + /* Set all clocks as invalid to begin with */ 669 + omap->ehci_logic_fck = ERR_PTR(-ENODEV); 670 + omap->init_60m_fclk = ERR_PTR(-ENODEV); 671 + omap->utmi_p1_gfclk = ERR_PTR(-ENODEV); 672 + omap->utmi_p2_gfclk = ERR_PTR(-ENODEV); 673 + omap->xclk60mhsp1_ck = ERR_PTR(-ENODEV); 674 + omap->xclk60mhsp2_ck = ERR_PTR(-ENODEV); 675 + 669 676 for (i = 0; i < omap->nports; i++) { 670 - if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) || 671 - is_ehci_hsic_mode(i)) 677 + omap->utmi_clk[i] = ERR_PTR(-ENODEV); 678 + omap->hsic480m_clk[i] = ERR_PTR(-ENODEV); 679 + omap->hsic60m_clk[i] = ERR_PTR(-ENODEV); 680 + } 681 + 682 + /* for OMAP3 i.e. USBHS REV1 */ 683 + if (omap->usbhs_rev == OMAP_USBHS_REV1) { 684 + need_logic_fck = false; 685 + for (i = 0; i < omap->nports; i++) { 686 + if (is_ehci_phy_mode(pdata->port_mode[i]) || 687 + is_ehci_tll_mode(pdata->port_mode[i]) || 688 + is_ehci_hsic_mode(pdata->port_mode[i])) 689 + 672 690 need_logic_fck |= true; 673 - } 674 - 675 - omap->ehci_logic_fck = ERR_PTR(-EINVAL); 676 - if (need_logic_fck) { 677 - omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck"); 678 - if (IS_ERR(omap->ehci_logic_fck)) { 679 - ret = PTR_ERR(omap->ehci_logic_fck); 680 - dev_dbg(dev, "ehci_logic_fck failed:%d\n", ret); 681 691 } 692 + 693 + if (need_logic_fck) { 694 + omap->ehci_logic_fck = devm_clk_get(dev, 695 + "usbhost_120m_fck"); 696 + if (IS_ERR(omap->ehci_logic_fck)) { 697 + ret = PTR_ERR(omap->ehci_logic_fck); 698 + dev_err(dev, "usbhost_120m_fck failed:%d\n", 699 + ret); 700 + goto err_mem; 701 + } 702 + } 703 + goto initialize; 682 704 } 683 705 684 - omap->utmi_p1_gfclk = clk_get(dev, "utmi_p1_gfclk"); 706 + /* for OMAP4+ i.e. USBHS REV2+ */ 707 + omap->utmi_p1_gfclk = devm_clk_get(dev, "utmi_p1_gfclk"); 685 708 if (IS_ERR(omap->utmi_p1_gfclk)) { 686 709 ret = PTR_ERR(omap->utmi_p1_gfclk); 687 710 dev_err(dev, "utmi_p1_gfclk failed error:%d\n", ret); 688 - goto err_p1_gfclk; 711 + goto err_mem; 689 712 } 690 713 691 - omap->utmi_p2_gfclk = clk_get(dev, "utmi_p2_gfclk"); 714 + omap->utmi_p2_gfclk = devm_clk_get(dev, "utmi_p2_gfclk"); 692 715 if (IS_ERR(omap->utmi_p2_gfclk)) { 693 716 ret = PTR_ERR(omap->utmi_p2_gfclk); 694 717 dev_err(dev, "utmi_p2_gfclk failed error:%d\n", ret); 695 - goto err_p2_gfclk; 718 + goto err_mem; 696 719 } 697 720 698 - omap->xclk60mhsp1_ck = clk_get(dev, "xclk60mhsp1_ck"); 721 + omap->xclk60mhsp1_ck = devm_clk_get(dev, "refclk_60m_ext_p1"); 699 722 if (IS_ERR(omap->xclk60mhsp1_ck)) { 700 723 ret = PTR_ERR(omap->xclk60mhsp1_ck); 701 - dev_err(dev, "xclk60mhsp1_ck failed error:%d\n", ret); 702 - goto err_xclk60mhsp1; 724 + dev_err(dev, "refclk_60m_ext_p1 failed error:%d\n", ret); 725 + goto err_mem; 703 726 } 704 727 705 - omap->xclk60mhsp2_ck = clk_get(dev, "xclk60mhsp2_ck"); 728 + omap->xclk60mhsp2_ck = devm_clk_get(dev, "refclk_60m_ext_p2"); 706 729 if (IS_ERR(omap->xclk60mhsp2_ck)) { 707 730 ret = PTR_ERR(omap->xclk60mhsp2_ck); 708 - dev_err(dev, "xclk60mhsp2_ck failed error:%d\n", ret); 709 - goto err_xclk60mhsp2; 731 + dev_err(dev, "refclk_60m_ext_p2 failed error:%d\n", ret); 732 + goto err_mem; 710 733 } 711 734 712 - omap->init_60m_fclk = clk_get(dev, "init_60m_fclk"); 735 + omap->init_60m_fclk = devm_clk_get(dev, "refclk_60m_int"); 713 736 if (IS_ERR(omap->init_60m_fclk)) { 714 737 ret = PTR_ERR(omap->init_60m_fclk); 715 - dev_err(dev, "init_60m_fclk failed error:%d\n", ret); 716 - goto err_init60m; 738 + dev_err(dev, "refclk_60m_int failed error:%d\n", ret); 739 + goto err_mem; 717 740 } 718 741 719 742 for (i = 0; i < omap->nports; i++) { ··· 750 727 * platforms have all clocks and we can function without 751 728 * them 752 729 */ 753 - omap->utmi_clk[i] = clk_get(dev, clkname); 754 - if (IS_ERR(omap->utmi_clk[i])) 755 - dev_dbg(dev, "Failed to get clock : %s : %ld\n", 756 - clkname, PTR_ERR(omap->utmi_clk[i])); 730 + omap->utmi_clk[i] = devm_clk_get(dev, clkname); 731 + if (IS_ERR(omap->utmi_clk[i])) { 732 + ret = PTR_ERR(omap->utmi_clk[i]); 733 + dev_err(dev, "Failed to get clock : %s : %d\n", 734 + clkname, ret); 735 + goto err_mem; 736 + } 757 737 758 738 snprintf(clkname, sizeof(clkname), 759 739 "usb_host_hs_hsic480m_p%d_clk", i + 1); 760 - omap->hsic480m_clk[i] = clk_get(dev, clkname); 761 - if (IS_ERR(omap->hsic480m_clk[i])) 762 - dev_dbg(dev, "Failed to get clock : %s : %ld\n", 763 - clkname, PTR_ERR(omap->hsic480m_clk[i])); 740 + omap->hsic480m_clk[i] = devm_clk_get(dev, clkname); 741 + if (IS_ERR(omap->hsic480m_clk[i])) { 742 + ret = PTR_ERR(omap->hsic480m_clk[i]); 743 + dev_err(dev, "Failed to get clock : %s : %d\n", 744 + clkname, ret); 745 + goto err_mem; 746 + } 764 747 765 748 snprintf(clkname, sizeof(clkname), 766 749 "usb_host_hs_hsic60m_p%d_clk", i + 1); 767 - omap->hsic60m_clk[i] = clk_get(dev, clkname); 768 - if (IS_ERR(omap->hsic60m_clk[i])) 769 - dev_dbg(dev, "Failed to get clock : %s : %ld\n", 770 - clkname, PTR_ERR(omap->hsic60m_clk[i])); 750 + omap->hsic60m_clk[i] = devm_clk_get(dev, clkname); 751 + if (IS_ERR(omap->hsic60m_clk[i])) { 752 + ret = PTR_ERR(omap->hsic60m_clk[i]); 753 + dev_err(dev, "Failed to get clock : %s : %d\n", 754 + clkname, ret); 755 + goto err_mem; 756 + } 771 757 } 772 758 773 759 if (is_ehci_phy_mode(pdata->port_mode[0])) { 774 - /* for OMAP3, clk_set_parent fails */ 775 760 ret = clk_set_parent(omap->utmi_p1_gfclk, 776 761 omap->xclk60mhsp1_ck); 777 - if (ret != 0) 778 - dev_dbg(dev, "xclk60mhsp1_ck set parent failed: %d\n", 779 - ret); 762 + if (ret != 0) { 763 + dev_err(dev, "xclk60mhsp1_ck set parent failed: %d\n", 764 + ret); 765 + goto err_mem; 766 + } 780 767 } else if (is_ehci_tll_mode(pdata->port_mode[0])) { 781 768 ret = clk_set_parent(omap->utmi_p1_gfclk, 782 769 omap->init_60m_fclk); 783 - if (ret != 0) 784 - dev_dbg(dev, "P0 init_60m_fclk set parent failed: %d\n", 785 - ret); 770 + if (ret != 0) { 771 + dev_err(dev, "P0 init_60m_fclk set parent failed: %d\n", 772 + ret); 773 + goto err_mem; 774 + } 786 775 } 787 776 788 777 if (is_ehci_phy_mode(pdata->port_mode[1])) { 789 778 ret = clk_set_parent(omap->utmi_p2_gfclk, 790 779 omap->xclk60mhsp2_ck); 791 - if (ret != 0) 792 - dev_dbg(dev, "xclk60mhsp2_ck set parent failed: %d\n", 793 - ret); 780 + if (ret != 0) { 781 + dev_err(dev, "xclk60mhsp2_ck set parent failed: %d\n", 782 + ret); 783 + goto err_mem; 784 + } 794 785 } else if (is_ehci_tll_mode(pdata->port_mode[1])) { 795 786 ret = clk_set_parent(omap->utmi_p2_gfclk, 796 787 omap->init_60m_fclk); 797 - if (ret != 0) 798 - dev_dbg(dev, "P1 init_60m_fclk set parent failed: %d\n", 799 - ret); 788 + if (ret != 0) { 789 + dev_err(dev, "P1 init_60m_fclk set parent failed: %d\n", 790 + ret); 791 + goto err_mem; 792 + } 800 793 } 801 794 795 + initialize: 802 796 omap_usbhs_init(dev); 803 797 804 798 if (dev->of_node) { ··· 824 784 825 785 if (ret) { 826 786 dev_err(dev, "Failed to create DT children: %d\n", ret); 827 - goto err_alloc; 787 + goto err_mem; 828 788 } 829 789 830 790 } else { ··· 832 792 if (ret) { 833 793 dev_err(dev, "omap_usbhs_alloc_children failed: %d\n", 834 794 ret); 835 - goto err_alloc; 795 + goto err_mem; 836 796 } 837 797 } 838 798 839 799 return 0; 840 - 841 - err_alloc: 842 - for (i = 0; i < omap->nports; i++) { 843 - if (!IS_ERR(omap->utmi_clk[i])) 844 - clk_put(omap->utmi_clk[i]); 845 - if (!IS_ERR(omap->hsic60m_clk[i])) 846 - clk_put(omap->hsic60m_clk[i]); 847 - if (!IS_ERR(omap->hsic480m_clk[i])) 848 - clk_put(omap->hsic480m_clk[i]); 849 - } 850 - 851 - clk_put(omap->init_60m_fclk); 852 - 853 - err_init60m: 854 - clk_put(omap->xclk60mhsp2_ck); 855 - 856 - err_xclk60mhsp2: 857 - clk_put(omap->xclk60mhsp1_ck); 858 - 859 - err_xclk60mhsp1: 860 - clk_put(omap->utmi_p2_gfclk); 861 - 862 - err_p2_gfclk: 863 - clk_put(omap->utmi_p1_gfclk); 864 - 865 - err_p1_gfclk: 866 - if (!IS_ERR(omap->ehci_logic_fck)) 867 - clk_put(omap->ehci_logic_fck); 868 800 869 801 err_mem: 870 802 pm_runtime_disable(dev); ··· 859 847 */ 860 848 static int usbhs_omap_remove(struct platform_device *pdev) 861 849 { 862 - struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); 863 - int i; 864 - 865 - for (i = 0; i < omap->nports; i++) { 866 - if (!IS_ERR(omap->utmi_clk[i])) 867 - clk_put(omap->utmi_clk[i]); 868 - if (!IS_ERR(omap->hsic60m_clk[i])) 869 - clk_put(omap->hsic60m_clk[i]); 870 - if (!IS_ERR(omap->hsic480m_clk[i])) 871 - clk_put(omap->hsic480m_clk[i]); 872 - } 873 - 874 - clk_put(omap->init_60m_fclk); 875 - clk_put(omap->utmi_p1_gfclk); 876 - clk_put(omap->utmi_p2_gfclk); 877 - clk_put(omap->xclk60mhsp2_ck); 878 - clk_put(omap->xclk60mhsp1_ck); 879 - 880 - if (!IS_ERR(omap->ehci_logic_fck)) 881 - clk_put(omap->ehci_logic_fck); 882 - 883 850 pm_runtime_disable(&pdev->dev); 884 851 885 852 /* remove children */
+1 -1
drivers/mfd/omap-usb-tll.c
··· 252 252 break; 253 253 } 254 254 255 - tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk * [tll->nch]), 255 + tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk *) * tll->nch, 256 256 GFP_KERNEL); 257 257 if (!tll->ch_clk) { 258 258 ret = -ENOMEM;
-1
drivers/mfd/pcf50633-adc.c
··· 19 19 #include <linux/kernel.h> 20 20 #include <linux/slab.h> 21 21 #include <linux/module.h> 22 - #include <linux/init.h> 23 22 #include <linux/device.h> 24 23 #include <linux/platform_device.h> 25 24 #include <linux/completion.h>
+365 -54
drivers/mfd/pm8921-core.c
··· 14 14 #define pr_fmt(fmt) "%s: " fmt, __func__ 15 15 16 16 #include <linux/kernel.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/irqchip/chained_irq.h> 19 + #include <linux/irq.h> 20 + #include <linux/irqdomain.h> 17 21 #include <linux/module.h> 18 22 #include <linux/platform_device.h> 19 23 #include <linux/slab.h> 20 24 #include <linux/err.h> 21 25 #include <linux/ssbi.h> 26 + #include <linux/regmap.h> 27 + #include <linux/of_platform.h> 22 28 #include <linux/mfd/core.h> 23 - #include <linux/mfd/pm8xxx/pm8921.h> 24 29 #include <linux/mfd/pm8xxx/core.h> 30 + 31 + #define SSBI_REG_ADDR_IRQ_BASE 0x1BB 32 + 33 + #define SSBI_REG_ADDR_IRQ_ROOT (SSBI_REG_ADDR_IRQ_BASE + 0) 34 + #define SSBI_REG_ADDR_IRQ_M_STATUS1 (SSBI_REG_ADDR_IRQ_BASE + 1) 35 + #define SSBI_REG_ADDR_IRQ_M_STATUS2 (SSBI_REG_ADDR_IRQ_BASE + 2) 36 + #define SSBI_REG_ADDR_IRQ_M_STATUS3 (SSBI_REG_ADDR_IRQ_BASE + 3) 37 + #define SSBI_REG_ADDR_IRQ_M_STATUS4 (SSBI_REG_ADDR_IRQ_BASE + 4) 38 + #define SSBI_REG_ADDR_IRQ_BLK_SEL (SSBI_REG_ADDR_IRQ_BASE + 5) 39 + #define SSBI_REG_ADDR_IRQ_IT_STATUS (SSBI_REG_ADDR_IRQ_BASE + 6) 40 + #define SSBI_REG_ADDR_IRQ_CONFIG (SSBI_REG_ADDR_IRQ_BASE + 7) 41 + #define SSBI_REG_ADDR_IRQ_RT_STATUS (SSBI_REG_ADDR_IRQ_BASE + 8) 42 + 43 + #define PM_IRQF_LVL_SEL 0x01 /* level select */ 44 + #define PM_IRQF_MASK_FE 0x02 /* mask falling edge */ 45 + #define PM_IRQF_MASK_RE 0x04 /* mask rising edge */ 46 + #define PM_IRQF_CLR 0x08 /* clear interrupt */ 47 + #define PM_IRQF_BITS_MASK 0x70 48 + #define PM_IRQF_BITS_SHIFT 4 49 + #define PM_IRQF_WRITE 0x80 50 + 51 + #define PM_IRQF_MASK_ALL (PM_IRQF_MASK_FE | \ 52 + PM_IRQF_MASK_RE) 25 53 26 54 #define REG_HWREV 0x002 /* PMIC4 revision */ 27 55 #define REG_HWREV_2 0x0E8 /* PMIC4 revision 2 */ 28 56 57 + #define PM8921_NR_IRQS 256 58 + 59 + struct pm_irq_chip { 60 + struct device *dev; 61 + struct regmap *regmap; 62 + spinlock_t pm_irq_lock; 63 + struct irq_domain *irqdomain; 64 + unsigned int num_irqs; 65 + unsigned int num_blocks; 66 + unsigned int num_masters; 67 + u8 config[0]; 68 + }; 69 + 29 70 struct pm8921 { 30 71 struct device *dev; 31 72 struct pm_irq_chip *irq_chip; 73 + }; 74 + 75 + static int pm8xxx_read_block_irq(struct pm_irq_chip *chip, unsigned int bp, 76 + unsigned int *ip) 77 + { 78 + int rc; 79 + 80 + spin_lock(&chip->pm_irq_lock); 81 + rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, bp); 82 + if (rc) { 83 + pr_err("Failed Selecting Block %d rc=%d\n", bp, rc); 84 + goto bail; 85 + } 86 + 87 + rc = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_IT_STATUS, ip); 88 + if (rc) 89 + pr_err("Failed Reading Status rc=%d\n", rc); 90 + bail: 91 + spin_unlock(&chip->pm_irq_lock); 92 + return rc; 93 + } 94 + 95 + static int 96 + pm8xxx_config_irq(struct pm_irq_chip *chip, unsigned int bp, unsigned int cp) 97 + { 98 + int rc; 99 + 100 + spin_lock(&chip->pm_irq_lock); 101 + rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, bp); 102 + if (rc) { 103 + pr_err("Failed Selecting Block %d rc=%d\n", bp, rc); 104 + goto bail; 105 + } 106 + 107 + cp |= PM_IRQF_WRITE; 108 + rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_CONFIG, cp); 109 + if (rc) 110 + pr_err("Failed Configuring IRQ rc=%d\n", rc); 111 + bail: 112 + spin_unlock(&chip->pm_irq_lock); 113 + return rc; 114 + } 115 + 116 + static int pm8xxx_irq_block_handler(struct pm_irq_chip *chip, int block) 117 + { 118 + int pmirq, irq, i, ret = 0; 119 + unsigned int bits; 120 + 121 + ret = pm8xxx_read_block_irq(chip, block, &bits); 122 + if (ret) { 123 + pr_err("Failed reading %d block ret=%d", block, ret); 124 + return ret; 125 + } 126 + if (!bits) { 127 + pr_err("block bit set in master but no irqs: %d", block); 128 + return 0; 129 + } 130 + 131 + /* Check IRQ bits */ 132 + for (i = 0; i < 8; i++) { 133 + if (bits & (1 << i)) { 134 + pmirq = block * 8 + i; 135 + irq = irq_find_mapping(chip->irqdomain, pmirq); 136 + generic_handle_irq(irq); 137 + } 138 + } 139 + return 0; 140 + } 141 + 142 + static int pm8xxx_irq_master_handler(struct pm_irq_chip *chip, int master) 143 + { 144 + unsigned int blockbits; 145 + int block_number, i, ret = 0; 146 + 147 + ret = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_M_STATUS1 + master, 148 + &blockbits); 149 + if (ret) { 150 + pr_err("Failed to read master %d ret=%d\n", master, ret); 151 + return ret; 152 + } 153 + if (!blockbits) { 154 + pr_err("master bit set in root but no blocks: %d", master); 155 + return 0; 156 + } 157 + 158 + for (i = 0; i < 8; i++) 159 + if (blockbits & (1 << i)) { 160 + block_number = master * 8 + i; /* block # */ 161 + ret |= pm8xxx_irq_block_handler(chip, block_number); 162 + } 163 + return ret; 164 + } 165 + 166 + static void pm8xxx_irq_handler(unsigned int irq, struct irq_desc *desc) 167 + { 168 + struct pm_irq_chip *chip = irq_desc_get_handler_data(desc); 169 + struct irq_chip *irq_chip = irq_desc_get_chip(desc); 170 + unsigned int root; 171 + int i, ret, masters = 0; 172 + 173 + chained_irq_enter(irq_chip, desc); 174 + 175 + ret = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_ROOT, &root); 176 + if (ret) { 177 + pr_err("Can't read root status ret=%d\n", ret); 178 + return; 179 + } 180 + 181 + /* on pm8xxx series masters start from bit 1 of the root */ 182 + masters = root >> 1; 183 + 184 + /* Read allowed masters for blocks. */ 185 + for (i = 0; i < chip->num_masters; i++) 186 + if (masters & (1 << i)) 187 + pm8xxx_irq_master_handler(chip, i); 188 + 189 + chained_irq_exit(irq_chip, desc); 190 + } 191 + 192 + static void pm8xxx_irq_mask_ack(struct irq_data *d) 193 + { 194 + struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); 195 + unsigned int pmirq = irqd_to_hwirq(d); 196 + int irq_bit; 197 + u8 block, config; 198 + 199 + block = pmirq / 8; 200 + irq_bit = pmirq % 8; 201 + 202 + config = chip->config[pmirq] | PM_IRQF_MASK_ALL | PM_IRQF_CLR; 203 + pm8xxx_config_irq(chip, block, config); 204 + } 205 + 206 + static void pm8xxx_irq_unmask(struct irq_data *d) 207 + { 208 + struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); 209 + unsigned int pmirq = irqd_to_hwirq(d); 210 + int irq_bit; 211 + u8 block, config; 212 + 213 + block = pmirq / 8; 214 + irq_bit = pmirq % 8; 215 + 216 + config = chip->config[pmirq]; 217 + pm8xxx_config_irq(chip, block, config); 218 + } 219 + 220 + static int pm8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type) 221 + { 222 + struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); 223 + unsigned int pmirq = irqd_to_hwirq(d); 224 + int irq_bit; 225 + u8 block, config; 226 + 227 + block = pmirq / 8; 228 + irq_bit = pmirq % 8; 229 + 230 + chip->config[pmirq] = (irq_bit << PM_IRQF_BITS_SHIFT) 231 + | PM_IRQF_MASK_ALL; 232 + if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) { 233 + if (flow_type & IRQF_TRIGGER_RISING) 234 + chip->config[pmirq] &= ~PM_IRQF_MASK_RE; 235 + if (flow_type & IRQF_TRIGGER_FALLING) 236 + chip->config[pmirq] &= ~PM_IRQF_MASK_FE; 237 + } else { 238 + chip->config[pmirq] |= PM_IRQF_LVL_SEL; 239 + 240 + if (flow_type & IRQF_TRIGGER_HIGH) 241 + chip->config[pmirq] &= ~PM_IRQF_MASK_RE; 242 + else 243 + chip->config[pmirq] &= ~PM_IRQF_MASK_FE; 244 + } 245 + 246 + config = chip->config[pmirq] | PM_IRQF_CLR; 247 + return pm8xxx_config_irq(chip, block, config); 248 + } 249 + 250 + static struct irq_chip pm8xxx_irq_chip = { 251 + .name = "pm8xxx", 252 + .irq_mask_ack = pm8xxx_irq_mask_ack, 253 + .irq_unmask = pm8xxx_irq_unmask, 254 + .irq_set_type = pm8xxx_irq_set_type, 255 + .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE, 256 + }; 257 + 258 + /** 259 + * pm8xxx_get_irq_stat - get the status of the irq line 260 + * @chip: pointer to identify a pmic irq controller 261 + * @irq: the irq number 262 + * 263 + * The pm8xxx gpio and mpp rely on the interrupt block to read 264 + * the values on their pins. This function is to facilitate reading 265 + * the status of a gpio or an mpp line. The caller has to convert the 266 + * gpio number to irq number. 267 + * 268 + * RETURNS: 269 + * an int indicating the value read on that line 270 + */ 271 + static int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq) 272 + { 273 + int pmirq, rc; 274 + unsigned int block, bits, bit; 275 + unsigned long flags; 276 + struct irq_data *irq_data = irq_get_irq_data(irq); 277 + 278 + pmirq = irq_data->hwirq; 279 + 280 + block = pmirq / 8; 281 + bit = pmirq % 8; 282 + 283 + spin_lock_irqsave(&chip->pm_irq_lock, flags); 284 + 285 + rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, block); 286 + if (rc) { 287 + pr_err("Failed Selecting block irq=%d pmirq=%d blk=%d rc=%d\n", 288 + irq, pmirq, block, rc); 289 + goto bail_out; 290 + } 291 + 292 + rc = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_RT_STATUS, &bits); 293 + if (rc) { 294 + pr_err("Failed Configuring irq=%d pmirq=%d blk=%d rc=%d\n", 295 + irq, pmirq, block, rc); 296 + goto bail_out; 297 + } 298 + 299 + rc = (bits & (1 << bit)) ? 1 : 0; 300 + 301 + bail_out: 302 + spin_unlock_irqrestore(&chip->pm_irq_lock, flags); 303 + 304 + return rc; 305 + } 306 + 307 + static int pm8xxx_irq_domain_map(struct irq_domain *d, unsigned int irq, 308 + irq_hw_number_t hwirq) 309 + { 310 + struct pm_irq_chip *chip = d->host_data; 311 + 312 + irq_set_chip_and_handler(irq, &pm8xxx_irq_chip, handle_level_irq); 313 + irq_set_chip_data(irq, chip); 314 + #ifdef CONFIG_ARM 315 + set_irq_flags(irq, IRQF_VALID); 316 + #else 317 + irq_set_noprobe(irq); 318 + #endif 319 + return 0; 320 + } 321 + 322 + static const struct irq_domain_ops pm8xxx_irq_domain_ops = { 323 + .xlate = irq_domain_xlate_twocell, 324 + .map = pm8xxx_irq_domain_map, 32 325 }; 33 326 34 327 static int pm8921_readb(const struct device *dev, u16 addr, u8 *val) ··· 374 81 .pmic_read_irq_stat = pm8921_read_irq_stat, 375 82 }; 376 83 377 - static int pm8921_add_subdevices(const struct pm8921_platform_data 378 - *pdata, 379 - struct pm8921 *pmic, 380 - u32 rev) 381 - { 382 - int ret = 0, irq_base = 0; 383 - struct pm_irq_chip *irq_chip; 84 + static const struct regmap_config ssbi_regmap_config = { 85 + .reg_bits = 16, 86 + .val_bits = 8, 87 + .max_register = 0x3ff, 88 + .fast_io = true, 89 + .reg_read = ssbi_reg_read, 90 + .reg_write = ssbi_reg_write 91 + }; 384 92 385 - if (pdata->irq_pdata) { 386 - pdata->irq_pdata->irq_cdata.nirqs = PM8921_NR_IRQS; 387 - pdata->irq_pdata->irq_cdata.rev = rev; 388 - irq_base = pdata->irq_pdata->irq_base; 389 - irq_chip = pm8xxx_irq_init(pmic->dev, pdata->irq_pdata); 390 - 391 - if (IS_ERR(irq_chip)) { 392 - pr_err("Failed to init interrupts ret=%ld\n", 393 - PTR_ERR(irq_chip)); 394 - return PTR_ERR(irq_chip); 395 - } 396 - pmic->irq_chip = irq_chip; 397 - } 398 - return ret; 399 - } 93 + static const struct of_device_id pm8921_id_table[] = { 94 + { .compatible = "qcom,pm8058", }, 95 + { .compatible = "qcom,pm8921", }, 96 + { } 97 + }; 98 + MODULE_DEVICE_TABLE(of, pm8921_id_table); 400 99 401 100 static int pm8921_probe(struct platform_device *pdev) 402 101 { 403 - const struct pm8921_platform_data *pdata = dev_get_platdata(&pdev->dev); 404 102 struct pm8921 *pmic; 405 - int rc; 406 - u8 val; 103 + struct regmap *regmap; 104 + int irq, rc; 105 + unsigned int val; 407 106 u32 rev; 107 + struct pm_irq_chip *chip; 108 + unsigned int nirqs = PM8921_NR_IRQS; 408 109 409 - if (!pdata) { 410 - pr_err("missing platform data\n"); 411 - return -EINVAL; 412 - } 110 + irq = platform_get_irq(pdev, 0); 111 + if (irq < 0) 112 + return irq; 413 113 414 114 pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8921), GFP_KERNEL); 415 115 if (!pmic) { ··· 410 124 return -ENOMEM; 411 125 } 412 126 127 + regmap = devm_regmap_init(&pdev->dev, NULL, pdev->dev.parent, 128 + &ssbi_regmap_config); 129 + if (IS_ERR(regmap)) 130 + return PTR_ERR(regmap); 131 + 413 132 /* Read PMIC chip revision */ 414 - rc = ssbi_read(pdev->dev.parent, REG_HWREV, &val, sizeof(val)); 133 + rc = regmap_read(regmap, REG_HWREV, &val); 415 134 if (rc) { 416 135 pr_err("Failed to read hw rev reg %d:rc=%d\n", REG_HWREV, rc); 417 136 return rc; ··· 425 134 rev = val; 426 135 427 136 /* Read PMIC chip revision 2 */ 428 - rc = ssbi_read(pdev->dev.parent, REG_HWREV_2, &val, sizeof(val)); 137 + rc = regmap_read(regmap, REG_HWREV_2, &val); 429 138 if (rc) { 430 139 pr_err("Failed to read hw rev 2 reg %d:rc=%d\n", 431 140 REG_HWREV_2, rc); ··· 438 147 pm8921_drvdata.pm_chip_data = pmic; 439 148 platform_set_drvdata(pdev, &pm8921_drvdata); 440 149 441 - rc = pm8921_add_subdevices(pdata, pmic, rev); 150 + chip = devm_kzalloc(&pdev->dev, sizeof(*chip) + 151 + sizeof(chip->config[0]) * nirqs, 152 + GFP_KERNEL); 153 + if (!chip) 154 + return -ENOMEM; 155 + 156 + pmic->irq_chip = chip; 157 + chip->dev = &pdev->dev; 158 + chip->regmap = regmap; 159 + chip->num_irqs = nirqs; 160 + chip->num_blocks = DIV_ROUND_UP(chip->num_irqs, 8); 161 + chip->num_masters = DIV_ROUND_UP(chip->num_blocks, 8); 162 + spin_lock_init(&chip->pm_irq_lock); 163 + 164 + chip->irqdomain = irq_domain_add_linear(pdev->dev.of_node, nirqs, 165 + &pm8xxx_irq_domain_ops, 166 + chip); 167 + if (!chip->irqdomain) 168 + return -ENODEV; 169 + 170 + irq_set_handler_data(irq, chip); 171 + irq_set_chained_handler(irq, pm8xxx_irq_handler); 172 + irq_set_irq_wake(irq, 1); 173 + 174 + rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); 442 175 if (rc) { 443 - pr_err("Cannot add subdevices rc=%d\n", rc); 444 - goto err; 176 + irq_set_chained_handler(irq, NULL); 177 + irq_set_handler_data(irq, NULL); 178 + irq_domain_remove(chip->irqdomain); 445 179 } 446 180 447 - /* gpio might not work if no irq device is found */ 448 - WARN_ON(pmic->irq_chip == NULL); 449 - 450 - return 0; 451 - 452 - err: 453 - mfd_remove_devices(pmic->dev); 454 181 return rc; 182 + } 183 + 184 + static int pm8921_remove_child(struct device *dev, void *unused) 185 + { 186 + platform_device_unregister(to_platform_device(dev)); 187 + return 0; 455 188 } 456 189 457 190 static int pm8921_remove(struct platform_device *pdev) 458 191 { 459 - struct pm8xxx_drvdata *drvdata; 460 - struct pm8921 *pmic = NULL; 192 + int irq = platform_get_irq(pdev, 0); 193 + struct pm8921 *pmic = pm8921_drvdata.pm_chip_data; 194 + struct pm_irq_chip *chip = pmic->irq_chip; 461 195 462 - drvdata = platform_get_drvdata(pdev); 463 - if (drvdata) 464 - pmic = drvdata->pm_chip_data; 465 - if (pmic) { 466 - mfd_remove_devices(pmic->dev); 467 - if (pmic->irq_chip) { 468 - pm8xxx_irq_exit(pmic->irq_chip); 469 - pmic->irq_chip = NULL; 470 - } 471 - } 196 + device_for_each_child(&pdev->dev, NULL, pm8921_remove_child); 197 + irq_set_chained_handler(irq, NULL); 198 + irq_set_handler_data(irq, NULL); 199 + irq_domain_remove(chip->irqdomain); 472 200 473 201 return 0; 474 202 } ··· 498 188 .driver = { 499 189 .name = "pm8921-core", 500 190 .owner = THIS_MODULE, 191 + .of_match_table = pm8921_id_table, 501 192 }, 502 193 }; 503 194
-371
drivers/mfd/pm8xxx-irq.c
··· 1 - /* 2 - * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 and 6 - * only version 2 as published by the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, 9 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 - * GNU General Public License for more details. 12 - */ 13 - 14 - #define pr_fmt(fmt) "%s: " fmt, __func__ 15 - 16 - #include <linux/err.h> 17 - #include <linux/interrupt.h> 18 - #include <linux/irq.h> 19 - #include <linux/kernel.h> 20 - #include <linux/mfd/pm8xxx/core.h> 21 - #include <linux/mfd/pm8xxx/irq.h> 22 - #include <linux/platform_device.h> 23 - #include <linux/slab.h> 24 - 25 - /* PMIC8xxx IRQ */ 26 - 27 - #define SSBI_REG_ADDR_IRQ_BASE 0x1BB 28 - 29 - #define SSBI_REG_ADDR_IRQ_ROOT (SSBI_REG_ADDR_IRQ_BASE + 0) 30 - #define SSBI_REG_ADDR_IRQ_M_STATUS1 (SSBI_REG_ADDR_IRQ_BASE + 1) 31 - #define SSBI_REG_ADDR_IRQ_M_STATUS2 (SSBI_REG_ADDR_IRQ_BASE + 2) 32 - #define SSBI_REG_ADDR_IRQ_M_STATUS3 (SSBI_REG_ADDR_IRQ_BASE + 3) 33 - #define SSBI_REG_ADDR_IRQ_M_STATUS4 (SSBI_REG_ADDR_IRQ_BASE + 4) 34 - #define SSBI_REG_ADDR_IRQ_BLK_SEL (SSBI_REG_ADDR_IRQ_BASE + 5) 35 - #define SSBI_REG_ADDR_IRQ_IT_STATUS (SSBI_REG_ADDR_IRQ_BASE + 6) 36 - #define SSBI_REG_ADDR_IRQ_CONFIG (SSBI_REG_ADDR_IRQ_BASE + 7) 37 - #define SSBI_REG_ADDR_IRQ_RT_STATUS (SSBI_REG_ADDR_IRQ_BASE + 8) 38 - 39 - #define PM_IRQF_LVL_SEL 0x01 /* level select */ 40 - #define PM_IRQF_MASK_FE 0x02 /* mask falling edge */ 41 - #define PM_IRQF_MASK_RE 0x04 /* mask rising edge */ 42 - #define PM_IRQF_CLR 0x08 /* clear interrupt */ 43 - #define PM_IRQF_BITS_MASK 0x70 44 - #define PM_IRQF_BITS_SHIFT 4 45 - #define PM_IRQF_WRITE 0x80 46 - 47 - #define PM_IRQF_MASK_ALL (PM_IRQF_MASK_FE | \ 48 - PM_IRQF_MASK_RE) 49 - 50 - struct pm_irq_chip { 51 - struct device *dev; 52 - spinlock_t pm_irq_lock; 53 - unsigned int devirq; 54 - unsigned int irq_base; 55 - unsigned int num_irqs; 56 - unsigned int num_blocks; 57 - unsigned int num_masters; 58 - u8 config[0]; 59 - }; 60 - 61 - static int pm8xxx_read_root_irq(const struct pm_irq_chip *chip, u8 *rp) 62 - { 63 - return pm8xxx_readb(chip->dev, SSBI_REG_ADDR_IRQ_ROOT, rp); 64 - } 65 - 66 - static int pm8xxx_read_master_irq(const struct pm_irq_chip *chip, u8 m, u8 *bp) 67 - { 68 - return pm8xxx_readb(chip->dev, 69 - SSBI_REG_ADDR_IRQ_M_STATUS1 + m, bp); 70 - } 71 - 72 - static int pm8xxx_read_block_irq(struct pm_irq_chip *chip, u8 bp, u8 *ip) 73 - { 74 - int rc; 75 - 76 - spin_lock(&chip->pm_irq_lock); 77 - rc = pm8xxx_writeb(chip->dev, SSBI_REG_ADDR_IRQ_BLK_SEL, bp); 78 - if (rc) { 79 - pr_err("Failed Selecting Block %d rc=%d\n", bp, rc); 80 - goto bail; 81 - } 82 - 83 - rc = pm8xxx_readb(chip->dev, SSBI_REG_ADDR_IRQ_IT_STATUS, ip); 84 - if (rc) 85 - pr_err("Failed Reading Status rc=%d\n", rc); 86 - bail: 87 - spin_unlock(&chip->pm_irq_lock); 88 - return rc; 89 - } 90 - 91 - static int pm8xxx_config_irq(struct pm_irq_chip *chip, u8 bp, u8 cp) 92 - { 93 - int rc; 94 - 95 - spin_lock(&chip->pm_irq_lock); 96 - rc = pm8xxx_writeb(chip->dev, SSBI_REG_ADDR_IRQ_BLK_SEL, bp); 97 - if (rc) { 98 - pr_err("Failed Selecting Block %d rc=%d\n", bp, rc); 99 - goto bail; 100 - } 101 - 102 - cp |= PM_IRQF_WRITE; 103 - rc = pm8xxx_writeb(chip->dev, SSBI_REG_ADDR_IRQ_CONFIG, cp); 104 - if (rc) 105 - pr_err("Failed Configuring IRQ rc=%d\n", rc); 106 - bail: 107 - spin_unlock(&chip->pm_irq_lock); 108 - return rc; 109 - } 110 - 111 - static int pm8xxx_irq_block_handler(struct pm_irq_chip *chip, int block) 112 - { 113 - int pmirq, irq, i, ret = 0; 114 - u8 bits; 115 - 116 - ret = pm8xxx_read_block_irq(chip, block, &bits); 117 - if (ret) { 118 - pr_err("Failed reading %d block ret=%d", block, ret); 119 - return ret; 120 - } 121 - if (!bits) { 122 - pr_err("block bit set in master but no irqs: %d", block); 123 - return 0; 124 - } 125 - 126 - /* Check IRQ bits */ 127 - for (i = 0; i < 8; i++) { 128 - if (bits & (1 << i)) { 129 - pmirq = block * 8 + i; 130 - irq = pmirq + chip->irq_base; 131 - generic_handle_irq(irq); 132 - } 133 - } 134 - return 0; 135 - } 136 - 137 - static int pm8xxx_irq_master_handler(struct pm_irq_chip *chip, int master) 138 - { 139 - u8 blockbits; 140 - int block_number, i, ret = 0; 141 - 142 - ret = pm8xxx_read_master_irq(chip, master, &blockbits); 143 - if (ret) { 144 - pr_err("Failed to read master %d ret=%d\n", master, ret); 145 - return ret; 146 - } 147 - if (!blockbits) { 148 - pr_err("master bit set in root but no blocks: %d", master); 149 - return 0; 150 - } 151 - 152 - for (i = 0; i < 8; i++) 153 - if (blockbits & (1 << i)) { 154 - block_number = master * 8 + i; /* block # */ 155 - ret |= pm8xxx_irq_block_handler(chip, block_number); 156 - } 157 - return ret; 158 - } 159 - 160 - static void pm8xxx_irq_handler(unsigned int irq, struct irq_desc *desc) 161 - { 162 - struct pm_irq_chip *chip = irq_desc_get_handler_data(desc); 163 - struct irq_chip *irq_chip = irq_desc_get_chip(desc); 164 - u8 root; 165 - int i, ret, masters = 0; 166 - 167 - ret = pm8xxx_read_root_irq(chip, &root); 168 - if (ret) { 169 - pr_err("Can't read root status ret=%d\n", ret); 170 - return; 171 - } 172 - 173 - /* on pm8xxx series masters start from bit 1 of the root */ 174 - masters = root >> 1; 175 - 176 - /* Read allowed masters for blocks. */ 177 - for (i = 0; i < chip->num_masters; i++) 178 - if (masters & (1 << i)) 179 - pm8xxx_irq_master_handler(chip, i); 180 - 181 - irq_chip->irq_ack(&desc->irq_data); 182 - } 183 - 184 - static void pm8xxx_irq_mask_ack(struct irq_data *d) 185 - { 186 - struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); 187 - unsigned int pmirq = d->irq - chip->irq_base; 188 - int master, irq_bit; 189 - u8 block, config; 190 - 191 - block = pmirq / 8; 192 - master = block / 8; 193 - irq_bit = pmirq % 8; 194 - 195 - config = chip->config[pmirq] | PM_IRQF_MASK_ALL | PM_IRQF_CLR; 196 - pm8xxx_config_irq(chip, block, config); 197 - } 198 - 199 - static void pm8xxx_irq_unmask(struct irq_data *d) 200 - { 201 - struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); 202 - unsigned int pmirq = d->irq - chip->irq_base; 203 - int master, irq_bit; 204 - u8 block, config; 205 - 206 - block = pmirq / 8; 207 - master = block / 8; 208 - irq_bit = pmirq % 8; 209 - 210 - config = chip->config[pmirq]; 211 - pm8xxx_config_irq(chip, block, config); 212 - } 213 - 214 - static int pm8xxx_irq_set_type(struct irq_data *d, unsigned int flow_type) 215 - { 216 - struct pm_irq_chip *chip = irq_data_get_irq_chip_data(d); 217 - unsigned int pmirq = d->irq - chip->irq_base; 218 - int master, irq_bit; 219 - u8 block, config; 220 - 221 - block = pmirq / 8; 222 - master = block / 8; 223 - irq_bit = pmirq % 8; 224 - 225 - chip->config[pmirq] = (irq_bit << PM_IRQF_BITS_SHIFT) 226 - | PM_IRQF_MASK_ALL; 227 - if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) { 228 - if (flow_type & IRQF_TRIGGER_RISING) 229 - chip->config[pmirq] &= ~PM_IRQF_MASK_RE; 230 - if (flow_type & IRQF_TRIGGER_FALLING) 231 - chip->config[pmirq] &= ~PM_IRQF_MASK_FE; 232 - } else { 233 - chip->config[pmirq] |= PM_IRQF_LVL_SEL; 234 - 235 - if (flow_type & IRQF_TRIGGER_HIGH) 236 - chip->config[pmirq] &= ~PM_IRQF_MASK_RE; 237 - else 238 - chip->config[pmirq] &= ~PM_IRQF_MASK_FE; 239 - } 240 - 241 - config = chip->config[pmirq] | PM_IRQF_CLR; 242 - return pm8xxx_config_irq(chip, block, config); 243 - } 244 - 245 - static int pm8xxx_irq_set_wake(struct irq_data *d, unsigned int on) 246 - { 247 - return 0; 248 - } 249 - 250 - static struct irq_chip pm8xxx_irq_chip = { 251 - .name = "pm8xxx", 252 - .irq_mask_ack = pm8xxx_irq_mask_ack, 253 - .irq_unmask = pm8xxx_irq_unmask, 254 - .irq_set_type = pm8xxx_irq_set_type, 255 - .irq_set_wake = pm8xxx_irq_set_wake, 256 - .flags = IRQCHIP_MASK_ON_SUSPEND, 257 - }; 258 - 259 - /** 260 - * pm8xxx_get_irq_stat - get the status of the irq line 261 - * @chip: pointer to identify a pmic irq controller 262 - * @irq: the irq number 263 - * 264 - * The pm8xxx gpio and mpp rely on the interrupt block to read 265 - * the values on their pins. This function is to facilitate reading 266 - * the status of a gpio or an mpp line. The caller has to convert the 267 - * gpio number to irq number. 268 - * 269 - * RETURNS: 270 - * an int indicating the value read on that line 271 - */ 272 - int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq) 273 - { 274 - int pmirq, rc; 275 - u8 block, bits, bit; 276 - unsigned long flags; 277 - 278 - if (chip == NULL || irq < chip->irq_base || 279 - irq >= chip->irq_base + chip->num_irqs) 280 - return -EINVAL; 281 - 282 - pmirq = irq - chip->irq_base; 283 - 284 - block = pmirq / 8; 285 - bit = pmirq % 8; 286 - 287 - spin_lock_irqsave(&chip->pm_irq_lock, flags); 288 - 289 - rc = pm8xxx_writeb(chip->dev, SSBI_REG_ADDR_IRQ_BLK_SEL, block); 290 - if (rc) { 291 - pr_err("Failed Selecting block irq=%d pmirq=%d blk=%d rc=%d\n", 292 - irq, pmirq, block, rc); 293 - goto bail_out; 294 - } 295 - 296 - rc = pm8xxx_readb(chip->dev, SSBI_REG_ADDR_IRQ_RT_STATUS, &bits); 297 - if (rc) { 298 - pr_err("Failed Configuring irq=%d pmirq=%d blk=%d rc=%d\n", 299 - irq, pmirq, block, rc); 300 - goto bail_out; 301 - } 302 - 303 - rc = (bits & (1 << bit)) ? 1 : 0; 304 - 305 - bail_out: 306 - spin_unlock_irqrestore(&chip->pm_irq_lock, flags); 307 - 308 - return rc; 309 - } 310 - EXPORT_SYMBOL_GPL(pm8xxx_get_irq_stat); 311 - 312 - struct pm_irq_chip * pm8xxx_irq_init(struct device *dev, 313 - const struct pm8xxx_irq_platform_data *pdata) 314 - { 315 - struct pm_irq_chip *chip; 316 - int devirq, rc; 317 - unsigned int pmirq; 318 - 319 - if (!pdata) { 320 - pr_err("No platform data\n"); 321 - return ERR_PTR(-EINVAL); 322 - } 323 - 324 - devirq = pdata->devirq; 325 - if (devirq < 0) { 326 - pr_err("missing devirq\n"); 327 - rc = devirq; 328 - return ERR_PTR(-EINVAL); 329 - } 330 - 331 - chip = kzalloc(sizeof(struct pm_irq_chip) 332 - + sizeof(u8) * pdata->irq_cdata.nirqs, GFP_KERNEL); 333 - if (!chip) { 334 - pr_err("Cannot alloc pm_irq_chip struct\n"); 335 - return ERR_PTR(-EINVAL); 336 - } 337 - 338 - chip->dev = dev; 339 - chip->devirq = devirq; 340 - chip->irq_base = pdata->irq_base; 341 - chip->num_irqs = pdata->irq_cdata.nirqs; 342 - chip->num_blocks = DIV_ROUND_UP(chip->num_irqs, 8); 343 - chip->num_masters = DIV_ROUND_UP(chip->num_blocks, 8); 344 - spin_lock_init(&chip->pm_irq_lock); 345 - 346 - for (pmirq = 0; pmirq < chip->num_irqs; pmirq++) { 347 - irq_set_chip_and_handler(chip->irq_base + pmirq, 348 - &pm8xxx_irq_chip, 349 - handle_level_irq); 350 - irq_set_chip_data(chip->irq_base + pmirq, chip); 351 - #ifdef CONFIG_ARM 352 - set_irq_flags(chip->irq_base + pmirq, IRQF_VALID); 353 - #else 354 - irq_set_noprobe(chip->irq_base + pmirq); 355 - #endif 356 - } 357 - 358 - irq_set_irq_type(devirq, pdata->irq_trigger_flag); 359 - irq_set_handler_data(devirq, chip); 360 - irq_set_chained_handler(devirq, pm8xxx_irq_handler); 361 - set_irq_wake(devirq, 1); 362 - 363 - return chip; 364 - } 365 - 366 - int pm8xxx_irq_exit(struct pm_irq_chip *chip) 367 - { 368 - irq_set_chained_handler(chip->devirq, NULL); 369 - kfree(chip); 370 - return 0; 371 - }
-1
drivers/mfd/rc5t583-irq.c
··· 22 22 */ 23 23 #include <linux/interrupt.h> 24 24 #include <linux/irq.h> 25 - #include <linux/init.h> 26 25 #include <linux/i2c.h> 27 26 #include <linux/mfd/rc5t583.h> 28 27
-1
drivers/mfd/rdc321x-southbridge.c
··· 19 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 20 * 21 21 */ 22 - #include <linux/init.h> 23 22 #include <linux/module.h> 24 23 #include <linux/kernel.h> 25 24 #include <linux/platform_device.h>
-1
drivers/mfd/retu-mfd.c
··· 19 19 #include <linux/err.h> 20 20 #include <linux/i2c.h> 21 21 #include <linux/irq.h> 22 - #include <linux/init.h> 23 22 #include <linux/slab.h> 24 23 #include <linux/mutex.h> 25 24 #include <linux/module.h>
+760
drivers/mfd/rtsx_usb.c
··· 1 + /* Driver for Realtek USB card reader 2 + * 3 + * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License version 2 7 + * as published by the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope that it will be useful, but 10 + * WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 + * General Public License for more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along 15 + * with this program; if not, see <http://www.gnu.org/licenses/>. 16 + * 17 + * Author: 18 + * Roger Tseng <rogerable@realtek.com> 19 + */ 20 + #include <linux/module.h> 21 + #include <linux/slab.h> 22 + #include <linux/mutex.h> 23 + #include <linux/usb.h> 24 + #include <linux/platform_device.h> 25 + #include <linux/mfd/core.h> 26 + #include <linux/mfd/rtsx_usb.h> 27 + 28 + static int polling_pipe = 1; 29 + module_param(polling_pipe, int, S_IRUGO | S_IWUSR); 30 + MODULE_PARM_DESC(polling_pipe, "polling pipe (0: ctl, 1: bulk)"); 31 + 32 + static struct mfd_cell rtsx_usb_cells[] = { 33 + [RTSX_USB_SD_CARD] = { 34 + .name = "rtsx_usb_sdmmc", 35 + .pdata_size = 0, 36 + }, 37 + [RTSX_USB_MS_CARD] = { 38 + .name = "rtsx_usb_ms", 39 + .pdata_size = 0, 40 + }, 41 + }; 42 + 43 + static void rtsx_usb_sg_timed_out(unsigned long data) 44 + { 45 + struct rtsx_ucr *ucr = (struct rtsx_ucr *)data; 46 + 47 + dev_dbg(&ucr->pusb_intf->dev, "%s: sg transfer timed out", __func__); 48 + usb_sg_cancel(&ucr->current_sg); 49 + 50 + /* we know the cancellation is caused by time-out */ 51 + ucr->current_sg.status = -ETIMEDOUT; 52 + } 53 + 54 + static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr, 55 + unsigned int pipe, struct scatterlist *sg, int num_sg, 56 + unsigned int length, unsigned int *act_len, int timeout) 57 + { 58 + int ret; 59 + 60 + dev_dbg(&ucr->pusb_intf->dev, "%s: xfer %u bytes, %d entries\n", 61 + __func__, length, num_sg); 62 + ret = usb_sg_init(&ucr->current_sg, ucr->pusb_dev, pipe, 0, 63 + sg, num_sg, length, GFP_NOIO); 64 + if (ret) 65 + return ret; 66 + 67 + ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout); 68 + add_timer(&ucr->sg_timer); 69 + usb_sg_wait(&ucr->current_sg); 70 + del_timer(&ucr->sg_timer); 71 + 72 + if (act_len) 73 + *act_len = ucr->current_sg.bytes; 74 + 75 + return ucr->current_sg.status; 76 + } 77 + 78 + int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe, 79 + void *buf, unsigned int len, int num_sg, 80 + unsigned int *act_len, int timeout) 81 + { 82 + if (timeout < 600) 83 + timeout = 600; 84 + 85 + if (num_sg) 86 + return rtsx_usb_bulk_transfer_sglist(ucr, pipe, 87 + (struct scatterlist *)buf, num_sg, len, act_len, 88 + timeout); 89 + else 90 + return usb_bulk_msg(ucr->pusb_dev, pipe, buf, len, act_len, 91 + timeout); 92 + } 93 + EXPORT_SYMBOL_GPL(rtsx_usb_transfer_data); 94 + 95 + static inline void rtsx_usb_seq_cmd_hdr(struct rtsx_ucr *ucr, 96 + u16 addr, u16 len, u8 seq_type) 97 + { 98 + rtsx_usb_cmd_hdr_tag(ucr); 99 + 100 + ucr->cmd_buf[PACKET_TYPE] = seq_type; 101 + ucr->cmd_buf[5] = (u8)(len >> 8); 102 + ucr->cmd_buf[6] = (u8)len; 103 + ucr->cmd_buf[8] = (u8)(addr >> 8); 104 + ucr->cmd_buf[9] = (u8)addr; 105 + 106 + if (seq_type == SEQ_WRITE) 107 + ucr->cmd_buf[STAGE_FLAG] = 0; 108 + else 109 + ucr->cmd_buf[STAGE_FLAG] = STAGE_R; 110 + } 111 + 112 + static int rtsx_usb_seq_write_register(struct rtsx_ucr *ucr, 113 + u16 addr, u16 len, u8 *data) 114 + { 115 + u16 cmd_len = ALIGN(SEQ_WRITE_DATA_OFFSET + len, 4); 116 + 117 + if (!data) 118 + return -EINVAL; 119 + 120 + if (cmd_len > IOBUF_SIZE) 121 + return -EINVAL; 122 + 123 + rtsx_usb_seq_cmd_hdr(ucr, addr, len, SEQ_WRITE); 124 + memcpy(ucr->cmd_buf + SEQ_WRITE_DATA_OFFSET, data, len); 125 + 126 + return rtsx_usb_transfer_data(ucr, 127 + usb_sndbulkpipe(ucr->pusb_dev, EP_BULK_OUT), 128 + ucr->cmd_buf, cmd_len, 0, NULL, 100); 129 + } 130 + 131 + static int rtsx_usb_seq_read_register(struct rtsx_ucr *ucr, 132 + u16 addr, u16 len, u8 *data) 133 + { 134 + int i, ret; 135 + u16 rsp_len = round_down(len, 4); 136 + u16 res_len = len - rsp_len; 137 + 138 + if (!data) 139 + return -EINVAL; 140 + 141 + /* 4-byte aligned part */ 142 + if (rsp_len) { 143 + rtsx_usb_seq_cmd_hdr(ucr, addr, len, SEQ_READ); 144 + ret = rtsx_usb_transfer_data(ucr, 145 + usb_sndbulkpipe(ucr->pusb_dev, EP_BULK_OUT), 146 + ucr->cmd_buf, 12, 0, NULL, 100); 147 + if (ret) 148 + return ret; 149 + 150 + ret = rtsx_usb_transfer_data(ucr, 151 + usb_rcvbulkpipe(ucr->pusb_dev, EP_BULK_IN), 152 + data, rsp_len, 0, NULL, 100); 153 + if (ret) 154 + return ret; 155 + } 156 + 157 + /* unaligned part */ 158 + for (i = 0; i < res_len; i++) { 159 + ret = rtsx_usb_read_register(ucr, addr + rsp_len + i, 160 + data + rsp_len + i); 161 + if (ret) 162 + return ret; 163 + } 164 + 165 + return 0; 166 + } 167 + 168 + int rtsx_usb_read_ppbuf(struct rtsx_ucr *ucr, u8 *buf, int buf_len) 169 + { 170 + return rtsx_usb_seq_read_register(ucr, PPBUF_BASE2, (u16)buf_len, buf); 171 + } 172 + EXPORT_SYMBOL_GPL(rtsx_usb_read_ppbuf); 173 + 174 + int rtsx_usb_write_ppbuf(struct rtsx_ucr *ucr, u8 *buf, int buf_len) 175 + { 176 + return rtsx_usb_seq_write_register(ucr, PPBUF_BASE2, (u16)buf_len, buf); 177 + } 178 + EXPORT_SYMBOL_GPL(rtsx_usb_write_ppbuf); 179 + 180 + int rtsx_usb_ep0_write_register(struct rtsx_ucr *ucr, u16 addr, 181 + u8 mask, u8 data) 182 + { 183 + u16 value, index; 184 + 185 + addr |= EP0_WRITE_REG_CMD << EP0_OP_SHIFT; 186 + value = swab16(addr); 187 + index = mask | data << 8; 188 + 189 + return usb_control_msg(ucr->pusb_dev, 190 + usb_sndctrlpipe(ucr->pusb_dev, 0), RTSX_USB_REQ_REG_OP, 191 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 192 + value, index, NULL, 0, 100); 193 + } 194 + EXPORT_SYMBOL_GPL(rtsx_usb_ep0_write_register); 195 + 196 + int rtsx_usb_ep0_read_register(struct rtsx_ucr *ucr, u16 addr, u8 *data) 197 + { 198 + u16 value; 199 + 200 + if (!data) 201 + return -EINVAL; 202 + *data = 0; 203 + 204 + addr |= EP0_READ_REG_CMD << EP0_OP_SHIFT; 205 + value = swab16(addr); 206 + 207 + return usb_control_msg(ucr->pusb_dev, 208 + usb_rcvctrlpipe(ucr->pusb_dev, 0), RTSX_USB_REQ_REG_OP, 209 + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 210 + value, 0, data, 1, 100); 211 + } 212 + EXPORT_SYMBOL_GPL(rtsx_usb_ep0_read_register); 213 + 214 + void rtsx_usb_add_cmd(struct rtsx_ucr *ucr, u8 cmd_type, u16 reg_addr, 215 + u8 mask, u8 data) 216 + { 217 + int i; 218 + 219 + if (ucr->cmd_idx < (IOBUF_SIZE - CMD_OFFSET) / 4) { 220 + i = CMD_OFFSET + ucr->cmd_idx * 4; 221 + 222 + ucr->cmd_buf[i++] = ((cmd_type & 0x03) << 6) | 223 + (u8)((reg_addr >> 8) & 0x3F); 224 + ucr->cmd_buf[i++] = (u8)reg_addr; 225 + ucr->cmd_buf[i++] = mask; 226 + ucr->cmd_buf[i++] = data; 227 + 228 + ucr->cmd_idx++; 229 + } 230 + } 231 + EXPORT_SYMBOL_GPL(rtsx_usb_add_cmd); 232 + 233 + int rtsx_usb_send_cmd(struct rtsx_ucr *ucr, u8 flag, int timeout) 234 + { 235 + int ret; 236 + 237 + ucr->cmd_buf[CNT_H] = (u8)(ucr->cmd_idx >> 8); 238 + ucr->cmd_buf[CNT_L] = (u8)(ucr->cmd_idx); 239 + ucr->cmd_buf[STAGE_FLAG] = flag; 240 + 241 + ret = rtsx_usb_transfer_data(ucr, 242 + usb_sndbulkpipe(ucr->pusb_dev, EP_BULK_OUT), 243 + ucr->cmd_buf, ucr->cmd_idx * 4 + CMD_OFFSET, 244 + 0, NULL, timeout); 245 + if (ret) { 246 + rtsx_usb_clear_fsm_err(ucr); 247 + return ret; 248 + } 249 + 250 + return 0; 251 + } 252 + EXPORT_SYMBOL_GPL(rtsx_usb_send_cmd); 253 + 254 + int rtsx_usb_get_rsp(struct rtsx_ucr *ucr, int rsp_len, int timeout) 255 + { 256 + if (rsp_len <= 0) 257 + return -EINVAL; 258 + 259 + rsp_len = ALIGN(rsp_len, 4); 260 + 261 + return rtsx_usb_transfer_data(ucr, 262 + usb_rcvbulkpipe(ucr->pusb_dev, EP_BULK_IN), 263 + ucr->rsp_buf, rsp_len, 0, NULL, timeout); 264 + } 265 + EXPORT_SYMBOL_GPL(rtsx_usb_get_rsp); 266 + 267 + static int rtsx_usb_get_status_with_bulk(struct rtsx_ucr *ucr, u16 *status) 268 + { 269 + int ret; 270 + 271 + rtsx_usb_init_cmd(ucr); 272 + rtsx_usb_add_cmd(ucr, READ_REG_CMD, CARD_EXIST, 0x00, 0x00); 273 + rtsx_usb_add_cmd(ucr, READ_REG_CMD, OCPSTAT, 0x00, 0x00); 274 + ret = rtsx_usb_send_cmd(ucr, MODE_CR, 100); 275 + if (ret) 276 + return ret; 277 + 278 + ret = rtsx_usb_get_rsp(ucr, 2, 100); 279 + if (ret) 280 + return ret; 281 + 282 + *status = ((ucr->rsp_buf[0] >> 2) & 0x0f) | 283 + ((ucr->rsp_buf[1] & 0x03) << 4); 284 + 285 + return 0; 286 + } 287 + 288 + int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status) 289 + { 290 + int ret; 291 + 292 + if (!status) 293 + return -EINVAL; 294 + 295 + if (polling_pipe == 0) 296 + ret = usb_control_msg(ucr->pusb_dev, 297 + usb_rcvctrlpipe(ucr->pusb_dev, 0), 298 + RTSX_USB_REQ_POLL, 299 + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 300 + 0, 0, status, 2, 100); 301 + else 302 + ret = rtsx_usb_get_status_with_bulk(ucr, status); 303 + 304 + /* usb_control_msg may return positive when success */ 305 + if (ret < 0) 306 + return ret; 307 + 308 + return 0; 309 + } 310 + EXPORT_SYMBOL_GPL(rtsx_usb_get_card_status); 311 + 312 + static int rtsx_usb_write_phy_register(struct rtsx_ucr *ucr, u8 addr, u8 val) 313 + { 314 + dev_dbg(&ucr->pusb_intf->dev, "Write 0x%x to phy register 0x%x\n", 315 + val, addr); 316 + 317 + rtsx_usb_init_cmd(ucr); 318 + 319 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VSTAIN, 0xFF, val); 320 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VCONTROL, 0xFF, addr & 0x0F); 321 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); 322 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); 323 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); 324 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VCONTROL, 325 + 0xFF, (addr >> 4) & 0x0F); 326 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); 327 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x00); 328 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, HS_VLOADM, 0xFF, 0x01); 329 + 330 + return rtsx_usb_send_cmd(ucr, MODE_C, 100); 331 + } 332 + 333 + int rtsx_usb_write_register(struct rtsx_ucr *ucr, u16 addr, u8 mask, u8 data) 334 + { 335 + rtsx_usb_init_cmd(ucr); 336 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, addr, mask, data); 337 + return rtsx_usb_send_cmd(ucr, MODE_C, 100); 338 + } 339 + EXPORT_SYMBOL_GPL(rtsx_usb_write_register); 340 + 341 + int rtsx_usb_read_register(struct rtsx_ucr *ucr, u16 addr, u8 *data) 342 + { 343 + int ret; 344 + 345 + if (data != NULL) 346 + *data = 0; 347 + 348 + rtsx_usb_init_cmd(ucr); 349 + rtsx_usb_add_cmd(ucr, READ_REG_CMD, addr, 0, 0); 350 + ret = rtsx_usb_send_cmd(ucr, MODE_CR, 100); 351 + if (ret) 352 + return ret; 353 + 354 + ret = rtsx_usb_get_rsp(ucr, 1, 100); 355 + if (ret) 356 + return ret; 357 + 358 + if (data != NULL) 359 + *data = ucr->rsp_buf[0]; 360 + 361 + return 0; 362 + } 363 + EXPORT_SYMBOL_GPL(rtsx_usb_read_register); 364 + 365 + static inline u8 double_ssc_depth(u8 depth) 366 + { 367 + return (depth > 1) ? (depth - 1) : depth; 368 + } 369 + 370 + static u8 revise_ssc_depth(u8 ssc_depth, u8 div) 371 + { 372 + if (div > CLK_DIV_1) { 373 + if (ssc_depth > div - 1) 374 + ssc_depth -= (div - 1); 375 + else 376 + ssc_depth = SSC_DEPTH_2M; 377 + } 378 + 379 + return ssc_depth; 380 + } 381 + 382 + int rtsx_usb_switch_clock(struct rtsx_ucr *ucr, unsigned int card_clock, 383 + u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk) 384 + { 385 + int ret; 386 + u8 n, clk_divider, mcu_cnt, div; 387 + 388 + if (!card_clock) { 389 + ucr->cur_clk = 0; 390 + return 0; 391 + } 392 + 393 + if (initial_mode) { 394 + /* We use 250k(around) here, in initial stage */ 395 + clk_divider = SD_CLK_DIVIDE_128; 396 + card_clock = 30000000; 397 + } else { 398 + clk_divider = SD_CLK_DIVIDE_0; 399 + } 400 + 401 + ret = rtsx_usb_write_register(ucr, SD_CFG1, 402 + SD_CLK_DIVIDE_MASK, clk_divider); 403 + if (ret < 0) 404 + return ret; 405 + 406 + card_clock /= 1000000; 407 + dev_dbg(&ucr->pusb_intf->dev, 408 + "Switch card clock to %dMHz\n", card_clock); 409 + 410 + if (!initial_mode && double_clk) 411 + card_clock *= 2; 412 + dev_dbg(&ucr->pusb_intf->dev, 413 + "Internal SSC clock: %dMHz (cur_clk = %d)\n", 414 + card_clock, ucr->cur_clk); 415 + 416 + if (card_clock == ucr->cur_clk) 417 + return 0; 418 + 419 + /* Converting clock value into internal settings: n and div */ 420 + n = card_clock - 2; 421 + if ((card_clock <= 2) || (n > MAX_DIV_N)) 422 + return -EINVAL; 423 + 424 + mcu_cnt = 60/card_clock + 3; 425 + if (mcu_cnt > 15) 426 + mcu_cnt = 15; 427 + 428 + /* Make sure that the SSC clock div_n is not less than MIN_DIV_N */ 429 + 430 + div = CLK_DIV_1; 431 + while (n < MIN_DIV_N && div < CLK_DIV_4) { 432 + n = (n + 2) * 2 - 2; 433 + div++; 434 + } 435 + dev_dbg(&ucr->pusb_intf->dev, "n = %d, div = %d\n", n, div); 436 + 437 + if (double_clk) 438 + ssc_depth = double_ssc_depth(ssc_depth); 439 + 440 + ssc_depth = revise_ssc_depth(ssc_depth, div); 441 + dev_dbg(&ucr->pusb_intf->dev, "ssc_depth = %d\n", ssc_depth); 442 + 443 + rtsx_usb_init_cmd(ucr); 444 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CLK_DIV, CLK_CHANGE, CLK_CHANGE); 445 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CLK_DIV, 446 + 0x3F, (div << 4) | mcu_cnt); 447 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, 0); 448 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_CTL2, 449 + SSC_DEPTH_MASK, ssc_depth); 450 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_DIV_N_0, 0xFF, n); 451 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SSC_CTL1, SSC_RSTB, SSC_RSTB); 452 + if (vpclk) { 453 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SD_VPCLK0_CTL, 454 + PHASE_NOT_RESET, 0); 455 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SD_VPCLK0_CTL, 456 + PHASE_NOT_RESET, PHASE_NOT_RESET); 457 + } 458 + 459 + ret = rtsx_usb_send_cmd(ucr, MODE_C, 2000); 460 + if (ret < 0) 461 + return ret; 462 + 463 + ret = rtsx_usb_write_register(ucr, SSC_CTL1, 0xff, 464 + SSC_RSTB | SSC_8X_EN | SSC_SEL_4M); 465 + if (ret < 0) 466 + return ret; 467 + 468 + /* Wait SSC clock stable */ 469 + usleep_range(100, 1000); 470 + 471 + ret = rtsx_usb_write_register(ucr, CLK_DIV, CLK_CHANGE, 0); 472 + if (ret < 0) 473 + return ret; 474 + 475 + ucr->cur_clk = card_clock; 476 + 477 + return 0; 478 + } 479 + EXPORT_SYMBOL_GPL(rtsx_usb_switch_clock); 480 + 481 + int rtsx_usb_card_exclusive_check(struct rtsx_ucr *ucr, int card) 482 + { 483 + int ret; 484 + u16 val; 485 + u16 cd_mask[] = { 486 + [RTSX_USB_SD_CARD] = (CD_MASK & ~SD_CD), 487 + [RTSX_USB_MS_CARD] = (CD_MASK & ~MS_CD) 488 + }; 489 + 490 + ret = rtsx_usb_get_card_status(ucr, &val); 491 + /* 492 + * If get status fails, return 0 (ok) for the exclusive check 493 + * and let the flow fail at somewhere else. 494 + */ 495 + if (ret) 496 + return 0; 497 + 498 + if (val & cd_mask[card]) 499 + return -EIO; 500 + 501 + return 0; 502 + } 503 + EXPORT_SYMBOL_GPL(rtsx_usb_card_exclusive_check); 504 + 505 + static int rtsx_usb_reset_chip(struct rtsx_ucr *ucr) 506 + { 507 + int ret; 508 + u8 val; 509 + 510 + rtsx_usb_init_cmd(ucr); 511 + 512 + if (CHECK_PKG(ucr, LQFP48)) { 513 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL, 514 + LDO3318_PWR_MASK, LDO_SUSPEND); 515 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PWR_CTL, 516 + FORCE_LDO_POWERB, FORCE_LDO_POWERB); 517 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL1, 518 + 0x30, 0x10); 519 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL5, 520 + 0x03, 0x01); 521 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_PULL_CTL6, 522 + 0x0C, 0x04); 523 + } 524 + 525 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SYS_DUMMY0, NYET_MSAK, NYET_EN); 526 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CD_DEGLITCH_WIDTH, 0xFF, 0x08); 527 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, 528 + CD_DEGLITCH_EN, XD_CD_DEGLITCH_EN, 0x0); 529 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, SD30_DRIVE_SEL, 530 + SD30_DRIVE_MASK, DRIVER_TYPE_D); 531 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, 532 + CARD_DRIVE_SEL, SD20_DRIVE_MASK, 0x0); 533 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, LDO_POWER_CFG, 0xE0, 0x0); 534 + 535 + if (ucr->is_rts5179) 536 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, 537 + CARD_PULL_CTL5, 0x03, 0x01); 538 + 539 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_DMA1_CTL, 540 + EXTEND_DMA1_ASYNC_SIGNAL, EXTEND_DMA1_ASYNC_SIGNAL); 541 + rtsx_usb_add_cmd(ucr, WRITE_REG_CMD, CARD_INT_PEND, 542 + XD_INT | MS_INT | SD_INT, 543 + XD_INT | MS_INT | SD_INT); 544 + 545 + ret = rtsx_usb_send_cmd(ucr, MODE_C, 100); 546 + if (ret) 547 + return ret; 548 + 549 + /* config non-crystal mode */ 550 + rtsx_usb_read_register(ucr, CFG_MODE, &val); 551 + if ((val & XTAL_FREE) || ((val & CLK_MODE_MASK) == CLK_MODE_NON_XTAL)) { 552 + ret = rtsx_usb_write_phy_register(ucr, 0xC2, 0x7C); 553 + if (ret) 554 + return ret; 555 + } 556 + 557 + return 0; 558 + } 559 + 560 + static int rtsx_usb_init_chip(struct rtsx_ucr *ucr) 561 + { 562 + int ret; 563 + u8 val; 564 + 565 + rtsx_usb_clear_fsm_err(ucr); 566 + 567 + /* power on SSC */ 568 + ret = rtsx_usb_write_register(ucr, 569 + FPDCTL, SSC_POWER_MASK, SSC_POWER_ON); 570 + if (ret) 571 + return ret; 572 + 573 + usleep_range(100, 1000); 574 + ret = rtsx_usb_write_register(ucr, CLK_DIV, CLK_CHANGE, 0x00); 575 + if (ret) 576 + return ret; 577 + 578 + /* determine IC version */ 579 + ret = rtsx_usb_read_register(ucr, HW_VERSION, &val); 580 + if (ret) 581 + return ret; 582 + 583 + ucr->ic_version = val & HW_VER_MASK; 584 + 585 + /* determine package */ 586 + ret = rtsx_usb_read_register(ucr, CARD_SHARE_MODE, &val); 587 + if (ret) 588 + return ret; 589 + 590 + if (val & CARD_SHARE_LQFP_SEL) { 591 + ucr->package = LQFP48; 592 + dev_dbg(&ucr->pusb_intf->dev, "Package: LQFP48\n"); 593 + } else { 594 + ucr->package = QFN24; 595 + dev_dbg(&ucr->pusb_intf->dev, "Package: QFN24\n"); 596 + } 597 + 598 + /* determine IC variations */ 599 + rtsx_usb_read_register(ucr, CFG_MODE_1, &val); 600 + if (val & RTS5179) { 601 + ucr->is_rts5179 = true; 602 + dev_dbg(&ucr->pusb_intf->dev, "Device is rts5179\n"); 603 + } else { 604 + ucr->is_rts5179 = false; 605 + } 606 + 607 + return rtsx_usb_reset_chip(ucr); 608 + } 609 + 610 + static int rtsx_usb_probe(struct usb_interface *intf, 611 + const struct usb_device_id *id) 612 + { 613 + struct usb_device *usb_dev = interface_to_usbdev(intf); 614 + struct rtsx_ucr *ucr; 615 + int ret; 616 + 617 + dev_dbg(&intf->dev, 618 + ": Realtek USB Card Reader found at bus %03d address %03d\n", 619 + usb_dev->bus->busnum, usb_dev->devnum); 620 + 621 + ucr = devm_kzalloc(&intf->dev, sizeof(*ucr), GFP_KERNEL); 622 + if (!ucr) 623 + return -ENOMEM; 624 + 625 + ucr->pusb_dev = usb_dev; 626 + 627 + ucr->iobuf = usb_alloc_coherent(ucr->pusb_dev, IOBUF_SIZE, 628 + GFP_KERNEL, &ucr->iobuf_dma); 629 + if (!ucr->iobuf) 630 + return -ENOMEM; 631 + 632 + usb_set_intfdata(intf, ucr); 633 + 634 + ucr->vendor_id = id->idVendor; 635 + ucr->product_id = id->idProduct; 636 + ucr->cmd_buf = ucr->rsp_buf = ucr->iobuf; 637 + 638 + mutex_init(&ucr->dev_mutex); 639 + 640 + ucr->pusb_intf = intf; 641 + 642 + /* initialize */ 643 + ret = rtsx_usb_init_chip(ucr); 644 + if (ret) 645 + goto out_init_fail; 646 + 647 + ret = mfd_add_devices(&intf->dev, usb_dev->devnum, rtsx_usb_cells, 648 + ARRAY_SIZE(rtsx_usb_cells), NULL, 0, NULL); 649 + if (ret) 650 + goto out_init_fail; 651 + 652 + /* initialize USB SG transfer timer */ 653 + init_timer(&ucr->sg_timer); 654 + setup_timer(&ucr->sg_timer, rtsx_usb_sg_timed_out, (unsigned long) ucr); 655 + #ifdef CONFIG_PM 656 + intf->needs_remote_wakeup = 1; 657 + usb_enable_autosuspend(usb_dev); 658 + #endif 659 + 660 + return 0; 661 + 662 + out_init_fail: 663 + usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, 664 + ucr->iobuf_dma); 665 + return ret; 666 + } 667 + 668 + static void rtsx_usb_disconnect(struct usb_interface *intf) 669 + { 670 + struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata(intf); 671 + 672 + dev_dbg(&intf->dev, "%s called\n", __func__); 673 + 674 + mfd_remove_devices(&intf->dev); 675 + 676 + usb_set_intfdata(ucr->pusb_intf, NULL); 677 + usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf, 678 + ucr->iobuf_dma); 679 + } 680 + 681 + #ifdef CONFIG_PM 682 + static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message) 683 + { 684 + struct rtsx_ucr *ucr = 685 + (struct rtsx_ucr *)usb_get_intfdata(intf); 686 + 687 + dev_dbg(&intf->dev, "%s called with pm message 0x%04u\n", 688 + __func__, message.event); 689 + 690 + mutex_lock(&ucr->dev_mutex); 691 + rtsx_usb_turn_off_led(ucr); 692 + mutex_unlock(&ucr->dev_mutex); 693 + return 0; 694 + } 695 + 696 + static int rtsx_usb_resume(struct usb_interface *intf) 697 + { 698 + return 0; 699 + } 700 + 701 + static int rtsx_usb_reset_resume(struct usb_interface *intf) 702 + { 703 + struct rtsx_ucr *ucr = 704 + (struct rtsx_ucr *)usb_get_intfdata(intf); 705 + 706 + rtsx_usb_reset_chip(ucr); 707 + return 0; 708 + } 709 + 710 + #else /* CONFIG_PM */ 711 + 712 + #define rtsx_usb_suspend NULL 713 + #define rtsx_usb_resume NULL 714 + #define rtsx_usb_reset_resume NULL 715 + 716 + #endif /* CONFIG_PM */ 717 + 718 + 719 + static int rtsx_usb_pre_reset(struct usb_interface *intf) 720 + { 721 + struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata(intf); 722 + 723 + mutex_lock(&ucr->dev_mutex); 724 + return 0; 725 + } 726 + 727 + static int rtsx_usb_post_reset(struct usb_interface *intf) 728 + { 729 + struct rtsx_ucr *ucr = (struct rtsx_ucr *)usb_get_intfdata(intf); 730 + 731 + mutex_unlock(&ucr->dev_mutex); 732 + return 0; 733 + } 734 + 735 + static struct usb_device_id rtsx_usb_usb_ids[] = { 736 + { USB_DEVICE(0x0BDA, 0x0129) }, 737 + { USB_DEVICE(0x0BDA, 0x0139) }, 738 + { USB_DEVICE(0x0BDA, 0x0140) }, 739 + { } 740 + }; 741 + 742 + static struct usb_driver rtsx_usb_driver = { 743 + .name = "rtsx_usb", 744 + .probe = rtsx_usb_probe, 745 + .disconnect = rtsx_usb_disconnect, 746 + .suspend = rtsx_usb_suspend, 747 + .resume = rtsx_usb_resume, 748 + .reset_resume = rtsx_usb_reset_resume, 749 + .pre_reset = rtsx_usb_pre_reset, 750 + .post_reset = rtsx_usb_post_reset, 751 + .id_table = rtsx_usb_usb_ids, 752 + .supports_autosuspend = 1, 753 + .soft_unbind = 1, 754 + }; 755 + 756 + module_usb_driver(rtsx_usb_driver); 757 + 758 + MODULE_LICENSE("GPL v2"); 759 + MODULE_AUTHOR("Roger Tseng <rogerable@realtek.com>"); 760 + MODULE_DESCRIPTION("Realtek USB Card Reader Driver");
+14 -3
drivers/mfd/sec-core.c
··· 60 60 .name = "s5m-rtc", 61 61 }, { 62 62 .name = "s5m8767-clk", 63 + .of_compatible = "samsung,s5m8767-clk", 63 64 } 64 65 }; 65 66 ··· 69 68 .name = "s2mps11-pmic", 70 69 }, { 71 70 .name = "s2mps11-clk", 71 + .of_compatible = "samsung,s2mps11-clk", 72 72 } 73 73 }; 74 74 ··· 80 78 .name = "s2mps14-rtc", 81 79 }, { 82 80 .name = "s2mps14-clk", 81 + .of_compatible = "samsung,s2mps14-clk", 83 82 } 84 83 }; 85 84 ··· 298 295 switch (sec_pmic->device_type) { 299 296 case S2MPA01: 300 297 regmap = &s2mpa01_regmap_config; 298 + /* 299 + * The rtc-s5m driver does not support S2MPA01 and there 300 + * is no mfd_cell for S2MPA01 RTC device. 301 + * However we must pass something to devm_regmap_init_i2c() 302 + * so use S5M-like regmap config even though it wouldn't work. 303 + */ 304 + regmap_rtc = &s5m_rtc_regmap_config; 301 305 break; 302 306 case S2MPS11X: 303 307 regmap = &s2mps11_regmap_config; ··· 354 344 ret = PTR_ERR(sec_pmic->regmap_rtc); 355 345 dev_err(&i2c->dev, "Failed to allocate RTC register map: %d\n", 356 346 ret); 357 - return ret; 347 + goto err_regmap_rtc; 358 348 } 359 349 360 350 if (pdata && pdata->cfg_pmic_irq) ··· 395 385 } 396 386 397 387 if (ret) 398 - goto err; 388 + goto err_mfd; 399 389 400 390 device_init_wakeup(sec_pmic->dev, sec_pmic->wakeup); 401 391 402 392 return ret; 403 393 404 - err: 394 + err_mfd: 405 395 sec_irq_exit(sec_pmic); 396 + err_regmap_rtc: 406 397 i2c_unregister_device(sec_pmic->rtc); 407 398 return ret; 408 399 }
-1
drivers/mfd/smsc-ece1099.c
··· 13 13 14 14 #include <linux/module.h> 15 15 #include <linux/moduleparam.h> 16 - #include <linux/init.h> 17 16 #include <linux/slab.h> 18 17 #include <linux/i2c.h> 19 18 #include <linux/gpio.h>
+1 -1
drivers/mfd/stmpe.c
··· 706 706 if (!(ret & STMPE1801_MSK_SYS_CTRL_RESET)) 707 707 return 0; 708 708 usleep_range(100, 200); 709 - }; 709 + } 710 710 return -EIO; 711 711 } 712 712
+7 -1
drivers/mfd/stw481x.c
··· 167 167 }, 168 168 }; 169 169 170 - const struct regmap_config stw481x_regmap_config = { 170 + static const struct regmap_config stw481x_regmap_config = { 171 171 .reg_bits = 8, 172 172 .val_bits = 8, 173 173 }; ··· 186 186 i2c_set_clientdata(client, stw481x); 187 187 stw481x->client = client; 188 188 stw481x->map = devm_regmap_init_i2c(client, &stw481x_regmap_config); 189 + if (IS_ERR(stw481x->map)) { 190 + ret = PTR_ERR(stw481x->map); 191 + dev_err(&client->dev, "Failed to allocate register map: %d\n", 192 + ret); 193 + return ret; 194 + } 189 195 190 196 ret = stw481x_startup(stw481x); 191 197 if (ret) {
+1 -8
drivers/mfd/syscon.c
··· 69 69 70 70 static int syscon_match_pdevname(struct device *dev, void *data) 71 71 { 72 - struct platform_device *pdev = to_platform_device(dev); 73 - const struct platform_device_id *id = platform_get_device_id(pdev); 74 - 75 - if (id) 76 - if (!strcmp(id->name, (const char *)data)) 77 - return 1; 78 - 79 72 return !strcmp(dev_name(dev), (const char *)data); 80 73 } 81 74 ··· 145 152 146 153 platform_set_drvdata(pdev, syscon); 147 154 148 - dev_info(dev, "regmap %pR registered\n", res); 155 + dev_dbg(dev, "regmap %pR registered\n", res); 149 156 150 157 return 0; 151 158 }
+59 -25
drivers/mfd/tc3589x.c
··· 13 13 #include <linux/slab.h> 14 14 #include <linux/i2c.h> 15 15 #include <linux/of.h> 16 + #include <linux/of_device.h> 16 17 #include <linux/mfd/core.h> 17 18 #include <linux/mfd/tc3589x.h> 19 + #include <linux/err.h> 18 20 19 21 /** 20 22 * enum tc3589x_version - indicates the TC3589x version ··· 162 160 .name = "tc3589x-gpio", 163 161 .num_resources = ARRAY_SIZE(gpio_resources), 164 162 .resources = &gpio_resources[0], 165 - .of_compatible = "tc3589x-gpio", 163 + .of_compatible = "toshiba,tc3589x-gpio", 166 164 }, 167 165 }; 168 166 ··· 171 169 .name = "tc3589x-keypad", 172 170 .num_resources = ARRAY_SIZE(keypad_resources), 173 171 .resources = &keypad_resources[0], 174 - .of_compatible = "tc3589x-keypad", 172 + .of_compatible = "toshiba,tc3589x-keypad", 175 173 }, 176 174 }; 177 175 ··· 320 318 return ret; 321 319 } 322 320 323 - static int tc3589x_of_probe(struct device_node *np, 324 - struct tc3589x_platform_data *pdata) 321 + #ifdef CONFIG_OF 322 + static const struct of_device_id tc3589x_match[] = { 323 + /* Legacy compatible string */ 324 + { .compatible = "tc3589x", .data = (void *) TC3589X_UNKNOWN }, 325 + { .compatible = "toshiba,tc35890", .data = (void *) TC3589X_TC35890 }, 326 + { .compatible = "toshiba,tc35892", .data = (void *) TC3589X_TC35892 }, 327 + { .compatible = "toshiba,tc35893", .data = (void *) TC3589X_TC35893 }, 328 + { .compatible = "toshiba,tc35894", .data = (void *) TC3589X_TC35894 }, 329 + { .compatible = "toshiba,tc35895", .data = (void *) TC3589X_TC35895 }, 330 + { .compatible = "toshiba,tc35896", .data = (void *) TC3589X_TC35896 }, 331 + { } 332 + }; 333 + 334 + MODULE_DEVICE_TABLE(of, tc3589x_match); 335 + 336 + static struct tc3589x_platform_data * 337 + tc3589x_of_probe(struct device *dev, enum tc3589x_version *version) 325 338 { 339 + struct device_node *np = dev->of_node; 340 + struct tc3589x_platform_data *pdata; 326 341 struct device_node *child; 342 + const struct of_device_id *of_id; 343 + 344 + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 345 + if (!pdata) 346 + return ERR_PTR(-ENOMEM); 347 + 348 + of_id = of_match_device(tc3589x_match, dev); 349 + if (!of_id) 350 + return ERR_PTR(-ENODEV); 351 + *version = (enum tc3589x_version) of_id->data; 327 352 328 353 for_each_child_of_node(np, child) { 329 - if (!strcmp(child->name, "tc3589x_gpio")) { 354 + if (of_device_is_compatible(child, "toshiba,tc3589x-gpio")) 330 355 pdata->block |= TC3589x_BLOCK_GPIO; 331 - } 332 - if (!strcmp(child->name, "tc3589x_keypad")) { 356 + if (of_device_is_compatible(child, "toshiba,tc3589x-keypad")) 333 357 pdata->block |= TC3589x_BLOCK_KEYPAD; 334 - } 335 358 } 336 359 337 - return 0; 360 + return pdata; 338 361 } 362 + #else 363 + static inline struct tc3589x_platform_data * 364 + tc3589x_of_probe(struct device *dev, enum tc3589x_version *version) 365 + { 366 + dev_err(dev, "no device tree support\n"); 367 + return ERR_PTR(-ENODEV); 368 + } 369 + #endif 339 370 340 371 static int tc3589x_probe(struct i2c_client *i2c, 341 372 const struct i2c_device_id *id) 342 373 { 343 - struct tc3589x_platform_data *pdata = dev_get_platdata(&i2c->dev); 344 374 struct device_node *np = i2c->dev.of_node; 375 + struct tc3589x_platform_data *pdata = dev_get_platdata(&i2c->dev); 345 376 struct tc3589x *tc3589x; 377 + enum tc3589x_version version; 346 378 int ret; 347 379 348 380 if (!pdata) { 349 - if (np) { 350 - pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL); 351 - if (!pdata) 352 - return -ENOMEM; 353 - 354 - ret = tc3589x_of_probe(np, pdata); 355 - if (ret) 356 - return ret; 357 - } 358 - else { 381 + pdata = tc3589x_of_probe(&i2c->dev, &version); 382 + if (IS_ERR(pdata)) { 359 383 dev_err(&i2c->dev, "No platform data or DT found\n"); 360 - return -EINVAL; 384 + return PTR_ERR(pdata); 361 385 } 386 + } else { 387 + /* When not probing from device tree we have this ID */ 388 + version = id->driver_data; 362 389 } 363 390 364 391 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA ··· 406 375 tc3589x->pdata = pdata; 407 376 tc3589x->irq_base = pdata->irq_base; 408 377 409 - switch (id->driver_data) { 378 + switch (version) { 410 379 case TC3589X_TC35893: 411 380 case TC3589X_TC35895: 412 381 case TC3589X_TC35896: ··· 502 471 MODULE_DEVICE_TABLE(i2c, tc3589x_id); 503 472 504 473 static struct i2c_driver tc3589x_driver = { 505 - .driver.name = "tc3589x", 506 - .driver.owner = THIS_MODULE, 507 - .driver.pm = &tc3589x_dev_pm_ops, 474 + .driver = { 475 + .name = "tc3589x", 476 + .owner = THIS_MODULE, 477 + .pm = &tc3589x_dev_pm_ops, 478 + .of_match_table = of_match_ptr(tc3589x_match), 479 + }, 508 480 .probe = tc3589x_probe, 509 481 .remove = tc3589x_remove, 510 482 .id_table = tc3589x_id,
-465
drivers/mfd/ti-ssp.c
··· 1 - /* 2 - * Sequencer Serial Port (SSP) driver for Texas Instruments' SoCs 3 - * 4 - * Copyright (C) 2010 Texas Instruments Inc 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License as published by 8 - * the Free Software Foundation; either version 2 of the License, or 9 - * (at your option) any later version. 10 - * 11 - * This program is distributed in the hope that it will be useful, 12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - * GNU General Public License for more details. 15 - * 16 - * You should have received a copy of the GNU General Public License 17 - * along with this program; if not, write to the Free Software 18 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 - */ 20 - 21 - #include <linux/errno.h> 22 - #include <linux/kernel.h> 23 - #include <linux/module.h> 24 - #include <linux/slab.h> 25 - #include <linux/err.h> 26 - #include <linux/init.h> 27 - #include <linux/wait.h> 28 - #include <linux/clk.h> 29 - #include <linux/interrupt.h> 30 - #include <linux/device.h> 31 - #include <linux/spinlock.h> 32 - #include <linux/platform_device.h> 33 - #include <linux/delay.h> 34 - #include <linux/io.h> 35 - #include <linux/sched.h> 36 - #include <linux/mfd/core.h> 37 - #include <linux/mfd/ti_ssp.h> 38 - 39 - /* Register Offsets */ 40 - #define REG_REV 0x00 41 - #define REG_IOSEL_1 0x04 42 - #define REG_IOSEL_2 0x08 43 - #define REG_PREDIV 0x0c 44 - #define REG_INTR_ST 0x10 45 - #define REG_INTR_EN 0x14 46 - #define REG_TEST_CTRL 0x18 47 - 48 - /* Per port registers */ 49 - #define PORT_CFG_2 0x00 50 - #define PORT_ADDR 0x04 51 - #define PORT_DATA 0x08 52 - #define PORT_CFG_1 0x0c 53 - #define PORT_STATE 0x10 54 - 55 - #define SSP_PORT_CONFIG_MASK (SSP_EARLY_DIN | SSP_DELAY_DOUT) 56 - #define SSP_PORT_CLKRATE_MASK 0x0f 57 - 58 - #define SSP_SEQRAM_WR_EN BIT(4) 59 - #define SSP_SEQRAM_RD_EN BIT(5) 60 - #define SSP_START BIT(15) 61 - #define SSP_BUSY BIT(10) 62 - #define SSP_PORT_ASL BIT(7) 63 - #define SSP_PORT_CFO1 BIT(6) 64 - 65 - #define SSP_PORT_SEQRAM_SIZE 32 66 - 67 - static const int ssp_port_base[] = {0x040, 0x080}; 68 - static const int ssp_port_seqram[] = {0x100, 0x180}; 69 - 70 - struct ti_ssp { 71 - struct resource *res; 72 - struct device *dev; 73 - void __iomem *regs; 74 - spinlock_t lock; 75 - struct clk *clk; 76 - int irq; 77 - wait_queue_head_t wqh; 78 - 79 - /* 80 - * Some of the iosel2 register bits always read-back as 0, we need to 81 - * remember these values so that we don't clobber previously set 82 - * values. 83 - */ 84 - u32 iosel2; 85 - }; 86 - 87 - static inline struct ti_ssp *dev_to_ssp(struct device *dev) 88 - { 89 - return dev_get_drvdata(dev->parent); 90 - } 91 - 92 - static inline int dev_to_port(struct device *dev) 93 - { 94 - return to_platform_device(dev)->id; 95 - } 96 - 97 - /* Register Access Helpers, rmw() functions need to run locked */ 98 - static inline u32 ssp_read(struct ti_ssp *ssp, int reg) 99 - { 100 - return __raw_readl(ssp->regs + reg); 101 - } 102 - 103 - static inline void ssp_write(struct ti_ssp *ssp, int reg, u32 val) 104 - { 105 - __raw_writel(val, ssp->regs + reg); 106 - } 107 - 108 - static inline void ssp_rmw(struct ti_ssp *ssp, int reg, u32 mask, u32 bits) 109 - { 110 - ssp_write(ssp, reg, (ssp_read(ssp, reg) & ~mask) | bits); 111 - } 112 - 113 - static inline u32 ssp_port_read(struct ti_ssp *ssp, int port, int reg) 114 - { 115 - return ssp_read(ssp, ssp_port_base[port] + reg); 116 - } 117 - 118 - static inline void ssp_port_write(struct ti_ssp *ssp, int port, int reg, 119 - u32 val) 120 - { 121 - ssp_write(ssp, ssp_port_base[port] + reg, val); 122 - } 123 - 124 - static inline void ssp_port_rmw(struct ti_ssp *ssp, int port, int reg, 125 - u32 mask, u32 bits) 126 - { 127 - ssp_rmw(ssp, ssp_port_base[port] + reg, mask, bits); 128 - } 129 - 130 - static inline void ssp_port_clr_bits(struct ti_ssp *ssp, int port, int reg, 131 - u32 bits) 132 - { 133 - ssp_port_rmw(ssp, port, reg, bits, 0); 134 - } 135 - 136 - static inline void ssp_port_set_bits(struct ti_ssp *ssp, int port, int reg, 137 - u32 bits) 138 - { 139 - ssp_port_rmw(ssp, port, reg, 0, bits); 140 - } 141 - 142 - /* Called to setup port clock mode, caller must hold ssp->lock */ 143 - static int __set_mode(struct ti_ssp *ssp, int port, int mode) 144 - { 145 - mode &= SSP_PORT_CONFIG_MASK; 146 - ssp_port_rmw(ssp, port, PORT_CFG_1, SSP_PORT_CONFIG_MASK, mode); 147 - 148 - return 0; 149 - } 150 - 151 - int ti_ssp_set_mode(struct device *dev, int mode) 152 - { 153 - struct ti_ssp *ssp = dev_to_ssp(dev); 154 - int port = dev_to_port(dev); 155 - int ret; 156 - 157 - spin_lock(&ssp->lock); 158 - ret = __set_mode(ssp, port, mode); 159 - spin_unlock(&ssp->lock); 160 - 161 - return ret; 162 - } 163 - EXPORT_SYMBOL(ti_ssp_set_mode); 164 - 165 - /* Called to setup iosel2, caller must hold ssp->lock */ 166 - static void __set_iosel2(struct ti_ssp *ssp, u32 mask, u32 val) 167 - { 168 - ssp->iosel2 = (ssp->iosel2 & ~mask) | val; 169 - ssp_write(ssp, REG_IOSEL_2, ssp->iosel2); 170 - } 171 - 172 - /* Called to setup port iosel, caller must hold ssp->lock */ 173 - static void __set_iosel(struct ti_ssp *ssp, int port, u32 iosel) 174 - { 175 - unsigned val, shift = port ? 16 : 0; 176 - 177 - /* IOSEL1 gets the least significant 16 bits */ 178 - val = ssp_read(ssp, REG_IOSEL_1); 179 - val &= 0xffff << (port ? 0 : 16); 180 - val |= (iosel & 0xffff) << (port ? 16 : 0); 181 - ssp_write(ssp, REG_IOSEL_1, val); 182 - 183 - /* IOSEL2 gets the most significant 16 bits */ 184 - val = (iosel >> 16) & 0x7; 185 - __set_iosel2(ssp, 0x7 << shift, val << shift); 186 - } 187 - 188 - int ti_ssp_set_iosel(struct device *dev, u32 iosel) 189 - { 190 - struct ti_ssp *ssp = dev_to_ssp(dev); 191 - int port = dev_to_port(dev); 192 - 193 - spin_lock(&ssp->lock); 194 - __set_iosel(ssp, port, iosel); 195 - spin_unlock(&ssp->lock); 196 - 197 - return 0; 198 - } 199 - EXPORT_SYMBOL(ti_ssp_set_iosel); 200 - 201 - int ti_ssp_load(struct device *dev, int offs, u32* prog, int len) 202 - { 203 - struct ti_ssp *ssp = dev_to_ssp(dev); 204 - int port = dev_to_port(dev); 205 - int i; 206 - 207 - if (len > SSP_PORT_SEQRAM_SIZE) 208 - return -ENOSPC; 209 - 210 - spin_lock(&ssp->lock); 211 - 212 - /* Enable SeqRAM access */ 213 - ssp_port_set_bits(ssp, port, PORT_CFG_2, SSP_SEQRAM_WR_EN); 214 - 215 - /* Copy code */ 216 - for (i = 0; i < len; i++) { 217 - __raw_writel(prog[i], ssp->regs + offs + 4*i + 218 - ssp_port_seqram[port]); 219 - } 220 - 221 - /* Disable SeqRAM access */ 222 - ssp_port_clr_bits(ssp, port, PORT_CFG_2, SSP_SEQRAM_WR_EN); 223 - 224 - spin_unlock(&ssp->lock); 225 - 226 - return 0; 227 - } 228 - EXPORT_SYMBOL(ti_ssp_load); 229 - 230 - int ti_ssp_raw_read(struct device *dev) 231 - { 232 - struct ti_ssp *ssp = dev_to_ssp(dev); 233 - int port = dev_to_port(dev); 234 - int shift = port ? 27 : 11; 235 - 236 - return (ssp_read(ssp, REG_IOSEL_2) >> shift) & 0xf; 237 - } 238 - EXPORT_SYMBOL(ti_ssp_raw_read); 239 - 240 - int ti_ssp_raw_write(struct device *dev, u32 val) 241 - { 242 - struct ti_ssp *ssp = dev_to_ssp(dev); 243 - int port = dev_to_port(dev), shift; 244 - 245 - spin_lock(&ssp->lock); 246 - 247 - shift = port ? 22 : 6; 248 - val &= 0xf; 249 - __set_iosel2(ssp, 0xf << shift, val << shift); 250 - 251 - spin_unlock(&ssp->lock); 252 - 253 - return 0; 254 - } 255 - EXPORT_SYMBOL(ti_ssp_raw_write); 256 - 257 - static inline int __xfer_done(struct ti_ssp *ssp, int port) 258 - { 259 - return !(ssp_port_read(ssp, port, PORT_CFG_1) & SSP_BUSY); 260 - } 261 - 262 - int ti_ssp_run(struct device *dev, u32 pc, u32 input, u32 *output) 263 - { 264 - struct ti_ssp *ssp = dev_to_ssp(dev); 265 - int port = dev_to_port(dev); 266 - int ret; 267 - 268 - if (pc & ~(0x3f)) 269 - return -EINVAL; 270 - 271 - /* Grab ssp->lock to serialize rmw on ssp registers */ 272 - spin_lock(&ssp->lock); 273 - 274 - ssp_port_write(ssp, port, PORT_ADDR, input >> 16); 275 - ssp_port_write(ssp, port, PORT_DATA, input & 0xffff); 276 - ssp_port_rmw(ssp, port, PORT_CFG_1, 0x3f, pc); 277 - 278 - /* grab wait queue head lock to avoid race with the isr */ 279 - spin_lock_irq(&ssp->wqh.lock); 280 - 281 - /* kick off sequence execution in hardware */ 282 - ssp_port_set_bits(ssp, port, PORT_CFG_1, SSP_START); 283 - 284 - /* drop ssp lock; no register writes beyond this */ 285 - spin_unlock(&ssp->lock); 286 - 287 - ret = wait_event_interruptible_locked_irq(ssp->wqh, 288 - __xfer_done(ssp, port)); 289 - spin_unlock_irq(&ssp->wqh.lock); 290 - 291 - if (ret < 0) 292 - return ret; 293 - 294 - if (output) { 295 - *output = (ssp_port_read(ssp, port, PORT_ADDR) << 16) | 296 - (ssp_port_read(ssp, port, PORT_DATA) & 0xffff); 297 - } 298 - 299 - ret = ssp_port_read(ssp, port, PORT_STATE) & 0x3f; /* stop address */ 300 - 301 - return ret; 302 - } 303 - EXPORT_SYMBOL(ti_ssp_run); 304 - 305 - static irqreturn_t ti_ssp_interrupt(int irq, void *dev_data) 306 - { 307 - struct ti_ssp *ssp = dev_data; 308 - 309 - spin_lock(&ssp->wqh.lock); 310 - 311 - ssp_write(ssp, REG_INTR_ST, 0x3); 312 - wake_up_locked(&ssp->wqh); 313 - 314 - spin_unlock(&ssp->wqh.lock); 315 - 316 - return IRQ_HANDLED; 317 - } 318 - 319 - static int ti_ssp_probe(struct platform_device *pdev) 320 - { 321 - static struct ti_ssp *ssp; 322 - const struct ti_ssp_data *pdata = dev_get_platdata(&pdev->dev); 323 - int error = 0, prediv = 0xff, id; 324 - unsigned long sysclk; 325 - struct device *dev = &pdev->dev; 326 - struct mfd_cell cells[2]; 327 - 328 - ssp = kzalloc(sizeof(*ssp), GFP_KERNEL); 329 - if (!ssp) { 330 - dev_err(dev, "cannot allocate device info\n"); 331 - return -ENOMEM; 332 - } 333 - 334 - ssp->dev = dev; 335 - dev_set_drvdata(dev, ssp); 336 - 337 - ssp->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 338 - if (!ssp->res) { 339 - error = -ENODEV; 340 - dev_err(dev, "cannot determine register area\n"); 341 - goto error_res; 342 - } 343 - 344 - if (!request_mem_region(ssp->res->start, resource_size(ssp->res), 345 - pdev->name)) { 346 - error = -ENOMEM; 347 - dev_err(dev, "cannot claim register memory\n"); 348 - goto error_res; 349 - } 350 - 351 - ssp->regs = ioremap(ssp->res->start, resource_size(ssp->res)); 352 - if (!ssp->regs) { 353 - error = -ENOMEM; 354 - dev_err(dev, "cannot map register memory\n"); 355 - goto error_map; 356 - } 357 - 358 - ssp->clk = clk_get(dev, NULL); 359 - if (IS_ERR(ssp->clk)) { 360 - error = PTR_ERR(ssp->clk); 361 - dev_err(dev, "cannot claim device clock\n"); 362 - goto error_clk; 363 - } 364 - 365 - ssp->irq = platform_get_irq(pdev, 0); 366 - if (ssp->irq < 0) { 367 - error = -ENODEV; 368 - dev_err(dev, "unknown irq\n"); 369 - goto error_irq; 370 - } 371 - 372 - error = request_threaded_irq(ssp->irq, NULL, ti_ssp_interrupt, 0, 373 - dev_name(dev), ssp); 374 - if (error < 0) { 375 - dev_err(dev, "cannot acquire irq\n"); 376 - goto error_irq; 377 - } 378 - 379 - spin_lock_init(&ssp->lock); 380 - init_waitqueue_head(&ssp->wqh); 381 - 382 - /* Power on and initialize SSP */ 383 - error = clk_enable(ssp->clk); 384 - if (error) { 385 - dev_err(dev, "cannot enable device clock\n"); 386 - goto error_enable; 387 - } 388 - 389 - /* Reset registers to a sensible known state */ 390 - ssp_write(ssp, REG_IOSEL_1, 0); 391 - ssp_write(ssp, REG_IOSEL_2, 0); 392 - ssp_write(ssp, REG_INTR_EN, 0x3); 393 - ssp_write(ssp, REG_INTR_ST, 0x3); 394 - ssp_write(ssp, REG_TEST_CTRL, 0); 395 - ssp_port_write(ssp, 0, PORT_CFG_1, SSP_PORT_ASL); 396 - ssp_port_write(ssp, 1, PORT_CFG_1, SSP_PORT_ASL); 397 - ssp_port_write(ssp, 0, PORT_CFG_2, SSP_PORT_CFO1); 398 - ssp_port_write(ssp, 1, PORT_CFG_2, SSP_PORT_CFO1); 399 - 400 - sysclk = clk_get_rate(ssp->clk); 401 - if (pdata && pdata->out_clock) 402 - prediv = (sysclk / pdata->out_clock) - 1; 403 - prediv = clamp(prediv, 0, 0xff); 404 - ssp_rmw(ssp, REG_PREDIV, 0xff, prediv); 405 - 406 - memset(cells, 0, sizeof(cells)); 407 - for (id = 0; id < 2; id++) { 408 - const struct ti_ssp_dev_data *data = &pdata->dev_data[id]; 409 - 410 - cells[id].id = id; 411 - cells[id].name = data->dev_name; 412 - cells[id].platform_data = data->pdata; 413 - } 414 - 415 - error = mfd_add_devices(dev, 0, cells, 2, NULL, 0, NULL); 416 - if (error < 0) { 417 - dev_err(dev, "cannot add mfd cells\n"); 418 - goto error_enable; 419 - } 420 - 421 - return 0; 422 - 423 - error_enable: 424 - free_irq(ssp->irq, ssp); 425 - error_irq: 426 - clk_put(ssp->clk); 427 - error_clk: 428 - iounmap(ssp->regs); 429 - error_map: 430 - release_mem_region(ssp->res->start, resource_size(ssp->res)); 431 - error_res: 432 - kfree(ssp); 433 - return error; 434 - } 435 - 436 - static int ti_ssp_remove(struct platform_device *pdev) 437 - { 438 - struct device *dev = &pdev->dev; 439 - struct ti_ssp *ssp = dev_get_drvdata(dev); 440 - 441 - mfd_remove_devices(dev); 442 - clk_disable(ssp->clk); 443 - free_irq(ssp->irq, ssp); 444 - clk_put(ssp->clk); 445 - iounmap(ssp->regs); 446 - release_mem_region(ssp->res->start, resource_size(ssp->res)); 447 - kfree(ssp); 448 - return 0; 449 - } 450 - 451 - static struct platform_driver ti_ssp_driver = { 452 - .probe = ti_ssp_probe, 453 - .remove = ti_ssp_remove, 454 - .driver = { 455 - .name = "ti-ssp", 456 - .owner = THIS_MODULE, 457 - } 458 - }; 459 - 460 - module_platform_driver(ti_ssp_driver); 461 - 462 - MODULE_DESCRIPTION("Sequencer Serial Port (SSP) Driver"); 463 - MODULE_AUTHOR("Cyril Chemparathy"); 464 - MODULE_LICENSE("GPL"); 465 - MODULE_ALIAS("platform:ti-ssp");
+4 -20
drivers/mfd/ti_am335x_tscadc.c
··· 14 14 */ 15 15 16 16 #include <linux/module.h> 17 - #include <linux/init.h> 18 17 #include <linux/slab.h> 19 18 #include <linux/err.h> 20 19 #include <linux/io.h> ··· 183 184 return -EINVAL; 184 185 } 185 186 186 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 187 - if (!res) { 188 - dev_err(&pdev->dev, "no memory resource defined.\n"); 189 - return -EINVAL; 190 - } 191 - 192 187 /* Allocate memory for device */ 193 188 tscadc = devm_kzalloc(&pdev->dev, 194 189 sizeof(struct ti_tscadc_dev), GFP_KERNEL); ··· 199 206 } else 200 207 tscadc->irq = err; 201 208 202 - res = devm_request_mem_region(&pdev->dev, 203 - res->start, resource_size(res), pdev->name); 204 - if (!res) { 205 - dev_err(&pdev->dev, "failed to reserve registers.\n"); 206 - return -EBUSY; 207 - } 208 - 209 - tscadc->tscadc_base = devm_ioremap(&pdev->dev, 210 - res->start, resource_size(res)); 211 - if (!tscadc->tscadc_base) { 212 - dev_err(&pdev->dev, "failed to map registers.\n"); 213 - return -ENOMEM; 214 - } 209 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 210 + tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res); 211 + if (IS_ERR(tscadc->tscadc_base)) 212 + return PTR_ERR(tscadc->tscadc_base); 215 213 216 214 tscadc->regmap_tscadc = devm_regmap_init_mmio(&pdev->dev, 217 215 tscadc->tscadc_base, &tscadc_regmap_config);
+1 -1
drivers/mfd/timberdale.c
··· 715 715 for (i = 0; i < TIMBERDALE_NR_IRQS; i++) 716 716 msix_entries[i].entry = i; 717 717 718 - err = pci_enable_msix(dev, msix_entries, TIMBERDALE_NR_IRQS); 718 + err = pci_enable_msix_exact(dev, msix_entries, TIMBERDALE_NR_IRQS); 719 719 if (err) { 720 720 dev_err(&dev->dev, 721 721 "MSI-X init failed: %d, expected entries: %d\n",
+282
drivers/mfd/tps65218.c
··· 1 + /* 2 + * Driver for TPS65218 Integrated power management chipsets 3 + * 4 + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 11 + * kind, whether expressed or implied; without even the implied warranty 12 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License version 2 for more details. 14 + */ 15 + 16 + #include <linux/kernel.h> 17 + #include <linux/device.h> 18 + #include <linux/module.h> 19 + #include <linux/platform_device.h> 20 + #include <linux/init.h> 21 + #include <linux/i2c.h> 22 + #include <linux/slab.h> 23 + #include <linux/regmap.h> 24 + #include <linux/err.h> 25 + #include <linux/of.h> 26 + #include <linux/of_device.h> 27 + #include <linux/irq.h> 28 + #include <linux/interrupt.h> 29 + #include <linux/mutex.h> 30 + 31 + #include <linux/mfd/core.h> 32 + #include <linux/mfd/tps65218.h> 33 + 34 + #define TPS65218_PASSWORD_REGS_UNLOCK 0x7D 35 + 36 + /** 37 + * tps65218_reg_read: Read a single tps65218 register. 38 + * 39 + * @tps: Device to read from. 40 + * @reg: Register to read. 41 + * @val: Contians the value 42 + */ 43 + int tps65218_reg_read(struct tps65218 *tps, unsigned int reg, 44 + unsigned int *val) 45 + { 46 + return regmap_read(tps->regmap, reg, val); 47 + } 48 + EXPORT_SYMBOL_GPL(tps65218_reg_read); 49 + 50 + /** 51 + * tps65218_reg_write: Write a single tps65218 register. 52 + * 53 + * @tps65218: Device to write to. 54 + * @reg: Register to write to. 55 + * @val: Value to write. 56 + * @level: Password protected level 57 + */ 58 + int tps65218_reg_write(struct tps65218 *tps, unsigned int reg, 59 + unsigned int val, unsigned int level) 60 + { 61 + int ret; 62 + unsigned int xor_reg_val; 63 + 64 + switch (level) { 65 + case TPS65218_PROTECT_NONE: 66 + return regmap_write(tps->regmap, reg, val); 67 + case TPS65218_PROTECT_L1: 68 + xor_reg_val = reg ^ TPS65218_PASSWORD_REGS_UNLOCK; 69 + ret = regmap_write(tps->regmap, TPS65218_REG_PASSWORD, 70 + xor_reg_val); 71 + if (ret < 0) 72 + return ret; 73 + 74 + return regmap_write(tps->regmap, reg, val); 75 + default: 76 + return -EINVAL; 77 + } 78 + } 79 + EXPORT_SYMBOL_GPL(tps65218_reg_write); 80 + 81 + /** 82 + * tps65218_update_bits: Modify bits w.r.t mask, val and level. 83 + * 84 + * @tps65218: Device to write to. 85 + * @reg: Register to read-write to. 86 + * @mask: Mask. 87 + * @val: Value to write. 88 + * @level: Password protected level 89 + */ 90 + static int tps65218_update_bits(struct tps65218 *tps, unsigned int reg, 91 + unsigned int mask, unsigned int val, unsigned int level) 92 + { 93 + int ret; 94 + unsigned int data; 95 + 96 + ret = tps65218_reg_read(tps, reg, &data); 97 + if (ret) { 98 + dev_err(tps->dev, "Read from reg 0x%x failed\n", reg); 99 + return ret; 100 + } 101 + 102 + data &= ~mask; 103 + data |= val & mask; 104 + 105 + mutex_lock(&tps->tps_lock); 106 + ret = tps65218_reg_write(tps, reg, data, level); 107 + if (ret) 108 + dev_err(tps->dev, "Write for reg 0x%x failed\n", reg); 109 + mutex_unlock(&tps->tps_lock); 110 + 111 + return ret; 112 + } 113 + 114 + int tps65218_set_bits(struct tps65218 *tps, unsigned int reg, 115 + unsigned int mask, unsigned int val, unsigned int level) 116 + { 117 + return tps65218_update_bits(tps, reg, mask, val, level); 118 + } 119 + EXPORT_SYMBOL_GPL(tps65218_set_bits); 120 + 121 + int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, 122 + unsigned int mask, unsigned int level) 123 + { 124 + return tps65218_update_bits(tps, reg, mask, 0, level); 125 + } 126 + EXPORT_SYMBOL_GPL(tps65218_clear_bits); 127 + 128 + static struct regmap_config tps65218_regmap_config = { 129 + .reg_bits = 8, 130 + .val_bits = 8, 131 + .cache_type = REGCACHE_RBTREE, 132 + }; 133 + 134 + static const struct regmap_irq tps65218_irqs[] = { 135 + /* INT1 IRQs */ 136 + [TPS65218_PRGC_IRQ] = { 137 + .mask = TPS65218_INT1_PRGC, 138 + }, 139 + [TPS65218_CC_AQC_IRQ] = { 140 + .mask = TPS65218_INT1_CC_AQC, 141 + }, 142 + [TPS65218_HOT_IRQ] = { 143 + .mask = TPS65218_INT1_HOT, 144 + }, 145 + [TPS65218_PB_IRQ] = { 146 + .mask = TPS65218_INT1_PB, 147 + }, 148 + [TPS65218_AC_IRQ] = { 149 + .mask = TPS65218_INT1_AC, 150 + }, 151 + [TPS65218_VPRG_IRQ] = { 152 + .mask = TPS65218_INT1_VPRG, 153 + }, 154 + [TPS65218_INVALID1_IRQ] = { 155 + }, 156 + [TPS65218_INVALID2_IRQ] = { 157 + }, 158 + /* INT2 IRQs*/ 159 + [TPS65218_LS1_I_IRQ] = { 160 + .mask = TPS65218_INT2_LS1_I, 161 + .reg_offset = 1, 162 + }, 163 + [TPS65218_LS2_I_IRQ] = { 164 + .mask = TPS65218_INT2_LS2_I, 165 + .reg_offset = 1, 166 + }, 167 + [TPS65218_LS3_I_IRQ] = { 168 + .mask = TPS65218_INT2_LS3_I, 169 + .reg_offset = 1, 170 + }, 171 + [TPS65218_LS1_F_IRQ] = { 172 + .mask = TPS65218_INT2_LS1_F, 173 + .reg_offset = 1, 174 + }, 175 + [TPS65218_LS2_F_IRQ] = { 176 + .mask = TPS65218_INT2_LS2_F, 177 + .reg_offset = 1, 178 + }, 179 + [TPS65218_LS3_F_IRQ] = { 180 + .mask = TPS65218_INT2_LS3_F, 181 + .reg_offset = 1, 182 + }, 183 + [TPS65218_INVALID3_IRQ] = { 184 + }, 185 + [TPS65218_INVALID4_IRQ] = { 186 + }, 187 + }; 188 + 189 + static struct regmap_irq_chip tps65218_irq_chip = { 190 + .name = "tps65218", 191 + .irqs = tps65218_irqs, 192 + .num_irqs = ARRAY_SIZE(tps65218_irqs), 193 + 194 + .num_regs = 2, 195 + .mask_base = TPS65218_REG_INT_MASK1, 196 + }; 197 + 198 + static const struct of_device_id of_tps65218_match_table[] = { 199 + { .compatible = "ti,tps65218", }, 200 + }; 201 + 202 + static int tps65218_probe(struct i2c_client *client, 203 + const struct i2c_device_id *ids) 204 + { 205 + struct tps65218 *tps; 206 + const struct of_device_id *match; 207 + int ret; 208 + 209 + match = of_match_device(of_tps65218_match_table, &client->dev); 210 + if (!match) { 211 + dev_err(&client->dev, 212 + "Failed to find matching dt id\n"); 213 + return -EINVAL; 214 + } 215 + 216 + tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 217 + if (!tps) 218 + return -ENOMEM; 219 + 220 + i2c_set_clientdata(client, tps); 221 + tps->dev = &client->dev; 222 + tps->irq = client->irq; 223 + tps->regmap = devm_regmap_init_i2c(client, &tps65218_regmap_config); 224 + if (IS_ERR(tps->regmap)) { 225 + ret = PTR_ERR(tps->regmap); 226 + dev_err(tps->dev, "Failed to allocate register map: %d\n", 227 + ret); 228 + return ret; 229 + } 230 + 231 + mutex_init(&tps->tps_lock); 232 + 233 + ret = regmap_add_irq_chip(tps->regmap, tps->irq, 234 + IRQF_ONESHOT, 0, &tps65218_irq_chip, 235 + &tps->irq_data); 236 + if (ret < 0) 237 + return ret; 238 + 239 + ret = of_platform_populate(client->dev.of_node, NULL, NULL, 240 + &client->dev); 241 + if (ret < 0) 242 + goto err_irq; 243 + 244 + return 0; 245 + 246 + err_irq: 247 + regmap_del_irq_chip(tps->irq, tps->irq_data); 248 + 249 + return ret; 250 + } 251 + 252 + static int tps65218_remove(struct i2c_client *client) 253 + { 254 + struct tps65218 *tps = i2c_get_clientdata(client); 255 + 256 + regmap_del_irq_chip(tps->irq, tps->irq_data); 257 + 258 + return 0; 259 + } 260 + 261 + static const struct i2c_device_id tps65218_id_table[] = { 262 + { "tps65218", TPS65218 }, 263 + { }, 264 + }; 265 + MODULE_DEVICE_TABLE(i2c, tps65218_id_table); 266 + 267 + static struct i2c_driver tps65218_driver = { 268 + .driver = { 269 + .name = "tps65218", 270 + .owner = THIS_MODULE, 271 + .of_match_table = of_tps65218_match_table, 272 + }, 273 + .probe = tps65218_probe, 274 + .remove = tps65218_remove, 275 + .id_table = tps65218_id_table, 276 + }; 277 + 278 + module_i2c_driver(tps65218_driver); 279 + 280 + MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>"); 281 + MODULE_DESCRIPTION("TPS65218 chip family multi-function driver"); 282 + MODULE_LICENSE("GPL v2");
+4 -1
drivers/mfd/tps65910.c
··· 255 255 ret = regmap_add_irq_chip(tps65910->regmap, tps65910->chip_irq, 256 256 IRQF_ONESHOT, pdata->irq_base, 257 257 tps6591x_irqs_chip, &tps65910->irq_data); 258 - if (ret < 0) 258 + if (ret < 0) { 259 259 dev_warn(tps65910->dev, "Failed to add irq_chip %d\n", ret); 260 + tps65910->chip_irq = 0; 261 + } 260 262 return ret; 261 263 } 262 264 ··· 511 509 regmap_irq_get_domain(tps65910->irq_data)); 512 510 if (ret < 0) { 513 511 dev_err(&i2c->dev, "mfd_add_devices failed: %d\n", ret); 512 + tps65910_irq_exit(tps65910); 514 513 return ret; 515 514 } 516 515
-1
drivers/mfd/tps65912-core.c
··· 15 15 16 16 #include <linux/module.h> 17 17 #include <linux/moduleparam.h> 18 - #include <linux/init.h> 19 18 #include <linux/slab.h> 20 19 #include <linux/gpio.h> 21 20 #include <linux/mfd/core.h>
-1
drivers/mfd/tps65912-irq.c
··· 15 15 16 16 #include <linux/kernel.h> 17 17 #include <linux/module.h> 18 - #include <linux/init.h> 19 18 #include <linux/bug.h> 20 19 #include <linux/device.h> 21 20 #include <linux/interrupt.h>
+5 -5
drivers/mfd/twl-core.c
··· 282 282 static bool twl4030_49_nop_reg(struct device *dev, unsigned int reg) 283 283 { 284 284 switch (reg) { 285 - case 0: 286 - case 3: 287 - case 40: 288 - case 41: 289 - case 42: 285 + case 0x00: 286 + case 0x03: 287 + case 0x40: 288 + case 0x41: 289 + case 0x42: 290 290 return false; 291 291 default: 292 292 return true;
-1
drivers/mfd/twl4030-irq.c
··· 27 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 28 */ 29 29 30 - #include <linux/init.h> 31 30 #include <linux/export.h> 32 31 #include <linux/interrupt.h> 33 32 #include <linux/irq.h>
+200 -123
drivers/mfd/twl4030-madc.c drivers/iio/adc/twl4030-madc.c
··· 29 29 * 30 30 */ 31 31 32 - #include <linux/init.h> 33 32 #include <linux/device.h> 34 33 #include <linux/interrupt.h> 35 34 #include <linux/kernel.h> ··· 46 47 #include <linux/gfp.h> 47 48 #include <linux/err.h> 48 49 49 - /* 50 + #include <linux/iio/iio.h> 51 + 52 + /** 50 53 * struct twl4030_madc_data - a container for madc info 51 - * @dev - pointer to device structure for madc 52 - * @lock - mutex protecting this data structure 53 - * @requests - Array of request struct corresponding to SW1, SW2 and RT 54 - * @imr - Interrupt mask register of MADC 55 - * @isr - Interrupt status register of MADC 54 + * @dev: Pointer to device structure for madc 55 + * @lock: Mutex protecting this data structure 56 + * @requests: Array of request struct corresponding to SW1, SW2 and RT 57 + * @use_second_irq: IRQ selection (main or co-processor) 58 + * @imr: Interrupt mask register of MADC 59 + * @isr: Interrupt status register of MADC 56 60 */ 57 61 struct twl4030_madc_data { 58 62 struct device *dev; 59 63 struct mutex lock; /* mutex protecting this data structure */ 60 64 struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS]; 61 - int imr; 62 - int isr; 65 + bool use_second_irq; 66 + u8 imr; 67 + u8 isr; 68 + }; 69 + 70 + static int twl4030_madc_read(struct iio_dev *iio_dev, 71 + const struct iio_chan_spec *chan, 72 + int *val, int *val2, long mask) 73 + { 74 + struct twl4030_madc_data *madc = iio_priv(iio_dev); 75 + struct twl4030_madc_request req; 76 + int ret; 77 + 78 + req.method = madc->use_second_irq ? TWL4030_MADC_SW2 : TWL4030_MADC_SW1; 79 + 80 + req.channels = BIT(chan->channel); 81 + req.active = false; 82 + req.func_cb = NULL; 83 + req.type = TWL4030_MADC_WAIT; 84 + req.raw = !(mask == IIO_CHAN_INFO_PROCESSED); 85 + req.do_avg = (mask == IIO_CHAN_INFO_AVERAGE_RAW); 86 + 87 + ret = twl4030_madc_conversion(&req); 88 + if (ret < 0) 89 + return ret; 90 + 91 + *val = req.rbuf[chan->channel]; 92 + 93 + return IIO_VAL_INT; 94 + } 95 + 96 + static const struct iio_info twl4030_madc_iio_info = { 97 + .read_raw = &twl4030_madc_read, 98 + .driver_module = THIS_MODULE, 99 + }; 100 + 101 + #define TWL4030_ADC_CHANNEL(_channel, _type, _name) { \ 102 + .type = _type, \ 103 + .channel = _channel, \ 104 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 105 + BIT(IIO_CHAN_INFO_AVERAGE_RAW) | \ 106 + BIT(IIO_CHAN_INFO_PROCESSED), \ 107 + .datasheet_name = _name, \ 108 + .indexed = 1, \ 109 + } 110 + 111 + static const struct iio_chan_spec twl4030_madc_iio_channels[] = { 112 + TWL4030_ADC_CHANNEL(0, IIO_VOLTAGE, "ADCIN0"), 113 + TWL4030_ADC_CHANNEL(1, IIO_TEMP, "ADCIN1"), 114 + TWL4030_ADC_CHANNEL(2, IIO_VOLTAGE, "ADCIN2"), 115 + TWL4030_ADC_CHANNEL(3, IIO_VOLTAGE, "ADCIN3"), 116 + TWL4030_ADC_CHANNEL(4, IIO_VOLTAGE, "ADCIN4"), 117 + TWL4030_ADC_CHANNEL(5, IIO_VOLTAGE, "ADCIN5"), 118 + TWL4030_ADC_CHANNEL(6, IIO_VOLTAGE, "ADCIN6"), 119 + TWL4030_ADC_CHANNEL(7, IIO_VOLTAGE, "ADCIN7"), 120 + TWL4030_ADC_CHANNEL(8, IIO_VOLTAGE, "ADCIN8"), 121 + TWL4030_ADC_CHANNEL(9, IIO_VOLTAGE, "ADCIN9"), 122 + TWL4030_ADC_CHANNEL(10, IIO_CURRENT, "ADCIN10"), 123 + TWL4030_ADC_CHANNEL(11, IIO_VOLTAGE, "ADCIN11"), 124 + TWL4030_ADC_CHANNEL(12, IIO_VOLTAGE, "ADCIN12"), 125 + TWL4030_ADC_CHANNEL(13, IIO_VOLTAGE, "ADCIN13"), 126 + TWL4030_ADC_CHANNEL(14, IIO_VOLTAGE, "ADCIN14"), 127 + TWL4030_ADC_CHANNEL(15, IIO_VOLTAGE, "ADCIN15"), 63 128 }; 64 129 65 130 static struct twl4030_madc_data *twl4030_madc; ··· 154 91 }; 155 92 156 93 157 - /* 158 - * Conversion table from -3 to 55 degree Celcius 159 - */ 160 - static int therm_tbl[] = { 161 - 30800, 29500, 28300, 27100, 162 - 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900, 163 - 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100, 164 - 11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310, 165 - 8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830, 166 - 5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170, 167 - 4040, 3910, 3790, 3670, 3550 94 + /* Conversion table from -3 to 55 degrees Celcius */ 95 + static int twl4030_therm_tbl[] = { 96 + 30800, 29500, 28300, 27100, 97 + 26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 98 + 17900, 17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 99 + 12600, 12100, 11600, 11200, 10800, 10400, 10000, 9630, 9280, 100 + 8950, 8620, 8310, 8020, 7730, 7460, 7200, 6950, 6710, 101 + 6470, 6250, 6040, 5830, 5640, 5450, 5260, 5090, 4920, 102 + 4760, 4600, 4450, 4310, 4170, 4040, 3910, 3790, 3670, 103 + 3550 168 104 }; 169 105 170 106 /* ··· 195 133 }, 196 134 }; 197 135 198 - /* 199 - * Function to read a particular channel value. 200 - * @madc - pointer to struct twl4030_madc_data 201 - * @reg - lsb of ADC Channel 202 - * If the i2c read fails it returns an error else returns 0. 136 + /** 137 + * twl4030_madc_channel_raw_read() - Function to read a particular channel value 138 + * @madc: pointer to struct twl4030_madc_data 139 + * @reg: lsb of ADC Channel 140 + * 141 + * Return: 0 on success, an error code otherwise. 203 142 */ 204 143 static int twl4030_madc_channel_raw_read(struct twl4030_madc_data *madc, u8 reg) 205 144 { 206 - u8 msb, lsb; 145 + u16 val; 207 146 int ret; 208 147 /* 209 148 * For each ADC channel, we have MSB and LSB register pair. MSB address 210 149 * is always LSB address+1. reg parameter is the address of LSB register 211 150 */ 212 - ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &msb, reg + 1); 151 + ret = twl_i2c_read_u16(TWL4030_MODULE_MADC, &val, reg); 213 152 if (ret) { 214 - dev_err(madc->dev, "unable to read MSB register 0x%X\n", 215 - reg + 1); 216 - return ret; 217 - } 218 - ret = twl_i2c_read_u8(TWL4030_MODULE_MADC, &lsb, reg); 219 - if (ret) { 220 - dev_err(madc->dev, "unable to read LSB register 0x%X\n", reg); 153 + dev_err(madc->dev, "unable to read register 0x%X\n", reg); 221 154 return ret; 222 155 } 223 156 224 - return (int)(((msb << 8) | lsb) >> 6); 157 + return (int)(val >> 6); 225 158 } 226 159 227 160 /* 228 - * Return battery temperature 161 + * Return battery temperature in degrees Celsius 229 162 * Or < 0 on failure. 230 163 */ 231 164 static int twl4030battery_temperature(int raw_volt) ··· 229 172 int temp, curr, volt, res, ret; 230 173 231 174 volt = (raw_volt * TEMP_STEP_SIZE) / TEMP_PSR_R; 232 - /* Getting and calculating the supply current in micro ampers */ 175 + /* Getting and calculating the supply current in micro amperes */ 233 176 ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, &val, 234 177 REG_BCICTL2); 235 178 if (ret < 0) 236 179 return ret; 180 + 237 181 curr = ((val & TWL4030_BCI_ITHEN) + 1) * 10; 238 182 /* Getting and calculating the thermistor resistance in ohms */ 239 183 res = volt * 1000 / curr; 240 184 /* calculating temperature */ 241 185 for (temp = 58; temp >= 0; temp--) { 242 - int actual = therm_tbl[temp]; 243 - 186 + int actual = twl4030_therm_tbl[temp]; 244 187 if ((actual - res) >= 0) 245 188 break; 246 189 } ··· 262 205 else /* slope of 0.88 mV/mA */ 263 206 return (raw_volt * CURR_STEP_SIZE) / CURR_PSR_R2; 264 207 } 208 + 265 209 /* 266 210 * Function to read channel values 267 211 * @madc - pointer to twl4030_madc_data struct 268 212 * @reg_base - Base address of the first channel 269 - * @Channels - 16 bit bitmap. If the bit is set, channel value is read 213 + * @Channels - 16 bit bitmap. If the bit is set, channel's value is read 270 214 * @buf - The channel values are stored here. if read fails error 271 215 * @raw - Return raw values without conversion 272 216 * value is stored ··· 278 220 long channels, int *buf, 279 221 bool raw) 280 222 { 281 - int count = 0, count_req = 0, i; 223 + int count = 0; 224 + int i; 282 225 u8 reg; 283 226 284 227 for_each_set_bit(i, &channels, TWL4030_MADC_MAX_CHANNELS) { 285 - reg = reg_base + 2 * i; 228 + reg = reg_base + (2 * i); 286 229 buf[i] = twl4030_madc_channel_raw_read(madc, reg); 287 230 if (buf[i] < 0) { 288 - dev_err(madc->dev, 289 - "Unable to read register 0x%X\n", reg); 290 - count_req++; 291 - continue; 231 + dev_err(madc->dev, "Unable to read register 0x%X\n", 232 + reg); 233 + return buf[i]; 292 234 } 293 235 if (raw) { 294 236 count++; ··· 299 241 buf[i] = twl4030battery_current(buf[i]); 300 242 if (buf[i] < 0) { 301 243 dev_err(madc->dev, "err reading current\n"); 302 - count_req++; 244 + return buf[i]; 303 245 } else { 304 246 count++; 305 247 buf[i] = buf[i] - 750; ··· 309 251 buf[i] = twl4030battery_temperature(buf[i]); 310 252 if (buf[i] < 0) { 311 253 dev_err(madc->dev, "err reading temperature\n"); 312 - count_req++; 254 + return buf[i]; 313 255 } else { 314 256 buf[i] -= 3; 315 257 count++; ··· 330 272 twl4030_divider_ratios[i].numerator); 331 273 } 332 274 } 333 - if (count_req) 334 - dev_err(madc->dev, "%d channel conversion failed\n", count_req); 335 275 336 276 return count; 337 277 } ··· 353 297 madc->imr); 354 298 return ret; 355 299 } 300 + 356 301 val &= ~(1 << id); 357 302 ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, val, madc->imr); 358 303 if (ret) { 359 304 dev_err(madc->dev, 360 305 "unable to write imr register 0x%X\n", madc->imr); 361 306 return ret; 362 - 363 307 } 364 308 365 309 return 0; ··· 422 366 continue; 423 367 ret = twl4030_madc_disable_irq(madc, i); 424 368 if (ret < 0) 425 - dev_dbg(madc->dev, "Disable interrupt failed%d\n", i); 369 + dev_dbg(madc->dev, "Disable interrupt failed %d\n", i); 426 370 madc->requests[i].result_pending = 1; 427 371 } 428 372 for (i = 0; i < TWL4030_MADC_NUM_METHODS; i++) { ··· 504 448 { 505 449 const struct twl4030_madc_conversion_method *method; 506 450 int ret = 0; 451 + 452 + if (conv_method != TWL4030_MADC_SW1 && conv_method != TWL4030_MADC_SW2) 453 + return -ENOTSUPP; 454 + 507 455 method = &twl4030_conversion_methods[conv_method]; 508 - switch (conv_method) { 509 - case TWL4030_MADC_SW1: 510 - case TWL4030_MADC_SW2: 511 - ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, 512 - TWL4030_MADC_SW_START, method->ctrl); 513 - if (ret) { 514 - dev_err(madc->dev, 515 - "unable to write ctrl register 0x%X\n", 516 - method->ctrl); 517 - return ret; 518 - } 519 - break; 520 - default: 521 - break; 456 + ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, TWL4030_MADC_SW_START, 457 + method->ctrl); 458 + if (ret) { 459 + dev_err(madc->dev, "unable to write ctrl register 0x%X\n", 460 + method->ctrl); 461 + return ret; 522 462 } 523 463 524 464 return 0; ··· 565 513 int twl4030_madc_conversion(struct twl4030_madc_request *req) 566 514 { 567 515 const struct twl4030_madc_conversion_method *method; 568 - u8 ch_msb, ch_lsb; 569 516 int ret; 570 517 571 518 if (!req || !twl4030_madc) ··· 580 529 ret = -EBUSY; 581 530 goto out; 582 531 } 583 - ch_msb = (req->channels >> 8) & 0xff; 584 - ch_lsb = req->channels & 0xff; 585 532 method = &twl4030_conversion_methods[req->method]; 586 533 /* Select channels to be converted */ 587 - ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, ch_msb, method->sel + 1); 534 + ret = twl_i2c_write_u16(TWL4030_MODULE_MADC, req->channels, method->sel); 588 535 if (ret) { 589 536 dev_err(twl4030_madc->dev, 590 - "unable to write sel register 0x%X\n", method->sel + 1); 591 - goto out; 592 - } 593 - ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, ch_lsb, method->sel); 594 - if (ret) { 595 - dev_err(twl4030_madc->dev, 596 - "unable to write sel register 0x%X\n", method->sel + 1); 537 + "unable to write sel register 0x%X\n", method->sel); 597 538 goto out; 598 539 } 599 540 /* Select averaging for all channels if do_avg is set */ 600 541 if (req->do_avg) { 601 - ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, 602 - ch_msb, method->avg + 1); 542 + ret = twl_i2c_write_u16(TWL4030_MODULE_MADC, req->channels, 543 + method->avg); 603 544 if (ret) { 604 545 dev_err(twl4030_madc->dev, 605 546 "unable to write avg register 0x%X\n", 606 - method->avg + 1); 607 - goto out; 608 - } 609 - ret = twl_i2c_write_u8(TWL4030_MODULE_MADC, 610 - ch_lsb, method->avg); 611 - if (ret) { 612 - dev_err(twl4030_madc->dev, 613 - "unable to write sel reg 0x%X\n", 614 - method->sel + 1); 547 + method->avg); 615 548 goto out; 616 549 } 617 550 } ··· 636 601 } 637 602 EXPORT_SYMBOL_GPL(twl4030_madc_conversion); 638 603 639 - /* 640 - * Return channel value 641 - * Or < 0 on failure. 642 - */ 643 604 int twl4030_get_madc_conversion(int channel_no) 644 605 { 645 606 struct twl4030_madc_request req; ··· 656 625 } 657 626 EXPORT_SYMBOL_GPL(twl4030_get_madc_conversion); 658 627 659 - /* 628 + /** 629 + * twl4030_madc_set_current_generator() - setup bias current 630 + * 631 + * @madc: pointer to twl4030_madc_data struct 632 + * @chan: can be one of the two values: 633 + * TWL4030_BCI_ITHEN 634 + * Enables bias current for main battery type reading 635 + * TWL4030_BCI_TYPEN 636 + * Enables bias current for main battery temperature sensing 637 + * @on: enable or disable chan. 638 + * 660 639 * Function to enable or disable bias current for 661 640 * main battery type reading or temperature sensing 662 - * @madc - pointer to twl4030_madc_data struct 663 - * @chan - can be one of the two values 664 - * TWL4030_BCI_ITHEN - Enables bias current for main battery type reading 665 - * TWL4030_BCI_TYPEN - Enables bias current for main battery temperature 666 - * sensing 667 - * @on - enable or disable chan. 668 641 */ 669 642 static int twl4030_madc_set_current_generator(struct twl4030_madc_data *madc, 670 643 int chan, int on) 671 644 { 672 645 int ret; 646 + int regmask; 673 647 u8 regval; 674 648 675 649 ret = twl_i2c_read_u8(TWL_MODULE_MAIN_CHARGE, ··· 684 648 TWL4030_BCI_BCICTL1); 685 649 return ret; 686 650 } 651 + 652 + regmask = chan ? TWL4030_BCI_ITHEN : TWL4030_BCI_TYPEN; 687 653 if (on) 688 - regval |= chan ? TWL4030_BCI_ITHEN : TWL4030_BCI_TYPEN; 654 + regval |= regmask; 689 655 else 690 - regval &= chan ? ~TWL4030_BCI_ITHEN : ~TWL4030_BCI_TYPEN; 656 + regval &= ~regmask; 657 + 691 658 ret = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE, 692 659 regval, TWL4030_BCI_BCICTL1); 693 660 if (ret) { ··· 705 666 /* 706 667 * Function that sets MADC software power on bit to enable MADC 707 668 * @madc - pointer to twl4030_madc_data struct 708 - * @on - Enable or disable MADC software powen on bit. 669 + * @on - Enable or disable MADC software power on bit. 709 670 * returns error if i2c read/write fails else 0 710 671 */ 711 672 static int twl4030_madc_set_power(struct twl4030_madc_data *madc, int on) ··· 741 702 { 742 703 struct twl4030_madc_data *madc; 743 704 struct twl4030_madc_platform_data *pdata = dev_get_platdata(&pdev->dev); 744 - int ret; 705 + struct device_node *np = pdev->dev.of_node; 706 + int irq, ret; 745 707 u8 regval; 708 + struct iio_dev *iio_dev = NULL; 746 709 747 - if (!pdata) { 748 - dev_err(&pdev->dev, "platform_data not available\n"); 710 + if (!pdata && !np) { 711 + dev_err(&pdev->dev, "neither platform data nor Device Tree node available\n"); 749 712 return -EINVAL; 750 713 } 751 - madc = kzalloc(sizeof(*madc), GFP_KERNEL); 752 - if (!madc) 753 - return -ENOMEM; 754 714 715 + iio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*madc)); 716 + if (!iio_dev) { 717 + dev_err(&pdev->dev, "failed allocating iio device\n"); 718 + return -ENOMEM; 719 + } 720 + 721 + madc = iio_priv(iio_dev); 755 722 madc->dev = &pdev->dev; 723 + 724 + iio_dev->name = dev_name(&pdev->dev); 725 + iio_dev->dev.parent = &pdev->dev; 726 + iio_dev->dev.of_node = pdev->dev.of_node; 727 + iio_dev->info = &twl4030_madc_iio_info; 728 + iio_dev->modes = INDIO_DIRECT_MODE; 729 + iio_dev->channels = twl4030_madc_iio_channels; 730 + iio_dev->num_channels = ARRAY_SIZE(twl4030_madc_iio_channels); 756 731 757 732 /* 758 733 * Phoenix provides 2 interrupt lines. The first one is connected to 759 734 * the OMAP. The other one can be connected to the other processor such 760 735 * as modem. Hence two separate ISR and IMR registers. 761 736 */ 762 - madc->imr = (pdata->irq_line == 1) ? 763 - TWL4030_MADC_IMR1 : TWL4030_MADC_IMR2; 764 - madc->isr = (pdata->irq_line == 1) ? 765 - TWL4030_MADC_ISR1 : TWL4030_MADC_ISR2; 737 + if (pdata) 738 + madc->use_second_irq = (pdata->irq_line != 1); 739 + else 740 + madc->use_second_irq = of_property_read_bool(np, 741 + "ti,system-uses-second-madc-irq"); 742 + 743 + madc->imr = madc->use_second_irq ? TWL4030_MADC_IMR2 : 744 + TWL4030_MADC_IMR1; 745 + madc->isr = madc->use_second_irq ? TWL4030_MADC_ISR2 : 746 + TWL4030_MADC_ISR1; 747 + 766 748 ret = twl4030_madc_set_power(madc, 1); 767 749 if (ret < 0) 768 - goto err_power; 750 + return ret; 769 751 ret = twl4030_madc_set_current_generator(madc, 0, 1); 770 752 if (ret < 0) 771 753 goto err_current_generator; ··· 828 768 } 829 769 } 830 770 831 - platform_set_drvdata(pdev, madc); 771 + platform_set_drvdata(pdev, iio_dev); 832 772 mutex_init(&madc->lock); 833 - ret = request_threaded_irq(platform_get_irq(pdev, 0), NULL, 773 + 774 + irq = platform_get_irq(pdev, 0); 775 + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, 834 776 twl4030_madc_threaded_irq_handler, 835 777 IRQF_TRIGGER_RISING, "twl4030_madc", madc); 836 778 if (ret) { 837 - dev_dbg(&pdev->dev, "could not request irq\n"); 779 + dev_err(&pdev->dev, "could not request irq\n"); 838 780 goto err_i2c; 839 781 } 840 782 twl4030_madc = madc; 783 + 784 + ret = iio_device_register(iio_dev); 785 + if (ret) { 786 + dev_err(&pdev->dev, "could not register iio device\n"); 787 + goto err_i2c; 788 + } 789 + 841 790 return 0; 791 + 842 792 err_i2c: 843 793 twl4030_madc_set_current_generator(madc, 0, 0); 844 794 err_current_generator: 845 795 twl4030_madc_set_power(madc, 0); 846 - err_power: 847 - kfree(madc); 848 - 849 796 return ret; 850 797 } 851 798 852 799 static int twl4030_madc_remove(struct platform_device *pdev) 853 800 { 854 - struct twl4030_madc_data *madc = platform_get_drvdata(pdev); 801 + struct iio_dev *iio_dev = platform_get_drvdata(pdev); 802 + struct twl4030_madc_data *madc = iio_priv(iio_dev); 855 803 856 - free_irq(platform_get_irq(pdev, 0), madc); 804 + iio_device_unregister(iio_dev); 805 + 857 806 twl4030_madc_set_current_generator(madc, 0, 0); 858 807 twl4030_madc_set_power(madc, 0); 859 - kfree(madc); 860 808 861 809 return 0; 862 810 } 811 + 812 + #ifdef CONFIG_OF 813 + static const struct of_device_id twl_madc_of_match[] = { 814 + { .compatible = "ti,twl4030-madc", }, 815 + { }, 816 + }; 817 + MODULE_DEVICE_TABLE(of, twl_madc_of_match); 818 + #endif 863 819 864 820 static struct platform_driver twl4030_madc_driver = { 865 821 .probe = twl4030_madc_probe, ··· 883 807 .driver = { 884 808 .name = "twl4030_madc", 885 809 .owner = THIS_MODULE, 886 - }, 810 + .of_match_table = of_match_ptr(twl_madc_of_match), 811 + }, 887 812 }; 888 813 889 814 module_platform_driver(twl4030_madc_driver);
-1
drivers/mfd/twl6030-irq.c
··· 31 31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 32 32 */ 33 33 34 - #include <linux/init.h> 35 34 #include <linux/export.h> 36 35 #include <linux/interrupt.h> 37 36 #include <linux/irq.h>
+5 -1
drivers/mfd/twl6040.c
··· 661 661 init_completion(&twl6040->ready); 662 662 663 663 twl6040->rev = twl6040_reg_read(twl6040, TWL6040_REG_ASICREV); 664 + if (twl6040->rev < 0) { 665 + dev_err(&client->dev, "Failed to read revision register: %d\n", 666 + twl6040->rev); 667 + goto gpio_err; 668 + } 664 669 665 670 /* ERRATA: Automatic power-up is not possible in ES1.0 */ 666 671 if (twl6040_get_revid(twl6040) > TWL6040_REV_ES1_0) ··· 708 703 } 709 704 710 705 /* dual-access registers controlled by I2C only */ 711 - twl6040_set_bits(twl6040, TWL6040_REG_ACCCTL, TWL6040_I2CSEL); 712 706 regmap_register_patch(twl6040->regmap, twl6040_patch, 713 707 ARRAY_SIZE(twl6040_patch)); 714 708
+1 -3
drivers/mfd/ucb1x00-core.c
··· 742 742 } 743 743 #endif 744 744 745 - static const struct dev_pm_ops ucb1x00_pm_ops = { 746 - SET_SYSTEM_SLEEP_PM_OPS(ucb1x00_suspend, ucb1x00_resume) 747 - }; 745 + static SIMPLE_DEV_PM_OPS(ucb1x00_pm_ops, ucb1x00_suspend, ucb1x00_resume); 748 746 749 747 static struct mcp_driver ucb1x00_driver = { 750 748 .drv = {
+1 -2
drivers/mfd/vexpress-config.c
··· 16 16 #include <linux/bitops.h> 17 17 #include <linux/completion.h> 18 18 #include <linux/export.h> 19 - #include <linux/init.h> 20 19 #include <linux/list.h> 21 20 #include <linux/of.h> 22 21 #include <linux/of_device.h> ··· 26 27 27 28 #define VEXPRESS_CONFIG_MAX_BRIDGES 2 28 29 29 - struct vexpress_config_bridge { 30 + static struct vexpress_config_bridge { 30 31 struct device_node *node; 31 32 struct vexpress_config_bridge_info *info; 32 33 struct list_head transactions;
+1 -1
drivers/mfd/vexpress-sysreg.c
··· 168 168 struct device_node *node) 169 169 { 170 170 struct vexpress_sysreg_config_func *config_func; 171 - u32 site; 171 + u32 site = 0; 172 172 u32 position = 0; 173 173 u32 dcc = 0; 174 174 u32 func_device[2];
+36
drivers/mfd/wm5102-tables.c
··· 73 73 { 0x171, 0x0000 }, 74 74 { 0x35E, 0x000C }, 75 75 { 0x2D4, 0x0000 }, 76 + { 0x4DC, 0x0900 }, 76 77 { 0x80, 0x0000 }, 77 78 }; 78 79 ··· 1840 1839 case ARIZONA_DSP1_STATUS_1: 1841 1840 case ARIZONA_DSP1_STATUS_2: 1842 1841 case ARIZONA_DSP1_STATUS_3: 1842 + case ARIZONA_DSP1_WDMA_BUFFER_1: 1843 + case ARIZONA_DSP1_WDMA_BUFFER_2: 1844 + case ARIZONA_DSP1_WDMA_BUFFER_3: 1845 + case ARIZONA_DSP1_WDMA_BUFFER_4: 1846 + case ARIZONA_DSP1_WDMA_BUFFER_5: 1847 + case ARIZONA_DSP1_WDMA_BUFFER_6: 1848 + case ARIZONA_DSP1_WDMA_BUFFER_7: 1849 + case ARIZONA_DSP1_WDMA_BUFFER_8: 1850 + case ARIZONA_DSP1_RDMA_BUFFER_1: 1851 + case ARIZONA_DSP1_RDMA_BUFFER_2: 1852 + case ARIZONA_DSP1_RDMA_BUFFER_3: 1853 + case ARIZONA_DSP1_RDMA_BUFFER_4: 1854 + case ARIZONA_DSP1_RDMA_BUFFER_5: 1855 + case ARIZONA_DSP1_RDMA_BUFFER_6: 1856 + case ARIZONA_DSP1_WDMA_CONFIG_1: 1857 + case ARIZONA_DSP1_WDMA_CONFIG_2: 1858 + case ARIZONA_DSP1_RDMA_CONFIG_1: 1843 1859 case ARIZONA_DSP1_SCRATCH_0: 1844 1860 case ARIZONA_DSP1_SCRATCH_1: 1845 1861 case ARIZONA_DSP1_SCRATCH_2: ··· 1912 1894 case ARIZONA_AOD_IRQ1: 1913 1895 case ARIZONA_AOD_IRQ2: 1914 1896 case ARIZONA_AOD_IRQ_RAW_STATUS: 1897 + case ARIZONA_DSP1_CLOCKING_1: 1915 1898 case ARIZONA_DSP1_STATUS_1: 1916 1899 case ARIZONA_DSP1_STATUS_2: 1917 1900 case ARIZONA_DSP1_STATUS_3: 1901 + case ARIZONA_DSP1_WDMA_BUFFER_1: 1902 + case ARIZONA_DSP1_WDMA_BUFFER_2: 1903 + case ARIZONA_DSP1_WDMA_BUFFER_3: 1904 + case ARIZONA_DSP1_WDMA_BUFFER_4: 1905 + case ARIZONA_DSP1_WDMA_BUFFER_5: 1906 + case ARIZONA_DSP1_WDMA_BUFFER_6: 1907 + case ARIZONA_DSP1_WDMA_BUFFER_7: 1908 + case ARIZONA_DSP1_WDMA_BUFFER_8: 1909 + case ARIZONA_DSP1_RDMA_BUFFER_1: 1910 + case ARIZONA_DSP1_RDMA_BUFFER_2: 1911 + case ARIZONA_DSP1_RDMA_BUFFER_3: 1912 + case ARIZONA_DSP1_RDMA_BUFFER_4: 1913 + case ARIZONA_DSP1_RDMA_BUFFER_5: 1914 + case ARIZONA_DSP1_RDMA_BUFFER_6: 1915 + case ARIZONA_DSP1_WDMA_CONFIG_1: 1916 + case ARIZONA_DSP1_WDMA_CONFIG_2: 1917 + case ARIZONA_DSP1_RDMA_CONFIG_1: 1918 1918 case ARIZONA_DSP1_SCRATCH_0: 1919 1919 case ARIZONA_DSP1_SCRATCH_1: 1920 1920 case ARIZONA_DSP1_SCRATCH_2:
+173 -1
drivers/mfd/wm5110-tables.c
··· 538 538 { 0x00000219, 0x01A6 }, /* R537 - Mic Bias Ctrl 2 */ 539 539 { 0x0000021A, 0x01A6 }, /* R538 - Mic Bias Ctrl 3 */ 540 540 { 0x00000293, 0x0000 }, /* R659 - Accessory Detect Mode 1 */ 541 - { 0x0000029B, 0x0020 }, /* R667 - Headphone Detect 1 */ 541 + { 0x0000029B, 0x0028 }, /* R667 - Headphone Detect 1 */ 542 542 { 0x0000029C, 0x0000 }, /* R668 - Headphone Detect 2 */ 543 543 { 0x000002A2, 0x0000 }, /* R674 - Micd clamp control */ 544 544 { 0x000002A3, 0x1102 }, /* R675 - Mic Detect 1 */ ··· 2461 2461 case ARIZONA_DSP1_STATUS_1: 2462 2462 case ARIZONA_DSP1_STATUS_2: 2463 2463 case ARIZONA_DSP1_STATUS_3: 2464 + case ARIZONA_DSP1_STATUS_4: 2465 + case ARIZONA_DSP1_WDMA_BUFFER_1: 2466 + case ARIZONA_DSP1_WDMA_BUFFER_2: 2467 + case ARIZONA_DSP1_WDMA_BUFFER_3: 2468 + case ARIZONA_DSP1_WDMA_BUFFER_4: 2469 + case ARIZONA_DSP1_WDMA_BUFFER_5: 2470 + case ARIZONA_DSP1_WDMA_BUFFER_6: 2471 + case ARIZONA_DSP1_WDMA_BUFFER_7: 2472 + case ARIZONA_DSP1_WDMA_BUFFER_8: 2473 + case ARIZONA_DSP1_RDMA_BUFFER_1: 2474 + case ARIZONA_DSP1_RDMA_BUFFER_2: 2475 + case ARIZONA_DSP1_RDMA_BUFFER_3: 2476 + case ARIZONA_DSP1_RDMA_BUFFER_4: 2477 + case ARIZONA_DSP1_RDMA_BUFFER_5: 2478 + case ARIZONA_DSP1_RDMA_BUFFER_6: 2479 + case ARIZONA_DSP1_WDMA_CONFIG_1: 2480 + case ARIZONA_DSP1_WDMA_CONFIG_2: 2481 + case ARIZONA_DSP1_WDMA_OFFSET_1: 2482 + case ARIZONA_DSP1_RDMA_CONFIG_1: 2483 + case ARIZONA_DSP1_RDMA_OFFSET_1: 2484 + case ARIZONA_DSP1_EXTERNAL_START_SELECT_1: 2464 2485 case ARIZONA_DSP1_SCRATCH_0: 2465 2486 case ARIZONA_DSP1_SCRATCH_1: 2466 2487 case ARIZONA_DSP1_SCRATCH_2: ··· 2491 2470 case ARIZONA_DSP2_STATUS_1: 2492 2471 case ARIZONA_DSP2_STATUS_2: 2493 2472 case ARIZONA_DSP2_STATUS_3: 2473 + case ARIZONA_DSP2_STATUS_4: 2474 + case ARIZONA_DSP2_WDMA_BUFFER_1: 2475 + case ARIZONA_DSP2_WDMA_BUFFER_2: 2476 + case ARIZONA_DSP2_WDMA_BUFFER_3: 2477 + case ARIZONA_DSP2_WDMA_BUFFER_4: 2478 + case ARIZONA_DSP2_WDMA_BUFFER_5: 2479 + case ARIZONA_DSP2_WDMA_BUFFER_6: 2480 + case ARIZONA_DSP2_WDMA_BUFFER_7: 2481 + case ARIZONA_DSP2_WDMA_BUFFER_8: 2482 + case ARIZONA_DSP2_RDMA_BUFFER_1: 2483 + case ARIZONA_DSP2_RDMA_BUFFER_2: 2484 + case ARIZONA_DSP2_RDMA_BUFFER_3: 2485 + case ARIZONA_DSP2_RDMA_BUFFER_4: 2486 + case ARIZONA_DSP2_RDMA_BUFFER_5: 2487 + case ARIZONA_DSP2_RDMA_BUFFER_6: 2488 + case ARIZONA_DSP2_WDMA_CONFIG_1: 2489 + case ARIZONA_DSP2_WDMA_CONFIG_2: 2490 + case ARIZONA_DSP2_WDMA_OFFSET_1: 2491 + case ARIZONA_DSP2_RDMA_CONFIG_1: 2492 + case ARIZONA_DSP2_RDMA_OFFSET_1: 2493 + case ARIZONA_DSP2_EXTERNAL_START_SELECT_1: 2494 2494 case ARIZONA_DSP2_SCRATCH_0: 2495 2495 case ARIZONA_DSP2_SCRATCH_1: 2496 2496 case ARIZONA_DSP2_SCRATCH_2: ··· 2521 2479 case ARIZONA_DSP3_STATUS_1: 2522 2480 case ARIZONA_DSP3_STATUS_2: 2523 2481 case ARIZONA_DSP3_STATUS_3: 2482 + case ARIZONA_DSP3_STATUS_4: 2483 + case ARIZONA_DSP3_WDMA_BUFFER_1: 2484 + case ARIZONA_DSP3_WDMA_BUFFER_2: 2485 + case ARIZONA_DSP3_WDMA_BUFFER_3: 2486 + case ARIZONA_DSP3_WDMA_BUFFER_4: 2487 + case ARIZONA_DSP3_WDMA_BUFFER_5: 2488 + case ARIZONA_DSP3_WDMA_BUFFER_6: 2489 + case ARIZONA_DSP3_WDMA_BUFFER_7: 2490 + case ARIZONA_DSP3_WDMA_BUFFER_8: 2491 + case ARIZONA_DSP3_RDMA_BUFFER_1: 2492 + case ARIZONA_DSP3_RDMA_BUFFER_2: 2493 + case ARIZONA_DSP3_RDMA_BUFFER_3: 2494 + case ARIZONA_DSP3_RDMA_BUFFER_4: 2495 + case ARIZONA_DSP3_RDMA_BUFFER_5: 2496 + case ARIZONA_DSP3_RDMA_BUFFER_6: 2497 + case ARIZONA_DSP3_WDMA_CONFIG_1: 2498 + case ARIZONA_DSP3_WDMA_CONFIG_2: 2499 + case ARIZONA_DSP3_WDMA_OFFSET_1: 2500 + case ARIZONA_DSP3_RDMA_CONFIG_1: 2501 + case ARIZONA_DSP3_RDMA_OFFSET_1: 2502 + case ARIZONA_DSP3_EXTERNAL_START_SELECT_1: 2524 2503 case ARIZONA_DSP3_SCRATCH_0: 2525 2504 case ARIZONA_DSP3_SCRATCH_1: 2526 2505 case ARIZONA_DSP3_SCRATCH_2: ··· 2551 2488 case ARIZONA_DSP4_STATUS_1: 2552 2489 case ARIZONA_DSP4_STATUS_2: 2553 2490 case ARIZONA_DSP4_STATUS_3: 2491 + case ARIZONA_DSP4_STATUS_4: 2492 + case ARIZONA_DSP4_WDMA_BUFFER_1: 2493 + case ARIZONA_DSP4_WDMA_BUFFER_2: 2494 + case ARIZONA_DSP4_WDMA_BUFFER_3: 2495 + case ARIZONA_DSP4_WDMA_BUFFER_4: 2496 + case ARIZONA_DSP4_WDMA_BUFFER_5: 2497 + case ARIZONA_DSP4_WDMA_BUFFER_6: 2498 + case ARIZONA_DSP4_WDMA_BUFFER_7: 2499 + case ARIZONA_DSP4_WDMA_BUFFER_8: 2500 + case ARIZONA_DSP4_RDMA_BUFFER_1: 2501 + case ARIZONA_DSP4_RDMA_BUFFER_2: 2502 + case ARIZONA_DSP4_RDMA_BUFFER_3: 2503 + case ARIZONA_DSP4_RDMA_BUFFER_4: 2504 + case ARIZONA_DSP4_RDMA_BUFFER_5: 2505 + case ARIZONA_DSP4_RDMA_BUFFER_6: 2506 + case ARIZONA_DSP4_WDMA_CONFIG_1: 2507 + case ARIZONA_DSP4_WDMA_CONFIG_2: 2508 + case ARIZONA_DSP4_WDMA_OFFSET_1: 2509 + case ARIZONA_DSP4_RDMA_CONFIG_1: 2510 + case ARIZONA_DSP4_RDMA_OFFSET_1: 2511 + case ARIZONA_DSP4_EXTERNAL_START_SELECT_1: 2554 2512 case ARIZONA_DSP4_SCRATCH_0: 2555 2513 case ARIZONA_DSP4_SCRATCH_1: 2556 2514 case ARIZONA_DSP4_SCRATCH_2: ··· 2627 2543 case ARIZONA_DSP1_STATUS_1: 2628 2544 case ARIZONA_DSP1_STATUS_2: 2629 2545 case ARIZONA_DSP1_STATUS_3: 2546 + case ARIZONA_DSP1_STATUS_4: 2547 + case ARIZONA_DSP1_WDMA_BUFFER_1: 2548 + case ARIZONA_DSP1_WDMA_BUFFER_2: 2549 + case ARIZONA_DSP1_WDMA_BUFFER_3: 2550 + case ARIZONA_DSP1_WDMA_BUFFER_4: 2551 + case ARIZONA_DSP1_WDMA_BUFFER_5: 2552 + case ARIZONA_DSP1_WDMA_BUFFER_6: 2553 + case ARIZONA_DSP1_WDMA_BUFFER_7: 2554 + case ARIZONA_DSP1_WDMA_BUFFER_8: 2555 + case ARIZONA_DSP1_RDMA_BUFFER_1: 2556 + case ARIZONA_DSP1_RDMA_BUFFER_2: 2557 + case ARIZONA_DSP1_RDMA_BUFFER_3: 2558 + case ARIZONA_DSP1_RDMA_BUFFER_4: 2559 + case ARIZONA_DSP1_RDMA_BUFFER_5: 2560 + case ARIZONA_DSP1_RDMA_BUFFER_6: 2561 + case ARIZONA_DSP1_WDMA_CONFIG_1: 2562 + case ARIZONA_DSP1_WDMA_CONFIG_2: 2563 + case ARIZONA_DSP1_WDMA_OFFSET_1: 2564 + case ARIZONA_DSP1_RDMA_CONFIG_1: 2565 + case ARIZONA_DSP1_RDMA_OFFSET_1: 2566 + case ARIZONA_DSP1_EXTERNAL_START_SELECT_1: 2630 2567 case ARIZONA_DSP1_SCRATCH_0: 2631 2568 case ARIZONA_DSP1_SCRATCH_1: 2632 2569 case ARIZONA_DSP1_SCRATCH_2: 2633 2570 case ARIZONA_DSP1_SCRATCH_3: 2571 + case ARIZONA_DSP1_CLOCKING_1: 2634 2572 case ARIZONA_DSP2_STATUS_1: 2635 2573 case ARIZONA_DSP2_STATUS_2: 2636 2574 case ARIZONA_DSP2_STATUS_3: 2575 + case ARIZONA_DSP2_STATUS_4: 2576 + case ARIZONA_DSP2_WDMA_BUFFER_1: 2577 + case ARIZONA_DSP2_WDMA_BUFFER_2: 2578 + case ARIZONA_DSP2_WDMA_BUFFER_3: 2579 + case ARIZONA_DSP2_WDMA_BUFFER_4: 2580 + case ARIZONA_DSP2_WDMA_BUFFER_5: 2581 + case ARIZONA_DSP2_WDMA_BUFFER_6: 2582 + case ARIZONA_DSP2_WDMA_BUFFER_7: 2583 + case ARIZONA_DSP2_WDMA_BUFFER_8: 2584 + case ARIZONA_DSP2_RDMA_BUFFER_1: 2585 + case ARIZONA_DSP2_RDMA_BUFFER_2: 2586 + case ARIZONA_DSP2_RDMA_BUFFER_3: 2587 + case ARIZONA_DSP2_RDMA_BUFFER_4: 2588 + case ARIZONA_DSP2_RDMA_BUFFER_5: 2589 + case ARIZONA_DSP2_RDMA_BUFFER_6: 2590 + case ARIZONA_DSP2_WDMA_CONFIG_1: 2591 + case ARIZONA_DSP2_WDMA_CONFIG_2: 2592 + case ARIZONA_DSP2_WDMA_OFFSET_1: 2593 + case ARIZONA_DSP2_RDMA_CONFIG_1: 2594 + case ARIZONA_DSP2_RDMA_OFFSET_1: 2595 + case ARIZONA_DSP2_EXTERNAL_START_SELECT_1: 2637 2596 case ARIZONA_DSP2_SCRATCH_0: 2638 2597 case ARIZONA_DSP2_SCRATCH_1: 2639 2598 case ARIZONA_DSP2_SCRATCH_2: 2640 2599 case ARIZONA_DSP2_SCRATCH_3: 2600 + case ARIZONA_DSP2_CLOCKING_1: 2641 2601 case ARIZONA_DSP3_STATUS_1: 2642 2602 case ARIZONA_DSP3_STATUS_2: 2643 2603 case ARIZONA_DSP3_STATUS_3: 2604 + case ARIZONA_DSP3_STATUS_4: 2605 + case ARIZONA_DSP3_WDMA_BUFFER_1: 2606 + case ARIZONA_DSP3_WDMA_BUFFER_2: 2607 + case ARIZONA_DSP3_WDMA_BUFFER_3: 2608 + case ARIZONA_DSP3_WDMA_BUFFER_4: 2609 + case ARIZONA_DSP3_WDMA_BUFFER_5: 2610 + case ARIZONA_DSP3_WDMA_BUFFER_6: 2611 + case ARIZONA_DSP3_WDMA_BUFFER_7: 2612 + case ARIZONA_DSP3_WDMA_BUFFER_8: 2613 + case ARIZONA_DSP3_RDMA_BUFFER_1: 2614 + case ARIZONA_DSP3_RDMA_BUFFER_2: 2615 + case ARIZONA_DSP3_RDMA_BUFFER_3: 2616 + case ARIZONA_DSP3_RDMA_BUFFER_4: 2617 + case ARIZONA_DSP3_RDMA_BUFFER_5: 2618 + case ARIZONA_DSP3_RDMA_BUFFER_6: 2619 + case ARIZONA_DSP3_WDMA_CONFIG_1: 2620 + case ARIZONA_DSP3_WDMA_CONFIG_2: 2621 + case ARIZONA_DSP3_WDMA_OFFSET_1: 2622 + case ARIZONA_DSP3_RDMA_CONFIG_1: 2623 + case ARIZONA_DSP3_RDMA_OFFSET_1: 2624 + case ARIZONA_DSP3_EXTERNAL_START_SELECT_1: 2644 2625 case ARIZONA_DSP3_SCRATCH_0: 2645 2626 case ARIZONA_DSP3_SCRATCH_1: 2646 2627 case ARIZONA_DSP3_SCRATCH_2: 2647 2628 case ARIZONA_DSP3_SCRATCH_3: 2629 + case ARIZONA_DSP3_CLOCKING_1: 2648 2630 case ARIZONA_DSP4_STATUS_1: 2649 2631 case ARIZONA_DSP4_STATUS_2: 2650 2632 case ARIZONA_DSP4_STATUS_3: 2633 + case ARIZONA_DSP4_STATUS_4: 2634 + case ARIZONA_DSP4_WDMA_BUFFER_1: 2635 + case ARIZONA_DSP4_WDMA_BUFFER_2: 2636 + case ARIZONA_DSP4_WDMA_BUFFER_3: 2637 + case ARIZONA_DSP4_WDMA_BUFFER_4: 2638 + case ARIZONA_DSP4_WDMA_BUFFER_5: 2639 + case ARIZONA_DSP4_WDMA_BUFFER_6: 2640 + case ARIZONA_DSP4_WDMA_BUFFER_7: 2641 + case ARIZONA_DSP4_WDMA_BUFFER_8: 2642 + case ARIZONA_DSP4_RDMA_BUFFER_1: 2643 + case ARIZONA_DSP4_RDMA_BUFFER_2: 2644 + case ARIZONA_DSP4_RDMA_BUFFER_3: 2645 + case ARIZONA_DSP4_RDMA_BUFFER_4: 2646 + case ARIZONA_DSP4_RDMA_BUFFER_5: 2647 + case ARIZONA_DSP4_RDMA_BUFFER_6: 2648 + case ARIZONA_DSP4_WDMA_CONFIG_1: 2649 + case ARIZONA_DSP4_WDMA_CONFIG_2: 2650 + case ARIZONA_DSP4_WDMA_OFFSET_1: 2651 + case ARIZONA_DSP4_RDMA_CONFIG_1: 2652 + case ARIZONA_DSP4_RDMA_OFFSET_1: 2653 + case ARIZONA_DSP4_EXTERNAL_START_SELECT_1: 2651 2654 case ARIZONA_DSP4_SCRATCH_0: 2652 2655 case ARIZONA_DSP4_SCRATCH_1: 2653 2656 case ARIZONA_DSP4_SCRATCH_2: 2654 2657 case ARIZONA_DSP4_SCRATCH_3: 2658 + case ARIZONA_DSP4_CLOCKING_1: 2655 2659 return true; 2656 2660 default: 2657 2661 return wm5110_is_adsp_memory(dev, reg);
-1
drivers/mfd/wm8350-core.c
··· 14 14 15 15 #include <linux/kernel.h> 16 16 #include <linux/module.h> 17 - #include <linux/init.h> 18 17 #include <linux/slab.h> 19 18 #include <linux/bug.h> 20 19 #include <linux/device.h>
-1
drivers/mfd/wm8350-irq.c
··· 14 14 15 15 #include <linux/kernel.h> 16 16 #include <linux/module.h> 17 - #include <linux/init.h> 18 17 #include <linux/bug.h> 19 18 #include <linux/device.h> 20 19 #include <linux/interrupt.h>
+5 -17
drivers/mfd/wm8400-core.c
··· 161 161 const struct i2c_device_id *id) 162 162 { 163 163 struct wm8400 *wm8400; 164 - int ret; 165 164 166 165 wm8400 = devm_kzalloc(&i2c->dev, sizeof(struct wm8400), GFP_KERNEL); 167 - if (wm8400 == NULL) { 168 - ret = -ENOMEM; 169 - goto err; 170 - } 166 + if (!wm8400) 167 + return -ENOMEM; 171 168 172 169 wm8400->regmap = devm_regmap_init_i2c(i2c, &wm8400_regmap_config); 173 - if (IS_ERR(wm8400->regmap)) { 174 - ret = PTR_ERR(wm8400->regmap); 175 - goto err; 176 - } 170 + if (IS_ERR(wm8400->regmap)) 171 + return PTR_ERR(wm8400->regmap); 177 172 178 173 wm8400->dev = &i2c->dev; 179 174 i2c_set_clientdata(i2c, wm8400); 180 175 181 - ret = wm8400_init(wm8400, dev_get_platdata(&i2c->dev)); 182 - if (ret != 0) 183 - goto err; 184 - 185 - return 0; 186 - 187 - err: 188 - return ret; 176 + return wm8400_init(wm8400, dev_get_platdata(&i2c->dev)); 189 177 } 190 178 191 179 static int wm8400_i2c_remove(struct i2c_client *i2c)
+83 -56
drivers/watchdog/iTCO_wdt.c
··· 48 48 49 49 /* Module and version information */ 50 50 #define DRV_NAME "iTCO_wdt" 51 - #define DRV_VERSION "1.10" 51 + #define DRV_VERSION "1.11" 52 52 53 53 /* Includes */ 54 54 #include <linux/module.h> /* For module specific items */ ··· 92 92 unsigned int iTCO_version; 93 93 struct resource *tco_res; 94 94 struct resource *smi_res; 95 - struct resource *gcs_res; 96 - /* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2)*/ 97 - unsigned long __iomem *gcs; 95 + /* 96 + * NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2), 97 + * or memory-mapped PMC register bit 4 (TCO version 3). 98 + */ 99 + struct resource *gcs_pmc_res; 100 + unsigned long __iomem *gcs_pmc; 98 101 /* the lock for io operations */ 99 102 spinlock_t io_lock; 100 103 struct platform_device *dev; ··· 128 125 * Some TCO specific functions 129 126 */ 130 127 131 - static inline unsigned int seconds_to_ticks(int seconds) 128 + /* 129 + * The iTCO v1 and v2's internal timer is stored as ticks which decrement 130 + * every 0.6 seconds. v3's internal timer is stored as seconds (some 131 + * datasheets incorrectly state 0.6 seconds). 132 + */ 133 + static inline unsigned int seconds_to_ticks(int secs) 132 134 { 133 - /* the internal timer is stored as ticks which decrement 134 - * every 0.6 seconds */ 135 - return (seconds * 10) / 6; 135 + return iTCO_wdt_private.iTCO_version == 3 ? secs : (secs * 10) / 6; 136 + } 137 + 138 + static inline unsigned int ticks_to_seconds(int ticks) 139 + { 140 + return iTCO_wdt_private.iTCO_version == 3 ? ticks : (ticks * 6) / 10; 136 141 } 137 142 138 143 static void iTCO_wdt_set_NO_REBOOT_bit(void) ··· 148 137 u32 val32; 149 138 150 139 /* Set the NO_REBOOT bit: this disables reboots */ 151 - if (iTCO_wdt_private.iTCO_version == 2) { 152 - val32 = readl(iTCO_wdt_private.gcs); 140 + if (iTCO_wdt_private.iTCO_version == 3) { 141 + val32 = readl(iTCO_wdt_private.gcs_pmc); 142 + val32 |= 0x00000010; 143 + writel(val32, iTCO_wdt_private.gcs_pmc); 144 + } else if (iTCO_wdt_private.iTCO_version == 2) { 145 + val32 = readl(iTCO_wdt_private.gcs_pmc); 153 146 val32 |= 0x00000020; 154 - writel(val32, iTCO_wdt_private.gcs); 147 + writel(val32, iTCO_wdt_private.gcs_pmc); 155 148 } else if (iTCO_wdt_private.iTCO_version == 1) { 156 149 pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32); 157 150 val32 |= 0x00000002; ··· 169 154 u32 val32; 170 155 171 156 /* Unset the NO_REBOOT bit: this enables reboots */ 172 - if (iTCO_wdt_private.iTCO_version == 2) { 173 - val32 = readl(iTCO_wdt_private.gcs); 174 - val32 &= 0xffffffdf; 175 - writel(val32, iTCO_wdt_private.gcs); 157 + if (iTCO_wdt_private.iTCO_version == 3) { 158 + val32 = readl(iTCO_wdt_private.gcs_pmc); 159 + val32 &= 0xffffffef; 160 + writel(val32, iTCO_wdt_private.gcs_pmc); 176 161 177 - val32 = readl(iTCO_wdt_private.gcs); 162 + val32 = readl(iTCO_wdt_private.gcs_pmc); 163 + if (val32 & 0x00000010) 164 + ret = -EIO; 165 + } else if (iTCO_wdt_private.iTCO_version == 2) { 166 + val32 = readl(iTCO_wdt_private.gcs_pmc); 167 + val32 &= 0xffffffdf; 168 + writel(val32, iTCO_wdt_private.gcs_pmc); 169 + 170 + val32 = readl(iTCO_wdt_private.gcs_pmc); 178 171 if (val32 & 0x00000020) 179 172 ret = -EIO; 180 173 } else if (iTCO_wdt_private.iTCO_version == 1) { ··· 215 192 216 193 /* Force the timer to its reload value by writing to the TCO_RLD 217 194 register */ 218 - if (iTCO_wdt_private.iTCO_version == 2) 195 + if (iTCO_wdt_private.iTCO_version >= 2) 219 196 outw(0x01, TCO_RLD); 220 197 else if (iTCO_wdt_private.iTCO_version == 1) 221 198 outb(0x01, TCO_RLD); ··· 263 240 iTCO_vendor_pre_keepalive(iTCO_wdt_private.smi_res, wd_dev->timeout); 264 241 265 242 /* Reload the timer by writing to the TCO Timer Counter register */ 266 - if (iTCO_wdt_private.iTCO_version == 2) 243 + if (iTCO_wdt_private.iTCO_version >= 2) { 267 244 outw(0x01, TCO_RLD); 268 - else if (iTCO_wdt_private.iTCO_version == 1) { 245 + } else if (iTCO_wdt_private.iTCO_version == 1) { 269 246 /* Reset the timeout status bit so that the timer 270 247 * needs to count down twice again before rebooting */ 271 248 outw(0x0008, TCO1_STS); /* write 1 to clear bit */ ··· 293 270 /* "Values of 0h-3h are ignored and should not be attempted" */ 294 271 if (tmrval < 0x04) 295 272 return -EINVAL; 296 - if (((iTCO_wdt_private.iTCO_version == 2) && (tmrval > 0x3ff)) || 273 + if (((iTCO_wdt_private.iTCO_version >= 2) && (tmrval > 0x3ff)) || 297 274 ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f))) 298 275 return -EINVAL; 299 276 300 277 iTCO_vendor_pre_set_heartbeat(tmrval); 301 278 302 279 /* Write new heartbeat to watchdog */ 303 - if (iTCO_wdt_private.iTCO_version == 2) { 280 + if (iTCO_wdt_private.iTCO_version >= 2) { 304 281 spin_lock(&iTCO_wdt_private.io_lock); 305 282 val16 = inw(TCOv2_TMR); 306 283 val16 &= 0xfc00; ··· 335 312 unsigned int time_left = 0; 336 313 337 314 /* read the TCO Timer */ 338 - if (iTCO_wdt_private.iTCO_version == 2) { 315 + if (iTCO_wdt_private.iTCO_version >= 2) { 339 316 spin_lock(&iTCO_wdt_private.io_lock); 340 317 val16 = inw(TCO_RLD); 341 318 val16 &= 0x3ff; 342 319 spin_unlock(&iTCO_wdt_private.io_lock); 343 320 344 - time_left = (val16 * 6) / 10; 321 + time_left = ticks_to_seconds(val16); 345 322 } else if (iTCO_wdt_private.iTCO_version == 1) { 346 323 spin_lock(&iTCO_wdt_private.io_lock); 347 324 val8 = inb(TCO_RLD); ··· 350 327 val8 += (inb(TCOv1_TMR) & 0x3f); 351 328 spin_unlock(&iTCO_wdt_private.io_lock); 352 329 353 - time_left = (val8 * 6) / 10; 330 + time_left = ticks_to_seconds(val8); 354 331 } 355 332 return time_left; 356 333 } ··· 399 376 resource_size(iTCO_wdt_private.tco_res)); 400 377 release_region(iTCO_wdt_private.smi_res->start, 401 378 resource_size(iTCO_wdt_private.smi_res)); 402 - if (iTCO_wdt_private.iTCO_version == 2) { 403 - iounmap(iTCO_wdt_private.gcs); 404 - release_mem_region(iTCO_wdt_private.gcs_res->start, 405 - resource_size(iTCO_wdt_private.gcs_res)); 379 + if (iTCO_wdt_private.iTCO_version >= 2) { 380 + iounmap(iTCO_wdt_private.gcs_pmc); 381 + release_mem_region(iTCO_wdt_private.gcs_pmc_res->start, 382 + resource_size(iTCO_wdt_private.gcs_pmc_res)); 406 383 } 407 384 408 385 iTCO_wdt_private.tco_res = NULL; 409 386 iTCO_wdt_private.smi_res = NULL; 410 - iTCO_wdt_private.gcs_res = NULL; 411 - iTCO_wdt_private.gcs = NULL; 387 + iTCO_wdt_private.gcs_pmc_res = NULL; 388 + iTCO_wdt_private.gcs_pmc = NULL; 412 389 } 413 390 414 391 static int iTCO_wdt_probe(struct platform_device *dev) ··· 437 414 iTCO_wdt_private.pdev = to_pci_dev(dev->dev.parent); 438 415 439 416 /* 440 - * Get the Memory-Mapped GCS register, we need it for the 441 - * NO_REBOOT flag (TCO v2). 417 + * Get the Memory-Mapped GCS or PMC register, we need it for the 418 + * NO_REBOOT flag (TCO v2 and v3). 442 419 */ 443 - if (iTCO_wdt_private.iTCO_version == 2) { 444 - iTCO_wdt_private.gcs_res = platform_get_resource(dev, 420 + if (iTCO_wdt_private.iTCO_version >= 2) { 421 + iTCO_wdt_private.gcs_pmc_res = platform_get_resource(dev, 445 422 IORESOURCE_MEM, 446 - ICH_RES_MEM_GCS); 423 + ICH_RES_MEM_GCS_PMC); 447 424 448 - if (!iTCO_wdt_private.gcs_res) 425 + if (!iTCO_wdt_private.gcs_pmc_res) 449 426 goto out; 450 427 451 - if (!request_mem_region(iTCO_wdt_private.gcs_res->start, 452 - resource_size(iTCO_wdt_private.gcs_res), dev->name)) { 428 + if (!request_mem_region(iTCO_wdt_private.gcs_pmc_res->start, 429 + resource_size(iTCO_wdt_private.gcs_pmc_res), dev->name)) { 453 430 ret = -EBUSY; 454 431 goto out; 455 432 } 456 - iTCO_wdt_private.gcs = ioremap(iTCO_wdt_private.gcs_res->start, 457 - resource_size(iTCO_wdt_private.gcs_res)); 458 - if (!iTCO_wdt_private.gcs) { 433 + iTCO_wdt_private.gcs_pmc = ioremap(iTCO_wdt_private.gcs_pmc_res->start, 434 + resource_size(iTCO_wdt_private.gcs_pmc_res)); 435 + if (!iTCO_wdt_private.gcs_pmc) { 459 436 ret = -EIO; 460 - goto unreg_gcs; 437 + goto unreg_gcs_pmc; 461 438 } 462 439 } 463 440 ··· 465 442 if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) { 466 443 pr_info("unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n"); 467 444 ret = -ENODEV; /* Cannot reset NO_REBOOT bit */ 468 - goto unmap_gcs; 445 + goto unmap_gcs_pmc; 469 446 } 470 447 471 448 /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ ··· 477 454 pr_err("I/O address 0x%04llx already in use, device disabled\n", 478 455 (u64)SMI_EN); 479 456 ret = -EBUSY; 480 - goto unmap_gcs; 457 + goto unmap_gcs_pmc; 481 458 } 482 459 if (turn_SMI_watchdog_clear_off >= iTCO_wdt_private.iTCO_version) { 483 460 /* ··· 501 478 ich_info->name, ich_info->iTCO_version, (u64)TCOBASE); 502 479 503 480 /* Clear out the (probably old) status */ 504 - outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */ 505 - outw(0x0002, TCO2_STS); /* Clear SECOND_TO_STS bit */ 506 - outw(0x0004, TCO2_STS); /* Clear BOOT_STS bit */ 481 + if (iTCO_wdt_private.iTCO_version == 3) { 482 + outl(0x20008, TCO1_STS); 483 + } else { 484 + outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */ 485 + outw(0x0002, TCO2_STS); /* Clear SECOND_TO_STS bit */ 486 + outw(0x0004, TCO2_STS); /* Clear BOOT_STS bit */ 487 + } 507 488 508 489 iTCO_wdt_watchdog_dev.bootstatus = 0; 509 490 iTCO_wdt_watchdog_dev.timeout = WATCHDOG_TIMEOUT; ··· 542 515 unreg_smi: 543 516 release_region(iTCO_wdt_private.smi_res->start, 544 517 resource_size(iTCO_wdt_private.smi_res)); 545 - unmap_gcs: 546 - if (iTCO_wdt_private.iTCO_version == 2) 547 - iounmap(iTCO_wdt_private.gcs); 548 - unreg_gcs: 549 - if (iTCO_wdt_private.iTCO_version == 2) 550 - release_mem_region(iTCO_wdt_private.gcs_res->start, 551 - resource_size(iTCO_wdt_private.gcs_res)); 518 + unmap_gcs_pmc: 519 + if (iTCO_wdt_private.iTCO_version >= 2) 520 + iounmap(iTCO_wdt_private.gcs_pmc); 521 + unreg_gcs_pmc: 522 + if (iTCO_wdt_private.iTCO_version >= 2) 523 + release_mem_region(iTCO_wdt_private.gcs_pmc_res->start, 524 + resource_size(iTCO_wdt_private.gcs_pmc_res)); 552 525 out: 553 526 iTCO_wdt_private.tco_res = NULL; 554 527 iTCO_wdt_private.smi_res = NULL; 555 - iTCO_wdt_private.gcs_res = NULL; 556 - iTCO_wdt_private.gcs = NULL; 528 + iTCO_wdt_private.gcs_pmc_res = NULL; 529 + iTCO_wdt_private.gcs_pmc = NULL; 557 530 558 531 return ret; 559 532 }
+12
include/linux/i2c/twl.h
··· 195 195 return twl_i2c_read(mod_no, val, reg, 1); 196 196 } 197 197 198 + static inline int twl_i2c_write_u16(u8 mod_no, u16 val, u8 reg) { 199 + val = cpu_to_le16(val); 200 + return twl_i2c_write(mod_no, (u8*) &val, reg, 2); 201 + } 202 + 203 + static inline int twl_i2c_read_u16(u8 mod_no, u16 *val, u8 reg) { 204 + int ret; 205 + ret = twl_i2c_read(mod_no, (u8*) val, reg, 2); 206 + *val = le16_to_cpu(*val); 207 + return ret; 208 + } 209 + 198 210 int twl_get_type(void); 199 211 int twl_get_version(void); 200 212 int twl_get_hfclk_rate(void);
+1 -1
include/linux/i2c/twl4030-madc.h
··· 44 44 45 45 struct twl4030_madc_request { 46 46 unsigned long channels; 47 - u16 do_avg; 47 + bool do_avg; 48 48 u16 method; 49 49 u16 type; 50 50 bool active;
+84
include/linux/mfd/arizona/registers.h
··· 1034 1034 #define ARIZONA_DSP1_STATUS_1 0x1104 1035 1035 #define ARIZONA_DSP1_STATUS_2 0x1105 1036 1036 #define ARIZONA_DSP1_STATUS_3 0x1106 1037 + #define ARIZONA_DSP1_STATUS_4 0x1107 1038 + #define ARIZONA_DSP1_WDMA_BUFFER_1 0x1110 1039 + #define ARIZONA_DSP1_WDMA_BUFFER_2 0x1111 1040 + #define ARIZONA_DSP1_WDMA_BUFFER_3 0x1112 1041 + #define ARIZONA_DSP1_WDMA_BUFFER_4 0x1113 1042 + #define ARIZONA_DSP1_WDMA_BUFFER_5 0x1114 1043 + #define ARIZONA_DSP1_WDMA_BUFFER_6 0x1115 1044 + #define ARIZONA_DSP1_WDMA_BUFFER_7 0x1116 1045 + #define ARIZONA_DSP1_WDMA_BUFFER_8 0x1117 1046 + #define ARIZONA_DSP1_RDMA_BUFFER_1 0x1120 1047 + #define ARIZONA_DSP1_RDMA_BUFFER_2 0x1121 1048 + #define ARIZONA_DSP1_RDMA_BUFFER_3 0x1122 1049 + #define ARIZONA_DSP1_RDMA_BUFFER_4 0x1123 1050 + #define ARIZONA_DSP1_RDMA_BUFFER_5 0x1124 1051 + #define ARIZONA_DSP1_RDMA_BUFFER_6 0x1125 1052 + #define ARIZONA_DSP1_WDMA_CONFIG_1 0x1130 1053 + #define ARIZONA_DSP1_WDMA_CONFIG_2 0x1131 1054 + #define ARIZONA_DSP1_WDMA_OFFSET_1 0x1132 1055 + #define ARIZONA_DSP1_RDMA_CONFIG_1 0x1134 1056 + #define ARIZONA_DSP1_RDMA_OFFSET_1 0x1135 1057 + #define ARIZONA_DSP1_EXTERNAL_START_SELECT_1 0x1138 1037 1058 #define ARIZONA_DSP1_SCRATCH_0 0x1140 1038 1059 #define ARIZONA_DSP1_SCRATCH_1 0x1141 1039 1060 #define ARIZONA_DSP1_SCRATCH_2 0x1142 ··· 1064 1043 #define ARIZONA_DSP2_STATUS_1 0x1204 1065 1044 #define ARIZONA_DSP2_STATUS_2 0x1205 1066 1045 #define ARIZONA_DSP2_STATUS_3 0x1206 1046 + #define ARIZONA_DSP2_STATUS_4 0x1207 1047 + #define ARIZONA_DSP2_WDMA_BUFFER_1 0x1210 1048 + #define ARIZONA_DSP2_WDMA_BUFFER_2 0x1211 1049 + #define ARIZONA_DSP2_WDMA_BUFFER_3 0x1212 1050 + #define ARIZONA_DSP2_WDMA_BUFFER_4 0x1213 1051 + #define ARIZONA_DSP2_WDMA_BUFFER_5 0x1214 1052 + #define ARIZONA_DSP2_WDMA_BUFFER_6 0x1215 1053 + #define ARIZONA_DSP2_WDMA_BUFFER_7 0x1216 1054 + #define ARIZONA_DSP2_WDMA_BUFFER_8 0x1217 1055 + #define ARIZONA_DSP2_RDMA_BUFFER_1 0x1220 1056 + #define ARIZONA_DSP2_RDMA_BUFFER_2 0x1221 1057 + #define ARIZONA_DSP2_RDMA_BUFFER_3 0x1222 1058 + #define ARIZONA_DSP2_RDMA_BUFFER_4 0x1223 1059 + #define ARIZONA_DSP2_RDMA_BUFFER_5 0x1224 1060 + #define ARIZONA_DSP2_RDMA_BUFFER_6 0x1225 1061 + #define ARIZONA_DSP2_WDMA_CONFIG_1 0x1230 1062 + #define ARIZONA_DSP2_WDMA_CONFIG_2 0x1231 1063 + #define ARIZONA_DSP2_WDMA_OFFSET_1 0x1232 1064 + #define ARIZONA_DSP2_RDMA_CONFIG_1 0x1234 1065 + #define ARIZONA_DSP2_RDMA_OFFSET_1 0x1235 1066 + #define ARIZONA_DSP2_EXTERNAL_START_SELECT_1 0x1238 1067 1067 #define ARIZONA_DSP2_SCRATCH_0 0x1240 1068 1068 #define ARIZONA_DSP2_SCRATCH_1 0x1241 1069 1069 #define ARIZONA_DSP2_SCRATCH_2 0x1242 ··· 1094 1052 #define ARIZONA_DSP3_STATUS_1 0x1304 1095 1053 #define ARIZONA_DSP3_STATUS_2 0x1305 1096 1054 #define ARIZONA_DSP3_STATUS_3 0x1306 1055 + #define ARIZONA_DSP3_STATUS_4 0x1307 1056 + #define ARIZONA_DSP3_WDMA_BUFFER_1 0x1310 1057 + #define ARIZONA_DSP3_WDMA_BUFFER_2 0x1311 1058 + #define ARIZONA_DSP3_WDMA_BUFFER_3 0x1312 1059 + #define ARIZONA_DSP3_WDMA_BUFFER_4 0x1313 1060 + #define ARIZONA_DSP3_WDMA_BUFFER_5 0x1314 1061 + #define ARIZONA_DSP3_WDMA_BUFFER_6 0x1315 1062 + #define ARIZONA_DSP3_WDMA_BUFFER_7 0x1316 1063 + #define ARIZONA_DSP3_WDMA_BUFFER_8 0x1317 1064 + #define ARIZONA_DSP3_RDMA_BUFFER_1 0x1320 1065 + #define ARIZONA_DSP3_RDMA_BUFFER_2 0x1321 1066 + #define ARIZONA_DSP3_RDMA_BUFFER_3 0x1322 1067 + #define ARIZONA_DSP3_RDMA_BUFFER_4 0x1323 1068 + #define ARIZONA_DSP3_RDMA_BUFFER_5 0x1324 1069 + #define ARIZONA_DSP3_RDMA_BUFFER_6 0x1325 1070 + #define ARIZONA_DSP3_WDMA_CONFIG_1 0x1330 1071 + #define ARIZONA_DSP3_WDMA_CONFIG_2 0x1331 1072 + #define ARIZONA_DSP3_WDMA_OFFSET_1 0x1332 1073 + #define ARIZONA_DSP3_RDMA_CONFIG_1 0x1334 1074 + #define ARIZONA_DSP3_RDMA_OFFSET_1 0x1335 1075 + #define ARIZONA_DSP3_EXTERNAL_START_SELECT_1 0x1338 1097 1076 #define ARIZONA_DSP3_SCRATCH_0 0x1340 1098 1077 #define ARIZONA_DSP3_SCRATCH_1 0x1341 1099 1078 #define ARIZONA_DSP3_SCRATCH_2 0x1342 ··· 1124 1061 #define ARIZONA_DSP4_STATUS_1 0x1404 1125 1062 #define ARIZONA_DSP4_STATUS_2 0x1405 1126 1063 #define ARIZONA_DSP4_STATUS_3 0x1406 1064 + #define ARIZONA_DSP4_STATUS_4 0x1407 1065 + #define ARIZONA_DSP4_WDMA_BUFFER_1 0x1410 1066 + #define ARIZONA_DSP4_WDMA_BUFFER_2 0x1411 1067 + #define ARIZONA_DSP4_WDMA_BUFFER_3 0x1412 1068 + #define ARIZONA_DSP4_WDMA_BUFFER_4 0x1413 1069 + #define ARIZONA_DSP4_WDMA_BUFFER_5 0x1414 1070 + #define ARIZONA_DSP4_WDMA_BUFFER_6 0x1415 1071 + #define ARIZONA_DSP4_WDMA_BUFFER_7 0x1416 1072 + #define ARIZONA_DSP4_WDMA_BUFFER_8 0x1417 1073 + #define ARIZONA_DSP4_RDMA_BUFFER_1 0x1420 1074 + #define ARIZONA_DSP4_RDMA_BUFFER_2 0x1421 1075 + #define ARIZONA_DSP4_RDMA_BUFFER_3 0x1422 1076 + #define ARIZONA_DSP4_RDMA_BUFFER_4 0x1423 1077 + #define ARIZONA_DSP4_RDMA_BUFFER_5 0x1424 1078 + #define ARIZONA_DSP4_RDMA_BUFFER_6 0x1425 1079 + #define ARIZONA_DSP4_WDMA_CONFIG_1 0x1430 1080 + #define ARIZONA_DSP4_WDMA_CONFIG_2 0x1431 1081 + #define ARIZONA_DSP4_WDMA_OFFSET_1 0x1432 1082 + #define ARIZONA_DSP4_RDMA_CONFIG_1 0x1434 1083 + #define ARIZONA_DSP4_RDMA_OFFSET_1 0x1435 1084 + #define ARIZONA_DSP4_EXTERNAL_START_SELECT_1 0x1438 1127 1085 #define ARIZONA_DSP4_SCRATCH_0 0x1440 1128 1086 #define ARIZONA_DSP4_SCRATCH_1 0x1441 1129 1087 #define ARIZONA_DSP4_SCRATCH_2 0x1442
+31
include/linux/mfd/bcm590xx.h
··· 1 + /* 2 + * Broadcom BCM590xx PMU 3 + * 4 + * Copyright 2014 Linaro Limited 5 + * Author: Matt Porter <mporter@linaro.org> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + * 12 + */ 13 + 14 + #ifndef __LINUX_MFD_BCM590XX_H 15 + #define __LINUX_MFD_BCM590XX_H 16 + 17 + #include <linux/device.h> 18 + #include <linux/i2c.h> 19 + #include <linux/regmap.h> 20 + 21 + /* max register address */ 22 + #define BCM590XX_MAX_REGISTER 0xe7 23 + 24 + struct bcm590xx { 25 + struct device *dev; 26 + struct i2c_client *i2c_client; 27 + struct regmap *regmap; 28 + unsigned int id; 29 + }; 30 + 31 + #endif /* __LINUX_MFD_BCM590XX_H */
+1
include/linux/mfd/da9052/da9052.h
··· 83 83 DA9053_AA, 84 84 DA9053_BA, 85 85 DA9053_BB, 86 + DA9053_BC, 86 87 }; 87 88 88 89 struct da9052_pdata;
+5 -1
include/linux/mfd/da9063/core.h
··· 33 33 PMIC_DA9063 = 0x61, 34 34 }; 35 35 36 + enum da9063_variant_codes { 37 + PMIC_DA9063_BB = 0x5 38 + }; 39 + 36 40 /* Interrupts */ 37 41 enum da9063_irqs { 38 42 DA9063_IRQ_ONKEY = 0, ··· 76 72 /* Device */ 77 73 struct device *dev; 78 74 unsigned short model; 79 - unsigned short revision; 75 + unsigned char variant_code; 80 76 unsigned int flags; 81 77 82 78 /* Control interface */
+61 -57
include/linux/mfd/da9063/registers.h
··· 17 17 #define _DA9063_REG_H 18 18 19 19 #define DA9063_I2C_PAGE_SEL_SHIFT 1 20 - 21 20 #define DA9063_EVENT_REG_NUM 4 22 - #define DA9210_EVENT_REG_NUM 2 23 - #define DA9063_EXT_EVENT_REG_NUM (DA9063_EVENT_REG_NUM + \ 24 - DA9210_EVENT_REG_NUM) 25 21 26 22 /* Page selection I2C or SPI always in the begining of any page. */ 27 23 /* Page 0 : I2C access 0x000 - 0x0FF SPI access 0x000 - 0x07F */ ··· 57 61 #define DA9063_REG_GPIO_10_11 0x1A 58 62 #define DA9063_REG_GPIO_12_13 0x1B 59 63 #define DA9063_REG_GPIO_14_15 0x1C 60 - #define DA9063_REG_GPIO_MODE_0_7 0x1D 61 - #define DA9063_REG_GPIO_MODE_8_15 0x1E 62 - #define DA9063_REG_GPIO_SWITCH_CONT 0x1F 64 + #define DA9063_REG_GPIO_MODE0_7 0x1D 65 + #define DA9063_REG_GPIO_MODE8_15 0x1E 66 + #define DA9063_REG_SWITCH_CONT 0x1F 63 67 64 68 /* Regulator Control Registers */ 65 69 #define DA9063_REG_BCORE2_CONT 0x20 ··· 79 83 #define DA9063_REG_LDO9_CONT 0x2E 80 84 #define DA9063_REG_LDO10_CONT 0x2F 81 85 #define DA9063_REG_LDO11_CONT 0x30 82 - #define DA9063_REG_VIB 0x31 86 + #define DA9063_REG_SUPPLIES 0x31 83 87 #define DA9063_REG_DVC_1 0x32 84 88 #define DA9063_REG_DVC_2 0x33 85 89 ··· 93 97 #define DA9063_REG_ADCIN1_RES 0x3A 94 98 #define DA9063_REG_ADCIN2_RES 0x3B 95 99 #define DA9063_REG_ADCIN3_RES 0x3C 96 - #define DA9063_REG_MON1_RES 0x3D 97 - #define DA9063_REG_MON2_RES 0x3E 98 - #define DA9063_REG_MON3_RES 0x3F 100 + #define DA9063_REG_MON_A8_RES 0x3D 101 + #define DA9063_REG_MON_A9_RES 0x3E 102 + #define DA9063_REG_MON_A10_RES 0x3F 99 103 100 104 /* RTC Calendar and Alarm Registers */ 101 105 #define DA9063_REG_COUNT_S 0x40 ··· 104 108 #define DA9063_REG_COUNT_D 0x43 105 109 #define DA9063_REG_COUNT_MO 0x44 106 110 #define DA9063_REG_COUNT_Y 0x45 107 - #define DA9063_REG_ALARM_MI 0x46 108 - #define DA9063_REG_ALARM_H 0x47 109 - #define DA9063_REG_ALARM_D 0x48 110 - #define DA9063_REG_ALARM_MO 0x49 111 - #define DA9063_REG_ALARM_Y 0x4A 112 - #define DA9063_REG_SECOND_A 0x4B 113 - #define DA9063_REG_SECOND_B 0x4C 114 - #define DA9063_REG_SECOND_C 0x4D 115 - #define DA9063_REG_SECOND_D 0x4E 111 + #define DA9063_REG_ALARM_S 0x46 112 + #define DA9063_REG_ALARM_MI 0x47 113 + #define DA9063_REG_ALARM_H 0x48 114 + #define DA9063_REG_ALARM_D 0x49 115 + #define DA9063_REG_ALARM_MO 0x4A 116 + #define DA9063_REG_ALARM_Y 0x4B 117 + #define DA9063_REG_SECOND_A 0x4C 118 + #define DA9063_REG_SECOND_B 0x4D 119 + #define DA9063_REG_SECOND_C 0x4E 120 + #define DA9063_REG_SECOND_D 0x4F 116 121 117 122 /* Sequencer Control Registers */ 118 123 #define DA9063_REG_SEQ 0x81 ··· 223 226 #define DA9063_REG_CONFIG_J 0x10F 224 227 #define DA9063_REG_CONFIG_K 0x110 225 228 #define DA9063_REG_CONFIG_L 0x111 226 - #define DA9063_REG_MON_REG_1 0x112 227 - #define DA9063_REG_MON_REG_2 0x113 228 - #define DA9063_REG_MON_REG_3 0x114 229 - #define DA9063_REG_MON_REG_4 0x115 230 - #define DA9063_REG_MON_REG_5 0x116 231 - #define DA9063_REG_MON_REG_6 0x117 232 - #define DA9063_REG_TRIM_CLDR 0x118 229 + #define DA9063_REG_CONFIG_M 0x112 230 + #define DA9063_REG_CONFIG_N 0x113 233 231 232 + #define DA9063_REG_MON_REG_1 0x114 233 + #define DA9063_REG_MON_REG_2 0x115 234 + #define DA9063_REG_MON_REG_3 0x116 235 + #define DA9063_REG_MON_REG_4 0x117 236 + #define DA9063_REG_MON_REG_5 0x11E 237 + #define DA9063_REG_MON_REG_6 0x11F 238 + #define DA9063_REG_TRIM_CLDR 0x120 234 239 /* General Purpose Registers */ 235 - #define DA9063_REG_GP_ID_0 0x119 236 - #define DA9063_REG_GP_ID_1 0x11A 237 - #define DA9063_REG_GP_ID_2 0x11B 238 - #define DA9063_REG_GP_ID_3 0x11C 239 - #define DA9063_REG_GP_ID_4 0x11D 240 - #define DA9063_REG_GP_ID_5 0x11E 241 - #define DA9063_REG_GP_ID_6 0x11F 242 - #define DA9063_REG_GP_ID_7 0x120 243 - #define DA9063_REG_GP_ID_8 0x121 244 - #define DA9063_REG_GP_ID_9 0x122 245 - #define DA9063_REG_GP_ID_10 0x123 246 - #define DA9063_REG_GP_ID_11 0x124 247 - #define DA9063_REG_GP_ID_12 0x125 248 - #define DA9063_REG_GP_ID_13 0x126 249 - #define DA9063_REG_GP_ID_14 0x127 250 - #define DA9063_REG_GP_ID_15 0x128 251 - #define DA9063_REG_GP_ID_16 0x129 252 - #define DA9063_REG_GP_ID_17 0x12A 253 - #define DA9063_REG_GP_ID_18 0x12B 254 - #define DA9063_REG_GP_ID_19 0x12C 240 + #define DA9063_REG_GP_ID_0 0x121 241 + #define DA9063_REG_GP_ID_1 0x122 242 + #define DA9063_REG_GP_ID_2 0x123 243 + #define DA9063_REG_GP_ID_3 0x124 244 + #define DA9063_REG_GP_ID_4 0x125 245 + #define DA9063_REG_GP_ID_5 0x126 246 + #define DA9063_REG_GP_ID_6 0x127 247 + #define DA9063_REG_GP_ID_7 0x128 248 + #define DA9063_REG_GP_ID_8 0x129 249 + #define DA9063_REG_GP_ID_9 0x12A 250 + #define DA9063_REG_GP_ID_10 0x12B 251 + #define DA9063_REG_GP_ID_11 0x12C 252 + #define DA9063_REG_GP_ID_12 0x12D 253 + #define DA9063_REG_GP_ID_13 0x12E 254 + #define DA9063_REG_GP_ID_14 0x12F 255 + #define DA9063_REG_GP_ID_15 0x130 256 + #define DA9063_REG_GP_ID_16 0x131 257 + #define DA9063_REG_GP_ID_17 0x132 258 + #define DA9063_REG_GP_ID_18 0x133 259 + #define DA9063_REG_GP_ID_19 0x134 255 260 256 261 /* Chip ID and variant */ 257 262 #define DA9063_REG_CHIP_ID 0x181 ··· 404 405 /* DA9063_REG_CONTROL_B (addr=0x0F) */ 405 406 #define DA9063_CHG_SEL 0x01 406 407 #define DA9063_WATCHDOG_PD 0x02 408 + #define DA9063_RESET_BLINKING 0x04 407 409 #define DA9063_NRES_MODE 0x08 408 410 #define DA9063_NONKEY_LOCK 0x10 411 + #define DA9063_BUCK_SLOWSTART 0x80 409 412 410 413 /* DA9063_REG_CONTROL_C (addr=0x10) */ 411 414 #define DA9063_DEBOUNCING_MASK 0x07 ··· 467 466 #define DA9063_GPADC_PAUSE 0x02 468 467 #define DA9063_PMIF_DIS 0x04 469 468 #define DA9063_HS2WIRE_DIS 0x08 469 + #define DA9063_CLDR_PAUSE 0x10 470 470 #define DA9063_BBAT_DIS 0x20 471 471 #define DA9063_OUT_32K_PAUSE 0x40 472 472 #define DA9063_PMCONT_DIS 0x80 ··· 662 660 #define DA9063_GPIO15_TYPE_GPO 0x04 663 661 #define DA9063_GPIO15_NO_WAKEUP 0x80 664 662 665 - /* DA9063_REG_GPIO_MODE_0_7 (addr=0x1D) */ 663 + /* DA9063_REG_GPIO_MODE0_7 (addr=0x1D) */ 666 664 #define DA9063_GPIO0_MODE 0x01 667 665 #define DA9063_GPIO1_MODE 0x02 668 666 #define DA9063_GPIO2_MODE 0x04 ··· 672 670 #define DA9063_GPIO6_MODE 0x40 673 671 #define DA9063_GPIO7_MODE 0x80 674 672 675 - /* DA9063_REG_GPIO_MODE_8_15 (addr=0x1E) */ 673 + /* DA9063_REG_GPIO_MODE8_15 (addr=0x1E) */ 676 674 #define DA9063_GPIO8_MODE 0x01 677 675 #define DA9063_GPIO9_MODE 0x02 678 676 #define DA9063_GPIO10_MODE 0x04 ··· 704 702 #define DA9063_SWITCH_SR_5MV 0x10 705 703 #define DA9063_SWITCH_SR_10MV 0x20 706 704 #define DA9063_SWITCH_SR_50MV 0x30 707 - #define DA9063_SWITCH_SR_DIS 0x40 705 + #define DA9063_CORE_SW_INTERNAL 0x40 708 706 #define DA9063_CP_EN_MODE 0x80 709 707 710 708 /* DA9063_REGL_Bxxxx_CONT common bits (addr=0x20-0x25) */ 711 709 #define DA9063_BUCK_EN 0x01 712 - #define DA9063_BUCK_GPI_MASK 0x06 710 + #define DA9063_BUCK_GPI_MASK 0x06 713 711 #define DA9063_BUCK_GPI_OFF 0x00 714 712 #define DA9063_BUCK_GPI_GPIO1 0x02 715 713 #define DA9063_BUCK_GPI_GPIO2 0x04 ··· 843 841 #define DA9063_COUNT_YEAR_MASK 0x3F 844 842 #define DA9063_MONITOR 0x40 845 843 846 - /* DA9063_REG_ALARM_MI (addr=0x46) */ 844 + /* DA9063_REG_ALARM_S (addr=0x46) */ 845 + #define DA9063_ALARM_S_MASK 0x3F 847 846 #define DA9063_ALARM_STATUS_ALARM 0x80 848 847 #define DA9063_ALARM_STATUS_TICK 0x40 848 + /* DA9063_REG_ALARM_MI (addr=0x47) */ 849 849 #define DA9063_ALARM_MIN_MASK 0x3F 850 850 851 - /* DA9063_REG_ALARM_H (addr=0x47) */ 851 + /* DA9063_REG_ALARM_H (addr=0x48) */ 852 852 #define DA9063_ALARM_HOUR_MASK 0x1F 853 853 854 - /* DA9063_REG_ALARM_D (addr=0x48) */ 854 + /* DA9063_REG_ALARM_D (addr=0x49) */ 855 855 #define DA9063_ALARM_DAY_MASK 0x1F 856 856 857 - /* DA9063_REG_ALARM_MO (addr=0x49) */ 857 + /* DA9063_REG_ALARM_MO (addr=0x4A) */ 858 858 #define DA9063_TICK_WAKE 0x20 859 859 #define DA9063_TICK_TYPE 0x10 860 860 #define DA9063_TICK_TYPE_SEC 0x00 861 861 #define DA9063_TICK_TYPE_MIN 0x10 862 862 #define DA9063_ALARM_MONTH_MASK 0x0F 863 863 864 - /* DA9063_REG_ALARM_Y (addr=0x4A) */ 864 + /* DA9063_REG_ALARM_Y (addr=0x4B) */ 865 865 #define DA9063_TICK_ON 0x80 866 866 #define DA9063_ALARM_ON 0x40 867 867 #define DA9063_ALARM_YEAR_MASK 0x3F ··· 910 906 911 907 /* DA9063_REG_Bxxxx_CFG common bits (addr=0x9D-0xA2) */ 912 908 #define DA9063_BUCK_FB_MASK 0x07 913 - #define DA9063_BUCK_PD_DIS_SHIFT 5 909 + #define DA9063_BUCK_PD_DIS_MASK 0x20 914 910 #define DA9063_BUCK_MODE_MASK 0xC0 915 911 #define DA9063_BUCK_MODE_MANUAL 0x00 916 912 #define DA9063_BUCK_MODE_SLEEP 0x40
+14 -11
include/linux/mfd/lpc_ich.h
··· 21 21 #define LPC_ICH_H 22 22 23 23 /* Watchdog resources */ 24 - #define ICH_RES_IO_TCO 0 25 - #define ICH_RES_IO_SMI 1 26 - #define ICH_RES_MEM_OFF 2 27 - #define ICH_RES_MEM_GCS 0 24 + #define ICH_RES_IO_TCO 0 25 + #define ICH_RES_IO_SMI 1 26 + #define ICH_RES_MEM_OFF 2 27 + #define ICH_RES_MEM_GCS_PMC 0 28 28 29 29 /* GPIO resources */ 30 30 #define ICH_RES_GPIO 0 31 31 #define ICH_RES_GPE0 1 32 32 33 33 /* GPIO compatibility */ 34 - #define ICH_I3100_GPIO 0x401 35 - #define ICH_V5_GPIO 0x501 36 - #define ICH_V6_GPIO 0x601 37 - #define ICH_V7_GPIO 0x701 38 - #define ICH_V9_GPIO 0x801 39 - #define ICH_V10CORP_GPIO 0xa01 40 - #define ICH_V10CONS_GPIO 0xa11 34 + enum { 35 + ICH_I3100_GPIO, 36 + ICH_V5_GPIO, 37 + ICH_V6_GPIO, 38 + ICH_V7_GPIO, 39 + ICH_V9_GPIO, 40 + ICH_V10CORP_GPIO, 41 + ICH_V10CONS_GPIO, 42 + AVOTON_GPIO, 43 + }; 41 44 42 45 struct lpc_ich_info { 43 46 char name[32];
-8
include/linux/mfd/max14577-private.h
··· 248 248 /* MAX14577 regulator SFOUT LDO voltage, fixed, uV */ 249 249 #define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000 250 250 251 - enum max14577_irq_source { 252 - MAX14577_IRQ_INT1 = 0, 253 - MAX14577_IRQ_INT2, 254 - MAX14577_IRQ_INT3, 255 - 256 - MAX14577_IRQ_REGS_NUM, 257 - }; 258 - 259 251 enum max14577_irq { 260 252 /* INT1 */ 261 253 MAX14577_IRQ_INT1_ADC,
-5
include/linux/mfd/max14577.h
··· 25 25 #ifndef __MAX14577_H__ 26 26 #define __MAX14577_H__ 27 27 28 - #include <linux/mfd/max14577-private.h> 29 28 #include <linux/regulator/consumer.h> 30 - 31 - /* 32 - * MAX14577 Regulator 33 - */ 34 29 35 30 /* MAX14577 regulator IDs */ 36 31 enum max14577_regulators {
-59
include/linux/mfd/pm8xxx/irq.h
··· 1 - /* 2 - * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 and 6 - * only version 2 as published by the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, 9 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 - * GNU General Public License for more details. 12 - */ 13 - /* 14 - * Qualcomm PMIC irq 8xxx driver header file 15 - * 16 - */ 17 - 18 - #ifndef __MFD_PM8XXX_IRQ_H 19 - #define __MFD_PM8XXX_IRQ_H 20 - 21 - #include <linux/errno.h> 22 - #include <linux/err.h> 23 - 24 - struct pm8xxx_irq_core_data { 25 - u32 rev; 26 - int nirqs; 27 - }; 28 - 29 - struct pm8xxx_irq_platform_data { 30 - int irq_base; 31 - struct pm8xxx_irq_core_data irq_cdata; 32 - int devirq; 33 - int irq_trigger_flag; 34 - }; 35 - 36 - struct pm_irq_chip; 37 - 38 - #ifdef CONFIG_MFD_PM8XXX_IRQ 39 - int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq); 40 - struct pm_irq_chip *pm8xxx_irq_init(struct device *dev, 41 - const struct pm8xxx_irq_platform_data *pdata); 42 - int pm8xxx_irq_exit(struct pm_irq_chip *chip); 43 - #else 44 - static inline int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq) 45 - { 46 - return -ENXIO; 47 - } 48 - static inline struct pm_irq_chip *pm8xxx_irq_init( 49 - const struct device *dev, 50 - const struct pm8xxx_irq_platform_data *pdata) 51 - { 52 - return ERR_PTR(-ENXIO); 53 - } 54 - static inline int pm8xxx_irq_exit(struct pm_irq_chip *chip) 55 - { 56 - return -ENXIO; 57 - } 58 - #endif /* CONFIG_MFD_PM8XXX_IRQ */ 59 - #endif /* __MFD_PM8XXX_IRQ_H */
-30
include/linux/mfd/pm8xxx/pm8921.h
··· 1 - /* 2 - * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 3 - * 4 - * This program is free software; you can redistribute it and/or modify 5 - * it under the terms of the GNU General Public License version 2 and 6 - * only version 2 as published by the Free Software Foundation. 7 - * 8 - * This program is distributed in the hope that it will be useful, 9 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 - * GNU General Public License for more details. 12 - */ 13 - /* 14 - * Qualcomm PMIC 8921 driver header file 15 - * 16 - */ 17 - 18 - #ifndef __MFD_PM8921_H 19 - #define __MFD_PM8921_H 20 - 21 - #include <linux/mfd/pm8xxx/irq.h> 22 - 23 - #define PM8921_NR_IRQS 256 24 - 25 - struct pm8921_platform_data { 26 - int irq_base; 27 - struct pm8xxx_irq_platform_data *irq_pdata; 28 - }; 29 - 30 - #endif
+628
include/linux/mfd/rtsx_usb.h
··· 1 + /* Driver for Realtek RTS5139 USB card reader 2 + * 3 + * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License version 2 7 + * as published by the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope that it will be useful, but 10 + * WITHOUT ANY WARRANTY; without even the implied warranty of 11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 + * General Public License for more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along 15 + * with this program; if not, see <http://www.gnu.org/licenses/>. 16 + * 17 + * Author: 18 + * Roger Tseng <rogerable@realtek.com> 19 + */ 20 + 21 + #ifndef __RTSX_USB_H 22 + #define __RTSX_USB_H 23 + 24 + #include <linux/usb.h> 25 + 26 + /* related module names */ 27 + #define RTSX_USB_SD_CARD 0 28 + #define RTSX_USB_MS_CARD 1 29 + 30 + /* endpoint numbers */ 31 + #define EP_BULK_OUT 1 32 + #define EP_BULK_IN 2 33 + #define EP_INTR_IN 3 34 + 35 + /* USB vendor requests */ 36 + #define RTSX_USB_REQ_REG_OP 0x00 37 + #define RTSX_USB_REQ_POLL 0x02 38 + 39 + /* miscellaneous parameters */ 40 + #define MIN_DIV_N 60 41 + #define MAX_DIV_N 120 42 + 43 + #define MAX_PHASE 15 44 + #define RX_TUNING_CNT 3 45 + 46 + #define QFN24 0 47 + #define LQFP48 1 48 + #define CHECK_PKG(ucr, pkg) ((ucr)->package == (pkg)) 49 + 50 + /* data structures */ 51 + struct rtsx_ucr { 52 + u16 vendor_id; 53 + u16 product_id; 54 + 55 + int package; 56 + u8 ic_version; 57 + bool is_rts5179; 58 + 59 + unsigned int cur_clk; 60 + 61 + u8 *cmd_buf; 62 + unsigned int cmd_idx; 63 + u8 *rsp_buf; 64 + 65 + struct usb_device *pusb_dev; 66 + struct usb_interface *pusb_intf; 67 + struct usb_sg_request current_sg; 68 + unsigned char *iobuf; 69 + dma_addr_t iobuf_dma; 70 + 71 + struct timer_list sg_timer; 72 + struct mutex dev_mutex; 73 + }; 74 + 75 + /* buffer size */ 76 + #define IOBUF_SIZE 1024 77 + 78 + /* prototypes of exported functions */ 79 + extern int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status); 80 + 81 + extern int rtsx_usb_read_register(struct rtsx_ucr *ucr, u16 addr, u8 *data); 82 + extern int rtsx_usb_write_register(struct rtsx_ucr *ucr, u16 addr, u8 mask, 83 + u8 data); 84 + 85 + extern int rtsx_usb_ep0_write_register(struct rtsx_ucr *ucr, u16 addr, u8 mask, 86 + u8 data); 87 + extern int rtsx_usb_ep0_read_register(struct rtsx_ucr *ucr, u16 addr, 88 + u8 *data); 89 + 90 + extern void rtsx_usb_add_cmd(struct rtsx_ucr *ucr, u8 cmd_type, 91 + u16 reg_addr, u8 mask, u8 data); 92 + extern int rtsx_usb_send_cmd(struct rtsx_ucr *ucr, u8 flag, int timeout); 93 + extern int rtsx_usb_get_rsp(struct rtsx_ucr *ucr, int rsp_len, int timeout); 94 + extern int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe, 95 + void *buf, unsigned int len, int use_sg, 96 + unsigned int *act_len, int timeout); 97 + 98 + extern int rtsx_usb_read_ppbuf(struct rtsx_ucr *ucr, u8 *buf, int buf_len); 99 + extern int rtsx_usb_write_ppbuf(struct rtsx_ucr *ucr, u8 *buf, int buf_len); 100 + extern int rtsx_usb_switch_clock(struct rtsx_ucr *ucr, unsigned int card_clock, 101 + u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk); 102 + extern int rtsx_usb_card_exclusive_check(struct rtsx_ucr *ucr, int card); 103 + 104 + /* card status */ 105 + #define SD_CD 0x01 106 + #define MS_CD 0x02 107 + #define XD_CD 0x04 108 + #define CD_MASK (SD_CD | MS_CD | XD_CD) 109 + #define SD_WP 0x08 110 + 111 + /* reader command field offset & parameters */ 112 + #define READ_REG_CMD 0 113 + #define WRITE_REG_CMD 1 114 + #define CHECK_REG_CMD 2 115 + 116 + #define PACKET_TYPE 4 117 + #define CNT_H 5 118 + #define CNT_L 6 119 + #define STAGE_FLAG 7 120 + #define CMD_OFFSET 8 121 + #define SEQ_WRITE_DATA_OFFSET 12 122 + 123 + #define BATCH_CMD 0 124 + #define SEQ_READ 1 125 + #define SEQ_WRITE 2 126 + 127 + #define STAGE_R 0x01 128 + #define STAGE_DI 0x02 129 + #define STAGE_DO 0x04 130 + #define STAGE_MS_STATUS 0x08 131 + #define STAGE_XD_STATUS 0x10 132 + #define MODE_C 0x00 133 + #define MODE_CR (STAGE_R) 134 + #define MODE_CDIR (STAGE_R | STAGE_DI) 135 + #define MODE_CDOR (STAGE_R | STAGE_DO) 136 + 137 + #define EP0_OP_SHIFT 14 138 + #define EP0_READ_REG_CMD 2 139 + #define EP0_WRITE_REG_CMD 3 140 + 141 + #define rtsx_usb_cmd_hdr_tag(ucr) \ 142 + do { \ 143 + ucr->cmd_buf[0] = 'R'; \ 144 + ucr->cmd_buf[1] = 'T'; \ 145 + ucr->cmd_buf[2] = 'C'; \ 146 + ucr->cmd_buf[3] = 'R'; \ 147 + } while (0) 148 + 149 + static inline void rtsx_usb_init_cmd(struct rtsx_ucr *ucr) 150 + { 151 + rtsx_usb_cmd_hdr_tag(ucr); 152 + ucr->cmd_idx = 0; 153 + ucr->cmd_buf[PACKET_TYPE] = BATCH_CMD; 154 + } 155 + 156 + /* internal register address */ 157 + #define FPDCTL 0xFC00 158 + #define SSC_DIV_N_0 0xFC07 159 + #define SSC_CTL1 0xFC09 160 + #define SSC_CTL2 0xFC0A 161 + #define CFG_MODE 0xFC0E 162 + #define CFG_MODE_1 0xFC0F 163 + #define RCCTL 0xFC14 164 + #define SOF_WDOG 0xFC28 165 + #define SYS_DUMMY0 0xFC30 166 + 167 + #define MS_BLKEND 0xFD30 168 + #define MS_READ_START 0xFD31 169 + #define MS_READ_COUNT 0xFD32 170 + #define MS_WRITE_START 0xFD33 171 + #define MS_WRITE_COUNT 0xFD34 172 + #define MS_COMMAND 0xFD35 173 + #define MS_OLD_BLOCK_0 0xFD36 174 + #define MS_OLD_BLOCK_1 0xFD37 175 + #define MS_NEW_BLOCK_0 0xFD38 176 + #define MS_NEW_BLOCK_1 0xFD39 177 + #define MS_LOG_BLOCK_0 0xFD3A 178 + #define MS_LOG_BLOCK_1 0xFD3B 179 + #define MS_BUS_WIDTH 0xFD3C 180 + #define MS_PAGE_START 0xFD3D 181 + #define MS_PAGE_LENGTH 0xFD3E 182 + #define MS_CFG 0xFD40 183 + #define MS_TPC 0xFD41 184 + #define MS_TRANS_CFG 0xFD42 185 + #define MS_TRANSFER 0xFD43 186 + #define MS_INT_REG 0xFD44 187 + #define MS_BYTE_CNT 0xFD45 188 + #define MS_SECTOR_CNT_L 0xFD46 189 + #define MS_SECTOR_CNT_H 0xFD47 190 + #define MS_DBUS_H 0xFD48 191 + 192 + #define CARD_DMA1_CTL 0xFD5C 193 + #define CARD_PULL_CTL1 0xFD60 194 + #define CARD_PULL_CTL2 0xFD61 195 + #define CARD_PULL_CTL3 0xFD62 196 + #define CARD_PULL_CTL4 0xFD63 197 + #define CARD_PULL_CTL5 0xFD64 198 + #define CARD_PULL_CTL6 0xFD65 199 + #define CARD_EXIST 0xFD6F 200 + #define CARD_INT_PEND 0xFD71 201 + 202 + #define LDO_POWER_CFG 0xFD7B 203 + 204 + #define SD_CFG1 0xFDA0 205 + #define SD_CFG2 0xFDA1 206 + #define SD_CFG3 0xFDA2 207 + #define SD_STAT1 0xFDA3 208 + #define SD_STAT2 0xFDA4 209 + #define SD_BUS_STAT 0xFDA5 210 + #define SD_PAD_CTL 0xFDA6 211 + #define SD_SAMPLE_POINT_CTL 0xFDA7 212 + #define SD_PUSH_POINT_CTL 0xFDA8 213 + #define SD_CMD0 0xFDA9 214 + #define SD_CMD1 0xFDAA 215 + #define SD_CMD2 0xFDAB 216 + #define SD_CMD3 0xFDAC 217 + #define SD_CMD4 0xFDAD 218 + #define SD_CMD5 0xFDAE 219 + #define SD_BYTE_CNT_L 0xFDAF 220 + #define SD_BYTE_CNT_H 0xFDB0 221 + #define SD_BLOCK_CNT_L 0xFDB1 222 + #define SD_BLOCK_CNT_H 0xFDB2 223 + #define SD_TRANSFER 0xFDB3 224 + #define SD_CMD_STATE 0xFDB5 225 + #define SD_DATA_STATE 0xFDB6 226 + #define SD_VPCLK0_CTL 0xFC2A 227 + #define SD_VPCLK1_CTL 0xFC2B 228 + #define SD_DCMPS0_CTL 0xFC2C 229 + #define SD_DCMPS1_CTL 0xFC2D 230 + 231 + #define CARD_DMA1_CTL 0xFD5C 232 + 233 + #define HW_VERSION 0xFC01 234 + 235 + #define SSC_CLK_FPGA_SEL 0xFC02 236 + #define CLK_DIV 0xFC03 237 + #define SFSM_ED 0xFC04 238 + 239 + #define CD_DEGLITCH_WIDTH 0xFC20 240 + #define CD_DEGLITCH_EN 0xFC21 241 + #define AUTO_DELINK_EN 0xFC23 242 + 243 + #define FPGA_PULL_CTL 0xFC1D 244 + #define CARD_CLK_SOURCE 0xFC2E 245 + 246 + #define CARD_SHARE_MODE 0xFD51 247 + #define CARD_DRIVE_SEL 0xFD52 248 + #define CARD_STOP 0xFD53 249 + #define CARD_OE 0xFD54 250 + #define CARD_AUTO_BLINK 0xFD55 251 + #define CARD_GPIO 0xFD56 252 + #define SD30_DRIVE_SEL 0xFD57 253 + 254 + #define CARD_DATA_SOURCE 0xFD5D 255 + #define CARD_SELECT 0xFD5E 256 + 257 + #define CARD_CLK_EN 0xFD79 258 + #define CARD_PWR_CTL 0xFD7A 259 + 260 + #define OCPCTL 0xFD80 261 + #define OCPPARA1 0xFD81 262 + #define OCPPARA2 0xFD82 263 + #define OCPSTAT 0xFD83 264 + 265 + #define HS_USB_STAT 0xFE01 266 + #define HS_VCONTROL 0xFE26 267 + #define HS_VSTAIN 0xFE27 268 + #define HS_VLOADM 0xFE28 269 + #define HS_VSTAOUT 0xFE29 270 + 271 + #define MC_IRQ 0xFF00 272 + #define MC_IRQEN 0xFF01 273 + #define MC_FIFO_CTL 0xFF02 274 + #define MC_FIFO_BC0 0xFF03 275 + #define MC_FIFO_BC1 0xFF04 276 + #define MC_FIFO_STAT 0xFF05 277 + #define MC_FIFO_MODE 0xFF06 278 + #define MC_FIFO_RD_PTR0 0xFF07 279 + #define MC_FIFO_RD_PTR1 0xFF08 280 + #define MC_DMA_CTL 0xFF10 281 + #define MC_DMA_TC0 0xFF11 282 + #define MC_DMA_TC1 0xFF12 283 + #define MC_DMA_TC2 0xFF13 284 + #define MC_DMA_TC3 0xFF14 285 + #define MC_DMA_RST 0xFF15 286 + 287 + #define RBUF_SIZE_MASK 0xFBFF 288 + #define RBUF_BASE 0xF000 289 + #define PPBUF_BASE1 0xF800 290 + #define PPBUF_BASE2 0xFA00 291 + 292 + /* internal register value macros */ 293 + #define POWER_OFF 0x03 294 + #define PARTIAL_POWER_ON 0x02 295 + #define POWER_ON 0x00 296 + #define POWER_MASK 0x03 297 + #define LDO3318_PWR_MASK 0x0C 298 + #define LDO_ON 0x00 299 + #define LDO_SUSPEND 0x08 300 + #define LDO_OFF 0x0C 301 + #define DV3318_AUTO_PWR_OFF 0x10 302 + #define FORCE_LDO_POWERB 0x60 303 + 304 + /* LDO_POWER_CFG */ 305 + #define TUNE_SD18_MASK 0x1C 306 + #define TUNE_SD18_1V7 0x00 307 + #define TUNE_SD18_1V8 (0x01 << 2) 308 + #define TUNE_SD18_1V9 (0x02 << 2) 309 + #define TUNE_SD18_2V0 (0x03 << 2) 310 + #define TUNE_SD18_2V7 (0x04 << 2) 311 + #define TUNE_SD18_2V8 (0x05 << 2) 312 + #define TUNE_SD18_2V9 (0x06 << 2) 313 + #define TUNE_SD18_3V3 (0x07 << 2) 314 + 315 + /* CLK_DIV */ 316 + #define CLK_CHANGE 0x80 317 + #define CLK_DIV_1 0x00 318 + #define CLK_DIV_2 0x01 319 + #define CLK_DIV_4 0x02 320 + #define CLK_DIV_8 0x03 321 + 322 + #define SSC_POWER_MASK 0x01 323 + #define SSC_POWER_DOWN 0x01 324 + #define SSC_POWER_ON 0x00 325 + 326 + #define FPGA_VER 0x80 327 + #define HW_VER_MASK 0x0F 328 + 329 + #define EXTEND_DMA1_ASYNC_SIGNAL 0x02 330 + 331 + /* CFG_MODE*/ 332 + #define XTAL_FREE 0x80 333 + #define CLK_MODE_MASK 0x03 334 + #define CLK_MODE_12M_XTAL 0x00 335 + #define CLK_MODE_NON_XTAL 0x01 336 + #define CLK_MODE_24M_OSC 0x02 337 + #define CLK_MODE_48M_OSC 0x03 338 + 339 + /* CFG_MODE_1*/ 340 + #define RTS5179 0x02 341 + 342 + #define NYET_EN 0x01 343 + #define NYET_MSAK 0x01 344 + 345 + #define SD30_DRIVE_MASK 0x07 346 + #define SD20_DRIVE_MASK 0x03 347 + 348 + #define DISABLE_SD_CD 0x08 349 + #define DISABLE_MS_CD 0x10 350 + #define DISABLE_XD_CD 0x20 351 + #define SD_CD_DEGLITCH_EN 0x01 352 + #define MS_CD_DEGLITCH_EN 0x02 353 + #define XD_CD_DEGLITCH_EN 0x04 354 + 355 + #define CARD_SHARE_LQFP48 0x04 356 + #define CARD_SHARE_QFN24 0x00 357 + #define CARD_SHARE_LQFP_SEL 0x04 358 + #define CARD_SHARE_XD 0x00 359 + #define CARD_SHARE_SD 0x01 360 + #define CARD_SHARE_MS 0x02 361 + #define CARD_SHARE_MASK 0x03 362 + 363 + 364 + /* SD30_DRIVE_SEL */ 365 + #define DRIVER_TYPE_A 0x05 366 + #define DRIVER_TYPE_B 0x03 367 + #define DRIVER_TYPE_C 0x02 368 + #define DRIVER_TYPE_D 0x01 369 + 370 + /* SD_BUS_STAT */ 371 + #define SD_CLK_TOGGLE_EN 0x80 372 + #define SD_CLK_FORCE_STOP 0x40 373 + #define SD_DAT3_STATUS 0x10 374 + #define SD_DAT2_STATUS 0x08 375 + #define SD_DAT1_STATUS 0x04 376 + #define SD_DAT0_STATUS 0x02 377 + #define SD_CMD_STATUS 0x01 378 + 379 + /* SD_PAD_CTL */ 380 + #define SD_IO_USING_1V8 0x80 381 + #define SD_IO_USING_3V3 0x7F 382 + #define TYPE_A_DRIVING 0x00 383 + #define TYPE_B_DRIVING 0x01 384 + #define TYPE_C_DRIVING 0x02 385 + #define TYPE_D_DRIVING 0x03 386 + 387 + /* CARD_CLK_EN */ 388 + #define SD_CLK_EN 0x04 389 + #define MS_CLK_EN 0x08 390 + 391 + /* CARD_SELECT */ 392 + #define SD_MOD_SEL 2 393 + #define MS_MOD_SEL 3 394 + 395 + /* CARD_SHARE_MODE */ 396 + #define CARD_SHARE_LQFP48 0x04 397 + #define CARD_SHARE_QFN24 0x00 398 + #define CARD_SHARE_LQFP_SEL 0x04 399 + #define CARD_SHARE_XD 0x00 400 + #define CARD_SHARE_SD 0x01 401 + #define CARD_SHARE_MS 0x02 402 + #define CARD_SHARE_MASK 0x03 403 + 404 + /* SSC_CTL1 */ 405 + #define SSC_RSTB 0x80 406 + #define SSC_8X_EN 0x40 407 + #define SSC_FIX_FRAC 0x20 408 + #define SSC_SEL_1M 0x00 409 + #define SSC_SEL_2M 0x08 410 + #define SSC_SEL_4M 0x10 411 + #define SSC_SEL_8M 0x18 412 + 413 + /* SSC_CTL2 */ 414 + #define SSC_DEPTH_MASK 0x03 415 + #define SSC_DEPTH_DISALBE 0x00 416 + #define SSC_DEPTH_2M 0x01 417 + #define SSC_DEPTH_1M 0x02 418 + #define SSC_DEPTH_512K 0x03 419 + 420 + /* SD_VPCLK0_CTL */ 421 + #define PHASE_CHANGE 0x80 422 + #define PHASE_NOT_RESET 0x40 423 + 424 + /* SD_TRANSFER */ 425 + #define SD_TRANSFER_START 0x80 426 + #define SD_TRANSFER_END 0x40 427 + #define SD_STAT_IDLE 0x20 428 + #define SD_TRANSFER_ERR 0x10 429 + #define SD_TM_NORMAL_WRITE 0x00 430 + #define SD_TM_AUTO_WRITE_3 0x01 431 + #define SD_TM_AUTO_WRITE_4 0x02 432 + #define SD_TM_AUTO_READ_3 0x05 433 + #define SD_TM_AUTO_READ_4 0x06 434 + #define SD_TM_CMD_RSP 0x08 435 + #define SD_TM_AUTO_WRITE_1 0x09 436 + #define SD_TM_AUTO_WRITE_2 0x0A 437 + #define SD_TM_NORMAL_READ 0x0C 438 + #define SD_TM_AUTO_READ_1 0x0D 439 + #define SD_TM_AUTO_READ_2 0x0E 440 + #define SD_TM_AUTO_TUNING 0x0F 441 + 442 + /* SD_CFG1 */ 443 + #define SD_CLK_DIVIDE_0 0x00 444 + #define SD_CLK_DIVIDE_256 0xC0 445 + #define SD_CLK_DIVIDE_128 0x80 446 + #define SD_CLK_DIVIDE_MASK 0xC0 447 + #define SD_BUS_WIDTH_1BIT 0x00 448 + #define SD_BUS_WIDTH_4BIT 0x01 449 + #define SD_BUS_WIDTH_8BIT 0x02 450 + #define SD_ASYNC_FIFO_RST 0x10 451 + #define SD_20_MODE 0x00 452 + #define SD_DDR_MODE 0x04 453 + #define SD_30_MODE 0x08 454 + 455 + /* SD_CFG2 */ 456 + #define SD_CALCULATE_CRC7 0x00 457 + #define SD_NO_CALCULATE_CRC7 0x80 458 + #define SD_CHECK_CRC16 0x00 459 + #define SD_NO_CHECK_CRC16 0x40 460 + #define SD_WAIT_CRC_TO_EN 0x20 461 + #define SD_WAIT_BUSY_END 0x08 462 + #define SD_NO_WAIT_BUSY_END 0x00 463 + #define SD_CHECK_CRC7 0x00 464 + #define SD_NO_CHECK_CRC7 0x04 465 + #define SD_RSP_LEN_0 0x00 466 + #define SD_RSP_LEN_6 0x01 467 + #define SD_RSP_LEN_17 0x02 468 + #define SD_RSP_TYPE_R0 0x04 469 + #define SD_RSP_TYPE_R1 0x01 470 + #define SD_RSP_TYPE_R1b 0x09 471 + #define SD_RSP_TYPE_R2 0x02 472 + #define SD_RSP_TYPE_R3 0x05 473 + #define SD_RSP_TYPE_R4 0x05 474 + #define SD_RSP_TYPE_R5 0x01 475 + #define SD_RSP_TYPE_R6 0x01 476 + #define SD_RSP_TYPE_R7 0x01 477 + 478 + /* SD_STAT1 */ 479 + #define SD_CRC7_ERR 0x80 480 + #define SD_CRC16_ERR 0x40 481 + #define SD_CRC_WRITE_ERR 0x20 482 + #define SD_CRC_WRITE_ERR_MASK 0x1C 483 + #define GET_CRC_TIME_OUT 0x02 484 + #define SD_TUNING_COMPARE_ERR 0x01 485 + 486 + /* SD_DATA_STATE */ 487 + #define SD_DATA_IDLE 0x80 488 + 489 + /* CARD_DATA_SOURCE */ 490 + #define PINGPONG_BUFFER 0x01 491 + #define RING_BUFFER 0x00 492 + 493 + /* CARD_OE */ 494 + #define SD_OUTPUT_EN 0x04 495 + #define MS_OUTPUT_EN 0x08 496 + 497 + /* CARD_STOP */ 498 + #define SD_STOP 0x04 499 + #define MS_STOP 0x08 500 + #define SD_CLR_ERR 0x40 501 + #define MS_CLR_ERR 0x80 502 + 503 + /* CARD_CLK_SOURCE */ 504 + #define CRC_FIX_CLK (0x00 << 0) 505 + #define CRC_VAR_CLK0 (0x01 << 0) 506 + #define CRC_VAR_CLK1 (0x02 << 0) 507 + #define SD30_FIX_CLK (0x00 << 2) 508 + #define SD30_VAR_CLK0 (0x01 << 2) 509 + #define SD30_VAR_CLK1 (0x02 << 2) 510 + #define SAMPLE_FIX_CLK (0x00 << 4) 511 + #define SAMPLE_VAR_CLK0 (0x01 << 4) 512 + #define SAMPLE_VAR_CLK1 (0x02 << 4) 513 + 514 + /* SD_SAMPLE_POINT_CTL */ 515 + #define DDR_FIX_RX_DAT 0x00 516 + #define DDR_VAR_RX_DAT 0x80 517 + #define DDR_FIX_RX_DAT_EDGE 0x00 518 + #define DDR_FIX_RX_DAT_14_DELAY 0x40 519 + #define DDR_FIX_RX_CMD 0x00 520 + #define DDR_VAR_RX_CMD 0x20 521 + #define DDR_FIX_RX_CMD_POS_EDGE 0x00 522 + #define DDR_FIX_RX_CMD_14_DELAY 0x10 523 + #define SD20_RX_POS_EDGE 0x00 524 + #define SD20_RX_14_DELAY 0x08 525 + #define SD20_RX_SEL_MASK 0x08 526 + 527 + /* SD_PUSH_POINT_CTL */ 528 + #define DDR_FIX_TX_CMD_DAT 0x00 529 + #define DDR_VAR_TX_CMD_DAT 0x80 530 + #define DDR_FIX_TX_DAT_14_TSU 0x00 531 + #define DDR_FIX_TX_DAT_12_TSU 0x40 532 + #define DDR_FIX_TX_CMD_NEG_EDGE 0x00 533 + #define DDR_FIX_TX_CMD_14_AHEAD 0x20 534 + #define SD20_TX_NEG_EDGE 0x00 535 + #define SD20_TX_14_AHEAD 0x10 536 + #define SD20_TX_SEL_MASK 0x10 537 + #define DDR_VAR_SDCLK_POL_SWAP 0x01 538 + 539 + /* MS_CFG */ 540 + #define SAMPLE_TIME_RISING 0x00 541 + #define SAMPLE_TIME_FALLING 0x80 542 + #define PUSH_TIME_DEFAULT 0x00 543 + #define PUSH_TIME_ODD 0x40 544 + #define NO_EXTEND_TOGGLE 0x00 545 + #define EXTEND_TOGGLE_CHK 0x20 546 + #define MS_BUS_WIDTH_1 0x00 547 + #define MS_BUS_WIDTH_4 0x10 548 + #define MS_BUS_WIDTH_8 0x18 549 + #define MS_2K_SECTOR_MODE 0x04 550 + #define MS_512_SECTOR_MODE 0x00 551 + #define MS_TOGGLE_TIMEOUT_EN 0x00 552 + #define MS_TOGGLE_TIMEOUT_DISEN 0x01 553 + #define MS_NO_CHECK_INT 0x02 554 + 555 + /* MS_TRANS_CFG */ 556 + #define WAIT_INT 0x80 557 + #define NO_WAIT_INT 0x00 558 + #define NO_AUTO_READ_INT_REG 0x00 559 + #define AUTO_READ_INT_REG 0x40 560 + #define MS_CRC16_ERR 0x20 561 + #define MS_RDY_TIMEOUT 0x10 562 + #define MS_INT_CMDNK 0x08 563 + #define MS_INT_BREQ 0x04 564 + #define MS_INT_ERR 0x02 565 + #define MS_INT_CED 0x01 566 + 567 + /* MS_TRANSFER */ 568 + #define MS_TRANSFER_START 0x80 569 + #define MS_TRANSFER_END 0x40 570 + #define MS_TRANSFER_ERR 0x20 571 + #define MS_BS_STATE 0x10 572 + #define MS_TM_READ_BYTES 0x00 573 + #define MS_TM_NORMAL_READ 0x01 574 + #define MS_TM_WRITE_BYTES 0x04 575 + #define MS_TM_NORMAL_WRITE 0x05 576 + #define MS_TM_AUTO_READ 0x08 577 + #define MS_TM_AUTO_WRITE 0x0C 578 + #define MS_TM_SET_CMD 0x06 579 + #define MS_TM_COPY_PAGE 0x07 580 + #define MS_TM_MULTI_READ 0x02 581 + #define MS_TM_MULTI_WRITE 0x03 582 + 583 + /* MC_FIFO_CTL */ 584 + #define FIFO_FLUSH 0x01 585 + 586 + /* MC_DMA_RST */ 587 + #define DMA_RESET 0x01 588 + 589 + /* MC_DMA_CTL */ 590 + #define DMA_TC_EQ_0 0x80 591 + #define DMA_DIR_TO_CARD 0x00 592 + #define DMA_DIR_FROM_CARD 0x02 593 + #define DMA_EN 0x01 594 + #define DMA_128 (0 << 2) 595 + #define DMA_256 (1 << 2) 596 + #define DMA_512 (2 << 2) 597 + #define DMA_1024 (3 << 2) 598 + #define DMA_PACK_SIZE_MASK 0x0C 599 + 600 + /* CARD_INT_PEND */ 601 + #define XD_INT 0x10 602 + #define MS_INT 0x08 603 + #define SD_INT 0x04 604 + 605 + /* LED operations*/ 606 + static inline int rtsx_usb_turn_on_led(struct rtsx_ucr *ucr) 607 + { 608 + return rtsx_usb_ep0_write_register(ucr, CARD_GPIO, 0x03, 0x02); 609 + } 610 + 611 + static inline int rtsx_usb_turn_off_led(struct rtsx_ucr *ucr) 612 + { 613 + return rtsx_usb_ep0_write_register(ucr, CARD_GPIO, 0x03, 0x03); 614 + } 615 + 616 + /* HW error clearing */ 617 + static inline void rtsx_usb_clear_fsm_err(struct rtsx_ucr *ucr) 618 + { 619 + rtsx_usb_ep0_write_register(ucr, SFSM_ED, 0xf8, 0xf8); 620 + } 621 + 622 + static inline void rtsx_usb_clear_dma_err(struct rtsx_ucr *ucr) 623 + { 624 + rtsx_usb_ep0_write_register(ucr, MC_FIFO_CTL, 625 + FIFO_FLUSH, FIFO_FLUSH); 626 + rtsx_usb_ep0_write_register(ucr, MC_DMA_RST, DMA_RESET, DMA_RESET); 627 + } 628 + #endif /* __RTS51139_H */
+284
include/linux/mfd/tps65218.h
··· 1 + /* 2 + * linux/mfd/tps65218.h 3 + * 4 + * Functions to access TPS65219 power management chip. 5 + * 6 + * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed "as is" WITHOUT ANY WARRANTY of any 13 + * kind, whether expressed or implied; without even the implied warranty 14 + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + * GNU General Public License version 2 for more details. 16 + */ 17 + 18 + #ifndef __LINUX_MFD_TPS65218_H 19 + #define __LINUX_MFD_TPS65218_H 20 + 21 + #include <linux/i2c.h> 22 + #include <linux/regulator/driver.h> 23 + #include <linux/regulator/machine.h> 24 + #include <linux/bitops.h> 25 + 26 + /* TPS chip id list */ 27 + #define TPS65218 0xF0 28 + 29 + /* I2C ID for TPS65218 part */ 30 + #define TPS65218_I2C_ID 0x24 31 + 32 + /* All register addresses */ 33 + #define TPS65218_REG_CHIPID 0x00 34 + #define TPS65218_REG_INT1 0x01 35 + #define TPS65218_REG_INT2 0x02 36 + #define TPS65218_REG_INT_MASK1 0x03 37 + #define TPS65218_REG_INT_MASK2 0x04 38 + #define TPS65218_REG_STATUS 0x05 39 + #define TPS65218_REG_CONTROL 0x06 40 + #define TPS65218_REG_FLAG 0x07 41 + 42 + #define TPS65218_REG_PASSWORD 0x10 43 + #define TPS65218_REG_ENABLE1 0x11 44 + #define TPS65218_REG_ENABLE2 0x12 45 + #define TPS65218_REG_CONFIG1 0x13 46 + #define TPS65218_REG_CONFIG2 0x14 47 + #define TPS65218_REG_CONFIG3 0x15 48 + #define TPS65218_REG_CONTROL_DCDC1 0x16 49 + #define TPS65218_REG_CONTROL_DCDC2 0x17 50 + #define TPS65218_REG_CONTROL_DCDC3 0x18 51 + #define TPS65218_REG_CONTROL_DCDC4 0x19 52 + #define TPS65218_REG_CONTRL_SLEW_RATE 0x1A 53 + #define TPS65218_REG_CONTROL_LDO1 0x1B 54 + #define TPS65218_REG_SEQ1 0x20 55 + #define TPS65218_REG_SEQ2 0x21 56 + #define TPS65218_REG_SEQ3 0x22 57 + #define TPS65218_REG_SEQ4 0x23 58 + #define TPS65218_REG_SEQ5 0x24 59 + #define TPS65218_REG_SEQ6 0x25 60 + #define TPS65218_REG_SEQ7 0x26 61 + 62 + /* Register field definitions */ 63 + #define TPS65218_CHIPID_CHIP_MASK 0xF8 64 + #define TPS65218_CHIPID_REV_MASK 0x07 65 + 66 + #define TPS65218_INT1_VPRG BIT(5) 67 + #define TPS65218_INT1_AC BIT(4) 68 + #define TPS65218_INT1_PB BIT(3) 69 + #define TPS65218_INT1_HOT BIT(2) 70 + #define TPS65218_INT1_CC_AQC BIT(1) 71 + #define TPS65218_INT1_PRGC BIT(0) 72 + 73 + #define TPS65218_INT2_LS3_F BIT(5) 74 + #define TPS65218_INT2_LS2_F BIT(4) 75 + #define TPS65218_INT2_LS1_F BIT(3) 76 + #define TPS65218_INT2_LS3_I BIT(2) 77 + #define TPS65218_INT2_LS2_I BIT(1) 78 + #define TPS65218_INT2_LS1_I BIT(0) 79 + 80 + #define TPS65218_INT_MASK1_VPRG BIT(5) 81 + #define TPS65218_INT_MASK1_AC BIT(4) 82 + #define TPS65218_INT_MASK1_PB BIT(3) 83 + #define TPS65218_INT_MASK1_HOT BIT(2) 84 + #define TPS65218_INT_MASK1_CC_AQC BIT(1) 85 + #define TPS65218_INT_MASK1_PRGC BIT(0) 86 + 87 + #define TPS65218_INT_MASK2_LS3_F BIT(5) 88 + #define TPS65218_INT_MASK2_LS2_F BIT(4) 89 + #define TPS65218_INT_MASK2_LS1_F BIT(3) 90 + #define TPS65218_INT_MASK2_LS3_I BIT(2) 91 + #define TPS65218_INT_MASK2_LS2_I BIT(1) 92 + #define TPS65218_INT_MASK2_LS1_I BIT(0) 93 + 94 + #define TPS65218_STATUS_FSEAL BIT(7) 95 + #define TPS65218_STATUS_EE BIT(6) 96 + #define TPS65218_STATUS_AC_STATE BIT(5) 97 + #define TPS65218_STATUS_PB_STATE BIT(4) 98 + #define TPS65218_STATUS_STATE_MASK 0xC 99 + #define TPS65218_STATUS_CC_STAT 0x3 100 + 101 + #define TPS65218_CONTROL_OFFNPFO BIT(1) 102 + #define TPS65218_CONTROL_CC_AQ BIT(0) 103 + 104 + #define TPS65218_FLAG_GPO3_FLG BIT(7) 105 + #define TPS65218_FLAG_GPO2_FLG BIT(6) 106 + #define TPS65218_FLAG_GPO1_FLG BIT(5) 107 + #define TPS65218_FLAG_LDO1_FLG BIT(4) 108 + #define TPS65218_FLAG_DC4_FLG BIT(3) 109 + #define TPS65218_FLAG_DC3_FLG BIT(2) 110 + #define TPS65218_FLAG_DC2_FLG BIT(1) 111 + #define TPS65218_FLAG_DC1_FLG BIT(0) 112 + 113 + #define TPS65218_ENABLE1_DC6_EN BIT(5) 114 + #define TPS65218_ENABLE1_DC5_EN BIT(4) 115 + #define TPS65218_ENABLE1_DC4_EN BIT(3) 116 + #define TPS65218_ENABLE1_DC3_EN BIT(2) 117 + #define TPS65218_ENABLE1_DC2_EN BIT(1) 118 + #define TPS65218_ENABLE1_DC1_EN BIT(0) 119 + 120 + #define TPS65218_ENABLE2_GPIO3 BIT(6) 121 + #define TPS65218_ENABLE2_GPIO2 BIT(5) 122 + #define TPS65218_ENABLE2_GPIO1 BIT(4) 123 + #define TPS65218_ENABLE2_LS3_EN BIT(3) 124 + #define TPS65218_ENABLE2_LS2_EN BIT(2) 125 + #define TPS65218_ENABLE2_LS1_EN BIT(1) 126 + #define TPS65218_ENABLE2_LDO1_EN BIT(0) 127 + 128 + 129 + #define TPS65218_CONFIG1_TRST BIT(7) 130 + #define TPS65218_CONFIG1_GPO2_BUF BIT(6) 131 + #define TPS65218_CONFIG1_IO1_SEL BIT(5) 132 + #define TPS65218_CONFIG1_PGDLY_MASK 0x18 133 + #define TPS65218_CONFIG1_STRICT BIT(2) 134 + #define TPS65218_CONFIG1_UVLO_MASK 0x3 135 + 136 + #define TPS65218_CONFIG2_DC12_RST BIT(7) 137 + #define TPS65218_CONFIG2_UVLOHYS BIT(6) 138 + #define TPS65218_CONFIG2_LS3ILIM_MASK 0xC 139 + #define TPS65218_CONFIG2_LS2ILIM_MASK 0x3 140 + 141 + #define TPS65218_CONFIG3_LS3NPFO BIT(5) 142 + #define TPS65218_CONFIG3_LS2NPFO BIT(4) 143 + #define TPS65218_CONFIG3_LS1NPFO BIT(3) 144 + #define TPS65218_CONFIG3_LS3DCHRG BIT(2) 145 + #define TPS65218_CONFIG3_LS2DCHRG BIT(1) 146 + #define TPS65218_CONFIG3_LS1DCHRG BIT(0) 147 + 148 + #define TPS65218_CONTROL_DCDC1_PFM BIT(7) 149 + #define TPS65218_CONTROL_DCDC1_MASK 0x7F 150 + 151 + #define TPS65218_CONTROL_DCDC2_PFM BIT(7) 152 + #define TPS65218_CONTROL_DCDC2_MASK 0x3F 153 + 154 + #define TPS65218_CONTROL_DCDC3_PFM BIT(7) 155 + #define TPS65218_CONTROL_DCDC3_MASK 0x3F 156 + 157 + #define TPS65218_CONTROL_DCDC4_PFM BIT(7) 158 + #define TPS65218_CONTROL_DCDC4_MASK 0x3F 159 + 160 + #define TPS65218_SLEW_RATE_GO BIT(7) 161 + #define TPS65218_SLEW_RATE_GODSBL BIT(6) 162 + #define TPS65218_SLEW_RATE_SLEW_MASK 0x7 163 + 164 + #define TPS65218_CONTROL_LDO1_MASK 0x3F 165 + 166 + #define TPS65218_SEQ1_DLY8 BIT(7) 167 + #define TPS65218_SEQ1_DLY7 BIT(6) 168 + #define TPS65218_SEQ1_DLY6 BIT(5) 169 + #define TPS65218_SEQ1_DLY5 BIT(4) 170 + #define TPS65218_SEQ1_DLY4 BIT(3) 171 + #define TPS65218_SEQ1_DLY3 BIT(2) 172 + #define TPS65218_SEQ1_DLY2 BIT(1) 173 + #define TPS65218_SEQ1_DLY1 BIT(0) 174 + 175 + #define TPS65218_SEQ2_DLYFCTR BIT(7) 176 + #define TPS65218_SEQ2_DLY9 BIT(0) 177 + 178 + #define TPS65218_SEQ3_DC2_SEQ_MASK 0xF0 179 + #define TPS65218_SEQ3_DC1_SEQ_MASK 0xF 180 + 181 + #define TPS65218_SEQ4_DC4_SEQ_MASK 0xF0 182 + #define TPS65218_SEQ4_DC3_SEQ_MASK 0xF 183 + 184 + #define TPS65218_SEQ5_DC6_SEQ_MASK 0xF0 185 + #define TPS65218_SEQ5_DC5_SEQ_MASK 0xF 186 + 187 + #define TPS65218_SEQ6_LS1_SEQ_MASK 0xF0 188 + #define TPS65218_SEQ6_LDO1_SEQ_MASK 0xF 189 + 190 + #define TPS65218_SEQ7_GPO3_SEQ_MASK 0xF0 191 + #define TPS65218_SEQ7_GPO1_SEQ_MASK 0xF 192 + #define TPS65218_PROTECT_NONE 0 193 + #define TPS65218_PROTECT_L1 1 194 + 195 + enum tps65218_regulator_id { 196 + /* DCDC's */ 197 + TPS65218_DCDC_1, 198 + TPS65218_DCDC_2, 199 + TPS65218_DCDC_3, 200 + TPS65218_DCDC_4, 201 + TPS65218_DCDC_5, 202 + TPS65218_DCDC_6, 203 + /* LDOs */ 204 + TPS65218_LDO_1, 205 + }; 206 + 207 + #define TPS65218_MAX_REG_ID TPS65218_LDO_1 208 + 209 + /* Number of step-down converters available */ 210 + #define TPS65218_NUM_DCDC 6 211 + /* Number of LDO voltage regulators available */ 212 + #define TPS65218_NUM_LDO 1 213 + /* Number of total regulators available */ 214 + #define TPS65218_NUM_REGULATOR (TPS65218_NUM_DCDC + TPS65218_NUM_LDO) 215 + 216 + /* Define the TPS65218 IRQ numbers */ 217 + enum tps65218_irqs { 218 + /* INT1 registers */ 219 + TPS65218_PRGC_IRQ, 220 + TPS65218_CC_AQC_IRQ, 221 + TPS65218_HOT_IRQ, 222 + TPS65218_PB_IRQ, 223 + TPS65218_AC_IRQ, 224 + TPS65218_VPRG_IRQ, 225 + TPS65218_INVALID1_IRQ, 226 + TPS65218_INVALID2_IRQ, 227 + /* INT2 registers */ 228 + TPS65218_LS1_I_IRQ, 229 + TPS65218_LS2_I_IRQ, 230 + TPS65218_LS3_I_IRQ, 231 + TPS65218_LS1_F_IRQ, 232 + TPS65218_LS2_F_IRQ, 233 + TPS65218_LS3_F_IRQ, 234 + TPS65218_INVALID3_IRQ, 235 + TPS65218_INVALID4_IRQ, 236 + }; 237 + 238 + /** 239 + * struct tps_info - packages regulator constraints 240 + * @id: Id of the regulator 241 + * @name: Voltage regulator name 242 + * @min_uV: minimum micro volts 243 + * @max_uV: minimum micro volts 244 + * 245 + * This data is used to check the regualtor voltage limits while setting. 246 + */ 247 + struct tps_info { 248 + int id; 249 + const char *name; 250 + int min_uV; 251 + int max_uV; 252 + }; 253 + 254 + /** 255 + * struct tps65218 - tps65218 sub-driver chip access routines 256 + * 257 + * Device data may be used to access the TPS65218 chip 258 + */ 259 + 260 + struct tps65218 { 261 + struct device *dev; 262 + unsigned int id; 263 + 264 + struct mutex tps_lock; /* lock guarding the data structure */ 265 + /* IRQ Data */ 266 + int irq; 267 + u32 irq_mask; 268 + struct regmap_irq_chip_data *irq_data; 269 + struct regulator_desc desc[TPS65218_NUM_REGULATOR]; 270 + struct regulator_dev *rdev[TPS65218_NUM_REGULATOR]; 271 + struct tps_info *info[TPS65218_NUM_REGULATOR]; 272 + struct regmap *regmap; 273 + }; 274 + 275 + int tps65218_reg_read(struct tps65218 *tps, unsigned int reg, 276 + unsigned int *val); 277 + int tps65218_reg_write(struct tps65218 *tps, unsigned int reg, 278 + unsigned int val, unsigned int level); 279 + int tps65218_set_bits(struct tps65218 *tps, unsigned int reg, 280 + unsigned int mask, unsigned int val, unsigned int level); 281 + int tps65218_clear_bits(struct tps65218 *tps, unsigned int reg, 282 + unsigned int mask, unsigned int level); 283 + 284 + #endif /* __LINUX_MFD_TPS65218_H */
+20
include/linux/ssbi.h
··· 20 20 int ssbi_write(struct device *dev, u16 addr, const u8 *buf, int len); 21 21 int ssbi_read(struct device *dev, u16 addr, u8 *buf, int len); 22 22 23 + static inline int 24 + ssbi_reg_read(void *context, unsigned int reg, unsigned int *val) 25 + { 26 + int ret; 27 + u8 v; 28 + 29 + ret = ssbi_read(context, reg, &v, 1); 30 + if (!ret) 31 + *val = v; 32 + 33 + return ret; 34 + } 35 + 36 + static inline int 37 + ssbi_reg_write(void *context, unsigned int reg, unsigned int val) 38 + { 39 + u8 v = val; 40 + return ssbi_write(context, reg, &v, 1); 41 + } 42 + 23 43 #endif