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

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

Pull MFD updates from Lee Jones:
"Core Frameworks:
- Add new !TOUCHSCREEN_SUN4I dependency for SUN4I_GPADC
- List include/dt-bindings/mfd/* to files supported in MAINTAINERS

New Drivers:
- Intel Apollo Lake SPI NOR
- ST STM32 Timers (Advanced, Basic and PWM)
- Motorola 6556002 CPCAP (PMIC)

New Device Support:
- Add support for AXP221 to axp20x
- Add support for Intel Gemini Lake to intel-lpss-pci
- Add support for MT6323 LED to mt6397-core
- Add support for COMe-bBD#, COMe-bSL6, COMe-bKL6, COMe-cAL6 and
COMe-cKL6 to kempld-core

New Functionality:
- Add support for Analog CODAC to sun6i-prcm
- Add support for Watchdog to lpc_ich

Fix-ups:
- Error handling improvements; axp288_charger, axp20x, ab8500-sysctrl
- Adapt platform data handling; axp20x
- IRQ handling improvements; arizona, axp20x
- Remove superfluous code; arizona, axp20x, lpc_ich
- Trivial coding style/spelling fixes; axp20x, abx500, mfd.txt
- Regmap fix-ups; axp20x
- DT changes; mfd.txt, aspeed-lpc, aspeed-gfx, ab8500-core, tps65912,
mt6397
- Use new I2C probing mechanism; max77686
- Constification; rk808

Bug Fixes:
- Stop data transfer whilst suspended; cros_ec"

* tag 'mfd-for-linus-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (43 commits)
mfd: lpc_ich: Enable watchdog on Intel Apollo Lake PCH
mfd: lpc_ich: Remove useless comments in core part
mfd: Add support for several boards to Kontron PLD driver
mfd: constify regmap_irq_chip structures
MAINTAINERS: Add include/dt-bindings/mfd to MFD entry
mfd: cpcap: Add minimal support
mfd: mt6397: Add MT6323 LED support into MT6397 driver
Documentation: devicetree: Add LED subnode binding for MT6323 PMIC
mfd: tps65912: Export OF device ID table as module aliases
mfd: ab8500-core: Rename clock device and compatible
mfd: cros_ec: Send correct suspend/resume event to EC
mfd: max77686: Remove I2C device ID table
mfd: max77686: Use the struct i2c_driver .probe_new instead of .probe
mfd: max77686: Use of_device_get_match_data() helper
mfd: max77686: Don't attempt to get i2c_device_id .data
mfd: ab8500-sysctrl: Handle probe deferral
mfd: intel-lpss: Add Intel Gemini Lake PCI IDs
mfd: axp20x: Fix AXP806 access errors on cold boot
mfd: cros_ec: Send suspend state notification to EC
mfd: cros_ec: Prevent data transfer while device is suspended
...

+1559 -145
+17
Documentation/devicetree/bindings/mfd/aspeed-gfx.txt
··· 1 + * Device tree bindings for Aspeed SoC Display Controller (GFX) 2 + 3 + The Aspeed SoC Display Controller primarily does as its name suggests, but also 4 + participates in pinmux requests on the g5 SoCs. It is therefore considered a 5 + syscon device. 6 + 7 + Required properties: 8 + - compatible: "aspeed,ast2500-gfx", "syscon" 9 + - reg: contains offset/length value of the GFX memory 10 + region. 11 + 12 + Example: 13 + 14 + gfx: display@1e6e6000 { 15 + compatible = "aspeed,ast2500-gfx", "syscon"; 16 + reg = <0x1e6e6000 0x1000>; 17 + };
+137
Documentation/devicetree/bindings/mfd/aspeed-lpc.txt
··· 1 + ====================================================================== 2 + Device tree bindings for the Aspeed Low Pin Count (LPC) Bus Controller 3 + ====================================================================== 4 + 5 + The LPC bus is a means to bridge a host CPU to a number of low-bandwidth 6 + peripheral devices, replacing the use of the ISA bus in the age of PCI[0]. The 7 + primary use case of the Aspeed LPC controller is as a slave on the bus 8 + (typically in a Baseboard Management Controller SoC), but under certain 9 + conditions it can also take the role of bus master. 10 + 11 + The LPC controller is represented as a multi-function device to account for the 12 + mix of functionality it provides. The principle split is between the register 13 + layout at the start of the I/O space which is, to quote the Aspeed datasheet, 14 + "basically compatible with the [LPC registers from the] popular BMC controller 15 + H8S/2168[1]", and everything else, where everything else is an eclectic 16 + collection of functions with a esoteric register layout. "Everything else", 17 + here labeled the "host" portion of the controller, includes, but is not limited 18 + to: 19 + 20 + * An IPMI Block Transfer[2] Controller 21 + 22 + * An LPC Host Controller: Manages LPC functions such as host vs slave mode, the 23 + physical properties of some LPC pins, configuration of serial IRQs, and 24 + APB-to-LPC bridging amonst other functions. 25 + 26 + * An LPC Host Interface Controller: Manages functions exposed to the host such 27 + as LPC firmware hub cycles, configuration of the LPC-to-AHB mapping, UART 28 + management and bus snoop configuration. 29 + 30 + * A set of SuperIO[3] scratch registers: Enables implementation of e.g. custom 31 + hardware management protocols for handover between the host and baseboard 32 + management controller. 33 + 34 + Additionally the state of the LPC controller influences the pinmux 35 + configuration, therefore the host portion of the controller is exposed as a 36 + syscon as a means to arbitrate access. 37 + 38 + [0] http://www.intel.com/design/chipsets/industry/25128901.pdf 39 + [1] https://www.renesas.com/en-sg/doc/products/mpumcu/001/rej09b0078_h8s2168.pdf?key=7c88837454702128622bee53acbda8f4 40 + [2] http://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/ipmi-second-gen-interface-spec-v2-rev1-1.pdf 41 + [3] https://en.wikipedia.org/wiki/Super_I/O 42 + 43 + Required properties 44 + =================== 45 + 46 + - compatible: One of: 47 + "aspeed,ast2400-lpc", "simple-mfd" 48 + "aspeed,ast2500-lpc", "simple-mfd" 49 + 50 + - reg: contains the physical address and length values of the Aspeed 51 + LPC memory region. 52 + 53 + - #address-cells: <1> 54 + - #size-cells: <1> 55 + - ranges: Maps 0 to the physical address and length of the LPC memory 56 + region 57 + 58 + Required LPC Child nodes 59 + ======================== 60 + 61 + BMC Node 62 + -------- 63 + 64 + - compatible: One of: 65 + "aspeed,ast2400-lpc-bmc" 66 + "aspeed,ast2500-lpc-bmc" 67 + 68 + - reg: contains the physical address and length values of the 69 + H8S/2168-compatible LPC controller memory region 70 + 71 + Host Node 72 + --------- 73 + 74 + - compatible: One of: 75 + "aspeed,ast2400-lpc-host", "simple-mfd", "syscon" 76 + "aspeed,ast2500-lpc-host", "simple-mfd", "syscon" 77 + 78 + - reg: contains the address and length values of the host-related 79 + register space for the Aspeed LPC controller 80 + 81 + - #address-cells: <1> 82 + - #size-cells: <1> 83 + - ranges: Maps 0 to the address and length of the host-related LPC memory 84 + region 85 + 86 + Example: 87 + 88 + lpc: lpc@1e789000 { 89 + compatible = "aspeed,ast2500-lpc", "simple-mfd"; 90 + reg = <0x1e789000 0x1000>; 91 + 92 + #address-cells = <1>; 93 + #size-cells = <1>; 94 + ranges = <0x0 0x1e789000 0x1000>; 95 + 96 + lpc_bmc: lpc-bmc@0 { 97 + compatible = "aspeed,ast2500-lpc-bmc"; 98 + reg = <0x0 0x80>; 99 + }; 100 + 101 + lpc_host: lpc-host@80 { 102 + compatible = "aspeed,ast2500-lpc-host", "simple-mfd", "syscon"; 103 + reg = <0x80 0x1e0>; 104 + reg-io-width = <4>; 105 + 106 + #address-cells = <1>; 107 + #size-cells = <1>; 108 + ranges = <0x0 0x80 0x1e0>; 109 + }; 110 + }; 111 + 112 + Host Node Children 113 + ================== 114 + 115 + LPC Host Controller 116 + ------------------- 117 + 118 + The Aspeed LPC Host Controller configures the Low Pin Count (LPC) bus behaviour 119 + between the host and the baseboard management controller. The registers exist 120 + in the "host" portion of the Aspeed LPC controller, which must be the parent of 121 + the LPC host controller node. 122 + 123 + Required properties: 124 + 125 + - compatible: One of: 126 + "aspeed,ast2400-lhc"; 127 + "aspeed,ast2500-lhc"; 128 + 129 + - reg: contains offset/length values of the LHC memory regions. In the 130 + AST2400 and AST2500 there are two regions. 131 + 132 + Example: 133 + 134 + lhc: lhc@20 { 135 + compatible = "aspeed,ast2500-lhc"; 136 + reg = <0x20 0x24 0x48 0x8>; 137 + };
+11 -1
Documentation/devicetree/bindings/mfd/mfd.txt
··· 19 19 20 20 - compatible : "simple-mfd" - this signifies that the operating system should 21 21 consider all subnodes of the MFD device as separate devices akin to how 22 - "simple-bus" inidicates when to see subnodes as children for a simple 22 + "simple-bus" indicates when to see subnodes as children for a simple 23 23 memory-mapped bus. For more complex devices, when the nexus driver has to 24 24 probe registers to figure out what child devices exist etc, this should not 25 25 be used. In the latter case the child devices will be determined by the 26 26 operating system. 27 + 28 + - ranges: Describes the address mapping relationship to the parent. Should set 29 + the child's base address to 0, the physical address within parent's address 30 + space, and the length of the address map. 31 + 32 + - #address-cells: Specifies the number of cells used to represent physical base 33 + addresses. Must be present if ranges is used. 34 + 35 + - #size-cells: Specifies the number of cells used to represent the size of an 36 + address. Must be present if ranges is used. 27 37 28 38 Example: 29 39
+31
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
··· 1 + Motorola CPCAP PMIC device tree binding 2 + 3 + Required properties: 4 + - compatible : One or both of "motorola,cpcap" or "ste,6556002" 5 + - reg : SPI chip select 6 + - interrupt-parent : The parent interrupt controller 7 + - interrupts : The interrupt line the device is connected to 8 + - interrupt-controller : Marks the device node as an interrupt controller 9 + - #interrupt-cells : The number of cells to describe an IRQ, should be 2 10 + - #address-cells : Child device offset number of cells, should be 1 11 + - #size-cells : Child device size number of cells, should be 0 12 + - spi-max-frequency : Typically set to 3000000 13 + - spi-cs-high : SPI chip select direction 14 + 15 + Example: 16 + 17 + &mcspi1 { 18 + cpcap: pmic@0 { 19 + compatible = "motorola,cpcap", "ste,6556002"; 20 + reg = <0>; /* cs0 */ 21 + interrupt-parent = <&gpio1>; 22 + interrupts = <7 IRQ_TYPE_EDGE_RISING>; 23 + interrupt-controller; 24 + #interrupt-cells = <2>; 25 + #address-cells = <1>; 26 + #size-cells = <0>; 27 + spi-max-frequency = <3000000>; 28 + spi-cs-high; 29 + }; 30 + }; 31 +
+4
Documentation/devicetree/bindings/mfd/mt6397.txt
··· 34 34 - clk 35 35 Required properties: 36 36 - compatible: "mediatek,mt6397-clk" 37 + - led 38 + Required properties: 39 + - compatible: "mediatek,mt6323-led" 40 + see Documentation/devicetree/bindings/leds/leds-mt6323.txt 37 41 38 42 Example: 39 43 pwrap: pwrap@1000f000 {
+1
MAINTAINERS
··· 8476 8476 F: Documentation/devicetree/bindings/mfd/ 8477 8477 F: drivers/mfd/ 8478 8478 F: include/linux/mfd/ 8479 + F: include/dt-bindings/mfd/ 8479 8480 8480 8481 MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM 8481 8482 M: Ulf Hansson <ulf.hansson@linaro.org>
+408 -46
drivers/input/keyboard/cros_ec_keyb.c
··· 34 34 #include <linux/mfd/cros_ec.h> 35 35 #include <linux/mfd/cros_ec_commands.h> 36 36 37 + #include <asm/unaligned.h> 38 + 37 39 /* 38 40 * @rows: Number of rows in the keypad 39 41 * @cols: Number of columns in the keypad ··· 45 43 * @valid_keys: bitmap of existing keys for each matrix column 46 44 * @old_kb_state: bitmap of keys pressed last scan 47 45 * @dev: Device pointer 48 - * @idev: Input device 49 46 * @ec: Top level ChromeOS device to use to talk to EC 47 + * @idev: The input device for the matrix keys. 48 + * @bs_idev: The input device for non-matrix buttons and switches (or NULL). 50 49 * @notifier: interrupt event notifier for transport devices 51 50 */ 52 51 struct cros_ec_keyb { ··· 60 57 uint8_t *old_kb_state; 61 58 62 59 struct device *dev; 63 - struct input_dev *idev; 64 60 struct cros_ec_device *ec; 61 + 62 + struct input_dev *idev; 63 + struct input_dev *bs_idev; 65 64 struct notifier_block notifier; 66 65 }; 67 66 67 + 68 + /** 69 + * cros_ec_bs_map - Struct mapping Linux keycodes to EC button/switch bitmap 70 + * #defines 71 + * 72 + * @ev_type: The type of the input event to generate (e.g., EV_KEY). 73 + * @code: A linux keycode 74 + * @bit: A #define like EC_MKBP_POWER_BUTTON or EC_MKBP_LID_OPEN 75 + * @inverted: If the #define and EV_SW have opposite meanings, this is true. 76 + * Only applicable to switches. 77 + */ 78 + struct cros_ec_bs_map { 79 + unsigned int ev_type; 80 + unsigned int code; 81 + u8 bit; 82 + bool inverted; 83 + }; 84 + 85 + /* cros_ec_keyb_bs - Map EC button/switch #defines into kernel ones */ 86 + static const struct cros_ec_bs_map cros_ec_keyb_bs[] = { 87 + /* Buttons */ 88 + { 89 + .ev_type = EV_KEY, 90 + .code = KEY_POWER, 91 + .bit = EC_MKBP_POWER_BUTTON, 92 + }, 93 + { 94 + .ev_type = EV_KEY, 95 + .code = KEY_VOLUMEUP, 96 + .bit = EC_MKBP_VOL_UP, 97 + }, 98 + { 99 + .ev_type = EV_KEY, 100 + .code = KEY_VOLUMEDOWN, 101 + .bit = EC_MKBP_VOL_DOWN, 102 + }, 103 + 104 + /* Switches */ 105 + { 106 + .ev_type = EV_SW, 107 + .code = SW_LID, 108 + .bit = EC_MKBP_LID_OPEN, 109 + .inverted = true, 110 + }, 111 + { 112 + .ev_type = EV_SW, 113 + .code = SW_TABLET_MODE, 114 + .bit = EC_MKBP_TABLET_MODE, 115 + }, 116 + }; 68 117 69 118 /* 70 119 * Returns true when there is at least one combination of pressed keys that ··· 204 149 input_sync(ckdev->idev); 205 150 } 206 151 207 - static int cros_ec_keyb_open(struct input_dev *dev) 152 + /** 153 + * cros_ec_keyb_report_bs - Report non-matrixed buttons or switches 154 + * 155 + * This takes a bitmap of buttons or switches from the EC and reports events, 156 + * syncing at the end. 157 + * 158 + * @ckdev: The keyboard device. 159 + * @ev_type: The input event type (e.g., EV_KEY). 160 + * @mask: A bitmap of buttons from the EC. 161 + */ 162 + static void cros_ec_keyb_report_bs(struct cros_ec_keyb *ckdev, 163 + unsigned int ev_type, u32 mask) 164 + 208 165 { 209 - struct cros_ec_keyb *ckdev = input_get_drvdata(dev); 166 + struct input_dev *idev = ckdev->bs_idev; 167 + int i; 210 168 211 - return blocking_notifier_chain_register(&ckdev->ec->event_notifier, 212 - &ckdev->notifier); 213 - } 169 + for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) { 170 + const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i]; 214 171 215 - static void cros_ec_keyb_close(struct input_dev *dev) 216 - { 217 - struct cros_ec_keyb *ckdev = input_get_drvdata(dev); 172 + if (map->ev_type != ev_type) 173 + continue; 218 174 219 - blocking_notifier_chain_unregister(&ckdev->ec->event_notifier, 220 - &ckdev->notifier); 175 + input_event(idev, ev_type, map->code, 176 + !!(mask & BIT(map->bit)) ^ map->inverted); 177 + } 178 + input_sync(idev); 221 179 } 222 180 223 181 static int cros_ec_keyb_work(struct notifier_block *nb, ··· 238 170 { 239 171 struct cros_ec_keyb *ckdev = container_of(nb, struct cros_ec_keyb, 240 172 notifier); 173 + u32 val; 174 + unsigned int ev_type; 241 175 242 - if (ckdev->ec->event_data.event_type != EC_MKBP_EVENT_KEY_MATRIX) 176 + switch (ckdev->ec->event_data.event_type) { 177 + case EC_MKBP_EVENT_KEY_MATRIX: 178 + /* 179 + * If EC is not the wake source, discard key state changes 180 + * during suspend. 181 + */ 182 + if (queued_during_suspend) 183 + return NOTIFY_OK; 184 + 185 + if (ckdev->ec->event_size != ckdev->cols) { 186 + dev_err(ckdev->dev, 187 + "Discarded incomplete key matrix event.\n"); 188 + return NOTIFY_OK; 189 + } 190 + cros_ec_keyb_process(ckdev, 191 + ckdev->ec->event_data.data.key_matrix, 192 + ckdev->ec->event_size); 193 + break; 194 + 195 + case EC_MKBP_EVENT_BUTTON: 196 + case EC_MKBP_EVENT_SWITCH: 197 + /* 198 + * If EC is not the wake source, discard key state 199 + * changes during suspend. Switches will be re-checked in 200 + * cros_ec_keyb_resume() to be sure nothing is lost. 201 + */ 202 + if (queued_during_suspend) 203 + return NOTIFY_OK; 204 + 205 + if (ckdev->ec->event_data.event_type == EC_MKBP_EVENT_BUTTON) { 206 + val = get_unaligned_le32( 207 + &ckdev->ec->event_data.data.buttons); 208 + ev_type = EV_KEY; 209 + } else { 210 + val = get_unaligned_le32( 211 + &ckdev->ec->event_data.data.switches); 212 + ev_type = EV_SW; 213 + } 214 + cros_ec_keyb_report_bs(ckdev, ev_type, val); 215 + break; 216 + 217 + default: 243 218 return NOTIFY_DONE; 244 - /* 245 - * If EC is not the wake source, discard key state changes during 246 - * suspend. 247 - */ 248 - if (queued_during_suspend) 249 - return NOTIFY_OK; 250 - if (ckdev->ec->event_size != ckdev->cols) { 251 - dev_err(ckdev->dev, 252 - "Discarded incomplete key matrix event.\n"); 253 - return NOTIFY_OK; 254 219 } 255 - cros_ec_keyb_process(ckdev, ckdev->ec->event_data.data.key_matrix, 256 - ckdev->ec->event_size); 220 + 257 221 return NOTIFY_OK; 258 222 } 259 223 ··· 313 213 } 314 214 } 315 215 316 - static int cros_ec_keyb_probe(struct platform_device *pdev) 216 + /** 217 + * cros_ec_keyb_info - Wrap the EC command EC_CMD_MKBP_INFO 218 + * 219 + * This wraps the EC_CMD_MKBP_INFO, abstracting out all of the marshalling and 220 + * unmarshalling and different version nonsense into something simple. 221 + * 222 + * @ec_dev: The EC device 223 + * @info_type: Either EC_MKBP_INFO_SUPPORTED or EC_MKBP_INFO_CURRENT. 224 + * @event_type: Either EC_MKBP_EVENT_BUTTON or EC_MKBP_EVENT_SWITCH. Actually 225 + * in some cases this could be EC_MKBP_EVENT_KEY_MATRIX or 226 + * EC_MKBP_EVENT_HOST_EVENT too but we don't use in this driver. 227 + * @result: Where we'll store the result; a union 228 + * @result_size: The size of the result. Expected to be the size of one of 229 + * the elements in the union. 230 + * 231 + * Returns 0 if no error or -error upon error. 232 + */ 233 + static int cros_ec_keyb_info(struct cros_ec_device *ec_dev, 234 + enum ec_mkbp_info_type info_type, 235 + enum ec_mkbp_event event_type, 236 + union ec_response_get_next_data *result, 237 + size_t result_size) 317 238 { 318 - struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); 319 - struct device *dev = &pdev->dev; 320 - struct cros_ec_keyb *ckdev; 239 + struct ec_params_mkbp_info *params; 240 + struct cros_ec_command *msg; 241 + int ret; 242 + 243 + msg = kzalloc(sizeof(*msg) + max_t(size_t, result_size, 244 + sizeof(*params)), GFP_KERNEL); 245 + if (!msg) 246 + return -ENOMEM; 247 + 248 + msg->command = EC_CMD_MKBP_INFO; 249 + msg->version = 1; 250 + msg->outsize = sizeof(*params); 251 + msg->insize = result_size; 252 + params = (struct ec_params_mkbp_info *)msg->data; 253 + params->info_type = info_type; 254 + params->event_type = event_type; 255 + 256 + ret = cros_ec_cmd_xfer(ec_dev, msg); 257 + if (ret < 0) { 258 + dev_warn(ec_dev->dev, "Transfer error %d/%d: %d\n", 259 + (int)info_type, (int)event_type, ret); 260 + } else if (msg->result == EC_RES_INVALID_VERSION) { 261 + /* With older ECs we just return 0 for everything */ 262 + memset(result, 0, result_size); 263 + ret = 0; 264 + } else if (msg->result != EC_RES_SUCCESS) { 265 + dev_warn(ec_dev->dev, "Error getting info %d/%d: %d\n", 266 + (int)info_type, (int)event_type, msg->result); 267 + ret = -EPROTO; 268 + } else if (ret != result_size) { 269 + dev_warn(ec_dev->dev, "Wrong size %d/%d: %d != %zu\n", 270 + (int)info_type, (int)event_type, 271 + ret, result_size); 272 + ret = -EPROTO; 273 + } else { 274 + memcpy(result, msg->data, result_size); 275 + ret = 0; 276 + } 277 + 278 + kfree(msg); 279 + 280 + return ret; 281 + } 282 + 283 + /** 284 + * cros_ec_keyb_query_switches - Query the state of switches and report 285 + * 286 + * This will ask the EC about the current state of switches and report to the 287 + * kernel. Note that we don't query for buttons because they are more 288 + * transitory and we'll get an update on the next release / press. 289 + * 290 + * @ckdev: The keyboard device 291 + * 292 + * Returns 0 if no error or -error upon error. 293 + */ 294 + static int cros_ec_keyb_query_switches(struct cros_ec_keyb *ckdev) 295 + { 296 + struct cros_ec_device *ec_dev = ckdev->ec; 297 + union ec_response_get_next_data event_data = {}; 298 + int ret; 299 + 300 + ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_CURRENT, 301 + EC_MKBP_EVENT_SWITCH, &event_data, 302 + sizeof(event_data.switches)); 303 + if (ret) 304 + return ret; 305 + 306 + cros_ec_keyb_report_bs(ckdev, EV_SW, 307 + get_unaligned_le32(&event_data.switches)); 308 + 309 + return 0; 310 + } 311 + 312 + /** 313 + * cros_ec_keyb_resume - Resume the keyboard 314 + * 315 + * We use the resume notification as a chance to query the EC for switches. 316 + * 317 + * @dev: The keyboard device 318 + * 319 + * Returns 0 if no error or -error upon error. 320 + */ 321 + static __maybe_unused int cros_ec_keyb_resume(struct device *dev) 322 + { 323 + struct cros_ec_keyb *ckdev = dev_get_drvdata(dev); 324 + 325 + if (ckdev->bs_idev) 326 + return cros_ec_keyb_query_switches(ckdev); 327 + 328 + return 0; 329 + } 330 + 331 + /** 332 + * cros_ec_keyb_register_bs - Register non-matrix buttons/switches 333 + * 334 + * Handles all the bits of the keyboard driver related to non-matrix buttons 335 + * and switches, including asking the EC about which are present and telling 336 + * the kernel to expect them. 337 + * 338 + * If this device has no support for buttons and switches we'll return no error 339 + * but the ckdev->bs_idev will remain NULL when this function exits. 340 + * 341 + * @ckdev: The keyboard device 342 + * 343 + * Returns 0 if no error or -error upon error. 344 + */ 345 + static int cros_ec_keyb_register_bs(struct cros_ec_keyb *ckdev) 346 + { 347 + struct cros_ec_device *ec_dev = ckdev->ec; 348 + struct device *dev = ckdev->dev; 321 349 struct input_dev *idev; 322 - struct device_node *np; 350 + union ec_response_get_next_data event_data = {}; 351 + const char *phys; 352 + u32 buttons; 353 + u32 switches; 354 + int ret; 355 + int i; 356 + 357 + ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_SUPPORTED, 358 + EC_MKBP_EVENT_BUTTON, &event_data, 359 + sizeof(event_data.buttons)); 360 + if (ret) 361 + return ret; 362 + buttons = get_unaligned_le32(&event_data.buttons); 363 + 364 + ret = cros_ec_keyb_info(ec_dev, EC_MKBP_INFO_SUPPORTED, 365 + EC_MKBP_EVENT_SWITCH, &event_data, 366 + sizeof(event_data.switches)); 367 + if (ret) 368 + return ret; 369 + switches = get_unaligned_le32(&event_data.switches); 370 + 371 + if (!buttons && !switches) 372 + return 0; 373 + 374 + /* 375 + * We call the non-matrix buttons/switches 'input1', if present. 376 + * Allocate phys before input dev, to ensure correct tear-down 377 + * ordering. 378 + */ 379 + phys = devm_kasprintf(dev, GFP_KERNEL, "%s/input1", ec_dev->phys_name); 380 + if (!phys) 381 + return -ENOMEM; 382 + 383 + idev = devm_input_allocate_device(dev); 384 + if (!idev) 385 + return -ENOMEM; 386 + 387 + idev->name = "cros_ec_buttons"; 388 + idev->phys = phys; 389 + __set_bit(EV_REP, idev->evbit); 390 + 391 + idev->id.bustype = BUS_VIRTUAL; 392 + idev->id.version = 1; 393 + idev->id.product = 0; 394 + idev->dev.parent = dev; 395 + 396 + input_set_drvdata(idev, ckdev); 397 + ckdev->bs_idev = idev; 398 + 399 + for (i = 0; i < ARRAY_SIZE(cros_ec_keyb_bs); i++) { 400 + const struct cros_ec_bs_map *map = &cros_ec_keyb_bs[i]; 401 + 402 + if (buttons & BIT(map->bit)) 403 + input_set_capability(idev, map->ev_type, map->code); 404 + } 405 + 406 + ret = cros_ec_keyb_query_switches(ckdev); 407 + if (ret) { 408 + dev_err(dev, "cannot query switches\n"); 409 + return ret; 410 + } 411 + 412 + ret = input_register_device(ckdev->bs_idev); 413 + if (ret) { 414 + dev_err(dev, "cannot register input device\n"); 415 + return ret; 416 + } 417 + 418 + return 0; 419 + } 420 + 421 + /** 422 + * cros_ec_keyb_register_bs - Register matrix keys 423 + * 424 + * Handles all the bits of the keyboard driver related to matrix keys. 425 + * 426 + * @ckdev: The keyboard device 427 + * 428 + * Returns 0 if no error or -error upon error. 429 + */ 430 + static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev) 431 + { 432 + struct cros_ec_device *ec_dev = ckdev->ec; 433 + struct device *dev = ckdev->dev; 434 + struct input_dev *idev; 435 + const char *phys; 323 436 int err; 324 437 325 - np = pdev->dev.of_node; 326 - if (!np) 327 - return -ENODEV; 328 - 329 - ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL); 330 - if (!ckdev) 331 - return -ENOMEM; 332 438 err = matrix_keypad_parse_of_params(dev, &ckdev->rows, &ckdev->cols); 333 439 if (err) 334 440 return err; ··· 547 241 if (!ckdev->old_kb_state) 548 242 return -ENOMEM; 549 243 244 + /* 245 + * We call the keyboard matrix 'input0'. Allocate phys before input 246 + * dev, to ensure correct tear-down ordering. 247 + */ 248 + phys = devm_kasprintf(dev, GFP_KERNEL, "%s/input0", ec_dev->phys_name); 249 + if (!phys) 250 + return -ENOMEM; 251 + 550 252 idev = devm_input_allocate_device(dev); 551 253 if (!idev) 552 254 return -ENOMEM; 553 255 554 - ckdev->ec = ec; 555 - ckdev->notifier.notifier_call = cros_ec_keyb_work; 556 - ckdev->dev = dev; 557 - dev_set_drvdata(dev, ckdev); 558 - 559 256 idev->name = CROS_EC_DEV_NAME; 560 - idev->phys = ec->phys_name; 257 + idev->phys = phys; 561 258 __set_bit(EV_REP, idev->evbit); 562 259 563 260 idev->id.bustype = BUS_VIRTUAL; 564 261 idev->id.version = 1; 565 262 idev->id.product = 0; 566 263 idev->dev.parent = dev; 567 - idev->open = cros_ec_keyb_open; 568 - idev->close = cros_ec_keyb_close; 569 264 570 - ckdev->ghost_filter = of_property_read_bool(np, 265 + ckdev->ghost_filter = of_property_read_bool(dev->of_node, 571 266 "google,needs-ghost-filter"); 572 267 573 268 err = matrix_keypad_build_keymap(NULL, NULL, ckdev->rows, ckdev->cols, ··· 594 287 return 0; 595 288 } 596 289 290 + static int cros_ec_keyb_probe(struct platform_device *pdev) 291 + { 292 + struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); 293 + struct device *dev = &pdev->dev; 294 + struct cros_ec_keyb *ckdev; 295 + int err; 296 + 297 + if (!dev->of_node) 298 + return -ENODEV; 299 + 300 + ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL); 301 + if (!ckdev) 302 + return -ENOMEM; 303 + 304 + ckdev->ec = ec; 305 + ckdev->dev = dev; 306 + dev_set_drvdata(dev, ckdev); 307 + 308 + err = cros_ec_keyb_register_matrix(ckdev); 309 + if (err) { 310 + dev_err(dev, "cannot register matrix inputs: %d\n", err); 311 + return err; 312 + } 313 + 314 + err = cros_ec_keyb_register_bs(ckdev); 315 + if (err) { 316 + dev_err(dev, "cannot register non-matrix inputs: %d\n", err); 317 + return err; 318 + } 319 + 320 + ckdev->notifier.notifier_call = cros_ec_keyb_work; 321 + err = blocking_notifier_chain_register(&ckdev->ec->event_notifier, 322 + &ckdev->notifier); 323 + if (err) { 324 + dev_err(dev, "cannot register notifier: %d\n", err); 325 + return err; 326 + } 327 + 328 + return 0; 329 + } 330 + 331 + static int cros_ec_keyb_remove(struct platform_device *pdev) 332 + { 333 + struct cros_ec_keyb *ckdev = dev_get_drvdata(&pdev->dev); 334 + 335 + blocking_notifier_chain_unregister(&ckdev->ec->event_notifier, 336 + &ckdev->notifier); 337 + 338 + return 0; 339 + } 340 + 597 341 #ifdef CONFIG_OF 598 342 static const struct of_device_id cros_ec_keyb_of_match[] = { 599 343 { .compatible = "google,cros-ec-keyb" }, ··· 653 295 MODULE_DEVICE_TABLE(of, cros_ec_keyb_of_match); 654 296 #endif 655 297 298 + static const SIMPLE_DEV_PM_OPS(cros_ec_keyb_pm_ops, NULL, cros_ec_keyb_resume); 299 + 656 300 static struct platform_driver cros_ec_keyb_driver = { 657 301 .probe = cros_ec_keyb_probe, 302 + .remove = cros_ec_keyb_remove, 658 303 .driver = { 659 304 .name = "cros-ec-keyb", 660 305 .of_match_table = of_match_ptr(cros_ec_keyb_of_match), 306 + .pm = &cros_ec_keyb_pm_ops, 661 307 }, 662 308 }; 663 309
+17
drivers/mfd/Kconfig
··· 46 46 select REGMAP_MMIO 47 47 select REGMAP_IRQ 48 48 depends on ARCH_SUNXI || COMPILE_TEST 49 + depends on !TOUCHSCREEN_SUN4I 49 50 help 50 51 Select this to get support for Allwinner SoCs (A10, A13 and A31) ADC. 51 52 This driver will only map the hardware interrupt and registers, you ··· 507 506 device may provide functions like watchdog, GPIO, UART and I2C bus. 508 507 509 508 The following modules are supported: 509 + * COMe-bBD# 510 510 * COMe-bBL6 511 511 * COMe-bHL6 512 + * COMe-bSL6 512 513 * COMe-bIP# 514 + * COMe-bKL6 513 515 * COMe-bPC2 (ETXexpress-PC) 514 516 * COMe-bSC# (ETXexpress-SC T#) 517 + * COMe-cAL6 515 518 * COMe-cBL6 516 519 * COMe-cBT6 517 520 * COMe-cBW6 518 521 * COMe-cCT6 519 522 * COMe-cDC2 (microETXexpress-DC) 520 523 * COMe-cHL6 524 + * COMe-cKL6 521 525 * COMe-cPC2 (microETXexpress-PC) 522 526 * COMe-cSL6 523 527 * COMe-mAL10 ··· 719 713 help 720 714 This enables the PCAP ASIC present on EZX Phones. This is 721 715 needed for MMC, TouchScreen, Sound, USB, etc.. 716 + 717 + config MFD_CPCAP 718 + tristate "Support for Motorola CPCAP" 719 + depends on SPI 720 + depends on OF || COMPILE_TEST 721 + select REGMAP_SPI 722 + select REGMAP_IRQ 723 + help 724 + Say yes here if you want to include driver for CPCAP. 725 + It is used on many Motorola phones and tablets as a PMIC. 726 + At least Motorola Droid 4 is known to use CPCAP. 722 727 723 728 config MFD_VIPERBOARD 724 729 tristate "Nano River Technologies Viperboard"
+1
drivers/mfd/Makefile
··· 97 97 obj-$(CONFIG_MFD_CORE) += mfd-core.o 98 98 99 99 obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o 100 + obj-$(CONFIG_MFD_CPCAP) += motorola-cpcap.o 100 101 101 102 obj-$(CONFIG_MCP) += mcp-core.o 102 103 obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o
+2 -2
drivers/mfd/ab8500-core.c
··· 656 656 .of_compatible = "stericsson,ab8500-regulator", 657 657 }, 658 658 { 659 - .name = "abx500-clk", 660 - .of_compatible = "stericsson,abx500-clk", 659 + .name = "ab8500-clk", 660 + .of_compatible = "stericsson,ab8500-clk", 661 661 }, 662 662 { 663 663 .name = "ab8500-gpadc",
+11 -3
drivers/mfd/ab8500-sysctrl.c
··· 101 101 u8 bank; 102 102 103 103 if (sysctrl_dev == NULL) 104 - return -EINVAL; 104 + return -EPROBE_DEFER; 105 105 106 106 bank = (reg >> 8); 107 107 if (!valid_bank(bank)) ··· 117 117 u8 bank; 118 118 119 119 if (sysctrl_dev == NULL) 120 - return -EINVAL; 120 + return -EPROBE_DEFER; 121 121 122 122 bank = (reg >> 8); 123 - if (!valid_bank(bank)) 123 + if (!valid_bank(bank)) { 124 + pr_err("invalid bank\n"); 124 125 return -EINVAL; 126 + } 125 127 126 128 return abx500_mask_and_set_register_interruptible(sysctrl_dev, bank, 127 129 (u8)(reg & 0xFF), mask, value); ··· 150 148 return 0; 151 149 } 152 150 151 + static const struct of_device_id ab8500_sysctrl_match[] = { 152 + { .compatible = "stericsson,ab8500-sysctrl", }, 153 + {} 154 + }; 155 + 153 156 static struct platform_driver ab8500_sysctrl_driver = { 154 157 .driver = { 155 158 .name = "ab8500-sysctrl", 159 + .of_match_table = ab8500_sysctrl_match, 156 160 }, 157 161 .probe = ab8500_sysctrl_probe, 158 162 .remove = ab8500_sysctrl_remove,
+58 -28
drivers/mfd/arizona-irq.c
··· 26 26 27 27 #include "arizona.h" 28 28 29 + #define ARIZONA_AOD_IRQ_INDEX 0 30 + #define ARIZONA_MAIN_IRQ_INDEX 1 31 + 29 32 static int arizona_map_irq(struct arizona *arizona, int irq) 30 33 { 31 34 int ret; ··· 207 204 int arizona_irq_init(struct arizona *arizona) 208 205 { 209 206 int flags = IRQF_ONESHOT; 210 - int ret, i; 207 + int ret; 211 208 const struct regmap_irq_chip *aod, *irq; 212 209 struct irq_data *irq_data; 210 + unsigned int virq; 213 211 214 212 arizona->ctrlif_error = true; 215 213 ··· 322 318 } 323 319 324 320 if (aod) { 325 - ret = regmap_add_irq_chip(arizona->regmap, 326 - irq_create_mapping(arizona->virq, 0), 327 - IRQF_ONESHOT, 0, aod, 328 - &arizona->aod_irq_chip); 321 + virq = irq_create_mapping(arizona->virq, ARIZONA_AOD_IRQ_INDEX); 322 + if (!virq) { 323 + dev_err(arizona->dev, "Failed to map AOD IRQs\n"); 324 + ret = -EINVAL; 325 + goto err_domain; 326 + } 327 + 328 + ret = regmap_add_irq_chip(arizona->regmap, virq, IRQF_ONESHOT, 329 + 0, aod, &arizona->aod_irq_chip); 329 330 if (ret != 0) { 330 331 dev_err(arizona->dev, 331 332 "Failed to add AOD IRQs: %d\n", ret); 332 - goto err; 333 + goto err_map_aod; 333 334 } 334 335 } 335 336 336 - ret = regmap_add_irq_chip(arizona->regmap, 337 - irq_create_mapping(arizona->virq, 1), 338 - IRQF_ONESHOT, 0, irq, 339 - &arizona->irq_chip); 337 + virq = irq_create_mapping(arizona->virq, ARIZONA_MAIN_IRQ_INDEX); 338 + if (!virq) { 339 + dev_err(arizona->dev, "Failed to map main IRQs\n"); 340 + ret = -EINVAL; 341 + goto err_aod; 342 + } 343 + 344 + ret = regmap_add_irq_chip(arizona->regmap, virq, IRQF_ONESHOT, 345 + 0, irq, &arizona->irq_chip); 340 346 if (ret != 0) { 341 347 dev_err(arizona->dev, "Failed to add main IRQs: %d\n", ret); 342 - goto err_aod; 348 + goto err_map_main_irq; 343 349 } 344 350 345 351 /* Used to emulate edge trigger and to work around broken pinmux */ ··· 382 368 } 383 369 384 370 /* Make sure the boot done IRQ is unmasked for resumes */ 385 - i = arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE); 386 - ret = request_threaded_irq(i, NULL, arizona_boot_done, IRQF_ONESHOT, 387 - "Boot done", arizona); 371 + ret = arizona_request_irq(arizona, ARIZONA_IRQ_BOOT_DONE, "Boot done", 372 + arizona_boot_done, arizona); 388 373 if (ret != 0) { 389 374 dev_err(arizona->dev, "Failed to request boot done %d: %d\n", 390 375 arizona->irq, ret); ··· 392 379 393 380 /* Handle control interface errors in the core */ 394 381 if (arizona->ctrlif_error) { 395 - i = arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR); 396 - ret = request_threaded_irq(i, NULL, arizona_ctrlif_err, 397 - IRQF_ONESHOT, 398 - "Control interface error", arizona); 382 + ret = arizona_request_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR, 383 + "Control interface error", 384 + arizona_ctrlif_err, arizona); 399 385 if (ret != 0) { 400 386 dev_err(arizona->dev, 401 387 "Failed to request CTRLIF_ERR %d: %d\n", ··· 406 394 return 0; 407 395 408 396 err_ctrlif: 409 - free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona); 397 + arizona_free_irq(arizona, ARIZONA_IRQ_BOOT_DONE, arizona); 410 398 err_boot_done: 411 399 free_irq(arizona->irq, arizona); 412 400 err_main_irq: 413 - regmap_del_irq_chip(irq_find_mapping(arizona->virq, 1), 401 + regmap_del_irq_chip(irq_find_mapping(arizona->virq, 402 + ARIZONA_MAIN_IRQ_INDEX), 414 403 arizona->irq_chip); 404 + err_map_main_irq: 405 + irq_dispose_mapping(irq_find_mapping(arizona->virq, 406 + ARIZONA_MAIN_IRQ_INDEX)); 415 407 err_aod: 416 - regmap_del_irq_chip(irq_find_mapping(arizona->virq, 0), 408 + regmap_del_irq_chip(irq_find_mapping(arizona->virq, 409 + ARIZONA_AOD_IRQ_INDEX), 417 410 arizona->aod_irq_chip); 411 + err_map_aod: 412 + irq_dispose_mapping(irq_find_mapping(arizona->virq, 413 + ARIZONA_AOD_IRQ_INDEX)); 414 + err_domain: 415 + irq_domain_remove(arizona->virq); 418 416 err: 419 417 return ret; 420 418 } 421 419 422 420 int arizona_irq_exit(struct arizona *arizona) 423 421 { 422 + unsigned int virq; 423 + 424 424 if (arizona->ctrlif_error) 425 - free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR), 426 - arizona); 427 - free_irq(arizona_map_irq(arizona, ARIZONA_IRQ_BOOT_DONE), arizona); 428 - regmap_del_irq_chip(irq_find_mapping(arizona->virq, 1), 429 - arizona->irq_chip); 430 - regmap_del_irq_chip(irq_find_mapping(arizona->virq, 0), 431 - arizona->aod_irq_chip); 425 + arizona_free_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR, arizona); 426 + arizona_free_irq(arizona, ARIZONA_IRQ_BOOT_DONE, arizona); 427 + 428 + virq = irq_find_mapping(arizona->virq, ARIZONA_MAIN_IRQ_INDEX); 429 + regmap_del_irq_chip(virq, arizona->irq_chip); 430 + irq_dispose_mapping(virq); 431 + 432 + virq = irq_find_mapping(arizona->virq, ARIZONA_AOD_IRQ_INDEX); 433 + regmap_del_irq_chip(virq, arizona->aod_irq_chip); 434 + irq_dispose_mapping(virq); 435 + 436 + irq_domain_remove(arizona->virq); 437 + 432 438 free_irq(arizona->irq, arizona); 433 439 434 440 return 0;
-2
drivers/mfd/arizona.h
··· 17 17 #include <linux/regmap.h> 18 18 #include <linux/pm.h> 19 19 20 - struct wm_arizona; 21 - 22 20 extern const struct regmap_config wm5102_i2c_regmap; 23 21 extern const struct regmap_config wm5102_spi_regmap; 24 22
+67 -11
drivers/mfd/axp20x.c
··· 31 31 32 32 #define AXP20X_OFF 0x80 33 33 34 + #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) 35 + 34 36 static const char * const axp20x_model_names[] = { 35 37 "AXP152", 36 38 "AXP202", ··· 120 118 }; 121 119 122 120 static const struct regmap_range axp288_volatile_ranges[] = { 121 + regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP288_POWER_REASON), 122 + regmap_reg_range(AXP288_BC_GLOBAL, AXP288_BC_GLOBAL), 123 + regmap_reg_range(AXP288_BC_DET_STAT, AXP288_BC_DET_STAT), 123 124 regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IPSOUT_V_HIGH_L), 125 + regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL), 126 + regmap_reg_range(AXP22X_GPIO_STATE, AXP22X_GPIO_STATE), 127 + regmap_reg_range(AXP288_RT_BATT_V_H, AXP288_RT_BATT_V_L), 128 + regmap_reg_range(AXP20X_FG_RES, AXP288_FG_CC_CAP_REG), 124 129 }; 125 130 126 131 static const struct regmap_access_table axp288_writeable_table = { ··· 216 207 static struct resource axp288_power_button_resources[] = { 217 208 { 218 209 .name = "PEK_DBR", 219 - .start = AXP288_IRQ_POKN, 220 - .end = AXP288_IRQ_POKN, 210 + .start = AXP288_IRQ_POKP, 211 + .end = AXP288_IRQ_POKP, 221 212 .flags = IORESOURCE_IRQ, 222 213 }, 223 214 { 224 215 .name = "PEK_DBF", 225 - .start = AXP288_IRQ_POKP, 226 - .end = AXP288_IRQ_POKP, 216 + .start = AXP288_IRQ_POKN, 217 + .end = AXP288_IRQ_POKN, 227 218 .flags = IORESOURCE_IRQ, 228 219 }, 229 220 }; ··· 416 407 INIT_REGMAP_IRQ(AXP288, VBUS_FALL, 0, 2), 417 408 INIT_REGMAP_IRQ(AXP288, VBUS_RISE, 0, 3), 418 409 INIT_REGMAP_IRQ(AXP288, OV, 0, 4), 410 + INIT_REGMAP_IRQ(AXP288, FALLING_ALT, 0, 5), 411 + INIT_REGMAP_IRQ(AXP288, RISING_ALT, 0, 6), 412 + INIT_REGMAP_IRQ(AXP288, OV_ALT, 0, 7), 419 413 420 414 INIT_REGMAP_IRQ(AXP288, DONE, 1, 2), 421 415 INIT_REGMAP_IRQ(AXP288, CHARGING, 1, 3), ··· 601 589 }, 602 590 }; 603 591 604 - static struct mfd_cell axp22x_cells[] = { 592 + static struct mfd_cell axp221_cells[] = { 593 + { 594 + .name = "axp20x-pek", 595 + .num_resources = ARRAY_SIZE(axp22x_pek_resources), 596 + .resources = axp22x_pek_resources, 597 + }, { 598 + .name = "axp20x-regulator", 599 + }, { 600 + .name = "axp20x-usb-power-supply", 601 + .of_compatible = "x-powers,axp221-usb-power-supply", 602 + .num_resources = ARRAY_SIZE(axp22x_usb_power_supply_resources), 603 + .resources = axp22x_usb_power_supply_resources, 604 + }, 605 + }; 606 + 607 + static struct mfd_cell axp223_cells[] = { 605 608 { 606 609 .name = "axp20x-pek", 607 610 .num_resources = ARRAY_SIZE(axp22x_pek_resources), ··· 625 598 .name = "axp20x-regulator", 626 599 }, { 627 600 .name = "axp20x-usb-power-supply", 628 - .of_compatible = "x-powers,axp221-usb-power-supply", 601 + .of_compatible = "x-powers,axp223-usb-power-supply", 629 602 .num_resources = ARRAY_SIZE(axp22x_usb_power_supply_resources), 630 603 .resources = axp22x_usb_power_supply_resources, 631 604 }, ··· 818 791 axp20x->regmap_irq_chip = &axp20x_regmap_irq_chip; 819 792 break; 820 793 case AXP221_ID: 794 + axp20x->nr_cells = ARRAY_SIZE(axp221_cells); 795 + axp20x->cells = axp221_cells; 796 + axp20x->regmap_cfg = &axp22x_regmap_config; 797 + axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip; 798 + break; 821 799 case AXP223_ID: 822 - axp20x->nr_cells = ARRAY_SIZE(axp22x_cells); 823 - axp20x->cells = axp22x_cells; 800 + axp20x->nr_cells = ARRAY_SIZE(axp223_cells); 801 + axp20x->cells = axp223_cells; 824 802 axp20x->regmap_cfg = &axp22x_regmap_config; 825 803 axp20x->regmap_irq_chip = &axp22x_regmap_irq_chip; 826 804 break; ··· 834 802 axp20x->nr_cells = ARRAY_SIZE(axp288_cells); 835 803 axp20x->regmap_cfg = &axp288_regmap_config; 836 804 axp20x->regmap_irq_chip = &axp288_regmap_irq_chip; 805 + axp20x->irq_flags = IRQF_TRIGGER_LOW; 837 806 break; 838 807 case AXP806_ID: 839 808 axp20x->nr_cells = ARRAY_SIZE(axp806_cells); ··· 863 830 { 864 831 int ret; 865 832 833 + /* 834 + * The AXP806 supports either master/standalone or slave mode. 835 + * Slave mode allows sharing the serial bus, even with multiple 836 + * AXP806 which all have the same hardware address. 837 + * 838 + * This is done with extra "serial interface address extension", 839 + * or AXP806_BUS_ADDR_EXT, and "register address extension", or 840 + * AXP806_REG_ADDR_EXT, registers. The former is read-only, with 841 + * 1 bit customizable at the factory, and 1 bit depending on the 842 + * state of an external pin. The latter is writable. The device 843 + * will only respond to operations to its other registers when 844 + * the these device addressing bits (in the upper 4 bits of the 845 + * registers) match. 846 + * 847 + * Since we only support an AXP806 chained to an AXP809 in slave 848 + * mode, and there isn't any existing hardware which uses AXP806 849 + * in master mode, or has 2 AXP806s in the same system, we can 850 + * just program the register address extension to the slave mode 851 + * address. 852 + */ 853 + if (axp20x->variant == AXP806_ID) 854 + regmap_write(axp20x->regmap, AXP806_REG_ADDR_EXT, 855 + AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE); 856 + 866 857 ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq, 867 - IRQF_ONESHOT | IRQF_SHARED, -1, 868 - axp20x->regmap_irq_chip, 869 - &axp20x->regmap_irqc); 858 + IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags, 859 + -1, axp20x->regmap_irq_chip, &axp20x->regmap_irqc); 870 860 if (ret) { 871 861 dev_err(axp20x->dev, "failed to add irq chip: %d\n", ret); 872 862 return ret;
+53
drivers/mfd/cros_ec.c
··· 23 23 #include <linux/module.h> 24 24 #include <linux/mfd/core.h> 25 25 #include <linux/mfd/cros_ec.h> 26 + #include <linux/suspend.h> 26 27 #include <asm/unaligned.h> 27 28 28 29 #define CROS_EC_DEV_EC_INDEX 0 ··· 64 63 blocking_notifier_call_chain(&ec_dev->event_notifier, 65 64 0, ec_dev); 66 65 return IRQ_HANDLED; 66 + } 67 + 68 + static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) 69 + { 70 + struct { 71 + struct cros_ec_command msg; 72 + struct ec_params_host_sleep_event req; 73 + } __packed buf; 74 + 75 + memset(&buf, 0, sizeof(buf)); 76 + 77 + buf.req.sleep_event = sleep_event; 78 + 79 + buf.msg.command = EC_CMD_HOST_SLEEP_EVENT; 80 + buf.msg.version = 0; 81 + buf.msg.outsize = sizeof(buf.req); 82 + 83 + return cros_ec_cmd_xfer(ec_dev, &buf.msg); 67 84 } 68 85 69 86 int cros_ec_register(struct cros_ec_device *ec_dev) ··· 155 136 } 156 137 } 157 138 139 + /* 140 + * Clear sleep event - this will fail harmlessly on platforms that 141 + * don't implement the sleep event host command. 142 + */ 143 + err = cros_ec_sleep_event(ec_dev, 0); 144 + if (err < 0) 145 + dev_dbg(ec_dev->dev, "Error %d clearing sleep event to ec", 146 + err); 147 + 158 148 dev_info(dev, "Chrome EC device registered\n"); 159 149 160 150 return 0; ··· 187 159 int cros_ec_suspend(struct cros_ec_device *ec_dev) 188 160 { 189 161 struct device *dev = ec_dev->dev; 162 + int ret; 163 + u8 sleep_event; 164 + 165 + sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ? 166 + HOST_SLEEP_EVENT_S3_RESUME : 167 + HOST_SLEEP_EVENT_S0IX_RESUME; 168 + 169 + ret = cros_ec_sleep_event(ec_dev, sleep_event); 170 + if (ret < 0) 171 + dev_dbg(ec_dev->dev, "Error %d sending suspend event to ec", 172 + ret); 190 173 191 174 if (device_may_wakeup(dev)) 192 175 ec_dev->wake_enabled = !enable_irq_wake(ec_dev->irq); 193 176 194 177 disable_irq(ec_dev->irq); 195 178 ec_dev->was_wake_device = ec_dev->wake_enabled; 179 + ec_dev->suspended = true; 196 180 197 181 return 0; 198 182 } ··· 219 179 220 180 int cros_ec_resume(struct cros_ec_device *ec_dev) 221 181 { 182 + int ret; 183 + u8 sleep_event; 184 + 185 + ec_dev->suspended = false; 222 186 enable_irq(ec_dev->irq); 187 + 188 + sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ? 189 + HOST_SLEEP_EVENT_S3_RESUME : 190 + HOST_SLEEP_EVENT_S0IX_RESUME; 191 + 192 + ret = cros_ec_sleep_event(ec_dev, sleep_event); 193 + if (ret < 0) 194 + dev_dbg(ec_dev->dev, "Error %d sending resume event to ec", 195 + ret); 223 196 224 197 /* 225 198 * In some cases, we need to distinguish between events that occur
+16 -1
drivers/mfd/intel-lpss-pci.c
··· 157 157 { PCI_VDEVICE(INTEL, 0x1ac4), (kernel_ulong_t)&bxt_info }, 158 158 { PCI_VDEVICE(INTEL, 0x1ac6), (kernel_ulong_t)&bxt_info }, 159 159 { PCI_VDEVICE(INTEL, 0x1aee), (kernel_ulong_t)&bxt_uart_info }, 160 - 160 + /* GLK */ 161 + { PCI_VDEVICE(INTEL, 0x31ac), (kernel_ulong_t)&bxt_i2c_info }, 162 + { PCI_VDEVICE(INTEL, 0x31ae), (kernel_ulong_t)&bxt_i2c_info }, 163 + { PCI_VDEVICE(INTEL, 0x31b0), (kernel_ulong_t)&bxt_i2c_info }, 164 + { PCI_VDEVICE(INTEL, 0x31b2), (kernel_ulong_t)&bxt_i2c_info }, 165 + { PCI_VDEVICE(INTEL, 0x31b4), (kernel_ulong_t)&bxt_i2c_info }, 166 + { PCI_VDEVICE(INTEL, 0x31b6), (kernel_ulong_t)&bxt_i2c_info }, 167 + { PCI_VDEVICE(INTEL, 0x31b8), (kernel_ulong_t)&bxt_i2c_info }, 168 + { PCI_VDEVICE(INTEL, 0x31ba), (kernel_ulong_t)&bxt_i2c_info }, 169 + { PCI_VDEVICE(INTEL, 0x31bc), (kernel_ulong_t)&bxt_uart_info }, 170 + { PCI_VDEVICE(INTEL, 0x31be), (kernel_ulong_t)&bxt_uart_info }, 171 + { PCI_VDEVICE(INTEL, 0x31c0), (kernel_ulong_t)&bxt_uart_info }, 172 + { PCI_VDEVICE(INTEL, 0x31ee), (kernel_ulong_t)&bxt_uart_info }, 173 + { PCI_VDEVICE(INTEL, 0x31c2), (kernel_ulong_t)&bxt_info }, 174 + { PCI_VDEVICE(INTEL, 0x31c4), (kernel_ulong_t)&bxt_info }, 175 + { PCI_VDEVICE(INTEL, 0x31c6), (kernel_ulong_t)&bxt_info }, 161 176 /* APL */ 162 177 { PCI_VDEVICE(INTEL, 0x5aac), (kernel_ulong_t)&apl_i2c_info }, 163 178 { PCI_VDEVICE(INTEL, 0x5aae), (kernel_ulong_t)&apl_i2c_info },
+40
drivers/mfd/kempld-core.c
··· 496 496 497 497 static struct dmi_system_id kempld_dmi_table[] __initdata = { 498 498 { 499 + .ident = "BBD6", 500 + .matches = { 501 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 502 + DMI_MATCH(DMI_BOARD_NAME, "COMe-bBD"), 503 + }, 504 + .driver_data = (void *)&kempld_platform_data_generic, 505 + .callback = kempld_create_platform_device, 506 + }, { 499 507 .ident = "BBL6", 500 508 .matches = { 501 509 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), ··· 516 508 .matches = { 517 509 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 518 510 DMI_MATCH(DMI_BOARD_NAME, "COMe-bHL6"), 511 + }, 512 + .driver_data = (void *)&kempld_platform_data_generic, 513 + .callback = kempld_create_platform_device, 514 + }, { 515 + .ident = "BKL6", 516 + .matches = { 517 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 518 + DMI_MATCH(DMI_BOARD_NAME, "COMe-bKL6"), 519 + }, 520 + .driver_data = (void *)&kempld_platform_data_generic, 521 + .callback = kempld_create_platform_device, 522 + }, { 523 + .ident = "BSL6", 524 + .matches = { 525 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 526 + DMI_MATCH(DMI_BOARD_NAME, "COMe-bSL6"), 527 + }, 528 + .driver_data = (void *)&kempld_platform_data_generic, 529 + .callback = kempld_create_platform_device, 530 + }, { 531 + .ident = "CAL6", 532 + .matches = { 533 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 534 + DMI_MATCH(DMI_BOARD_NAME, "COMe-cAL"), 519 535 }, 520 536 .driver_data = (void *)&kempld_platform_data_generic, 521 537 .callback = kempld_create_platform_device, ··· 628 596 .matches = { 629 597 DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 630 598 DMI_MATCH(DMI_BOARD_NAME, "COMe-bSC6"), 599 + }, 600 + .driver_data = (void *)&kempld_platform_data_generic, 601 + .callback = kempld_create_platform_device, 602 + }, { 603 + .ident = "CKL6", 604 + .matches = { 605 + DMI_MATCH(DMI_BOARD_VENDOR, "Kontron"), 606 + DMI_MATCH(DMI_BOARD_NAME, "COMe-cKL6"), 631 607 }, 632 608 .driver_data = (void *)&kempld_platform_data_generic, 633 609 .callback = kempld_create_platform_device,
+1 -16
drivers/mfd/lpc_ich.c
··· 20 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 21 * GNU General Public License for more details. 22 22 * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; see the file COPYING. If not, write to 25 - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 26 - * 27 23 * This driver supports the following I/O Controller hubs: 28 24 * (See the intel documentation on http://developer.intel.com.) 29 25 * document number 290655-003, 290677-014: 82801AA (ICH), 82801AB (ICHO) ··· 41 45 * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH) 42 46 * document number 320066-003, 320257-008: EP80597 (IICH) 43 47 * document number 324645-001, 324646-001: Cougar Point (CPT) 44 - * document number TBD : Patsburg (PBG) 45 - * document number TBD : DH89xxCC 46 - * document number TBD : Panther Point 47 - * document number TBD : Lynx Point 48 - * document number TBD : Lynx Point-LP 49 - * document number TBD : Wellsburg 50 - * document number TBD : Avoton SoC 51 - * document number TBD : Coleto Creek 52 - * document number TBD : Wildcat Point-LP 53 - * document number TBD : 9 Series 54 - * document number TBD : Lewisburg 55 - * document number TBD : Apollo Lake SoC 56 48 */ 57 49 58 50 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ··· 551 567 }, 552 568 [LPC_APL] = { 553 569 .name = "Apollo Lake SoC", 570 + .iTCO_version = 5, 554 571 .spi_type = INTEL_SPI_BXT, 555 572 }, 556 573 };
+4 -21
drivers/mfd/max77686.c
··· 34 34 #include <linux/mfd/max77686-private.h> 35 35 #include <linux/err.h> 36 36 #include <linux/of.h> 37 + #include <linux/of_device.h> 37 38 38 39 static const struct mfd_cell max77686_devs[] = { 39 40 { .name = "max77686-pmic", }, ··· 172 171 }; 173 172 MODULE_DEVICE_TABLE(of, max77686_pmic_dt_match); 174 173 175 - static int max77686_i2c_probe(struct i2c_client *i2c, 176 - const struct i2c_device_id *id) 174 + static int max77686_i2c_probe(struct i2c_client *i2c) 177 175 { 178 176 struct max77686_dev *max77686 = NULL; 179 - const struct of_device_id *match; 180 177 unsigned int data; 181 178 int ret = 0; 182 179 const struct regmap_config *config; ··· 187 188 if (!max77686) 188 189 return -ENOMEM; 189 190 190 - if (i2c->dev.of_node) { 191 - match = of_match_node(max77686_pmic_dt_match, i2c->dev.of_node); 192 - if (!match) 193 - return -EINVAL; 194 - 195 - max77686->type = (unsigned long)match->data; 196 - } else 197 - max77686->type = id->driver_data; 198 - 199 191 i2c_set_clientdata(i2c, max77686); 192 + max77686->type = (unsigned long)of_device_get_match_data(&i2c->dev); 200 193 max77686->dev = &i2c->dev; 201 194 max77686->i2c = i2c; 202 195 ··· 241 250 return 0; 242 251 } 243 252 244 - static const struct i2c_device_id max77686_i2c_id[] = { 245 - { "max77686", TYPE_MAX77686 }, 246 - { "max77802", TYPE_MAX77802 }, 247 - { } 248 - }; 249 - MODULE_DEVICE_TABLE(i2c, max77686_i2c_id); 250 - 251 253 #ifdef CONFIG_PM_SLEEP 252 254 static int max77686_suspend(struct device *dev) 253 255 { ··· 286 302 .pm = &max77686_pm, 287 303 .of_match_table = of_match_ptr(max77686_pmic_dt_match), 288 304 }, 289 - .probe = max77686_i2c_probe, 290 - .id_table = max77686_i2c_id, 305 + .probe_new = max77686_i2c_probe, 291 306 }; 292 307 293 308 module_i2c_driver(max77686_i2c_driver);
+259
drivers/mfd/motorola-cpcap.c
··· 1 + /* 2 + * Motorola CPCAP PMIC core driver 3 + * 4 + * Copyright (C) 2016 Tony Lindgren <tony@atomide.com> 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 version 2 as 8 + * published by the Free Software Foundation. 9 + */ 10 + 11 + #include <linux/device.h> 12 + #include <linux/err.h> 13 + #include <linux/interrupt.h> 14 + #include <linux/irq.h> 15 + #include <linux/kernel.h> 16 + #include <linux/module.h> 17 + #include <linux/of_device.h> 18 + #include <linux/regmap.h> 19 + #include <linux/sysfs.h> 20 + 21 + #include <linux/mfd/motorola-cpcap.h> 22 + #include <linux/spi/spi.h> 23 + 24 + #define CPCAP_NR_IRQ_REG_BANKS 6 25 + #define CPCAP_NR_IRQ_CHIPS 3 26 + 27 + struct cpcap_ddata { 28 + struct spi_device *spi; 29 + struct regmap_irq *irqs; 30 + struct regmap_irq_chip_data *irqdata[CPCAP_NR_IRQ_CHIPS]; 31 + const struct regmap_config *regmap_conf; 32 + struct regmap *regmap; 33 + }; 34 + 35 + static int cpcap_check_revision(struct cpcap_ddata *cpcap) 36 + { 37 + u16 vendor, rev; 38 + int ret; 39 + 40 + ret = cpcap_get_vendor(&cpcap->spi->dev, cpcap->regmap, &vendor); 41 + if (ret) 42 + return ret; 43 + 44 + ret = cpcap_get_revision(&cpcap->spi->dev, cpcap->regmap, &rev); 45 + if (ret) 46 + return ret; 47 + 48 + dev_info(&cpcap->spi->dev, "CPCAP vendor: %s rev: %i.%i (%x)\n", 49 + vendor == CPCAP_VENDOR_ST ? "ST" : "TI", 50 + CPCAP_REVISION_MAJOR(rev), CPCAP_REVISION_MINOR(rev), 51 + rev); 52 + 53 + if (rev < CPCAP_REVISION_2_1) { 54 + dev_info(&cpcap->spi->dev, 55 + "Please add old CPCAP revision support as needed\n"); 56 + return -ENODEV; 57 + } 58 + 59 + return 0; 60 + } 61 + 62 + /* 63 + * First two irq chips are the two private macro interrupt chips, the third 64 + * irq chip is for register banks 1 - 4 and is available for drivers to use. 65 + */ 66 + static struct regmap_irq_chip cpcap_irq_chip[CPCAP_NR_IRQ_CHIPS] = { 67 + { 68 + .name = "cpcap-m2", 69 + .num_regs = 1, 70 + .status_base = CPCAP_REG_MI1, 71 + .ack_base = CPCAP_REG_MI1, 72 + .mask_base = CPCAP_REG_MIM1, 73 + .use_ack = true, 74 + }, 75 + { 76 + .name = "cpcap-m2", 77 + .num_regs = 1, 78 + .status_base = CPCAP_REG_MI2, 79 + .ack_base = CPCAP_REG_MI2, 80 + .mask_base = CPCAP_REG_MIM2, 81 + .use_ack = true, 82 + }, 83 + { 84 + .name = "cpcap1-4", 85 + .num_regs = 4, 86 + .status_base = CPCAP_REG_INT1, 87 + .ack_base = CPCAP_REG_INT1, 88 + .mask_base = CPCAP_REG_INTM1, 89 + .type_base = CPCAP_REG_INTS1, 90 + .use_ack = true, 91 + }, 92 + }; 93 + 94 + static void cpcap_init_one_regmap_irq(struct cpcap_ddata *cpcap, 95 + struct regmap_irq *rirq, 96 + int irq_base, int irq) 97 + { 98 + unsigned int reg_offset; 99 + unsigned int bit, mask; 100 + 101 + reg_offset = irq - irq_base; 102 + reg_offset /= cpcap->regmap_conf->val_bits; 103 + reg_offset *= cpcap->regmap_conf->reg_stride; 104 + 105 + bit = irq % cpcap->regmap_conf->val_bits; 106 + mask = (1 << bit); 107 + 108 + rirq->reg_offset = reg_offset; 109 + rirq->mask = mask; 110 + } 111 + 112 + static int cpcap_init_irq_chip(struct cpcap_ddata *cpcap, int irq_chip, 113 + int irq_start, int nr_irqs) 114 + { 115 + struct regmap_irq_chip *chip = &cpcap_irq_chip[irq_chip]; 116 + int i, ret; 117 + 118 + for (i = irq_start; i < irq_start + nr_irqs; i++) { 119 + struct regmap_irq *rirq = &cpcap->irqs[i]; 120 + 121 + cpcap_init_one_regmap_irq(cpcap, rirq, irq_start, i); 122 + } 123 + chip->irqs = &cpcap->irqs[irq_start]; 124 + chip->num_irqs = nr_irqs; 125 + chip->irq_drv_data = cpcap; 126 + 127 + ret = devm_regmap_add_irq_chip(&cpcap->spi->dev, cpcap->regmap, 128 + cpcap->spi->irq, 129 + IRQF_TRIGGER_RISING | 130 + IRQF_SHARED, -1, 131 + chip, &cpcap->irqdata[irq_chip]); 132 + if (ret) { 133 + dev_err(&cpcap->spi->dev, "could not add irq chip %i: %i\n", 134 + irq_chip, ret); 135 + return ret; 136 + } 137 + 138 + return 0; 139 + } 140 + 141 + static int cpcap_init_irq(struct cpcap_ddata *cpcap) 142 + { 143 + int ret; 144 + 145 + cpcap->irqs = devm_kzalloc(&cpcap->spi->dev, 146 + sizeof(*cpcap->irqs) * 147 + CPCAP_NR_IRQ_REG_BANKS * 148 + cpcap->regmap_conf->val_bits, 149 + GFP_KERNEL); 150 + if (!cpcap->irqs) 151 + return -ENOMEM; 152 + 153 + ret = cpcap_init_irq_chip(cpcap, 0, 0, 16); 154 + if (ret) 155 + return ret; 156 + 157 + ret = cpcap_init_irq_chip(cpcap, 1, 16, 16); 158 + if (ret) 159 + return ret; 160 + 161 + ret = cpcap_init_irq_chip(cpcap, 2, 32, 64); 162 + if (ret) 163 + return ret; 164 + 165 + enable_irq_wake(cpcap->spi->irq); 166 + 167 + return 0; 168 + } 169 + 170 + static const struct of_device_id cpcap_of_match[] = { 171 + { .compatible = "motorola,cpcap", }, 172 + { .compatible = "st,6556002", }, 173 + {}, 174 + }; 175 + MODULE_DEVICE_TABLE(of, cpcap_of_match); 176 + 177 + static const struct regmap_config cpcap_regmap_config = { 178 + .reg_bits = 16, 179 + .reg_stride = 4, 180 + .pad_bits = 0, 181 + .val_bits = 16, 182 + .write_flag_mask = 0x8000, 183 + .max_register = CPCAP_REG_ST_TEST2, 184 + .cache_type = REGCACHE_NONE, 185 + .reg_format_endian = REGMAP_ENDIAN_LITTLE, 186 + .val_format_endian = REGMAP_ENDIAN_LITTLE, 187 + }; 188 + 189 + static int cpcap_probe(struct spi_device *spi) 190 + { 191 + const struct of_device_id *match; 192 + struct cpcap_ddata *cpcap; 193 + int ret; 194 + 195 + match = of_match_device(of_match_ptr(cpcap_of_match), &spi->dev); 196 + if (!match) 197 + return -ENODEV; 198 + 199 + cpcap = devm_kzalloc(&spi->dev, sizeof(*cpcap), GFP_KERNEL); 200 + if (!cpcap) 201 + return -ENOMEM; 202 + 203 + cpcap->spi = spi; 204 + spi_set_drvdata(spi, cpcap); 205 + 206 + spi->bits_per_word = 16; 207 + spi->mode = SPI_MODE_0 | SPI_CS_HIGH; 208 + 209 + ret = spi_setup(spi); 210 + if (ret) 211 + return ret; 212 + 213 + cpcap->regmap_conf = &cpcap_regmap_config; 214 + cpcap->regmap = devm_regmap_init_spi(spi, &cpcap_regmap_config); 215 + if (IS_ERR(cpcap->regmap)) { 216 + ret = PTR_ERR(cpcap->regmap); 217 + dev_err(&cpcap->spi->dev, "Failed to initialize regmap: %d\n", 218 + ret); 219 + 220 + return ret; 221 + } 222 + 223 + ret = cpcap_check_revision(cpcap); 224 + if (ret) { 225 + dev_err(&cpcap->spi->dev, "Failed to detect CPCAP: %i\n", ret); 226 + return ret; 227 + } 228 + 229 + ret = cpcap_init_irq(cpcap); 230 + if (ret) 231 + return ret; 232 + 233 + return of_platform_populate(spi->dev.of_node, NULL, NULL, 234 + &cpcap->spi->dev); 235 + } 236 + 237 + static int cpcap_remove(struct spi_device *pdev) 238 + { 239 + struct cpcap_ddata *cpcap = spi_get_drvdata(pdev); 240 + 241 + of_platform_depopulate(&cpcap->spi->dev); 242 + 243 + return 0; 244 + } 245 + 246 + static struct spi_driver cpcap_driver = { 247 + .driver = { 248 + .name = "cpcap-core", 249 + .of_match_table = cpcap_of_match, 250 + }, 251 + .probe = cpcap_probe, 252 + .remove = cpcap_remove, 253 + }; 254 + module_spi_driver(cpcap_driver); 255 + 256 + MODULE_ALIAS("platform:cpcap"); 257 + MODULE_DESCRIPTION("CPCAP driver"); 258 + MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>"); 259 + MODULE_LICENSE("GPL v2");
+4
drivers/mfd/mt6397-core.c
··· 48 48 .name = "mt6323-regulator", 49 49 .of_compatible = "mediatek,mt6323-regulator" 50 50 }, 51 + { 52 + .name = "mt6323-led", 53 + .of_compatible = "mediatek,mt6323-led" 54 + }, 51 55 }; 52 56 53 57 static const struct mfd_cell mt6397_devs[] = {
+2 -2
drivers/mfd/rk808.c
··· 247 247 }, 248 248 }; 249 249 250 - static struct regmap_irq_chip rk808_irq_chip = { 250 + static const struct regmap_irq_chip rk808_irq_chip = { 251 251 .name = "rk808", 252 252 .irqs = rk808_irqs, 253 253 .num_irqs = ARRAY_SIZE(rk808_irqs), ··· 259 259 .init_ack_masked = true, 260 260 }; 261 261 262 - static struct regmap_irq_chip rk818_irq_chip = { 262 + static const struct regmap_irq_chip rk818_irq_chip = { 263 263 .name = "rk818", 264 264 .irqs = rk818_irqs, 265 265 .num_irqs = ARRAY_SIZE(rk818_irqs),
+13
drivers/mfd/sun6i-prcm.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/of.h> 14 14 15 + #define SUN8I_CODEC_ANALOG_BASE 0x1c0 16 + #define SUN8I_CODEC_ANALOG_SIZE 0x4 17 + 15 18 struct prcm_data { 16 19 int nsubdevs; 17 20 const struct mfd_cell *subdevs; ··· 58 55 .end = 0xb3, 59 56 .flags = IORESOURCE_MEM, 60 57 }, 58 + }; 59 + 60 + static const struct resource sun8i_codec_analog_res[] = { 61 + DEFINE_RES_MEM(SUN8I_CODEC_ANALOG_BASE, SUN8I_CODEC_ANALOG_SIZE), 61 62 }; 62 63 63 64 static const struct mfd_cell sun6i_a31_prcm_subdevs[] = { ··· 115 108 .of_compatible = "allwinner,sun6i-a31-clock-reset", 116 109 .num_resources = ARRAY_SIZE(sun6i_a31_apb0_rstc_res), 117 110 .resources = sun6i_a31_apb0_rstc_res, 111 + }, 112 + { 113 + .name = "sun8i-codec-analog", 114 + .of_compatible = "allwinner,sun8i-a23-codec-analog", 115 + .num_resources = ARRAY_SIZE(sun8i_codec_analog_res), 116 + .resources = sun8i_codec_analog_res, 118 117 }, 119 118 }; 120 119
+1
drivers/mfd/tps65912-i2c.c
··· 27 27 { .compatible = "ti,tps65912", }, 28 28 { /* sentinel */ } 29 29 }; 30 + MODULE_DEVICE_TABLE(of, tps65912_i2c_of_match_table); 30 31 31 32 static int tps65912_i2c_probe(struct i2c_client *client, 32 33 const struct i2c_device_id *ids)
+5
drivers/platform/chrome/cros_ec_proto.c
··· 447 447 struct cros_ec_command *msg = (struct cros_ec_command *)&buffer; 448 448 int ret; 449 449 450 + if (ec_dev->suspended) { 451 + dev_dbg(ec_dev->dev, "Device suspended.\n"); 452 + return -EHOSTDOWN; 453 + } 454 + 450 455 msg->version = 0; 451 456 msg->command = EC_CMD_GET_NEXT_EVENT; 452 457 msg->insize = sizeof(ec_dev->event_data);
+1 -1
include/linux/mfd/abx500.h
··· 45 45 * struct abx500_res_to_temp - defines one point in a temp to res curve. To 46 46 * be used in battery packs that combines the identification resistor with a 47 47 * NTC resistor. 48 - * @temp: battery pack temperature in Celcius 48 + * @temp: battery pack temperature in Celsius 49 49 * @resist: NTC resistor net total resistance 50 50 */ 51 51 struct abx500_res_to_temp {
+2 -2
include/linux/mfd/abx500/ab8500-bm.h
··· 279 279 * struct res_to_temp - defines one point in a temp to res curve. To 280 280 * be used in battery packs that combines the identification resistor with a 281 281 * NTC resistor. 282 - * @temp: battery pack temperature in Celcius 282 + * @temp: battery pack temperature in Celsius 283 283 * @resist: NTC resistor net total resistance 284 284 */ 285 285 struct res_to_temp { ··· 290 290 /** 291 291 * struct batres_vs_temp - defines one point in a temp vs battery internal 292 292 * resistance curve. 293 - * @temp: battery pack temperature in Celcius 293 + * @temp: battery pack temperature in Celsius 294 294 * @resist: battery internal reistance in mOhm 295 295 */ 296 296 struct batres_vs_temp {
+13 -7
include/linux/mfd/axp20x.h
··· 235 235 #define AXP22X_BATLOW_THRES1 0xe6 236 236 237 237 /* AXP288 specific registers */ 238 + #define AXP288_POWER_REASON 0x02 239 + #define AXP288_BC_GLOBAL 0x2c 240 + #define AXP288_BC_VBUS_CNTL 0x2d 241 + #define AXP288_BC_USB_STAT 0x2e 242 + #define AXP288_BC_DET_STAT 0x2f 238 243 #define AXP288_PMIC_ADC_H 0x56 239 244 #define AXP288_PMIC_ADC_L 0x57 245 + #define AXP288_TS_ADC_H 0x58 246 + #define AXP288_TS_ADC_L 0x59 247 + #define AXP288_GP_ADC_H 0x5a 248 + #define AXP288_GP_ADC_L 0x5b 240 249 #define AXP288_ADC_TS_PIN_CTRL 0x84 241 - #define AXP288_PMIC_ADC_EN 0x84 250 + #define AXP288_RT_BATT_V_H 0xa0 251 + #define AXP288_RT_BATT_V_L 0xa1 242 252 243 253 /* Fuel Gauge */ 244 254 #define AXP288_FG_RDC1_REG 0xba ··· 525 515 AXP809_IRQ_GPIO0_INPUT, 526 516 }; 527 517 528 - #define AXP288_TS_ADC_H 0x58 529 - #define AXP288_TS_ADC_L 0x59 530 - #define AXP288_GP_ADC_H 0x5a 531 - #define AXP288_GP_ADC_L 0x5b 532 - 533 518 struct axp20x_dev { 534 519 struct device *dev; 535 520 int irq; 521 + unsigned long irq_flags; 536 522 struct regmap *regmap; 537 523 struct regmap_irq_chip_data *regmap_irqc; 538 524 long variant; ··· 588 582 int axp20x_device_probe(struct axp20x_dev *axp20x); 589 583 590 584 /** 591 - * axp20x_device_probe(): Remove a axp20x device 585 + * axp20x_device_remove(): Remove a axp20x device 592 586 * 593 587 * @axp20x: axp20x device to remove 594 588 *
+2
include/linux/mfd/cros_ec.h
··· 103 103 * @din_size: size of din buffer to allocate (zero to use static din) 104 104 * @dout_size: size of dout buffer to allocate (zero to use static dout) 105 105 * @wake_enabled: true if this device can wake the system from sleep 106 + * @suspended: true if this device had been suspended 106 107 * @cmd_xfer: send command to EC and get response 107 108 * Returns the number of bytes received if the communication succeeded, but 108 109 * that doesn't mean the EC was happy with the command. The caller ··· 137 136 int din_size; 138 137 int dout_size; 139 138 bool wake_enabled; 139 + bool suspended; 140 140 int (*cmd_xfer)(struct cros_ec_device *ec, 141 141 struct cros_ec_command *msg); 142 142 int (*pkt_xfer)(struct cros_ec_device *ec,
+86 -2
include/linux/mfd/cros_ec_commands.h
··· 1840 1840 * 1841 1841 * Returns raw data for keyboard cols; see ec_response_mkbp_info.cols for 1842 1842 * expected response size. 1843 + * 1844 + * NOTE: This has been superseded by EC_CMD_MKBP_GET_NEXT_EVENT. If you wish 1845 + * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type 1846 + * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX. 1843 1847 */ 1844 1848 #define EC_CMD_MKBP_STATE 0x60 1845 1849 1846 - /* Provide information about the matrix : number of rows and columns */ 1850 + /* 1851 + * Provide information about various MKBP things. See enum ec_mkbp_info_type. 1852 + */ 1847 1853 #define EC_CMD_MKBP_INFO 0x61 1848 1854 1849 1855 struct ec_response_mkbp_info { 1850 1856 uint32_t rows; 1851 1857 uint32_t cols; 1852 - uint8_t switches; 1858 + /* Formerly "switches", which was 0. */ 1859 + uint8_t reserved; 1853 1860 } __packed; 1861 + 1862 + struct ec_params_mkbp_info { 1863 + uint8_t info_type; 1864 + uint8_t event_type; 1865 + } __packed; 1866 + 1867 + enum ec_mkbp_info_type { 1868 + /* 1869 + * Info about the keyboard matrix: number of rows and columns. 1870 + * 1871 + * Returns struct ec_response_mkbp_info. 1872 + */ 1873 + EC_MKBP_INFO_KBD = 0, 1874 + 1875 + /* 1876 + * For buttons and switches, info about which specifically are 1877 + * supported. event_type must be set to one of the values in enum 1878 + * ec_mkbp_event. 1879 + * 1880 + * For EC_MKBP_EVENT_BUTTON and EC_MKBP_EVENT_SWITCH, returns a 4 byte 1881 + * bitmask indicating which buttons or switches are present. See the 1882 + * bit inidices below. 1883 + */ 1884 + EC_MKBP_INFO_SUPPORTED = 1, 1885 + 1886 + /* 1887 + * Instantaneous state of buttons and switches. 1888 + * 1889 + * event_type must be set to one of the values in enum ec_mkbp_event. 1890 + * 1891 + * For EC_MKBP_EVENT_KEY_MATRIX, returns uint8_t key_matrix[13] 1892 + * indicating the current state of the keyboard matrix. 1893 + * 1894 + * For EC_MKBP_EVENT_HOST_EVENT, return uint32_t host_event, the raw 1895 + * event state. 1896 + * 1897 + * For EC_MKBP_EVENT_BUTTON, returns uint32_t buttons, indicating the 1898 + * state of supported buttons. 1899 + * 1900 + * For EC_MKBP_EVENT_SWITCH, returns uint32_t switches, indicating the 1901 + * state of supported switches. 1902 + */ 1903 + EC_MKBP_INFO_CURRENT = 2, 1904 + }; 1854 1905 1855 1906 /* Simulate key press */ 1856 1907 #define EC_CMD_MKBP_SIMULATE_KEY 0x62 ··· 2035 1984 /* New Sensor FIFO data. The event data is fifo_info structure. */ 2036 1985 EC_MKBP_EVENT_SENSOR_FIFO = 2, 2037 1986 1987 + /* The state of the non-matrixed buttons have changed. */ 1988 + EC_MKBP_EVENT_BUTTON = 3, 1989 + 1990 + /* The state of the switches have changed. */ 1991 + EC_MKBP_EVENT_SWITCH = 4, 1992 + 2038 1993 /* Number of MKBP events */ 2039 1994 EC_MKBP_EVENT_COUNT, 2040 1995 }; ··· 2050 1993 2051 1994 /* Unaligned */ 2052 1995 uint32_t host_event; 1996 + 1997 + uint32_t buttons; 1998 + uint32_t switches; 2053 1999 } __packed; 2054 2000 2055 2001 struct ec_response_get_next_event { ··· 2060 2000 /* Followed by event data if any */ 2061 2001 union ec_response_get_next_data data; 2062 2002 } __packed; 2003 + 2004 + /* Bit indices for buttons and switches.*/ 2005 + /* Buttons */ 2006 + #define EC_MKBP_POWER_BUTTON 0 2007 + #define EC_MKBP_VOL_UP 1 2008 + #define EC_MKBP_VOL_DOWN 2 2009 + 2010 + /* Switches */ 2011 + #define EC_MKBP_LID_OPEN 0 2012 + #define EC_MKBP_TABLET_MODE 1 2063 2013 2064 2014 /*****************************************************************************/ 2065 2015 /* Temperature sensor commands */ ··· 2546 2476 2547 2477 struct ec_params_ext_power_current_limit { 2548 2478 uint32_t limit; /* in mA */ 2479 + } __packed; 2480 + 2481 + /* Inform the EC when entering a sleep state */ 2482 + #define EC_CMD_HOST_SLEEP_EVENT 0xa9 2483 + 2484 + enum host_sleep_event { 2485 + HOST_SLEEP_EVENT_S3_SUSPEND = 1, 2486 + HOST_SLEEP_EVENT_S3_RESUME = 2, 2487 + HOST_SLEEP_EVENT_S0IX_SUSPEND = 3, 2488 + HOST_SLEEP_EVENT_S0IX_RESUME = 4 2489 + }; 2490 + 2491 + struct ec_params_host_sleep_event { 2492 + uint8_t sleep_event; 2549 2493 } __packed; 2550 2494 2551 2495 /*****************************************************************************/
+292
include/linux/mfd/motorola-cpcap.h
··· 1 + /* 2 + * The register defines are based on earlier cpcap.h in Motorola Linux kernel 3 + * tree. 4 + * 5 + * Copyright (C) 2007-2009 Motorola, Inc. 6 + * 7 + * Rewritten for the real register offsets instead of enumeration 8 + * to make the defines usable with Linux kernel regmap support 9 + * 10 + * Copyright (C) 2016 Tony Lindgren <tony@atomide.com> 11 + * 12 + * This program is free software; you can redistribute it and/or modify 13 + * it under the terms of the GNU General Public License version 2 as 14 + * published by the Free Software Foundation. 15 + */ 16 + 17 + #define CPCAP_VENDOR_ST 0 18 + #define CPCAP_VENDOR_TI 1 19 + 20 + #define CPCAP_REVISION_MAJOR(r) (((r) >> 4) + 1) 21 + #define CPCAP_REVISION_MINOR(r) ((r) & 0xf) 22 + 23 + #define CPCAP_REVISION_1_0 0x08 24 + #define CPCAP_REVISION_1_1 0x09 25 + #define CPCAP_REVISION_2_0 0x10 26 + #define CPCAP_REVISION_2_1 0x11 27 + 28 + /* CPCAP registers */ 29 + #define CPCAP_REG_INT1 0x0000 /* Interrupt 1 */ 30 + #define CPCAP_REG_INT2 0x0004 /* Interrupt 2 */ 31 + #define CPCAP_REG_INT3 0x0008 /* Interrupt 3 */ 32 + #define CPCAP_REG_INT4 0x000c /* Interrupt 4 */ 33 + #define CPCAP_REG_INTM1 0x0010 /* Interrupt Mask 1 */ 34 + #define CPCAP_REG_INTM2 0x0014 /* Interrupt Mask 2 */ 35 + #define CPCAP_REG_INTM3 0x0018 /* Interrupt Mask 3 */ 36 + #define CPCAP_REG_INTM4 0x001c /* Interrupt Mask 4 */ 37 + #define CPCAP_REG_INTS1 0x0020 /* Interrupt Sense 1 */ 38 + #define CPCAP_REG_INTS2 0x0024 /* Interrupt Sense 2 */ 39 + #define CPCAP_REG_INTS3 0x0028 /* Interrupt Sense 3 */ 40 + #define CPCAP_REG_INTS4 0x002c /* Interrupt Sense 4 */ 41 + #define CPCAP_REG_ASSIGN1 0x0030 /* Resource Assignment 1 */ 42 + #define CPCAP_REG_ASSIGN2 0x0034 /* Resource Assignment 2 */ 43 + #define CPCAP_REG_ASSIGN3 0x0038 /* Resource Assignment 3 */ 44 + #define CPCAP_REG_ASSIGN4 0x003c /* Resource Assignment 4 */ 45 + #define CPCAP_REG_ASSIGN5 0x0040 /* Resource Assignment 5 */ 46 + #define CPCAP_REG_ASSIGN6 0x0044 /* Resource Assignment 6 */ 47 + #define CPCAP_REG_VERSC1 0x0048 /* Version Control 1 */ 48 + #define CPCAP_REG_VERSC2 0x004c /* Version Control 2 */ 49 + 50 + #define CPCAP_REG_MI1 0x0200 /* Macro Interrupt 1 */ 51 + #define CPCAP_REG_MIM1 0x0204 /* Macro Interrupt Mask 1 */ 52 + #define CPCAP_REG_MI2 0x0208 /* Macro Interrupt 2 */ 53 + #define CPCAP_REG_MIM2 0x020c /* Macro Interrupt Mask 2 */ 54 + #define CPCAP_REG_UCC1 0x0210 /* UC Control 1 */ 55 + #define CPCAP_REG_UCC2 0x0214 /* UC Control 2 */ 56 + 57 + #define CPCAP_REG_PC1 0x021c /* Power Cut 1 */ 58 + #define CPCAP_REG_PC2 0x0220 /* Power Cut 2 */ 59 + #define CPCAP_REG_BPEOL 0x0224 /* BP and EOL */ 60 + #define CPCAP_REG_PGC 0x0228 /* Power Gate and Control */ 61 + #define CPCAP_REG_MT1 0x022c /* Memory Transfer 1 */ 62 + #define CPCAP_REG_MT2 0x0230 /* Memory Transfer 2 */ 63 + #define CPCAP_REG_MT3 0x0234 /* Memory Transfer 3 */ 64 + #define CPCAP_REG_PF 0x0238 /* Print Format */ 65 + 66 + #define CPCAP_REG_SCC 0x0400 /* System Clock Control */ 67 + #define CPCAP_REG_SW1 0x0404 /* Stop Watch 1 */ 68 + #define CPCAP_REG_SW2 0x0408 /* Stop Watch 2 */ 69 + #define CPCAP_REG_UCTM 0x040c /* UC Turbo Mode */ 70 + #define CPCAP_REG_TOD1 0x0410 /* Time of Day 1 */ 71 + #define CPCAP_REG_TOD2 0x0414 /* Time of Day 2 */ 72 + #define CPCAP_REG_TODA1 0x0418 /* Time of Day Alarm 1 */ 73 + #define CPCAP_REG_TODA2 0x041c /* Time of Day Alarm 2 */ 74 + #define CPCAP_REG_DAY 0x0420 /* Day */ 75 + #define CPCAP_REG_DAYA 0x0424 /* Day Alarm */ 76 + #define CPCAP_REG_VAL1 0x0428 /* Validity 1 */ 77 + #define CPCAP_REG_VAL2 0x042c /* Validity 2 */ 78 + 79 + #define CPCAP_REG_SDVSPLL 0x0600 /* Switcher DVS and PLL */ 80 + #define CPCAP_REG_SI2CC1 0x0604 /* Switcher I2C Control 1 */ 81 + #define CPCAP_REG_Si2CC2 0x0608 /* Switcher I2C Control 2 */ 82 + #define CPCAP_REG_S1C1 0x060c /* Switcher 1 Control 1 */ 83 + #define CPCAP_REG_S1C2 0x0610 /* Switcher 1 Control 2 */ 84 + #define CPCAP_REG_S2C1 0x0614 /* Switcher 2 Control 1 */ 85 + #define CPCAP_REG_S2C2 0x0618 /* Switcher 2 Control 2 */ 86 + #define CPCAP_REG_S3C 0x061c /* Switcher 3 Control */ 87 + #define CPCAP_REG_S4C1 0x0620 /* Switcher 4 Control 1 */ 88 + #define CPCAP_REG_S4C2 0x0624 /* Switcher 4 Control 2 */ 89 + #define CPCAP_REG_S5C 0x0628 /* Switcher 5 Control */ 90 + #define CPCAP_REG_S6C 0x062c /* Switcher 6 Control */ 91 + #define CPCAP_REG_VCAMC 0x0630 /* VCAM Control */ 92 + #define CPCAP_REG_VCSIC 0x0634 /* VCSI Control */ 93 + #define CPCAP_REG_VDACC 0x0638 /* VDAC Control */ 94 + #define CPCAP_REG_VDIGC 0x063c /* VDIG Control */ 95 + #define CPCAP_REG_VFUSEC 0x0640 /* VFUSE Control */ 96 + #define CPCAP_REG_VHVIOC 0x0644 /* VHVIO Control */ 97 + #define CPCAP_REG_VSDIOC 0x0648 /* VSDIO Control */ 98 + #define CPCAP_REG_VPLLC 0x064c /* VPLL Control */ 99 + #define CPCAP_REG_VRF1C 0x0650 /* VRF1 Control */ 100 + #define CPCAP_REG_VRF2C 0x0654 /* VRF2 Control */ 101 + #define CPCAP_REG_VRFREFC 0x0658 /* VRFREF Control */ 102 + #define CPCAP_REG_VWLAN1C 0x065c /* VWLAN1 Control */ 103 + #define CPCAP_REG_VWLAN2C 0x0660 /* VWLAN2 Control */ 104 + #define CPCAP_REG_VSIMC 0x0664 /* VSIM Control */ 105 + #define CPCAP_REG_VVIBC 0x0668 /* VVIB Control */ 106 + #define CPCAP_REG_VUSBC 0x066c /* VUSB Control */ 107 + #define CPCAP_REG_VUSBINT1C 0x0670 /* VUSBINT1 Control */ 108 + #define CPCAP_REG_VUSBINT2C 0x0674 /* VUSBINT2 Control */ 109 + #define CPCAP_REG_URT 0x0678 /* Useroff Regulator Trigger */ 110 + #define CPCAP_REG_URM1 0x067c /* Useroff Regulator Mask 1 */ 111 + #define CPCAP_REG_URM2 0x0680 /* Useroff Regulator Mask 2 */ 112 + 113 + #define CPCAP_REG_VAUDIOC 0x0800 /* VAUDIO Control */ 114 + #define CPCAP_REG_CC 0x0804 /* Codec Control */ 115 + #define CPCAP_REG_CDI 0x0808 /* Codec Digital Interface */ 116 + #define CPCAP_REG_SDAC 0x080c /* Stereo DAC */ 117 + #define CPCAP_REG_SDACDI 0x0810 /* Stereo DAC Digital Interface */ 118 + #define CPCAP_REG_TXI 0x0814 /* TX Inputs */ 119 + #define CPCAP_REG_TXMP 0x0818 /* TX MIC PGA's */ 120 + #define CPCAP_REG_RXOA 0x081c /* RX Output Amplifiers */ 121 + #define CPCAP_REG_RXVC 0x0820 /* RX Volume Control */ 122 + #define CPCAP_REG_RXCOA 0x0824 /* RX Codec to Output Amps */ 123 + #define CPCAP_REG_RXSDOA 0x0828 /* RX Stereo DAC to Output Amps */ 124 + #define CPCAP_REG_RXEPOA 0x082c /* RX External PGA to Output Amps */ 125 + #define CPCAP_REG_RXLL 0x0830 /* RX Low Latency */ 126 + #define CPCAP_REG_A2LA 0x0834 /* A2 Loudspeaker Amplifier */ 127 + #define CPCAP_REG_MIPIS1 0x0838 /* MIPI Slimbus 1 */ 128 + #define CPCAP_REG_MIPIS2 0x083c /* MIPI Slimbus 2 */ 129 + #define CPCAP_REG_MIPIS3 0x0840 /* MIPI Slimbus 3. */ 130 + #define CPCAP_REG_LVAB 0x0844 /* LMR Volume and A4 Balanced. */ 131 + 132 + #define CPCAP_REG_CCC1 0x0a00 /* Coulomb Counter Control 1 */ 133 + #define CPCAP_REG_CRM 0x0a04 /* Charger and Reverse Mode */ 134 + #define CPCAP_REG_CCCC2 0x0a08 /* Coincell and Coulomb Ctr Ctrl 2 */ 135 + #define CPCAP_REG_CCS1 0x0a0c /* Coulomb Counter Sample 1 */ 136 + #define CPCAP_REG_CCS2 0x0a10 /* Coulomb Counter Sample 2 */ 137 + #define CPCAP_REG_CCA1 0x0a14 /* Coulomb Counter Accumulator 1 */ 138 + #define CPCAP_REG_CCA2 0x0a18 /* Coulomb Counter Accumulator 2 */ 139 + #define CPCAP_REG_CCM 0x0a1c /* Coulomb Counter Mode */ 140 + #define CPCAP_REG_CCO 0x0a20 /* Coulomb Counter Offset */ 141 + #define CPCAP_REG_CCI 0x0a24 /* Coulomb Counter Integrator */ 142 + 143 + #define CPCAP_REG_ADCC1 0x0c00 /* A/D Converter Configuration 1 */ 144 + #define CPCAP_REG_ADCC2 0x0c04 /* A/D Converter Configuration 2 */ 145 + #define CPCAP_REG_ADCD0 0x0c08 /* A/D Converter Data 0 */ 146 + #define CPCAP_REG_ADCD1 0x0c0c /* A/D Converter Data 1 */ 147 + #define CPCAP_REG_ADCD2 0x0c10 /* A/D Converter Data 2 */ 148 + #define CPCAP_REG_ADCD3 0x0c14 /* A/D Converter Data 3 */ 149 + #define CPCAP_REG_ADCD4 0x0c18 /* A/D Converter Data 4 */ 150 + #define CPCAP_REG_ADCD5 0x0c1c /* A/D Converter Data 5 */ 151 + #define CPCAP_REG_ADCD6 0x0c20 /* A/D Converter Data 6 */ 152 + #define CPCAP_REG_ADCD7 0x0c24 /* A/D Converter Data 7 */ 153 + #define CPCAP_REG_ADCAL1 0x0c28 /* A/D Converter Calibration 1 */ 154 + #define CPCAP_REG_ADCAL2 0x0c2c /* A/D Converter Calibration 2 */ 155 + 156 + #define CPCAP_REG_USBC1 0x0e00 /* USB Control 1 */ 157 + #define CPCAP_REG_USBC2 0x0e04 /* USB Control 2 */ 158 + #define CPCAP_REG_USBC3 0x0e08 /* USB Control 3 */ 159 + #define CPCAP_REG_UVIDL 0x0e0c /* ULPI Vendor ID Low */ 160 + #define CPCAP_REG_UVIDH 0x0e10 /* ULPI Vendor ID High */ 161 + #define CPCAP_REG_UPIDL 0x0e14 /* ULPI Product ID Low */ 162 + #define CPCAP_REG_UPIDH 0x0e18 /* ULPI Product ID High */ 163 + #define CPCAP_REG_UFC1 0x0e1c /* ULPI Function Control 1 */ 164 + #define CPCAP_REG_UFC2 0x0e20 /* ULPI Function Control 2 */ 165 + #define CPCAP_REG_UFC3 0x0e24 /* ULPI Function Control 3 */ 166 + #define CPCAP_REG_UIC1 0x0e28 /* ULPI Interface Control 1 */ 167 + #define CPCAP_REG_UIC2 0x0e2c /* ULPI Interface Control 2 */ 168 + #define CPCAP_REG_UIC3 0x0e30 /* ULPI Interface Control 3 */ 169 + #define CPCAP_REG_USBOTG1 0x0e34 /* USB OTG Control 1 */ 170 + #define CPCAP_REG_USBOTG2 0x0e38 /* USB OTG Control 2 */ 171 + #define CPCAP_REG_USBOTG3 0x0e3c /* USB OTG Control 3 */ 172 + #define CPCAP_REG_UIER1 0x0e40 /* USB Interrupt Enable Rising 1 */ 173 + #define CPCAP_REG_UIER2 0x0e44 /* USB Interrupt Enable Rising 2 */ 174 + #define CPCAP_REG_UIER3 0x0e48 /* USB Interrupt Enable Rising 3 */ 175 + #define CPCAP_REG_UIEF1 0x0e4c /* USB Interrupt Enable Falling 1 */ 176 + #define CPCAP_REG_UIEF2 0x0e50 /* USB Interrupt Enable Falling 1 */ 177 + #define CPCAP_REG_UIEF3 0x0e54 /* USB Interrupt Enable Falling 1 */ 178 + #define CPCAP_REG_UIS 0x0e58 /* USB Interrupt Status */ 179 + #define CPCAP_REG_UIL 0x0e5c /* USB Interrupt Latch */ 180 + #define CPCAP_REG_USBD 0x0e60 /* USB Debug */ 181 + #define CPCAP_REG_SCR1 0x0e64 /* Scratch 1 */ 182 + #define CPCAP_REG_SCR2 0x0e68 /* Scratch 2 */ 183 + #define CPCAP_REG_SCR3 0x0e6c /* Scratch 3 */ 184 + 185 + #define CPCAP_REG_VMC 0x0eac /* Video Mux Control */ 186 + #define CPCAP_REG_OWDC 0x0eb0 /* One Wire Device Control */ 187 + #define CPCAP_REG_GPIO0 0x0eb4 /* GPIO 0 Control */ 188 + 189 + #define CPCAP_REG_GPIO1 0x0ebc /* GPIO 1 Control */ 190 + 191 + #define CPCAP_REG_GPIO2 0x0ec4 /* GPIO 2 Control */ 192 + 193 + #define CPCAP_REG_GPIO3 0x0ecc /* GPIO 3 Control */ 194 + 195 + #define CPCAP_REG_GPIO4 0x0ed4 /* GPIO 4 Control */ 196 + 197 + #define CPCAP_REG_GPIO5 0x0edc /* GPIO 5 Control */ 198 + 199 + #define CPCAP_REG_GPIO6 0x0ee4 /* GPIO 6 Control */ 200 + 201 + #define CPCAP_REG_MDLC 0x1000 /* Main Display Lighting Control */ 202 + #define CPCAP_REG_KLC 0x1004 /* Keypad Lighting Control */ 203 + #define CPCAP_REG_ADLC 0x1008 /* Aux Display Lighting Control */ 204 + #define CPCAP_REG_REDC 0x100c /* Red Triode Control */ 205 + #define CPCAP_REG_GREENC 0x1010 /* Green Triode Control */ 206 + #define CPCAP_REG_BLUEC 0x1014 /* Blue Triode Control */ 207 + #define CPCAP_REG_CFC 0x1018 /* Camera Flash Control */ 208 + #define CPCAP_REG_ABC 0x101c /* Adaptive Boost Control */ 209 + #define CPCAP_REG_BLEDC 0x1020 /* Bluetooth LED Control */ 210 + #define CPCAP_REG_CLEDC 0x1024 /* Camera Privacy LED Control */ 211 + 212 + #define CPCAP_REG_OW1C 0x1200 /* One Wire 1 Command */ 213 + #define CPCAP_REG_OW1D 0x1204 /* One Wire 1 Data */ 214 + #define CPCAP_REG_OW1I 0x1208 /* One Wire 1 Interrupt */ 215 + #define CPCAP_REG_OW1IE 0x120c /* One Wire 1 Interrupt Enable */ 216 + 217 + #define CPCAP_REG_OW1 0x1214 /* One Wire 1 Control */ 218 + 219 + #define CPCAP_REG_OW2C 0x1220 /* One Wire 2 Command */ 220 + #define CPCAP_REG_OW2D 0x1224 /* One Wire 2 Data */ 221 + #define CPCAP_REG_OW2I 0x1228 /* One Wire 2 Interrupt */ 222 + #define CPCAP_REG_OW2IE 0x122c /* One Wire 2 Interrupt Enable */ 223 + 224 + #define CPCAP_REG_OW2 0x1234 /* One Wire 2 Control */ 225 + 226 + #define CPCAP_REG_OW3C 0x1240 /* One Wire 3 Command */ 227 + #define CPCAP_REG_OW3D 0x1244 /* One Wire 3 Data */ 228 + #define CPCAP_REG_OW3I 0x1248 /* One Wire 3 Interrupt */ 229 + #define CPCAP_REG_OW3IE 0x124c /* One Wire 3 Interrupt Enable */ 230 + 231 + #define CPCAP_REG_OW3 0x1254 /* One Wire 3 Control */ 232 + #define CPCAP_REG_GCAIC 0x1258 /* GCAI Clock Control */ 233 + #define CPCAP_REG_GCAIM 0x125c /* GCAI GPIO Mode */ 234 + #define CPCAP_REG_LGDIR 0x1260 /* LMR GCAI GPIO Direction */ 235 + #define CPCAP_REG_LGPU 0x1264 /* LMR GCAI GPIO Pull-up */ 236 + #define CPCAP_REG_LGPIN 0x1268 /* LMR GCAI GPIO Pin */ 237 + #define CPCAP_REG_LGMASK 0x126c /* LMR GCAI GPIO Mask */ 238 + #define CPCAP_REG_LDEB 0x1270 /* LMR Debounce Settings */ 239 + #define CPCAP_REG_LGDET 0x1274 /* LMR GCAI Detach Detect */ 240 + #define CPCAP_REG_LMISC 0x1278 /* LMR Misc Bits */ 241 + #define CPCAP_REG_LMACE 0x127c /* LMR Mace IC Support */ 242 + 243 + #define CPCAP_REG_TEST 0x7c00 /* Test */ 244 + 245 + #define CPCAP_REG_ST_TEST1 0x7d08 /* ST Test1 */ 246 + 247 + #define CPCAP_REG_ST_TEST2 0x7d18 /* ST Test2 */ 248 + 249 + /* 250 + * Helpers for child devices to check the revision and vendor. 251 + * 252 + * REVISIT: No documentation for the bits below, please update 253 + * to use proper names for defines when available. 254 + */ 255 + 256 + static inline int cpcap_get_revision(struct device *dev, 257 + struct regmap *regmap, 258 + u16 *revision) 259 + { 260 + unsigned int val; 261 + int ret; 262 + 263 + ret = regmap_read(regmap, CPCAP_REG_VERSC1, &val); 264 + if (ret) { 265 + dev_err(dev, "Could not read revision\n"); 266 + 267 + return ret; 268 + } 269 + 270 + *revision = ((val >> 3) & 0x7) | ((val << 3) & 0x38); 271 + 272 + return 0; 273 + } 274 + 275 + static inline int cpcap_get_vendor(struct device *dev, 276 + struct regmap *regmap, 277 + u16 *vendor) 278 + { 279 + unsigned int val; 280 + int ret; 281 + 282 + ret = regmap_read(regmap, CPCAP_REG_VERSC1, &val); 283 + if (ret) { 284 + dev_err(dev, "Could not read vendor\n"); 285 + 286 + return ret; 287 + } 288 + 289 + *vendor = (val >> 6) & 0x7; 290 + 291 + return 0; 292 + }