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

Merge tag 'mfd-next-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
"New drivers:
- Add support for Cherry Trail Dollar Cove TI PMIC
- Add support for Add Spreadtrum SC27xx series PMICs

New device support:
- Add support Regulator to axp20x

New functionality:
- Add DT support; aspeed-scu sc27xx-pmic
- Add power saving support; rts5249

Fix-ups:
- DT clean-up/rework; tps65217, max77693, iproc-cdru, iproc-mhb, tps65218
- Staticise/constify; stw481x
- Use new succinct IRQ API; fsl-imx25-tsadc
- Kconfig fix-ups; MFD_TPS65218
- Identify SPI method; lpc_ich
- Use managed resources (devm_*) calls; ssbi
- Remove unused/obsolete code/documentation; mc13xxx

Bug fixes:
- Fix typo in MAINTAINERS
- Fix error handling; mxs-lradc
- Clean-up IRQs on .remove; fsl-imx25-tsadc"

* tag 'mfd-next-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (21 commits)
dt-bindings: mfd: mc13xxx: Remove obsolete property
mfd: axp20x: Add axp20x-regulator cell for AXP813
mfd: Add Spreadtrum SC27xx series PMICs driver
dt-bindings: mfd: Add Spreadtrum SC27xx PMIC documentation
mfd: ssbi: Use devm_of_platform_populate()
mfd: fsl-imx25: Clean up irq settings during removal
mfd: mxs-lradc: Fix error handling in mxs_lradc_probe()
mfd: lpc_ich: Avoton/Rangeley uses SPI_BYT method
mfd: tps65218: Introduce dependency on CONFIG_OF
mfd: tps65218: Correct the config description
MAINTAINERS: Fix Dialog search term for watchdog binding file
mfd: fsl-imx25: Set irq handler and data in one go
mfd: rts5249: Add support for RTS5250S power saving
ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC
mfd: Add support for Cherry Trail Dollar Cove TI PMIC
syscon: dt-bindings: Add binding document for iProc MHB block
syscon: dt-bindings: Add binding doc for Broadcom iProc CDRU
mfd: max77693: Add muic of_compatible in mfd_cell
mfd: stw481x: Make three arrays static const, reduces object code size
mfd: tps65217: Introduce dependency on CONFIG_OF
...

+1138 -75
+6
Documentation/devicetree/bindings/mfd/aspeed-scu.txt
··· 9 9 "aspeed,g5-scu", "syscon", "simple-mfd" 10 10 11 11 - reg: contains the offset and length of the SCU memory region 12 + - #clock-cells: should be set to <1> - the system controller is also a 13 + clock provider 14 + - #reset-cells: should be set to <1> - the system controller is also a 15 + reset line provider 12 16 13 17 Example: 14 18 15 19 syscon: syscon@1e6e2000 { 16 20 compatible = "aspeed,ast2400-scu", "syscon", "simple-mfd"; 17 21 reg = <0x1e6e2000 0x1a8>; 22 + #clock-cells = <1>; 23 + #reset-cells = <1>; 18 24 };
+16
Documentation/devicetree/bindings/mfd/brcm,iproc-cdru.txt
··· 1 + Broadcom iProc Chip Device Resource Unit (CDRU) 2 + 3 + Various Broadcom iProc SoCs have a set of registers that provide various 4 + chip specific device and resource configurations. This node allows access to 5 + these CDRU registers via syscon. 6 + 7 + Required properties: 8 + - compatible: should contain: 9 + "brcm,sr-cdru", "syscon" for Stingray 10 + - reg: base address and range of the CDRU registers 11 + 12 + Example: 13 + cdru: syscon@6641d000 { 14 + compatible = "brcm,sr-cdru", "syscon"; 15 + reg = <0 0x6641d000 0 0x400>; 16 + };
+18
Documentation/devicetree/bindings/mfd/brcm,iproc-mhb.txt
··· 1 + Broadcom iProc Multi Host Bridge (MHB) 2 + 3 + Certain Broadcom iProc SoCs have a multi host bridge (MHB) block that controls 4 + the connection and configuration of 1) internal PCIe serdes; 2) PCIe endpoint 5 + interface; 3) access to the Nitro (network processing) engine 6 + 7 + This node allows access to these MHB registers via syscon. 8 + 9 + Required properties: 10 + - compatible: should contain: 11 + "brcm,sr-mhb", "syscon" for Stingray 12 + - reg: base address and range of the MHB registers 13 + 14 + Example: 15 + mhb: syscon@60401000 { 16 + compatible = "brcm,sr-mhb", "syscon"; 17 + reg = <0 0x60401000 0 0x38c>; 18 + };
+6
Documentation/devicetree/bindings/mfd/max77693.txt
··· 127 127 Optional properties for the LED child node: 128 128 - label : see Documentation/devicetree/bindings/leds/common.txt 129 129 130 + Optional nodes: 131 + - max77693-muic : 132 + Node used only by extcon consumers. 133 + Required properties: 134 + - compatible : "maxim,max77693-muic" 135 + 130 136 Example: 131 137 #include <dt-bindings/leds/common.h> 132 138
-1
Documentation/devicetree/bindings/mfd/mc13xxx.txt
··· 113 113 Examples: 114 114 115 115 ecspi@70010000 { /* ECSPI1 */ 116 - fsl,spi-num-chipselects = <2>; 117 116 cs-gpios = <&gpio4 24 0>, /* GPIO4_24 */ 118 117 <&gpio4 25 0>; /* GPIO4_25 */ 119 118
+40
Documentation/devicetree/bindings/mfd/sprd,sc27xx-pmic.txt
··· 1 + Spreadtrum SC27xx Power Management Integrated Circuit (PMIC) 2 + 3 + The Spreadtrum SC27xx series PMICs contain SC2720, SC2721, SC2723, SC2730 4 + and SC2731. The Spreadtrum PMIC belonging to SC27xx series integrates all 5 + mobile handset power management, audio codec, battery management and user 6 + interface support function in a single chip. It has 6 major functional 7 + blocks: 8 + - DCDCs to support CPU, memory. 9 + - LDOs to support both internal and external requirement. 10 + - Battery management system, such as charger, fuel gauge. 11 + - Audio codec. 12 + - User interface function, such as indicator, flash LED and so on. 13 + - IC level interface, such as power on/off control, RTC and typec and so on. 14 + 15 + Required properties: 16 + - compatible: Should be one of the following: 17 + "sprd,sc2720" 18 + "sprd,sc2721" 19 + "sprd,sc2723" 20 + "sprd,sc2730" 21 + "sprd,sc2731" 22 + - reg: The address of the device chip select, should be 0. 23 + - spi-max-frequency: Typically set to 26000000. 24 + - interrupts: The interrupt line the device is connected to. 25 + - interrupt-controller: Marks the device node as an interrupt controller. 26 + - #interrupt-cells: The number of cells to describe an PMIC IRQ, must be 2. 27 + - #address-cells: Child device offset number of cells, must be 1. 28 + - #size-cells: Child device size number of cells, must be 0. 29 + 30 + Example: 31 + pmic@0 { 32 + compatible = "sprd,sc2731"; 33 + reg = <0>; 34 + spi-max-frequency = <26000000>; 35 + interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 36 + interrupt-controller; 37 + #interrupt-cells = <2>; 38 + #address-cells = <1>; 39 + #size-cells = <0>; 40 + };
+1 -1
MAINTAINERS
··· 4146 4146 F: Documentation/devicetree/bindings/input/da90??-onkey.txt 4147 4147 F: Documentation/devicetree/bindings/thermal/da90??-thermal.txt 4148 4148 F: Documentation/devicetree/bindings/regulator/da92*.txt 4149 - F: Documentation/devicetree/bindings/watchdog/da92??-wdt.txt 4149 + F: Documentation/devicetree/bindings/watchdog/da90??-wdt.txt 4150 4150 F: Documentation/devicetree/bindings/sound/da[79]*.txt 4151 4151 F: drivers/gpio/gpio-da90??.c 4152 4152 F: drivers/hwmon/da90??-hwmon.c
+6
drivers/acpi/Kconfig
··· 527 527 help 528 528 This config adds ACPI operation region support for CHT Whiskey Cove PMIC. 529 529 530 + config CHT_DC_TI_PMIC_OPREGION 531 + bool "ACPI operation region support for Dollar Cove TI PMIC" 532 + depends on INTEL_SOC_PMIC_CHTDC_TI 533 + help 534 + This config adds ACPI operation region support for Dollar Cove TI PMIC. 535 + 530 536 endif 531 537 532 538 config ACPI_CONFIGFS
+1
drivers/acpi/Makefile
··· 106 106 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o 107 107 obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o 108 108 obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o 109 + obj-$(CONFIG_CHT_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_chtdc_ti.o 109 110 110 111 obj-$(CONFIG_ACPI_CONFIGFS) += acpi_configfs.o 111 112
+137
drivers/acpi/pmic/intel_pmic_chtdc_ti.c
··· 1 + /* 2 + * Dollar Cove TI PMIC operation region driver 3 + * Copyright (C) 2014 Intel Corporation. All rights reserved. 4 + * 5 + * Rewritten and cleaned up 6 + * Copyright (C) 2017 Takashi Iwai <tiwai@suse.de> 7 + */ 8 + 9 + #include <linux/acpi.h> 10 + #include <linux/init.h> 11 + #include <linux/mfd/intel_soc_pmic.h> 12 + #include <linux/platform_device.h> 13 + #include "intel_pmic.h" 14 + 15 + /* registers stored in 16bit BE (high:low, total 10bit) */ 16 + #define CHTDC_TI_VBAT 0x54 17 + #define CHTDC_TI_DIETEMP 0x56 18 + #define CHTDC_TI_BPTHERM 0x58 19 + #define CHTDC_TI_GPADC 0x5a 20 + 21 + static struct pmic_table chtdc_ti_power_table[] = { 22 + { .address = 0x00, .reg = 0x41 }, 23 + { .address = 0x04, .reg = 0x42 }, 24 + { .address = 0x08, .reg = 0x43 }, 25 + { .address = 0x0c, .reg = 0x45 }, 26 + { .address = 0x10, .reg = 0x46 }, 27 + { .address = 0x14, .reg = 0x47 }, 28 + { .address = 0x18, .reg = 0x48 }, 29 + { .address = 0x1c, .reg = 0x49 }, 30 + { .address = 0x20, .reg = 0x4a }, 31 + { .address = 0x24, .reg = 0x4b }, 32 + { .address = 0x28, .reg = 0x4c }, 33 + { .address = 0x2c, .reg = 0x4d }, 34 + { .address = 0x30, .reg = 0x4e }, 35 + }; 36 + 37 + static struct pmic_table chtdc_ti_thermal_table[] = { 38 + { 39 + .address = 0x00, 40 + .reg = CHTDC_TI_GPADC 41 + }, 42 + { 43 + .address = 0x0c, 44 + .reg = CHTDC_TI_GPADC 45 + }, 46 + /* TMP2 -> SYSTEMP */ 47 + { 48 + .address = 0x18, 49 + .reg = CHTDC_TI_GPADC 50 + }, 51 + /* TMP3 -> BPTHERM */ 52 + { 53 + .address = 0x24, 54 + .reg = CHTDC_TI_BPTHERM 55 + }, 56 + { 57 + .address = 0x30, 58 + .reg = CHTDC_TI_GPADC 59 + }, 60 + /* TMP5 -> DIETEMP */ 61 + { 62 + .address = 0x3c, 63 + .reg = CHTDC_TI_DIETEMP 64 + }, 65 + }; 66 + 67 + static int chtdc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit, 68 + u64 *value) 69 + { 70 + int data; 71 + 72 + if (regmap_read(regmap, reg, &data)) 73 + return -EIO; 74 + 75 + *value = data & 1; 76 + return 0; 77 + } 78 + 79 + static int chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit, 80 + bool on) 81 + { 82 + return regmap_update_bits(regmap, reg, 1, on); 83 + } 84 + 85 + static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg) 86 + { 87 + u8 buf[2]; 88 + 89 + if (regmap_bulk_read(regmap, reg, buf, 2)) 90 + return -EIO; 91 + 92 + /* stored in big-endian */ 93 + return ((buf[0] & 0x03) << 8) | buf[1]; 94 + } 95 + 96 + static struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = { 97 + .get_power = chtdc_ti_pmic_get_power, 98 + .update_power = chtdc_ti_pmic_update_power, 99 + .get_raw_temp = chtdc_ti_pmic_get_raw_temp, 100 + .power_table = chtdc_ti_power_table, 101 + .power_table_count = ARRAY_SIZE(chtdc_ti_power_table), 102 + .thermal_table = chtdc_ti_thermal_table, 103 + .thermal_table_count = ARRAY_SIZE(chtdc_ti_thermal_table), 104 + }; 105 + 106 + static int chtdc_ti_pmic_opregion_probe(struct platform_device *pdev) 107 + { 108 + struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent); 109 + int err; 110 + 111 + err = intel_pmic_install_opregion_handler(&pdev->dev, 112 + ACPI_HANDLE(pdev->dev.parent), pmic->regmap, 113 + &chtdc_ti_pmic_opregion_data); 114 + if (err < 0) 115 + return err; 116 + 117 + /* Re-enumerate devices depending on PMIC */ 118 + acpi_walk_dep_device_list(ACPI_HANDLE(pdev->dev.parent)); 119 + return 0; 120 + } 121 + 122 + static const struct platform_device_id chtdc_ti_pmic_opregion_id_table[] = { 123 + { .name = "chtdc_ti_region" }, 124 + {}, 125 + }; 126 + 127 + static struct platform_driver chtdc_ti_pmic_opregion_driver = { 128 + .probe = chtdc_ti_pmic_opregion_probe, 129 + .driver = { 130 + .name = "cht_dollar_cove_ti_pmic", 131 + }, 132 + .id_table = chtdc_ti_pmic_opregion_id_table, 133 + }; 134 + module_platform_driver(chtdc_ti_pmic_opregion_driver); 135 + 136 + MODULE_DESCRIPTION("Dollar Cove TI PMIC opregion driver"); 137 + MODULE_LICENSE("GPL v2");
+32 -4
drivers/mfd/Kconfig
··· 510 510 available before any devices using it are probed. This option also 511 511 causes the designware-i2c driver to be builtin for the same reason. 512 512 513 + config INTEL_SOC_PMIC_CHTDC_TI 514 + tristate "Support for Intel Cherry Trail Dollar Cove TI PMIC" 515 + depends on GPIOLIB 516 + depends on I2C 517 + depends on ACPI 518 + depends on X86 519 + select MFD_CORE 520 + select REGMAP_I2C 521 + select REGMAP_IRQ 522 + help 523 + Select this option for supporting Dollar Cove (TI version) PMIC 524 + device that is found on some Intel Cherry Trail systems. 525 + 513 526 config MFD_INTEL_LPSS 514 527 tristate 515 528 select COMMON_CLK ··· 1070 1057 To compile this driver as a module, choose M here: the 1071 1058 module will be called smsc. 1072 1059 1060 + config MFD_SC27XX_PMIC 1061 + tristate "Spreadtrum SC27xx PMICs" 1062 + depends on ARCH_SPRD || COMPILE_TEST 1063 + depends on SPI_MASTER 1064 + select MFD_CORE 1065 + select REGMAP_SPI 1066 + select REGMAP_IRQ 1067 + help 1068 + This enables support for the Spreadtrum SC27xx PMICs with SPI 1069 + interface. The SC27xx series PMICs integrate power management, 1070 + audio codec, battery management and user interface support 1071 + function (such as RTC, Typec, indicator and so on) in a single chip. 1072 + 1073 + This driver provides common support for accessing the SC27xx PMICs, 1074 + and it also adds the irq_chip parts for handling the PMIC chip events. 1075 + 1073 1076 config ABX500_CORE 1074 1077 bool "ST-Ericsson ABX500 Mixed Signal Circuit register functions" 1075 1078 default y if ARCH_U300 || ARCH_U8500 || COMPILE_TEST ··· 1367 1338 1368 1339 config MFD_TPS65217 1369 1340 tristate "TI TPS65217 Power Management / White LED chips" 1370 - depends on I2C 1341 + depends on I2C && OF 1371 1342 select MFD_CORE 1372 1343 select REGMAP_I2C 1373 1344 select IRQ_DOMAIN ··· 1429 1400 1430 1401 config MFD_TPS65218 1431 1402 tristate "TI TPS65218 Power Management chips" 1432 - depends on I2C 1403 + depends on I2C && OF 1433 1404 select MFD_CORE 1434 1405 select REGMAP_I2C 1435 1406 select REGMAP_IRQ ··· 1437 1408 If you say yes here you get support for the TPS65218 series of 1438 1409 Power Management chips. 1439 1410 These include voltage regulators, gpio and other features 1440 - that are often used in portable devices. Only regulator 1441 - component is currently supported. 1411 + that are often used in portable devices. 1442 1412 1443 1413 This driver can also be built as a module. If so, the module 1444 1414 will be called tps65218.
+2
drivers/mfd/Makefile
··· 220 220 obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o 221 221 obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC) += intel_soc_pmic_bxtwc.o 222 222 obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o 223 + obj-$(CONFIG_INTEL_SOC_PMIC_CHTDC_TI) += intel_soc_pmic_chtdc_ti.o 223 224 obj-$(CONFIG_MFD_MT6397) += mt6397-core.o 224 225 225 226 obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o ··· 229 228 obj-$(CONFIG_MFD_STM32_LPTIMER) += stm32-lptimer.o 230 229 obj-$(CONFIG_MFD_STM32_TIMERS) += stm32-timers.o 231 230 obj-$(CONFIG_MFD_MXS_LRADC) += mxs-lradc.o 231 + obj-$(CONFIG_MFD_SC27XX_PMIC) += sprd-sc27xx-spi.o
+2
drivers/mfd/axp20x.c
··· 876 876 .name = "axp221-pek", 877 877 .num_resources = ARRAY_SIZE(axp803_pek_resources), 878 878 .resources = axp803_pek_resources, 879 + }, { 880 + .name = "axp20x-regulator", 879 881 } 880 882 }; 881 883
+15 -2
drivers/mfd/fsl-imx25-tsadc.c
··· 84 84 return -ENOMEM; 85 85 } 86 86 87 - irq_set_chained_handler(irq, mx25_tsadc_irq_handler); 88 - irq_set_handler_data(irq, tsadc); 87 + irq_set_chained_handler_and_data(irq, mx25_tsadc_irq_handler, tsadc); 89 88 90 89 return 0; 91 90 } ··· 179 180 return devm_of_platform_populate(dev); 180 181 } 181 182 183 + static int mx25_tsadc_remove(struct platform_device *pdev) 184 + { 185 + struct mx25_tsadc *tsadc = platform_get_drvdata(pdev); 186 + int irq = platform_get_irq(pdev, 0); 187 + 188 + if (irq) { 189 + irq_set_chained_handler_and_data(irq, NULL, NULL); 190 + irq_domain_remove(tsadc->domain); 191 + } 192 + 193 + return 0; 194 + } 195 + 182 196 static const struct of_device_id mx25_tsadc_ids[] = { 183 197 { .compatible = "fsl,imx25-tsadc" }, 184 198 { /* Sentinel */ } ··· 204 192 .of_match_table = of_match_ptr(mx25_tsadc_ids), 205 193 }, 206 194 .probe = mx25_tsadc_probe, 195 + .remove = mx25_tsadc_remove, 207 196 }; 208 197 module_platform_driver(mx25_tsadc_driver); 209 198
+184
drivers/mfd/intel_soc_pmic_chtdc_ti.c
··· 1 + /* 2 + * Device access for Dollar Cove TI PMIC 3 + * 4 + * Copyright (c) 2014, Intel Corporation. 5 + * Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com> 6 + * 7 + * Cleanup and forward-ported 8 + * Copyright (c) 2017 Takashi Iwai <tiwai@suse.de> 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License version 2 as 12 + * published by the Free Software Foundation. 13 + */ 14 + 15 + #include <linux/acpi.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/i2c.h> 18 + #include <linux/mfd/core.h> 19 + #include <linux/mfd/intel_soc_pmic.h> 20 + #include <linux/module.h> 21 + #include <linux/regmap.h> 22 + 23 + #define CHTDC_TI_IRQLVL1 0x01 24 + #define CHTDC_TI_MASK_IRQLVL1 0x02 25 + 26 + /* Level 1 IRQs */ 27 + enum { 28 + CHTDC_TI_PWRBTN = 0, /* power button */ 29 + CHTDC_TI_DIETMPWARN, /* thermal */ 30 + CHTDC_TI_ADCCMPL, /* ADC */ 31 + /* No IRQ 3 */ 32 + CHTDC_TI_VBATLOW = 4, /* battery */ 33 + CHTDC_TI_VBUSDET, /* power source */ 34 + /* No IRQ 6 */ 35 + CHTDC_TI_CCEOCAL = 7, /* battery */ 36 + }; 37 + 38 + static struct resource power_button_resources[] = { 39 + DEFINE_RES_IRQ(CHTDC_TI_PWRBTN), 40 + }; 41 + 42 + static struct resource thermal_resources[] = { 43 + DEFINE_RES_IRQ(CHTDC_TI_DIETMPWARN), 44 + }; 45 + 46 + static struct resource adc_resources[] = { 47 + DEFINE_RES_IRQ(CHTDC_TI_ADCCMPL), 48 + }; 49 + 50 + static struct resource pwrsrc_resources[] = { 51 + DEFINE_RES_IRQ(CHTDC_TI_VBUSDET), 52 + }; 53 + 54 + static struct resource battery_resources[] = { 55 + DEFINE_RES_IRQ(CHTDC_TI_VBATLOW), 56 + DEFINE_RES_IRQ(CHTDC_TI_CCEOCAL), 57 + }; 58 + 59 + static struct mfd_cell chtdc_ti_dev[] = { 60 + { 61 + .name = "chtdc_ti_pwrbtn", 62 + .num_resources = ARRAY_SIZE(power_button_resources), 63 + .resources = power_button_resources, 64 + }, { 65 + .name = "chtdc_ti_adc", 66 + .num_resources = ARRAY_SIZE(adc_resources), 67 + .resources = adc_resources, 68 + }, { 69 + .name = "chtdc_ti_thermal", 70 + .num_resources = ARRAY_SIZE(thermal_resources), 71 + .resources = thermal_resources, 72 + }, { 73 + .name = "chtdc_ti_pwrsrc", 74 + .num_resources = ARRAY_SIZE(pwrsrc_resources), 75 + .resources = pwrsrc_resources, 76 + }, { 77 + .name = "chtdc_ti_battery", 78 + .num_resources = ARRAY_SIZE(battery_resources), 79 + .resources = battery_resources, 80 + }, 81 + { .name = "chtdc_ti_region", }, 82 + }; 83 + 84 + static const struct regmap_config chtdc_ti_regmap_config = { 85 + .reg_bits = 8, 86 + .val_bits = 8, 87 + .max_register = 128, 88 + .cache_type = REGCACHE_NONE, 89 + }; 90 + 91 + static const struct regmap_irq chtdc_ti_irqs[] = { 92 + REGMAP_IRQ_REG(CHTDC_TI_PWRBTN, 0, BIT(CHTDC_TI_PWRBTN)), 93 + REGMAP_IRQ_REG(CHTDC_TI_DIETMPWARN, 0, BIT(CHTDC_TI_DIETMPWARN)), 94 + REGMAP_IRQ_REG(CHTDC_TI_ADCCMPL, 0, BIT(CHTDC_TI_ADCCMPL)), 95 + REGMAP_IRQ_REG(CHTDC_TI_VBATLOW, 0, BIT(CHTDC_TI_VBATLOW)), 96 + REGMAP_IRQ_REG(CHTDC_TI_VBUSDET, 0, BIT(CHTDC_TI_VBUSDET)), 97 + REGMAP_IRQ_REG(CHTDC_TI_CCEOCAL, 0, BIT(CHTDC_TI_CCEOCAL)), 98 + }; 99 + 100 + static const struct regmap_irq_chip chtdc_ti_irq_chip = { 101 + .name = KBUILD_MODNAME, 102 + .irqs = chtdc_ti_irqs, 103 + .num_irqs = ARRAY_SIZE(chtdc_ti_irqs), 104 + .num_regs = 1, 105 + .status_base = CHTDC_TI_IRQLVL1, 106 + .mask_base = CHTDC_TI_MASK_IRQLVL1, 107 + .ack_base = CHTDC_TI_IRQLVL1, 108 + }; 109 + 110 + static int chtdc_ti_probe(struct i2c_client *i2c) 111 + { 112 + struct device *dev = &i2c->dev; 113 + struct intel_soc_pmic *pmic; 114 + int ret; 115 + 116 + pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); 117 + if (!pmic) 118 + return -ENOMEM; 119 + 120 + i2c_set_clientdata(i2c, pmic); 121 + 122 + pmic->regmap = devm_regmap_init_i2c(i2c, &chtdc_ti_regmap_config); 123 + if (IS_ERR(pmic->regmap)) 124 + return PTR_ERR(pmic->regmap); 125 + pmic->irq = i2c->irq; 126 + 127 + ret = devm_regmap_add_irq_chip(dev, pmic->regmap, pmic->irq, 128 + IRQF_ONESHOT, 0, 129 + &chtdc_ti_irq_chip, 130 + &pmic->irq_chip_data); 131 + if (ret) 132 + return ret; 133 + 134 + return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, chtdc_ti_dev, 135 + ARRAY_SIZE(chtdc_ti_dev), NULL, 0, 136 + regmap_irq_get_domain(pmic->irq_chip_data)); 137 + } 138 + 139 + static void chtdc_ti_shutdown(struct i2c_client *i2c) 140 + { 141 + struct intel_soc_pmic *pmic = i2c_get_clientdata(i2c); 142 + 143 + disable_irq(pmic->irq); 144 + } 145 + 146 + static int __maybe_unused chtdc_ti_suspend(struct device *dev) 147 + { 148 + struct intel_soc_pmic *pmic = dev_get_drvdata(dev); 149 + 150 + disable_irq(pmic->irq); 151 + 152 + return 0; 153 + } 154 + 155 + static int __maybe_unused chtdc_ti_resume(struct device *dev) 156 + { 157 + struct intel_soc_pmic *pmic = dev_get_drvdata(dev); 158 + 159 + enable_irq(pmic->irq); 160 + 161 + return 0; 162 + } 163 + 164 + static SIMPLE_DEV_PM_OPS(chtdc_ti_pm_ops, chtdc_ti_suspend, chtdc_ti_resume); 165 + 166 + static const struct acpi_device_id chtdc_ti_acpi_ids[] = { 167 + { "INT33F5" }, 168 + { }, 169 + }; 170 + MODULE_DEVICE_TABLE(acpi, chtdc_ti_acpi_ids); 171 + 172 + static struct i2c_driver chtdc_ti_i2c_driver = { 173 + .driver = { 174 + .name = "intel_soc_pmic_chtdc_ti", 175 + .pm = &chtdc_ti_pm_ops, 176 + .acpi_match_table = chtdc_ti_acpi_ids, 177 + }, 178 + .probe_new = chtdc_ti_probe, 179 + .shutdown = chtdc_ti_shutdown, 180 + }; 181 + module_i2c_driver(chtdc_ti_i2c_driver); 182 + 183 + MODULE_DESCRIPTION("I2C driver for Intel SoC Dollar Cove TI PMIC"); 184 + MODULE_LICENSE("GPL v2");
+1
drivers/mfd/lpc_ich.c
··· 522 522 .name = "Avoton SoC", 523 523 .iTCO_version = 3, 524 524 .gpio_version = AVOTON_GPIO, 525 + .spi_type = INTEL_SPI_BYT, 525 526 }, 526 527 [LPC_BAYTRAIL] = { 527 528 .name = "Bay Trail SoC",
+4 -1
drivers/mfd/max77693.c
··· 48 48 .name = "max77693-charger", 49 49 .of_compatible = "maxim,max77693-charger", 50 50 }, 51 - { .name = "max77693-muic", }, 51 + { 52 + .name = "max77693-muic", 53 + .of_compatible = "maxim,max77693-muic", 54 + }, 52 55 { 53 56 .name = "max77693-haptic", 54 57 .of_compatible = "maxim,max77693-haptic",
+4 -2
drivers/mfd/mxs-lradc.c
··· 196 196 platform_set_drvdata(pdev, lradc); 197 197 198 198 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 199 - if (!res) 200 - return -ENOMEM; 199 + if (!res) { 200 + ret = -ENOMEM; 201 + goto err_clk; 202 + } 201 203 202 204 switch (lradc->soc) { 203 205 case IMX23_LRADC:
+154 -1
drivers/mfd/rts5249.c
··· 103 103 rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); 104 104 } 105 105 106 + static void rts5249_init_from_cfg(struct rtsx_pcr *pcr) 107 + { 108 + struct rtsx_cr_option *option = &(pcr->option); 109 + u32 lval; 110 + 111 + if (CHK_PCI_PID(pcr, PID_524A)) 112 + rtsx_pci_read_config_dword(pcr, 113 + PCR_ASPM_SETTING_REG1, &lval); 114 + else 115 + rtsx_pci_read_config_dword(pcr, 116 + PCR_ASPM_SETTING_REG2, &lval); 117 + 118 + if (lval & ASPM_L1_1_EN_MASK) 119 + rtsx_set_dev_flag(pcr, ASPM_L1_1_EN); 120 + 121 + if (lval & ASPM_L1_2_EN_MASK) 122 + rtsx_set_dev_flag(pcr, ASPM_L1_2_EN); 123 + 124 + if (lval & PM_L1_1_EN_MASK) 125 + rtsx_set_dev_flag(pcr, PM_L1_1_EN); 126 + 127 + if (lval & PM_L1_2_EN_MASK) 128 + rtsx_set_dev_flag(pcr, PM_L1_2_EN); 129 + 130 + if (option->ltr_en) { 131 + u16 val; 132 + 133 + pcie_capability_read_word(pcr->pci, PCI_EXP_DEVCTL2, &val); 134 + if (val & PCI_EXP_DEVCTL2_LTR_EN) { 135 + option->ltr_enabled = true; 136 + option->ltr_active = true; 137 + rtsx_set_ltr_latency(pcr, option->ltr_active_latency); 138 + } else { 139 + option->ltr_enabled = false; 140 + } 141 + } 142 + } 143 + 144 + static int rts5249_init_from_hw(struct rtsx_pcr *pcr) 145 + { 146 + struct rtsx_cr_option *option = &(pcr->option); 147 + 148 + if (rtsx_check_dev_flag(pcr, ASPM_L1_1_EN | ASPM_L1_2_EN 149 + | PM_L1_1_EN | PM_L1_2_EN)) 150 + option->force_clkreq_0 = false; 151 + else 152 + option->force_clkreq_0 = true; 153 + 154 + return 0; 155 + } 156 + 106 157 static int rts5249_extra_init_hw(struct rtsx_pcr *pcr) 107 158 { 159 + struct rtsx_cr_option *option = &(pcr->option); 160 + 161 + rts5249_init_from_cfg(pcr); 162 + rts5249_init_from_hw(pcr); 163 + 108 164 rtsx_pci_init_cmd(pcr); 109 165 110 166 /* Rest L1SUB Config */ ··· 181 125 else 182 126 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80); 183 127 184 - return rtsx_pci_send_cmd(pcr, 100); 128 + /* 129 + * If u_force_clkreq_0 is enabled, CLKREQ# PIN will be forced 130 + * to drive low, and we forcibly request clock. 131 + */ 132 + if (option->force_clkreq_0) 133 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 134 + FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_LOW); 135 + else 136 + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 137 + FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_HIGH); 138 + 139 + return rtsx_pci_send_cmd(pcr, CMD_TIMEOUT_DEF); 185 140 } 186 141 187 142 static int rts5249_optimize_phy(struct rtsx_pcr *pcr) ··· 352 285 return rtsx_pci_send_cmd(pcr, 100); 353 286 } 354 287 288 + static void rts5249_set_aspm(struct rtsx_pcr *pcr, bool enable) 289 + { 290 + struct rtsx_cr_option *option = &pcr->option; 291 + u8 val = 0; 292 + 293 + if (pcr->aspm_enabled == enable) 294 + return; 295 + 296 + if (option->dev_aspm_mode == DEV_ASPM_DYNAMIC) { 297 + if (enable) 298 + val = pcr->aspm_en; 299 + rtsx_pci_update_cfg_byte(pcr, 300 + pcr->pcie_cap + PCI_EXP_LNKCTL, 301 + ASPM_MASK_NEG, val); 302 + } else if (option->dev_aspm_mode == DEV_ASPM_BACKDOOR) { 303 + u8 mask = FORCE_ASPM_VAL_MASK | FORCE_ASPM_CTL0; 304 + 305 + if (!enable) 306 + val = FORCE_ASPM_CTL0; 307 + rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); 308 + } 309 + 310 + pcr->aspm_enabled = enable; 311 + } 312 + 355 313 static const struct pcr_ops rts5249_pcr_ops = { 356 314 .fetch_vendor_settings = rtsx_base_fetch_vendor_settings, 357 315 .extra_init_hw = rts5249_extra_init_hw, ··· 389 297 .card_power_off = rtsx_base_card_power_off, 390 298 .switch_output_voltage = rtsx_base_switch_output_voltage, 391 299 .force_power_down = rtsx_base_force_power_down, 300 + .set_aspm = rts5249_set_aspm, 392 301 }; 393 302 394 303 /* SD Pull Control Enable: ··· 446 353 447 354 void rts5249_init_params(struct rtsx_pcr *pcr) 448 355 { 356 + struct rtsx_cr_option *option = &(pcr->option); 357 + 449 358 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; 450 359 pcr->num_slots = 2; 451 360 pcr->ops = &rts5249_pcr_ops; ··· 467 372 pcr->ms_pull_ctl_disable_tbl = rts5249_ms_pull_ctl_disable_tbl; 468 373 469 374 pcr->reg_pm_ctrl3 = PM_CTRL3; 375 + 376 + option->dev_flags = (LTR_L1SS_PWR_GATE_CHECK_CARD_EN 377 + | LTR_L1SS_PWR_GATE_EN); 378 + option->ltr_en = true; 379 + 380 + /* Init latency of active, idle, L1OFF to 60us, 300us, 3ms */ 381 + option->ltr_active_latency = LTR_ACTIVE_LATENCY_DEF; 382 + option->ltr_idle_latency = LTR_IDLE_LATENCY_DEF; 383 + option->ltr_l1off_latency = LTR_L1OFF_LATENCY_DEF; 384 + option->dev_aspm_mode = DEV_ASPM_DYNAMIC; 385 + option->l1_snooze_delay = L1_SNOOZE_DELAY_DEF; 386 + option->ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5249_DEF; 387 + option->ltr_l1off_snooze_sspwrgate = 388 + LTR_L1OFF_SNOOZE_SSPWRGATE_5249_DEF; 470 389 } 471 390 472 391 static int rts524a_write_phy(struct rtsx_pcr *pcr, u8 addr, u16 val) ··· 568 459 return 0; 569 460 } 570 461 462 + static void rts5250_set_l1off_cfg_sub_d0(struct rtsx_pcr *pcr, int active) 463 + { 464 + struct rtsx_cr_option *option = &(pcr->option); 465 + 466 + u32 interrupt = rtsx_pci_readl(pcr, RTSX_BIPR); 467 + int card_exist = (interrupt & SD_EXIST) | (interrupt & MS_EXIST); 468 + int aspm_L1_1, aspm_L1_2; 469 + u8 val = 0; 470 + 471 + aspm_L1_1 = rtsx_check_dev_flag(pcr, ASPM_L1_1_EN); 472 + aspm_L1_2 = rtsx_check_dev_flag(pcr, ASPM_L1_2_EN); 473 + 474 + if (active) { 475 + /* Run, latency: 60us */ 476 + if (aspm_L1_1) 477 + val = option->ltr_l1off_snooze_sspwrgate; 478 + } else { 479 + /* L1off, latency: 300us */ 480 + if (aspm_L1_2) 481 + val = option->ltr_l1off_sspwrgate; 482 + } 483 + 484 + if (aspm_L1_1 || aspm_L1_2) { 485 + if (rtsx_check_dev_flag(pcr, 486 + LTR_L1SS_PWR_GATE_CHECK_CARD_EN)) { 487 + if (card_exist) 488 + val &= ~L1OFF_MBIAS2_EN_5250; 489 + else 490 + val |= L1OFF_MBIAS2_EN_5250; 491 + } 492 + } 493 + rtsx_set_l1off_sub(pcr, val); 494 + } 495 + 571 496 static const struct pcr_ops rts524a_pcr_ops = { 572 497 .write_phy = rts524a_write_phy, 573 498 .read_phy = rts524a_read_phy, ··· 616 473 .card_power_off = rtsx_base_card_power_off, 617 474 .switch_output_voltage = rtsx_base_switch_output_voltage, 618 475 .force_power_down = rtsx_base_force_power_down, 476 + .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, 477 + .set_aspm = rts5249_set_aspm, 619 478 }; 620 479 621 480 void rts524a_init_params(struct rtsx_pcr *pcr) 622 481 { 623 482 rts5249_init_params(pcr); 483 + pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF; 484 + pcr->option.ltr_l1off_snooze_sspwrgate = 485 + LTR_L1OFF_SNOOZE_SSPWRGATE_5250_DEF; 624 486 625 487 pcr->reg_pm_ctrl3 = RTS524A_PM_CTRL3; 626 488 pcr->ops = &rts524a_pcr_ops; ··· 724 576 .card_power_off = rtsx_base_card_power_off, 725 577 .switch_output_voltage = rts525a_switch_output_voltage, 726 578 .force_power_down = rtsx_base_force_power_down, 579 + .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0, 580 + .set_aspm = rts5249_set_aspm, 727 581 }; 728 582 729 583 void rts525a_init_params(struct rtsx_pcr *pcr) 730 584 { 731 585 rts5249_init_params(pcr); 586 + pcr->option.ltr_l1off_sspwrgate = LTR_L1OFF_SSPWRGATE_5250_DEF; 587 + pcr->option.ltr_l1off_snooze_sspwrgate = 588 + LTR_L1OFF_SNOOZE_SSPWRGATE_5250_DEF; 732 589 733 590 pcr->reg_pm_ctrl3 = RTS524A_PM_CTRL3; 734 591 pcr->ops = &rts525a_pcr_ops;
+137 -5
drivers/mfd/rtsx_pcr.c
··· 79 79 0xFC, 0); 80 80 } 81 81 82 + int rtsx_comm_set_ltr_latency(struct rtsx_pcr *pcr, u32 latency) 83 + { 84 + rtsx_pci_write_register(pcr, MSGTXDATA0, 85 + MASK_8_BIT_DEF, (u8) (latency & 0xFF)); 86 + rtsx_pci_write_register(pcr, MSGTXDATA1, 87 + MASK_8_BIT_DEF, (u8)((latency >> 8) & 0xFF)); 88 + rtsx_pci_write_register(pcr, MSGTXDATA2, 89 + MASK_8_BIT_DEF, (u8)((latency >> 16) & 0xFF)); 90 + rtsx_pci_write_register(pcr, MSGTXDATA3, 91 + MASK_8_BIT_DEF, (u8)((latency >> 24) & 0xFF)); 92 + rtsx_pci_write_register(pcr, LTR_CTL, LTR_TX_EN_MASK | 93 + LTR_LATENCY_MODE_MASK, LTR_TX_EN_1 | LTR_LATENCY_MODE_SW); 94 + 95 + return 0; 96 + } 97 + 98 + int rtsx_set_ltr_latency(struct rtsx_pcr *pcr, u32 latency) 99 + { 100 + if (pcr->ops->set_ltr_latency) 101 + return pcr->ops->set_ltr_latency(pcr, latency); 102 + else 103 + return rtsx_comm_set_ltr_latency(pcr, latency); 104 + } 105 + 106 + static void rtsx_comm_set_aspm(struct rtsx_pcr *pcr, bool enable) 107 + { 108 + struct rtsx_cr_option *option = &pcr->option; 109 + 110 + if (pcr->aspm_enabled == enable) 111 + return; 112 + 113 + if (option->dev_aspm_mode == DEV_ASPM_DYNAMIC) { 114 + if (enable) 115 + rtsx_pci_enable_aspm(pcr); 116 + else 117 + rtsx_pci_disable_aspm(pcr); 118 + } else if (option->dev_aspm_mode == DEV_ASPM_BACKDOOR) { 119 + u8 mask = FORCE_ASPM_VAL_MASK; 120 + u8 val = 0; 121 + 122 + if (enable) 123 + val = pcr->aspm_en; 124 + rtsx_pci_write_register(pcr, ASPM_FORCE_CTL, mask, val); 125 + } 126 + 127 + pcr->aspm_enabled = enable; 128 + } 129 + 130 + static void rtsx_disable_aspm(struct rtsx_pcr *pcr) 131 + { 132 + if (pcr->ops->set_aspm) 133 + pcr->ops->set_aspm(pcr, false); 134 + else 135 + rtsx_comm_set_aspm(pcr, false); 136 + } 137 + 138 + int rtsx_set_l1off_sub(struct rtsx_pcr *pcr, u8 val) 139 + { 140 + rtsx_pci_write_register(pcr, L1SUB_CONFIG3, 0xFF, val); 141 + 142 + return 0; 143 + } 144 + 145 + void rtsx_set_l1off_sub_cfg_d0(struct rtsx_pcr *pcr, int active) 146 + { 147 + if (pcr->ops->set_l1off_cfg_sub_d0) 148 + pcr->ops->set_l1off_cfg_sub_d0(pcr, active); 149 + } 150 + 151 + static void rtsx_comm_pm_full_on(struct rtsx_pcr *pcr) 152 + { 153 + struct rtsx_cr_option *option = &pcr->option; 154 + 155 + rtsx_disable_aspm(pcr); 156 + 157 + if (option->ltr_enabled) 158 + rtsx_set_ltr_latency(pcr, option->ltr_active_latency); 159 + 160 + if (rtsx_check_dev_flag(pcr, LTR_L1SS_PWR_GATE_EN)) 161 + rtsx_set_l1off_sub_cfg_d0(pcr, 1); 162 + } 163 + 164 + void rtsx_pm_full_on(struct rtsx_pcr *pcr) 165 + { 166 + if (pcr->ops->full_on) 167 + pcr->ops->full_on(pcr); 168 + else 169 + rtsx_comm_pm_full_on(pcr); 170 + } 171 + 82 172 void rtsx_pci_start_run(struct rtsx_pcr *pcr) 83 173 { 84 174 /* If pci device removed, don't queue idle work any more */ ··· 179 89 pcr->state = PDEV_STAT_RUN; 180 90 if (pcr->ops->enable_auto_blink) 181 91 pcr->ops->enable_auto_blink(pcr); 182 - 183 - if (pcr->aspm_en) 184 - rtsx_pci_disable_aspm(pcr); 92 + rtsx_pm_full_on(pcr); 185 93 } 186 94 187 95 mod_delayed_work(system_wq, &pcr->idle_work, msecs_to_jiffies(200)); ··· 1046 958 return 0; 1047 959 } 1048 960 961 + static void rtsx_enable_aspm(struct rtsx_pcr *pcr) 962 + { 963 + if (pcr->ops->set_aspm) 964 + pcr->ops->set_aspm(pcr, true); 965 + else 966 + rtsx_comm_set_aspm(pcr, true); 967 + } 968 + 969 + static void rtsx_comm_pm_power_saving(struct rtsx_pcr *pcr) 970 + { 971 + struct rtsx_cr_option *option = &pcr->option; 972 + 973 + if (option->ltr_enabled) { 974 + u32 latency = option->ltr_l1off_latency; 975 + 976 + if (rtsx_check_dev_flag(pcr, L1_SNOOZE_TEST_EN)) 977 + mdelay(option->l1_snooze_delay); 978 + 979 + rtsx_set_ltr_latency(pcr, latency); 980 + } 981 + 982 + if (rtsx_check_dev_flag(pcr, LTR_L1SS_PWR_GATE_EN)) 983 + rtsx_set_l1off_sub_cfg_d0(pcr, 0); 984 + 985 + rtsx_enable_aspm(pcr); 986 + } 987 + 988 + void rtsx_pm_power_saving(struct rtsx_pcr *pcr) 989 + { 990 + if (pcr->ops->power_saving) 991 + pcr->ops->power_saving(pcr); 992 + else 993 + rtsx_comm_pm_power_saving(pcr); 994 + } 995 + 1049 996 static void rtsx_pci_idle_work(struct work_struct *work) 1050 997 { 1051 998 struct delayed_work *dwork = to_delayed_work(work); ··· 1097 974 if (pcr->ops->turn_off_led) 1098 975 pcr->ops->turn_off_led(pcr); 1099 976 1100 - if (pcr->aspm_en) 1101 - rtsx_pci_enable_aspm(pcr); 977 + rtsx_pm_power_saving(pcr); 1102 978 1103 979 mutex_unlock(&pcr->pcr_mutex); 1104 980 } ··· 1184 1062 err = rtsx_pci_send_cmd(pcr, 100); 1185 1063 if (err < 0) 1186 1064 return err; 1065 + 1066 + switch (PCI_PID(pcr)) { 1067 + case PID_5250: 1068 + case PID_524A: 1069 + case PID_525A: 1070 + rtsx_pci_write_register(pcr, PM_CLK_FORCE_CTL, 1, 1); 1071 + break; 1072 + default: 1073 + break; 1074 + } 1187 1075 1188 1076 /* Enable clk_request_n to enable clock power management */ 1189 1077 rtsx_pci_write_config_byte(pcr, pcr->pcie_cap + PCI_EXP_LNKCTL + 1, 1);
+14
drivers/mfd/rtsx_pcr.h
··· 32 32 #define RTS524A_PME_FORCE_CTL 0xFF78 33 33 #define RTS524A_PM_CTRL3 0xFF7E 34 34 35 + #define LTR_ACTIVE_LATENCY_DEF 0x883C 36 + #define LTR_IDLE_LATENCY_DEF 0x892C 37 + #define LTR_L1OFF_LATENCY_DEF 0x9003 38 + #define L1_SNOOZE_DELAY_DEF 1 39 + #define LTR_L1OFF_SSPWRGATE_5249_DEF 0xAF 40 + #define LTR_L1OFF_SSPWRGATE_5250_DEF 0xFF 41 + #define LTR_L1OFF_SNOOZE_SSPWRGATE_5249_DEF 0xAC 42 + #define LTR_L1OFF_SNOOZE_SSPWRGATE_5250_DEF 0xF8 43 + #define CMD_TIMEOUT_DEF 100 44 + #define ASPM_MASK_NEG 0xFC 45 + #define MASK_8_BIT_DEF 0xFF 46 + 35 47 int __rtsx_pci_write_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 val); 36 48 int __rtsx_pci_read_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 *val); 37 49 ··· 97 85 98 86 /* generic operations */ 99 87 int rtsx_gops_pm_reset(struct rtsx_pcr *pcr); 88 + int rtsx_set_ltr_latency(struct rtsx_pcr *pcr, u32 latency); 89 + int rtsx_set_l1off_sub(struct rtsx_pcr *pcr, u8 val); 100 90 101 91 #endif
+259
drivers/mfd/sprd-sc27xx-spi.c
··· 1 + /* 2 + * Copyright (C) 2017 Spreadtrum Communications Inc. 3 + * 4 + * This software is licensed under the terms of the GNU General Public 5 + * License version 2, as published by the Free Software Foundation, and 6 + * may be copied, distributed, and modified under those terms. 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 + #include <linux/interrupt.h> 15 + #include <linux/kernel.h> 16 + #include <linux/module.h> 17 + #include <linux/mfd/core.h> 18 + #include <linux/of_device.h> 19 + #include <linux/regmap.h> 20 + #include <linux/spi/spi.h> 21 + 22 + #define SPRD_PMIC_INT_MASK_STATUS 0x0 23 + #define SPRD_PMIC_INT_RAW_STATUS 0x4 24 + #define SPRD_PMIC_INT_EN 0x8 25 + 26 + #define SPRD_SC2731_IRQ_BASE 0x140 27 + #define SPRD_SC2731_IRQ_NUMS 16 28 + 29 + struct sprd_pmic { 30 + struct regmap *regmap; 31 + struct device *dev; 32 + struct regmap_irq *irqs; 33 + struct regmap_irq_chip irq_chip; 34 + struct regmap_irq_chip_data *irq_data; 35 + int irq; 36 + }; 37 + 38 + struct sprd_pmic_data { 39 + u32 irq_base; 40 + u32 num_irqs; 41 + }; 42 + 43 + /* 44 + * Since different PMICs of SC27xx series can have different interrupt 45 + * base address and irq number, we should save irq number and irq base 46 + * in the device data structure. 47 + */ 48 + static const struct sprd_pmic_data sc2731_data = { 49 + .irq_base = SPRD_SC2731_IRQ_BASE, 50 + .num_irqs = SPRD_SC2731_IRQ_NUMS, 51 + }; 52 + 53 + static const struct mfd_cell sprd_pmic_devs[] = { 54 + { 55 + .name = "sc27xx-wdt", 56 + .of_compatible = "sprd,sc27xx-wdt", 57 + }, { 58 + .name = "sc27xx-rtc", 59 + .of_compatible = "sprd,sc27xx-rtc", 60 + }, { 61 + .name = "sc27xx-charger", 62 + .of_compatible = "sprd,sc27xx-charger", 63 + }, { 64 + .name = "sc27xx-chg-timer", 65 + .of_compatible = "sprd,sc27xx-chg-timer", 66 + }, { 67 + .name = "sc27xx-fast-chg", 68 + .of_compatible = "sprd,sc27xx-fast-chg", 69 + }, { 70 + .name = "sc27xx-chg-wdt", 71 + .of_compatible = "sprd,sc27xx-chg-wdt", 72 + }, { 73 + .name = "sc27xx-typec", 74 + .of_compatible = "sprd,sc27xx-typec", 75 + }, { 76 + .name = "sc27xx-flash", 77 + .of_compatible = "sprd,sc27xx-flash", 78 + }, { 79 + .name = "sc27xx-eic", 80 + .of_compatible = "sprd,sc27xx-eic", 81 + }, { 82 + .name = "sc27xx-efuse", 83 + .of_compatible = "sprd,sc27xx-efuse", 84 + }, { 85 + .name = "sc27xx-thermal", 86 + .of_compatible = "sprd,sc27xx-thermal", 87 + }, { 88 + .name = "sc27xx-adc", 89 + .of_compatible = "sprd,sc27xx-adc", 90 + }, { 91 + .name = "sc27xx-audio-codec", 92 + .of_compatible = "sprd,sc27xx-audio-codec", 93 + }, { 94 + .name = "sc27xx-regulator", 95 + .of_compatible = "sprd,sc27xx-regulator", 96 + }, { 97 + .name = "sc27xx-vibrator", 98 + .of_compatible = "sprd,sc27xx-vibrator", 99 + }, { 100 + .name = "sc27xx-keypad-led", 101 + .of_compatible = "sprd,sc27xx-keypad-led", 102 + }, { 103 + .name = "sc27xx-bltc", 104 + .of_compatible = "sprd,sc27xx-bltc", 105 + }, { 106 + .name = "sc27xx-fgu", 107 + .of_compatible = "sprd,sc27xx-fgu", 108 + }, { 109 + .name = "sc27xx-7sreset", 110 + .of_compatible = "sprd,sc27xx-7sreset", 111 + }, { 112 + .name = "sc27xx-poweroff", 113 + .of_compatible = "sprd,sc27xx-poweroff", 114 + }, 115 + }; 116 + 117 + static int sprd_pmic_spi_write(void *context, const void *data, size_t count) 118 + { 119 + struct device *dev = context; 120 + struct spi_device *spi = to_spi_device(dev); 121 + 122 + return spi_write(spi, data, count); 123 + } 124 + 125 + static int sprd_pmic_spi_read(void *context, 126 + const void *reg, size_t reg_size, 127 + void *val, size_t val_size) 128 + { 129 + struct device *dev = context; 130 + struct spi_device *spi = to_spi_device(dev); 131 + u32 rx_buf[2] = { 0 }; 132 + int ret; 133 + 134 + /* Now we only support one PMIC register to read every time. */ 135 + if (reg_size != sizeof(u32) || val_size != sizeof(u32)) 136 + return -EINVAL; 137 + 138 + /* Copy address to read from into first element of SPI buffer. */ 139 + memcpy(rx_buf, reg, sizeof(u32)); 140 + ret = spi_read(spi, rx_buf, 1); 141 + if (ret < 0) 142 + return ret; 143 + 144 + memcpy(val, rx_buf, val_size); 145 + return 0; 146 + } 147 + 148 + static struct regmap_bus sprd_pmic_regmap = { 149 + .write = sprd_pmic_spi_write, 150 + .read = sprd_pmic_spi_read, 151 + .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, 152 + .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 153 + }; 154 + 155 + static const struct regmap_config sprd_pmic_config = { 156 + .reg_bits = 32, 157 + .val_bits = 32, 158 + .reg_stride = 4, 159 + .max_register = 0xffff, 160 + }; 161 + 162 + static int sprd_pmic_probe(struct spi_device *spi) 163 + { 164 + struct sprd_pmic *ddata; 165 + const struct sprd_pmic_data *pdata; 166 + int ret, i; 167 + 168 + pdata = of_device_get_match_data(&spi->dev); 169 + if (!pdata) { 170 + dev_err(&spi->dev, "No matching driver data found\n"); 171 + return -EINVAL; 172 + } 173 + 174 + ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL); 175 + if (!ddata) 176 + return -ENOMEM; 177 + 178 + ddata->regmap = devm_regmap_init(&spi->dev, &sprd_pmic_regmap, 179 + &spi->dev, &sprd_pmic_config); 180 + if (IS_ERR(ddata->regmap)) { 181 + ret = PTR_ERR(ddata->regmap); 182 + dev_err(&spi->dev, "Failed to allocate register map %d\n", ret); 183 + return ret; 184 + } 185 + 186 + spi_set_drvdata(spi, ddata); 187 + ddata->dev = &spi->dev; 188 + ddata->irq = spi->irq; 189 + 190 + ddata->irq_chip.name = dev_name(&spi->dev); 191 + ddata->irq_chip.status_base = 192 + pdata->irq_base + SPRD_PMIC_INT_MASK_STATUS; 193 + ddata->irq_chip.mask_base = pdata->irq_base + SPRD_PMIC_INT_EN; 194 + ddata->irq_chip.ack_base = 0; 195 + ddata->irq_chip.num_regs = 1; 196 + ddata->irq_chip.num_irqs = pdata->num_irqs; 197 + ddata->irq_chip.mask_invert = true; 198 + 199 + ddata->irqs = devm_kzalloc(&spi->dev, sizeof(struct regmap_irq) * 200 + pdata->num_irqs, GFP_KERNEL); 201 + if (!ddata->irqs) 202 + return -ENOMEM; 203 + 204 + ddata->irq_chip.irqs = ddata->irqs; 205 + for (i = 0; i < pdata->num_irqs; i++) { 206 + ddata->irqs[i].reg_offset = i / pdata->num_irqs; 207 + ddata->irqs[i].mask = BIT(i % pdata->num_irqs); 208 + } 209 + 210 + ret = devm_regmap_add_irq_chip(&spi->dev, ddata->regmap, ddata->irq, 211 + IRQF_ONESHOT | IRQF_NO_SUSPEND, 0, 212 + &ddata->irq_chip, &ddata->irq_data); 213 + if (ret) { 214 + dev_err(&spi->dev, "Failed to add PMIC irq chip %d\n", ret); 215 + return ret; 216 + } 217 + 218 + ret = devm_mfd_add_devices(&spi->dev, PLATFORM_DEVID_AUTO, 219 + sprd_pmic_devs, ARRAY_SIZE(sprd_pmic_devs), 220 + NULL, 0, 221 + regmap_irq_get_domain(ddata->irq_data)); 222 + if (ret) { 223 + dev_err(&spi->dev, "Failed to register device %d\n", ret); 224 + return ret; 225 + } 226 + 227 + return 0; 228 + } 229 + 230 + static const struct of_device_id sprd_pmic_match[] = { 231 + { .compatible = "sprd,sc2731", .data = &sc2731_data }, 232 + {}, 233 + }; 234 + MODULE_DEVICE_TABLE(of, sprd_pmic_match); 235 + 236 + static struct spi_driver sprd_pmic_driver = { 237 + .driver = { 238 + .name = "sc27xx-pmic", 239 + .bus = &spi_bus_type, 240 + .of_match_table = sprd_pmic_match, 241 + }, 242 + .probe = sprd_pmic_probe, 243 + }; 244 + 245 + static int __init sprd_pmic_init(void) 246 + { 247 + return spi_register_driver(&sprd_pmic_driver); 248 + } 249 + subsys_initcall(sprd_pmic_init); 250 + 251 + static void __exit sprd_pmic_exit(void) 252 + { 253 + spi_unregister_driver(&sprd_pmic_driver); 254 + } 255 + module_exit(sprd_pmic_exit); 256 + 257 + MODULE_LICENSE("GPL v2"); 258 + MODULE_DESCRIPTION("Spreadtrum SC27xx PMICs driver"); 259 + MODULE_AUTHOR("Baolin Wang <baolin.wang@spreadtrum.com>");
+1 -1
drivers/mfd/ssbi.c
··· 314 314 315 315 spin_lock_init(&ssbi->lock); 316 316 317 - return of_platform_populate(np, NULL, NULL, &pdev->dev); 317 + return devm_of_platform_populate(&pdev->dev); 318 318 } 319 319 320 320 static const struct of_device_id ssbi_match_table[] = {
+6 -4
drivers/mfd/stw481x.c
··· 72 72 static int stw481x_startup(struct stw481x *stw481x) 73 73 { 74 74 /* Voltages multiplied by 100 */ 75 - u8 vcore_val[] = { 100, 105, 110, 115, 120, 122, 124, 126, 128, 76 - 130, 132, 134, 136, 138, 140, 145 }; 77 - u8 vpll_val[] = { 105, 120, 130, 180 }; 78 - u8 vaux_val[] = { 15, 18, 25, 28 }; 75 + static const u8 vcore_val[] = { 76 + 100, 105, 110, 115, 120, 122, 124, 126, 128, 77 + 130, 132, 134, 136, 138, 140, 145 78 + }; 79 + static const u8 vpll_val[] = { 105, 120, 130, 180 }; 80 + static const u8 vaux_val[] = { 15, 18, 25, 28 }; 79 81 u8 vcore; 80 82 u8 vcore_slp; 81 83 u8 vpll;
+5 -23
drivers/mfd/tps65217.c
··· 311 311 }; 312 312 313 313 static const struct of_device_id tps65217_of_match[] = { 314 - { .compatible = "ti,tps65217", .data = (void *)TPS65217 }, 314 + { .compatible = "ti,tps65217"}, 315 315 { /* sentinel */ }, 316 316 }; 317 317 MODULE_DEVICE_TABLE(of, tps65217_of_match); 318 318 319 - static int tps65217_probe(struct i2c_client *client, 320 - const struct i2c_device_id *ids) 319 + static int tps65217_probe(struct i2c_client *client) 321 320 { 322 321 struct tps65217 *tps; 323 322 unsigned int version; 324 - unsigned long chip_id = ids->driver_data; 325 - const struct of_device_id *match; 326 323 bool status_off = false; 327 324 int ret; 328 325 329 - if (client->dev.of_node) { 330 - match = of_match_device(tps65217_of_match, &client->dev); 331 - if (!match) { 332 - dev_err(&client->dev, 333 - "Failed to find matching dt id\n"); 334 - return -EINVAL; 335 - } 336 - chip_id = (unsigned long)match->data; 337 - status_off = of_property_read_bool(client->dev.of_node, 338 - "ti,pmic-shutdown-controller"); 339 - } 340 - 341 - if (!chip_id) { 342 - dev_err(&client->dev, "id is null.\n"); 343 - return -ENODEV; 344 - } 326 + status_off = of_property_read_bool(client->dev.of_node, 327 + "ti,pmic-shutdown-controller"); 345 328 346 329 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 347 330 if (!tps) ··· 332 349 333 350 i2c_set_clientdata(client, tps); 334 351 tps->dev = &client->dev; 335 - tps->id = chip_id; 336 352 337 353 tps->regmap = devm_regmap_init_i2c(client, &tps65217_regmap_config); 338 354 if (IS_ERR(tps->regmap)) { ··· 412 430 .of_match_table = tps65217_of_match, 413 431 }, 414 432 .id_table = tps65217_id_table, 415 - .probe = tps65217_probe, 433 + .probe_new = tps65217_probe, 416 434 .remove = tps65217_remove, 417 435 }; 418 436
-8
drivers/mfd/tps65218.c
··· 215 215 const struct i2c_device_id *ids) 216 216 { 217 217 struct tps65218 *tps; 218 - const struct of_device_id *match; 219 218 int ret; 220 219 unsigned int chipid; 221 - 222 - match = of_match_device(of_tps65218_match_table, &client->dev); 223 - if (!match) { 224 - dev_err(&client->dev, 225 - "Failed to find matching dt id\n"); 226 - return -EINVAL; 227 - } 228 220 229 221 tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); 230 222 if (!tps)
-5
drivers/regulator/tps65217-regulator.c
··· 228 228 int i, ret; 229 229 unsigned int val; 230 230 231 - if (tps65217_chip_id(tps) != TPS65217) { 232 - dev_err(&pdev->dev, "Invalid tps chip version\n"); 233 - return -ENODEV; 234 - } 235 - 236 231 /* Allocate memory for strobes */ 237 232 tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) * 238 233 TPS65217_NUM_REGULATOR, GFP_KERNEL);
+3 -11
drivers/video/backlight/tps65217_bl.c
··· 275 275 struct tps65217_bl_pdata *pdata; 276 276 struct backlight_properties bl_props; 277 277 278 - if (tps->dev->of_node) { 279 - pdata = tps65217_bl_parse_dt(pdev); 280 - if (IS_ERR(pdata)) 281 - return PTR_ERR(pdata); 282 - } else { 283 - pdata = dev_get_platdata(&pdev->dev); 284 - if (!pdata) { 285 - dev_err(&pdev->dev, "no platform data provided\n"); 286 - return -EINVAL; 287 - } 288 - } 278 + pdata = tps65217_bl_parse_dt(pdev); 279 + if (IS_ERR(pdata)) 280 + return PTR_ERR(pdata); 289 281 290 282 tps65217_bl = devm_kzalloc(&pdev->dev, sizeof(*tps65217_bl), 291 283 GFP_KERNEL);
+84
include/linux/mfd/rtsx_pci.h
··· 574 574 #define MSGTXDATA3 0xFE47 575 575 #define MSGTXCTL 0xFE48 576 576 #define LTR_CTL 0xFE4A 577 + #define LTR_TX_EN_MASK BIT(7) 578 + #define LTR_TX_EN_1 BIT(7) 579 + #define LTR_TX_EN_0 0 580 + #define LTR_LATENCY_MODE_MASK BIT(6) 581 + #define LTR_LATENCY_MODE_HW 0 582 + #define LTR_LATENCY_MODE_SW BIT(6) 577 583 #define OBFF_CFG 0xFE4C 578 584 579 585 #define CDRESUMECTL 0xFE52 ··· 623 617 #define L1SUB_CONFIG2 0xFE8E 624 618 #define L1SUB_AUTO_CFG 0x02 625 619 #define L1SUB_CONFIG3 0xFE8F 620 + #define L1OFF_MBIAS2_EN_5250 BIT(7) 626 621 627 622 #define DUMMY_REG_RESET_0 0xFE90 628 623 629 624 #define AUTOLOAD_CFG_BASE 0xFF00 630 625 #define PETXCFG 0xFF03 626 + #define FORCE_CLKREQ_DELINK_MASK BIT(7) 627 + #define FORCE_CLKREQ_LOW 0x80 628 + #define FORCE_CLKREQ_HIGH 0x00 631 629 632 630 #define PM_CTRL1 0xFF44 633 631 #define CD_RESUME_EN_MASK 0xF0 ··· 855 845 #define PHY_DIG1E_RX_EN_KEEP 0x0001 856 846 #define PHY_DUM_REG 0x1F 857 847 848 + #define PCR_ASPM_SETTING_REG1 0x160 849 + #define PCR_ASPM_SETTING_REG2 0x168 850 + 858 851 #define PCR_SETTING_REG1 0x724 859 852 #define PCR_SETTING_REG2 0x814 860 853 #define PCR_SETTING_REG3 0x747 ··· 890 877 int (*conv_clk_and_div_n)(int clk, int dir); 891 878 void (*fetch_vendor_settings)(struct rtsx_pcr *pcr); 892 879 void (*force_power_down)(struct rtsx_pcr *pcr, u8 pm_state); 880 + 881 + void (*set_aspm)(struct rtsx_pcr *pcr, bool enable); 882 + int (*set_ltr_latency)(struct rtsx_pcr *pcr, u32 latency); 883 + int (*set_l1off_sub)(struct rtsx_pcr *pcr, u8 val); 884 + void (*set_l1off_cfg_sub_d0)(struct rtsx_pcr *pcr, int active); 885 + void (*full_on)(struct rtsx_pcr *pcr); 886 + void (*power_saving)(struct rtsx_pcr *pcr); 893 887 }; 894 888 895 889 enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN}; 890 + 891 + #define ASPM_L1_1_EN_MASK BIT(3) 892 + #define ASPM_L1_2_EN_MASK BIT(2) 893 + #define PM_L1_1_EN_MASK BIT(1) 894 + #define PM_L1_2_EN_MASK BIT(0) 895 + 896 + #define ASPM_L1_1_EN BIT(0) 897 + #define ASPM_L1_2_EN BIT(1) 898 + #define PM_L1_1_EN BIT(2) 899 + #define PM_L1_2_EN BIT(3) 900 + #define LTR_L1SS_PWR_GATE_EN BIT(4) 901 + #define L1_SNOOZE_TEST_EN BIT(5) 902 + #define LTR_L1SS_PWR_GATE_CHECK_CARD_EN BIT(6) 903 + 904 + enum dev_aspm_mode { 905 + DEV_ASPM_DISABLE = 0, 906 + DEV_ASPM_DYNAMIC, 907 + DEV_ASPM_BACKDOOR, 908 + DEV_ASPM_STATIC, 909 + }; 910 + 911 + /* 912 + * struct rtsx_cr_option - card reader option 913 + * @dev_flags: device flags 914 + * @force_clkreq_0: force clock request 915 + * @ltr_en: enable ltr mode flag 916 + * @ltr_enabled: ltr mode in configure space flag 917 + * @ltr_active: ltr mode status 918 + * @ltr_active_latency: ltr mode active latency 919 + * @ltr_idle_latency: ltr mode idle latency 920 + * @ltr_l1off_latency: ltr mode l1off latency 921 + * @dev_aspm_mode: device aspm mode 922 + * @l1_snooze_delay: l1 snooze delay 923 + * @ltr_l1off_sspwrgate: ltr l1off sspwrgate 924 + * @ltr_l1off_snooze_sspwrgate: ltr l1off snooze sspwrgate 925 + */ 926 + struct rtsx_cr_option { 927 + u32 dev_flags; 928 + bool force_clkreq_0; 929 + bool ltr_en; 930 + bool ltr_enabled; 931 + bool ltr_active; 932 + u32 ltr_active_latency; 933 + u32 ltr_idle_latency; 934 + u32 ltr_l1off_latency; 935 + enum dev_aspm_mode dev_aspm_mode; 936 + u32 l1_snooze_delay; 937 + u8 ltr_l1off_sspwrgate; 938 + u8 ltr_l1off_snooze_sspwrgate; 939 + }; 940 + 941 + #define rtsx_set_dev_flag(cr, flag) \ 942 + ((cr)->option.dev_flags |= (flag)) 943 + #define rtsx_clear_dev_flag(cr, flag) \ 944 + ((cr)->option.dev_flags &= ~(flag)) 945 + #define rtsx_check_dev_flag(cr, flag) \ 946 + ((cr)->option.dev_flags & (flag)) 896 947 897 948 struct rtsx_pcr { 898 949 struct pci_dev *pci; 899 950 unsigned int id; 900 951 int pcie_cap; 952 + struct rtsx_cr_option option; 901 953 902 954 /* pci resources */ 903 955 unsigned long addr; ··· 1019 941 u8 card_drive_sel; 1020 942 #define ASPM_L1_EN 0x02 1021 943 u8 aspm_en; 944 + bool aspm_enabled; 1022 945 1023 946 #define PCR_MS_PMOS (1 << 0) 1024 947 #define PCR_REVERSE_SOCKET (1 << 1) ··· 1043 964 1044 965 u8 dma_error_count; 1045 966 }; 967 + 968 + #define PID_524A 0x524A 969 + #define PID_5249 0x5249 970 + #define PID_5250 0x5250 971 + #define PID_525A 0x525A 1046 972 1047 973 #define CHK_PCI_PID(pcr, pid) ((pcr)->pci->device == (pid)) 1048 974 #define PCI_VID(pcr) ((pcr)->pci->vendor)
-6
include/linux/mfd/tps65217.h
··· 263 263 struct tps65217 { 264 264 struct device *dev; 265 265 struct tps65217_board *pdata; 266 - unsigned long id; 267 266 struct regulator_desc desc[TPS65217_NUM_REGULATOR]; 268 267 struct regmap *regmap; 269 268 u8 *strobes; ··· 275 276 static inline struct tps65217 *dev_to_tps65217(struct device *dev) 276 277 { 277 278 return dev_get_drvdata(dev); 278 - } 279 - 280 - static inline unsigned long tps65217_chip_id(struct tps65217 *tps65217) 281 - { 282 - return tps65217->id; 283 279 } 284 280 285 281 int tps65217_reg_read(struct tps65217 *tps, unsigned int reg,